Page Menu
Home
Search
Configure Global Search
Log In
Files
F15332
win_ghost_mouse_loopcut_fix.patch
Public
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Authored By
Alexander Kuznetsov (alexk)
Nov 13 2013, 3:10 PM
Size
5 KB
Subscribers
None
win_ghost_mouse_loopcut_fix.patch
View Options
Index: intern/ghost/intern/GHOST_SystemWin32.cpp
===================================================================
--- intern/ghost/intern/GHOST_SystemWin32.cpp (revision 35487)
+++ intern/ghost/intern/GHOST_SystemWin32.cpp (working copy)
@@ -862,19 +862,19 @@
// Mouse events, processed
////////////////////////////////////////////////////////////////////////
case WM_LBUTTONDOWN:
- window->registerMouseClickEvent(true);
+ window->registerMouseClickEvent(0);
event = processButtonEvent(GHOST_kEventButtonDown, window, GHOST_kButtonMaskLeft);
break;
case WM_MBUTTONDOWN:
- window->registerMouseClickEvent(true);
+ window->registerMouseClickEvent(0);
event = processButtonEvent(GHOST_kEventButtonDown, window, GHOST_kButtonMaskMiddle);
break;
case WM_RBUTTONDOWN:
- window->registerMouseClickEvent(true);
+ window->registerMouseClickEvent(0);
event = processButtonEvent(GHOST_kEventButtonDown, window, GHOST_kButtonMaskRight);
break;
case WM_XBUTTONDOWN:
- window->registerMouseClickEvent(true);
+ window->registerMouseClickEvent(0);
if ((short) HIWORD(wParam) == XBUTTON1){
event = processButtonEvent(GHOST_kEventButtonDown, window, GHOST_kButtonMaskButton4);
}else if((short) HIWORD(wParam) == XBUTTON2){
@@ -882,19 +882,19 @@
}
break;
case WM_LBUTTONUP:
- window->registerMouseClickEvent(false);
+ window->registerMouseClickEvent(1);
event = processButtonEvent(GHOST_kEventButtonUp, window, GHOST_kButtonMaskLeft);
break;
case WM_MBUTTONUP:
- window->registerMouseClickEvent(false);
+ window->registerMouseClickEvent(1);
event = processButtonEvent(GHOST_kEventButtonUp, window, GHOST_kButtonMaskMiddle);
break;
case WM_RBUTTONUP:
- window->registerMouseClickEvent(false);
+ window->registerMouseClickEvent(1);
event = processButtonEvent(GHOST_kEventButtonUp, window, GHOST_kButtonMaskRight);
break;
case WM_XBUTTONUP:
- window->registerMouseClickEvent(false);
+ window->registerMouseClickEvent(1);
if ((short) HIWORD(wParam) == XBUTTON1){
event = processButtonEvent(GHOST_kEventButtonUp, window, GHOST_kButtonMaskButton4);
}else if((short) HIWORD(wParam) == XBUTTON2){
Index: intern/ghost/intern/GHOST_WindowWin32.cpp
===================================================================
--- intern/ghost/intern/GHOST_WindowWin32.cpp (revision 35487)
+++ intern/ghost/intern/GHOST_WindowWin32.cpp (working copy)
@@ -125,6 +125,7 @@
m_hDC(0),
m_hGlRc(0),
m_hasMouseCaptured(false),
+ m_hasGrabMouse(false),
m_nPressedButtons(0),
m_customCursor(0),
m_wintab(NULL),
@@ -831,29 +832,38 @@
void GHOST_WindowWin32::lostMouseCapture()
{
- if (m_hasMouseCaptured) {
- m_hasMouseCaptured = false;
- m_nPressedButtons = 0;
- }
+ if(m_hasMouseCaptured)
+ { m_hasGrabMouse = false;
+ m_nPressedButtons = 0;
+ m_hasMouseCaptured = false;
+ };
}
-void GHOST_WindowWin32::registerMouseClickEvent(bool press)
+void GHOST_WindowWin32::registerMouseClickEvent(int press)
{
- if (press) {
- if (!m_hasMouseCaptured) {
+ /*printf("%i",press);*/
+
+ switch(press)
+ {
+ case 0: m_nPressedButtons++; break;
+ case 1: if(m_nPressedButtons) m_nPressedButtons--; break;
+ case 2: m_hasGrabMouse=true; break;
+ case 3: m_hasGrabMouse=false; break;
+ }
+
+ if(!m_nPressedButtons && !m_hasGrabMouse && m_hasMouseCaptured)
+ {
+ ::ReleaseCapture();
+ m_hasMouseCaptured = false;
+ /*printf("Rel");*/
+ }
+ else if((m_nPressedButtons || m_hasGrabMouse) && !m_hasMouseCaptured)
+ {
::SetCapture(m_hWnd);
m_hasMouseCaptured = true;
- }
- m_nPressedButtons++;
- } else {
- if (m_nPressedButtons) {
- m_nPressedButtons--;
- if (!m_nPressedButtons) {
- ::ReleaseCapture();
- m_hasMouseCaptured = false;
- }
- }
+ /*printf("Cap");*/
}
+ /*printf("\t%i+%i\n",m_nPressedButtons,m_hasGrabMouse);*/
}
@@ -924,7 +934,7 @@
if(mode == GHOST_kGrabHide)
setWindowCursorVisibility(false);
}
- registerMouseClickEvent(true);
+ registerMouseClickEvent(2);
}
else {
if (m_cursorGrab==GHOST_kGrabHide) {
@@ -943,7 +953,7 @@
/* Almost works without but important otherwise the mouse GHOST location can be incorrect on exit */
setCursorGrabAccum(0, 0);
m_cursorGrabBounds.m_l= m_cursorGrabBounds.m_r= -1; /* disable */
- registerMouseClickEvent(false);
+ registerMouseClickEvent(3);
}
return GHOST_kSuccess;
Index: intern/ghost/intern/GHOST_WindowWin32.h
===================================================================
--- intern/ghost/intern/GHOST_WindowWin32.h (revision 35487)
+++ intern/ghost/intern/GHOST_WindowWin32.h (working copy)
@@ -251,9 +251,13 @@
* for any real button press, controls mouse
* capturing).
*
- * @param press True the event was a button press.
+ * @param press
+ * 0 - mouse pressed
+ * 1 - mouse released
+ * 2 - operator grab
+ * 3 - operator ungrab
*/
- void registerMouseClickEvent(bool press);
+ void registerMouseClickEvent(int press);
/**
* Inform the window that it has lost mouse capture,
@@ -342,6 +346,9 @@
static HDC s_firstHDC;
/** Flag for if window has captured the mouse */
bool m_hasMouseCaptured;
+ /** Flag if an operator grabs the mouse with WM_cursor_grab/ungrab()
+ * Multiple grabs must be realesed with a single ungrab*/
+ bool m_hasGrabMouse;
/** Count of number of pressed buttons */
int m_nPressedButtons;
/** HCURSOR structure of the custom cursor */
File Metadata
Details
Mime Type
text/x-diff
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
79/e4/3d63cf8fc80517d7b7d6e8448935
Event Timeline
Log In to Comment