Fix T44747: Drag toggle /w nodes (glitch)
It was possible to perform actions while performing a drag-toggle.
This commit is contained in:
parent
565faadd8e
commit
bfa7586ba3
Notes:
blender-bot
2023-02-14 09:07:17 +01:00
Referenced by issue #44747, Nodes: Dragging-to-toggle feature not work well sometimes
|
@ -746,7 +746,7 @@ void UI_panel_category_draw_all(struct ARegion *ar, const
|
|||
* as screen/ if ED_KEYMAP_UI is set, or internally in popup functions. */
|
||||
|
||||
void UI_region_handlers_add(struct ListBase *handlers);
|
||||
void UI_popup_handlers_add(struct bContext *C, struct ListBase *handlers, uiPopupBlockHandle *popup, const bool accept_dbl_click);
|
||||
void UI_popup_handlers_add(struct bContext *C, struct ListBase *handlers, uiPopupBlockHandle *popup, const char flag);
|
||||
void UI_popup_handlers_remove(struct ListBase *handlers, uiPopupBlockHandle *popup);
|
||||
void UI_popup_handlers_remove_all(struct bContext *C, struct ListBase *handlers);
|
||||
|
||||
|
|
|
@ -1629,10 +1629,11 @@ static bool ui_but_drag_init(bContext *C, uiBut *but, uiHandleButtonData *data,
|
|||
ar_prev = CTX_wm_region(C);
|
||||
CTX_wm_region_set(C, data->region);
|
||||
|
||||
WM_event_add_ui_handler(C, &data->window->modalhandlers,
|
||||
ui_handler_region_drag_toggle,
|
||||
ui_handler_region_drag_toggle_remove,
|
||||
drag_info, false);
|
||||
WM_event_add_ui_handler(
|
||||
C, &data->window->modalhandlers,
|
||||
ui_handler_region_drag_toggle,
|
||||
ui_handler_region_drag_toggle_remove,
|
||||
drag_info, WM_HANDLER_BLOCKING);
|
||||
|
||||
CTX_wm_region_set(C, ar_prev);
|
||||
}
|
||||
|
@ -7519,7 +7520,7 @@ static void button_activate_state(bContext *C, uiBut *but, uiHandleButtonState s
|
|||
if (!(but->block->handle && but->block->handle->popup)) {
|
||||
if (button_modal_state(state)) {
|
||||
if (!button_modal_state(data->state))
|
||||
WM_event_add_ui_handler(C, &data->window->modalhandlers, ui_handler_region_menu, NULL, data, false);
|
||||
WM_event_add_ui_handler(C, &data->window->modalhandlers, ui_handler_region_menu, NULL, data, 0);
|
||||
}
|
||||
else {
|
||||
if (button_modal_state(data->state)) {
|
||||
|
@ -9835,12 +9836,12 @@ static void ui_popup_handler_remove(bContext *C, void *userdata)
|
|||
void UI_region_handlers_add(ListBase *handlers)
|
||||
{
|
||||
WM_event_remove_ui_handler(handlers, ui_region_handler, ui_region_handler_remove, NULL, false);
|
||||
WM_event_add_ui_handler(NULL, handlers, ui_region_handler, ui_region_handler_remove, NULL, false);
|
||||
WM_event_add_ui_handler(NULL, handlers, ui_region_handler, ui_region_handler_remove, NULL, 0);
|
||||
}
|
||||
|
||||
void UI_popup_handlers_add(bContext *C, ListBase *handlers, uiPopupBlockHandle *popup, const bool accept_dbl_click)
|
||||
void UI_popup_handlers_add(bContext *C, ListBase *handlers, uiPopupBlockHandle *popup, const char flag)
|
||||
{
|
||||
WM_event_add_ui_handler(C, handlers, ui_popup_handler, ui_popup_handler_remove, popup, accept_dbl_click);
|
||||
WM_event_add_ui_handler(C, handlers, ui_popup_handler, ui_popup_handler_remove, popup, flag);
|
||||
}
|
||||
|
||||
void UI_popup_handlers_remove(ListBase *handlers, uiPopupBlockHandle *popup)
|
||||
|
|
|
@ -1294,7 +1294,7 @@ static void ui_panel_drag_collapse_handler_add(const bContext *C, const bool was
|
|||
C, &win->modalhandlers,
|
||||
ui_panel_drag_collapse_handler,
|
||||
ui_panel_drag_collapse_handler_remove,
|
||||
dragcol_data, false);
|
||||
dragcol_data, 0);
|
||||
}
|
||||
|
||||
/* this function is supposed to call general window drawing too */
|
||||
|
@ -2107,7 +2107,7 @@ static void panel_activate_state(const bContext *C, Panel *pa, uiHandlePanelStat
|
|||
data = MEM_callocN(sizeof(uiHandlePanelData), "uiHandlePanelData");
|
||||
pa->activedata = data;
|
||||
|
||||
WM_event_add_ui_handler(C, &win->modalhandlers, ui_handler_panel, ui_handler_remove_panel, pa, false);
|
||||
WM_event_add_ui_handler(C, &win->modalhandlers, ui_handler_panel, ui_handler_remove_panel, pa, 0);
|
||||
}
|
||||
|
||||
if (ELEM(state, PANEL_STATE_ANIMATION, PANEL_STATE_DRAG))
|
||||
|
|
|
@ -2617,7 +2617,7 @@ uiPopupBlockHandle *ui_popup_menu_create(
|
|||
if (!but) {
|
||||
handle->popup = true;
|
||||
|
||||
UI_popup_handlers_add(C, &window->modalhandlers, handle, false);
|
||||
UI_popup_handlers_add(C, &window->modalhandlers, handle, 0);
|
||||
WM_event_add_mousemove(C);
|
||||
}
|
||||
|
||||
|
@ -2679,7 +2679,7 @@ void UI_popup_menu_end(bContext *C, uiPopupMenu *pup)
|
|||
menu = ui_popup_block_create(C, NULL, NULL, NULL, ui_block_func_POPUP, pup);
|
||||
menu->popup = true;
|
||||
|
||||
UI_popup_handlers_add(C, &window->modalhandlers, menu, false);
|
||||
UI_popup_handlers_add(C, &window->modalhandlers, menu, 0);
|
||||
WM_event_add_mousemove(C);
|
||||
|
||||
MEM_freeN(pup);
|
||||
|
@ -2805,7 +2805,9 @@ void UI_pie_menu_end(bContext *C, uiPieMenu *pie)
|
|||
menu->popup = true;
|
||||
menu->towardstime = PIL_check_seconds_timer();
|
||||
|
||||
UI_popup_handlers_add(C, &window->modalhandlers, menu, true);
|
||||
UI_popup_handlers_add(
|
||||
C, &window->modalhandlers,
|
||||
menu, WM_HANDLER_ACCEPT_DBL_CLICK);
|
||||
WM_event_add_mousemove(C);
|
||||
|
||||
MEM_freeN(pie);
|
||||
|
@ -2997,7 +2999,7 @@ void UI_popup_block_invoke_ex(bContext *C, uiBlockCreateFunc func, void *arg, co
|
|||
handle->optype = (opname) ? WM_operatortype_find(opname, 0) : NULL;
|
||||
handle->opcontext = opcontext;
|
||||
|
||||
UI_popup_handlers_add(C, &window->modalhandlers, handle, false);
|
||||
UI_popup_handlers_add(C, &window->modalhandlers, handle, 0);
|
||||
WM_event_add_mousemove(C);
|
||||
}
|
||||
|
||||
|
@ -3020,7 +3022,7 @@ void UI_popup_block_ex(bContext *C, uiBlockCreateFunc func, uiBlockHandleFunc po
|
|||
handle->cancel_func = cancel_func;
|
||||
// handle->opcontext = opcontext;
|
||||
|
||||
UI_popup_handlers_add(C, &window->modalhandlers, handle, false);
|
||||
UI_popup_handlers_add(C, &window->modalhandlers, handle, 0);
|
||||
WM_event_add_mousemove(C);
|
||||
}
|
||||
|
||||
|
@ -3039,7 +3041,7 @@ void uiPupBlockOperator(bContext *C, uiBlockCreateFunc func, wmOperator *op, int
|
|||
handle->cancel_func = confirm_cancel_operator;
|
||||
handle->opcontext = opcontext;
|
||||
|
||||
UI_popup_handlers_add(C, &window->modalhandlers, handle);
|
||||
UI_popup_handlers_add(C, &window->modalhandlers, handle, 0);
|
||||
WM_event_add_mousemove(C);
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -151,7 +151,7 @@ typedef void (*wmUIHandlerRemoveFunc)(struct bContext *C, void *userdata);
|
|||
struct wmEventHandler *WM_event_add_ui_handler(
|
||||
const struct bContext *C, ListBase *handlers,
|
||||
wmUIHandlerFunc ui_handle, wmUIHandlerRemoveFunc ui_remove,
|
||||
void *userdata, const bool accept_dbl_click);
|
||||
void *userdata, const char flag);
|
||||
void WM_event_remove_ui_handler(
|
||||
ListBase *handlers,
|
||||
wmUIHandlerFunc ui_handle, wmUIHandlerRemoveFunc ui_remove,
|
||||
|
@ -165,6 +165,15 @@ void WM_event_free_ui_handler_all(
|
|||
struct wmEventHandler *WM_event_add_modal_handler(struct bContext *C, struct wmOperator *op);
|
||||
void WM_event_remove_handlers(struct bContext *C, ListBase *handlers);
|
||||
|
||||
/* handler flag */
|
||||
enum {
|
||||
WM_HANDLER_BLOCKING = (1 << 0), /* after this handler all others are ignored */
|
||||
WM_HANDLER_ACCEPT_DBL_CLICK = (1 << 1), /* handler accepts double key press events */
|
||||
|
||||
/* internal */
|
||||
WM_HANDLER_DO_FREE = (1 << 7), /* handler tagged to be freed in wm_handlers_do() */
|
||||
};
|
||||
|
||||
struct wmEventHandler *WM_event_add_dropbox_handler(ListBase *handlers, ListBase *dropboxes);
|
||||
|
||||
/* mouse */
|
||||
|
|
|
@ -2677,7 +2677,7 @@ void WM_event_remove_keymap_handler(ListBase *handlers, wmKeyMap *keymap)
|
|||
wmEventHandler *WM_event_add_ui_handler(
|
||||
const bContext *C, ListBase *handlers,
|
||||
wmUIHandlerFunc ui_handle, wmUIHandlerRemoveFunc ui_remove,
|
||||
void *userdata, const bool accept_dbl_click)
|
||||
void *userdata, const char flag)
|
||||
{
|
||||
wmEventHandler *handler = MEM_callocN(sizeof(wmEventHandler), "event ui handler");
|
||||
handler->ui_handle = ui_handle;
|
||||
|
@ -2694,9 +2694,8 @@ wmEventHandler *WM_event_add_ui_handler(
|
|||
handler->ui_menu = NULL;
|
||||
}
|
||||
|
||||
if (accept_dbl_click) {
|
||||
handler->flag |= WM_HANDLER_ACCEPT_DBL_CLICK;
|
||||
}
|
||||
BLI_assert((flag & WM_HANDLER_DO_FREE) == 0);
|
||||
handler->flag = flag;
|
||||
|
||||
BLI_addhead(handlers, handler);
|
||||
|
||||
|
|
|
@ -45,8 +45,8 @@ struct ARegion;
|
|||
typedef struct wmEventHandler {
|
||||
struct wmEventHandler *next, *prev;
|
||||
|
||||
int type; /* WM_HANDLER_DEFAULT, ... */
|
||||
int flag; /* WM_HANDLER_BLOCKING, ... */
|
||||
char type; /* WM_HANDLER_DEFAULT, ... */
|
||||
char flag; /* WM_HANDLER_BLOCKING, ... */
|
||||
|
||||
/* keymap handler */
|
||||
wmKeyMap *keymap; /* pointer to builtin/custom keymaps */
|
||||
|
@ -77,13 +77,6 @@ enum {
|
|||
WM_HANDLER_FILESELECT
|
||||
};
|
||||
|
||||
/* handler flag */
|
||||
enum {
|
||||
WM_HANDLER_BLOCKING = (1 << 0), /* after this handler all others are ignored */
|
||||
WM_HANDLER_DO_FREE = (1 << 1), /* handler tagged to be freed in wm_handlers_do() */
|
||||
WM_HANDLER_ACCEPT_DBL_CLICK = (1 << 2), /* handler accepts double key press events */
|
||||
};
|
||||
|
||||
/* wm_event_system.c */
|
||||
void wm_event_free_all (wmWindow *win);
|
||||
void wm_event_free (wmEvent *event);
|
||||
|
|
Loading…
Reference in New Issue