aboutsummaryrefslogtreecommitdiffstats
path: root/common
Commit message (Collapse)AuthorAge
* Define _POSIX_C_SOURCE globallyLibravatar Simon Ser2024-02-23
| | | | See discussion in https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4555
* common: move load_image to swaybarLibravatar Manuel Stoeckl2023-11-23
| | | | | swaynag, swaymsg, and sway do not use this function and are unlikely to in the future.
* common: rename load_background_image to load_imageLibravatar Manuel Stoeckl2023-11-23
|
* common: Drop unused render_background_imageLibravatar Manuel Stoeckl2023-11-23
| | | | And the associated background_mode enum.
* Use format_str() throughoutLibravatar Simon Ser2023-04-14
|
* common/gesture: use format_str()Libravatar Simon Ser2023-04-14
| | | | We already had a similar function in there.
* Add format_str() and vformat_str()Libravatar Simon Ser2023-04-14
| | | | Simple helpers to allocate and format a string.
* Reuse parsed PangoFontDescriptionLibravatar Hugo Osvaldo Barrera2022-07-01
| | | | Avoids parsing the configured font each time text is rendered.
* Reject font values that are invalid for pangoLibravatar Hugo Osvaldo Barrera2022-07-01
| | | | | | | | | Use pango to parse font configuration early, and reject the command as invalid if the value is invalid for pango. Since we're already parsing the font into a `PangoFontDescription`, keep that instance around and avoid re-parsing the font each time we render text. Fixes: https://github.com/swaywm/sway/issues/6805
* sway: add bindgesture commandLibravatar Florian Franzen2022-05-30
| | | | Co-authored-by: Michael Weiser <michael.weiser@gmx.de>
* Add safety assert in parse_movement_unitLibravatar Simon Ser2022-01-09
| | | | | | Let's add this just in case a caller passes argc == 0. References: https://github.com/swaywm/sway/issues/6737#issuecomment-1008082540
* Avoid unecessary font metric calculationsLibravatar Hugo Osvaldo Barrera2021-09-20
| | | | | | | | | | | | | | | | | | | | | Prior to 62d90a8e, titlebar's font height (and other related values) would change any time any titlebar's content changed, so these values were recalculated each time any titlebar's content changed (or a new titlebar was created). However, since the above was merge, these values no longer change so often and we only need to recalculate them when the configured font changes (and stop calling `config_update_font_height` each time titlebars are rendered). This commit removes all the unecessary calls to this function and avoids all those unecessary calculations. Whenever the font strays from the default value, the `font` command is called, and it calls `config_update_font_height`, which is enough to keep the value always up to date. I've also added a default value to the `font_baseline` config, since otherwise that's zero for setups that don't explicitly specify a font.
* Rename pango_printf to render_textLibravatar Simon Ser2021-09-13
| | | | | This avoids using the pango_ prefix, reserved for functions coming from the Pango library.
* Use fixed titlebar heightsLibravatar Hugo Osvaldo Barrera2021-08-26
| | | | | | | | | | | | | | | Use fixed titlebar heights. The default height is calculated based on font metrics for the configured font and current locale. Some testing with titles with emoji and CJK characters (which are substantially higher in my setup) shows that the titlebars retain their initial value, text does shift up or down, and all titlebars always remain aligned. Also drop some also now-unecessary title_height calculations. Makes also needed to be updated, since they should be positioned with the same rules.
* 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.