Commit graph

133 commits

Author SHA1 Message Date
Consolatis
9e6aaa689a project wide: clean up event listeners on shutdown
This ensures all event listeners are removed before the emitting
wlroots object is being destroyed. This will be enforced with asserts
in wlroots 0.19 but there is no reason to not do it right now either.

This change in wlroots 0.19 is implemented via commit
8f56f7ca43257cc05c7c4eb57a0f541e05cf9a79
"Assert (almost all) signals have no attached listeners on destroy"
2025-03-13 17:33:51 +09:00
Consolatis
a4d1fcfef2 src/overlay.c: clean up timer on exit 2025-02-12 00:09:17 +09:00
Consolatis
138a514c90 seat: set repeat information for virtual keyboards
Fixes: #2513
2025-01-13 06:28:37 +09:00
tokyo4j
8f8e734405 src/seat.c: small refactor
The condition server->input_mode != LAB_INPUT_STATE_PASSTHROUGH is enough
to catch when window switcher is active.
2024-12-30 18:07:45 +09:00
tokyo4j
bad788ccdd Clear keyboard/pointer focus on Move/Resize, window switcher and menu
The previous revert fixed the problem of stuck modifier keys with
keybinds in Blender, but made Firefox show its menu bar with Alt-*
keybinds. This is fundamentally inevitable due to the limitation of
wayland protocol, but at least for the default Alt-Tab keybind for
window switcher, we can mitigate this problem by clearing the keyboard
focus when the window switcher is activated. This is what KWin does, and
we decided to follow that.

So in this commit, keyboard and pointer focus are temporarily cleared
while Move/Resize, window switcher and menu interactions and restored
after them. We slightly deviate from KWin as KWin doesn't clear the
keyboard focus while Move/Resize, but it solves our existing problem
that Firefox shows its menu bar after dragging it with default Alt-Drag
mousebind, and this is what Mutter does.

We considered other solutions, but they don't work well:
1. Send wl_keyboard.{leave,enter} every time keybinds/mousebinds are
   triggered. This solves the Firefox's menu bar problem, but that
   sounds like a workaround and sending unnecessary events every time is
   not desirable.
2. Send release events for both modifiers and keys even when they are
   bound to keybinds. This is what Mutter is doing, but it looks like an
   implementation issue and violates wayland protocol.
2024-12-29 16:27:34 +09:00
Consolatis
7b1af3036c Remove some line terminators from log messages 2024-11-16 22:13:17 +00:00
tokyo4j
102bcc5013 seat: destroy seat->workspace_osd_timer on exit 2024-11-12 16:21:06 +09:00
Jens Peters
fc774d0071 input: hide cursor when using touch input
Hide the cursor on touch input and keep the cursur invisible
until pointer or tablet input.
2024-11-10 17:08:38 +09:00
Jens Peters
d1cde3c435 input: close xdg-popups on touch down
Taken over and now shared from the tablet implementation.
2024-11-10 17:08:38 +09:00
Simon Long
01f6c5d073
src/seat.c: Allow pointer speed of -1 2024-11-08 21:38:56 +01:00
tokyo4j
25f5cdd3a6 Refactor the logic of placing client-menu with ShowMenu action
Before this commit, we assumed `ShowMenu` action is not bound to any
buttons other than window menu button and always place the client-menu
under the window-menu button when atCursor="no". Also, it was going to be
difficult to distinguish whether the action is executed from the window
menu button or the window icon, which will be added soon.

This commit fixes it to open the menu under the actually-clicked button by
passing `cursor_context` to `actions_run()`, with some refactoring:
- `seat->pressed.resize_edges` is removed and it's calculated from the
  cursor position and `seat->pressed.type` just before running Resize
  action. This slightly changes the existing logic to determine the
  resizing edges with Alt-Right + Drag mousebinding, but
  `seat->pressed.type` is still stored on button press so it doesn't bring
  back the issue #543.
- `seat->pressed.toplevel` is removed and `get_toplevel()` in
  `update_pressed_surface()` may be called more often, but its overhead
  will be negligible.
2024-09-21 18:07:34 +01:00
tokyo4j
b667107d1a input: move <scrollFactor> to <libinput> section
This allows per-device configuration of scroll factor (e.g. setting
different scroll factors for mice and touchpads).
2024-08-23 16:20:56 +09:00
Jens Peters
dd0cee02a4 input: move cursor event listeners from tablet to seat
Otherwise we would subscribe multiple times to the
same event when having multiple tablets.
2024-08-13 18:40:34 +02:00
Consolatis
d16c6dd63a chase: tablet_pad to tablet
https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4585
2024-07-17 21:28:59 +01:00
Consolatis
3e614814fe chase: input inhibit removal
https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4440
2024-07-17 21:28:59 +01:00
Jens Peters
3c0cea92f2 input: support tablet-v2 pad notifications 2024-06-13 21:23:37 +01:00
Jens Peters
61e5e0e4d9 input: track tablets and tablet-pads at seat 2024-06-13 21:23:37 +01:00
Simon Long
84c222a84f Add onRelease option to <keybind>
...to make keybind actions fire on the release event rather then when the
key is first pressed. This is useful for binding actions to modifier keys
only. The most likely use-case for this is the binding of a Super key to a
menu, for example:

    <keybind key="Super_L" onRelease="yes">
      <action name="Execute" command="rofi -show drun"/>
    </keybind>

If another keybind is issued between the press and release, the on-release
keybind is cancelled.

Co-authored-by: @johanmalm
2024-06-09 21:15:58 +01:00
Jens Peters
2388f37cc7 input: prevent cursor notifications from pointer and tablet tool
... at the same time. Omit cursor notifications from
a pointer when a tablet tool (stylus/pen) is in
proximity. We expect to get cursor notifications
from the tablet tool instead.
2024-05-31 16:59:43 +02:00
tokyo4j
a39c8afc10 session-lock: refactor
- Replaced `session_lock` with `session_lock_manager` which is
  persistent throughout the session.
- Replaced `session_lock->abandoned` with `session_lock_manager->locked`.
  Old `session_lock->abandoned` is equal to
  `!session_lock_manager->lock && session_lock_manager->locked`.
- Eliminated the use of global variables in `session-lock.c`.
- Changed some function names.
2024-05-31 11:21:29 +09:00
tokyo4j
23b96ad2a6 Replace _ with - in source file names 2024-05-22 07:10:51 +01:00
Jens Peters
b6e439a5cc seat: announce pointer capability for tablet tool
We use pointer focus for the tablet tool, so we
should also use this capability. There is no
dedicated tablet tool capability.
2024-05-19 21:21:52 +01:00
Hiroaki Yamamoto
ad15c0474d
seat: prevent xwayland from using incorrect keymap (#1816)
With commit cafdcd8e, the keyboard from the keyboard group is set to the
seat when the active keyboard is destroyed, but this broke `wtype`
against XWayland surfaces. This is likely because XWayland caches
keycodes from the compositor and convert them with the last keymap
received from the compositor. So when we run `wtype a` over a XWayland
surface, the keycode for `a` is cached by XWayland, the keymap from the
keyboard group is sent to XWayland, then Xwayland converts the keycode
using the keymap from the keyboard group, not the one `wtype` set.

This commit fixes this by setting the keyboard from the keyboard group
to the seat when the keyboard focus is moved to a surface, not when the
active keyboard is destroyed.
2024-05-14 21:15:28 +01:00
tokyo4j
cafdcd8e19 seat: prevent Chromium from crashing when active keyboard is gone
Chromium (and slurp) expect wl_keyboard.keymap event to be sent before
wl_keyboard.modifiers event. Normally, wl_keyboard.keymap event is sent
on the client first obtains wl_keyboard with wl_seat.get_keyboard
request.
However, after the active (especially virtual) keyboard is destroyed,
wlroots doesn't respond to wl_seat.get_keyboard request with
wl_keyboard.keymap event since there's no active keyboard on the seat.

Therefore, if we run commands like "sleep 2; wtype hello; chromium", the
active keyboard is destroyed when wtype finishes and
wl_keyboard.modifiers event is sent to Chromium when Chromium first maps
the surface and the keyboard focus is moved to it, then Chromium crashes.

With slurp, fcitx5 and multi-monitor setup, a similar thing happens.
When slurp first creates the layer-shell surfaces, the focus moves to it
(without wl_keyboard.enter though), and fcitx5 is transiently deactivated
and it destroys the virtual keyboard. Then when slurp maps those
surfaces, the focus moves between them again and wl_keyboard.modifiers
event is sent, thus slurp crashes.

So with this commit, when the active keyboard on the seat is destroyed,
the keyboard from the keyboard group is set to the seat instead so
wlroots can respond to wl_seat.get_keyboard request with
wl_keyboard.keymap.
2024-05-08 20:39:09 +01:00
Consolatis
8d4f295440 cursor: reload cursor on Reconfigure
This gives instant feedback when changing cursor theme or size.
It only works for server side cursors or clients using the
cursor-shape protocol.

Fixes: #1619
2024-05-04 21:28:10 +01:00
Hiroaki Yamamoto
d64e3915a3
Fix some header includes detected by clangd
There were some missing headers like <stddef.h> for `NULL`, <wayland-util.h>
for `wl_link` and <stdbool.h> for `true`/`false`.

Also this commit fixes that `labwc.h` and `ime.h` included each other.
2024-04-21 21:58:57 +02:00
tokyo4j
50fd65416f overlay: add theme setting snapping.preview.[region|edge].fill
This settings allows user to choose whether to draw a filled rectangle
or an outlined rectangle as the preview for window snapping.
2024-04-15 12:33:40 +02:00
SnowNF
fb921ab431 Optimize the code based on the suggestions 2024-03-20 22:52:19 +00:00
SnowNF
bd4d92bad8 libinput: add support for touchscreen set matrix
My android pad emit a strange touch input from libinput, need to rotate it in 270 degree clockwise to fix.
2024-03-20 22:52:19 +00:00
Johan Malm
045dd8a378 seat: remove unecessary top/overlay check in seat_set_focus_layer()
Such checks should be made prior to calling the function (which they
are).
2024-03-17 21:18:47 +00:00
Johan Malm
5cb3583108 keyboard: use 'us' as fallback for XKB_DEFAULT_LAYOUT
...if keymap cannot be created for the provided XKB_DEFAULT_LAYOUT.

If keymap still cannot be created, exit with a helpful message to avoid
crash that is hard to understand.

Fixes: https://github.com/stefonarch/lxqt-labwc-session/issues/7
2024-03-12 20:59:39 +00:00
Simon Long
1e1e90d0bb
Reload cursor theme and size on reconfigure
Fixes: #1587
2024-03-12 20:53:41 +01:00
Hiroaki Yamamoto
be37f9a564
Fix various typos across the codebase 2024-03-08 13:59:20 +01:00
John Lindgren
bb8f0bc960 seat: don't deactivate view for any non-view surface
Now we now longer gray-out the active window when opening a focusable
popup menu (e.g. the applications menu from an XWayland panel). This
matches Openbox behavior.
2024-03-05 20:51:32 +00:00
tokyo4j
334cd09106 IME: support input method 2024-03-05 20:28:15 +00:00
Sachin Bhat
6fb06c54c2 config: support libinput sendEventsMode
This allows to enable / disable libinput devices.

Co-Authored-By: @Consolatis
2024-02-24 21:36:53 +01:00
Jens Peters
9456b50983 seat: fix configure condition for click method
Exclude none (zero) from the bitmask test , otherwise
the bitmask test is always true when click method is
configured to 'none' and as a result the configuration
will be skipped.
2024-02-24 20:39:54 +01:00
Marvin Dostal
8be9c38460
Add click method libinput option (#1416)
<libinput>
  <device>
    <clickMethod>none|buttonAreas|clickfinger</clickMethod>
  </device>
</libinput>
2024-02-21 17:19:48 +00:00
Consolatis
a5c6b2f83d Prevent 'unused variable' warnings when compiled without asserts 2024-02-10 19:22:12 +01:00
Consolatis
e9552fb661 src/seat.c: provide NULL fallback for output name
This fixes a warning when doing a release build.
2024-02-10 19:22:12 +01:00
Jens Peters
1d4961650f seat: re-map pointer to output on reconfigure
Makes testing easier, also consistent with other
devices types on reconfigure.
2024-01-22 21:50:18 +00:00
Jens Peters
19cab55092 seat: get output name from touch config for current device
The output name attached to the touch device has
still priority.
2024-01-22 21:50:18 +00:00
Jens Peters
2c3ab16f39 config: parse multiple touch configurations
Also temporary disable touch output mapping.
Will be restored later.
2024-01-22 21:50:18 +00:00
Simon Long
8c9be2f0d1 keyboard: set keyboard layout on reconfigure
If keyboard-layout-per-toplevel-window is used, reset the group (index)
for each window on --reconfigure whenever the keymap has changed.

Refactor to use a common configure function for reconfigure and
keyboard-group creation.

Co-authored-by: @johanmalm

Fixes #1407
2024-01-19 18:59:14 +00:00
Jens Peters
6d6f243ff5 seat: re-map pointer to output on output change 2024-01-13 22:18:20 +00:00
Jens Peters
f5f5a7b036 seat: configure libinput for touch on reconfigure 2024-01-13 22:18:20 +00:00
Jens Peters
ffc4b0fdee seat: remove not needed device type test
The device type is already validated in the calling
function.
2024-01-13 22:18:20 +00:00
Jens Peters
516423f9ba seat: re-map touch to output on output change 2024-01-13 22:18:20 +00:00
Jens Peters
0eb1ae4d66 seat: re-map touch to output on reconfigure 2024-01-13 22:18:20 +00:00
Jens Peters
21cf3071e3 seat: map touch to configured output name
The output name linked to the touch device
has preference when set. This happens when
the compositor runs in nested mode.
2024-01-13 22:18:20 +00:00