diff options
author | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2018-04-10 11:32:56 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2018-09-27 13:21:48 +0300 |
commit | 2a63e062b0e71c291d57aa155d9462f68fed8535 (patch) | |
tree | 021ccbd04fb17caf169c7f98430caf431c1fbd87 /source | |
parent | 09c7bfe42b4da7db26888999fda5eb1f53f8ce3c (diff) |
Tests: add --no-window-focus to open window without focus.
This is useful to run OpenGL tests while continuing to do other tasks
without windows constantly popping up in the foreground.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/windowmanager/WM_api.h | 1 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_window.c | 14 | ||||
-rw-r--r-- | source/creator/creator_args.c | 11 |
3 files changed, 24 insertions, 2 deletions
diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index 33e918b25e5..2ff416c0ba6 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -78,6 +78,7 @@ const char *WM_init_state_app_template_get(void); void WM_init_state_size_set (int stax, int stay, int sizx, int sizy); void WM_init_state_fullscreen_set(void); void WM_init_state_normal_set(void); +void WM_init_window_focus_set(bool do_it); void WM_init_native_pixels(bool do_it); void WM_init (struct bContext *C, int argc, const char **argv); diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c index d74657d0c15..04a236e5d66 100644 --- a/source/blender/windowmanager/intern/wm_window.c +++ b/source/blender/windowmanager/intern/wm_window.c @@ -102,8 +102,9 @@ static struct WMInitStruct { int windowstate; WinOverrideFlag override_flag; + bool window_focus; bool native_pixels; -} wm_init_state = {0, 0, 0, 0, GHOST_kWindowStateNormal, 0, true}; +} wm_init_state = {0, 0, 0, 0, GHOST_kWindowStateNormal, 0, true, true}; /* ******** win open & close ************ */ @@ -624,7 +625,9 @@ static void wm_window_ghostwindow_add(wmWindowManager *wm, const char *title, wm #ifndef __APPLE__ /* set the state here, so minimized state comes up correct on windows */ - GHOST_SetWindowState(ghostwin, (GHOST_TWindowState)win->windowstate); + if (wm_init_state.window_focus) { + GHOST_SetWindowState(ghostwin, (GHOST_TWindowState)win->windowstate); + } #endif /* until screens get drawn, make it nice gray */ glClearColor(0.55, 0.55, 0.55, 0.0); @@ -1546,6 +1549,8 @@ void wm_ghost_init(bContext *C) if (wm_init_state.native_pixels) { GHOST_UseNativePixels(); } + + GHOST_UseWindowFocus(wm_init_state.window_focus); } } @@ -1832,6 +1837,11 @@ void WM_init_state_normal_set(void) wm_init_state.override_flag |= WIN_OVERRIDE_WINSTATE; } +void WM_init_window_focus_set(bool do_it) +{ + wm_init_state.window_focus = do_it; +} + void WM_init_native_pixels(bool do_it) { wm_init_state.native_pixels = do_it; diff --git a/source/creator/creator_args.c b/source/creator/creator_args.c index acb03efb895..f8fe57b05a2 100644 --- a/source/creator/creator_args.c +++ b/source/creator/creator_args.c @@ -514,6 +514,7 @@ static int arg_handle_print_help(int UNUSED(argc), const char **UNUSED(argv), vo BLI_argsPrintArgDoc(ba, "--window-geometry"); BLI_argsPrintArgDoc(ba, "--start-console"); BLI_argsPrintArgDoc(ba, "--no-native-pixels"); + BLI_argsPrintArgDoc(ba, "--no-window-focus"); printf("\n"); @@ -1134,6 +1135,15 @@ static int arg_handle_without_borders(int UNUSED(argc), const char **UNUSED(argv return 0; } +static const char arg_handle_no_window_focus_doc[] = +"\n\tOpen behind other windows and without taking focus." +; +static int arg_handle_no_window_focus(int UNUSED(argc), const char **UNUSED(argv), void *UNUSED(data)) +{ + WM_init_window_focus_set(false); + return 0; +} + extern bool wm_start_with_console; /* wm_init_exit.c */ static const char arg_handle_start_with_console_doc[] = @@ -2072,6 +2082,7 @@ void main_args_setup(bContext *C, bArgs *ba, SYS_SystemHandle *syshandle) BLI_argsAdd(ba, 2, "-p", "--window-geometry", CB(arg_handle_window_geometry), NULL); BLI_argsAdd(ba, 2, "-w", "--window-border", CB(arg_handle_with_borders), NULL); BLI_argsAdd(ba, 2, "-W", "--window-fullscreen", CB(arg_handle_without_borders), NULL); + BLI_argsAdd(ba, 2, NULL, "--no-window-focus", CB(arg_handle_no_window_focus), NULL); BLI_argsAdd(ba, 2, "-con", "--start-console", CB(arg_handle_start_with_console), NULL); BLI_argsAdd(ba, 2, "-R", NULL, CB(arg_handle_register_extension), NULL); BLI_argsAdd(ba, 2, "-r", NULL, CB_EX(arg_handle_register_extension, silent), ba); |