diff options
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/editors/interface/interface_handlers.c | 7 | ||||
-rw-r--r-- | source/blender/windowmanager/WM_api.h | 3 | ||||
-rw-r--r-- | source/blender/windowmanager/WM_types.h | 2 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_event_system.c | 2 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_tooltip.c | 32 |
5 files changed, 34 insertions, 12 deletions
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 11106dd403f..b34188684e6 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -294,6 +294,7 @@ typedef struct uiHandleButtonMulti { typedef struct uiHandleButtonData { wmWindowManager *wm; wmWindow *window; + ScrArea *area; ARegion *region; bool interactive; @@ -7721,7 +7722,8 @@ static void button_tooltip_timer_reset(bContext *C, uiBut *but) if (!wm->drags.first) { bool is_label = UI_but_has_tooltip_label(but); double delay = is_label ? UI_TOOLTIP_DELAY_LABEL : UI_TOOLTIP_DELAY; - WM_tooltip_timer_init_ex(C, data->window, data->region, ui_but_tooltip_init, delay); + WM_tooltip_timer_init_ex( + C, data->window, data->area, data->region, ui_but_tooltip_init, delay); if (is_label) { bScreen *sc = WM_window_get_active_screen(data->window); if (sc->tool_tip) { @@ -7927,6 +7929,7 @@ static void button_activate_init(bContext *C, ARegion *ar, uiBut *but, uiButtonA data = MEM_callocN(sizeof(uiHandleButtonData), "uiHandleButtonData"); data->wm = CTX_wm_manager(C); data->window = CTX_wm_window(C); + data->area = CTX_wm_area(C); BLI_assert(ar != NULL); data->region = ar; @@ -8009,7 +8012,7 @@ static void button_activate_init(bContext *C, ARegion *ar, uiBut *but, uiButtonA /* Show a label for this button. */ bScreen *sc = WM_window_get_active_screen(data->window); if ((PIL_check_seconds_timer() - WM_tooltip_time_closed()) < 0.1) { - WM_tooltip_immediate_init(C, CTX_wm_window(C), ar, ui_but_tooltip_init); + WM_tooltip_immediate_init(C, CTX_wm_window(C), data->area, ar, ui_but_tooltip_init); if (sc->tool_tip) { sc->tool_tip->pass = 1; } diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index 44fd9158934..72ccbb0fb55 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -821,15 +821,18 @@ typedef struct ARegion *(*wmTooltipInitFn)(struct bContext *C, void WM_tooltip_immediate_init(struct bContext *C, struct wmWindow *win, + struct ScrArea *sa, struct ARegion *ar, wmTooltipInitFn init); void WM_tooltip_timer_init_ex(struct bContext *C, struct wmWindow *win, + struct ScrArea *sa, struct ARegion *ar, wmTooltipInitFn init, double delay); void WM_tooltip_timer_init(struct bContext *C, struct wmWindow *win, + struct ScrArea *sa, struct ARegion *ar, wmTooltipInitFn init); void WM_tooltip_timer_clear(struct bContext *C, struct wmWindow *win); diff --git a/source/blender/windowmanager/WM_types.h b/source/blender/windowmanager/WM_types.h index 15ad8cbedc4..0c3a5f92113 100644 --- a/source/blender/windowmanager/WM_types.h +++ b/source/blender/windowmanager/WM_types.h @@ -894,6 +894,8 @@ typedef struct wmDropBox { typedef struct wmTooltipState { /** Create tooltip on this event. */ struct wmTimer *timer; + /** The area the tooltip is created in. */ + struct ScrArea *area_from; /** The region the tooltip is created in. */ struct ARegion *region_from; /** The tooltip region. */ diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index c63bc24d58e..180a518de2b 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -2850,7 +2850,7 @@ static int wm_handlers_do_intern(bContext *C, wmEvent *event, ListBase *handlers if (wm_gizmomap_highlight_set(gzmap, C, gz, part)) { if (gz != NULL) { if (U.flag & USER_TOOLTIPS) { - WM_tooltip_timer_init(C, CTX_wm_window(C), region, WM_gizmomap_tooltip_init); + WM_tooltip_timer_init(C, CTX_wm_window(C), area, region, WM_gizmomap_tooltip_init); } } } diff --git a/source/blender/windowmanager/intern/wm_tooltip.c b/source/blender/windowmanager/intern/wm_tooltip.c index 3a219d7a573..b192ea94010 100644 --- a/source/blender/windowmanager/intern/wm_tooltip.c +++ b/source/blender/windowmanager/intern/wm_tooltip.c @@ -42,7 +42,8 @@ double WM_tooltip_time_closed(void) return g_tooltip_time_closed; } -void WM_tooltip_immediate_init(bContext *C, wmWindow *win, ARegion *ar, wmTooltipInitFn init) +void WM_tooltip_immediate_init( + bContext *C, wmWindow *win, ScrArea *sa, ARegion *ar, wmTooltipInitFn init) { WM_tooltip_timer_clear(C, win); @@ -50,13 +51,14 @@ void WM_tooltip_immediate_init(bContext *C, wmWindow *win, ARegion *ar, wmToolti if (screen->tool_tip == NULL) { screen->tool_tip = MEM_callocN(sizeof(*screen->tool_tip), __func__); } + screen->tool_tip->area_from = sa; screen->tool_tip->region_from = ar; screen->tool_tip->init = init; WM_tooltip_init(C, win); } void WM_tooltip_timer_init_ex( - bContext *C, wmWindow *win, ARegion *ar, wmTooltipInitFn init, double delay) + bContext *C, wmWindow *win, ScrArea *sa, ARegion *ar, wmTooltipInitFn init, double delay) { WM_tooltip_timer_clear(C, win); @@ -65,14 +67,16 @@ void WM_tooltip_timer_init_ex( if (screen->tool_tip == NULL) { screen->tool_tip = MEM_callocN(sizeof(*screen->tool_tip), __func__); } + screen->tool_tip->area_from = sa; screen->tool_tip->region_from = ar; screen->tool_tip->timer = WM_event_add_timer(wm, win, TIMER, delay); screen->tool_tip->init = init; } -void WM_tooltip_timer_init(bContext *C, wmWindow *win, ARegion *ar, wmTooltipInitFn init) +void WM_tooltip_timer_init( + bContext *C, wmWindow *win, ScrArea *sa, ARegion *ar, wmTooltipInitFn init) { - WM_tooltip_timer_init_ex(C, win, ar, init, UI_TOOLTIP_DELAY); + WM_tooltip_timer_init_ex(C, win, sa, ar, init, UI_TOOLTIP_DELAY); } void WM_tooltip_timer_clear(bContext *C, wmWindow *win) @@ -112,11 +116,21 @@ void WM_tooltip_init(bContext *C, wmWindow *win) } const int pass_prev = screen->tool_tip->pass; double pass_delay = 0.0; - screen->tool_tip->region = screen->tool_tip->init(C, - screen->tool_tip->region_from, - &screen->tool_tip->pass, - &pass_delay, - &screen->tool_tip->exit_on_event); + + { + ScrArea *area_prev = CTX_wm_area(C); + ARegion *ar_prev = CTX_wm_region(C); + CTX_wm_area_set(C, screen->tool_tip->area_from); + CTX_wm_region_set(C, screen->tool_tip->region_from); + screen->tool_tip->region = screen->tool_tip->init(C, + screen->tool_tip->region_from, + &screen->tool_tip->pass, + &pass_delay, + &screen->tool_tip->exit_on_event); + CTX_wm_area_set(C, area_prev); + CTX_wm_region_set(C, ar_prev); + } + copy_v2_v2_int(screen->tool_tip->event_xy, &win->eventstate->x); if (pass_prev != screen->tool_tip->pass) { /* The pass changed, add timer for next pass. */ |