Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/intern
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2009-07-09 20:05:01 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2009-07-09 20:05:01 +0400
commitb00409e72d04fe9e710c25fb4f076d1e960328dc (patch)
tree17d44f7ea5541b926ed5fde5aaa82fd8fb201949 /intern
parent5e659c0b0895e07351bd2b2425deea342141e515 (diff)
2.5: X11
* Pass on mouse location on window leave/enter too, fixing some issues with button highlights and tooltips. * When a modal operator runs, grab the mouse cursor so that for example transform still works when you move your mouse outside of the window, previously it would just stop then. This is automatic now for all modal ops, perhaps not always needed? * Fix for a trailing button highlight issue.
Diffstat (limited to 'intern')
-rw-r--r--intern/ghost/GHOST_C-api.h11
-rw-r--r--intern/ghost/GHOST_IWindow.h8
-rw-r--r--intern/ghost/intern/GHOST_C-api.cpp8
-rw-r--r--intern/ghost/intern/GHOST_SystemX11.cpp15
-rw-r--r--intern/ghost/intern/GHOST_Window.cpp15
-rw-r--r--intern/ghost/intern/GHOST_Window.h16
-rw-r--r--intern/ghost/intern/GHOST_WindowX11.cpp15
-rw-r--r--intern/ghost/intern/GHOST_WindowX11.h9
8 files changed, 97 insertions, 0 deletions
diff --git a/intern/ghost/GHOST_C-api.h b/intern/ghost/GHOST_C-api.h
index c3158214830..c0b7077fb53 100644
--- a/intern/ghost/GHOST_C-api.h
+++ b/intern/ghost/GHOST_C-api.h
@@ -367,6 +367,17 @@ extern GHOST_TSuccess GHOST_SetCursorPosition(GHOST_SystemHandle systemhandle,
GHOST_TInt32 x,
GHOST_TInt32 y);
+/**
+ * Grabs the cursor for a modal operation, to keep receiving
+ * events when the mouse is outside the window. X11 only, others
+ * do this automatically.
+ * @param windowhandle The handle to the window
+ * @param grab The new grab state of the cursor.
+ * @return Indication of success.
+ */
+extern GHOST_TSuccess GHOST_SetCursorGrab(GHOST_WindowHandle windowhandle,
+ int grab);
+
/***************************************************************************************
** Access to mouse button and keyboard states.
***************************************************************************************/
diff --git a/intern/ghost/GHOST_IWindow.h b/intern/ghost/GHOST_IWindow.h
index 0861d8b8946..a05e014dc4f 100644
--- a/intern/ghost/GHOST_IWindow.h
+++ b/intern/ghost/GHOST_IWindow.h
@@ -252,6 +252,14 @@ public:
* @return Indication of success.
*/
virtual GHOST_TSuccess setCursorVisibility(bool visible) = 0;
+
+ /**
+ * Grabs the cursor for a modal operation.
+ * @param grab The new grab state of the cursor.
+ * @return Indication of success.
+ */
+ virtual GHOST_TSuccess setCursorGrab(bool grab) { printf("?! grab\n"); return GHOST_kSuccess; };
+
};
#endif // _GHOST_IWINDOW_H_
diff --git a/intern/ghost/intern/GHOST_C-api.cpp b/intern/ghost/intern/GHOST_C-api.cpp
index 401dba8d240..5c23b6c42a3 100644
--- a/intern/ghost/intern/GHOST_C-api.cpp
+++ b/intern/ghost/intern/GHOST_C-api.cpp
@@ -354,6 +354,14 @@ GHOST_TSuccess GHOST_SetCursorPosition(GHOST_SystemHandle systemhandle,
}
+GHOST_TSuccess GHOST_SetCursorGrab(GHOST_WindowHandle windowhandle,
+ int grab)
+{
+ GHOST_IWindow* window = (GHOST_IWindow*) windowhandle;
+
+ return window->setCursorGrab(grab?true:false);
+}
+
GHOST_TSuccess GHOST_GetModifierKeyState(GHOST_SystemHandle systemhandle,
GHOST_TModifierKeyMask mask,
diff --git a/intern/ghost/intern/GHOST_SystemX11.cpp b/intern/ghost/intern/GHOST_SystemX11.cpp
index a975322e9ce..fcf78d9ad20 100644
--- a/intern/ghost/intern/GHOST_SystemX11.cpp
+++ b/intern/ghost/intern/GHOST_SystemX11.cpp
@@ -550,11 +550,26 @@ GHOST_SystemX11::processEvent(XEvent *xe)
// We're not interested in the following things.(yet...)
case NoExpose :
case GraphicsExpose :
+ break;
case EnterNotify:
case LeaveNotify:
+ {
// XCrossingEvents pointer leave enter window.
+ // also do cursor move here, MotionNotify only
+ // happens when motion starts & ends inside window
+ XCrossingEvent &xce = xe->xcrossing;
+
+ g_event = new
+ GHOST_EventCursor(
+ getMilliSeconds(),
+ GHOST_kEventCursorMove,
+ window,
+ xce.x_root,
+ xce.y_root
+ );
break;
+ }
case MapNotify:
/*
* From ICCCM:
diff --git a/intern/ghost/intern/GHOST_Window.cpp b/intern/ghost/intern/GHOST_Window.cpp
index a35680d1586..dee890830a1 100644
--- a/intern/ghost/intern/GHOST_Window.cpp
+++ b/intern/ghost/intern/GHOST_Window.cpp
@@ -50,6 +50,7 @@ GHOST_Window::GHOST_Window(
:
m_drawingContextType(type),
m_cursorVisible(true),
+ m_cursorGrabbed(true),
m_cursorShape(GHOST_kStandardCursorDefault),
m_stereoVisual(stereoVisual)
{
@@ -93,6 +94,20 @@ GHOST_TSuccess GHOST_Window::setCursorVisibility(bool visible)
}
}
+GHOST_TSuccess GHOST_Window::setCursorGrab(bool grab)
+{
+ if(m_cursorGrabbed == grab)
+ return GHOST_kSuccess;
+
+ if (setWindowCursorGrab(grab)) {
+ m_cursorGrabbed = grab;
+ return GHOST_kSuccess;
+ }
+ else {
+ return GHOST_kFailure;
+ }
+}
+
GHOST_TSuccess GHOST_Window::setCursorShape(GHOST_TStandardCursor cursorShape)
{
if (setWindowCursorShape(cursorShape)) {
diff --git a/intern/ghost/intern/GHOST_Window.h b/intern/ghost/intern/GHOST_Window.h
index 06318613b14..43744b70be2 100644
--- a/intern/ghost/intern/GHOST_Window.h
+++ b/intern/ghost/intern/GHOST_Window.h
@@ -167,6 +167,13 @@ public:
virtual GHOST_TSuccess setCursorVisibility(bool visible);
/**
+ * Sets the cursor grab.
+ * @param grab The new grab state of the cursor.
+ * @return Indication of success.
+ */
+ virtual GHOST_TSuccess setCursorGrab(bool grab);
+
+ /**
* Returns the type of drawing context used in this window.
* @return The current type of drawing context.
*/
@@ -218,6 +225,12 @@ protected:
* native window system calls.
*/
virtual GHOST_TSuccess setWindowCursorVisibility(bool visible) = 0;
+
+ /**
+ * Sets the cursor grab on the window using
+ * native window system calls.
+ */
+ virtual GHOST_TSuccess setWindowCursorGrab(bool grab) = 0;
/**
* Sets the cursor shape on the window using
@@ -242,6 +255,9 @@ protected:
/** The current visibility of the cursor */
bool m_cursorVisible;
+
+ /** The current grabbed state of the cursor */
+ bool m_cursorGrabbed;
/** The current shape of the cursor */
GHOST_TStandardCursor m_cursorShape;
diff --git a/intern/ghost/intern/GHOST_WindowX11.cpp b/intern/ghost/intern/GHOST_WindowX11.cpp
index 2cc30aaa5bc..1525b4eb16d 100644
--- a/intern/ghost/intern/GHOST_WindowX11.cpp
+++ b/intern/ghost/intern/GHOST_WindowX11.cpp
@@ -1271,6 +1271,21 @@ setWindowCursorVisibility(
GHOST_TSuccess
GHOST_WindowX11::
+setWindowCursorGrab(
+ bool grab
+){
+ if(grab)
+ XGrabPointer(m_display, m_window, True, ButtonPressMask| ButtonReleaseMask|PointerMotionMask, GrabModeAsync, GrabModeAsync, None, None, CurrentTime);
+ else
+ XUngrabPointer(m_display, CurrentTime);
+
+ XFlush(m_display);
+
+ return GHOST_kSuccess;
+}
+
+ GHOST_TSuccess
+GHOST_WindowX11::
setWindowCursorShape(
GHOST_TStandardCursor shape
){
diff --git a/intern/ghost/intern/GHOST_WindowX11.h b/intern/ghost/intern/GHOST_WindowX11.h
index 1392e2c19a6..6f8940bdcbb 100644
--- a/intern/ghost/intern/GHOST_WindowX11.h
+++ b/intern/ghost/intern/GHOST_WindowX11.h
@@ -250,6 +250,15 @@ protected:
);
/**
+ * Sets the cursor grab on the window using
+ * native window system calls.
+ */
+ GHOST_TSuccess
+ setWindowCursorGrab(
+ bool grab
+ );
+
+ /**
* Sets the cursor shape on the window using
* native window system calls.
*/