| Index: ui/views/widget/desktop_aura/x11_whole_screen_move_loop.cc
|
| diff --git a/ui/views/widget/desktop_aura/x11_whole_screen_move_loop.cc b/ui/views/widget/desktop_aura/x11_whole_screen_move_loop.cc
|
| index 3f48b8993b7e83b6f4a9ddd878f6a85951fbb4bb..782a9074ba9275e4a89f1aad9ccc32cb489e8034 100644
|
| --- a/ui/views/widget/desktop_aura/x11_whole_screen_move_loop.cc
|
| +++ b/ui/views/widget/desktop_aura/x11_whole_screen_move_loop.cc
|
| @@ -8,6 +8,7 @@
|
| // Get rid of a macro from Xlib.h that conflicts with Aura's RootWindow class.
|
| #undef RootWindow
|
|
|
| +#include "base/bind.h"
|
| #include "base/message_loop/message_loop.h"
|
| #include "base/message_loop/message_pump_x11.h"
|
| #include "base/run_loop.h"
|
| @@ -31,6 +32,7 @@ namespace {
|
| // The minimum alpha before we declare a pixel transparent when searching in
|
| // our source image.
|
| const uint32 kMinAlpha = 32;
|
| +const unsigned char kDragWidgetOpacity = 0xc0;
|
|
|
| class ScopedCapturer {
|
| public:
|
| @@ -56,7 +58,9 @@ X11WholeScreenMoveLoop::X11WholeScreenMoveLoop(
|
| : delegate_(delegate),
|
| in_move_loop_(false),
|
| should_reset_mouse_flags_(false),
|
| - grab_input_window_(None) {
|
| + grab_input_window_(None),
|
| + motion_task_posted_(false) {
|
| + last_xmotion_.type = NoEventMask;
|
| }
|
|
|
| X11WholeScreenMoveLoop::~X11WholeScreenMoveLoop() {}
|
| @@ -64,6 +68,16 @@ X11WholeScreenMoveLoop::~X11WholeScreenMoveLoop() {}
|
| ////////////////////////////////////////////////////////////////////////////////
|
| // DesktopWindowTreeHostLinux, MessagePumpDispatcher implementation:
|
|
|
| +void X11WholeScreenMoveLoop::DispatchMouseMovement()
|
| +{
|
| + if (!motion_task_posted_)
|
| + return;
|
| +
|
| + motion_task_posted_ = false;
|
| + gfx::Point screen_point(last_xmotion_.x_root, last_xmotion_.y_root);
|
| + delegate_->OnMouseMovement(&last_xmotion_);
|
| +}
|
| +
|
| uint32_t X11WholeScreenMoveLoop::Dispatch(const base::NativeEvent& event) {
|
| XEvent* xev = event;
|
|
|
| @@ -76,21 +90,34 @@ uint32_t X11WholeScreenMoveLoop::Dispatch(const base::NativeEvent& event) {
|
| gfx::Point location = gfx::ToFlooredPoint(
|
| screen->GetCursorScreenPoint() - drag_offset_);
|
| drag_widget_->SetBounds(gfx::Rect(location, drag_image_.size()));
|
| + drag_widget_->StackAtTop();
|
| + }
|
| + last_xmotion_ = xev->xmotion;
|
| + if (!motion_task_posted_) {
|
| + gfx::Point screen_point(xev->xmotion.x_root, xev->xmotion.y_root);
|
| + motion_task_posted_ = true;
|
| + base::MessageLoopForUI::current()->PostTask(
|
| + FROM_HERE,
|
| + base::Bind(&X11WholeScreenMoveLoop::DispatchMouseMovement,
|
| + base::Unretained(this)));
|
| }
|
| - delegate_->OnMouseMovement(&xev->xmotion);
|
| break;
|
| }
|
| case ButtonRelease: {
|
| if (xev->xbutton.button == Button1) {
|
| // Assume that drags are being done with the left mouse button. Only
|
| // break the drag if the left mouse button was released.
|
| + if (motion_task_posted_)
|
| + DispatchMouseMovement();
|
| delegate_->OnMouseReleased();
|
| }
|
| break;
|
| }
|
| case KeyPress: {
|
| - if (ui::KeyboardCodeFromXKeyEvent(xev) == ui::VKEY_ESCAPE)
|
| + if (ui::KeyboardCodeFromXKeyEvent(xev) == ui::VKEY_ESCAPE) {
|
| + motion_task_posted_ = false;
|
| EndMoveLoop();
|
| + }
|
| break;
|
| }
|
| }
|
| @@ -267,6 +294,7 @@ void X11WholeScreenMoveLoop::CreateDragImageWindow() {
|
| widget->set_focus_on_creation(false);
|
| widget->set_frame_type(Widget::FRAME_TYPE_FORCE_NATIVE);
|
| widget->Init(params);
|
| + widget->SetOpacity(kDragWidgetOpacity);
|
| widget->GetNativeWindow()->SetName("DragWindow");
|
|
|
| ImageView* image = new ImageView();
|
|
|