diff options
Diffstat (limited to 'source/blender/windowmanager')
18 files changed, 193 insertions, 190 deletions
diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index 1c86e4da291..2cb91f6cadf 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -51,6 +51,7 @@ struct MenuType; struct PointerRNA; struct PropertyRNA; struct ScrArea; +struct View3D; struct ViewLayer; struct bContext; struct rcti; @@ -176,7 +177,10 @@ void WM_autosave_init(struct wmWindowManager *wm); void WM_recover_last_session(struct bContext *C, struct ReportList *reports); void WM_file_tag_modified(void); -struct ID *WM_file_append_datablock(struct bContext *C, +struct ID *WM_file_append_datablock(struct Main *bmain, + struct Scene *scene, + struct ViewLayer *view_layer, + struct View3D *v3d, const char *filepath, const short id_code, const char *id_name); @@ -293,13 +297,17 @@ struct wmEventHandler_Dropbox *WM_event_add_dropbox_handler(ListBase *handlers, ListBase *dropboxes); /* mouse */ -void WM_event_add_mousemove(const struct bContext *C); +void WM_event_add_mousemove(wmWindow *win); #ifdef WITH_INPUT_NDOF /* 3D mouse */ void WM_ndof_deadzone_set(float deadzone); #endif /* notifiers */ +void WM_event_add_notifier_ex(struct wmWindowManager *wm, + const struct wmWindow *win, + unsigned int type, + void *reference); void WM_event_add_notifier(const struct bContext *C, unsigned int type, void *reference); void WM_main_add_notifier(unsigned int type, void *reference); void WM_main_remove_notifier_reference(const void *reference); @@ -619,9 +627,12 @@ int WM_gesture_straightline_modal(struct bContext *C, void WM_gesture_straightline_cancel(struct bContext *C, struct wmOperator *op); /* Gesture manager API */ -struct wmGesture *WM_gesture_new(struct bContext *C, const struct wmEvent *event, int type); -void WM_gesture_end(struct bContext *C, struct wmGesture *gesture); -void WM_gestures_remove(struct bContext *C); +struct wmGesture *WM_gesture_new(struct wmWindow *window, + const struct ARegion *ar, + const struct wmEvent *event, + int type); +void WM_gesture_end(struct wmWindow *win, struct wmGesture *gesture); +void WM_gestures_remove(struct wmWindow *win); void WM_gestures_free_all(struct wmWindow *win); bool WM_gesture_is_modal_first(const struct wmGesture *gesture); diff --git a/source/blender/windowmanager/WM_keymap.h b/source/blender/windowmanager/WM_keymap.h index 16c072afccf..1d8e6bb8772 100644 --- a/source/blender/windowmanager/WM_keymap.h +++ b/source/blender/windowmanager/WM_keymap.h @@ -74,11 +74,11 @@ wmKeyMap *WM_keymap_ensure(struct wmKeyConfig *keyconf, const char *idname, int spaceid, int regionid); -wmKeyMap *WM_keymap_find_all(const struct bContext *C, +wmKeyMap *WM_keymap_find_all(struct wmWindowManager *wm, const char *idname, int spaceid, int regionid); -wmKeyMap *WM_keymap_find_all_spaceid_or_empty(const struct bContext *C, +wmKeyMap *WM_keymap_find_all_spaceid_or_empty(struct wmWindowManager *wm, const char *idname, int spaceid, int regionid); @@ -148,9 +148,9 @@ void WM_modalkeymap_assign(struct wmKeyMap *km, const char *opname); /* Keymap Editor */ -void WM_keymap_restore_to_default(struct wmKeyMap *keymap, struct bContext *C); +void WM_keymap_restore_to_default(struct wmKeyMap *keymap, struct wmWindowManager *wm); void WM_keymap_item_properties_reset(struct wmKeyMapItem *kmi, struct IDProperty *properties); -void WM_keymap_item_restore_to_default(struct bContext *C, +void WM_keymap_item_restore_to_default(wmWindowManager *wm, struct wmKeyMap *keymap, struct wmKeyMapItem *kmi); int WM_keymap_item_map_type_get(const struct wmKeyMapItem *kmi); diff --git a/source/blender/windowmanager/WM_types.h b/source/blender/windowmanager/WM_types.h index 2038871844f..8c278319fd5 100644 --- a/source/blender/windowmanager/WM_types.h +++ b/source/blender/windowmanager/WM_types.h @@ -256,8 +256,7 @@ typedef enum eOperatorPropTags { typedef struct wmNotifier { struct wmNotifier *next, *prev; - struct wmWindowManager *wm; - struct wmWindow *window; + const struct wmWindow *window; unsigned int category, data, subtype, action; diff --git a/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c b/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c index 98669afdd08..1bf60c212c8 100644 --- a/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c +++ b/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c @@ -950,7 +950,7 @@ bool WM_gizmomap_select_all(bContext *C, wmGizmoMap *gzmap, const int action) } if (changed) { - WM_event_add_mousemove(C); + WM_event_add_mousemove(CTX_wm_window(C)); } return changed; @@ -1136,7 +1136,7 @@ void wm_gizmomap_modal_set( } } ED_region_tag_redraw_editor_overlays(CTX_wm_region(C)); - WM_event_add_mousemove(C); + WM_event_add_mousemove(win); } gzmap->gzmap_context.event_xy[0] = INT_MAX; diff --git a/source/blender/windowmanager/intern/wm.c b/source/blender/windowmanager/intern/wm.c index 3d8532fd40c..c0a653e5e2f 100644 --- a/source/blender/windowmanager/intern/wm.c +++ b/source/blender/windowmanager/intern/wm.c @@ -332,7 +332,7 @@ void wm_add_default(Main *bmain, bContext *C) WorkSpaceLayout *layout = BKE_workspace_layout_find_global(bmain, screen, &workspace); CTX_wm_manager_set(C, wm); - win = wm_window_new(C, NULL); + win = wm_window_new(bmain, wm, NULL); win->scene = CTX_data_scene(C); STRNCPY(win->view_layer_name, CTX_data_view_layer(C)->name); BKE_workspace_active_set(win->workspace_hook, workspace); diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index c1bfa904fad..6247cc5d5ea 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -190,11 +190,9 @@ void wm_event_init_from_window(wmWindow *win, wmEvent *event) /** \name Notifiers & Listeners * \{ */ -static bool wm_test_duplicate_notifier(wmWindowManager *wm, unsigned int type, void *reference) +static bool wm_test_duplicate_notifier(const wmWindowManager *wm, uint type, void *reference) { - wmNotifier *note; - - for (note = wm->queue.first; note; note = note->next) { + for (wmNotifier *note = wm->queue.first; note; note = note->next) { if ((note->category | note->data | note->subtype | note->action) == type && note->reference == reference) { return 1; @@ -204,10 +202,8 @@ static bool wm_test_duplicate_notifier(wmWindowManager *wm, unsigned int type, v return 0; } -/* XXX: in future, which notifiers to send to other windows? */ -void WM_event_add_notifier(const bContext *C, unsigned int type, void *reference) +void WM_event_add_notifier_ex(wmWindowManager *wm, const wmWindow *win, uint type, void *reference) { - wmWindowManager *wm = CTX_wm_manager(C); wmNotifier *note; if (wm_test_duplicate_notifier(wm, type, reference)) { @@ -216,10 +212,9 @@ void WM_event_add_notifier(const bContext *C, unsigned int type, void *reference note = MEM_callocN(sizeof(wmNotifier), "notifier"); - note->wm = wm; - BLI_addtail(¬e->wm->queue, note); + BLI_addtail(&wm->queue, note); - note->window = CTX_wm_window(C); + note->window = win; note->category = type & NOTE_CATEGORY; note->data = type & NOTE_DATA; @@ -229,6 +224,12 @@ void WM_event_add_notifier(const bContext *C, unsigned int type, void *reference note->reference = reference; } +/* XXX: in future, which notifiers to send to other windows? */ +void WM_event_add_notifier(const bContext *C, uint type, void *reference) +{ + WM_event_add_notifier_ex(CTX_wm_manager(C), CTX_wm_window(C), type, reference); +} + void WM_main_add_notifier(unsigned int type, void *reference) { Main *bmain = G_MAIN; @@ -241,8 +242,7 @@ void WM_main_add_notifier(unsigned int type, void *reference) note = MEM_callocN(sizeof(wmNotifier), "notifier"); - note->wm = wm; - BLI_addtail(¬e->wm->queue, note); + BLI_addtail(&wm->queue, note); note->category = type & NOTE_CATEGORY; note->data = type & NOTE_DATA; @@ -3856,11 +3856,9 @@ static void WM_event_remove_handler(ListBase *handlers, wmEventHandler *handler) } #endif -void WM_event_add_mousemove(const bContext *C) +void WM_event_add_mousemove(wmWindow *win) { - wmWindow *window = CTX_wm_window(C); - - window->addmousemove = 1; + win->addmousemove = 1; } /** \} */ diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c index a12d325f6d5..160fbe95b25 100644 --- a/source/blender/windowmanager/intern/wm_files.c +++ b/source/blender/windowmanager/intern/wm_files.c @@ -1499,7 +1499,7 @@ void WM_autosave_init(wmWindowManager *wm) } } -void wm_autosave_timer(const bContext *C, wmWindowManager *wm, wmTimer *UNUSED(wt)) +void wm_autosave_timer(Main *bmain, wmWindowManager *wm, wmTimer *UNUSED(wt)) { char filepath[FILE_MAX]; @@ -1532,7 +1532,6 @@ void wm_autosave_timer(const bContext *C, wmWindowManager *wm, wmTimer *UNUSED(w } else { /* save as regular blend file */ - Main *bmain = CTX_data_main(C); int fileflags = G.fileflags & ~(G_FILE_COMPRESS | G_FILE_HISTORY); ED_editors_flush_edits(bmain); @@ -2009,7 +2008,8 @@ static void wm_free_operator_properties_callback(void *user_data) static int wm_homefile_read_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) { - if (U.uiflag & USER_SAVE_PROMPT && wm_file_or_image_is_modified(C)) { + if (U.uiflag & USER_SAVE_PROMPT && + wm_file_or_image_is_modified(CTX_data_main(C), CTX_wm_manager(C))) { wmGenericCallback *callback = MEM_callocN(sizeof(*callback), __func__); callback->exec = wm_homefile_read_after_dialog_callback; callback->user_data = IDP_CopyProperty(op->properties); @@ -2172,7 +2172,8 @@ static int wm_open_mainfile__discard_changes(bContext *C, wmOperator *op) set_next_operator_state(op, OPEN_MAINFILE_STATE_OPEN); } - if (U.uiflag & USER_SAVE_PROMPT && wm_file_or_image_is_modified(C)) { + if (U.uiflag & USER_SAVE_PROMPT && + wm_file_or_image_is_modified(CTX_data_main(C), CTX_wm_manager(C))) { wmGenericCallback *callback = MEM_callocN(sizeof(*callback), __func__); callback->exec = wm_open_mainfile_after_dialog_callback; callback->user_data = IDP_CopyProperty(op->properties); @@ -2986,15 +2987,16 @@ static void wm_block_file_close_discard(bContext *C, void *arg_block, void *arg_ static void wm_block_file_close_save(bContext *C, void *arg_block, void *arg_data) { + const Main *bmain = CTX_data_main(C); wmGenericCallback *callback = WM_generic_callback_steal((wmGenericCallback *)arg_data); bool execute_callback = true; wmWindow *win = CTX_wm_window(C); UI_popup_block_close(C, win, arg_block); - int modified_images_count = ED_image_save_all_modified_info(C, NULL); + int modified_images_count = ED_image_save_all_modified_info(CTX_data_main(C), NULL); if (modified_images_count > 0 && save_images_when_file_is_closed) { - if (ED_image_should_save_modified(C)) { + if (ED_image_should_save_modified(bmain)) { ReportList *reports = CTX_wm_reports(C); ED_image_save_all_modified(C, reports); WM_report_banner_show(); @@ -3004,7 +3006,6 @@ static void wm_block_file_close_save(bContext *C, void *arg_block, void *arg_dat } } - Main *bmain = CTX_data_main(C); bool file_has_been_saved_before = BKE_main_blendfile_path(bmain)[0] != '\0'; if (file_has_been_saved_before) { @@ -3098,7 +3099,7 @@ static uiBlock *block_create__close_file_dialog(struct bContext *C, struct ARegi /* Image Saving */ ReportList reports; BKE_reports_init(&reports, RPT_STORE); - uint modified_images_count = ED_image_save_all_modified_info(C, &reports); + uint modified_images_count = ED_image_save_all_modified_info(bmain, &reports); LISTBASE_FOREACH (Report *, report, &reports.list) { uiItemL_ex(layout, report->message, ICON_CANCEL, false, true); @@ -3189,7 +3190,7 @@ static void free_post_file_close_action(void *arg) void wm_close_file_dialog(bContext *C, wmGenericCallback *post_action) { - if (!UI_popup_block_name_exists(C, close_file_dialog_name)) { + if (!UI_popup_block_name_exists(CTX_wm_screen(C), close_file_dialog_name)) { UI_popup_block_invoke( C, block_create__close_file_dialog, post_action, free_post_file_close_action); } @@ -3198,10 +3199,9 @@ void wm_close_file_dialog(bContext *C, wmGenericCallback *post_action) } } -bool wm_file_or_image_is_modified(const bContext *C) +bool wm_file_or_image_is_modified(const Main *bmain, const wmWindowManager *wm) { - wmWindowManager *wm = CTX_wm_manager(C); - return !wm->file_saved || ED_image_should_save_modified(C); + return !wm->file_saved || ED_image_should_save_modified(bmain); } /** \} */ diff --git a/source/blender/windowmanager/intern/wm_files_link.c b/source/blender/windowmanager/intern/wm_files_link.c index c6d4c13c411..73c7a6209ee 100644 --- a/source/blender/windowmanager/intern/wm_files_link.c +++ b/source/blender/windowmanager/intern/wm_files_link.c @@ -623,13 +623,14 @@ void WM_OT_append(wmOperatorType *ot) * * \{ */ -ID *WM_file_append_datablock(bContext *C, +ID *WM_file_append_datablock(Main *bmain, + Scene *scene, + ViewLayer *view_layer, + View3D *v3d, const char *filepath, const short id_code, const char *id_name) { - Main *bmain = CTX_data_main(C); - /* Tag everything so we can make local only the new datablock. */ BKE_main_id_tag_all(bmain, LIB_TAG_PRE_EXISTING, true); @@ -641,9 +642,6 @@ ID *WM_file_append_datablock(bContext *C, BLI_BITMAP_ENABLE(item->libraries, 0); /* Link datablock. */ - Scene *scene = CTX_data_scene(C); - ViewLayer *view_layer = CTX_data_view_layer(C); - View3D *v3d = CTX_wm_view3d(C); wm_link_do(lapp_data, NULL, bmain, scene, view_layer, v3d); /* Get linked datablock and free working data. */ diff --git a/source/blender/windowmanager/intern/wm_gesture.c b/source/blender/windowmanager/intern/wm_gesture.c index 5943e947b41..bd9a6464332 100644 --- a/source/blender/windowmanager/intern/wm_gesture.c +++ b/source/blender/windowmanager/intern/wm_gesture.c @@ -51,11 +51,9 @@ #include "BIF_glutil.h" /* context checked on having screen, window and area */ -wmGesture *WM_gesture_new(bContext *C, const wmEvent *event, int type) +wmGesture *WM_gesture_new(wmWindow *window, const ARegion *ar, const wmEvent *event, int type) { wmGesture *gesture = MEM_callocN(sizeof(wmGesture), "new gesture"); - wmWindow *window = CTX_wm_window(C); - ARegion *ar = CTX_wm_region(C); BLI_addtail(&window->gesture, gesture); @@ -97,7 +95,7 @@ wmGesture *WM_gesture_new(bContext *C, const wmEvent *event, int type) return gesture; } -static void wm_gesture_end_with_window(wmWindow *win, wmGesture *gesture) +void WM_gesture_end(wmWindow *win, wmGesture *gesture) { if (win->tweak == gesture) { win->tweak = NULL; @@ -108,24 +106,17 @@ static void wm_gesture_end_with_window(wmWindow *win, wmGesture *gesture) MEM_freeN(gesture); } -void WM_gesture_end(bContext *C, wmGesture *gesture) -{ - wm_gesture_end_with_window(CTX_wm_window(C), gesture); -} - void WM_gestures_free_all(wmWindow *win) { while (win->gesture.first) { - wm_gesture_end_with_window(win, win->gesture.first); + WM_gesture_end(win, win->gesture.first); } } -void WM_gestures_remove(bContext *C) +void WM_gestures_remove(wmWindow *win) { - wmWindow *win = CTX_wm_window(C); - while (win->gesture.first) { - WM_gesture_end(C, win->gesture.first); + WM_gesture_end(win, win->gesture.first); } } @@ -531,9 +522,9 @@ void wm_gesture_draw(wmWindow *win) } } -void wm_gesture_tag_redraw(bContext *C) +void wm_gesture_tag_redraw(wmWindow *win) { - bScreen *screen = CTX_wm_screen(C); + bScreen *screen = WM_window_get_active_screen(win); if (screen) { screen->do_draw_gesture = true; diff --git a/source/blender/windowmanager/intern/wm_gesture_ops.c b/source/blender/windowmanager/intern/wm_gesture_ops.c index a5f32b4ff1f..c78f0d7376d 100644 --- a/source/blender/windowmanager/intern/wm_gesture_ops.c +++ b/source/blender/windowmanager/intern/wm_gesture_ops.c @@ -61,15 +61,16 @@ static void gesture_modal_end(bContext *C, wmOperator *op) { + wmWindow *win = CTX_wm_window(C); wmGesture *gesture = op->customdata; - WM_gesture_end(C, gesture); /* frees gesture itself, and unregisters from window */ + WM_gesture_end(win, gesture); /* frees gesture itself, and unregisters from window */ op->customdata = NULL; ED_area_tag_redraw(CTX_wm_area(C)); if (RNA_struct_find_property(op->ptr, "cursor")) { - WM_cursor_modal_restore(CTX_wm_window(C)); + WM_cursor_modal_restore(win); } } @@ -173,12 +174,15 @@ static bool gesture_box_apply(bContext *C, wmOperator *op) int WM_gesture_box_invoke(bContext *C, wmOperator *op, const wmEvent *event) { + wmWindow *win = CTX_wm_window(C); + const ARegion *ar = CTX_wm_region(C); const bool wait_for_input = !ISTWEAK(event->type) && RNA_boolean_get(op->ptr, "wait_for_input"); + if (wait_for_input) { - op->customdata = WM_gesture_new(C, event, WM_GESTURE_CROSS_RECT); + op->customdata = WM_gesture_new(win, ar, event, WM_GESTURE_CROSS_RECT); } else { - op->customdata = WM_gesture_new(C, event, WM_GESTURE_RECT); + op->customdata = WM_gesture_new(win, ar, event, WM_GESTURE_RECT); } { @@ -189,13 +193,14 @@ int WM_gesture_box_invoke(bContext *C, wmOperator *op, const wmEvent *event) /* add modal handler */ WM_event_add_modal_handler(C, op); - wm_gesture_tag_redraw(C); + wm_gesture_tag_redraw(win); return OPERATOR_RUNNING_MODAL; } int WM_gesture_box_modal(bContext *C, wmOperator *op, const wmEvent *event) { + wmWindow *win = CTX_wm_window(C); wmGesture *gesture = op->customdata; rcti *rect = gesture->customdata; @@ -210,14 +215,14 @@ int WM_gesture_box_modal(bContext *C, wmOperator *op, const wmEvent *event) } gesture_box_apply_rect(op); - wm_gesture_tag_redraw(C); + wm_gesture_tag_redraw(win); } else if (event->type == EVT_MODAL_MAP) { switch (event->val) { case GESTURE_MODAL_BEGIN: if (gesture->type == WM_GESTURE_CROSS_RECT && gesture->is_active == false) { gesture->is_active = true; - wm_gesture_tag_redraw(C); + wm_gesture_tag_redraw(win); } break; case GESTURE_MODAL_SELECT: @@ -276,9 +281,10 @@ static void gesture_circle_apply(bContext *C, wmOperator *op); int WM_gesture_circle_invoke(bContext *C, wmOperator *op, const wmEvent *event) { + wmWindow *win = CTX_wm_window(C); const bool wait_for_input = !ISTWEAK(event->type) && RNA_boolean_get(op->ptr, "wait_for_input"); - op->customdata = WM_gesture_new(C, event, WM_GESTURE_CIRCLE); + op->customdata = WM_gesture_new(win, CTX_wm_region(C), event, WM_GESTURE_CIRCLE); wmGesture *gesture = op->customdata; rcti *rect = gesture->customdata; @@ -297,7 +303,7 @@ int WM_gesture_circle_invoke(bContext *C, wmOperator *op, const wmEvent *event) /* add modal handler */ WM_event_add_modal_handler(C, op); - wm_gesture_tag_redraw(C); + wm_gesture_tag_redraw(win); return OPERATOR_RUNNING_MODAL; } @@ -332,6 +338,7 @@ static void gesture_circle_apply(bContext *C, wmOperator *op) int WM_gesture_circle_modal(bContext *C, wmOperator *op, const wmEvent *event) { + wmWindow *win = CTX_wm_window(C); wmGesture *gesture = op->customdata; rcti *rect = gesture->customdata; @@ -340,7 +347,7 @@ int WM_gesture_circle_modal(bContext *C, wmOperator *op, const wmEvent *event) rect->xmin = event->x - gesture->winrct.xmin; rect->ymin = event->y - gesture->winrct.ymin; - wm_gesture_tag_redraw(C); + wm_gesture_tag_redraw(win); if (gesture->is_active) { gesture_circle_apply(C, op); @@ -392,7 +399,7 @@ int WM_gesture_circle_modal(bContext *C, wmOperator *op, const wmEvent *event) /* apply first click */ gesture->is_active = true; gesture_circle_apply(C, op); - wm_gesture_tag_redraw(C); + wm_gesture_tag_redraw(win); } break; } @@ -407,7 +414,7 @@ int WM_gesture_circle_modal(bContext *C, wmOperator *op, const wmEvent *event) } if (is_circle_size) { - wm_gesture_tag_redraw(C); + wm_gesture_tag_redraw(win); /* So next use remembers last seen size, even if we didn't apply it. */ RNA_int_set(op->ptr, "radius", rect->xmax); @@ -527,7 +534,7 @@ static void gesture_tweak_modal(bContext *C, const wmEvent *event) if (gesture_end) { /* Frees gesture itself, and unregisters from window. */ - WM_gesture_end(C, gesture); + WM_gesture_end(window, gesture); /* This isn't very nice but needed to redraw gizmos which are hidden while tweaking, * See #WM_GIZMOGROUPTYPE_DELAY_REFRESH_FOR_TWEAK for details. */ @@ -546,10 +553,12 @@ void wm_tweakevent_test(bContext *C, const wmEvent *event, int action) wmWindow *win = CTX_wm_window(C); if (win->tweak == NULL) { - if (CTX_wm_region(C)) { + const ARegion *ar = CTX_wm_region(C); + + if (ar) { if (event->val == KM_PRESS) { if (ELEM(event->type, LEFTMOUSE, MIDDLEMOUSE, RIGHTMOUSE)) { - win->tweak = WM_gesture_new(C, event, WM_GESTURE_TWEAK); + win->tweak = WM_gesture_new(win, ar, event, WM_GESTURE_TWEAK); } } } @@ -557,7 +566,7 @@ void wm_tweakevent_test(bContext *C, const wmEvent *event, int action) else { /* no tweaks if event was handled */ if ((action & WM_HANDLER_BREAK)) { - WM_gesture_end(C, win->tweak); + WM_gesture_end(win, win->tweak); } else { gesture_tweak_modal(C, event); @@ -573,17 +582,18 @@ void wm_tweakevent_test(bContext *C, const wmEvent *event, int action) int WM_gesture_lasso_invoke(bContext *C, wmOperator *op, const wmEvent *event) { + wmWindow *win = CTX_wm_window(C); PropertyRNA *prop; - op->customdata = WM_gesture_new(C, event, WM_GESTURE_LASSO); + op->customdata = WM_gesture_new(win, CTX_wm_region(C), event, WM_GESTURE_LASSO); /* add modal handler */ WM_event_add_modal_handler(C, op); - wm_gesture_tag_redraw(C); + wm_gesture_tag_redraw(win); if ((prop = RNA_struct_find_property(op->ptr, "cursor"))) { - WM_cursor_modal_set(CTX_wm_window(C), RNA_property_int_get(op->ptr, prop)); + WM_cursor_modal_set(win, RNA_property_int_get(op->ptr, prop)); } return OPERATOR_RUNNING_MODAL; @@ -591,17 +601,18 @@ int WM_gesture_lasso_invoke(bContext *C, wmOperator *op, const wmEvent *event) int WM_gesture_lines_invoke(bContext *C, wmOperator *op, const wmEvent *event) { + wmWindow *win = CTX_wm_window(C); PropertyRNA *prop; - op->customdata = WM_gesture_new(C, event, WM_GESTURE_LINES); + op->customdata = WM_gesture_new(win, CTX_wm_region(C), event, WM_GESTURE_LINES); /* add modal handler */ WM_event_add_modal_handler(C, op); - wm_gesture_tag_redraw(C); + wm_gesture_tag_redraw(win); if ((prop = RNA_struct_find_property(op->ptr, "cursor"))) { - WM_cursor_modal_set(CTX_wm_window(C), RNA_property_int_get(op->ptr, prop)); + WM_cursor_modal_set(win, RNA_property_int_get(op->ptr, prop)); } return OPERATOR_RUNNING_MODAL; @@ -641,7 +652,7 @@ int WM_gesture_lasso_modal(bContext *C, wmOperator *op, const wmEvent *event) case MOUSEMOVE: case INBETWEEN_MOUSEMOVE: - wm_gesture_tag_redraw(C); + wm_gesture_tag_redraw(CTX_wm_window(C)); if (gesture->points == gesture->points_alloc) { gesture->points_alloc *= 2; @@ -806,9 +817,10 @@ static bool gesture_straightline_apply(bContext *C, wmOperator *op) int WM_gesture_straightline_invoke(bContext *C, wmOperator *op, const wmEvent *event) { + wmWindow *win = CTX_wm_window(C); PropertyRNA *prop; - op->customdata = WM_gesture_new(C, event, WM_GESTURE_STRAIGHTLINE); + op->customdata = WM_gesture_new(win, CTX_wm_region(C), event, WM_GESTURE_STRAIGHTLINE); if (ISTWEAK(event->type)) { wmGesture *gesture = op->customdata; @@ -818,10 +830,10 @@ int WM_gesture_straightline_invoke(bContext *C, wmOperator *op, const wmEvent *e /* add modal handler */ WM_event_add_modal_handler(C, op); - wm_gesture_tag_redraw(C); + wm_gesture_tag_redraw(win); if ((prop = RNA_struct_find_property(op->ptr, "cursor"))) { - WM_cursor_modal_set(CTX_wm_window(C), RNA_property_int_get(op->ptr, prop)); + WM_cursor_modal_set(win, RNA_property_int_get(op->ptr, prop)); } return OPERATOR_RUNNING_MODAL; @@ -830,6 +842,7 @@ int WM_gesture_straightline_invoke(bContext *C, wmOperator *op, const wmEvent *e int WM_gesture_straightline_modal(bContext *C, wmOperator *op, const wmEvent *event) { wmGesture *gesture = op->customdata; + wmWindow *win = CTX_wm_window(C); rcti *rect = gesture->customdata; if (event->type == MOUSEMOVE) { @@ -843,14 +856,14 @@ int WM_gesture_straightline_modal(bContext *C, wmOperator *op, const wmEvent *ev gesture_straightline_apply(C, op); } - wm_gesture_tag_redraw(C); + wm_gesture_tag_redraw(win); } else if (event->type == EVT_MODAL_MAP) { switch (event->val) { case GESTURE_MODAL_BEGIN: if (gesture->is_active == false) { gesture->is_active = true; - wm_gesture_tag_redraw(C); + wm_gesture_tag_redraw(win); } break; case GESTURE_MODAL_SELECT: diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c index b775b16c6df..7a05ef4b849 100644 --- a/source/blender/windowmanager/intern/wm_init_exit.c +++ b/source/blender/windowmanager/intern/wm_init_exit.c @@ -150,11 +150,9 @@ static void wm_init_reports(bContext *C) BKE_reports_init(reports, RPT_STORE); } -static void wm_free_reports(bContext *C) +static void wm_free_reports(wmWindowManager *wm) { - ReportList *reports = CTX_wm_reports(C); - - BKE_reports_clear(reports); + BKE_reports_clear(&wm->reports); } static bool wm_start_with_console = false; @@ -470,7 +468,7 @@ void wm_exit_schedule_delayed(const bContext *C) /* Use modal UI handler for now. * Could add separate WM handlers or so, but probably not worth it. */ WM_event_add_ui_handler(C, &win->modalhandlers, wm_exit_handler, NULL, NULL, 0); - WM_event_add_mousemove(C); /* ensure handler actually gets called */ + WM_event_add_mousemove(win); /* ensure handler actually gets called */ } /** @@ -558,9 +556,9 @@ void WM_exit_ex(bContext *C, const bool do_python) ED_preview_free_dbase(); /* frees a Main dbase, before BKE_blender_free! */ - if (C && wm) { + if (wm) { /* Before BKE_blender_free! - since the ListBases get freed there. */ - wm_free_reports(C); + wm_free_reports(wm); } BKE_sequencer_free_clipboard(); /* sequencer.c */ diff --git a/source/blender/windowmanager/intern/wm_jobs.c b/source/blender/windowmanager/intern/wm_jobs.c index a417d80a9a9..1cc9c82ec60 100644 --- a/source/blender/windowmanager/intern/wm_jobs.c +++ b/source/blender/windowmanager/intern/wm_jobs.c @@ -624,7 +624,7 @@ void wm_jobs_timer_ended(wmWindowManager *wm, wmTimer *wt) } /* hardcoded to event TIMERJOBS */ -void wm_jobs_timer(const bContext *C, wmWindowManager *wm, wmTimer *wt) +void wm_jobs_timer(wmWindowManager *wm, wmTimer *wt) { wmJob *wm_job, *wm_jobnext; @@ -645,11 +645,11 @@ void wm_jobs_timer(const bContext *C, wmWindowManager *wm, wmTimer *wt) wm_job->update(wm_job->run_customdata); } if (wm_job->note) { - WM_event_add_notifier(C, wm_job->note, NULL); + WM_event_add_notifier_ex(wm, wm_job->win, wm_job->note, NULL); } if (wm_job->flag & WM_JOB_PROGRESS) { - WM_event_add_notifier(C, NC_WM | ND_JOB, NULL); + WM_event_add_notifier_ex(wm, wm_job->win, NC_WM | ND_JOB, NULL); } wm_job->do_update = false; } @@ -680,10 +680,10 @@ void wm_jobs_timer(const bContext *C, wmWindowManager *wm, wmTimer *wt) WM_job_main_thread_lock_acquire(wm_job); if (wm_job->endnote) { - WM_event_add_notifier(C, wm_job->endnote, NULL); + WM_event_add_notifier_ex(wm, wm_job->win, wm_job->endnote, NULL); } - WM_event_add_notifier(C, NC_WM | ND_JOB, NULL); + WM_event_add_notifier_ex(wm, wm_job->win, NC_WM | ND_JOB, NULL); /* new job added for wm_job? */ if (wm_job->customdata) { diff --git a/source/blender/windowmanager/intern/wm_keymap.c b/source/blender/windowmanager/intern/wm_keymap.c index bbe685b56cb..9d587ff9e9b 100644 --- a/source/blender/windowmanager/intern/wm_keymap.c +++ b/source/blender/windowmanager/intern/wm_keymap.c @@ -889,20 +889,16 @@ wmKeyMap *WM_keymap_ensure(wmKeyConfig *keyconf, const char *idname, int spaceid return km; } -wmKeyMap *WM_keymap_find_all(const bContext *C, const char *idname, int spaceid, int regionid) +wmKeyMap *WM_keymap_find_all(wmWindowManager *wm, const char *idname, int spaceid, int regionid) { - wmWindowManager *wm = CTX_wm_manager(C); - return WM_keymap_list_find(&wm->userconf->keymaps, idname, spaceid, regionid); } -wmKeyMap *WM_keymap_find_all_spaceid_or_empty(const bContext *C, +wmKeyMap *WM_keymap_find_all_spaceid_or_empty(wmWindowManager *wm, const char *idname, int spaceid, int regionid) { - wmWindowManager *wm = CTX_wm_manager(C); - return WM_keymap_list_find_spaceid_or_empty(&wm->userconf->keymaps, idname, spaceid, regionid); } @@ -1965,9 +1961,8 @@ wmKeyMap *WM_keymap_active(wmWindowManager *wm, wmKeyMap *keymap) * In the keymap editor the user key configuration is edited. * \{ */ -void WM_keymap_item_restore_to_default(bContext *C, wmKeyMap *keymap, wmKeyMapItem *kmi) +void WM_keymap_item_restore_to_default(wmWindowManager *wm, wmKeyMap *keymap, wmKeyMapItem *kmi) { - wmWindowManager *wm = CTX_wm_manager(C); wmKeyMap *defaultmap, *addonmap; wmKeyMapItem *orig; @@ -2026,13 +2021,10 @@ void WM_keymap_item_restore_to_default(bContext *C, wmKeyMap *keymap, wmKeyMapIt } } -void WM_keymap_restore_to_default(wmKeyMap *keymap, bContext *C) +void WM_keymap_restore_to_default(wmKeyMap *keymap, wmWindowManager *wm) { - wmWindowManager *wm = CTX_wm_manager(C); - wmKeyMap *usermap; - /* remove keymap from U.user_keymaps and update */ - usermap = WM_keymap_list_find( + wmKeyMap *usermap = WM_keymap_list_find( &U.user_keymaps, keymap->idname, keymap->spaceid, keymap->regionid); if (usermap) { diff --git a/source/blender/windowmanager/intern/wm_keymap_utils.c b/source/blender/windowmanager/intern/wm_keymap_utils.c index 5e6b55a508e..6e494280820 100644 --- a/source/blender/windowmanager/intern/wm_keymap_utils.c +++ b/source/blender/windowmanager/intern/wm_keymap_utils.c @@ -194,7 +194,7 @@ wmKeyMap *WM_keymap_guess_from_context(const bContext *C) return NULL; } - wmKeyMap *km = WM_keymap_find_all(C, km_id, 0, 0); + wmKeyMap *km = WM_keymap_find_all(CTX_wm_manager(C), km_id, 0, 0); BLI_assert(km); return km; } @@ -218,6 +218,7 @@ wmKeyMap *WM_keymap_guess_opname(const bContext *C, const char *opname) */ wmKeyMap *km = NULL; + wmWindowManager *wm = CTX_wm_manager(C); SpaceLink *sl = CTX_wm_space_data(C); /* Window */ @@ -227,113 +228,113 @@ wmKeyMap *WM_keymap_guess_opname(const bContext *C, const char *opname) } if (km == NULL) { - km = WM_keymap_find_all(C, "Window", 0, 0); + km = WM_keymap_find_all(wm, "Window", 0, 0); } } /* Screen & Render */ else if (STRPREFIX(opname, "SCREEN_OT") || STRPREFIX(opname, "RENDER_OT") || STRPREFIX(opname, "SOUND_OT") || STRPREFIX(opname, "SCENE_OT")) { - km = WM_keymap_find_all(C, "Screen", 0, 0); + km = WM_keymap_find_all(wm, "Screen", 0, 0); } /* Grease Pencil */ else if (STRPREFIX(opname, "GPENCIL_OT")) { - km = WM_keymap_find_all(C, "Grease Pencil", 0, 0); + km = WM_keymap_find_all(wm, "Grease Pencil", 0, 0); } /* Markers */ else if (STRPREFIX(opname, "MARKER_OT")) { - km = WM_keymap_find_all(C, "Markers", 0, 0); + km = WM_keymap_find_all(wm, "Markers", 0, 0); } /* Import/Export*/ else if (STRPREFIX(opname, "IMPORT_") || STRPREFIX(opname, "EXPORT_")) { - km = WM_keymap_find_all(C, "Window", 0, 0); + km = WM_keymap_find_all(wm, "Window", 0, 0); } /* 3D View */ else if (STRPREFIX(opname, "VIEW3D_OT")) { - km = WM_keymap_find_all(C, "3D View", sl->spacetype, 0); + km = WM_keymap_find_all(wm, "3D View", sl->spacetype, 0); } else if (STRPREFIX(opname, "OBJECT_OT")) { /* exception, this needs to work outside object mode too */ if (STRPREFIX(opname, "OBJECT_OT_mode_set")) { - km = WM_keymap_find_all(C, "Object Non-modal", 0, 0); + km = WM_keymap_find_all(wm, "Object Non-modal", 0, 0); } else { - km = WM_keymap_find_all(C, "Object Mode", 0, 0); + km = WM_keymap_find_all(wm, "Object Mode", 0, 0); } } /* Object mode related */ else if (STRPREFIX(opname, "GROUP_OT") || STRPREFIX(opname, "MATERIAL_OT") || STRPREFIX(opname, "PTCACHE_OT") || STRPREFIX(opname, "RIGIDBODY_OT")) { - km = WM_keymap_find_all(C, "Object Mode", 0, 0); + km = WM_keymap_find_all(wm, "Object Mode", 0, 0); } /* Editing Modes */ else if (STRPREFIX(opname, "MESH_OT")) { - km = WM_keymap_find_all(C, "Mesh", 0, 0); + km = WM_keymap_find_all(wm, "Mesh", 0, 0); /* some mesh operators are active in object mode too, like add-prim */ if (km && !WM_keymap_poll((bContext *)C, km)) { - km = WM_keymap_find_all(C, "Object Mode", 0, 0); + km = WM_keymap_find_all(wm, "Object Mode", 0, 0); } } else if (STRPREFIX(opname, "CURVE_OT") || STRPREFIX(opname, "SURFACE_OT")) { - km = WM_keymap_find_all(C, "Curve", 0, 0); + km = WM_keymap_find_all(wm, "Curve", 0, 0); /* some curve operators are active in object mode too, like add-prim */ if (km && !WM_keymap_poll((bContext *)C, km)) { - km = WM_keymap_find_all(C, "Object Mode", 0, 0); + km = WM_keymap_find_all(wm, "Object Mode", 0, 0); } } else if (STRPREFIX(opname, "ARMATURE_OT") || STRPREFIX(opname, "SKETCH_OT")) { - km = WM_keymap_find_all(C, "Armature", 0, 0); + km = WM_keymap_find_all(wm, "Armature", 0, 0); } else if (STRPREFIX(opname, "POSE_OT") || STRPREFIX(opname, "POSELIB_OT")) { - km = WM_keymap_find_all(C, "Pose", 0, 0); + km = WM_keymap_find_all(wm, "Pose", 0, 0); } else if (STRPREFIX(opname, "SCULPT_OT")) { switch (CTX_data_mode_enum(C)) { case CTX_MODE_SCULPT: - km = WM_keymap_find_all(C, "Sculpt", 0, 0); + km = WM_keymap_find_all(wm, "Sculpt", 0, 0); break; default: break; } } else if (STRPREFIX(opname, "MBALL_OT")) { - km = WM_keymap_find_all(C, "Metaball", 0, 0); + km = WM_keymap_find_all(wm, "Metaball", 0, 0); /* some mball operators are active in object mode too, like add-prim */ if (km && !WM_keymap_poll((bContext *)C, km)) { - km = WM_keymap_find_all(C, "Object Mode", 0, 0); + km = WM_keymap_find_all(wm, "Object Mode", 0, 0); } } else if (STRPREFIX(opname, "LATTICE_OT")) { - km = WM_keymap_find_all(C, "Lattice", 0, 0); + km = WM_keymap_find_all(wm, "Lattice", 0, 0); } else if (STRPREFIX(opname, "PARTICLE_OT")) { - km = WM_keymap_find_all(C, "Particle", 0, 0); + km = WM_keymap_find_all(wm, "Particle", 0, 0); } else if (STRPREFIX(opname, "FONT_OT")) { - km = WM_keymap_find_all(C, "Font", 0, 0); + km = WM_keymap_find_all(wm, "Font", 0, 0); } /* Paint Face Mask */ else if (STRPREFIX(opname, "PAINT_OT_face_select")) { - km = WM_keymap_find_all(C, "Paint Face Mask (Weight, Vertex, Texture)", 0, 0); + km = WM_keymap_find_all(wm, "Paint Face Mask (Weight, Vertex, Texture)", 0, 0); } else if (STRPREFIX(opname, "PAINT_OT")) { /* check for relevant mode */ switch (CTX_data_mode_enum(C)) { case CTX_MODE_PAINT_WEIGHT: - km = WM_keymap_find_all(C, "Weight Paint", 0, 0); + km = WM_keymap_find_all(wm, "Weight Paint", 0, 0); break; case CTX_MODE_PAINT_VERTEX: - km = WM_keymap_find_all(C, "Vertex Paint", 0, 0); + km = WM_keymap_find_all(wm, "Vertex Paint", 0, 0); break; case CTX_MODE_PAINT_TEXTURE: - km = WM_keymap_find_all(C, "Image Paint", 0, 0); + km = WM_keymap_find_all(wm, "Image Paint", 0, 0); break; case CTX_MODE_SCULPT: - km = WM_keymap_find_all(C, "Sculpt", 0, 0); + km = WM_keymap_find_all(wm, "Sculpt", 0, 0); break; default: break; @@ -341,109 +342,109 @@ wmKeyMap *WM_keymap_guess_opname(const bContext *C, const char *opname) } /* Image Editor */ else if (STRPREFIX(opname, "IMAGE_OT")) { - km = WM_keymap_find_all(C, "Image", sl->spacetype, 0); + km = WM_keymap_find_all(wm, "Image", sl->spacetype, 0); } /* Clip Editor */ else if (STRPREFIX(opname, "CLIP_OT")) { - km = WM_keymap_find_all(C, "Clip", sl->spacetype, 0); + km = WM_keymap_find_all(wm, "Clip", sl->spacetype, 0); } else if (STRPREFIX(opname, "MASK_OT")) { - km = WM_keymap_find_all(C, "Mask Editing", 0, 0); + km = WM_keymap_find_all(wm, "Mask Editing", 0, 0); } /* UV Editor */ else if (STRPREFIX(opname, "UV_OT")) { /* Hack to allow using UV unwrapping ops from 3DView/editmode. * Mesh keymap is probably not ideal, but best place I could find to put those. */ if (sl->spacetype == SPACE_VIEW3D) { - km = WM_keymap_find_all(C, "Mesh", 0, 0); + km = WM_keymap_find_all(wm, "Mesh", 0, 0); if (km && !WM_keymap_poll((bContext *)C, km)) { km = NULL; } } if (!km) { - km = WM_keymap_find_all(C, "UV Editor", 0, 0); + km = WM_keymap_find_all(wm, "UV Editor", 0, 0); } } /* Node Editor */ else if (STRPREFIX(opname, "NODE_OT")) { - km = WM_keymap_find_all(C, "Node Editor", sl->spacetype, 0); + km = WM_keymap_find_all(wm, "Node Editor", sl->spacetype, 0); } /* Animation Editor Channels */ else if (STRPREFIX(opname, "ANIM_OT_channels")) { - km = WM_keymap_find_all(C, "Animation Channels", 0, 0); + km = WM_keymap_find_all(wm, "Animation Channels", 0, 0); } /* Animation Generic - after channels */ else if (STRPREFIX(opname, "ANIM_OT")) { - km = WM_keymap_find_all(C, "Animation", 0, 0); + km = WM_keymap_find_all(wm, "Animation", 0, 0); } /* Graph Editor */ else if (STRPREFIX(opname, "GRAPH_OT")) { - km = WM_keymap_find_all(C, "Graph Editor", sl->spacetype, 0); + km = WM_keymap_find_all(wm, "Graph Editor", sl->spacetype, 0); } /* Dopesheet Editor */ else if (STRPREFIX(opname, "ACTION_OT")) { - km = WM_keymap_find_all(C, "Dopesheet", sl->spacetype, 0); + km = WM_keymap_find_all(wm, "Dopesheet", sl->spacetype, 0); } /* NLA Editor */ else if (STRPREFIX(opname, "NLA_OT")) { - km = WM_keymap_find_all(C, "NLA Editor", sl->spacetype, 0); + km = WM_keymap_find_all(wm, "NLA Editor", sl->spacetype, 0); } /* Script */ else if (STRPREFIX(opname, "SCRIPT_OT")) { - km = WM_keymap_find_all(C, "Script", sl->spacetype, 0); + km = WM_keymap_find_all(wm, "Script", sl->spacetype, 0); } /* Text */ else if (STRPREFIX(opname, "TEXT_OT")) { - km = WM_keymap_find_all(C, "Text", sl->spacetype, 0); + km = WM_keymap_find_all(wm, "Text", sl->spacetype, 0); } /* Sequencer */ else if (STRPREFIX(opname, "SEQUENCER_OT")) { - km = WM_keymap_find_all(C, "Sequencer", sl->spacetype, 0); + km = WM_keymap_find_all(wm, "Sequencer", sl->spacetype, 0); } /* Console */ else if (STRPREFIX(opname, "CONSOLE_OT")) { - km = WM_keymap_find_all(C, "Console", sl->spacetype, 0); + km = WM_keymap_find_all(wm, "Console", sl->spacetype, 0); } /* Console */ else if (STRPREFIX(opname, "INFO_OT")) { - km = WM_keymap_find_all(C, "Info", sl->spacetype, 0); + km = WM_keymap_find_all(wm, "Info", sl->spacetype, 0); } /* File browser */ else if (STRPREFIX(opname, "FILE_OT")) { - km = WM_keymap_find_all(C, "File Browser", sl->spacetype, 0); + km = WM_keymap_find_all(wm, "File Browser", sl->spacetype, 0); } /* Logic Editor */ else if (STRPREFIX(opname, "LOGIC_OT")) { - km = WM_keymap_find_all(C, "Logic Editor", sl->spacetype, 0); + km = WM_keymap_find_all(wm, "Logic Editor", sl->spacetype, 0); } /* Outliner */ else if (STRPREFIX(opname, "OUTLINER_OT")) { - km = WM_keymap_find_all(C, "Outliner", sl->spacetype, 0); + km = WM_keymap_find_all(wm, "Outliner", sl->spacetype, 0); } /* Transform */ else if (STRPREFIX(opname, "TRANSFORM_OT")) { /* check for relevant editor */ switch (sl->spacetype) { case SPACE_VIEW3D: - km = WM_keymap_find_all(C, "3D View", sl->spacetype, 0); + km = WM_keymap_find_all(wm, "3D View", sl->spacetype, 0); break; case SPACE_GRAPH: - km = WM_keymap_find_all(C, "Graph Editor", sl->spacetype, 0); + km = WM_keymap_find_all(wm, "Graph Editor", sl->spacetype, 0); break; case SPACE_ACTION: - km = WM_keymap_find_all(C, "Dopesheet", sl->spacetype, 0); + km = WM_keymap_find_all(wm, "Dopesheet", sl->spacetype, 0); break; case SPACE_NLA: - km = WM_keymap_find_all(C, "NLA Editor", sl->spacetype, 0); + km = WM_keymap_find_all(wm, "NLA Editor", sl->spacetype, 0); break; case SPACE_IMAGE: - km = WM_keymap_find_all(C, "UV Editor", 0, 0); + km = WM_keymap_find_all(wm, "UV Editor", 0, 0); break; case SPACE_NODE: - km = WM_keymap_find_all(C, "Node Editor", sl->spacetype, 0); + km = WM_keymap_find_all(wm, "Node Editor", sl->spacetype, 0); break; case SPACE_SEQ: - km = WM_keymap_find_all(C, "Sequencer", sl->spacetype, 0); + km = WM_keymap_find_all(wm, "Sequencer", sl->spacetype, 0); break; } } diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c index 148195df372..57612964295 100644 --- a/source/blender/windowmanager/intern/wm_window.c +++ b/source/blender/windowmanager/intern/wm_window.c @@ -283,10 +283,8 @@ static int find_free_winid(wmWindowManager *wm) } /* don't change context itself */ -wmWindow *wm_window_new(bContext *C, wmWindow *parent) +wmWindow *wm_window_new(const Main *bmain, wmWindowManager *wm, wmWindow *parent) { - Main *bmain = CTX_data_main(C); - wmWindowManager *wm = CTX_wm_manager(C); wmWindow *win = MEM_callocN(sizeof(wmWindow), "window"); BLI_addtail(&wm->windows, win); @@ -300,14 +298,14 @@ wmWindow *wm_window_new(bContext *C, wmWindow *parent) } /* part of wm_window.c api */ -wmWindow *wm_window_copy(bContext *C, +wmWindow *wm_window_copy(Main *bmain, + wmWindowManager *wm, wmWindow *win_src, const bool duplicate_layout, const bool child) { - Main *bmain = CTX_data_main(C); wmWindow *win_parent = (child) ? win_src : win_src->parent; - wmWindow *win_dst = wm_window_new(C, win_parent); + wmWindow *win_dst = wm_window_new(bmain, wm, win_parent); WorkSpace *workspace = WM_window_get_active_workspace(win_src); WorkSpaceLayout *layout_old = WM_window_get_active_layout(win_src); WorkSpaceLayout *layout_new; @@ -339,15 +337,16 @@ wmWindow *wm_window_copy_test(bContext *C, const bool duplicate_layout, const bool child) { + Main *bmain = CTX_data_main(C); wmWindowManager *wm = CTX_wm_manager(C); wmWindow *win_dst; - win_dst = wm_window_copy(C, win_src, duplicate_layout, child); + win_dst = wm_window_copy(bmain, wm, win_src, duplicate_layout, child); WM_check(C); if (win_dst->ghostwin) { - WM_event_add_notifier(C, NC_WINDOW | NA_ADDED, NULL); + WM_event_add_notifier_ex(wm, CTX_wm_window(C), NC_WINDOW | NA_ADDED, NULL); return win_dst; } else { @@ -394,7 +393,7 @@ void wm_quit_with_optional_confirmation_prompt(bContext *C, wmWindow *win) CTX_wm_window_set(C, win); if (U.uiflag & USER_SAVE_PROMPT) { - if (wm_file_or_image_is_modified(C) && !G.background) { + if (wm_file_or_image_is_modified(CTX_data_main(C), CTX_wm_manager(C)) && !G.background) { wm_window_raise(win); wm_confirm_quit(C); } @@ -809,8 +808,9 @@ void wm_window_ghostwindows_remove_invalid(bContext *C, wmWindowManager *wm) */ wmWindow *WM_window_open(bContext *C, const rcti *rect) { + wmWindowManager *wm = CTX_wm_manager(C); wmWindow *win_prev = CTX_wm_window(C); - wmWindow *win = wm_window_new(C, win_prev); + wmWindow *win = wm_window_new(CTX_data_main(C), wm, win_prev); win->posx = rect->xmin; win->posy = rect->ymin; @@ -823,7 +823,7 @@ wmWindow *WM_window_open(bContext *C, const rcti *rect) return win; } else { - wm_window_close(C, CTX_wm_manager(C), win); + wm_window_close(C, wm, win); CTX_wm_window_set(C, win_prev); return NULL; } @@ -881,7 +881,7 @@ wmWindow *WM_window_open_temp(bContext *C, /* add new window? */ if (win == NULL) { - win = wm_window_new(C, win_prev); + win = wm_window_new(bmain, wm, win_prev); win->posx = rect.xmin; win->posy = rect.ymin; @@ -1573,6 +1573,7 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_ptr */ static int wm_window_timer(const bContext *C) { + Main *bmain = CTX_data_main(C); wmWindowManager *wm = CTX_wm_manager(C); wmTimer *wt, *wtnext; wmWindow *win; @@ -1591,10 +1592,10 @@ static int wm_window_timer(const bContext *C) wt->ntime = wt->stime + wt->timestep * ceil(wt->duration / wt->timestep); if (wt->event_type == TIMERJOBS) { - wm_jobs_timer(C, wm, wt); + wm_jobs_timer(wm, wt); } else if (wt->event_type == TIMERAUTOSAVE) { - wm_autosave_timer(C, wm, wt); + wm_autosave_timer(bmain, wm, wt); } else if (wt->event_type == TIMERNOTIFIER) { WM_main_add_notifier(POINTER_AS_UINT(wt->customdata), NULL); diff --git a/source/blender/windowmanager/wm.h b/source/blender/windowmanager/wm.h index 00d9a8a2fab..1de8ec997a8 100644 --- a/source/blender/windowmanager/wm.h +++ b/source/blender/windowmanager/wm.h @@ -62,17 +62,17 @@ void wm_operatortypes_register(void); /* wm_gesture.c */ void wm_gesture_draw(struct wmWindow *win); int wm_gesture_evaluate(wmGesture *gesture, const struct wmEvent *event); -void wm_gesture_tag_redraw(bContext *C); +void wm_gesture_tag_redraw(struct wmWindow *win); /* wm_gesture_ops.c */ void wm_tweakevent_test(bContext *C, const wmEvent *event, int action); /* wm_jobs.c */ -void wm_jobs_timer(const bContext *C, wmWindowManager *wm, wmTimer *wt); +void wm_jobs_timer(wmWindowManager *wm, wmTimer *wt); void wm_jobs_timer_ended(wmWindowManager *wm, wmTimer *wt); /* wm_files.c */ -void wm_autosave_timer(const bContext *C, wmWindowManager *wm, wmTimer *wt); +void wm_autosave_timer(struct Main *bmain, wmWindowManager *wm, wmTimer *wt); void wm_autosave_timer_ended(wmWindowManager *wm); void wm_autosave_delete(void); void wm_autosave_read(bContext *C, struct ReportList *reports); diff --git a/source/blender/windowmanager/wm_files.h b/source/blender/windowmanager/wm_files.h index 0aa4357a8f4..e081742b904 100644 --- a/source/blender/windowmanager/wm_files.h +++ b/source/blender/windowmanager/wm_files.h @@ -42,7 +42,7 @@ void wm_homefile_read(struct bContext *C, void wm_file_read_report(bContext *C, struct Main *bmain); void wm_close_file_dialog(bContext *C, struct wmGenericCallback *post_action); -bool wm_file_or_image_is_modified(const struct bContext *C); +bool wm_file_or_image_is_modified(const Main *bmain, const wmWindowManager *wm); void WM_OT_save_homefile(struct wmOperatorType *ot); void WM_OT_userpref_autoexec_path_add(struct wmOperatorType *ot); diff --git a/source/blender/windowmanager/wm_window.h b/source/blender/windowmanager/wm_window.h index b0329f7415e..ce9d79b8e59 100644 --- a/source/blender/windowmanager/wm_window.h +++ b/source/blender/windowmanager/wm_window.h @@ -33,8 +33,9 @@ void wm_ghost_exit(void); void wm_get_screensize(int *r_width, int *r_height); void wm_get_desktopsize(int *r_width, int *r_height); -wmWindow *wm_window_new(bContext *C, wmWindow *parent); -wmWindow *wm_window_copy(bContext *C, +wmWindow *wm_window_new(const struct Main *bmain, wmWindowManager *wm, wmWindow *parent); +wmWindow *wm_window_copy(struct Main *bmain, + wmWindowManager *wm, wmWindow *win_src, const bool duplicate_layout, const bool child); |