Chromium Code Reviews| Index: chrome/browser/ui/views/panels/panel_frame_view.cc |
| diff --git a/chrome/browser/ui/views/panels/panel_frame_view.cc b/chrome/browser/ui/views/panels/panel_frame_view.cc |
| index 30667d950f2272176209b8675f5294e5c1772376..8e327c1f1a7153693ca4cd346f72e53ad398847d 100644 |
| --- a/chrome/browser/ui/views/panels/panel_frame_view.cc |
| +++ b/chrome/browser/ui/views/panels/panel_frame_view.cc |
| @@ -23,6 +23,11 @@ |
| #include "ui/views/widget/widget.h" |
| #include "ui/views/widget/widget_delegate.h" |
| +#if defined(OS_LINUX) && !defined(OS_CHROMEOS) |
| +#include <X11/extensions/XInput2.h> |
| +#include <X11/Xlib.h> |
| +#endif |
| + |
| #if defined(OS_WIN) |
| #include "base/win/scoped_gdi_object.h" |
| #include "ui/base/win/shell.h" |
| @@ -59,6 +64,26 @@ const SkColor kMinimizeBackgroundDefaultColor = SkColorSetRGB(0xf5, 0xf4, 0xf0); |
| // Color used to draw the title text under default theme. |
| const SkColor kTitleTextDefaultColor = SkColorSetRGB(0xf9, 0xf9, 0xf9); |
| +#if defined(USE_X11) && !defined(OS_CHROMEOS) |
|
pkotwicz
2014/03/18 02:48:26
I did not put this method in events_x.cc because I
|
| +// Extracts the position in screen coordinates from |native_event|. |
| +gfx::Point GetEventLocationInScreenFromNative( |
| + const base::NativeEvent& native_event) { |
| + switch (native_event->type) { |
| + case MotionNotify: |
| + return gfx::Point(native_event->xmotion.x_root, |
| + native_event->xmotion.y_root); |
| + case GenericEvent: { |
| + XIDeviceEvent* xievent = |
| + static_cast<XIDeviceEvent*>(native_event->xcookie.data); |
| + return gfx::Point(static_cast<int>(xievent->root_x), |
| + static_cast<int>(xievent->root_y)); |
| + } |
| + } |
| + NOTREACHED(); |
| + return gfx::Point(); |
| +} |
| +#endif |
| + |
| gfx::ImageSkia* CreateImageForColor(SkColor color) { |
| gfx::Canvas canvas(gfx::Size(1, 1), 1.0f, true); |
| canvas.DrawColor(color); |
| @@ -578,10 +603,22 @@ bool PanelFrameView::OnMousePressed(const ui::MouseEvent& event) { |
| } |
| bool PanelFrameView::OnMouseDragged(const ui::MouseEvent& event) { |
| +#if defined(OS_LINUX) && !defined(OS_CHROMEOS) |
| + // Converting the mouse location to screen coordinates returns an incorrect |
| + // location while the panel is moving. See crbug.com/353393 for more details. |
| + // Get the mouse location in screen coordinates from the base::NativeEvent |
| + // instead. |
| + // TODO(pkotwicz): Fix conversion to screen coordinates |
| + if (event.type() != ui::ET_MOUSE_DRAGGED) |
| + return false; |
| + gfx::Point mouse_location = |
| + GetEventLocationInScreenFromNative(event.native_event()); |
| +#else |
| // |event.location| is in the view's coordinate system. Convert it to the |
| // screen coordinate system. |
| gfx::Point mouse_location = event.location(); |
| views::View::ConvertPointToScreen(this, &mouse_location); |
| +#endif |
| if (panel_view_->OnTitlebarMouseDragged(mouse_location)) |
| return true; |