From bfa1c424e56093bc4a08184ec68543e45b468374 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 14 Aug 2025 21:19:13 +0200 Subject: [PATCH] Wayland: Fix fallback decoration menu placement The fallback decorations would place the menu at the wrong position, by not translating the last decoration surface position into toplevel surface coordinates. This also limits the menu to the caption area of the top decoration surface, similar to how other toolkits work. --- README.md | 1 + src/wl_window.c | 20 +++++++++++++------- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index cebdf089..6efa1ae7 100644 --- a/README.md +++ b/README.md @@ -139,6 +139,7 @@ information on what to include when reporting a bug. fallback decorations - [Wayland] Bugfix: Fallback decorations would report scroll events - [Wayland] Bugfix: Keyboard repeat events halted when any key is released (#2568) + - [Wayland] Bugfix: Fallback decorations would show menu at wrong position - [X11] Bugfix: Running without a WM could trigger an assert (#2593,#2601,#2631) - [Null] Added Vulkan 'window' surface creation via `VK_EXT_headless_surface` - [Null] Added EGL context creation on Mesa via `EGL_MESA_platform_surfaceless` diff --git a/src/wl_window.c b/src/wl_window.c index 2b172c9c..b9aa405d 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -405,13 +405,19 @@ static void handleFallbackDecorationButton(_GLFWwindow* window, } else if (button == BTN_RIGHT) { - if (window->wl.xdg.toplevel) - { - xdg_toplevel_show_window_menu(window->wl.xdg.toplevel, - _glfw.wl.seat, serial, - window->wl.cursorPosX, - window->wl.cursorPosY); - } + if (!window->wl.xdg.toplevel) + return; + + if (window->wl.fallback.focus != window->wl.fallback.top.surface) + return; + + if (ypos < GLFW_BORDER_SIZE) + return; + + xdg_toplevel_show_window_menu(window->wl.xdg.toplevel, + _glfw.wl.seat, serial, + xpos, + ypos - GLFW_CAPTION_HEIGHT - GLFW_BORDER_SIZE); } }