Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(617)

Side by Side Diff: ash/display/unified_mouse_warp_controller.cc

Issue 1838833002: Move DisplayLayout and DisplayLayoutBuilder From ash To ui/display (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@screenwinmove
Patch Set: Fix comment Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/unified_mouse_warp_controller.h" 5 #include "ash/display/unified_mouse_warp_controller.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 8
9 #include "ash/display/display_manager.h" 9 #include "ash/display/display_manager.h"
10 #include "ash/display/display_util.h" 10 #include "ash/display/display_util.h"
11 #include "ash/display/mirror_window_controller.h" 11 #include "ash/display/mirror_window_controller.h"
12 #include "ash/display/window_tree_host_manager.h" 12 #include "ash/display/window_tree_host_manager.h"
13 #include "ash/host/ash_window_tree_host.h" 13 #include "ash/host/ash_window_tree_host.h"
14 #include "ash/shell.h" 14 #include "ash/shell.h"
15 #include "ui/aura/client/cursor_client.h" 15 #include "ui/aura/client/cursor_client.h"
16 #include "ui/aura/window.h" 16 #include "ui/aura/window.h"
17 #include "ui/aura/window_tree_host.h" 17 #include "ui/aura/window_tree_host.h"
18 #include "ui/base/layout.h" 18 #include "ui/base/layout.h"
19 #include "ui/display/manager/display_layout.h"
19 #include "ui/events/event_utils.h" 20 #include "ui/events/event_utils.h"
20 #include "ui/gfx/screen.h" 21 #include "ui/gfx/screen.h"
21 #include "ui/wm/core/coordinate_conversion.h" 22 #include "ui/wm/core/coordinate_conversion.h"
22 23
23 namespace ash { 24 namespace ash {
24 25
25 namespace { 26 namespace {
26 27
27 AshWindowTreeHost* GetMirroringAshWindowTreeHostForDisplayId( 28 AshWindowTreeHost* GetMirroringAshWindowTreeHostForDisplayId(
28 int64_t display_id) { 29 int64_t display_id) {
29 return Shell::GetInstance() 30 return Shell::GetInstance()
30 ->window_tree_host_manager() 31 ->window_tree_host_manager()
31 ->mirror_window_controller() 32 ->mirror_window_controller()
32 ->GetAshWindowTreeHostForDisplayId(display_id); 33 ->GetAshWindowTreeHostForDisplayId(display_id);
33 } 34 }
34 35
35 #if defined(USE_OZONE) 36 #if defined(USE_OZONE)
36 // Find a WindowTreeHost used for mirroring displays that contains 37 // Find a WindowTreeHost used for mirroring displays that contains
37 // the |point_in_screen|. Returns nullptr if such WTH does not exist. 38 // the |point_in_screen|. Returns nullptr if such WTH does not exist.
38 aura::WindowTreeHost* FindMirroringWindowTreeHostFromScreenPoint( 39 aura::WindowTreeHost* FindMirroringWindowTreeHostFromScreenPoint(
39 const gfx::Point& point_in_screen) { 40 const gfx::Point& point_in_screen) {
40 DisplayList mirroring_display_list = Shell::GetInstance() 41 display::DisplayList mirroring_display_list =
41 ->display_manager() 42 Shell::GetInstance()
42 ->software_mirroring_display_list(); 43 ->display_manager()
44 ->software_mirroring_display_list();
43 int index = 45 int index =
44 FindDisplayIndexContainingPoint(mirroring_display_list, point_in_screen); 46 FindDisplayIndexContainingPoint(mirroring_display_list, point_in_screen);
45 if (index < 0) 47 if (index < 0)
46 return nullptr; 48 return nullptr;
47 return GetMirroringAshWindowTreeHostForDisplayId( 49 return GetMirroringAshWindowTreeHostForDisplayId(
48 mirroring_display_list[index].id())->AsWindowTreeHost(); 50 mirroring_display_list[index].id())->AsWindowTreeHost();
49 } 51 }
50 #endif 52 #endif
51 53
52 } // namespace 54 } // namespace
(...skipping 15 matching lines...) Expand all
68 gfx::Point point_in_unified_host = event->location(); 70 gfx::Point point_in_unified_host = event->location();
69 ::wm::ConvertPointToScreen(target, &point_in_unified_host); 71 ::wm::ConvertPointToScreen(target, &point_in_unified_host);
70 // The display bounds of the mirroring windows isn't scaled, so 72 // The display bounds of the mirroring windows isn't scaled, so
71 // transform back to the host coordinates. 73 // transform back to the host coordinates.
72 target->GetHost()->GetRootTransform().TransformPoint(&point_in_unified_host); 74 target->GetHost()->GetRootTransform().TransformPoint(&point_in_unified_host);
73 75
74 if (current_cursor_display_id_ != gfx::Display::kInvalidDisplayID) { 76 if (current_cursor_display_id_ != gfx::Display::kInvalidDisplayID) {
75 aura::client::CursorClient* cursor_client = 77 aura::client::CursorClient* cursor_client =
76 aura::client::GetCursorClient(target->GetRootWindow()); 78 aura::client::GetCursorClient(target->GetRootWindow());
77 if (cursor_client) { 79 if (cursor_client) {
78 DisplayList mirroring_display_list = 80 display::DisplayList mirroring_display_list =
79 Shell::GetInstance() 81 Shell::GetInstance()
80 ->display_manager() 82 ->display_manager()
81 ->software_mirroring_display_list(); 83 ->software_mirroring_display_list();
82 int index = FindDisplayIndexContainingPoint(mirroring_display_list, 84 int index = FindDisplayIndexContainingPoint(mirroring_display_list,
83 point_in_unified_host); 85 point_in_unified_host);
84 if (index >= 0) { 86 if (index >= 0) {
85 const gfx::Display& new_display = mirroring_display_list[index]; 87 const gfx::Display& new_display = mirroring_display_list[index];
86 if (current_cursor_display_id_ != new_display.id()) { 88 if (current_cursor_display_id_ != new_display.id()) {
87 cursor_client->SetDisplay(new_display); 89 cursor_client->SetDisplay(new_display);
88 current_cursor_display_id_ = gfx::Display::kInvalidDisplayID; 90 current_cursor_display_id_ = gfx::Display::kInvalidDisplayID;
(...skipping 23 matching lines...) Expand all
112 114
113 return WarpMouseCursorInNativeCoords(point_in_native, point_in_unified_host, 115 return WarpMouseCursorInNativeCoords(point_in_native, point_in_unified_host,
114 update_location_for_test_); 116 update_location_for_test_);
115 } 117 }
116 118
117 void UnifiedMouseWarpController::SetEnabled(bool enabled) { 119 void UnifiedMouseWarpController::SetEnabled(bool enabled) {
118 // Mouse warp shuld be always on in Unified mode. 120 // Mouse warp shuld be always on in Unified mode.
119 } 121 }
120 122
121 void UnifiedMouseWarpController::ComputeBounds() { 123 void UnifiedMouseWarpController::ComputeBounds() {
122 DisplayList display_list = Shell::GetInstance() 124 display::DisplayList display_list = Shell::GetInstance()
123 ->display_manager() 125 ->display_manager()
124 ->software_mirroring_display_list(); 126 ->software_mirroring_display_list();
125 127
126 if (display_list.size() < 2) { 128 if (display_list.size() < 2) {
127 LOG(ERROR) << "Mirroring Display lost during re-configuration"; 129 LOG(ERROR) << "Mirroring Display lost during re-configuration";
128 return; 130 return;
129 } 131 }
130 LOG_IF(ERROR, display_list.size() > 2) << "Only two displays are supported"; 132 LOG_IF(ERROR, display_list.size() > 2) << "Only two displays are supported";
131 133
132 const gfx::Display& first = display_list[0]; 134 const gfx::Display& first = display_list[0];
133 const gfx::Display& second = display_list[1]; 135 const gfx::Display& second = display_list[1];
134 bool success = ComputeBoundary(first, second, &first_edge_bounds_in_native_, 136 bool success = ComputeBoundary(first, second, &first_edge_bounds_in_native_,
(...skipping 10 matching lines...) Expand all
145 } 147 }
146 148
147 bool UnifiedMouseWarpController::WarpMouseCursorInNativeCoords( 149 bool UnifiedMouseWarpController::WarpMouseCursorInNativeCoords(
148 const gfx::Point& point_in_native, 150 const gfx::Point& point_in_native,
149 const gfx::Point& point_in_unified_host, 151 const gfx::Point& point_in_unified_host,
150 bool update_mouse_location_now) { 152 bool update_mouse_location_now) {
151 bool in_first_edge = first_edge_bounds_in_native_.Contains(point_in_native); 153 bool in_first_edge = first_edge_bounds_in_native_.Contains(point_in_native);
152 bool in_second_edge = second_edge_bounds_in_native_.Contains(point_in_native); 154 bool in_second_edge = second_edge_bounds_in_native_.Contains(point_in_native);
153 if (!in_first_edge && !in_second_edge) 155 if (!in_first_edge && !in_second_edge)
154 return false; 156 return false;
155 DisplayList display_list = Shell::GetInstance() 157 display::DisplayList display_list = Shell::GetInstance()
156 ->display_manager() 158 ->display_manager()
157 ->software_mirroring_display_list(); 159 ->software_mirroring_display_list();
158 // Wait updating the cursor until the cursor moves to the new display 160 // Wait updating the cursor until the cursor moves to the new display
159 // to avoid showing the wrong sized cursor at the source display. 161 // to avoid showing the wrong sized cursor at the source display.
160 current_cursor_display_id_ = 162 current_cursor_display_id_ =
161 in_first_edge ? display_list[0].id() : display_list[1].id(); 163 in_first_edge ? display_list[0].id() : display_list[1].id();
162 AshWindowTreeHost* target_ash_host = 164 AshWindowTreeHost* target_ash_host =
163 GetMirroringAshWindowTreeHostForDisplayId( 165 GetMirroringAshWindowTreeHostForDisplayId(
164 in_first_edge ? display_list[1].id() : display_list[0].id()); 166 in_first_edge ? display_list[1].id() : display_list[0].id());
165 MoveCursorTo(target_ash_host, point_in_unified_host, 167 MoveCursorTo(target_ash_host, point_in_unified_host,
166 update_mouse_location_now); 168 update_mouse_location_now);
167 return true; 169 return true;
168 } 170 }
169 171
170 } // namespace ash 172 } // namespace ash
OLDNEW
« no previous file with comments | « ash/display/screen_position_controller_unittest.cc ('k') | ash/display/window_tree_host_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698