Commit Graph

46 Commits

Author SHA1 Message Date
Simon Ser
6cb69a40c7 Add safety assert in parse_movement_unit
Let's add this just in case a caller passes argc == 0.

References: https://github.com/swaywm/sway/issues/6737#issuecomment-1008082540
2022-01-09 10:17:02 +01:00
Kenny Levinsen
80315217f7 input: Move get_current_time_msec in from util
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.
2021-06-23 09:55:36 +02:00
Nils Schulte
6898d1963f moved and renamed movement-unit parsing to common 2020-07-21 10:07:01 +02:00
Tudor Brindus
d7900c6e5e common/util: fix get_current_time_msec returning microseconds
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.
2020-06-06 13:38:41 +02:00
Brian Ashworth
66dc33296c cmd_client_*: refactor duplicated code
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-28 10:07:25 +01:00
Brian Ashworth
97f9f0b699 parse_color: return success + drop fallback color
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-12-28 10:07:25 +01:00
Sheena Artrip
7efb5d4673 Rename symbol set_cloexec to sway_set_cloexec, remove duplicates.
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-11-01 12:41:08 -04:00
Brian Ashworth
6961bf2e4c Spawn swaynag as a wayland client
This spawns swaynag as a wayland client similar to how swaybar and
swaybg are already done
2019-04-14 12:41:59 +03:00
Geoff Greer
6e3046878d Add support for manually setting subpixel hinting on outputs.
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-24 09:37:24 +02:00
Ian Fan
de9a357de8 util.c: remove numlen function
Its uses have been replaced by snprintf, which is more in line with its usage.
2019-01-22 13:10:25 +01:00
M Stoeckl
c040defd5f Fix edge case bug in numlen, dropping use of math.h functions
(Specifically, numlen when called with INT_MIN gave an incorrect
result, because abs(INT_MIN) == INT_MIN < 0.)
2019-01-21 12:46:45 -05:00
M Stoeckl
d7ff776552 Move sway-specific functions in common/util.c into sway/
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-21 12:39:16 -05:00
M Stoeckl
1211a81aad Replace wlr_log with sway_log
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-21 12:59:42 +01:00
Ian Fan
a82b8a3c14 Remove readline.c
All occurrences of read_line have been replaced by getline.
peek_line has been absorbed into detect_brace.
2019-01-01 09:01:25 +00:00
emersion
bf7af9c690
Merge pull request #3083 from c-edw/feature/StripWorkspaceName
Implement strip_workspace_name.
2018-11-19 17:56:18 +01:00
Spencer Michaels
70bc4c3ab6 Add scroll factor config option. 2018-11-18 13:49:30 -05:00
Connor E
4bd46fb079 Implement strip_workspace_name. 2018-11-17 16:11:28 +00:00
Ryan Dwyer
bf19f63a79 Wrap to fartherest output when running focus output
Also moves the `opposite_direction` function into `util.c` as it's used
in two places now.
2018-11-01 08:29:45 +10:00
madblobfish
1f23ec2d05 Revert "Add resolve_path() to utils"
This reverts commit c9694ee63d.
2018-10-31 13:04:08 +01:00
Ryan Dwyer
7be309710d Remove enum movement_direction
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-30 23:27:49 +10:00
Ryan Dwyer
5dbbab7bdc Remove layout.c
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-08-26 12:05:16 +10:00
Brian Ashworth
9ec1d6cf79 Address review comments on parse_boolean 2018-07-23 21:37:53 -04:00
Brian Ashworth
d56d62c1c0 Remove unneeded const 2018-07-23 21:33:17 -04:00
Brian Ashworth
863914ec95 Switch to using a function to parse booleans 2018-07-23 21:33:17 -04:00
emersion
63b4bf5000
Update for swaywm/wlroots#1126 2018-07-09 22:54:30 +01:00
Dominique Martinet
f0d1d26320 get_parent_pid: fix memory leak
Found through static analysis.
2018-07-02 08:03:41 +09:00
Dominique Martinet
67985e9031 sway: change all sway_log to wlr_log 2018-01-05 23:39:46 +01:00
Dominique Martinet
977c1f6a30 common/util: replace WLC_BIT_MOD_* by WLR_MODIFIER_*
This removes the last wlc/wlc.h include actually in use
2017-11-23 00:23:37 +01:00
johalun
7fef283044 FreeBSD fixes
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-06-06 09:45:50 +02:00
Mykyta Holubakha
f470fa58a3 Replace spaces with tabs in resolve_path 2017-05-11 19:38:32 +03:00
Jerzi Kaminsky
c9694ee63d Add resolve_path() to utils 2017-04-16 17:09:53 +03:00
Drew DeVault
9aed9d9359 UnGNUify the codebase 2017-03-10 23:41:24 -05:00
Calvin Lee
34e2c70abc Feature for #1078: Configurable swaylock colors
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.
2017-02-21 14:12:31 -07:00
Drew DeVault
416417a54c Reorganize includes 2016-09-01 08:18:37 -04:00
progandy
bf4056a2c6 common: use strtoul in parse_color to avoid clamp
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-08-04 14:37:54 +02:00
Zandr Martin
98aa59fdda
implement solid color rendering for swaybg 2016-07-30 18:50:13 -05:00
Zandr Martin
9ecb43ea3b
couple small fixes 2016-06-11 15:29:04 -05:00
Zandr Martin
2298143d09
cleanup + add timeouts for pid_workspace list 2016-06-11 12:43:34 -05:00
Zandr Martin
03d79b41c7
semi-working (only non-client/server wayland apps) 2016-06-10 06:08:59 -05:00
Mikkel Oscar Lyderik
c8cf3f70f9 numlen(0) == 1 2016-01-24 03:02:51 +01:00
Mikkel Oscar Lyderik
2707be7199 use log10 in numlen 2016-01-24 02:59:58 +01:00
Drew DeVault
a416715372 Revert "s/numlen/log10/g"
This reverts commit 038bb8cc7c.
2016-01-23 16:35:32 -05:00
Drew DeVault
038bb8cc7c s/numlen/log10/g 2016-01-23 15:51:38 -05:00
Mikkel Oscar Lyderik
dffacea831 Add function for getting list of modifier names.
Get an array of modifier names from modifier masks.
2016-01-08 03:03:40 +01:00
Mikkel Oscar Lyderik
95e0f44c73 Move modifier name table to common/util.c
Lookup of modifier names is required in several places, thus it makes
sense to move it to a general place.
2016-01-05 18:36:24 +01:00
Mikkel Oscar Lyderik
cf56c41c10 Move sway/util.c to common/util.c 2015-12-14 17:17:06 +01:00