Sort unlaunched apps on app list start page by apps grid order.
[chromium-blink-merge.git] / ui / views / win / scoped_fullscreen_visibility.cc
blobb6fd33f1d7f8c6f6312e550754b391812ffbb211
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"
9 namespace views {
11 // static
12 std::map<HWND, int>* ScopedFullscreenVisibility::full_screen_windows_ = NULL;
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);
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;
46 // static
47 bool ScopedFullscreenVisibility::IsHiddenForFullscreen(HWND hwnd) {
48 if (!full_screen_windows_)
49 return false;
50 return full_screen_windows_->find(hwnd) != full_screen_windows_->end();
53 } // namespace views