diff options
Diffstat (limited to 'source/blender/windowmanager/intern')
-rw-r--r-- | source/blender/windowmanager/intern/wm_event_system.c | 28 |
1 files changed, 26 insertions, 2 deletions
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; |