summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ash/ash.gyp2
-rw-r--r--ash/display/mouse_cursor_event_filter.cc5
-rw-r--r--ash/drag_drop/drag_drop_controller.cc8
-rw-r--r--ash/shell.cc9
-rw-r--r--ash/shell.h8
-rw-r--r--ash/tooltips/tooltip_controller.cc4
-rw-r--r--ash/tooltips/tooltip_controller_unittest.cc6
-rw-r--r--ash/wm/cursor_delegate.h (renamed from ui/aura/cursor_delegate.h)12
-rw-r--r--ash/wm/cursor_manager.cc (renamed from ui/aura/cursor_manager.cc)12
-rw-r--r--ash/wm/cursor_manager.h (renamed from ui/aura/cursor_manager.h)17
-rw-r--r--ash/wm/default_window_resizer.cc6
-rw-r--r--ash/wm/power_button_controller.cc13
-rw-r--r--ash/wm/power_button_controller_unittest.cc4
-rw-r--r--ash/wm/window_manager_unittest.cc6
-rw-r--r--ash/wm/workspace/workspace_window_resizer.cc6
-rw-r--r--chrome/browser/ui/views/extensions/extension_dialog.cc4
-rw-r--r--content/browser/renderer_host/render_widget_host_view_aura.cc12
-rw-r--r--ui/aura/aura.gyp7
-rw-r--r--ui/aura/client/cursor_client.cc28
-rw-r--r--ui/aura/client/cursor_client.h39
-rw-r--r--ui/aura/desktop/desktop_cursor_client.cc30
-rw-r--r--ui/aura/desktop/desktop_cursor_client.h36
-rw-r--r--ui/aura/env.cc1
-rw-r--r--ui/aura/env.h5
-rw-r--r--ui/aura/shared/compound_event_filter.cc38
-rw-r--r--ui/aura/shared/compound_event_filter.h3
-rw-r--r--ui/aura/shared/compound_event_filter_unittest.cc37
-rw-r--r--ui/views/widget/desktop_native_widget_helper_aura.cc7
-rw-r--r--ui/views/widget/desktop_native_widget_helper_aura.h4
29 files changed, 278 insertions, 91 deletions
diff --git a/ash/ash.gyp b/ash/ash.gyp
index c788f00..a3067f8 100644
--- a/ash/ash.gyp
+++ b/ash/ash.gyp
@@ -232,6 +232,8 @@
'wm/base_layout_manager.h',
'wm/capture_controller.cc',
'wm/capture_controller.h',
+ 'wm/cursor_manager.cc',
+ 'wm/cursor_manager.h',
'wm/custom_frame_view_ash.cc',
'wm/custom_frame_view_ash.h',
'wm/default_window_resizer.cc',
diff --git a/ash/display/mouse_cursor_event_filter.cc b/ash/display/mouse_cursor_event_filter.cc
index 781742a..9b6d297 100644
--- a/ash/display/mouse_cursor_event_filter.cc
+++ b/ash/display/mouse_cursor_event_filter.cc
@@ -5,7 +5,8 @@
#include "ash/display/mouse_cursor_event_filter.h"
#include "ash/display/display_controller.h"
-#include "ui/aura/cursor_manager.h"
+#include "ash/shell.h"
+#include "ash/wm/cursor_manager.h"
#include "ui/aura/env.h"
#include "ui/aura/event.h"
#include "ui/aura/root_window.h"
@@ -31,7 +32,7 @@ bool MouseCursorEventFilter::PreHandleKeyEvent(aura::Window* target,
bool MouseCursorEventFilter::PreHandleMouseEvent(aura::Window* target,
aura::MouseEvent* event) {
if (event->type() != ui::ET_MOUSE_MOVED ||
- aura::Env::GetInstance()->cursor_manager()->is_cursor_locked())
+ ash::Shell::GetInstance()->cursor_manager()->is_cursor_locked())
return false;
aura::RootWindow* current_root = target->GetRootWindow();
gfx::Point location_in_root(event->location());
diff --git a/ash/drag_drop/drag_drop_controller.cc b/ash/drag_drop/drag_drop_controller.cc
index 34028ae..dd8a097 100644
--- a/ash/drag_drop/drag_drop_controller.cc
+++ b/ash/drag_drop/drag_drop_controller.cc
@@ -6,11 +6,11 @@
#include "ash/drag_drop/drag_image_view.h"
#include "ash/shell.h"
+#include "ash/wm/cursor_manager.h"
#include "base/message_loop.h"
#include "base/run_loop.h"
#include "ui/aura/client/capture_client.h"
#include "ui/aura/client/drag_drop_delegate.h"
-#include "ui/aura/cursor_manager.h"
#include "ui/aura/env.h"
#include "ui/aura/root_window.h"
#include "ui/aura/window.h"
@@ -128,7 +128,7 @@ void DragDropController::DragUpdate(aura::Window* target,
cursor = ui::kCursorAlias;
else if (op & ui::DragDropTypes::DRAG_MOVE)
cursor = ui::kCursorMove;
- aura::Env::GetInstance()->cursor_manager()->SetCursor(cursor);
+ ash::Shell::GetInstance()->cursor_manager()->SetCursor(cursor);
}
}
@@ -141,7 +141,7 @@ void DragDropController::DragUpdate(aura::Window* target,
void DragDropController::Drop(aura::Window* target,
const aura::LocatedEvent& event) {
- aura::Env::GetInstance()->cursor_manager()->SetCursor(ui::kCursorPointer);
+ ash::Shell::GetInstance()->cursor_manager()->SetCursor(ui::kCursorPointer);
aura::client::DragDropDelegate* delegate = NULL;
// We must guarantee that a target gets a OnDragEntered before Drop. WebKit
@@ -170,7 +170,7 @@ void DragDropController::Drop(aura::Window* target,
}
void DragDropController::DragCancel() {
- aura::Env::GetInstance()->cursor_manager()->SetCursor(ui::kCursorPointer);
+ ash::Shell::GetInstance()->cursor_manager()->SetCursor(ui::kCursorPointer);
// |drag_window_| can be NULL if we have just started the drag and have not
// received any DragUpdates, or, if the |drag_window_| gets destroyed during
diff --git a/ash/shell.cc b/ash/shell.cc
index 42986da..535b3a4 100644
--- a/ash/shell.cc
+++ b/ash/shell.cc
@@ -71,7 +71,6 @@
#include "grit/ui_resources.h"
#include "ui/aura/client/aura_constants.h"
#include "ui/aura/client/user_action_client.h"
-#include "ui/aura/cursor_manager.h"
#include "ui/aura/env.h"
#include "ui/aura/focus_manager.h"
#include "ui/aura/layout_manager.h"
@@ -205,7 +204,7 @@ Shell::~Shell() {
if (active_root_window_)
active_root_window_->GetFocusManager()->SetFocusedWindow(NULL, NULL);
- aura::Env::GetInstance()->cursor_manager()->set_delegate(NULL);
+ cursor_manager_.set_delegate(NULL);
// Please keep in same order as in Init() because it's easy to miss one.
RemoveEnvEventFilter(user_activity_detector_.get());
@@ -371,8 +370,7 @@ void Shell::Init() {
// Pass ownership of the filter to the Env.
aura::Env::GetInstance()->SetEventFilter(env_filter_);
- aura::Env::GetInstance()->cursor_manager()->set_delegate(this);
-
+ cursor_manager_.set_delegate(this);
focus_manager_.reset(new aura::FocusManager);
activation_controller_.reset(
@@ -497,7 +495,7 @@ void Shell::Init() {
display_controller_->InitSecondaryDisplays();
if (initially_hide_cursor_)
- aura::Env::GetInstance()->cursor_manager()->ShowCursor(false);
+ cursor_manager_.ShowCursor(false);
}
void Shell::AddEnvEventFilter(aura::EventFilter* filter) {
@@ -707,6 +705,7 @@ void Shell::InitRootWindowController(
aura::client::SetCaptureClient(root_window, capture_controller_.get());
aura::client::SetScreenPositionClient(root_window,
screen_position_controller_.get());
+ aura::client::SetCursorClient(root_window, &cursor_manager_);
aura::client::SetTooltipClient(root_window, tooltip_controller_.get());
if (nested_dispatcher_controller_.get()) {
diff --git a/ash/shell.h b/ash/shell.h
index 1361465..588de5d 100644
--- a/ash/shell.h
+++ b/ash/shell.h
@@ -10,13 +10,14 @@
#include "ash/ash_export.h"
#include "ash/system/user/login_status.h"
+#include "ash/wm/cursor_delegate.h"
+#include "ash/wm/cursor_manager.h"
#include "ash/wm/shelf_types.h"
#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "base/gtest_prod_util.h"
#include "base/memory/scoped_ptr.h"
#include "base/observer_list.h"
-#include "ui/aura/cursor_delegate.h"
#include "ui/gfx/insets.h"
#include "ui/gfx/size.h"
@@ -109,7 +110,7 @@ class WorkspaceController;
//
// Upon creation, the Shell sets itself as the RootWindow's delegate, which
// takes ownership of the Shell.
-class ASH_EXPORT Shell : aura::CursorDelegate {
+class ASH_EXPORT Shell : ash::CursorDelegate {
public:
typedef std::vector<aura::RootWindow*> RootWindowList;
typedef std::vector<internal::RootWindowController*> RootWindowControllerList;
@@ -285,6 +286,7 @@ class ASH_EXPORT Shell : aura::CursorDelegate {
internal::DisplayController* display_controller() {
return display_controller_.get();
}
+ CursorManager* cursor_manager() { return &cursor_manager_; }
ShellDelegate* delegate() { return delegate_.get(); }
@@ -467,6 +469,8 @@ class ASH_EXPORT Shell : aura::CursorDelegate {
scoped_ptr<chromeos::OutputConfigurator> output_configurator_;
#endif // defined(OS_CHROMEOS)
+ CursorManager cursor_manager_;
+
// The shelf for managing the launcher and the status widget in non-compact
// mode. Shell does not own the shelf. Instead, it is owned by container of
// the status area.
diff --git a/ash/tooltips/tooltip_controller.cc b/ash/tooltips/tooltip_controller.cc
index 937ebc7..4704271 100644
--- a/ash/tooltips/tooltip_controller.cc
+++ b/ash/tooltips/tooltip_controller.cc
@@ -8,12 +8,12 @@
#include "ash/ash_switches.h"
#include "ash/shell.h"
+#include "ash/wm/cursor_manager.h"
#include "base/command_line.h"
#include "base/location.h"
#include "base/string_split.h"
#include "base/time.h"
#include "ui/aura/client/drag_drop_client.h"
-#include "ui/aura/cursor_manager.h"
#include "ui/aura/env.h"
#include "ui/aura/event.h"
#include "ui/aura/root_window.h"
@@ -403,7 +403,7 @@ void TooltipController::TooltipShownTimerFired() {
void TooltipController::UpdateIfRequired() {
if (!tooltips_enabled_ || mouse_pressed_ || IsDragDropInProgress() ||
- !aura::Env::GetInstance()->cursor_manager()->cursor_visible()) {
+ !ash::Shell::GetInstance()->cursor_manager()->cursor_visible()) {
GetTooltip()->Hide();
return;
}
diff --git a/ash/tooltips/tooltip_controller_unittest.cc b/ash/tooltips/tooltip_controller_unittest.cc
index c1febfd..bd8405f 100644
--- a/ash/tooltips/tooltip_controller_unittest.cc
+++ b/ash/tooltips/tooltip_controller_unittest.cc
@@ -5,9 +5,9 @@
#include "ash/shell.h"
#include "ash/test/ash_test_base.h"
#include "ash/tooltips/tooltip_controller.h"
+#include "ash/wm/cursor_manager.h"
#include "base/utf_string_conversions.h"
#include "ui/aura/client/tooltip_client.h"
-#include "ui/aura/cursor_manager.h"
#include "ui/aura/env.h"
#include "ui/aura/root_window.h"
#include "ui/aura/test/event_generator.h"
@@ -259,12 +259,12 @@ TEST_F(TooltipControllerTest, HideTooltipWhenCursorHidden) {
EXPECT_TRUE(IsTooltipVisible());
// Hide the cursor and check again.
- aura::Env::GetInstance()->cursor_manager()->ShowCursor(false);
+ ash::Shell::GetInstance()->cursor_manager()->ShowCursor(false);
FireTooltipTimer();
EXPECT_FALSE(IsTooltipVisible());
// Show the cursor and re-check.
- aura::Env::GetInstance()->cursor_manager()->ShowCursor(true);
+ ash::Shell::GetInstance()->cursor_manager()->ShowCursor(true);
FireTooltipTimer();
EXPECT_TRUE(IsTooltipVisible());
}
diff --git a/ui/aura/cursor_delegate.h b/ash/wm/cursor_delegate.h
index 8ae8d70..05d901f 100644
--- a/ui/aura/cursor_delegate.h
+++ b/ash/wm/cursor_delegate.h
@@ -2,17 +2,17 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef UI_AURA_CURSOR_DELEGATE_H_
-#define UI_AURA_CURSOR_DELEGATE_H_
+#ifndef ASH_WM_CURSOR_DELEGATE_H_
+#define ASH_WM_CURSOR_DELEGATE_H_
-#include "ui/aura/aura_export.h"
+#include "ash/ash_export.h"
#include "ui/gfx/native_widget_types.h"
-namespace aura {
+namespace ash {
// This interface is implmented by a platform specific object that changes
// the cursor's image and visibility.
-class AURA_EXPORT CursorDelegate {
+class ASH_EXPORT CursorDelegate {
public:
virtual void SetCursor(gfx::NativeCursor cursor) = 0;
virtual void ShowCursor(bool visible) = 0;
@@ -23,4 +23,4 @@ class AURA_EXPORT CursorDelegate {
} // namespace aura
-#endif // UI_AURA_CURSOR_DELEGATE_H_
+#endif // ASH_WM_CURSOR_DELEGATE_H_
diff --git a/ui/aura/cursor_manager.cc b/ash/wm/cursor_manager.cc
index 30c7af1c..1ebc72b 100644
--- a/ui/aura/cursor_manager.cc
+++ b/ash/wm/cursor_manager.cc
@@ -2,13 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "ui/aura/cursor_manager.h"
+#include "ash/wm/cursor_manager.h"
+#include "ash/wm/cursor_delegate.h"
#include "base/logging.h"
-#include "ui/aura/cursor_delegate.h"
#include "ui/aura/env.h"
-namespace aura {
+namespace ash {
CursorManager::CursorManager()
: delegate_(NULL),
@@ -55,4 +55,8 @@ void CursorManager::ShowCursor(bool show) {
delegate_->ShowCursor(show);
}
-} // namespace aura
+bool CursorManager::IsCursorVisible() const {
+ return cursor_visible_;
+}
+
+} // namespace ash
diff --git a/ui/aura/cursor_manager.h b/ash/wm/cursor_manager.h
index 4050997..d124802 100644
--- a/ui/aura/cursor_manager.h
+++ b/ash/wm/cursor_manager.h
@@ -2,20 +2,22 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef UI_AURA_CURSOR_MANAGER_H_
-#define UI_AURA_CURSOR_MANAGER_H_
+#ifndef ASH_WM_CURSOR_MANAGER_H_
+#define ASH_WM_CURSOR_MANAGER_H_
#include "base/basictypes.h"
+#include "base/compiler_specific.h"
#include "ui/aura/aura_export.h"
+#include "ui/aura/client/cursor_client.h"
#include "ui/gfx/native_widget_types.h"
-namespace aura {
+namespace ash {
class CursorDelegate;
// This class controls the visibility and the type of the cursor.
// The cursor type can be locked so that the type stays the same
// until it's unlocked.
-class AURA_EXPORT CursorManager {
+class CursorManager : public aura::client::CursorClient {
public:
CursorManager();
~CursorManager();
@@ -28,12 +30,13 @@ class AURA_EXPORT CursorManager {
bool is_cursor_locked() const { return cursor_lock_count_ > 0; }
- void SetCursor(gfx::NativeCursor);
-
// Shows or hides the cursor.
- void ShowCursor(bool show);
bool cursor_visible() const { return cursor_visible_; }
+ virtual void SetCursor(gfx::NativeCursor) OVERRIDE;
+ virtual void ShowCursor(bool show) OVERRIDE;
+ virtual bool IsCursorVisible() const OVERRIDE;
+
private:
CursorDelegate* delegate_;
diff --git a/ash/wm/default_window_resizer.cc b/ash/wm/default_window_resizer.cc
index 8b57115..4368c73 100644
--- a/ash/wm/default_window_resizer.cc
+++ b/ash/wm/default_window_resizer.cc
@@ -5,8 +5,8 @@
#include "ash/wm/default_window_resizer.h"
#include "ash/shell.h"
+#include "ash/wm/cursor_manager.h"
#include "ui/aura/client/aura_constants.h"
-#include "ui/aura/cursor_manager.h"
#include "ui/aura/env.h"
#include "ui/aura/root_window.h"
#include "ui/aura/window.h"
@@ -20,7 +20,7 @@
namespace ash {
DefaultWindowResizer::~DefaultWindowResizer() {
- aura::Env::GetInstance()->cursor_manager()->UnlockCursor();
+ ash::Shell::GetInstance()->cursor_manager()->UnlockCursor();
}
// static
@@ -76,7 +76,7 @@ DefaultWindowResizer::DefaultWindowResizer(const Details& details)
: details_(details),
did_move_or_resize_(false) {
DCHECK(details_.is_resizable);
- aura::Env::GetInstance()->cursor_manager()->LockCursor();
+ ash::Shell::GetInstance()->cursor_manager()->LockCursor();
}
} // namespace aura
diff --git a/ash/wm/power_button_controller.cc b/ash/wm/power_button_controller.cc
index 7f2ceac..73c1a3b 100644
--- a/ash/wm/power_button_controller.cc
+++ b/ash/wm/power_button_controller.cc
@@ -7,11 +7,11 @@
#include "ash/ash_switches.h"
#include "ash/shell.h"
#include "ash/shell_window_ids.h"
+#include "ash/wm/cursor_manager.h"
#include "base/command_line.h"
#include "base/logging.h"
#include "base/time.h"
#include "third_party/skia/include/core/SkColor.h"
-#include "ui/aura/cursor_manager.h"
#include "ui/aura/env.h"
#include "ui/aura/root_window.h"
#include "ui/aura/shared/compound_event_filter.h"
@@ -311,9 +311,9 @@ void PowerButtonController::OnAppTerminating() {
// can really hope for is that we'll have time to clear the screen.
if (!shutting_down_) {
shutting_down_ = true;
- ash::Shell::GetInstance()->env_filter()->
- set_update_cursor_visibility(false);
- aura::Env::GetInstance()->cursor_manager()->ShowCursor(false);
+ Shell* shell = ash::Shell::GetInstance();
+ shell->env_filter()->set_update_cursor_visibility(false);
+ shell->cursor_manager()->ShowCursor(false);
ShowBackgroundLayer();
StartAnimation(ALL_CONTAINERS, ANIMATION_HIDE);
}
@@ -536,8 +536,9 @@ void PowerButtonController::StartShutdownAnimationAndRequestShutdown() {
DCHECK(!shutting_down_);
shutting_down_ = true;
- ash::Shell::GetInstance()->env_filter()->set_update_cursor_visibility(false);
- aura::Env::GetInstance()->cursor_manager()->ShowCursor(false);
+ Shell* shell = ash::Shell::GetInstance();
+ shell->env_filter()->set_update_cursor_visibility(false);
+ shell->cursor_manager()->ShowCursor(false);
ShowBackgroundLayer();
if (login_status_ != user::LOGGED_IN_NONE) {
diff --git a/ash/wm/power_button_controller_unittest.cc b/ash/wm/power_button_controller_unittest.cc
index 14f0232..b84a071 100644
--- a/ash/wm/power_button_controller_unittest.cc
+++ b/ash/wm/power_button_controller_unittest.cc
@@ -6,9 +6,9 @@
#include "ash/shell.h"
#include "ash/test/ash_test_base.h"
+#include "ash/wm/cursor_manager.h"
#include "base/memory/scoped_ptr.h"
#include "base/time.h"
-#include "ui/aura/cursor_manager.h"
#include "ui/aura/env.h"
#include "ui/aura/root_window.h"
#include "ui/gfx/rect.h"
@@ -18,7 +18,7 @@ namespace ash {
namespace test {
namespace {
bool cursor_visible() {
- return aura::Env::GetInstance()->cursor_manager()->cursor_visible();
+ return ash::Shell::GetInstance()->cursor_manager()->cursor_visible();
}
}
diff --git a/ash/wm/window_manager_unittest.cc b/ash/wm/window_manager_unittest.cc
index 4217e64..fa78d3f 100644
--- a/ash/wm/window_manager_unittest.cc
+++ b/ash/wm/window_manager_unittest.cc
@@ -7,10 +7,10 @@
#include "ash/test/ash_test_base.h"
#include "ash/test/test_activation_delegate.h"
#include "ash/wm/activation_controller.h"
+#include "ash/wm/cursor_manager.h"
#include "ash/wm/window_util.h"
#include "ui/aura/client/activation_client.h"
#include "ui/aura/client/activation_delegate.h"
-#include "ui/aura/cursor_manager.h"
#include "ui/aura/env.h"
#include "ui/aura/event.h"
#include "ui/aura/focus_manager.h"
@@ -574,8 +574,8 @@ TEST_F(WindowManagerTest, UpdateCursorVisibility) {
aura::shared::CompoundEventFilter* env_filter =
Shell::GetInstance()->env_filter();
- aura::CursorManager* cursor_manager =
- aura::Env::GetInstance()->cursor_manager();
+ ash::CursorManager* cursor_manager =
+ ash::Shell::GetInstance()->cursor_manager();
aura::MouseEvent mouse_moved(
ui::ET_MOUSE_MOVED, gfx::Point(0, 0), gfx::Point(0, 0), 0x0);
diff --git a/ash/wm/workspace/workspace_window_resizer.cc b/ash/wm/workspace/workspace_window_resizer.cc
index 5912280..78f109bb 100644
--- a/ash/wm/workspace/workspace_window_resizer.cc
+++ b/ash/wm/workspace/workspace_window_resizer.cc
@@ -9,11 +9,11 @@
#include "ash/screen_ash.h"
#include "ash/shell.h"
+#include "ash/wm/cursor_manager.h"
#include "ash/wm/property_util.h"
#include "ash/wm/window_util.h"
#include "ash/wm/workspace/phantom_window_controller.h"
#include "ash/wm/workspace/snap_sizer.h"
-#include "ui/aura/cursor_manager.h"
#include "ui/aura/env.h"
#include "ui/aura/window.h"
#include "ui/aura/window_delegate.h"
@@ -46,7 +46,7 @@ const int WorkspaceWindowResizer::kMinOnscreenSize = 20;
const int WorkspaceWindowResizer::kMinOnscreenHeight = 32;
WorkspaceWindowResizer::~WorkspaceWindowResizer() {
- aura::Env::GetInstance()->cursor_manager()->UnlockCursor();
+ ash::Shell::GetInstance()->cursor_manager()->UnlockCursor();
}
// static
@@ -164,7 +164,7 @@ WorkspaceWindowResizer::WorkspaceWindowResizer(
snap_type_(SNAP_NONE),
num_mouse_moves_since_bounds_change_(0) {
DCHECK(details_.is_resizable);
- aura::Env::GetInstance()->cursor_manager()->LockCursor();
+ ash::Shell::GetInstance()->cursor_manager()->LockCursor();
// Only support attaching to the right/bottom.
DCHECK(attached_windows_.empty() ||
diff --git a/chrome/browser/ui/views/extensions/extension_dialog.cc b/chrome/browser/ui/views/extensions/extension_dialog.cc
index 59ba640..e3aeb3d 100644
--- a/chrome/browser/ui/views/extensions/extension_dialog.cc
+++ b/chrome/browser/ui/views/extensions/extension_dialog.cc
@@ -20,7 +20,7 @@
#include "ui/views/background.h"
#include "ui/views/widget/widget.h"
-#if defined(USE_AURA)
+#if defined(USE_ASH)
#include "ash/shell.h"
#include "ui/aura/root_window.h"
#endif
@@ -123,7 +123,7 @@ ExtensionHost* ExtensionDialog::CreateExtensionHost(const GURL& url,
return manager->CreateDialogHost(url);
}
-#if defined(USE_AURA)
+#if defined(USE_ASH)
void ExtensionDialog::InitWindowFullscreen() {
aura::RootWindow* root_window = ash::Shell::GetPrimaryRootWindow();
gfx::Rect screen_rect =
diff --git a/content/browser/renderer_host/render_widget_host_view_aura.cc b/content/browser/renderer_host/render_widget_host_view_aura.cc
index cc774c1..8663456 100644
--- a/content/browser/renderer_host/render_widget_host_view_aura.cc
+++ b/content/browser/renderer_host/render_widget_host_view_aura.cc
@@ -28,10 +28,10 @@
#include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebScreenInfo.h"
#include "ui/aura/client/aura_constants.h"
+#include "ui/aura/client/cursor_client.h"
#include "ui/aura/client/screen_position_client.h"
#include "ui/aura/client/tooltip_client.h"
#include "ui/aura/client/window_types.h"
-#include "ui/aura/cursor_manager.h"
#include "ui/aura/env.h"
#include "ui/aura/event.h"
#include "ui/aura/root_window.h"
@@ -744,7 +744,10 @@ bool RenderWidgetHostViewAura::LockMouse() {
mouse_locked_ = true;
window_->SetCapture();
- aura::Env::GetInstance()->cursor_manager()->ShowCursor(false);
+ aura::client::CursorClient* cursor_client =
+ aura::client::GetCursorClient(root_window);
+ if (cursor_client)
+ cursor_client->ShowCursor(false);
synthetic_move_sent_ = true;
window_->MoveCursorTo(gfx::Rect(window_->bounds().size()).CenterPoint());
if (aura::client::GetTooltipClient(root_window))
@@ -761,7 +764,10 @@ void RenderWidgetHostViewAura::UnlockMouse() {
window_->ReleaseCapture();
window_->MoveCursorTo(unlocked_mouse_position_);
- aura::Env::GetInstance()->cursor_manager()->ShowCursor(true);
+ aura::client::CursorClient* cursor_client =
+ aura::client::GetCursorClient(root_window);
+ if (cursor_client)
+ cursor_client->ShowCursor(true);
if (aura::client::GetTooltipClient(root_window))
aura::client::GetTooltipClient(root_window)->SetTooltipsEnabled(true);
diff --git a/ui/aura/aura.gyp b/ui/aura/aura.gyp
index 5ccb33a..c1d6191 100644
--- a/ui/aura/aura.gyp
+++ b/ui/aura/aura.gyp
@@ -34,6 +34,8 @@
'client/capture_client.cc',
'client/capture_client.h',
'client/capture_delegate.h',
+ 'client/cursor_client.cc',
+ 'client/cursor_client.h',
'client/dispatcher_client.cc',
'client/dispatcher_client.h',
'client/drag_drop_client.cc',
@@ -55,11 +57,10 @@
'client/window_move_client.cc',
'client/window_move_client.h',
'client/window_types.h',
- 'cursor_delegate.h',
- 'cursor_manager.cc',
- 'cursor_manager.h',
'desktop/desktop_activation_client.cc',
'desktop/desktop_activation_client.h',
+ 'desktop/desktop_cursor_client.cc',
+ 'desktop/desktop_cursor_client.h',
'desktop/desktop_dispatcher_client.cc',
'desktop/desktop_dispatcher_client.h',
'desktop/desktop_screen.h',
diff --git a/ui/aura/client/cursor_client.cc b/ui/aura/client/cursor_client.cc
new file mode 100644
index 0000000..ca105ed
--- /dev/null
+++ b/ui/aura/client/cursor_client.cc
@@ -0,0 +1,28 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ui/aura/client/cursor_client.h"
+
+#include "ui/aura/window.h"
+#include "ui/aura/window_property.h"
+
+DECLARE_WINDOW_PROPERTY_TYPE(aura::client::CursorClient*)
+
+namespace aura {
+namespace client {
+
+// A property key to store a client that handles window moves.
+DEFINE_LOCAL_WINDOW_PROPERTY_KEY(
+ CursorClient*, kCursorClientKey, NULL);
+
+void SetCursorClient(Window* window, CursorClient* client) {
+ window->SetProperty(kCursorClientKey, client);
+}
+
+CursorClient* GetCursorClient(Window* window) {
+ return window->GetProperty(kCursorClientKey);
+}
+
+} // namespace client
+} // namespace aura
diff --git a/ui/aura/client/cursor_client.h b/ui/aura/client/cursor_client.h
new file mode 100644
index 0000000..418c559
--- /dev/null
+++ b/ui/aura/client/cursor_client.h
@@ -0,0 +1,39 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef UI_AURA_CLIENT_CURSOR_CLIENT_H_
+#define UI_AURA_CLIENT_CURSOR_CLIENT_H_
+
+#include "ui/aura/aura_export.h"
+#include "ui/gfx/native_widget_types.h"
+
+namespace aura {
+class Window;
+namespace client {
+
+// An interface that receives cursor change events.
+class AURA_EXPORT CursorClient {
+ public:
+ // Notes that |window| has requested the change to |cursor|.
+ virtual void SetCursor(gfx::NativeCursor cursor) = 0;
+
+ // Changes the visibility of the cursor.
+ virtual void ShowCursor(bool show) = 0;
+
+ // Gets whether the cursor is visible.
+ virtual bool IsCursorVisible() const = 0;
+
+ protected:
+ virtual ~CursorClient() {}
+};
+
+// Sets/Gets the activation client for the specified window.
+AURA_EXPORT void SetCursorClient(Window* window,
+ CursorClient* client);
+AURA_EXPORT CursorClient* GetCursorClient(Window* window);
+
+} // namespace client
+} // namespace aura
+
+#endif // UI_AURA_CLIENT_CURSOR_CLIENT_H_
diff --git a/ui/aura/desktop/desktop_cursor_client.cc b/ui/aura/desktop/desktop_cursor_client.cc
new file mode 100644
index 0000000..d44cb32
--- /dev/null
+++ b/ui/aura/desktop/desktop_cursor_client.cc
@@ -0,0 +1,30 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ui/aura/desktop/desktop_cursor_client.h"
+
+#include "ui/aura/root_window.h"
+
+namespace aura {
+
+DesktopCursorClient::DesktopCursorClient(aura::RootWindow* window)
+ : root_window_(window) {
+}
+
+DesktopCursorClient::~DesktopCursorClient() {
+}
+
+void DesktopCursorClient::SetCursor(gfx::NativeCursor cursor) {
+ root_window_->SetCursor(cursor);
+}
+
+void DesktopCursorClient::ShowCursor(bool show) {
+ root_window_->ShowCursor(show);
+}
+
+bool DesktopCursorClient::IsCursorVisible() const {
+ return root_window_->cursor_shown();
+}
+
+} // namespace aura
diff --git a/ui/aura/desktop/desktop_cursor_client.h b/ui/aura/desktop/desktop_cursor_client.h
new file mode 100644
index 0000000..a4315ed
--- /dev/null
+++ b/ui/aura/desktop/desktop_cursor_client.h
@@ -0,0 +1,36 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef UI_AURA_DESKTOP_DESKTOP_CURSOR_CLIENT_H_
+#define UI_AURA_DESKTOP_DESKTOP_CURSOR_CLIENT_H_
+
+#include "base/compiler_specific.h"
+#include "ui/aura/aura_export.h"
+
+#include "ui/aura/client/cursor_client.h"
+
+namespace aura {
+class RootWindow;
+
+// A CursorClient that interacts with only one RootWindow. (Unlike the one in
+// ash, which interacts with all the RootWindows.)
+class AURA_EXPORT DesktopCursorClient : public client::CursorClient {
+ public:
+ explicit DesktopCursorClient(aura::RootWindow* window);
+ virtual ~DesktopCursorClient();
+
+ // Overridden from client::CursorClient:
+ virtual void SetCursor(gfx::NativeCursor cursor) OVERRIDE;
+ virtual void ShowCursor(bool show) OVERRIDE;
+ virtual bool IsCursorVisible() const OVERRIDE;
+
+ private:
+ aura::RootWindow* root_window_;
+
+ DISALLOW_COPY_AND_ASSIGN(DesktopCursorClient);
+};
+
+} // namespace aura
+
+#endif // UI_AURA_DESKTOP_DESKTOP_CURSOR_CLIENT_H_
diff --git a/ui/aura/env.cc b/ui/aura/env.cc
index 60bca1a..b00dd89 100644
--- a/ui/aura/env.cc
+++ b/ui/aura/env.cc
@@ -6,7 +6,6 @@
#include "base/command_line.h"
#include "ui/aura/client/screen_position_client.h"
-#include "ui/aura/cursor_manager.h"
#include "ui/aura/env_observer.h"
#include "ui/aura/event_filter.h"
#include "ui/aura/display_manager.h"
diff --git a/ui/aura/env.h b/ui/aura/env.h
index a6f49ba..e5a1952 100644
--- a/ui/aura/env.h
+++ b/ui/aura/env.h
@@ -9,12 +9,10 @@
#include "base/message_loop.h"
#include "base/observer_list.h"
#include "ui/aura/aura_export.h"
-#include "ui/aura/cursor_manager.h"
#include "ui/aura/client/stacking_client.h"
#include "ui/gfx/point.h"
namespace aura {
-class CursorManager;
class EnvObserver;
class EventFilter;
class DisplayManager;
@@ -78,8 +76,6 @@ class AURA_EXPORT Env {
EventFilter* event_filter() { return event_filter_.get(); }
void SetEventFilter(EventFilter* event_filter);
- CursorManager* cursor_manager() { return &cursor_manager_; }
-
// Returns the native event dispatcher. The result should only be passed to
// base::RunLoop(dispatcher), or used to dispatch an event by
// |Dispatch(const NativeEvent&)| on it. It must never be stored.
@@ -109,7 +105,6 @@ class AURA_EXPORT Env {
client::StackingClient* stacking_client_;
scoped_ptr<DisplayManager> display_manager_;
scoped_ptr<EventFilter> event_filter_;
- CursorManager cursor_manager_;
#if defined(USE_X11)
scoped_ptr<internal::DisplayChangeObserverX11> display_change_observer_;
diff --git a/ui/aura/shared/compound_event_filter.cc b/ui/aura/shared/compound_event_filter.cc
index f32d480..4bc8866 100644
--- a/ui/aura/shared/compound_event_filter.cc
+++ b/ui/aura/shared/compound_event_filter.cc
@@ -5,7 +5,7 @@
#include "ui/aura/shared/compound_event_filter.h"
#include "ui/aura/client/activation_client.h"
-#include "ui/aura/cursor_manager.h"
+#include "ui/aura/client/cursor_client.h"
#include "ui/aura/env.h"
#include "ui/aura/event.h"
#include "ui/aura/focus_manager.h"
@@ -103,7 +103,7 @@ bool CompoundEventFilter::PreHandleMouseEvent(aura::Window* target,
if (event->type() == ui::ET_MOUSE_MOVED ||
event->type() == ui::ET_MOUSE_PRESSED ||
event->type() == ui::ET_MOUSEWHEEL) {
- SetVisibilityOnEvent(event, true);
+ SetVisibilityOnEvent(target, event, true);
UpdateCursor(target, event);
}
@@ -145,7 +145,7 @@ ui::GestureStatus CompoundEventFilter::PreHandleGestureEvent(
event->details().touch_points() == 1 &&
target->GetRootWindow() &&
GetActiveWindow(target) != target) {
- SetVisibilityOnEvent(event, false);
+ SetVisibilityOnEvent(target, event, false);
target->GetFocusManager()->SetFocusedWindow(
FindFocusableWindowFor(target), event);
}
@@ -157,14 +157,19 @@ ui::GestureStatus CompoundEventFilter::PreHandleGestureEvent(
// CompoundEventFilter, private:
void CompoundEventFilter::UpdateCursor(aura::Window* target,
- aura::MouseEvent* event) {
- gfx::NativeCursor cursor = target->GetCursor(event->location());
- if (event->flags() & ui::EF_IS_NON_CLIENT) {
- int window_component =
- target->delegate()->GetNonClientComponent(event->location());
- cursor = CursorForWindowComponent(window_component);
+ aura::MouseEvent* event) {
+ aura::client::CursorClient* client =
+ aura::client::GetCursorClient(target->GetRootWindow());
+ if (client) {
+ gfx::NativeCursor cursor = target->GetCursor(event->location());
+ if (event->flags() & ui::EF_IS_NON_CLIENT) {
+ int window_component =
+ target->delegate()->GetNonClientComponent(event->location());
+ cursor = CursorForWindowComponent(window_component);
+ }
+
+ client->SetCursor(cursor);
}
- Env::GetInstance()->cursor_manager()->SetCursor(cursor);
}
bool CompoundEventFilter::FilterKeyEvent(aura::Window* target,
@@ -206,10 +211,15 @@ ui::TouchStatus CompoundEventFilter::FilterTouchEvent(
return status;
}
-void CompoundEventFilter::SetVisibilityOnEvent(aura::LocatedEvent* event,
- bool show) {
- if (update_cursor_visibility_ && !(event->flags() & ui::EF_IS_SYNTHESIZED))
- Env::GetInstance()->cursor_manager()->ShowCursor(show);
+void CompoundEventFilter::SetVisibilityOnEvent(aura::Window* target,
+ aura::LocatedEvent* event,
+ bool show) {
+ if (update_cursor_visibility_ && !(event->flags() & ui::EF_IS_SYNTHESIZED)) {
+ aura::client::CursorClient* client =
+ aura::client::GetCursorClient(target->GetRootWindow());
+ if (client)
+ client->ShowCursor(show);
+ }
}
} // namespace shared
diff --git a/ui/aura/shared/compound_event_filter.h b/ui/aura/shared/compound_event_filter.h
index 363287b..6fe76be 100644
--- a/ui/aura/shared/compound_event_filter.h
+++ b/ui/aura/shared/compound_event_filter.h
@@ -68,7 +68,8 @@ class AURA_EXPORT CompoundEventFilter : public aura::EventFilter {
// Sets the visibility of the cursor if the event is not synthesized and
// |update_cursor_visibility_| is true.
- void SetVisibilityOnEvent(aura::LocatedEvent* event, bool show);
+ void SetVisibilityOnEvent(aura::Window* target, aura::LocatedEvent* event,
+ bool show);
// Additional event filters that pre-handles events.
ObserverList<aura::EventFilter, true> filters_;
diff --git a/ui/aura/shared/compound_event_filter_unittest.cc b/ui/aura/shared/compound_event_filter_unittest.cc
index 85ecc47..edf6fb1 100644
--- a/ui/aura/shared/compound_event_filter_unittest.cc
+++ b/ui/aura/shared/compound_event_filter_unittest.cc
@@ -5,7 +5,7 @@
#include "ui/aura/shared/compound_event_filter.h"
#include "ui/aura/client/activation_client.h"
-#include "ui/aura/cursor_manager.h"
+#include "ui/aura/client/cursor_client.h"
#include "ui/aura/env.h"
#include "ui/aura/root_window.h"
#include "ui/aura/shared/root_window_capture_client.h"
@@ -17,6 +17,27 @@ namespace {
base::TimeDelta GetTime() {
return base::Time::NowFromSystemTime() - base::Time();
}
+
+class TestVisibleClient : public aura::client::CursorClient {
+ public:
+ TestVisibleClient() : visible_(false) {}
+ virtual ~TestVisibleClient() {}
+
+ virtual void SetCursor(gfx::NativeCursor cursor) OVERRIDE {
+ }
+
+ virtual void ShowCursor(bool show) OVERRIDE {
+ visible_ = show;
+ }
+
+ virtual bool IsCursorVisible() const OVERRIDE {
+ return visible_;
+ }
+
+ private:
+ bool visible_;
+};
+
}
namespace aura {
@@ -35,30 +56,32 @@ TEST_F(CompoundEventFilterTest, TouchHidesCursor) {
gfx::Rect(5, 5, 100, 100), NULL));
window->Show();
window->SetCapture();
- CursorManager* cursor_manager = aura::Env::GetInstance()->cursor_manager();
+
+ TestVisibleClient cursor_client;
+ aura::client::SetCursorClient(root_window(), &cursor_client);
MouseEvent mouse(ui::ET_MOUSE_MOVED, gfx::Point(10, 10),
gfx::Point(15, 15), 0);
root_window()->DispatchMouseEvent(&mouse);
- EXPECT_TRUE(cursor_manager->cursor_visible());
+ EXPECT_TRUE(cursor_client.IsCursorVisible());
// This press is required for the GestureRecognizer to associate a target
// with kTouchId
TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(90, 90), 1, GetTime());
root_window()->DispatchTouchEvent(&press);
- EXPECT_FALSE(cursor_manager->cursor_visible());
+ EXPECT_FALSE(cursor_client.IsCursorVisible());
TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(10, 10), 1,
GetTime());
root_window()->DispatchTouchEvent(&move);
- EXPECT_FALSE(cursor_manager->cursor_visible());
+ EXPECT_FALSE(cursor_client.IsCursorVisible());
TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(10, 10), 1, GetTime());
root_window()->DispatchTouchEvent(&release);
- EXPECT_FALSE(cursor_manager->cursor_visible());
+ EXPECT_FALSE(cursor_client.IsCursorVisible());
root_window()->DispatchMouseEvent(&mouse);
- EXPECT_TRUE(cursor_manager->cursor_visible());
+ EXPECT_TRUE(cursor_client.IsCursorVisible());
}
} // namespace test
diff --git a/ui/views/widget/desktop_native_widget_helper_aura.cc b/ui/views/widget/desktop_native_widget_helper_aura.cc
index e79171b..8606789 100644
--- a/ui/views/widget/desktop_native_widget_helper_aura.cc
+++ b/ui/views/widget/desktop_native_widget_helper_aura.cc
@@ -6,8 +6,8 @@
#include "ui/aura/client/dispatcher_client.h"
#include "ui/aura/client/screen_position_client.h"
-#include "ui/aura/cursor_manager.h"
#include "ui/aura/desktop/desktop_activation_client.h"
+#include "ui/aura/desktop/desktop_cursor_client.h"
#include "ui/aura/desktop/desktop_dispatcher_client.h"
#include "ui/aura/focus_manager.h"
#include "ui/aura/root_window.h"
@@ -134,8 +134,6 @@ void DesktopNativeWidgetHelperAura::PreInitialize(
// will probably be SetBounds()ed soon.
bounds.set_size(gfx::Size(100, 100));
}
- // TODO(erg): Implement aura::CursorManager::Delegate to control
- // cursor's shape and visibility.
aura::FocusManager* focus_manager = NULL;
aura::DesktopActivationClient* activation_client = NULL;
@@ -166,6 +164,9 @@ void DesktopNativeWidgetHelperAura::PreInitialize(
capture_client_.reset(
new aura::shared::RootWindowCaptureClient(root_window_.get()));
+ cursor_client_.reset(new aura::DesktopCursorClient(root_window_.get()));
+ aura::client::SetCursorClient(root_window_.get(), cursor_client_.get());
+
#if defined(USE_X11)
x11_window_event_filter_.reset(
new X11WindowEventFilter(root_window_.get(), activation_client, widget_));
diff --git a/ui/views/widget/desktop_native_widget_helper_aura.h b/ui/views/widget/desktop_native_widget_helper_aura.h
index e8ef105..90d41cb 100644
--- a/ui/views/widget/desktop_native_widget_helper_aura.h
+++ b/ui/views/widget/desktop_native_widget_helper_aura.h
@@ -13,6 +13,7 @@
namespace aura {
class RootWindow;
+class DesktopCursorClient;
namespace client {
class ScreenPositionClient;
}
@@ -89,6 +90,9 @@ class VIEWS_EXPORT DesktopNativeWidgetHelperAura
// do, we're responsible for the lifetime.
scoped_ptr<aura::client::ScreenPositionClient> position_client_;
+ // A simple cursor client which just forwards events to the RootWindow.
+ scoped_ptr<aura::DesktopCursorClient> cursor_client_;
+
#if defined(OS_WIN)
scoped_ptr<ui::HWNDMessageFilter> hwnd_message_filter_;
#elif defined(USE_X11)