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 "ash/drag_drop/drag_drop_tracker.h" | 5 #include "ash/drag_drop/drag_drop_tracker.h" |
6 | 6 |
7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
8 #include "ash/shell_window_ids.h" | 8 #include "ash/shell_window_ids.h" |
9 #include "ash/wm/coordinate_conversion.h" | 9 #include "ash/wm/coordinate_conversion.h" |
10 #include "ui/aura/root_window.h" | 10 #include "ui/aura/root_window.h" |
11 #include "ui/base/events/event.h" | 11 #include "ui/base/events/event.h" |
12 #include "ui/gfx/screen.h" | 12 #include "ui/gfx/screen.h" |
13 | 13 |
14 namespace { | 14 namespace { |
15 | 15 |
16 // Creates a window for capturing drag events. | 16 // Creates a window for capturing drag events. |
17 aura::Window* CreateCaptureWindow() { | 17 aura::Window* CreateCaptureWindow(aura::RootWindow* context_root) { |
18 aura::Window* window = new aura::Window(NULL); | 18 aura::Window* window = new aura::Window(NULL); |
19 window->SetType(aura::client::WINDOW_TYPE_NORMAL); | 19 window->SetType(aura::client::WINDOW_TYPE_NORMAL); |
20 window->Init(ui::LAYER_NOT_DRAWN); | 20 window->Init(ui::LAYER_NOT_DRAWN); |
21 window->SetParent(NULL); | 21 window->SetDefaultParentByRootWindow(context_root, gfx::Rect()); |
22 window->Show(); | 22 window->Show(); |
23 return window; | 23 return window; |
24 } | 24 } |
25 | 25 |
26 } // namespace | 26 } // namespace |
27 | 27 |
28 namespace ash { | 28 namespace ash { |
29 namespace internal { | 29 namespace internal { |
30 | 30 |
31 DragDropTracker::DragDropTracker() | 31 DragDropTracker::DragDropTracker(aura::RootWindow* context_root) |
32 : capture_window_(CreateCaptureWindow()) { | 32 : capture_window_(CreateCaptureWindow(context_root)) { |
33 } | 33 } |
34 | 34 |
35 DragDropTracker::~DragDropTracker() { | 35 DragDropTracker::~DragDropTracker() { |
36 capture_window_->ReleaseCapture(); | 36 capture_window_->ReleaseCapture(); |
37 } | 37 } |
38 | 38 |
39 void DragDropTracker::TakeCapture() { | 39 void DragDropTracker::TakeCapture() { |
40 capture_window_->SetCapture(); | 40 capture_window_->SetCapture(); |
41 } | 41 } |
42 | 42 |
(...skipping 24 matching lines...) Expand all Loading... |
67 ash::wm::GetRootWindowAt(location_in_screen), | 67 ash::wm::GetRootWindowAt(location_in_screen), |
68 &target_root_location); | 68 &target_root_location); |
69 return new ui::MouseEvent(event.type(), | 69 return new ui::MouseEvent(event.type(), |
70 target_location, | 70 target_location, |
71 target_root_location, | 71 target_root_location, |
72 event.flags()); | 72 event.flags()); |
73 } | 73 } |
74 | 74 |
75 } // namespace internal | 75 } // namespace internal |
76 } // namespace ash | 76 } // namespace ash |
OLD | NEW |