OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "athena/wm/window_manager_impl.h" | 5 #include "athena/wm/window_manager_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "athena/screen/public/screen_manager.h" | 9 #include "athena/screen/public/screen_manager.h" |
10 #include "athena/util/container_priorities.h" | 10 #include "athena/util/container_priorities.h" |
11 #include "athena/wm/bezel_controller.h" | 11 #include "athena/wm/bezel_controller.h" |
12 #include "athena/wm/public/window_manager_observer.h" | 12 #include "athena/wm/public/window_manager_observer.h" |
13 #include "athena/wm/split_view_controller.h" | 13 #include "athena/wm/split_view_controller.h" |
14 #include "athena/wm/title_drag_controller.h" | 14 #include "athena/wm/title_drag_controller.h" |
15 #include "athena/wm/window_list_provider_impl.h" | 15 #include "athena/wm/window_list_provider_impl.h" |
16 #include "athena/wm/window_overview_mode.h" | 16 #include "athena/wm/window_overview_mode.h" |
17 #include "base/bind.h" | 17 #include "base/bind.h" |
18 #include "base/logging.h" | 18 #include "base/logging.h" |
19 #include "ui/aura/client/aura_constants.h" | |
19 #include "ui/aura/layout_manager.h" | 20 #include "ui/aura/layout_manager.h" |
20 #include "ui/aura/window.h" | 21 #include "ui/aura/window.h" |
22 #include "ui/aura/window_delegate.h" | |
21 #include "ui/compositor/closure_animation_observer.h" | 23 #include "ui/compositor/closure_animation_observer.h" |
22 #include "ui/compositor/scoped_layer_animation_settings.h" | 24 #include "ui/compositor/scoped_layer_animation_settings.h" |
23 #include "ui/gfx/display.h" | 25 #include "ui/gfx/display.h" |
24 #include "ui/gfx/screen.h" | 26 #include "ui/gfx/screen.h" |
25 #include "ui/wm/core/shadow_controller.h" | 27 #include "ui/wm/core/shadow_controller.h" |
26 #include "ui/wm/core/transient_window_manager.h" | 28 #include "ui/wm/core/transient_window_manager.h" |
27 #include "ui/wm/core/window_util.h" | 29 #include "ui/wm/core/window_util.h" |
28 #include "ui/wm/core/wm_state.h" | 30 #include "ui/wm/core/wm_state.h" |
29 #include "ui/wm/public/activation_client.h" | 31 #include "ui/wm/public/activation_client.h" |
30 #include "ui/wm/public/window_types.h" | 32 #include "ui/wm/public/window_types.h" |
31 | 33 |
32 namespace athena { | 34 namespace athena { |
33 namespace { | 35 namespace { |
34 class WindowManagerImpl* instance = NULL; | 36 class WindowManagerImpl* instance = NULL; |
35 | 37 |
36 void SetWindowState(aura::Window* window, | 38 void SetWindowState(aura::Window* window, |
37 const gfx::Rect& bounds, | 39 const gfx::Rect& bounds, |
38 const gfx::Transform& transform) { | 40 const gfx::Transform& transform) { |
39 window->SetBounds(bounds); | 41 window->SetBounds(bounds); |
40 window->SetTransform(transform); | 42 window->SetTransform(transform); |
41 } | 43 } |
42 | 44 |
45 // Tests whether the given window can be maximized | |
46 bool CanWindowMaximize(aura::Window* window) { | |
47 bool can_maximize = window->GetProperty(aura::client::kCanMaximizeKey); | |
48 aura::WindowDelegate* delegate = window->delegate(); | |
49 bool has_no_maximum_bound = | |
50 delegate ? delegate->GetMaximumSize().IsEmpty() : true; | |
oshima
2014/10/23 01:05:46
nit: how about
bool no_max_size = !delegate || de
afakhry
2014/10/24 02:09:45
Acknowledged.
| |
51 | |
52 return (can_maximize && has_no_maximum_bound); | |
53 } | |
54 | |
43 } // namespace | 55 } // namespace |
44 | 56 |
45 class AthenaContainerLayoutManager : public aura::LayoutManager { | 57 class AthenaContainerLayoutManager : public aura::LayoutManager { |
46 public: | 58 public: |
47 AthenaContainerLayoutManager(); | 59 AthenaContainerLayoutManager(); |
48 virtual ~AthenaContainerLayoutManager(); | 60 virtual ~AthenaContainerLayoutManager(); |
49 | 61 |
50 private: | 62 private: |
51 // aura::LayoutManager: | 63 // aura::LayoutManager: |
52 virtual void OnWindowResized() override; | 64 virtual void OnWindowResized() override; |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
131 aura::Window* child) { | 143 aura::Window* child) { |
132 } | 144 } |
133 | 145 |
134 void AthenaContainerLayoutManager::OnWindowRemovedFromLayout( | 146 void AthenaContainerLayoutManager::OnWindowRemovedFromLayout( |
135 aura::Window* child) { | 147 aura::Window* child) { |
136 } | 148 } |
137 | 149 |
138 void AthenaContainerLayoutManager::OnChildWindowVisibilityChanged( | 150 void AthenaContainerLayoutManager::OnChildWindowVisibilityChanged( |
139 aura::Window* child, | 151 aura::Window* child, |
140 bool visible) { | 152 bool visible) { |
153 if(visible && CanWindowMaximize(child)) | |
oshima
2014/10/23 01:05:46
nit: you need {} in this case
afakhry
2014/10/24 02:09:45
Acknowledged.
| |
154 child->SetBounds(gfx::Screen::GetNativeScreen()-> | |
155 GetPrimaryDisplay().work_area()); | |
141 } | 156 } |
142 | 157 |
143 void AthenaContainerLayoutManager::SetChildBounds( | 158 void AthenaContainerLayoutManager::SetChildBounds( |
144 aura::Window* child, | 159 aura::Window* child, |
145 const gfx::Rect& requested_bounds) { | 160 const gfx::Rect& requested_bounds) { |
146 if (!requested_bounds.IsEmpty()) | 161 if (!requested_bounds.IsEmpty()) |
147 SetChildBoundsDirect(child, requested_bounds); | 162 SetChildBoundsDirect(child, requested_bounds); |
148 } | 163 } |
149 | 164 |
150 WindowManagerImpl::WindowManagerImpl() { | 165 WindowManagerImpl::WindowManagerImpl() { |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
297 wm::ActivateWindow(window); | 312 wm::ActivateWindow(window); |
298 | 313 |
299 if (split_view_controller_->IsSplitViewModeActive()) { | 314 if (split_view_controller_->IsSplitViewModeActive()) { |
300 split_view_controller_->DeactivateSplitMode(); | 315 split_view_controller_->DeactivateSplitMode(); |
301 FOR_EACH_OBSERVER(WindowManagerObserver, observers_, OnSplitViewModeExit()); | 316 FOR_EACH_OBSERVER(WindowManagerObserver, observers_, OnSplitViewModeExit()); |
302 } | 317 } |
303 // If |window| does not have the size of the work-area, then make sure it is | 318 // If |window| does not have the size of the work-area, then make sure it is |
304 // resized. | 319 // resized. |
305 const gfx::Size work_area = | 320 const gfx::Size work_area = |
306 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().work_area().size(); | 321 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().work_area().size(); |
307 if (window->GetTargetBounds().size() != work_area) { | 322 |
323 // Resize to the screen bounds only if the window is maximize-able, and | |
324 // is not already maximized | |
325 if (window->GetTargetBounds().size() != work_area && | |
326 CanWindowMaximize(window)) { | |
308 const gfx::Rect& window_bounds = window->bounds(); | 327 const gfx::Rect& window_bounds = window->bounds(); |
309 const gfx::Rect desired_bounds(work_area); | 328 const gfx::Rect desired_bounds(work_area); |
310 gfx::Transform transform; | 329 gfx::Transform transform; |
311 transform.Translate(desired_bounds.x() - window_bounds.x(), | 330 transform.Translate(desired_bounds.x() - window_bounds.x(), |
312 desired_bounds.y() - window_bounds.y()); | 331 desired_bounds.y() - window_bounds.y()); |
313 transform.Scale(desired_bounds.width() / window_bounds.width(), | 332 transform.Scale(desired_bounds.width() / window_bounds.width(), |
314 desired_bounds.height() / window_bounds.height()); | 333 desired_bounds.height() / window_bounds.height()); |
315 ui::ScopedLayerAnimationSettings settings(window->layer()->GetAnimator()); | 334 ui::ScopedLayerAnimationSettings settings(window->layer()->GetAnimator()); |
316 settings.SetPreemptionStrategy( | 335 settings.SetPreemptionStrategy( |
317 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); | 336 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
453 DCHECK(!instance); | 472 DCHECK(!instance); |
454 } | 473 } |
455 | 474 |
456 // static | 475 // static |
457 WindowManager* WindowManager::Get() { | 476 WindowManager* WindowManager::Get() { |
458 DCHECK(instance); | 477 DCHECK(instance); |
459 return instance; | 478 return instance; |
460 } | 479 } |
461 | 480 |
462 } // namespace athena | 481 } // namespace athena |
OLD | NEW |