| OLD | NEW |
| 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/host/ash_window_tree_host_x11.h" | 5 #include "ash/host/ash_window_tree_host_x11.h" |
| 6 | 6 |
| 7 #include <X11/extensions/Xfixes.h> | 7 #include <X11/extensions/Xfixes.h> |
| 8 #include <X11/extensions/XInput2.h> | 8 #include <X11/extensions/XInput2.h> |
| 9 #include <X11/Xatom.h> | 9 #include <X11/Xatom.h> |
| 10 #include <X11/Xlib.h> | 10 #include <X11/Xlib.h> |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 | 279 |
| 280 gfx::Transform AshWindowTreeHostX11::GetInverseRootTransform() const { | 280 gfx::Transform AshWindowTreeHostX11::GetInverseRootTransform() const { |
| 281 return transformer_helper_.GetInverseTransform(); | 281 return transformer_helper_.GetInverseTransform(); |
| 282 } | 282 } |
| 283 | 283 |
| 284 void AshWindowTreeHostX11::UpdateRootWindowSize(const gfx::Size& host_size) { | 284 void AshWindowTreeHostX11::UpdateRootWindowSize(const gfx::Size& host_size) { |
| 285 transformer_helper_.UpdateWindowSize(host_size); | 285 transformer_helper_.UpdateWindowSize(host_size); |
| 286 } | 286 } |
| 287 | 287 |
| 288 void AshWindowTreeHostX11::OnCursorVisibilityChangedNative(bool show) { | 288 void AshWindowTreeHostX11::OnCursorVisibilityChangedNative(bool show) { |
| 289 #if defined(OS_CHROMEOS) | |
| 290 SetCrOSTapPaused(!show); | 289 SetCrOSTapPaused(!show); |
| 291 #endif | |
| 292 } | 290 } |
| 293 | 291 |
| 294 void AshWindowTreeHostX11::OnWindowInitialized(aura::Window* window) {} | 292 void AshWindowTreeHostX11::OnWindowInitialized(aura::Window* window) {} |
| 295 | 293 |
| 296 void AshWindowTreeHostX11::OnHostInitialized(aura::WindowTreeHost* host) { | 294 void AshWindowTreeHostX11::OnHostInitialized(aura::WindowTreeHost* host) { |
| 297 // UpdateIsInternalDisplay relies on RootWindowSettings' display_id being set | 295 // UpdateIsInternalDisplay relies on RootWindowSettings' display_id being set |
| 298 // available by the time WED::Init is called. (set in | 296 // available by the time WED::Init is called. (set in |
| 299 // DisplayManager::CreateRootWindowForDisplay) | 297 // DisplayManager::CreateRootWindowForDisplay) |
| 300 // Ready when NotifyHostInitialized is called from WED::Init. | 298 // Ready when NotifyHostInitialized is called from WED::Init. |
| 301 if (host != AsWindowTreeHost()) | 299 if (host != AsWindowTreeHost()) |
| 302 return; | 300 return; |
| 303 UpdateIsInternalDisplay(); | 301 UpdateIsInternalDisplay(); |
| 304 | 302 |
| 305 #if defined(OS_CHROMEOS) | |
| 306 // We have to enable Tap-to-click by default because the cursor is set to | 303 // We have to enable Tap-to-click by default because the cursor is set to |
| 307 // visible in Shell::InitRootWindowController. | 304 // visible in Shell::InitRootWindowController. |
| 308 SetCrOSTapPaused(false); | 305 SetCrOSTapPaused(false); |
| 309 #endif | |
| 310 } | 306 } |
| 311 | 307 |
| 312 void AshWindowTreeHostX11::OnConfigureNotify() { | 308 void AshWindowTreeHostX11::OnConfigureNotify() { |
| 313 UpdateIsInternalDisplay(); | 309 UpdateIsInternalDisplay(); |
| 314 | 310 |
| 315 // Always update barrier and mouse location because |bounds_| might | 311 // Always update barrier and mouse location because |bounds_| might |
| 316 // have already been updated in |SetBounds|. | 312 // have already been updated in |SetBounds|. |
| 317 if (pointer_barriers_) { | 313 if (pointer_barriers_) { |
| 318 UnConfineCursor(); | 314 UnConfineCursor(); |
| 319 ConfineCursorToRootWindow(); | 315 ConfineCursorToRootWindow(); |
| 320 } | 316 } |
| 321 } | 317 } |
| 322 | 318 |
| 323 void AshWindowTreeHostX11::TranslateAndDispatchLocatedEvent( | 319 void AshWindowTreeHostX11::TranslateAndDispatchLocatedEvent( |
| 324 ui::LocatedEvent* event) { | 320 ui::LocatedEvent* event) { |
| 325 switch (event->type()) { | 321 switch (event->type()) { |
| 326 case ui::ET_TOUCH_MOVED: | 322 case ui::ET_TOUCH_MOVED: |
| 327 case ui::ET_TOUCH_PRESSED: | 323 case ui::ET_TOUCH_PRESSED: |
| 328 case ui::ET_TOUCH_CANCELLED: | 324 case ui::ET_TOUCH_CANCELLED: |
| 329 case ui::ET_TOUCH_RELEASED: { | 325 case ui::ET_TOUCH_RELEASED: { |
| 330 #if defined(OS_CHROMEOS) | |
| 331 ui::TouchEvent* touchev = static_cast<ui::TouchEvent*>(event); | 326 ui::TouchEvent* touchev = static_cast<ui::TouchEvent*>(event); |
| 332 if (base::SysInfo::IsRunningOnChromeOS()) { | 327 if (base::SysInfo::IsRunningOnChromeOS()) { |
| 333 // X maps the touch-surface to the size of the X root-window. | 328 // X maps the touch-surface to the size of the X root-window. |
| 334 // In multi-monitor setup, Coordinate Transformation Matrix | 329 // In multi-monitor setup, Coordinate Transformation Matrix |
| 335 // repositions the touch-surface onto part of X root-window | 330 // repositions the touch-surface onto part of X root-window |
| 336 // containing aura root-window corresponding to the touchscreen. | 331 // containing aura root-window corresponding to the touchscreen. |
| 337 // However, if aura root-window has non-zero origin, | 332 // However, if aura root-window has non-zero origin, |
| 338 // we need to relocate the event into aura root-window coordinates. | 333 // we need to relocate the event into aura root-window coordinates. |
| 339 touchev->Relocate(bounds().origin()); | 334 touchev->Relocate(bounds().origin()); |
| 340 #if defined(USE_XI2_MT) | 335 #if defined(USE_XI2_MT) |
| 341 if (is_internal_display_) | 336 if (is_internal_display_) |
| 342 touch_calibrate_->Calibrate(touchev, bounds()); | 337 touch_calibrate_->Calibrate(touchev, bounds()); |
| 343 #endif // defined(USE_XI2_MT) | 338 #endif // defined(USE_XI2_MT) |
| 344 } | 339 } |
| 345 #endif // defined(OS_CHROMEOS) | |
| 346 break; | 340 break; |
| 347 } | 341 } |
| 348 default: { | 342 default: { |
| 349 aura::Window* root_window = window(); | 343 aura::Window* root_window = window(); |
| 350 aura::client::ScreenPositionClient* screen_position_client = | 344 aura::client::ScreenPositionClient* screen_position_client = |
| 351 aura::client::GetScreenPositionClient(root_window); | 345 aura::client::GetScreenPositionClient(root_window); |
| 352 gfx::Rect local(bounds().size()); | 346 gfx::Rect local(bounds().size()); |
| 353 local.Inset(transformer_helper_.GetHostInsets()); | 347 local.Inset(transformer_helper_.GetHostInsets()); |
| 354 if (screen_position_client && !local.Contains(event->location())) { | 348 if (screen_position_client && !local.Contains(event->location())) { |
| 355 gfx::Point location(event->location()); | 349 gfx::Point location(event->location()); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 371 } | 365 } |
| 372 | 366 |
| 373 void AshWindowTreeHostX11::UpdateIsInternalDisplay() { | 367 void AshWindowTreeHostX11::UpdateIsInternalDisplay() { |
| 374 aura::Window* root_window = window(); | 368 aura::Window* root_window = window(); |
| 375 gfx::Screen* screen = gfx::Screen::GetScreenFor(root_window); | 369 gfx::Screen* screen = gfx::Screen::GetScreenFor(root_window); |
| 376 gfx::Display display = screen->GetDisplayNearestWindow(root_window); | 370 gfx::Display display = screen->GetDisplayNearestWindow(root_window); |
| 377 DCHECK(display.is_valid()); | 371 DCHECK(display.is_valid()); |
| 378 is_internal_display_ = display.IsInternal(); | 372 is_internal_display_ = display.IsInternal(); |
| 379 } | 373 } |
| 380 | 374 |
| 381 #if defined(OS_CHROMEOS) | |
| 382 void AshWindowTreeHostX11::SetCrOSTapPaused(bool state) { | 375 void AshWindowTreeHostX11::SetCrOSTapPaused(bool state) { |
| 383 if (!ui::IsXInput2Available()) | 376 if (!ui::IsXInput2Available()) |
| 384 return; | 377 return; |
| 385 // Temporarily pause tap-to-click when the cursor is hidden. | 378 // Temporarily pause tap-to-click when the cursor is hidden. |
| 386 Atom prop = atom_cache()->GetAtom("Tap Paused"); | 379 Atom prop = atom_cache()->GetAtom("Tap Paused"); |
| 387 unsigned char value = state; | 380 unsigned char value = state; |
| 388 XIDeviceList dev_list = | 381 XIDeviceList dev_list = |
| 389 ui::DeviceListCacheX::GetInstance()->GetXI2DeviceList(xdisplay()); | 382 ui::DeviceListCacheX::GetInstance()->GetXI2DeviceList(xdisplay()); |
| 390 | 383 |
| 391 // Only slave pointer devices could possibly have tap-paused property. | 384 // Only slave pointer devices could possibly have tap-paused property. |
| (...skipping 22 matching lines...) Expand all Loading... |
| 414 dev_list[i].deviceid, | 407 dev_list[i].deviceid, |
| 415 prop, | 408 prop, |
| 416 XA_INTEGER, | 409 XA_INTEGER, |
| 417 8, | 410 8, |
| 418 PropModeReplace, | 411 PropModeReplace, |
| 419 &value, | 412 &value, |
| 420 1); | 413 1); |
| 421 } | 414 } |
| 422 } | 415 } |
| 423 } | 416 } |
| 424 #endif | |
| 425 | 417 |
| 426 AshWindowTreeHost* AshWindowTreeHost::Create(const gfx::Rect& initial_bounds) { | 418 AshWindowTreeHost* AshWindowTreeHost::Create(const gfx::Rect& initial_bounds) { |
| 427 return new AshWindowTreeHostX11(initial_bounds); | 419 return new AshWindowTreeHostX11(initial_bounds); |
| 428 } | 420 } |
| 429 | 421 |
| 430 } // namespace ash | 422 } // namespace ash |
| OLD | NEW |