| 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/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 |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 | 94 |
| 95 DISALLOW_COPY_AND_ASSIGN(CalloutWidgetBackground); | 95 DISALLOW_COPY_AND_ASSIGN(CalloutWidgetBackground); |
| 96 }; | 96 }; |
| 97 | 97 |
| 98 struct VisiblePanelPositionInfo { | 98 struct VisiblePanelPositionInfo { |
| 99 VisiblePanelPositionInfo() | 99 VisiblePanelPositionInfo() |
| 100 : min_major(0), | 100 : min_major(0), |
| 101 max_major(0), | 101 max_major(0), |
| 102 major_pos(0), | 102 major_pos(0), |
| 103 major_length(0), | 103 major_length(0), |
| 104 window(NULL), | 104 window(nullptr), |
| 105 slide_in(false) {} | 105 slide_in(false) {} |
| 106 | 106 |
| 107 int min_major; | 107 int min_major; |
| 108 int max_major; | 108 int max_major; |
| 109 int major_pos; | 109 int major_pos; |
| 110 int major_length; | 110 int major_length; |
| 111 WmWindow* window; | 111 WmWindow* window; |
| 112 bool slide_in; | 112 bool slide_in; |
| 113 }; | 113 }; |
| 114 | 114 |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 } | 238 } |
| 239 | 239 |
| 240 //////////////////////////////////////////////////////////////////////////////// | 240 //////////////////////////////////////////////////////////////////////////////// |
| 241 // PanelLayoutManager public implementation: | 241 // PanelLayoutManager public implementation: |
| 242 PanelLayoutManager::PanelLayoutManager(WmWindow* panel_container) | 242 PanelLayoutManager::PanelLayoutManager(WmWindow* panel_container) |
| 243 : panel_container_(panel_container), | 243 : panel_container_(panel_container), |
| 244 root_window_controller_(panel_container->GetRootWindowController()), | 244 root_window_controller_(panel_container->GetRootWindowController()), |
| 245 in_add_window_(false), | 245 in_add_window_(false), |
| 246 in_layout_(false), | 246 in_layout_(false), |
| 247 show_callout_widgets_(true), | 247 show_callout_widgets_(true), |
| 248 dragged_panel_(NULL), | 248 dragged_panel_(nullptr), |
| 249 shelf_(nullptr), | 249 shelf_(nullptr), |
| 250 last_active_panel_(NULL), | 250 last_active_panel_(nullptr), |
| 251 keyboard_observer_(this), |
| 251 weak_factory_(this) { | 252 weak_factory_(this) { |
| 252 DCHECK(panel_container); | 253 DCHECK(panel_container); |
| 253 WmShell* shell = panel_container->GetShell(); | 254 WmShell* shell = panel_container->GetShell(); |
| 254 Shell::GetInstance()->activation_client()->AddObserver(this); | 255 Shell::GetInstance()->activation_client()->AddObserver(this); |
| 255 shell->AddDisplayObserver(this); | 256 shell->AddDisplayObserver(this); |
| 256 Shell::GetInstance()->AddShellObserver(this); | 257 Shell::GetInstance()->AddShellObserver(this); |
| 257 } | 258 } |
| 258 | 259 |
| 259 PanelLayoutManager::~PanelLayoutManager() { | 260 PanelLayoutManager::~PanelLayoutManager() { |
| 260 Shutdown(); | 261 Shutdown(); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 287 Shell::GetInstance()->RemoveShellObserver(this); | 288 Shell::GetInstance()->RemoveShellObserver(this); |
| 288 } | 289 } |
| 289 | 290 |
| 290 void PanelLayoutManager::StartDragging(WmWindow* panel) { | 291 void PanelLayoutManager::StartDragging(WmWindow* panel) { |
| 291 DCHECK(!dragged_panel_); | 292 DCHECK(!dragged_panel_); |
| 292 dragged_panel_ = panel; | 293 dragged_panel_ = panel; |
| 293 Relayout(); | 294 Relayout(); |
| 294 } | 295 } |
| 295 | 296 |
| 296 void PanelLayoutManager::FinishDragging() { | 297 void PanelLayoutManager::FinishDragging() { |
| 297 dragged_panel_ = NULL; | 298 dragged_panel_ = nullptr; |
| 298 Relayout(); | 299 Relayout(); |
| 299 } | 300 } |
| 300 | 301 |
| 301 void PanelLayoutManager::SetShelf(WmShelf* shelf) { | 302 void PanelLayoutManager::SetShelf(WmShelf* shelf) { |
| 302 DCHECK(!shelf_); | 303 DCHECK(!shelf_); |
| 303 shelf_ = shelf; | 304 shelf_ = shelf; |
| 304 shelf_->AddObserver(this); | 305 shelf_->AddObserver(this); |
| 305 WillChangeVisibilityState(shelf_->GetVisibilityState()); | 306 WillChangeVisibilityState(shelf_->GetVisibilityState()); |
| 306 } | 307 } |
| 307 | 308 |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 378 if (found != panel_windows_.end()) { | 379 if (found != panel_windows_.end()) { |
| 379 delete found->callout_widget; | 380 delete found->callout_widget; |
| 380 panel_windows_.erase(found); | 381 panel_windows_.erase(found); |
| 381 } | 382 } |
| 382 if (restore_windows_on_shelf_visible_) | 383 if (restore_windows_on_shelf_visible_) |
| 383 restore_windows_on_shelf_visible_->Remove(child->aura_window()); | 384 restore_windows_on_shelf_visible_->Remove(child->aura_window()); |
| 384 child->aura_window()->RemoveObserver(this); | 385 child->aura_window()->RemoveObserver(this); |
| 385 child->GetWindowState()->RemoveObserver(this); | 386 child->GetWindowState()->RemoveObserver(this); |
| 386 | 387 |
| 387 if (dragged_panel_ == child) | 388 if (dragged_panel_ == child) |
| 388 dragged_panel_ = NULL; | 389 dragged_panel_ = nullptr; |
| 389 | 390 |
| 390 if (last_active_panel_ == child) | 391 if (last_active_panel_ == child) |
| 391 last_active_panel_ = NULL; | 392 last_active_panel_ = nullptr; |
| 392 | 393 |
| 393 Relayout(); | 394 Relayout(); |
| 394 } | 395 } |
| 395 | 396 |
| 396 void PanelLayoutManager::OnChildWindowVisibilityChanged(WmWindow* child, | 397 void PanelLayoutManager::OnChildWindowVisibilityChanged(WmWindow* child, |
| 397 bool visible) { | 398 bool visible) { |
| 398 if (visible) | 399 if (visible) |
| 399 child->GetWindowState()->Restore(); | 400 child->GetWindowState()->Restore(); |
| 400 Relayout(); | 401 Relayout(); |
| 401 } | 402 } |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 445 | 446 |
| 446 void PanelLayoutManager::OnOverviewModeEnded() { | 447 void PanelLayoutManager::OnOverviewModeEnded() { |
| 447 Relayout(); | 448 Relayout(); |
| 448 } | 449 } |
| 449 | 450 |
| 450 void PanelLayoutManager::OnShelfAlignmentChanged(WmWindow* root_window) { | 451 void PanelLayoutManager::OnShelfAlignmentChanged(WmWindow* root_window) { |
| 451 if (root_window_controller_->GetWindow() == root_window) | 452 if (root_window_controller_->GetWindow() == root_window) |
| 452 Relayout(); | 453 Relayout(); |
| 453 } | 454 } |
| 454 | 455 |
| 456 void PanelLayoutManager::OnVirtualKeyboardStateChanged(bool activated, |
| 457 WmWindow* root_window) { |
| 458 if (root_window != panel_container_->GetRootWindow()) |
| 459 return; |
| 460 |
| 461 keyboard::KeyboardController* const keyboard_controller = |
| 462 keyboard::KeyboardController::GetInstance(); |
| 463 if (activated && !keyboard_observer_.IsObserving(keyboard_controller)) { |
| 464 keyboard_observer_.Add(keyboard_controller); |
| 465 } else if (!activated && |
| 466 keyboard_observer_.IsObserving(keyboard_controller)) { |
| 467 keyboard_observer_.Remove(keyboard_controller); |
| 468 } |
| 469 } |
| 470 |
| 455 ///////////////////////////////////////////////////////////////////////////// | 471 ///////////////////////////////////////////////////////////////////////////// |
| 456 // PanelLayoutManager, WindowObserver implementation: | 472 // PanelLayoutManager, WindowObserver implementation: |
| 457 | 473 |
| 458 void PanelLayoutManager::OnWindowPropertyChanged(aura::Window* window, | 474 void PanelLayoutManager::OnWindowPropertyChanged(aura::Window* window, |
| 459 const void* key, | 475 const void* key, |
| 460 intptr_t old) { | 476 intptr_t old) { |
| 461 // Trigger a relayout to position the panels whenever the panel icon is set | 477 // Trigger a relayout to position the panels whenever the panel icon is set |
| 462 // or changes. | 478 // or changes. |
| 463 if (key == kShelfIDKey) | 479 if (key == kShelfIDKey) |
| 464 Relayout(); | 480 Relayout(); |
| (...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 785 } | 801 } |
| 786 | 802 |
| 787 WmWindow* previous_panel = nullptr; | 803 WmWindow* previous_panel = nullptr; |
| 788 for (std::map<int, WmWindow*>::const_iterator it = window_ordering.begin(); | 804 for (std::map<int, WmWindow*>::const_iterator it = window_ordering.begin(); |
| 789 it != window_ordering.end() && it->second != active_panel; ++it) { | 805 it != window_ordering.end() && it->second != active_panel; ++it) { |
| 790 if (previous_panel) | 806 if (previous_panel) |
| 791 panel_container_->StackChildAbove(it->second, previous_panel); | 807 panel_container_->StackChildAbove(it->second, previous_panel); |
| 792 previous_panel = it->second; | 808 previous_panel = it->second; |
| 793 } | 809 } |
| 794 | 810 |
| 795 previous_panel = NULL; | 811 previous_panel = nullptr; |
| 796 for (std::map<int, WmWindow*>::const_reverse_iterator it = | 812 for (std::map<int, WmWindow*>::const_reverse_iterator it = |
| 797 window_ordering.rbegin(); | 813 window_ordering.rbegin(); |
| 798 it != window_ordering.rend() && it->second != active_panel; ++it) { | 814 it != window_ordering.rend() && it->second != active_panel; ++it) { |
| 799 if (previous_panel) | 815 if (previous_panel) |
| 800 panel_container_->StackChildAbove(it->second, previous_panel); | 816 panel_container_->StackChildAbove(it->second, previous_panel); |
| 801 previous_panel = it->second; | 817 previous_panel = it->second; |
| 802 } | 818 } |
| 803 | 819 |
| 804 panel_container_->StackChildAtTop(active_panel); | 820 panel_container_->StackChildAtTop(active_panel); |
| 805 if (dragged_panel_ && dragged_panel_->GetParent() == panel_container_) | 821 if (dragged_panel_ && dragged_panel_->GetParent() == panel_container_) |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 923 } else if (panel_state->HasRestoreBounds()) { | 939 } else if (panel_state->HasRestoreBounds()) { |
| 924 // Keyboard hidden, restore original bounds if they exist. | 940 // Keyboard hidden, restore original bounds if they exist. |
| 925 panel->SetBoundsDirect(panel_state->GetRestoreBoundsInScreen()); | 941 panel->SetBoundsDirect(panel_state->GetRestoreBoundsInScreen()); |
| 926 } | 942 } |
| 927 } | 943 } |
| 928 // This bounds change will have caused a change to the Shelf which does not | 944 // This bounds change will have caused a change to the Shelf which does not |
| 929 // propogate automatically to this class, so manually recalculate bounds. | 945 // propogate automatically to this class, so manually recalculate bounds. |
| 930 OnWindowResized(); | 946 OnWindowResized(); |
| 931 } | 947 } |
| 932 | 948 |
| 933 void PanelLayoutManager::OnKeyboardClosed() {} | 949 void PanelLayoutManager::OnKeyboardClosed() { |
| 950 keyboard_observer_.RemoveAll(); |
| 951 } |
| 934 | 952 |
| 935 } // namespace ash | 953 } // namespace ash |
| OLD | NEW |