Refactor: Move various window manager runtime pointers out of DNA

All of these pointers were cleared on file read. It's clearer to just
move them to the runtime struct.

Pull Request: https://projects.blender.org/blender/blender/pulls/144729
This commit is contained in:
Hans Goudey
2025-08-18 20:44:44 +02:00
committed by Hans Goudey
parent 2615cecf10
commit 178eca9427
41 changed files with 408 additions and 325 deletions

View File

@@ -9,6 +9,10 @@
#pragma once
struct GSet;
struct UndoStack;
struct wmMsgBus;
struct wmKeyConfig;
struct wmWindow;
#ifdef WITH_INPUT_IME
struct wmIMEData;
#endif
@@ -20,6 +24,16 @@ struct wmIMEData;
namespace blender::bke {
struct WindowManagerRuntime {
/** Separate active from drawable. */
wmWindow *windrawable = nullptr;
/**
* \note `CTX_wm_window(C)` is usually preferred.
* Avoid relying on this where possible as this may become NULL during when handling
* events that close or replace windows (e.g. opening a file).
* While this happens rarely in practice, it can cause difficult to reproduce bugs.
*/
wmWindow *winactive = nullptr;
/** Indicates whether interface is locked for user interaction. */
bool is_interface_locked = false;
@@ -63,6 +77,20 @@ struct WindowManagerRuntime {
/** Active dragged items. */
ListBase drags = {nullptr, nullptr};
/** Default configuration. */
wmKeyConfig *defaultconf = nullptr;
/** Addon configuration. */
wmKeyConfig *addonconf = nullptr;
/** User configuration. */
wmKeyConfig *userconf = nullptr;
/** All undo history. */
UndoStack *undo_stack = nullptr;
wmMsgBus *message_bus = nullptr;
WindowManagerRuntime();
~WindowManagerRuntime();
};

View File

@@ -822,7 +822,7 @@ wmGizmoGroup *CTX_wm_gizmo_group(const bContext *C)
wmMsgBus *CTX_wm_message_bus(const bContext *C)
{
return C->wm.manager ? C->wm.manager->message_bus : nullptr;
return C->wm.manager ? C->wm.manager->runtime->message_bus : nullptr;
}
ReportList *CTX_wm_reports(const bContext *C)

View File

@@ -7,6 +7,7 @@
*/
#include "BKE_report.hh"
#include "BKE_undo_system.hh"
#include "BKE_wm_runtime.hh"
#include "BLI_ghash.h"
@@ -14,6 +15,8 @@
#include "WM_api.hh"
#include "WM_message.hh"
namespace blender::bke {
WindowManagerRuntime::WindowManagerRuntime()
@@ -49,6 +52,14 @@ WindowManagerRuntime::~WindowManagerRuntime()
}
WM_drag_free_list(&this->drags);
if (this->undo_stack) {
BKE_undosys_stack_destroy(this->undo_stack);
}
if (this->message_bus != nullptr) {
WM_msgbus_destroy(this->message_bus);
}
}
WindowRuntime::~WindowRuntime()

View File

@@ -365,7 +365,7 @@ void region_init(wmWindowManager *wm, ARegion *region)
UI_view2d_region_reinit(&region->v2d, V2D_COMMONVIEW_PANELS_UI, region->winx, region->winy);
wmKeyMap *keymap = WM_keymap_ensure(
wm->defaultconf, "View2D Buttons List", SPACE_EMPTY, RGN_TYPE_WINDOW);
wm->runtime->defaultconf, "View2D Buttons List", SPACE_EMPTY, RGN_TYPE_WINDOW);
WM_event_add_keymap_handler(&region->runtime->handlers, keymap);
region->v2d.scroll = V2D_SCROLL_RIGHT | V2D_SCROLL_VERTICAL_HIDE;

View File

@@ -100,7 +100,7 @@ void base_active_refresh(Main *bmain, Scene *scene, ViewLayer *view_layer)
{
WM_main_add_notifier(NC_SCENE | ND_OB_ACTIVE, scene);
DEG_id_tag_update(&scene->id, ID_RECALC_SELECT);
wmMsgBus *mbus = ((wmWindowManager *)bmain->wm.first)->message_bus;
wmMsgBus *mbus = ((wmWindowManager *)bmain->wm.first)->runtime->message_bus;
if (mbus != nullptr) {
WM_msg_publish_rna_prop(mbus, &scene->id, view_layer, LayerObjects, active);
}

View File

@@ -565,7 +565,7 @@ void ED_region_do_draw(bContext *C, ARegion *region)
wmWindowManager *wm = CTX_wm_manager(C);
bScreen *screen = WM_window_get_active_screen(win);
Scene *scene = CTX_data_scene(C);
wmMsgBus *mbus = wm->message_bus;
wmMsgBus *mbus = wm->runtime->message_bus;
WM_msgbus_clear_by_owner(mbus, region);
/* Cheat, always subscribe to this space type properties.
@@ -1857,7 +1857,7 @@ static void ed_default_handlers(
/* XXX: it would be good to have bound-box checks for some of these. */
if (flag & ED_KEYMAP_UI) {
wmKeyMap *keymap = WM_keymap_ensure(
wm->defaultconf, "User Interface", SPACE_EMPTY, RGN_TYPE_WINDOW);
wm->runtime->defaultconf, "User Interface", SPACE_EMPTY, RGN_TYPE_WINDOW);
WM_event_add_keymap_handler(handlers, keymap);
ListBase *dropboxes = WM_dropboxmap_find("User Interface", SPACE_EMPTY, RGN_TYPE_WINDOW);
@@ -1882,22 +1882,24 @@ static void ed_default_handlers(
}
if (flag & ED_KEYMAP_VIEW2D) {
/* 2d-viewport handling+manipulation */
wmKeyMap *keymap = WM_keymap_ensure(wm->defaultconf, "View2D", SPACE_EMPTY, RGN_TYPE_WINDOW);
wmKeyMap *keymap = WM_keymap_ensure(
wm->runtime->defaultconf, "View2D", SPACE_EMPTY, RGN_TYPE_WINDOW);
WM_event_add_keymap_handler(handlers, keymap);
}
if (flag & ED_KEYMAP_ANIMATION) {
wmKeyMap *keymap;
/* time-markers */
keymap = WM_keymap_ensure(wm->defaultconf, "Markers", SPACE_EMPTY, RGN_TYPE_WINDOW);
keymap = WM_keymap_ensure(wm->runtime->defaultconf, "Markers", SPACE_EMPTY, RGN_TYPE_WINDOW);
WM_event_add_keymap_handler_poll(handlers, keymap, WM_event_handler_region_marker_poll);
/* time-scrub */
keymap = WM_keymap_ensure(wm->defaultconf, "Time Scrub", SPACE_EMPTY, RGN_TYPE_WINDOW);
keymap = WM_keymap_ensure(
wm->runtime->defaultconf, "Time Scrub", SPACE_EMPTY, RGN_TYPE_WINDOW);
WM_event_add_keymap_handler_poll(handlers, keymap, ED_time_scrub_event_in_region_poll);
/* frame changing and timeline operators (for time spaces) */
keymap = WM_keymap_ensure(wm->defaultconf, "Animation", SPACE_EMPTY, RGN_TYPE_WINDOW);
keymap = WM_keymap_ensure(wm->runtime->defaultconf, "Animation", SPACE_EMPTY, RGN_TYPE_WINDOW);
WM_event_add_keymap_handler(handlers, keymap);
}
if (flag & ED_KEYMAP_TOOL) {
@@ -1912,31 +1914,32 @@ static void ed_default_handlers(
}
if (flag & ED_KEYMAP_FRAMES) {
/* frame changing/jumping (for all spaces) */
wmKeyMap *keymap = WM_keymap_ensure(wm->defaultconf, "Frames", SPACE_EMPTY, RGN_TYPE_WINDOW);
wmKeyMap *keymap = WM_keymap_ensure(
wm->runtime->defaultconf, "Frames", SPACE_EMPTY, RGN_TYPE_WINDOW);
WM_event_add_keymap_handler(handlers, keymap);
}
if (flag & ED_KEYMAP_HEADER) {
/* standard keymap for headers regions */
wmKeyMap *keymap = WM_keymap_ensure(
wm->defaultconf, "Region Context Menu", SPACE_EMPTY, RGN_TYPE_WINDOW);
wm->runtime->defaultconf, "Region Context Menu", SPACE_EMPTY, RGN_TYPE_WINDOW);
WM_event_add_keymap_handler(handlers, keymap);
}
if (flag & ED_KEYMAP_FOOTER) {
/* standard keymap for footer regions */
wmKeyMap *keymap = WM_keymap_ensure(
wm->defaultconf, "Region Context Menu", SPACE_EMPTY, RGN_TYPE_WINDOW);
wm->runtime->defaultconf, "Region Context Menu", SPACE_EMPTY, RGN_TYPE_WINDOW);
WM_event_add_keymap_handler(handlers, keymap);
}
if (flag & ED_KEYMAP_NAVBAR) {
/* standard keymap for Navigation bar regions */
wmKeyMap *keymap = WM_keymap_ensure(
wm->defaultconf, "Region Context Menu", SPACE_EMPTY, RGN_TYPE_WINDOW);
wm->runtime->defaultconf, "Region Context Menu", SPACE_EMPTY, RGN_TYPE_WINDOW);
WM_event_add_keymap_handler(&region->runtime->handlers, keymap);
}
if (flag & ED_KEYMAP_ASSET_SHELF) {
/* standard keymap for asset shelf regions */
wmKeyMap *keymap = WM_keymap_ensure(
wm->defaultconf, "Asset Shelf", SPACE_EMPTY, RGN_TYPE_WINDOW);
wm->runtime->defaultconf, "Asset Shelf", SPACE_EMPTY, RGN_TYPE_WINDOW);
WM_event_add_keymap_handler(&region->runtime->handlers, keymap);
}
@@ -1945,7 +1948,7 @@ static void ed_default_handlers(
/* grease pencil */
{
wmKeyMap *keymap = WM_keymap_ensure(
wm->defaultconf, "Grease Pencil", SPACE_EMPTY, RGN_TYPE_WINDOW);
wm->runtime->defaultconf, "Grease Pencil", SPACE_EMPTY, RGN_TYPE_WINDOW);
WM_event_add_keymap_handler(handlers, keymap);
}
}
@@ -2176,8 +2179,8 @@ static void area_offscreen_exit(wmWindowManager *wm, wmWindow *win, ScrArea *are
region->runtime->regiontimer = nullptr;
}
if (wm->message_bus) {
WM_msgbus_clear_by_owner(wm->message_bus, region);
if (wm->runtime->message_bus) {
WM_msgbus_clear_by_owner(wm->runtime->message_bus, region);
}
}
@@ -3519,7 +3522,7 @@ void ED_region_panels_init(wmWindowManager *wm, ARegion *region)
}
wmKeyMap *keymap = WM_keymap_ensure(
wm->defaultconf, "View2D Buttons List", SPACE_EMPTY, RGN_TYPE_WINDOW);
wm->runtime->defaultconf, "View2D Buttons List", SPACE_EMPTY, RGN_TYPE_WINDOW);
WM_event_add_keymap_handler(&region->runtime->handlers, keymap);
}

View File

@@ -952,7 +952,7 @@ void ED_region_exit(bContext *C, ARegion *region)
region->runtime->regiontimer = nullptr;
}
WM_msgbus_clear_by_owner(wm->message_bus, region);
WM_msgbus_clear_by_owner(wm->runtime->message_bus, region);
CTX_wm_region_set(C, prevar);
}

View File

@@ -370,7 +370,7 @@ static void paint_stroke_update_step(bContext *C,
}
if ((brush->flag & BRUSH_DRAG_DOT) || (brush->flag & BRUSH_ANCHORED)) {
UndoStack *ustack = CTX_wm_manager(C)->undo_stack;
UndoStack *ustack = CTX_wm_manager(C)->runtime->undo_stack;
ED_image_undo_restore(ustack->step_init);
}

View File

@@ -450,7 +450,7 @@ void object_sculpt_mode_enter(Main &bmain,
if ((message_unsupported == nullptr) || force_dyntopo) {
/* Needed because we may be entering this mode before the undo system loads. */
wmWindowManager *wm = static_cast<wmWindowManager *>(bmain.wm.first);
const bool has_undo = wm->undo_stack != nullptr;
const bool has_undo = wm->runtime->undo_stack != nullptr;
/* Undo push is needed to prevent memory leak. */
if (has_undo) {
undo::push_begin_ex(scene, ob, "Dynamic topology enable");

View File

@@ -166,11 +166,12 @@ static void action_main_region_init(wmWindowManager *wm, ARegion *region)
UI_view2d_region_reinit(&region->v2d, V2D_COMMONVIEW_CUSTOM, region->winx, region->winy);
/* own keymap */
keymap = WM_keymap_ensure(wm->defaultconf, "Dopesheet", SPACE_ACTION, RGN_TYPE_WINDOW);
keymap = WM_keymap_ensure(wm->runtime->defaultconf, "Dopesheet", SPACE_ACTION, RGN_TYPE_WINDOW);
WM_event_add_keymap_handler_poll(
&region->runtime->handlers, keymap, WM_event_handler_region_v2d_mask_no_marker_poll);
keymap = WM_keymap_ensure(wm->defaultconf, "Dopesheet Generic", SPACE_ACTION, RGN_TYPE_WINDOW);
keymap = WM_keymap_ensure(
wm->runtime->defaultconf, "Dopesheet Generic", SPACE_ACTION, RGN_TYPE_WINDOW);
WM_event_add_keymap_handler(&region->runtime->handlers, keymap);
}
@@ -310,10 +311,12 @@ static void action_channel_region_init(wmWindowManager *wm, ARegion *region)
UI_view2d_region_reinit(&region->v2d, V2D_COMMONVIEW_LIST, region->winx, region->winy);
/* own keymap */
keymap = WM_keymap_ensure(wm->defaultconf, "Animation Channels", SPACE_EMPTY, RGN_TYPE_WINDOW);
keymap = WM_keymap_ensure(
wm->runtime->defaultconf, "Animation Channels", SPACE_EMPTY, RGN_TYPE_WINDOW);
WM_event_add_keymap_handler_v2d_mask(&region->runtime->handlers, keymap);
keymap = WM_keymap_ensure(wm->defaultconf, "Dopesheet Generic", SPACE_ACTION, RGN_TYPE_WINDOW);
keymap = WM_keymap_ensure(
wm->runtime->defaultconf, "Dopesheet Generic", SPACE_ACTION, RGN_TYPE_WINDOW);
WM_event_add_keymap_handler(&region->runtime->handlers, keymap);
}
@@ -793,7 +796,8 @@ static void action_buttons_area_init(wmWindowManager *wm, ARegion *region)
ED_region_panels_init(wm, region);
keymap = WM_keymap_ensure(wm->defaultconf, "Dopesheet Generic", SPACE_ACTION, RGN_TYPE_WINDOW);
keymap = WM_keymap_ensure(
wm->runtime->defaultconf, "Dopesheet Generic", SPACE_ACTION, RGN_TYPE_WINDOW);
WM_event_add_keymap_handler(&region->runtime->handlers, keymap);
}

View File

@@ -159,7 +159,8 @@ static void buttons_main_region_init(wmWindowManager *wm, ARegion *region)
region->flag |= RGN_FLAG_INDICATE_OVERFLOW;
keymap = WM_keymap_ensure(wm->defaultconf, "Property Editor", SPACE_PROPERTIES, RGN_TYPE_WINDOW);
keymap = WM_keymap_ensure(
wm->runtime->defaultconf, "Property Editor", SPACE_PROPERTIES, RGN_TYPE_WINDOW);
WM_event_add_keymap_handler(&region->runtime->handlers, keymap);
}

View File

@@ -661,14 +661,15 @@ static void clip_main_region_init(wmWindowManager *wm, ARegion *region)
* since the space clip manages its own v2d in #movieclip_main_area_set_view2d */
/* mask polls mode */
keymap = WM_keymap_ensure(wm->defaultconf, "Mask Editing", SPACE_EMPTY, RGN_TYPE_WINDOW);
keymap = WM_keymap_ensure(
wm->runtime->defaultconf, "Mask Editing", SPACE_EMPTY, RGN_TYPE_WINDOW);
WM_event_add_keymap_handler_v2d_mask(&region->runtime->handlers, keymap);
/* own keymap */
keymap = WM_keymap_ensure(wm->defaultconf, "Clip", SPACE_CLIP, RGN_TYPE_WINDOW);
keymap = WM_keymap_ensure(wm->runtime->defaultconf, "Clip", SPACE_CLIP, RGN_TYPE_WINDOW);
WM_event_add_keymap_handler_v2d_mask(&region->runtime->handlers, keymap);
keymap = WM_keymap_ensure(wm->defaultconf, "Clip Editor", SPACE_CLIP, RGN_TYPE_WINDOW);
keymap = WM_keymap_ensure(wm->runtime->defaultconf, "Clip Editor", SPACE_CLIP, RGN_TYPE_WINDOW);
WM_event_add_keymap_handler_v2d_mask(&region->runtime->handlers, keymap);
}
@@ -826,17 +827,20 @@ static void clip_preview_region_init(wmWindowManager *wm, ARegion *region)
/* own keymap */
keymap = WM_keymap_ensure(wm->defaultconf, "Clip", SPACE_CLIP, RGN_TYPE_WINDOW);
keymap = WM_keymap_ensure(wm->runtime->defaultconf, "Clip", SPACE_CLIP, RGN_TYPE_WINDOW);
WM_event_add_keymap_handler_v2d_mask(&region->runtime->handlers, keymap);
keymap = WM_keymap_ensure(wm->defaultconf, "Clip Time Scrub", SPACE_CLIP, RGN_TYPE_PREVIEW);
keymap = WM_keymap_ensure(
wm->runtime->defaultconf, "Clip Time Scrub", SPACE_CLIP, RGN_TYPE_PREVIEW);
WM_event_add_keymap_handler_poll(
&region->runtime->handlers, keymap, ED_time_scrub_event_in_region_poll);
keymap = WM_keymap_ensure(wm->defaultconf, "Clip Graph Editor", SPACE_CLIP, RGN_TYPE_WINDOW);
keymap = WM_keymap_ensure(
wm->runtime->defaultconf, "Clip Graph Editor", SPACE_CLIP, RGN_TYPE_WINDOW);
WM_event_add_keymap_handler_v2d_mask(&region->runtime->handlers, keymap);
keymap = WM_keymap_ensure(wm->defaultconf, "Clip Dopesheet Editor", SPACE_CLIP, RGN_TYPE_WINDOW);
keymap = WM_keymap_ensure(
wm->runtime->defaultconf, "Clip Dopesheet Editor", SPACE_CLIP, RGN_TYPE_WINDOW);
WM_event_add_keymap_handler_v2d_mask(&region->runtime->handlers, keymap);
}
@@ -981,7 +985,8 @@ static void clip_channels_region_init(wmWindowManager *wm, ARegion *region)
UI_view2d_region_reinit(&region->v2d, V2D_COMMONVIEW_LIST, region->winx, region->winy);
keymap = WM_keymap_ensure(wm->defaultconf, "Clip Dopesheet Editor", SPACE_CLIP, RGN_TYPE_WINDOW);
keymap = WM_keymap_ensure(
wm->runtime->defaultconf, "Clip Dopesheet Editor", SPACE_CLIP, RGN_TYPE_WINDOW);
WM_event_add_keymap_handler_v2d_mask(&region->runtime->handlers, keymap);
}
@@ -1067,7 +1072,7 @@ static void clip_tools_region_init(wmWindowManager *wm, ARegion *region)
ED_region_panels_init(wm, region);
keymap = WM_keymap_ensure(wm->defaultconf, "Clip", SPACE_CLIP, RGN_TYPE_WINDOW);
keymap = WM_keymap_ensure(wm->runtime->defaultconf, "Clip", SPACE_CLIP, RGN_TYPE_WINDOW);
WM_event_add_keymap_handler(&region->runtime->handlers, keymap);
}
@@ -1131,7 +1136,7 @@ static void clip_properties_region_init(wmWindowManager *wm, ARegion *region)
ED_region_panels_init(wm, region);
keymap = WM_keymap_ensure(wm->defaultconf, "Clip", SPACE_CLIP, RGN_TYPE_WINDOW);
keymap = WM_keymap_ensure(wm->runtime->defaultconf, "Clip", SPACE_CLIP, RGN_TYPE_WINDOW);
WM_event_add_keymap_handler(&region->runtime->handlers, keymap);
}

View File

@@ -121,11 +121,12 @@ static void console_main_region_init(wmWindowManager *wm, ARegion *region)
}
/* own keymap */
keymap = WM_keymap_ensure(wm->defaultconf, "Console", SPACE_CONSOLE, RGN_TYPE_WINDOW);
keymap = WM_keymap_ensure(wm->runtime->defaultconf, "Console", SPACE_CONSOLE, RGN_TYPE_WINDOW);
WM_event_add_keymap_handler_v2d_mask(&region->runtime->handlers, keymap);
/* Include after "Console" so cursor motion keys such as "Home" isn't overridden. */
keymap = WM_keymap_ensure(wm->defaultconf, "View2D Buttons List", SPACE_EMPTY, RGN_TYPE_WINDOW);
keymap = WM_keymap_ensure(
wm->runtime->defaultconf, "View2D Buttons List", SPACE_EMPTY, RGN_TYPE_WINDOW);
WM_event_add_keymap_handler(&region->runtime->handlers, keymap);
/* add drop boxes */

View File

@@ -1328,8 +1328,9 @@ void ED_fileselect_exit(wmWindowManager *wm, SpaceFile *sfile)
return;
}
if (sfile->op) {
wmWindow *temp_win = (wm->winactive && WM_window_is_temp_screen(wm->winactive)) ?
wm->winactive :
wmWindow *temp_win = (wm->runtime->winactive &&
WM_window_is_temp_screen(wm->runtime->winactive)) ?
wm->runtime->winactive :
nullptr;
if (temp_win) {
int win_size[2];

View File

@@ -444,10 +444,11 @@ static void file_main_region_init(wmWindowManager *wm, ARegion *region)
region->v2d.cur.ymax = trunc(region->v2d.cur.ymax);
/* own keymaps */
keymap = WM_keymap_ensure(wm->defaultconf, "File Browser", SPACE_FILE, RGN_TYPE_WINDOW);
keymap = WM_keymap_ensure(wm->runtime->defaultconf, "File Browser", SPACE_FILE, RGN_TYPE_WINDOW);
WM_event_add_keymap_handler_v2d_mask(&region->runtime->handlers, keymap);
keymap = WM_keymap_ensure(wm->defaultconf, "File Browser Main", SPACE_FILE, RGN_TYPE_WINDOW);
keymap = WM_keymap_ensure(
wm->runtime->defaultconf, "File Browser Main", SPACE_FILE, RGN_TYPE_WINDOW);
WM_event_add_keymap_handler_v2d_mask(&region->runtime->handlers, keymap);
}
@@ -680,7 +681,7 @@ static void file_tools_region_init(wmWindowManager *wm, ARegion *region)
ED_region_panels_init(wm, region);
/* own keymaps */
keymap = WM_keymap_ensure(wm->defaultconf, "File Browser", SPACE_FILE, RGN_TYPE_WINDOW);
keymap = WM_keymap_ensure(wm->runtime->defaultconf, "File Browser", SPACE_FILE, RGN_TYPE_WINDOW);
WM_event_add_keymap_handler_v2d_mask(&region->runtime->handlers, keymap);
}
@@ -730,7 +731,7 @@ static void file_header_region_init(wmWindowManager *wm, ARegion *region)
ED_region_header_init(region);
keymap = WM_keymap_ensure(wm->defaultconf, "File Browser", SPACE_FILE, RGN_TYPE_WINDOW);
keymap = WM_keymap_ensure(wm->runtime->defaultconf, "File Browser", SPACE_FILE, RGN_TYPE_WINDOW);
WM_event_add_keymap_handler_v2d_mask(&region->runtime->handlers, keymap);
}
@@ -748,10 +749,11 @@ static void file_ui_region_init(wmWindowManager *wm, ARegion *region)
region->v2d.keepzoom |= V2D_LOCKZOOM_X | V2D_LOCKZOOM_Y;
/* own keymap */
keymap = WM_keymap_ensure(wm->defaultconf, "File Browser", SPACE_FILE, RGN_TYPE_WINDOW);
keymap = WM_keymap_ensure(wm->runtime->defaultconf, "File Browser", SPACE_FILE, RGN_TYPE_WINDOW);
WM_event_add_keymap_handler_v2d_mask(&region->runtime->handlers, keymap);
keymap = WM_keymap_ensure(wm->defaultconf, "File Browser Buttons", SPACE_FILE, RGN_TYPE_WINDOW);
keymap = WM_keymap_ensure(
wm->runtime->defaultconf, "File Browser Buttons", SPACE_FILE, RGN_TYPE_WINDOW);
WM_event_add_keymap_handler_v2d_mask(&region->runtime->handlers, keymap);
}
@@ -768,7 +770,7 @@ static void file_execution_region_init(wmWindowManager *wm, ARegion *region)
region->v2d.keepzoom |= V2D_LOCKZOOM_X | V2D_LOCKZOOM_Y;
/* own keymap */
keymap = WM_keymap_ensure(wm->defaultconf, "File Browser", SPACE_FILE, RGN_TYPE_WINDOW);
keymap = WM_keymap_ensure(wm->runtime->defaultconf, "File Browser", SPACE_FILE, RGN_TYPE_WINDOW);
WM_event_add_keymap_handler_v2d_mask(&region->runtime->handlers, keymap);
}

View File

@@ -186,10 +186,12 @@ static void graph_main_region_init(wmWindowManager *wm, ARegion *region)
UI_view2d_region_reinit(&region->v2d, V2D_COMMONVIEW_CUSTOM, region->winx, region->winy);
/* own keymap */
keymap = WM_keymap_ensure(wm->defaultconf, "Graph Editor", SPACE_GRAPH, RGN_TYPE_WINDOW);
keymap = WM_keymap_ensure(
wm->runtime->defaultconf, "Graph Editor", SPACE_GRAPH, RGN_TYPE_WINDOW);
WM_event_add_keymap_handler_poll(
&region->runtime->handlers, keymap, WM_event_handler_region_v2d_mask_no_marker_poll);
keymap = WM_keymap_ensure(wm->defaultconf, "Graph Editor Generic", SPACE_GRAPH, RGN_TYPE_WINDOW);
keymap = WM_keymap_ensure(
wm->runtime->defaultconf, "Graph Editor Generic", SPACE_GRAPH, RGN_TYPE_WINDOW);
WM_event_add_keymap_handler(&region->runtime->handlers, keymap);
}
@@ -388,9 +390,11 @@ static void graph_channel_region_init(wmWindowManager *wm, ARegion *region)
UI_view2d_region_reinit(&region->v2d, V2D_COMMONVIEW_LIST, region->winx, region->winy);
/* own keymap */
keymap = WM_keymap_ensure(wm->defaultconf, "Animation Channels", SPACE_EMPTY, RGN_TYPE_WINDOW);
keymap = WM_keymap_ensure(
wm->runtime->defaultconf, "Animation Channels", SPACE_EMPTY, RGN_TYPE_WINDOW);
WM_event_add_keymap_handler_v2d_mask(&region->runtime->handlers, keymap);
keymap = WM_keymap_ensure(wm->defaultconf, "Graph Editor Generic", SPACE_GRAPH, RGN_TYPE_WINDOW);
keymap = WM_keymap_ensure(
wm->runtime->defaultconf, "Graph Editor Generic", SPACE_GRAPH, RGN_TYPE_WINDOW);
WM_event_add_keymap_handler(&region->runtime->handlers, keymap);
}
@@ -453,7 +457,8 @@ static void graph_buttons_region_init(wmWindowManager *wm, ARegion *region)
ED_region_panels_init(wm, region);
keymap = WM_keymap_ensure(wm->defaultconf, "Graph Editor Generic", SPACE_GRAPH, RGN_TYPE_WINDOW);
keymap = WM_keymap_ensure(
wm->runtime->defaultconf, "Graph Editor Generic", SPACE_GRAPH, RGN_TYPE_WINDOW);
WM_event_add_keymap_handler_v2d_mask(&region->runtime->handlers, keymap);
}

View File

@@ -605,26 +605,28 @@ static void image_main_region_init(wmWindowManager *wm, ARegion *region)
* since the space clip manages own v2d in #image_main_region_set_view2d */
/* mask polls mode */
keymap = WM_keymap_ensure(wm->defaultconf, "Mask Editing", SPACE_EMPTY, RGN_TYPE_WINDOW);
keymap = WM_keymap_ensure(
wm->runtime->defaultconf, "Mask Editing", SPACE_EMPTY, RGN_TYPE_WINDOW);
WM_event_add_keymap_handler_v2d_mask(&region->runtime->handlers, keymap);
/* image paint polls for mode */
keymap = WM_keymap_ensure(wm->defaultconf, "Curve", SPACE_EMPTY, RGN_TYPE_WINDOW);
keymap = WM_keymap_ensure(wm->runtime->defaultconf, "Curve", SPACE_EMPTY, RGN_TYPE_WINDOW);
WM_event_add_keymap_handler_v2d_mask(&region->runtime->handlers, keymap);
keymap = WM_keymap_ensure(wm->defaultconf, "Paint Curve", SPACE_EMPTY, RGN_TYPE_WINDOW);
keymap = WM_keymap_ensure(wm->runtime->defaultconf, "Paint Curve", SPACE_EMPTY, RGN_TYPE_WINDOW);
WM_event_add_keymap_handler(&region->runtime->handlers, keymap);
keymap = WM_keymap_ensure(wm->defaultconf, "Image Paint", SPACE_EMPTY, RGN_TYPE_WINDOW);
keymap = WM_keymap_ensure(wm->runtime->defaultconf, "Image Paint", SPACE_EMPTY, RGN_TYPE_WINDOW);
WM_event_add_keymap_handler_v2d_mask(&region->runtime->handlers, keymap);
keymap = WM_keymap_ensure(wm->defaultconf, "UV Editor", SPACE_EMPTY, RGN_TYPE_WINDOW);
keymap = WM_keymap_ensure(wm->runtime->defaultconf, "UV Editor", SPACE_EMPTY, RGN_TYPE_WINDOW);
WM_event_add_keymap_handler(&region->runtime->handlers, keymap);
/* own keymaps */
keymap = WM_keymap_ensure(wm->defaultconf, "Image Generic", SPACE_IMAGE, RGN_TYPE_WINDOW);
keymap = WM_keymap_ensure(
wm->runtime->defaultconf, "Image Generic", SPACE_IMAGE, RGN_TYPE_WINDOW);
WM_event_add_keymap_handler(&region->runtime->handlers, keymap);
keymap = WM_keymap_ensure(wm->defaultconf, "Image", SPACE_IMAGE, RGN_TYPE_WINDOW);
keymap = WM_keymap_ensure(wm->runtime->defaultconf, "Image", SPACE_IMAGE, RGN_TYPE_WINDOW);
WM_event_add_keymap_handler_v2d_mask(&region->runtime->handlers, keymap);
}
@@ -839,7 +841,8 @@ static void image_buttons_region_init(wmWindowManager *wm, ARegion *region)
region->v2d.scroll = V2D_SCROLL_RIGHT | V2D_SCROLL_VERTICAL_HIDE;
ED_region_panels_init(wm, region);
keymap = WM_keymap_ensure(wm->defaultconf, "Image Generic", SPACE_IMAGE, RGN_TYPE_WINDOW);
keymap = WM_keymap_ensure(
wm->runtime->defaultconf, "Image Generic", SPACE_IMAGE, RGN_TYPE_WINDOW);
WM_event_add_keymap_handler(&region->runtime->handlers, keymap);
}
@@ -958,7 +961,8 @@ static void image_tools_region_init(wmWindowManager *wm, ARegion *region)
region->v2d.scroll = V2D_SCROLL_RIGHT | V2D_SCROLL_VERTICAL_HIDE;
ED_region_panels_init(wm, region);
keymap = WM_keymap_ensure(wm->defaultconf, "Image Generic", SPACE_IMAGE, RGN_TYPE_WINDOW);
keymap = WM_keymap_ensure(
wm->runtime->defaultconf, "Image Generic", SPACE_IMAGE, RGN_TYPE_WINDOW);
WM_event_add_keymap_handler(&region->runtime->handlers, keymap);
}
@@ -1084,7 +1088,7 @@ static void image_asset_shelf_region_init(wmWindowManager *wm, ARegion *region)
{
using namespace blender::ed;
wmKeyMap *keymap = WM_keymap_ensure(
wm->defaultconf, "Image Generic", SPACE_IMAGE, RGN_TYPE_WINDOW);
wm->runtime->defaultconf, "Image Generic", SPACE_IMAGE, RGN_TYPE_WINDOW);
WM_event_add_keymap_handler(&region->runtime->handlers, keymap);
asset::shelf::region_init(wm, region);

View File

@@ -96,7 +96,7 @@ static void info_main_region_init(wmWindowManager *wm, ARegion *region)
UI_view2d_region_reinit(&region->v2d, V2D_COMMONVIEW_CUSTOM, region->winx, region->winy);
/* own keymap */
keymap = WM_keymap_ensure(wm->defaultconf, "Info", SPACE_INFO, RGN_TYPE_WINDOW);
keymap = WM_keymap_ensure(wm->runtime->defaultconf, "Info", SPACE_INFO, RGN_TYPE_WINDOW);
WM_event_add_keymap_handler(&region->runtime->handlers, keymap);
}

View File

@@ -172,14 +172,15 @@ static void nla_track_region_init(wmWindowManager *wm, ARegion *region)
/* own keymap */
/* own tracks map first to override some track keymaps */
keymap = WM_keymap_ensure(wm->defaultconf, "NLA Tracks", SPACE_NLA, RGN_TYPE_WINDOW);
keymap = WM_keymap_ensure(wm->runtime->defaultconf, "NLA Tracks", SPACE_NLA, RGN_TYPE_WINDOW);
WM_event_add_keymap_handler_poll(
&region->runtime->handlers, keymap, WM_event_handler_region_v2d_mask_no_marker_poll);
/* now generic channels map for everything else that can apply */
keymap = WM_keymap_ensure(wm->defaultconf, "Animation Channels", SPACE_EMPTY, RGN_TYPE_WINDOW);
keymap = WM_keymap_ensure(
wm->runtime->defaultconf, "Animation Channels", SPACE_EMPTY, RGN_TYPE_WINDOW);
WM_event_add_keymap_handler_v2d_mask(&region->runtime->handlers, keymap);
keymap = WM_keymap_ensure(wm->defaultconf, "NLA Generic", SPACE_NLA, RGN_TYPE_WINDOW);
keymap = WM_keymap_ensure(wm->runtime->defaultconf, "NLA Generic", SPACE_NLA, RGN_TYPE_WINDOW);
WM_event_add_keymap_handler_v2d_mask(&region->runtime->handlers, keymap);
}
@@ -241,9 +242,9 @@ static void nla_main_region_init(wmWindowManager *wm, ARegion *region)
UI_view2d_region_reinit(&region->v2d, V2D_COMMONVIEW_CUSTOM, region->winx, region->winy);
/* own keymap */
keymap = WM_keymap_ensure(wm->defaultconf, "NLA Editor", SPACE_NLA, RGN_TYPE_WINDOW);
keymap = WM_keymap_ensure(wm->runtime->defaultconf, "NLA Editor", SPACE_NLA, RGN_TYPE_WINDOW);
WM_event_add_keymap_handler_v2d_mask(&region->runtime->handlers, keymap);
keymap = WM_keymap_ensure(wm->defaultconf, "NLA Generic", SPACE_NLA, RGN_TYPE_WINDOW);
keymap = WM_keymap_ensure(wm->runtime->defaultconf, "NLA Generic", SPACE_NLA, RGN_TYPE_WINDOW);
WM_event_add_keymap_handler(&region->runtime->handlers, keymap);
}
@@ -362,7 +363,7 @@ static void nla_buttons_region_init(wmWindowManager *wm, ARegion *region)
ED_region_panels_init(wm, region);
keymap = WM_keymap_ensure(wm->defaultconf, "NLA Generic", SPACE_NLA, RGN_TYPE_WINDOW);
keymap = WM_keymap_ensure(wm->runtime->defaultconf, "NLA Generic", SPACE_NLA, RGN_TYPE_WINDOW);
WM_event_add_keymap_handler_v2d_mask(&region->runtime->handlers, keymap);
}

View File

@@ -875,7 +875,7 @@ static void node_buttons_region_init(wmWindowManager *wm, ARegion *region)
ED_region_panels_init(wm, region);
keymap = WM_keymap_ensure(wm->defaultconf, "Node Generic", SPACE_NODE, RGN_TYPE_WINDOW);
keymap = WM_keymap_ensure(wm->runtime->defaultconf, "Node Generic", SPACE_NODE, RGN_TYPE_WINDOW);
WM_event_add_keymap_handler(&region->runtime->handlers, keymap);
}
@@ -891,7 +891,7 @@ static void node_toolbar_region_init(wmWindowManager *wm, ARegion *region)
ED_region_panels_init(wm, region);
keymap = WM_keymap_ensure(wm->defaultconf, "Node Generic", SPACE_NODE, RGN_TYPE_WINDOW);
keymap = WM_keymap_ensure(wm->runtime->defaultconf, "Node Generic", SPACE_NODE, RGN_TYPE_WINDOW);
WM_event_add_keymap_handler(&region->runtime->handlers, keymap);
}
@@ -928,10 +928,10 @@ static void node_main_region_init(wmWindowManager *wm, ARegion *region)
UI_view2d_region_reinit(&region->v2d, V2D_COMMONVIEW_CUSTOM, region->winx, region->winy);
/* own keymaps */
keymap = WM_keymap_ensure(wm->defaultconf, "Node Generic", SPACE_NODE, RGN_TYPE_WINDOW);
keymap = WM_keymap_ensure(wm->runtime->defaultconf, "Node Generic", SPACE_NODE, RGN_TYPE_WINDOW);
WM_event_add_keymap_handler(&region->runtime->handlers, keymap);
keymap = WM_keymap_ensure(wm->defaultconf, "Node Editor", SPACE_NODE, RGN_TYPE_WINDOW);
keymap = WM_keymap_ensure(wm->runtime->defaultconf, "Node Editor", SPACE_NODE, RGN_TYPE_WINDOW);
WM_event_add_keymap_handler_v2d_mask(&region->runtime->handlers, keymap);
/* add drop boxes */
@@ -1754,7 +1754,7 @@ static void node_asset_shelf_region_init(wmWindowManager *wm, ARegion *region)
{
using namespace blender::ed;
wmKeyMap *keymap = WM_keymap_ensure(
wm->defaultconf, "Node Generic", SPACE_NODE, RGN_TYPE_WINDOW);
wm->runtime->defaultconf, "Node Generic", SPACE_NODE, RGN_TYPE_WINDOW);
WM_event_add_keymap_handler(&region->runtime->handlers, keymap);
asset::shelf::region_init(wm, region);

View File

@@ -77,7 +77,7 @@ static void outliner_main_region_init(wmWindowManager *wm, ARegion *region)
UI_view2d_region_reinit(&region->v2d, V2D_COMMONVIEW_LIST, region->winx, region->winy);
/* own keymap */
keymap = WM_keymap_ensure(wm->defaultconf, "Outliner", SPACE_OUTLINER, RGN_TYPE_WINDOW);
keymap = WM_keymap_ensure(wm->runtime->defaultconf, "Outliner", SPACE_OUTLINER, RGN_TYPE_WINDOW);
WM_event_add_keymap_handler_v2d_mask(&region->runtime->handlers, keymap);
/* Add dropboxes */

View File

@@ -93,7 +93,7 @@ static void script_main_region_init(wmWindowManager *wm, ARegion *region)
UI_view2d_region_reinit(&region->v2d, V2D_COMMONVIEW_STANDARD, region->winx, region->winy);
/* own keymap */
keymap = WM_keymap_ensure(wm->defaultconf, "Script", SPACE_SCRIPT, RGN_TYPE_WINDOW);
keymap = WM_keymap_ensure(wm->runtime->defaultconf, "Script", SPACE_SCRIPT, RGN_TYPE_WINDOW);
WM_event_add_keymap_handler_v2d_mask(&region->runtime->handlers, keymap);
}

View File

@@ -435,15 +435,16 @@ static void sequencer_main_region_init(wmWindowManager *wm, ARegion *region)
UI_view2d_region_reinit(&region->v2d, V2D_COMMONVIEW_CUSTOM, region->winx, region->winy);
#if 0
keymap = WM_keymap_ensure(wm->defaultconf, "Mask Editing", SPACE_EMPTY, RGN_TYPE_WINDOW);
keymap = WM_keymap_ensure(wm->runtime->defaultconf, "Mask Editing", SPACE_EMPTY, RGN_TYPE_WINDOW);
WM_event_add_keymap_handler_v2d_mask(&region->runtime->handlers, keymap);
#endif
keymap = WM_keymap_ensure(wm->defaultconf, "Video Sequence Editor", SPACE_SEQ, RGN_TYPE_WINDOW);
keymap = WM_keymap_ensure(
wm->runtime->defaultconf, "Video Sequence Editor", SPACE_SEQ, RGN_TYPE_WINDOW);
WM_event_add_keymap_handler_v2d_mask(&region->runtime->handlers, keymap);
/* Own keymap. */
keymap = WM_keymap_ensure(wm->defaultconf, "Sequencer", SPACE_SEQ, RGN_TYPE_WINDOW);
keymap = WM_keymap_ensure(wm->runtime->defaultconf, "Sequencer", SPACE_SEQ, RGN_TYPE_WINDOW);
WM_event_add_keymap_handler_poll(
&region->runtime->handlers, keymap, WM_event_handler_region_v2d_mask_no_marker_poll);
@@ -778,7 +779,8 @@ static void sequencer_tools_region_init(wmWindowManager *wm, ARegion *region)
region->v2d.scroll = V2D_SCROLL_RIGHT | V2D_SCROLL_VERTICAL_HIDE;
ED_region_panels_init(wm, region);
keymap = WM_keymap_ensure(wm->defaultconf, "Video Sequence Editor", SPACE_SEQ, RGN_TYPE_WINDOW);
keymap = WM_keymap_ensure(
wm->runtime->defaultconf, "Video Sequence Editor", SPACE_SEQ, RGN_TYPE_WINDOW);
WM_event_add_keymap_handler_v2d_mask(&region->runtime->handlers, keymap);
}
@@ -815,24 +817,25 @@ static void sequencer_preview_region_init(wmWindowManager *wm, ARegion *region)
UI_view2d_region_reinit(&region->v2d, V2D_COMMONVIEW_CUSTOM, region->winx, region->winy);
#if 0
keymap = WM_keymap_ensure(wm->defaultconf, "Mask Editing", SPACE_EMPTY, RGN_TYPE_WINDOW);
keymap = WM_keymap_ensure(wm->runtime->defaultconf, "Mask Editing", SPACE_EMPTY, RGN_TYPE_WINDOW);
WM_event_add_keymap_handler_v2d_mask(&region->runtime->handlers, keymap);
#endif
/* Own keymap. */
keymap = WM_keymap_ensure(wm->defaultconf, "Preview", SPACE_SEQ, RGN_TYPE_WINDOW);
keymap = WM_keymap_ensure(wm->runtime->defaultconf, "Preview", SPACE_SEQ, RGN_TYPE_WINDOW);
WM_event_add_keymap_handler_v2d_mask(&region->runtime->handlers, keymap);
keymap = WM_keymap_ensure(wm->defaultconf, "Video Sequence Editor", SPACE_SEQ, RGN_TYPE_WINDOW);
keymap = WM_keymap_ensure(
wm->runtime->defaultconf, "Video Sequence Editor", SPACE_SEQ, RGN_TYPE_WINDOW);
WM_event_add_keymap_handler_v2d_mask(&region->runtime->handlers, keymap);
/* Do this instead of adding V2D and frames `ED_KEYMAP_*` flags to `art->keymapflag`, since text
* editing conflicts with several of their keymap items (e.g. arrow keys when editing text or
* advancing frames). This seems to be the best way to define the proper order of evaluation. */
keymap = WM_keymap_ensure(wm->defaultconf, "View2D", SPACE_EMPTY, RGN_TYPE_WINDOW);
keymap = WM_keymap_ensure(wm->runtime->defaultconf, "View2D", SPACE_EMPTY, RGN_TYPE_WINDOW);
WM_event_add_keymap_handler_v2d_mask(&region->runtime->handlers, keymap);
keymap = WM_keymap_ensure(wm->defaultconf, "Frames", SPACE_EMPTY, RGN_TYPE_WINDOW);
keymap = WM_keymap_ensure(wm->runtime->defaultconf, "Frames", SPACE_EMPTY, RGN_TYPE_WINDOW);
WM_event_add_keymap_handler_v2d_mask(&region->runtime->handlers, keymap);
ListBase *lb = WM_dropboxmap_find("Sequencer", SPACE_SEQ, RGN_TYPE_PREVIEW);
@@ -1003,7 +1006,8 @@ static void sequencer_buttons_region_init(wmWindowManager *wm, ARegion *region)
{
wmKeyMap *keymap;
keymap = WM_keymap_ensure(wm->defaultconf, "Video Sequence Editor", SPACE_SEQ, RGN_TYPE_WINDOW);
keymap = WM_keymap_ensure(
wm->runtime->defaultconf, "Video Sequence Editor", SPACE_SEQ, RGN_TYPE_WINDOW);
WM_event_add_keymap_handler_v2d_mask(&region->runtime->handlers, keymap);
UI_panel_category_active_set_default(region, "Strip");
@@ -1079,7 +1083,8 @@ static void sequencer_channel_region_init(wmWindowManager *wm, ARegion *region)
UI_view2d_region_reinit(&region->v2d, V2D_COMMONVIEW_LIST, region->winx, region->winy);
keymap = WM_keymap_ensure(wm->defaultconf, "Sequencer Channels", SPACE_SEQ, RGN_TYPE_WINDOW);
keymap = WM_keymap_ensure(
wm->runtime->defaultconf, "Sequencer Channels", SPACE_SEQ, RGN_TYPE_WINDOW);
WM_event_add_keymap_handler_v2d_mask(&region->runtime->handlers, keymap);
}

View File

@@ -196,12 +196,12 @@ static void spreadsheet_main_region_init(wmWindowManager *wm, ARegion *region)
{
wmKeyMap *keymap = WM_keymap_ensure(
wm->defaultconf, "View2D Buttons List", SPACE_EMPTY, RGN_TYPE_WINDOW);
wm->runtime->defaultconf, "View2D Buttons List", SPACE_EMPTY, RGN_TYPE_WINDOW);
WM_event_add_keymap_handler(&region->runtime->handlers, keymap);
}
{
wmKeyMap *keymap = WM_keymap_ensure(
wm->defaultconf, "Spreadsheet Generic", SPACE_SPREADSHEET, RGN_TYPE_WINDOW);
wm->runtime->defaultconf, "Spreadsheet Generic", SPACE_SPREADSHEET, RGN_TYPE_WINDOW);
WM_event_add_keymap_handler(&region->runtime->handlers, keymap);
}
}
@@ -714,7 +714,7 @@ static void spreadsheet_sidebar_init(wmWindowManager *wm, ARegion *region)
ED_region_panels_init(wm, region);
wmKeyMap *keymap = WM_keymap_ensure(
wm->defaultconf, "Spreadsheet Generic", SPACE_SPREADSHEET, RGN_TYPE_WINDOW);
wm->runtime->defaultconf, "Spreadsheet Generic", SPACE_SPREADSHEET, RGN_TYPE_WINDOW);
WM_event_add_keymap_handler(&region->runtime->handlers, keymap);
}

View File

@@ -256,9 +256,9 @@ static void text_main_region_init(wmWindowManager *wm, ARegion *region)
UI_view2d_region_reinit(&region->v2d, V2D_COMMONVIEW_STANDARD, region->winx, region->winy);
/* Own keymap. */
keymap = WM_keymap_ensure(wm->defaultconf, "Text Generic", SPACE_TEXT, RGN_TYPE_WINDOW);
keymap = WM_keymap_ensure(wm->runtime->defaultconf, "Text Generic", SPACE_TEXT, RGN_TYPE_WINDOW);
WM_event_add_keymap_handler_v2d_mask(&region->runtime->handlers, keymap);
keymap = WM_keymap_ensure(wm->defaultconf, "Text", SPACE_TEXT, RGN_TYPE_WINDOW);
keymap = WM_keymap_ensure(wm->runtime->defaultconf, "Text", SPACE_TEXT, RGN_TYPE_WINDOW);
WM_event_add_keymap_handler_v2d_mask(&region->runtime->handlers, keymap);
/* Add drop boxes. */
@@ -383,7 +383,7 @@ static void text_properties_region_init(wmWindowManager *wm, ARegion *region)
ED_region_panels_init(wm, region);
/* Own keymaps. */
keymap = WM_keymap_ensure(wm->defaultconf, "Text Generic", SPACE_TEXT, RGN_TYPE_WINDOW);
keymap = WM_keymap_ensure(wm->runtime->defaultconf, "Text Generic", SPACE_TEXT, RGN_TYPE_WINDOW);
WM_event_add_keymap_handler_v2d_mask(&region->runtime->handlers, keymap);
}

View File

@@ -90,7 +90,8 @@ static void topbar_main_region_init(wmWindowManager *wm, ARegion *region)
}
UI_view2d_region_reinit(&region->v2d, V2D_COMMONVIEW_HEADER, region->winx, region->winy);
keymap = WM_keymap_ensure(wm->defaultconf, "View2D Buttons List", SPACE_EMPTY, RGN_TYPE_WINDOW);
keymap = WM_keymap_ensure(
wm->runtime->defaultconf, "View2D Buttons List", SPACE_EMPTY, RGN_TYPE_WINDOW);
WM_event_add_keymap_handler(&region->runtime->handlers, keymap);
}
@@ -213,13 +214,13 @@ static void recent_files_menu_register()
static void undo_history_draw_menu(const bContext *C, Menu *menu)
{
wmWindowManager *wm = CTX_wm_manager(C);
if (wm->undo_stack == nullptr) {
if (wm->runtime->undo_stack == nullptr) {
return;
}
int undo_step_count = 0;
int undo_step_count_all = 0;
LISTBASE_FOREACH_BACKWARD (UndoStep *, us, &wm->undo_stack->steps) {
LISTBASE_FOREACH_BACKWARD (UndoStep *, us, &wm->runtime->undo_stack->steps) {
undo_step_count_all += 1;
if (us->skip) {
continue;
@@ -236,7 +237,8 @@ static void undo_history_draw_menu(const bContext *C, Menu *menu)
/* Reverse the order so the most recent state is first in the menu. */
int i = undo_step_count_all - 1;
for (UndoStep *us = static_cast<UndoStep *>(wm->undo_stack->steps.last); us; us = us->prev, i--)
for (UndoStep *us = static_cast<UndoStep *>(wm->runtime->undo_stack->steps.last); us;
us = us->prev, i--)
{
if (us->skip) {
continue;
@@ -244,7 +246,7 @@ static void undo_history_draw_menu(const bContext *C, Menu *menu)
if (!(undo_step_count % col_size)) {
column = &split->column(false);
}
const bool is_active = (us == wm->undo_stack->step_active);
const bool is_active = (us == wm->runtime->undo_stack->step_active);
uiLayout *row = &column->row(false);
row->enabled_set(!is_active);
PointerRNA op_ptr = row->op("ED_OT_undo_history",

View File

@@ -337,63 +337,70 @@ static void view3d_main_region_init(wmWindowManager *wm, ARegion *region)
/* object ops. */
/* important to be before Pose keymap since they can both be enabled at once */
keymap = WM_keymap_ensure(
wm->defaultconf, "Paint Face Mask (Weight, Vertex, Texture)", SPACE_EMPTY, RGN_TYPE_WINDOW);
keymap = WM_keymap_ensure(wm->runtime->defaultconf,
"Paint Face Mask (Weight, Vertex, Texture)",
SPACE_EMPTY,
RGN_TYPE_WINDOW);
WM_event_add_keymap_handler(&region->runtime->handlers, keymap);
keymap = WM_keymap_ensure(
wm->defaultconf, "Paint Vertex Selection (Weight, Vertex)", SPACE_EMPTY, RGN_TYPE_WINDOW);
keymap = WM_keymap_ensure(wm->runtime->defaultconf,
"Paint Vertex Selection (Weight, Vertex)",
SPACE_EMPTY,
RGN_TYPE_WINDOW);
WM_event_add_keymap_handler(&region->runtime->handlers, keymap);
/* Before 'Weight/Vertex Paint' so adding curve points is not overridden. */
keymap = WM_keymap_ensure(wm->defaultconf, "Paint Curve", SPACE_EMPTY, RGN_TYPE_WINDOW);
keymap = WM_keymap_ensure(wm->runtime->defaultconf, "Paint Curve", SPACE_EMPTY, RGN_TYPE_WINDOW);
WM_event_add_keymap_handler(&region->runtime->handlers, keymap);
/* Before 'Pose' so weight paint menus aren't overridden by pose menus. */
keymap = WM_keymap_ensure(wm->defaultconf, "Weight Paint", SPACE_EMPTY, RGN_TYPE_WINDOW);
keymap = WM_keymap_ensure(
wm->runtime->defaultconf, "Weight Paint", SPACE_EMPTY, RGN_TYPE_WINDOW);
WM_event_add_keymap_handler(&region->runtime->handlers, keymap);
keymap = WM_keymap_ensure(wm->defaultconf, "Vertex Paint", SPACE_EMPTY, RGN_TYPE_WINDOW);
keymap = WM_keymap_ensure(
wm->runtime->defaultconf, "Vertex Paint", SPACE_EMPTY, RGN_TYPE_WINDOW);
WM_event_add_keymap_handler(&region->runtime->handlers, keymap);
/* pose is not modal, operator poll checks for this */
keymap = WM_keymap_ensure(wm->defaultconf, "Pose", SPACE_EMPTY, RGN_TYPE_WINDOW);
keymap = WM_keymap_ensure(wm->runtime->defaultconf, "Pose", SPACE_EMPTY, RGN_TYPE_WINDOW);
WM_event_add_keymap_handler(&region->runtime->handlers, keymap);
keymap = WM_keymap_ensure(wm->defaultconf, "Object Mode", SPACE_EMPTY, RGN_TYPE_WINDOW);
keymap = WM_keymap_ensure(wm->runtime->defaultconf, "Object Mode", SPACE_EMPTY, RGN_TYPE_WINDOW);
WM_event_add_keymap_handler(&region->runtime->handlers, keymap);
keymap = WM_keymap_ensure(wm->defaultconf, "Curve", SPACE_EMPTY, RGN_TYPE_WINDOW);
keymap = WM_keymap_ensure(wm->runtime->defaultconf, "Curve", SPACE_EMPTY, RGN_TYPE_WINDOW);
WM_event_add_keymap_handler(&region->runtime->handlers, keymap);
keymap = WM_keymap_ensure(wm->defaultconf, "Curves", SPACE_EMPTY, RGN_TYPE_WINDOW);
keymap = WM_keymap_ensure(wm->runtime->defaultconf, "Curves", SPACE_EMPTY, RGN_TYPE_WINDOW);
WM_event_add_keymap_handler(&region->runtime->handlers, keymap);
keymap = WM_keymap_ensure(wm->defaultconf, "Image Paint", SPACE_EMPTY, RGN_TYPE_WINDOW);
keymap = WM_keymap_ensure(wm->runtime->defaultconf, "Image Paint", SPACE_EMPTY, RGN_TYPE_WINDOW);
WM_event_add_keymap_handler(&region->runtime->handlers, keymap);
keymap = WM_keymap_ensure(wm->defaultconf, "Sculpt", SPACE_EMPTY, RGN_TYPE_WINDOW);
keymap = WM_keymap_ensure(wm->runtime->defaultconf, "Sculpt", SPACE_EMPTY, RGN_TYPE_WINDOW);
WM_event_add_keymap_handler(&region->runtime->handlers, keymap);
keymap = WM_keymap_ensure(wm->defaultconf, "Mesh", SPACE_EMPTY, RGN_TYPE_WINDOW);
keymap = WM_keymap_ensure(wm->runtime->defaultconf, "Mesh", SPACE_EMPTY, RGN_TYPE_WINDOW);
WM_event_add_keymap_handler(&region->runtime->handlers, keymap);
keymap = WM_keymap_ensure(wm->defaultconf, "Armature", SPACE_EMPTY, RGN_TYPE_WINDOW);
keymap = WM_keymap_ensure(wm->runtime->defaultconf, "Armature", SPACE_EMPTY, RGN_TYPE_WINDOW);
WM_event_add_keymap_handler(&region->runtime->handlers, keymap);
keymap = WM_keymap_ensure(wm->defaultconf, "Metaball", SPACE_EMPTY, RGN_TYPE_WINDOW);
keymap = WM_keymap_ensure(wm->runtime->defaultconf, "Metaball", SPACE_EMPTY, RGN_TYPE_WINDOW);
WM_event_add_keymap_handler(&region->runtime->handlers, keymap);
keymap = WM_keymap_ensure(wm->defaultconf, "Lattice", SPACE_EMPTY, RGN_TYPE_WINDOW);
keymap = WM_keymap_ensure(wm->runtime->defaultconf, "Lattice", SPACE_EMPTY, RGN_TYPE_WINDOW);
WM_event_add_keymap_handler(&region->runtime->handlers, keymap);
keymap = WM_keymap_ensure(wm->defaultconf, "Particle", SPACE_EMPTY, RGN_TYPE_WINDOW);
keymap = WM_keymap_ensure(wm->runtime->defaultconf, "Particle", SPACE_EMPTY, RGN_TYPE_WINDOW);
WM_event_add_keymap_handler(&region->runtime->handlers, keymap);
keymap = WM_keymap_ensure(wm->defaultconf, "Point Cloud", SPACE_EMPTY, RGN_TYPE_WINDOW);
keymap = WM_keymap_ensure(wm->runtime->defaultconf, "Point Cloud", SPACE_EMPTY, RGN_TYPE_WINDOW);
WM_event_add_keymap_handler(&region->runtime->handlers, keymap);
keymap = WM_keymap_ensure(wm->defaultconf, "Sculpt Curves", SPACE_EMPTY, RGN_TYPE_WINDOW);
keymap = WM_keymap_ensure(
wm->runtime->defaultconf, "Sculpt Curves", SPACE_EMPTY, RGN_TYPE_WINDOW);
WM_event_add_keymap_handler(&region->runtime->handlers, keymap);
/* NOTE: Grease Pencil handlers used to be added using #ED_KEYMAP_GPENCIL in
@@ -401,52 +408,54 @@ static void view3d_main_region_init(wmWindowManager *wm, ARegion *region)
* annotations.). But for OB_GREASE_PENCIL, we only need it to register the keymaps for the
* 3D View. */
keymap = WM_keymap_ensure(
wm->defaultconf, "Grease Pencil Selection", SPACE_EMPTY, RGN_TYPE_WINDOW);
wm->runtime->defaultconf, "Grease Pencil Selection", SPACE_EMPTY, RGN_TYPE_WINDOW);
WM_event_add_keymap_handler(&region->runtime->handlers, keymap);
keymap = WM_keymap_ensure(
wm->defaultconf, "Grease Pencil Edit Mode", SPACE_EMPTY, RGN_TYPE_WINDOW);
wm->runtime->defaultconf, "Grease Pencil Edit Mode", SPACE_EMPTY, RGN_TYPE_WINDOW);
WM_event_add_keymap_handler(&region->runtime->handlers, keymap);
keymap = WM_keymap_ensure(
wm->defaultconf, "Grease Pencil Paint Mode", SPACE_EMPTY, RGN_TYPE_WINDOW);
wm->runtime->defaultconf, "Grease Pencil Paint Mode", SPACE_EMPTY, RGN_TYPE_WINDOW);
WM_event_add_keymap_handler(&region->runtime->handlers, keymap);
keymap = WM_keymap_ensure(
wm->defaultconf, "Grease Pencil Sculpt Mode", SPACE_EMPTY, RGN_TYPE_WINDOW);
wm->runtime->defaultconf, "Grease Pencil Sculpt Mode", SPACE_EMPTY, RGN_TYPE_WINDOW);
WM_event_add_keymap_handler(&region->runtime->handlers, keymap);
keymap = WM_keymap_ensure(
wm->defaultconf, "Grease Pencil Weight Paint", SPACE_EMPTY, RGN_TYPE_WINDOW);
wm->runtime->defaultconf, "Grease Pencil Weight Paint", SPACE_EMPTY, RGN_TYPE_WINDOW);
WM_event_add_keymap_handler(&region->runtime->handlers, keymap);
keymap = WM_keymap_ensure(
wm->defaultconf, "Grease Pencil Vertex Paint", SPACE_EMPTY, RGN_TYPE_WINDOW);
wm->runtime->defaultconf, "Grease Pencil Vertex Paint", SPACE_EMPTY, RGN_TYPE_WINDOW);
WM_event_add_keymap_handler(&region->runtime->handlers, keymap);
keymap = WM_keymap_ensure(
wm->defaultconf, "Grease Pencil Brush Stroke", SPACE_EMPTY, RGN_TYPE_WINDOW);
wm->runtime->defaultconf, "Grease Pencil Brush Stroke", SPACE_EMPTY, RGN_TYPE_WINDOW);
WM_event_add_keymap_handler(&region->runtime->handlers, keymap);
keymap = WM_keymap_ensure(
wm->defaultconf, "Grease Pencil Fill Tool", SPACE_EMPTY, RGN_TYPE_WINDOW);
wm->runtime->defaultconf, "Grease Pencil Fill Tool", SPACE_EMPTY, RGN_TYPE_WINDOW);
WM_event_add_keymap_handler(&region->runtime->handlers, keymap);
/* Edit-font key-map swallows almost all (because of text input). */
keymap = WM_keymap_ensure(wm->defaultconf, "Font", SPACE_EMPTY, RGN_TYPE_WINDOW);
keymap = WM_keymap_ensure(wm->runtime->defaultconf, "Font", SPACE_EMPTY, RGN_TYPE_WINDOW);
WM_event_add_keymap_handler(&region->runtime->handlers, keymap);
keymap = WM_keymap_ensure(wm->defaultconf, "Object Non-modal", SPACE_EMPTY, RGN_TYPE_WINDOW);
keymap = WM_keymap_ensure(
wm->runtime->defaultconf, "Object Non-modal", SPACE_EMPTY, RGN_TYPE_WINDOW);
WM_event_add_keymap_handler(&region->runtime->handlers, keymap);
keymap = WM_keymap_ensure(wm->defaultconf, "Frames", SPACE_EMPTY, RGN_TYPE_WINDOW);
keymap = WM_keymap_ensure(wm->runtime->defaultconf, "Frames", SPACE_EMPTY, RGN_TYPE_WINDOW);
WM_event_add_keymap_handler(&region->runtime->handlers, keymap);
/* own keymap, last so modes can override it */
keymap = WM_keymap_ensure(wm->defaultconf, "3D View Generic", SPACE_VIEW3D, RGN_TYPE_WINDOW);
keymap = WM_keymap_ensure(
wm->runtime->defaultconf, "3D View Generic", SPACE_VIEW3D, RGN_TYPE_WINDOW);
WM_event_add_keymap_handler(&region->runtime->handlers, keymap);
keymap = WM_keymap_ensure(wm->defaultconf, "3D View", SPACE_VIEW3D, RGN_TYPE_WINDOW);
keymap = WM_keymap_ensure(wm->runtime->defaultconf, "3D View", SPACE_VIEW3D, RGN_TYPE_WINDOW);
WM_event_add_keymap_handler(&region->runtime->handlers, keymap);
/* add drop boxes */
@@ -973,7 +982,7 @@ static void view3d_main_region_cursor(wmWindow *win, ScrArea *area, ARegion *reg
static void view3d_header_region_init(wmWindowManager *wm, ARegion *region)
{
wmKeyMap *keymap = WM_keymap_ensure(
wm->defaultconf, "3D View Generic", SPACE_VIEW3D, RGN_TYPE_WINDOW);
wm->runtime->defaultconf, "3D View Generic", SPACE_VIEW3D, RGN_TYPE_WINDOW);
WM_event_add_keymap_handler(&region->runtime->handlers, keymap);
@@ -1125,7 +1134,8 @@ static void view3d_buttons_region_init(wmWindowManager *wm, ARegion *region)
region->flag |= RGN_FLAG_INDICATE_OVERFLOW;
keymap = WM_keymap_ensure(wm->defaultconf, "3D View Generic", SPACE_VIEW3D, RGN_TYPE_WINDOW);
keymap = WM_keymap_ensure(
wm->runtime->defaultconf, "3D View Generic", SPACE_VIEW3D, RGN_TYPE_WINDOW);
WM_event_add_keymap_handler(&region->runtime->handlers, keymap);
}
@@ -1382,7 +1392,8 @@ static void view3d_tools_region_init(wmWindowManager *wm, ARegion *region)
region->flag |= RGN_FLAG_INDICATE_OVERFLOW;
keymap = WM_keymap_ensure(wm->defaultconf, "3D View Generic", SPACE_VIEW3D, RGN_TYPE_WINDOW);
keymap = WM_keymap_ensure(
wm->runtime->defaultconf, "3D View Generic", SPACE_VIEW3D, RGN_TYPE_WINDOW);
WM_event_add_keymap_handler(&region->runtime->handlers, keymap);
}
@@ -1407,7 +1418,7 @@ static void view3d_asset_shelf_region_init(wmWindowManager *wm, ARegion *region)
{
using namespace blender::ed;
wmKeyMap *keymap = WM_keymap_ensure(
wm->defaultconf, "3D View Generic", SPACE_VIEW3D, RGN_TYPE_WINDOW);
wm->runtime->defaultconf, "3D View Generic", SPACE_VIEW3D, RGN_TYPE_WINDOW);
WM_event_add_keymap_handler(&region->runtime->handlers, keymap);
asset::shelf::region_init(wm, region);

View File

@@ -983,7 +983,7 @@ static void v3d_cursor_snap_activate()
* TODO: ED_view3d_cursor_snap_init */
#ifdef USE_SNAP_DETECT_FROM_KEYMAP_HACK
wmKeyConfig *keyconf = ((wmWindowManager *)G.main->wm.first)->defaultconf;
wmKeyConfig *keyconf = ((wmWindowManager *)G.main->wm.first)->runtime->defaultconf;
data_intern->keymap = WM_modalkeymap_find(keyconf, "Generic Gizmo Tweak Modal Map");
RNA_enum_value_from_id(

View File

@@ -107,7 +107,7 @@ static wmGizmo *tool_generic_create_gizmo(const bContext *C, wmGizmoGroup *gzgro
}
wmWindowManager *wm = CTX_wm_manager(C);
wmKeyConfig *kc = wm->defaultconf;
wmKeyConfig *kc = wm->runtime->defaultconf;
gz->keymap = WM_keymap_ensure(kc, tref->runtime->keymap, tref->space_type, RGN_TYPE_WINDOW);
return gz;

View File

@@ -64,16 +64,16 @@ bool ED_undo_is_state_valid(bContext *C)
wmWindowManager *wm = CTX_wm_manager(C);
/* Currently only checks matching begin/end calls. */
if (wm->undo_stack == nullptr) {
if (wm->runtime->undo_stack == nullptr) {
/* No undo stack is valid, nothing to do. */
return true;
}
if (wm->undo_stack->group_level != 0) {
if (wm->runtime->undo_stack->group_level != 0) {
/* If this fails #ED_undo_grouped_begin, #ED_undo_grouped_end calls don't match. */
return false;
}
if (wm->undo_stack->step_active != nullptr) {
if (wm->undo_stack->step_active->skip == true) {
if (wm->runtime->undo_stack->step_active != nullptr) {
if (wm->runtime->undo_stack->step_active->skip == true) {
/* Skip is only allowed between begin/end calls,
* a state that should never happen in main event loop. */
return false;
@@ -85,13 +85,13 @@ bool ED_undo_is_state_valid(bContext *C)
void ED_undo_group_begin(bContext *C)
{
wmWindowManager *wm = CTX_wm_manager(C);
BKE_undosys_stack_group_begin(wm->undo_stack);
BKE_undosys_stack_group_begin(wm->runtime->undo_stack);
}
void ED_undo_group_end(bContext *C)
{
wmWindowManager *wm = CTX_wm_manager(C);
BKE_undosys_stack_group_end(wm->undo_stack);
BKE_undosys_stack_group_end(wm->runtime->undo_stack);
}
void ED_undo_push(bContext *C, const char *str)
@@ -110,7 +110,7 @@ void ED_undo_push(bContext *C, const char *str)
*
* For this reason we need to handle the undo step even when undo steps is set to zero.
*/
if ((steps <= 0) && wm->undo_stack->step_init != nullptr) {
if ((steps <= 0) && wm->runtime->undo_stack->step_init != nullptr) {
steps = 1;
}
if (steps <= 0) {
@@ -120,7 +120,7 @@ void ED_undo_push(bContext *C, const char *str)
/* Python developers may have explicitly created the undo stack in background mode,
* otherwise allow it to be nullptr, see: #60934.
* Otherwise it must never be nullptr, even when undo is disabled. */
if (wm->undo_stack == nullptr) {
if (wm->runtime->undo_stack == nullptr) {
return;
}
}
@@ -128,19 +128,21 @@ void ED_undo_push(bContext *C, const char *str)
eUndoPushReturn push_retval;
/* Only apply limit if this is the last undo step. */
if (wm->undo_stack->step_active && (wm->undo_stack->step_active->next == nullptr)) {
BKE_undosys_stack_limit_steps_and_memory(wm->undo_stack, steps - 1, 0);
if (wm->runtime->undo_stack->step_active &&
(wm->runtime->undo_stack->step_active->next == nullptr))
{
BKE_undosys_stack_limit_steps_and_memory(wm->runtime->undo_stack, steps - 1, 0);
}
push_retval = BKE_undosys_step_push(wm->undo_stack, C, str);
push_retval = BKE_undosys_step_push(wm->runtime->undo_stack, C, str);
if (U.undomemory != 0) {
const size_t memory_limit = size_t(U.undomemory) * 1024 * 1024;
BKE_undosys_stack_limit_steps_and_memory(wm->undo_stack, -1, memory_limit);
BKE_undosys_stack_limit_steps_and_memory(wm->runtime->undo_stack, -1, memory_limit);
}
if (CLOG_CHECK(&LOG, CLG_LEVEL_DEBUG)) {
BKE_undosys_print(wm->undo_stack);
BKE_undosys_print(wm->runtime->undo_stack);
}
if (push_retval & UNDO_PUSH_RET_OVERRIDE_CHANGED) {
@@ -223,7 +225,7 @@ static void ed_undo_step_post(bContext *C,
asset::list::storage_tag_main_data_dirty();
if (CLOG_CHECK(&LOG, CLG_LEVEL_DEBUG)) {
BKE_undosys_print(wm->undo_stack);
BKE_undosys_print(wm->runtime->undo_stack);
}
}
@@ -245,10 +247,10 @@ static wmOperatorStatus ed_undo_step_direction(bContext *C,
ed_undo_step_pre(C, wm, step, reports);
if (step == STEP_UNDO) {
BKE_undosys_step_undo(wm->undo_stack, C);
BKE_undosys_step_undo(wm->runtime->undo_stack, C);
}
else {
BKE_undosys_step_redo(wm->undo_stack, C);
BKE_undosys_step_redo(wm->runtime->undo_stack, C);
}
ed_undo_step_post(C, wm, step, reports);
@@ -266,7 +268,8 @@ static int ed_undo_step_by_name(bContext *C, const char *undo_name, ReportList *
BLI_assert(undo_name != nullptr);
wmWindowManager *wm = CTX_wm_manager(C);
UndoStep *undo_step_from_name = BKE_undosys_step_find_by_name(wm->undo_stack, undo_name);
UndoStep *undo_step_from_name = BKE_undosys_step_find_by_name(wm->runtime->undo_stack,
undo_name);
if (undo_step_from_name == nullptr) {
CLOG_ERROR(&LOG, "Step name='%s' not found in current undo stack", undo_name);
@@ -281,7 +284,7 @@ static int ed_undo_step_by_name(bContext *C, const char *undo_name, ReportList *
}
const int undo_dir_i = BKE_undosys_step_calc_direction(
wm->undo_stack, undo_step_target, nullptr);
wm->runtime->undo_stack, undo_step_target, nullptr);
BLI_assert(ELEM(undo_dir_i, -1, 1));
const enum eUndoStepDir undo_dir = (undo_dir_i == -1) ? STEP_UNDO : STEP_REDO;
@@ -292,7 +295,7 @@ static int ed_undo_step_by_name(bContext *C, const char *undo_name, ReportList *
ed_undo_step_pre(C, wm, undo_dir, reports);
BKE_undosys_step_load_data_ex(wm->undo_stack, C, undo_step_target, nullptr, true);
BKE_undosys_step_load_data_ex(wm->runtime->undo_stack, C, undo_step_target, nullptr, true);
ed_undo_step_post(C, wm, undo_dir, reports);
@@ -309,7 +312,8 @@ static int ed_undo_step_by_index(bContext *C, const int undo_index, ReportList *
BLI_assert(undo_index >= 0);
wmWindowManager *wm = CTX_wm_manager(C);
const int active_step_index = BLI_findindex(&wm->undo_stack->steps, wm->undo_stack->step_active);
const int active_step_index = BLI_findindex(&wm->runtime->undo_stack->steps,
wm->runtime->undo_stack->step_active);
if (undo_index == active_step_index) {
return OPERATOR_CANCELLED;
}
@@ -322,7 +326,7 @@ static int ed_undo_step_by_index(bContext *C, const int undo_index, ReportList *
ed_undo_step_pre(C, wm, undo_dir, reports);
BKE_undosys_step_load_from_index(wm->undo_stack, C, undo_index);
BKE_undosys_step_load_from_index(wm->runtime->undo_stack, C, undo_index);
ed_undo_step_post(C, wm, undo_dir, reports);
@@ -333,9 +337,9 @@ void ED_undo_grouped_push(bContext *C, const char *str)
{
/* do nothing if previous undo task is the same as this one (or from the same undo group) */
wmWindowManager *wm = CTX_wm_manager(C);
const UndoStep *us = wm->undo_stack->step_active;
const UndoStep *us = wm->runtime->undo_stack->step_active;
if (us && STREQ(str, us->name)) {
BKE_undosys_stack_clear_active(wm->undo_stack);
BKE_undosys_stack_clear_active(wm->runtime->undo_stack);
}
/* push as usual */
@@ -376,7 +380,7 @@ void ED_undo_pop_op(bContext *C, wmOperator *op)
bool ED_undo_is_valid(const bContext *C, const char *undoname)
{
wmWindowManager *wm = CTX_wm_manager(C);
return BKE_undosys_stack_has_undo(wm->undo_stack, undoname);
return BKE_undosys_stack_has_undo(wm->runtime->undo_stack, undoname);
}
bool ED_undo_is_memfile_compatible(const bContext *C)
@@ -437,7 +441,7 @@ bool ED_undo_is_legacy_compatible_for_property(bContext *C, ID *id, PointerRNA &
UndoStack *ED_undo_stack_get()
{
wmWindowManager *wm = static_cast<wmWindowManager *>(G_MAIN->wm.first);
return wm->undo_stack;
return wm->runtime->undo_stack;
}
/** \} */
@@ -478,8 +482,8 @@ static wmOperatorStatus ed_undo_push_exec(bContext *C, wmOperator *op)
* NOTE: since the undo stack isn't initialized on startup, background mode behavior
* won't match regular usage, this is just for scripts to do explicit undo pushes. */
wmWindowManager *wm = CTX_wm_manager(C);
if (wm->undo_stack == nullptr) {
wm->undo_stack = BKE_undosys_stack_create();
if (wm->runtime->undo_stack == nullptr) {
wm->runtime->undo_stack = BKE_undosys_stack_create();
}
}
char str[BKE_UNDO_STR_MAX];
@@ -514,7 +518,7 @@ static wmOperatorStatus ed_undo_redo_exec(bContext *C, wmOperator * /*op*/)
static bool ed_undo_is_init_poll(bContext *C)
{
wmWindowManager *wm = CTX_wm_manager(C);
if (wm->undo_stack == nullptr) {
if (wm->runtime->undo_stack == nullptr) {
/* This message is intended for Python developers,
* it will be part of the exception when attempting to call undo in background mode. */
CTX_wm_operator_poll_msg_set(
@@ -546,7 +550,7 @@ static bool ed_undo_poll(bContext *C)
if (!ed_undo_is_init_and_screenactive_poll(C)) {
return false;
}
UndoStack *undo_stack = CTX_wm_manager(C)->undo_stack;
UndoStack *undo_stack = CTX_wm_manager(C)->runtime->undo_stack;
return (undo_stack->step_active != nullptr) && (undo_stack->step_active->prev != nullptr);
}
@@ -589,7 +593,7 @@ static bool ed_redo_poll(bContext *C)
if (!ed_undo_is_init_and_screenactive_poll(C)) {
return false;
}
UndoStack *undo_stack = CTX_wm_manager(C)->undo_stack;
UndoStack *undo_stack = CTX_wm_manager(C)->runtime->undo_stack;
return (undo_stack->step_active != nullptr) && (undo_stack->step_active->next != nullptr);
}

View File

@@ -223,9 +223,9 @@ void ED_editors_exit(Main *bmain, bool do_undo_system)
wmWindowManager *wm = static_cast<wmWindowManager *>(G_MAIN->wm.first);
/* normally we don't check for null undo stack,
* do here since it may run in different context. */
if (wm->undo_stack) {
BKE_undosys_stack_destroy(wm->undo_stack);
wm->undo_stack = nullptr;
if (wm->runtime->undo_stack) {
BKE_undosys_stack_destroy(wm->runtime->undo_stack);
wm->runtime->undo_stack = nullptr;
}
}

View File

@@ -91,15 +91,6 @@ typedef struct wmWindowManager {
ID id;
/** Separate active from drawable. */
struct wmWindow *windrawable;
/**
* \note `CTX_wm_window(C)` is usually preferred.
* Avoid relying on this where possible as this may become NULL during when handling
* events that close or replace windows (e.g. opening a file).
* While this happens rarely in practice, it can cause difficult to reproduce bugs.
*/
struct wmWindow *winactive;
ListBase windows;
/** Set on file read. */
@@ -118,24 +109,12 @@ typedef struct wmWindowManager {
/** Number of blocked & installed extensions. */
int extensions_blocked;
/** Default configuration. */
struct wmKeyConfig *defaultconf;
/** Addon configuration. */
struct wmKeyConfig *addonconf;
/** User configuration. */
struct wmKeyConfig *userconf;
/** Timer for auto save. */
struct wmTimer *autosavetimer;
/** Auto-save timer was up, but it wasn't possible to auto-save in the current mode. */
char autosave_scheduled;
char _pad2[7];
/** All undo history (runtime only). */
struct UndoStack *undo_stack;
struct wmMsgBus *message_bus;
// #ifdef WITH_XR_OPENXR
wmXrData xr;
// #endif
@@ -143,7 +122,8 @@ typedef struct wmWindowManager {
WindowManagerRuntimeHandle *runtime;
} wmWindowManager;
#define WM_KEYCONFIG_ARRAY_P(wm) &(wm)->defaultconf, &(wm)->addonconf, &(wm)->userconf
#define WM_KEYCONFIG_ARRAY_P(wm) \
&(wm)->runtime->defaultconf, &(wm)->runtime->addonconf, &(wm)->runtime->userconf
/** #wmWindowManager.extensions_updates */
enum {

View File

@@ -1272,7 +1272,7 @@ static PointerRNA rna_WindowManager_active_keyconfig_get(PointerRNA *ptr)
BLI_findstring(&wm->runtime->keyconfigs, U.keyconfigstr, offsetof(wmKeyConfig, idname)));
if (!kc) {
kc = wm->defaultconf;
kc = wm->runtime->defaultconf;
}
return RNA_pointer_create_with_parent(*ptr, &RNA_KeyConfig, kc);
@@ -1290,6 +1290,24 @@ static void rna_WindowManager_active_keyconfig_set(PointerRNA *ptr,
}
}
static PointerRNA rna_WindowManager_default_keyconfig_get(PointerRNA *ptr)
{
wmWindowManager *wm = static_cast<wmWindowManager *>(ptr->data);
return RNA_pointer_create_with_parent(*ptr, &RNA_KeyConfig, wm->runtime->defaultconf);
}
static PointerRNA rna_WindowManager_addon_keyconfig_get(PointerRNA *ptr)
{
wmWindowManager *wm = static_cast<wmWindowManager *>(ptr->data);
return RNA_pointer_create_with_parent(*ptr, &RNA_KeyConfig, wm->runtime->addonconf);
}
static PointerRNA rna_WindowManager_user_keyconfig_get(PointerRNA *ptr)
{
wmWindowManager *wm = static_cast<wmWindowManager *>(ptr->data);
return RNA_pointer_create_with_parent(*ptr, &RNA_KeyConfig, wm->runtime->userconf);
}
static void rna_WindowManager_extensions_statusbar_update(Main * /*bmain*/,
Scene * /*scene*/,
PointerRNA *ptr)
@@ -2803,13 +2821,15 @@ static void rna_def_wm_keyconfigs(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_property_ui_text(prop, "Active KeyConfig", "Active key configuration (preset)");
prop = RNA_def_property(srna, "default", PROP_POINTER, PROP_NEVER_NULL);
RNA_def_property_pointer_sdna(prop, nullptr, "defaultconf");
RNA_def_property_pointer_funcs(
prop, "rna_WindowManager_default_keyconfig_get", nullptr, nullptr, nullptr);
RNA_def_property_struct_type(prop, "KeyConfig");
RNA_def_property_ui_text(prop, "Default Key Configuration", "Default builtin key configuration");
prop = RNA_def_property(srna, "addon", PROP_POINTER, PROP_NEVER_NULL);
RNA_def_property_pointer_sdna(prop, nullptr, "addonconf");
RNA_def_property_struct_type(prop, "KeyConfig");
RNA_def_property_pointer_funcs(
prop, "rna_WindowManager_addon_keyconfig_get", nullptr, nullptr, nullptr);
RNA_def_property_ui_text(
prop,
"Add-on Key Configuration",
@@ -2817,8 +2837,9 @@ static void rna_def_wm_keyconfigs(BlenderRNA *brna, PropertyRNA *cprop)
"configuration when handling events");
prop = RNA_def_property(srna, "user", PROP_POINTER, PROP_NEVER_NULL);
RNA_def_property_pointer_sdna(prop, nullptr, "userconf");
RNA_def_property_struct_type(prop, "KeyConfig");
RNA_def_property_pointer_funcs(
prop, "rna_WindowManager_user_keyconfig_get", nullptr, nullptr, nullptr);
RNA_def_property_ui_text(
prop,
"User Key Configuration",

View File

@@ -202,7 +202,7 @@ static void rna_progress_update(wmWindowManager *wm, float value)
{
if (wm_progress_state.is_valid) {
/* Map to factor 0..1. */
wmWindow *win = wm->winactive;
wmWindow *win = wm->runtime->winactive;
if (win) {
const float progress_factor = (value - wm_progress_state.min) /
(wm_progress_state.max - wm_progress_state.min);
@@ -214,7 +214,7 @@ static void rna_progress_update(wmWindowManager *wm, float value)
static void rna_progress_end(wmWindowManager *wm)
{
if (wm_progress_state.is_valid) {
wmWindow *win = wm->winactive;
wmWindow *win = wm->runtime->winactive;
if (win) {
WM_cursor_modal_restore(win);
wm_progress_state.is_valid = false;
@@ -490,7 +490,7 @@ static wmKeyMap *rna_KeyMaps_new(wmKeyConfig *keyconf,
* Currently this is only useful for add-ons to override built-in modal keymaps
* which is not the intended use for add-on keymaps. */
wmWindowManager *wm = static_cast<wmWindowManager *>(G_MAIN->wm.first);
if (keyconf == wm->addonconf) {
if (keyconf == wm->runtime->addonconf) {
BKE_reportf(reports, RPT_ERROR, "Modal key-maps not supported for add-on key-config");
return nullptr;
}
@@ -676,7 +676,7 @@ static void rna_PieMenuEnd(bContext *C, PointerRNA *handle)
static void rna_WindowManager_print_undo_steps(wmWindowManager *wm)
{
BKE_undosys_print(wm->undo_stack);
BKE_undosys_print(wm->runtime->undo_stack);
}
static void rna_WindowManager_tag_script_reload()

View File

@@ -248,7 +248,7 @@ void WM_gizmogroup_ensure_init(const bContext *C, wmGizmoGroup *gzgroup)
wmGizmoGroupType *gzgt = gzgroup->type;
if (gzgt->keymap == nullptr) {
wmWindowManager *wm = CTX_wm_manager(C);
wm_gizmogrouptype_setup_keymap(gzgt, wm->defaultconf);
wm_gizmogrouptype_setup_keymap(gzgt, wm->runtime->defaultconf);
BLI_assert(gzgt->keymap != nullptr);
}
gzgroup->init_flag |= WM_GIZMOGROUP_INIT_SETUP;
@@ -887,7 +887,7 @@ wmKeyMap *WM_gizmo_keymap_generic_with_keyconfig(wmKeyConfig *kc)
}
wmKeyMap *WM_gizmo_keymap_generic(wmWindowManager *wm)
{
return WM_gizmo_keymap_generic_with_keyconfig(wm->defaultconf);
return WM_gizmo_keymap_generic_with_keyconfig(wm->runtime->defaultconf);
}
wmKeyMap *WM_gizmo_keymap_generic_select_with_keyconfig(wmKeyConfig *kc)
@@ -897,7 +897,7 @@ wmKeyMap *WM_gizmo_keymap_generic_select_with_keyconfig(wmKeyConfig *kc)
}
wmKeyMap *WM_gizmo_keymap_generic_select(wmWindowManager *wm)
{
return WM_gizmo_keymap_generic_select_with_keyconfig(wm->defaultconf);
return WM_gizmo_keymap_generic_select_with_keyconfig(wm->runtime->defaultconf);
}
wmKeyMap *WM_gizmo_keymap_generic_drag_with_keyconfig(wmKeyConfig *kc)
@@ -907,7 +907,7 @@ wmKeyMap *WM_gizmo_keymap_generic_drag_with_keyconfig(wmKeyConfig *kc)
}
wmKeyMap *WM_gizmo_keymap_generic_drag(wmWindowManager *wm)
{
return WM_gizmo_keymap_generic_drag_with_keyconfig(wm->defaultconf);
return WM_gizmo_keymap_generic_drag_with_keyconfig(wm->runtime->defaultconf);
}
wmKeyMap *WM_gizmo_keymap_generic_press_drag_with_keyconfig(wmKeyConfig *kc)
@@ -917,7 +917,7 @@ wmKeyMap *WM_gizmo_keymap_generic_press_drag_with_keyconfig(wmKeyConfig *kc)
}
wmKeyMap *WM_gizmo_keymap_generic_press_drag(wmWindowManager *wm)
{
return WM_gizmo_keymap_generic_press_drag_with_keyconfig(wm->defaultconf);
return WM_gizmo_keymap_generic_press_drag_with_keyconfig(wm->runtime->defaultconf);
}
wmKeyMap *WM_gizmo_keymap_generic_maybe_drag_with_keyconfig(wmKeyConfig *kc)
@@ -927,7 +927,7 @@ wmKeyMap *WM_gizmo_keymap_generic_maybe_drag_with_keyconfig(wmKeyConfig *kc)
}
wmKeyMap *WM_gizmo_keymap_generic_maybe_drag(wmWindowManager *wm)
{
return WM_gizmo_keymap_generic_maybe_drag_with_keyconfig(wm->defaultconf);
return WM_gizmo_keymap_generic_maybe_drag_with_keyconfig(wm->runtime->defaultconf);
}
/** \} */
@@ -979,7 +979,7 @@ void WM_gizmomaptype_group_init_runtime_keymap(const Main *bmain, wmGizmoGroupTy
{
/* Initialize key-map.
* On startup there's an extra call to initialize keymaps for 'permanent' gizmo-groups. */
wm_gizmogrouptype_setup_keymap(gzgt, ((wmWindowManager *)bmain->wm.first)->defaultconf);
wm_gizmogrouptype_setup_keymap(gzgt, ((wmWindowManager *)bmain->wm.first)->runtime->defaultconf);
}
void WM_gizmomaptype_group_init_runtime(const Main *bmain,

View File

@@ -200,17 +200,8 @@ static void window_manager_blend_read_data(BlendDataReader *reader, ID *id)
direct_link_wm_xr_data(reader, &wm->xr);
wm->defaultconf = nullptr;
wm->addonconf = nullptr;
wm->userconf = nullptr;
wm->undo_stack = nullptr;
wm->message_bus = nullptr;
wm->xr.runtime = nullptr;
wm->windrawable = nullptr;
wm->winactive = nullptr;
wm->init_flag = 0;
wm->op_undo_depth = 0;
wm->extensions_updates = WM_EXTENSIONS_UPDATE_UNSET;
@@ -426,28 +417,28 @@ void WM_keyconfig_init(bContext *C)
wmWindowManager *wm = CTX_wm_manager(C);
/* Create standard key configuration. */
if (wm->defaultconf == nullptr) {
if (wm->runtime->defaultconf == nullptr) {
/* Keep lowercase to match the preset filename. */
wm->defaultconf = WM_keyconfig_new(wm, WM_KEYCONFIG_STR_DEFAULT, false);
wm->runtime->defaultconf = WM_keyconfig_new(wm, WM_KEYCONFIG_STR_DEFAULT, false);
}
if (wm->addonconf == nullptr) {
wm->addonconf = WM_keyconfig_new(wm, WM_KEYCONFIG_STR_DEFAULT " addon", false);
if (wm->runtime->addonconf == nullptr) {
wm->runtime->addonconf = WM_keyconfig_new(wm, WM_KEYCONFIG_STR_DEFAULT " addon", false);
}
if (wm->userconf == nullptr) {
wm->userconf = WM_keyconfig_new(wm, WM_KEYCONFIG_STR_DEFAULT " user", false);
if (wm->runtime->userconf == nullptr) {
wm->runtime->userconf = WM_keyconfig_new(wm, WM_KEYCONFIG_STR_DEFAULT " user", false);
}
/* Initialize only after python init is done, for keymaps that use python operators. */
if (CTX_py_init_get(C) && (wm->init_flag & WM_INIT_FLAG_KEYCONFIG) == 0) {
/* Create default key config, only initialize once,
* it's persistent across sessions. */
if (!(wm->defaultconf->flag & KEYCONF_INIT_DEFAULT)) {
wm_window_keymap(wm->defaultconf);
ED_spacetypes_keymap(wm->defaultconf);
if (!(wm->runtime->defaultconf->flag & KEYCONF_INIT_DEFAULT)) {
wm_window_keymap(wm->runtime->defaultconf);
ED_spacetypes_keymap(wm->runtime->defaultconf);
WM_keyconfig_reload(C);
wm->defaultconf->flag |= KEYCONF_INIT_DEFAULT;
wm->runtime->defaultconf->flag |= KEYCONF_INIT_DEFAULT;
}
/* Harmless, but no need to update in background mode. */
@@ -476,8 +467,8 @@ void WM_check(bContext *C)
}
/* Run before loading the keyconfig. */
if (wm->message_bus == nullptr) {
wm->message_bus = WM_msgbus_create();
if (wm->runtime->message_bus == nullptr) {
wm->runtime->message_bus = WM_msgbus_create();
}
if (!G.background) {
@@ -540,7 +531,7 @@ void wm_add_default(Main *bmain, bContext *C)
BKE_workspace_active_layout_set(win->workspace_hook, win->winid, workspace, layout);
screen->winid = win->winid;
wm->winactive = win;
wm->runtime->winactive = win;
wm->file_saved = 1;
wm->runtime = MEM_new<blender::bke::WindowManagerRuntime>(__func__);
wm_window_make_drawable(wm, win);
@@ -577,21 +568,12 @@ void wm_close_and_free(bContext *C, wmWindowManager *wm)
wm_window_free(C, wm, win);
}
if (wm->message_bus != nullptr) {
WM_msgbus_destroy(wm->message_bus);
}
#ifdef WITH_PYTHON
BPY_callback_wm_free(wm);
#endif
wm_reports_free(wm);
if (wm->undo_stack) {
BKE_undosys_stack_destroy(wm->undo_stack);
wm->undo_stack = nullptr;
}
if (C && CTX_wm_manager(C) == wm) {
CTX_wm_manager_set(C, nullptr);
}

View File

@@ -1332,7 +1332,7 @@ uint8_t *WM_window_pixels_read_from_frontbuffer(const wmWindowManager *wm,
* for a slower but more reliable version of this function
* #WM_window_pixels_read_from_offscreen should be preferred.
* See it's comments for details on why it's needed, see also #98462. */
bool setup_context = wm->windrawable != win;
bool setup_context = wm->runtime->windrawable != win;
if (setup_context) {
GHOST_ActivateWindowDrawingContext(static_cast<GHOST_WindowHandle>(win->ghostwin));
@@ -1346,10 +1346,10 @@ uint8_t *WM_window_pixels_read_from_frontbuffer(const wmWindowManager *wm,
GPU_frontbuffer_read_color(0, 0, win_size[0], win_size[1], 4, GPU_DATA_UBYTE, rect);
if (setup_context) {
if (wm->windrawable) {
if (wm->runtime->windrawable) {
GHOST_ActivateWindowDrawingContext(
static_cast<GHOST_WindowHandle>(wm->windrawable->ghostwin));
GPU_context_active_set(static_cast<GPUContext *>(wm->windrawable->gpuctx));
static_cast<GHOST_WindowHandle>(wm->runtime->windrawable->ghostwin));
GPU_context_active_set(static_cast<GPUContext *>(wm->runtime->windrawable->gpuctx));
}
}
@@ -1371,7 +1371,7 @@ void WM_window_pixels_read_sample_from_frontbuffer(const wmWindowManager *wm,
float r_col[3])
{
BLI_assert(WM_capabilities_flag() & WM_CAPABILITY_GPU_FRONT_BUFFER_READ);
bool setup_context = wm->windrawable != win;
bool setup_context = wm->runtime->windrawable != win;
if (setup_context) {
GHOST_ActivateWindowDrawingContext(static_cast<GHOST_WindowHandle>(win->ghostwin));
@@ -1389,10 +1389,10 @@ void WM_window_pixels_read_sample_from_frontbuffer(const wmWindowManager *wm,
copy_v3_v3(r_col, color_with_alpha.xyz());
if (setup_context) {
if (wm->windrawable) {
if (wm->runtime->windrawable) {
GHOST_ActivateWindowDrawingContext(
static_cast<GHOST_WindowHandle>(wm->windrawable->ghostwin));
GPU_context_active_set(static_cast<GPUContext *>(wm->windrawable->gpuctx));
static_cast<GHOST_WindowHandle>(wm->runtime->windrawable->ghostwin));
GPU_context_active_set(static_cast<GPUContext *>(wm->runtime->windrawable->gpuctx));
}
}
}

View File

@@ -438,8 +438,8 @@ void WM_main_remove_notifier_reference(const void *reference)
/* Remap instead. */
#if 0
if (wm->message_bus) {
WM_msg_id_remove(wm->message_bus, reference);
if (wm->runtime->message_bus) {
WM_msg_id_remove(wm->runtime->message_bus, reference);
}
#endif
}
@@ -461,7 +461,7 @@ void WM_main_remap_editor_id_reference(const blender::bke::id::IDRemapper &mappi
[](ID *old_id, ID *new_id) { blender::ed::asset::list::storage_id_remap(old_id, new_id); });
if (wmWindowManager *wm = static_cast<wmWindowManager *>(bmain->wm.first)) {
if (wmMsgBus *mbus = wm->message_bus) {
if (wmMsgBus *mbus = wm->runtime->message_bus) {
mappings.iter([&](ID *old_id, ID *new_id) {
if (new_id != nullptr) {
WM_msg_id_update(mbus, old_id, new_id);
@@ -793,7 +793,7 @@ void wm_event_do_notifiers(bContext *C)
{
LISTBASE_FOREACH (wmWindow *, win, &wm->windows) {
CTX_wm_window_set(C, win);
WM_msgbus_handle(wm->message_bus, C);
WM_msgbus_handle(wm->runtime->message_bus, C);
}
CTX_wm_window_set(C, nullptr);
}
@@ -803,8 +803,8 @@ void wm_event_do_notifiers(bContext *C)
RE_FreeUnusedGPUResources();
/* Status bar. */
if (wm->winactive) {
wmWindow *win = wm->winactive;
if (wm->runtime->winactive) {
wmWindow *win = wm->runtime->winactive;
CTX_wm_window_set(C, win);
WM_window_cursor_keymap_status_refresh(C, win);
CTX_wm_window_set(C, nullptr);
@@ -972,7 +972,7 @@ static void wm_event_handler_ui_cancel(bContext *C)
void WM_report_banner_show(wmWindowManager *wm, wmWindow *win)
{
if (win == nullptr) {
win = wm->winactive;
win = wm->runtime->winactive;
if (win == nullptr) {
win = static_cast<wmWindow *>(wm->windows.first);
}
@@ -1061,8 +1061,8 @@ void WM_global_reportf(eReportType type, const char *format, ...)
*/
static intptr_t wm_operator_undo_active_id(const wmWindowManager *wm)
{
if (wm->undo_stack) {
return intptr_t(wm->undo_stack->step_active);
if (wm->runtime->undo_stack) {
return intptr_t(wm->runtime->undo_stack->step_active);
}
return -1;
}
@@ -2900,7 +2900,7 @@ static eHandlerActionFlag wm_handler_fileselect_do(bContext *C,
if (wm_cursor_position_get(root_win, &xy[0], &xy[1])) {
copy_v2_v2_int(eventstate->xy, xy);
}
wm->winactive = root_win; /* Reports use this... */
wm->runtime->winactive = root_win; /* Reports use this... */
}
else if (file_area->full) {
ED_screen_full_prevspace(C, file_area);
@@ -4852,7 +4852,7 @@ static void wm_event_get_keymap_from_toolsystem_ex(wmWindowManager *wm,
BLI_assert(keymap_id && keymap_id[0]);
wmKeyMap *km = WM_keymap_list_find_spaceid_or_empty(
&wm->userconf->keymaps, keymap_id, area->spacetype, RGN_TYPE_WINDOW);
&wm->runtime->userconf->keymaps, keymap_id, area->spacetype, RGN_TYPE_WINDOW);
/* We shouldn't use key-maps from unrelated spaces. */
if (km == nullptr) {
printf("Key-map: '%s' not found for tool '%s'\n", keymap_id, area->runtime.tool->idname);
@@ -5945,9 +5945,11 @@ void wm_event_add_ghostevent(wmWindowManager *wm,
/* Always use modifiers from the active window since
* changes to modifiers aren't sent to inactive windows, see: #66088. */
if ((wm->winactive != win) && (wm->winactive && wm->winactive->eventstate)) {
event.modifier = wm->winactive->eventstate->modifier;
event.keymodifier = wm->winactive->eventstate->keymodifier;
if ((wm->runtime->winactive != win) &&
(wm->runtime->winactive && wm->runtime->winactive->eventstate))
{
event.modifier = wm->runtime->winactive->eventstate->modifier;
event.keymodifier = wm->runtime->winactive->eventstate->keymodifier;
}
/* Ensure the event state is correct, any deviation from this may cause bugs.

View File

@@ -243,9 +243,9 @@ static BlendFileReadWMSetupData *wm_file_read_setup_wm_init(bContext *C,
* However it's _not_ cleared when the UI is kept. This complicates use from add-ons
* which can re-register subscribers on file-load. To support this use case,
* it's best to have predictable behavior - always clear. */
if (wm->message_bus != nullptr) {
WM_msgbus_destroy(wm->message_bus);
wm->message_bus = nullptr;
if (wm->runtime->message_bus != nullptr) {
WM_msgbus_destroy(wm->runtime->message_bus);
wm->runtime->message_bus = nullptr;
}
/* XXX Hack! We have to clear context popup-region here, because removing all
@@ -279,11 +279,11 @@ static void wm_file_read_setup_wm_substitute_old_window(wmWindowManager *oldwm,
win->gpuctx = oldwin->gpuctx;
win->active = oldwin->active;
if (win->active) {
wm->winactive = win;
wm->runtime->winactive = win;
}
if (oldwm->windrawable == oldwin) {
oldwm->windrawable = nullptr;
wm->windrawable = win;
if (oldwm->runtime->windrawable == oldwin) {
oldwm->runtime->windrawable = nullptr;
wm->runtime->windrawable = win;
}
/* File loading in background mode still calls this. */
@@ -378,18 +378,18 @@ static void wm_file_read_setup_wm_use_new(bContext *C,
/* Move existing key configurations into the new WM. */
wm->runtime->keyconfigs = old_wm->runtime->keyconfigs;
wm->addonconf = old_wm->addonconf;
wm->defaultconf = old_wm->defaultconf;
wm->userconf = old_wm->userconf;
wm->runtime->addonconf = old_wm->runtime->addonconf;
wm->runtime->defaultconf = old_wm->runtime->defaultconf;
wm->runtime->userconf = old_wm->runtime->userconf;
BLI_listbase_clear(&old_wm->runtime->keyconfigs);
old_wm->addonconf = nullptr;
old_wm->defaultconf = nullptr;
old_wm->userconf = nullptr;
old_wm->runtime->addonconf = nullptr;
old_wm->runtime->defaultconf = nullptr;
old_wm->runtime->userconf = nullptr;
/* Ensure new keymaps are made, and space types are set. */
wm->init_flag = 0;
wm->winactive = nullptr;
wm->runtime->winactive = nullptr;
/* Clearing drawable of old WM before deleting any context to avoid clearing the wrong wm. */
wm_window_clear_drawable(old_wm);
@@ -857,14 +857,14 @@ static void wm_file_read_post(bContext *C,
if (use_data) {
if (!G.background) {
if (wm->undo_stack == nullptr) {
wm->undo_stack = BKE_undosys_stack_create();
if (wm->runtime->undo_stack == nullptr) {
wm->runtime->undo_stack = BKE_undosys_stack_create();
}
else {
BKE_undosys_stack_clear(wm->undo_stack);
BKE_undosys_stack_clear(wm->runtime->undo_stack);
}
BKE_undosys_stack_init_from_main(wm->undo_stack, bmain);
BKE_undosys_stack_init_from_context(wm->undo_stack, C);
BKE_undosys_stack_init_from_main(wm->runtime->undo_stack, bmain);
BKE_undosys_stack_init_from_context(wm->runtime->undo_stack, C);
}
}
@@ -1540,8 +1540,8 @@ void wm_homefile_read_ex(bContext *C,
/* Clear keymaps because the current default keymap may have been initialized
* from user preferences, which have been reset. */
LISTBASE_FOREACH (wmWindowManager *, wm, &bmain->wm) {
if (wm->defaultconf) {
wm->defaultconf->flag &= ~KEYCONF_INIT_DEFAULT;
if (wm->runtime->defaultconf) {
wm->runtime->defaultconf->flag &= ~KEYCONF_INIT_DEFAULT;
}
}
}
@@ -1956,7 +1956,7 @@ static ImBuf *blend_file_thumb_from_camera(const bContext *C,
BlendThumbnail *thumb;
wmWindowManager *wm = CTX_wm_manager(C);
const float pixelsize_old = U.pixelsize;
wmWindow *windrawable_old = wm->windrawable;
wmWindow *windrawable_old = wm->runtime->windrawable;
char err_out[256] = "unknown";
/* Screen if no camera found. */
@@ -2318,7 +2318,7 @@ static bool wm_autosave_write_try(Main *bmain, wmWindowManager *wm)
* compared to when the #MemFile undo step was used for saving undo-steps. So for now just skip
* auto-save when we are in a mode where auto-save wouldn't have worked previously anyway. This
* check can be removed once the performance regressions have been solved. */
if (ED_undosys_stack_memfile_get_if_active(wm->undo_stack) != nullptr) {
if (ED_undosys_stack_memfile_get_if_active(wm->runtime->undo_stack) != nullptr) {
WM_autosave_write(wm, bmain);
return true;
}
@@ -4272,7 +4272,8 @@ void wm_test_autorun_warning(bContext *C)
G.f |= G_FLAG_SCRIPT_AUTOEXEC_FAIL_QUIET;
wmWindowManager *wm = CTX_wm_manager(C);
wmWindow *win = (wm->winactive) ? wm->winactive : static_cast<wmWindow *>(wm->windows.first);
wmWindow *win = (wm->runtime->winactive) ? wm->runtime->winactive :
static_cast<wmWindow *>(wm->windows.first);
if (win) {
/* We want this warning on the Main window, not a child window even if active. See #118765. */
@@ -4296,7 +4297,8 @@ void wm_test_foreign_file_warning(bContext *C)
G_MAIN->is_read_invalid = false;
wmWindowManager *wm = CTX_wm_manager(C);
wmWindow *win = (wm->winactive) ? wm->winactive : static_cast<wmWindow *>(wm->windows.first);
wmWindow *win = (wm->runtime->winactive) ? wm->runtime->winactive :
static_cast<wmWindow *>(wm->windows.first);
if (win) {
/* We want this warning on the Main window, not a child window even if active. See #118765. */

View File

@@ -308,7 +308,7 @@ wmKeyConfig *WM_keyconfig_ensure(wmWindowManager *wm, const char *idname, bool u
wmKeyConfig *keyconf = static_cast<wmKeyConfig *>(
BLI_findstring(&wm->runtime->keyconfigs, idname, offsetof(wmKeyConfig, idname)));
if (keyconf) {
if (keyconf == wm->defaultconf) {
if (keyconf == wm->runtime->defaultconf) {
/* For default configuration, we need to keep keymap
* modal items and poll functions intact. */
LISTBASE_FOREACH (wmKeyMap *, km, &keyconf->keymaps) {
@@ -330,7 +330,7 @@ void WM_keyconfig_remove(wmWindowManager *wm, wmKeyConfig *keyconf)
{
BLI_assert(BLI_findindex(&wm->runtime->keyconfigs, keyconf) != -1);
if (STREQLEN(U.keyconfigstr, keyconf->idname, sizeof(U.keyconfigstr))) {
STRNCPY(U.keyconfigstr, wm->defaultconf->idname);
STRNCPY(U.keyconfigstr, wm->runtime->defaultconf->idname);
U.runtime.is_dirty = true;
WM_keyconfig_update_tag(nullptr, nullptr);
}
@@ -376,7 +376,7 @@ static wmKeyConfig *WM_keyconfig_active(wmWindowManager *wm)
}
/* Otherwise use default. */
return wm->defaultconf;
return wm->runtime->defaultconf;
}
void WM_keyconfig_set_active(wmWindowManager *wm, const char *idname)
@@ -906,7 +906,7 @@ wmKeyMap *WM_keymap_ensure(wmKeyConfig *keyconf, const char *idname, int spaceid
wmKeyMap *WM_keymap_find_all(wmWindowManager *wm, const char *idname, int spaceid, int regionid)
{
return WM_keymap_list_find(&wm->userconf->keymaps, idname, spaceid, regionid);
return WM_keymap_list_find(&wm->runtime->userconf->keymaps, idname, spaceid, regionid);
}
wmKeyMap *WM_keymap_find_all_spaceid_or_empty(wmWindowManager *wm,
@@ -914,7 +914,8 @@ wmKeyMap *WM_keymap_find_all_spaceid_or_empty(wmWindowManager *wm,
int spaceid,
int regionid)
{
return WM_keymap_list_find_spaceid_or_empty(&wm->userconf->keymaps, idname, spaceid, regionid);
return WM_keymap_list_find_spaceid_or_empty(
&wm->runtime->userconf->keymaps, idname, spaceid, regionid);
}
/** \} */
@@ -935,9 +936,9 @@ wmKeyMap *WM_modalkeymap_ensure(wmKeyConfig *keyconf,
/* Initialize modal items from default configuration. */
wmWindowManager *wm = static_cast<wmWindowManager *>(G_MAIN->wm.first);
if (wm->defaultconf && wm->defaultconf != keyconf) {
if (wm->runtime->defaultconf && wm->runtime->defaultconf != keyconf) {
wmKeyMap *defaultkm = WM_keymap_list_find(
&wm->defaultconf->keymaps, km->idname, SPACE_EMPTY, RGN_TYPE_WINDOW);
&wm->runtime->defaultconf->keymaps, km->idname, SPACE_EMPTY, RGN_TYPE_WINDOW);
if (defaultkm) {
km->modal_items = defaultkm->modal_items;
@@ -1042,12 +1043,12 @@ static void wm_user_modal_keymap_set_items(wmWindowManager *wm, wmKeyMap *km)
* being created before the actual modal keymaps, so no modal_items. */
if (km && (km->flag & KEYMAP_MODAL) && !km->modal_items) {
if (wm->defaultconf == nullptr) {
if (wm->runtime->defaultconf == nullptr) {
return;
}
wmKeyMap *defaultkm = WM_keymap_list_find(
&wm->defaultconf->keymaps, km->idname, SPACE_EMPTY, RGN_TYPE_WINDOW);
&wm->runtime->defaultconf->keymaps, km->idname, SPACE_EMPTY, RGN_TYPE_WINDOW);
if (!defaultkm) {
return;
}
@@ -1854,8 +1855,9 @@ static wmKeyMap *wm_keymap_preset(wmWindowManager *wm, wmKeyConfig *keyconf, wmK
{
BLI_assert(keyconf == WM_keyconfig_active(wm));
wmKeyMap *keymap = WM_keymap_list_find(&keyconf->keymaps, km->idname, km->spaceid, km->regionid);
if (!keymap && wm->defaultconf) {
keymap = WM_keymap_list_find(&wm->defaultconf->keymaps, km->idname, km->spaceid, km->regionid);
if (!keymap && wm->runtime->defaultconf) {
keymap = WM_keymap_list_find(
&wm->runtime->defaultconf->keymaps, km->idname, km->spaceid, km->regionid);
}
return keymap;
@@ -1932,13 +1934,13 @@ void WM_keyconfig_update_ex(wmWindowManager *wm, bool keep_properties)
}
/* Update `U.user_keymaps` with user key configuration changes. */
LISTBASE_FOREACH (wmKeyMap *, km, &wm->userconf->keymaps) {
LISTBASE_FOREACH (wmKeyMap *, km, &wm->runtime->userconf->keymaps) {
/* Only diff if the user keymap was modified. */
if (wm_keymap_test_and_clear_update(km)) {
/* Find keymaps. */
wmKeyMap *defaultmap = wm_keymap_preset(wm, kc_active, km);
wmKeyMap *addonmap = WM_keymap_list_find(
&wm->addonconf->keymaps, km->idname, km->spaceid, km->regionid);
&wm->runtime->addonconf->keymaps, km->idname, km->spaceid, km->regionid);
/* Diff. */
if (defaultmap) {
@@ -1948,11 +1950,11 @@ void WM_keyconfig_update_ex(wmWindowManager *wm, bool keep_properties)
}
/* Create user key configuration from preset + addon + user preferences. */
LISTBASE_FOREACH (wmKeyMap *, km, &wm->defaultconf->keymaps) {
LISTBASE_FOREACH (wmKeyMap *, km, &wm->runtime->defaultconf->keymaps) {
/* Find keymaps. */
wmKeyMap *defaultmap = wm_keymap_preset(wm, kc_active, km);
wmKeyMap *addonmap = WM_keymap_list_find(
&wm->addonconf->keymaps, km->idname, km->spaceid, km->regionid);
&wm->runtime->addonconf->keymaps, km->idname, km->spaceid, km->regionid);
wmKeyMap *usermap = WM_keymap_list_find(
&U.user_keymaps, km->idname, km->spaceid, km->regionid);
@@ -1962,7 +1964,7 @@ void WM_keyconfig_update_ex(wmWindowManager *wm, bool keep_properties)
/* Add. */
wmKeyMap *kmn = wm_keymap_patch_update(
&wm->userconf->keymaps, defaultmap, addonmap, usermap);
&wm->runtime->userconf->keymaps, defaultmap, addonmap, usermap);
if (kmn) {
kmn->modal_items = km->modal_items;
@@ -2032,7 +2034,7 @@ wmKeyMap *WM_keymap_active(const wmWindowManager *wm, wmKeyMap *keymap)
/* First user defined keymaps. */
wmKeyMap *km = WM_keymap_list_find(
&wm->userconf->keymaps, keymap->idname, keymap->spaceid, keymap->regionid);
&wm->runtime->userconf->keymaps, keymap->idname, keymap->spaceid, keymap->regionid);
if (km) {
return km;
@@ -2059,7 +2061,7 @@ void WM_keymap_item_restore_to_default(wmWindowManager *wm, wmKeyMap *keymap, wm
wmKeyConfig *kc_active = WM_keyconfig_active(wm);
wmKeyMap *defaultmap = wm_keymap_preset(wm, kc_active, keymap);
wmKeyMap *addonmap = WM_keymap_list_find(
&wm->addonconf->keymaps, keymap->idname, keymap->spaceid, keymap->regionid);
&wm->runtime->addonconf->keymaps, keymap->idname, keymap->spaceid, keymap->regionid);
if (addonmap) {
defaultmap = wm_keymap_copy(defaultmap);
@@ -2158,7 +2160,7 @@ wmKeyMapItem *WM_keymap_item_find_match(wmKeyMap *km_base,
if (wm_keymap_update_flag != 0) {
/* NOTE: this could be limited to the key-maps marked for updating.
* However #KEYMAP_UPDATE is only cleared for `wm->userconf`
* However #KEYMAP_UPDATE is only cleared for `wm->runtime->userconf`
* so only check the global flag for now.
*
* Use a warning not an error because scripts cannot prevent other scripts from manipulating
@@ -2201,13 +2203,16 @@ wmKeyMapItem *WM_keymap_item_find_match(wmKeyMap *km_base,
match_type = KM_TYPE_UNKNOWN;
if (km_base->flag & KEYMAP_USER) {
if (km_base == WM_keymap_list_find(&wm->userconf->keymaps, idname, spaceid, regionid)) {
if (km_base == WM_keymap_list_find(&wm->runtime->userconf->keymaps, idname, spaceid, regionid))
{
base_type = KM_TYPE_USER;
}
}
if ((km_match->flag & KEYMAP_USER) == 0) {
if (km_match == WM_keymap_list_find(&wm->addonconf->keymaps, idname, spaceid, regionid)) {
if (km_match ==
WM_keymap_list_find(&wm->runtime->addonconf->keymaps, idname, spaceid, regionid))
{
match_type = KM_TYPE_ADDON;
}
else if (km_match == WM_keymap_list_find(&kc_active->keymaps, idname, spaceid, regionid)) {

View File

@@ -224,8 +224,8 @@ static void wm_ghostwindow_destroy(wmWindowManager *wm, wmWindow *win)
* drawing context to discard the GW context. */
wm_window_clear_drawable(wm);
if (win == wm->winactive) {
wm->winactive = nullptr;
if (win == wm->runtime->winactive) {
wm->runtime->winactive = nullptr;
}
/* We need this window's GPU context active to discard it. */
@@ -897,7 +897,7 @@ static void wm_window_ghostwindow_add(wmWindowManager *wm,
}
/* Clear drawable so we can set the new window. */
wmWindow *prev_windrawable = wm->windrawable;
wmWindow *prev_windrawable = wm->runtime->windrawable;
wm_window_clear_drawable(wm);
GHOST_WindowHandle ghostwin = GHOST_CreateWindow(
@@ -1015,13 +1015,15 @@ static void wm_window_ghostwindow_ensure(wmWindowManager *wm, wmWindow *win, boo
}
/* Add key-map handlers (1 handler for all keys in map!). */
wmKeyMap *keymap = WM_keymap_ensure(wm->defaultconf, "Window", SPACE_EMPTY, RGN_TYPE_WINDOW);
wmKeyMap *keymap = WM_keymap_ensure(
wm->runtime->defaultconf, "Window", SPACE_EMPTY, RGN_TYPE_WINDOW);
WM_event_add_keymap_handler(&win->handlers, keymap);
keymap = WM_keymap_ensure(wm->defaultconf, "Screen", SPACE_EMPTY, RGN_TYPE_WINDOW);
keymap = WM_keymap_ensure(wm->runtime->defaultconf, "Screen", SPACE_EMPTY, RGN_TYPE_WINDOW);
WM_event_add_keymap_handler(&win->handlers, keymap);
keymap = WM_keymap_ensure(wm->defaultconf, "Screen Editing", SPACE_EMPTY, RGN_TYPE_WINDOW);
keymap = WM_keymap_ensure(
wm->runtime->defaultconf, "Screen Editing", SPACE_EMPTY, RGN_TYPE_WINDOW);
WM_event_add_keymap_handler(&win->modalhandlers, keymap);
/* Add drop boxes. */
@@ -1414,9 +1416,9 @@ static uint8_t wm_ghost_modifier_query(const enum ModSide side)
static void wm_window_set_drawable(wmWindowManager *wm, wmWindow *win, bool activate)
{
BLI_assert(ELEM(wm->windrawable, nullptr, win));
BLI_assert(ELEM(wm->runtime->windrawable, nullptr, win));
wm->windrawable = win;
wm->runtime->windrawable = win;
if (activate) {
GHOST_ActivateWindowDrawingContext(static_cast<GHOST_WindowHandle>(win->ghostwin));
}
@@ -1425,8 +1427,8 @@ static void wm_window_set_drawable(wmWindowManager *wm, wmWindow *win, bool acti
void wm_window_clear_drawable(wmWindowManager *wm)
{
if (wm->windrawable) {
wm->windrawable = nullptr;
if (wm->runtime->windrawable) {
wm->runtime->windrawable = nullptr;
}
}
@@ -1434,7 +1436,7 @@ void wm_window_make_drawable(wmWindowManager *wm, wmWindow *win)
{
BLI_assert(GPU_framebuffer_active_get() == GPU_framebuffer_back_get());
if (win != wm->windrawable && win->ghostwin) {
if (win != wm->runtime->windrawable && win->ghostwin) {
// win->lmbut = 0; /* Keeps hanging when mouse-pressed while other window opened. */
wm_window_clear_drawable(wm);
@@ -1460,7 +1462,7 @@ void wm_window_reset_drawable()
if (wm == nullptr) {
return;
}
wmWindow *win = wm->windrawable;
wmWindow *win = wm->runtime->windrawable;
if (win && win->ghostwin) {
wm_window_clear_drawable(wm);
@@ -1570,7 +1572,7 @@ static bool ghost_event_proc(GHOST_EventHandle ghost_event, GHOST_TUserDataPtr C
win = static_cast<wmWindow *>(GHOST_GetWindowUserData(ghostwin));
}
else {
win = wm->winactive;
win = wm->runtime->winactive;
}
/* Display quit dialog or quit immediately. */
@@ -1620,8 +1622,8 @@ static bool ghost_event_proc(GHOST_EventHandle ghost_event, GHOST_TUserDataPtr C
/* Entering window, update mouse position (without sending an event). */
wm_window_update_eventstate(win);
/* No context change! `C->wm->windrawable` is drawable, or for area queues. */
wm->winactive = win;
/* No context change! `C->wm->runtime->windrawable` is drawable, or for area queues. */
wm->runtime->winactive = win;
win->active = 1;
/* Zero the `keymodifier`, it hangs on hotkeys that open windows otherwise. */
@@ -1806,8 +1808,8 @@ static bool ghost_event_proc(GHOST_EventHandle ghost_event, GHOST_TUserDataPtr C
event.flag = eWM_EventFlag(0);
/* No context change! `C->wm->windrawable` is drawable, or for area queues. */
wm->winactive = win;
/* No context change! `C->wm->runtime->windrawable` is drawable, or for area queues. */
wm->runtime->winactive = win;
win->active = 1;
WM_event_add(win, &event);
@@ -2150,7 +2152,8 @@ void wm_test_gpu_backend_fallback(bContext *C)
G.f |= G_FLAG_GPU_BACKEND_FALLBACK_QUIET;
wmWindowManager *wm = CTX_wm_manager(C);
wmWindow *win = static_cast<wmWindow *>((wm->winactive) ? wm->winactive : wm->windows.first);
wmWindow *win = static_cast<wmWindow *>((wm->runtime->winactive) ? wm->runtime->winactive :
wm->windows.first);
if (win) {
/* We want this warning on the Main window, not a child window even if active. See #118765. */