Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(323)

Unified Diff: ui/views/widget/desktop_aura/x11_whole_screen_move_loop.cc

Issue 196213004: Allows menu host windows to be enumerated in DragTargetWindowFinder (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Implements menu XID caching and dispatches mouse drags in a posted task (test) Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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()
sadrul 2014/03/26 18:01:07 { EOL here
varkha 2014/03/27 04:48:13 Done (moved to https://codereview.chromium.org/214
+{
+ 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;
sadrul 2014/03/26 18:01:07 Don't copy the whole event. Just keep track of the
varkha 2014/03/27 04:48:13 This was moved to https://codereview.chromium.org/
+ 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)));
sadrul 2014/03/26 18:01:07 You should use a WeakPtr<> here, instead of using
varkha 2014/03/27 04:48:13 Will do in https://codereview.chromium.org/2141130
}
- 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();

Powered by Google App Engine
This is Rietveld 408576698