diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index e46def3be6f..c5211fe9dd7 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -7606,6 +7606,14 @@ static int ui_handler_popup(bContext *C, const wmEvent *event, void *userdata) ui_popup_block_free(C, menu); UI_remove_popup_handlers(&CTX_wm_window(C)->modalhandlers, menu); +#ifdef USE_DRAG_TOGGLE + { + wmWindow *win = CTX_wm_window(C); + WM_event_free_ui_handler_all(C, &win->modalhandlers, + ui_handler_region_drag_toggle, ui_handler_region_drag_toggle_remove); + } +#endif + if ((temp.menuretval & UI_RETURN_OK) || (temp.menuretval & UI_RETURN_POPUP_OK)) { if (temp.popup_func) temp.popup_func(C, temp.popup_arg, temp.retvalue); diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index 585201bc559..9830dcb9e9f 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -159,6 +159,9 @@ void WM_event_remove_ui_handler(ListBase *handlers, void (*remove)(struct bContext *C, void *userdata), void *userdata, const bool postpone); void WM_event_remove_area_handler(struct ListBase *handlers, void *area); +void WM_event_free_ui_handler_all(struct bContext *C, ListBase *handlers, + int (*func)(struct bContext *C, const struct wmEvent *event, void *userdata), + void (*remove)(struct bContext *C, void *userdata)); struct wmEventHandler *WM_event_add_modal_handler(struct bContext *C, struct wmOperator *op); void WM_event_remove_handlers(struct bContext *C, ListBase *handlers); diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index 89dc6ccc038..03a1785541e 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -2476,6 +2476,21 @@ void WM_event_remove_ui_handler(ListBase *handlers, } } +void WM_event_free_ui_handler_all(bContext *C, ListBase *handlers, + wmUIHandlerFunc func, wmUIHandlerRemoveFunc remove) +{ + wmEventHandler *handler, *handler_next; + + for (handler = handlers->first; handler; handler = handler_next) { + handler_next = handler->next; + if (handler->ui_handle == func && handler->ui_remove == remove) { + remove(C, handler->ui_userdata); + BLI_remlink(handlers, handler); + wm_event_free_handler(handler); + } + } +} + wmEventHandler *WM_event_add_dropbox_handler(ListBase *handlers, ListBase *dropboxes) { wmEventHandler *handler;