diff options
author | Campbell Barton <ideasman42@gmail.com> | 2021-03-01 04:21:58 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2021-03-01 08:54:52 +0300 |
commit | 6de41bed2ff8cd8ddcaf429ff291152023c0f28c (patch) | |
tree | ac3519ee5178c1bf8ad30476496bef424949da34 /source/blender/windowmanager/intern | |
parent | 72d1545ec202c61d02c3024a61605b045d2c2640 (diff) |
Cleanup: move logic to copy the previous event state to a function
Diffstat (limited to 'source/blender/windowmanager/intern')
-rw-r--r-- | source/blender/windowmanager/intern/wm_event_system.c | 34 |
1 files changed, 20 insertions, 14 deletions
diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index 9188cac3ed7..f6f7bc64b70 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -4360,6 +4360,22 @@ static bool wm_event_is_double_click(const wmEvent *event, const wmEvent *event_ return false; } +/** + * Copy the current state to the previous event state. + */ +static void wm_event_prev_values_set(wmEvent *event_state) +{ + event_state->prevval = event_state->val; + event_state->prevtype = event_state->type; +} + +static void wm_event_prev_click_set(wmEvent *event_state) +{ + event_state->prevclicktime = PIL_check_seconds_timer(); + event_state->prevclickx = event_state->x; + event_state->prevclicky = event_state->y; +} + static wmEvent *wm_event_add_mousemove(wmWindow *win, const wmEvent *event) { wmEvent *event_last = win->queue.last; @@ -4523,10 +4539,7 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, void wm_tablet_data_from_ghost(&bd->tablet, &event.tablet); wm_eventemulation(&event, false); - - /* Copy previous state to prev event state (two old!). */ - evt->prevval = evt->val; - evt->prevtype = evt->type; + wm_event_prev_values_set(evt); /* Copy to event state. */ evt->val = event.val; @@ -4538,9 +4551,7 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, void event.val = KM_DBL_CLICK; } if (event.val == KM_PRESS) { - evt->prevclicktime = PIL_check_seconds_timer(); - evt->prevclickx = event.x; - evt->prevclicky = event.y; + wm_event_prev_click_set(evt); } /* Add to other window if event is there (not to both!). */ @@ -4575,10 +4586,7 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, void event.val = (type == GHOST_kEventKeyDown) ? KM_PRESS : KM_RELEASE; wm_eventemulation(&event, false); - - /* Copy previous state to prev event state (two old!). */ - evt->prevval = evt->val; - evt->prevtype = evt->type; + wm_event_prev_values_set(evt); /* Copy to event state. */ evt->val = event.val; @@ -4707,9 +4715,7 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, void if (event.val == KM_PRESS) { /* Don't reset timer & location when holding the key generates repeat events. */ if ((evt->prevtype != event.type) || (evt->prevval != KM_PRESS)) { - evt->prevclicktime = PIL_check_seconds_timer(); - evt->prevclickx = event.x; - evt->prevclicky = event.y; + wm_event_prev_click_set(evt); } } |