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>2021-03-01 06:12:27 +0300
committerCampbell Barton <ideasman42@gmail.com>2021-03-01 09:12:46 +0300
commitbfc70a6a958b9c35bde765ea8a02e8b1fd36db8b (patch)
treecfbea592e8434e8a670bc48f3292c039f704b313
parentd8b35219d1e71ba4c3e16ec4a9b057aaf65e9f37 (diff)
Fix T86116: Failure to detect click events with modifier held
Click detection logic relied on the event queue not accumulating events as newly added events at the end of the queue adjusted `wm->eventstate->prev{val/type}` which was then compared with events at the front of the queue. This made Ctrl-Click fail to detect the click as releasing Ctrl set the previous value before the previous event was handled. In practice this only happened in heavy scenes, updating 10 fps or lower. It also made automated tests fail that accumulate events before handling them.
-rw-r--r--source/blender/windowmanager/intern/wm_event_system.c28
1 files changed, 14 insertions, 14 deletions
diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c
index 22fa3838ac3..205e49c5ab4 100644
--- a/source/blender/windowmanager/intern/wm_event_system.c
+++ b/source/blender/windowmanager/intern/wm_event_system.c
@@ -2960,16 +2960,16 @@ static int wm_handlers_do(bContext *C, wmEvent *event, ListBase *handlers)
if (wm_action_not_handled(action)) {
if (event->check_drag) {
wmWindow *win = CTX_wm_window(C);
- if (WM_event_drag_test(event, &win->eventstate->prevclickx)) {
+ if (WM_event_drag_test(event, &event->prevclickx)) {
int x = event->x;
int y = event->y;
short val = event->val;
short type = event->type;
- event->x = win->eventstate->prevclickx;
- event->y = win->eventstate->prevclicky;
+ event->x = event->prevclickx;
+ event->y = event->prevclicky;
event->val = KM_CLICK_DRAG;
- event->type = win->eventstate->type;
+ event->type = event->prevtype;
CLOG_INFO(WM_LOG_HANDLERS, 1, "handling PRESS_DRAG");
@@ -3012,12 +3012,12 @@ static int wm_handlers_do(bContext *C, wmEvent *event, ListBase *handlers)
}
}
- if (win && win->eventstate->prevtype == event->type) {
+ if (win && event->prevtype == event->type) {
if (event->val == KM_RELEASE) {
- if (win->eventstate->prevval == KM_PRESS) {
+ if (event->prevval == KM_PRESS) {
if (win->eventstate->check_click == true) {
- if (WM_event_drag_test(event, &win->eventstate->prevclickx)) {
+ if (WM_event_drag_test(event, &event->prevclickx)) {
win->eventstate->check_click = 0;
win->eventstate->check_drag = 0;
}
@@ -3071,7 +3071,7 @@ static int wm_handlers_do(bContext *C, wmEvent *event, ListBase *handlers)
else {
wmWindow *win = CTX_wm_window(C);
if (win) {
- if (ISKEYMODIFIER(win->eventstate->type)) {
+ if (ISKEYMODIFIER(event->prevtype)) {
win->eventstate->check_click = 0;
}
}
@@ -4358,15 +4358,15 @@ static wmWindow *wm_event_cursor_other_windows(wmWindowManager *wm, wmWindow *wi
return NULL;
}
-static bool wm_event_is_double_click(const wmEvent *event, const wmEvent *event_state)
+static bool wm_event_is_double_click(const wmEvent *event)
{
- if ((event->type == event_state->prevtype) && (event_state->prevval == KM_RELEASE) &&
+ if ((event->type == event->prevtype) && (event->prevval == KM_RELEASE) &&
(event->val == KM_PRESS)) {
- if (ISMOUSE(event->type) && WM_event_drag_test(event, &event_state->prevclickx)) {
+ if (ISMOUSE(event->type) && WM_event_drag_test(event, &event->prevclickx)) {
/* Pass. */
}
else {
- if ((PIL_check_seconds_timer() - event_state->prevclicktime) * 1000 < U.dbl_click_time) {
+ if ((PIL_check_seconds_timer() - event->prevclicktime) * 1000 < U.dbl_click_time) {
return true;
}
}
@@ -4561,7 +4561,7 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, void
evt->type = event.type;
/* Double click test. */
- if (wm_event_is_double_click(&event, evt)) {
+ if (wm_event_is_double_click(&event)) {
CLOG_INFO(WM_LOG_HANDLERS, 1, "Send double click");
event.val = KM_DBL_CLICK;
}
@@ -4699,7 +4699,7 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, void
/* Double click test. */
/* If previous event was same type, and previous was release, and now it presses... */
- if (wm_event_is_double_click(&event, evt)) {
+ if (wm_event_is_double_click(&event)) {
CLOG_INFO(WM_LOG_HANDLERS, 1, "Send double click");
event.val = KM_DBL_CLICK;
}