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

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

Issue 2314203002: Move DisplayList to display; add ScreenBase. (Closed)
Patch Set: Update unit test namespace. Created 4 years, 3 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
« no previous file with comments | « ash/display/mirror_window_controller.cc ('k') | ash/mus/test/wm_test_base.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
(...skipping 21 matching lines...) Expand all
32 ->window_tree_host_manager() 32 ->window_tree_host_manager()
33 ->mirror_window_controller() 33 ->mirror_window_controller()
34 ->GetAshWindowTreeHostForDisplayId(display_id); 34 ->GetAshWindowTreeHostForDisplayId(display_id);
35 } 35 }
36 36
37 #if defined(USE_OZONE) 37 #if defined(USE_OZONE)
38 // Find a WindowTreeHost used for mirroring displays that contains 38 // Find a WindowTreeHost used for mirroring displays that contains
39 // the |point_in_screen|. Returns nullptr if such WTH does not exist. 39 // the |point_in_screen|. Returns nullptr if such WTH does not exist.
40 aura::WindowTreeHost* FindMirroringWindowTreeHostFromScreenPoint( 40 aura::WindowTreeHost* FindMirroringWindowTreeHostFromScreenPoint(
41 const gfx::Point& point_in_screen) { 41 const gfx::Point& point_in_screen) {
42 display::DisplayList mirroring_display_list = 42 display::Displays mirroring_display_list =
43 Shell::GetInstance() 43 Shell::GetInstance()
44 ->display_manager() 44 ->display_manager()
45 ->software_mirroring_display_list(); 45 ->software_mirroring_display_list();
46 int index = display::FindDisplayIndexContainingPoint(mirroring_display_list, 46 int index = display::FindDisplayIndexContainingPoint(mirroring_display_list,
47 point_in_screen); 47 point_in_screen);
48 if (index < 0) 48 if (index < 0)
49 return nullptr; 49 return nullptr;
50 return GetMirroringAshWindowTreeHostForDisplayId( 50 return GetMirroringAshWindowTreeHostForDisplayId(
51 mirroring_display_list[index].id()) 51 mirroring_display_list[index].id())
52 ->AsWindowTreeHost(); 52 ->AsWindowTreeHost();
(...skipping 18 matching lines...) Expand all
71 gfx::Point point_in_unified_host = event->location(); 71 gfx::Point point_in_unified_host = event->location();
72 ::wm::ConvertPointToScreen(target, &point_in_unified_host); 72 ::wm::ConvertPointToScreen(target, &point_in_unified_host);
73 // The display bounds of the mirroring windows isn't scaled, so 73 // The display bounds of the mirroring windows isn't scaled, so
74 // transform back to the host coordinates. 74 // transform back to the host coordinates.
75 target->GetHost()->GetRootTransform().TransformPoint(&point_in_unified_host); 75 target->GetHost()->GetRootTransform().TransformPoint(&point_in_unified_host);
76 76
77 if (current_cursor_display_id_ != display::Display::kInvalidDisplayID) { 77 if (current_cursor_display_id_ != display::Display::kInvalidDisplayID) {
78 aura::client::CursorClient* cursor_client = 78 aura::client::CursorClient* cursor_client =
79 aura::client::GetCursorClient(target->GetRootWindow()); 79 aura::client::GetCursorClient(target->GetRootWindow());
80 if (cursor_client) { 80 if (cursor_client) {
81 display::DisplayList mirroring_display_list = 81 display::Displays mirroring_display_list =
82 Shell::GetInstance() 82 Shell::GetInstance()
83 ->display_manager() 83 ->display_manager()
84 ->software_mirroring_display_list(); 84 ->software_mirroring_display_list();
85 int index = display::FindDisplayIndexContainingPoint( 85 int index = display::FindDisplayIndexContainingPoint(
86 mirroring_display_list, point_in_unified_host); 86 mirroring_display_list, point_in_unified_host);
87 if (index >= 0) { 87 if (index >= 0) {
88 const display::Display& new_display = mirroring_display_list[index]; 88 const display::Display& new_display = mirroring_display_list[index];
89 if (current_cursor_display_id_ != new_display.id()) { 89 if (current_cursor_display_id_ != new_display.id()) {
90 cursor_client->SetDisplay(new_display); 90 cursor_client->SetDisplay(new_display);
91 current_cursor_display_id_ = display::Display::kInvalidDisplayID; 91 current_cursor_display_id_ = display::Display::kInvalidDisplayID;
(...skipping 23 matching lines...) Expand all
115 115
116 return WarpMouseCursorInNativeCoords(point_in_native, point_in_unified_host, 116 return WarpMouseCursorInNativeCoords(point_in_native, point_in_unified_host,
117 update_location_for_test_); 117 update_location_for_test_);
118 } 118 }
119 119
120 void UnifiedMouseWarpController::SetEnabled(bool enabled) { 120 void UnifiedMouseWarpController::SetEnabled(bool enabled) {
121 // Mouse warp shuld be always on in Unified mode. 121 // Mouse warp shuld be always on in Unified mode.
122 } 122 }
123 123
124 void UnifiedMouseWarpController::ComputeBounds() { 124 void UnifiedMouseWarpController::ComputeBounds() {
125 display::DisplayList display_list = Shell::GetInstance() 125 display::Displays display_list = Shell::GetInstance()
126 ->display_manager() 126 ->display_manager()
127 ->software_mirroring_display_list(); 127 ->software_mirroring_display_list();
128 128
129 if (display_list.size() < 2) { 129 if (display_list.size() < 2) {
130 LOG(ERROR) << "Mirroring Display lost during re-configuration"; 130 LOG(ERROR) << "Mirroring Display lost during re-configuration";
131 return; 131 return;
132 } 132 }
133 LOG_IF(ERROR, display_list.size() > 2) << "Only two displays are supported"; 133 LOG_IF(ERROR, display_list.size() > 2) << "Only two displays are supported";
134 134
135 const display::Display& first = display_list[0]; 135 const display::Display& first = display_list[0];
136 const display::Display& second = display_list[1]; 136 const display::Display& second = display_list[1];
137 bool success = 137 bool success =
(...skipping 11 matching lines...) Expand all
149 } 149 }
150 150
151 bool UnifiedMouseWarpController::WarpMouseCursorInNativeCoords( 151 bool UnifiedMouseWarpController::WarpMouseCursorInNativeCoords(
152 const gfx::Point& point_in_native, 152 const gfx::Point& point_in_native,
153 const gfx::Point& point_in_unified_host, 153 const gfx::Point& point_in_unified_host,
154 bool update_mouse_location_now) { 154 bool update_mouse_location_now) {
155 bool in_first_edge = first_edge_bounds_in_native_.Contains(point_in_native); 155 bool in_first_edge = first_edge_bounds_in_native_.Contains(point_in_native);
156 bool in_second_edge = second_edge_bounds_in_native_.Contains(point_in_native); 156 bool in_second_edge = second_edge_bounds_in_native_.Contains(point_in_native);
157 if (!in_first_edge && !in_second_edge) 157 if (!in_first_edge && !in_second_edge)
158 return false; 158 return false;
159 display::DisplayList display_list = Shell::GetInstance() 159 display::Displays display_list = Shell::GetInstance()
160 ->display_manager() 160 ->display_manager()
161 ->software_mirroring_display_list(); 161 ->software_mirroring_display_list();
162 // Wait updating the cursor until the cursor moves to the new display 162 // Wait updating the cursor until the cursor moves to the new display
163 // to avoid showing the wrong sized cursor at the source display. 163 // to avoid showing the wrong sized cursor at the source display.
164 current_cursor_display_id_ = 164 current_cursor_display_id_ =
165 in_first_edge ? display_list[0].id() : display_list[1].id(); 165 in_first_edge ? display_list[0].id() : display_list[1].id();
166 AshWindowTreeHost* target_ash_host = 166 AshWindowTreeHost* target_ash_host =
167 GetMirroringAshWindowTreeHostForDisplayId( 167 GetMirroringAshWindowTreeHostForDisplayId(
168 in_first_edge ? display_list[1].id() : display_list[0].id()); 168 in_first_edge ? display_list[1].id() : display_list[0].id());
169 MoveCursorTo(target_ash_host, point_in_unified_host, 169 MoveCursorTo(target_ash_host, point_in_unified_host,
170 update_mouse_location_now); 170 update_mouse_location_now);
171 return true; 171 return true;
172 } 172 }
173 173
174 } // namespace ash 174 } // namespace ash
OLDNEW
« no previous file with comments | « ash/display/mirror_window_controller.cc ('k') | ash/mus/test/wm_test_base.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698