Cleanup: move logic to copy the previous event state to a function
This commit is contained in:
@@ -4360,6 +4360,22 @@ static bool wm_event_is_double_click(const wmEvent *event, const wmEvent *event_
|
|||||||
return false;
|
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)
|
static wmEvent *wm_event_add_mousemove(wmWindow *win, const wmEvent *event)
|
||||||
{
|
{
|
||||||
wmEvent *event_last = win->queue.last;
|
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_tablet_data_from_ghost(&bd->tablet, &event.tablet);
|
||||||
|
|
||||||
wm_eventemulation(&event, false);
|
wm_eventemulation(&event, false);
|
||||||
|
wm_event_prev_values_set(evt);
|
||||||
/* Copy previous state to prev event state (two old!). */
|
|
||||||
evt->prevval = evt->val;
|
|
||||||
evt->prevtype = evt->type;
|
|
||||||
|
|
||||||
/* Copy to event state. */
|
/* Copy to event state. */
|
||||||
evt->val = event.val;
|
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;
|
event.val = KM_DBL_CLICK;
|
||||||
}
|
}
|
||||||
if (event.val == KM_PRESS) {
|
if (event.val == KM_PRESS) {
|
||||||
evt->prevclicktime = PIL_check_seconds_timer();
|
wm_event_prev_click_set(evt);
|
||||||
evt->prevclickx = event.x;
|
|
||||||
evt->prevclicky = event.y;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Add to other window if event is there (not to both!). */
|
/* 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;
|
event.val = (type == GHOST_kEventKeyDown) ? KM_PRESS : KM_RELEASE;
|
||||||
|
|
||||||
wm_eventemulation(&event, false);
|
wm_eventemulation(&event, false);
|
||||||
|
wm_event_prev_values_set(evt);
|
||||||
/* Copy previous state to prev event state (two old!). */
|
|
||||||
evt->prevval = evt->val;
|
|
||||||
evt->prevtype = evt->type;
|
|
||||||
|
|
||||||
/* Copy to event state. */
|
/* Copy to event state. */
|
||||||
evt->val = event.val;
|
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) {
|
if (event.val == KM_PRESS) {
|
||||||
/* Don't reset timer & location when holding the key generates repeat events. */
|
/* Don't reset timer & location when holding the key generates repeat events. */
|
||||||
if ((evt->prevtype != event.type) || (evt->prevval != KM_PRESS)) {
|
if ((evt->prevtype != event.type) || (evt->prevval != KM_PRESS)) {
|
||||||
evt->prevclicktime = PIL_check_seconds_timer();
|
wm_event_prev_click_set(evt);
|
||||||
evt->prevclickx = event.x;
|
|
||||||
evt->prevclicky = event.y;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user