diff options
Diffstat (limited to 'source/blender/windowmanager/intern')
19 files changed, 420 insertions, 455 deletions
diff --git a/source/blender/windowmanager/intern/wm.c b/source/blender/windowmanager/intern/wm.c index 2112477e62a..43c08a2b980 100644 --- a/source/blender/windowmanager/intern/wm.c +++ b/source/blender/windowmanager/intern/wm.c @@ -293,7 +293,7 @@ void WM_keyconfig_init(bContext *C) /* initialize only after python init is done, for keymaps that * use python operators */ - if (CTX_py_init_get(C) && (wm->initialized & WM_KEYCONFIG_IS_INITIALIZED) == 0) { + if (CTX_py_init_get(C) && (wm->initialized & WM_KEYCONFIG_IS_INIT) == 0) { /* create default key config, only initialize once, * it's persistent across sessions */ if (!(wm->defaultconf->flag & KEYCONF_INIT_DEFAULT)) { @@ -308,7 +308,7 @@ void WM_keyconfig_init(bContext *C) WM_keyconfig_update_tag(NULL, NULL); WM_keyconfig_update(wm); - wm->initialized |= WM_KEYCONFIG_IS_INITIALIZED; + wm->initialized |= WM_KEYCONFIG_IS_INIT; } } @@ -334,7 +334,7 @@ void WM_check(bContext *C) if (!G.background) { /* case: fileread */ - if ((wm->initialized & WM_WINDOW_IS_INITIALIZED) == 0) { + if ((wm->initialized & WM_WINDOW_IS_INIT) == 0) { WM_keyconfig_init(C); WM_autosave_init(wm); } @@ -345,9 +345,9 @@ void WM_check(bContext *C) /* case: fileread */ /* note: this runs in bg mode to set the screen context cb */ - if ((wm->initialized & WM_WINDOW_IS_INITIALIZED) == 0) { - ED_screens_initialize(bmain, wm); - wm->initialized |= WM_WINDOW_IS_INITIALIZED; + if ((wm->initialized & WM_WINDOW_IS_INIT) == 0) { + ED_screens_init(bmain, wm); + wm->initialized |= WM_WINDOW_IS_INIT; } } diff --git a/source/blender/windowmanager/intern/wm_cursors.c b/source/blender/windowmanager/intern/wm_cursors.c index 2af68956923..8e89c08a831 100644 --- a/source/blender/windowmanager/intern/wm_cursors.c +++ b/source/blender/windowmanager/intern/wm_cursors.c @@ -121,7 +121,7 @@ static GHOST_TStandardCursor convert_to_ghost_standard_cursor(WMCursorType curs) } static void window_set_custom_cursor( - wmWindow *win, const uchar mask[16][2], uchar bitmap[16][2], int hotx, int hoty) + wmWindow *win, const uchar mask[16][2], const uchar bitmap[16][2], int hotx, int hoty) { GHOST_SetCustomCursorShape( win->ghostwin, (GHOST_TUns8 *)bitmap, (GHOST_TUns8 *)mask, 16, 16, hotx, hoty, true); @@ -319,15 +319,15 @@ bool wm_cursor_arrow_move(wmWindow *win, const wmEvent *event) wm_cursor_warp_relative(win, 0, fac); return 1; } - else if (event->type == EVT_DOWNARROWKEY) { + if (event->type == EVT_DOWNARROWKEY) { wm_cursor_warp_relative(win, 0, -fac); return 1; } - else if (event->type == EVT_LEFTARROWKEY) { + if (event->type == EVT_LEFTARROWKEY) { wm_cursor_warp_relative(win, -fac, 0); return 1; } - else if (event->type == EVT_RIGHTARROWKEY) { + if (event->type == EVT_RIGHTARROWKEY) { wm_cursor_warp_relative(win, fac, 0); return 1; } diff --git a/source/blender/windowmanager/intern/wm_dragdrop.c b/source/blender/windowmanager/intern/wm_dragdrop.c index 5f13adcb971..ec18a401fa4 100644 --- a/source/blender/windowmanager/intern/wm_dragdrop.c +++ b/source/blender/windowmanager/intern/wm_dragdrop.c @@ -296,7 +296,7 @@ void WM_drag_add_ID(wmDrag *drag, ID *id, ID *from_parent) } return; } - else if (GS(drag_id->id->name) != GS(id->name)) { + if (GS(drag_id->id->name) != GS(id->name)) { BLI_assert(!"All dragged IDs must have the same type"); return; } @@ -355,7 +355,7 @@ static const char *wm_drag_name(wmDrag *drag) if (single) { return id->name + 2; } - else if (id) { + if (id) { return BKE_idtype_idcode_to_name_plural(GS(id->name)); } break; diff --git a/source/blender/windowmanager/intern/wm_draw.c b/source/blender/windowmanager/intern/wm_draw.c index 16454e473cc..b8cb5432a49 100644 --- a/source/blender/windowmanager/intern/wm_draw.c +++ b/source/blender/windowmanager/intern/wm_draw.c @@ -51,7 +51,7 @@ #include "ED_screen.h" #include "ED_view3d.h" -#include "GPU_draw.h" +#include "GPU_context.h" #include "GPU_framebuffer.h" #include "GPU_immediate.h" #include "GPU_state.h" @@ -207,7 +207,7 @@ static bool wm_draw_region_stereo_set(Main *bmain, if (region->regiontype == RGN_TYPE_PREVIEW) { return true; } - else if (region->regiontype == RGN_TYPE_WINDOW) { + if (region->regiontype == RGN_TYPE_WINDOW) { return (sseq->draw_flag & SEQ_DRAW_BACKDROP) != 0; } } @@ -520,9 +520,7 @@ GPUTexture *wm_draw_region_texture(ARegion *region, int view) if (viewport) { return GPU_viewport_color_texture(viewport, view); } - else { - return GPU_offscreen_color_texture(region->draw_buffer->offscreen); - } + return GPU_offscreen_color_texture(region->draw_buffer->offscreen); } void wm_draw_region_blend(ARegion *region, int view, bool blend) @@ -572,8 +570,8 @@ void wm_draw_region_blend(ARegion *region, int view, bool blend) } /* Not the same layout as rectf/recti. */ - float rectt[4] = {rect_tex.xmin, rect_tex.ymin, rect_tex.xmax, rect_tex.ymax}; - float rectg[4] = {rect_geo.xmin, rect_geo.ymin, rect_geo.xmax, rect_geo.ymax}; + const float rectt[4] = {rect_tex.xmin, rect_tex.ymin, rect_tex.xmax, rect_tex.ymax}; + const float rectg[4] = {rect_geo.xmin, rect_geo.ymin, rect_geo.xmax, rect_geo.ymax}; if (blend) { /* GL_ONE because regions drawn offscreen have premultiplied alpha. */ @@ -999,7 +997,8 @@ void wm_draw_update(bContext *C) wmWindowManager *wm = CTX_wm_manager(C); wmWindow *win; - GPU_free_unused_buffers(); + GPU_context_main_lock(); + BKE_image_free_unused_gpu_textures(); for (win = wm->windows.first; win; win = win->next) { #ifdef WIN32 @@ -1036,6 +1035,8 @@ void wm_draw_update(bContext *C) /* Draw non-windows (surfaces) */ wm_surfaces_iter(C, wm_draw_surface); + + GPU_context_main_unlock(); } void wm_draw_region_clear(wmWindow *win, ARegion *UNUSED(region)) diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index 05ef4bfac30..bea4faa779a 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -387,6 +387,18 @@ void wm_event_do_refresh_wm_and_depsgraph(bContext *C) CTX_wm_window_set(C, NULL); } +static void wm_event_execute_timers(bContext *C) +{ + wmWindowManager *wm = CTX_wm_manager(C); + + /* Set the first window as context, so that there is some minimal context. This avoids crashes + * when calling code that assumes that there is always a window in the context (which many + * operators do). */ + CTX_wm_window_set(C, wm->windows.first); + BLI_timer_execute(); + CTX_wm_window_set(C, NULL); +} + /* called in mainloop */ void wm_event_do_notifiers(bContext *C) { @@ -398,7 +410,7 @@ void wm_event_do_notifiers(bContext *C) return; } - BLI_timer_execute(); + wm_event_execute_timers(C); /* disable? - keep for now since its used for window level notifiers. */ #if 1 @@ -597,7 +609,7 @@ static int wm_handler_ui_call(bContext *C, if (is_wheel) { return WM_HANDLER_CONTINUE; } - else if (wm_event_always_pass(event) == 0) { + if (wm_event_always_pass(event) == 0) { do_wheel_ui = true; } } @@ -783,7 +795,7 @@ bool WM_operator_poll(bContext *C, wmOperatorType *ot) if (ot->pyop_poll) { return ot->pyop_poll(C, ot); } - else if (ot->poll) { + if (ot->poll) { return ot->poll(C); } @@ -1095,7 +1107,7 @@ bool WM_operator_repeat_check(const bContext *UNUSED(C), wmOperator *op) if (op->type->exec != NULL) { return true; } - else if (op->opm) { + if (op->opm) { /* for macros, check all have exec() we can call */ wmOperatorTypeMacro *otmacro; for (otmacro = op->opm->type->macro.first; otmacro; otmacro = otmacro->next) { @@ -1816,10 +1828,10 @@ static bool wm_eventmatch(const wmEvent *winevent, const wmKeyMapItem *kmi) /* tablet events can occur on hover + keypress */ return false; } - else if ((kmitype == TABLET_STYLUS) && (wmtab->active != EVT_TABLET_STYLUS)) { + if ((kmitype == TABLET_STYLUS) && (wmtab->active != EVT_TABLET_STYLUS)) { return false; } - else if ((kmitype == TABLET_ERASER) && (wmtab->active != EVT_TABLET_ERASER)) { + if ((kmitype == TABLET_ERASER) && (wmtab->active != EVT_TABLET_ERASER)) { return false; } } @@ -2434,13 +2446,11 @@ static int wm_handlers_do_keymap_with_keymap_handler( } break; } + if (action & WM_HANDLER_HANDLED) { + CLOG_INFO(WM_LOG_HANDLERS, 2, "handled - and pass on! '%s'", kmi->idname); + } else { - if (action & WM_HANDLER_HANDLED) { - CLOG_INFO(WM_LOG_HANDLERS, 2, "handled - and pass on! '%s'", kmi->idname); - } - else { - CLOG_INFO(WM_LOG_HANDLERS, 2, "un-handled '%s'", kmi->idname); - } + CLOG_INFO(WM_LOG_HANDLERS, 2, "un-handled '%s'", kmi->idname); } } } @@ -2492,16 +2502,14 @@ static int wm_handlers_do_keymap_with_gizmo_handler( } break; } - else { - if (action & WM_HANDLER_HANDLED) { - if (G.debug & (G_DEBUG_EVENTS | G_DEBUG_HANDLERS)) { - printf("%s: handled - and pass on! '%s'\n", __func__, kmi->idname); - } - } - else { - PRINT("%s: un-handled '%s'\n", __func__, kmi->idname); + if (action & WM_HANDLER_HANDLED) { + if (G.debug & (G_DEBUG_EVENTS | G_DEBUG_HANDLERS)) { + printf("%s: handled - and pass on! '%s'\n", __func__, kmi->idname); } } + else { + PRINT("%s: un-handled '%s'\n", __func__, kmi->idname); + } } } } @@ -3126,13 +3134,9 @@ static bool wm_event_pie_filter(wmWindow *win, const wmEvent *event) win->lock_pie_event = EVENT_NONE; return false; } - else { - return true; - } - } - else { - return false; + return true; } + return false; } /** @@ -3692,10 +3696,8 @@ wmKeyMap *WM_event_get_keymap_from_toolsystem_fallback(wmWindowManager *wm, handler->keymap_tool = area->runtime.tool; return km; } - else { - printf( - "Keymap: '%s' not found for tool '%s'\n", tref_rt->keymap, area->runtime.tool->idname); - } + printf( + "Keymap: '%s' not found for tool '%s'\n", tref_rt->keymap, area->runtime.tool->idname); } } return NULL; @@ -3716,10 +3718,8 @@ wmKeyMap *WM_event_get_keymap_from_toolsystem(wmWindowManager *wm, wmEventHandle handler->keymap_tool = area->runtime.tool; return km; } - else { - printf( - "Keymap: '%s' not found for tool '%s'\n", tref_rt->keymap, area->runtime.tool->idname); - } + printf( + "Keymap: '%s' not found for tool '%s'\n", tref_rt->keymap, area->runtime.tool->idname); } } return NULL; @@ -3775,12 +3775,10 @@ static bool event_or_prev_in_rect(const wmEvent *event, const rcti *rect) if (BLI_rcti_isect_pt(rect, event->x, event->y)) { return true; } - else if (event->type == MOUSEMOVE && BLI_rcti_isect_pt(rect, event->prevx, event->prevy)) { + if (event->type == MOUSEMOVE && BLI_rcti_isect_pt(rect, event->prevx, event->prevy)) { return true; } - else { - return false; - } + return false; } static bool handler_region_v2d_mask_test(const ARegion *region, const wmEvent *event) @@ -3966,138 +3964,137 @@ static int convert_key(GHOST_TKey key) if (key >= GHOST_kKeyA && key <= GHOST_kKeyZ) { return (EVT_AKEY + ((int)key - GHOST_kKeyA)); } - else if (key >= GHOST_kKey0 && key <= GHOST_kKey9) { + if (key >= GHOST_kKey0 && key <= GHOST_kKey9) { return (EVT_ZEROKEY + ((int)key - GHOST_kKey0)); } - else if (key >= GHOST_kKeyNumpad0 && key <= GHOST_kKeyNumpad9) { + if (key >= GHOST_kKeyNumpad0 && key <= GHOST_kKeyNumpad9) { return (EVT_PAD0 + ((int)key - GHOST_kKeyNumpad0)); } - else if (key >= GHOST_kKeyF1 && key <= GHOST_kKeyF24) { + if (key >= GHOST_kKeyF1 && key <= GHOST_kKeyF24) { return (EVT_F1KEY + ((int)key - GHOST_kKeyF1)); } - else { - switch (key) { - case GHOST_kKeyBackSpace: - return EVT_BACKSPACEKEY; - case GHOST_kKeyTab: - return EVT_TABKEY; - case GHOST_kKeyLinefeed: - return EVT_LINEFEEDKEY; - case GHOST_kKeyClear: - return 0; - case GHOST_kKeyEnter: - return EVT_RETKEY; - - case GHOST_kKeyEsc: - return EVT_ESCKEY; - case GHOST_kKeySpace: - return EVT_SPACEKEY; - case GHOST_kKeyQuote: - return EVT_QUOTEKEY; - case GHOST_kKeyComma: - return EVT_COMMAKEY; - case GHOST_kKeyMinus: - return EVT_MINUSKEY; - case GHOST_kKeyPlus: - return EVT_PLUSKEY; - case GHOST_kKeyPeriod: - return EVT_PERIODKEY; - case GHOST_kKeySlash: - return EVT_SLASHKEY; - - case GHOST_kKeySemicolon: - return EVT_SEMICOLONKEY; - case GHOST_kKeyEqual: - return EVT_EQUALKEY; - - case GHOST_kKeyLeftBracket: - return EVT_LEFTBRACKETKEY; - case GHOST_kKeyRightBracket: - return EVT_RIGHTBRACKETKEY; - case GHOST_kKeyBackslash: - return EVT_BACKSLASHKEY; - case GHOST_kKeyAccentGrave: - return EVT_ACCENTGRAVEKEY; - - case GHOST_kKeyLeftShift: - return EVT_LEFTSHIFTKEY; - case GHOST_kKeyRightShift: - return EVT_RIGHTSHIFTKEY; - case GHOST_kKeyLeftControl: - return EVT_LEFTCTRLKEY; - case GHOST_kKeyRightControl: - return EVT_RIGHTCTRLKEY; - case GHOST_kKeyOS: - return EVT_OSKEY; - case GHOST_kKeyLeftAlt: - return EVT_LEFTALTKEY; - case GHOST_kKeyRightAlt: - return EVT_RIGHTALTKEY; - case GHOST_kKeyApp: - return EVT_APPKEY; - - case GHOST_kKeyCapsLock: - return EVT_CAPSLOCKKEY; - case GHOST_kKeyNumLock: - return 0; - case GHOST_kKeyScrollLock: - return 0; - - case GHOST_kKeyLeftArrow: - return EVT_LEFTARROWKEY; - case GHOST_kKeyRightArrow: - return EVT_RIGHTARROWKEY; - case GHOST_kKeyUpArrow: - return EVT_UPARROWKEY; - case GHOST_kKeyDownArrow: - return EVT_DOWNARROWKEY; - - case GHOST_kKeyPrintScreen: - return 0; - case GHOST_kKeyPause: - return EVT_PAUSEKEY; - - case GHOST_kKeyInsert: - return EVT_INSERTKEY; - case GHOST_kKeyDelete: - return EVT_DELKEY; - case GHOST_kKeyHome: - return EVT_HOMEKEY; - case GHOST_kKeyEnd: - return EVT_ENDKEY; - case GHOST_kKeyUpPage: - return EVT_PAGEUPKEY; - case GHOST_kKeyDownPage: - return EVT_PAGEDOWNKEY; - - case GHOST_kKeyNumpadPeriod: - return EVT_PADPERIOD; - case GHOST_kKeyNumpadEnter: - return EVT_PADENTER; - case GHOST_kKeyNumpadPlus: - return EVT_PADPLUSKEY; - case GHOST_kKeyNumpadMinus: - return EVT_PADMINUS; - case GHOST_kKeyNumpadAsterisk: - return EVT_PADASTERKEY; - case GHOST_kKeyNumpadSlash: - return EVT_PADSLASHKEY; - - case GHOST_kKeyGrLess: - return EVT_GRLESSKEY; - - case GHOST_kKeyMediaPlay: - return EVT_MEDIAPLAY; - case GHOST_kKeyMediaStop: - return EVT_MEDIASTOP; - case GHOST_kKeyMediaFirst: - return EVT_MEDIAFIRST; - case GHOST_kKeyMediaLast: - return EVT_MEDIALAST; - - default: - return EVT_UNKNOWNKEY; /* GHOST_kKeyUnknown */ - } + + switch (key) { + case GHOST_kKeyBackSpace: + return EVT_BACKSPACEKEY; + case GHOST_kKeyTab: + return EVT_TABKEY; + case GHOST_kKeyLinefeed: + return EVT_LINEFEEDKEY; + case GHOST_kKeyClear: + return 0; + case GHOST_kKeyEnter: + return EVT_RETKEY; + + case GHOST_kKeyEsc: + return EVT_ESCKEY; + case GHOST_kKeySpace: + return EVT_SPACEKEY; + case GHOST_kKeyQuote: + return EVT_QUOTEKEY; + case GHOST_kKeyComma: + return EVT_COMMAKEY; + case GHOST_kKeyMinus: + return EVT_MINUSKEY; + case GHOST_kKeyPlus: + return EVT_PLUSKEY; + case GHOST_kKeyPeriod: + return EVT_PERIODKEY; + case GHOST_kKeySlash: + return EVT_SLASHKEY; + + case GHOST_kKeySemicolon: + return EVT_SEMICOLONKEY; + case GHOST_kKeyEqual: + return EVT_EQUALKEY; + + case GHOST_kKeyLeftBracket: + return EVT_LEFTBRACKETKEY; + case GHOST_kKeyRightBracket: + return EVT_RIGHTBRACKETKEY; + case GHOST_kKeyBackslash: + return EVT_BACKSLASHKEY; + case GHOST_kKeyAccentGrave: + return EVT_ACCENTGRAVEKEY; + + case GHOST_kKeyLeftShift: + return EVT_LEFTSHIFTKEY; + case GHOST_kKeyRightShift: + return EVT_RIGHTSHIFTKEY; + case GHOST_kKeyLeftControl: + return EVT_LEFTCTRLKEY; + case GHOST_kKeyRightControl: + return EVT_RIGHTCTRLKEY; + case GHOST_kKeyOS: + return EVT_OSKEY; + case GHOST_kKeyLeftAlt: + return EVT_LEFTALTKEY; + case GHOST_kKeyRightAlt: + return EVT_RIGHTALTKEY; + case GHOST_kKeyApp: + return EVT_APPKEY; + + case GHOST_kKeyCapsLock: + return EVT_CAPSLOCKKEY; + case GHOST_kKeyNumLock: + return 0; + case GHOST_kKeyScrollLock: + return 0; + + case GHOST_kKeyLeftArrow: + return EVT_LEFTARROWKEY; + case GHOST_kKeyRightArrow: + return EVT_RIGHTARROWKEY; + case GHOST_kKeyUpArrow: + return EVT_UPARROWKEY; + case GHOST_kKeyDownArrow: + return EVT_DOWNARROWKEY; + + case GHOST_kKeyPrintScreen: + return 0; + case GHOST_kKeyPause: + return EVT_PAUSEKEY; + + case GHOST_kKeyInsert: + return EVT_INSERTKEY; + case GHOST_kKeyDelete: + return EVT_DELKEY; + case GHOST_kKeyHome: + return EVT_HOMEKEY; + case GHOST_kKeyEnd: + return EVT_ENDKEY; + case GHOST_kKeyUpPage: + return EVT_PAGEUPKEY; + case GHOST_kKeyDownPage: + return EVT_PAGEDOWNKEY; + + case GHOST_kKeyNumpadPeriod: + return EVT_PADPERIOD; + case GHOST_kKeyNumpadEnter: + return EVT_PADENTER; + case GHOST_kKeyNumpadPlus: + return EVT_PADPLUSKEY; + case GHOST_kKeyNumpadMinus: + return EVT_PADMINUS; + case GHOST_kKeyNumpadAsterisk: + return EVT_PADASTERKEY; + case GHOST_kKeyNumpadSlash: + return EVT_PADSLASHKEY; + + case GHOST_kKeyGrLess: + return EVT_GRLESSKEY; + + case GHOST_kKeyMediaPlay: + return EVT_MEDIAPLAY; + case GHOST_kKeyMediaStop: + return EVT_MEDIASTOP; + case GHOST_kKeyMediaFirst: + return EVT_MEDIAFIRST; + case GHOST_kKeyMediaLast: + return EVT_MEDIALAST; + + default: + return EVT_UNKNOWNKEY; /* GHOST_kKeyUnknown */ } } diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c index f431a6f431b..ef4f2b4a62a 100644 --- a/source/blender/windowmanager/intern/wm_files.c +++ b/source/blender/windowmanager/intern/wm_files.c @@ -258,7 +258,7 @@ static void wm_window_match_keep_current_wm(const bContext *C, bScreen *screen = NULL; /* match oldwm to new dbase, only old files */ - wm->initialized &= ~WM_WINDOW_IS_INITIALIZED; + wm->initialized &= ~WM_WINDOW_IS_INIT; /* when loading without UI, no matching needed */ if (load_ui && (screen = CTX_wm_screen(C))) { @@ -1404,10 +1404,8 @@ bool write_crash_blend(void) printf("written: %s\n", path); return 1; } - else { - printf("failed: %s\n", path); - return 0; - } + printf("failed: %s\n", path); + return 0; } /** @@ -2091,9 +2089,7 @@ static int wm_homefile_read_invoke(bContext *C, wmOperator *op, const wmEvent *U wm_close_file_dialog(C, callback); return OPERATOR_INTERFACE; } - else { - return wm_homefile_read_exec(C, op); - } + return wm_homefile_read_exec(C, op); } static void read_homefile_props(wmOperatorType *ot) @@ -2255,9 +2251,7 @@ static int wm_open_mainfile__discard_changes(bContext *C, wmOperator *op) wm_close_file_dialog(C, callback); return OPERATOR_INTERFACE; } - else { - return wm_open_mainfile_dispatch(C, op); - } + return wm_open_mainfile_dispatch(C, op); } static int wm_open_mainfile__select_file_path(bContext *C, wmOperator *op) @@ -2328,9 +2322,7 @@ static int wm_open_mainfile__open(bContext *C, wmOperator *op) ED_view3d_local_collections_reset(C, (G.fileflags & G_FILE_NO_UI) != 0); return OPERATOR_FINISHED; } - else { - return OPERATOR_CANCELLED; - } + return OPERATOR_CANCELLED; } static OperatorDispatchTarget wm_open_mainfile_dispatch_targets[] = { @@ -2475,9 +2467,7 @@ static int wm_revert_mainfile_exec(bContext *C, wmOperator *op) if (success) { return OPERATOR_FINISHED; } - else { - return OPERATOR_CANCELLED; - } + return OPERATOR_CANCELLED; } static bool wm_revert_mainfile_poll(bContext *UNUSED(C)) @@ -2572,9 +2562,7 @@ static int wm_recover_auto_save_exec(bContext *C, wmOperator *op) if (success) { return OPERATOR_FINISHED; } - else { - return OPERATOR_CANCELLED; - } + return OPERATOR_CANCELLED; } static int wm_recover_auto_save_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) diff --git a/source/blender/windowmanager/intern/wm_files_link.c b/source/blender/windowmanager/intern/wm_files_link.c index 31d36603505..6ccc5d79962 100644 --- a/source/blender/windowmanager/intern/wm_files_link.c +++ b/source/blender/windowmanager/intern/wm_files_link.c @@ -357,11 +357,11 @@ static int wm_link_append_exec(bContext *C, wmOperator *op) BKE_reportf(op->reports, RPT_ERROR, "'%s': not a library", path); return OPERATOR_CANCELLED; } - else if (!group) { + if (!group) { BKE_reportf(op->reports, RPT_ERROR, "'%s': nothing indicated", path); return OPERATOR_CANCELLED; } - else if (BLI_path_cmp(BKE_main_blendfile_path(bmain), libname) == 0) { + if (BLI_path_cmp(BKE_main_blendfile_path(bmain), libname) == 0) { BKE_reportf(op->reports, RPT_ERROR, "'%s': cannot use current file as library", path); return OPERATOR_CANCELLED; } @@ -755,7 +755,7 @@ static void lib_relocate_do_remap(Main *bmain, if (c == '.') { break; } - else if (c < '0' || c > '9') { + if (c < '0' || c > '9') { has_num = false; break; } diff --git a/source/blender/windowmanager/intern/wm_gesture.c b/source/blender/windowmanager/intern/wm_gesture.c index 5a66cbd10eb..55233168ab2 100644 --- a/source/blender/windowmanager/intern/wm_gesture.c +++ b/source/blender/windowmanager/intern/wm_gesture.c @@ -324,7 +324,7 @@ static void draw_filled_lasso(wmGesture *gt) int(*mcoords)[2] = MEM_mallocN(sizeof(*mcoords) * (mcoords_len + 1), __func__); int i; rcti rect; - float red[4] = {1.0f, 0.0f, 0.0f, 0.0f}; + const float red[4] = {1.0f, 0.0f, 0.0f, 0.0f}; for (i = 0; i < mcoords_len; i++, lasso += 2) { mcoords[i][0] = lasso[0]; diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c index 945d5fd42e4..03e84f098c0 100644 --- a/source/blender/windowmanager/intern/wm_init_exit.c +++ b/source/blender/windowmanager/intern/wm_init_exit.c @@ -59,6 +59,7 @@ #include "BKE_font.h" #include "BKE_global.h" #include "BKE_icons.h" +#include "BKE_image.h" #include "BKE_keyconfig.h" #include "BKE_lib_remap.h" #include "BKE_main.h" @@ -120,7 +121,7 @@ #include "UI_interface.h" #include "UI_resources.h" -#include "GPU_draw.h" +#include "GPU_context.h" #include "GPU_init_exit.h" #include "GPU_material.h" @@ -171,7 +172,7 @@ void WM_init_state_start_with_console_set(bool value) */ static bool opengl_is_init = false; -void WM_init_opengl(Main *bmain) +void WM_init_opengl(void) { /* must be called only once */ BLI_assert(opengl_is_init == false); @@ -185,9 +186,6 @@ void WM_init_opengl(Main *bmain) DRW_opengl_context_create(); GPU_init(); - GPU_set_mipmap(bmain, true); - GPU_set_linear_mipmap(true); - GPU_set_anisotropic(U.anisotropic_filter); GPU_pass_cache_init(); @@ -315,7 +313,7 @@ void WM_init(bContext *C, int argc, const char **argv) /* sets 3D mouse deadzone */ WM_ndof_deadzone_set(U.ndof_deadzone); #endif - WM_init_opengl(G_MAIN); + WM_init_opengl(); if (!WM_platform_support_perform_checks()) { exit(-1); @@ -578,7 +576,7 @@ void WM_exit_ex(bContext *C, const bool do_python) BKE_subdiv_exit(); if (opengl_is_init) { - GPU_free_unused_buffers(); + BKE_image_free_unused_gpu_textures(); } BKE_blender_free(); /* blender.c, does entire library and spacetypes */ @@ -637,6 +635,8 @@ void WM_exit_ex(bContext *C, const bool do_python) RNA_exit(); /* should be after BPY_python_end so struct python slots are cleared */ + GPU_backend_exit(); + wm_ghost_exit(); CTX_free(C); diff --git a/source/blender/windowmanager/intern/wm_jobs.c b/source/blender/windowmanager/intern/wm_jobs.c index 87a19d832c9..c9b125901e7 100644 --- a/source/blender/windowmanager/intern/wm_jobs.c +++ b/source/blender/windowmanager/intern/wm_jobs.c @@ -344,9 +344,7 @@ void *WM_jobs_customdata_get(wmJob *wm_job) if (!wm_job->customdata) { return wm_job->run_customdata; } - else { - return wm_job->customdata; - } + return wm_job->customdata; } void WM_jobs_customdata_set(wmJob *wm_job, void *customdata, void (*free)(void *)) diff --git a/source/blender/windowmanager/intern/wm_keymap.c b/source/blender/windowmanager/intern/wm_keymap.c index d7102a1e8af..d7ff2689a86 100644 --- a/source/blender/windowmanager/intern/wm_keymap.c +++ b/source/blender/windowmanager/intern/wm_keymap.c @@ -321,9 +321,7 @@ bool WM_keyconfig_remove(wmWindowManager *wm, wmKeyConfig *keyconf) return true; } - else { - return false; - } + return false; } void WM_keyconfig_clear(wmKeyConfig *keyconf) @@ -363,7 +361,7 @@ void WM_keyconfig_set_active(wmWindowManager *wm, const char *idname) WM_keyconfig_update(wm); BLI_strncpy(U.keyconfigstr, idname, sizeof(U.keyconfigstr)); - if (wm->initialized & WM_KEYCONFIG_IS_INITIALIZED) { + if (wm->initialized & WM_KEYCONFIG_IS_INIT) { U.runtime.is_dirty = true; } @@ -448,9 +446,7 @@ bool WM_keymap_remove(wmKeyConfig *keyconf, wmKeyMap *keymap) return true; } - else { - return false; - } + return false; } bool WM_keymap_poll(bContext *C, wmKeyMap *keymap) @@ -551,9 +547,7 @@ bool WM_keymap_remove_item(wmKeyMap *keymap, wmKeyMapItem *kmi) WM_keyconfig_update_tag(keymap, NULL); return true; } - else { - return false; - } + return false; } /** \} */ @@ -1122,7 +1116,7 @@ const char *WM_key_event_string(const short type, const bool compact) if (platform == MACOS) { return key_event_glyph_or_text(font_id, IFACE_("Cmd"), "\xe2\x8c\x98"); } - else if (platform == MSWIN) { + if (platform == MSWIN) { return key_event_glyph_or_text(font_id, IFACE_("Win"), "\xe2\x9d\x96"); } return IFACE_("OS"); diff --git a/source/blender/windowmanager/intern/wm_keymap_utils.c b/source/blender/windowmanager/intern/wm_keymap_utils.c index 5ab36b15666..953fb9fed79 100644 --- a/source/blender/windowmanager/intern/wm_keymap_utils.c +++ b/source/blender/windowmanager/intern/wm_keymap_utils.c @@ -217,7 +217,6 @@ wmKeyMap *WM_keymap_guess_opname(const bContext *C, const char *opname) * FLUID_OT * TEXTURE_OT * UI_OT - * VIEW2D_OT * WORLD_OT */ @@ -344,6 +343,10 @@ wmKeyMap *WM_keymap_guess_opname(const bContext *C, const char *opname) break; } } + /* General 2D View, not bound to a specific spacetype. */ + else if (STRPREFIX(opname, "VIEW2D_OT")) { + km = WM_keymap_find_all(wm, "View2D", 0, 0); + } /* Image Editor */ else if (STRPREFIX(opname, "IMAGE_OT")) { km = WM_keymap_find_all(wm, "Image", sl->spacetype, 0); @@ -379,7 +382,25 @@ wmKeyMap *WM_keymap_guess_opname(const bContext *C, const char *opname) } /* Animation Generic - after channels */ else if (STRPREFIX(opname, "ANIM_OT")) { - km = WM_keymap_find_all(wm, "Animation", 0, 0); + if (sl->spacetype == SPACE_VIEW3D) { + switch (CTX_data_mode_enum(C)) { + case CTX_MODE_OBJECT: + km = WM_keymap_find_all(wm, "Object Mode", 0, 0); + break; + case CTX_MODE_POSE: + km = WM_keymap_find_all(wm, "Pose", 0, 0); + break; + default: + break; + } + if (km && !WM_keymap_poll((bContext *)C, km)) { + km = NULL; + } + } + + if (!km) { + km = WM_keymap_find_all(wm, "Animation", 0, 0); + } } /* Graph Editor */ else if (STRPREFIX(opname, "GRAPH_OT")) { diff --git a/source/blender/windowmanager/intern/wm_operator_type.c b/source/blender/windowmanager/intern/wm_operator_type.c index 650d5bbe015..457cd0f16be 100644 --- a/source/blender/windowmanager/intern/wm_operator_type.c +++ b/source/blender/windowmanager/intern/wm_operator_type.c @@ -606,9 +606,7 @@ char *WM_operatortype_description(struct bContext *C, if (description[0]) { return description; } - else { - MEM_freeN(description); - } + MEM_freeN(description); } } @@ -621,9 +619,7 @@ char *WM_operatortype_description(struct bContext *C, if (info && info[0]) { return BLI_strdup(info); } - else { - return NULL; - } + return NULL; } /** \} */ diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index d1f65b6271b..1964813fff9 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -864,19 +864,17 @@ int WM_generic_select_modal(bContext *C, wmOperator *op, const wmEvent *event) } return ret_value | OPERATOR_PASS_THROUGH; } - else { - /* If we are in init phase, and cannot validate init of modal operations, - * just fall back to basic exec. - */ - RNA_property_boolean_set(op->ptr, wait_to_deselect_prop, false); + /* If we are in init phase, and cannot validate init of modal operations, + * just fall back to basic exec. + */ + RNA_property_boolean_set(op->ptr, wait_to_deselect_prop, false); - ret_value = op->type->exec(C, op); - OPERATOR_RETVAL_CHECK(ret_value); + ret_value = op->type->exec(C, op); + OPERATOR_RETVAL_CHECK(ret_value); - return ret_value | OPERATOR_PASS_THROUGH; - } + return ret_value | OPERATOR_PASS_THROUGH; } - else if (event->type == init_event_type && event->val == KM_RELEASE) { + if (event->type == init_event_type && event->val == KM_RELEASE) { RNA_property_boolean_set(op->ptr, wait_to_deselect_prop, false); ret_value = op->type->exec(C, op); @@ -884,7 +882,7 @@ int WM_generic_select_modal(bContext *C, wmOperator *op, const wmEvent *event) return ret_value | OPERATOR_PASS_THROUGH; } - else if (ELEM(event->type, MOUSEMOVE, INBETWEEN_MOUSEMOVE)) { + if (ELEM(event->type, MOUSEMOVE, INBETWEEN_MOUSEMOVE)) { const int drag_delta[2] = { mval[0] - event->mval[0], mval[1] - event->mval[1], @@ -895,11 +893,9 @@ int WM_generic_select_modal(bContext *C, wmOperator *op, const wmEvent *event) if (WM_event_drag_test_with_delta(event, drag_delta)) { return OPERATOR_FINISHED | OPERATOR_PASS_THROUGH; } - else { - /* Important not to return anything other than PASS_THROUGH here, - * otherwise it prevents underlying tweak detection code to work properly. */ - return OPERATOR_PASS_THROUGH; - } + /* Important not to return anything other than PASS_THROUGH here, + * otherwise it prevents underlying tweak detection code to work properly. */ + return OPERATOR_PASS_THROUGH; } return OPERATOR_RUNNING_MODAL | OPERATOR_PASS_THROUGH; @@ -1151,9 +1147,7 @@ int WM_operator_confirm_or_exec(bContext *C, wmOperator *op, const wmEvent *UNUS if (confirm) { return WM_operator_confirm_message(C, op, NULL); } - else { - return op->type->exec(C, op); - } + return op->type->exec(C, op); } /* op->invoke, opens fileselect if path property not set, otherwise executes */ @@ -1162,10 +1156,8 @@ int WM_operator_filesel(bContext *C, wmOperator *op, const wmEvent *UNUSED(event if (RNA_struct_property_is_set(op->ptr, "filepath")) { return WM_operator_call_notest(C, op); /* call exec direct */ } - else { - WM_event_add_fileselect(C, op); - return OPERATOR_RUNNING_MODAL; - } + WM_event_add_fileselect(C, op); + return OPERATOR_RUNNING_MODAL; } bool WM_operator_filesel_ensure_ext_imtype(wmOperator *op, const struct ImageFormatData *im_format) @@ -2322,7 +2314,7 @@ static void radial_control_paint_curve(uint pos, Brush *br, float radius, int li GPU_line_width(2.0f); immUniformColor4f(0.8f, 0.8f, 0.8f, 0.85f); float step = (radius * 2.0f) / (float)line_segments; - BKE_curvemapping_initialize(br->curve); + BKE_curvemapping_init(br->curve); immBegin(GPU_PRIM_LINES, line_segments * 2); for (int i = 0; i < line_segments; i++) { float h1 = BKE_brush_curve_strength_clamped(br, fabsf((i * step) - radius), radius); @@ -2453,7 +2445,7 @@ static void radial_control_paint_cursor(bContext *UNUSED(C), int x, int y, void imm_draw_circle_wire_2d(pos, 0.0f, 0.0f, r2, 80); if (rmin > 0.0f) { /* Inner fill circle to increase the contrast of the value */ - float black[3] = {0.0f}; + const float black[3] = {0.0f}; immUniformColor3fvAlpha(black, 0.2f); imm_draw_circle_fill_2d(pos, 0.0, 0.0f, rmin, 80); @@ -2536,10 +2528,8 @@ static int radial_control_get_path(PointerRNA *ctx_ptr, if (flags & RC_PROP_ALLOW_MISSING) { return 1; } - else { - BKE_reportf(op->reports, RPT_ERROR, "Could not resolve path '%s'", name); - return 0; - } + BKE_reportf(op->reports, RPT_ERROR, "Could not resolve path '%s'", name); + return 0; } /* check property type */ @@ -2591,13 +2581,12 @@ static int radial_control_get_properties(bContext *C, wmOperator *op) (RC_PROP_ALLOW_MISSING | RC_PROP_REQUIRE_BOOL))) { return 0; } + + if (use_secondary_prop && RNA_property_boolean_get(&use_secondary_ptr, use_secondary_prop)) { + data_path = "data_path_secondary"; + } else { - if (use_secondary_prop && RNA_property_boolean_get(&use_secondary_ptr, use_secondary_prop)) { - data_path = "data_path_secondary"; - } - else { - data_path = "data_path_primary"; - } + data_path = "data_path_primary"; } if (!radial_control_get_path(&ctx_ptr, op, data_path, &rc->ptr, &rc->prop, 0, 0)) { @@ -2664,7 +2653,7 @@ static int radial_control_get_properties(bContext *C, wmOperator *op) if (!radial_control_get_path(&ctx_ptr, op, "image_id", &rc->image_id_ptr, NULL, 0, 0)) { return 0; } - else if (rc->image_id_ptr.data) { + if (rc->image_id_ptr.data) { /* extra check, pointer must be to an ID */ if (!RNA_struct_is_ID(rc->image_id_ptr.type)) { BKE_report(op->reports, RPT_ERROR, "Pointer from path image_id is not an ID"); @@ -2841,171 +2830,169 @@ static int radial_control_modal(bContext *C, wmOperator *op, const wmEvent *even radial_control_update_header(op, C); return OPERATOR_RUNNING_MODAL; } - else { - handled = false; - switch (event->type) { - case EVT_ESCKEY: - case RIGHTMOUSE: - /* canceled; restore original value */ - radial_control_set_value(rc, rc->initial_value); - ret = OPERATOR_CANCELLED; - break; - - case LEFTMOUSE: - case EVT_PADENTER: - case EVT_RETKEY: - /* done; value already set */ - RNA_property_update(C, &rc->ptr, rc->prop); - ret = OPERATOR_FINISHED; - break; - - case MOUSEMOVE: - if (!has_numInput) { - if (rc->slow_mode) { - if (rc->subtype == PROP_ANGLE) { - float position[2] = {event->x, event->y}; - - /* calculate the initial angle here first */ - delta[0] = rc->initial_mouse[0] - rc->slow_mouse[0]; - delta[1] = rc->initial_mouse[1] - rc->slow_mouse[1]; - - /* precision angle gets calculated from dial and gets added later */ - angle_precision = -0.1f * BLI_dial_angle(rc->dial, position); - } - else { - delta[0] = rc->initial_mouse[0] - rc->slow_mouse[0]; - delta[1] = 0.0f; - if (rc->zoom_prop) { - RNA_property_float_get_array(&rc->zoom_ptr, rc->zoom_prop, zoom); - delta[0] /= zoom[0]; - } + handled = false; + switch (event->type) { + case EVT_ESCKEY: + case RIGHTMOUSE: + /* canceled; restore original value */ + radial_control_set_value(rc, rc->initial_value); + ret = OPERATOR_CANCELLED; + break; - dist = len_v2(delta); + case LEFTMOUSE: + case EVT_PADENTER: + case EVT_RETKEY: + /* done; value already set */ + RNA_property_update(C, &rc->ptr, rc->prop); + ret = OPERATOR_FINISHED; + break; - delta[0] = event->x - rc->slow_mouse[0]; + case MOUSEMOVE: + if (!has_numInput) { + if (rc->slow_mode) { + if (rc->subtype == PROP_ANGLE) { + const float position[2] = {event->x, event->y}; - if (rc->zoom_prop) { - delta[0] /= zoom[0]; - } + /* calculate the initial angle here first */ + delta[0] = rc->initial_mouse[0] - rc->slow_mouse[0]; + delta[1] = rc->initial_mouse[1] - rc->slow_mouse[1]; - dist = dist + 0.1f * (delta[0]); - } + /* precision angle gets calculated from dial and gets added later */ + angle_precision = -0.1f * BLI_dial_angle(rc->dial, position); } else { - delta[0] = rc->initial_mouse[0] - event->x; - delta[1] = rc->initial_mouse[1] - event->y; + delta[0] = rc->initial_mouse[0] - rc->slow_mouse[0]; + delta[1] = 0.0f; + if (rc->zoom_prop) { RNA_property_float_get_array(&rc->zoom_ptr, rc->zoom_prop, zoom); delta[0] /= zoom[0]; - delta[1] /= zoom[1]; } - if (rc->subtype == PROP_ANGLE) { - dist = len_v2(delta); - } - else { - dist = clamp_f(-delta[0], 0.0f, FLT_MAX); + + dist = len_v2(delta); + + delta[0] = event->x - rc->slow_mouse[0]; + + if (rc->zoom_prop) { + delta[0] /= zoom[0]; } - } - /* calculate new value and apply snapping */ - switch (rc->subtype) { - case PROP_NONE: - case PROP_DISTANCE: - case PROP_PIXEL: - new_value = dist; - if (snap) { - new_value = ((int)new_value + 5) / 10 * 10; - } - break; - case PROP_PERCENTAGE: - new_value = ((dist - WM_RADIAL_CONTROL_DISPLAY_MIN_SIZE) / - WM_RADIAL_CONTROL_DISPLAY_WIDTH) * - 100.0f; - if (snap) { - new_value = ((int)(new_value + 2.5f)) / 5 * 5; - } - break; - case PROP_FACTOR: - new_value = (WM_RADIAL_CONTROL_DISPLAY_SIZE - dist) / - WM_RADIAL_CONTROL_DISPLAY_WIDTH; - if (snap) { - new_value = ((int)ceil(new_value * 10.f) * 10.0f) / 100.f; - } - /* Invert new value to increase the factor moving the mouse to the right */ - new_value = 1 - new_value; - break; - case PROP_ANGLE: - new_value = atan2f(delta[1], delta[0]) + (float)M_PI + angle_precision; - new_value = fmod(new_value, 2.0f * (float)M_PI); - if (new_value < 0.0f) { - new_value += 2.0f * (float)M_PI; - } - if (snap) { - new_value = DEG2RADF(((int)RAD2DEGF(new_value) + 5) / 10 * 10); - } - break; - default: - new_value = dist; /* dummy value, should this ever happen? - campbell */ - break; + dist = dist + 0.1f * (delta[0]); } - - /* clamp and update */ - CLAMP(new_value, rc->min_value, rc->max_value); - radial_control_set_value(rc, new_value); - rc->current_value = new_value; - handled = true; - break; } - break; - - case EVT_LEFTSHIFTKEY: - case EVT_RIGHTSHIFTKEY: { - if (event->val == KM_PRESS) { - rc->slow_mouse[0] = event->x; - rc->slow_mouse[1] = event->y; - rc->slow_mode = true; + else { + delta[0] = rc->initial_mouse[0] - event->x; + delta[1] = rc->initial_mouse[1] - event->y; + if (rc->zoom_prop) { + RNA_property_float_get_array(&rc->zoom_ptr, rc->zoom_prop, zoom); + delta[0] /= zoom[0]; + delta[1] /= zoom[1]; + } if (rc->subtype == PROP_ANGLE) { - float initial_position[2] = {UNPACK2(rc->initial_mouse)}; - float current_position[2] = {UNPACK2(rc->slow_mouse)}; - rc->dial = BLI_dial_initialize(initial_position, 0.0f); - /* immediately set the position to get a an initial direction */ - BLI_dial_angle(rc->dial, current_position); + dist = len_v2(delta); } - handled = true; - } - if (event->val == KM_RELEASE) { - rc->slow_mode = false; - handled = true; - if (rc->dial) { - MEM_freeN(rc->dial); - rc->dial = NULL; + else { + dist = clamp_f(-delta[0], 0.0f, FLT_MAX); } } + + /* calculate new value and apply snapping */ + switch (rc->subtype) { + case PROP_NONE: + case PROP_DISTANCE: + case PROP_PIXEL: + new_value = dist; + if (snap) { + new_value = ((int)new_value + 5) / 10 * 10; + } + break; + case PROP_PERCENTAGE: + new_value = ((dist - WM_RADIAL_CONTROL_DISPLAY_MIN_SIZE) / + WM_RADIAL_CONTROL_DISPLAY_WIDTH) * + 100.0f; + if (snap) { + new_value = ((int)(new_value + 2.5f)) / 5 * 5; + } + break; + case PROP_FACTOR: + new_value = (WM_RADIAL_CONTROL_DISPLAY_SIZE - dist) / WM_RADIAL_CONTROL_DISPLAY_WIDTH; + if (snap) { + new_value = ((int)ceil(new_value * 10.f) * 10.0f) / 100.f; + } + /* Invert new value to increase the factor moving the mouse to the right */ + new_value = 1 - new_value; + break; + case PROP_ANGLE: + new_value = atan2f(delta[1], delta[0]) + (float)M_PI + angle_precision; + new_value = fmod(new_value, 2.0f * (float)M_PI); + if (new_value < 0.0f) { + new_value += 2.0f * (float)M_PI; + } + if (snap) { + new_value = DEG2RADF(((int)RAD2DEGF(new_value) + 5) / 10 * 10); + } + break; + default: + new_value = dist; /* dummy value, should this ever happen? - campbell */ + break; + } + + /* clamp and update */ + CLAMP(new_value, rc->min_value, rc->max_value); + radial_control_set_value(rc, new_value); + rc->current_value = new_value; + handled = true; break; } + break; + + case EVT_LEFTSHIFTKEY: + case EVT_RIGHTSHIFTKEY: { + if (event->val == KM_PRESS) { + rc->slow_mouse[0] = event->x; + rc->slow_mouse[1] = event->y; + rc->slow_mode = true; + if (rc->subtype == PROP_ANGLE) { + const float initial_position[2] = {UNPACK2(rc->initial_mouse)}; + const float current_position[2] = {UNPACK2(rc->slow_mouse)}; + rc->dial = BLI_dial_init(initial_position, 0.0f); + /* immediately set the position to get a an initial direction */ + BLI_dial_angle(rc->dial, current_position); + } + handled = true; + } + if (event->val == KM_RELEASE) { + rc->slow_mode = false; + handled = true; + if (rc->dial) { + MEM_freeN(rc->dial); + rc->dial = NULL; + } + } + break; } + } - /* Modal numinput inactive, try to handle numeric inputs last... */ - if (!handled && event->val == KM_PRESS && handleNumInput(C, &rc->num_input, event)) { - applyNumInput(&rc->num_input, &numValue); + /* Modal numinput inactive, try to handle numeric inputs last... */ + if (!handled && event->val == KM_PRESS && handleNumInput(C, &rc->num_input, event)) { + applyNumInput(&rc->num_input, &numValue); - if (rc->subtype == PROP_ANGLE) { - numValue = fmod(numValue, 2.0f * (float)M_PI); - if (numValue < 0.0f) { - numValue += 2.0f * (float)M_PI; - } + if (rc->subtype == PROP_ANGLE) { + numValue = fmod(numValue, 2.0f * (float)M_PI); + if (numValue < 0.0f) { + numValue += 2.0f * (float)M_PI; } + } - CLAMP(numValue, rc->min_value, rc->max_value); - new_value = numValue; + CLAMP(numValue, rc->min_value, rc->max_value); + new_value = numValue; - radial_control_set_value(rc, new_value); + radial_control_set_value(rc, new_value); - rc->current_value = new_value; - radial_control_update_header(op, C); - return OPERATOR_RUNNING_MODAL; - } + rc->current_value = new_value; + radial_control_update_header(op, C); + return OPERATOR_RUNNING_MODAL; } ED_region_tag_redraw(CTX_wm_region(C)); @@ -3722,6 +3709,7 @@ static int wm_xr_session_toggle_exec(bContext *C, wmOperator *UNUSED(op)) { Main *bmain = CTX_data_main(C); wmWindowManager *wm = CTX_wm_manager(C); + wmWindow *win = CTX_wm_window(C); View3D *v3d = CTX_wm_view3d(C); /* Lazy-create xr context - tries to dynlink to the runtime, reading active_runtime.json. */ @@ -3730,7 +3718,7 @@ static int wm_xr_session_toggle_exec(bContext *C, wmOperator *UNUSED(op)) } v3d->runtime.flag |= V3D_RUNTIME_XR_SESSION_ROOT; - wm_xr_session_toggle(wm, wm_xr_session_update_screen_on_exit_cb); + wm_xr_session_toggle(wm, win, wm_xr_session_update_screen_on_exit_cb); wm_xr_session_update_screen(bmain, &wm->xr); WM_event_add_notifier(C, NC_WM | ND_XR_DATA_CHANGED, NULL); @@ -3917,6 +3905,7 @@ static void gesture_box_modal_keymap(wmKeyConfig *keyconf) WM_modalkeymap_assign(keymap, "CLIP_OT_select_box"); WM_modalkeymap_assign(keymap, "CLIP_OT_graph_select_box"); WM_modalkeymap_assign(keymap, "MASK_OT_select_box"); + WM_modalkeymap_assign(keymap, "PAINT_OT_mask_box_gesture"); WM_modalkeymap_assign(keymap, "VIEW2D_OT_zoom_border"); WM_modalkeymap_assign(keymap, "VIEW3D_OT_clip_border"); WM_modalkeymap_assign(keymap, "VIEW3D_OT_render_border"); diff --git a/source/blender/windowmanager/intern/wm_platform_support.h b/source/blender/windowmanager/intern/wm_platform_support.h index a8e20f6bcdf..6346f517343 100644 --- a/source/blender/windowmanager/intern/wm_platform_support.h +++ b/source/blender/windowmanager/intern/wm_platform_support.h @@ -20,11 +20,8 @@ /** \file * \ingroup wm */ -#ifndef __WM_PLATFORM_SUPPORT_H__ -#define __WM_PLATFORM_SUPPORT_H__ +#pragma once #include "BLI_sys_types.h" bool WM_platform_support_perform_checks(void); - -#endif diff --git a/source/blender/windowmanager/intern/wm_playanim.c b/source/blender/windowmanager/intern/wm_playanim.c index d0a70596957..a0a21fadbbb 100644 --- a/source/blender/windowmanager/intern/wm_playanim.c +++ b/source/blender/windowmanager/intern/wm_playanim.c @@ -1293,8 +1293,7 @@ static char *wm_main_playanim_intern(int argc, const char **argv) // GHOST_ActivateWindowDrawingContext(g_WS.ghost_window); /* initialize OpenGL immediate mode */ - GLuint default_fb = GHOST_GetDefaultOpenGLFramebuffer(g_WS.ghost_window); - g_WS.gpu_context = GPU_context_create(default_fb); + g_WS.gpu_context = GPU_context_create(g_WS.ghost_window); GPU_init(); immActivate(); diff --git a/source/blender/windowmanager/intern/wm_stereo.c b/source/blender/windowmanager/intern/wm_stereo.c index 245560d3795..9667ed5b631 100644 --- a/source/blender/windowmanager/intern/wm_stereo.c +++ b/source/blender/windowmanager/intern/wm_stereo.c @@ -353,12 +353,11 @@ int wm_stereo3d_set_exec(bContext *C, wmOperator *op) WM_event_add_notifier(C, NC_WINDOW, NULL); return OPERATOR_FINISHED; } - else { - /* without this, the popup won't be freed freed properly T44688 */ - CTX_wm_window_set(C, win_src); - win_src->stereo3d_format->display_mode = prev_display_mode; - return OPERATOR_CANCELLED; - } + + /* without this, the popup won't be freed freed properly T44688 */ + CTX_wm_window_set(C, win_src); + win_src->stereo3d_format->display_mode = prev_display_mode; + return OPERATOR_CANCELLED; } int wm_stereo3d_set_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) @@ -368,9 +367,7 @@ int wm_stereo3d_set_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(ev if (wm_stereo3d_set_properties(C, op)) { return wm_stereo3d_set_exec(C, op); } - else { - return WM_operator_props_dialog_popup(C, op, 250); - } + return WM_operator_props_dialog_popup(C, op, 250); } void wm_stereo3d_set_draw(bContext *UNUSED(C), wmOperator *op) diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c index e444c5b2109..47afa343394 100644 --- a/source/blender/windowmanager/intern/wm_window.c +++ b/source/blender/windowmanager/intern/wm_window.c @@ -355,10 +355,8 @@ wmWindow *wm_window_copy_test(bContext *C, WM_event_add_notifier_ex(wm, CTX_wm_window(C), NC_WINDOW | NA_ADDED, NULL); return win_dst; } - else { - wm_window_close(C, wm, win_dst); - return NULL; - } + wm_window_close(C, wm, win_dst); + return NULL; } /** \} */ @@ -617,8 +615,7 @@ static void wm_window_ghostwindow_add(wmWindowManager *wm, if (ghostwin) { GHOST_RectangleHandle bounds; - GLuint default_fb = GHOST_GetDefaultOpenGLFramebuffer(ghostwin); - win->gpuctx = GPU_context_create(default_fb); + win->gpuctx = GPU_context_create(ghostwin); /* needed so we can detect the graphics card below */ GPU_init(); @@ -813,9 +810,7 @@ static bool wm_window_update_size_position(wmWindow *win) win->posy = posy; return true; } - else { - return false; - } + return false; } /** @@ -840,11 +835,10 @@ wmWindow *WM_window_open(bContext *C, const rcti *rect) if (win->ghostwin) { return win; } - else { - wm_window_close(C, wm, win); - CTX_wm_window_set(C, win_prev); - return NULL; - } + + wm_window_close(C, wm, win); + CTX_wm_window_set(C, win_prev); + return NULL; } /** @@ -969,13 +963,12 @@ wmWindow *WM_window_open_temp(bContext *C, GHOST_SetTitle(win->ghostwin, title); return win; } - else { - /* very unlikely! but opening a new window can fail */ - wm_window_close(C, wm, win); - CTX_wm_window_set(C, win_prev); - return NULL; - } + /* very unlikely! but opening a new window can fail */ + wm_window_close(C, wm, win); + CTX_wm_window_set(C, win_prev); + + return NULL; } /* ****************** Operators ****************** */ @@ -1206,7 +1199,7 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_ptr /* Ghost now can call this function for life resizes, * 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_INITIALIZED) == 0) { + if ((wm->initialized & WM_WINDOW_IS_INIT) == 0) { return 1; } if (!ghostwin) { @@ -1215,15 +1208,13 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_ptr puts("<!> event has no window"); return 1; } - else if (!GHOST_ValidWindow(g_system, ghostwin)) { + 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; } - else { - win = GHOST_GetWindowUserData(ghostwin); - } + win = GHOST_GetWindowUserData(ghostwin); switch (type) { case GHOST_kEventWindowDeactivate: diff --git a/source/blender/windowmanager/intern/wm_window_private.h b/source/blender/windowmanager/intern/wm_window_private.h index 115539861d7..c208d07ee37 100644 --- a/source/blender/windowmanager/intern/wm_window_private.h +++ b/source/blender/windowmanager/intern/wm_window_private.h @@ -20,8 +20,7 @@ /** \file * \ingroup wm */ -#ifndef __WM_WINDOW_PRIVATE_H__ -#define __WM_WINDOW_PRIVATE_H__ +#pragma once #include "BLI_sys_types.h" #include "GHOST_Types.h" @@ -38,5 +37,3 @@ void WM_ghost_show_message_box(const char *title, const char *continue_label, const char *link, GHOST_DialogOptions dialog_options); - -#endif |