Give the Wayland window an Adwaita-like frame

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.
This commit is contained in:
alexei-zebra 2026-10-09 22:27:18 +03:00
parent 6c2192b5d8
commit c269d6efb3
No known key found for this signature in database
GPG key ID: D19D450AC3D9A80E
11 changed files with 434 additions and 58 deletions

View file

@ -55,6 +55,9 @@ double barPressX = 0.0;
double barPressY = 0.0;
uint32_t barPressSerial = 0;
bool barPressed = false;
bool initialSizeApplied = false;
mutable bool frameRendered = false;
bool sizeChanged = false;
bool barDragging = false;
int barPressedButton = -1;
int initialWidth = 0;
@ -113,9 +116,40 @@ glm::vec4 scissorArea {};
static constexpr int BAR_HEIGHT = 30;
static constexpr int BAR_BUTTON = 30;
static constexpr int BAR_HEIGHT = 48;
static constexpr int BAR_BUTTON = 24;
static constexpr int BAR_PADDING = 12;
static constexpr int BAR_GAP = 12;
static constexpr int BAR_EDGE = 8;
static constexpr int SHADOW_MARGIN = 10;
static constexpr int RESIZE_GRAB_EXTRA = 2;
bool shadowEnabled = false;
GLuint shadowProgram = 0;
GLint shadowUniforms[7] {};
int marginSize() const;
double contentX(double x) const {
return x - marginSize();
}
double contentY(double y) const {
return y - marginSize();
}
glm::ivec2 surfaceSize() const;
void updateWindowGeometry();
void initShadowRenderer();
void drawShadow();
void composeFrame();
void makeContentOpaque(int x, int y, int width, int height);
int decorationOffset() const {
return barVisible() ? BAR_HEIGHT : 0;
@ -152,6 +186,7 @@ glm::vec4 scissorArea {};
int barButtonAt(double x, double y) const;
uint32_t barEdgeAt(double x, double y) const;
static CursorShape edgeCursor(uint32_t edges);
uint32_t pointerEdges() const;
bool handleBarMotion(double x, double y);
bool handleBarButton(uint32_t serial, int button, bool pressed);
bool handleBarScroll() const;