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:
authorMartin Poirier <theeth@yahoo.com>2009-11-24 08:03:44 +0300
committerMartin Poirier <theeth@yahoo.com>2009-11-24 08:03:44 +0300
commit2597d4966456f8f008af03ee6bae62feb9d6ac3c (patch)
tree97bcaa92e4ca55144ab4e68d3d0ddb9a6cfa60e9 /source
parent4dd78dcbdfdfdf1dd9acf028506ad65fb22c1de1 (diff)
Extend handler return values to distinguish between events that have been handled and passed through and those that haven't been handled at all.
This also solves a bug with Click event (not visible with keymaps that use Click in default)
Diffstat (limited to 'source')
-rw-r--r--source/blender/windowmanager/intern/wm_event_system.c53
-rw-r--r--source/blender/windowmanager/intern/wm_operators.c2
-rw-r--r--source/blender/windowmanager/wm_event_system.h1
3 files changed, 33 insertions, 23 deletions
diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c
index 534edde5d4a..24a0bba310d 100644
--- a/source/blender/windowmanager/intern/wm_event_system.c
+++ b/source/blender/windowmanager/intern/wm_event_system.c
@@ -937,6 +937,10 @@ static int wm_handler_operator_call(bContext *C, ListBase *handlers, wmEventHand
retval= wm_operator_invoke(C, ot, event, properties, NULL);
}
+ /* Finished and pass through flag as handled */
+ if(retval == (OPERATOR_FINISHED|OPERATOR_PASS_THROUGH))
+ return WM_HANDLER_HANDLED;
+
if(retval & OPERATOR_PASS_THROUGH)
return WM_HANDLER_CONTINUE;
@@ -1110,7 +1114,7 @@ static int wm_handlers_do(bContext *C, wmEvent *event, ListBase *handlers)
/* modal+blocking handler */
if(handler->flag & WM_HANDLER_BLOCKING)
- action= WM_HANDLER_BREAK;
+ action |= WM_HANDLER_BREAK;
if(handler->keymap) {
wmKeyMap *keymap= WM_keymap_active(wm, handler->keymap);
@@ -1122,28 +1126,28 @@ static int wm_handlers_do(bContext *C, wmEvent *event, ListBase *handlers)
event->keymap_idname= kmi->idname; /* weak, but allows interactive callback to not use rawkey */
- action= wm_handler_operator_call(C, handlers, handler, event, kmi->ptr);
- if(action==WM_HANDLER_BREAK) /* not always_pass here, it denotes removed handler */
+ action |= wm_handler_operator_call(C, handlers, handler, event, kmi->ptr);
+ if(action & WM_HANDLER_BREAK) /* not always_pass here, it denotes removed handler */
break;
}
}
}
}
else if(handler->ui_handle) {
- action= wm_handler_ui_call(C, handler, event);
+ action |= wm_handler_ui_call(C, handler, event);
}
else if(handler->type==WM_HANDLER_FILESELECT) {
/* screen context changes here */
- action= wm_handler_fileselect_call(C, handlers, handler, event);
+ action |= wm_handler_fileselect_call(C, handlers, handler, event);
}
else {
/* modal, swallows all */
- action= wm_handler_operator_call(C, handlers, handler, event, NULL);
+ action |= wm_handler_operator_call(C, handlers, handler, event, NULL);
}
- if(action==WM_HANDLER_BREAK) {
+ if(action & WM_HANDLER_BREAK) {
if(always_pass)
- action= WM_HANDLER_CONTINUE;
+ action &= ~WM_HANDLER_BREAK;
else
break;
}
@@ -1160,10 +1164,10 @@ static int wm_handlers_do(bContext *C, wmEvent *event, ListBase *handlers)
if (win && win->last_type == event->type && win->last_val == KM_PRESS) {
event->val = KM_CLICK;
- action = wm_handlers_do(C, event, handlers);
+ action |= wm_handlers_do(C, event, handlers);
/* revert value if not handled */
- if (action == WM_HANDLER_CONTINUE) {
+ if ((action & WM_HANDLER_BREAK) == 0) {
event->val = KM_RELEASE;
}
}
@@ -1261,12 +1265,12 @@ void wm_event_do_handlers(bContext *C)
for(win= CTX_wm_manager(C)->windows.first; win; win= win->next) {
wmEvent *event;
+ int action = WM_HANDLER_CONTINUE;
if( win->screen==NULL )
wm_event_free_all(win);
while( (event= win->queue.first) ) {
- int action;
CTX_wm_window_set(C, win);
@@ -1278,7 +1282,7 @@ void wm_event_do_handlers(bContext *C)
wm_window_make_drawable(C, win);
/* first we do priority handlers, modal + some limited keymaps */
- action= wm_handlers_do(C, event, &win->modalhandlers);
+ action |= wm_handlers_do(C, event, &win->modalhandlers);
/* fileread case */
if(CTX_wm_window(C)==NULL)
@@ -1287,7 +1291,7 @@ void wm_event_do_handlers(bContext *C)
/* builtin tweak, if action is break it removes tweak */
wm_tweakevent_test(C, event, action);
- if(action==WM_HANDLER_CONTINUE) {
+ if((action & WM_HANDLER_BREAK) == 0) {
ScrArea *sa;
ARegion *ar;
int doit= 0;
@@ -1304,15 +1308,15 @@ void wm_event_do_handlers(bContext *C)
if(wm_event_inside_i(event, &sa->totrct)) {
CTX_wm_area_set(C, sa);
- if(action==WM_HANDLER_CONTINUE) {
+ if((action & WM_HANDLER_BREAK) == 0) {
for(ar=sa->regionbase.first; ar; ar= ar->next) {
if(wm_event_inside_i(event, &ar->winrct)) {
CTX_wm_region_set(C, ar);
- action= wm_handlers_do(C, event, &ar->handlers);
+ action |= wm_handlers_do(C, event, &ar->handlers);
doit |= (BLI_in_rcti(&ar->winrct, event->x, event->y));
- if(action==WM_HANDLER_BREAK)
+ if(action & WM_HANDLER_BREAK)
break;
}
}
@@ -1320,8 +1324,8 @@ void wm_event_do_handlers(bContext *C)
CTX_wm_region_set(C, NULL);
- if(action==WM_HANDLER_CONTINUE)
- action= wm_handlers_do(C, event, &sa->handlers);
+ if((action & WM_HANDLER_BREAK) == 0)
+ action |= wm_handlers_do(C, event, &sa->handlers);
CTX_wm_area_set(C, NULL);
@@ -1329,12 +1333,12 @@ void wm_event_do_handlers(bContext *C)
}
}
- if(action==WM_HANDLER_CONTINUE) {
+ if((action & WM_HANDLER_BREAK) == 0) {
/* also some non-modal handlers need active area/region */
CTX_wm_area_set(C, area_event_inside(C, event->x, event->y));
CTX_wm_region_set(C, region_event_inside(C, event->x, event->y));
- action= wm_handlers_do(C, event, &win->handlers);
+ action |= wm_handlers_do(C, event, &win->handlers);
/* fileread case */
if(CTX_wm_window(C)==NULL)
@@ -1350,8 +1354,13 @@ void wm_event_do_handlers(bContext *C)
}
/* store last event for this window */
- win->last_type = event->type;
- win->last_val = event->val;
+ if (action == WM_HANDLER_CONTINUE) {
+ win->last_type = event->type;
+ win->last_val = event->val;
+ } else {
+ win->last_type = -1;
+ win->last_val = 0;
+ }
/* unlink and free here, blender-quit then frees all */
BLI_remlink(&win->queue, event);
diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c
index 5116b9b39a0..82506091bbd 100644
--- a/source/blender/windowmanager/intern/wm_operators.c
+++ b/source/blender/windowmanager/intern/wm_operators.c
@@ -2037,7 +2037,7 @@ void wm_tweakevent_test(bContext *C, wmEvent *event, int action)
}
}
else {
- if(action==WM_HANDLER_BREAK) {
+ if(action & WM_HANDLER_BREAK) {
WM_gesture_end(C, win->tweak);
win->tweak= NULL;
}
diff --git a/source/blender/windowmanager/wm_event_system.h b/source/blender/windowmanager/wm_event_system.h
index b7c881629a2..78655a9fcd3 100644
--- a/source/blender/windowmanager/wm_event_system.h
+++ b/source/blender/windowmanager/wm_event_system.h
@@ -31,6 +31,7 @@
/* return value of handler-operator call */
#define WM_HANDLER_CONTINUE 0
#define WM_HANDLER_BREAK 1
+#define WM_HANDLER_HANDLED 2
struct ScrArea;
struct ARegion;