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/source
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2009-10-08 01:19:35 +0400
committerCampbell Barton <ideasman42@gmail.com>2009-10-08 01:19:35 +0400
commit0c857a4f1462a909b111ec4533e1c1f5ab54af4f (patch)
tree97390de3a70172b7e6c47210094f78a44a019bdd /source
parenta4e36f24c74dfc825347752aae2e55e0247924ef (diff)
- made ungrab a second function - WM_cursor_ungrab
- ungrab can restore the position of the mouse clamped to the window bounds (much nicer for transform)
Diffstat (limited to 'source')
-rw-r--r--source/blender/editors/interface/interface_handlers.c4
-rw-r--r--source/blender/windowmanager/WM_api.h3
-rw-r--r--source/blender/windowmanager/intern/wm_cursors.c10
-rw-r--r--source/blender/windowmanager/intern/wm_event_system.c6
4 files changed, 15 insertions, 8 deletions
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index 385a0eec040..8dea3fa1fc3 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -3709,12 +3709,12 @@ static void button_activate_state(bContext *C, uiBut *but, uiHandleButtonState s
/* number editing */
if(state == BUTTON_STATE_NUM_EDITING) {
if(ui_is_a_warp_but(but))
- WM_cursor_grab(CTX_wm_window(C), 1, 1);
+ WM_cursor_grab(CTX_wm_window(C), TRUE);
ui_numedit_begin(but, data);
} else if(data->state == BUTTON_STATE_NUM_EDITING) {
ui_numedit_end(but, data);
if(ui_is_a_warp_but(but))
- WM_cursor_grab(CTX_wm_window(C), 0, -1);
+ WM_cursor_ungrab(CTX_wm_window(C), FALSE);
}
/* menu open */
if(state == BUTTON_STATE_MENU_OPEN)
diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h
index 321afec51b7..e7f5bb3b291 100644
--- a/source/blender/windowmanager/WM_api.h
+++ b/source/blender/windowmanager/WM_api.h
@@ -75,7 +75,8 @@ void WM_cursor_set (struct wmWindow *win, int curs);
void WM_cursor_modal (struct wmWindow *win, int curs);
void WM_cursor_restore (struct wmWindow *win);
void WM_cursor_wait (int val);
-void WM_cursor_grab (struct wmWindow *win, int val, int warp);
+void WM_cursor_grab(struct wmWindow *win, int warp);
+void WM_cursor_ungrab(wmWindow *win, int restore);
void WM_timecursor (struct wmWindow *win, int nr);
void *WM_paint_cursor_activate(struct wmWindowManager *wm, int (*poll)(struct bContext *C), void (*draw)(struct bContext *C, int, int, void *customdata), void *customdata);
diff --git a/source/blender/windowmanager/intern/wm_cursors.c b/source/blender/windowmanager/intern/wm_cursors.c
index d14cde56083..e33132d18b9 100644
--- a/source/blender/windowmanager/intern/wm_cursors.c
+++ b/source/blender/windowmanager/intern/wm_cursors.c
@@ -163,10 +163,16 @@ void WM_cursor_wait(int val)
}
}
-void WM_cursor_grab(wmWindow *win, int val, int warp)
+void WM_cursor_grab(wmWindow *win, int warp)
{
if(win)
- GHOST_SetCursorGrab(win->ghostwin, val, warp);
+ GHOST_SetCursorGrab(win->ghostwin, 1, warp, -1);
+}
+
+void WM_cursor_ungrab(wmWindow *win, int restore)
+{
+ if(win)
+ GHOST_SetCursorGrab(win->ghostwin, 0, -1, restore);
}
/* afer this you can call restore too */
diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c
index 54841f0e063..086fdd3665b 100644
--- a/source/blender/windowmanager/intern/wm_event_system.c
+++ b/source/blender/windowmanager/intern/wm_event_system.c
@@ -442,7 +442,7 @@ static int wm_operator_invoke(bContext *C, wmOperatorType *ot, wmEvent *event, P
else if(retval & OPERATOR_RUNNING_MODAL) {
/* grab cursor during blocking modal ops (X11) */
if(ot->flag & OPTYPE_BLOCKING)
- WM_cursor_grab(CTX_wm_window(C), 1, (U.uiflag & USER_CONTINUOUS_MOUSE));
+ WM_cursor_grab(CTX_wm_window(C), (U.uiflag & USER_CONTINUOUS_MOUSE));
}
else
WM_operator_free(op);
@@ -637,7 +637,7 @@ void WM_event_remove_handlers(bContext *C, ListBase *handlers)
CTX_wm_region_set(C, region);
}
- WM_cursor_grab(CTX_wm_window(C), 0, -1);
+ WM_cursor_ungrab(CTX_wm_window(C), TRUE);
WM_operator_free(handler->op);
}
else if(handler->ui_remove) {
@@ -835,7 +835,7 @@ static int wm_handler_operator_call(bContext *C, ListBase *handlers, wmEventHand
/* remove modal handler, operator itself should have been cancelled and freed */
if(retval & (OPERATOR_CANCELLED|OPERATOR_FINISHED)) {
- WM_cursor_grab(CTX_wm_window(C), 0, -1);
+ WM_cursor_ungrab(CTX_wm_window(C), TRUE);
BLI_remlink(handlers, handler);
wm_event_free_handler(handler);