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" | |
10 #include "ash/common/shelf/shelf_layout_manager.h" | 9 #include "ash/common/shelf/shelf_layout_manager.h" |
11 #include "ash/common/shelf/shelf_locking_manager.h" | 10 #include "ash/common/shelf/shelf_locking_manager.h" |
12 #include "ash/common/shelf/shelf_model.h" | 11 #include "ash/common/shelf/shelf_model.h" |
13 #include "ash/common/shelf/shelf_widget.h" | 12 #include "ash/common/shelf/shelf_widget.h" |
14 #include "ash/common/shelf/wm_shelf_observer.h" | 13 #include "ash/common/shelf/wm_shelf_observer.h" |
15 #include "ash/common/system/tray/system_tray_delegate.h" | 14 #include "ash/common/system/tray/system_tray_delegate.h" |
16 #include "ash/common/wm_shell.h" | 15 #include "ash/common/wm_shell.h" |
17 #include "ash/common/wm_window.h" | 16 #include "ash/common/wm_window.h" |
18 #include "ash/public/cpp/shell_window_ids.h" | 17 #include "ash/public/cpp/shell_window_ids.h" |
18 #include "ash/public/interfaces/shelf.mojom.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, std::vector<mojom::MenuItemPtr>) {} | |
James Cook
2017/03/10 16:56:01
btw, I like how you leave out the argument names o
msw
2017/03/10 20:44:45
Acknowledged.
| |
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 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
284 if (found_index >= 0 && (indexes_left == -1 || item_index < 0)) { | 291 if (found_index >= 0 && (indexes_left == -1 || item_index < 0)) { |
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 mojom::ShelfItemDelegate* item_delegate = |
295 item_delegate->ItemSelected(ui::ET_KEY_RELEASED, ui::EF_NONE, | 302 shelf_model->GetShelfItemDelegate(item.id); |
296 display::kInvalidDisplayId, LAUNCH_FROM_UNKNOWN); | 303 std::unique_ptr<ui::Event> event = base::MakeUnique<ui::KeyEvent>( |
304 ui::ET_KEY_RELEASED, ui::VKEY_UNKNOWN, ui::EF_NONE); | |
305 item_delegate->ItemSelected(std::move(event), display::kInvalidDisplayId, | |
306 LAUNCH_FROM_UNKNOWN, base::Bind(&NoopCallback)); | |
297 } | 307 } |
298 | 308 |
299 bool WmShelf::ProcessGestureEvent(const ui::GestureEvent& event) { | 309 bool WmShelf::ProcessGestureEvent(const ui::GestureEvent& event) { |
300 // Can be called at login screen. | 310 // Can be called at login screen. |
301 if (!shelf_layout_manager_) | 311 if (!shelf_layout_manager_) |
302 return false; | 312 return false; |
303 return shelf_layout_manager_->ProcessGestureEvent(event); | 313 return shelf_layout_manager_->ProcessGestureEvent(event); |
304 } | 314 } |
305 | 315 |
306 void WmShelf::AddObserver(WmShelfObserver* observer) { | 316 void WmShelf::AddObserver(WmShelfObserver* observer) { |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
366 | 376 |
367 void WmShelf::OnBackgroundUpdated(ShelfBackgroundType background_type, | 377 void WmShelf::OnBackgroundUpdated(ShelfBackgroundType background_type, |
368 AnimationChangeType change_type) { | 378 AnimationChangeType change_type) { |
369 if (background_type == GetBackgroundType()) | 379 if (background_type == GetBackgroundType()) |
370 return; | 380 return; |
371 for (auto& observer : observers_) | 381 for (auto& observer : observers_) |
372 observer.OnBackgroundTypeChanged(background_type, change_type); | 382 observer.OnBackgroundTypeChanged(background_type, change_type); |
373 } | 383 } |
374 | 384 |
375 } // namespace ash | 385 } // namespace ash |
OLD | NEW |