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

Side by Side Diff: ui/views/widget/desktop_aura/x11_whole_screen_move_loop.cc

Issue 110223004: linux-aura: Fix some dragging behaviour. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/views/widget/desktop_aura/x11_whole_screen_move_loop.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 43
44 DISALLOW_COPY_AND_ASSIGN(ScopedCapturer); 44 DISALLOW_COPY_AND_ASSIGN(ScopedCapturer);
45 }; 45 };
46 46
47 } // namespace 47 } // namespace
48 48
49 X11WholeScreenMoveLoop::X11WholeScreenMoveLoop( 49 X11WholeScreenMoveLoop::X11WholeScreenMoveLoop(
50 X11WholeScreenMoveLoopDelegate* delegate) 50 X11WholeScreenMoveLoopDelegate* delegate)
51 : delegate_(delegate), 51 : delegate_(delegate),
52 in_move_loop_(false), 52 in_move_loop_(false),
53 should_reset_mouse_flags_(false),
53 grab_input_window_(None) { 54 grab_input_window_(None) {
54 } 55 }
55 56
56 X11WholeScreenMoveLoop::~X11WholeScreenMoveLoop() {} 57 X11WholeScreenMoveLoop::~X11WholeScreenMoveLoop() {}
57 58
58 //////////////////////////////////////////////////////////////////////////////// 59 ////////////////////////////////////////////////////////////////////////////////
59 // DesktopRootWindowHostLinux, MessageLoop::Dispatcher implementation: 60 // DesktopRootWindowHostLinux, MessageLoop::Dispatcher implementation:
60 61
61 bool X11WholeScreenMoveLoop::Dispatch(const base::NativeEvent& event) { 62 bool X11WholeScreenMoveLoop::Dispatch(const base::NativeEvent& event) {
62 XEvent* xev = event; 63 XEvent* xev = event;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 CreateDragImageWindow(); 107 CreateDragImageWindow();
107 base::MessagePumpX11::Current()->AddDispatcherForWindow( 108 base::MessagePumpX11::Current()->AddDispatcherForWindow(
108 this, grab_input_window_); 109 this, grab_input_window_);
109 110
110 if (!GrabPointerWithCursor(cursor)) 111 if (!GrabPointerWithCursor(cursor))
111 return false; 112 return false;
112 113
113 // We are handling a mouse drag outside of the aura::RootWindow system. We 114 // We are handling a mouse drag outside of the aura::RootWindow system. We
114 // must manually make aura think that the mouse button is pressed so that we 115 // must manually make aura think that the mouse button is pressed so that we
115 // don't draw extraneous tooltips. 116 // don't draw extraneous tooltips.
116 aura::Env::GetInstance()->set_mouse_button_flags(ui::EF_LEFT_MOUSE_BUTTON); 117 aura::Env* env = aura::Env::GetInstance();
118 if (!env->IsMouseButtonDown()) {
119 env->set_mouse_button_flags(ui::EF_LEFT_MOUSE_BUTTON);
120 should_reset_mouse_flags_ = true;
121 }
117 122
118 base::MessageLoopForUI* loop = base::MessageLoopForUI::current(); 123 base::MessageLoopForUI* loop = base::MessageLoopForUI::current();
119 base::MessageLoop::ScopedNestableTaskAllower allow_nested(loop); 124 base::MessageLoop::ScopedNestableTaskAllower allow_nested(loop);
120 base::RunLoop run_loop(aura::Env::GetInstance()->GetDispatcher()); 125 base::RunLoop run_loop(aura::Env::GetInstance()->GetDispatcher());
121 quit_closure_ = run_loop.QuitClosure(); 126 quit_closure_ = run_loop.QuitClosure();
122 run_loop.Run(); 127 run_loop.Run();
123 return true; 128 return true;
124 } 129 }
125 130
126 void X11WholeScreenMoveLoop::UpdateCursor(gfx::NativeCursor cursor) { 131 void X11WholeScreenMoveLoop::UpdateCursor(gfx::NativeCursor cursor) {
127 DCHECK(in_move_loop_); 132 DCHECK(in_move_loop_);
128 GrabPointerWithCursor(cursor); 133 GrabPointerWithCursor(cursor);
129 } 134 }
130 135
131 void X11WholeScreenMoveLoop::EndMoveLoop() { 136 void X11WholeScreenMoveLoop::EndMoveLoop() {
132 if (!in_move_loop_) 137 if (!in_move_loop_)
133 return; 138 return;
134 139
135 // We undo our emulated mouse click from RunMoveLoop(); 140 // We undo our emulated mouse click from RunMoveLoop();
136 aura::Env::GetInstance()->set_mouse_button_flags(0); 141 if (should_reset_mouse_flags_) {
142 aura::Env::GetInstance()->set_mouse_button_flags(0);
143 should_reset_mouse_flags_ = false;
144 }
137 145
138 // TODO(erg): Is this ungrab the cause of having to click to give input focus 146 // TODO(erg): Is this ungrab the cause of having to click to give input focus
139 // on drawn out windows? Not ungrabbing here screws the X server until I kill 147 // on drawn out windows? Not ungrabbing here screws the X server until I kill
140 // the chrome process. 148 // the chrome process.
141 149
142 // Ungrab before we let go of the window. 150 // Ungrab before we let go of the window.
143 XDisplay* display = gfx::GetXDisplay(); 151 XDisplay* display = gfx::GetXDisplay();
144 XUngrabPointer(display, CurrentTime); 152 XUngrabPointer(display, CurrentTime);
145 153
146 base::MessagePumpX11::Current()->RemoveDispatcherForWindow( 154 base::MessagePumpX11::Current()->RemoveDispatcherForWindow(
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 image->SetBounds(0, 0, drag_image_.width(), drag_image_.height()); 236 image->SetBounds(0, 0, drag_image_.width(), drag_image_.height());
229 widget->SetContentsView(image); 237 widget->SetContentsView(image);
230 238
231 widget->Show(); 239 widget->Show();
232 widget->GetNativeWindow()->layer()->SetFillsBoundsOpaquely(false); 240 widget->GetNativeWindow()->layer()->SetFillsBoundsOpaquely(false);
233 241
234 drag_widget_.reset(widget); 242 drag_widget_.reset(widget);
235 } 243 }
236 244
237 } // namespace views 245 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/widget/desktop_aura/x11_whole_screen_move_loop.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698