Prevent a use-after-free when closing a nested dwl with Ctrl+c.
It happened because cleanup() → input_method_relay_finish() frees
input_method_relay, and then closemon() → focusclient() →
input_method_relay_set_focus() uses relay->surface.
When focusing an unmanaged client (like dmenu) or a layer shell surface
(like wmenu) keep the focused border color of the regular client, but
still deactivate it. This is consistent with dwm and sway.
This was already done for unmanaged clients but not for layer shell
surfaces.
This is not perfect because you can press MODKEY+j/k or move the cursor
while a program like dmenu is focused and have 2 clients with focused
border color after closing dmenu. But this doesn't work well even in
sway where if you change focus while dmenu is open you can longer focus
it, and after closing a layer shell surface with on-demand keyboard
interactivity all toplevels have the focused border color, so this will
do for now.
Fixes https://codeberg.org/dwl/dwl/issues/1169
The c->isfloating check is needed to have the correct floating window
size with e.g. alacritty -o window.dimensions.columns=15
window.dimensions.lines=10.
If l is not initialized, accessing
l->layer_surface->current.keyboard_interactive causes a segmentation
fault. This was hard to see because c above was never initialized but
never caused a crash, and dwl also didn't crash building with ASan.
Also initialize c to be safe.
Fixes 4c54bd8.
Fixes https://codeberg.org/dwl/dwl/issues/1225.
This is used by lswt which lists toplevel ids and titles.
keyd-application-mapper will also support it hopefully.
This will also be needed to support screenshare of single windows
(https://codeberg.org/dwl/dwl/pulls/1157).
Co-authored-by: Zuki Air <zukirust@gmail.com>
xytonode() does not return the layer surface under the cursor because
pnode->data is always NULL. It was not noticed because it is not passed
the LayerSurface argument anywhere. But it is noticeable after
implementing layer shell on-demand keyboard interactivity because layer
shell surfaces are never focused by sloppyfocus.
Rather than figuring out how to fix it, just replace its implementation
with toplevel_from_wlr_surface() which works and also reduces the SLOC.
This allows single-source compilation and whole-program optimization using something like:
make CFLAGS='-flto -ffunction-sections -fdata-sections -Wl,--gc-sections'
Furthermore, move more compositor-agnostic utility functions/macros to util.h,
similar to the original dwm sources.
This is no longer needed as wlroots => 0.19 handles this internally via scene-level surface state tracking and
linux-drm-syncobj explicit sync.
The manual commit skip now causes the c->resize to be stuck on non-zero
state which leads to choppy resizing experience.
mapnotify() stores the client's scene tree in client_surface(c)->data;
checkidleinhibitor() later reads it back as a wlr_scene_tree and calls
wlr_scene_node_coords() on it. unmapnotify() frees the scene tree with
wlr_scene_node_destroy() but leaves surface->data dangling, so the next
arrange() -> checkidleinhibitor() dereferences freed memory and crashes
(SIGSEGV) whenever an idle inhibitor outlives the unmap.
Reset the pointer to NULL on unmap so the existing !tree guard handles it.
This change effectively reverts DWL to the prior development model, where development of DWL itself happens against the current wlroots release, and changes in anticipation of the next wlroots release are made on a separate branch.
Enables the protocol documented at
https://wayland.app/protocols/ext-data-control-v1
It is the upstreamed version of the old wlr_data_control.
It is used e.g. by mpv to read and write the clipboard.