| 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_lookup.h" | 16 #include "ash/common/wm_lookup.h" |
| 17 #include "ash/common/wm_shell.h" | 17 #include "ash/common/wm_shell.h" |
| 18 #include "ash/common/wm_window.h" | 18 #include "ash/common/wm_window.h" |
| 19 #include "ash/public/cpp/shell_window_ids.h" | 19 #include "ash/public/cpp/shell_window_ids.h" |
| 20 #include "ash/root_window_controller.h" | 20 #include "ash/root_window_controller.h" |
| 21 #include "ash/shelf/shelf_bezel_event_handler.h" | 21 #include "ash/shelf/shelf_bezel_event_handler.h" |
| 22 #include "ash/shell.h" | 22 #include "ash/shell.h" |
| 23 #include "base/logging.h" | 23 #include "base/logging.h" |
| 24 #include "base/memory/ptr_util.h" | 24 #include "base/memory/ptr_util.h" |
| 25 #include "ui/aura/env.h" | 25 #include "ui/aura/env.h" |
| 26 #include "ui/display/types/display_constants.h" |
| 26 #include "ui/gfx/geometry/rect.h" | 27 #include "ui/gfx/geometry/rect.h" |
| 27 | 28 |
| 28 namespace ash { | 29 namespace ash { |
| 29 | 30 |
| 30 // WmShelf::AutoHideEventHandler ----------------------------------------------- | 31 // WmShelf::AutoHideEventHandler ----------------------------------------------- |
| 31 | 32 |
| 32 // Forwards mouse and gesture events to ShelfLayoutManager for auto-hide. | 33 // Forwards mouse and gesture events to ShelfLayoutManager for auto-hide. |
| 33 // TODO(mash): Add similar event handling support for mash. | 34 // TODO(mash): Add similar event handling support for mash. |
| 34 class WmShelf::AutoHideEventHandler : public ui::EventHandler { | 35 class WmShelf::AutoHideEventHandler : public ui::EventHandler { |
| 35 public: | 36 public: |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 // found (which is true when indexes_left is -1) or b.) the last item was | 286 // found (which is true when indexes_left is -1) or b.) the last item was |
| 286 // requested (which is true when index was passed in as a negative number). | 287 // requested (which is true when index was passed in as a negative number). |
| 287 if (found_index >= 0 && (indexes_left == -1 || item_index < 0)) { | 288 if (found_index >= 0 && (indexes_left == -1 || item_index < 0)) { |
| 288 // Then set this one as active (or advance to the next item of its kind). | 289 // Then set this one as active (or advance to the next item of its kind). |
| 289 ActivateShelfItem(found_index); | 290 ActivateShelfItem(found_index); |
| 290 } | 291 } |
| 291 } | 292 } |
| 292 | 293 |
| 293 // static | 294 // static |
| 294 void WmShelf::ActivateShelfItem(int item_index) { | 295 void WmShelf::ActivateShelfItem(int item_index) { |
| 295 // We pass in a keyboard event which will then trigger a switch to the | |
| 296 // next item if the current one is already active. | |
| 297 ui::KeyEvent event(ui::ET_KEY_RELEASED, | |
| 298 ui::VKEY_UNKNOWN, // The actual key gets ignored. | |
| 299 ui::EF_NONE); | |
| 300 | |
| 301 ShelfModel* shelf_model = WmShell::Get()->shelf_model(); | 296 ShelfModel* shelf_model = WmShell::Get()->shelf_model(); |
| 302 const ShelfItem& item = shelf_model->items()[item_index]; | 297 const ShelfItem& item = shelf_model->items()[item_index]; |
| 303 ShelfItemDelegate* item_delegate = shelf_model->GetShelfItemDelegate(item.id); | 298 ShelfItemDelegate* item_delegate = shelf_model->GetShelfItemDelegate(item.id); |
| 304 item_delegate->ItemSelected(event); | 299 item_delegate->ItemSelected(ui::ET_KEY_RELEASED, ui::EF_NONE, |
| 300 display::kInvalidDisplayId, LAUNCH_FROM_UNKNOWN); |
| 305 } | 301 } |
| 306 | 302 |
| 307 bool WmShelf::ProcessGestureEvent(const ui::GestureEvent& event) { | 303 bool WmShelf::ProcessGestureEvent(const ui::GestureEvent& event) { |
| 308 // Can be called at login screen. | 304 // Can be called at login screen. |
| 309 if (!shelf_layout_manager_) | 305 if (!shelf_layout_manager_) |
| 310 return false; | 306 return false; |
| 311 return shelf_layout_manager_->ProcessGestureEvent(event); | 307 return shelf_layout_manager_->ProcessGestureEvent(event); |
| 312 } | 308 } |
| 313 | 309 |
| 314 void WmShelf::AddObserver(WmShelfObserver* observer) { | 310 void WmShelf::AddObserver(WmShelfObserver* observer) { |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 374 | 370 |
| 375 void WmShelf::OnBackgroundUpdated(ShelfBackgroundType background_type, | 371 void WmShelf::OnBackgroundUpdated(ShelfBackgroundType background_type, |
| 376 AnimationChangeType change_type) { | 372 AnimationChangeType change_type) { |
| 377 if (background_type == GetBackgroundType()) | 373 if (background_type == GetBackgroundType()) |
| 378 return; | 374 return; |
| 379 for (auto& observer : observers_) | 375 for (auto& observer : observers_) |
| 380 observer.OnBackgroundTypeChanged(background_type, change_type); | 376 observer.OnBackgroundTypeChanged(background_type, change_type); |
| 381 } | 377 } |
| 382 | 378 |
| 383 } // namespace ash | 379 } // namespace ash |
| OLD | NEW |