OLD | NEW |
---|---|
(Empty) | |
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. | |
4 | |
5 #include "ui/views/win/scoped_fullscreen_visibility.h" | |
6 | |
7 #include "base/logging.h" | |
8 | |
9 namespace views { | |
10 | |
11 // static | |
12 std::map<HWND, int>* ScopedFullscreenVisibility::full_screen_windows_ = NULL; | |
13 | |
14 ScopedFullscreenVisibility::ScopedFullscreenVisibility(HWND hwnd) | |
15 : 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()) { | |
20 it->second++; | |
21 } else { | |
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); | |
30 } | |
31 } | |
32 | |
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); | |
sky
2012/08/22 19:13:47
nit: if (full_screen_windows_->empty()) {
delete
| |
39 } | |
40 } | |
41 | |
42 // static | |
43 bool ScopedFullscreenVisibility::IsHiddenForFullscreen(HWND hwnd) { | |
44 if (!full_screen_windows_) | |
45 return false; | |
46 return full_screen_windows_->find(hwnd) != full_screen_windows_->end(); | |
47 } | |
48 | |
49 } // namespace views | |
OLD | NEW |