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 "ui/aura/window_tree_host_x11.h" | 5 #include "ui/aura/window_tree_host_x11.h" |
6 | 6 |
7 #include <strings.h> | 7 #include <strings.h> |
8 #include <X11/cursorfont.h> | 8 #include <X11/cursorfont.h> |
9 #include <X11/extensions/XInput2.h> | 9 #include <X11/extensions/XInput2.h> |
10 #include <X11/extensions/Xrandr.h> | 10 #include <X11/extensions/Xrandr.h> |
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
492 void WindowTreeHostX11::OnCursorVisibilityChangedNative(bool show) { | 492 void WindowTreeHostX11::OnCursorVisibilityChangedNative(bool show) { |
493 } | 493 } |
494 | 494 |
495 ui::EventProcessor* WindowTreeHostX11::GetEventProcessor() { | 495 ui::EventProcessor* WindowTreeHostX11::GetEventProcessor() { |
496 return dispatcher(); | 496 return dispatcher(); |
497 } | 497 } |
498 | 498 |
499 void WindowTreeHostX11::DispatchXI2Event(const base::NativeEvent& event) { | 499 void WindowTreeHostX11::DispatchXI2Event(const base::NativeEvent& event) { |
500 ui::TouchFactory* factory = ui::TouchFactory::GetInstance(); | 500 ui::TouchFactory* factory = ui::TouchFactory::GetInstance(); |
501 XEvent* xev = event; | 501 XEvent* xev = event; |
502 XIDeviceEvent* xiev = static_cast<XIDeviceEvent*>(xev->xcookie.data); | |
502 if (!factory->ShouldProcessXI2Event(xev)) | 503 if (!factory->ShouldProcessXI2Event(xev)) |
503 return; | 504 return; |
504 | 505 |
505 TRACE_EVENT1("input", "WindowTreeHostX11::DispatchXI2Event", | 506 TRACE_EVENT1("input", "WindowTreeHostX11::DispatchXI2Event", |
506 "event_latency_us", | 507 "event_latency_us", |
507 (ui::EventTimeForNow() - ui::EventTimeFromNative(event)). | 508 (ui::EventTimeForNow() - ui::EventTimeFromNative(event)). |
508 InMicroseconds()); | 509 InMicroseconds()); |
509 | 510 |
510 ui::EventType type = ui::EventTypeFromNative(xev); | 511 ui::EventType type = ui::EventTypeFromNative(xev); |
511 XEvent last_event; | 512 XEvent last_event; |
512 int num_coalesced = 0; | 513 int num_coalesced = 0; |
513 | 514 |
514 switch (type) { | 515 switch (type) { |
515 case ui::ET_TOUCH_MOVED: | 516 case ui::ET_TOUCH_MOVED: |
516 case ui::ET_TOUCH_PRESSED: | 517 case ui::ET_TOUCH_PRESSED: |
517 case ui::ET_TOUCH_CANCELLED: | 518 case ui::ET_TOUCH_CANCELLED: |
518 case ui::ET_TOUCH_RELEASED: { | 519 case ui::ET_TOUCH_RELEASED: { |
519 #if defined(OS_CHROMEOS) | |
520 // Bail out early before generating a ui::TouchEvent if this event | |
521 // is not within the range of this RootWindow. Converting an xevent | |
522 // to ui::TouchEvent might change the state of the global touch tracking | |
523 // state, e.g. touch release event can remove the touch id from the | |
524 // record, and doing this multiple time when there are multiple | |
525 // RootWindow will cause problem. So only generate the ui::TouchEvent | |
526 // when we are sure it belongs to this RootWindow. | |
527 if (base::SysInfo::IsRunningOnChromeOS() && | |
528 !bounds().Contains(ui::EventLocationFromNative(xev))) | |
529 return; | |
530 #endif | |
531 ui::TouchEvent touchev(xev); | 520 ui::TouchEvent touchev(xev); |
oshima
2014/05/06 01:47:57
I vaguely remember that creating TouchEvent before
| |
521 ui::DeviceDataManager::GetInstance()->CalibrateTouchEvent( | |
522 &touchev, xiev->deviceid, bounds_); | |
532 TranslateAndDispatchLocatedEvent(&touchev); | 523 TranslateAndDispatchLocatedEvent(&touchev); |
533 break; | 524 break; |
534 } | 525 } |
535 case ui::ET_MOUSE_MOVED: | 526 case ui::ET_MOUSE_MOVED: |
536 case ui::ET_MOUSE_DRAGGED: | 527 case ui::ET_MOUSE_DRAGGED: |
537 case ui::ET_MOUSE_PRESSED: | 528 case ui::ET_MOUSE_PRESSED: |
538 case ui::ET_MOUSE_RELEASED: | 529 case ui::ET_MOUSE_RELEASED: |
539 case ui::ET_MOUSE_ENTERED: | 530 case ui::ET_MOUSE_ENTERED: |
540 case ui::ET_MOUSE_EXITED: { | 531 case ui::ET_MOUSE_EXITED: { |
541 if (type == ui::ET_MOUSE_MOVED || type == ui::ET_MOUSE_DRAGGED) { | 532 if (type == ui::ET_MOUSE_MOVED || type == ui::ET_MOUSE_DRAGGED) { |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
604 } | 595 } |
605 | 596 |
606 namespace test { | 597 namespace test { |
607 | 598 |
608 void SetUseOverrideRedirectWindowByDefault(bool override_redirect) { | 599 void SetUseOverrideRedirectWindowByDefault(bool override_redirect) { |
609 default_override_redirect = override_redirect; | 600 default_override_redirect = override_redirect; |
610 } | 601 } |
611 | 602 |
612 } // namespace test | 603 } // namespace test |
613 } // namespace aura | 604 } // namespace aura |
OLD | NEW |