Stickies: Don't send extra event on KM_CLICK

Just add KM_CLICK to the already sent KM_RELEASE, don't send a new one
for this.

This might help us to get rid of quite some glitches and workarounds \o/
(why didn't this come earlier to my mind? :S)
This commit is contained in:
Julian Eisel
2015-04-05 19:32:57 +02:00
parent af23e8d44a
commit 776bfa64a5
2 changed files with 18 additions and 12 deletions

View File

@@ -2994,7 +2994,7 @@ static wmWindow *wm_event_cursor_other_windows(wmWindowManager *wm, wmWindow *wi
* - #KM_PRESS && time since first #KM_PRESS > U.click_timeout --> send #KM_HOLD * - #KM_PRESS && time since first #KM_PRESS > U.click_timeout --> send #KM_HOLD
* - #KM_PRESS after a #KM_RELEASE && time since previous #KM_PRESS < U.dbl_click_time --> send #KM_DBL_CLICK * - #KM_PRESS after a #KM_RELEASE && time since previous #KM_PRESS < U.dbl_click_time --> send #KM_DBL_CLICK
* *
* \note: only #KM_DBL_CLICK is handled here, rest in #wm_window_event_clicktype_init (wm_window.c) * \note: only #KM_DBL_CLICK and #KM_CLICK are handled here, #KM_HOLD in #wm_window_event_clicktype_init (wm_window.c)
*/ */
static void wm_event_clicktype_init(wmWindow *win, wmEvent *event, wmEvent *event_state) static void wm_event_clicktype_init(wmWindow *win, wmEvent *event, wmEvent *event_state)
{ {
@@ -3025,6 +3025,19 @@ static void wm_event_clicktype_init(wmWindow *win, wmEvent *event, wmEvent *even
} }
} }
if ((PIL_check_seconds_timer() - event->click_time) * 1000 <= U.click_timeout) {
/* for any reason some X11 systems send two release events triggering two KM_CLICK events
* - making the rules more strict by checking for prevval resolves this (not needed for mouse) */
if (event->val == KM_RELEASE &&
(ISMOUSE(event->type) || event->prevval != KM_RELEASE))
{
click_type = KM_CLICK;
if (G.debug & (G_DEBUG_HANDLERS | G_DEBUG_EVENTS)) {
printf("%s Send click event\n", __func__);
}
}
}
if (click_type != event->click_type) { if (click_type != event->click_type) {
event_state->click_type = event->click_type = click_type; event_state->click_type = event->click_type = click_type;
} }

View File

@@ -1098,9 +1098,9 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_ptr
} }
/** /**
* #KM_DBL_CLICK is set in wm_event_clicktype_init (wm_event_system.c) * #KM_DBL_CLICK and #KM_CLICK are set in wm_event_clicktype_init (wm_event_system.c)
* Normally, this should be there too, but for #KM_CLICK/#KM_HOLD, we need a * Normally, #KM_HOLD should be there too, but we need a time precision of a few
* time precision of a few milliseconds, which we can't get from there * milliseconds for it, which we can't get from there
*/ */
static void wm_window_event_clicktype_init(const bContext *C) static void wm_window_event_clicktype_init(const bContext *C)
{ {
@@ -1141,14 +1141,7 @@ static void wm_window_event_clicktype_init(const bContext *C)
/* the actual test */ /* the actual test */
if ((PIL_check_seconds_timer() - event->click_time) * 1000 <= U.click_timeout) { if ((PIL_check_seconds_timer() - event->click_time) * 1000 <= U.click_timeout) {
/* for any reason some X11 systems send two release events triggering two KM_CLICK /* sending of KM_CLICK is handled in wm_event_clicktype_init (wm_event_system.c) */
* events - making the rules more strict by checking for prevval resolves this */
if (event->val == KM_RELEASE && event->prevval != KM_RELEASE) {
click_type = KM_CLICK;
if (G.debug & (G_DEBUG_HANDLERS | G_DEBUG_EVENTS)) {
printf("%s Send click event\n", __func__);
}
}
} }
else if (event->is_key_pressed) { else if (event->is_key_pressed) {
click_type = KM_HOLD; click_type = KM_HOLD;