Cleanup: move logic to copy the previous event state to a function
This commit is contained in:
parent
72d1545ec2
commit
6de41bed2f
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue