| 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/aura/wm_window_aura.h" | 7 #include "ash/aura/wm_window_aura.h" |
| 8 #include "ash/common/wm/window_positioning_utils.h" | 8 #include "ash/common/wm/window_positioning_utils.h" |
| 9 #include "ash/common/wm/window_state.h" | 9 #include "ash/common/wm/window_state.h" |
| 10 #include "ash/common/wm_shell.h" | 10 #include "ash/common/wm_shell.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 void ScreenPositionController::ConvertHostPointToRelativeToRootWindow( | 32 void ScreenPositionController::ConvertHostPointToRelativeToRootWindow( |
| 33 aura::Window* root_window, | 33 aura::Window* root_window, |
| 34 const aura::Window::Windows& root_windows, | 34 const aura::Window::Windows& root_windows, |
| 35 gfx::Point* point, | 35 gfx::Point* point, |
| 36 aura::Window** target_root) { | 36 aura::Window** target_root) { |
| 37 DCHECK(!root_window->parent()); | 37 DCHECK(!root_window->parent()); |
| 38 gfx::Point point_in_root(*point); | 38 gfx::Point point_in_root(*point); |
| 39 root_window->GetHost()->ConvertPointFromHost(&point_in_root); | 39 root_window->GetHost()->ConvertPointFromHost(&point_in_root); |
| 40 | 40 |
| 41 #if defined(USE_X11) || defined(USE_OZONE) | 41 #if defined(USE_X11) || defined(USE_OZONE) |
| 42 gfx::Rect host_bounds(root_window->GetHost()->GetBounds().size()); | 42 gfx::Rect host_bounds(root_window->GetHost()->GetBoundsInPixels().size()); |
| 43 if (!host_bounds.Contains(*point)) { | 43 if (!host_bounds.Contains(*point)) { |
| 44 // This conversion is necessary to deal with X's passive input | 44 // This conversion is necessary to deal with X's passive input |
| 45 // grab while dragging window. For example, if we have two | 45 // grab while dragging window. For example, if we have two |
| 46 // displays, say 1000x1000 (primary) and 500x500 (extended one | 46 // displays, say 1000x1000 (primary) and 500x500 (extended one |
| 47 // on the right), and start dragging a window at (999, 123), and | 47 // on the right), and start dragging a window at (999, 123), and |
| 48 // then move the pointer to the right, the pointer suddenly | 48 // then move the pointer to the right, the pointer suddenly |
| 49 // warps to the extended display. The destination is (0, 123) in | 49 // warps to the extended display. The destination is (0, 123) in |
| 50 // the secondary root window's coordinates, or (1000, 123) in | 50 // the secondary root window's coordinates, or (1000, 123) in |
| 51 // the screen coordinates. However, since the mouse is captured | 51 // the screen coordinates. However, since the mouse is captured |
| 52 // by X during drag, a weird LocatedEvent, something like (0, 1123) | 52 // by X during drag, a weird LocatedEvent, something like (0, 1123) |
| 53 // in the *primary* root window's coordinates, is sent to Chrome | 53 // in the *primary* root window's coordinates, is sent to Chrome |
| 54 // (Remember that in the native X11 world, the two root windows | 54 // (Remember that in the native X11 world, the two root windows |
| 55 // are always stacked vertically regardless of the display | 55 // are always stacked vertically regardless of the display |
| 56 // layout in Ash). We need to figure out that (0, 1123) in the | 56 // layout in Ash). We need to figure out that (0, 1123) in the |
| 57 // primary root window's coordinates is actually (0, 123) in the | 57 // primary root window's coordinates is actually (0, 123) in the |
| 58 // extended root window's coordinates. | 58 // extended root window's coordinates. |
| 59 // | 59 // |
| 60 // For now Ozone works in a similar manner as X11. Transitioning from one | 60 // For now Ozone works in a similar manner as X11. Transitioning from one |
| 61 // display's coordinate system to anothers may cause events in the | 61 // display's coordinate system to anothers may cause events in the |
| 62 // primary's coordinate system which fall in the extended display. | 62 // primary's coordinate system which fall in the extended display. |
| 63 | 63 |
| 64 gfx::Point location_in_native(point_in_root); | 64 gfx::Point location_in_native(point_in_root); |
| 65 | 65 |
| 66 root_window->GetHost()->ConvertPointToNativeScreen(&location_in_native); | 66 root_window->GetHost()->ConvertPointToNativeScreen(&location_in_native); |
| 67 | 67 |
| 68 for (size_t i = 0; i < root_windows.size(); ++i) { | 68 for (size_t i = 0; i < root_windows.size(); ++i) { |
| 69 aura::WindowTreeHost* host = root_windows[i]->GetHost(); | 69 aura::WindowTreeHost* host = root_windows[i]->GetHost(); |
| 70 const gfx::Rect native_bounds = host->GetBounds(); | 70 const gfx::Rect native_bounds = host->GetBoundsInPixels(); |
| 71 if (native_bounds.Contains(location_in_native)) { | 71 if (native_bounds.Contains(location_in_native)) { |
| 72 *target_root = root_windows[i]; | 72 *target_root = root_windows[i]; |
| 73 *point = location_in_native; | 73 *point = location_in_native; |
| 74 host->ConvertPointFromNativeScreen(point); | 74 host->ConvertPointFromNativeScreen(point); |
| 75 return; | 75 return; |
| 76 } | 76 } |
| 77 } | 77 } |
| 78 } | 78 } |
| 79 #endif | 79 #endif |
| 80 *target_root = root_window; | 80 *target_root = root_window; |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 const display::Display& display) { | 121 const display::Display& display) { |
| 122 if (!window->parent()->GetProperty(kUsesScreenCoordinatesKey)) { | 122 if (!window->parent()->GetProperty(kUsesScreenCoordinatesKey)) { |
| 123 window->SetBounds(bounds); | 123 window->SetBounds(bounds); |
| 124 return; | 124 return; |
| 125 } | 125 } |
| 126 | 126 |
| 127 wm::SetBoundsInScreen(WmWindowAura::Get(window), bounds, display); | 127 wm::SetBoundsInScreen(WmWindowAura::Get(window), bounds, display); |
| 128 } | 128 } |
| 129 | 129 |
| 130 } // namespace ash | 130 } // namespace ash |
| OLD | NEW |