Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(38)

Side by Side Diff: ash/common/wm/dock/docked_window_layout_manager.cc

Issue 2736753005: Converts WmActivationObserver to aura::client::ActivationChangeObserver (Closed)
Patch Set: cleanup Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/shelf/shelf_background_animator.h" 8 #include "ash/common/shelf/shelf_background_animator.h"
9 #include "ash/common/shelf/shelf_background_animator_observer.h" 9 #include "ash/common/shelf/shelf_background_animator_observer.h"
10 #include "ash/common/shelf/shelf_constants.h" 10 #include "ash/common/shelf/shelf_constants.h"
11 #include "ash/common/shelf/wm_shelf.h" 11 #include "ash/common/shelf/wm_shelf.h"
12 #include "ash/common/shelf/wm_shelf_observer.h" 12 #include "ash/common/shelf/wm_shelf_observer.h"
13 #include "ash/common/wm/overview/window_selector_controller.h" 13 #include "ash/common/wm/overview/window_selector_controller.h"
14 #include "ash/common/wm/window_animation_types.h" 14 #include "ash/common/wm/window_animation_types.h"
15 #include "ash/common/wm/window_parenting_utils.h" 15 #include "ash/common/wm/window_parenting_utils.h"
16 #include "ash/common/wm/window_resizer.h" 16 #include "ash/common/wm/window_resizer.h"
17 #include "ash/common/wm/window_state.h" 17 #include "ash/common/wm/window_state.h"
18 #include "ash/common/wm_shell.h" 18 #include "ash/common/wm_shell.h"
19 #include "ash/common/wm_window.h" 19 #include "ash/common/wm_window.h"
20 #include "ash/public/cpp/shell_window_ids.h" 20 #include "ash/public/cpp/shell_window_ids.h"
21 #include "ash/resources/grit/ash_resources.h" 21 #include "ash/resources/grit/ash_resources.h"
22 #include "ash/root_window_controller.h" 22 #include "ash/root_window_controller.h"
23 #include "ash/shell.h"
23 #include "ash/wm/window_state_aura.h" 24 #include "ash/wm/window_state_aura.h"
24 #include "base/auto_reset.h" 25 #include "base/auto_reset.h"
25 #include "base/metrics/histogram_macros.h" 26 #include "base/metrics/histogram_macros.h"
26 #include "third_party/skia/include/core/SkColor.h" 27 #include "third_party/skia/include/core/SkColor.h"
27 #include "ui/base/resource/resource_bundle.h" 28 #include "ui/base/resource/resource_bundle.h"
28 #include "ui/compositor/scoped_layer_animation_settings.h" 29 #include "ui/compositor/scoped_layer_animation_settings.h"
29 #include "ui/display/display.h" 30 #include "ui/display/display.h"
30 #include "ui/display/screen.h" 31 #include "ui/display/screen.h"
31 #include "ui/views/background.h" 32 #include "ui/views/background.h"
32 #include "ui/wm/core/coordinate_conversion.h" 33 #include "ui/wm/core/coordinate_conversion.h"
33 #include "ui/wm/core/window_animations.h" 34 #include "ui/wm/core/window_animations.h"
35 #include "ui/wm/public/activation_client.h"
34 36
35 namespace ash { 37 namespace ash {
36 38
37 // Minimum, maximum width of the dock area and a width of the gap 39 // Minimum, maximum width of the dock area and a width of the gap
38 // static 40 // static
39 const int DockedWindowLayoutManager::kMaxDockWidth = 360; 41 const int DockedWindowLayoutManager::kMaxDockWidth = 360;
40 // static 42 // static
41 const int DockedWindowLayoutManager::kMinDockWidth = 200; 43 const int DockedWindowLayoutManager::kMinDockWidth = 200;
42 // static 44 // static
43 const int DockedWindowLayoutManager::kMinDockGap = 2; 45 const int DockedWindowLayoutManager::kMinDockGap = 2;
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 docked_width_(0), 376 docked_width_(0),
375 in_overview_(false), 377 in_overview_(false),
376 alignment_(DOCKED_ALIGNMENT_NONE), 378 alignment_(DOCKED_ALIGNMENT_NONE),
377 preferred_alignment_(DOCKED_ALIGNMENT_NONE), 379 preferred_alignment_(DOCKED_ALIGNMENT_NONE),
378 event_source_(DOCKED_ACTION_SOURCE_UNKNOWN), 380 event_source_(DOCKED_ACTION_SOURCE_UNKNOWN),
379 last_active_window_(nullptr), 381 last_active_window_(nullptr),
380 last_action_time_(base::Time::Now()), 382 last_action_time_(base::Time::Now()),
381 background_widget_(nullptr) { 383 background_widget_(nullptr) {
382 DCHECK(dock_container); 384 DCHECK(dock_container);
383 dock_container_->GetShell()->AddShellObserver(this); 385 dock_container_->GetShell()->AddShellObserver(this);
384 dock_container->GetShell()->AddActivationObserver(this); 386 Shell::GetInstance()->activation_client()->AddObserver(this);
385 display::Screen::GetScreen()->AddObserver(this); 387 display::Screen::GetScreen()->AddObserver(this);
386 } 388 }
387 389
388 DockedWindowLayoutManager::~DockedWindowLayoutManager() { 390 DockedWindowLayoutManager::~DockedWindowLayoutManager() {
389 Shutdown(); 391 Shutdown();
390 } 392 }
391 393
392 // static 394 // static
393 DockedWindowLayoutManager* DockedWindowLayoutManager::Get(WmWindow* window) { 395 DockedWindowLayoutManager* DockedWindowLayoutManager::Get(WmWindow* window) {
394 if (!window) 396 if (!window)
395 return nullptr; 397 return nullptr;
396 398
397 WmWindow* root = window->GetRootWindow(); 399 WmWindow* root = window->GetRootWindow();
398 return static_cast<DockedWindowLayoutManager*>( 400 return static_cast<DockedWindowLayoutManager*>(
399 root->GetChildByShellWindowId(kShellWindowId_DockedContainer) 401 root->GetChildByShellWindowId(kShellWindowId_DockedContainer)
400 ->GetLayoutManager()); 402 ->GetLayoutManager());
401 } 403 }
402 404
403 void DockedWindowLayoutManager::Shutdown() { 405 void DockedWindowLayoutManager::Shutdown() {
404 background_widget_.reset(); 406 background_widget_.reset();
405 shelf_observer_.reset(); 407 shelf_observer_.reset();
406 shelf_ = nullptr; 408 shelf_ = nullptr;
407 for (WmWindow* child : dock_container_->GetChildren()) { 409 for (WmWindow* child : dock_container_->GetChildren()) {
408 child->aura_window()->RemoveObserver(this); 410 child->aura_window()->RemoveObserver(this);
409 child->GetWindowState()->RemoveObserver(this); 411 child->GetWindowState()->RemoveObserver(this);
410 } 412 }
411 dock_container_->GetShell()->RemoveActivationObserver(this); 413 Shell::GetInstance()->activation_client()->RemoveObserver(this);
412 dock_container_->GetShell()->RemoveShellObserver(this); 414 dock_container_->GetShell()->RemoveShellObserver(this);
413 display::Screen::GetScreen()->RemoveObserver(this); 415 display::Screen::GetScreen()->RemoveObserver(this);
414 } 416 }
415 417
416 void DockedWindowLayoutManager::AddObserver( 418 void DockedWindowLayoutManager::AddObserver(
417 DockedWindowLayoutManagerObserver* observer) { 419 DockedWindowLayoutManagerObserver* observer) {
418 observer_list_.AddObserver(observer); 420 observer_list_.AddObserver(observer);
419 } 421 }
420 422
421 void DockedWindowLayoutManager::RemoveObserver( 423 void DockedWindowLayoutManager::RemoveObserver(
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
795 FinishDragging(DOCKED_ACTION_NONE, DOCKED_ACTION_SOURCE_UNKNOWN); 797 FinishDragging(DOCKED_ACTION_NONE, DOCKED_ACTION_SOURCE_UNKNOWN);
796 DCHECK(!dragged_window_); 798 DCHECK(!dragged_window_);
797 DCHECK(!is_dragged_window_docked_); 799 DCHECK(!is_dragged_window_docked_);
798 } 800 }
799 if (WmWindow::Get(window) == last_active_window_) 801 if (WmWindow::Get(window) == last_active_window_)
800 last_active_window_ = nullptr; 802 last_active_window_ = nullptr;
801 RecordUmaAction(DOCKED_ACTION_CLOSE, event_source_); 803 RecordUmaAction(DOCKED_ACTION_CLOSE, event_source_);
802 } 804 }
803 805
804 //////////////////////////////////////////////////////////////////////////////// 806 ////////////////////////////////////////////////////////////////////////////////
805 // DockedWindowLayoutManager, WmActivationObserver implementation: 807 // DockedWindowLayoutManager, ActivationChangeObserver implementation:
806 808
807 void DockedWindowLayoutManager::OnWindowActivated(WmWindow* gained_active, 809 void DockedWindowLayoutManager::OnWindowActivated(ActivationReason reason,
808 WmWindow* lost_active) { 810 aura::Window* gained_active,
809 if (gained_active && IsPopupOrTransient(gained_active)) 811 aura::Window* lost_active) {
812 WmWindow* wm_gained_active = WmWindow::Get(gained_active);
813 if (wm_gained_active && IsPopupOrTransient(wm_gained_active))
810 return; 814 return;
811 // Ignore if the window that is not managed by this was activated. 815 // Ignore if the window that is not managed by this was activated.
812 WmWindow* ancestor = nullptr; 816 WmWindow* ancestor = nullptr;
813 for (WmWindow* parent = gained_active; parent; parent = parent->GetParent()) { 817 for (WmWindow* parent = wm_gained_active; parent;
818 parent = parent->GetParent()) {
814 if (parent->GetParent() == dock_container_) { 819 if (parent->GetParent() == dock_container_) {
815 ancestor = parent; 820 ancestor = parent;
816 break; 821 break;
817 } 822 }
818 } 823 }
819 if (ancestor) { 824 if (ancestor) {
820 // Window activation from overview mode may unminimize a window and require 825 // Window activation from overview mode may unminimize a window and require
821 // layout update. 826 // layout update.
822 MaybeMinimizeChildrenExcept(gained_active); 827 MaybeMinimizeChildrenExcept(wm_gained_active);
823 Relayout(); 828 Relayout();
824 UpdateStacking(ancestor); 829 UpdateStacking(ancestor);
825 } 830 }
826 } 831 }
827 832
828 //////////////////////////////////////////////////////////////////////////////// 833 ////////////////////////////////////////////////////////////////////////////////
829 // DockedWindowLayoutManager, ShellObserver implementation: 834 // DockedWindowLayoutManager, ShellObserver implementation:
830 835
831 void DockedWindowLayoutManager::OnShelfAlignmentChanged(WmWindow* root_window) { 836 void DockedWindowLayoutManager::OnShelfAlignmentChanged(WmWindow* root_window) {
832 if (!shelf_ || alignment_ == DOCKED_ALIGNMENT_NONE || 837 if (!shelf_ || alignment_ == DOCKED_ALIGNMENT_NONE ||
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after
1327 const gfx::Rect& keyboard_bounds) { 1332 const gfx::Rect& keyboard_bounds) {
1328 // This bounds change will have caused a change to the Shelf which does not 1333 // This bounds change will have caused a change to the Shelf which does not
1329 // propagate automatically to this class, so manually recalculate bounds. 1334 // propagate automatically to this class, so manually recalculate bounds.
1330 Relayout(); 1335 Relayout();
1331 UpdateDockBounds(DockedWindowLayoutManagerObserver::KEYBOARD_BOUNDS_CHANGING); 1336 UpdateDockBounds(DockedWindowLayoutManagerObserver::KEYBOARD_BOUNDS_CHANGING);
1332 } 1337 }
1333 1338
1334 void DockedWindowLayoutManager::OnKeyboardClosed() {} 1339 void DockedWindowLayoutManager::OnKeyboardClosed() {}
1335 1340
1336 } // namespace ash 1341 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698