diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2018-09-27 15:51:33 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2018-09-27 15:51:33 +0300 |
commit | 4de1e673a411d14c5ab980d37cc3e1bb8b3d99ea (patch) | |
tree | f4f84a3813247e9b8ba07ade7fbce3e52fd4d48d /intern/ghost | |
parent | 1472550ba195a3278ee3eb2977515c2c3b62c9ce (diff) | |
parent | 8f9a6b1bab89b9af821b3996514af7de7c8cce7c (diff) |
Merge branch 'master' into blender2.8
Diffstat (limited to 'intern/ghost')
-rw-r--r-- | intern/ghost/GHOST_C-api.h | 5 | ||||
-rw-r--r-- | intern/ghost/GHOST_ISystem.h | 5 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_C-api.cpp | 6 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_System.cpp | 6 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_System.h | 6 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_SystemCocoa.mm | 12 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_WindowWin32.cpp | 9 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_WindowX11.cpp | 10 |
8 files changed, 49 insertions, 10 deletions
diff --git a/intern/ghost/GHOST_C-api.h b/intern/ghost/GHOST_C-api.h index a911c4560e4..1ce051d2660 100644 --- a/intern/ghost/GHOST_C-api.h +++ b/intern/ghost/GHOST_C-api.h @@ -940,6 +940,11 @@ extern int GHOST_SupportsNativeDialogs(void); extern int GHOST_UseNativePixels(void); /** + * Focus window after opening, or put them in the background. + */ +extern void GHOST_UseWindowFocus(int use_focus); + +/** * If window was opened using native pixel size, it returns scaling factor. */ extern float GHOST_GetNativePixelSize(GHOST_WindowHandle windowhandle); diff --git a/intern/ghost/GHOST_ISystem.h b/intern/ghost/GHOST_ISystem.h index 07273c40d17..42ae750e20a 100644 --- a/intern/ghost/GHOST_ISystem.h +++ b/intern/ghost/GHOST_ISystem.h @@ -321,6 +321,11 @@ public: */ virtual bool useNativePixel(void) = 0; + /** + * Focus window after opening, or put them in the background. + */ + virtual void useWindowFocus(const bool use_focus) = 0; + /*************************************************************************************** * Event management functionality ***************************************************************************************/ diff --git a/intern/ghost/intern/GHOST_C-api.cpp b/intern/ghost/intern/GHOST_C-api.cpp index 90956cf541a..ab0e7b724b8 100644 --- a/intern/ghost/intern/GHOST_C-api.cpp +++ b/intern/ghost/intern/GHOST_C-api.cpp @@ -939,6 +939,12 @@ int GHOST_UseNativePixels(void) return system->useNativePixel(); } +void GHOST_UseWindowFocus(int use_focus) +{ + GHOST_ISystem *system = GHOST_ISystem::getSystem(); + return system->useWindowFocus(use_focus); +} + float GHOST_GetNativePixelSize(GHOST_WindowHandle windowhandle) { GHOST_IWindow *window = (GHOST_IWindow *) windowhandle; diff --git a/intern/ghost/intern/GHOST_System.cpp b/intern/ghost/intern/GHOST_System.cpp index 4a8a8c48018..fc69900acdf 100644 --- a/intern/ghost/intern/GHOST_System.cpp +++ b/intern/ghost/intern/GHOST_System.cpp @@ -48,6 +48,7 @@ GHOST_System::GHOST_System() : m_nativePixel(false), + m_windowFocus(true), m_displayManager(NULL), m_timerManager(NULL), m_windowManager(NULL), @@ -394,3 +395,8 @@ bool GHOST_System::useNativePixel(void) m_nativePixel = true; return 1; } + +void GHOST_System::useWindowFocus(const bool use_focus) +{ + m_windowFocus = use_focus; +} diff --git a/intern/ghost/intern/GHOST_System.h b/intern/ghost/intern/GHOST_System.h index 464d9269f28..ee3c30c35b4 100644 --- a/intern/ghost/intern/GHOST_System.h +++ b/intern/ghost/intern/GHOST_System.h @@ -177,6 +177,12 @@ public: bool useNativePixel(void); bool m_nativePixel; + /** + * Focus window after opening, or put them in the background. + */ + void useWindowFocus(const bool use_focus); + bool m_windowFocus; + /*************************************************************************************** * Event management functionality ***************************************************************************************/ diff --git a/intern/ghost/intern/GHOST_SystemCocoa.mm b/intern/ghost/intern/GHOST_SystemCocoa.mm index 43ed30bd415..8672e298fe2 100644 --- a/intern/ghost/intern/GHOST_SystemCocoa.mm +++ b/intern/ghost/intern/GHOST_SystemCocoa.mm @@ -309,11 +309,13 @@ extern "C" int GHOST_HACK_getFirstFile(char buf[FIRSTFILEBUFLG]) - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { - // raise application to front, convenient when starting from the terminal - // and important for launching the animation player. we call this after the - // application finishes launching, as doing it earlier can make us end up - // with a frontmost window but an inactive application - [NSApp activateIgnoringOtherApps:YES]; + if (systemCocoa->m_windowFocus) { + // Raise application to front, convenient when starting from the terminal + // and important for launching the animation player. we call this after the + // application finishes launching, as doing it earlier can make us end up + // with a frontmost window but an inactive application. + [NSApp activateIgnoringOtherApps:YES]; + } } - (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filename diff --git a/intern/ghost/intern/GHOST_WindowWin32.cpp b/intern/ghost/intern/GHOST_WindowWin32.cpp index 70edc66d570..c2aaa018609 100644 --- a/intern/ghost/intern/GHOST_WindowWin32.cpp +++ b/intern/ghost/intern/GHOST_WindowWin32.cpp @@ -201,6 +201,11 @@ GHOST_WindowWin32::GHOST_WindowWin32(GHOST_SystemWin32 *system, // Store a pointer to this class in the window structure ::SetWindowLongPtr(m_hWnd, GWLP_USERDATA, (LONG_PTR) this); + if (!m_system->m_windowFocus) { + // Lower to bottom and don't activate if we don't want focus + ::SetWindowPos(m_hWnd, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); + } + // Store the device context m_hDC = ::GetDC(m_hWnd); @@ -214,11 +219,11 @@ GHOST_WindowWin32::GHOST_WindowWin32(GHOST_SystemWin32 *system, nCmdShow = SW_SHOWMAXIMIZED; break; case GHOST_kWindowStateMinimized: - nCmdShow = SW_SHOWMINIMIZED; + nCmdShow = (m_system->m_windowFocus) ? SW_SHOWMINIMIZED : SW_SHOWMINNOACTIVE; break; case GHOST_kWindowStateNormal: default: - nCmdShow = SW_SHOWNORMAL; + nCmdShow = (m_system->m_windowFocus) ? SW_SHOWNORMAL : SW_SHOWNOACTIVATE; break; } diff --git a/intern/ghost/intern/GHOST_WindowX11.cpp b/intern/ghost/intern/GHOST_WindowX11.cpp index 11aa2094997..01b4991ec72 100644 --- a/intern/ghost/intern/GHOST_WindowX11.cpp +++ b/intern/ghost/intern/GHOST_WindowX11.cpp @@ -517,7 +517,7 @@ GHOST_WindowX11(GHOST_SystemX11 *system, natom++; } - if (m_system->m_atom.WM_TAKE_FOCUS) { + if (m_system->m_atom.WM_TAKE_FOCUS && m_system->m_windowFocus) { atoms[natom] = m_system->m_atom.WM_TAKE_FOCUS; natom++; } @@ -532,7 +532,7 @@ GHOST_WindowX11(GHOST_SystemX11 *system, { XWMHints *xwmhints = XAllocWMHints(); xwmhints->initial_state = NormalState; - xwmhints->input = True; + xwmhints->input = (m_system->m_windowFocus) ? True : False; xwmhints->flags = InputHint | StateHint; XSetWMHints(display, m_window, xwmhints); XFree(xwmhints); @@ -586,11 +586,15 @@ GHOST_WindowX11(GHOST_SystemX11 *system, setTitle(title); - if (exclusive) { + if (exclusive && system->m_windowFocus) { XMapRaised(m_display, m_window); } else { XMapWindow(m_display, m_window); + + if (!system->m_windowFocus) { + XLowerWindow(m_display, m_window); + } } GHOST_PRINT("Mapped window\n"); |