aboutsummaryrefslogtreecommitdiffstats
path: root/common
Commit message (Collapse)AuthorAge
* input: Move get_current_time_msec in from utilLibravatar Kenny Levinsen2021-06-23
| | | | | | | get_current_time_msec is only used in cursor.c, so we can move it in and make it static. This is primarily intended to avoid a symbol collision with wlroots, which we unfortunately do not have a good solution for yet.
* cairo: Replace <cairo/cairo.h> by <cairo.h>Libravatar Issam E. Maghni2021-05-10
| | | | | | | For full context, read https://gitlab.freedesktop.org/cairo/cairo/-/issues/479 TL;DR, cairo’s pc file adds `/cairo` to CFLAGS. So namespace cairo shouldn’t be used.
* common/log: write log importanceLibravatar Simon Ser2020-12-10
| | | | | | | | | | When colors aren't used, write the log importance to stderr. This makes it easier to grep for errors and avoids mistaking error messages for debug messages. This is [1] ported to Sway. [1]: https://github.com/swaywm/wlroots/pull/2149
* common: make 'lenient_strcmp' arguments constLibravatar Paul Riou2020-12-04
| | | | | | | Prevents build failures when calling the function with 'const char *' arguments. This is also more accurate since the function is not expected to modify the args.
* common/loop: check return of reallocLibravatar Antonin Décimo2020-07-30
|
* ipc: fix aligment issue of data bufferLibravatar Antonin Décimo2020-07-30
| | | | | | The pointer `data` is cast to a more strictly aligned pointer type. To prevent issues, the `data32` buffer is removed and its occurrences are replaced with an offset from the `data` buffer.
* moved and renamed movement-unit parsing to commonLibravatar Nils Schulte2020-07-21
|
* common/util: fix `get_current_time_msec` returning microsecondsLibravatar Tudor Brindus2020-06-06
| | | | | | | | This commit makes `get_current_time_msec` correctly return milliseconds as opposed to microseconds. It also considers the value of `tv_sec`, so we don't lose occasionally go back in time by one second. Finally, the function is moved into `util.c` so that it can be reused elsewhere without having to consider these pitfalls.
* Add wayland_client dependency to commonLibravatar TheAvidDev2020-06-06
|
* common/log: use bright black rather than black for SWAY_DEBUGLibravatar Tudor Brindus2020-05-24
| | | | | | | On some terminals under default settings, black is truly rendered as `#000`, making it unreadable when the background is also black. Closes #5141.
* common/log: bump POSIX version used after e81d9fde667eLibravatar Jan Beich2020-03-07
| | | | | | | | | ../common/log.c:63:16: error: use of undeclared identifier 'CLOCK_MONOTONIC' clock_gettime(CLOCK_MONOTONIC, &start_time); ^ ../common/log.c:75:16: error: use of undeclared identifier 'CLOCK_MONOTONIC' clock_gettime(CLOCK_MONOTONIC, &ts); ^
* common/log: improve time prefixLibravatar Simon Ser2020-03-07
| | | | | | Same as [1]. [1]: https://github.com/swaywm/wlroots/pull/2052
* cmd_client_*: refactor duplicated codeLibravatar Brian Ashworth2019-12-28
| | | | | | | | | | | | | This is the second in a series of commits to refactor the color handling in sway. This removes the duplicated color parsing code in sway/commands/client.c. Additionally, this combines the parsing of colors to float arrays with that in sway/config.c and introduces a color_to_rgba function in commom/util.c. As an added bonus, this also makes it so non of the colors in a border color class will be changed unless all of the colors specified are valid. This ensures that an invalid command does not get partially applied.
* parse_color: return success + drop fallback colorLibravatar Brian Ashworth2019-12-28
| | | | | | | | | | | | This is the first in a series of commits to refactor the color handling in sway. This changes parse_color to return whether it was success and no longer uses 0xFFFFFFFF as the fallback color. This also verifies that the string actually contains a valid hexadecimal number along with the length checks. In the process of altering the calls to parse_color, I also took the opportunity to heavily refactor swaybar's ipc_parse_colors function. This allowed for several lines of duplicated code to be removed.
* Amend typosLibravatar Jason2019-11-23
|
* input_cmd_xkb_file: allow shell path expansionLibravatar Brian Ashworth2019-11-21
| | | | | This allows for shell path expansion for input_cmd_xkb_file. The logic has been extracted from output_cmd_background
* Rename symbol set_cloexec to sway_set_cloexec, remove duplicates.Libravatar Sheena Artrip2019-11-01
| | | | | | | | set_cloexec is defined by both sway and wlroots (and who-knows-else), so rename the sway one for supporting static linkage. We also remove the duplicate version of this in client/. Fixes: https://github.com/swaywm/sway/issues/4677
* ipc-client: remove useless free for failed mallocLibravatar Antonin Décimo2019-08-12
|
* Use -fmacro-prefix-map to strip build pathLibravatar Manuel Stoeckl2019-07-15
| | | | | | | | | | | | | | 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.
* Fix segfaults caused by faulty command parsingLibravatar Matt Coffin2019-06-11
| | | | | | | | | | | | | | | | 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
* common/ipc-client: remove ipc recv timeout logLibravatar Brian Ashworth2019-05-27
| | | | | | | | | | | 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.
* swaybg: split into standalone projectLibravatar Drew DeVault2019-04-25
| | | | | | | 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.
* swaymsg: add timeout and type checksLibravatar Brian Ashworth2019-04-17
| | | | | | | | | | | | | | | 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.
* Spawn swaynag as a wayland clientLibravatar Brian Ashworth2019-04-14
| | | | | This spawns swaynag as a wayland client similar to how swaybar and swaybg are already done
* Add support for manually setting subpixel hinting on outputs.Libravatar Geoff Greer2019-03-24
| | | | | | 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
* stringop.c: refactor a few functionsLibravatar Ian Fan2019-03-11
|
* stringop.c: clean up headersLibravatar Ian Fan2019-03-11
|
* stringop.c: remove unused functionsLibravatar Ian Fan2019-03-11
| | | | The only use of `join_list` in swaybar/tray/icon.c has been rewritten.
* output_cmd_background: fix no file + valid modeLibravatar Brian Ashworth2019-02-05
| | | | | | | | | | | | | 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.
* background-image.c: remove stdbool headerLibravatar Ian Fan2019-01-22
|
* util.c: remove numlen functionLibravatar Ian Fan2019-01-22
| | | | Its uses have been replaced by snprintf, which is more in line with its usage.
* Removed unused wlroots dependency for sway(bg|bar|msg|nag)Libravatar M Stoeckl2019-01-21
| | | | Also remove direct libm dependency where unused.
* Fix edge case bug in numlen, dropping use of math.h functionsLibravatar M Stoeckl2019-01-21
| | | | | (Specifically, numlen when called with INT_MIN gave an incorrect result, because abs(INT_MIN) == INT_MIN < 0.)
* Move sway-specific functions in common/util.c into sway/Libravatar M Stoeckl2019-01-21
| | | | | | 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 .
* Replace wlr_log with sway_logLibravatar M Stoeckl2019-01-21
| | | | | | | | | | | | | 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.
* Allocate minimum size necessary in pango text functions. (#3473)Libravatar Connor Edwards2019-01-20
| | | | | | * Allocate minimum size necessary in pango text functions. * Handle malloc failure.
* Fix backup methods in get_socketpath for IPC clientLibravatar M Stoeckl2019-01-19
| | | | | | | | | | 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.
* Remove unicode.cLibravatar emersion2019-01-17
|
* Use static arrays where possible.Libravatar Connor E2019-01-16
|
* Remove usage of VLAs.Libravatar Connor E2019-01-16
|
* fixup! stringop.c: rewrite strip_whitespaceLibravatar Ian Fan2019-01-02
|
* Remove readline.cLibravatar Ian Fan2019-01-01
| | | | | All occurrences of read_line have been replaced by getline. peek_line has been absorbed into detect_brace.
* stringop.c: rewrite strip_whitespaceLibravatar Ian Fan2019-01-01
|
* Merge pull request #3271 from ianyfan/list-cleanupLibravatar Ryan Dwyer2018-12-09
|\ | | | | list.c: Remove list_foreach
| * list.c: rename free_flat_list to list_free_items_and_destroyLibravatar Ian Fan2018-12-09
| |
| * Cleanup list codeLibravatar Ian Fan2018-12-09
| |
| * list.c: Remove list_foreachLibravatar Ian Fan2018-12-09
| | | | | | | | | | 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.
* | list: double list capacity when resizing instead of incrementingLibravatar Ian Fan2018-12-06
|/ | | | | This is the industry standard since it allows insertion to be amortized O(1) time.
* Replace _XOPEN_SOURCE with _POSIX_C_SOURCELibravatar emersion2018-11-25
| | | | And make sure we don't define both in the same source file.
* Merge pull request #3083 from c-edw/feature/StripWorkspaceNameLibravatar emersion2018-11-19
|\ | | | | Implement strip_workspace_name.