diff --git a/glfw/wl_init.c b/glfw/wl_init.c index 010ce9e24..62f59a396 100644 --- a/glfw/wl_init.c +++ b/glfw/wl_init.c @@ -202,27 +202,27 @@ static void pointerHandleMotion(void* data UNUSED, _glfw.wl.cursorPreviousShape = GLFW_INVALID_CURSOR; return; case topDecoration: - if (y < _GLFW_DECORATION_WIDTH) + if (y < window->wl.decoration_metrics.width) cursorShape = GLFW_VRESIZE_CURSOR; else cursorShape = GLFW_ARROW_CURSOR; break; case leftDecoration: - if (y < _GLFW_DECORATION_WIDTH) + if (y < window->wl.decoration_metrics.width) cursorShape = GLFW_NW_RESIZE_CURSOR; else cursorShape = GLFW_HRESIZE_CURSOR; break; case rightDecoration: - if (y < _GLFW_DECORATION_WIDTH) + if (y < window->wl.decoration_metrics.width) cursorShape = GLFW_NE_RESIZE_CURSOR; else cursorShape = GLFW_HRESIZE_CURSOR; break; case bottomDecoration: - if (x < _GLFW_DECORATION_WIDTH) + if (x < window->wl.decoration_metrics.width) cursorShape = GLFW_SW_RESIZE_CURSOR; - else if (x > window->wl.width + _GLFW_DECORATION_WIDTH) + else if (x > window->wl.width + window->wl.decoration_metrics.width) cursorShape = GLFW_SE_RESIZE_CURSOR; else cursorShape = GLFW_VRESIZE_CURSOR; @@ -254,7 +254,7 @@ static void pointerHandleButton(void* data UNUSED, case mainWindow: break; case topDecoration: - if (y < _GLFW_DECORATION_WIDTH) + if (y < window->wl.decoration_metrics.width) edges = XDG_TOPLEVEL_RESIZE_EDGE_TOP; else { @@ -263,21 +263,21 @@ static void pointerHandleButton(void* data UNUSED, } break; case leftDecoration: - if (y < _GLFW_DECORATION_WIDTH) + if (y < window->wl.decoration_metrics.width) edges = XDG_TOPLEVEL_RESIZE_EDGE_TOP_LEFT; else edges = XDG_TOPLEVEL_RESIZE_EDGE_LEFT; break; case rightDecoration: - if (y < _GLFW_DECORATION_WIDTH) + if (y < window->wl.decoration_metrics.width) edges = XDG_TOPLEVEL_RESIZE_EDGE_TOP_RIGHT; else edges = XDG_TOPLEVEL_RESIZE_EDGE_RIGHT; break; case bottomDecoration: - if (x < _GLFW_DECORATION_WIDTH) + if (x < window->wl.decoration_metrics.width) edges = XDG_TOPLEVEL_RESIZE_EDGE_BOTTOM_LEFT; - else if (x > window->wl.width + _GLFW_DECORATION_WIDTH) + else if (x > window->wl.width + window->wl.decoration_metrics.width) edges = XDG_TOPLEVEL_RESIZE_EDGE_BOTTOM_RIGHT; else edges = XDG_TOPLEVEL_RESIZE_EDGE_BOTTOM; @@ -295,7 +295,7 @@ static void pointerHandleButton(void* data UNUSED, { if (window->wl.decorations.focus != mainWindow && window->wl.xdg.toplevel) { - xdg_toplevel_show_window_menu(window->wl.xdg.toplevel, _glfw.wl.seat, serial, (int32_t)x, (int32_t)y - _GLFW_DECORATION_TOP); + xdg_toplevel_show_window_menu(window->wl.xdg.toplevel, _glfw.wl.seat, serial, (int32_t)x, (int32_t)y - window->wl.decoration_metrics.top); return; } } diff --git a/glfw/wl_platform.h b/glfw/wl_platform.h index 82b438667..1f37cb0c9 100644 --- a/glfw/wl_platform.h +++ b/glfw/wl_platform.h @@ -89,11 +89,6 @@ typedef void (* PFN_wl_egl_window_resize)(struct wl_egl_window*, int, int, int, #define wl_egl_window_destroy _glfw.wl.egl.window_destroy #define wl_egl_window_resize _glfw.wl.egl.window_resize -#define _GLFW_DECORATION_WIDTH 4 -#define _GLFW_DECORATION_TOP 24 -#define _GLFW_DECORATION_VERTICAL (_GLFW_DECORATION_TOP + _GLFW_DECORATION_WIDTH) -#define _GLFW_DECORATION_HORIZONTAL (2 * _GLFW_DECORATION_WIDTH) - typedef enum _GLFWdecorationSideWayland { mainWindow, @@ -167,6 +162,9 @@ typedef struct _GLFWwindowWayland struct wl_callback *current_wl_callback; } frameCallbackData; + struct { + unsigned int width, top, horizontal, vertical; + } decoration_metrics; } _GLFWwindowWayland; diff --git a/glfw/wl_window.c b/glfw/wl_window.c index d089fceec..e029e5751 100644 --- a/glfw/wl_window.c +++ b/glfw/wl_window.c @@ -171,26 +171,26 @@ static void resizeFramebuffer(_GLFWwindow* window) // Top decoration. wp_viewport_set_destination(window->wl.decorations.top.viewport, - window->wl.width, _GLFW_DECORATION_TOP); + window->wl.width, window->wl.decoration_metrics.top); wl_surface_commit(window->wl.decorations.top.surface); // Left decoration. wp_viewport_set_destination(window->wl.decorations.left.viewport, - _GLFW_DECORATION_WIDTH, window->wl.height + _GLFW_DECORATION_TOP); + window->wl.decoration_metrics.width, window->wl.height + window->wl.decoration_metrics.top); wl_surface_commit(window->wl.decorations.left.surface); // Right decoration. wl_subsurface_set_position(window->wl.decorations.right.subsurface, - window->wl.width, -_GLFW_DECORATION_TOP); + window->wl.width, -window->wl.decoration_metrics.top); wp_viewport_set_destination(window->wl.decorations.right.viewport, - _GLFW_DECORATION_WIDTH, window->wl.height + _GLFW_DECORATION_TOP); + window->wl.decoration_metrics.width, window->wl.height + window->wl.decoration_metrics.top); wl_surface_commit(window->wl.decorations.right.surface); // Bottom decoration. wl_subsurface_set_position(window->wl.decorations.bottom.subsurface, - -_GLFW_DECORATION_WIDTH, window->wl.height); + -window->wl.decoration_metrics.width, window->wl.height); wp_viewport_set_destination(window->wl.decorations.bottom.viewport, - window->wl.width + _GLFW_DECORATION_HORIZONTAL, _GLFW_DECORATION_WIDTH); + window->wl.width + window->wl.decoration_metrics.horizontal, window->wl.decoration_metrics.width); wl_surface_commit(window->wl.decorations.bottom.surface); } @@ -394,20 +394,20 @@ static void createDecorations(_GLFWwindow* window) createDecoration(&window->wl.decorations.top, window->wl.surface, window->wl.decorations.buffer, opaque, - 0, -_GLFW_DECORATION_TOP, - window->wl.width, _GLFW_DECORATION_TOP); + 0, -window->wl.decoration_metrics.top, + window->wl.width, window->wl.decoration_metrics.top); createDecoration(&window->wl.decorations.left, window->wl.surface, window->wl.decorations.buffer, opaque, - -_GLFW_DECORATION_WIDTH, -_GLFW_DECORATION_TOP, - _GLFW_DECORATION_WIDTH, window->wl.height + _GLFW_DECORATION_TOP); + -window->wl.decoration_metrics.width, -window->wl.decoration_metrics.top, + window->wl.decoration_metrics.width, window->wl.height + window->wl.decoration_metrics.top); createDecoration(&window->wl.decorations.right, window->wl.surface, window->wl.decorations.buffer, opaque, - window->wl.width, -_GLFW_DECORATION_TOP, - _GLFW_DECORATION_WIDTH, window->wl.height + _GLFW_DECORATION_TOP); + window->wl.width, -window->wl.decoration_metrics.top, + window->wl.decoration_metrics.width, window->wl.height + window->wl.decoration_metrics.top); createDecoration(&window->wl.decorations.bottom, window->wl.surface, window->wl.decorations.buffer, opaque, - -_GLFW_DECORATION_WIDTH, window->wl.height, - window->wl.width + _GLFW_DECORATION_HORIZONTAL, _GLFW_DECORATION_WIDTH); + -window->wl.decoration_metrics.width, window->wl.height, + window->wl.width + window->wl.decoration_metrics.horizontal, window->wl.decoration_metrics.width); } static void destroyDecoration(_GLFWdecorationWayland* decoration) @@ -622,8 +622,8 @@ static void xdgToplevelHandleConfigure(void* data, window->wl.fullscreened = fullscreen; if (!fullscreen) { if (window->decorated && !window->wl.decorations.serverSide && window->wl.decorations.buffer) { - width -= _GLFW_DECORATION_HORIZONTAL; - height -= _GLFW_DECORATION_VERTICAL; + width -= window->wl.decoration_metrics.horizontal; + height -= window->wl.decoration_metrics.vertical; } } dispatchChangesAfterConfigure(window, width, height); @@ -882,6 +882,10 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window, const _GLFWctxconfig* ctxconfig, const _GLFWfbconfig* fbconfig) { + window->wl.decoration_metrics.width = 4; + window->wl.decoration_metrics.top = 24; + window->wl.decoration_metrics.horizontal = 2 * window->wl.decoration_metrics.width; + window->wl.decoration_metrics.vertical = window->wl.decoration_metrics.width + window->wl.decoration_metrics.top; window->wl.transparent = fbconfig->transparent; strncpy(window->wl.appId, wndconfig->wl.appId, sizeof(window->wl.appId)); @@ -1086,13 +1090,13 @@ void _glfwPlatformGetWindowFrameSize(_GLFWwindow* window, if (window->decorated && !window->monitor && !window->wl.decorations.serverSide) { if (top) - *top = _GLFW_DECORATION_TOP; + *top = window->wl.decoration_metrics.top; if (left) - *left = _GLFW_DECORATION_WIDTH; + *left = window->wl.decoration_metrics.width; if (right) - *right = _GLFW_DECORATION_WIDTH; + *right = window->wl.decoration_metrics.width; if (bottom) - *bottom = _GLFW_DECORATION_WIDTH; + *bottom = window->wl.decoration_metrics.width; } }