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/shelf/shelf.h" | 5 #include "ash/shelf/shelf.h" |
6 | 6 |
7 #include "ash/public/cpp/config.h" | 7 #include "ash/public/cpp/config.h" |
8 #include "ash/public/cpp/shelf_item_delegate.h" | 8 #include "ash/public/cpp/shelf_item_delegate.h" |
9 #include "ash/public/cpp/shell_window_ids.h" | 9 #include "ash/public/cpp/shell_window_ids.h" |
10 #include "ash/root_window_controller.h" | 10 #include "ash/root_window_controller.h" |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 // found (which is true when indexes_left is -1) or b.) the last item was | 267 // found (which is true when indexes_left is -1) or b.) the last item was |
268 // requested (which is true when index was passed in as a negative number). | 268 // requested (which is true when index was passed in as a negative number). |
269 if (found_index >= 0 && (indexes_left == -1 || item_index < 0)) { | 269 if (found_index >= 0 && (indexes_left == -1 || item_index < 0)) { |
270 // Then set this one as active (or advance to the next item of its kind). | 270 // Then set this one as active (or advance to the next item of its kind). |
271 ActivateShelfItem(found_index); | 271 ActivateShelfItem(found_index); |
272 } | 272 } |
273 } | 273 } |
274 | 274 |
275 // static | 275 // static |
276 void Shelf::ActivateShelfItem(int item_index) { | 276 void Shelf::ActivateShelfItem(int item_index) { |
| 277 ActivateShelfItemOnDisplay(item_index, display::kInvalidDisplayId); |
| 278 } |
| 279 |
| 280 // static |
| 281 void Shelf::ActivateShelfItemOnDisplay(int item_index, int64_t display_id) { |
277 ShelfModel* shelf_model = Shell::Get()->shelf_model(); | 282 ShelfModel* shelf_model = Shell::Get()->shelf_model(); |
278 const ShelfItem& item = shelf_model->items()[item_index]; | 283 const ShelfItem& item = shelf_model->items()[item_index]; |
279 ShelfItemDelegate* item_delegate = shelf_model->GetShelfItemDelegate(item.id); | 284 ShelfItemDelegate* item_delegate = shelf_model->GetShelfItemDelegate(item.id); |
280 std::unique_ptr<ui::Event> event = base::MakeUnique<ui::KeyEvent>( | 285 std::unique_ptr<ui::Event> event = base::MakeUnique<ui::KeyEvent>( |
281 ui::ET_KEY_RELEASED, ui::VKEY_UNKNOWN, ui::EF_NONE); | 286 ui::ET_KEY_RELEASED, ui::VKEY_UNKNOWN, ui::EF_NONE); |
282 item_delegate->ItemSelected(std::move(event), display::kInvalidDisplayId, | 287 item_delegate->ItemSelected(std::move(event), display_id, LAUNCH_FROM_UNKNOWN, |
283 LAUNCH_FROM_UNKNOWN, base::Bind(&NoopCallback)); | 288 base::Bind(&NoopCallback)); |
284 } | 289 } |
285 | 290 |
286 bool Shelf::ProcessGestureEvent(const ui::GestureEvent& event) { | 291 bool Shelf::ProcessGestureEvent(const ui::GestureEvent& event) { |
287 // Can be called at login screen. | 292 // Can be called at login screen. |
288 if (!shelf_layout_manager_) | 293 if (!shelf_layout_manager_) |
289 return false; | 294 return false; |
290 return shelf_layout_manager_->ProcessGestureEvent(event); | 295 return shelf_layout_manager_->ProcessGestureEvent(event); |
291 } | 296 } |
292 | 297 |
293 void Shelf::AddObserver(ShelfObserver* observer) { | 298 void Shelf::AddObserver(ShelfObserver* observer) { |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
353 | 358 |
354 void Shelf::OnBackgroundUpdated(ShelfBackgroundType background_type, | 359 void Shelf::OnBackgroundUpdated(ShelfBackgroundType background_type, |
355 AnimationChangeType change_type) { | 360 AnimationChangeType change_type) { |
356 if (background_type == GetBackgroundType()) | 361 if (background_type == GetBackgroundType()) |
357 return; | 362 return; |
358 for (auto& observer : observers_) | 363 for (auto& observer : observers_) |
359 observer.OnBackgroundTypeChanged(background_type, change_type); | 364 observer.OnBackgroundTypeChanged(background_type, change_type); |
360 } | 365 } |
361 | 366 |
362 } // namespace ash | 367 } // namespace ash |
OLD | NEW |