Commit Graph

4288 Commits

Author SHA1 Message Date
Hugo Osvaldo Barrera 80e386fd97 Reuse parsed PangoFontDescription
Avoids parsing the configured font each time text is rendered.
2022-07-01 13:05:58 +02:00
Hugo Osvaldo Barrera 75605491a5 Reject font values that are invalid for pango
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
2022-07-01 13:05:58 +02:00
Hugo Osvaldo Barrera 9e8866ae20 Avoid unecessary string copy 2022-07-01 13:05:58 +02:00
Thomas Jost a55472c6d8 Strip quotes in bindsym --input-device=...
If the input device is quoted, which is common when using variables in the
config file, those quotes must be ignored here, or the input device will be
ignored.

Fixes #7029.
2022-06-25 11:27:49 +02:00
Simon Ser 445bc2a943 Rename dpms output command to power
The "dpms" command refers to VESA Display Power Management
Signaling, a deprecated standard. It's superseded by VESA DPM.

Instead of tying out command name to a particular standard, use the
neutral term "power".
2022-06-23 14:47:50 -04:00
Simon Ser 122d8ce954 Remove access to wlr_input_device union
References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/3626
Closes: https://github.com/swaywm/sway/issues/7077
2022-06-22 12:44:15 -04:00
kraftwerk28 49cef51e6e Allocate enough space for `cmd_results->error` 2022-06-16 09:32:44 +02:00
Simon Ser 1c69d0e72f config/output: use wlr_output_commit_state
This makes the code more robust because we don't potentially leave
bad state in wlr_output.pending behind anymore. This also fixes a
bug.

Closes: https://github.com/swaywm/sway/issues/7043
References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/3610
2022-06-10 11:35:30 +02:00
Kenny Levinsen e5728052b5 Refuse to start when SUID is detected
This ensures that those surprised by the deprecation of SUID operation
receive an error rather than accidentally having sway run as root.

This detection will be removed in a future release.
2022-06-03 12:37:40 +02:00
Simon Ser 251a648e2c ipc: remove chatty debug log messages
These aren't particularly useful, and clobber the debug logs.
2022-05-30 18:44:18 +02:00
Simon Ser a5c2e9fee0 build: link with -pthread
Fixes the following FreeBSD error:

    ld: error: undefined symbol: pthread_getschedparam
    >>> referenced by realtime.c:25 (../sway/realtime.c:25)
    >>>               sway/sway.p/realtime.c.o:(set_rr_scheduling)

Fixes: a3a82efbf6 ("realtime: request SCHED_RR using CAP_SYS_NICE")
2022-05-30 18:40:26 +02:00
Florian Franzen cab2189aa6 sway: add bindgesture command
Co-authored-by: Michael Weiser <michael.weiser@gmx.de>
2022-05-30 12:20:43 +02:00
Kirill Primak 6a59e38aeb xdg-shell: schedule a configure on maximize request
This commit reverts 03879290db and
fc84bcb7fb.
2022-05-27 15:49:57 +02:00
Kirill Primak 26a0e97634 chore: chase wlroots xdg-shell update 2022-05-27 15:42:22 +02:00
Simon Ser d0b9bf94a5 Handle NULL output make/model/serial 2022-05-26 15:42:56 -04:00
Simon Ser f0d57da315 De-duplicate IPC output descriptions 2022-05-26 15:42:56 -04:00
Daniel De Graaf 75b2d0b105 ext-session-lock: disable direct scan-out when locked 2022-05-23 08:15:51 +02:00
Rouven Czerwinski a3a82efbf6 realtime: request SCHED_RR using CAP_SYS_NICE
Try to gain SCHED_RR (round-robin) realtime scheduling privileges before
starting the server. This requires CAP_SYS_NICE on Linux systems.
We additionally register a pthread_atfork callback which resets the
scheduling class back to SCHED_OTHER (the Linux system default).

Due to CAP_SYS_NICE, setting RLIMIT_RTPRIO has no effect on the process
as documented within man 7 sched (from Linux):

  Privileged (CAP_SYS_NICE) threads ignore the RLIMIT_RTPRIO limit;
  as with older kernels, they can make arbitrary changes to
  scheduling policy and priority. See getrlimit(2) for further
  information on RLIMIT_RTPRIO

Note that this requires the sway distribution packagers to set the
CAP_SYS_NICE capability on the sway binary.

Supersedes #6992
2022-05-18 11:20:17 +02:00
Rouven Czerwinski 3f600565e4 server: request xdg-shell v2
Wlroots does not yet support the newer xdg-shell versions and now
requires the compositor to set the supported xdg-shell version during
creation. Set this to v2 for sway as well.

Fixes https://github.com/swaywm/sway/issues/7001
2022-05-16 11:20:39 -04:00
-k ffc603d451 man: Fix trailing spaces 2022-05-11 19:55:51 +02:00
-k 28941cee20 Add descriptions for `stacking` and `tabbed` layouts
Resolves #5918
2022-05-11 19:07:54 +02:00
Simon Ser 1e9be019b2 Replace strncpy with memcpy
strncpy is useless here, is dangerous because it doesn't guarantee
that the string is NUL-terminated and causes the following warning:

    ../sway/criteria.c: In function ‘criteria_parse’:
    ../sway/criteria.c:712:25: error: ‘strncpy’ destination unchanged after copying no bytes [-Werror=stringop-truncation]
      712 |                         strncpy(value, valuestart, head - valuestart);
          |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2022-05-11 11:47:49 -04:00
Daniel De Graaf a7898637de Avoid inspecting a NULL view in seat_set_focus
Fixes #6968
2022-04-30 00:36:44 +02:00
Daniel De Graaf 519038a7e9 Implement ext-session-lock-v1 2022-04-29 09:06:36 +02:00
Victor Makarov 70d30ac72b
xkb_switch_layout: fix relative layout switches
Fixes #6011
2022-04-28 13:20:44 +02:00
kraftwerk28 acdb48a59c Chase wlroots X11 hints update 2022-04-18 08:57:16 +02:00
Thomas Hebb d726e50643 layer_shell: keep output non-NULL wherever possible
Our layer shell implementation assigns every layer surface to an output
on creation. It tracks this output using the output field on the
underlying wlr_layer_surface_v1 structure. As such, much of the existing
code assumes that output is always non-NULL and omits NULL checks
accordingly.

However, there are currently two cases where we destroy a
sway_layer_surface and output is NULL. The first is when we can't find
an output to assign the surface to and destroy it immediately after
creation. The second is when we destroy a surface in response to its
output getting destroyed, as we set output to NULL in
handle_output_destroy() before we call wlr_layer_surface_v1_destroy(),
which is what calls the appropriate unmap and destroy callbacks.

The former case doesn't cause any problems, since we haven't even
allocated a sway_layer_surface at that point or registered any
callbacks. The latter case, however, currently triggers a crash (#6120)
if a popup is visible, since our popup_handle_unmap() implementation
can't handle a NULL output.

To fix this issue, keep output set until right before we free the
sway_layer_surface. All we need to do is remove some of the cleanup
logic from handle_output_destroy(), since as of commit c9060bcc12
("layer-shell: replace close() with destroy()") that same logic is
guaranteed to be happen later when wlroots calls handle_destroy() as
part of wlr_layer_surface_v1_destroy().

This lets us remove some NULL checks from other unmap/destroy callbacks,
which is nice. We also don't need to check that the wlr_output points to
a valid sway_output anymore, since we unset that pointer after disabling
the output as of commit a0bbe67076 ("Address emersions comments on
output re-enabling") Just to be safe, I've added assertions that the
wlr_output is non-NULL wherever we use it.

Fixes #6120.
2022-04-13 10:05:24 +02:00
Daniel De Graaf cf413b9c0b Shuffle variables to satisfy -Werror=restrict
This also fixes an invalid strlen invocation on uninitialized memory.
2022-04-09 18:27:57 +02:00
Daniel De Graaf 20181974c2 Avoid format-truncation warning
The existing code gives this error when compiled with GCC 12:

../sway/server.c: In function ‘server_init’:
../sway/server.c:217:75: error: ‘%d’ directive output may be truncated writing between 1 and 11 bytes into a region of size 8 [-Werror=format-truncation=]
  217 |                 snprintf(name_candidate, sizeof(name_candidate), "wayland-%d", i);
      |                                                                           ^~
../sway/server.c:217:66: note: directive argument in the range [-2147483647, 32]
  217 |                 snprintf(name_candidate, sizeof(name_candidate), "wayland-%d", i);
      |                                                                  ^~~~~~~~~~~~
../sway/server.c:217:17: note: ‘snprintf’ output between 10 and 20 bytes into a destination of size 16
  217 |                 snprintf(name_candidate, sizeof(name_candidate), "wayland-%d", i);
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Because i is never negative, this is a false positive, but it is easy to
change i to unsigned to silence the error.
2022-04-09 18:27:57 +02:00
Manuel Stoeckl 8f036b6f78 sway/main: move constants off the stack
This makes stack traces from gdb slightly easier to read.
2022-03-29 08:42:17 +02:00
Leonardo Hernández Hernández 6c4c0387a2 sway/input: wlr_seat_keyboard() now takes wlr_keyboard 2022-03-23 18:09:54 +01:00
Leonardo Hernández Hernández ca016689a0 sway/input: fix bad position of wlr_drag 2022-03-22 09:00:28 +01:00
Simon Zeni 440d0bc22d sway/input: follow up wlroots input device events renaming 2022-03-17 21:52:59 +03:00
Simon Zeni 49b3ac9a2c sway/input/seat: take output name from specialized input device 2022-03-17 21:52:59 +03:00
Simon Zeni 0345148ea6 sway/input/cursor: take device mm size from wlr_tablet 2022-03-17 21:52:59 +03:00
Bill Li f167acce3a Updating criteria checking with PCRE2 2022-03-15 11:28:04 +01:00
ndren f614f35e73
Replace pcre with pcre2
Closes: https://github.com/swaywm/sway/issues/6838
2022-03-12 14:02:32 +01:00
Simon Ser 04676936e7 Remove WLR_SWITCH_STATE_TOGGLE usage
Ref [1].

[1]: 4792446ee8
2022-03-08 13:24:11 -05:00
Nicolas Avrutin 9f98c38d3e commands/focus: fix segfault when no container is already focused.
Fixes #6690.
2022-03-06 18:24:16 -07:00
Moon Sungjoon 3444ce7302 sway/input: destroy sway_switch properly
Fix: #6861
Added seat_device_destroy function to seat_device_destroy function.
2022-03-05 20:39:47 +01:00
Alexander Gramiak d6f279902a sway/input: don't pass possibly invalid modifiers pointer
active_keyboard may be NULL, in which case an invalid pointer could be
passed to wlr_input_method_keyboard_grab_v2_send_modifiers. This
procedure call is unnecessary since wlroots commit 372a52ec "input
method: send modifiers in set_keyboard", so the call can simply be
removed.

Fixes #6836.
2022-03-04 08:37:07 +01:00
Thomas Hebb 0ee54a5243 Don't enter seatop_move_floating when fullscreen
Currently, a floating window that's been fullscreened can send us
xdg_toplevel::move, and we'll enter seatop_move_floating, which lets us
drag the surface around while it's fullscreen. We don't want
this--fullscreen surfaces should always be aligned to the screen--so add
the same check that seatop_default already does when entering this mode.

Tested with Weston's weston-fullscreen demo, which sends a move request
if you click anywhere on its surface.
2022-02-24 12:12:12 +01:00
Thomas Hebb b38b845c63 Remove some erroneous apostrophes in comments 2022-02-22 09:50:58 +01:00
Simon Zeni 85d1c98476 sway/input: use wlr_input_device from input device base 2022-02-21 20:25:47 +03:00
Simon Zeni f8990523b4 sway/commands: add missing wlr_keyboard interface include in xkb_switch_layout 2022-02-21 20:25:47 +03:00
Simon Ser f707f583e1 Remove all sprintf calls
Replace them with snprintf, which ensures buffer overflows won't
happen.
2022-02-08 09:20:13 -05:00
Muhamed Hobi ac7892371c Fix snprintf compiler warning 2022-02-08 09:43:32 +01:00
Simon Ser 9a6687ee04 xdg-shell: use wlr_xdg_popup in sway_xdg_popup
Improved type safety.
2022-02-07 23:22:16 +03:00
Simon Ser f795aa1c95 xdg-shell: use wlr_xdg_toplevel in sway_view
Improved type safety.

Closes: https://github.com/swaywm/sway/issues/6813
2022-02-07 23:22:16 +03:00
Alexander Browne 36f5467993 Minor update to focus_on_window_activation
Removed xwayland limitation since wayland clients are supported via xdg-activation.
2022-02-06 09:11:06 +01:00