summaryrefslogtreecommitdiffstats
path: root/views/widget
diff options
context:
space:
mode:
authorxiyuan@chromium.org <xiyuan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-16 05:29:32 +0000
committerxiyuan@chromium.org <xiyuan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-16 05:29:32 +0000
commit1e498ed00f877c07964760a7045ef576452fe42d (patch)
tree1a69ad606b0f898c59e5ef1e372da04744b26223 /views/widget
parent19e9aad1795387d97f0ab6849321a2c0f95ef49b (diff)
downloadchromium_src-1e498ed00f877c07964760a7045ef576452fe42d.zip
chromium_src-1e498ed00f877c07964760a7045ef576452fe42d.tar.gz
chromium_src-1e498ed00f877c07964760a7045ef576452fe42d.tar.bz2
Gtk views code touch up
- Fix wrong mouse event coordinates in gtk event handlers. Gtk events could be propogate to parent if child does not handle it and we need to translate the coordinates in gtk event in this case; - Consume button pressed event if a widget is not transparent; - Move mouse cursor reset handling on mouse leave from WindowGtk into RootView. This is because once WindowGtk set a mouse cursor, it stucks there and RootView could not change it. BUG=None TEST=Verify the following two cases: 1. Click on top of a tab should not move chrome; 2. Dock devtools and mouse cursor should change correct on the split and change back to left pointer on leave the split; Review URL: http://codereview.chromium.org/997002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@41681 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/widget')
-rw-r--r--views/widget/root_view.cc7
-rw-r--r--views/widget/widget_gtk.cc21
2 files changed, 22 insertions, 6 deletions
diff --git a/views/widget/root_view.cc b/views/widget/root_view.cc
index c64dc08..5a8bb74 100644
--- a/views/widget/root_view.cc
+++ b/views/widget/root_view.cc
@@ -16,6 +16,10 @@
#include "views/widget/widget.h"
#include "views/window/window.h"
+#if defined(OS_LINUX)
+#include "views/widget/widget_gtk.h"
+#endif // defined(OS_LINUX)
+
namespace views {
/////////////////////////////////////////////////////////////////////////////
@@ -929,7 +933,8 @@ void RootView::SetActiveCursor(gfx::NativeCursor cursor) {
previous_cursor_ = NULL;
}
#elif defined(OS_LINUX)
- gfx::NativeView native_view = GetWidget()->GetNativeView();
+ gfx::NativeView native_view =
+ static_cast<WidgetGtk*>(GetWidget())->window_contents();
if (!native_view)
return;
gdk_window_set_cursor(native_view->window, cursor);
diff --git a/views/widget/widget_gtk.cc b/views/widget/widget_gtk.cc
index 91726afe..2c4c80a 100644
--- a/views/widget/widget_gtk.cc
+++ b/views/widget/widget_gtk.cc
@@ -798,6 +798,10 @@ gboolean WidgetGtk::OnEnterNotify(GtkWidget* widget, GdkEventCrossing* event) {
last_mouse_move_x_ = event->x_root;
last_mouse_move_y_ = event->y_root;
last_mouse_event_was_move_ = true;
+
+ int x = 0, y = 0;
+ GetContainedWidgetEventCoordinates(event, &x, &y);
+
// If this event is the result of pressing a button then one of the button
// modifiers is set. Unset it as we're compensating for the leave generated
// when you press a button.
@@ -805,7 +809,7 @@ gboolean WidgetGtk::OnEnterNotify(GtkWidget* widget, GdkEventCrossing* event) {
~(Event::EF_LEFT_BUTTON_DOWN |
Event::EF_MIDDLE_BUTTON_DOWN |
Event::EF_RIGHT_BUTTON_DOWN));
- MouseEvent mouse_move(Event::ET_MOUSE_MOVED, event->x, event->y, flags);
+ MouseEvent mouse_move(Event::ET_MOUSE_MOVED, x, y, flags);
root_view_->OnMouseMoved(mouse_move);
}
@@ -820,10 +824,13 @@ gboolean WidgetGtk::OnLeaveNotify(GtkWidget* widget, GdkEventCrossing* event) {
}
gboolean WidgetGtk::OnMotionNotify(GtkWidget* widget, GdkEventMotion* event) {
+ int x = 0, y = 0;
+ GetContainedWidgetEventCoordinates(event, &x, &y);
+
if (has_capture_ && is_mouse_down_) {
last_mouse_event_was_move_ = false;
int flags = Event::GetFlagsFromGdkState(event->state);
- MouseEvent mouse_drag(Event::ET_MOUSE_DRAGGED, event->x, event->y, flags);
+ MouseEvent mouse_drag(Event::ET_MOUSE_DRAGGED, x, y, flags);
root_view_->OnMouseDragged(mouse_drag);
return true;
}
@@ -837,7 +844,7 @@ gboolean WidgetGtk::OnMotionNotify(GtkWidget* widget, GdkEventMotion* event) {
last_mouse_move_y_ = screen_loc.y();
last_mouse_event_was_move_ = true;
int flags = Event::GetFlagsFromGdkState(event->state);
- MouseEvent mouse_move(Event::ET_MOUSE_MOVED, event->x, event->y, flags);
+ MouseEvent mouse_move(Event::ET_MOUSE_MOVED, x, y, flags);
root_view_->OnMouseMoved(mouse_move);
return true;
}
@@ -1006,12 +1013,16 @@ bool WidgetGtk::ProcessMousePressed(GdkEventButton* event) {
return true;
}
- return false;
+ // Returns true to consume the event when widget is not transparent.
+ return !transparent_;
}
void WidgetGtk::ProcessMouseReleased(GdkEventButton* event) {
+ int x = 0, y = 0;
+ GetContainedWidgetEventCoordinates(event, &x, &y);
+
last_mouse_event_was_move_ = false;
- MouseEvent mouse_up(Event::ET_MOUSE_RELEASED, event->x, event->y,
+ MouseEvent mouse_up(Event::ET_MOUSE_RELEASED, x, y,
GetFlagsForEventButton(*event));
// Release the capture first, that way we don't get confused if
// OnMouseReleased blocks.