OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ui/aura_shell/window_util.h" | 5 #include "ui/aura_shell/window_util.h" |
6 | 6 |
7 #include "ui/aura/client/activation_client.h" | 7 #include "ui/aura/client/activation_client.h" |
8 #include "ui/aura/client/aura_constants.h" | 8 #include "ui/aura/client/aura_constants.h" |
9 #include "ui/aura/root_window.h" | 9 #include "ui/aura/root_window.h" |
10 #include "ui/aura/window.h" | 10 #include "ui/aura/window.h" |
11 #include "ui/aura_shell/activation_controller.h" | 11 #include "ui/aura_shell/activation_controller.h" |
| 12 #include "ui/aura_shell/property_util.h" |
12 #include "ui/base/ui_base_types.h" | 13 #include "ui/base/ui_base_types.h" |
| 14 #include "ui/gfx/screen.h" |
13 | 15 |
14 namespace aura_shell { | 16 namespace aura_shell { |
15 | 17 |
16 bool IsWindowMaximized(aura::Window* window) { | 18 bool IsWindowMaximized(aura::Window* window) { |
17 return window->GetIntProperty(aura::kShowStateKey) == | 19 return window->GetIntProperty(aura::kShowStateKey) == |
18 ui::SHOW_STATE_MAXIMIZED; | 20 ui::SHOW_STATE_MAXIMIZED; |
19 } | 21 } |
20 | 22 |
21 void ActivateWindow(aura::Window* window) { | 23 void ActivateWindow(aura::Window* window) { |
22 aura::ActivationClient::GetActivationClient()->ActivateWindow(window); | 24 aura::ActivationClient::GetActivationClient()->ActivateWindow(window); |
23 } | 25 } |
24 | 26 |
25 void DeactivateWindow(aura::Window* window) { | 27 void DeactivateWindow(aura::Window* window) { |
26 aura::ActivationClient::GetActivationClient()->DeactivateWindow(window); | 28 aura::ActivationClient::GetActivationClient()->DeactivateWindow(window); |
27 } | 29 } |
28 | 30 |
29 bool IsActiveWindow(aura::Window* window) { | 31 bool IsActiveWindow(aura::Window* window) { |
30 return GetActiveWindow() == window; | 32 return GetActiveWindow() == window; |
31 } | 33 } |
32 | 34 |
33 aura::Window* GetActiveWindow() { | 35 aura::Window* GetActiveWindow() { |
34 return aura::ActivationClient::GetActivationClient()->GetActiveWindow(); | 36 return aura::ActivationClient::GetActivationClient()->GetActiveWindow(); |
35 } | 37 } |
36 | 38 |
37 aura::Window* GetActivatableWindow(aura::Window* window) { | 39 aura::Window* GetActivatableWindow(aura::Window* window) { |
38 return internal::ActivationController::GetActivatableWindow(window); | 40 return internal::ActivationController::GetActivatableWindow(window); |
39 } | 41 } |
40 | 42 |
| 43 void UpdateBoundsFromShowState(aura::Window* window) { |
| 44 switch (window->GetIntProperty(aura::kShowStateKey)) { |
| 45 case ui::SHOW_STATE_NORMAL: { |
| 46 const gfx::Rect* restore = GetRestoreBounds(window); |
| 47 window->SetProperty(aura::kRestoreBoundsKey, NULL); |
| 48 if (restore) |
| 49 window->SetBounds(*restore); |
| 50 delete restore; |
| 51 break; |
| 52 } |
| 53 |
| 54 case ui::SHOW_STATE_MAXIMIZED: |
| 55 SetRestoreBoundsIfNotSet(window); |
| 56 window->SetBounds(gfx::Screen::GetMonitorWorkAreaNearestWindow(window)); |
| 57 break; |
| 58 |
| 59 case ui::SHOW_STATE_FULLSCREEN: |
| 60 SetRestoreBoundsIfNotSet(window); |
| 61 window->SetBounds(gfx::Screen::GetMonitorAreaNearestWindow(window)); |
| 62 break; |
| 63 |
| 64 default: |
| 65 break; |
| 66 } |
| 67 } |
| 68 |
41 } // namespace aura_shell | 69 } // namespace aura_shell |
OLD | NEW |