From e776ecfddec846b50b6bbd86f2ea56d159b6f237 Mon Sep 17 00:00:00 2001 From: Martin Poirier Date: Wed, 11 Nov 2009 04:08:09 +0000 Subject: Background mode in more working conditions. What works: The usual command line options for rendering. All python scripts are loaded (which includes custom properties) Render engines are loaded and can be used -P to run scripts works partially: rna api works ok, not operators. What doesn't: Most operator calls in python. This is a problem with poll functions. (Brecht and Campbell are aware of this already) Changes: -d now also applied with -b (it was ignored before) user file (.B25.blend) now also loaded in bg mode. This helps for custom paths and all. wm is also initialized (it's needed for a lot of context calls) Ghost, however, is not initialized. --- source/blender/windowmanager/WM_api.h | 3 +++ source/blender/windowmanager/intern/wm.c | 31 ++++++++++++---------- source/blender/windowmanager/intern/wm_files.c | 6 ++--- source/blender/windowmanager/intern/wm_init_exit.c | 14 ++++++---- source/blender/windowmanager/intern/wm_window.c | 8 +++--- source/blender/windowmanager/wm.h | 1 - 6 files changed, 36 insertions(+), 27 deletions(-) (limited to 'source/blender/windowmanager') diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index f9732b9c929..a784a1d560a 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -52,6 +52,9 @@ void WM_init (struct bContext *C); void WM_exit (struct bContext *C); void WM_main (struct bContext *C); + +void WM_check (struct bContext *C); + struct wmWindow *WM_window_open (struct bContext *C, struct rcti *rect); /* defines for 'type' WM_window_open_temp */ diff --git a/source/blender/windowmanager/intern/wm.c b/source/blender/windowmanager/intern/wm.c index 1d173005d85..d455c8b2bc1 100644 --- a/source/blender/windowmanager/intern/wm.c +++ b/source/blender/windowmanager/intern/wm.c @@ -43,6 +43,7 @@ #include "BKE_main.h" #include "BKE_screen.h" #include "BKE_report.h" +#include "BKE_global.h" #include "WM_api.h" #include "WM_types.h" @@ -196,7 +197,7 @@ void WM_keymap_init(bContext *C) WM_keyconfig_userdef(wm); } -void wm_check(bContext *C) +void WM_check(bContext *C) { wmWindowManager *wm= CTX_wm_manager(C); @@ -208,19 +209,21 @@ void wm_check(bContext *C) if(wm==NULL) return; if(wm->windows.first==NULL) return; - /* case: fileread */ - if((wm->initialized & WM_INIT_WINDOW) == 0) { - WM_keymap_init(C); - WM_autosave_init(C); - } - - /* case: no open windows at all, for old file reads */ - wm_window_add_ghostwindows(wm); - - /* case: fileread */ - if((wm->initialized & WM_INIT_WINDOW) == 0) { - ED_screens_initialize(wm); - wm->initialized |= WM_INIT_WINDOW; + if (!G.background) { + /* case: fileread */ + if((wm->initialized & WM_INIT_WINDOW) == 0) { + WM_keymap_init(C); + WM_autosave_init(C); + } + + /* case: no open windows at all, for old file reads */ + wm_window_add_ghostwindows(wm); + + /* case: fileread */ + if((wm->initialized & WM_INIT_WINDOW) == 0) { + ED_screens_initialize(wm); + wm->initialized |= WM_INIT_WINDOW; + } } } diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c index b2e55c8532e..79c718ea5d6 100644 --- a/source/blender/windowmanager/intern/wm_files.c +++ b/source/blender/windowmanager/intern/wm_files.c @@ -256,8 +256,8 @@ void WM_read_file(bContext *C, char *name, ReportList *reports) G.save_over = 1; /* match the read WM with current WM */ - wm_window_match_do(C, &wmbase); - wm_check(C); /* opens window(s), checks keymaps */ + wm_window_match_do(C, &wmbase); + WM_check(C); /* opens window(s), checks keymaps */ // XXX mainwindow_set_filename_to_title(G.main->name); @@ -322,7 +322,7 @@ int WM_read_homefile(bContext *C, wmOperator *op) /* match the read WM with current WM */ wm_window_match_do(C, &wmbase); - wm_check(C); /* opens window(s), checks keymaps */ + WM_check(C); /* opens window(s), checks keymaps */ strcpy(G.sce, scestr); /* restore */ diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c index 8097822acbc..06227086006 100644 --- a/source/blender/windowmanager/intern/wm_init_exit.c +++ b/source/blender/windowmanager/intern/wm_init_exit.c @@ -108,8 +108,10 @@ static void wm_free_reports(bContext *C) void WM_init(bContext *C) { - wm_ghost_init(C); /* note: it assigns C to ghost! */ - wm_init_cursor_data(); + if (!G.background) { + wm_ghost_init(C); /* note: it assigns C to ghost! */ + wm_init_cursor_data(); + } wm_operatortype_init(); set_free_windowmanager_cb(wm_close_and_free); /* library.c */ @@ -130,10 +132,12 @@ void WM_init(bContext *C) WM_read_homefile(C, NULL); wm_init_reports(C); /* reports cant be initialized before the wm */ - - GPU_extensions_init(); - UI_init(); + if (!G.background) { + GPU_extensions_init(); + + UI_init(); + } // clear_matcopybuf(); /* XXX */ diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c index 70d40df4532..ae6d9ddb425 100644 --- a/source/blender/windowmanager/intern/wm_window.c +++ b/source/blender/windowmanager/intern/wm_window.c @@ -335,7 +335,7 @@ static void wm_window_add_ghostwindow(wmWindowManager *wm, char *title, wmWindow /* for wmWindows without ghostwin, open these and clear */ /* window size is read from window, if 0 it uses prefsize */ -/* called in wm_check, also inits stuff after file read */ +/* called in WM_check, also inits stuff after file read */ void wm_window_add_ghostwindows(wmWindowManager *wm) { wmKeyMap *keymap; @@ -403,7 +403,7 @@ wmWindow *WM_window_open(bContext *C, rcti *rect) win->drawmethod= -1; win->drawdata= NULL; - wm_check(C); + WM_check(C); return win; } @@ -448,7 +448,7 @@ void WM_window_open_temp(bContext *C, rcti *position, int type) /* make window active, and validate/resize */ CTX_wm_window_set(C, win); - wm_check(C); + WM_check(C); /* ensure it shows the right spacetype editor */ sa= win->screen->areabase.first; @@ -480,7 +480,7 @@ void WM_window_open_temp(bContext *C, rcti *position, int type) int wm_window_duplicate_op(bContext *C, wmOperator *op) { wm_window_copy(C, CTX_wm_window(C)); - wm_check(C); + WM_check(C); return OPERATOR_FINISHED; } diff --git a/source/blender/windowmanager/wm.h b/source/blender/windowmanager/wm.h index c476b7efa1e..9b888a0e347 100644 --- a/source/blender/windowmanager/wm.h +++ b/source/blender/windowmanager/wm.h @@ -44,7 +44,6 @@ extern void wm_close_and_free(bContext *C, wmWindowManager *); extern void wm_close_and_free_all(bContext *C, ListBase *); extern void wm_add_default(bContext *C); -extern void wm_check(bContext *C); extern void wm_clear_default_size(bContext *C); /* register to windowmanager for redo or macro */ -- cgit v1.2.3