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 native Wayland backend had no window controls: no title, no close
button, no way to move or resize the window, and the fullscreen toggle
could throw the window to another monitor. GNOME does not implement
zxdg_decoration_manager_v1, so there is nobody to draw a frame for us:
the backend now falls back to its own decorations when the compositor
offers no server side ones, and the engine draws the visible part.
The bar itself is drawn by the engine (WindowBar.cpp) through the usual
batch and font, so it uses the same assets as the rest of the UI and the
backend only owns the behaviour: hit zones, cursor shapes, click
interception and the xdg-shell requests. Its geometry follows the
desktop's button layout, read and subscribed through
xdg-desktop-portal over sd-bus (libsystemd is an optional dependency,
gsettings is only a startup fallback).
Controls behave like they do elsewhere:
- pressing anywhere on the bar starts a move once the pointer leaves a
5 px radius, so dragging works from the buttons as well;
- a button acts on release, only if the pointer stayed on it;
- a double click on the bar toggles maximize;
- the top edge and the top corners resize, the top 8 px of the sides,
the sides and the bottom are 8 px wide resize strips;
- right and middle clicks and the scroll wheel over the bar never reach
the game.
The in-game user interface is offset below the bar while menus keep the
whole window, so the translucent bar shows the menu background through
itself and never covers the HUD. The HUD lays its elements out against
the content height and the cursor is translated once, which fixes items
following the mouse one row above the pointer in game.
The window size is now written to the settings when the window is
resized in windowed mode and applied on the first configure, so the
window opens with the size it was left with, and leaving fullscreen or
borderless mode restores it instead of overwriting the settings with the
fullscreen size (an unconditional unmaximize made the compositor restore
the maximized geometry).
Measured: menu layout unchanged (706 bright pixels in the same place),
gui viewport 1123x751 in menus against 1123x721 in game, 1123x751 ->
2560x1080 -> 1123x751 round trip keeps the settings, a saved 1000x640
opens as 1000x640, no errors in the log.