xsurface->data is presumed to be a (struct view *) if set, so it must be
left NULL for an unmanaged surface. Otherwise view_from_wlr_surface()
may return a (struct xwayland_unmanaged *) where a (struct view *) was
expected, leading to a crash.
valgrind backtrace:
Invalid read of size 1
at 0x48F8FFC: wlr_scene_node_set_enabled (wlr_scene.c:903)
by 0x124C9F: ssd_set_active (ssd.c:323)
by 0x124C9F: ssd_set_active (ssd.c:318)
by 0x124C9F: view_set_activated (view.c:215)
by 0x118851: focus_change_notify (seat.c:353)
by 0x487E01D: wl_signal_emit_mutable (wayland-server.c:2241)
by 0x48FC8F2: wlr_seat_keyboard_enter (wlr_seat_keyboard.c:298)
by 0x119E60: seat_focus.lto_priv.0 (seat.c:473)
by 0x1248FD: seat_focus_surface (seat.c:491)
by 0x1248FD: unmanaged_handle_map (xwayland-unmanaged.c:51)
by 0x487E01D: wl_signal_emit_mutable (wayland-server.c:2241)
by 0x487E01D: wl_signal_emit_mutable (wayland-server.c:2241)
by 0x490FC91: surface_commit_state (wlr_compositor.c:499)
by 0x56A24F5: ffi_call_unix64 (unix64.S:104)
by 0x569EF5D: ffi_call_int.lto_priv.0 (ffi64.c:673)
Address 0xa0e15ff30788b68 is not stack'd, malloc'd or (recently) free'd
Fixes: 4028a9482f
("seat: use focus_change event to update focused/active view")
XWayland views can self-declare that they don't want keyboard focus via
the ICCCM WM_HINTS property. Most of the logic is already in place to
avoid giving focus to such views (e.g. taskbars).
Add a couple of missing pieces to make this work:
- Hook up view_isfocusable() to look at WM_HINTS for XWayland views
- Adjust desktop_focus_topmost_mapped_view() to skip unfocusable views
Follow-up from b816c16701
Chase wlroots: Stop using wlr_xwayland_surface event data
Chases: 27edd024f83892f4af9c5084d47b73f26966aaf1
xwayland: pass NULL as event data
- Connect to wlr_seat_keyboard_state's focus_change event.
- Add view_from_wlr_surface(), which does what the name says.
- Use focus_change event along with view_from_wlr_surface() to update
server->focused_view and set SSD states via view_set_activated().
- Eliminate desktop_focused_view() since server->focused_view should be
reliably up-to-date now.
- Eliminate view_focus/defocus() since we can now just call
seat_focus_surface() directly.
Do not withhold the release event associated with a keybind which executes
a keyboard-input-inhibiting client like swaylock.
In other words, make release-events of absorbed keys (those used up by a
keybind) de-register as such even though session-lock or input-inhibit is
in-force.
Fixes: issue #1114
Helped-by: @Consolatis
Make desktop_focus_view() always switch to the workspace containing the
view being focused. It doesn't make much sense for an invisible view to
have the keyboard focus.
Also add an optional "raise" parameter to desktop_focus_view(). This
allows the common pattern of desktop_focus_view() + view_move_to_front()
to be reduced to a single function call.
...and avoid failing to send release events to clients for any keys that were
not absorbed by a keybind.
Do not match keybinds if there are other non-modifier keys (not part of any
defined bind) pressed at the same time.
Only store non-modifier keycodes in the key-state.c 'pressed' array.
This makes the call to wlr_seat_keyboard_notify_enter() in seat_focus()
consistent with the equivalent in sway (in seat_keyboard_notify_enter()).
Fixes: issue #1091
Our current approach to handling the focused/active view is a bit
confusing. In particular, it's hard to be sure when server->focused_view
is or isn't in sync with the real wlroots keyboard focus.
Try to clean things up a bit. In particular:
- Add comments to server->focused_view and desktop_focused_view() to
clarify that they should match, but it's not guaranteed.
- desktop_focused_view() now prints a warning if it detects that
server->focused_view is out of sync. We should keep an eye out for
this warning, and if we see it, try to figure out why it happened.
- For consistency, use only "focus/defocus" as the verbs in function
names rather than "activate". This is a bit arbitrary, but the idea is
that focus is the primary action while the active/inactive state is a
side effect.
- view_focus/defocus() replace view_set_activated() and now update both
focus and active/inactive state, to try to keep them in sync.
- Add comments at view_focus/defocus() to warn against calling them
directly (we should generally call the desktop.c functions).
- desktop_focus_view(NULL) is now forbidden and is no longer handled as
a special case to clear the focus. This was (at least to me) a
surprising behavior and caused trouble when working on another change.
- To maintain existing behavior, desktop_focus_topmost_mapped_view() now
explicitly clears the focus if there are no mapped views.
There should be no behavioral change here.
For views with a non-pixel size increment (e.g. X11 terminals), it's
helpful to subtract the base size of the window (typically including
menu bar, scrollbars, etc.) before computing the number of size
increments (e.g. cells/characters). This way, the displayed size will
exactly match the terminal grid (e.g. 80x25 or whatever).
wlr_box isn't really the best fit for size hints, so let's define a
struct view_size_hints and a nice view_get_size_hints() function,
wrapping view->impl->get_size_hints().
This also seems like a great opportunity to make view_adjust_size()
window-system-agnostic and eliminate xwayland_apply_size_hints().
...<command> argument (but still resolve tilde).
This makes it easier to write sh -c '' constructs without turning labwc
into a shell parser in order to expand environment variables, whilst
respecting single quotes and escaped characters as well as ignoring
subshells syntax like $(foo) and backticks.
Also, fix bug where buffer length+alloc get out-of-sync
Before this patch we were using the internal .enabled flag of the titlebar
tree node. This failed due to ssd_thickness() not having view->ssd assigned
when initially called. Instead of assigning view->ssd within ssd_create()
we just always use the view boolean flag directly. This fixes an issue
where a border-only view that has been snapped to an edge or region would
have a gap in the size of the titlebar on top after a Reconfigure.
Fixes#1083
When a view is destroyed (including override_redirect in the xwayland
case), the view_destroy() handler is called which checks for a currently
open A-Tab window switcher and causes an update there to remove the
destroying view from the list. Before view_destroy() is called, both
xwayland and xdg handlers reset the xdg_surface / xwayland_surface.
The window switcher update then creates a list of all windows which do
not have the 'skipWindowSwitcher' window rule property set. If there is
at least one 'matchOnce' window rule configured, this also tries to get
string properties of the destroying view which already had their
xdg_surface / xwayland_surface reset and thus run into an assert.
This patch fixes that so that the string_prop() handlers always return
an empty string in those cases rather than running into the assert.
For a more in-depth analyses and alternative solutions see the linked
issue.
Fixes#1082
Add -Dsvg=disabled to your meson setup/configure command to disable svg
buttons even if the correct version of librsvg is available.
Note that regardless of this patch and the value of the 'svg' variable,
the build will gracefully fall back to not using librsvg if the correct
version is not available.
Helped-by: @01micko
This allows to define keybinds as layout dependent. E.g. keybinds
only trigger if the configured key exists in the currently active
keyboard layout. The keybind will also only trigger on the physical
key that is mapped to the configured key in the active layout.
By default the new argument is false which means all keybinds by
default are layout agnostic. This optional argument can be used
to restore the earlier default behavior of having keys layout
dependent.
Before this patch, when moving a CSD client below a layershell surface -
like a panel that was configured with either the "top" or "overlay"
layers - we'd only send a matching release button event to the client but
not actually end the interactive move operation. That caused the drag to
continue even though the user already released the mouse button.
In comparison, SSD clients were not suffering from the same issue because
the initial mouse "down" event was not attached to any client surface and
thus it would not take the first early return because there was no surface
attached to the release event.
This patch fixes the issue by reordering the conditions where we return
early. It also ensures that when we finish the move, we still send the
release event to CSD clients.
Fixes: #1053
Reported-by: @DynamoFox (thanks)