summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--views/view.cc24
-rw-r--r--views/view_gtk.cc15
-rw-r--r--views/view_win.cc16
-rw-r--r--views/widget/root_view.cc11
-rw-r--r--views/widget/root_view_gtk.cc4
-rw-r--r--views/widget/root_view_win.cc17
6 files changed, 35 insertions, 52 deletions
diff --git a/views/view.cc b/views/view.cc
index f817f1c..1730bb9 100644
--- a/views/view.cc
+++ b/views/view.cc
@@ -11,6 +11,7 @@
#include "app/drag_drop_types.h"
#include "app/gfx/canvas.h"
+#include "app/gfx/path.h"
#include "app/l10n_util.h"
#include "base/logging.h"
#include "base/message_loop.h"
@@ -402,6 +403,29 @@ gfx::NativeCursor View::GetCursorForPoint(Event::EventType event_type, int x,
return NULL;
}
+bool View::HitTest(const gfx::Point& l) const {
+ if (l.x() >= 0 && l.x() < static_cast<int>(width()) &&
+ l.y() >= 0 && l.y() < static_cast<int>(height())) {
+ if (HasHitTestMask()) {
+ gfx::Path mask;
+ GetHitTestMask(&mask);
+#if defined(OS_WIN)
+ ScopedHRGN rgn(mask.CreateHRGN());
+ return !!PtInRegion(rgn, l.x(), l.y());
+#elif defined(OS_LINUX)
+ GdkRegion* region = mask.CreateGdkRegion();
+ bool result = gdk_region_point_in(region, l.x(), l.y());
+ gdk_region_destroy(region);
+ return result;
+#endif
+ }
+ // No mask, but inside our bounds.
+ return true;
+ }
+ // Outside our bounds.
+ return false;
+}
+
void View::SetContextMenuController(ContextMenuController* menu_controller) {
context_menu_controller_ = menu_controller;
}
diff --git a/views/view_gtk.cc b/views/view_gtk.cc
index 61ca6ca..4edb9e3 100644
--- a/views/view_gtk.cc
+++ b/views/view_gtk.cc
@@ -22,21 +22,6 @@ ViewAccessibilityWrapper* View::GetViewAccessibilityWrapper() {
return NULL;
}
-bool View::HitTest(const gfx::Point& l) const {
- if (l.x() >= 0 && l.x() < static_cast<int>(width()) &&
- l.y() >= 0 && l.y() < static_cast<int>(height())) {
- if (HasHitTestMask()) {
- // TODO(port): port the windows hit test code here. Once that's factored
- // out, we can probably move View::HitTest back into views.cc.
- NOTIMPLEMENTED();
- }
- // No mask, but inside our bounds.
- return true;
- }
- // Outside our bounds.
- return false;
-}
-
void View::Focus() {
NOTIMPLEMENTED();
}
diff --git a/views/view_win.cc b/views/view_win.cc
index cff8e53..c61363d 100644
--- a/views/view_win.cc
+++ b/views/view_win.cc
@@ -50,22 +50,6 @@ ViewAccessibilityWrapper* View::GetViewAccessibilityWrapper() {
return accessibility_.get();
}
-bool View::HitTest(const gfx::Point& l) const {
- if (l.x() >= 0 && l.x() < static_cast<int>(width()) &&
- l.y() >= 0 && l.y() < static_cast<int>(height())) {
- if (HasHitTestMask()) {
- gfx::Path mask;
- GetHitTestMask(&mask);
- ScopedHRGN rgn(mask.CreateHRGN());
- return !!PtInRegion(rgn, l.x(), l.y());
- }
- // No mask, but inside our bounds.
- return true;
- }
- // Outside our bounds.
- return false;
-}
-
void View::Focus() {
// Set the native focus to the root view window so it receives the keyboard
// messages.
diff --git a/views/widget/root_view.cc b/views/widget/root_view.cc
index 08b7e6e..df11d3e 100644
--- a/views/widget/root_view.cc
+++ b/views/widget/root_view.cc
@@ -408,6 +408,17 @@ bool RootView::ConvertPointToMouseHandler(const gfx::Point& l,
return true;
}
+void RootView::UpdateCursor(const MouseEvent& e) {
+ gfx::NativeCursor cursor = NULL;
+ View* v = GetViewForPoint(e.location());
+ if (v && v != this) {
+ gfx::Point l(e.location());
+ View::ConvertPointToView(this, v, &l);
+ cursor = v->GetCursorForPoint(e.GetType(), l.x(), l.y());
+ }
+ SetActiveCursor(cursor);
+}
+
bool RootView::OnMouseDragged(const MouseEvent& e) {
UpdateCursor(e);
diff --git a/views/widget/root_view_gtk.cc b/views/widget/root_view_gtk.cc
index 9010960..5c02a71 100644
--- a/views/widget/root_view_gtk.cc
+++ b/views/widget/root_view_gtk.cc
@@ -12,10 +12,6 @@
namespace views {
-void RootView::UpdateCursor(const MouseEvent& e) {
- NOTIMPLEMENTED();
-}
-
void RootView::OnPaint(GdkEventExpose* event) {
gfx::CanvasPaint canvas(event);
diff --git a/views/widget/root_view_win.cc b/views/widget/root_view_win.cc
index 14ca68a6..f5b315cb 100644
--- a/views/widget/root_view_win.cc
+++ b/views/widget/root_view_win.cc
@@ -12,23 +12,6 @@
namespace views {
-void RootView::UpdateCursor(const MouseEvent& e) {
- View *v = GetViewForPoint(e.location());
-
- if (v && v != this) {
- gfx::Point l(e.location());
- View::ConvertPointToView(this, v, &l);
- HCURSOR cursor = v->GetCursorForPoint(e.GetType(), l.x(), l.y());
- if (cursor) {
- ::SetCursor(cursor);
- return;
- }
- }
- if (previous_cursor_) {
- SetCursor(previous_cursor_);
- }
-}
-
void RootView::OnPaint(HWND hwnd) {
gfx::Rect original_dirty_region = GetScheduledPaintRectConstrainedToSize();
if (!original_dirty_region.IsEmpty()) {