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

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: not using default parameter 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/tray/system_tray_notifier.h"
11 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h" 12 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h"
12 #include "ash/common/wm_shell.h" 13 #include "ash/common/wm_shell.h"
13 #include "ash/shell.h" 14 #include "ash/shell.h"
14 #include "ash/wm/lock_state_controller.h" 15 #include "ash/wm/lock_state_controller.h"
15 #include "ash/wm/session_state_animator.h" 16 #include "ash/wm/session_state_animator.h"
16 #include "base/command_line.h" 17 #include "base/command_line.h"
17 #include "ui/aura/window_event_dispatcher.h" 18 #include "ui/aura/window_event_dispatcher.h"
18 #include "ui/display/types/display_snapshot.h" 19 #include "ui/display/types/display_snapshot.h"
19 #include "ui/events/event_handler.h" 20 #include "ui/events/event_handler.h"
20 #include "ui/wm/core/compound_event_filter.h" 21 #include "ui/wm/core/compound_event_filter.h"
21 22
22 #if defined(OS_CHROMEOS) 23 #if defined(OS_CHROMEOS)
24 #include "chromeos/audio/cras_audio_handler.h"
23 #include "chromeos/dbus/dbus_thread_manager.h" 25 #include "chromeos/dbus/dbus_thread_manager.h"
24 #endif 26 #endif
25 27
26 namespace ash { 28 namespace ash {
27 29
28 PowerButtonController::PowerButtonController(LockStateController* controller) 30 PowerButtonController::PowerButtonController(LockStateController* controller)
29 : power_button_down_(false), 31 : power_button_down_(false),
30 lock_button_down_(false), 32 lock_button_down_(false),
31 volume_down_pressed_(false), 33 volume_down_pressed_(false),
34 volume_percent_before_screenshot_(0),
Daniel Erat 2016/07/28 23:57:52 maybe ifdef this too (also in header) since you do
Qiang(Joe) Xu 2016/07/29 04:30:31 Done.
32 brightness_is_zero_(false), 35 brightness_is_zero_(false),
33 internal_display_off_and_external_display_on_(false), 36 internal_display_off_and_external_display_on_(false),
34 has_legacy_power_button_( 37 has_legacy_power_button_(
35 base::CommandLine::ForCurrentProcess()->HasSwitch( 38 base::CommandLine::ForCurrentProcess()->HasSwitch(
36 switches::kAuraLegacyPowerButton)), 39 switches::kAuraLegacyPowerButton)),
37 #if defined(OS_CHROMEOS) 40 #if defined(OS_CHROMEOS)
38 enable_quick_lock_(base::CommandLine::ForCurrentProcess()->HasSwitch( 41 enable_quick_lock_(base::CommandLine::ForCurrentProcess()->HasSwitch(
39 switches::kAshEnableTouchView)), 42 switches::kAshEnableTouchView)),
40 #else 43 #else
41 enable_quick_lock_(false), 44 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 76 // 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 77 // while the screen is off (http://crbug.com/128451), unless an external
75 // display is still on (http://crosbug.com/p/24912). 78 // display is still on (http://crosbug.com/p/24912).
76 if (brightness_is_zero_ && !internal_display_off_and_external_display_on_) 79 if (brightness_is_zero_ && !internal_display_off_and_external_display_on_)
77 return; 80 return;
78 81
79 if (volume_down_pressed_ && down && 82 if (volume_down_pressed_ && down &&
80 WmShell::Get() 83 WmShell::Get()
81 ->maximize_mode_controller() 84 ->maximize_mode_controller()
82 ->IsMaximizeModeWindowManagerEnabled()) { 85 ->IsMaximizeModeWindowManagerEnabled()) {
83 WmShell::Get()->accelerator_controller()->PerformActionIfEnabled( 86 // Notify that maximize mode screenshot is going to be taken. Receiver does
84 TAKE_SCREENSHOT); 87 // preparation work.
88 WmShell* wm_shell = WmShell::Get();
89 wm_shell->system_tray_notifier()->NotifyWillTakeScreenshotInMaximizeMode();
90 wm_shell->accelerator_controller()->PerformActionIfEnabled(TAKE_SCREENSHOT);
91
92 #if defined(OS_CHROMEOS)
93 // Restore volume.
94 chromeos::CrasAudioHandler* audio_handler =
95 chromeos::CrasAudioHandler::Get();
96 audio_handler->SetOutputVolumePercentInQuietMode(
97 volume_percent_before_screenshot_);
98 #endif
85 return; 99 return;
86 } 100 }
87 101
88 const SessionStateDelegate* session_state_delegate = 102 const SessionStateDelegate* session_state_delegate =
89 WmShell::Get()->GetSessionStateDelegate(); 103 WmShell::Get()->GetSessionStateDelegate();
90 if (has_legacy_power_button_) { 104 if (has_legacy_power_button_) {
91 // If power button releases won't get reported correctly because we're not 105 // 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 106 // running on official hardware, just lock the screen or shut down
93 // immediately. 107 // immediately.
94 if (down) { 108 if (down) {
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 if (power_button_down_) 158 if (power_button_down_)
145 return; 159 return;
146 160
147 if (down) 161 if (down)
148 controller_->StartLockAnimation(false); 162 controller_->StartLockAnimation(false);
149 else 163 else
150 controller_->CancelLockAnimation(); 164 controller_->CancelLockAnimation();
151 } 165 }
152 166
153 void PowerButtonController::OnKeyEvent(ui::KeyEvent* event) { 167 void PowerButtonController::OnKeyEvent(ui::KeyEvent* event) {
154 if (event->key_code() == ui::VKEY_VOLUME_DOWN) 168 if (event->key_code() == ui::VKEY_VOLUME_DOWN) {
155 volume_down_pressed_ = event->type() == ui::ET_KEY_PRESSED; 169 volume_down_pressed_ = event->type() == ui::ET_KEY_PRESSED;
170 #if defined(OS_CHROMEOS)
171 if (!event->is_repeat()) {
172 chromeos::CrasAudioHandler* audio_handler =
173 chromeos::CrasAudioHandler::Get();
174 volume_percent_before_screenshot_ =
175 audio_handler->GetOutputVolumePercent();
176 }
177 #endif
178 }
156 } 179 }
157 180
158 #if defined(OS_CHROMEOS) 181 #if defined(OS_CHROMEOS)
159 void PowerButtonController::OnDisplayModeChanged( 182 void PowerButtonController::OnDisplayModeChanged(
160 const ui::DisplayConfigurator::DisplayStateList& display_states) { 183 const ui::DisplayConfigurator::DisplayStateList& display_states) {
161 bool internal_display_off = false; 184 bool internal_display_off = false;
162 bool external_display_on = false; 185 bool external_display_on = false;
163 for (const ui::DisplaySnapshot* display : display_states) { 186 for (const ui::DisplaySnapshot* display : display_states) {
164 if (display->type() == ui::DISPLAY_CONNECTION_TYPE_INTERNAL) { 187 if (display->type() == ui::DISPLAY_CONNECTION_TYPE_INTERNAL) {
165 if (!display->current_mode()) 188 if (!display->current_mode())
166 internal_display_off = true; 189 internal_display_off = true;
167 } else if (display->current_mode()) { 190 } else if (display->current_mode()) {
168 external_display_on = true; 191 external_display_on = true;
169 } 192 }
170 } 193 }
171 internal_display_off_and_external_display_on_ = 194 internal_display_off_and_external_display_on_ =
172 internal_display_off && external_display_on; 195 internal_display_off && external_display_on;
173 } 196 }
174 197
175 void PowerButtonController::PowerButtonEventReceived( 198 void PowerButtonController::PowerButtonEventReceived(
176 bool down, 199 bool down,
177 const base::TimeTicks& timestamp) { 200 const base::TimeTicks& timestamp) {
178 OnPowerButtonEvent(down, timestamp); 201 OnPowerButtonEvent(down, timestamp);
179 } 202 }
180 #endif // defined(OS_CHROMEOS) 203 #endif // defined(OS_CHROMEOS)
181 204
182 } // namespace ash 205 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698