diff options
author | oshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-26 21:59:40 +0000 |
---|---|---|
committer | oshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-26 21:59:40 +0000 |
commit | 2f47c0a61a8477021dbbb6ff034a1bd9157076dd (patch) | |
tree | e7b03cdea066712c401fb0267b89807e2e58c16d | |
parent | 61520982769181322a9363604782e3084142b210 (diff) | |
download | chromium_src-2f47c0a61a8477021dbbb6ff034a1bd9157076dd.zip chromium_src-2f47c0a61a8477021dbbb6ff034a1bd9157076dd.tar.gz chromium_src-2f47c0a61a8477021dbbb6ff034a1bd9157076dd.tar.bz2 |
Merge 163723 - Ignore next mouse event when all displays are turned off due to idleness
BUG=chromium-os:35568
TEST=manually tested on the device (see bug for repro step). Also added test case for this.
Review URL: https://chromiumcodereview.appspot.com/11227060
TBR=oshima@chromium.org
Review URL: https://codereview.chromium.org/11305015
git-svn-id: svn://svn.chromium.org/chrome/branches/1271/src@164423 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | ash/wm/user_activity_detector.cc | 11 | ||||
-rw-r--r-- | ash/wm/user_activity_detector.h | 8 | ||||
-rw-r--r-- | ash/wm/user_activity_detector_unittest.cc | 7 | ||||
-rw-r--r-- | chrome/browser/chromeos/power/output_observer.cc | 9 |
4 files changed, 33 insertions, 2 deletions
diff --git a/ash/wm/user_activity_detector.cc b/ash/wm/user_activity_detector.cc index 8632b95..469da42 100644 --- a/ash/wm/user_activity_detector.cc +++ b/ash/wm/user_activity_detector.cc @@ -12,7 +12,7 @@ namespace ash { const double UserActivityDetector::kNotifyIntervalMs = 200.0; -UserActivityDetector::UserActivityDetector() { +UserActivityDetector::UserActivityDetector() : ignore_next_mouse_event_(false) { } UserActivityDetector::~UserActivityDetector() { @@ -30,6 +30,10 @@ void UserActivityDetector::RemoveObserver(UserActivityObserver* observer) { observers_.RemoveObserver(observer); } +void UserActivityDetector::OnAllOutputsTurnedOff() { + ignore_next_mouse_event_ = true; +} + bool UserActivityDetector::PreHandleKeyEvent(aura::Window* target, ui::KeyEvent* event) { MaybeNotify(); @@ -38,8 +42,11 @@ bool UserActivityDetector::PreHandleKeyEvent(aura::Window* target, bool UserActivityDetector::PreHandleMouseEvent(aura::Window* target, ui::MouseEvent* event) { - if (!(event->flags() & ui::EF_IS_SYNTHESIZED)) + VLOG_IF(1, ignore_next_mouse_event_) << "ignoring mouse event"; + if (!(event->flags() & ui::EF_IS_SYNTHESIZED) && + !ignore_next_mouse_event_) MaybeNotify(); + ignore_next_mouse_event_ = false; return false; } diff --git a/ash/wm/user_activity_detector.h b/ash/wm/user_activity_detector.h index 3bf6516..03a6338 100644 --- a/ash/wm/user_activity_detector.h +++ b/ash/wm/user_activity_detector.h @@ -32,6 +32,9 @@ class ASH_EXPORT UserActivityDetector : public aura::EventFilter { void AddObserver(UserActivityObserver* observer); void RemoveObserver(UserActivityObserver* observer); + // Called when chrome has received a request to turn of all displays. + void OnAllOutputsTurnedOff(); + // aura::EventFilter implementation. virtual bool PreHandleKeyEvent( aura::Window* target, @@ -59,6 +62,11 @@ class ASH_EXPORT UserActivityDetector : public aura::EventFilter { // simulate the passage of time. base::TimeTicks now_for_test_; + // When this is true, the next mouse event is ignored. This is to + // avoid mis-detecting a mouse enter event that occurs when turning + // off display as a user activity. + bool ignore_next_mouse_event_; + DISALLOW_COPY_AND_ASSIGN(UserActivityDetector); }; diff --git a/ash/wm/user_activity_detector_unittest.cc b/ash/wm/user_activity_detector_unittest.cc index abbc55f..d614975 100644 --- a/ash/wm/user_activity_detector_unittest.cc +++ b/ash/wm/user_activity_detector_unittest.cc @@ -96,6 +96,13 @@ TEST_F(UserActivityDetectorTest, Basic) { EXPECT_EQ(1, observer_->num_invocations()); observer_->reset_stats(); + // Ignore one mouse event when all displays are turned off. + detector_->OnAllOutputsTurnedOff(); + AdvanceTime(advance_delta); + EXPECT_FALSE(detector_->PreHandleMouseEvent(window.get(), &mouse_event)); + EXPECT_EQ(0, observer_->num_invocations()); + observer_->reset_stats(); + AdvanceTime(advance_delta); ui::TouchEvent touch_event( ui::ET_TOUCH_PRESSED, gfx::Point(), 0, base::TimeDelta()); diff --git a/chrome/browser/chromeos/power/output_observer.cc b/chrome/browser/chromeos/power/output_observer.cc index 9b8c221..24e573e 100644 --- a/chrome/browser/chromeos/power/output_observer.cc +++ b/chrome/browser/chromeos/power/output_observer.cc @@ -5,6 +5,7 @@ #include "chrome/browser/chromeos/power/output_observer.h" #include "ash/shell.h" +#include "ash/wm/user_activity_detector.h" #include "chromeos/dbus/dbus_thread_manager.h" #include "chromeos/display/output_configurator.h" @@ -19,6 +20,14 @@ OutputObserver::~OutputObserver() { } void OutputObserver::ScreenPowerSet(bool power_on, bool all_displays) { + if (!power_on && all_displays) { + // All displays are turned off when the device becomes idle, which + // may trigger a mouse move. Let the UserActivityDetector know so + // that it can ignore such events. + ash::Shell::GetInstance()->user_activity_detector()-> + OnAllOutputsTurnedOff(); + } + ash::Shell::GetInstance()->output_configurator()-> ScreenPowerSet(power_on, all_displays); } |