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/compositor/layer.h" | 18 #include "ui/compositor/layer.h" |
18 #include "ui/gfx/display.h" | 19 #include "ui/gfx/display.h" |
19 #include "ui/gfx/rect.h" | 20 #include "ui/gfx/rect.h" |
20 #include "ui/gfx/screen.h" | 21 #include "ui/gfx/screen.h" |
21 | 22 |
22 namespace ash { | 23 namespace ash { |
23 namespace wm { | 24 namespace wm { |
24 | 25 |
25 void ActivateWindow(aura::Window* window) { | 26 void ActivateWindow(aura::Window* window) { |
26 DCHECK(window); | 27 DCHECK(window); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 } | 77 } |
77 | 78 |
78 bool CanMaximizeWindow(const aura::Window* window) { | 79 bool CanMaximizeWindow(const aura::Window* window) { |
79 return window->GetProperty(aura::client::kCanMaximizeKey); | 80 return window->GetProperty(aura::client::kCanMaximizeKey); |
80 } | 81 } |
81 | 82 |
82 bool CanResizeWindow(const aura::Window* window) { | 83 bool CanResizeWindow(const aura::Window* window) { |
83 return window->GetProperty(aura::client::kCanResizeKey); | 84 return window->GetProperty(aura::client::kCanResizeKey); |
84 } | 85 } |
85 | 86 |
| 87 bool CanSnapWindow(aura::Window* window) { |
| 88 // If a window has a maximum size defined, snapping may make it too big. |
| 89 return window->delegate()->GetMaximumSize().IsEmpty(); |
| 90 } |
| 91 |
86 bool IsWindowNormal(const aura::Window* window) { | 92 bool IsWindowNormal(const aura::Window* window) { |
87 return IsWindowStateNormal(window->GetProperty(aura::client::kShowStateKey)); | 93 return IsWindowStateNormal(window->GetProperty(aura::client::kShowStateKey)); |
88 } | 94 } |
89 | 95 |
90 bool IsWindowStateNormal(ui::WindowShowState state) { | 96 bool IsWindowStateNormal(ui::WindowShowState state) { |
91 return state == ui::SHOW_STATE_NORMAL || state == ui::SHOW_STATE_DEFAULT; | 97 return state == ui::SHOW_STATE_NORMAL || state == ui::SHOW_STATE_DEFAULT; |
92 } | 98 } |
93 | 99 |
94 bool IsWindowMaximized(const aura::Window* window) { | 100 bool IsWindowMaximized(const aura::Window* window) { |
95 return window->GetProperty(aura::client::kShowStateKey) == | 101 return window->GetProperty(aura::client::kShowStateKey) == |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 x_offset = work_area.right() - bounds->x() - kMinimumOnScreenArea; | 210 x_offset = work_area.right() - bounds->x() - kMinimumOnScreenArea; |
205 } else if (bounds->right() < work_area.x()) { | 211 } else if (bounds->right() < work_area.x()) { |
206 x_offset = work_area.x() - bounds->right() + kMinimumOnScreenArea; | 212 x_offset = work_area.x() - bounds->right() + kMinimumOnScreenArea; |
207 } | 213 } |
208 bounds->Offset(x_offset, y_offset); | 214 bounds->Offset(x_offset, y_offset); |
209 } | 215 } |
210 } | 216 } |
211 | 217 |
212 } // namespace wm | 218 } // namespace wm |
213 } // namespace ash | 219 } // namespace ash |
OLD | NEW |