Add operator to close a window
Useful for Python scripts, which could duplicate but not close windows.
This commit is contained in:
parent
0173116117
commit
8bcc68b21c
|
@ -2247,6 +2247,17 @@ static int wm_operator_winactive_normal(bContext *C)
|
|||
return 1;
|
||||
}
|
||||
|
||||
/* included for script-access */
|
||||
static void WM_OT_window_close(wmOperatorType *ot)
|
||||
{
|
||||
ot->name = "Close Window";
|
||||
ot->idname = "WM_OT_window_close";
|
||||
ot->description = "Close the current Blender window";
|
||||
|
||||
ot->exec = wm_window_close_exec;
|
||||
ot->poll = WM_operator_winactive;
|
||||
}
|
||||
|
||||
static void WM_OT_window_duplicate(wmOperatorType *ot)
|
||||
{
|
||||
ot->name = "Duplicate Window";
|
||||
|
@ -5250,6 +5261,7 @@ void wm_operatortype_init(void)
|
|||
/* reserve size is set based on blender default setup */
|
||||
global_ops_hash = BLI_ghash_str_new_ex("wm_operatortype_init gh", 2048);
|
||||
|
||||
WM_operatortype_append(WM_OT_window_close);
|
||||
WM_operatortype_append(WM_OT_window_duplicate);
|
||||
WM_operatortype_append(WM_OT_read_history);
|
||||
WM_operatortype_append(WM_OT_read_homefile);
|
||||
|
|
|
@ -712,6 +712,14 @@ wmWindow *WM_window_open_temp(bContext *C, const rcti *rect_init, int type)
|
|||
|
||||
/* ****************** Operators ****************** */
|
||||
|
||||
int wm_window_close_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
{
|
||||
wmWindowManager *wm = CTX_wm_manager(C);
|
||||
wmWindow *win = CTX_wm_window(C);
|
||||
wm_window_close(C, wm, win);
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
/* operator callback */
|
||||
int wm_window_duplicate_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
{
|
||||
|
|
|
@ -77,6 +77,7 @@ void wm_window_IME_end (wmWindow *win);
|
|||
#endif
|
||||
|
||||
/* *************** window operators ************** */
|
||||
int wm_window_close_exec(bContext *C, struct wmOperator *op);
|
||||
int wm_window_duplicate_exec(bContext *C, struct wmOperator *op);
|
||||
int wm_window_fullscreen_toggle_exec(bContext *C, struct wmOperator *op);
|
||||
|
||||
|
|
Loading…
Reference in New Issue