| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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/shelf/shelf.h" | 5 #include "ash/shelf/shelf.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 | 9 |
| 10 #include "ash/aura/wm_window_aura.h" | 10 #include "ash/aura/wm_window_aura.h" |
| 11 #include "ash/common/shelf/shelf_delegate.h" | 11 #include "ash/common/shelf/shelf_delegate.h" |
| 12 #include "ash/common/shelf/shelf_item_delegate.h" | 12 #include "ash/common/shelf/shelf_item_delegate.h" |
| 13 #include "ash/common/shelf/shelf_model.h" | 13 #include "ash/common/shelf/shelf_model.h" |
| 14 #include "ash/common/shelf/shelf_navigator.h" | 14 #include "ash/common/shelf/shelf_navigator.h" |
| 15 #include "ash/common/shelf/shelf_view.h" | 15 #include "ash/common/shelf/shelf_view.h" |
| 16 #include "ash/common/shell_window_ids.h" | 16 #include "ash/common/shell_window_ids.h" |
| 17 #include "ash/common/wm_lookup.h" |
| 17 #include "ash/common/wm_shell.h" | 18 #include "ash/common/wm_shell.h" |
| 19 #include "ash/common/wm_window_property.h" |
| 18 #include "ash/root_window_controller.h" | 20 #include "ash/root_window_controller.h" |
| 19 #include "ash/screen_util.h" | |
| 20 #include "ash/shelf/shelf_layout_manager.h" | 21 #include "ash/shelf/shelf_layout_manager.h" |
| 21 #include "ash/shelf/shelf_util.h" | |
| 22 #include "ash/shell.h" | |
| 23 #include "ash/wm/window_properties.h" | |
| 24 #include "ui/aura/window.h" | 22 #include "ui/aura/window.h" |
| 25 #include "ui/aura/window_event_dispatcher.h" | |
| 26 #include "ui/aura/window_observer.h" | |
| 27 #include "ui/compositor/layer.h" | 23 #include "ui/compositor/layer.h" |
| 28 #include "ui/gfx/canvas.h" | 24 #include "ui/gfx/canvas.h" |
| 29 #include "ui/gfx/image/image.h" | 25 #include "ui/gfx/image/image.h" |
| 30 #include "ui/gfx/image/image_skia_operations.h" | 26 #include "ui/gfx/image/image_skia_operations.h" |
| 31 #include "ui/gfx/skbitmap_operations.h" | 27 #include "ui/gfx/skbitmap_operations.h" |
| 32 #include "ui/views/accessible_pane_view.h" | 28 #include "ui/views/accessible_pane_view.h" |
| 33 #include "ui/views/widget/widget.h" | 29 #include "ui/views/widget/widget.h" |
| 34 #include "ui/views/widget/widget_delegate.h" | 30 #include "ui/views/widget/widget_delegate.h" |
| 35 #include "ui/wm/public/activation_client.h" | 31 #include "ui/wm/public/activation_client.h" |
| 36 | 32 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 53 shelf_widget_->GetContentsView()->AddChildView(shelf_view_); | 49 shelf_widget_->GetContentsView()->AddChildView(shelf_view_); |
| 54 shelf_widget_->GetNativeView()->SetName(kNativeViewName); | 50 shelf_widget_->GetNativeView()->SetName(kNativeViewName); |
| 55 } | 51 } |
| 56 | 52 |
| 57 Shelf::~Shelf() { | 53 Shelf::~Shelf() { |
| 58 WmShell::Get()->shelf_delegate()->OnShelfDestroyed(this); | 54 WmShell::Get()->shelf_delegate()->OnShelfDestroyed(this); |
| 59 } | 55 } |
| 60 | 56 |
| 61 // static | 57 // static |
| 62 Shelf* Shelf::ForPrimaryDisplay() { | 58 Shelf* Shelf::ForPrimaryDisplay() { |
| 63 return Shelf::ForWindow(Shell::GetPrimaryRootWindow()); | 59 return Shelf::ForWindow(WmShell::Get()->GetPrimaryRootWindow()); |
| 64 } | 60 } |
| 65 | 61 |
| 66 // static | 62 // static |
| 67 Shelf* Shelf::ForWindow(const aura::Window* window) { | 63 Shelf* Shelf::ForWindow(const WmWindow* window) { |
| 64 const aura::Window* aura_window = WmWindowAura::GetAuraWindow(window); |
| 68 ShelfWidget* shelf_widget = | 65 ShelfWidget* shelf_widget = |
| 69 RootWindowController::ForWindow(window)->shelf_widget(); | 66 RootWindowController::ForWindow(aura_window)->shelf_widget(); |
| 70 return shelf_widget ? shelf_widget->shelf() : nullptr; | 67 return shelf_widget ? shelf_widget->shelf() : nullptr; |
| 71 } | 68 } |
| 72 | 69 |
| 73 void Shelf::SetAlignment(ShelfAlignment alignment) { | 70 void Shelf::SetAlignment(ShelfAlignment alignment) { |
| 74 if (alignment_ == alignment) | 71 if (alignment_ == alignment) |
| 75 return; | 72 return; |
| 76 | 73 |
| 77 if (shelf_locking_manager_.is_locked() && | 74 if (shelf_locking_manager_.is_locked() && |
| 78 alignment != SHELF_ALIGNMENT_BOTTOM_LOCKED) { | 75 alignment != SHELF_ALIGNMENT_BOTTOM_LOCKED) { |
| 79 shelf_locking_manager_.set_stored_alignment(alignment); | 76 shelf_locking_manager_.set_stored_alignment(alignment); |
| 80 return; | 77 return; |
| 81 } | 78 } |
| 82 | 79 |
| 83 alignment_ = alignment; | 80 alignment_ = alignment; |
| 84 shelf_view_->OnShelfAlignmentChanged(); | 81 shelf_view_->OnShelfAlignmentChanged(); |
| 85 shelf_widget_->OnShelfAlignmentChanged(); | 82 shelf_widget_->OnShelfAlignmentChanged(); |
| 86 WmShell::Get()->shelf_delegate()->OnShelfAlignmentChanged(this); | 83 WmShell::Get()->shelf_delegate()->OnShelfAlignmentChanged(this); |
| 87 Shell::GetInstance()->OnShelfAlignmentChanged( | 84 WmShell::Get()->NotifyShelfAlignmentChanged( |
| 88 WmWindowAura::Get(shelf_widget_->GetNativeWindow()->GetRootWindow())); | 85 WmLookup::Get()->GetWindowForWidget(shelf_widget_)->GetRootWindow()); |
| 89 // ShelfLayoutManager will resize the shelf. | 86 // ShelfLayoutManager will resize the shelf. |
| 90 } | 87 } |
| 91 | 88 |
| 92 void Shelf::SetAutoHideBehavior(ShelfAutoHideBehavior auto_hide_behavior) { | 89 void Shelf::SetAutoHideBehavior(ShelfAutoHideBehavior auto_hide_behavior) { |
| 93 if (auto_hide_behavior_ == auto_hide_behavior) | 90 if (auto_hide_behavior_ == auto_hide_behavior) |
| 94 return; | 91 return; |
| 95 | 92 |
| 96 auto_hide_behavior_ = auto_hide_behavior; | 93 auto_hide_behavior_ = auto_hide_behavior; |
| 97 WmShell::Get()->shelf_delegate()->OnShelfAutoHideBehaviorChanged(this); | 94 WmShell::Get()->shelf_delegate()->OnShelfAutoHideBehaviorChanged(this); |
| 98 Shell::GetInstance()->OnShelfAutoHideBehaviorChanged( | 95 WmShell::Get()->NotifyShelfAutoHideBehaviorChanged( |
| 99 WmWindowAura::Get(shelf_widget_->GetNativeWindow()->GetRootWindow())); | 96 WmLookup::Get()->GetWindowForWidget(shelf_widget_)->GetRootWindow()); |
| 100 } | 97 } |
| 101 | 98 |
| 102 ShelfAutoHideState Shelf::GetAutoHideState() const { | 99 ShelfAutoHideState Shelf::GetAutoHideState() const { |
| 103 return shelf_widget_->shelf_layout_manager()->auto_hide_state(); | 100 return shelf_widget_->shelf_layout_manager()->auto_hide_state(); |
| 104 } | 101 } |
| 105 | 102 |
| 106 ShelfVisibilityState Shelf::GetVisibilityState() const { | 103 ShelfVisibilityState Shelf::GetVisibilityState() const { |
| 107 return shelf_widget_->shelf_layout_manager()->visibility_state(); | 104 return shelf_widget_->shelf_layout_manager()->visibility_state(); |
| 108 } | 105 } |
| 109 | 106 |
| 110 gfx::Rect Shelf::GetScreenBoundsOfItemIconForWindow( | 107 gfx::Rect Shelf::GetScreenBoundsOfItemIconForWindow(WmWindow* window) { |
| 111 const aura::Window* window) { | 108 ShelfID id = window->GetIntProperty(WmWindowProperty::SHELF_ID); |
| 112 ShelfID id = GetShelfIDForWindow(window); | |
| 113 gfx::Rect bounds(shelf_view_->GetIdealBoundsOfItemIcon(id)); | 109 gfx::Rect bounds(shelf_view_->GetIdealBoundsOfItemIcon(id)); |
| 114 gfx::Point screen_origin; | 110 gfx::Point screen_origin; |
| 115 views::View::ConvertPointToScreen(shelf_view_, &screen_origin); | 111 views::View::ConvertPointToScreen(shelf_view_, &screen_origin); |
| 116 return gfx::Rect(screen_origin.x() + bounds.x(), | 112 return gfx::Rect(screen_origin.x() + bounds.x(), |
| 117 screen_origin.y() + bounds.y(), bounds.width(), | 113 screen_origin.y() + bounds.y(), bounds.width(), |
| 118 bounds.height()); | 114 bounds.height()); |
| 119 } | 115 } |
| 120 | 116 |
| 121 void Shelf::UpdateIconPositionForWindow(aura::Window* window) { | 117 void Shelf::UpdateIconPositionForWindow(WmWindow* window) { |
| 118 WmWindow* shelf_window = WmLookup::Get()->GetWindowForWidget(shelf_widget_); |
| 122 shelf_view_->UpdatePanelIconPosition( | 119 shelf_view_->UpdatePanelIconPosition( |
| 123 GetShelfIDForWindow(window), | 120 window->GetIntProperty(WmWindowProperty::SHELF_ID), |
| 124 ScreenUtil::ConvertRectFromScreen(shelf_widget()->GetNativeView(), | 121 shelf_window->ConvertRectFromScreen(window->GetBoundsInScreen()) |
| 125 window->GetBoundsInScreen()) | |
| 126 .CenterPoint()); | 122 .CenterPoint()); |
| 127 } | 123 } |
| 128 | 124 |
| 129 void Shelf::ActivateShelfItem(int index) { | 125 void Shelf::ActivateShelfItem(int index) { |
| 130 // We pass in a keyboard event which will then trigger a switch to the | 126 // We pass in a keyboard event which will then trigger a switch to the |
| 131 // next item if the current one is already active. | 127 // next item if the current one is already active. |
| 132 ui::KeyEvent event(ui::ET_KEY_RELEASED, | 128 ui::KeyEvent event(ui::ET_KEY_RELEASED, |
| 133 ui::VKEY_UNKNOWN, // The actual key gets ignored. | 129 ui::VKEY_UNKNOWN, // The actual key gets ignored. |
| 134 ui::EF_NONE); | 130 ui::EF_NONE); |
| 135 | 131 |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 | 205 |
| 210 app_list::ApplicationDragAndDropHost* Shelf::GetDragAndDropHostForAppList() { | 206 app_list::ApplicationDragAndDropHost* Shelf::GetDragAndDropHostForAppList() { |
| 211 return shelf_view_; | 207 return shelf_view_; |
| 212 } | 208 } |
| 213 | 209 |
| 214 void Shelf::UpdateShelfItemBackground(int alpha) { | 210 void Shelf::UpdateShelfItemBackground(int alpha) { |
| 215 shelf_view_->UpdateShelfItemBackground(alpha); | 211 shelf_view_->UpdateShelfItemBackground(alpha); |
| 216 } | 212 } |
| 217 | 213 |
| 218 } // namespace ash | 214 } // namespace ash |
| OLD | NEW |