Browse Source

Merge pull request #62824 from MinusKube/haunted-editor-bug

Fix haunted editor bug causing weird issues with mouse behaviour
Rémi Verschelde 3 years ago
parent
commit
19b10e2784

+ 5 - 7
platform/windows/display_server_windows.cpp

@@ -2382,7 +2382,7 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
 		}
 		}
 		case WM_MOUSELEAVE: {
 		case WM_MOUSELEAVE: {
 			old_invalid = true;
 			old_invalid = true;
-			outside = true;
+			windows[window_id].mouse_outside = true;
 
 
 			_send_window_event(windows[window_id], WINDOW_EVENT_MOUSE_EXIT);
 			_send_window_event(windows[window_id], WINDOW_EVENT_MOUSE_EXIT);
 
 
@@ -2612,7 +2612,7 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
 				}
 				}
 			}
 			}
 
 
-			if (outside) {
+			if (windows[window_id].mouse_outside) {
 				// Mouse enter.
 				// Mouse enter.
 
 
 				if (mouse_mode != MOUSE_MODE_CAPTURED) {
 				if (mouse_mode != MOUSE_MODE_CAPTURED) {
@@ -2622,7 +2622,7 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
 				CursorShape c = cursor_shape;
 				CursorShape c = cursor_shape;
 				cursor_shape = CURSOR_MAX;
 				cursor_shape = CURSOR_MAX;
 				cursor_set_shape(c);
 				cursor_set_shape(c);
-				outside = false;
+				windows[window_id].mouse_outside = false;
 
 
 				// Once-off notification, must call again.
 				// Once-off notification, must call again.
 				track_mouse_leave_event(hWnd);
 				track_mouse_leave_event(hWnd);
@@ -2713,7 +2713,7 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
 				}
 				}
 			}
 			}
 
 
-			if (outside) {
+			if (windows[window_id].mouse_outside) {
 				// Mouse enter.
 				// Mouse enter.
 
 
 				if (mouse_mode != MOUSE_MODE_CAPTURED) {
 				if (mouse_mode != MOUSE_MODE_CAPTURED) {
@@ -2723,7 +2723,7 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
 				CursorShape c = cursor_shape;
 				CursorShape c = cursor_shape;
 				cursor_shape = CURSOR_MAX;
 				cursor_shape = CURSOR_MAX;
 				cursor_set_shape(c);
 				cursor_set_shape(c);
-				outside = false;
+				windows[window_id].mouse_outside = false;
 
 
 				// Once-off notification, must call again.
 				// Once-off notification, must call again.
 				track_mouse_leave_event(hWnd);
 				track_mouse_leave_event(hWnd);
@@ -3608,8 +3608,6 @@ DisplayServerWindows::DisplayServerWindows(const String &p_rendering_driver, Win
 	old_invalid = true;
 	old_invalid = true;
 	mouse_mode = MOUSE_MODE_VISIBLE;
 	mouse_mode = MOUSE_MODE_VISIBLE;
 
 
-	outside = true;
-
 	rendering_driver = p_rendering_driver;
 	rendering_driver = p_rendering_driver;
 
 
 	// Init TTS
 	// Init TTS

+ 1 - 1
platform/windows/display_server_windows.h

@@ -313,7 +313,6 @@ class DisplayServerWindows : public DisplayServer {
 	int key_event_pos;
 	int key_event_pos;
 
 
 	bool old_invalid;
 	bool old_invalid;
-	bool outside;
 	int old_x, old_y;
 	int old_x, old_y;
 	Point2i center;
 	Point2i center;
 
 
@@ -387,6 +386,7 @@ class DisplayServerWindows : public DisplayServer {
 
 
 		Size2 window_rect;
 		Size2 window_rect;
 		Point2 last_pos;
 		Point2 last_pos;
+		bool mouse_outside = true;
 
 
 		ObjectID instance_id;
 		ObjectID instance_id;