| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/dock/docked_window_layout_manager.h" | 5 #include "ash/common/wm/dock/docked_window_layout_manager.h" |
| 6 | 6 |
| 7 #include "ash/animation/animation_change_type.h" | 7 #include "ash/animation/animation_change_type.h" |
| 8 #include "ash/common/keyboard/keyboard_observer_register.h" |
| 8 #include "ash/common/shelf/shelf_background_animator.h" | 9 #include "ash/common/shelf/shelf_background_animator.h" |
| 9 #include "ash/common/shelf/shelf_background_animator_observer.h" | 10 #include "ash/common/shelf/shelf_background_animator_observer.h" |
| 10 #include "ash/common/shelf/shelf_constants.h" | 11 #include "ash/common/shelf/shelf_constants.h" |
| 11 #include "ash/common/shelf/wm_shelf.h" | 12 #include "ash/common/shelf/wm_shelf.h" |
| 12 #include "ash/common/shelf/wm_shelf_observer.h" | 13 #include "ash/common/shelf/wm_shelf_observer.h" |
| 13 #include "ash/common/wm/overview/window_selector_controller.h" | 14 #include "ash/common/wm/overview/window_selector_controller.h" |
| 14 #include "ash/common/wm/window_animation_types.h" | 15 #include "ash/common/wm/window_animation_types.h" |
| 15 #include "ash/common/wm/window_parenting_utils.h" | 16 #include "ash/common/wm/window_parenting_utils.h" |
| 16 #include "ash/common/wm/window_resizer.h" | 17 #include "ash/common/wm/window_resizer.h" |
| 17 #include "ash/common/wm/window_state.h" | 18 #include "ash/common/wm/window_state.h" |
| 18 #include "ash/common/wm_shell.h" | 19 #include "ash/common/wm_shell.h" |
| 19 #include "ash/common/wm_window.h" | 20 #include "ash/common/wm_window.h" |
| 20 #include "ash/public/cpp/shell_window_ids.h" | 21 #include "ash/public/cpp/shell_window_ids.h" |
| 21 #include "ash/resources/grit/ash_resources.h" | 22 #include "ash/resources/grit/ash_resources.h" |
| 22 #include "ash/root_window_controller.h" | 23 #include "ash/root_window_controller.h" |
| 23 #include "ash/shell.h" | 24 #include "ash/shell.h" |
| 24 #include "ash/wm/window_state_aura.h" | 25 #include "ash/wm/window_state_aura.h" |
| 25 #include "base/auto_reset.h" | 26 #include "base/auto_reset.h" |
| 26 #include "base/metrics/histogram_macros.h" | 27 #include "base/metrics/histogram_macros.h" |
| 27 #include "third_party/skia/include/core/SkColor.h" | 28 #include "third_party/skia/include/core/SkColor.h" |
| 28 #include "ui/aura/window.h" | 29 #include "ui/aura/window.h" |
| 29 #include "ui/base/resource/resource_bundle.h" | 30 #include "ui/base/resource/resource_bundle.h" |
| 30 #include "ui/compositor/scoped_layer_animation_settings.h" | 31 #include "ui/compositor/scoped_layer_animation_settings.h" |
| 31 #include "ui/display/display.h" | 32 #include "ui/display/display.h" |
| 32 #include "ui/display/screen.h" | 33 #include "ui/display/screen.h" |
| 34 #include "ui/keyboard/keyboard_controller.h" |
| 33 #include "ui/views/background.h" | 35 #include "ui/views/background.h" |
| 34 #include "ui/wm/core/coordinate_conversion.h" | 36 #include "ui/wm/core/coordinate_conversion.h" |
| 35 #include "ui/wm/core/window_animations.h" | 37 #include "ui/wm/core/window_animations.h" |
| 36 #include "ui/wm/public/activation_client.h" | 38 #include "ui/wm/public/activation_client.h" |
| 37 | 39 |
| 38 namespace ash { | 40 namespace ash { |
| 39 | 41 |
| 40 // Minimum, maximum width of the dock area and a width of the gap | 42 // Minimum, maximum width of the dock area and a width of the gap |
| 41 // static | 43 // static |
| 42 const int DockedWindowLayoutManager::kMaxDockWidth = 360; | 44 const int DockedWindowLayoutManager::kMaxDockWidth = 360; |
| (...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 374 shelf_(nullptr), | 376 shelf_(nullptr), |
| 375 in_fullscreen_(root_window_controller_->GetWorkspaceWindowState() == | 377 in_fullscreen_(root_window_controller_->GetWorkspaceWindowState() == |
| 376 wm::WORKSPACE_WINDOW_STATE_FULL_SCREEN), | 378 wm::WORKSPACE_WINDOW_STATE_FULL_SCREEN), |
| 377 docked_width_(0), | 379 docked_width_(0), |
| 378 in_overview_(false), | 380 in_overview_(false), |
| 379 alignment_(DOCKED_ALIGNMENT_NONE), | 381 alignment_(DOCKED_ALIGNMENT_NONE), |
| 380 preferred_alignment_(DOCKED_ALIGNMENT_NONE), | 382 preferred_alignment_(DOCKED_ALIGNMENT_NONE), |
| 381 event_source_(DOCKED_ACTION_SOURCE_UNKNOWN), | 383 event_source_(DOCKED_ACTION_SOURCE_UNKNOWN), |
| 382 last_active_window_(nullptr), | 384 last_active_window_(nullptr), |
| 383 last_action_time_(base::Time::Now()), | 385 last_action_time_(base::Time::Now()), |
| 384 background_widget_(nullptr) { | 386 background_widget_(nullptr), |
| 387 keyboard_observer_(this) { |
| 385 DCHECK(dock_container); | 388 DCHECK(dock_container); |
| 386 Shell::GetInstance()->AddShellObserver(this); | 389 Shell::GetInstance()->AddShellObserver(this); |
| 387 Shell::GetInstance()->activation_client()->AddObserver(this); | 390 Shell::GetInstance()->activation_client()->AddObserver(this); |
| 388 display::Screen::GetScreen()->AddObserver(this); | 391 display::Screen::GetScreen()->AddObserver(this); |
| 389 } | 392 } |
| 390 | 393 |
| 391 DockedWindowLayoutManager::~DockedWindowLayoutManager() { | 394 DockedWindowLayoutManager::~DockedWindowLayoutManager() { |
| 392 Shutdown(); | 395 Shutdown(); |
| 393 } | 396 } |
| 394 | 397 |
| (...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 888 void DockedWindowLayoutManager::OnOverviewModeStarting() { | 891 void DockedWindowLayoutManager::OnOverviewModeStarting() { |
| 889 in_overview_ = true; | 892 in_overview_ = true; |
| 890 UpdateDockBounds(DockedWindowLayoutManagerObserver::CHILD_CHANGED); | 893 UpdateDockBounds(DockedWindowLayoutManagerObserver::CHILD_CHANGED); |
| 891 } | 894 } |
| 892 | 895 |
| 893 void DockedWindowLayoutManager::OnOverviewModeEnded() { | 896 void DockedWindowLayoutManager::OnOverviewModeEnded() { |
| 894 in_overview_ = false; | 897 in_overview_ = false; |
| 895 UpdateDockBounds(DockedWindowLayoutManagerObserver::CHILD_CHANGED); | 898 UpdateDockBounds(DockedWindowLayoutManagerObserver::CHILD_CHANGED); |
| 896 } | 899 } |
| 897 | 900 |
| 901 void DockedWindowLayoutManager::OnVirtualKeyboardStateChanged( |
| 902 bool activated, |
| 903 WmWindow* root_window) { |
| 904 UpdateKeyboardObserverFromStateChanged(activated, root_window, |
| 905 dock_container_->GetRootWindow(), |
| 906 &keyboard_observer_); |
| 907 } |
| 908 |
| 898 //////////////////////////////////////////////////////////////////////////////// | 909 //////////////////////////////////////////////////////////////////////////////// |
| 899 // DockedWindowLayoutManager private implementation: | 910 // DockedWindowLayoutManager private implementation: |
| 900 | 911 |
| 901 void DockedWindowLayoutManager::MaybeMinimizeChildrenExcept(WmWindow* child) { | 912 void DockedWindowLayoutManager::MaybeMinimizeChildrenExcept(WmWindow* child) { |
| 902 WindowSelectorController* window_selector_controller = | 913 WindowSelectorController* window_selector_controller = |
| 903 WmShell::Get()->window_selector_controller(); | 914 WmShell::Get()->window_selector_controller(); |
| 904 if (window_selector_controller->IsRestoringMinimizedWindows()) | 915 if (window_selector_controller->IsRestoringMinimizedWindows()) |
| 905 return; | 916 return; |
| 906 // Minimize any windows that don't fit without overlap. | 917 // Minimize any windows that don't fit without overlap. |
| 907 const gfx::Rect work_area = | 918 const gfx::Rect work_area = |
| (...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1330 // keyboard::KeyboardControllerObserver implementation: | 1341 // keyboard::KeyboardControllerObserver implementation: |
| 1331 | 1342 |
| 1332 void DockedWindowLayoutManager::OnKeyboardBoundsChanging( | 1343 void DockedWindowLayoutManager::OnKeyboardBoundsChanging( |
| 1333 const gfx::Rect& keyboard_bounds) { | 1344 const gfx::Rect& keyboard_bounds) { |
| 1334 // This bounds change will have caused a change to the Shelf which does not | 1345 // This bounds change will have caused a change to the Shelf which does not |
| 1335 // propagate automatically to this class, so manually recalculate bounds. | 1346 // propagate automatically to this class, so manually recalculate bounds. |
| 1336 Relayout(); | 1347 Relayout(); |
| 1337 UpdateDockBounds(DockedWindowLayoutManagerObserver::KEYBOARD_BOUNDS_CHANGING); | 1348 UpdateDockBounds(DockedWindowLayoutManagerObserver::KEYBOARD_BOUNDS_CHANGING); |
| 1338 } | 1349 } |
| 1339 | 1350 |
| 1340 void DockedWindowLayoutManager::OnKeyboardClosed() {} | 1351 void DockedWindowLayoutManager::OnKeyboardClosed() { |
| 1352 keyboard_observer_.RemoveAll(); |
| 1353 } |
| 1341 | 1354 |
| 1342 } // namespace ash | 1355 } // namespace ash |
| OLD | NEW |