summaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-26 18:12:06 +0000
committerben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-26 18:12:06 +0000
commitd525dfd45eeb3f6e5172f7d0d194a4cac43204d2 (patch)
treed5726beb313bac9f70568e7b4b470dc5a873151c /ui
parent00dde4c3d606d2d989df81d73b996ce0a1fe1f73 (diff)
downloadchromium_src-d525dfd45eeb3f6e5172f7d0d194a4cac43204d2.zip
chromium_src-d525dfd45eeb3f6e5172f7d0d194a4cac43204d2.tar.gz
chromium_src-d525dfd45eeb3f6e5172f7d0d194a4cac43204d2.tar.bz2
Move GetCursor() method from WindowDelegate to its own delegate interface CursorDelegate.
R=sky@chromium.org http://crbug.com/308845 Review URL: https://codereview.chromium.org/211733003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@259631 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r--ui/aura/demo/demo_main.cc3
-rw-r--r--ui/aura/test/test_window_delegate.cc4
-rw-r--r--ui/aura/test/test_window_delegate.h1
-rw-r--r--ui/aura/window.cc4
-rw-r--r--ui/aura/window.h3
-rw-r--r--ui/aura/window_delegate.h4
-rw-r--r--ui/keyboard/keyboard_controller.cc3
-rw-r--r--ui/views/controls/native/native_view_host_aura.cc8
-rw-r--r--ui/views/widget/desktop_aura/desktop_native_widget_aura.cc13
-rw-r--r--ui/views/widget/desktop_aura/desktop_native_widget_aura.h8
-rw-r--r--ui/views/widget/native_widget_aura.cc12
-rw-r--r--ui/views/widget/native_widget_aura.h8
-rw-r--r--ui/wm/core/compound_event_filter.cc5
-rw-r--r--ui/wm/public/cursor_delegate.cc24
-rw-r--r--ui/wm/public/cursor_delegate.h35
-rw-r--r--ui/wm/wm.gyp2
16 files changed, 100 insertions, 37 deletions
diff --git a/ui/aura/demo/demo_main.cc b/ui/aura/demo/demo_main.cc
index 548aede..a7a21cc 100644
--- a/ui/aura/demo/demo_main.cc
+++ b/ui/aura/demo/demo_main.cc
@@ -49,9 +49,6 @@ class DemoWindowDelegate : public aura::WindowDelegate {
virtual void OnBoundsChanged(const gfx::Rect& old_bounds,
const gfx::Rect& new_bounds) OVERRIDE {}
- virtual gfx::NativeCursor GetCursor(const gfx::Point& point) OVERRIDE {
- return gfx::kNullCursor;
- }
virtual int GetNonClientComponent(const gfx::Point& point) const OVERRIDE {
return HTCAPTION;
}
diff --git a/ui/aura/test/test_window_delegate.cc b/ui/aura/test/test_window_delegate.cc
index 7f0ca1b..127c545 100644
--- a/ui/aura/test/test_window_delegate.cc
+++ b/ui/aura/test/test_window_delegate.cc
@@ -50,10 +50,6 @@ void TestWindowDelegate::OnBoundsChanged(const gfx::Rect& old_bounds,
const gfx::Rect& new_bounds) {
}
-gfx::NativeCursor TestWindowDelegate::GetCursor(const gfx::Point& point) {
- return gfx::kNullCursor;
-}
-
int TestWindowDelegate::GetNonClientComponent(const gfx::Point& point) const {
return window_component_;
}
diff --git a/ui/aura/test/test_window_delegate.h b/ui/aura/test/test_window_delegate.h
index 6f36e44..e100116 100644
--- a/ui/aura/test/test_window_delegate.h
+++ b/ui/aura/test/test_window_delegate.h
@@ -46,7 +46,6 @@ class TestWindowDelegate : public WindowDelegate {
virtual gfx::Size GetMaximumSize() const OVERRIDE;
virtual void OnBoundsChanged(const gfx::Rect& old_bounds,
const gfx::Rect& new_bounds) OVERRIDE;
- virtual gfx::NativeCursor GetCursor(const gfx::Point& point) OVERRIDE;
virtual int GetNonClientComponent(const gfx::Point& point) const OVERRIDE;
virtual bool ShouldDescendIntoChildForEventHandling(
Window* child,
diff --git a/ui/aura/window.cc b/ui/aura/window.cc
index 86c9046..f3b8d5a 100644
--- a/ui/aura/window.cc
+++ b/ui/aura/window.cc
@@ -622,10 +622,6 @@ void Window::MoveCursorTo(const gfx::Point& point_in_window) {
root_window->GetHost()->MoveCursorTo(point_in_root);
}
-gfx::NativeCursor Window::GetCursor(const gfx::Point& point) const {
- return delegate_ ? delegate_->GetCursor(point) : gfx::kNullCursor;
-}
-
void Window::SetEventFilter(ui::EventHandler* event_filter) {
if (event_filter_)
RemovePreTargetHandler(event_filter_.get());
diff --git a/ui/aura/window.h b/ui/aura/window.h
index 2324533..b74e605 100644
--- a/ui/aura/window.h
+++ b/ui/aura/window.h
@@ -217,9 +217,6 @@ class AURA_EXPORT Window : public ui::LayerDelegate,
// Moves the cursor to the specified location relative to the window.
virtual void MoveCursorTo(const gfx::Point& point_in_window);
- // Returns the cursor for the specified point, in window coordinates.
- gfx::NativeCursor GetCursor(const gfx::Point& point) const;
-
// Sets an 'event filter' for the window. An 'event filter' for a Window is
// a pre-target event handler, where the window owns the handler. A window
// can have only one such event filter. Setting a new filter removes and
diff --git a/ui/aura/window_delegate.h b/ui/aura/window_delegate.h
index 90e978a..ce0a457 100644
--- a/ui/aura/window_delegate.h
+++ b/ui/aura/window_delegate.h
@@ -44,10 +44,6 @@ class AURA_EXPORT WindowDelegate : public ui::EventHandler {
virtual void OnBoundsChanged(const gfx::Rect& old_bounds,
const gfx::Rect& new_bounds) = 0;
- // Returns the native cursor for the specified point, in window coordinates,
- // or NULL for the default cursor.
- virtual gfx::NativeCursor GetCursor(const gfx::Point& point) = 0;
-
// Returns the non-client component (see hit_test.h) containing |point|, in
// window coordinates.
virtual int GetNonClientComponent(const gfx::Point& point) const = 0;
diff --git a/ui/keyboard/keyboard_controller.cc b/ui/keyboard/keyboard_controller.cc
index 1de832c..72f16ce 100644
--- a/ui/keyboard/keyboard_controller.cc
+++ b/ui/keyboard/keyboard_controller.cc
@@ -84,9 +84,6 @@ class KeyboardWindowDelegate : public aura::WindowDelegate {
const gfx::Rect& new_bounds) OVERRIDE {
bounds_ = new_bounds;
}
- virtual gfx::NativeCursor GetCursor(const gfx::Point& point) OVERRIDE {
- return gfx::kNullCursor;
- }
virtual int GetNonClientComponent(const gfx::Point& point) const OVERRIDE {
return HTNOWHERE;
}
diff --git a/ui/views/controls/native/native_view_host_aura.cc b/ui/views/controls/native/native_view_host_aura.cc
index 49bf733..edd65a6 100644
--- a/ui/views/controls/native/native_view_host_aura.cc
+++ b/ui/views/controls/native/native_view_host_aura.cc
@@ -11,6 +11,7 @@
#include "ui/views/controls/native/native_view_host.h"
#include "ui/views/view_constants_aura.h"
#include "ui/views/widget/widget.h"
+#include "ui/wm/public/cursor_delegate.h"
namespace views {
@@ -102,8 +103,11 @@ gfx::NativeViewAccessible NativeViewHostAura::GetNativeViewAccessible() {
}
gfx::NativeCursor NativeViewHostAura::GetCursor(int x, int y) {
- if (host_->native_view())
- return host_->native_view()->GetCursor(gfx::Point(x, y));
+ if (host_->native_view()) {
+ wm::CursorDelegate* delegate = wm::GetCursorDelegate(host_->native_view());
+ if (delegate)
+ return delegate->GetCursorForPoint(gfx::Point(x, y));
+ }
return gfx::kNullCursor;
}
diff --git a/ui/views/widget/desktop_aura/desktop_native_widget_aura.cc b/ui/views/widget/desktop_aura/desktop_native_widget_aura.cc
index 8341bce..ed46dc0 100644
--- a/ui/views/widget/desktop_aura/desktop_native_widget_aura.cc
+++ b/ui/views/widget/desktop_aura/desktop_native_widget_aura.cc
@@ -259,6 +259,7 @@ DesktopNativeWidgetAura::DesktopNativeWidgetAura(
widget_type_(Widget::InitParams::TYPE_WINDOW) {
aura::client::SetFocusChangeObserver(content_window_, this);
aura::client::SetActivationChangeObserver(content_window_, this);
+ wm::SetCursorDelegate(content_window_, this);
}
DesktopNativeWidgetAura::~DesktopNativeWidgetAura() {
@@ -929,10 +930,6 @@ gfx::Size DesktopNativeWidgetAura::GetMaximumSize() const {
return native_widget_delegate_->GetMaximumSize();
}
-gfx::NativeCursor DesktopNativeWidgetAura::GetCursor(const gfx::Point& point) {
- return cursor_;
-}
-
int DesktopNativeWidgetAura::GetNonClientComponent(
const gfx::Point& point) const {
return native_widget_delegate_->GetNonClientComponent(point);
@@ -1160,6 +1157,14 @@ void DesktopNativeWidgetAura::OnHostMoved(const aura::WindowTreeHost* host,
}
////////////////////////////////////////////////////////////////////////////////
+// DesktopNativeWidgetAura, wm::CursorDelegate implementation:
+
+gfx::NativeCursor DesktopNativeWidgetAura::GetCursorForPoint(
+ const gfx::Point& point) {
+ return cursor_;
+}
+
+////////////////////////////////////////////////////////////////////////////////
// DesktopNativeWidgetAura, NativeWidget implementation:
ui::EventHandler* DesktopNativeWidgetAura::GetEventHandler() {
diff --git a/ui/views/widget/desktop_aura/desktop_native_widget_aura.h b/ui/views/widget/desktop_aura/desktop_native_widget_aura.h
index c2966d9..687b0b3 100644
--- a/ui/views/widget/desktop_aura/desktop_native_widget_aura.h
+++ b/ui/views/widget/desktop_aura/desktop_native_widget_aura.h
@@ -15,6 +15,7 @@
#include "ui/wm/core/compound_event_filter.h"
#include "ui/wm/public/activation_change_observer.h"
#include "ui/wm/public/activation_delegate.h"
+#include "ui/wm/public/cursor_delegate.h"
#include "ui/wm/public/drag_drop_delegate.h"
namespace aura {
@@ -60,7 +61,8 @@ class VIEWS_EXPORT DesktopNativeWidgetAura
public aura::client::FocusChangeObserver,
public views::internal::InputMethodDelegate,
public aura::client::DragDropDelegate,
- public aura::WindowTreeHostObserver {
+ public aura::WindowTreeHostObserver,
+ public wm::CursorDelegate {
public:
explicit DesktopNativeWidgetAura(internal::NativeWidgetDelegate* delegate);
virtual ~DesktopNativeWidgetAura();
@@ -186,7 +188,6 @@ class VIEWS_EXPORT DesktopNativeWidgetAura
virtual gfx::Size GetMaximumSize() const OVERRIDE;
virtual void OnBoundsChanged(const gfx::Rect& old_bounds,
const gfx::Rect& new_bounds) OVERRIDE {}
- virtual gfx::NativeCursor GetCursor(const gfx::Point& point) OVERRIDE;
virtual int GetNonClientComponent(const gfx::Point& point) const OVERRIDE;
virtual bool ShouldDescendIntoChildForEventHandling(
aura::Window* child,
@@ -234,6 +235,9 @@ class VIEWS_EXPORT DesktopNativeWidgetAura
virtual void OnHostMoved(const aura::WindowTreeHost* host,
const gfx::Point& new_origin) OVERRIDE;
+ // Overridden from wm::CursorDelegate:
+ virtual gfx::NativeCursor GetCursorForPoint(const gfx::Point& point) OVERRIDE;
+
private:
friend class FocusManagerEventHandler;
friend class RootWindowDestructionObserver;
diff --git a/ui/views/widget/native_widget_aura.cc b/ui/views/widget/native_widget_aura.cc
index 8b36973..60a63a2 100644
--- a/ui/views/widget/native_widget_aura.cc
+++ b/ui/views/widget/native_widget_aura.cc
@@ -80,6 +80,7 @@ NativeWidgetAura::NativeWidgetAura(internal::NativeWidgetDelegate* delegate)
saved_window_state_(ui::SHOW_STATE_DEFAULT) {
aura::client::SetFocusChangeObserver(window_, this);
aura::client::SetActivationChangeObserver(window_, this);
+ wm::SetCursorDelegate(window_, this);
}
// static
@@ -725,10 +726,6 @@ void NativeWidgetAura::OnBoundsChanged(const gfx::Rect& old_bounds,
delegate_->OnNativeWidgetSizeChanged(new_bounds.size());
}
-gfx::NativeCursor NativeWidgetAura::GetCursor(const gfx::Point& point) {
- return cursor_;
-}
-
int NativeWidgetAura::GetNonClientComponent(const gfx::Point& point) const {
return delegate_->GetNonClientComponent(point);
}
@@ -944,6 +941,13 @@ int NativeWidgetAura::OnPerformDrop(const ui::DropTargetEvent& event) {
}
////////////////////////////////////////////////////////////////////////////////
+// NativeWidgetAura, wm::CursorDelegate implementation:
+
+gfx::NativeCursor NativeWidgetAura::GetCursorForPoint(const gfx::Point& point) {
+ return cursor_;
+}
+
+////////////////////////////////////////////////////////////////////////////////
// NativeWidgetAura, NativeWidget implementation:
ui::EventHandler* NativeWidgetAura::GetEventHandler() {
diff --git a/ui/views/widget/native_widget_aura.h b/ui/views/widget/native_widget_aura.h
index 6ca1e71..387eb31 100644
--- a/ui/views/widget/native_widget_aura.h
+++ b/ui/views/widget/native_widget_aura.h
@@ -16,6 +16,7 @@
#include "ui/views/widget/native_widget_private.h"
#include "ui/wm/public/activation_change_observer.h"
#include "ui/wm/public/activation_delegate.h"
+#include "ui/wm/public/cursor_delegate.h"
#include "ui/wm/public/drag_drop_delegate.h"
namespace aura {
@@ -38,7 +39,8 @@ class VIEWS_EXPORT NativeWidgetAura
public aura::client::ActivationDelegate,
public aura::client::ActivationChangeObserver,
public aura::client::FocusChangeObserver,
- public aura::client::DragDropDelegate {
+ public aura::client::DragDropDelegate,
+ public wm::CursorDelegate {
public:
explicit NativeWidgetAura(internal::NativeWidgetDelegate* delegate);
@@ -144,7 +146,6 @@ class VIEWS_EXPORT NativeWidgetAura
virtual gfx::Size GetMaximumSize() const OVERRIDE;
virtual void OnBoundsChanged(const gfx::Rect& old_bounds,
const gfx::Rect& new_bounds) OVERRIDE;
- virtual gfx::NativeCursor GetCursor(const gfx::Point& point) OVERRIDE;
virtual int GetNonClientComponent(const gfx::Point& point) const OVERRIDE;
virtual bool ShouldDescendIntoChildForEventHandling(
aura::Window* child,
@@ -183,6 +184,9 @@ class VIEWS_EXPORT NativeWidgetAura
virtual void OnDragExited() OVERRIDE;
virtual int OnPerformDrop(const ui::DropTargetEvent& event) OVERRIDE;
+ // Overridden from wm::CursorDelegate:
+ virtual gfx::NativeCursor GetCursorForPoint(const gfx::Point& point) OVERRIDE;
+
// Overridden from NativeWidget:
virtual ui::EventHandler* GetEventHandler() OVERRIDE;
diff --git a/ui/wm/core/compound_event_filter.cc b/ui/wm/core/compound_event_filter.cc
index edb7146..6efafea 100644
--- a/ui/wm/core/compound_event_filter.cc
+++ b/ui/wm/core/compound_event_filter.cc
@@ -15,6 +15,7 @@
#include "ui/base/hit_test.h"
#include "ui/events/event.h"
#include "ui/wm/public/activation_client.h"
+#include "ui/wm/public/cursor_delegate.h"
#include "ui/wm/public/drag_drop_client.h"
#if defined(OS_CHROMEOS) && defined(USE_X11)
@@ -158,7 +159,9 @@ void CompoundEventFilter::UpdateCursor(aura::Window* target,
aura::client::CursorClient* cursor_client =
aura::client::GetCursorClient(root_window);
if (cursor_client) {
- gfx::NativeCursor cursor = target->GetCursor(event->location());
+ CursorDelegate* delegate = GetCursorDelegate(target);
+ gfx::NativeCursor cursor = delegate ?
+ delegate->GetCursorForPoint(event->location()) : gfx::kNullCursor;
if ((event->flags() & ui::EF_IS_NON_CLIENT)) {
if (target->delegate()) {
int window_component =
diff --git a/ui/wm/public/cursor_delegate.cc b/ui/wm/public/cursor_delegate.cc
new file mode 100644
index 0000000..bea259d
--- /dev/null
+++ b/ui/wm/public/cursor_delegate.cc
@@ -0,0 +1,24 @@
+// Copyright 2014 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/wm/public/cursor_delegate.h"
+
+#include "ui/aura/window.h"
+#include "ui/aura/window_property.h"
+
+DECLARE_WINDOW_PROPERTY_TYPE(wm::CursorDelegate*);
+
+namespace wm {
+
+DEFINE_LOCAL_WINDOW_PROPERTY_KEY(CursorDelegate*, kCursorDelegateKey, NULL);
+
+void SetCursorDelegate(aura::Window* window, CursorDelegate* delegate) {
+ window->SetProperty(kCursorDelegateKey, delegate);
+}
+
+CursorDelegate* GetCursorDelegate(aura::Window* window) {
+ return window ? window->GetProperty(kCursorDelegateKey) : NULL;
+}
+
+} // namespace wm
diff --git a/ui/wm/public/cursor_delegate.h b/ui/wm/public/cursor_delegate.h
new file mode 100644
index 0000000..1acf4d7
--- /dev/null
+++ b/ui/wm/public/cursor_delegate.h
@@ -0,0 +1,35 @@
+// Copyright 2014 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_WM_PUBLIC_CURSOR_DELEGATE_H_
+#define UI_WM_PUBLIC_CURSOR_DELEGATE_H_
+
+#include "ui/gfx/native_widget_types.h"
+#include "ui/wm/core/wm_core_export.h"
+
+namespace aura {
+class Window;
+}
+
+namespace gfx {
+class Point;
+}
+
+namespace wm {
+
+class WM_CORE_EXPORT CursorDelegate {
+ public:
+ virtual gfx::NativeCursor GetCursorForPoint(const gfx::Point& point) = 0;
+
+ protected:
+ virtual ~CursorDelegate() {}
+};
+
+WM_CORE_EXPORT void SetCursorDelegate(aura::Window* window,
+ CursorDelegate* delegate);
+WM_CORE_EXPORT CursorDelegate* GetCursorDelegate(aura::Window* window);
+
+} // namespace wm
+
+#endif // UI_WM_PUBLIC_CURSOR_DELEGATE_H_
diff --git a/ui/wm/wm.gyp b/ui/wm/wm.gyp
index a1960ec..cccadc0 100644
--- a/ui/wm/wm.gyp
+++ b/ui/wm/wm.gyp
@@ -85,6 +85,8 @@
'core/wm_core_switches.h',
'core/wm_state.cc',
'core/wm_state.h',
+ 'public/cursor_delegate.cc',
+ 'public/cursor_delegate.h',
],
},
{