Cleanup: Reduce context usage in UI functions

Part of https://developer.blender.org/T74429.

There's a chance that this causes some issues becaue in some cases we
change from getting the window from context to getting it from somewhere
else.
This commit is contained in:
Julian Eisel 2020-03-06 16:22:28 +01:00
parent b242cc6792
commit d5572eacc5
Notes: blender-bot 2023-02-14 01:07:44 +01:00
Referenced by commit dc3ff1db3f, Fix T74585: Crash when scrolling viewport shading pop-up
Referenced by issue #74585, Crash when scrolling Viewport Shading pop-up
41 changed files with 272 additions and 270 deletions

View File

@ -354,7 +354,7 @@ static int gizmo_arrow_modal(bContext *C,
/* tag the region for redraw */
ED_region_tag_redraw_editor_overlays(ar);
WM_event_add_mousemove(C);
WM_event_add_mousemove(CTX_wm_window(C));
return OPERATOR_RUNNING_MODAL;
}

View File

@ -1087,7 +1087,7 @@ static int gizmo_cage2d_modal(bContext *C,
/* tag the region for redraw */
ED_region_tag_redraw_editor_overlays(CTX_wm_region(C));
WM_event_add_mousemove(C);
WM_event_add_mousemove(CTX_wm_window(C));
return OPERATOR_RUNNING_MODAL;
}

View File

@ -586,7 +586,7 @@ static int gizmo_cage3d_modal(bContext *C,
/* tag the region for redraw */
ED_region_tag_redraw_editor_overlays(CTX_wm_region(C));
WM_event_add_mousemove(C);
WM_event_add_mousemove(CTX_wm_window(C));
return OPERATOR_RUNNING_MODAL;
}

View File

@ -122,8 +122,8 @@ void ED_image_draw_info(struct Scene *scene,
bool ED_space_image_show_cache(struct SpaceImage *sima);
bool ED_image_should_save_modified(const struct bContext *C);
int ED_image_save_all_modified_info(const struct bContext *C, struct ReportList *reports);
bool ED_image_should_save_modified(const struct Main *bmain);
int ED_image_save_all_modified_info(const struct Main *bmain, struct ReportList *reports);
bool ED_image_save_all_modified(const struct bContext *C, struct ReportList *reports);
/* image_sequence.c */

View File

@ -632,7 +632,7 @@ void uiPupBlockOperator(struct bContext *C,
void UI_popup_block_close(struct bContext *C, struct wmWindow *win, uiBlock *block);
bool UI_popup_block_name_exists(struct bContext *C, const char *name);
bool UI_popup_block_name_exists(const struct bScreen *screen, const char *name);
/* Blocks
*

View File

@ -125,7 +125,9 @@ static int datadropper_init(bContext *C, wmOperator *op)
static void datadropper_exit(bContext *C, wmOperator *op)
{
WM_cursor_modal_restore(CTX_wm_window(C));
wmWindow *win = CTX_wm_window(C);
WM_cursor_modal_restore(win);
if (op->customdata) {
DataDropper *ddr = (DataDropper *)op->customdata;
@ -139,7 +141,7 @@ static void datadropper_exit(bContext *C, wmOperator *op)
op->customdata = NULL;
}
WM_event_add_mousemove(C);
WM_event_add_mousemove(win);
}
/* *** datadropper id helper functions *** */

View File

@ -1552,7 +1552,7 @@ static int ui_handler_region_drag_toggle(bContext *C, const wmEvent *event, void
false);
ui_handler_region_drag_toggle_remove(C, drag_info);
WM_event_add_mousemove(C);
WM_event_add_mousemove(win);
return WM_UI_HANDLER_BREAK;
}
else {
@ -1843,7 +1843,7 @@ static bool ui_but_drag_init(bContext *C,
const wmEvent *event)
{
/* prevent other WM gestures to start while we try to drag */
WM_gestures_remove(C);
WM_gestures_remove(CTX_wm_window(C));
/* Clamp the maximum to half the UI unit size so a high user preference
* doesn't require the user to drag more then half the default button height. */
@ -3280,7 +3280,7 @@ wmIMEData *ui_but_ime_data_get(uiBut *but)
static void ui_textedit_begin(bContext *C, uiBut *but, uiHandleButtonData *data)
{
wmWindow *win = CTX_wm_window(C);
wmWindow *win = data->window;
int len;
const bool is_num_but = ELEM(but->type, UI_BTYPE_NUM, UI_BTYPE_NUM_SLIDER);
bool no_zero_strip = false;
@ -3370,7 +3370,7 @@ static void ui_textedit_begin(bContext *C, uiBut *but, uiHandleButtonData *data)
static void ui_textedit_end(bContext *C, uiBut *but, uiHandleButtonData *data)
{
wmWindow *win = CTX_wm_window(C);
wmWindow *win = data->window;
if (but) {
if (UI_but_is_utf8(but)) {
@ -3945,7 +3945,7 @@ static void ui_but_extra_operator_icon_apply(bContext *C, uiBut *but, uiButExtra
/* Force recreation of extra operator icons (pseudo update). */
ui_but_extra_operator_icons_free(but);
WM_event_add_mousemove(C);
WM_event_add_mousemove(CTX_wm_window(C));
}
/** \} */
@ -4020,8 +4020,7 @@ static void ui_block_open_begin(bContext *C, uiBut *but, uiHandleButtonData *dat
#ifdef USE_ALLSELECT
{
wmWindow *win = CTX_wm_window(C);
if (IS_ALLSELECT_EVENT(win->eventstate)) {
if (IS_ALLSELECT_EVENT(data->window->eventstate)) {
data->select_others.is_enabled = true;
}
}
@ -5570,7 +5569,7 @@ static int ui_do_but_BLOCK(bContext *C, uiBut *but, uiHandleButtonData *data, co
* The active state of the button could be maintained some other way
* and remove this mousemove event.
*/
WM_event_add_mousemove(C);
WM_event_add_mousemove(data->window);
return WM_UI_HANDLER_BREAK;
}
@ -8039,11 +8038,12 @@ static void button_activate_init(bContext *C, ARegion *ar, uiBut *but, uiButtonA
static void button_activate_exit(
bContext *C, uiBut *but, uiHandleButtonData *data, const bool mousemove, const bool onfree)
{
wmWindow *win = data->window;
uiBlock *block = but->block;
uiBut *bt;
if (but->type == UI_BTYPE_GRIP) {
WM_cursor_modal_restore(data->window);
WM_cursor_modal_restore(win);
}
/* ensure we are in the exit state */
@ -8160,7 +8160,7 @@ static void button_activate_exit(
* still over a button. We cannot just check for this ourselves because
* at this point the mouse may be over a button in another region */
if (mousemove) {
WM_event_add_mousemove(C);
WM_event_add_mousemove(CTX_wm_window(C));
}
}
@ -8818,7 +8818,7 @@ static int ui_handle_button_event(bContext *C, const wmEvent *event, uiBut *but)
button_activate_init(C, ar, post_but, post_type);
}
else {
/* XXX issue is because WM_event_add_mousemove(C) is a bad hack and not reliable,
/* XXX issue is because WM_event_add_mousemove(wm) is a bad hack and not reliable,
* if that gets coded better this bypass can go away too.
*
* This is needed to make sure if a button was active,
@ -9592,7 +9592,7 @@ static int ui_handle_menu_event(bContext *C,
but->active->cancel = true;
button_activate_exit(C, but, but->active, false, false);
}
WM_event_add_mousemove(C);
WM_event_add_mousemove(but->active->window);
}
}
break;
@ -10776,7 +10776,7 @@ static int ui_popup_handler(bContext *C, const wmEvent *event, void *userdata)
temp.cancel_func(C, temp.popup_arg);
}
WM_event_add_mousemove(C);
WM_event_add_mousemove(win);
}
else {
/* re-enable tooltips */

View File

@ -1649,7 +1649,7 @@ static int ui_button_press_invoke(bContext *C, wmOperator *op, const wmEvent *ev
but->optype = but_optype;
WM_event_add_mousemove(C);
WM_event_add_mousemove(CTX_wm_window(C));
return OPERATOR_FINISHED;
}

View File

@ -213,7 +213,7 @@ void UI_pie_menu_end(bContext *C, uiPieMenu *pie)
menu->towardstime = PIL_check_seconds_timer();
UI_popup_handlers_add(C, &window->modalhandlers, menu, WM_HANDLER_ACCEPT_DBL_CLICK);
WM_event_add_mousemove(C);
WM_event_add_mousemove(window);
MEM_freeN(pie);
}

View File

@ -357,7 +357,7 @@ uiPopupBlockHandle *ui_popup_menu_create(
handle->popup = true;
UI_popup_handlers_add(C, &window->modalhandlers, handle, 0);
WM_event_add_mousemove(C);
WM_event_add_mousemove(window);
}
MEM_freeN(pup);
@ -467,7 +467,7 @@ void UI_popup_menu_end(bContext *C, uiPopupMenu *pup)
menu->popup = true;
UI_popup_handlers_add(C, &window->modalhandlers, menu, 0);
WM_event_add_mousemove(C);
WM_event_add_mousemove(window);
MEM_freeN(pup);
}
@ -599,7 +599,7 @@ void UI_popup_block_invoke_ex(bContext *C,
UI_popup_handlers_add(C, &window->modalhandlers, handle, 0);
UI_block_active_only_flagged_buttons(C, handle->region, handle->region->uiblocks.first);
WM_event_add_mousemove(C);
WM_event_add_mousemove(window);
}
void UI_popup_block_invoke(bContext *C,
@ -633,7 +633,7 @@ void UI_popup_block_ex(bContext *C,
UI_popup_handlers_add(C, &window->modalhandlers, handle, 0);
UI_block_active_only_flagged_buttons(C, handle->region, handle->region->uiblocks.first);
WM_event_add_mousemove(C);
WM_event_add_mousemove(window);
}
#if 0 /* UNUSED */
@ -676,14 +676,10 @@ void UI_popup_block_close(bContext *C, wmWindow *win, uiBlock *block)
}
}
bool UI_popup_block_name_exists(bContext *C, const char *name)
bool UI_popup_block_name_exists(const bScreen *screen, const char *name)
{
bScreen *sc = CTX_wm_screen(C);
uiBlock *block;
ARegion *ar;
for (ar = sc->regionbase.first; ar; ar = ar->next) {
for (block = ar->uiblocks.first; block; block = block->next) {
for (const ARegion *ar = screen->regionbase.first; ar; ar = ar->next) {
for (const uiBlock *block = ar->uiblocks.first; block; block = block->next) {
if (STREQ(block->name, name)) {
return true;
}

View File

@ -284,7 +284,7 @@ uiPopupBlockHandle *ui_popover_panel_create(
* add a modal handler and pass on events. */
if (!but) {
UI_popup_handlers_add(C, &window->modalhandlers, handle, 0);
WM_event_add_mousemove(C);
WM_event_add_mousemove(window);
handle->popup = true;
}
@ -403,7 +403,7 @@ void UI_popover_end(bContext *C, uiPopover *pup, wmKeyMap *keymap)
/* Add handlers. */
UI_popup_handlers_add(C, &window->modalhandlers, handle, 0);
WM_event_add_mousemove(C);
WM_event_add_mousemove(window);
handle->popup = true;
/* Re-add so it gets priority. */

View File

@ -706,15 +706,6 @@ uiBlock *ui_popup_block_refresh(bContext *C,
}
}
else {
/* Add an offset to draw the popover arrow. */
if ((block->flag & UI_BLOCK_POPOVER) && ELEM(block->direction, UI_DIR_UP, UI_DIR_DOWN)) {
/* Keep sync with 'ui_draw_popover_back_impl'. */
const float unit_size = U.widget_unit / block->aspect;
const float unit_half = unit_size * (block->direction == UI_DIR_DOWN ? 0.5 : -0.5);
UI_block_translate(block, 0, -unit_half);
}
/* clip block with window boundary */
ui_popup_block_clip(window, block);

View File

@ -188,7 +188,7 @@ static void view_pan_apply_ex(bContext *C, v2dViewPanData *vpd, float dx, float
ED_region_tag_redraw_no_rebuild(vpd->ar);
/* request updates to be done... */
WM_event_add_mousemove(C);
WM_event_add_mousemove(CTX_wm_window(C));
UI_view2d_sync(vpd->sc, vpd->sa, v2d, V2D_LOCK_COPY);
}
@ -1592,6 +1592,7 @@ void UI_view2d_smooth_view(bContext *C, ARegion *ar, const rctf *cur, const int
/* only meant for timer usage */
static int view2d_smoothview_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *event)
{
wmWindow *win = CTX_wm_window(C);
ARegion *ar = CTX_wm_region(C);
View2D *v2d = &ar->v2d;
struct SmoothView2DStore *sms = v2d->sms;
@ -1616,11 +1617,11 @@ static int view2d_smoothview_invoke(bContext *C, wmOperator *UNUSED(op), const w
MEM_freeN(v2d->sms);
v2d->sms = NULL;
WM_event_remove_timer(CTX_wm_manager(C), CTX_wm_window(C), v2d->smooth_timer);
WM_event_remove_timer(CTX_wm_manager(C), win, v2d->smooth_timer);
v2d->smooth_timer = NULL;
/* Event handling won't know if a UI item has been moved under the pointer. */
WM_event_add_mousemove(C);
WM_event_add_mousemove(win);
}
else {
/* ease in/out */

View File

@ -162,7 +162,7 @@ static int edbm_polybuild_transform_at_cursor_invoke(bContext *C,
}
}
BM_select_history_store(bm, ele_act);
WM_event_add_mousemove(C);
WM_event_add_mousemove(vc.win);
return OPERATOR_FINISHED;
}
@ -244,7 +244,7 @@ static int edbm_polybuild_delete_at_cursor_invoke(bContext *C,
ED_object_base_activate(C, basact);
}
}
WM_event_add_mousemove(C);
WM_event_add_mousemove(vc.win);
return OPERATOR_FINISHED;
}
else {
@ -411,7 +411,7 @@ static int edbm_polybuild_face_at_cursor_invoke(bContext *C, wmOperator *op, con
}
}
WM_event_add_mousemove(C);
WM_event_add_mousemove(vc.win);
return OPERATOR_FINISHED;
}
@ -495,7 +495,7 @@ static int edbm_polybuild_split_at_cursor_invoke(bContext *C,
EDBM_mesh_normals_update(em);
EDBM_update_generic(vc.obedit->data, true, true);
WM_event_add_mousemove(C);
WM_event_add_mousemove(vc.win);
if (vc.view_layer->basact != basact) {
ED_object_base_activate(C, basact);
@ -592,7 +592,7 @@ static int edbm_polybuild_dissolve_at_cursor_invoke(bContext *C,
ED_object_base_activate(C, basact);
}
WM_event_add_mousemove(C);
WM_event_add_mousemove(vc.win);
return OPERATOR_FINISHED;
}

View File

@ -1971,6 +1971,7 @@ void ED_area_data_swap(ScrArea *sa_dst, ScrArea *sa_src)
void ED_area_swapspace(bContext *C, ScrArea *sa1, ScrArea *sa2)
{
ScrArea *tmp = MEM_callocN(sizeof(ScrArea), "addscrarea");
wmWindow *win = CTX_wm_window(C);
ED_area_exit(C, sa1);
ED_area_exit(C, sa2);
@ -1978,14 +1979,14 @@ void ED_area_swapspace(bContext *C, ScrArea *sa1, ScrArea *sa2)
ED_area_data_copy(tmp, sa1, false);
ED_area_data_copy(sa1, sa2, true);
ED_area_data_copy(sa2, tmp, true);
ED_area_initialize(CTX_wm_manager(C), CTX_wm_window(C), sa1);
ED_area_initialize(CTX_wm_manager(C), CTX_wm_window(C), sa2);
ED_area_initialize(CTX_wm_manager(C), win, sa1);
ED_area_initialize(CTX_wm_manager(C), win, sa2);
BKE_screen_area_free(tmp);
MEM_freeN(tmp);
/* tell WM to refresh, cursor types etc */
WM_event_add_mousemove(C);
WM_event_add_mousemove(win);
ED_area_tag_redraw(sa1);
ED_area_tag_refresh(sa1);
@ -2119,7 +2120,7 @@ void ED_area_newspace(bContext *C, ScrArea *sa, int type, const bool skip_ar_exi
ED_area_initialize(CTX_wm_manager(C), win, sa);
/* tell WM to refresh, cursor types etc */
WM_event_add_mousemove(C);
WM_event_add_mousemove(win);
/* send space change notifier */
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_CHANGED, sa);

View File

@ -1013,7 +1013,7 @@ void screen_change_update(bContext *C, wmWindow *win, bScreen *sc)
WM_event_add_notifier(C, NC_SCREEN | ND_LAYOUTSET, layout);
/* makes button hilites work */
WM_event_add_mousemove(C);
WM_event_add_mousemove(win);
}
/**

View File

@ -4042,7 +4042,7 @@ static int region_flip_exec(bContext *C, wmOperator *UNUSED(op))
}
ED_area_tag_redraw(CTX_wm_area(C));
WM_event_add_mousemove(C);
WM_event_add_mousemove(CTX_wm_window(C));
WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL);
return OPERATOR_FINISHED;

View File

@ -334,7 +334,7 @@ static int workspace_append_activate_exec(bContext *C, wmOperator *op)
RNA_string_get(op->ptr, "filepath", filepath);
WorkSpace *appended_workspace = (WorkSpace *)WM_file_append_datablock(
C, filepath, ID_WS, idname);
bmain, CTX_data_scene(C), CTX_data_view_layer(C), CTX_wm_view3d(C), filepath, ID_WS, idname);
if (appended_workspace) {
/* Set defaults. */

View File

@ -536,7 +536,7 @@ static int file_select_invoke(bContext *C, wmOperator *op, const wmEvent *event)
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_PARAMS, NULL);
}
WM_event_add_mousemove(C); /* for directory changes */
WM_event_add_mousemove(CTX_wm_window(C)); /* for directory changes */
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_PARAMS, NULL);
return OPERATOR_FINISHED;
@ -578,7 +578,8 @@ void FILE_OT_select(wmOperatorType *ot)
/**
* \returns true if selection has changed
*/
static bool file_walk_select_selection_set(bContext *C,
static bool file_walk_select_selection_set(wmWindow *win,
ARegion *ar,
SpaceFile *sfile,
const int direction,
const int numfiles,
@ -656,7 +657,7 @@ static bool file_walk_select_selection_set(bContext *C,
/* highlight file under mouse pos */
params->highlight_file = -1;
WM_event_add_mousemove(C);
WM_event_add_mousemove(win);
}
/* do the actual selection */
@ -686,7 +687,7 @@ static bool file_walk_select_selection_set(bContext *C,
fileselect_file_set(sfile, params->active_file);
/* ensure newly selected file is inside viewbounds */
file_ensure_inside_viewbounds(CTX_wm_region(C), sfile, params->active_file);
file_ensure_inside_viewbounds(ar, sfile, params->active_file);
/* selection changed */
return true;
@ -702,6 +703,8 @@ static bool file_walk_select_do(bContext *C,
const bool extend,
const bool fill)
{
wmWindow *win = CTX_wm_window(C);
ARegion *ar = CTX_wm_region(C);
struct FileList *files = sfile->files;
const int numfiles = filelist_files_ensure(files);
const bool has_selection = file_is_any_selected(files);
@ -717,7 +720,6 @@ static bool file_walk_select_do(bContext *C,
}
if (has_selection) {
ARegion *ar = CTX_wm_region(C);
FileLayout *layout = ED_fileselect_get_layout(sfile, ar);
const int idx_shift = (layout->flag & FILE_LAYOUT_HOR) ? layout->rows : layout->flow_columns;
@ -763,7 +765,8 @@ static bool file_walk_select_do(bContext *C,
}
}
return file_walk_select_selection_set(C,
return file_walk_select_selection_set(win,
ar,
sfile,
direction,
numfiles,
@ -867,7 +870,7 @@ static int file_select_all_exec(bContext *C, wmOperator *op)
}
file_draw_check(C);
WM_event_add_mousemove(C);
WM_event_add_mousemove(CTX_wm_window(C));
ED_area_tag_redraw(sa);
return OPERATOR_FINISHED;

View File

@ -2315,12 +2315,12 @@ static bool image_has_valid_path(Image *ima)
return strchr(ima->name, '\\') || strchr(ima->name, '/');
}
bool ED_image_should_save_modified(const bContext *C)
bool ED_image_should_save_modified(const Main *bmain)
{
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);
bool should_save = modified_images_count || !BLI_listbase_is_empty(&reports.list);
BKE_reports_clear(&reports);
@ -2328,9 +2328,8 @@ bool ED_image_should_save_modified(const bContext *C)
return should_save;
}
int ED_image_save_all_modified_info(const bContext *C, ReportList *reports)
int ED_image_save_all_modified_info(const Main *bmain, ReportList *reports)
{
Main *bmain = CTX_data_main(C);
GSet *unique_paths = BLI_gset_str_new(__func__);
int num_saveable_images = 0;
@ -2387,9 +2386,10 @@ int ED_image_save_all_modified_info(const bContext *C, ReportList *reports)
bool ED_image_save_all_modified(const bContext *C, ReportList *reports)
{
ED_image_save_all_modified_info(C, reports);
Main *bmain = CTX_data_main(C);
ED_image_save_all_modified_info(bmain, reports);
bool ok = true;
for (Image *ima = bmain->images.first; ima; ima = ima->id.next) {
@ -2417,7 +2417,7 @@ bool ED_image_save_all_modified(const bContext *C, ReportList *reports)
static bool image_save_all_modified_poll(bContext *C)
{
int num_files = ED_image_save_all_modified_info(C, NULL);
int num_files = ED_image_save_all_modified_info(CTX_data_main(C), NULL);
return num_files > 0;
}

View File

@ -381,7 +381,7 @@ static void view3d_smoothview_apply(bContext *C, View3D *v3d, ARegion *ar, bool
}
/* Event handling won't know if a UI item has been moved under the pointer. */
WM_event_add_mousemove(C);
WM_event_add_mousemove(CTX_wm_window(C));
}
if (sync_boxview && (rv3d->viewlock & RV3D_BOXVIEW)) {

View File

@ -389,7 +389,7 @@ static int ed_undo_exec(bContext *C, wmOperator *op)
int ret = ed_undo_step_direction(C, 1, op->reports);
if (ret & OPERATOR_FINISHED) {
/* Keep button under the cursor active. */
WM_event_add_mousemove(C);
WM_event_add_mousemove(CTX_wm_window(C));
}
ED_outliner_select_sync_from_all_tag(C);
@ -418,7 +418,7 @@ static int ed_redo_exec(bContext *C, wmOperator *op)
int ret = ed_undo_step_direction(C, -1, op->reports);
if (ret & OPERATOR_FINISHED) {
/* Keep button under the cursor active. */
WM_event_add_mousemove(C);
WM_event_add_mousemove(CTX_wm_window(C));
}
ED_outliner_select_sync_from_all_tag(C);
@ -432,7 +432,7 @@ static int ed_undo_redo_exec(bContext *C, wmOperator *UNUSED(op))
ret = ret ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
if (ret & OPERATOR_FINISHED) {
/* Keep button under the cursor active. */
WM_event_add_mousemove(C);
WM_event_add_mousemove(CTX_wm_window(C));
}
return ret;
}

View File

@ -83,9 +83,14 @@ static wmKeyMap *rna_keymap_active(wmKeyMap *km, bContext *C)
return WM_keymap_active(wm, km);
}
static void rna_keymap_restore_to_default(wmKeyMap *km, bContext *C)
{
WM_keymap_restore_to_default(km, CTX_wm_manager(C));
}
static void rna_keymap_restore_item_to_default(wmKeyMap *km, bContext *C, wmKeyMapItem *kmi)
{
WM_keymap_item_restore_to_default(C, km, kmi);
WM_keymap_item_restore_to_default(CTX_wm_manager(C), km, kmi);
}
static void rna_Operator_report(wmOperator *op, int type, const char *msg)
@ -1050,7 +1055,7 @@ void RNA_api_keymap(StructRNA *srna)
parm = RNA_def_pointer(func, "keymap", "KeyMap", "Key Map", "Active key map");
RNA_def_function_return(func, parm);
func = RNA_def_function(srna, "restore_to_default", "WM_keymap_restore_to_default");
func = RNA_def_function(srna, "restore_to_default", "rna_keymap_restore_to_default");
RNA_def_function_flag(func, FUNC_USE_CONTEXT);
func = RNA_def_function(srna, "restore_item_to_default", "rna_keymap_restore_item_to_default");

View File

@ -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);

View File

@ -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);

View File

@ -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;

View File

@ -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;

View File

@ -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);

View File

@ -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(&note->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(&note->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;
}
/** \} */

View File

@ -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);
}
/** \} */

View File

@ -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. */

View File

@ -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;

View File

@ -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:

View File

@ -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 */

View File

@ -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) {

View File

@ -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) {

View File

@ -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;
}
}

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);