| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ui/views/widget/desktop_aura/x11_whole_screen_move_loop.h" | 5 #include "ui/views/widget/desktop_aura/x11_whole_screen_move_loop.h" |
| 6 | 6 |
| 7 #include <X11/Xlib.h> | 7 #include <X11/Xlib.h> |
| 8 // Get rid of a macro from Xlib.h that conflicts with Aura's RootWindow class. | 8 // Get rid of a macro from Xlib.h that conflicts with Aura's RootWindow class. |
| 9 #undef RootWindow | 9 #undef RootWindow |
| 10 | 10 |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 | 87 |
| 88 return POST_DISPATCH_NONE; | 88 return POST_DISPATCH_NONE; |
| 89 } | 89 } |
| 90 | 90 |
| 91 //////////////////////////////////////////////////////////////////////////////// | 91 //////////////////////////////////////////////////////////////////////////////// |
| 92 // DesktopWindowTreeHostLinux, aura::client::WindowMoveClient implementation: | 92 // DesktopWindowTreeHostLinux, aura::client::WindowMoveClient implementation: |
| 93 | 93 |
| 94 bool X11WholeScreenMoveLoop::RunMoveLoop(aura::Window* source, | 94 bool X11WholeScreenMoveLoop::RunMoveLoop(aura::Window* source, |
| 95 gfx::NativeCursor cursor) { | 95 gfx::NativeCursor cursor) { |
| 96 // Start a capture on the host, so that it continues to receive events during | 96 // Start a capture on the host, so that it continues to receive events during |
| 97 // the drag. | 97 // the drag. This may be second time we are capturing the mouse events - the |
| 98 ScopedCapturer capturer(source->GetDispatcher()->host()); | 98 // first being when a mouse is first pressed. That first capture needs to be |
| 99 // released before the call to GrabPointerWithCursor below, otherwise it may |
| 100 // get released while we still need the pointer grab, which is why we restrict |
| 101 // the scope here. |
| 102 { |
| 103 ScopedCapturer capturer(source->GetDispatcher()->host()); |
| 99 | 104 |
| 100 DCHECK(!in_move_loop_); // Can only handle one nested loop at a time. | 105 DCHECK(!in_move_loop_); // Can only handle one nested loop at a time. |
| 101 in_move_loop_ = true; | 106 in_move_loop_ = true; |
| 102 | 107 |
| 103 XDisplay* display = gfx::GetXDisplay(); | 108 XDisplay* display = gfx::GetXDisplay(); |
| 104 | 109 |
| 105 grab_input_window_ = CreateDragInputWindow(display); | 110 grab_input_window_ = CreateDragInputWindow(display); |
| 106 if (!drag_image_.isNull()) | 111 if (!drag_image_.isNull()) |
| 107 CreateDragImageWindow(); | 112 CreateDragImageWindow(); |
| 108 base::MessagePumpX11::Current()->AddDispatcherForWindow( | 113 base::MessagePumpX11::Current()->AddDispatcherForWindow( |
| 109 this, grab_input_window_); | 114 this, grab_input_window_); |
| 110 | 115 // Releasing ScopedCapturer ensures that any other instance of |
| 116 // X11ScopedCapture will not prematurely release grab that will be acquired |
| 117 // below. |
| 118 } |
| 119 // TODO(varkha): Consider integrating GrabPointerWithCursor with |
| 120 // ScopedCapturer to avoid possibility of logically keeping multiple grabs. |
| 111 if (!GrabPointerWithCursor(cursor)) | 121 if (!GrabPointerWithCursor(cursor)) |
| 112 return false; | 122 return false; |
| 113 | 123 |
| 114 // We are handling a mouse drag outside of the aura::RootWindow system. We | 124 // We are handling a mouse drag outside of the aura::RootWindow system. We |
| 115 // must manually make aura think that the mouse button is pressed so that we | 125 // must manually make aura think that the mouse button is pressed so that we |
| 116 // don't draw extraneous tooltips. | 126 // don't draw extraneous tooltips. |
| 117 aura::Env* env = aura::Env::GetInstance(); | 127 aura::Env* env = aura::Env::GetInstance(); |
| 118 if (!env->IsMouseButtonDown()) { | 128 if (!env->IsMouseButtonDown()) { |
| 119 env->set_mouse_button_flags(ui::EF_LEFT_MOUSE_BUTTON); | 129 env->set_mouse_button_flags(ui::EF_LEFT_MOUSE_BUTTON); |
| 120 should_reset_mouse_flags_ = true; | 130 should_reset_mouse_flags_ = true; |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 image->SetBounds(0, 0, drag_image_.width(), drag_image_.height()); | 250 image->SetBounds(0, 0, drag_image_.width(), drag_image_.height()); |
| 241 widget->SetContentsView(image); | 251 widget->SetContentsView(image); |
| 242 | 252 |
| 243 widget->Show(); | 253 widget->Show(); |
| 244 widget->GetNativeWindow()->layer()->SetFillsBoundsOpaquely(false); | 254 widget->GetNativeWindow()->layer()->SetFillsBoundsOpaquely(false); |
| 245 | 255 |
| 246 drag_widget_.reset(widget); | 256 drag_widget_.reset(widget); |
| 247 } | 257 } |
| 248 | 258 |
| 249 } // namespace views | 259 } // namespace views |
| OLD | NEW |