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

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

Issue 2747543002: ash: Start/stop observing KeyboardController via ShellObserver (Closed)
Patch Set: rebase 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"
(...skipping 12 matching lines...) Expand all
23 #include "ash/shell.h" 23 #include "ash/shell.h"
24 #include "ash/wm/window_state_aura.h" 24 #include "ash/wm/window_state_aura.h"
25 #include "base/auto_reset.h" 25 #include "base/auto_reset.h"
26 #include "base/metrics/histogram_macros.h" 26 #include "base/metrics/histogram_macros.h"
27 #include "third_party/skia/include/core/SkColor.h" 27 #include "third_party/skia/include/core/SkColor.h"
28 #include "ui/aura/window.h" 28 #include "ui/aura/window.h"
29 #include "ui/base/resource/resource_bundle.h" 29 #include "ui/base/resource/resource_bundle.h"
30 #include "ui/compositor/scoped_layer_animation_settings.h" 30 #include "ui/compositor/scoped_layer_animation_settings.h"
31 #include "ui/display/display.h" 31 #include "ui/display/display.h"
32 #include "ui/display/screen.h" 32 #include "ui/display/screen.h"
33 #include "ui/keyboard/keyboard_controller.h"
33 #include "ui/views/background.h" 34 #include "ui/views/background.h"
34 #include "ui/wm/core/coordinate_conversion.h" 35 #include "ui/wm/core/coordinate_conversion.h"
35 #include "ui/wm/core/window_animations.h" 36 #include "ui/wm/core/window_animations.h"
36 #include "ui/wm/public/activation_client.h" 37 #include "ui/wm/public/activation_client.h"
37 38
38 namespace ash { 39 namespace ash {
39 40
40 // Minimum, maximum width of the dock area and a width of the gap 41 // Minimum, maximum width of the dock area and a width of the gap
41 // static 42 // static
42 const int DockedWindowLayoutManager::kMaxDockWidth = 360; 43 const int DockedWindowLayoutManager::kMaxDockWidth = 360;
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 shelf_(nullptr), 375 shelf_(nullptr),
375 in_fullscreen_(root_window_controller_->GetWorkspaceWindowState() == 376 in_fullscreen_(root_window_controller_->GetWorkspaceWindowState() ==
376 wm::WORKSPACE_WINDOW_STATE_FULL_SCREEN), 377 wm::WORKSPACE_WINDOW_STATE_FULL_SCREEN),
377 docked_width_(0), 378 docked_width_(0),
378 in_overview_(false), 379 in_overview_(false),
379 alignment_(DOCKED_ALIGNMENT_NONE), 380 alignment_(DOCKED_ALIGNMENT_NONE),
380 preferred_alignment_(DOCKED_ALIGNMENT_NONE), 381 preferred_alignment_(DOCKED_ALIGNMENT_NONE),
381 event_source_(DOCKED_ACTION_SOURCE_UNKNOWN), 382 event_source_(DOCKED_ACTION_SOURCE_UNKNOWN),
382 last_active_window_(nullptr), 383 last_active_window_(nullptr),
383 last_action_time_(base::Time::Now()), 384 last_action_time_(base::Time::Now()),
384 background_widget_(nullptr) { 385 background_widget_(nullptr),
386 keyboard_observer_(this) {
385 DCHECK(dock_container); 387 DCHECK(dock_container);
386 Shell::GetInstance()->AddShellObserver(this); 388 Shell::GetInstance()->AddShellObserver(this);
387 Shell::GetInstance()->activation_client()->AddObserver(this); 389 Shell::GetInstance()->activation_client()->AddObserver(this);
388 display::Screen::GetScreen()->AddObserver(this); 390 display::Screen::GetScreen()->AddObserver(this);
389 } 391 }
390 392
391 DockedWindowLayoutManager::~DockedWindowLayoutManager() { 393 DockedWindowLayoutManager::~DockedWindowLayoutManager() {
392 Shutdown(); 394 Shutdown();
393 } 395 }
394 396
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
622 624
623 Relayout(); 625 Relayout();
624 UpdateDockBounds(DockedWindowLayoutManagerObserver::CHILD_CHANGED); 626 UpdateDockBounds(DockedWindowLayoutManagerObserver::CHILD_CHANGED);
625 } 627 }
626 628
627 void DockedWindowLayoutManager::OnShelfBoundsChanged() { 629 void DockedWindowLayoutManager::OnShelfBoundsChanged() {
628 Relayout(); 630 Relayout();
629 UpdateDockBounds(DockedWindowLayoutManagerObserver::DISPLAY_INSETS_CHANGED); 631 UpdateDockBounds(DockedWindowLayoutManagerObserver::DISPLAY_INSETS_CHANGED);
630 } 632 }
631 633
634 void DockedWindowLayoutManager::StartObservingKeyboard(
635 keyboard::KeyboardController* keyboard_controller) {
636 DCHECK(!keyboard_observer_.IsObservingSources());
637 keyboard_observer_.Add(keyboard_controller);
638 }
639
640 void DockedWindowLayoutManager::StopObservingKeyboard(
641 keyboard::KeyboardController* keyboard_controller) {
642 if (keyboard_observer_.IsObserving(keyboard_controller))
643 keyboard_observer_.Remove(keyboard_controller);
644 }
645
632 //////////////////////////////////////////////////////////////////////////////// 646 ////////////////////////////////////////////////////////////////////////////////
633 // DockedWindowLayoutManager, aura::LayoutManager implementation: 647 // DockedWindowLayoutManager, aura::LayoutManager implementation:
634 void DockedWindowLayoutManager::OnWindowResized() { 648 void DockedWindowLayoutManager::OnWindowResized() {
635 MaybeMinimizeChildrenExcept(dragged_window_); 649 MaybeMinimizeChildrenExcept(dragged_window_);
636 Relayout(); 650 Relayout();
637 // When screen resizes update the insets even when dock width or alignment 651 // When screen resizes update the insets even when dock width or alignment
638 // does not change. 652 // does not change.
639 UpdateDockBounds(DockedWindowLayoutManagerObserver::DISPLAY_RESIZED); 653 UpdateDockBounds(DockedWindowLayoutManagerObserver::DISPLAY_RESIZED);
640 } 654 }
641 655
(...skipping 688 matching lines...) Expand 10 before | Expand all | Expand 10 after
1330 // keyboard::KeyboardControllerObserver implementation: 1344 // keyboard::KeyboardControllerObserver implementation:
1331 1345
1332 void DockedWindowLayoutManager::OnKeyboardBoundsChanging( 1346 void DockedWindowLayoutManager::OnKeyboardBoundsChanging(
1333 const gfx::Rect& keyboard_bounds) { 1347 const gfx::Rect& keyboard_bounds) {
1334 // This bounds change will have caused a change to the Shelf which does not 1348 // This bounds change will have caused a change to the Shelf which does not
1335 // propagate automatically to this class, so manually recalculate bounds. 1349 // propagate automatically to this class, so manually recalculate bounds.
1336 Relayout(); 1350 Relayout();
1337 UpdateDockBounds(DockedWindowLayoutManagerObserver::KEYBOARD_BOUNDS_CHANGING); 1351 UpdateDockBounds(DockedWindowLayoutManagerObserver::KEYBOARD_BOUNDS_CHANGING);
1338 } 1352 }
1339 1353
1340 void DockedWindowLayoutManager::OnKeyboardClosed() {} 1354 void DockedWindowLayoutManager::OnKeyboardClosed() {
1355 keyboard_observer_.RemoveAll();
1356 }
1341 1357
1342 } // namespace ash 1358 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698