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-05 09:09:01 +0300
committerCampbell Barton <ideasman42@gmail.com>2021-03-05 09:10:11 +0300
commitb5d154f400e46ba322f0e08a231bb2557bf51a1e (patch)
tree554d34430b54a1bdac5315b856aa93809b2ef4b2 /source/blender/windowmanager/intern/wm_event_system.c
parent663b0bb04c324659f24e6b408ee4437cb3d5148b (diff)
Cleanup: move check_drag & check_click out of wmEvent
These variables track the wmWindow.event_queue state, however they were used in a way that wasn't correct. - check_drag & check_click from wmWindow.eventstate were used to track the click/drag status of events handled in wmWindow.event_queue. - Event's in the queue read from wmEvent.check_drag. - Once a drag action was detected, wmWindow.eventstate.check_drag was disabled. Disabling drag in the event state would not change the drag state for values already in the event queue. Simplify logic by moving these values into the window, so there is one place these variables are tracked.
Diffstat (limited to 'source/blender/windowmanager/intern/wm_event_system.c')
-rw-r--r--source/blender/windowmanager/intern/wm_event_system.c35
1 files changed, 20 insertions, 15 deletions
diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c
index d4ea7b36c9c..fe503167f8d 100644
--- a/source/blender/windowmanager/intern/wm_event_system.c
+++ b/source/blender/windowmanager/intern/wm_event_system.c
@@ -2960,8 +2960,8 @@ static int wm_handlers_do(bContext *C, wmEvent *event, ListBase *handlers)
/* Test for CLICK_DRAG events. */
if (wm_action_not_handled(action)) {
- if (event->check_drag) {
- wmWindow *win = CTX_wm_window(C);
+ wmWindow *win = CTX_wm_window(C);
+ if (win->event_queue_check_drag) {
if (WM_event_drag_test(event, &event->prevclickx)) {
int x = event->x;
int y = event->y;
@@ -2982,15 +2982,18 @@ static int wm_handlers_do(bContext *C, wmEvent *event, ListBase *handlers)
event->x = x;
event->y = y;
- win->eventstate->check_click = false;
- win->eventstate->check_drag = false;
+ win->event_queue_check_click = false;
+ if (!wm_action_not_handled(action)) {
+ /* Only disable when handled as other handlers may use this drag event. */
+ win->event_queue_check_drag = false;
+ }
}
}
}
else {
wmWindow *win = CTX_wm_window(C);
if (win) {
- win->eventstate->check_drag = false;
+ win->event_queue_check_drag = false;
}
}
}
@@ -3006,11 +3009,13 @@ static int wm_handlers_do(bContext *C, wmEvent *event, ListBase *handlers)
if (win != NULL) {
if (event->val == KM_PRESS) {
- win->eventstate->check_click = true;
- win->eventstate->check_drag = true;
+ if (event->prevval != KM_PRESS) {
+ win->event_queue_check_click = true;
+ win->event_queue_check_drag = true;
+ }
}
else if (event->val == KM_RELEASE) {
- win->eventstate->check_drag = false;
+ win->event_queue_check_drag = false;
}
}
@@ -3018,10 +3023,10 @@ static int wm_handlers_do(bContext *C, wmEvent *event, ListBase *handlers)
if (event->val == KM_RELEASE) {
if (event->prevval == KM_PRESS) {
- if (win->eventstate->check_click == true) {
+ if (win->event_queue_check_click == true) {
if (WM_event_drag_test(event, &event->prevclickx)) {
- win->eventstate->check_click = 0;
- win->eventstate->check_drag = 0;
+ win->event_queue_check_click = false;
+ win->event_queue_check_drag = false;
}
else {
/* Position is where the actual click happens, for more
@@ -3059,8 +3064,8 @@ static int wm_handlers_do(bContext *C, wmEvent *event, ListBase *handlers)
else {
wmWindow *win = CTX_wm_window(C);
if (win) {
- win->eventstate->check_click = 0;
- win->eventstate->check_drag = 0;
+ win->event_queue_check_click = false;
+ win->event_queue_check_drag = false;
}
}
}
@@ -3074,7 +3079,7 @@ static int wm_handlers_do(bContext *C, wmEvent *event, ListBase *handlers)
wmWindow *win = CTX_wm_window(C);
if (win) {
if (ISKEYMODIFIER(event->prevtype)) {
- win->eventstate->check_click = 0;
+ win->event_queue_check_click = false;
}
}
}
@@ -3497,7 +3502,7 @@ void wm_event_do_handlers(bContext *C)
* press in tool keymap can override click in editor keymap.*/
if (ISMOUSE_BUTTON(event->type) && event->val == KM_PRESS &&
!wm_action_not_handled(action)) {
- win->eventstate->check_click = false;
+ win->event_queue_check_click = false;
}
/* Update previous mouse position for following events to use. */