Report the errors the display read loop can fail with instead of
dispatching events on a dead connection, and release exactly the keys the
user really holds: BaseInput::pressedKeys is never erased, so the previous
list sent key releases for keys that were never pressed.
The bar is the only owner of the pointer edges now, the fullscreen state
comes from the compositor, and the decorations are enabled once, with the
window geometry published again. The initialization failure paths destroy
their resources exactly once, the screen state is reset on teardown, the
clipboard write does not block the frame loop on a slow reader, and the
gsettings fallback is not retried after it failed.
The stretch blit of the last frame is gone: composeFrame() already paints
the cached content.
A review of the branch turned up a number of defects, gaps and leftovers;
this commit addresses all of them.
Defects:
- the shadow uniform array held seven entries while eight locations were
written, so the last one landed outside the object;
- CursorShape::LAST stayed in the middle of the enum after the new corner
shapes were appended, which made the GLFW cursor table read out of
bounds; the extra shapes are now mapped onto the ones GLFW knows, and
the table is only filled for those;
- GlStateGuard asked glIsEnabled for an attribute pname, so it always got
GL_INVALID_ENUM and never restored the vertex attribute arrays;
- the early returns in wayland_window_initialize left the global window
and input pointers dangling when falling back to GLFW;
- the icon textures were listed nowhere, so none of them ever loaded;
- a shader failure disabled the shadow after the surface had already been
sized for it, and VOXEL_DECORATIONS outlived the switch cleanup.
Behavior:
- the keyboard now releases every pressed key when it loses focus, and a
repeat rate of zero means no repeat;
- the fourth UTF-8 lead byte is decoded with the right mask, control
characters no longer reach text fields, and a vanished clipboard offer
clears the cached text;
- compositor side decorations disable ours again instead of leaving two
titles, the window destructor releases the rest of the state, and the
content inset is computed before the GUI acts so the HUD and the
container never disagree for a frame; the HUD clamps it;
- the window controls fall back to minimize, maximize and close, and the
icons are drawn from textures only.
Cleanups: one monotonic timer instead of three, one vertex shader shared
by both renderers with a link check, one button layout parser, the inset
rule moved into Screen, the scissor stack moved into the base Window
(about 110 duplicated lines), named shadow and evdev constants, trimmed
includes, a README note about the Wayland dependencies, and the long
lines introduced by this branch wrapped.
The bar used to be drawn by the Wayland backend with its own shader,
bitmap font and textures, straight into the engine's GL frame. That
leaked GL state (the batch caches bound textures, so the engine kept
sampling the backend texture and all text turned into solid white
rectangles) and it duplicated fonts and styling.
Now the backend only owns the behaviour: hit zones, cursor shapes,
click interception and the compositor requests (move, resize,
minimize, maximize/restore, close). The bar itself is drawn by the
engine in WindowBar.cpp through the regular Batch2D/Font path, so it
looks like the rest of the UI.
Window gained getTitle(), getDecorationHeight() and
getDecorationHoveredButton(); GLFW keeps the defaults, so X11 and
Windows are unaffected. The backend's decoration drawing (bitmap font,
shader, quad batches) is removed: WaylandBar.cpp went from 630 to 140
lines.
Fixes found while debugging:
- GlStateGuard was defined but never used after the file split, so the
stretched frame left its texture bound and broke text rendering after
a window mode change; it is now applied around the cache capture and
the stretched frame;
- takeScreenshot() now reads the front buffer and restores the read
buffer afterwards.
WaylandWindow.cpp kept the window class with all methods defined in
place, the decorations, the free event listeners and the initialization
in one file. Now:
- WaylandWindow.hpp: the class declaration;
- WaylandWindow.cpp: surface, EGL, resize and frame pacing;
- WaylandBar.cpp: the window decorations (bar, font, buttons, dragging,
edge resizing);
- WaylandListeners.cpp/.hpp: the free Wayland event handlers;
- WaylandInit.cpp: wayland_window_initialize.
No functional change.
WaylandWindow.cpp held the protocol bindings, the shared compositor
state, the input implementation, the window itself, the free event
listeners and the initialization code in one 2400-line file.
Moved out of it:
- WaylandCommon.hpp/.cpp: shared compositor state, the display event
loop, keysym mapping and the window logger;
- WaylandInput.hpp: the input implementation (keyboard, clipboard,
cursors, key repeat).
No functional change.