aboutsummaryrefslogtreecommitdiff
path: root/common
AgeCommit message (Collapse)Author
2019-08-12ipc-client: remove useless free for failed mallocAntonin DĂ©cimo
2019-07-15Use -fmacro-prefix-map to strip build pathManuel Stoeckl
Because meson does not provide a simple way to get the relative build path, it is computed with a pair of foreach loops. As meson does not have a simple way to compute string length (except via underscorify and 63 split operations), the build script uses a shell command instead. If the compiler does not suppot -fmacro-prefix-map, then fall back to passing in the relative path prefix, and use its length to offset the uses of __FILE__ in log messages so that the build path is at least still not included in the logs. This is significantly more efficient than calling _sway_strip_path.
2019-06-11Fix segfaults caused by faulty command parsingMatt Coffin
This patch fixes faulty command parsing introduced by f0f5de9a9e87ca1f0d74e7cbf82ffceba51ffbe6. When that commit allowed criteria reset on ';' delimeters in commands lists, it failed to account for its inner ','-parsing loop eating threw the entire rest of the string. This patch refactors argsep to use a list of multiple separators, and (optionally) return the separator that it matched against in this iteration via a pointer. This allows it to hint at the command parser which separator was used at the end of the last command, allowing it to trigger a potential secondary read of the criteria. Fixes #4239
2019-05-27common/ipc-client: remove ipc recv timeout logBrian Ashworth
This just removes the ipc recv timeout log statement in `ipc_recv_set_timeout`. The `tv_sec` field of `struct timeval` has varying types and/or sizes depending on the platform and architecture. On some of these, the current format string will cause compilation errors. Additionally, the log statement is not extremely useful and the function is currently only used by swaymsg, which has a hardcoded log level that will prevent it from even being shown, so there is no point in even keeping it.
2019-04-25swaybg: split into standalone projectDrew DeVault
The new upstream is https://github.com/swaywm/swaybg This commit also refactors our use of gdk-pixbuf a bit, since the only remaining reverse dependency is swaybar tray support.
2019-04-17swaymsg: add timeout and type checksBrian Ashworth
This adds a 3 second timeout to the initial reply in swaymsg. This prevents swaymsg from hanging when `swaymsg -t get_{inputs,seats}` is used in i3. The timeout is removed when waiting for a subscribed event or monitoring for subscribed events. This also adds type checks to commands where i3 does not reply with all of the properties that sway does (such as `modes` in `get_outputs`). This is mostly just a behavioral adjustment since swaymsg should run on i3. When running under i3, some command reply's (such as the one for `get_outputs) may have more useful information in the raw json than the pretty printed version.
2019-04-14Spawn swaynag as a wayland clientBrian Ashworth
This spawns swaynag as a wayland client similar to how swaybar and swaybg are already done
2019-03-24Add support for manually setting subpixel hinting on outputs.Geoff Greer
Many laptop screens report unknown subpixel order. Allow users to manually set subpixel hinting to work around this. Addresses https://github.com/swaywm/sway/issues/3163
2019-03-11stringop.c: refactor a few functionsIan Fan
2019-03-11stringop.c: clean up headersIan Fan
2019-03-11stringop.c: remove unused functionsIan Fan
The only use of `join_list` in swaybar/tray/icon.c has been rewritten.
2019-02-05output_cmd_background: fix no file + valid modeBrian Ashworth
If output_cmd_background is given a valid mode as the first argument, then there is no file given and an error should be returned. join_args should not be called with an argc of zero since it sets the last character to the null terminator. With an argc of zero, the length is zero causing a heap buffer overflow when setting the byte before the start of argv to '\0'. This probably will not ever generate a segfault, but may cause data corruption to whatever is directly before it in memory. To make other such cases easier to detect, this also adds a sway_assert in join_args when argc is zero.
2019-01-22background-image.c: remove stdbool headerIan Fan
2019-01-22util.c: remove numlen functionIan Fan
Its uses have been replaced by snprintf, which is more in line with its usage.
2019-01-21Removed unused wlroots dependency for sway(bg|bar|msg|nag)M Stoeckl
Also remove direct libm dependency where unused.
2019-01-21Fix edge case bug in numlen, dropping use of math.h functionsM Stoeckl
(Specifically, numlen when called with INT_MIN gave an incorrect result, because abs(INT_MIN) == INT_MIN < 0.)
2019-01-21Move sway-specific functions in common/util.c into sway/M Stoeckl
Modifier handling functions were moved into sway/input/keyboard.c; opposite_direction for enum wlr_direction into sway/tree/output.c; and get_parent_pid into sway/tree/root.c .
2019-01-21Replace wlr_log with sway_logM Stoeckl
This commit mostly duplicates the wlr_log functions, although with a sway_* prefix. (This is very similar to PR #2009.) However, the logging function no longer needs to be replaceable, so sway_log_init's second argument is used to set the exit callback for sway_abort. wlr_log_init is still invoked in sway/main.c This commit makes it easier to remove the wlroots dependency for the helper programs swaymsg, swaybg, swaybar, and swaynag.
2019-01-20Allocate minimum size necessary in pango text functions. (#3473)Connor Edwards
* Allocate minimum size necessary in pango text functions. * Handle malloc failure.
2019-01-19Fix backup methods in get_socketpath for IPC clientM Stoeckl
Previously, the success of `getline` was tested by checking if the buffer it allocates is nonempty and has a nonzero first byte. As `getline` does not explicitly zero out its memory buffer, this may fail (e.g., with AddressSanitizer). Instead, we check that at least one character was returned on standard output. Also, trailing newlines (if present) are now removed.
2019-01-17Remove unicode.cemersion
2019-01-16Use static arrays where possible.Connor E
2019-01-16Remove usage of VLAs.Connor E
2019-01-02fixup! stringop.c: rewrite strip_whitespaceIan Fan
2019-01-01Remove readline.cIan Fan
All occurrences of read_line have been replaced by getline. peek_line has been absorbed into detect_brace.
2019-01-01stringop.c: rewrite strip_whitespaceIan Fan
2018-12-09Merge pull request #3271 from ianyfan/list-cleanupRyan Dwyer
list.c: Remove list_foreach
2018-12-09list.c: rename free_flat_list to list_free_items_and_destroyIan Fan
2018-12-09Cleanup list codeIan Fan
2018-12-09list.c: Remove list_foreachIan Fan
Most occurrences have been replaced by `free_flat_list` which has been moved from stringop.c to list.c. The rest have been replaced by for loops.
2018-12-06list: double list capacity when resizing instead of incrementingIan Fan
This is the industry standard since it allows insertion to be amortized O(1) time.
2018-11-25Replace _XOPEN_SOURCE with _POSIX_C_SOURCEemersion
And make sure we don't define both in the same source file.
2018-11-19Merge pull request #3083 from c-edw/feature/StripWorkspaceNameemersion
Implement strip_workspace_name.
2018-11-18Add scroll factor config option.Spencer Michaels
2018-11-18Use #if instead of #ifdefemersion
2018-11-17Implement strip_workspace_name.Connor E
2018-11-01Wrap to fartherest output when running focus outputRyan Dwyer
Also moves the `opposite_direction` function into `util.c` as it's used in two places now.
2018-10-31Revert "Add resolve_path() to utils"madblobfish
This reverts commit c9694ee63d451da62dc50b234b3080a35a40e844.
2018-10-30Remove enum movement_directionRyan Dwyer
There's no point having both movement_direction and wlr_direction. This replaces the former with the latter. As movement_direction also contained MOVE_PARENT and MOVE_CHILD items, these are now checked specifically in the focus command and handled in separate functions, just like the other focus variants.
2018-10-17Merge pull request #2864 from sghctoma/freebsd-fixesDrew DeVault
FreeBSD fixes
2018-10-17Fix stringop-overflow warningsNiccolò Scatena
2018-10-17Increase _POSIX_C_SOURCE to 200112Lsghctoma
CLOCK_MONOTONIC appeared in IEEE Std. 1003.1-200x, it was not part of POSIX.1b (the 1993 version), and FreeBSD treats it accordingly.
2018-10-16Truncate message, append buffer overflow message if too long.Connor E
Increase buffer size, remove macros. Make variables lowercase. Some more feedback.
2018-10-15common/loop.c: add _POSIX_C_SOURCE for clock_gettime and CLOCK_MONOTONICCole Mickens
2018-10-15Event loop: Fix memmove and remove extraneous declarationRyan Dwyer
2018-10-15Event loop: Free fds and fix race conditionRyan Dwyer
2018-10-15Remove timerfd from loop implementationRyan Dwyer
timerfd doesn't work on the BSDs, so this replaces it with a timespec for the expiry and uses a poll timeout to check the timers when needed.
2018-10-15swaylock: Remove indicator after 3 secondsRyan Dwyer
2018-10-15Move swaybar's event loop to common directory and refactorRyan Dwyer
* The loop functions are now prefixed with `loop_`. * It is now easy to add timers to the loop. * Timers are implemented using pollfd and timerfd, rather than manually checking them when any other event happens to arrive.
2018-09-23swaybg: fix increasingly smaller bg on hotplugBrian Ashworth
render_background_image alters the scale that cairo uses. Depending on the image mode, resolution, and image size, this may cause the surface to be rendered increasingly smaller. By calling cairo_save and cairo_restore, any changes to the cairo settings by the function are not kept as a side effect. The surface that swaybg uses is also now cleared before rendering a frame. This is needed to avoid artifacts on resolution or scale changes with certain combinations of image modes, resolutions, and image sizes. This was also part of the increasingly smaller background visual since it made it so it was not obvious the region being rendered to was smaller and caused an increasing number of smaller images to be appear for each hotplug.