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/display/screen_position_controller.h" | 5 #include "ash/display/screen_position_controller.h" |
6 | 6 |
7 #include "ash/display/display_controller.h" | 7 #include "ash/display/display_controller.h" |
8 #include "ash/root_window_controller.h" | 8 #include "ash/root_window_controller.h" |
9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
10 #include "ash/shell_window_ids.h" | 10 #include "ash/shell_window_ids.h" |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
65 // function usually returns |window->GetRootWindow()|, but if the mouse pointer | 65 // function usually returns |window->GetRootWindow()|, but if the mouse pointer |
66 // is moved outside the |window|'s root while the mouse is captured, it returns | 66 // is moved outside the |window|'s root while the mouse is captured, it returns |
67 // the other root window. | 67 // the other root window. |
68 std::pair<aura::Window*, gfx::Point> GetRootWindowRelativeToWindow( | 68 std::pair<aura::Window*, gfx::Point> GetRootWindowRelativeToWindow( |
69 aura::Window* window, | 69 aura::Window* window, |
70 const gfx::Point& location) { | 70 const gfx::Point& location) { |
71 aura::Window* root_window = window->GetRootWindow(); | 71 aura::Window* root_window = window->GetRootWindow(); |
72 gfx::Point location_in_root(location); | 72 gfx::Point location_in_root(location); |
73 aura::Window::ConvertPointToTarget(window, root_window, &location_in_root); | 73 aura::Window::ConvertPointToTarget(window, root_window, &location_in_root); |
74 | 74 |
75 #if defined(USE_X11) | 75 #if defined(USE_X11) || defined(USE_OZONE) |
76 if (!root_window->ContainsPointInRoot(location_in_root)) { | 76 if (!root_window->ContainsPointInRoot(location_in_root)) { |
77 // This conversion is necessary to deal with X's passive input | 77 // This conversion is necessary to deal with X's passive input |
78 // grab while dragging window. For example, if we have two | 78 // grab while dragging window. For example, if we have two |
79 // displays, say 1000x1000 (primary) and 500x500 (extended one | 79 // displays, say 1000x1000 (primary) and 500x500 (extended one |
80 // on the right), and start dragging a window at (999, 123), and | 80 // on the right), and start dragging a window at (999, 123), and |
81 // then move the pointer to the right, the pointer suddenly | 81 // then move the pointer to the right, the pointer suddenly |
82 // warps to the extended display. The destination is (0, 123) in | 82 // warps to the extended display. The destination is (0, 123) in |
83 // the secondary root window's coordinates, or (1000, 123) in | 83 // the secondary root window's coordinates, or (1000, 123) in |
84 // the screen coordinates. However, since the mouse is captured | 84 // the screen coordinates. However, since the mouse is captured |
85 // by X during drag, a weird LocatedEvent, something like (0, 1123) | 85 // by X during drag, a weird LocatedEvent, something like (0, 1123) |
86 // in the *primary* root window's coordinates, is sent to Chrome | 86 // in the *primary* root window's coordinates, is sent to Chrome |
87 // (Remember that in the native X11 world, the two root windows | 87 // (Remember that in the native X11 world, the two root windows |
88 // are always stacked vertically regardless of the display | 88 // are always stacked vertically regardless of the display |
89 // layout in Ash). We need to figure out that (0, 1123) in the | 89 // layout in Ash). We need to figure out that (0, 1123) in the |
90 // primary root window's coordinates is actually (0, 123) in the | 90 // primary root window's coordinates is actually (0, 123) in the |
91 // extended root window's coordinates. | 91 // extended root window's coordinates. |
92 // | |
93 // For now Ozone works in a similar manner as X11. Events are reported in | |
94 // the currently focused window coordinates. So when the cursor leaves the | |
oshima
2014/08/06 21:59:33
Passive grab has nothing to do with focus. See
htt
| |
95 // window we need properly convert the event. | |
92 | 96 |
93 gfx::Point location_in_native(location_in_root); | 97 gfx::Point location_in_native(location_in_root); |
94 root_window->GetHost()->ConvertPointToNativeScreen(&location_in_native); | 98 root_window->GetHost()->ConvertPointToNativeScreen(&location_in_native); |
95 | 99 |
96 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 100 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
97 for (size_t i = 0; i < root_windows.size(); ++i) { | 101 for (size_t i = 0; i < root_windows.size(); ++i) { |
98 aura::WindowTreeHost* host = root_windows[i]->GetHost(); | 102 aura::WindowTreeHost* host = root_windows[i]->GetHost(); |
99 const gfx::Rect native_bounds = host->GetBounds(); | 103 const gfx::Rect native_bounds = host->GetBounds(); |
100 if (native_bounds.Contains(location_in_native)) { | 104 if (native_bounds.Contains(location_in_native)) { |
101 root_window = root_windows[i]; | 105 root_window = root_windows[i]; |
102 location_in_root = location_in_native; | 106 location_in_root = location_in_native; |
103 host->ConvertPointFromNativeScreen(&location_in_root); | 107 host->ConvertPointFromNativeScreen(&location_in_root); |
104 break; | 108 break; |
105 } | 109 } |
106 } | 110 } |
107 } | 111 } |
108 #else | 112 #else |
109 // TODO(yusukes): Support non-X11 platforms if necessary. | 113 // TODO(yusukes): Support non-X11 platforms if necessary. |
114 NOTIMPLEMENTED(); | |
110 #endif | 115 #endif |
111 | 116 |
112 return std::make_pair(root_window, location_in_root); | 117 return std::make_pair(root_window, location_in_root); |
113 } | 118 } |
114 | 119 |
115 } // namespace | 120 } // namespace |
116 | 121 |
117 void ScreenPositionController::ConvertPointToScreen( | 122 void ScreenPositionController::ConvertPointToScreen( |
118 const aura::Window* window, | 123 const aura::Window* window, |
119 gfx::Point* point) { | 124 gfx::Point* point) { |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
219 } | 224 } |
220 } | 225 } |
221 gfx::Point origin(bounds.origin()); | 226 gfx::Point origin(bounds.origin()); |
222 const gfx::Point display_origin = Shell::GetScreen()->GetDisplayNearestWindow( | 227 const gfx::Point display_origin = Shell::GetScreen()->GetDisplayNearestWindow( |
223 window).bounds().origin(); | 228 window).bounds().origin(); |
224 origin.Offset(-display_origin.x(), -display_origin.y()); | 229 origin.Offset(-display_origin.x(), -display_origin.y()); |
225 window->SetBounds(gfx::Rect(origin, bounds.size())); | 230 window->SetBounds(gfx::Rect(origin, bounds.size())); |
226 } | 231 } |
227 | 232 |
228 } // namespace ash | 233 } // namespace ash |
OLD | NEW |