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:
authorCampbell Barton <ideasman42@gmail.com>2013-01-16 08:17:34 +0400
committerCampbell Barton <ideasman42@gmail.com>2013-01-16 08:17:34 +0400
commit4d65a3297dbb14bae69428b45ccd8081d39374cd (patch)
treeb935c6df76a4277351eb39fc012207ca56e69ccb /source/blender/windowmanager
parentd0e65f2bf4d5e2140752c0695d19507ffee1ebd8 (diff)
move double click check into its own function.
Diffstat (limited to 'source/blender/windowmanager')
-rw-r--r--source/blender/windowmanager/intern/wm_event_system.c35
1 files changed, 17 insertions, 18 deletions
diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c
index c7cd91dfa3e..97abfb37fe9 100644
--- a/source/blender/windowmanager/intern/wm_event_system.c
+++ b/source/blender/windowmanager/intern/wm_event_system.c
@@ -2747,6 +2747,15 @@ static wmWindow *wm_event_cursor_other_windows(wmWindowManager *wm, wmWindow *wi
return NULL;
}
+static bool wm_event_is_double_click(wmEvent *event, wmEvent *event_state)
+{
+ return (((event->type == event_state->prevtype && event_state->prevval == KM_RELEASE && event->val == KM_PRESS)) &&
+ ((ABS(event->x - event_state->prevclickx)) <= 2 &&
+ (ABS(event->y - event_state->prevclicky)) <= 2 &&
+ ((PIL_check_seconds_timer() - event_state->prevclicktime) * 1000 < U.dbl_click_time))
+ );
+}
+
/* windows store own event queues, no bContext here */
/* time is in 1000s of seconds, from ghost */
void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int UNUSED(time), void *customdata)
@@ -2868,15 +2877,10 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int U
}
/* double click test */
- if (event.type == evt->prevtype && event.val == KM_PRESS) {
- if ((ABS(event.x - evt->prevclickx)) <= 2 &&
- (ABS(event.y - evt->prevclicky)) <= 2 &&
- ((PIL_check_seconds_timer() - evt->prevclicktime) * 1000 < U.dbl_click_time))
- {
- if (G.debug & (G_DEBUG_HANDLERS | G_DEBUG_EVENTS) )
- printf("%s Send double click\n", __func__);
- event.val = KM_DBL_CLICK;
- }
+ if (wm_event_is_double_click(&event, evt)) {
+ if (G.debug & (G_DEBUG_HANDLERS | G_DEBUG_EVENTS) )
+ printf("%s Send double click\n", __func__);
+ event.val = KM_DBL_CLICK;
}
if (event.val == KM_PRESS) {
evt->prevclicktime = PIL_check_seconds_timer();
@@ -2982,15 +2986,10 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int U
/* double click test */
/* if previous event was same type, and previous was release, and now it presses... */
- if (event.type == evt->prevtype && evt->prevval == KM_RELEASE && event.val == KM_PRESS) {
- if ((ABS(event.x - evt->prevclickx)) <= 2 &&
- (ABS(event.y - evt->prevclicky)) <= 2 &&
- ((PIL_check_seconds_timer() - evt->prevclicktime) * 1000 < U.dbl_click_time))
- {
- if (G.debug & (G_DEBUG_HANDLERS | G_DEBUG_EVENTS) )
- printf("%s Send double click\n", __func__);
- evt->val = event.val = KM_DBL_CLICK;
- }
+ if (wm_event_is_double_click(&event, evt)) {
+ if (G.debug & (G_DEBUG_HANDLERS | G_DEBUG_EVENTS) )
+ printf("%s Send double click\n", __func__);
+ evt->val = event.val = KM_DBL_CLICK;
}
/* this case happens on holding a key pressed, it should not generate