Skip to content

Fix cursor visibility for window cursor state - #98

Closed
Abendlied wants to merge 1 commit into
Try:masterfrom
Abendlied:fix-cursor-visibility
Closed

Fix cursor visibility for window cursor state#98
Abendlied wants to merge 1 commit into
Try:masterfrom
Abendlied:fix-cursor-visibility

Conversation

@Abendlied

Copy link
Copy Markdown

Fix for Linux on X11.
The mouse cursor always remained visible ingame. The initial setCursorShape(CursorShape::Hidden) call in common/mainwindow.cpp either did not update the (system native) mouse cursor until a mouse moving event was triggered or it does not stick.
The expected behaviour however is that the cursor is hidden while OpenGothic has focus and only become visible when losing focus, e.g. alt-tabbing scenario. So we have to touch the X11 API.

Widget::setCursorShape() only updated the native window cursor when wstate.moveOver was set..During window initialisation, this state is not yet set. We have a timing problem leading to setCursorShape(CursorShape::Hidden) not reaching the X11 implementation part. Basically this caused that setting the cursor during startup had no effect.

We fix this when we make Window::setCursorShape() update the cursor immediately when called, even when moveOver has not been set yet.

This hides the native window cursor during initialisation of the game and it consequently stays invisible when the game starts.

Tested on Linux with X11:
Cursor is hidden immediately on startup of the game and remains hidden as long as OpenGothic has focus. Cursor becomes visible when losing focus, e.g. alt-tabbing. Cursor is hidden again when focus comes back to OpenGothic.
I did not witness any mouse movement or handling changes on the potato of a machine I am running this with.

@Try

Try commented Sep 3, 2026

Copy link
Copy Markdown
Owner

Hi, @Abendlied and thanks for PR!

Unfortunately, in current state this is not a working code. In engine, it's allowed to call setCursorShape at any point. For example have LineEdit under the mouse and call setCursorShape on the parent window - this swap cursor incorrectly. There can be multiple windows at once, and so on.

In principle, one way to actually fix this is to reevaluate EventDispatcher::mouseOver, if widget is created or widget's geometry is changed.

@Try

Try commented Sep 5, 2026

Copy link
Copy Markdown
Owner

closed - there is a newer PR

@Try Try closed this Sep 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants