Commit graph

79 commits

Author SHA1 Message Date
tokyo4j
4073a6b923 cursor: rate-limit resize events respecting monitor's refresh rate
This fixes the lag when resizing windows of some apps on XWayland
(e.g. Chromium and Steam).
2024-05-31 17:28:43 +02: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
Jens Peters
15135465d9 input: send tablet proximity-in only above a valid surface
A resize with a tablet tool might end above a
non-tablet capable surface, discard the
proximity-in in that case.
2024-05-28 22:05:06 +02:00
Jens Peters
d65f56e8a5 input: postpone tablet notifications when tip or button is pressed
We should not switch to tablet notifications when an
out-of-surface-move had been started on a non-tablet
capabale surface.

Also postpone proximity-in when moving to a new surface
with the tip down.
2024-05-27 22:40:50 +02:00
Jens Peters
4b17083aa0 input: close xdg-popups on tablet tip or button press 2024-05-27 22:40:50 +02:00
Jens Peters
caf9c9a599 input: prevent interference between pointer and tablet tool motion
Move the pointer "out of the way" on proximity-in
to prevent interference with tablet motion.
2024-05-27 22:40:50 +02:00
Jens Peters
6d05bed883 config: add option for forcing mouse emulation
Default is off. Also allow switching with reconfigure.
2024-05-27 22:40:50 +02:00
Jens Peters
be72c4bde3 input: support button mapping for tablet capable surfaces
Apply the original mapping to mouse buttons and
map those back to stylus buttons.
2024-05-27 22:40:50 +02:00
Jens Peters
fb57d61f35 input: add tablet-v2 notifications for axis and buttons
Similar like touch, this is guarded by checking if
a surface accepts the tablet protocol. Also reuse
common cursor logic.

Intialize tablet tools on proximity.
Notify idle manager about activity on events.
2024-05-27 22:40:50 +02:00
Jens Peters
63744951af input: handle tablet tool cursor requests
Similar to cursor requests for pointers.
2024-05-27 22:40:50 +02:00
Jens Peters
abfa100b38 input: add tablet tool setup 2024-05-27 22:40:50 +02:00
Jens Peters
634a2beb31 input: expose general cursor motion and button functions
Separate the general logic from the pointer notifications
to allow reuse of those function for other (e.g. tablet)
input sources.
2024-05-27 22:40:50 +02:00
tokyo4j
23b96ad2a6 Replace _ with - in source file names 2024-05-22 07:10:51 +01:00
tokyo4j
2f1fcb4468 IME: support multiple IME popups
We didn't support multiple IME popups since input-method-v2 protocol
has no way to position them individually, but we should support it to
provide IME developers with more programming flexibility.
2024-05-20 09:35:26 +09:00
Simon Long
1c334cc918 Update consumed_by_frame_context for LAB_SSD_ALL 2024-05-19 22:17:04 +01:00
Jens Peters
f8a7d18cf0 input: ignore not supported tablet tools
We currently only support cursor emulation
for absolute motion, thus ignore tools/pens
that use relative motion.

Add a log statement on proximity-in to give
some feedback.
2024-05-19 21:21:52 +01:00
Jens Peters
163f11595f input: remove tablet/pad signal listeners on destroy
We should remove those when destroying a tablet
or a tablet pad.

Also rename 'tablet' to 'pad' in 'tablet_pad' for better
readability and consistency.
2024-05-19 21:21:52 +01:00
Consolatis
abd8e971c6 osd: prevent handling cursor actions in preview mode
Fixes: #1640

Co-Authored-By: tokyo4j <hrak1529@gmail.com>
2024-05-05 21:05:32 +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
tokyo4j
4b6efb7307 cursor: implement <menu><ignoreButtonReleasePeriod>
Addresses UX degradation introduced by commit 1d3ed457.

This prevents clicks with small movement with the intention of opening
the menu from unexpectedly closing the menu or selecting a menu item.
2024-05-01 19:08:07 +09:00
tokyo4j
1d3ed45704 cursor: do action/close menu in successive press & release
In OpenBox, when cursor button is pressed to open menu, a subsequent
cursor button release can perform actions or close the menu.
This commit makes labwc follow that behavior.

Fixes: #1750
2024-04-24 20:53:02 +09: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
Hiroaki Yamamoto
9be18f3009
IME: prevent virtual keyboard from unintentionally releasing modifiers (#1721)
When Fcitx5 is activated, it creates a virtual keyboard to send keycodes to
applications, then creates a keyboard grab to capture keycodes the user typed.

Before this commit, we set keyboard grab's modifiers to that of currently
active keyboard, which is the virtual keyboard created in the case described
above. However, since the modifiers of the virtual keyboard is empty at first,
we actually set empty modifiers, even when the user is pressing modifiers.
Then, Fcitx5 assumes no modifiers is pressed and redirect the modifier state
back to the compositor via the virtual keyboard. As a result, when the focus
is switched between windows by workspace-switcher, the workspace-switcher is
immediately terminated.

To fix this issue, with this commit, the modifier state of the currently active
keyboard is not set to the keyboard grab if the keyboard is a virtual keyboard
created by the same input-method client.

Fcitx5's commit below is also required to fix the issue.
b2924bd361
2024-04-18 21:57:03 +01:00
Jens Peters
42c09eeef8 input: notify idle manager when emulating cursor move
Looks like we forgot that one earlier.
2024-04-12 23:31:40 +02:00
droc12345
d672765ea7
osd: add window-switcher custom field (#1670)
Add custom field with subset of printf style formatting
to replace the original field formats.

Example:

    <windowSwitcher preview="no" outlines="no" allWorkspaces="yes">
      <fields>
        <field content="custom" format="foobar %b %3s %-10o %-20W %-10i%t" width="100%" />
      </fields>
    </windowSwitcher>

Mono space font recommended. May need OSD width adjusted

Co-authored-by: @Consolatis (based on work done by them)
2024-04-10 23:39:31 +01:00
Johan Malm
33859138cf cursor: fix dnd bug
...where dnd does not finish properly on cursor-button-release if there
is no surface under the cursor such as on the desktop when no background
client is running.

Written-by: @tokyo4j

Fixes: #1673
2024-04-06 21:50:12 +01:00
tokyo4j
da9456881d cursor: send release event to CSD client before finishing window dragging
This fixes that, when a CSD window is dragged into below waybar and the cursor
button is released, the cursor focus is moved from the CSD window to waybar and
a release event is sent to waybar, not original CSD window.
2024-04-05 11:37:52 +02:00
Hiroaki Yamamoto
5cc0757390
overlay: add snap-to-edge overlay (PR #1652)
...and unify region overlay and snap-to-edge overlay into overlay.c.

Snap-to-edge overlay is delayed for 500ms to prevent flickering when
the view is dragged from an output to another (demo in discussion labwc#1613).

This also fixes a bug that region overlay is not shown when a modifier
key is re-pressed.
2024-04-05 04:35:31 +02:00
Johan Malm
d68376f2ac cursor: validate double-click against SSD part type
...because click on different parts of a client should not be
interpreted as a double click.

Previously only cursor-button and view were validated to be the same
between clicks. This resulted in, for example a click on the client
surface itself quickly followed by a click on the SSD titlebar being
interpreted as a double-click on the titlebar.

Fixes: #1657
2024-03-28 06:00:06 +01:00
Johan Malm
06bf71162e cursor: use layer_try_set_focus() on press
This means that the logic described in 2ff026b will be used when a
layer-surface is pressed on with a cursor button. For example, a surface
with on-demand keyboard interactivity will not steal focus from a client
with exclusive keyboard interactivity.
2024-03-17 21:18:47 +00:00
tokyo4j
b6d576922b IME: support IME popup 2024-03-14 20:11:03 +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
Johan Malm
a5fcbfaf72 cursor: process layer subsurfaces in cursor_button_press()
...to give keyboard focus to layer-shell clients if exclusive or on-demand
interactivity is set, so that menu popups can be navigated with the
keyboard. This still only works if the client is in top (or overlay)
layers. Support for bottom and background to be done as a separate patch
set.

Revert 06b19f0 to process layer-shell subsurfaces in
`cursor_button_press()`, but only when their parent layer-shell surface
has keyboard interactivity.

Fix bug in `get_cursor_context()` which resulted in layer-surfaces not
being detected correctly.

Background:

Commit 06b19f0 (issue #1131) disabled processing of layer-shell
subsurfaces in cursor_button_press() because when pressing a task in
Waybar (Gtk panel using layer-shell subsurfaces) the foreign-toplevel
minimize-raise action did not work correctly as the action logic relied on
the recipient window being activated and by clicking on the panel, the
panel itself was both surface-focusd and activated (and thus the window
de-activated).

The un-intended consequence was that by not responding to layer-subsurface
cursor buttons presses, layer-shell clients (such as panels) were not
given keyboard focus if they indeed wanted it by setting exclusive or
on-demand keyboard interactivity.

The good news is that that following @jlindgren90's refactoring (various)
the only place where we call `view_set_actived()` is in
`focus_change_notify()` in `seat.c` and we now only do it for views
(bb8f0bc).

Another side-effect (positive) of 06b19f0 was that a Waybar dnd bug was
fixed (pointer-serial-number validation failure).

Have tested with sfwbar, waybar and tint (test-panel) the following
results:
- Minimize-raise works even when on-demand keyboard interactivity is set
- Keyboard interactivity is given popup-menus (sfwbar and tint) when the
  panels are in the top layer (support for bottom will be as a separate
  patch set)
- Waybar dnd still works (even when hard-coding keyboard-interactivity)

References:
- bb8f0bc960
- 40ce95a68c/src/seat.c (L481-L483)
- 40ce95a68c/src/dnd.c (L24)
- https://github.com/johanmalm/tint

Fixes: #1572
2024-03-09 00:44:19 +01:00
Johan Malm
7704b595d3 osd: restore preview at end of cycling
...so that sub-views are shown in front of root ones.
2024-03-05 22:16:55 +01:00
Simon Long
3ebc07f7aa
Handle touch on headerbar (#1550)
...using cursor emulate events.
2024-03-05 20:41:17 +00:00
tokyo4j
334cd09106 IME: support input method 2024-03-05 20:28:15 +00:00
John Lindgren
c78750283f key-state: use struct assignment 2024-03-04 02:27:40 +01:00
Consolatis
a5c6b2f83d Prevent 'unused variable' warnings when compiled without asserts 2024-02-10 19:22:12 +01:00
Jens Peters
6def1319d1 input: move function to config
This function is only about rc, so fits better
in config.
2024-01-22 21:50:18 +00:00
Andrew J. Hesford
57ea197e6c resistance: add window-edge resistance for interactive moves/resizes 2024-01-21 16:10:50 -05: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
Johan Malm
774eb2170f keyboard: cancel key repeat on vt change
...(calling `wlr_session_change_vt()`) because when the session is
switched, the access to the keyboard is lost and therefore the RELEASE
event will not be passed to the compositor.

Fixes bug whereby compositor crashes on VT change on FreeBSD.

Fixes #1424
2024-01-15 21:56:18 +00:00
Consolatis
e05bedb140 feat: add Shade/Unshade/ToggleShade actions
This builds on the work of @Consolatis in #1018.

Co-authored-by: Consolatis <35009135+Consolatis@users.noreply.github.com>
Co-authored-by: Andrew J. Hesford <ajh@sideband.org>
2024-01-15 21:37:36 +00:00
Johan Malm
e9023f51c6 menu: run actions on button release
...and call actions after closing menus so that virtual keyboard input
caused by actions are sent to the surface with keyboard-focus rather
than being consumed by the open menu.

Fixes: #1366
2024-01-11 20:31:24 +00:00
Tomi Ollila
785a34e8ad Fixed some typos 2024-01-04 19:32:51 +00:00
Jens Peters
c2687d9281 input: add tablet pad setup and button handler
Split pad initialization from tablet initialization to
avoid conflicting handler names.
Also reuse 'get_mapped_button'.
2024-01-02 21:28:42 +00:00
Jens Peters
28e7cd3006 input: add area transformation for tablet coordinates 2024-01-01 22:11:33 +00:00
Jens Peters
dd91cd89ae input: log tablet dimensions 2024-01-01 22:11:33 +00:00