summaryrefslogtreecommitdiffstats
path: root/ash
diff options
context:
space:
mode:
authorskaslev@chromium.org <skaslev@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-06 20:49:22 +0000
committerskaslev@chromium.org <skaslev@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-06 20:49:22 +0000
commite7b31a66d26ee5c675ca6ade8ca9cc0a43c66d48 (patch)
treeca7111cd8b844b9357156a0767ef555ed9cdd41b /ash
parentbe8d972a2764e069e1c963399e902c4221d1e471 (diff)
downloadchromium_src-e7b31a66d26ee5c675ca6ade8ca9cc0a43c66d48.zip
chromium_src-e7b31a66d26ee5c675ca6ade8ca9cc0a43c66d48.tar.gz
chromium_src-e7b31a66d26ee5c675ca6ade8ca9cc0a43c66d48.tar.bz2
Revert 198519 "Notify all visible renderers when the visibility ..."
> Notify all visible renderers when the visibility of the mouse cursor changes > > Blink side patch: > https://codereview.chromium.org/14047016/ > > The ultimate goal of both patches is to disallow new hover > effects from being invoked in web contents when the mouse > cursor is not visible to the user (i.e., while touch > scrolling). The job of this patch is to communicate the > cursor visibility state to all visible renderers using > the new IPC InputMsg_CursorVisibilityChange whenever the > visibility state changes. > > Added the new observer type CursorClientObserver. > Subscribers (instances of RenderWidgetHostViewAura) are > notified whenever the cursor visibility changes, at which > point the IPC is sent to the renderer. > > I have also removed the code in ash_native_cursor_manager.cc > that sets the mouse cursor location to the bogus value > of (-10000,-10000) when mouse events are disabled; afaik > this was originally added as a way to prevent unwanted > hover effects in web contents but it does not work in all > cases and causes other problems (see crbug.com/174358). > > BUG=153784,174358 > R=jamesr@chromium.org, kenrb@chromium.org, oshima@chromium.org, sky@chromium.org > > Review URL: https://codereview.chromium.org/14047015 TBR=tdanderson@google.com Review URL: https://codereview.chromium.org/14975004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@198526 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash')
-rw-r--r--ash/wm/ash_native_cursor_manager.cc6
-rw-r--r--ash/wm/window_manager_unittest.cc84
2 files changed, 6 insertions, 84 deletions
diff --git a/ash/wm/ash_native_cursor_manager.cc b/ash/wm/ash_native_cursor_manager.cc
index dd72af1..be9c6b7 100644
--- a/ash/wm/ash_native_cursor_manager.cc
+++ b/ash/wm/ash_native_cursor_manager.cc
@@ -13,6 +13,10 @@
namespace {
+// The coordinate of the cursor used when the mouse events are disabled.
+const int kDisabledCursorLocationX = -10000;
+const int kDisabledCursorLocationY = -10000;
+
void SetCursorOnAllRootWindows(gfx::NativeCursor cursor) {
ash::Shell::RootWindowList root_windows =
ash::Shell::GetInstance()->GetAllRootWindows();
@@ -95,6 +99,8 @@ void AshNativeCursorManager::SetMouseEventsEnabled(
disabled_cursor_location_);
} else {
disabled_cursor_location_ = aura::Env::GetInstance()->last_mouse_location();
+ aura::Env::GetInstance()->set_last_mouse_location(
+ gfx::Point(kDisabledCursorLocationX, kDisabledCursorLocationY));
}
SetVisibility(delegate->GetCurrentVisibility(), delegate);
diff --git a/ash/wm/window_manager_unittest.cc b/ash/wm/window_manager_unittest.cc
index 936b29a..e12c9db 100644
--- a/ash/wm/window_manager_unittest.cc
+++ b/ash/wm/window_manager_unittest.cc
@@ -11,7 +11,6 @@
#include "ash/wm/window_util.h"
#include "ui/aura/client/activation_client.h"
#include "ui/aura/client/activation_delegate.h"
-#include "ui/aura/client/cursor_client_observer.h"
#include "ui/aura/client/focus_client.h"
#include "ui/aura/env.h"
#include "ui/aura/root_window.h"
@@ -31,28 +30,6 @@
namespace {
-class TestingCursorClientObserver : public aura::client::CursorClientObserver {
- public:
- TestingCursorClientObserver()
- : cursor_visibility_(false),
- did_visibility_change_(false) {}
- void reset() { cursor_visibility_ = did_visibility_change_ = false; }
- bool is_cursor_visible() const { return cursor_visibility_; }
- bool did_visibility_change() const { return did_visibility_change_; }
-
- // Overridden from aura::client::CursorClientObserver:
- virtual void OnCursorVisibilityChanged(bool is_visible) OVERRIDE {
- cursor_visibility_ = is_visible;
- did_visibility_change_ = true;
- }
-
- private:
- bool cursor_visibility_;
- bool did_visibility_change_;
-
- DISALLOW_COPY_AND_ASSIGN(TestingCursorClientObserver);
-};
-
base::TimeDelta getTime() {
return ui::EventTimeForNow();
}
@@ -776,65 +753,4 @@ TEST_F(WindowManagerTest, UpdateCursorVisibilityOnKeyEvent) {
EXPECT_TRUE(cursor_manager->IsMouseEventsEnabled());
}
-TEST_F(WindowManagerTest, TestCursorClientObserver) {
- aura::test::EventGenerator& generator = GetEventGenerator();
- views::corewm::CursorManager* cursor_manager =
- ash::Shell::GetInstance()->cursor_manager();
-
- scoped_ptr<aura::Window> w1(CreateTestWindowInShell(
- SK_ColorWHITE, -1, gfx::Rect(0, 0, 100, 100)));
- wm::ActivateWindow(w1.get());
-
- // Add two observers. Both should have OnCursorVisibilityChanged()
- // invoked when an event changes the visibility of the cursor.
- TestingCursorClientObserver observer_a;
- TestingCursorClientObserver observer_b;
- cursor_manager->AddObserver(&observer_a);
- cursor_manager->AddObserver(&observer_b);
-
- // Initial state before any events have been sent.
- observer_a.reset();
- observer_b.reset();
- EXPECT_FALSE(observer_a.did_visibility_change());
- EXPECT_FALSE(observer_b.did_visibility_change());
- EXPECT_FALSE(observer_a.is_cursor_visible());
- EXPECT_FALSE(observer_b.is_cursor_visible());
-
- // Keypress should hide the cursor.
- generator.PressKey(ui::VKEY_A, ui::EF_NONE);
- EXPECT_TRUE(observer_a.did_visibility_change());
- EXPECT_TRUE(observer_b.did_visibility_change());
- EXPECT_FALSE(observer_a.is_cursor_visible());
- EXPECT_FALSE(observer_b.is_cursor_visible());
-
- // Mouse move should show the cursor.
- observer_a.reset();
- observer_b.reset();
- generator.MoveMouseTo(50, 50);
- EXPECT_TRUE(observer_a.did_visibility_change());
- EXPECT_TRUE(observer_b.did_visibility_change());
- EXPECT_TRUE(observer_a.is_cursor_visible());
- EXPECT_TRUE(observer_b.is_cursor_visible());
-
- // Remove observer_b. Its OnCursorVisibilityChanged() should
- // not be invoked past this point.
- cursor_manager->RemoveObserver(&observer_b);
-
- // Gesture tap should hide the cursor.
- observer_a.reset();
- observer_b.reset();
- generator.GestureTapAt(gfx::Point(25, 25));
- EXPECT_TRUE(observer_a.did_visibility_change());
- EXPECT_FALSE(observer_b.did_visibility_change());
- EXPECT_FALSE(observer_a.is_cursor_visible());
-
- // Mouse move should show the cursor.
- observer_a.reset();
- observer_b.reset();
- generator.MoveMouseTo(50, 50);
- EXPECT_TRUE(observer_a.did_visibility_change());
- EXPECT_FALSE(observer_b.did_visibility_change());
- EXPECT_TRUE(observer_a.is_cursor_visible());
-}
-
} // namespace ash