| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/shelf/wm_shelf.h" | 5 #include "ash/common/shelf/wm_shelf.h" |
| 6 | 6 |
| 7 #include "ash/common/shelf/shelf_controller.h" | 7 #include "ash/common/shelf/shelf_controller.h" |
| 8 #include "ash/common/shelf/shelf_delegate.h" | 8 #include "ash/common/shelf/shelf_delegate.h" |
| 9 #include "ash/common/shelf/shelf_item_delegate.h" | 9 #include "ash/common/shelf/shelf_item_delegate.h" |
| 10 #include "ash/common/shelf/shelf_layout_manager.h" | 10 #include "ash/common/shelf/shelf_layout_manager.h" |
| 11 #include "ash/common/shelf/shelf_locking_manager.h" | 11 #include "ash/common/shelf/shelf_locking_manager.h" |
| 12 #include "ash/common/shelf/shelf_model.h" | 12 #include "ash/common/shelf/shelf_model.h" |
| 13 #include "ash/common/shelf/shelf_widget.h" | 13 #include "ash/common/shelf/shelf_widget.h" |
| 14 #include "ash/common/shelf/wm_shelf_observer.h" | 14 #include "ash/common/shelf/wm_shelf_observer.h" |
| 15 #include "ash/common/system/tray/system_tray_delegate.h" | 15 #include "ash/common/system/tray/system_tray_delegate.h" |
| 16 #include "ash/common/wm_shell.h" | 16 #include "ash/common/wm_shell.h" |
| 17 #include "ash/common/wm_window.h" | 17 #include "ash/common/wm_window.h" |
| 18 #include "ash/public/cpp/shell_window_ids.h" | 18 #include "ash/public/cpp/shell_window_ids.h" |
| 19 #include "ash/root_window_controller.h" | 19 #include "ash/root_window_controller.h" |
| 20 #include "ash/shelf/shelf_bezel_event_handler.h" | 20 #include "ash/shelf/shelf_bezel_event_handler.h" |
| 21 #include "ash/shell.h" | 21 #include "ash/shell.h" |
| 22 #include "base/logging.h" | 22 #include "base/logging.h" |
| 23 #include "base/memory/ptr_util.h" | 23 #include "base/memory/ptr_util.h" |
| 24 #include "ui/aura/env.h" | 24 #include "ui/aura/env.h" |
| 25 #include "ui/display/types/display_constants.h" | 25 #include "ui/display/types/display_constants.h" |
| 26 #include "ui/gfx/geometry/rect.h" | 26 #include "ui/gfx/geometry/rect.h" |
| 27 | 27 |
| 28 namespace ash { | 28 namespace ash { |
| 29 | 29 |
| 30 namespace { |
| 31 |
| 32 // A callback that does nothing after shelf item selection handling. |
| 33 void NoopCallback(ShelfAction, ShelfItemDelegate::MenuItemList) {} |
| 34 |
| 35 } // namespace |
| 36 |
| 30 // WmShelf::AutoHideEventHandler ----------------------------------------------- | 37 // WmShelf::AutoHideEventHandler ----------------------------------------------- |
| 31 | 38 |
| 32 // Forwards mouse and gesture events to ShelfLayoutManager for auto-hide. | 39 // Forwards mouse and gesture events to ShelfLayoutManager for auto-hide. |
| 33 // TODO(mash): Add similar event handling support for mash. | 40 // TODO(mash): Add similar event handling support for mash. |
| 34 class WmShelf::AutoHideEventHandler : public ui::EventHandler { | 41 class WmShelf::AutoHideEventHandler : public ui::EventHandler { |
| 35 public: | 42 public: |
| 36 explicit AutoHideEventHandler(ShelfLayoutManager* shelf_layout_manager) | 43 explicit AutoHideEventHandler(ShelfLayoutManager* shelf_layout_manager) |
| 37 : shelf_layout_manager_(shelf_layout_manager) { | 44 : shelf_layout_manager_(shelf_layout_manager) { |
| 38 Shell::GetInstance()->AddPreTargetHandler(this); | 45 Shell::GetInstance()->AddPreTargetHandler(this); |
| 39 } | 46 } |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 // Then set this one as active (or advance to the next item of its kind). | 292 // Then set this one as active (or advance to the next item of its kind). |
| 286 ActivateShelfItem(found_index); | 293 ActivateShelfItem(found_index); |
| 287 } | 294 } |
| 288 } | 295 } |
| 289 | 296 |
| 290 // static | 297 // static |
| 291 void WmShelf::ActivateShelfItem(int item_index) { | 298 void WmShelf::ActivateShelfItem(int item_index) { |
| 292 ShelfModel* shelf_model = WmShell::Get()->shelf_model(); | 299 ShelfModel* shelf_model = WmShell::Get()->shelf_model(); |
| 293 const ShelfItem& item = shelf_model->items()[item_index]; | 300 const ShelfItem& item = shelf_model->items()[item_index]; |
| 294 ShelfItemDelegate* item_delegate = shelf_model->GetShelfItemDelegate(item.id); | 301 ShelfItemDelegate* item_delegate = shelf_model->GetShelfItemDelegate(item.id); |
| 295 item_delegate->ItemSelected(ui::ET_KEY_RELEASED, ui::EF_NONE, | 302 std::unique_ptr<ui::Event> event = base::MakeUnique<ui::KeyEvent>( |
| 296 display::kInvalidDisplayId, LAUNCH_FROM_UNKNOWN); | 303 ui::ET_KEY_RELEASED, ui::VKEY_UNKNOWN, ui::EF_NONE); |
| 304 item_delegate->ItemSelected(std::move(event), display::kInvalidDisplayId, |
| 305 LAUNCH_FROM_UNKNOWN, base::Bind(&NoopCallback)); |
| 297 } | 306 } |
| 298 | 307 |
| 299 bool WmShelf::ProcessGestureEvent(const ui::GestureEvent& event) { | 308 bool WmShelf::ProcessGestureEvent(const ui::GestureEvent& event) { |
| 300 // Can be called at login screen. | 309 // Can be called at login screen. |
| 301 if (!shelf_layout_manager_) | 310 if (!shelf_layout_manager_) |
| 302 return false; | 311 return false; |
| 303 return shelf_layout_manager_->ProcessGestureEvent(event); | 312 return shelf_layout_manager_->ProcessGestureEvent(event); |
| 304 } | 313 } |
| 305 | 314 |
| 306 void WmShelf::AddObserver(WmShelfObserver* observer) { | 315 void WmShelf::AddObserver(WmShelfObserver* observer) { |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 366 | 375 |
| 367 void WmShelf::OnBackgroundUpdated(ShelfBackgroundType background_type, | 376 void WmShelf::OnBackgroundUpdated(ShelfBackgroundType background_type, |
| 368 AnimationChangeType change_type) { | 377 AnimationChangeType change_type) { |
| 369 if (background_type == GetBackgroundType()) | 378 if (background_type == GetBackgroundType()) |
| 370 return; | 379 return; |
| 371 for (auto& observer : observers_) | 380 for (auto& observer : observers_) |
| 372 observer.OnBackgroundTypeChanged(background_type, change_type); | 381 observer.OnBackgroundTypeChanged(background_type, change_type); |
| 373 } | 382 } |
| 374 | 383 |
| 375 } // namespace ash | 384 } // namespace ash |
| OLD | NEW |