From 7126158d68d4853eac01c3c3999fd07308aea456 Mon Sep 17 00:00:00 2001 From: alexei-zebra Date: Sat, 10 Oct 2026 15:51:32 +0300 Subject: [PATCH] Keep the window frame usable without a window manager frame_has_native_operations() trusted the X11 accessors of GLFW alone, but a window manager that does not advertise _NET_WM_MOVERESIZE drops the request silently: on a plain X11 session the frame asked it to move and resize the window and nothing happened at all. The root window is checked for the atom now, and the frame falls back to moving and resizing the window itself. The resize edges also win over the bar instead of the bar swallowing its top strip, which made the top edge and the top corners impossible to grab. Both backends log the active path as "engine window frame: on, window manager operations are on|off". --- src/window/detail/FrameOperations.cpp | 51 +++++++++++++++++++++++++-- src/window/detail/GLFWWindow.cpp | 26 ++++++++------ 2 files changed, 64 insertions(+), 13 deletions(-) diff --git a/src/window/detail/FrameOperations.cpp b/src/window/detail/FrameOperations.cpp index 294428789..6f9009888 100644 --- a/src/window/detail/FrameOperations.cpp +++ b/src/window/detail/FrameOperations.cpp @@ -1,6 +1,7 @@ #include "window/detail/FrameOperations.hpp" #if defined(VOXEL_X11_FRAME) +#include #include #include @@ -38,6 +39,50 @@ namespace { return api; } + /// @brief Whether the window manager advertises _NET_WM_MOVERESIZE + /// + /// Without it the request would be silently dropped, and the frame has to + /// move and resize the window itself. The answer is cached. + bool x11_supports_moveresize(Display* display) { + static int cached = -1; + if (cached >= 0) { + return cached == 1; + } + cached = 0; + const Atom supported = XInternAtom(display, "_NET_SUPPORTED", False); + const Atom moveresize = + XInternAtom(display, "_NET_WM_MOVERESIZE", False); + Atom type = 0; + int format = 0; + unsigned long count = 0, after = 0; + unsigned char* data = nullptr; + if (XGetWindowProperty( + display, + DefaultRootWindow(display), + supported, + 0, + 8192, + False, + XA_ATOM, + &type, + &format, + &count, + &after, + &data + ) == Success && + data != nullptr) { + const Atom* atoms = reinterpret_cast(data); + for (unsigned long i = 0; i < count; i++) { + if (atoms[i] == moveresize) { + cached = 1; + break; + } + } + XFree(data); + } + return cached == 1; + } + /// @brief Edge mask to the _NET_WM_MOVERESIZE direction int x11_direction(int edges) { switch (edges) { @@ -70,7 +115,8 @@ namespace { } Display* display = api.display(); const Window window = api.window(glfwWindow); - if (display == nullptr || window == 0) { + if (display == nullptr || window == 0 || + !x11_supports_moveresize(display)) { return false; } const Window root = DefaultRootWindow(display); @@ -184,7 +230,8 @@ namespace { bool frame_has_native_operations() { #if defined(VOXEL_X11_FRAME) - return x11_api().available(); + X11Api& api = x11_api(); + return api.available() && x11_supports_moveresize(api.display()); #else return false; #endif diff --git a/src/window/detail/GLFWWindow.cpp b/src/window/detail/GLFWWindow.cpp index 3038f8f24..737c1f736 100644 --- a/src/window/detail/GLFWWindow.cpp +++ b/src/window/detail/GLFWWindow.cpp @@ -378,18 +378,18 @@ public: ) >= 0) { return frame::Hit {}; } - if (y < height) { - return frame::Hit {true, 0}; + // the resize edges win over the bar, its top strip resizes too + const int edges = frame::edgesAt( + getSize().x, + getSize().y, + height, + static_cast(x), + static_cast(y) + ); + if (edges != 0) { + return frame::Hit {false, edges}; } - return frame::Hit { - false, - frame::edgesAt( - getSize().x, - getSize().y, - height, - static_cast(x), - static_cast(y) - )}; + return frame::Hit {y < height, 0}; } /// @brief Turns a pointer move into hovering, dragging or resizing @@ -919,6 +919,10 @@ std::tuple< logger.info() << "windowing platform: " << get_platform_name(); const bool engineFrame = use_engine_frame(); + logger.info() << "engine window frame: " << (engineFrame ? "on" : "off") + << (engineFrame && frame_has_native_operations() + ? ", window manager operations are on" + : ""); if (engineFrame) { // the engine draws the window bar, the system frame must be gone glfwWindowHint(GLFW_DECORATED, GLFW_FALSE);