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
path: root/source
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2021-04-16 16:46:21 +0300
committerCampbell Barton <ideasman42@gmail.com>2021-04-16 16:50:05 +0300
commit7bbead1e87254623deed56f588e65f524d14343b (patch)
treefc189b75c782aa10348dae5e77d5e2fb560858c0 /source
parent278b19745b9d8d8f108f98d7686d0366fbbde736 (diff)
WM: prevent drag events being continually tested
Click-drag events that weren't handled would continually be tested for each mouse-motion event. As well as being redundant, this added the overhead of querying gizmos twice per motion event. Now click-drag is only tested once when the drag threshold is reached. This mitigates T87511, although the single drag test still causes the snap gizmo to flicker.
Diffstat (limited to 'source')
-rw-r--r--source/blender/makesdna/DNA_windowmanager_types.h8
-rw-r--r--source/blender/windowmanager/intern/wm.c1
-rw-r--r--source/blender/windowmanager/intern/wm_event_system.c10
3 files changed, 18 insertions, 1 deletions
diff --git a/source/blender/makesdna/DNA_windowmanager_types.h b/source/blender/makesdna/DNA_windowmanager_types.h
index 130b308f224..59091fec4b8 100644
--- a/source/blender/makesdna/DNA_windowmanager_types.h
+++ b/source/blender/makesdna/DNA_windowmanager_types.h
@@ -278,8 +278,14 @@ typedef struct wmWindow {
char event_queue_check_click;
/** Enable when #KM_PRESS events are not handled (keyboard/mouse-buttons only). */
char event_queue_check_drag;
+ /**
+ * Enable when the drag was handled,
+ * to avoid mouse-motion continually triggering drag events which are not handled
+ * but add overhead to gizmo handling (for example), see T87511.
+ */
+ char event_queue_check_drag_handled;
- char _pad0[2];
+ char _pad0[1];
/** Internal, lock pie creation from this event until released. */
short pie_event_type_lock;
diff --git a/source/blender/windowmanager/intern/wm.c b/source/blender/windowmanager/intern/wm.c
index ae5b6c468f7..46e47ae95c4 100644
--- a/source/blender/windowmanager/intern/wm.c
+++ b/source/blender/windowmanager/intern/wm.c
@@ -186,6 +186,7 @@ static void window_manager_blend_read_data(BlendDataReader *reader, ID *id)
win->addmousemove = true;
win->event_queue_check_click = 0;
win->event_queue_check_drag = 0;
+ win->event_queue_check_drag_handled = 0;
BLO_read_data_address(reader, &win->stereo3d_format);
/* Multi-view always fallback to anaglyph at file opening
diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c
index 627ec1d5722..cb4aa3b6549 100644
--- a/source/blender/windowmanager/intern/wm_event_system.c
+++ b/source/blender/windowmanager/intern/wm_event_system.c
@@ -2941,6 +2941,8 @@ static int wm_handlers_do(bContext *C, wmEvent *event, ListBase *handlers)
if (wm_action_not_handled(action)) {
if (win->event_queue_check_drag) {
if (WM_event_drag_test(event, &event->prevclickx)) {
+ win->event_queue_check_drag_handled = true;
+
int x = event->x;
int y = event->y;
short val = event->val;
@@ -2984,6 +2986,7 @@ static int wm_handlers_do(bContext *C, wmEvent *event, ListBase *handlers)
if (event->is_repeat == false) {
win->event_queue_check_click = true;
win->event_queue_check_drag = true;
+ win->event_queue_check_drag_handled = false;
}
}
else if (event->val == KM_RELEASE) {
@@ -3470,6 +3473,13 @@ void wm_event_do_handlers(bContext *C)
win->event_queue_check_click = false;
}
+ /* If the drag even was handled, don't attempt to keep re-handing the same
+ * drag event on every cursor motion, see: T87511. */
+ if (win->event_queue_check_drag_handled) {
+ win->event_queue_check_drag = false;
+ win->event_queue_check_drag_handled = false;
+ }
+
/* Update previous mouse position for following events to use. */
win->eventstate->prevx = event->x;
win->eventstate->prevy = event->y;