diff options
author | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2016-12-19 22:37:24 +0100 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2016-12-20 10:54:53 +0000 |
commit | 081267ebaacb38c564b36bb3e2576bf22d52b3e5 (patch) | |
tree | defc1e8da4213a3ed5015e5dcde388cab3c5365c /vcl/win/window | |
parent | 9a017238082f73ca2015f571804f35928db1f38c (diff) |
try to avoid the annoying focus stealing on windows
Change-Id: Ic6d3492a4707f24b616a7dee34a111ba0af4f281
Reviewed-on: https://gerrit.libreoffice.org/32207
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
Diffstat (limited to 'vcl/win/window')
-rw-r--r-- | vcl/win/window/salframe.cxx | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/vcl/win/window/salframe.cxx b/vcl/win/window/salframe.cxx index 424e58807cd9..689a69c0699c 100644 --- a/vcl/win/window/salframe.cxx +++ b/vcl/win/window/salframe.cxx @@ -827,6 +827,17 @@ static void ImplSalFrameFullScreenPos( WinSalFrame* pFrame, bool bAlways = FALSE } } +namespace { + +void SetForegroundWindow_Impl(HWND hwnd) +{ + static bool bUseForegroundWindow = !std::getenv("VCL_HIDE_WINDOWS"); + if (bUseForegroundWindow) + SetForegroundWindow(hwnd); +} + +} + WinSalFrame::WinSalFrame() { SalData* pSalData = GetSalData(); @@ -1179,8 +1190,8 @@ static void ImplSalShow( HWND hWnd, bool bVisible, bool bNoActivate ) { HWND hWndParent = ::GetParent( hWnd ); if ( hWndParent ) - SetForegroundWindow( hWndParent ); - SetForegroundWindow( hWnd ); + SetForegroundWindow_Impl( hWndParent ); + SetForegroundWindow_Impl( hWnd ); } pFrame->mbInShow = FALSE; @@ -1977,7 +1988,7 @@ static void ImplSalToTop( HWND hWnd, SalFrameToTop nFlags ) DWORD myThreadID = GetCurrentThreadId(); DWORD currThreadID = GetWindowThreadProcessId(hCurrWnd,nullptr); AttachThreadInput(myThreadID, currThreadID,TRUE); - SetForegroundWindow(hWnd); + SetForegroundWindow_Impl(hWnd); AttachThreadInput(myThreadID,currThreadID,FALSE); } @@ -2011,7 +2022,7 @@ static void ImplSalToTop( HWND hWnd, SalFrameToTop nFlags ) // Windows sometimes incorrectly reports to have the focus; // thus make sure to really get the focus if ( ::GetFocus() == hWnd ) - SetForegroundWindow( hWnd ); + SetForegroundWindow_Impl( hWnd ); } } |