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

@ -147,16 +147,18 @@ void WaylandWindow::updateButtonLayout() {
void WaylandWindow::updateBarGeometry() {
barButtons.clear();
const float width = static_cast<float>(size.x);
constexpr float pitch = BAR_BUTTON + BAR_GAP;
for (size_t i = 0; i < leftButtons.size(); i++) {
const float x = static_cast<float>(i) * BAR_BUTTON;
const float x = BAR_PADDING + static_cast<float>(i) * pitch;
if (x + BAR_BUTTON > width) {
break;
}
barButtons.push_back({leftButtons[i], x, BAR_BUTTON});
}
for (size_t i = 0; i < rightButtons.size(); i++) {
const float x = width -
static_cast<float>(rightButtons.size() - i) * BAR_BUTTON;
const float x = width - BAR_PADDING -
static_cast<float>(rightButtons.size() - i) * pitch +
BAR_GAP;
if (x < 0.0f) {
break;
}
@ -193,7 +195,8 @@ bool WaylandWindow::barVisible() const {
}
int WaylandWindow::barButtonAt(double x, double y) const {
if (!barVisible() || y < 0.0 || y >= BAR_HEIGHT) {
constexpr int top = (BAR_HEIGHT - BAR_BUTTON) / 2;
if (!barVisible() || y < top || y >= top + BAR_BUTTON) {
return -1;
}
for (size_t i = 0; i < barButtons.size(); i++) {
@ -232,21 +235,56 @@ CursorShape WaylandWindow::edgeCursor(uint32_t edges) {
const bool right = edges & XDG_TOPLEVEL_RESIZE_EDGE_RIGHT;
const bool top = edges & XDG_TOPLEVEL_RESIZE_EDGE_TOP;
const bool bottom = edges & XDG_TOPLEVEL_RESIZE_EDGE_BOTTOM;
if ((left && top) || (right && bottom)) {
return CursorShape::NWSE_RESIZE;
if (left && top) {
return CursorShape::NW_RESIZE;
}
if ((right && top) || (left && bottom)) {
return CursorShape::NESW_RESIZE;
if (right && top) {
return CursorShape::NE_RESIZE;
}
if (left || right) {
return CursorShape::EW_RESIZE;
if (left && bottom) {
return CursorShape::SW_RESIZE;
}
if (top || bottom) {
return CursorShape::NS_RESIZE;
if (right && bottom) {
return CursorShape::SE_RESIZE;
}
if (left) {
return CursorShape::W_RESIZE;
}
if (right) {
return CursorShape::E_RESIZE;
}
if (top) {
return CursorShape::N_RESIZE;
}
if (bottom) {
return CursorShape::S_RESIZE;
}
return CursorShape::ARROW;
}
uint32_t WaylandWindow::pointerEdges() const {
const int margin = marginSize();
uint32_t edges = 0;
if (margin > 0) {
const auto surface = surfaceSize();
const int edge = margin + RESIZE_GRAB_EXTRA;
if (pointerX < edge) {
edges |= XDG_TOPLEVEL_RESIZE_EDGE_LEFT;
} else if (pointerX >= surface.x - edge) {
edges |= XDG_TOPLEVEL_RESIZE_EDGE_RIGHT;
}
if (pointerY < edge) {
edges |= XDG_TOPLEVEL_RESIZE_EDGE_TOP;
} else if (pointerY >= surface.y - edge) {
edges |= XDG_TOPLEVEL_RESIZE_EDGE_BOTTOM;
}
}
if (edges == 0 && margin == 0) {
edges = barEdgeAt(contentX(pointerX), contentY(pointerY));
}
return edges;
}
bool WaylandWindow::handleBarMotion(double x, double y) {
pointerX = x;
pointerY = y;
@ -257,20 +295,22 @@ bool WaylandWindow::handleBarMotion(double x, double y) {
hoveredButton = -1;
xdg_toplevel_move(state.toplevel, state.seat, barPressSerial);
}
const uint32_t edges = barEdgeAt(x, y);
const uint32_t edges = pointerEdges();
if (edges != 0) {
hoveredButton = -1;
pointerInBar = false;
input.setOverrideCursor(edgeCursor(edges));
return true;
}
const bool inBar = barVisible() && y >= 0.0 && y < BAR_HEIGHT;
const double contentY = this->contentY(y);
const bool inBar = barVisible() && contentY >= 0.0 && contentY < BAR_HEIGHT;
if (inBar && !pointerInBar) {
lastLayoutCheck = 0.0;
}
pointerInBar = inBar;
if (inBar) {
hoveredButton = barDragging ? -1 : barButtonAt(x, y);
hoveredButton =
barDragging ? -1 : barButtonAt(contentX(x), contentY);
input.setOverrideCursor(
hoveredButton >= 0 ? CursorShape::POINTER : CursorShape::ARROW
);
@ -282,9 +322,9 @@ bool WaylandWindow::handleBarMotion(double x, double y) {
}
bool WaylandWindow::handleBarButton(uint32_t serial, int button, bool pressed) {
const double x = pointerX;
const double y = pointerY;
const uint32_t edges = barEdgeAt(x, y);
const double x = contentX(pointerX);
const double y = contentY(pointerY);
const uint32_t edges = pointerEdges();
const bool inBar = barVisible() && y >= 0.0 && y < BAR_HEIGHT;
if (button != 0) {
return inBar || edges != 0;
@ -345,8 +385,8 @@ bool WaylandWindow::handleBarButton(uint32_t serial, int button, bool pressed) {
}
bool WaylandWindow::handleBarScroll() const {
return (barVisible() && pointerY >= 0.0 && pointerY < BAR_HEIGHT) ||
barEdgeAt(pointerX, pointerY) != 0;
const double y = contentY(pointerY);
return (barVisible() && y >= 0.0 && y < BAR_HEIGHT) || pointerEdges() != 0;
}
void WaylandWindow::onPointerLeave() {

View file

@ -120,33 +120,46 @@ wayland_window_initialize(DisplaySettings* settings, std::string title) {
eglBindAPI(EGL_OPENGL_API);
EGLint samples = settings->samples.get();
const EGLint requestedSamples = samples > 0 ? samples : 0;
EGLConfig config = nullptr;
EGLint configCount = 0;
const EGLint configAttributes[] {
EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT,
EGL_RED_SIZE, 8, EGL_GREEN_SIZE, 8, EGL_BLUE_SIZE, 8,
EGL_ALPHA_SIZE, 0, EGL_DEPTH_SIZE, 24, EGL_STENCIL_SIZE, 8,
EGL_SAMPLES, samples > 0 ? samples : 0,
EGL_NONE
};
eglChooseConfig(window->eglDisplay, configAttributes, &config, 1, &configCount);
if (samples > 0 && configCount == 0) {
waylandLogger.warning() << "multisampling is not available";
const EGLint fallbackAttributes[] {
const auto chooseConfig = [&] (EGLint alpha, EGLint sampleCount) {
const EGLint attributes[] {
EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT,
EGL_RED_SIZE, 8, EGL_GREEN_SIZE, 8, EGL_BLUE_SIZE, 8,
EGL_ALPHA_SIZE, 0, EGL_DEPTH_SIZE, 24, EGL_STENCIL_SIZE, 8,
EGL_ALPHA_SIZE, alpha, EGL_DEPTH_SIZE, 24, EGL_STENCIL_SIZE, 8,
EGL_SAMPLES, sampleCount,
EGL_NONE
};
config = nullptr;
configCount = 0;
eglChooseConfig(
window->eglDisplay, fallbackAttributes, &config, 1, &configCount
window->eglDisplay, attributes, &config, 1, &configCount
);
}
if (configCount == 0) {
waylandLogger.error() << "no suitable EGL config";
return {nullptr, nullptr};
if (configCount == 0) {
return false;
}
EGLint value = 0;
eglGetConfigAttrib(
window->eglDisplay, config, EGL_ALPHA_SIZE, &value
);
window->shadowEnabled = value >= 8;
return true;
};
if (!chooseConfig(8, requestedSamples)) {
if (requestedSamples > 0) {
waylandLogger.warning() << "multisampling is not available";
}
if (!chooseConfig(8, 0)) {
waylandLogger.warning()
<< "no EGL config with alpha, the drop shadow is off";
if (!chooseConfig(0, requestedSamples) && !chooseConfig(0, 0)) {
waylandLogger.error() << "no suitable EGL config";
return {nullptr, nullptr};
}
window->shadowEnabled = false;
}
}
const EGLint contextAttributes[] {
@ -157,8 +170,9 @@ wayland_window_initialize(DisplaySettings* settings, std::string title) {
window->eglContext = eglCreateContext(
window->eglDisplay, config, EGL_NO_CONTEXT, contextAttributes
);
const auto surfaceSize = window->surfaceSize();
window->eglWindow = wl_egl_window_create(
state.surface, window->getSize().x, window->getSize().y
state.surface, surfaceSize.x, surfaceSize.y
);
window->eglSurface = eglCreateWindowSurface(
window->eglDisplay, config,
@ -184,6 +198,7 @@ wayland_window_initialize(DisplaySettings* settings, std::string title) {
}
window->initStretchRenderer();
window->initShadowRenderer();
glViewport(0, 0, window->getSize().x, window->getSize().y);
glClearColor(0.0f, 0.0f, 0.0f, 1);
glEnable(GL_BLEND);

View file

@ -217,6 +217,22 @@ private:
return WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_NESW_RESIZE;
case CursorShape::ALL_RESIZE:
return WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_ALL_RESIZE;
case CursorShape::N_RESIZE:
return WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_N_RESIZE;
case CursorShape::S_RESIZE:
return WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_S_RESIZE;
case CursorShape::E_RESIZE:
return WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_E_RESIZE;
case CursorShape::W_RESIZE:
return WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_W_RESIZE;
case CursorShape::NE_RESIZE:
return WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_NE_RESIZE;
case CursorShape::NW_RESIZE:
return WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_NW_RESIZE;
case CursorShape::SE_RESIZE:
return WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_SE_RESIZE;
case CursorShape::SW_RESIZE:
return WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_SW_RESIZE;
case CursorShape::NOT_ALLOWED:
return WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_NOT_ALLOWED;
}

View file

@ -15,7 +15,9 @@ static void pointer_enter(
return;
}
if (input) {
input->setCursorPosition(x, y);
input->setCursorPosition(
window ? window->contentX(x) : x, window ? window->contentY(y) : y
);
if (state.entered) {
input->applyCursor();
}
@ -39,7 +41,9 @@ static void pointer_motion(
return;
}
if (input) {
input->setCursorPosition(x, y);
input->setCursorPosition(
window ? window->contentX(x) : x, window ? window->contentY(y) : y
);
input->refreshWindow();
}
}

View file

@ -45,6 +45,9 @@ WaylandWindow::~WaylandWindow() {
if (stretchProgram) {
glDeleteProgram(stretchProgram);
}
if (shadowProgram) {
glDeleteProgram(shadowProgram);
}
if (stretchVbo) {
glDeleteBuffers(1, &stretchVbo);
}
@ -96,14 +99,21 @@ void WaylandWindow::swapBuffers() {
if (renderPending) {
cacheContent();
renderPending = false;
} else {
} else if (marginSize() == 0) {
drawStretched();
}
} else {
} else if (frameRendered) {
cacheContent();
}
frameRendered = false;
composeFrame();
requestFrame();
eglSwapBuffers(eglDisplay, eglSurface);
if (sizeChanged) {
sizeChanged = false;
composeFrame();
eglSwapBuffers(eglDisplay, eglSurface);
}
resetScissor();
frameDone = false;
presentPending = false;
@ -119,7 +129,7 @@ void WaylandWindow::swapBuffers() {
1.0 / 30.0
);
}
}
}
lastPresent = current;
nextFrameTime = current + frameInterval;
lastSwapEnd = now();
@ -160,7 +170,11 @@ bool WaylandWindow::isIconified() const {
}
bool WaylandWindow::isFrameRequired() const {
return !resizing || renderPending;
const bool required = !resizing || renderPending;
if (required) {
frameRendered = true;
}
return required;
}
bool WaylandWindow::isShouldClose() const {
@ -234,19 +248,47 @@ void WaylandWindow::setMaximized(bool enabled) {
}
}
int WaylandWindow::marginSize() const {
if (!barEnabled || !shadowEnabled) {
return 0;
}
if (fullscreen || maximized || Window::mode != WindowMode::WINDOWED) {
return 0;
}
return SHADOW_MARGIN;
}
glm::ivec2 WaylandWindow::surfaceSize() const {
const int margin = marginSize() * 2;
return {size.x + margin, size.y + margin};
}
void WaylandWindow::updateWindowGeometry() {
if (state.xdgSurface == nullptr) {
return;
}
const int margin = marginSize();
xdg_surface_set_window_geometry(
state.xdgSurface, margin, margin, size.x, size.y
);
}
void WaylandWindow::resize(int width, int height) {
if (width <= 0 || height <= 0) {
return;
}
if (size.x != width || size.y != height) {
markResizing();
sizeChanged = true;
}
presentPending = true;
size = {width, height};
if (eglWindow) {
wl_egl_window_resize(eglWindow, width, height, 0, 0);
const auto surface = surfaceSize();
wl_egl_window_resize(eglWindow, surface.x, surface.y, 0, 0);
}
glViewport(0, 0, width, height);
size = {width, height};
updateWindowGeometry();
if (Window::mode == WindowMode::WINDOWED && !maximized) {
settings->width.set(width);
settings->height.set(height);
@ -281,11 +323,12 @@ void WaylandWindow::applyConfigure() {
maximized = stateMaximized;
suspended = stateSuspended;
if (pendingWidth > 0 && pendingHeight > 0) {
if (!configured && Window::mode == WindowMode::WINDOWED && !maximized &&
initialWidth > 0 && initialHeight > 0) {
if (!initialSizeApplied && Window::mode == WindowMode::WINDOWED &&
!maximized && initialWidth > 0 && initialHeight > 0) {
pendingWidth = initialWidth;
pendingHeight = initialHeight;
}
initialSizeApplied = true;
resize(pendingWidth, pendingHeight);
}
if (stateActivated && !activated) {
@ -358,9 +401,18 @@ std::unique_ptr<ImageData> WaylandWindow::takeScreenshot() {
GLint readBuffer = 0;
glGetIntegerv(GL_READ_BUFFER, &readBuffer);
glReadBuffer(GL_FRONT);
const int margin = marginSize();
auto data = std::make_unique<ubyte[]>(size.x * size.y * 3);
glPixelStorei(GL_PACK_ALIGNMENT, 1);
glReadPixels(0, 0, size.x, size.y, GL_RGB, GL_UNSIGNED_BYTE, data.get());
glReadPixels(
margin,
margin,
size.x,
size.y,
GL_RGB,
GL_UNSIGNED_BYTE,
data.get()
);
glReadBuffer(static_cast<GLenum>(readBuffer));
return std::make_unique<ImageData>(
ImageFormat::RGB888, size.x, size.y, data.release()
@ -416,6 +468,174 @@ void WaylandWindow::initStretchRenderer() {
glGenTextures(1, &cacheTexture);
}
void WaylandWindow::initShadowRenderer() {
if (!shadowEnabled) {
return;
}
static const char* vertexSource =
"#version 330 core\n"
"layout(location = 0) in vec2 aPos;\n"
"out vec2 vUV;\n"
"void main() {\n"
" vUV = aPos * 0.5 + 0.5;\n"
" gl_Position = vec4(aPos, 0.0, 1.0);\n"
"}\n";
static const char* fragmentSource =
"#version 330 core\n"
"in vec2 vUV;\n"
"out vec4 color;\n"
"uniform vec2 uSurface;\n"
"uniform vec4 uRect;\n"
"uniform float uBlur;\n"
"uniform float uStrength;\n"
"uniform float uOffset;\n"
"uniform float uSpread;\n"
"uniform float uBorder;\n"
"uniform float uRadius;\n"
"float erfcApprox(float x) {\n"
" float t = 1.0 / (1.0 + 0.5 * abs(x));\n"
" float tau = t * exp(-x * x - 1.26551223 +\n"
" t * (1.00002368 +\n"
" t * (0.37409196 +\n"
" t * (0.09678418 +\n"
" t * (-0.18628806 +\n"
" t * (0.27886807 +\n"
" t * (-1.13520398 +\n"
" t * (1.48851587 +\n"
" t * (-0.82215223 +\n"
" t * 0.17087277)))))))));\n"
" return x >= 0.0 ? tau : 2.0 - tau;\n"
"}\n"
"float boxDistance(vec2 p, vec2 center, vec2 halfSize, float radius) {\n"
" vec2 q = abs(p - center) - (halfSize - vec2(radius));\n"
" return length(max(q, 0.0)) + min(max(q.x, q.y), 0.0) - radius;\n"
"}\n"
"void main() {\n"
" vec2 p = vUV * uSurface;\n"
" vec2 halfSize = uRect.zw * 0.5;\n"
" vec2 center = uRect.xy + halfSize;\n"
" float shadow = boxDistance(\n"
" p, center + vec2(0.0, -uOffset), halfSize + uSpread,\n"
" uRadius + uSpread\n"
" );\n"
" float sigma = max(uBlur * 0.5, 0.001);\n"
" float alpha = uStrength * 0.5 * erfcApprox(shadow / (sigma * 1.41421356));\n"
" float side = boxDistance(p, center, halfSize, uRadius);\n"
" float border = side > 0.0 && side <= 1.0 ? uBorder : 0.0;\n"
" color = vec4(0.0, 0.0, 0.0, max(alpha, border));\n"
"}\n";
shadowProgram = compile_program(vertexSource, fragmentSource);
GLint linked = 0;
glGetProgramiv(shadowProgram, GL_LINK_STATUS, &linked);
if (shadowProgram == 0 || linked == 0) {
char log[1024] = {};
glGetProgramInfoLog(shadowProgram, sizeof(log), nullptr, log);
for (char* c = log; *c != '\0'; c++) {
if (*c == '\n') {
*c = ' ';
}
}
waylandLogger.error() << "failed to build the shadow shader: " << log;
shadowEnabled = false;
return;
}
const char* names[] {
"uSurface", "uRect", "uBlur", "uStrength", "uOffset", "uSpread",
"uBorder", "uRadius", nullptr
};
for (int i = 0; names[i] != nullptr; i++) {
shadowUniforms[i] = glGetUniformLocation(shadowProgram, names[i]);
}
}
void WaylandWindow::drawShadow() {
const int margin = marginSize();
if (margin <= 0 || shadowProgram == 0) {
return;
}
const auto surface = surfaceSize();
glViewport(0, 0, surface.x, surface.y);
glEnable(GL_BLEND);
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
glDisable(GL_DEPTH_TEST);
glDisable(GL_CULL_FACE);
glDisable(GL_SCISSOR_TEST);
glUseProgram(shadowProgram);
glUniform2f(
shadowUniforms[0],
static_cast<float>(surface.x),
static_cast<float>(surface.y)
);
glUniform4f(
shadowUniforms[1],
static_cast<float>(margin),
static_cast<float>(margin),
static_cast<float>(size.x),
static_cast<float>(size.y)
);
glUniform1f(shadowUniforms[2], 7.0f);
glUniform1f(shadowUniforms[3], activated ? 0.5f : 0.3f);
glUniform1f(shadowUniforms[4], 0.0f);
glUniform1f(shadowUniforms[5], 1.0f);
glUniform1f(shadowUniforms[6], activated ? 0.1f : 0.05f);
glUniform1f(shadowUniforms[7], 0.0f);
glBindVertexArray(stretchVao);
glDrawArrays(GL_TRIANGLES, 0, 3);
glBindVertexArray(0);
glUseProgram(0);
}
void WaylandWindow::makeContentOpaque(int x, int y, int width, int height) {
glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_TRUE);
glEnable(GL_SCISSOR_TEST);
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
glScissor(x, y, width, height);
glClear(GL_COLOR_BUFFER_BIT);
glDisable(GL_SCISSOR_TEST);
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
}
void WaylandWindow::composeFrame() {
const int margin = marginSize();
GlStateGuard state;
glBindFramebuffer(GL_FRAMEBUFFER, 0);
if (margin <= 0) {
makeContentOpaque(0, 0, size.x, size.y);
return;
}
const auto surface = surfaceSize();
glViewport(0, 0, surface.x, surface.y);
glDisable(GL_SCISSOR_TEST);
glDisable(GL_BLEND);
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glClear(GL_COLOR_BUFFER_BIT);
drawShadow();
if (stretchProgram == 0 || cacheWidth == 0) {
glEnable(GL_SCISSOR_TEST);
glScissor(margin, margin, size.x, size.y);
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
return;
}
glViewport(margin, margin, size.x, size.y);
glDisable(GL_DEPTH_TEST);
glDisable(GL_BLEND);
glDisable(GL_CULL_FACE);
glDisable(GL_SCISSOR_TEST);
glUseProgram(stretchProgram);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, cacheTexture);
glUniform1i(glGetUniformLocation(stretchProgram, "uTexture"), 0);
glBindVertexArray(stretchVao);
glDrawArrays(GL_TRIANGLES, 0, 3);
glBindVertexArray(0);
glUseProgram(0);
makeContentOpaque(margin, margin, size.x, size.y);
}
void WaylandWindow::resizeCache(int width, int height) {
if (cacheWidth == width && cacheHeight == height) {
return;

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;