summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormsw@chromium.org <msw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-03 21:48:00 +0000
committermsw@chromium.org <msw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-03 21:48:00 +0000
commit3446c069d6670e68bf688aac606f4c2c818f22c3 (patch)
treeb6ba31d38a44b21cf1926572e47e41b793549b6a
parent8e1c5a3616e15f83e05766cb94093e8e9710f661 (diff)
downloadchromium_src-3446c069d6670e68bf688aac606f4c2c818f22c3.zip
chromium_src-3446c069d6670e68bf688aac606f4c2c818f22c3.tar.gz
chromium_src-3446c069d6670e68bf688aac606f4c2c818f22c3.tar.bz2
Rename View::GetCursor and simplify arguments.
Simplify RootView::UpdateCursor with MouseEvent ctor support. Restore pre-r83123 WigetWin::SetCursor(NULL) behavior. Cleanup (function ordering, OVERRIDEs, unnecessary "views::"). This originates from changes and comments of Patch Set 3 at: http://codereview.chromium.org/6893096/ BUG=72040 TEST=Mouse cursors. Review URL: http://codereview.chromium.org/6910032 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@83970 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/chromeos/login/shutdown_button.cc9
-rw-r--r--chrome/browser/chromeos/login/shutdown_button.h3
-rw-r--r--chrome/browser/chromeos/login/user_view.cc9
-rw-r--r--chrome/browser/chromeos/login/username_view.cc3
-rw-r--r--chrome/browser/chromeos/login/username_view.h3
-rw-r--r--chrome/browser/renderer_host/render_widget_host_view_views.cc4
-rw-r--r--chrome/browser/renderer_host/render_widget_host_view_views.h3
-rw-r--r--chrome/browser/ui/views/content_setting_bubble_contents.cc8
-rw-r--r--views/controls/link.cc47
-rw-r--r--views/controls/link.h11
-rw-r--r--views/controls/resize_area.cc3
-rw-r--r--views/controls/resize_area.h3
-rw-r--r--views/controls/single_split_view.cc20
-rw-r--r--views/controls/single_split_view.h3
-rw-r--r--views/controls/textfield/native_textfield_views.cc20
-rw-r--r--views/controls/textfield/native_textfield_views.h25
-rw-r--r--views/events/event.cc2
-rw-r--r--views/view.cc3
-rw-r--r--views/view.h5
-rw-r--r--views/widget/root_view.cc25
-rw-r--r--views/widget/widget_win.cc8
-rw-r--r--views/widget/widget_win.h4
22 files changed, 96 insertions, 125 deletions
diff --git a/chrome/browser/chromeos/login/shutdown_button.cc b/chrome/browser/chromeos/login/shutdown_button.cc
index 248a364..6b4c03e 100644
--- a/chrome/browser/chromeos/login/shutdown_button.cc
+++ b/chrome/browser/chromeos/login/shutdown_button.cc
@@ -106,6 +106,10 @@ void ShutdownButton::LayoutIn(views::View* parent) {
button_size.height());
}
+gfx::NativeCursor ShutdownButton::GetCursor(const views::MouseEvent& event) {
+ return IsEnabled() ? gfx::GetCursor(GDK_HAND2) : NULL;
+}
+
void ShutdownButton::OnLocaleChanged() {
SetText(UTF8ToWide(l10n_util::GetStringUTF8(IDS_SHUTDOWN_BUTTON)));
if (parent()) {
@@ -114,11 +118,6 @@ void ShutdownButton::OnLocaleChanged() {
}
}
-gfx::NativeCursor ShutdownButton::GetCursorForPoint(ui::EventType event_type,
- const gfx::Point& p) {
- return IsEnabled() ? gfx::GetCursor(GDK_HAND2) : NULL;
-}
-
void ShutdownButton::ButtonPressed(views::Button* sender,
const views::Event& event) {
DCHECK(CrosLibrary::Get()->EnsureLoaded());
diff --git a/chrome/browser/chromeos/login/shutdown_button.h b/chrome/browser/chromeos/login/shutdown_button.h
index 23fbc60..ba23640 100644
--- a/chrome/browser/chromeos/login/shutdown_button.h
+++ b/chrome/browser/chromeos/login/shutdown_button.h
@@ -24,9 +24,8 @@ class ShutdownButton : public views::TextButton,
private:
// views::View overrides.
+ virtual gfx::NativeCursor GetCursor(const views::MouseEvent& event) OVERRIDE;
virtual void OnLocaleChanged() OVERRIDE;
- virtual gfx::NativeCursor GetCursorForPoint(ui::EventType event_type,
- const gfx::Point& p) OVERRIDE;
// views::ButtonListener implementation.
virtual void ButtonPressed(views::Button* sender,
diff --git a/chrome/browser/chromeos/login/user_view.cc b/chrome/browser/chromeos/login/user_view.cc
index 1acdab46..e68a13f 100644
--- a/chrome/browser/chromeos/login/user_view.cc
+++ b/chrome/browser/chromeos/login/user_view.cc
@@ -227,6 +227,10 @@ class PodImageView : public views::ImageView {
protected:
// Overridden from View:
+ gfx::NativeCursor GetCursor(const views::MouseEvent& event) OVERRIDE {
+ return delegate_->IsUserSelected() ? NULL : gfx::GetCursor(GDK_HAND2);
+ }
+
virtual void OnMouseEntered(const views::MouseEvent& event) OVERRIDE {
views::ImageView::SetImage(image_hot_);
}
@@ -235,11 +239,6 @@ class PodImageView : public views::ImageView {
views::ImageView::SetImage(image_);
}
- gfx::NativeCursor GetCursorForPoint(ui::EventType event_type,
- const gfx::Point& p) OVERRIDE {
- return (delegate_->IsUserSelected()) ? NULL : gfx::GetCursor(GDK_HAND2);
- }
-
private:
const UserView::Delegate* delegate_;
diff --git a/chrome/browser/chromeos/login/username_view.cc b/chrome/browser/chromeos/login/username_view.cc
index a93cb01..92fbcbc 100644
--- a/chrome/browser/chromeos/login/username_view.cc
+++ b/chrome/browser/chromeos/login/username_view.cc
@@ -97,8 +97,7 @@ UsernameView* UsernameView::CreateShapedUsernameView(
return new HalfRoundedView<UsernameView>(username, use_small_shape);
}
-gfx::NativeCursor UsernameView::GetCursorForPoint(ui::EventType event_type,
- const gfx::Point& p) {
+gfx::NativeCursor UsernameView::GetCursor(const views::MouseEvent& event) {
return use_small_shape_ ? gfx::GetCursor(GDK_HAND2) : NULL;
}
diff --git a/chrome/browser/chromeos/login/username_view.h b/chrome/browser/chromeos/login/username_view.h
index 46d1c57..fd778a2 100644
--- a/chrome/browser/chromeos/login/username_view.h
+++ b/chrome/browser/chromeos/login/username_view.h
@@ -45,8 +45,7 @@ class UsernameView : public views::Label {
private:
// Overriden from View.
- virtual gfx::NativeCursor GetCursorForPoint(ui::EventType event_type,
- const gfx::Point& p) OVERRIDE;
+ virtual gfx::NativeCursor GetCursor(const views::MouseEvent& event) OVERRIDE;
virtual void OnLocaleChanged() OVERRIDE;
// Paints username to the bitmap with the bounds given.
diff --git a/chrome/browser/renderer_host/render_widget_host_view_views.cc b/chrome/browser/renderer_host/render_widget_host_view_views.cc
index be7e8fc..7ad2fe7 100644
--- a/chrome/browser/renderer_host/render_widget_host_view_views.cc
+++ b/chrome/browser/renderer_host/render_widget_host_view_views.cc
@@ -439,8 +439,8 @@ std::string RenderWidgetHostViewViews::GetClassName() const {
return kViewClassName;
}
-gfx::NativeCursor RenderWidgetHostViewViews::GetCursorForPoint(
- ui::EventType type, const gfx::Point& point) {
+gfx::NativeCursor RenderWidgetHostViewViews::GetCursor(
+ const views::MouseEvent& event) {
return native_cursor_;
}
diff --git a/chrome/browser/renderer_host/render_widget_host_view_views.h b/chrome/browser/renderer_host/render_widget_host_view_views.h
index 955afa9..9c6d218 100644
--- a/chrome/browser/renderer_host/render_widget_host_view_views.h
+++ b/chrome/browser/renderer_host/render_widget_host_view_views.h
@@ -90,8 +90,7 @@ class RenderWidgetHostViewViews : public RenderWidgetHostView,
// Overridden from views::View.
virtual std::string GetClassName() const OVERRIDE;
- virtual gfx::NativeCursor GetCursorForPoint(ui::EventType type,
- const gfx::Point& point) OVERRIDE;
+ virtual gfx::NativeCursor GetCursor(const views::MouseEvent& event) OVERRIDE;
virtual bool OnMousePressed(const views::MouseEvent& event) OVERRIDE;
virtual bool OnMouseDragged(const views::MouseEvent& event) OVERRIDE;
virtual void OnMouseReleased(const views::MouseEvent& event) OVERRIDE;
diff --git a/chrome/browser/ui/views/content_setting_bubble_contents.cc b/chrome/browser/ui/views/content_setting_bubble_contents.cc
index 2e6ad13..de8d67f 100644
--- a/chrome/browser/ui/views/content_setting_bubble_contents.cc
+++ b/chrome/browser/ui/views/content_setting_bubble_contents.cc
@@ -53,8 +53,7 @@ class ContentSettingBubbleContents::Favicon : public views::ImageView {
// views::View overrides:
virtual bool OnMousePressed(const views::MouseEvent& event) OVERRIDE;
virtual void OnMouseReleased(const views::MouseEvent& event) OVERRIDE;
- virtual gfx::NativeCursor GetCursorForPoint(ui::EventType event_type,
- const gfx::Point& p) OVERRIDE;
+ virtual gfx::NativeCursor GetCursor(const views::MouseEvent& event) OVERRIDE;
ContentSettingBubbleContents* parent_;
views::Link* link_;
@@ -85,9 +84,8 @@ void ContentSettingBubbleContents::Favicon::OnMouseReleased(
}
}
-gfx::NativeCursor ContentSettingBubbleContents::Favicon::GetCursorForPoint(
- ui::EventType event_type,
- const gfx::Point& p) {
+gfx::NativeCursor ContentSettingBubbleContents::Favicon::GetCursor(
+ const views::MouseEvent& event) {
#if defined(OS_WIN)
static HCURSOR g_hand_cursor = LoadCursor(NULL, IDC_HAND);
return g_hand_cursor;
diff --git a/views/controls/link.cc b/views/controls/link.cc
index 061b36d..3c8bceac 100644
--- a/views/controls/link.cc
+++ b/views/controls/link.cc
@@ -88,6 +88,29 @@ void Link::Init() {
Link::~Link() {
}
+void Link::SetEnabled(bool flag) {
+ if (flag != enabled_) {
+ enabled_ = flag;
+ ValidateStyle();
+ SchedulePaint();
+ }
+}
+
+std::string Link::GetClassName() const {
+ return kViewClassName;
+}
+
+gfx::NativeCursor Link::GetCursor(const MouseEvent& event) {
+ if (!enabled_)
+ return NULL;
+#if defined(OS_WIN)
+ static HCURSOR g_hand_cursor = LoadCursor(NULL, IDC_HAND);
+ return g_hand_cursor;
+#elif defined(OS_LINUX)
+ return gfx::GetCursor(GDK_HAND2);
+#endif
+}
+
bool Link::OnMousePressed(const MouseEvent& event) {
if (!enabled_ || (!event.IsLeftMouseButton() && !event.IsMiddleMouseButton()))
return false;
@@ -153,30 +176,6 @@ void Link::SetFont(const gfx::Font& font) {
ValidateStyle();
}
-void Link::SetEnabled(bool flag) {
- if (flag != enabled_) {
- enabled_ = flag;
- ValidateStyle();
- SchedulePaint();
- }
-}
-
-gfx::NativeCursor Link::GetCursorForPoint(ui::EventType event_type,
- const gfx::Point& p) {
- if (!enabled_)
- return NULL;
-#if defined(OS_WIN)
- static HCURSOR g_hand_cursor = LoadCursor(NULL, IDC_HAND);
- return g_hand_cursor;
-#elif defined(OS_LINUX)
- return gfx::GetCursor(GDK_HAND2);
-#endif
-}
-
-std::string Link::GetClassName() const {
- return kViewClassName;
-}
-
void Link::SetHighlightedColor(const SkColor& color) {
highlighted_color_ = color;
ValidateStyle();
diff --git a/views/controls/link.h b/views/controls/link.h
index d0197ad..2a356bd 100644
--- a/views/controls/link.h
+++ b/views/controls/link.h
@@ -32,6 +32,9 @@ class Link : public Label {
void set_listener(LinkListener* listener) { listener_ = listener; }
// Overridden from View:
+ virtual void SetEnabled(bool flag) OVERRIDE;
+ virtual std::string GetClassName() const OVERRIDE;
+ virtual gfx::NativeCursor GetCursor(const MouseEvent& event) OVERRIDE;
virtual bool OnMousePressed(const MouseEvent& event) OVERRIDE;
virtual bool OnMouseDragged(const MouseEvent& event) OVERRIDE;
virtual void OnMouseReleased(const MouseEvent& event) OVERRIDE;
@@ -43,14 +46,6 @@ class Link : public Label {
// Overridden from Label:
virtual void SetFont(const gfx::Font& font) OVERRIDE;
- // Set whether the link is enabled.
- virtual void SetEnabled(bool flag) OVERRIDE;
-
- virtual gfx::NativeCursor GetCursorForPoint(ui::EventType event_type,
- const gfx::Point& p) OVERRIDE;
-
- virtual std::string GetClassName() const OVERRIDE;
-
void SetHighlightedColor(const SkColor& color);
void SetDisabledColor(const SkColor& color);
void SetNormalColor(const SkColor& color);
diff --git a/views/controls/resize_area.cc b/views/controls/resize_area.cc
index 8e17919..a0a62ee 100644
--- a/views/controls/resize_area.cc
+++ b/views/controls/resize_area.cc
@@ -31,8 +31,7 @@ std::string ResizeArea::GetClassName() const {
return kViewClassName;
}
-gfx::NativeCursor ResizeArea::GetCursorForPoint(ui::EventType event_type,
- const gfx::Point& p) {
+gfx::NativeCursor ResizeArea::GetCursor(const MouseEvent& event) {
if (!enabled_)
return NULL;
#if defined(OS_WIN)
diff --git a/views/controls/resize_area.h b/views/controls/resize_area.h
index 6c0f66d..1ac9f82 100644
--- a/views/controls/resize_area.h
+++ b/views/controls/resize_area.h
@@ -42,8 +42,7 @@ class ResizeArea : public View {
// Overridden from views::View:
virtual std::string GetClassName() const OVERRIDE;
- virtual gfx::NativeCursor GetCursorForPoint(ui::EventType event_type,
- const gfx::Point& p) OVERRIDE;
+ virtual gfx::NativeCursor GetCursor(const views::MouseEvent& event) OVERRIDE;
virtual bool OnMousePressed(const views::MouseEvent& event) OVERRIDE;
virtual bool OnMouseDragged(const views::MouseEvent& event) OVERRIDE;
virtual void OnMouseReleased(const views::MouseEvent& event) OVERRIDE;
diff --git a/views/controls/single_split_view.cc b/views/controls/single_split_view.cc
index d9f8912..1d2c8a9 100644
--- a/views/controls/single_split_view.cc
+++ b/views/controls/single_split_view.cc
@@ -85,21 +85,17 @@ gfx::Size SingleSplitView::GetPreferredSize() {
return gfx::Size(width, height);
}
-gfx::NativeCursor SingleSplitView::GetCursorForPoint(
- ui::EventType event_type,
- const gfx::Point& p) {
- if (IsPointInDivider(p)) {
+gfx::NativeCursor SingleSplitView::GetCursor(const MouseEvent& event) {
+ if (!IsPointInDivider(event.location()))
+ return NULL;
#if defined(OS_WIN)
- static HCURSOR we_resize_cursor = LoadCursor(NULL, IDC_SIZEWE);
- static HCURSOR ns_resize_cursor = LoadCursor(NULL, IDC_SIZENS);
- return is_horizontal_ ? we_resize_cursor : ns_resize_cursor;
+ static HCURSOR we_resize_cursor = LoadCursor(NULL, IDC_SIZEWE);
+ static HCURSOR ns_resize_cursor = LoadCursor(NULL, IDC_SIZENS);
+ return is_horizontal_ ? we_resize_cursor : ns_resize_cursor;
#elif defined(OS_LINUX)
- return gfx::GetCursor(is_horizontal_ ?
- GDK_SB_H_DOUBLE_ARROW :
- GDK_SB_V_DOUBLE_ARROW);
+ return gfx::GetCursor(is_horizontal_ ? GDK_SB_H_DOUBLE_ARROW :
+ GDK_SB_V_DOUBLE_ARROW);
#endif
- }
- return NULL;
}
void SingleSplitView::CalculateChildrenBounds(
diff --git a/views/controls/single_split_view.h b/views/controls/single_split_view.h
index 63fd702..ab6bedf 100644
--- a/views/controls/single_split_view.h
+++ b/views/controls/single_split_view.h
@@ -48,8 +48,7 @@ class SingleSplitView : public views::View {
virtual gfx::Size GetPreferredSize() OVERRIDE;
// Overriden to return a resize cursor when over the divider.
- virtual gfx::NativeCursor GetCursorForPoint(ui::EventType event_type,
- const gfx::Point& p) OVERRIDE;
+ virtual gfx::NativeCursor GetCursor(const MouseEvent& event) OVERRIDE;
Orientation orientation() const {
return is_horizontal_ ? HORIZONTAL_SPLIT : VERTICAL_SPLIT;
diff --git a/views/controls/textfield/native_textfield_views.cc b/views/controls/textfield/native_textfield_views.cc
index 546b188..77b8098 100644
--- a/views/controls/textfield/native_textfield_views.cc
+++ b/views/controls/textfield/native_textfield_views.cc
@@ -86,7 +86,7 @@ NativeTextfieldViews::~NativeTextfieldViews() {
////////////////////////////////////////////////////////////////////////////////
// NativeTextfieldViews, View overrides:
-bool NativeTextfieldViews::OnMousePressed(const views::MouseEvent& event) {
+bool NativeTextfieldViews::OnMousePressed(const MouseEvent& event) {
OnBeforeUserAction();
if (HandleMousePressed(event))
SchedulePaint();
@@ -94,7 +94,7 @@ bool NativeTextfieldViews::OnMousePressed(const views::MouseEvent& event) {
return true;
}
-bool NativeTextfieldViews::OnMouseDragged(const views::MouseEvent& event) {
+bool NativeTextfieldViews::OnMouseDragged(const MouseEvent& event) {
OnBeforeUserAction();
size_t pos = FindCursorPosition(event.location());
if (model_->MoveCursorTo(pos, true)) {
@@ -105,14 +105,14 @@ bool NativeTextfieldViews::OnMouseDragged(const views::MouseEvent& event) {
return true;
}
-bool NativeTextfieldViews::OnKeyPressed(const views::KeyEvent& event) {
+bool NativeTextfieldViews::OnKeyPressed(const KeyEvent& event) {
// OnKeyPressed/OnKeyReleased/OnFocus/OnBlur will never be invoked on
// NativeTextfieldViews as it will never gain focus.
NOTREACHED();
return false;
}
-bool NativeTextfieldViews::OnKeyReleased(const views::KeyEvent& event) {
+bool NativeTextfieldViews::OnKeyReleased(const KeyEvent& event) {
NOTREACHED();
return false;
}
@@ -133,9 +133,7 @@ void NativeTextfieldViews::OnBlur() {
NOTREACHED();
}
-gfx::NativeCursor NativeTextfieldViews::GetCursorForPoint(
- ui::EventType event_type,
- const gfx::Point& p) {
+gfx::NativeCursor NativeTextfieldViews::GetCursor(const MouseEvent& event) {
#if defined(OS_WIN)
static HCURSOR ibeam = LoadCursor(NULL, IDC_IBEAM);
return ibeam;
@@ -145,7 +143,7 @@ gfx::NativeCursor NativeTextfieldViews::GetCursorForPoint(
}
/////////////////////////////////////////////////////////////////
-// NativeTextfieldViews, views::ContextMenuController overrides:
+// NativeTextfieldViews, ContextMenuController overrides:
void NativeTextfieldViews::ShowContextMenuForView(View* source,
const gfx::Point& p,
bool is_mouse_gesture) {
@@ -287,7 +285,7 @@ size_t NativeTextfieldViews::GetCursorPosition() const {
return model_->cursor_pos();
}
-bool NativeTextfieldViews::HandleKeyPressed(const views::KeyEvent& e) {
+bool NativeTextfieldViews::HandleKeyPressed(const KeyEvent& e) {
TextfieldController* controller = textfield_->GetController();
bool handled = false;
if (controller)
@@ -295,7 +293,7 @@ bool NativeTextfieldViews::HandleKeyPressed(const views::KeyEvent& e) {
return handled || HandleKeyEvent(e);
}
-bool NativeTextfieldViews::HandleKeyReleased(const views::KeyEvent& e) {
+bool NativeTextfieldViews::HandleKeyReleased(const KeyEvent& e) {
return true;
}
@@ -339,7 +337,7 @@ bool NativeTextfieldViews::IsCommandIdEnabled(int command_id) const {
case IDS_APP_COPY:
return model_->HasSelection();
case IDS_APP_PASTE:
- views::ViewsDelegate::views_delegate->GetClipboard()
+ ViewsDelegate::views_delegate->GetClipboard()
->ReadText(ui::Clipboard::BUFFER_STANDARD, &result);
return editable && !result.empty();
case IDS_APP_DELETE:
diff --git a/views/controls/textfield/native_textfield_views.h b/views/controls/textfield/native_textfield_views.h
index 69385049c..e95c1a5 100644
--- a/views/controls/textfield/native_textfield_views.h
+++ b/views/controls/textfield/native_textfield_views.h
@@ -40,8 +40,8 @@ class Menu2;
// chromeos, so we may not need them)
// * Double click to select word, and triple click to select all.
// * Undo/Redo
-class NativeTextfieldViews : public views::View,
- public views::ContextMenuController,
+class NativeTextfieldViews : public View,
+ public ContextMenuController,
public NativeTextfieldWrapper,
public ui::SimpleMenuModel::Delegate,
public TextInputClient,
@@ -50,18 +50,17 @@ class NativeTextfieldViews : public views::View,
explicit NativeTextfieldViews(Textfield* parent);
~NativeTextfieldViews();
- // views::View overrides:
- virtual bool OnMousePressed(const views::MouseEvent& event) OVERRIDE;
- virtual bool OnMouseDragged(const views::MouseEvent& event) OVERRIDE;
- virtual bool OnKeyPressed(const views::KeyEvent& event) OVERRIDE;
- virtual bool OnKeyReleased(const views::KeyEvent& event) OVERRIDE;
+ // View overrides:
+ virtual gfx::NativeCursor GetCursor(const MouseEvent& event) OVERRIDE;
+ virtual bool OnMousePressed(const MouseEvent& event) OVERRIDE;
+ virtual bool OnMouseDragged(const MouseEvent& event) OVERRIDE;
+ virtual bool OnKeyPressed(const KeyEvent& event) OVERRIDE;
+ virtual bool OnKeyReleased(const KeyEvent& event) OVERRIDE;
virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE;
virtual void OnFocus() OVERRIDE;
virtual void OnBlur() OVERRIDE;
- virtual gfx::NativeCursor GetCursorForPoint(ui::EventType event_type,
- const gfx::Point& p) OVERRIDE;
- // views::ContextMenuController overrides:
+ // ContextMenuController overrides:
virtual void ShowContextMenuForView(View* source,
const gfx::Point& p,
bool is_mouse_gesture) OVERRIDE;
@@ -90,8 +89,8 @@ class NativeTextfieldViews : public views::View,
virtual void GetSelectedRange(ui::Range* range) const OVERRIDE;
virtual void SelectRange(const ui::Range& range) OVERRIDE;
virtual size_t GetCursorPosition() const OVERRIDE;
- virtual bool HandleKeyPressed(const views::KeyEvent& e) OVERRIDE;
- virtual bool HandleKeyReleased(const views::KeyEvent& e) OVERRIDE;
+ virtual bool HandleKeyPressed(const KeyEvent& e) OVERRIDE;
+ virtual bool HandleKeyReleased(const KeyEvent& e) OVERRIDE;
virtual void HandleFocus() OVERRIDE;
virtual void HandleBlur() OVERRIDE;
virtual TextInputClient* GetTextInputClient() OVERRIDE;
@@ -178,7 +177,7 @@ class NativeTextfieldViews : public views::View,
size_t FindCursorPosition(const gfx::Point& point) const;
// Mouse event handler. Returns true if textfield needs to be repainted.
- bool HandleMousePressed(const views::MouseEvent& e);
+ bool HandleMousePressed(const MouseEvent& e);
// Helper function that sets the cursor position at the location of mouse
// event.
diff --git a/views/events/event.cc b/views/events/event.cc
index 9f820cf..b729967 100644
--- a/views/events/event.cc
+++ b/views/events/event.cc
@@ -49,7 +49,7 @@ LocatedEvent::LocatedEvent(const LocatedEvent& model, View* source,
View* target)
: Event(model),
location_(model.location_) {
- if (target)
+ if (target && target != source)
View::ConvertPointToView(source, target, &location_);
}
diff --git a/views/view.cc b/views/view.cc
index 177fa4b..eeab268 100644
--- a/views/view.cc
+++ b/views/view.cc
@@ -767,8 +767,7 @@ View* View::GetEventHandlerForPoint(const gfx::Point& point) {
return this;
}
-gfx::NativeCursor View::GetCursorForPoint(ui::EventType event_type,
- const gfx::Point& p) {
+gfx::NativeCursor View::GetCursor(const MouseEvent& event) {
#if defined(OS_WIN)
static HCURSOR arrow = LoadCursor(NULL, IDC_ARROW);
return arrow;
diff --git a/views/view.h b/views/view.h
index 5df51d6..3722e986 100644
--- a/views/view.h
+++ b/views/view.h
@@ -584,12 +584,11 @@ class View : public AcceleratorTarget {
virtual View* GetEventHandlerForPoint(const gfx::Point& point);
// Return the cursor that should be used for this view or the default cursor.
- // The provided point is in the receiver's coordinate system. The caller is
+ // The event location is in the receiver's coordinate system. The caller is
// responsible for managing the lifetime of the returned object, though that
// lifetime may vary from platform to platform. On Windows, the cursor is a
// shared resource, but Gtk destroys the returned cursor after setting it.
- virtual gfx::NativeCursor GetCursorForPoint(ui::EventType event_type,
- const gfx::Point& p);
+ virtual gfx::NativeCursor GetCursor(const MouseEvent& event);
// Convenience to test whether a point is within this view's bounds
virtual bool HitTest(const gfx::Point& l) const;
diff --git a/views/widget/root_view.cc b/views/widget/root_view.cc
index 029a84b..ad1666b 100644
--- a/views/widget/root_view.cc
+++ b/views/widget/root_view.cc
@@ -299,12 +299,11 @@ void RootView::OnMouseMoved(const MouseEvent& event) {
}
MouseEvent moved_event(e, this, mouse_move_handler_);
mouse_move_handler_->OnMouseMoved(moved_event);
-
- if (!(event.flags() & ui::EF_IS_NON_CLIENT))
- widget_->SetCursor(mouse_move_handler_->GetCursorForPoint(
- moved_event.type(), moved_event.location()));
+ if (!(moved_event.flags() & ui::EF_IS_NON_CLIENT))
+ widget_->SetCursor(mouse_move_handler_->GetCursor(moved_event));
} else if (mouse_move_handler_ != NULL) {
mouse_move_handler_->OnMouseExited(e);
+ widget_->SetCursor(NULL);
}
}
@@ -440,22 +439,10 @@ void RootView::OnPaint(gfx::Canvas* canvas) {
// Input -----------------------------------------------------------------------
void RootView::UpdateCursor(const MouseEvent& event) {
- if (event.flags() & ui::EF_IS_NON_CLIENT)
- return;
-
- gfx::NativeCursor cursor = NULL;
-#if defined(OS_WIN)
- static HCURSOR arrow = LoadCursor(NULL, IDC_ARROW);
- cursor = arrow;
-#endif
-
- View* v = GetEventHandlerForPoint(event.location());
- if (v && v != this) {
- gfx::Point l(event.location());
- View::ConvertPointToView(this, v, &l);
- cursor = v->GetCursorForPoint(event.type(), l);
+ if (!(event.flags() & ui::EF_IS_NON_CLIENT)) {
+ View* v = GetEventHandlerForPoint(event.location());
+ widget_->SetCursor(v->GetCursor(MouseEvent(event, this, v)));
}
- widget_->SetCursor(cursor);
}
void RootView::SetMouseLocationAndFlags(const MouseEvent& event) {
diff --git a/views/widget/widget_win.cc b/views/widget/widget_win.cc
index 1d2ab99..4fb0802 100644
--- a/views/widget/widget_win.cc
+++ b/views/widget/widget_win.cc
@@ -145,6 +145,7 @@ WidgetWin::WidgetWin()
restore_focus_when_enabled_(false),
accessibility_view_events_index_(-1),
accessibility_view_events_(kMaxAccessibilityViewEvents),
+ previous_cursor_(NULL),
is_input_method_win_(false) {
set_native_widget(this);
}
@@ -438,7 +439,12 @@ void WidgetWin::SchedulePaintInRect(const gfx::Rect& rect) {
}
void WidgetWin::SetCursor(gfx::NativeCursor cursor) {
- ::SetCursor(cursor);
+ if(cursor) {
+ previous_cursor_ = ::SetCursor(cursor);
+ } else if (previous_cursor_) {
+ ::SetCursor(previous_cursor_);
+ previous_cursor_ = NULL;
+ }
}
void WidgetWin::NotifyAccessibilityEvent(
diff --git a/views/widget/widget_win.h b/views/widget/widget_win.h
index 4fe63cc..3c2974b 100644
--- a/views/widget/widget_win.h
+++ b/views/widget/widget_win.h
@@ -510,6 +510,10 @@ class WidgetWin : public ui::WindowImpl,
// we always mod this value with the max view events above .
int accessibility_view_events_index_;
+ // The last cursor that was active before the current one was selected. Saved
+ // so that we can restore it.
+ gfx::NativeCursor previous_cursor_;
+
ViewProps props_;
scoped_ptr<InputMethod> input_method_;