| 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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 // the screen coordinates. However, since the mouse is captured | 85 // the screen coordinates. However, since the mouse is captured |
| 86 // by X during drag, a weird LocatedEvent, something like (0, 1123) | 86 // by X during drag, a weird LocatedEvent, something like (0, 1123) |
| 87 // in the *primary* root window's coordinates, is sent to Chrome | 87 // in the *primary* root window's coordinates, is sent to Chrome |
| 88 // (Remember that in the native X11 world, the two root windows | 88 // (Remember that in the native X11 world, the two root windows |
| 89 // are always stacked vertically regardless of the display | 89 // are always stacked vertically regardless of the display |
| 90 // layout in Ash). We need to figure out that (0, 1123) in the | 90 // layout in Ash). We need to figure out that (0, 1123) in the |
| 91 // primary root window's coordinates is actually (0, 123) in the | 91 // primary root window's coordinates is actually (0, 123) in the |
| 92 // extended root window's coordinates. | 92 // extended root window's coordinates. |
| 93 | 93 |
| 94 gfx::Point location_in_native(location_in_root); | 94 gfx::Point location_in_native(location_in_root); |
| 95 root_window->GetDispatcher()->host()->ConvertPointToNativeScreen( | 95 root_window->GetHost()->ConvertPointToNativeScreen(&location_in_native); |
| 96 &location_in_native); | |
| 97 | 96 |
| 98 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 97 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
| 99 for (size_t i = 0; i < root_windows.size(); ++i) { | 98 for (size_t i = 0; i < root_windows.size(); ++i) { |
| 100 aura::WindowEventDispatcher* dispatcher = | 99 aura::WindowTreeHost* host = root_windows[i]->GetHost(); |
| 101 root_windows[i]->GetDispatcher(); | 100 const gfx::Rect native_bounds = host->GetBounds(); |
| 102 const gfx::Rect native_bounds = dispatcher->host()->GetBounds(); | |
| 103 if (native_bounds.Contains(location_in_native)) { | 101 if (native_bounds.Contains(location_in_native)) { |
| 104 root_window = root_windows[i]; | 102 root_window = root_windows[i]; |
| 105 location_in_root = location_in_native; | 103 location_in_root = location_in_native; |
| 106 dispatcher->host()->ConvertPointFromNativeScreen(&location_in_root); | 104 host->ConvertPointFromNativeScreen(&location_in_root); |
| 107 break; | 105 break; |
| 108 } | 106 } |
| 109 } | 107 } |
| 110 } | 108 } |
| 111 #else | 109 #else |
| 112 // TODO(yusukes): Support non-X11 platforms if necessary. | 110 // TODO(yusukes): Support non-X11 platforms if necessary. |
| 113 #endif | 111 #endif |
| 114 | 112 |
| 115 return std::make_pair(root_window, location_in_root); | 113 return std::make_pair(root_window, location_in_root); |
| 116 } | 114 } |
| (...skipping 19 matching lines...) Expand all Loading... |
| 136 const gfx::Point display_origin = Shell::GetScreen()->GetDisplayNearestWindow( | 134 const gfx::Point display_origin = Shell::GetScreen()->GetDisplayNearestWindow( |
| 137 const_cast<aura::Window*>(root)).bounds().origin(); | 135 const_cast<aura::Window*>(root)).bounds().origin(); |
| 138 point->Offset(-display_origin.x(), -display_origin.y()); | 136 point->Offset(-display_origin.x(), -display_origin.y()); |
| 139 aura::Window::ConvertPointToTarget(root, window, point); | 137 aura::Window::ConvertPointToTarget(root, window, point); |
| 140 } | 138 } |
| 141 | 139 |
| 142 void ScreenPositionController::ConvertHostPointToScreen( | 140 void ScreenPositionController::ConvertHostPointToScreen( |
| 143 aura::Window* root_window, | 141 aura::Window* root_window, |
| 144 gfx::Point* point) { | 142 gfx::Point* point) { |
| 145 aura::Window* root = root_window->GetRootWindow(); | 143 aura::Window* root = root_window->GetRootWindow(); |
| 146 root->GetDispatcher()->host()->ConvertPointFromHost(point); | 144 root->GetHost()->ConvertPointFromHost(point); |
| 147 std::pair<aura::Window*, gfx::Point> pair = | 145 std::pair<aura::Window*, gfx::Point> pair = |
| 148 GetRootWindowRelativeToWindow(root, *point); | 146 GetRootWindowRelativeToWindow(root, *point); |
| 149 *point = pair.second; | 147 *point = pair.second; |
| 150 ConvertPointToScreen(pair.first, point); | 148 ConvertPointToScreen(pair.first, point); |
| 151 } | 149 } |
| 152 | 150 |
| 153 void ScreenPositionController::SetBounds(aura::Window* window, | 151 void ScreenPositionController::SetBounds(aura::Window* window, |
| 154 const gfx::Rect& bounds, | 152 const gfx::Rect& bounds, |
| 155 const gfx::Display& display) { | 153 const gfx::Display& display) { |
| 156 DCHECK_NE(-1, display.id()); | 154 DCHECK_NE(-1, display.id()); |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 } | 223 } |
| 226 gfx::Point origin(bounds.origin()); | 224 gfx::Point origin(bounds.origin()); |
| 227 const gfx::Point display_origin = Shell::GetScreen()->GetDisplayNearestWindow( | 225 const gfx::Point display_origin = Shell::GetScreen()->GetDisplayNearestWindow( |
| 228 window).bounds().origin(); | 226 window).bounds().origin(); |
| 229 origin.Offset(-display_origin.x(), -display_origin.y()); | 227 origin.Offset(-display_origin.x(), -display_origin.y()); |
| 230 window->SetBounds(gfx::Rect(origin, bounds.size())); | 228 window->SetBounds(gfx::Rect(origin, bounds.size())); |
| 231 } | 229 } |
| 232 | 230 |
| 233 } // internal | 231 } // internal |
| 234 } // ash | 232 } // ash |
| OLD | NEW |