1
1
Fork 0
mirror of https://github.com/swaywm/sway synced 2024-05-24 10:06:07 +02:00
Commit Graph

761 Commits

Author SHA1 Message Date
Ronan Pigott 2f2cdd60de input: enable user xkb configs with cap_sys_nice 2023-01-11 11:32:09 +01:00
John Chadwick 3061999ec5 Improve tablet tool button handling.
This change allows the tablet tool button to be used for floating mod
resize. In addition, it attempts to ensure that tablet tool events are
consistent such that tablet v2 events and pointer events will never be
interleaved, and such that the tool buttons count will never fall out of
sync and cause tool button emulation to break.

Some of this logic is similar to what is done for tablet tool tip, but
not quite identical, because of the complication that we have to deal
with multiple inputs that can overlap eachother.

Fixes #7036.
2023-01-07 23:52:27 -05:00
Alexander Orzechowski 88c17ece3b warp_to_constraint_cursor_hint: Handle NULL view
This might be the wrong fix, but the crash is happening because the ->data
field on an xwayland surface is NULL. A NULL data field is normal for
unmanaged surfaces, however it seems clients can do weird things: They can
create a cursor lock on a regular xwayland surface then make it unmanaged
by calling override_redirect. In this case, the xwayland server should
destroy the cursor lock, which is does, but does so in the wrong order
making it try to dereference a NULL pointer after sway has acknowledged
its new unmanaged status.

```
(gdb) bt full
0  0x000055fd91934861 in warp_to_constraint_cursor_hint (cursor=0x55fd93486c00)
    at ../sway/input/cursor.c:1243
        sy = 605
        lx = 6.9527431433545762e-310
        sx = 1272
        view = 0x0
        con = 0x7ffd1cdfe400
        ly = -6.949595189996421e+59
        constraint = 0x55fd93e7faa0
1  0x000055fd91934976 in handle_constraint_destroy (listener=0x55fd93f0fd58, data=0x55fd93e7faa0)
    at ../sway/input/cursor.c:1266
        sway_constraint = 0x55fd93f0fd30
        constraint = 0x55fd93e7faa0
        cursor = 0x55fd93486c00
2  0x00007fda8275bf6e in wl_signal_emit_mutable () at /usr/lib/libwayland-server.so.0
3  0x00007fda82e57016 in pointer_constraint_destroy (constraint=0x55fd93e7faa0)
    at ../subprojects/wlroots/types/wlr_pointer_constraints_v1.c:49
4  0x00007fda82e570dc in pointer_constraint_destroy_resource (resource=0x55fd933cf8f0)
    at ../subprojects/wlroots/types/wlr_pointer_constraints_v1.c:66
        constraint = 0x55fd93e7faa0
5  0x00007fda8275d8ba in  () at /usr/lib/libwayland-server.so.0
6  0x00007fda8275f6a9 in wl_resource_destroy () at /usr/lib/libwayland-server.so.0
7  0x00007fda82e56fb3 in resource_destroy (client=0x55fd93ea52e0, resource=0x55fd933cf8f0)
    at ../subprojects/wlroots/types/wlr_pointer_constraints_v1.c:39
8  0x00007fda81d8f4f6 in  () at /usr/lib/libffi.so.8
9  0x00007fda81d8bf5e in  () at /usr/lib/libffi.so.8
10 0x00007fda81d8eb73 in ffi_call () at /usr/lib/libffi.so.8
11 0x00007fda8275aada in  () at /usr/lib/libwayland-server.so.0
12 0x00007fda8275f01c in  () at /usr/lib/libwayland-server.so.0
13 0x00007fda8275d9e2 in wl_event_loop_dispatch () at /usr/lib/libwayland-server.so.0
14 0x00007fda8275e197 in wl_display_run () at /usr/lib/libwayland-server.so.0
15 0x000055fd919264d3 in server_run (server=0x55fd919a3a80 <server>) at ../sway/server.c:320
16 0x000055fd91925457 in main (argc=1, argv=0x7ffd1cdfed98) at ../sway/main.c:411
        verbose = false
        debug = false
        validate = false
        allow_unsupported_gpu = false
        config_path = 0x0
        c = -1
```
2023-01-04 10:37:36 +01:00
Carl Smedstad 9425ce2fba Replace math functions that promote float to double 2023-01-03 21:50:56 +01:00
Kenny Levinsen 1ade0ce753 seat: Set keyboard if seat keyboard is NULL
sway sends wl_keyboard.enter on seat focus change and when a keyboard
active on a seat is configured. If all keyboards are removed and a
keyboard is added back without changing the focused client, no new
notify event would be sent despite having keyboard focus. This could
lead to key events without notify, which is a protocol violation.

As a quick fix, when configuring a keyboard on a seat where no keyboard
is currently active, activate the keyboard so that a focused surface
will receive a notify event.

Regressed by: e1b268af98
Closes: https://github.com/swaywm/sway/issues/7330
2022-12-19 10:02:58 +01:00
Lucas Zampieri efd83cb8b9 Add libinput RotationAngle
This patch adds the libinput option RotationAngle to sway.

Signoff-by: Lucas Zampieri <lzampier@redhat.com>
2022-12-09 11:28:53 +01:00
Kenny Levinsen e1b268af98 seat: Avoid sending redundant keymaps on reload
When we reload the config, we reset every input device and re-apply
configuration from the config file. This means that the keyboard keymap
is updated at least once during config reload, more if the config file
contains keyboard configuration.

When they keyboard keymap changes and is updated through wlr_seat, the
keymap ends up sent to every keyboard bound in every client, seemingly
multiple times. On an x230 of mine with a keyboard layout set in the
config file, I see 42 keymap events sent to foot on config reload.

Reduce events from keyboard configurations by skipping all but the
currently active keyboard for the seat, and by clearing the active
keyboard during input manager device reset. After this change, I only
see a single just-in-time keymap event.

Fixes: https://github.com/swaywm/sway/issues/6654
2022-12-04 13:01:41 -07:00
Simon Ser e62299daa4 Make libinput backend optional 2022-11-28 13:28:15 -05:00
Simon Ser 46170580b2 Make session optional 2022-11-28 13:28:15 -05:00
Simon Ser 7623292734 Update for wlroots!3814
References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/3814
2022-11-15 22:26:43 +01:00
Simon Ser 024c3e4428 input/seat: locally compute drag icon offset
References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/3861
2022-11-15 16:58:20 +03:00
pudiva chip líquida 7cc8ab6d6c Support libinput's 1.21 new dwtp option
Support the new dwtp (disable while trackpointing) option introduced in
libinput 1.21, allowing users to control whether the trackpoint (like
those in Thinkpads, but not only) should be disabled while using the
keyboard/touchpad.

See: https://gitlab.freedesktop.org/libinput/libinput/-/issues/731
2022-10-30 10:56:34 +01:00
Daniel De Graaf 8aa89dc277 Fix focus tracking when session lock is active
Remove the incorrect attempt to block focus changes when an input grab
is present and replace it with the same logic used for layer_shell-based
screen lockers: restore the focus after changing it.

This fixes a use-after-free of seat->workspace if outputs are destroyed
while a screen lock is enabled.
2022-10-28 19:41:24 +02:00
Daniel De Graaf 8f7bb145b7 Rework session lock keyboard focus handling
When removing outputs, it is possible to end up in a situation where
none of the session lock client's surfaces have keyboard focus,
resulting in it not receiving keyboard events.  Track the focused
surface and update it as needed on surface destroy.
2022-10-28 19:41:24 +02:00
Yaroslav de la Peña Smirnov 9d99bb956f Fix keymap being NULL and segfaulting on dev add
Moved `libinput_config` to the callers of
`sway_input_configure_libinput_device` so that we send the event after
the added event.
2022-10-23 11:56:29 +02:00
Tudor Brindus 5e514e6474 input: tweak focus behavior to allow focusing parent containers
Sway focuses the inactive child when focusing split containers. However,
there is currently no way to focus the parent container itself by mouse.
A user must use the keyboard to do so.

This commit maintains the current behavior, but makes it such that a
second click on the split container titlebar (i.e., after its children
are visible) focuses the split container itself.
2022-10-21 10:05:00 +02:00
Simon Ser 9400bd963c Add support for ext-idle-notify-v1
References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/3753
2022-10-14 15:56:07 +02:00
Tudor Brindus c7bced9329 input: focus container when scrolling on titlebar
Fixes #6503.
2022-10-10 08:56:51 +02:00
Tudor Brindus 09354db878 input: focus floating container when clicked on border
Fixes #7209.
2022-10-10 08:55:21 +02:00
Ferdinand Schober 99acdb4e62 Use keyboard_state.focused_surface directly 2022-10-09 10:07:51 +02:00
Ferdinand Schober be7707874a use seat directly 2022-10-09 10:07:51 +02:00
Ferdinand Schober e2bb5799af check for NULL 2022-10-09 10:07:51 +02:00
Ferdinand Schober d5659948f1 allow pointer_constraints on layer_shell surfaces 2022-10-09 10:07:51 +02:00
Kirill Primak 6b97c4fa71 input: chase delta_discrete semantics change 2022-07-15 14:14:41 -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
Florian Franzen cab2189aa6 sway: add bindgesture command
Co-authored-by: Michael Weiser <michael.weiser@gmx.de>
2022-05-30 12:20:43 +02: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
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
Simon Ser 04676936e7 Remove WLR_SWITCH_STATE_TOGGLE usage
Ref [1].

[1]: 4792446ee8
2022-03-08 13:24:11 -05: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 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
Tudor Brindus 8ca2847b42 input/cursor: pass through pointer hold gestures
This just follows swaywm/wlroots#3047, so `wl_pointer_gestures_v1`
clients can be notified of these events.
2022-01-22 23:43:46 +01:00
Tudor Brindus 7d1ccafae5 input/cursor: treat swipe begin as idle activity too
Accidentally overlooked in fd53f80.
2022-01-17 23:17:36 +01:00
Tudor Brindus fd53f80156 input/cursor: count pointer gestures as idle activity
Fixes https://github.com/swaywm/sway/issues/6765.
2022-01-17 23:05:19 +01:00
Thomas Hebb 921b0a8633 input/seat: unset has_focus when focus_stack becomes empty
We currently track the focus of a seat in two ways: we use a list called
focus_stack to track the order in which nodes have been focused, with
the first node representing what's currently focused, and we use a
variable called has_focus to indicate whether anything has focus--i.e.
whether we should actually treat that first node as focused at any given
time.

In a number of places, we treat has_focus as implying that a focused
node exists. If it's true, we attempt to dereference the return value of
seat_get_focus(), our helper function for getting the first node in
focus_list, with no further checks. But this isn't quite correct with
the current implementation of seat_get_focus(): not only does it return
NULL when has_focus is false, it also returns NULL when focus_stack
contains no items.

In most cases, focus_stack never becomes empty and so this doesn't
matter at all. Since focus_stack stores a history of focused nodes, we
rarely remove nodes from it. The exception to this is when a node itself
goes away. In that case, we call seat_node_destroy() to remove it from
focus_stack and free it. But we don't unset has_focus if we've removed
the final node! This lets us get into a state where has_focus is true
but seat_get_focus() returns NULL, leading to a segfault when we try to
dereference it.

Fix the issue both by updating has_focus in seat_node_destroy() and by
adding an assertion in seat_get_focus() that ensures focus_stack and
has_focus are in sync, which will make it easier to track down similar
issues in the future.

Fixes #6395.

[1] There's some discussion in #1585 from when this was implemented
about whether has_focus is actually necessary; it's possible we could
remove it entirely, but for the moment this is the architecture we have.
2022-01-07 14:08:24 +01:00
RoastVeg f2b6d1ec29 Handle border width and height on minimum floating sizes
This fixes: https://github.com/swaywm/sway/issues/5337

Co-authored-by: Moon Sungjoon <sumoon@seoulsaram.org>
2021-12-14 10:30:10 +01:00
Rasmus Moorats aaf68cf423 fix cursor input for layer-shell surfaces
previously, fullscreen global containers would grab cursor input
even if a shell-layer surface was on top of it

related issue: https://github.com/swaywm/sway/issues/6501
2021-10-26 15:13:37 +03:00
siikamiika f4db502d44 use node_is_view 2021-10-10 09:35:15 +02:00
Jari Ronkainen 624ffa4516 Improve built-in touchscreen detection
Adds detection code to handle pci-*-platform-* strings
in ID_PATH

References: https://github.com/swaywm/sway/issues/6590

Signed-off-by: Jari Ronkainen <ronchaine@gmail.com>
2021-10-08 19:09:42 +02:00
Simon Plakolb 4baf845a3a seatop_down: End if surface is destroyed or other seatop starts
If the surface the pointer started to interact with is destroyed we also
want the seatop_down to end. In case a drag is initiated we receive a
call to handle_end.
2021-09-02 13:13:40 -04:00
Simon Plakolb 9e58425cb3 input: Use seatop_down on layer surface click
This solves an issue where layer-shell items would not receive a button
release event when the pointer left them while being pressed. The
default seatop changes focus immediately while seatop_down defers any
focus changes until the pointer is released or seatop_down is destroyed.
2021-09-02 13:13:40 -04:00
David Rosca d0fe721fbb seatop_down: Change type of sx, sy to double in begin_seatop_down
Losing the precision resulted in wlr_cursor and wlr_seat::pointer_state
getting out of sync during pointer motion in seatop_down.
Since the difference was always under 1 px, it was practically
impossible to notice in normal use.

But because of being out of sync, cursor_rebase would always end up
incorrectly calling wlr_seat_pointer_notify_motion from
seatop_default_begin (on releasing mouse button) which broke cursor
locking.

See #5405
Closes #4632
2021-08-05 09:26:11 -04:00
Simon Ser 2e03a61262 Fix wl_pointer.frame not sent on touch emulation
When emulating touch, the simulating_pointer_from_touch field is
set to true. It's switched back to false when a touch_up event is
received. However we need to ensure we always send a wl_pointer.frame
event following a group of other wl_pointer events.

Since a touch_frame event is always guaranteed to come after a group
of touch events, unset simulating_pointer_from_touch in the touch_frame
handler instead of the touch_up handler. Add a new field to know whether
the touch_frame handler should stop emulation.
2021-07-26 16:58:11 +02:00