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

Side by Side Diff: ash/touch/touch_transformer_controller.cc

Issue 922843002: Fix software mirror mode on Ozone part 2/2 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/touch/touch_transformer_controller.h" 5 #include "ash/touch/touch_transformer_controller.h"
6 6
7 #include "ash/display/display_controller.h" 7 #include "ash/display/display_controller.h"
8 #include "ash/display/display_manager.h" 8 #include "ash/display/display_manager.h"
9 #include "ash/host/ash_window_tree_host.h" 9 #include "ash/host/ash_window_tree_host.h"
10 #include "ash/root_window_controller.h" 10 #include "ash/root_window_controller.h"
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 single_display.touch_device_id(), 171 single_display.touch_device_id(),
172 GetTouchResolutionScale( 172 GetTouchResolutionScale(
173 single_display, 173 single_display,
174 FindTouchscreenById(single_display.touch_device_id()))); 174 FindTouchscreenById(single_display.touch_device_id())));
175 } 175 }
176 176
177 gfx::Size fb_size = 177 gfx::Size fb_size =
178 Shell::GetInstance()->display_configurator()->framebuffer_size(); 178 Shell::GetInstance()->display_configurator()->framebuffer_size();
179 179
180 if (display_state == ui::MULTIPLE_DISPLAY_STATE_DUAL_MIRROR) { 180 if (display_state == ui::MULTIPLE_DISPLAY_STATE_DUAL_MIRROR) {
181 // In mirror mode, both displays share the same root window so 181 // In mirror mode, there is just one WindowTreeHost and two displays. Make
182 // both display ids are associated with the root window. 182 // the WindowTreeHost accept touch events from both displays.
183 aura::Window* root = display_controller->GetPrimaryRootWindow(); 183 int64 primary_display_id = display_controller->GetPrimaryDisplayId();
184 RootWindowController::ForWindow(root)->ash_host()->UpdateDisplayID( 184 device_manager->SetDestinationDisplayForTouchDevice(
185 display1_id, display2_id); 185 display1.touch_device_id(), primary_display_id);
186 device_manager->SetDestinationDisplayForTouchDevice(
187 display2.touch_device_id(), primary_display_id);
188
186 device_manager->UpdateTouchInfoForDisplay( 189 device_manager->UpdateTouchInfoForDisplay(
187 display1_id, display1.touch_device_id(), 190 display1_id, display1.touch_device_id(),
188 GetTouchTransform(display1, display1, 191 GetTouchTransform(display1, display1,
189 FindTouchscreenById(display1.touch_device_id()), 192 FindTouchscreenById(display1.touch_device_id()),
190 fb_size)); 193 fb_size));
191 device_manager->UpdateTouchInfoForDisplay( 194 device_manager->UpdateTouchInfoForDisplay(
192 display2_id, display2.touch_device_id(), 195 display2_id, display2.touch_device_id(),
193 GetTouchTransform(display2, display2, 196 GetTouchTransform(display2, display2,
194 FindTouchscreenById(display2.touch_device_id()), 197 FindTouchscreenById(display2.touch_device_id()),
195 fb_size)); 198 fb_size));
196 return; 199 return;
197 } 200 }
198 201
199 if (display_state == ui::MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED) { 202 if (display_state == ui::MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED) {
200 // In extended but software mirroring mode, ther is only one X root window 203 // In extended but software mirroring mode, there is a WindowTreeHost for
201 // that associates with both displays. 204 // each display, but all touches are forwarded to the primary root window's
205 // WindowTreeHost.
202 if (GetDisplayManager()->software_mirroring_enabled()) { 206 if (GetDisplayManager()->software_mirroring_enabled()) {
203 aura::Window* root = display_controller->GetPrimaryRootWindow(); 207 DisplayInfo destination_display =
204 RootWindowController::ForWindow(root)->ash_host()->UpdateDisplayID(
205 display1_id, display2_id);
206 DisplayInfo source_display =
207 display_controller->GetPrimaryDisplayId() == display1_id ? display1 208 display_controller->GetPrimaryDisplayId() == display1_id ? display1
208 : display2; 209 : display2;
210 device_manager->SetDestinationDisplayForTouchDevice(
211 display1.touch_device_id(), destination_display.id());
212 device_manager->SetDestinationDisplayForTouchDevice(
213 display2.touch_device_id(), destination_display.id());
214
209 // Mapping from framebuffer size to the source display's native 215 // Mapping from framebuffer size to the source display's native
210 // resolution. 216 // resolution.
211 device_manager->UpdateTouchInfoForDisplay( 217 device_manager->UpdateTouchInfoForDisplay(
212 display1_id, display1.touch_device_id(), 218 display1_id, display1.touch_device_id(),
213 GetTouchTransform(source_display, display1, 219 GetTouchTransform(destination_display, display1,
214 FindTouchscreenById(display1.touch_device_id()), 220 FindTouchscreenById(display1.touch_device_id()),
215 fb_size)); 221 fb_size));
216 device_manager->UpdateTouchInfoForDisplay( 222 device_manager->UpdateTouchInfoForDisplay(
217 display2_id, display2.touch_device_id(), 223 display2_id, display2.touch_device_id(),
218 GetTouchTransform(source_display, display2, 224 GetTouchTransform(destination_display, display2,
219 FindTouchscreenById(display2.touch_device_id()), 225 FindTouchscreenById(display2.touch_device_id()),
220 fb_size)); 226 fb_size));
221 } else { 227 } else {
222 // In actual extended mode, each display is associated with one root 228 // In actual extended mode, each display is associated with one
223 // window. 229 // WindowTreeHost.
224 aura::Window* root1 = 230 device_manager->SetDestinationDisplayForTouchDevice(
225 display_controller->GetRootWindowForDisplayId(display1_id); 231 display1.touch_device_id(), display1.id());
226 aura::Window* root2 = 232 device_manager->SetDestinationDisplayForTouchDevice(
227 display_controller->GetRootWindowForDisplayId(display2_id); 233 display2.touch_device_id(), display2.id());
228 RootWindowController::ForWindow(root1)->ash_host()->UpdateDisplayID( 234
229 display1_id, gfx::Display::kInvalidDisplayID);
230 RootWindowController::ForWindow(root2)->ash_host()->UpdateDisplayID(
231 display2_id, gfx::Display::kInvalidDisplayID);
232 // Mapping from framebuffer size to each display's native resolution. 235 // Mapping from framebuffer size to each display's native resolution.
233 device_manager->UpdateTouchInfoForDisplay( 236 device_manager->UpdateTouchInfoForDisplay(
234 display1_id, display1.touch_device_id(), 237 display1_id, display1.touch_device_id(),
235 GetTouchTransform(display1, display1, 238 GetTouchTransform(display1, display1,
236 FindTouchscreenById(display1.touch_device_id()), 239 FindTouchscreenById(display1.touch_device_id()),
237 fb_size)); 240 fb_size));
238 device_manager->UpdateTouchInfoForDisplay( 241 device_manager->UpdateTouchInfoForDisplay(
239 display2_id, display2.touch_device_id(), 242 display2_id, display2.touch_device_id(),
240 GetTouchTransform(display2, display2, 243 GetTouchTransform(display2, display2,
241 FindTouchscreenById(display2.touch_device_id()), 244 FindTouchscreenById(display2.touch_device_id()),
242 fb_size)); 245 fb_size));
243 } 246 }
244 return; 247 return;
245 } 248 }
246 249
247 // Single display mode. The root window has one associated display id. 250 // Single display mode. The WindowTreeHost has one associated display id.
248 aura::Window* root = 251 device_manager->SetDestinationDisplayForTouchDevice(
249 display_controller->GetRootWindowForDisplayId(single_display.id()); 252 single_display.touch_device_id(), single_display.id());
250 RootWindowController::ForWindow(root)->ash_host()->UpdateDisplayID(
251 single_display.id(), gfx::Display::kInvalidDisplayID);
252 device_manager->UpdateTouchInfoForDisplay( 253 device_manager->UpdateTouchInfoForDisplay(
253 single_display_id, single_display.touch_device_id(), 254 single_display_id, single_display.touch_device_id(),
254 GetTouchTransform(single_display, single_display, 255 GetTouchTransform(single_display, single_display,
255 FindTouchscreenById(single_display.touch_device_id()), 256 FindTouchscreenById(single_display.touch_device_id()),
256 fb_size)); 257 fb_size));
257 } 258 }
258 259
259 void TouchTransformerController::OnDisplaysInitialized() { 260 void TouchTransformerController::OnDisplaysInitialized() {
260 UpdateTouchTransformer(); 261 UpdateTouchTransformer();
261 } 262 }
262 263
263 void TouchTransformerController::OnDisplayConfigurationChanged() { 264 void TouchTransformerController::OnDisplayConfigurationChanged() {
264 UpdateTouchTransformer(); 265 UpdateTouchTransformer();
265 } 266 }
266 267
267 } // namespace ash 268 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698