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

Side by Side Diff: ash/wm/power_button_controller.cc

Issue 2190773002: Fix Volume slider is captured in screenshot done in touchview mode (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: several updates included Created 4 years, 4 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/wm/power_button_controller.h" 5 #include "ash/wm/power_button_controller.h"
6 6
7 #include "ash/common/accelerators/accelerator_controller.h" 7 #include "ash/common/accelerators/accelerator_controller.h"
8 #include "ash/common/ash_switches.h" 8 #include "ash/common/ash_switches.h"
9 #include "ash/common/session/session_state_delegate.h" 9 #include "ash/common/session/session_state_delegate.h"
10 #include "ash/common/shell_window_ids.h" 10 #include "ash/common/shell_window_ids.h"
11 #include "ash/common/system/audio/tray_audio.h"
12 #include "ash/common/system/tray/system_tray.h"
11 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h" 13 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h"
12 #include "ash/common/wm_shell.h" 14 #include "ash/common/wm_shell.h"
13 #include "ash/shell.h" 15 #include "ash/shell.h"
14 #include "ash/wm/lock_state_controller.h" 16 #include "ash/wm/lock_state_controller.h"
15 #include "ash/wm/session_state_animator.h" 17 #include "ash/wm/session_state_animator.h"
16 #include "base/command_line.h" 18 #include "base/command_line.h"
17 #include "ui/aura/window_event_dispatcher.h" 19 #include "ui/aura/window_event_dispatcher.h"
18 #include "ui/display/types/display_snapshot.h" 20 #include "ui/display/types/display_snapshot.h"
19 #include "ui/events/event_handler.h" 21 #include "ui/events/event_handler.h"
20 #include "ui/wm/core/compound_event_filter.h" 22 #include "ui/wm/core/compound_event_filter.h"
21 23
22 #if defined(OS_CHROMEOS) 24 #if defined(OS_CHROMEOS)
25 #include "chromeos/audio/cras_audio_handler.h"
23 #include "chromeos/dbus/dbus_thread_manager.h" 26 #include "chromeos/dbus/dbus_thread_manager.h"
24 #endif 27 #endif
25 28
26 namespace ash { 29 namespace ash {
27 30
28 PowerButtonController::PowerButtonController(LockStateController* controller) 31 PowerButtonController::PowerButtonController(LockStateController* controller)
29 : power_button_down_(false), 32 : power_button_down_(false),
30 lock_button_down_(false), 33 lock_button_down_(false),
31 volume_down_pressed_(false), 34 volume_down_pressed_(false),
35 #if defined(OS_CHROMEOS)
36 volume_percent_before_screenshot_(0),
37 #endif
32 brightness_is_zero_(false), 38 brightness_is_zero_(false),
33 internal_display_off_and_external_display_on_(false), 39 internal_display_off_and_external_display_on_(false),
34 has_legacy_power_button_( 40 has_legacy_power_button_(
35 base::CommandLine::ForCurrentProcess()->HasSwitch( 41 base::CommandLine::ForCurrentProcess()->HasSwitch(
36 switches::kAuraLegacyPowerButton)), 42 switches::kAuraLegacyPowerButton)),
37 #if defined(OS_CHROMEOS) 43 #if defined(OS_CHROMEOS)
38 enable_quick_lock_(base::CommandLine::ForCurrentProcess()->HasSwitch( 44 enable_quick_lock_(base::CommandLine::ForCurrentProcess()->HasSwitch(
39 switches::kAshEnableTouchView)), 45 switches::kAshEnableTouchView)),
40 #else 46 #else
41 enable_quick_lock_(false), 47 enable_quick_lock_(false),
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 // Avoid starting the lock/shutdown sequence if the power button is pressed 79 // Avoid starting the lock/shutdown sequence if the power button is pressed
74 // while the screen is off (http://crbug.com/128451), unless an external 80 // while the screen is off (http://crbug.com/128451), unless an external
75 // display is still on (http://crosbug.com/p/24912). 81 // display is still on (http://crosbug.com/p/24912).
76 if (brightness_is_zero_ && !internal_display_off_and_external_display_on_) 82 if (brightness_is_zero_ && !internal_display_off_and_external_display_on_)
77 return; 83 return;
78 84
79 if (volume_down_pressed_ && down && 85 if (volume_down_pressed_ && down &&
80 WmShell::Get() 86 WmShell::Get()
81 ->maximize_mode_controller() 87 ->maximize_mode_controller()
82 ->IsMaximizeModeWindowManagerEnabled()) { 88 ->IsMaximizeModeWindowManagerEnabled()) {
89 SystemTray* system_tray = Shell::GetInstance()->GetPrimarySystemTray();
90 if (system_tray && system_tray->GetTrayAudio())
91 system_tray->GetTrayAudio()->HideDetailedView(false);
92
83 WmShell::Get()->accelerator_controller()->PerformActionIfEnabled( 93 WmShell::Get()->accelerator_controller()->PerformActionIfEnabled(
84 TAKE_SCREENSHOT); 94 TAKE_SCREENSHOT);
95
96 #if defined(OS_CHROMEOS)
97 // Restore volume.
98 chromeos::CrasAudioHandler* audio_handler =
99 chromeos::CrasAudioHandler::Get();
100 audio_handler->SetOutputVolumePercentWithoutNotifyingObservers(
101 volume_percent_before_screenshot_,
102 chromeos::CrasAudioHandler::VOLUME_CHANGE_MAXIMIZE_MODE_SCREENSHOT);
103 #endif
85 return; 104 return;
86 } 105 }
87 106
88 const SessionStateDelegate* session_state_delegate = 107 const SessionStateDelegate* session_state_delegate =
89 WmShell::Get()->GetSessionStateDelegate(); 108 WmShell::Get()->GetSessionStateDelegate();
90 if (has_legacy_power_button_) { 109 if (has_legacy_power_button_) {
91 // If power button releases won't get reported correctly because we're not 110 // If power button releases won't get reported correctly because we're not
92 // running on official hardware, just lock the screen or shut down 111 // running on official hardware, just lock the screen or shut down
93 // immediately. 112 // immediately.
94 if (down) { 113 if (down) {
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 if (power_button_down_) 163 if (power_button_down_)
145 return; 164 return;
146 165
147 if (down) 166 if (down)
148 controller_->StartLockAnimation(false); 167 controller_->StartLockAnimation(false);
149 else 168 else
150 controller_->CancelLockAnimation(); 169 controller_->CancelLockAnimation();
151 } 170 }
152 171
153 void PowerButtonController::OnKeyEvent(ui::KeyEvent* event) { 172 void PowerButtonController::OnKeyEvent(ui::KeyEvent* event) {
154 if (event->key_code() == ui::VKEY_VOLUME_DOWN) 173 if (event->key_code() == ui::VKEY_VOLUME_DOWN) {
155 volume_down_pressed_ = event->type() == ui::ET_KEY_PRESSED; 174 volume_down_pressed_ = event->type() == ui::ET_KEY_PRESSED;
175 #if defined(OS_CHROMEOS)
176 if (!event->is_repeat()) {
177 chromeos::CrasAudioHandler* audio_handler =
178 chromeos::CrasAudioHandler::Get();
179 volume_percent_before_screenshot_ =
180 audio_handler->GetOutputVolumePercent();
181 }
182 #endif
183 }
156 } 184 }
157 185
158 #if defined(OS_CHROMEOS) 186 #if defined(OS_CHROMEOS)
159 void PowerButtonController::OnDisplayModeChanged( 187 void PowerButtonController::OnDisplayModeChanged(
160 const ui::DisplayConfigurator::DisplayStateList& display_states) { 188 const ui::DisplayConfigurator::DisplayStateList& display_states) {
161 bool internal_display_off = false; 189 bool internal_display_off = false;
162 bool external_display_on = false; 190 bool external_display_on = false;
163 for (const ui::DisplaySnapshot* display : display_states) { 191 for (const ui::DisplaySnapshot* display : display_states) {
164 if (display->type() == ui::DISPLAY_CONNECTION_TYPE_INTERNAL) { 192 if (display->type() == ui::DISPLAY_CONNECTION_TYPE_INTERNAL) {
165 if (!display->current_mode()) 193 if (!display->current_mode())
166 internal_display_off = true; 194 internal_display_off = true;
167 } else if (display->current_mode()) { 195 } else if (display->current_mode()) {
168 external_display_on = true; 196 external_display_on = true;
169 } 197 }
170 } 198 }
171 internal_display_off_and_external_display_on_ = 199 internal_display_off_and_external_display_on_ =
172 internal_display_off && external_display_on; 200 internal_display_off && external_display_on;
173 } 201 }
174 202
175 void PowerButtonController::PowerButtonEventReceived( 203 void PowerButtonController::PowerButtonEventReceived(
176 bool down, 204 bool down,
177 const base::TimeTicks& timestamp) { 205 const base::TimeTicks& timestamp) {
178 OnPowerButtonEvent(down, timestamp); 206 OnPowerButtonEvent(down, timestamp);
179 } 207 }
180 #endif // defined(OS_CHROMEOS) 208 #endif // defined(OS_CHROMEOS)
181 209
182 } // namespace ash 210 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698