Commit graph

117 commits

Author SHA1 Message Date
John Lindgren
9c5266ac76 Chase wlroots: Use wlr_cursor_set_xcursor()
Chases: 18bafbfc57039e16d1dabd78b882b3d6477f76b5
xcursor-manager: drop wlr_xcursor_manager_set_cursor_image()
2023-11-27 21:01:53 +00:00
John Lindgren
b5220a723e Chase wlroots: convert to try_from
Chases: 711a1a3ed42150fdbc716e80719d482006075f69
xdg-shell: convert to try_from

Chases: f9bd416d4156942ce3951a6c5cf9f81a3cf4a3dd
layer-shell-v1: convert to try_from

Chases: fbf5982e3838ee28b5345e98832f6956c402b225
xwayland/xwm: introduce wlr_xwayland_surface_try_from_wlr_surface()
2023-11-27 21:01:53 +00:00
Consolatis
46e3e29e26 Chase wlroots: wlr_session refactor
Chases 41b7acbab78597e2eb0724e415ed94b910d113c1
backend: return wlr_session in wlr_backend_autocreate() call
2023-11-27 21:01:53 +00:00
Johan Malm
2734302fd2 keyboard: fix key repeat bug on surface focus change
The bug can be reproduced by using the following keybinds and then taking
the steps below with an XWayland client, for example xterm:

    <keybind key="C-S-h">
      <action name="GoToDesktop" to="left" wrap="yes"/>
    </keybind>
    <keybind key="C-S-l">
      <action name="GoToDesktop" to="right" wrap="yes"/>
    </keybind>

1. Press C-S-h
2. Press C-S-l
3. Observe llllllll.... in xterm

Store the key-state in `handle_keybind()` before any call to
`action_run()` as this may lead to `seat_focus()` which passes
'pressed-sent' keys to the new surface.

This partially reverts 7571c4b, which as a standalone commit was fine, but
when 'pressed_mods' were then included in 'bound' in 98bf316,
`key_state_store_pressed_keys_as_bound()` was again required in
`handle_keybind()` to ensure modifers are not passed as non-modifiers in
`wlr_seat_keyboard_notify_enter()` in `seat_focus()`
2023-11-18 14:17:25 +00:00
Johan Malm
ba76b26165 key-state.c: add logging for 'pressed-sent' 2023-11-18 14:17:25 +00:00
John Lindgren
98bf316ee6 keyboard: include pressed modifiers in bound set
This prevents applications from seeing and handling the release event
for a modifier key that was part of a keybinding (e.g. Firefox displays
its menu bar for a lone Alt press + release).
2023-11-12 17:37:30 +00:00
John Lindgren
fe9491443c keyboard: remove exceptions from storing pressed keys
These exceptions were added to prevent certain keys (modifiers and
synthetic layout switch key-events) from disabling keybindings (due to
the "nr_pressed_keys > 1" check). That check no longer exists, so the
exceptions should no longer be necessary.

Partially reverts e77330bc3f and 3e2baa3f05.
2023-11-12 17:37:30 +00:00
John Lindgren
5a77a3ad51 keyboard: remove nr_pressed_keys == 1 restriction for keybindings
This restriction should be unnecessary now (see the previous commit for
details) and caused issues with keybindings not working on some systems
where irregular keypress events are received (e.g. XF86XK_WakeUp)
without an accompanying release event.

Kept separate from the previous commit for the sake of potential future
bisects.

Partially reverts e77330bc3f.
2023-11-12 17:37:30 +00:00
John Lindgren
7571c4bed3 keyboard: avoid stuck keys due to keybindings (alternate approach)
Before commit e77330bc3f, there were issues with keys becoming "stuck"
if other keys were pressed at the time a keybinding was matched, because
those other keys were included in the "bound" set and the release events
were incorrectly eaten by labwc.

Commit e77330bc3f solved that issue with the "big hammer" approach of
preventing keybindings from working at all if other keys were pressed:

        if (key_state_nr_pressed_keys() > 1) {
                return false;
        }

This is an alternate approach to solving the original problem, by (1)
not including those other keys in the "bound" set and (2) making sure we
always forward release events for un-bound keys to clients (even if a
menu or OSD is displayed).

Details:

- Since we only ever want to store the single matched keycode as bound,
  key_state_store_pressed_keys_as_bound() doesn't really make sense in
  the plural, so rename it to key_state_store_pressed_key_as_bound() and
  pass in the keycode.

- The calls to key_state_store_pressed_keys_as_bound() within
  handle_keybinding() appear to be redundant since it is also called
  from the parent function (handle_compositor_keybindings()). So remove
  these calls.

- Finally, rework the logic for handling key-release events so that we
  always forward release events for keys not in the "bound" set.

This PR does not remove the "key_state_nr_pressed_keys() > 1" check, and
because of that should not result in any functional change. It should
however make it possible to relax or remove that check in future.
2023-11-12 17:37:30 +00:00
Johan Malm
dcc10ba81b keyboard: fix shifted keystroke delay
Remove wlr_seat_set_keyboard() from `keyboard_modifiers_notify()`
but leave it in `keyboard_key_notify()`

Fixes regression introduced in 984aeb0

Reported-by: @jlindgren90

Fixes: #1238
2023-11-11 20:20:29 -05:00
Consolatis
984aeb0b0b keyboard: allow applying keyboard layout per window
Fixes #1076

It can be enabled with a config like

~/.config/labwc/rc.xml:
<keyboard layoutScope="window">

~/.config/labwc/environment:
XKB_DEFAULT_LAYOUT=de,us
XKB_DEFAULT_OPTIONS=grp:alt_shift_toggle,grp_led:scroll

With a configuration like this each window should now remember
the active keyboard layout when switching between windows.

By default, the keyboard layout keeps being a global state.
2023-11-04 07:58:43 +00:00
John Lindgren
c5437b1153 cursor: allow re-focusing xwayland-unmanaged surfaces
We already allow some xwayland-unmanaged surfaces to take focus on map,
if indicated by wlr_xwayland_or_surface_wants_focus(). But once these
surfaces lose focus, they never regain it again.

Add desktop_focus_view_or_surface() and call it in the appropriate
places to allow these views to regain focus in the usual ways (e.g.
clicking on them or focus-follows-mouse).
2023-11-02 19:31:10 +00:00
Consolatis
797e743c8a Move input handler init() and finish() functions to input/input.c 2023-10-30 21:14:04 +00:00
Consolatis
b359b1560c Move keyboard functions into input/keyboard.h 2023-10-30 21:14:04 +00:00
Consolatis
5e1562fae6 Make touch depend on cursor to prevent racing 2023-10-30 21:14:04 +00:00
Consolatis
8d0812d45a Move gesture handling out of cursor.c 2023-10-30 21:14:04 +00:00
Consolatis
67a8ae8561 Move input related source files into src/input/ 2023-10-30 21:14:04 +00:00