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

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

Issue 2700623003: Make sure that the pressure is always 0 for pointerup events (Closed)
Patch Set: pointer pressure Created 3 years, 10 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
« no previous file with comments | « ui/events/x/events_x_unittest.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) 2016 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2016 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/x/events_x_utils.h" 5 #include "ui/events/x/events_x_utils.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
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 707 matching lines...) Expand 10 before | Expand all | Expand 10 after
718 return radius; 718 return radius;
719 } 719 }
720 720
721 float GetTouchAngleFromXEvent(const XEvent& xev) { 721 float GetTouchAngleFromXEvent(const XEvent& xev) {
722 return GetTouchParamFromXEvent( 722 return GetTouchParamFromXEvent(
723 xev, ui::DeviceDataManagerX11::DT_TOUCH_ORIENTATION, 0.0) / 723 xev, ui::DeviceDataManagerX11::DT_TOUCH_ORIENTATION, 0.0) /
724 2.0; 724 2.0;
725 } 725 }
726 726
727 float GetTouchForceFromXEvent(const XEvent& xev) { 727 float GetTouchForceFromXEvent(const XEvent& xev) {
728 double force = 0.0; 728 double force = 0.0;
sadrul 2017/02/21 19:18:07 Wrap everything below in a 'if (event->evtype != T
729 force = GetTouchParamFromXEvent( 729 force = GetTouchParamFromXEvent(
730 xev, ui::DeviceDataManagerX11::DT_TOUCH_PRESSURE, 0.0); 730 xev, ui::DeviceDataManagerX11::DT_TOUCH_PRESSURE, 0.0);
731 unsigned int deviceid = 731 unsigned int deviceid =
732 static_cast<XIDeviceEvent*>(xev.xcookie.data)->sourceid; 732 static_cast<XIDeviceEvent*>(xev.xcookie.data)->sourceid;
733 // Force is normalized to fall into [0, 1] 733 // Force is normalized to fall into [0, 1]
734 if (!ui::DeviceDataManagerX11::GetInstance()->NormalizeData( 734 if (!ui::DeviceDataManagerX11::GetInstance()->NormalizeData(
735 deviceid, ui::DeviceDataManagerX11::DT_TOUCH_PRESSURE, &force)) 735 deviceid, ui::DeviceDataManagerX11::DT_TOUCH_PRESSURE, &force))
736 force = 0.0; 736 force = 0.0;
737 XIDeviceEvent* event = static_cast<XIDeviceEvent*>(xev.xcookie.data);
738 if (event->evtype == XI_TouchEnd)
739 force = 0.0;
737 return force; 740 return force;
738 } 741 }
739 742
740 bool GetScrollOffsetsFromXEvent(const XEvent& xev, 743 bool GetScrollOffsetsFromXEvent(const XEvent& xev,
741 float* x_offset, 744 float* x_offset,
742 float* y_offset, 745 float* y_offset,
743 float* x_offset_ordinal, 746 float* x_offset_ordinal,
744 float* y_offset_ordinal, 747 float* y_offset_ordinal,
745 int* finger_count) { 748 int* finger_count) {
746 if (DeviceDataManagerX11::GetInstance()->IsScrollEvent(xev)) { 749 if (DeviceDataManagerX11::GetInstance()->IsScrollEvent(xev)) {
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
806 } 809 }
807 810
808 void ResetTimestampRolloverCountersForTesting( 811 void ResetTimestampRolloverCountersForTesting(
809 std::unique_ptr<base::TickClock> tick_clock) { 812 std::unique_ptr<base::TickClock> tick_clock) {
810 g_last_seen_timestamp_ms = 0; 813 g_last_seen_timestamp_ms = 0;
811 g_rollover_ms = 0; 814 g_rollover_ms = 0;
812 SetEventTickClockForTesting(std::move(tick_clock)); 815 SetEventTickClockForTesting(std::move(tick_clock));
813 } 816 }
814 817
815 } // namespace ui 818 } // namespace ui
OLDNEW
« no previous file with comments | « ui/events/x/events_x_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698