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/Xfixes.h> | 9 #include <X11/extensions/Xfixes.h> |
10 #include <X11/extensions/XInput2.h> | 10 #include <X11/extensions/XInput2.h> |
(...skipping 790 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
801 ui::EventType type = ui::EventTypeFromNative(xev); | 801 ui::EventType type = ui::EventTypeFromNative(xev); |
802 XEvent last_event; | 802 XEvent last_event; |
803 int num_coalesced = 0; | 803 int num_coalesced = 0; |
804 | 804 |
805 switch (type) { | 805 switch (type) { |
806 case ui::ET_TOUCH_MOVED: | 806 case ui::ET_TOUCH_MOVED: |
807 case ui::ET_TOUCH_PRESSED: | 807 case ui::ET_TOUCH_PRESSED: |
808 case ui::ET_TOUCH_CANCELLED: | 808 case ui::ET_TOUCH_CANCELLED: |
809 case ui::ET_TOUCH_RELEASED: { | 809 case ui::ET_TOUCH_RELEASED: { |
810 #if defined(OS_CHROMEOS) | 810 #if defined(OS_CHROMEOS) |
811 // Bail out early before generating a ui::TouchEvent if this event | 811 // Bail out early before generating a ui::TouchEvent if this event is |
812 // is not within the range of this RootWindow. Converting an xevent | 812 // not targeting this RootWindow. Converting an xevent to ui::TouchEvent |
813 // to ui::TouchEvent might change the state of the global touch tracking | 813 // might change the global touch tracking state, e.g. touch release event |
814 // state, e.g. touch release event can remove the touch id from the | 814 // can remove the touch id from the record, and doing this multiple time |
815 // record, and doing this multiple time when there are multiple | 815 // when there are multiple RootWindow will cause problem. |
816 // RootWindow will cause problem. So only generate the ui::TouchEvent | 816 // If the root window does not have a TouchCTM for the touch device where |
817 // when we are sure it belongs to this RootWindow. | 817 // the touch event is from, then the touch event is not intended for this |
818 if (base::SysInfo::IsRunningOnChromeOS() && | 818 // root window. |
819 !bounds_.Contains(ui::EventLocationFromNative(xev))) | 819 XIDeviceEvent* xiev = static_cast<XIDeviceEvent*>(xev->xcookie.data); |
820 if (touch_ctm_map_.find(xiev->deviceid) == touch_ctm_map_.end()) | |
sadrul
2014/03/10 20:20:12
It looks like the display-controller in ash is the
Yufeng Shen (Slow to review)
2014/03/13 20:55:46
As discussed, in the new patch I am firstly using
| |
820 break; | 821 break; |
821 #endif // defined(OS_CHROMEOS) | 822 #endif // defined(OS_CHROMEOS) |
822 ui::TouchEvent touchev(xev); | 823 ui::TouchEvent touchev(xev); |
824 #if defined(OS_CHROMEOS) | |
825 TouchCTM ctm = touch_ctm_map_[xiev->deviceid]; | |
826 float transformed_x = touchev.x() * ctm.x_scale + ctm.x_offset; | |
827 float transformed_y = touchev.y() * ctm.y_scale + ctm.y_offset; | |
828 touchev.set_location(gfx::PointF(transformed_x, transformed_y)); | |
829 touchev.set_root_location(gfx::PointF(transformed_x, transformed_y)); | |
830 #endif // defined(OS_CHROMEOS) | |
823 #if defined(USE_XI2_MT) | 831 #if defined(USE_XI2_MT) |
824 // Ignore touch events with touch press happening on the side bezel. | 832 // Ignore touch events with touch press happening on the side bezel. |
825 if (!IsSideBezelsEnabled()) { | 833 if (!IsSideBezelsEnabled()) { |
826 uint32 tracking_id = (1 << touchev.touch_id()); | 834 uint32 tracking_id = (1 << touchev.touch_id()); |
827 if (type == ui::ET_TOUCH_PRESSED && | 835 if (type == ui::ET_TOUCH_PRESSED && |
828 touch_calibrate_->IsEventOnSideBezels(xev, bounds_)) | 836 touch_calibrate_->IsEventOnSideBezels(xev, bounds_)) |
829 bezel_tracking_ids_ |= tracking_id; | 837 bezel_tracking_ids_ |= tracking_id; |
830 if (bezel_tracking_ids_ & tracking_id) { | 838 if (bezel_tracking_ids_ & tracking_id) { |
831 if (type == ui::ET_TOUCH_CANCELLED || type == ui::ET_TOUCH_RELEASED) | 839 if (type == ui::ET_TOUCH_CANCELLED || type == ui::ET_TOUCH_RELEASED) |
832 bezel_tracking_ids_ = | 840 bezel_tracking_ids_ = |
833 (bezel_tracking_ids_ | tracking_id) ^ tracking_id; | 841 (bezel_tracking_ids_ | tracking_id) ^ tracking_id; |
834 return; | 842 return; |
835 } | 843 } |
836 } | 844 } |
837 #endif // defined(USE_XI2_MT) | 845 #endif // defined(USE_XI2_MT) |
838 #if defined(OS_CHROMEOS) | 846 #if defined(OS_CHROMEOS) |
839 if (base::SysInfo::IsRunningOnChromeOS()) { | 847 if (base::SysInfo::IsRunningOnChromeOS()) { |
840 // X maps the touch-surface to the size of the X root-window. | 848 // X maps the touch-surface to the size of the X root-window. |
841 // In multi-monitor setup, Coordinate Transformation Matrix | 849 // In multi-monitor setup, Coordinate Transformation Matrix |
842 // repositions the touch-surface onto part of X root-window | 850 // repositions the touch-surface onto part of X root-window |
843 // containing aura root-window corresponding to the touchscreen. | 851 // containing aura root-window corresponding to the touchscreen. |
844 // However, if aura root-window has non-zero origin, | 852 // However, if aura root-window has non-zero origin, |
845 // we need to relocate the event into aura root-window coordinates. | 853 // we need to relocate the event into aura root-window coordinates. |
846 touchev.Relocate(bounds_.origin()); | 854 touchev.Relocate(bounds_.origin()); |
847 #if defined(USE_XI2_MT) | 855 #if defined(USE_XI2_MT) |
848 if (is_internal_display_) | 856 if (is_internal_display_) |
849 touch_calibrate_->Calibrate(&touchev, bounds_); | 857 touch_calibrate_->Calibrate(&touchev, bounds_); |
sadrul
2014/03/10 20:20:12
We should get rid of this code, and TouchEventCali
Yufeng Shen (Slow to review)
2014/03/13 20:55:46
so the new patch is like:
if (!IsTouchEventTarget
| |
850 #endif // defined(USE_XI2_MT) | 858 #endif // defined(USE_XI2_MT) |
851 } | 859 } |
852 #endif // defined(OS_CHROMEOS) | 860 #endif // defined(OS_CHROMEOS) |
853 SendEventToProcessor(&touchev); | 861 SendEventToProcessor(&touchev); |
854 break; | 862 break; |
855 } | 863 } |
856 case ui::ET_MOUSE_MOVED: | 864 case ui::ET_MOUSE_MOVED: |
857 case ui::ET_MOUSE_DRAGGED: | 865 case ui::ET_MOUSE_DRAGGED: |
858 case ui::ET_MOUSE_PRESSED: | 866 case ui::ET_MOUSE_PRESSED: |
859 case ui::ET_MOUSE_RELEASED: | 867 case ui::ET_MOUSE_RELEASED: |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
998 } | 1006 } |
999 | 1007 |
1000 namespace test { | 1008 namespace test { |
1001 | 1009 |
1002 void SetUseOverrideRedirectWindowByDefault(bool override_redirect) { | 1010 void SetUseOverrideRedirectWindowByDefault(bool override_redirect) { |
1003 default_override_redirect = override_redirect; | 1011 default_override_redirect = override_redirect; |
1004 } | 1012 } |
1005 | 1013 |
1006 } // namespace test | 1014 } // namespace test |
1007 } // namespace aura | 1015 } // namespace aura |
OLD | NEW |