summaryrefslogtreecommitdiffstats
path: root/views/widget
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 /views/widget
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
Diffstat (limited to 'views/widget')
-rw-r--r--views/widget/root_view.cc25
-rw-r--r--views/widget/widget_win.cc8
-rw-r--r--views/widget/widget_win.h4
3 files changed, 17 insertions, 20 deletions
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_;