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 backend, decoration and resize-logging switches were only used
while working on this, and undocumented ones should not stay:
- VOXEL_WINDOW_BACKEND: the backend is still chosen by WAYLAND_DISPLAY,
and GLFW is used when it is not set;
- VOXEL_DECORATIONS: own decorations are always enabled when the
compositor provides none;
- VOXEL_LOG_RESIZE: the resize statistics are removed together with the
counters they needed.
WaylandDecorations.cpp replaces WaylandBar.cpp: drawing moved to the
engine, the file only holds the decoration behaviour now.
Wayland support was missing a proper windowing layer: the GLFW backend
leaves the known platform gaps (cursor themes, window icon, window
position, fullscreen output selection).
The new backend talks to the compositor directly:
- xdg-shell, EGL, xkbcommon (keyboard, repeat, layout) instead of GLFW;
- cursors through wp_cursor_shape_manager_v1, so no cursor theme lookup
is required and no "standard cursor shape unavailable" errors appear;
- window icon and title are drawn by the engine itself, since Wayland
has no window icon protocol and GNOME provides no server-side
decorations;
- fullscreen requests the current output (set_fullscreen with NULL), so
the window no longer jumps to another monitor;
- interactive resize presents a cached frame scaled to the new size
while the pointer is down and refreshes the real frame when the drag
pauses, keeping the window glued to the cursor.
libdecor is not used: libdecor_frame_commit() redraws the whole
decoration and acks the configure in the same call, and mutter sends
200-330 configures per second during an interactive resize, so the
decoration was redrawn hundreds of times per second (measured: 2 s of
work per second, loop stalls up to 6 s). The decorations are drawn by
the engine instead, which measured 2.3 ms average configure-to-present
latency during a real drag.
GLFW stays the backend for X11 and Windows; VOXEL_WINDOW_BACKEND=x11
forces it on Wayland sessions.