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-02 10:19:13 +0300
committerCampbell Barton <ideasman42@gmail.com>2021-03-02 10:40:15 +0300
commitc4ef90f5a0b1d05b16187eb6e32323defe6461c0 (patch)
tree7a191a715a5a82d25f28eaea71a6a177cf44e43b /source/blender/windowmanager
parentae96db0cf5576a2995132e6478dbb3508c02e58f (diff)
Fix click-drag regression in fix for T86116
1638af109e46522a1a24645289016922bb9ca977 & bfc70a6a958b9c35bde765ea8a02e8b1fd36db8b caused a regression with click-drag (not tweak which has it's own logic). Restore some changes from these commits with added comments. Minor changes from previous functionality from 39919e35326c732141bfd2d740b19000b6bc1d51. - `prevval` & `prevtype` are now set for all kinds of new events in the queue previously this was not done for some kinds of events (mouse wheel, ndof - for example). - Set `prevval` & `prevtype` for other windows for mouse buttons.
Diffstat (limited to 'source/blender/windowmanager')
-rw-r--r--source/blender/windowmanager/intern/wm_event_query.c7
-rw-r--r--source/blender/windowmanager/intern/wm_event_system.c25
2 files changed, 28 insertions, 4 deletions
diff --git a/source/blender/windowmanager/intern/wm_event_query.c b/source/blender/windowmanager/intern/wm_event_query.c
index 2f5332e9672..9b9be6bb497 100644
--- a/source/blender/windowmanager/intern/wm_event_query.c
+++ b/source/blender/windowmanager/intern/wm_event_query.c
@@ -280,8 +280,11 @@ int WM_event_drag_threshold(const struct wmEvent *event)
if (WM_event_is_tablet(event)) {
drag_threshold = U.drag_threshold_tablet;
}
- else if (ISMOUSE(event->type)) {
- /* Mouse button or mouse motion. */
+ else if (ISMOUSE(event->prevtype)) {
+ BLI_assert(event->prevtype != MOUSEMOVE);
+ /* Using the previous type is important is we want to check the last pressed/released button,
+ * The `event->type` would include #MOUSEMOVE which is always the case when dragging
+ * and does not help us know which threshold to use. */
drag_threshold = U.drag_threshold_mouse;
}
else {
diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c
index a1a9c24d178..411ecb1cac8 100644
--- a/source/blender/windowmanager/intern/wm_event_system.c
+++ b/source/blender/windowmanager/intern/wm_event_system.c
@@ -4458,6 +4458,19 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, void
event = *evt;
event.is_repeat = false;
+ /**
+ * Always support accessing the last key press/release. This is set from `win->eventstate`,
+ * so it will always be a valid event type to store in the previous state.
+ *
+ * Note that these values are intentionally _not_ set in the `win->eventstate`,
+ * as copying these values only makes sense when `win->eventstate->{val/type}` would be
+ * written to (which only happens for some kinds of events).
+ * If this was done it could leave `win->eventstate` previous and current value
+ * set to the same key press/release state which doesn't make sense.
+ */
+ event.prevtype = event.type;
+ event.prevval = event.val;
+
/* Ensure the event state is correct, any deviation from this may cause bugs. */
#ifndef NDEBUG
if ((evt->type || evt->val) && /* Ignore cleared event state. */
@@ -4498,6 +4511,10 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, void
oevent = *oevt;
+ /* See comment for this operation on `event` for details. */
+ oevent.prevtype = oevent.type;
+ oevent.prevval = oevent.val;
+
copy_v2_v2_int(&oevent.x, &event.x);
oevent.type = MOUSEMOVE;
{
@@ -4593,8 +4610,12 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, void
if (owin) {
wmEvent oevent = *(owin->eventstate);
- oevent.x = event.x;
- oevent.y = event.y;
+ /* See comment for this operation on `event` for details. */
+ oevent.prevtype = oevent.type;
+ oevent.prevval = oevent.val;
+
+ copy_v2_v2_int(&oevent.x, &event.x);
+
oevent.type = event.type;
oevent.val = event.val;
oevent.tablet = event.tablet;