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

Side by Side Diff: ash/common/shelf/wm_shelf.cc

Issue 2696073002: Merge ShelfItemDelegate::ItemSelected & LauncherItemDelegate::Activate. (Closed)
Patch Set: Cleanup Created 3 years, 10 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
OLDNEW
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/display.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
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 int64_t display_id = display::Screen::GetScreen()->GetPrimaryDisplay().id();
300 item_delegate->ItemSelected(ui::ET_KEY_RELEASED, ui::EF_NONE, display_id,
301 LAUNCH_FROM_UNKNOWN);
305 } 302 }
306 303
307 bool WmShelf::ProcessGestureEvent(const ui::GestureEvent& event) { 304 bool WmShelf::ProcessGestureEvent(const ui::GestureEvent& event) {
308 // Can be called at login screen. 305 // Can be called at login screen.
309 if (!shelf_layout_manager_) 306 if (!shelf_layout_manager_)
310 return false; 307 return false;
311 return shelf_layout_manager_->ProcessGestureEvent(event); 308 return shelf_layout_manager_->ProcessGestureEvent(event);
312 } 309 }
313 310
314 void WmShelf::AddObserver(WmShelfObserver* observer) { 311 void WmShelf::AddObserver(WmShelfObserver* observer) {
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 371
375 void WmShelf::OnBackgroundUpdated(ShelfBackgroundType background_type, 372 void WmShelf::OnBackgroundUpdated(ShelfBackgroundType background_type,
376 AnimationChangeType change_type) { 373 AnimationChangeType change_type) {
377 if (background_type == GetBackgroundType()) 374 if (background_type == GetBackgroundType())
378 return; 375 return;
379 for (auto& observer : observers_) 376 for (auto& observer : observers_)
380 observer.OnBackgroundTypeChanged(background_type, change_type); 377 observer.OnBackgroundTypeChanged(background_type, change_type);
381 } 378 }
382 379
383 } // namespace ash 380 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698