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

Side by Side Diff: ash/system/overview/overview_button_tray.cc

Issue 2882073004: wm: Allow double tap on overview button to quick switch. (Closed)
Patch Set: Use tap_count(). Created 3 years, 7 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/system/overview/overview_button_tray.h" 5 #include "ash/system/overview/overview_button_tray.h"
6 6
7 #include "ash/resources/vector_icons/vector_icons.h" 7 #include "ash/resources/vector_icons/vector_icons.h"
8 #include "ash/session/session_controller.h" 8 #include "ash/session/session_controller.h"
9 #include "ash/shelf/shelf_constants.h" 9 #include "ash/shelf/shelf_constants.h"
10 #include "ash/shell.h" 10 #include "ash/shell.h"
11 #include "ash/shell_port.h" 11 #include "ash/shell_port.h"
12 #include "ash/strings/grit/ash_strings.h" 12 #include "ash/strings/grit/ash_strings.h"
13 #include "ash/system/tray/tray_constants.h" 13 #include "ash/system/tray/tray_constants.h"
14 #include "ash/system/tray/tray_container.h" 14 #include "ash/system/tray/tray_container.h"
15 #include "ash/wm/maximize_mode/maximize_mode_controller.h" 15 #include "ash/wm/maximize_mode/maximize_mode_controller.h"
16 #include "ash/wm/mru_window_tracker.h"
16 #include "ash/wm/overview/window_selector_controller.h" 17 #include "ash/wm/overview/window_selector_controller.h"
18 #include "ash/wm_window.h"
17 #include "ui/base/l10n/l10n_util.h" 19 #include "ui/base/l10n/l10n_util.h"
18 #include "ui/gfx/paint_vector_icon.h" 20 #include "ui/gfx/paint_vector_icon.h"
19 #include "ui/views/border.h" 21 #include "ui/views/border.h"
20 #include "ui/views/controls/image_view.h" 22 #include "ui/views/controls/image_view.h"
23 #include "ui/wm/core/window_util.h"
21 24
22 namespace ash { 25 namespace ash {
23 26
24 OverviewButtonTray::OverviewButtonTray(WmShelf* wm_shelf) 27 OverviewButtonTray::OverviewButtonTray(WmShelf* wm_shelf)
25 : TrayBackgroundView(wm_shelf), 28 : TrayBackgroundView(wm_shelf),
26 icon_(new views::ImageView()), 29 icon_(new views::ImageView()),
27 scoped_session_observer_(this) { 30 scoped_session_observer_(this) {
28 SetInkDropMode(InkDropMode::ON); 31 SetInkDropMode(InkDropMode::ON);
29 32
30 gfx::ImageSkia image = 33 gfx::ImageSkia image =
(...skipping 14 matching lines...) Expand all
45 48
46 OverviewButtonTray::~OverviewButtonTray() { 49 OverviewButtonTray::~OverviewButtonTray() {
47 Shell::Get()->RemoveShellObserver(this); 50 Shell::Get()->RemoveShellObserver(this);
48 } 51 }
49 52
50 void OverviewButtonTray::UpdateAfterLoginStatusChange(LoginStatus status) { 53 void OverviewButtonTray::UpdateAfterLoginStatusChange(LoginStatus status) {
51 UpdateIconVisibility(); 54 UpdateIconVisibility();
52 } 55 }
53 56
54 bool OverviewButtonTray::PerformAction(const ui::Event& event) { 57 bool OverviewButtonTray::PerformAction(const ui::Event& event) {
58 if (event.type() == ui::ET_GESTURE_TAP) {
59 if (event.AsGestureEvent()->details().tap_count() == 2) {
60 // Ignore double taps if we are on the window selection page.
61 if (Shell::Get()->window_selector_controller()->IsSelecting())
62 return true;
63
64 MruWindowTracker::WindowList mru_window_list =
65 Shell::Get()->mru_window_tracker()->BuildMruWindowList();
66
67 // Switch to the second most recently used window (most recent is the
68 // current window), if it exists.
69 if (mru_window_list.size() > 1) {
70 AnimateInkDrop(views::InkDropState::DEACTIVATED, nullptr);
71 ::wm::ActivateWindow(WmWindow::GetAuraWindow(mru_window_list[1]));
72 return true;
73 }
74 }
75 }
76
55 WindowSelectorController* controller = 77 WindowSelectorController* controller =
56 Shell::Get()->window_selector_controller(); 78 Shell::Get()->window_selector_controller();
57 // Toggling overview mode will fail if there is no window to show. 79 // Note: Toggling overview mode will fail if there is no window to show, the
80 // screen is locked, a modal dialog is open or is running in kiosk app
81 // session.
58 bool performed = controller->ToggleOverview(); 82 bool performed = controller->ToggleOverview();
59 ShellPort::Get()->RecordUserMetricsAction(UMA_TRAY_OVERVIEW); 83 ShellPort::Get()->RecordUserMetricsAction(UMA_TRAY_OVERVIEW);
60 return performed; 84 return performed;
61 } 85 }
62 86
63 void OverviewButtonTray::OnSessionStateChanged( 87 void OverviewButtonTray::OnSessionStateChanged(
64 session_manager::SessionState state) { 88 session_manager::SessionState state) {
65 UpdateIconVisibility(); 89 UpdateIconVisibility();
66 } 90 }
67 91
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 SetVisible( 127 SetVisible(
104 shell->maximize_mode_controller()->IsMaximizeModeWindowManagerEnabled() && 128 shell->maximize_mode_controller()->IsMaximizeModeWindowManagerEnabled() &&
105 session_controller->IsActiveUserSessionStarted() && 129 session_controller->IsActiveUserSessionStarted() &&
106 !session_controller->IsScreenLocked() && 130 !session_controller->IsScreenLocked() &&
107 session_controller->GetSessionState() == 131 session_controller->GetSessionState() ==
108 session_manager::SessionState::ACTIVE && 132 session_manager::SessionState::ACTIVE &&
109 !session_controller->IsKioskSession()); 133 !session_controller->IsKioskSession());
110 } 134 }
111 135
112 } // namespace ash 136 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698