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-17 18:08:01 +0400
committerCampbell Barton <ideasman42@gmail.com>2009-10-17 18:08:01 +0400
commit91d89c1ff7c215744e46957a1e7cc40adb7ac066 (patch)
treea811c95542f7fd40ff13cf592dfff1077a34f7d4 /source
parent53624a53d9054a91688a1a988c6f3515ab601923 (diff)
Adjustments to continuous grab
- Use an enum for grab modes rather then boolean options. -- GHOST_kGrabNormal: continuous grab userpref disabled -- GHOST_kGrabWrap: wrap the mouse at the screen bounds * -- GHOST_kGrabHide: hide the mouse while grabbing and restore the mouse where it was initially pressed * GrabWrap is nice for transform and tools where you want some idea where the cursor is, previously I found both restoring the mouse at its original location and restoring at a clamped location was confusing with operators like transform, wrapping is not ideal but IMHO the best of a bad bunch of options. GrabHide is for numbuts, where restoring the mouse at the initial location isnt so confusing.
Diffstat (limited to 'source')
-rw-r--r--source/blender/editors/interface/interface_handlers.c4
-rw-r--r--source/blender/windowmanager/WM_api.h4
-rw-r--r--source/blender/windowmanager/intern/wm_cursors.c13
-rw-r--r--source/blender/windowmanager/intern/wm_event_system.c6
4 files changed, 16 insertions, 11 deletions
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index 479c72304b2..bce38066899 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -3723,12 +3723,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), TRUE);
+ WM_cursor_grab(CTX_wm_window(C), TRUE, 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_ungrab(CTX_wm_window(C), FALSE);
+ WM_cursor_ungrab(CTX_wm_window(C));
}
/* 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 958b388f574..d90d812d0bb 100644
--- a/source/blender/windowmanager/WM_api.h
+++ b/source/blender/windowmanager/WM_api.h
@@ -76,8 +76,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 warp);
-void WM_cursor_ungrab(wmWindow *win, int restore);
+void WM_cursor_grab(struct wmWindow *win, int wrap, int hide);
+void WM_cursor_ungrab(struct wmWindow *win);
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 c1dfd9ee9fb..1d5b10f2583 100644
--- a/source/blender/windowmanager/intern/wm_cursors.c
+++ b/source/blender/windowmanager/intern/wm_cursors.c
@@ -163,21 +163,26 @@ void WM_cursor_wait(int val)
}
}
-void WM_cursor_grab(wmWindow *win, int warp)
+void WM_cursor_grab(wmWindow *win, int wrap, int hide)
{
/* Only grab cursor when not running debug.
* It helps not to get a stuck WM when hitting a breakpoint
* */
+ GHOST_TGrabCursorMode mode = GHOST_kGrabNormal;
+
+ if(hide) mode = GHOST_kGrabHide;
+ else if(wrap) mode = GHOST_kGrabWrap;
+
if ((G.f & G_DEBUG) == 0)
if(win)
- GHOST_SetCursorGrab(win->ghostwin, 1, warp, -1);
+ GHOST_SetCursorGrab(win->ghostwin, mode);
}
-void WM_cursor_ungrab(wmWindow *win, int restore)
+void WM_cursor_ungrab(wmWindow *win)
{
if ((G.f & G_DEBUG) == 0)
if(win)
- GHOST_SetCursorGrab(win->ghostwin, 0, -1, restore);
+ GHOST_SetCursorGrab(win->ghostwin, GHOST_kGrabDisable);
}
/* 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 f1104feaf5b..9e5f982880e 100644
--- a/source/blender/windowmanager/intern/wm_event_system.c
+++ b/source/blender/windowmanager/intern/wm_event_system.c
@@ -464,7 +464,7 @@ static int wm_operator_invoke(bContext *C, wmOperatorType *ot, wmEvent *event, P
/* grab cursor during blocking modal ops (X11) */
if(ot->flag & OPTYPE_BLOCKING) {
int warp = (U.uiflag & USER_CONTINUOUS_MOUSE) && ((op->flag & OP_GRAB_POINTER) || (ot->flag & OPTYPE_GRAB_POINTER));
- WM_cursor_grab(CTX_wm_window(C), warp);
+ WM_cursor_grab(CTX_wm_window(C), warp, FALSE);
}
}
else
@@ -660,7 +660,7 @@ void WM_event_remove_handlers(bContext *C, ListBase *handlers)
CTX_wm_region_set(C, region);
}
- WM_cursor_ungrab(CTX_wm_window(C), TRUE);
+ WM_cursor_ungrab(CTX_wm_window(C));
WM_operator_free(handler->op);
}
else if(handler->ui_remove) {
@@ -858,7 +858,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_ungrab(CTX_wm_window(C), TRUE);
+ WM_cursor_ungrab(CTX_wm_window(C));
BLI_remlink(handlers, handler);
wm_event_free_handler(handler);