| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 "ash/wm/window_util.h" | 5 #include "ash/wm/window_util.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "ash/ash_constants.h" | 9 #include "ash/ash_constants.h" |
| 10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
| 11 #include "ash/wm/activation_controller.h" | 11 #include "ash/wm/activation_controller.h" |
| 12 #include "ash/wm/window_properties.h" | 12 #include "ash/wm/window_properties.h" |
| 13 #include "ui/aura/client/activation_client.h" | 13 #include "ui/aura/client/activation_client.h" |
| 14 #include "ui/aura/client/aura_constants.h" | 14 #include "ui/aura/client/aura_constants.h" |
| 15 #include "ui/aura/root_window.h" | 15 #include "ui/aura/root_window.h" |
| 16 #include "ui/aura/window.h" | 16 #include "ui/aura/window.h" |
| 17 #include "ui/aura/window_delegate.h" | 17 #include "ui/aura/window_delegate.h" |
| 18 #include "ui/compositor/layer.h" | 18 #include "ui/compositor/layer.h" |
| 19 #include "ui/gfx/display.h" | 19 #include "ui/gfx/display.h" |
| 20 #include "ui/gfx/rect.h" | 20 #include "ui/gfx/rect.h" |
| 21 #include "ui/gfx/screen.h" | 21 #include "ui/gfx/screen.h" |
| 22 #include "ui/views/corewm/window_util.h" |
| 22 | 23 |
| 23 namespace ash { | 24 namespace ash { |
| 24 namespace wm { | 25 namespace wm { |
| 25 | 26 |
| 27 // TODO(beng): replace many of these functions with the corewm versions. |
| 26 void ActivateWindow(aura::Window* window) { | 28 void ActivateWindow(aura::Window* window) { |
| 27 DCHECK(window); | 29 views::corewm::ActivateWindow(window); |
| 28 DCHECK(window->GetRootWindow()); | |
| 29 aura::client::GetActivationClient(window->GetRootWindow())->ActivateWindow( | |
| 30 window); | |
| 31 } | 30 } |
| 32 | 31 |
| 33 void DeactivateWindow(aura::Window* window) { | 32 void DeactivateWindow(aura::Window* window) { |
| 34 DCHECK(window); | 33 views::corewm::DeactivateWindow(window); |
| 35 DCHECK(window->GetRootWindow()); | |
| 36 aura::client::GetActivationClient(window->GetRootWindow())->DeactivateWindow( | |
| 37 window); | |
| 38 } | 34 } |
| 39 | 35 |
| 40 bool IsActiveWindow(aura::Window* window) { | 36 bool IsActiveWindow(aura::Window* window) { |
| 41 DCHECK(window); | 37 return views::corewm::IsActiveWindow(window); |
| 42 if (!window->GetRootWindow()) | |
| 43 return false; | |
| 44 aura::client::ActivationClient* client = | |
| 45 aura::client::GetActivationClient(window->GetRootWindow()); | |
| 46 return client && client->GetActiveWindow() == window; | |
| 47 } | 38 } |
| 48 | 39 |
| 49 aura::Window* GetActiveWindow() { | 40 aura::Window* GetActiveWindow() { |
| 50 return aura::client::GetActivationClient(Shell::GetPrimaryRootWindow())-> | 41 return aura::client::GetActivationClient(Shell::GetPrimaryRootWindow())-> |
| 51 GetActiveWindow(); | 42 GetActiveWindow(); |
| 52 } | 43 } |
| 53 | 44 |
| 54 aura::Window* GetActivatableWindow(aura::Window* window) { | 45 aura::Window* GetActivatableWindow(aura::Window* window) { |
| 55 return internal::ActivationController::GetActivatableWindow(window, NULL); | 46 return views::corewm::GetActivatableWindow(window); |
| 56 } | 47 } |
| 57 | 48 |
| 58 bool IsActiveWindowFullscreen() { | 49 bool IsActiveWindowFullscreen() { |
| 59 aura::Window* window = GetActiveWindow(); | 50 aura::Window* window = GetActiveWindow(); |
| 60 while (window) { | 51 while (window) { |
| 61 if (window->GetProperty(aura::client::kShowStateKey) == | 52 if (window->GetProperty(aura::client::kShowStateKey) == |
| 62 ui::SHOW_STATE_FULLSCREEN) { | 53 ui::SHOW_STATE_FULLSCREEN) { |
| 63 return true; | 54 return true; |
| 64 } | 55 } |
| 65 window = window->parent(); | 56 window = window->parent(); |
| 66 } | 57 } |
| 67 return false; | 58 return false; |
| 68 } | 59 } |
| 69 | 60 |
| 70 bool CanActivateWindow(aura::Window* window) { | 61 bool CanActivateWindow(aura::Window* window) { |
| 71 DCHECK(window); | 62 return views::corewm::CanActivateWindow(window); |
| 72 if (!window->GetRootWindow()) | |
| 73 return false; | |
| 74 aura::client::ActivationClient* client = | |
| 75 aura::client::GetActivationClient(window->GetRootWindow()); | |
| 76 return client && client->CanActivateWindow(window); | |
| 77 } | 63 } |
| 78 | 64 |
| 79 bool CanMaximizeWindow(const aura::Window* window) { | 65 bool CanMaximizeWindow(const aura::Window* window) { |
| 80 return window->GetProperty(aura::client::kCanMaximizeKey); | 66 return window->GetProperty(aura::client::kCanMaximizeKey); |
| 81 } | 67 } |
| 82 | 68 |
| 83 bool CanResizeWindow(const aura::Window* window) { | 69 bool CanResizeWindow(const aura::Window* window) { |
| 84 return window->GetProperty(aura::client::kCanResizeKey); | 70 return window->GetProperty(aura::client::kCanResizeKey); |
| 85 } | 71 } |
| 86 | 72 |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 x_offset = work_area.right() - bounds->x() - kMinimumOnScreenArea; | 171 x_offset = work_area.right() - bounds->x() - kMinimumOnScreenArea; |
| 186 } else if (bounds->right() < work_area.x()) { | 172 } else if (bounds->right() < work_area.x()) { |
| 187 x_offset = work_area.x() - bounds->right() + kMinimumOnScreenArea; | 173 x_offset = work_area.x() - bounds->right() + kMinimumOnScreenArea; |
| 188 } | 174 } |
| 189 bounds->Offset(x_offset, y_offset); | 175 bounds->Offset(x_offset, y_offset); |
| 190 } | 176 } |
| 191 } | 177 } |
| 192 | 178 |
| 193 } // namespace wm | 179 } // namespace wm |
| 194 } // namespace ash | 180 } // namespace ash |
| OLD | NEW |