Bug 106663 - The macro FP3232_TO_DOUBLE always ignores the fractional part of number
Summary: The macro FP3232_TO_DOUBLE always ignores the fractional part of number
Alias: None
Product: xorg
Classification: Unclassified
Component: Lib/Xi (show other bugs)
Version: git
Hardware: Other All
: medium normal
Assignee: Xorg Project Team
QA Contact: Xorg Project Team
Depends on:
Reported: 2018-05-26 07:52 UTC by bay
Modified: 2018-08-10 20:15 UTC (History)
0 users

See Also:
i915 platform:
i915 features:

The patch (1.39 KB, patch)
2018-05-26 07:54 UTC, bay
no flags Details | Splinter Review

Description bay 2018-05-26 07:52:07 UTC

The FP3232_TO_DOUBLE(x) is declared in XExtInt.c as:
#define FP3232_TO_DOUBLE(x) ((double) (x).integral + (x).frac / (1ULL << 32))

The (x).frac is integer and (1ULL << 32) is also integer, to the result is also integer and zero.

The proposed fix is to convert (x).frac to double:
#define FP3232_TO_DOUBLE(x) ((double) (x).integral + (double) (x).frac / (1ULL << 32))

Also the fractional values are ignored in copy_classes function and there is a 
/* FIXME: fractional parts */

The fix is trivial:

Instead of:
cls_lib->min        = cls_wire->min.integral;
cls_lib->max        = cls_wire->max.integral;
cls_lib->value      = cls_wire->value.integral;
/* FIXME: fractional parts */

Could be replaced by:
cls_lib->min        =  FP3232_TO_DOUBLE(cls_wire->min);
cls_lib->max        = FP3232_TO_DOUBLE(cls_wire->max);
cls_lib->value      = FP3232_TO_DOUBLE(cls_wire->value);

This fixes glitchy scrolling in Qt applications when the application was just activated or was scrolled in the backgroud. Qt is using XIQueryDevice call to synchronize internal scroll location with an actual one (QXcbConnection::xi2HandleDeviceChangedEvent and QXcbConnection::updateScrollingDevice functions in http://code.qt.io/cgit/qt/qtbase.git/tree/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp)

The patch is attached

Alexander Bersenev
Comment 1 bay 2018-05-26 07:54:00 UTC
Created attachment 139786 [details] [review]
The patch
Comment 2 bay 2018-05-26 08:21:18 UTC
https://www.youtube.com/watch?v=PYDa05QKD_8 - the demonstration of scrolling glitches in Qt programs
Comment 3 GitLab Migration User 2018-08-10 20:15:16 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/xorg/lib/libxi/issues/10.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.