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 engine-drawn title bar grew to 48 px with 24x24 window controls,
12 px away from the edge and from each other, all sharing one hover
highlight. The controls use textures now (gui/cross, gui/minimize_w,
gui/maximize_w and gui/restore_w when maximized) with the vector icons
kept as a fallback, and the title is centred in the bar, clamped to the
free space between the button groups.
The bar now sits inside invisible margins that carry a drop shadow, so
the window is resizable from outside the visible frame: the surface is
content plus twice SHADOW_MARGIN and xdg_surface.set_window_geometry
tells the compositor which part is the window. The shadow follows
Adwaita's window shadow: a Gaussian blur of 7 px (sigma 3.5) expanded by
1 px, rgba(0,0,0,0.5) focused and 0.3 in the backdrop, plus a 1 px
hairline, symmetric on all four sides - a 16 px wide frame would show a
fatter tail than the reference. Margins exist only while the window is
decorated by us and not maximized or fullscreen.
The engine composes the frame itself: it renders exactly as before, then
the backend copies the frame into a texture, clears the surface, draws
the shadow and puts the content in place with alpha forced to 1, which
keeps the frame opaque without touching a single render pass. Only
frames the engine actually drew are cached, and the EGL window is
resized before its surface size is asked for, so no frame is composed
from a buffer the compositor just replaced - that was the one frame
blink after a resize.
Resize cursors match GNOME: directional shapes for edges and corners
(w/e/n/s/ne/nw/se/sw) instead of the double-headed diagonals, with the
extra CursorShape values appended so the existing GLFW indices stay.
Measured: window 1123x751 opens as saved, fullscreen round trip returns
the same size with the settings untouched, the shadow alpha profile is
0.20/0.10/0.03 at 1/4/7 px from the edge against Adwaita's 0.21/0.095/
0.055, all four sides equal, menu layout baseline unchanged (706),
no errors in the log.
Both backends asked for an alpha channel (GLFW defaults to 8 alpha
bits, the Wayland EGL config requested 8), so everything the engine
draws with alpha - the UI panels, the water post effect - lowered the
window's own alpha and the compositor blended the desktop through it.
Visible on wine/Proton, where the whole window is composited.
Both now ask for an opaque framebuffer: GLFW_ALPHA_BITS 0, and
EGL_ALPHA_SIZE 0 with a fallback to an alpha config if the driver
provides none. Checked the result through the back buffer attachment:
alpha size is 0 on Wayland and on X11.
getClipboardText() used to open a pipe, ask the selection owner for
the text and poll it with a 500 ms deadline, so every paste blocked the
UI thread (TextBox calls it directly) and a slow owner meant a visible
hang.
The selection is now fetched in the background: when the selection
changes, the backend requests the text into a non-blocking pipe and
getClipboardText() only returns the buffer, which the event loop fills
in as the data arrives. Pasting no longer blocks, and a source that
never answers simply leaves the previous buffer in place.
Also clears the advertised MIME list when a new selection offer
arrives, so a request is never made with MIME types of a previous
owner.
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.