| 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/common/wm/workspace/workspace_layout_manager.h" | 5 #include "ash/common/wm/workspace/workspace_layout_manager.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "ash/aura/wm_window_aura.h" | 10 #include "ash/aura/wm_window_aura.h" |
| 11 #include "ash/common/session/session_state_delegate.h" | 11 #include "ash/common/session/session_state_delegate.h" |
| 12 #include "ash/common/shelf/shelf.h" | |
| 13 #include "ash/common/shelf/shelf_constants.h" | 12 #include "ash/common/shelf/shelf_constants.h" |
| 14 #include "ash/common/shelf/shelf_layout_manager.h" | 13 #include "ash/common/shelf/shelf_layout_manager.h" |
| 14 #include "ash/common/shelf/wm_shelf.h" |
| 15 #include "ash/common/shell_observer.h" | 15 #include "ash/common/shell_observer.h" |
| 16 #include "ash/common/shell_window_ids.h" | 16 #include "ash/common/shell_window_ids.h" |
| 17 #include "ash/common/wm/maximize_mode/workspace_backdrop_delegate.h" | 17 #include "ash/common/wm/maximize_mode/workspace_backdrop_delegate.h" |
| 18 #include "ash/common/wm/window_state.h" | 18 #include "ash/common/wm/window_state.h" |
| 19 #include "ash/common/wm/wm_event.h" | 19 #include "ash/common/wm/wm_event.h" |
| 20 #include "ash/common/wm/workspace/workspace_window_resizer.h" | 20 #include "ash/common/wm/workspace/workspace_window_resizer.h" |
| 21 #include "ash/common/wm_shell.h" | 21 #include "ash/common/wm_shell.h" |
| 22 #include "ash/display/display_manager.h" | 22 #include "ash/display/display_manager.h" |
| 23 #include "ash/root_window_controller.h" | 23 #include "ash/root_window_controller.h" |
| 24 #include "ash/screen_util.h" | 24 #include "ash/screen_util.h" |
| (...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 // WindowObserver implementation used by DontClobberRestoreBoundsWindowObserver. | 306 // WindowObserver implementation used by DontClobberRestoreBoundsWindowObserver. |
| 307 // This code mirrors what BrowserFrameAsh does. In particular when this code | 307 // This code mirrors what BrowserFrameAsh does. In particular when this code |
| 308 // sees the window was maximized it changes the bounds of a secondary | 308 // sees the window was maximized it changes the bounds of a secondary |
| 309 // window. The secondary window mirrors the status window. | 309 // window. The secondary window mirrors the status window. |
| 310 class DontClobberRestoreBoundsWindowObserver : public aura::WindowObserver { | 310 class DontClobberRestoreBoundsWindowObserver : public aura::WindowObserver { |
| 311 public: | 311 public: |
| 312 DontClobberRestoreBoundsWindowObserver() : window_(nullptr) {} | 312 DontClobberRestoreBoundsWindowObserver() : window_(nullptr) {} |
| 313 | 313 |
| 314 void set_window(aura::Window* window) { window_ = window; } | 314 void set_window(aura::Window* window) { window_ = window; } |
| 315 | 315 |
| 316 // aura::WindowObserver: |
| 316 void OnWindowPropertyChanged(aura::Window* window, | 317 void OnWindowPropertyChanged(aura::Window* window, |
| 317 const void* key, | 318 const void* key, |
| 318 intptr_t old) override { | 319 intptr_t old) override { |
| 319 if (!window_) | 320 if (!window_) |
| 320 return; | 321 return; |
| 321 | 322 |
| 322 if (wm::GetWindowState(window)->IsMaximized()) { | 323 if (wm::GetWindowState(window)->IsMaximized()) { |
| 323 aura::Window* w = window_; | 324 aura::Window* w = window_; |
| 324 window_ = nullptr; | 325 window_ = nullptr; |
| 325 | 326 |
| 326 gfx::Rect shelf_bounds( | 327 gfx::Rect shelf_bounds( |
| 327 Shelf::ForPrimaryDisplay()->shelf_layout_manager()->GetIdealBounds()); | 328 test::AshTestBase::GetPrimaryShelf()->GetIdealBounds()); |
| 328 const gfx::Rect& window_bounds(w->bounds()); | 329 const gfx::Rect& window_bounds(w->bounds()); |
| 329 w->SetBounds(gfx::Rect(window_bounds.x(), shelf_bounds.y() - 1, | 330 w->SetBounds(gfx::Rect(window_bounds.x(), shelf_bounds.y() - 1, |
| 330 window_bounds.width(), window_bounds.height())); | 331 window_bounds.width(), window_bounds.height())); |
| 331 } | 332 } |
| 332 } | 333 } |
| 333 | 334 |
| 334 private: | 335 private: |
| 335 aura::Window* window_; | 336 aura::Window* window_; |
| 336 | 337 |
| 337 DISALLOW_COPY_AND_ASSIGN(DontClobberRestoreBoundsWindowObserver); | 338 DISALLOW_COPY_AND_ASSIGN(DontClobberRestoreBoundsWindowObserver); |
| (...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 834 } | 835 } |
| 835 | 836 |
| 836 // Verify if the window is not resized during screen lock. See: crbug.com/173127 | 837 // Verify if the window is not resized during screen lock. See: crbug.com/173127 |
| 837 TEST_F(WorkspaceLayoutManagerSoloTest, NotResizeWhenScreenIsLocked) { | 838 TEST_F(WorkspaceLayoutManagerSoloTest, NotResizeWhenScreenIsLocked) { |
| 838 SetCanLockScreen(true); | 839 SetCanLockScreen(true); |
| 839 std::unique_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(1, 2, 3, 4))); | 840 std::unique_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(1, 2, 3, 4))); |
| 840 // window with AlwaysOnTop will be managed by BaseLayoutManager. | 841 // window with AlwaysOnTop will be managed by BaseLayoutManager. |
| 841 window->SetProperty(aura::client::kAlwaysOnTopKey, true); | 842 window->SetProperty(aura::client::kAlwaysOnTopKey, true); |
| 842 window->Show(); | 843 window->Show(); |
| 843 | 844 |
| 844 Shelf* shelf = Shelf::ForWindow(WmWindowAura::Get(window.get())); | 845 WmShelf* shelf = GetPrimaryShelf(); |
| 845 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 846 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
| 846 | 847 |
| 847 window->SetBounds(ScreenUtil::GetMaximizedWindowBoundsInParent(window.get())); | 848 window->SetBounds(ScreenUtil::GetMaximizedWindowBoundsInParent(window.get())); |
| 848 gfx::Rect window_bounds = window->bounds(); | 849 gfx::Rect window_bounds = window->bounds(); |
| 849 EXPECT_EQ( | 850 EXPECT_EQ( |
| 850 ScreenUtil::GetMaximizedWindowBoundsInParent(window.get()).ToString(), | 851 ScreenUtil::GetMaximizedWindowBoundsInParent(window.get()).ToString(), |
| 851 window_bounds.ToString()); | 852 window_bounds.ToString()); |
| 852 | 853 |
| 853 // The window size should not get touched while we are in lock screen. | 854 // The window size should not get touched while we are in lock screen. |
| 854 WmShell::Get()->GetSessionStateDelegate()->LockScreen(); | 855 WmShell::Get()->GetSessionStateDelegate()->LockScreen(); |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1029 EXPECT_EQ("b,x", GetWindowOrderAsString(backdrop, window1.get(), | 1030 EXPECT_EQ("b,x", GetWindowOrderAsString(backdrop, window1.get(), |
| 1030 window2.get(), window3.get())); | 1031 window2.get(), window3.get())); |
| 1031 ShowTopWindowBackdrop(false); | 1032 ShowTopWindowBackdrop(false); |
| 1032 EXPECT_EQ("b", GetWindowOrderAsString(nullptr, window1.get(), window2.get(), | 1033 EXPECT_EQ("b", GetWindowOrderAsString(nullptr, window1.get(), window2.get(), |
| 1033 window3.get())); | 1034 window3.get())); |
| 1034 } | 1035 } |
| 1035 | 1036 |
| 1036 // Tests that when hidding the shelf, that the backdrop resizes to fill the | 1037 // Tests that when hidding the shelf, that the backdrop resizes to fill the |
| 1037 // entire workspace area. | 1038 // entire workspace area. |
| 1038 TEST_F(WorkspaceLayoutManagerBackdropTest, ShelfVisibilityChangesBounds) { | 1039 TEST_F(WorkspaceLayoutManagerBackdropTest, ShelfVisibilityChangesBounds) { |
| 1039 Shelf* shelf = Shelf::ForPrimaryDisplay(); | 1040 WmShelf* shelf = GetPrimaryShelf(); |
| 1040 ShelfLayoutManager* shelf_layout_manager = shelf->shelf_layout_manager(); | 1041 ShelfLayoutManager* shelf_layout_manager = shelf->shelf_layout_manager(); |
| 1041 ShowTopWindowBackdrop(true); | 1042 ShowTopWindowBackdrop(true); |
| 1042 RunAllPendingInMessageLoop(); | 1043 RunAllPendingInMessageLoop(); |
| 1043 | 1044 |
| 1044 ASSERT_EQ(SHELF_VISIBLE, shelf_layout_manager->visibility_state()); | 1045 ASSERT_EQ(SHELF_VISIBLE, shelf_layout_manager->visibility_state()); |
| 1045 gfx::Rect initial_bounds = default_container()->children()[0]->bounds(); | 1046 gfx::Rect initial_bounds = default_container()->children()[0]->bounds(); |
| 1046 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_ALWAYS_HIDDEN); | 1047 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_ALWAYS_HIDDEN); |
| 1047 shelf_layout_manager->UpdateVisibilityState(); | 1048 shelf_layout_manager->UpdateVisibilityState(); |
| 1048 | 1049 |
| 1049 // When the shelf is re-shown WorkspaceLayoutManager shrinks all children | 1050 // When the shelf is re-shown WorkspaceLayoutManager shrinks all children |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1308 changed_window_bounds.Offset(0, -shift); | 1309 changed_window_bounds.Offset(0, -shift); |
| 1309 // Window should be shifted up. | 1310 // Window should be shifted up. |
| 1310 EXPECT_EQ(changed_window_bounds, window->bounds()); | 1311 EXPECT_EQ(changed_window_bounds, window->bounds()); |
| 1311 | 1312 |
| 1312 kb_controller->HideKeyboard( | 1313 kb_controller->HideKeyboard( |
| 1313 keyboard::KeyboardController::HIDE_REASON_AUTOMATIC); | 1314 keyboard::KeyboardController::HIDE_REASON_AUTOMATIC); |
| 1314 EXPECT_EQ(orig_window_bounds, window->bounds()); | 1315 EXPECT_EQ(orig_window_bounds, window->bounds()); |
| 1315 } | 1316 } |
| 1316 | 1317 |
| 1317 } // namespace ash | 1318 } // namespace ash |
| OLD | NEW |