diff options
Diffstat (limited to 'source/blender/windowmanager/intern')
8 files changed, 68 insertions, 44 deletions
diff --git a/source/blender/windowmanager/intern/wm_draw.c b/source/blender/windowmanager/intern/wm_draw.c index c2a63c9db7a..63a7fb5ddaa 100644 --- a/source/blender/windowmanager/intern/wm_draw.c +++ b/source/blender/windowmanager/intern/wm_draw.c @@ -1153,9 +1153,17 @@ static bool wm_draw_update_test_window(Main *bmain, bContext *C, wmWindow *win) if (wm_software_cursor_needed()) { struct GrabState grab_state; - if (wm_software_cursor_needed_for_window(win, &grab_state) && - wm_software_cursor_motion_test(win)) { - return true; + if (wm_software_cursor_needed_for_window(win, &grab_state)) { + if (wm_software_cursor_motion_test(win)) { + return true; + } + } + else { + /* Detect the edge case when the previous draw used the software cursor but this one doesn't, + * it's important to redraw otherwise the software cursor will remain displayed. */ + if (g_software_cursor.winid != -1) { + return true; + } } } diff --git a/source/blender/windowmanager/intern/wm_event_system.cc b/source/blender/windowmanager/intern/wm_event_system.cc index 7420e756b31..d3ae4177e4d 100644 --- a/source/blender/windowmanager/intern/wm_event_system.cc +++ b/source/blender/windowmanager/intern/wm_event_system.cc @@ -873,7 +873,7 @@ bool WM_operator_poll(bContext *C, wmOperatorType *ot) { LISTBASE_FOREACH (wmOperatorTypeMacro *, macro, &ot->macro) { - wmOperatorType *ot_macro = WM_operatortype_find(macro->idname, 0); + wmOperatorType *ot_macro = WM_operatortype_find(macro->idname, false); if (!WM_operator_poll(C, ot_macro)) { return false; @@ -903,7 +903,7 @@ bool WM_operator_check_ui_empty(wmOperatorType *ot) if (ot->macro.first != nullptr) { /* For macros, check all have exec() we can call. */ LISTBASE_FOREACH (wmOperatorTypeMacro *, macro, &ot->macro) { - wmOperatorType *otm = WM_operatortype_find(macro->idname, 0); + wmOperatorType *otm = WM_operatortype_find(macro->idname, false); if (otm && !WM_operator_check_ui_empty(otm)) { return false; } @@ -1180,7 +1180,7 @@ bool WM_operator_repeat_check(const bContext *UNUSED(C), wmOperator *op) if (op->opm) { /* For macros, check all have exec() we can call. */ LISTBASE_FOREACH (wmOperatorTypeMacro *, macro, &op->opm->type->macro) { - wmOperatorType *otm = WM_operatortype_find(macro->idname, 0); + wmOperatorType *otm = WM_operatortype_find(macro->idname, false); if (otm && otm->exec == nullptr) { return false; } @@ -1260,7 +1260,7 @@ static wmOperator *wm_operator_create(wmWindowManager *wm, /* Skip invalid properties. */ if (STREQ(RNA_property_identifier(prop), otmacro->idname)) { - wmOperatorType *otm = WM_operatortype_find(otmacro->idname, 0); + wmOperatorType *otm = WM_operatortype_find(otmacro->idname, false); PointerRNA someptr = RNA_property_pointer_get(properties, prop); wmOperator *opm = wm_operator_create(wm, otm, &someptr, nullptr); @@ -1276,7 +1276,7 @@ static wmOperator *wm_operator_create(wmWindowManager *wm, } else { LISTBASE_FOREACH (wmOperatorTypeMacro *, macro, &ot->macro) { - wmOperatorType *otm = WM_operatortype_find(macro->idname, 0); + wmOperatorType *otm = WM_operatortype_find(macro->idname, false); wmOperator *opm = wm_operator_create(wm, otm, macro->ptr, nullptr); BLI_addtail(&motherop->macro, opm); @@ -1289,7 +1289,7 @@ static wmOperator *wm_operator_create(wmWindowManager *wm, } } - WM_operator_properties_sanitize(op->ptr, 0); + WM_operator_properties_sanitize(op->ptr, false); return op; } @@ -1649,7 +1649,7 @@ int WM_operator_name_call(bContext *C, PointerRNA *properties, const wmEvent *event) { - wmOperatorType *ot = WM_operatortype_find(opstring, 0); + wmOperatorType *ot = WM_operatortype_find(opstring, false); if (ot) { return WM_operator_name_call_ptr(C, ot, context, properties, event); } @@ -1659,7 +1659,7 @@ int WM_operator_name_call(bContext *C, bool WM_operator_name_poll(bContext *C, const char *opstring) { - wmOperatorType *ot = WM_operatortype_find(opstring, 0); + wmOperatorType *ot = WM_operatortype_find(opstring, false); if (!ot) { return false; } @@ -1827,7 +1827,7 @@ void WM_operator_name_call_ptr_with_depends_on_cursor(bContext *C, int flag = ot->flag; LISTBASE_FOREACH (wmOperatorTypeMacro *, macro, &ot->macro) { - wmOperatorType *otm = WM_operatortype_find(macro->idname, 0); + wmOperatorType *otm = WM_operatortype_find(macro->idname, false); if (otm != nullptr) { flag |= otm->flag; } @@ -2396,11 +2396,11 @@ static int wm_handler_operator_call(bContext *C, } } else { - wmOperatorType *ot = WM_operatortype_find(kmi_idname, 0); + wmOperatorType *ot = WM_operatortype_find(kmi_idname, false); if (ot && wm_operator_check_locked_interface(C, ot)) { bool use_last_properties = true; - PointerRNA tool_properties = {0}; + PointerRNA tool_properties = {nullptr}; bToolRef *keymap_tool = nullptr; if (handler_base->type == WM_HANDLER_TYPE_KEYMAP) { @@ -2770,7 +2770,7 @@ static const char *keymap_handler_log_kmi_op_str(bContext *C, /* The key-map item properties can further help distinguish this item from others. */ char *kmi_props = nullptr; if (kmi->properties != nullptr) { - wmOperatorType *ot = WM_operatortype_find(kmi->idname, 0); + wmOperatorType *ot = WM_operatortype_find(kmi->idname, false); if (ot) { kmi_props = RNA_pointer_as_string_keywords(C, kmi->ptr, false, false, true, 512); } @@ -3031,7 +3031,7 @@ static int wm_handlers_do_gizmo_handler(bContext *C, if ((kmi->flag & KMI_INACTIVE) == 0) { if (wm_eventmatch(&event_test_click, kmi) || wm_eventmatch(&event_test_click_drag, kmi)) { - wmOperatorType *ot = WM_operatortype_find(kmi->idname, 0); + wmOperatorType *ot = WM_operatortype_find(kmi->idname, false); if (WM_operator_poll_context(C, ot, WM_OP_INVOKE_DEFAULT)) { is_event_handle_all = true; break; @@ -3179,7 +3179,7 @@ static int wm_handlers_do_intern(bContext *C, wmWindow *win, wmEvent *event, Lis /* Pass single matched #wmDrag onto the operator. */ BLI_remlink(lb, drag); - ListBase single_lb = {0}; + ListBase single_lb = {nullptr}; BLI_addtail(&single_lb, drag); event->customdata = &single_lb; @@ -4604,7 +4604,7 @@ wmOperator *WM_operator_find_modal_by_type(wmWindow *win, const wmOperatorType * return handler->op; } } - return NULL; + return nullptr; } #if 0 @@ -4942,7 +4942,11 @@ static void attach_ndof_data(wmEvent *event, const GHOST_TEventNDOFMotionData *g /* Imperfect but probably usable... draw/enable drags to other windows. */ static wmWindow *wm_event_cursor_other_windows(wmWindowManager *wm, wmWindow *win, wmEvent *event) { - int mval[2] = {event->xy[0], event->xy[1]}; + /* If GHOST doesn't support window positioning, don't use this feature at all. */ + const static int8_t supports_window_position = GHOST_SupportsWindowPosition(); + if (!supports_window_position) { + return nullptr; + } if (wm->windows.first == wm->windows.last) { return nullptr; @@ -4951,8 +4955,9 @@ static wmWindow *wm_event_cursor_other_windows(wmWindowManager *wm, wmWindow *wi /* In order to use window size and mouse position (pixels), we have to use a WM function. */ /* Check if outside, include top window bar. */ - if (mval[0] < 0 || mval[1] < 0 || mval[0] > WM_window_pixels_x(win) || - mval[1] > WM_window_pixels_y(win) + 30) { + int event_xy[2] = {UNPACK2(event->xy)}; + if (event_xy[0] < 0 || event_xy[1] < 0 || event_xy[0] > WM_window_pixels_x(win) || + event_xy[1] > WM_window_pixels_y(win) + 30) { /* Let's skip windows having modal handlers now. */ /* Potential XXX ugly... I wouldn't have added a `modalhandlers` list * (introduced in rev 23331, ton). */ @@ -4962,9 +4967,9 @@ static wmWindow *wm_event_cursor_other_windows(wmWindowManager *wm, wmWindow *wi } } - wmWindow *win_other = WM_window_find_under_cursor(win, mval, mval); + wmWindow *win_other = WM_window_find_under_cursor(win, event_xy, event_xy); if (win_other && win_other != win) { - copy_v2_v2_int(event->xy, mval); + copy_v2_v2_int(event->xy, event_xy); return win_other; } } @@ -5632,7 +5637,7 @@ wmKeyMapItem *WM_event_match_keymap_item(bContext *C, wmKeyMap *keymap, const wm { LISTBASE_FOREACH (wmKeyMapItem *, kmi, &keymap->items) { if (wm_eventmatch(event, kmi)) { - wmOperatorType *ot = WM_operatortype_find(kmi->idname, 0); + wmOperatorType *ot = WM_operatortype_find(kmi->idname, false); if (WM_operator_poll_context(C, ot, WM_OP_INVOKE_DEFAULT)) { return kmi; } @@ -5882,7 +5887,7 @@ void WM_window_cursor_keymap_status_refresh(bContext *C, wmWindow *win) } } if (kmi) { - wmOperatorType *ot = WM_operatortype_find(kmi->idname, 0); + wmOperatorType *ot = WM_operatortype_find(kmi->idname, false); const char *name = (ot) ? WM_operatortype_name(ot, kmi->ptr) : kmi->idname; STRNCPY(cd->text[button_index][type_index], name); } diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c index 330231f3f18..f77aad24719 100644 --- a/source/blender/windowmanager/intern/wm_init_exit.c +++ b/source/blender/windowmanager/intern/wm_init_exit.c @@ -338,10 +338,10 @@ void WM_init(bContext *C, int argc, const char **argv) if (!G.background) { if (wm_start_with_console) { - setConsoleWindowState(GHOST_kConsoleWindowStateShow); + GHOST_setConsoleWindowState(GHOST_kConsoleWindowStateShow); } else { - setConsoleWindowState(GHOST_kConsoleWindowStateHideForNonConsoleLaunch); + GHOST_setConsoleWindowState(GHOST_kConsoleWindowStateHideForNonConsoleLaunch); } } diff --git a/source/blender/windowmanager/intern/wm_keymap_utils.c b/source/blender/windowmanager/intern/wm_keymap_utils.c index 531da3cf2e8..0817b10f86e 100644 --- a/source/blender/windowmanager/intern/wm_keymap_utils.c +++ b/source/blender/windowmanager/intern/wm_keymap_utils.c @@ -270,7 +270,10 @@ wmKeyMap *WM_keymap_guess_opname(const bContext *C, const char *opname) break; } } - else if (STRPREFIX(opname, "CURVES_SCULPT_OT")) { + else if (STRPREFIX(opname, "CURVES_OT")) { + km = WM_keymap_find_all(wm, "Curves", 0, 0); + } + else if (STRPREFIX(opname, "SCULPT_CURVES_OT")) { km = WM_keymap_find_all(wm, "Sculpt Curves", 0, 0); } else if (STRPREFIX(opname, "MBALL_OT")) { diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 7b768bd8c70..33c69a23558 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -1308,6 +1308,10 @@ ID *WM_operator_drop_load_path(struct bContext *C, wmOperator *op, const short i return id; } + if (!WM_operator_properties_id_lookup_is_set(op->ptr)) { + return NULL; + } + /* Lookup an already existing ID. */ id = WM_operator_properties_id_lookup_from_name_or_session_uuid(bmain, op->ptr, idcode); @@ -2068,7 +2072,7 @@ static void WM_OT_quit_blender(wmOperatorType *ot) static int wm_console_toggle_exec(bContext *UNUSED(C), wmOperator *UNUSED(op)) { - setConsoleWindowState(GHOST_kConsoleWindowStateToggle); + GHOST_setConsoleWindowState(GHOST_kConsoleWindowStateToggle); return OPERATOR_FINISHED; } diff --git a/source/blender/windowmanager/intern/wm_playanim.c b/source/blender/windowmanager/intern/wm_playanim.c index 7cd54a7e191..3100e6e4fd3 100644 --- a/source/blender/windowmanager/intern/wm_playanim.c +++ b/source/blender/windowmanager/intern/wm_playanim.c @@ -33,6 +33,7 @@ #include "BLI_path_util.h" #include "BLI_rect.h" #include "BLI_string.h" +#include "BLI_system.h" #include "BLI_utildefines.h" #include "IMB_colormanagement.h" @@ -211,7 +212,7 @@ static void playanim_gl_matrix(void) /* implementation */ static void playanim_event_qual_update(void) { - int val; + bool val; /* Shift */ GHOST_GetModifierKeyState(g_WS.ghost_system, GHOST_kModifierKeyLeftShift, &val); @@ -870,7 +871,7 @@ static void change_frame(PlayState *ps) ps->need_frame_update = false; } -static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr ps_void) +static bool ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr ps_void) { PlayState *ps = (PlayState *)ps_void; const GHOST_TEventType type = GHOST_GetEventType(evt); @@ -901,7 +902,7 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr ps_void) default: break; } - return 1; + return true; } if (ps->wait2 && ps->stopped == false) { @@ -1334,7 +1335,7 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr ps_void) break; } - return 1; + return true; } static void playanim_window_open(const char *title, int posx, int posy, int sizex, int sizey) @@ -1536,6 +1537,8 @@ static char *wm_main_playanim_intern(int argc, const char **argv) GHOST_EventConsumerHandle consumer = GHOST_CreateEventConsumer(ghost_event_proc, &ps); + GHOST_SetBacktraceHandler((GHOST_TBacktraceFn)BLI_system_backtrace); + g_WS.ghost_system = GHOST_CreateSystem(); GHOST_AddEventConsumer(g_WS.ghost_system, consumer); diff --git a/source/blender/windowmanager/intern/wm_uilist_type.c b/source/blender/windowmanager/intern/wm_uilist_type.c index 88eacf9013b..6dd64b89eb6 100644 --- a/source/blender/windowmanager/intern/wm_uilist_type.c +++ b/source/blender/windowmanager/intern/wm_uilist_type.c @@ -20,7 +20,6 @@ #include "UI_interface.h" #include "BLI_ghash.h" -#include "BLI_listbase.h" #include "BLI_string.h" #include "BLI_utildefines.h" diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c index 7b5de5b53b8..104eda220cc 100644 --- a/source/blender/windowmanager/intern/wm_window.c +++ b/source/blender/windowmanager/intern/wm_window.c @@ -23,6 +23,7 @@ #include "BLI_blenlib.h" #include "BLI_math.h" +#include "BLI_system.h" #include "BLI_utildefines.h" #include "BLT_translation.h" @@ -982,7 +983,7 @@ static int query_qual(modifierKeyType qual) break; } - int val = 0; + bool val = false; GHOST_GetModifierKeyState(g_system, left, &val); if (!val) { GHOST_GetModifierKeyState(g_system, right, &val); @@ -1052,7 +1053,7 @@ void wm_window_reset_drawable(void) * * Mouse coordinate conversion happens here. */ -static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_ptr) +static bool ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_ptr) { bContext *C = C_void_ptr; wmWindowManager *wm = CTX_wm_manager(C); @@ -1090,17 +1091,17 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_ptr * but it should return if WM didn't initialize yet. * Can happen on file read (especially full size window). */ if ((wm->initialized & WM_WINDOW_IS_INIT) == 0) { - return 1; + return true; } if (!ghostwin) { /* XXX: should be checked, why are we getting an event here, and what is it? */ puts("<!> event has no window"); - return 1; + return true; } if (!GHOST_ValidWindow(g_system, ghostwin)) { /* XXX: should be checked, why are we getting an event here, and what is it? */ puts("<!> event has invalid window"); - return 1; + return true; } wmWindow *win = GHOST_GetWindowUserData(ghostwin); @@ -1443,7 +1444,7 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_ptr } } } - return 1; + return true; } /** @@ -1543,6 +1544,8 @@ void wm_ghost_init(bContext *C) consumer = GHOST_CreateEventConsumer(ghost_event_proc, C); } + GHOST_SetBacktraceHandler((GHOST_TBacktraceFn)BLI_system_backtrace); + g_system = GHOST_CreateSystem(); GHOST_Debug debug = {0}; @@ -1869,11 +1872,10 @@ wmWindow *WM_window_find_under_cursor(wmWindow *win, const int mval[2], int r_mv return NULL; } - wmWindow *r_win = GHOST_GetWindowUserData(ghostwin); - wm_cursor_position_from_ghost(r_win, &tmp[0], &tmp[1]); + wmWindow *win_other = GHOST_GetWindowUserData(ghostwin); + wm_cursor_position_from_ghost(win_other, &tmp[0], &tmp[1]); copy_v2_v2_int(r_mval, tmp); - - return r_win; + return win_other; } void WM_window_pixel_sample_read(const wmWindowManager *wm, |