Merge pull request #52753 from SilverCreekEntertainment/fix-cursor-disappearing-in-windows-fullscreen-3.x

This commit is contained in:
Rémi Verschelde 2021-09-17 11:16:23 +02:00 committed by GitHub
commit 48b2a026c9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 0 deletions

View file

@ -212,6 +212,7 @@ void OS_Windows::initialize_core() {
crash_handler.initialize();
last_button_state = 0;
restore_mouse_trails = 0;
//RedirectIOToConsole();
maximized = false;
@ -1426,6 +1427,13 @@ Error OS_Windows::initialize(const VideoMode &p_desired, int p_video_driver, int
video_mode.fullscreen=false;
}*/
pre_fs_valid = false;
// If the user has mouse trails enabled in windows, then sometimes the cursor disappears in fullscreen mode.
// Save number of trails so we can restore when exiting, then turn off mouse trails
SystemParametersInfoA(SPI_GETMOUSETRAILS, 0, &restore_mouse_trails, 0);
if (restore_mouse_trails > 1) {
SystemParametersInfoA(SPI_SETMOUSETRAILS, 0, 0, 0);
}
}
DWORD dwExStyle;
@ -1770,6 +1778,10 @@ void OS_Windows::finalize() {
if (user_proc) {
SetWindowLongPtr(hWnd, GWLP_WNDPROC, (LONG_PTR)user_proc);
};
if (restore_mouse_trails > 1) {
SystemParametersInfoA(SPI_SETMOUSETRAILS, restore_mouse_trails, 0, 0);
}
}
void OS_Windows::finalize_core() {
@ -2124,6 +2136,10 @@ void OS_Windows::set_window_fullscreen(bool p_enabled) {
MoveWindow(hWnd, pos.x, pos.y, size.width, size.height, TRUE);
SystemParametersInfoA(SPI_GETMOUSETRAILS, 0, &restore_mouse_trails, 0);
if (restore_mouse_trails > 1) {
SystemParametersInfoA(SPI_SETMOUSETRAILS, 0, 0, 0);
}
} else {
RECT rect;
@ -2143,6 +2159,10 @@ void OS_Windows::set_window_fullscreen(bool p_enabled) {
MoveWindow(hWnd, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, TRUE);
pre_fs_valid = true;
if (restore_mouse_trails > 1) {
SystemParametersInfoA(SPI_SETMOUSETRAILS, restore_mouse_trails, 0, 0);
}
}
}
bool OS_Windows::is_window_fullscreen() const {

View file

@ -334,6 +334,7 @@ class OS_Windows : public OS {
Vector2 im_position;
MouseMode mouse_mode;
int restore_mouse_trails;
bool alt_mem;
bool gr_mem;
bool shift_mem;