From dcfe49ef4838f523d788f8206759f825e4e01862 Mon Sep 17 00:00:00 2001 From: crs Date: Sat, 1 May 2004 08:56:24 +0000 Subject: [PATCH] Fixed regression where cursor wasn't locked to screen when a mouse button is down on win32. --- lib/platform/CMSWindowsScreen.cpp | 74 ++++++++++++++++++------------- lib/platform/CMSWindowsScreen.h | 3 ++ 2 files changed, 45 insertions(+), 32 deletions(-) diff --git a/lib/platform/CMSWindowsScreen.cpp b/lib/platform/CMSWindowsScreen.cpp index 0ee9d454..39d40dc1 100644 --- a/lib/platform/CMSWindowsScreen.cpp +++ b/lib/platform/CMSWindowsScreen.cpp @@ -964,8 +964,8 @@ bool CMSWindowsScreen::onMouseButton(WPARAM wParam, LPARAM lParam) { // get which button - bool pressed = false; - const ButtonID button = mapButtonFromEvent(wParam, lParam); + bool pressed = mapPressFromEvent(wParam, lParam); + ButtonID button = mapButtonFromEvent(wParam, lParam); // keep our shadow key state up to date if (button >= kButtonLeft && button <= kButtonExtra0 + 1) { @@ -979,44 +979,17 @@ CMSWindowsScreen::onMouseButton(WPARAM wParam, LPARAM lParam) // ignore message if posted prior to last mark change if (!ignore()) { - switch (wParam) { - case WM_LBUTTONDOWN: - case WM_MBUTTONDOWN: - case WM_RBUTTONDOWN: - case WM_XBUTTONDOWN: - case WM_LBUTTONDBLCLK: - case WM_MBUTTONDBLCLK: - case WM_RBUTTONDBLCLK: - case WM_XBUTTONDBLCLK: - case WM_NCLBUTTONDOWN: - case WM_NCMBUTTONDOWN: - case WM_NCRBUTTONDOWN: - case WM_NCXBUTTONDOWN: - case WM_NCLBUTTONDBLCLK: - case WM_NCMBUTTONDBLCLK: - case WM_NCRBUTTONDBLCLK: - case WM_NCXBUTTONDBLCLK: + if (pressed) { LOG((CLOG_DEBUG1 "event: button press button=%d", button)); if (button != kButtonNone) { sendEvent(getButtonDownEvent(), CButtonInfo::alloc(button)); } - pressed = true; - break; - - case WM_LBUTTONUP: - case WM_MBUTTONUP: - case WM_RBUTTONUP: - case WM_XBUTTONUP: - case WM_NCLBUTTONUP: - case WM_NCMBUTTONUP: - case WM_NCRBUTTONUP: - case WM_NCXBUTTONUP: + } + else { LOG((CLOG_DEBUG1 "event: button release button=%d", button)); if (button != kButtonNone) { sendEvent(getButtonUpEvent(), CButtonInfo::alloc(button)); } - pressed = false; - break; } } @@ -1302,6 +1275,43 @@ CMSWindowsScreen::mapButtonFromEvent(WPARAM msg, LPARAM button) const } } +bool +CMSWindowsScreen::mapPressFromEvent(WPARAM msg, LPARAM) const +{ + switch (msg) { + case WM_LBUTTONDOWN: + case WM_MBUTTONDOWN: + case WM_RBUTTONDOWN: + case WM_XBUTTONDOWN: + case WM_LBUTTONDBLCLK: + case WM_MBUTTONDBLCLK: + case WM_RBUTTONDBLCLK: + case WM_XBUTTONDBLCLK: + case WM_NCLBUTTONDOWN: + case WM_NCMBUTTONDOWN: + case WM_NCRBUTTONDOWN: + case WM_NCXBUTTONDOWN: + case WM_NCLBUTTONDBLCLK: + case WM_NCMBUTTONDBLCLK: + case WM_NCRBUTTONDBLCLK: + case WM_NCXBUTTONDBLCLK: + return true; + + case WM_LBUTTONUP: + case WM_MBUTTONUP: + case WM_RBUTTONUP: + case WM_XBUTTONUP: + case WM_NCLBUTTONUP: + case WM_NCMBUTTONUP: + case WM_NCRBUTTONUP: + case WM_NCXBUTTONUP: + return false; + + default: + return false; + } +} + void CMSWindowsScreen::fixKeys() { diff --git a/lib/platform/CMSWindowsScreen.h b/lib/platform/CMSWindowsScreen.h index b0695f76..5dc64f73 100644 --- a/lib/platform/CMSWindowsScreen.h +++ b/lib/platform/CMSWindowsScreen.h @@ -157,6 +157,9 @@ private: // map a button event to a button ID ButtonID mapButtonFromEvent(WPARAM msg, LPARAM button) const; + // map a button event to a press (true) or release (false) + bool mapPressFromEvent(WPARAM msg, LPARAM button) const; + // fix the key state, synthesizing fake key releases for keys // that aren't down anymore. void fixKeys();