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

Side by Side Diff: ash/common/wm/panels/panel_layout_manager.cc

Issue 2747543002: ash: Start/stop observing KeyboardController via ShellObserver (Closed)
Patch Set: update LockLayoutManager to use similar logic 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) 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/panels/panel_layout_manager.h" 5 #include "ash/common/wm/panels/panel_layout_manager.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <map> 8 #include <map>
9 #include <utility> 9 #include <utility>
10 10
11 #include "ash/common/keyboard/keyboard_observer_register.h"
11 #include "ash/common/shelf/wm_shelf.h" 12 #include "ash/common/shelf/wm_shelf.h"
12 #include "ash/common/shelf/wm_shelf_util.h" 13 #include "ash/common/shelf/wm_shelf_util.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_state.h" 17 #include "ash/common/wm/window_state.h"
17 #include "ash/common/wm_shell.h" 18 #include "ash/common/wm_shell.h"
18 #include "ash/common/wm_window.h" 19 #include "ash/common/wm_window.h"
19 #include "ash/public/cpp/shell_window_ids.h" 20 #include "ash/public/cpp/shell_window_ids.h"
20 #include "ash/public/cpp/window_properties.h" 21 #include "ash/public/cpp/window_properties.h"
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 95
95 DISALLOW_COPY_AND_ASSIGN(CalloutWidgetBackground); 96 DISALLOW_COPY_AND_ASSIGN(CalloutWidgetBackground);
96 }; 97 };
97 98
98 struct VisiblePanelPositionInfo { 99 struct VisiblePanelPositionInfo {
99 VisiblePanelPositionInfo() 100 VisiblePanelPositionInfo()
100 : min_major(0), 101 : min_major(0),
101 max_major(0), 102 max_major(0),
102 major_pos(0), 103 major_pos(0),
103 major_length(0), 104 major_length(0),
104 window(NULL), 105 window(nullptr),
105 slide_in(false) {} 106 slide_in(false) {}
106 107
107 int min_major; 108 int min_major;
108 int max_major; 109 int max_major;
109 int major_pos; 110 int major_pos;
110 int major_length; 111 int major_length;
111 WmWindow* window; 112 WmWindow* window;
112 bool slide_in; 113 bool slide_in;
113 }; 114 };
114 115
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 } 239 }
239 240
240 //////////////////////////////////////////////////////////////////////////////// 241 ////////////////////////////////////////////////////////////////////////////////
241 // PanelLayoutManager public implementation: 242 // PanelLayoutManager public implementation:
242 PanelLayoutManager::PanelLayoutManager(WmWindow* panel_container) 243 PanelLayoutManager::PanelLayoutManager(WmWindow* panel_container)
243 : panel_container_(panel_container), 244 : panel_container_(panel_container),
244 root_window_controller_(panel_container->GetRootWindowController()), 245 root_window_controller_(panel_container->GetRootWindowController()),
245 in_add_window_(false), 246 in_add_window_(false),
246 in_layout_(false), 247 in_layout_(false),
247 show_callout_widgets_(true), 248 show_callout_widgets_(true),
248 dragged_panel_(NULL), 249 dragged_panel_(nullptr),
249 shelf_(nullptr), 250 shelf_(nullptr),
250 last_active_panel_(NULL), 251 last_active_panel_(nullptr),
252 keyboard_observer_(this),
251 weak_factory_(this) { 253 weak_factory_(this) {
252 DCHECK(panel_container); 254 DCHECK(panel_container);
253 WmShell* shell = panel_container->GetShell(); 255 WmShell* shell = panel_container->GetShell();
254 Shell::GetInstance()->activation_client()->AddObserver(this); 256 Shell::GetInstance()->activation_client()->AddObserver(this);
255 shell->AddDisplayObserver(this); 257 shell->AddDisplayObserver(this);
256 Shell::GetInstance()->AddShellObserver(this); 258 Shell::GetInstance()->AddShellObserver(this);
257 } 259 }
258 260
259 PanelLayoutManager::~PanelLayoutManager() { 261 PanelLayoutManager::~PanelLayoutManager() {
260 Shutdown(); 262 Shutdown();
(...skipping 26 matching lines...) Expand all
287 Shell::GetInstance()->RemoveShellObserver(this); 289 Shell::GetInstance()->RemoveShellObserver(this);
288 } 290 }
289 291
290 void PanelLayoutManager::StartDragging(WmWindow* panel) { 292 void PanelLayoutManager::StartDragging(WmWindow* panel) {
291 DCHECK(!dragged_panel_); 293 DCHECK(!dragged_panel_);
292 dragged_panel_ = panel; 294 dragged_panel_ = panel;
293 Relayout(); 295 Relayout();
294 } 296 }
295 297
296 void PanelLayoutManager::FinishDragging() { 298 void PanelLayoutManager::FinishDragging() {
297 dragged_panel_ = NULL; 299 dragged_panel_ = nullptr;
298 Relayout(); 300 Relayout();
299 } 301 }
300 302
301 void PanelLayoutManager::SetShelf(WmShelf* shelf) { 303 void PanelLayoutManager::SetShelf(WmShelf* shelf) {
302 DCHECK(!shelf_); 304 DCHECK(!shelf_);
303 shelf_ = shelf; 305 shelf_ = shelf;
304 shelf_->AddObserver(this); 306 shelf_->AddObserver(this);
305 WillChangeVisibilityState(shelf_->GetVisibilityState()); 307 WillChangeVisibilityState(shelf_->GetVisibilityState());
306 } 308 }
307 309
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 if (found != panel_windows_.end()) { 380 if (found != panel_windows_.end()) {
379 delete found->callout_widget; 381 delete found->callout_widget;
380 panel_windows_.erase(found); 382 panel_windows_.erase(found);
381 } 383 }
382 if (restore_windows_on_shelf_visible_) 384 if (restore_windows_on_shelf_visible_)
383 restore_windows_on_shelf_visible_->Remove(child->aura_window()); 385 restore_windows_on_shelf_visible_->Remove(child->aura_window());
384 child->aura_window()->RemoveObserver(this); 386 child->aura_window()->RemoveObserver(this);
385 child->GetWindowState()->RemoveObserver(this); 387 child->GetWindowState()->RemoveObserver(this);
386 388
387 if (dragged_panel_ == child) 389 if (dragged_panel_ == child)
388 dragged_panel_ = NULL; 390 dragged_panel_ = nullptr;
389 391
390 if (last_active_panel_ == child) 392 if (last_active_panel_ == child)
391 last_active_panel_ = NULL; 393 last_active_panel_ = nullptr;
392 394
393 Relayout(); 395 Relayout();
394 } 396 }
395 397
396 void PanelLayoutManager::OnChildWindowVisibilityChanged(WmWindow* child, 398 void PanelLayoutManager::OnChildWindowVisibilityChanged(WmWindow* child,
397 bool visible) { 399 bool visible) {
398 if (visible) 400 if (visible)
399 child->GetWindowState()->Restore(); 401 child->GetWindowState()->Restore();
400 Relayout(); 402 Relayout();
401 } 403 }
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
445 447
446 void PanelLayoutManager::OnOverviewModeEnded() { 448 void PanelLayoutManager::OnOverviewModeEnded() {
447 Relayout(); 449 Relayout();
448 } 450 }
449 451
450 void PanelLayoutManager::OnShelfAlignmentChanged(WmWindow* root_window) { 452 void PanelLayoutManager::OnShelfAlignmentChanged(WmWindow* root_window) {
451 if (root_window_controller_->GetWindow() == root_window) 453 if (root_window_controller_->GetWindow() == root_window)
452 Relayout(); 454 Relayout();
453 } 455 }
454 456
457 void PanelLayoutManager::OnVirtualKeyboardStateChanged(bool activated,
458 WmWindow* root_window) {
459 UpdateKeyboardObserverFromStateChanged(activated, root_window,
460 panel_container_->GetRootWindow(),
461 &keyboard_observer_);
462 }
463
455 ///////////////////////////////////////////////////////////////////////////// 464 /////////////////////////////////////////////////////////////////////////////
456 // PanelLayoutManager, WindowObserver implementation: 465 // PanelLayoutManager, WindowObserver implementation:
457 466
458 void PanelLayoutManager::OnWindowPropertyChanged(aura::Window* window, 467 void PanelLayoutManager::OnWindowPropertyChanged(aura::Window* window,
459 const void* key, 468 const void* key,
460 intptr_t old) { 469 intptr_t old) {
461 // Trigger a relayout to position the panels whenever the panel icon is set 470 // Trigger a relayout to position the panels whenever the panel icon is set
462 // or changes. 471 // or changes.
463 if (key == kShelfIDKey) 472 if (key == kShelfIDKey)
464 Relayout(); 473 Relayout();
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
785 } 794 }
786 795
787 WmWindow* previous_panel = nullptr; 796 WmWindow* previous_panel = nullptr;
788 for (std::map<int, WmWindow*>::const_iterator it = window_ordering.begin(); 797 for (std::map<int, WmWindow*>::const_iterator it = window_ordering.begin();
789 it != window_ordering.end() && it->second != active_panel; ++it) { 798 it != window_ordering.end() && it->second != active_panel; ++it) {
790 if (previous_panel) 799 if (previous_panel)
791 panel_container_->StackChildAbove(it->second, previous_panel); 800 panel_container_->StackChildAbove(it->second, previous_panel);
792 previous_panel = it->second; 801 previous_panel = it->second;
793 } 802 }
794 803
795 previous_panel = NULL; 804 previous_panel = nullptr;
796 for (std::map<int, WmWindow*>::const_reverse_iterator it = 805 for (std::map<int, WmWindow*>::const_reverse_iterator it =
797 window_ordering.rbegin(); 806 window_ordering.rbegin();
798 it != window_ordering.rend() && it->second != active_panel; ++it) { 807 it != window_ordering.rend() && it->second != active_panel; ++it) {
799 if (previous_panel) 808 if (previous_panel)
800 panel_container_->StackChildAbove(it->second, previous_panel); 809 panel_container_->StackChildAbove(it->second, previous_panel);
801 previous_panel = it->second; 810 previous_panel = it->second;
802 } 811 }
803 812
804 panel_container_->StackChildAtTop(active_panel); 813 panel_container_->StackChildAtTop(active_panel);
805 if (dragged_panel_ && dragged_panel_->GetParent() == panel_container_) 814 if (dragged_panel_ && dragged_panel_->GetParent() == panel_container_)
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
923 } else if (panel_state->HasRestoreBounds()) { 932 } else if (panel_state->HasRestoreBounds()) {
924 // Keyboard hidden, restore original bounds if they exist. 933 // Keyboard hidden, restore original bounds if they exist.
925 panel->SetBoundsDirect(panel_state->GetRestoreBoundsInScreen()); 934 panel->SetBoundsDirect(panel_state->GetRestoreBoundsInScreen());
926 } 935 }
927 } 936 }
928 // This bounds change will have caused a change to the Shelf which does not 937 // This bounds change will have caused a change to the Shelf which does not
929 // propogate automatically to this class, so manually recalculate bounds. 938 // propogate automatically to this class, so manually recalculate bounds.
930 OnWindowResized(); 939 OnWindowResized();
931 } 940 }
932 941
933 void PanelLayoutManager::OnKeyboardClosed() {} 942 void PanelLayoutManager::OnKeyboardClosed() {
943 keyboard_observer_.RemoveAll();
944 }
934 945
935 } // namespace ash 946 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/wm/panels/panel_layout_manager.h ('k') | ash/common/wm/workspace/workspace_layout_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698