summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordavemoore@chromium.org <davemoore@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-21 21:11:55 +0000
committerdavemoore@chromium.org <davemoore@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-21 21:11:55 +0000
commit1a8cb33717f86b14b90281824f29412e276fc91a (patch)
treea3d4a4b29d4d943fd2271206b5b0e5ef761b7547
parentd81445683110dc751fbae58cd28c2a91a4f262ab (diff)
downloadchromium_src-1a8cb33717f86b14b90281824f29412e276fc91a.zip
chromium_src-1a8cb33717f86b14b90281824f29412e276fc91a.tar.gz
chromium_src-1a8cb33717f86b14b90281824f29412e276fc91a.tar.bz2
If a window is moving in response to a mouse motion event,
you can't just convert the relative coords from the event to the screen because you don't know if your View's position relative to the screen may or may not have changed. You need the screen coordinates from the event itself. This change uses gdk_get_current_event() to get the event so we can get the screen coords from it Review URL: http://codereview.chromium.org/173213 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@24011 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/views/panel_controller.cc32
1 files changed, 22 insertions, 10 deletions
diff --git a/chrome/browser/views/panel_controller.cc b/chrome/browser/views/panel_controller.cc
index a6623e4..9d5dd69 100644
--- a/chrome/browser/views/panel_controller.cc
+++ b/chrome/browser/views/panel_controller.cc
@@ -115,14 +115,20 @@ bool PanelController::TitleMousePressed(const views::MouseEvent& event) {
if (!event.IsOnlyLeftMouseButton()) {
return false;
}
- gfx::Point abs_location = event.location();
- views::View::ConvertPointToScreen(title_content_, &abs_location);
+ GdkEvent* gdk_event = gtk_get_current_event();
+ if (gdk_event->type != GDK_BUTTON_PRESS) {
+ gdk_event_free(gdk_event);
+ NOTREACHED();
+ return false;
+ }
+ GdkEventButton last_button_event = gdk_event->button;
mouse_down_ = true;
- mouse_down_abs_x_ = abs_location.x();
- mouse_down_abs_y_ = abs_location.y();
+ mouse_down_abs_x_ = last_button_event.x_root;
+ mouse_down_abs_y_ = last_button_event.y_root;
mouse_down_offset_x_ = event.x();
mouse_down_offset_y_ = event.y();
dragging_ = false;
+ gdk_event_free(gdk_event);
return true;
}
@@ -157,22 +163,28 @@ bool PanelController::TitleMouseDragged(const views::MouseEvent& event) {
return false;
}
- gfx::Point abs_location = event.location();
- views::View::ConvertPointToScreen(title_content_, &abs_location);
+ GdkEvent* gdk_event = gtk_get_current_event();
+ if (gdk_event->type != GDK_MOTION_NOTIFY) {
+ gdk_event_free(gdk_event);
+ NOTREACHED();
+ return false;
+ }
+ GdkEventMotion last_motion_event = gdk_event->motion;
if (!dragging_) {
if (views::View::ExceededDragThreshold(
- abs_location.x() - mouse_down_abs_x_,
- abs_location.y() - mouse_down_abs_y_)) {
+ last_motion_event.x_root - mouse_down_abs_x_,
+ last_motion_event.y_root - mouse_down_abs_y_)) {
dragging_ = true;
}
}
if (dragging_) {
TabOverviewTypes::Message msg(TabOverviewTypes::Message::WM_MOVE_PANEL);
msg.set_param(0, panel_xid_);
- msg.set_param(1, abs_location.x() - mouse_down_offset_x_);
- msg.set_param(2, abs_location.y() - mouse_down_offset_y_);
+ msg.set_param(1, last_motion_event.x_root - mouse_down_offset_x_);
+ msg.set_param(2, last_motion_event.y_root - mouse_down_offset_y_);
TabOverviewTypes::instance()->SendMessage(msg);
}
+ gdk_event_free(gdk_event);
return true;
}