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;