From 4b00f9e660693b91e85ca13065beb624b90a810f Mon Sep 17 00:00:00 2001 From: rdb Date: Sat, 2 May 2020 10:47:37 +0200 Subject: [PATCH] windisplay: Fix M_confined mode confining cursor to incorrect region It should be confined to the client rect, not the window rect. Fixes #929 --- panda/src/windisplay/winGraphicsWindow.cxx | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/panda/src/windisplay/winGraphicsWindow.cxx b/panda/src/windisplay/winGraphicsWindow.cxx index 39559fce7d..c2e39d592e 100644 --- a/panda/src/windisplay/winGraphicsWindow.cxx +++ b/panda/src/windisplay/winGraphicsWindow.cxx @@ -1311,22 +1311,18 @@ track_mouse_leaving(HWND hwnd) { bool WinGraphicsWindow:: confine_cursor() { RECT clip; - if (!GetWindowRect(_hWnd, &clip)) { + get_client_rect_screen(_hWnd, &clip); + + windisplay_cat.info() + << "ClipCursor() to " << clip.left << "," << clip.top << " to " + << clip.right << "," << clip.bottom << endl; + + if (!ClipCursor(&clip)) { windisplay_cat.warning() - << "GetWindowRect() failed, cannot confine cursor.\n"; + << "Failed to confine cursor to window.\n"; return false; } else { - windisplay_cat.info() - << "ClipCursor() to " << clip.left << "," << clip.top << " to " - << clip.right << "," << clip.bottom << endl; - - if (!ClipCursor(&clip)) { - windisplay_cat.warning() - << "Failed to confine cursor to window.\n"; - return false; - } else { - return true; - } + return true; } }