From f13b75475f5d3861f142407769868c4bb67287f4 Mon Sep 17 00:00:00 2001 From: alexei-zebra Date: Sat, 10 Oct 2026 16:04:39 +0300 Subject: [PATCH] Let the window frame keep its cursor The GUI sets the cursor of the hovered widget every frame, and over the window that widget is usually the background with a plain arrow. The frame sets its resize cursors on pointer motion, so the GUI replaced them on the next frame: hovering a window edge did not show a resize cursor, it flickered and stayed an arrow. The window now reports whether the frame owns the cursor, and the GUI only sets the hovered cursor when it does not. The GLFW backend claims it inside the frame and gives it back in the client area together with the arrow, since the GUI sets a cursor only while a widget is hovered. Wayland keeps returning false, so the GUI behaves exactly as before there. --- src/graphics/ui/GUI.cpp | 2 +- src/window/Window.hpp | 8 ++++++++ src/window/detail/GLFWWindow.cpp | 13 +++++++++++++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/graphics/ui/GUI.cpp b/src/graphics/ui/GUI.cpp index d80c03d71..2786590cb 100644 --- a/src/graphics/ui/GUI.cpp +++ b/src/graphics/ui/GUI.cpp @@ -310,7 +310,7 @@ void GUI::draw(const DrawContext& pctx, Assets& assets) { frame->draw(ctx, assets); } - if (hover) { + if (hover && !engine.getWindow().ownsCursor()) { engine.getWindow().setCursor(hover->getCursor()); } if (hover && debug) { diff --git a/src/window/Window.hpp b/src/window/Window.hpp index b1840175c..db837eade 100644 --- a/src/window/Window.hpp +++ b/src/window/Window.hpp @@ -52,6 +52,14 @@ public: } virtual void setCursor(CursorShape shape) = 0; + + /// @brief Whether the engine drawn window frame owns the cursor now + /// + /// The frame puts the resize cursors of its edges and of the bar, and the + /// GUI must not override them with the cursor of the hovered widget. + virtual bool ownsCursor() const { + return false; + } virtual void setMode(WindowMode mode) = 0; virtual WindowMode getMode() const = 0; diff --git a/src/window/detail/GLFWWindow.cpp b/src/window/detail/GLFWWindow.cpp index 737c1f736..c6ec88758 100644 --- a/src/window/detail/GLFWWindow.cpp +++ b/src/window/detail/GLFWWindow.cpp @@ -361,6 +361,10 @@ public: return hoveredButton; } + bool ownsCursor() const override { + return frameCursorActive; + } + /// @brief What the pointer is over, in client coordinates frame::Hit hitTestFrame(int x, int y) const { const int height = barHeight(); @@ -396,6 +400,7 @@ public: void handleFrameMotion(double x, double y) { if (input.isCursorLocked() || barHeight() <= 0) { hoveredButton = -1; + frameCursorActive = false; return; } if (dragging || resizeEdges != 0) { @@ -641,8 +646,15 @@ private: ) : 0; if (edges != 0) { + frameCursorActive = true; setCursor(edgeCursor(edges)); } else if (y < height) { + frameCursorActive = true; + setCursor(CursorShape::ARROW); + } else if (frameCursorActive) { + // the client area below the bar belongs to the GUI, which only + // sets a cursor when a widget is hovered + frameCursorActive = false; setCursor(CursorShape::ARROW); } } @@ -779,6 +791,7 @@ private: }; mutable std::vector buttonRects; int hoveredButton = -1; + bool frameCursorActive = false; int pressedButton = -1; bool dragging = false; bool frameMoved = false;