This commit rewrites the nested action parser into append_actions() which
is used by following commits. At this point, it's not used yet and parsing
"If" action is temporarily disabled.
...before processing the entire xml tree. This is a preparation to prevent
breaking changes when we refactor rcxml.c to use recursion instead of
encoding nodes into dotted strings.
John Lindgren [Tue, 29 Jul 2025 05:17:42 +0000 (01:17 -0400)]
CONTRIBUTING.md: minor updates
- style "GLib" with two capitals as in its own upstream docs
- use title-case consistently for headings
- add missing heading to table of contents
- update dead GLib documentation URL
John Lindgren [Mon, 28 Jul 2025 05:02:01 +0000 (01:02 -0400)]
src: include primary header first
This is a common practice in C projects, which simply enforces that
each header must compile cleanly without implicit dependencies on
other headers (see also the previous commit).
John Lindgren [Sat, 19 Jul 2025 03:06:20 +0000 (23:06 -0400)]
menu: add struct menu_parse_context to reduce static vars
The lifetime of the "current_" variables (current_menu, current_item,
current_item_action) is very difficult to understand from reading the
code. It appears that e.g. current_menu could still point to a previous
menu when starting to parse a new one, with unpredictable results.
Let's use a context struct when parsing, and consistently initialize
it when beginning to build a new menu.
Lightly tested with:
- default menus (no menu.xml)
- example static menu from labwc.github.io/getting-started.html
- an added "client-list-combined-menu" sub-menu
- pipe menu generated by `labwc-menu-generator -p`
cursor: prevent hi-res mice triggering scroll actions too often
Hi-res mice produces mulitple scroll events with `delta_discrete` != 0
during a single "click". This patch makes them trigger `Scroll` actions
only when the accumulated `delta_discrete` exceeds 120 (= 1 click).
See https://lists.freedesktop.org/archives/wayland-devel/2019-April/040377.html
for how hi-res scroll events are reported.
John Lindgren [Fri, 4 Jul 2025 04:12:21 +0000 (00:12 -0400)]
src: avoid tentative definitions of static data
Having multiple declarations of the same static data (where one is
considered "tentative") is kind of an obscure C feature -- I didn't
even know the name of it until today. It's also forbidden in C++.
In the case of circular dependencies between static data <-> function,
the more typical pattern is to forward-declare the function, then the
data, then provide the function definition. Let's follow that pattern.
John Lindgren [Sun, 13 Jul 2025 01:30:26 +0000 (21:30 -0400)]
img: fix apparent double-free in img_svg_render() failure path
img_svg_render() calls g_object_unref() on the RsvgHandle in its
error path, but the handle is owned by the shared lab_img_data
struct and will be double-freed later by lab_img_destroy().
The double-free was introduced when img_svg_load() was split from
img_svg_render(). The g_object_unref() should have been removed from
img_svg_render() but was missed.
Wlroots now destroys the wlr_output when granting a lease.
So we can't iterate through the outputs in the request after
granting the lease. This is also not necessary anymore because
they are already destroyed and thus removed from the layout.
tokyo4j [Mon, 30 Jun 2025 07:42:45 +0000 (16:42 +0900)]
rcxml: revise drag-lock behavior and option names
This revises the changes done in 22d319c:
- Cancel defaulting to <dragLock>sticky<dragLock>. So labwc now disables
drag-lock by default, as libinput does.
- Update the options from [yes|no|sticky] to [timeout|no|yes] to
emphasize that the "sticky" mode (now "yes") is recommended when using
drag-lock.
Johan Malm [Sun, 29 Jun 2025 21:09:16 +0000 (22:09 +0100)]
layers.c: fix UAF bug on TTY change
Call seat_set_focus_layer(seat, NULL) in node-destroy-handler to avoid
seat->focused_layer becoming invalid and causing UAF issues in certain
situations like when outputs (and therefore layer-trees) are destroyed.
Consolatis [Sat, 28 Jun 2025 15:34:53 +0000 (17:34 +0200)]
meson.build: require xwayland version 21.1.9 for xwayland support
This and later xwayland releases ship fixes for drm leased devices
causing lags in Chromium and Electron based applications. We used
to work around the issue by simply not sending drm leases to xwayland
but we can now rely on the fixes being widely available.
See #553 for more information.
tokyo4j [Fri, 27 Jun 2025 06:10:06 +0000 (15:10 +0900)]
layers: don't send configure events in unmap handler
Alternative to 7bf08af which was reverted in the previous commit.
7bf08af fixed the problem that layer-shell clients are terminated when
it's unmapped, by sending configure events in node-destroy handler
rather than in unmap handler. But it caused a UAF bug when an output
with layer-shell clients is destroyed.
So this patch fixes the original issue by simply skipping the surface in
arrange_one_layer() if it's being unmapped.
tokyo4j [Thu, 26 Jun 2025 10:39:36 +0000 (19:39 +0900)]
ssd: work around the translucent titlebar in pixman renderer
Due to wlroots/pixman bug, the widened 1px buffer for the gradient
titlebar become translucent with WLR_RENDERER=pixman and
WLR_SCALE_FILTER_BILINEAR filter mode. This patch works around this
problem by using WLR_SCALE_FILTER_NEAREST filter mode if pixman
renderer is used.
tokyo4j [Mon, 23 Jun 2025 19:32:40 +0000 (04:32 +0900)]
ime: revert workarounds for wlroots 0.18.2
The workarounds added in #2498 and #2437 fixed stuck key/modifier bug
caused by wlroots commit e218990. But now that the commit was reverted in
0.19, the workarounds are no longer needed.
Removing the workarounds also fixes a minor regression with Fcitx5+Firefox
that pressing Ctrl+Enter in an input box causes stuck modifier.
Johan Malm [Fri, 13 Jun 2025 17:54:02 +0000 (18:54 +0100)]
config: deprecate A-<arrow> keybinds
...because Alt- keybinds should be for clients to use and the A-<arrow>
default combination is a frequent user complaint because it prevents some
common usage patterns like alt-left/right in web browers.
Jens Peters [Sun, 15 Jun 2025 07:39:19 +0000 (09:39 +0200)]
input: clear SSD hover effects after touch-up
Having a hover effect visible without interaction looks out of
place when there is no cursor (the cursor becomes hidden for/after
touch interaction until next mouse or tablet interaction). Just
clear the hover effect after touch-up to prevent this.
Note that SSD hover effects are still shown during touch-move and
touch-down.
Jens Peters [Fri, 13 Jun 2025 12:59:02 +0000 (14:59 +0200)]
input: use mouse emulation for touch when labwc menu is open
Only use the touch protocol when no labwc menu is open.
This ensure that labwc menus will be closed on first touch
down/up since cursor emulation takes care of closing a
menu.
This prevents that a labwc menu stay open during touch
interactions in native touch mode.
Jens Peters [Sun, 8 Jun 2025 06:27:25 +0000 (08:27 +0200)]
input: move tablet axis members to tablet tool
It doesn't matter much since those are about the combination
of tablet and tablet tool. That said, this feels slightly more
natural.
As a consequence we always create a tablet tool and decide
indirectly via `tablet_get_coords()` and the returning surface
if mouse emulation should be used or not. Now we can also
add a `motion_mode` to the tablet tool which is slightly cleaner.
tokyo4j [Mon, 9 Jun 2025 21:50:41 +0000 (06:50 +0900)]
Bump xdg-shell version from 3 to 6
- Send xdg_toplevel.wm_capabilities
- Send xdg_toplevel.configure_bounds so that clients can map a window that
fits within the usable area, without relying on
view_constrain_size_to_that_of_usable_area() which is called after map.
- (The new "suspended" state should be handled by wlr_scene in the future)
Jens Peters [Sun, 8 Jun 2025 09:38:25 +0000 (11:38 +0200)]
cursor: omit pointer cursor shape for tablet tool
Omit cursor notifications from a pointer when a tablet
tool (stylus/pen) is in proximity. This is equivalent
to `handle_request_set_cursor()` and prevents a resize
cursor for out-of-surface scrolling with a tablet tool in
recent GTK4 (which uses the cursor shape protocol).
John Lindgren [Wed, 11 Jun 2025 20:12:56 +0000 (16:12 -0400)]
xwayland: fix possible loss of focus when multiple views are unmapped
Due to the asynchronous nature of view_offer_focus(), there was a race
condition that could result in no view remaining active when multiple
views were unmapped at once. Check for this and prevent it.
John Lindgren [Wed, 11 Jun 2025 19:40:37 +0000 (15:40 -0400)]
xwayland: correctly return seat focus from menus/tooltips in CLion
CLion's main window uses the Globally Active input model, and since 8fb2ecefcbd6 it is given focus asynchronously via view_offer_focus().
However, we need to return seat focus immediately after an unmanaged
surface (e.g. popup) is unmapped, or focus is lost completely.
John Lindgren [Mon, 9 Jun 2025 15:11:32 +0000 (11:11 -0400)]
xwayland: always offer focus in Globally Active case
In 9e3785f8cd7a, a heuristic was added to assume that NORMAL and DIALOG
window types were always focusable. (This was before we had the "offer
focus" mechanism in place.)
However, we should still call wlr_xwayland_surface_offer_focus() for
these views, in case they actually don't want focus. (This is uncommon
but has recently been seen with WeChat popups, which have both NORMAL
and UTILITY type.)
To make this possible, refine view_wants_focus() to return either
LIKELY or UNLIKELY for Globally Active input windows. This decouples
the question of "should we try to focus this view" from the actual
mechanism used to do so.