aboutsummaryrefslogtreecommitdiff
path: root/common/util.c
AgeCommit message (Collapse)AuthorLines
2025-06-16Rename get_current_time_msec to get_current_time_in_msec and move to util.cFurkan Sahin-0/+6
get_current_time_msec conflicts with a function with the same name in wlroots.
2024-02-16Define _POSIX_C_SOURCE globallyFurkan Sahin-1/+0
See discussion in https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4555
2022-01-09Add safety assert in parse_movement_unitFurkan Sahin-0/+6
Let's add this just in case a caller passes argc == 0. References: https://github.com/swaywm/sway/issues/6737#issuecomment-1008082540
2021-06-20input: Move get_current_time_msec in from utilFurkan Sahin-6/+0
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.
2020-07-16moved and renamed movement-unit parsing to commonFurkan Sahin-0/+34
2020-06-05common/util: fix `get_current_time_msec` returning microsecondsFurkan Sahin-1/+7
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.
2019-12-27cmd_client_*: refactor duplicated codeFurkan Sahin-0/+7
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.
2019-12-27parse_color: return success + drop fallback colorFurkan Sahin-9/+10
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.
2019-10-28Rename symbol set_cloexec to sway_set_cloexec, remove duplicates.Furkan Sahin-1/+1
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
2019-04-14Spawn swaynag as a wayland clientFurkan Sahin-0/+19
This spawns swaynag as a wayland client similar to how swaybar and swaybg are already done
2019-02-10Add support for manually setting subpixel hinting on outputs.Furkan Sahin-0/+21
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-01-22util.c: remove numlen functionFurkan Sahin-9/+0
Its uses have been replaced by snprintf, which is more in line with its usage.
2019-01-21Fix edge case bug in numlen, dropping use of math.h functionsFurkan Sahin-4/+5
(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/Furkan Sahin-105/+0
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-20Replace wlr_log with sway_logFurkan Sahin-2/+2
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.
2018-12-09Remove readline.cFurkan Sahin-2/+2
All occurrences of read_line have been replaced by getline. peek_line has been absorbed into detect_brace.
2018-11-19Merge pull request #3083 from c-edw/feature/StripWorkspaceNameFurkan Sahin-2/+3
Implement strip_workspace_name.
2018-11-17Add scroll factor config option.Furkan Sahin-0/+12
2018-11-17Implement strip_workspace_name.Furkan Sahin-2/+3
2018-11-01Wrap to fartherest output when running focus outputFurkan Sahin-0/+16
Also moves the `opposite_direction` function into `util.c` as it's used in two places now.
2018-10-27Revert "Add resolve_path() to utils"Furkan Sahin-37/+0
This reverts commit 619145b12ce433feceacded9eed1da4ac6f145a5.
2018-10-30Remove enum movement_directionFurkan Sahin-21/+0
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-08-26Remove layout.cFurkan Sahin-0/+21
When we have type safety we'll need to have functions for workspace_add_tiling and so on. This means the existing container functions will be just for containers, so they are being moved to container.c. At this point layout.c doesn't contain much else, so I've relocated everything and removed the file. * container_swap and its static functions have been moved to the swap command and made static. * container_recursive_resize has been moved to the resize command and made static. * The following have been moved to container.c: * container_handle_fullscreen_reparent * container_insert_child * container_add_sibling * container_add_child * container_remove_child * container_replace_child * container_split * enum movement_direction and sway_dir_to_wlr have been moved to util.c. Side note: Several commands included layout.h which then included root.h. With layout.h gone, root.h has to be included by those commands.
2018-07-23Address review comments on parse_booleanFurkan Sahin-8/+9
2018-07-23Remove unneeded constFurkan Sahin-1/+1
2018-07-23Switch to using a function to parse booleansFurkan Sahin-0/+15
2018-07-09Update for swaywm/wlroots#1126Furkan Sahin-1/+1
2018-07-01get_parent_pid: fix memory leakFurkan Sahin-1/+1
Found through static analysis.
2018-01-05sway: change all sway_log to wlr_logFurkan Sahin-1/+1
2017-11-23common/util: replace WLC_BIT_MOD_* by WLR_MODIFIER_*Furkan Sahin-11/+11
This removes the last wlc/wlc.h include actually in use
2017-06-05FreeBSD fixesFurkan Sahin-1/+1
Increase _POSIX_SOURCE value where needed. Increase _XOPEN_SOURCE value where needed. Conditionally link to libcap (only on Linux). Possibly some trailing whitespace fixes (automatic).
2017-05-11Replace spaces with tabs in resolve_pathFurkan Sahin-33/+33
2017-04-14Add resolve_path() to utilsFurkan Sahin-0/+41
2017-03-10UnGNUify the codebaseFurkan Sahin-0/+1
2017-02-21Feature for #1078: Configurable swaylock colorsFurkan Sahin-3/+7
Colors are configured through the command line so that swaylock conforms to the i3lock fork 'github.com/chrjguill/i3lock-color'. Differences from it are that one letter options '-r' and '-s' are not implimentend because '-s' is already used by '--scaling' in swaylock. This commit also fixed whitespace in 'include/swaylock/swaylock.h' and changed `parse_color` in 'common/util.h' so that it can accept colors that do not start with a hash. This was done to keep compatability with the i3lock fork.
2016-09-01Reorganize includesFurkan Sahin-2/+5
2016-08-04common: use strtoul in parse_color to avoid clampFurkan Sahin-1/+1
Some implementations of strtol may clamp the values to LONG_MAX instead of wrapping around to negative values, so use strtoul instead to parse colors.
2016-07-30implement solid color rendering for swaybgFurkan Sahin-0/+13
2016-06-11couple small fixesFurkan Sahin-8/+12
2016-06-11cleanup + add timeouts for pid_workspace listFurkan Sahin-18/+10
2016-06-10semi-working (only non-client/server wayland apps)Furkan Sahin-1/+38
2016-01-24numlen(0) == 1Furkan Sahin-1/+1
2016-01-24use log10 in numlenFurkan Sahin-7/+6
2016-01-23Revert "s/numlen/log10/g"Furkan Sahin-0/+10
This reverts commit 4d8a071134db4ced1870c2d3177fb8a95e249567.
2016-01-23s/numlen/log10/gFurkan Sahin-10/+0
2016-01-06Add function for getting list of modifier names.Furkan Sahin-0/+14
Get an array of modifier names from modifier masks.
2016-01-05Move modifier name table to common/util.cFurkan Sahin-0/+38
Lookup of modifier names is required in several places, thus it makes sense to move it to a general place.
2015-12-14Move sway/util.c to common/util.cFurkan Sahin-0/+15