1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "ui/views/win/scoped_fullscreen_visibility.h"
7 #include "base/logging.h"
12 std::map
<HWND
, int>* ScopedFullscreenVisibility::full_screen_windows_
= NULL
;
14 ScopedFullscreenVisibility::ScopedFullscreenVisibility(HWND hwnd
)
16 if (!full_screen_windows_
)
17 full_screen_windows_
= new FullscreenHWNDs
;
18 FullscreenHWNDs::iterator it
= full_screen_windows_
->find(hwnd_
);
19 if (it
!= full_screen_windows_
->end()) {
22 full_screen_windows_
->insert(std::make_pair(hwnd_
, 1));
23 // NOTE: Be careful not to activate any windows here (for example, calling
24 // ShowWindow(SW_HIDE) will automatically activate another window). This
25 // code can be called while a window is being deactivated, and activating
26 // another window will screw up the activation that is already in progress.
27 SetWindowPos(hwnd_
, NULL
, 0, 0, 0, 0,
28 SWP_HIDEWINDOW
| SWP_NOACTIVATE
| SWP_NOMOVE
|
29 SWP_NOREPOSITION
| SWP_NOSIZE
| SWP_NOZORDER
);
33 ScopedFullscreenVisibility::~ScopedFullscreenVisibility() {
34 FullscreenHWNDs::iterator it
= full_screen_windows_
->find(hwnd_
);
35 DCHECK(it
!= full_screen_windows_
->end());
36 if (--it
->second
== 0) {
37 full_screen_windows_
->erase(it
);
38 ShowWindow(hwnd_
, SW_SHOW
);
40 if (full_screen_windows_
->empty()) {
41 delete full_screen_windows_
;
42 full_screen_windows_
= NULL
;
47 bool ScopedFullscreenVisibility::IsHiddenForFullscreen(HWND hwnd
) {
48 if (!full_screen_windows_
)
50 return full_screen_windows_
->find(hwnd
) != full_screen_windows_
->end();