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

Side by Side Diff: ui/events/x/events_x.cc

Issue 412553005: Scale touch event radius (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address comment Created 6 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « ui/events/x/device_data_manager_x11.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/events/event_constants.h" 5 #include "ui/events/event_constants.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 #include <string.h> 8 #include <string.h>
9 #include <X11/extensions/XInput.h> 9 #include <X11/extensions/XInput.h>
10 #include <X11/extensions/XInput2.h> 10 #include <X11/extensions/XInput2.h>
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 } 279 }
280 280
281 double GetTouchParamFromXEvent(XEvent* xev, 281 double GetTouchParamFromXEvent(XEvent* xev,
282 ui::DeviceDataManagerX11::DataType val, 282 ui::DeviceDataManagerX11::DataType val,
283 double default_value) { 283 double default_value) {
284 ui::DeviceDataManagerX11::GetInstance()->GetEventData( 284 ui::DeviceDataManagerX11::GetInstance()->GetEventData(
285 *xev, val, &default_value); 285 *xev, val, &default_value);
286 return default_value; 286 return default_value;
287 } 287 }
288 288
289 void ScaleTouchRadius(XEvent* xev, double* radius) {
290 DCHECK_EQ(GenericEvent, xev->type);
291 XIDeviceEvent* xiev = static_cast<XIDeviceEvent*>(xev->xcookie.data);
292 ui::DeviceDataManagerX11::GetInstance()->ApplyTouchRadiusScale(
293 xiev->sourceid, radius);
294 }
295
289 } // namespace 296 } // namespace
290 297
291 namespace ui { 298 namespace ui {
292 299
293 void UpdateDeviceList() { 300 void UpdateDeviceList() {
294 XDisplay* display = gfx::GetXDisplay(); 301 XDisplay* display = gfx::GetXDisplay();
295 DeviceListCacheX::GetInstance()->UpdateDeviceList(display); 302 DeviceListCacheX::GetInstance()->UpdateDeviceList(display);
296 TouchFactory::GetInstance()->UpdateDeviceList(display); 303 TouchFactory::GetInstance()->UpdateDeviceList(display);
297 DeviceDataManagerX11::GetInstance()->UpdateDeviceList(display); 304 DeviceDataManagerX11::GetInstance()->UpdateDeviceList(display);
298 } 305 }
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after
697 *xev, ui::DeviceDataManagerX11::DT_TOUCH_TRACKING_ID, &tracking_id)) { 704 *xev, ui::DeviceDataManagerX11::DT_TOUCH_TRACKING_ID, &tracking_id)) {
698 LOG(ERROR) << "Could not get the tracking ID for the event. Using 0."; 705 LOG(ERROR) << "Could not get the tracking ID for the event. Using 0.";
699 } else { 706 } else {
700 ui::TouchFactory* factory = ui::TouchFactory::GetInstance(); 707 ui::TouchFactory* factory = ui::TouchFactory::GetInstance();
701 slot = factory->GetSlotForTrackingID(tracking_id); 708 slot = factory->GetSlotForTrackingID(tracking_id);
702 } 709 }
703 return slot; 710 return slot;
704 } 711 }
705 712
706 float GetTouchRadiusX(const base::NativeEvent& native_event) { 713 float GetTouchRadiusX(const base::NativeEvent& native_event) {
707 return GetTouchParamFromXEvent(native_event, 714 double radius = GetTouchParamFromXEvent(native_event,
708 ui::DeviceDataManagerX11::DT_TOUCH_MAJOR, 0.0) / 2.0; 715 ui::DeviceDataManagerX11::DT_TOUCH_MAJOR, 0.0) / 2.0;
716 ScaleTouchRadius(native_event, &radius);
717 return radius;
709 } 718 }
710 719
711 float GetTouchRadiusY(const base::NativeEvent& native_event) { 720 float GetTouchRadiusY(const base::NativeEvent& native_event) {
712 return GetTouchParamFromXEvent(native_event, 721 double radius = GetTouchParamFromXEvent(native_event,
713 ui::DeviceDataManagerX11::DT_TOUCH_MINOR, 0.0) / 2.0; 722 ui::DeviceDataManagerX11::DT_TOUCH_MINOR, 0.0) / 2.0;
723 ScaleTouchRadius(native_event, &radius);
724 return radius;
714 } 725 }
715 726
716 float GetTouchAngle(const base::NativeEvent& native_event) { 727 float GetTouchAngle(const base::NativeEvent& native_event) {
717 return GetTouchParamFromXEvent(native_event, 728 return GetTouchParamFromXEvent(native_event,
718 ui::DeviceDataManagerX11::DT_TOUCH_ORIENTATION, 0.0) / 2.0; 729 ui::DeviceDataManagerX11::DT_TOUCH_ORIENTATION, 0.0) / 2.0;
719 } 730 }
720 731
721 float GetTouchForce(const base::NativeEvent& native_event) { 732 float GetTouchForce(const base::NativeEvent& native_event) {
722 double force = 0.0; 733 double force = 0.0;
723 force = GetTouchParamFromXEvent(native_event, 734 force = GetTouchParamFromXEvent(native_event,
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
802 start_time = &start_time_; 813 start_time = &start_time_;
803 if (!end_time) 814 if (!end_time)
804 end_time = &end_time_; 815 end_time = &end_time_;
805 816
806 DeviceDataManagerX11::GetInstance()->GetGestureTimes( 817 DeviceDataManagerX11::GetInstance()->GetGestureTimes(
807 native_event, start_time, end_time); 818 native_event, start_time, end_time);
808 return true; 819 return true;
809 } 820 }
810 821
811 } // namespace ui 822 } // namespace ui
OLDNEW
« no previous file with comments | « ui/events/x/device_data_manager_x11.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698