Pārlūkot izejas kodu

[dx] Prevent ClipCursor when window have focus but is not foreground (#781)

Yuxiao Mao 4 mēneši atpakaļ
vecāks
revīzija
5da7d242c4
1 mainītis faili ar 8 papildinājumiem un 1 dzēšanām
  1. 8 1
      libs/directx/window.c

+ 8 - 1
libs/directx/window.c

@@ -83,7 +83,8 @@ typedef enum {
 	RButton = 8,
 	MButton = 16,
 	XButton1 = 32,
-	XButton2 = 64
+	XButton2 = 64,
+	NotForeground = 128
 } mouse_capture_flags;
 static int disable_capture = 0;
 static bool capture_mouse = false;
@@ -396,6 +397,12 @@ static LRESULT CALLBACK WndProc( HWND wnd, UINT umsg, WPARAM wparam, LPARAM lpar
 		addState(Blur);
 		break;
 	case WM_WINDOWPOSCHANGED:
+		HWND wndFg = GetForegroundWindow();
+		if( wndFg != wnd ) {
+			disable_capture |= NotForeground;
+		} else {
+			disable_capture &= ~NotForeground;
+		}
 		updateClipCursor(wnd);
 		break;
 	case WM_GETMINMAXINFO: