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

Unified Diff: ash/system/chromeos/power/tablet_power_button_controller.cc

Issue 2533373002: Enabled/disable touch screen in TabletPowerButtonController (Closed)
Patch Set: nits Created 4 years 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 side-by-side diff with in-line comments
Download patch
Index: ash/system/chromeos/power/tablet_power_button_controller.cc
diff --git a/ash/system/chromeos/power/tablet_power_button_controller.cc b/ash/system/chromeos/power/tablet_power_button_controller.cc
index bd52b98a83a518168425597b1184b32e571aa33d..66841d16597b65f645e36c4b68846202ecc4625e 100644
--- a/ash/system/chromeos/power/tablet_power_button_controller.cc
+++ b/ash/system/chromeos/power/tablet_power_button_controller.cc
@@ -6,6 +6,7 @@
#include "ash/common/accessibility_delegate.h"
#include "ash/common/session/session_state_delegate.h"
+#include "ash/common/shell_delegate.h"
#include "ash/common/wm/maximize_mode/maximize_mode_controller.h"
#include "ash/common/wm_shell.h"
#include "ash/shell.h"
@@ -96,24 +97,27 @@ void TabletPowerButtonController::OnPowerButtonEvent(
// backlight has been turned back on before seeing the power button events
// that woke the system. Ignore events just after resuming to ensure that we
// don't turn the screen off in response to the events.
+ //
+ // TODO(warx): pressing power button should also StartShutdownTimer() in this
+ // case. Reorganize the code to support that.
if (timestamp - last_resume_time_ <=
base::TimeDelta::FromMilliseconds(kIgnorePowerButtonAfterResumeMs)) {
// If backlights are forced off, stop forcing off because resuming system
// doesn't handle this.
if (down && backlights_forced_off_)
- SetBacklightsForcedOff(false);
+ SetDisplayForcedOff(false);
return;
}
if (down) {
screen_off_when_power_button_down_ = brightness_level_is_zero_;
- SetBacklightsForcedOff(false);
+ SetDisplayForcedOff(false);
StartShutdownTimer();
} else {
if (shutdown_timer_.IsRunning()) {
shutdown_timer_.Stop();
if (!screen_off_when_power_button_down_) {
- SetBacklightsForcedOff(true);
+ SetDisplayForcedOff(true);
LockScreenIfRequired();
}
}
@@ -149,7 +153,7 @@ void TabletPowerButtonController::OnKeyEvent(ui::KeyEvent* event) {
return;
if (!IsTabletModeActive() && backlights_forced_off_)
- SetBacklightsForcedOff(false);
+ SetDisplayForcedOff(false);
}
void TabletPowerButtonController::OnMouseEvent(ui::MouseEvent* event) {
@@ -161,13 +165,13 @@ void TabletPowerButtonController::OnMouseEvent(ui::MouseEvent* event) {
}
if (!IsTabletModeActive() && backlights_forced_off_)
- SetBacklightsForcedOff(false);
+ SetDisplayForcedOff(false);
}
void TabletPowerButtonController::OnStylusStateChanged(ui::StylusState state) {
if (IsTabletModeSupported() && state == ui::StylusState::REMOVED &&
backlights_forced_off_) {
- SetBacklightsForcedOff(false);
+ SetDisplayForcedOff(false);
}
}
@@ -177,15 +181,21 @@ void TabletPowerButtonController::SetTickClockForTesting(
tick_clock_ = std::move(tick_clock);
}
-void TabletPowerButtonController::SetBacklightsForcedOff(bool forced_off) {
+void TabletPowerButtonController::SetDisplayForcedOff(bool forced_off) {
if (backlights_forced_off_ == forced_off)
return;
+ // Set the display and keyboard backlights (if present) to |forced_off|.
chromeos::DBusThreadManager::Get()
->GetPowerManagerClient()
->SetBacklightsForcedOff(forced_off);
backlights_forced_off_ = forced_off;
+ ShellDelegate* delegate = WmShell::Get()->delegate();
+ delegate->SetTouchscreenEnabledInPrefs(!forced_off,
+ true /* use_local_state */);
+ delegate->UpdateTouchscreenStatusFromPrefs();
+
// Send an a11y alert.
WmShell::Get()->accessibility_delegate()->TriggerAccessibilityAlert(
forced_off ? A11Y_ALERT_SCREEN_OFF : A11Y_ALERT_SCREEN_ON);

Powered by Google App Engine
This is Rietveld 408576698