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

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

Issue 2907853002: [mus+ash] Removes WmWindow from ash/shelf and ash/shell (Closed)
Patch Set: [mus+ash] Removes WmWindow from ash/shelf and ash/shell (removed some more wm_window.h) Created 3 years, 6 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
« no previous file with comments | « ash/wm/panels/panel_layout_manager.h ('k') | ash/wm/panels/panel_layout_manager_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/wm/panels/panel_layout_manager.h" 5 #include "ash/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/keyboard/keyboard_observer_register.h" 11 #include "ash/keyboard/keyboard_observer_register.h"
12 #include "ash/public/cpp/shell_window_ids.h" 12 #include "ash/public/cpp/shell_window_ids.h"
13 #include "ash/public/cpp/window_properties.h" 13 #include "ash/public/cpp/window_properties.h"
14 #include "ash/root_window_controller.h" 14 #include "ash/root_window_controller.h"
15 #include "ash/shelf/shelf.h" 15 #include "ash/shelf/shelf.h"
16 #include "ash/shell.h" 16 #include "ash/shell.h"
17 #include "ash/shell_port.h" 17 #include "ash/shell_port.h"
18 #include "ash/wm/overview/window_selector_controller.h" 18 #include "ash/wm/overview/window_selector_controller.h"
19 #include "ash/wm/window_animation_types.h" 19 #include "ash/wm/window_animation_types.h"
20 #include "ash/wm/window_parenting_utils.h" 20 #include "ash/wm/window_parenting_utils.h"
21 #include "ash/wm/window_properties.h" 21 #include "ash/wm/window_properties.h"
22 #include "ash/wm/window_state.h" 22 #include "ash/wm/window_state.h"
23 #include "ash/wm/window_util.h" 23 #include "ash/wm/window_util.h"
24 #include "ash/wm_window.h"
25 #include "base/auto_reset.h" 24 #include "base/auto_reset.h"
26 #include "third_party/skia/include/core/SkColor.h" 25 #include "third_party/skia/include/core/SkColor.h"
27 #include "third_party/skia/include/core/SkPath.h" 26 #include "third_party/skia/include/core/SkPath.h"
28 #include "ui/aura/client/window_parenting_client.h" 27 #include "ui/aura/client/window_parenting_client.h"
29 #include "ui/aura/window_delegate.h" 28 #include "ui/aura/window_delegate.h"
30 #include "ui/compositor/scoped_layer_animation_settings.h" 29 #include "ui/compositor/scoped_layer_animation_settings.h"
31 #include "ui/gfx/canvas.h" 30 #include "ui/gfx/canvas.h"
32 #include "ui/gfx/geometry/rect.h" 31 #include "ui/gfx/geometry/rect.h"
33 #include "ui/gfx/geometry/vector2d.h" 32 #include "ui/gfx/geometry/vector2d.h"
34 #include "ui/views/background.h" 33 #include "ui/views/background.h"
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 Window* window = this->GetNativeWindow(); 192 Window* window = this->GetNativeWindow();
194 gfx::Rect callout_bounds = window->bounds(); 193 gfx::Rect callout_bounds = window->bounds();
195 if (shelf->IsHorizontalAlignment()) { 194 if (shelf->IsHorizontalAlignment()) {
196 callout_bounds.set_width(kArrowWidth); 195 callout_bounds.set_width(kArrowWidth);
197 callout_bounds.set_height(kArrowHeight); 196 callout_bounds.set_height(kArrowHeight);
198 } else { 197 } else {
199 callout_bounds.set_width(kArrowHeight); 198 callout_bounds.set_width(kArrowHeight);
200 callout_bounds.set_height(kArrowWidth); 199 callout_bounds.set_height(kArrowWidth);
201 } 200 }
202 Window* parent = window->parent(); 201 Window* parent = window->parent();
203 // It's important this go through WmWindow and not Widget. Going through 202 // It's important this go through Window and not Widget. Going through
204 // Widget means it may move do a different screen, we don't want that. 203 // Widget means it may move do a different screen, we don't want that.
205 window->SetBounds(callout_bounds); 204 window->SetBounds(callout_bounds);
206 // Setting the bounds should not trigger changing the parent. 205 // Setting the bounds should not trigger changing the parent.
207 DCHECK_EQ(parent, window->parent()); 206 DCHECK_EQ(parent, window->parent());
208 if (background_->alignment() != shelf->alignment()) { 207 if (background_->alignment() != shelf->alignment()) {
209 background_->set_alignment(shelf->alignment()); 208 background_->set_alignment(shelf->alignment());
210 SchedulePaintInRect(gfx::Rect(callout_bounds.size())); 209 SchedulePaintInRect(gfx::Rect(callout_bounds.size()));
211 } 210 }
212 } 211 }
213 212
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 Relayout(); 445 Relayout();
447 } 446 }
448 447
449 //////////////////////////////////////////////////////////////////////////////// 448 ////////////////////////////////////////////////////////////////////////////////
450 // PanelLayoutManager, ShellObserver implementation: 449 // PanelLayoutManager, ShellObserver implementation:
451 450
452 void PanelLayoutManager::OnOverviewModeEnded() { 451 void PanelLayoutManager::OnOverviewModeEnded() {
453 Relayout(); 452 Relayout();
454 } 453 }
455 454
456 void PanelLayoutManager::OnShelfAlignmentChanged(WmWindow* root_window) { 455 void PanelLayoutManager::OnShelfAlignmentChanged(aura::Window* root_window) {
457 if (root_window_controller_->GetWindow() == root_window) 456 if (root_window_controller_->GetRootWindow() == root_window)
458 Relayout(); 457 Relayout();
459 } 458 }
460 459
461 void PanelLayoutManager::OnVirtualKeyboardStateChanged(bool activated, 460 void PanelLayoutManager::OnVirtualKeyboardStateChanged(bool activated,
462 Window* root_window) { 461 Window* root_window) {
463 UpdateKeyboardObserverFromStateChanged(activated, root_window, 462 UpdateKeyboardObserverFromStateChanged(activated, root_window,
464 panel_container_->GetRootWindow(), 463 panel_container_->GetRootWindow(),
465 &keyboard_observer_); 464 &keyboard_observer_);
466 } 465 }
467 466
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
645 // If the shelf is currently hidden (full-screen mode), minimize panel until 644 // If the shelf is currently hidden (full-screen mode), minimize panel until
646 // full-screen mode is exited. When a panel is dragged from another display 645 // full-screen mode is exited. When a panel is dragged from another display
647 // the shelf state does not update before the panel is added so we exclude 646 // the shelf state does not update before the panel is added so we exclude
648 // the dragged panel. 647 // the dragged panel.
649 if (panel != dragged_panel_ && restore_windows_on_shelf_visible_) { 648 if (panel != dragged_panel_ && restore_windows_on_shelf_visible_) {
650 wm::GetWindowState(panel)->Minimize(); 649 wm::GetWindowState(panel)->Minimize();
651 restore_windows_on_shelf_visible_->Add(panel); 650 restore_windows_on_shelf_visible_->Add(panel);
652 continue; 651 continue;
653 } 652 }
654 653
655 gfx::Rect icon_bounds = 654 gfx::Rect icon_bounds = shelf_->GetScreenBoundsOfItemIconForWindow(panel);
656 shelf_->GetScreenBoundsOfItemIconForWindow(WmWindow::Get(panel));
657 655
658 // If both the icon width and height are 0 then there is no icon in the 656 // If both the icon width and height are 0 then there is no icon in the
659 // shelf. If the shelf is hidden, one of the height or width will be 657 // shelf. If the shelf is hidden, one of the height or width will be
660 // 0 but the position in the shelf and major dimension is still reported 658 // 0 but the position in the shelf and major dimension is still reported
661 // correctly and the panel can be aligned above where the hidden icon is. 659 // correctly and the panel can be aligned above where the hidden icon is.
662 if (icon_bounds.width() == 0 && icon_bounds.height() == 0) 660 if (icon_bounds.width() == 0 && icon_bounds.height() == 0)
663 continue; 661 continue;
664 662
665 if (panel->HasFocus() || panel->Contains(wm::GetFocusedWindow())) { 663 if (panel->HasFocus() || panel->Contains(wm::GetFocusedWindow())) {
666 DCHECK(!active_panel); 664 DCHECK(!active_panel);
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
825 const bool horizontal = shelf_->IsHorizontalAlignment(); 823 const bool horizontal = shelf_->IsHorizontalAlignment();
826 for (PanelList::iterator iter = panel_windows_.begin(); 824 for (PanelList::iterator iter = panel_windows_.begin();
827 iter != panel_windows_.end(); ++iter) { 825 iter != panel_windows_.end(); ++iter) {
828 Window* panel = iter->window; 826 Window* panel = iter->window;
829 views::Widget* callout_widget = iter->callout_widget; 827 views::Widget* callout_widget = iter->callout_widget;
830 Window* callout_widget_window = callout_widget->GetNativeWindow(); 828 Window* callout_widget_window = callout_widget->GetNativeWindow();
831 829
832 gfx::Rect current_bounds = panel->GetBoundsInScreen(); 830 gfx::Rect current_bounds = panel->GetBoundsInScreen();
833 gfx::Rect bounds = panel->GetTargetBounds(); 831 gfx::Rect bounds = panel->GetTargetBounds();
834 ::wm::ConvertRectToScreen(panel->parent(), &bounds); 832 ::wm::ConvertRectToScreen(panel->parent(), &bounds);
835 gfx::Rect icon_bounds = 833 gfx::Rect icon_bounds = shelf_->GetScreenBoundsOfItemIconForWindow(panel);
836 shelf_->GetScreenBoundsOfItemIconForWindow(WmWindow::Get(panel));
837 if (icon_bounds.IsEmpty() || !panel->layer()->GetTargetVisibility() || 834 if (icon_bounds.IsEmpty() || !panel->layer()->GetTargetVisibility() ||
838 panel == dragged_panel_ || !show_callout_widgets_) { 835 panel == dragged_panel_ || !show_callout_widgets_) {
839 callout_widget->Hide(); 836 callout_widget->Hide();
840 callout_widget_window->layer()->SetOpacity(0); 837 callout_widget_window->layer()->SetOpacity(0);
841 continue; 838 continue;
842 } 839 }
843 840
844 gfx::Rect callout_bounds = callout_widget->GetWindowBoundsInScreen(); 841 gfx::Rect callout_bounds = callout_widget->GetWindowBoundsInScreen();
845 gfx::Vector2d slide_vector = bounds.origin() - current_bounds.origin(); 842 gfx::Vector2d slide_vector = bounds.origin() - current_bounds.origin();
846 int slide_distance = horizontal ? slide_vector.x() : slide_vector.y(); 843 int slide_distance = horizontal ? slide_vector.x() : slide_vector.y();
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
938 // This bounds change will have caused a change to the Shelf which does not 935 // This bounds change will have caused a change to the Shelf which does not
939 // propogate automatically to this class, so manually recalculate bounds. 936 // propogate automatically to this class, so manually recalculate bounds.
940 OnWindowResized(); 937 OnWindowResized();
941 } 938 }
942 939
943 void PanelLayoutManager::OnKeyboardClosed() { 940 void PanelLayoutManager::OnKeyboardClosed() {
944 keyboard_observer_.RemoveAll(); 941 keyboard_observer_.RemoveAll();
945 } 942 }
946 943
947 } // namespace ash 944 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/panels/panel_layout_manager.h ('k') | ash/wm/panels/panel_layout_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698