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
diff options
context:
space:
mode:
authorMartin Poirier <theeth@yahoo.com>2009-12-11 02:24:29 +0300
committerMartin Poirier <theeth@yahoo.com>2009-12-11 02:24:29 +0300
commit5a0436b8ea44bf4a90993c255f9fc7cda048bc73 (patch)
tree88fa642605aab517621080c17531f00c325477c4
parentab7e9da34299d029eab38e3e4e758ebead0b659e (diff)
Double Click plays nicer with Click.
1) Double Click takes priority over a second Click (Click will still be send if not handled) 2) The first Click being handled doesn't stop the following Double Click
-rw-r--r--source/blender/windowmanager/intern/wm_event_system.c30
1 files changed, 21 insertions, 9 deletions
diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c
index 9aad7da7a58..906a166a28c 100644
--- a/source/blender/windowmanager/intern/wm_event_system.c
+++ b/source/blender/windowmanager/intern/wm_event_system.c
@@ -1093,6 +1093,11 @@ static int handler_boundbox_test(wmEventHandler *handler, wmEvent *event)
return 1;
}
+static int wm_action_not_handled(int action)
+{
+ return action == WM_HANDLER_CONTINUE || action == (WM_HANDLER_BREAK|WM_HANDLER_MODAL);
+}
+
static int wm_handlers_do(bContext *C, wmEvent *event, ListBase *handlers)
{
wmWindowManager *wm= CTX_wm_manager(C);
@@ -1158,21 +1163,24 @@ static int wm_handlers_do(bContext *C, wmEvent *event, ListBase *handlers)
}
/* test for CLICK event */
- if ((action == WM_HANDLER_CONTINUE || action == (WM_HANDLER_BREAK|WM_HANDLER_MODAL)) && event->val == KM_RELEASE) {
+ if (wm_action_not_handled(action) && event->val == KM_RELEASE) {
wmWindow *win = CTX_wm_window(C);
if (win && win->last_type == event->type && win->last_val == KM_PRESS) {
- event->val = KM_CLICK;
- action |= wm_handlers_do(C, event, handlers);
-
- /* if not handled and time is right, check double click */
- if ((action & WM_HANDLER_BREAK) == 0 && (PIL_check_seconds_timer() - win->last_click_time) * 1000 < U.dbl_click_time) {
+ /* test for double click first */
+ if ((PIL_check_seconds_timer() - win->last_click_time) * 1000 < U.dbl_click_time) {
event->val = KM_DBL_CLICK;
action |= wm_handlers_do(C, event, handlers);
}
+ if (wm_action_not_handled(action)) {
+ event->val = KM_CLICK;
+ action |= wm_handlers_do(C, event, handlers);
+ }
+
+
/* revert value if not handled */
- if ((action & WM_HANDLER_BREAK) == 0) {
+ if (wm_action_not_handled(action)) {
event->val = KM_RELEASE;
}
}
@@ -1361,7 +1369,7 @@ void wm_event_do_handlers(bContext *C)
/* store last event for this window */
/* mousemove event don't overwrite last type */
if (event->type != MOUSEMOVE) {
- if (action == WM_HANDLER_CONTINUE || action == (WM_HANDLER_BREAK|WM_HANDLER_MODAL)) {
+ if (wm_action_not_handled(action)) {
if (win->last_type == event->type) {
/* set click time on first click (press -> release) */
if (win->last_val == KM_PRESS && event->val == KM_RELEASE) {
@@ -1374,7 +1382,11 @@ void wm_event_do_handlers(bContext *C)
win->last_val = event->val;
win->last_type = event->type;
- } else {
+ } else if (event->val == KM_CLICK) { /* keep click for double click later */
+ win->last_type = event->type;
+ win->last_val = event->val;
+ win->last_click_time = PIL_check_seconds_timer();
+ } else { /* reset if not */
win->last_type = -1;
win->last_val = 0;
win->last_click_time = 0;