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 13 matching lines...) Expand all Loading... |
24 #include "ui/views/controls/image_view.h" | 24 #include "ui/views/controls/image_view.h" |
25 #include "ui/views/widget/widget.h" | 25 #include "ui/views/widget/widget.h" |
26 | 26 |
27 namespace views { | 27 namespace views { |
28 | 28 |
29 namespace { | 29 namespace { |
30 | 30 |
31 // The minimum alpha before we declare a pixel transparent when searching in | 31 // The minimum alpha before we declare a pixel transparent when searching in |
32 // our source image. | 32 // our source image. |
33 const uint32 kMinAlpha = 32; | 33 const uint32 kMinAlpha = 32; |
| 34 const unsigned char kDragWidgetOpacity = 0xc0; |
34 | 35 |
35 class ScopedCapturer { | 36 class ScopedCapturer { |
36 public: | 37 public: |
37 explicit ScopedCapturer(aura::WindowTreeHost* host) | 38 explicit ScopedCapturer(aura::WindowTreeHost* host) |
38 : host_(host) { | 39 : host_(host) { |
39 host_->SetCapture(); | 40 host_->SetCapture(); |
40 } | 41 } |
41 | 42 |
42 ~ScopedCapturer() { | 43 ~ScopedCapturer() { |
43 host_->ReleaseCapture(); | 44 host_->ReleaseCapture(); |
(...skipping 25 matching lines...) Expand all Loading... |
69 | 70 |
70 // Note: the escape key is handled in the tab drag controller, which has | 71 // Note: the escape key is handled in the tab drag controller, which has |
71 // keyboard focus even though we took pointer grab. | 72 // keyboard focus even though we took pointer grab. |
72 switch (xev->type) { | 73 switch (xev->type) { |
73 case MotionNotify: { | 74 case MotionNotify: { |
74 if (drag_widget_.get()) { | 75 if (drag_widget_.get()) { |
75 gfx::Screen* screen = gfx::Screen::GetNativeScreen(); | 76 gfx::Screen* screen = gfx::Screen::GetNativeScreen(); |
76 gfx::Point location = gfx::ToFlooredPoint( | 77 gfx::Point location = gfx::ToFlooredPoint( |
77 screen->GetCursorScreenPoint() - drag_offset_); | 78 screen->GetCursorScreenPoint() - drag_offset_); |
78 drag_widget_->SetBounds(gfx::Rect(location, drag_image_.size())); | 79 drag_widget_->SetBounds(gfx::Rect(location, drag_image_.size())); |
| 80 drag_widget_->StackAtTop(); |
79 } | 81 } |
80 delegate_->OnMouseMovement(&xev->xmotion); | 82 delegate_->OnMouseMovement(&xev->xmotion); |
81 break; | 83 break; |
82 } | 84 } |
83 case ButtonRelease: { | 85 case ButtonRelease: { |
84 if (xev->xbutton.button == Button1) { | 86 if (xev->xbutton.button == Button1) { |
85 // Assume that drags are being done with the left mouse button. Only | 87 // Assume that drags are being done with the left mouse button. Only |
86 // break the drag if the left mouse button was released. | 88 // break the drag if the left mouse button was released. |
87 delegate_->OnMouseReleased(); | 89 delegate_->OnMouseReleased(); |
88 } | 90 } |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 params.opacity = Widget::InitParams::OPAQUE_WINDOW; | 262 params.opacity = Widget::InitParams::OPAQUE_WINDOW; |
261 params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | 263 params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
262 params.accept_events = false; | 264 params.accept_events = false; |
263 | 265 |
264 gfx::Point location = gfx::ToFlooredPoint( | 266 gfx::Point location = gfx::ToFlooredPoint( |
265 gfx::Screen::GetNativeScreen()->GetCursorScreenPoint() - drag_offset_); | 267 gfx::Screen::GetNativeScreen()->GetCursorScreenPoint() - drag_offset_); |
266 params.bounds = gfx::Rect(location, drag_image_.size()); | 268 params.bounds = gfx::Rect(location, drag_image_.size()); |
267 widget->set_focus_on_creation(false); | 269 widget->set_focus_on_creation(false); |
268 widget->set_frame_type(Widget::FRAME_TYPE_FORCE_NATIVE); | 270 widget->set_frame_type(Widget::FRAME_TYPE_FORCE_NATIVE); |
269 widget->Init(params); | 271 widget->Init(params); |
| 272 widget->SetOpacity(kDragWidgetOpacity); |
270 widget->GetNativeWindow()->SetName("DragWindow"); | 273 widget->GetNativeWindow()->SetName("DragWindow"); |
271 | 274 |
272 ImageView* image = new ImageView(); | 275 ImageView* image = new ImageView(); |
273 image->SetImage(drag_image_); | 276 image->SetImage(drag_image_); |
274 image->SetBounds(0, 0, drag_image_.width(), drag_image_.height()); | 277 image->SetBounds(0, 0, drag_image_.width(), drag_image_.height()); |
275 widget->SetContentsView(image); | 278 widget->SetContentsView(image); |
276 widget->Show(); | 279 widget->Show(); |
277 widget->GetNativeWindow()->layer()->SetFillsBoundsOpaquely(false); | 280 widget->GetNativeWindow()->layer()->SetFillsBoundsOpaquely(false); |
278 | 281 |
279 drag_widget_.reset(widget); | 282 drag_widget_.reset(widget); |
(...skipping 19 matching lines...) Expand all Loading... |
299 for (int x = 0; x < in_bitmap->width(); ++x) { | 302 for (int x = 0; x < in_bitmap->width(); ++x) { |
300 if (SkColorGetA(in_row[x]) > kMinAlpha) | 303 if (SkColorGetA(in_row[x]) > kMinAlpha) |
301 return true; | 304 return true; |
302 } | 305 } |
303 } | 306 } |
304 | 307 |
305 return false; | 308 return false; |
306 } | 309 } |
307 | 310 |
308 } // namespace views | 311 } // namespace views |
OLD | NEW |