[Bf-blender-cvs] [6dffdb02fa2] blender-v2.93-release: Fix drag event leaving the gizmo not under the cursor highlighted

Campbell Barton noreply at git.blender.org
Mon Apr 19 09:36:19 CEST 2021


Commit: 6dffdb02fa2a416cc8ffb49d8b842704aadad3a9
Author: Campbell Barton
Date:   Mon Apr 19 17:18:59 2021 +1000
Branches: blender-v2.93-release
https://developer.blender.org/rB6dffdb02fa2a416cc8ffb49d8b842704aadad3a9

Fix drag event leaving the gizmo not under the cursor highlighted

Prevent drag events from changing the highlighted gizmo
unless the drag event activates the gizmo.

This resolves a glitch where testing a drag event would highlight
at the point the drag was initiated even when the event was not handled.

===================================================================

M	source/blender/windowmanager/intern/wm_event_system.c

===================================================================

diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c
index 0764dce7158..0d1f4cc4830 100644
--- a/source/blender/windowmanager/intern/wm_event_system.c
+++ b/source/blender/windowmanager/intern/wm_event_system.c
@@ -2599,6 +2599,10 @@ static int wm_handlers_do_gizmo_handler(bContext *C,
    * Get the highlight again in case the user dragged off the gizmo. */
   const bool is_event_drag = ISTWEAK(event->type) || (event->val == KM_CLICK_DRAG);
   const bool is_event_modifier = ISKEYMODIFIER(event->type);
+  /* Only keep the highlight if the gizmo becomes modal as result of event handling.
+   * Without this check, even un-handled drag events will set the highlight if the drag
+   * was initiated over a gizmo. */
+  const bool restore_highlight_unless_activated = is_event_drag;
 
   int action = WM_HANDLER_CONTINUE;
   ScrArea *area = CTX_wm_area(C);
@@ -2613,8 +2617,10 @@ static int wm_handlers_do_gizmo_handler(bContext *C,
   if (region->type->clip_gizmo_events_by_ui) {
     if (UI_region_block_find_mouse_over(region, &event->x, true)) {
       if (gz != NULL && event->type != EVT_GIZMO_UPDATE) {
-        WM_tooltip_clear(C, CTX_wm_window(C));
-        wm_gizmomap_highlight_set(gzmap, C, NULL, 0);
+        if (restore_highlight_unless_activated == false) {
+          WM_tooltip_clear(C, CTX_wm_window(C));
+          wm_gizmomap_highlight_set(gzmap, C, NULL, 0);
+        }
       }
       return action;
     }
@@ -2652,6 +2658,14 @@ static int wm_handlers_do_gizmo_handler(bContext *C,
     handle_keymap = true;
   }
 
+  /* There is no need to handle this event when the key-map isn't being applied
+   * since any change to the highlight will be restored to the previous value. */
+  if (restore_highlight_unless_activated) {
+    if ((handle_highlight == true) && (handle_keymap == false)) {
+      return action;
+    }
+  }
+
   if (handle_highlight) {
     int part = -1;
     gz = wm_gizmomap_highlight_find(gzmap, C, event, &part);
@@ -2737,6 +2751,16 @@ static int wm_handlers_do_gizmo_handler(bContext *C,
     }
   }
 
+  if (handle_highlight) {
+    if (restore_highlight_unless_activated) {
+      /* Check handling the key-map didn't activate a gizmo. */
+      wmGizmo *gz_modal = wm_gizmomap_modal_get(gzmap);
+      if (!(gz_modal && (gz_modal != prev.gz_modal))) {
+        wm_gizmomap_highlight_set(gzmap, C, prev.gz, prev.part);
+      }
+    }
+  }
+
   if (is_event_handle_all) {
     if (action == WM_HANDLER_CONTINUE) {
       action |= WM_HANDLER_BREAK | WM_HANDLER_MODAL;



More information about the Bf-blender-cvs mailing list