Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix clearing custom cursor #74511

Merged
merged 1 commit into from Jun 19, 2023
Merged

Conversation

AThousandShips
Copy link
Member

@AThousandShips AThousandShips commented Mar 6, 2023

Fixes #74508

Clearing the cursor in Windows fails because the cache is not cleared before calling to update cursor.

@akien-mga
Copy link
Member

The logic is the same on other platforms, should it be changed too?

Linux:

                // Reset to default system cursor
                if (img[p_shape]) {
                        cursors[p_shape] = XcursorImageLoadCursor(x11_display, img[p_shape]);
                }

                CursorShape c = current_cursor;
                current_cursor = CURSOR_MAX;
                cursor_set_shape(c);

                cursors_cache.erase(p_shape);

macOS:

                // Reset to default system cursor.
                if (cursors[p_shape] != nullptr) {
                        cursors[p_shape] = nullptr;
                }

                cursor_update_shape();

                cursors_cache.erase(p_shape);

@AThousandShips
Copy link
Member Author

AThousandShips commented Mar 6, 2023

Oh probably yeah, will take a look there too, cannot test the effect myself though

@AThousandShips

This comment was marked as outdated.

@AThousandShips
Copy link
Member Author

This is where it causes a problem in the Windows implementation:

if (cursors_cache.has(p_shape)) {
SetCursor(cursors[p_shape]);
} else {
SetCursor(LoadCursor(hInstance, win_cursors[p_shape]));
}

@AThousandShips AThousandShips requested review from a team as code owners March 10, 2023 11:00
@AThousandShips AThousandShips changed the title [Windows] Fix clearing custom cursor Fix clearing custom cursor Mar 10, 2023
@AThousandShips
Copy link
Member Author

AThousandShips commented Mar 10, 2023

Updated to include MacOS and Linux as well as I was told the bug affected those as well, cannot test for those platforms myself however.

@akien-mga akien-mga merged commit 356a602 into godotengine:master Jun 19, 2023
6 checks passed
@akien-mga
Copy link
Member

Thanks!

@AThousandShips AThousandShips deleted the win_cursor_fix branch June 20, 2023 06:09
@AThousandShips
Copy link
Member Author

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

set_custom_mouse_cursor(null) makes the cursor disappear.
2 participants