- Store a pointer to the `struct view` in `struct ssd`
- Pass `struct ssd *` instead of `struct view *` to ssd functions
- Add `ssd_get_margin()` convenience function
Add xdg_surface_from_view() + xwayland_surface_from_view() accessors
that assert() the view is of the expected type before returning.
Fix a real bug in xdg.c parent_of() that dereferenced
`view->xdg_surface->toplevel` without first checking `view->type`.
The goal of the new accessors is to catch similar bugs in future.
IMHO it encourages better design (by making dependencies more obvious)
to have source file/header file pairs like view.c/view.h, rather than a
monolithic header like labwc.h with everything in it.
I don't think we need to break up all of labwc.h at once, but maybe we
can start pulling it apart bit by bit as it's convenient.
Also:
- Move "struct border" to ssd.h so that view.h can use it without pulling
in all of labwc.h.
- Add a missing required #include within scaled_font_buffer.h (forward
declaration of "struct font" is not enough).
Currently, snapping to a screen edge and then snapping to maximize
results in both the natural_geometry and tiled state of the view
getting messed up. After unmaximize, the view ends up in a weird
state (tiled location but natural/untiled size).
There are also a couple of sketchy things going on in the code:
- interactive_begin() pokes its own values into view->natural_geometry
to force view_maximize() to set a particular geometry.
- interactive_end() "fixes" view->natural_geometry after calling
view_maximize() to save the original geometry from the start of the
interactive move/resize.
To fix all this:
- Adjust/expand the API of view.c so that the interactive.c can
avoid this "back door" of overwriting view->natural_geometry
directly.
- Save the natural geometry and the tiled state of the view in
interactive_begin() when starting to move the view. When done,
interactive_end() will update the tiled state if appropriate but
*not* overwrite the natural geometry.
map() in xwayland.c called ssd_create() but did not call
view_apply_maximized_geometry() afterward, resulting in the
decorations being displayed off-screen.
Rather than calling view_apply_maximized_geometry() in more places,
let's reuse the existing call in view_set_decorations(), and extend
ssd_update_geometry() to call ssd_create() when needed.
At least for XWayland surfaces, handle_commit() is not always
called after map(), and as a result, the scene-graph node is never
positioned.
Not sure 100% if the same can occur with XDG surfaces, but the
extra view_moved() call should be harmless, so add it there too
for consistency.
For a move-only client configure request, treat it similarly to
view_move() by updating the scene-graph immediately, rather than waiting
for handle_commit(). Move-and-resize requests are handled the same as
before.
This (mostly?) fixes the glitchiness that was noticeable when dragging
an undecorated XWayland window (e.g. Audacious in Winamp mode).
Also:
- Reduce some code duplication in handle_request_configure() by
simply calling configure(), as suggested by @johanmalm in #428.
- Factor out common logic after a move and/or resize into view_moved().
...on first map so that view->unmaximized_geometry is known even if an
xdg-shell application started in maximized mode.
Fixes issue #305
Reported-by: @01micko
Consolidates all of the view destruction code for xwl + xdg into one function.
Fixes several notable bugs along the way:
- Fixes a crash when alt tabbing when a selected view gets destroyed.
- Fixes the OSD not updating to reflect a view has been destroyed.
Commit 08c537e ("xwayland: Honor size increments from
WM_SIZE_HINTS") adjusted only the window width/height according
to the size hints. If resizing from the top or left edge of the
window, we also need to adjust the window position to keep the
bottom or right edge from jumping around.
Support identification of wlr_scene_node role to enable simplification
of codebase including the avoidance of iterating over lists of
layer-surface, menuitems, and so on.
Use node-descriptors for xdg toplevels and popups
Handlers for the "destroy" signal need to unregister themselves from the
signal (using wl_list_remove()) before invoking free().
Invalid write of size 8
at 0x487DF27: wl_list_remove (in /usr/lib/libwayland-server.so.0.20.0)
by 0x4906FF0: wlr_signal_emit_safe (signal.c:32)
by 0x48EA304: reset_xdg_surface (wlr_xdg_surface.c:430)
by 0x48EA3D6: UnknownInlinedFun (wlr_xdg_surface.c:464)
by 0x48EA3D6: xdg_surface_handle_resource_destroy (wlr_xdg_surface.c:282)
by 0x4877899: ??? (in /usr/lib/libwayland-server.so.0.20.0)
by 0x487DEBF: ??? (in /usr/lib/libwayland-server.so.0.20.0)
by 0x487E3DF: ??? (in /usr/lib/libwayland-server.so.0.20.0)
by 0x487830D: wl_client_destroy (in /usr/lib/libwayland-server.so.0.20.0)
by 0x48783F6: ??? (in /usr/lib/libwayland-server.so.0.20.0)
by 0x487B1C9: wl_event_loop_dispatch (in /usr/lib/libwayland-server.so.0.20.0)
by 0x4878D36: wl_display_run (in /usr/lib/libwayland-server.so.0.20.0)
by 0x110DAC: main (main.c:81)
Address 0xc3213d8 is 424 bytes inside a block of size 704 free'd
at 0x484118B: free (vg_replace_malloc.c:755)
by 0x4906FDD: wlr_signal_emit_safe (signal.c:29)
by 0x48EA304: reset_xdg_surface (wlr_xdg_surface.c:430)
by 0x48EA3D6: UnknownInlinedFun (wlr_xdg_surface.c:464)
by 0x48EA3D6: xdg_surface_handle_resource_destroy (wlr_xdg_surface.c:282)
by 0x4877899: ??? (in /usr/lib/libwayland-server.so.0.20.0)
by 0x487DEBF: ??? (in /usr/lib/libwayland-server.so.0.20.0)
by 0x487E3DF: ??? (in /usr/lib/libwayland-server.so.0.20.0)
by 0x487830D: wl_client_destroy (in /usr/lib/libwayland-server.so.0.20.0)
by 0x48783F6: ??? (in /usr/lib/libwayland-server.so.0.20.0)
by 0x487B1C9: wl_event_loop_dispatch (in /usr/lib/libwayland-server.so.0.20.0)
by 0x4878D36: wl_display_run (in /usr/lib/libwayland-server.so.0.20.0)
by 0x110DAC: main (main.c:81)
Block was alloc'd at
at 0x48435FF: calloc (vg_replace_malloc.c:1117)
by 0x113E22: xdg_surface_new (xdg.c:401)
by 0x4906FDD: wlr_signal_emit_safe (signal.c:29)
by 0x48EABE7: handle_xdg_surface_commit (wlr_xdg_surface.c:331)
by 0x4908FE7: surface_commit_state (wlr_surface.c:457)
by 0x524DD49: ??? (in /usr/lib/libffi.so.8.1.0)
by 0x524D266: ??? (in /usr/lib/libffi.so.8.1.0)
by 0x487D322: ??? (in /usr/lib/libwayland-server.so.0.20.0)
by 0x48785CB: ??? (in /usr/lib/libwayland-server.so.0.20.0)
by 0x487B1C9: wl_event_loop_dispatch (in /usr/lib/libwayland-server.so.0.20.0)
by 0x4878D36: wl_display_run (in /usr/lib/libwayland-server.so.0.20.0)
by 0x110DAC: main (main.c:81)
Invalid write of size 8
at 0x487DF27: wl_list_remove (in /usr/lib/libwayland-server.so.0.20.0)
by 0x4906FF0: wlr_signal_emit_safe (signal.c:32)
by 0x48F5529: UnknownInlinedFun (wlr_input_device.c:34)
by 0x48F5529: wlr_input_device_destroy (wlr_input_device.c:29)
by 0x48CE4B5: backend_destroy.part.0.lto_priv.0 (backend.c:148)
by 0x48D2D55: multi_backend_destroy (backend.c:59)
by 0x48788FE: wl_display_destroy (in /usr/lib/libwayland-server.so.0.20.0)
by 0x110E71: UnknownInlinedFun (server.c:406)
by 0x110E71: main (main.c:83)
Address 0xc466568 is 24 bytes inside a block of size 56 free'd
at 0x484118B: free (vg_replace_malloc.c:755)
by 0x4906FDD: wlr_signal_emit_safe (signal.c:29)
by 0x48F5529: UnknownInlinedFun (wlr_input_device.c:34)
by 0x48F5529: wlr_input_device_destroy (wlr_input_device.c:29)
by 0x48CE4B5: backend_destroy.part.0.lto_priv.0 (backend.c:148)
by 0x48D2D55: multi_backend_destroy (backend.c:59)
by 0x48788FE: wl_display_destroy (in /usr/lib/libwayland-server.so.0.20.0)
by 0x110E71: UnknownInlinedFun (server.c:406)
by 0x110E71: main (main.c:83)
Block was alloc'd at
at 0x48435FF: calloc (vg_replace_malloc.c:1117)
by 0x11590F: new_input_notify (seat.c:137)
by 0x4906FDD: wlr_signal_emit_safe (signal.c:29)
by 0x4906FDD: wlr_signal_emit_safe (signal.c:29)
by 0x48CDCEE: UnknownInlinedFun (events.c:109)
by 0x48CDCEE: UnknownInlinedFun (events.c:242)
by 0x48CDCEE: UnknownInlinedFun (backend.c:58)
by 0x48CDCEE: handle_libinput_readable (backend.c:48)
by 0x48CE1BE: backend_start.lto_priv.0 (backend.c:114)
by 0x48D2CE5: multi_backend_start (backend.c:33)
by 0x110C45: UnknownInlinedFun (server.c:375)
by 0x110C45: main (main.c:68)
e.g., open an editor from a terminal, minimize it, then hit ^C in the terminal
simply don't unmap xdg or xwayland views if they are not currently marked as mapped
When a window title changed dynamically (for example when running
"cd" within an xfce4-terminal), the titlebar did not immediately
update to show the new title. (The titlebar would update as soon
as the mouse cursor moved.)
...and replace with a local MAX macro, because:
- They contain a ({}) construct which is a GNU extension and that's
against Drew's coding style
- min() is not used anyway
- MAX() clashes with cairo's macro, so best to not add this in labwc.h