xserver/mi
Willem Jan Palenstijn f54647dfa6 mi: fix rounding issues around zero in miPointerSetPosition
Fixes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/577

This patch replaces the instances of trunc in miPointerSetPosition by
floor, thereby removing the incorrect behaviour with subpixel pointer
locations between -1 and 0.

This is the relevant code fragment:

    /* In the event we actually change screen or we get confined, we just
     * drop the float component on the floor
     * FIXME: only drop remainder for ConstrainCursorHarder, not for screen
     * crossings */
    if (x != trunc(*screenx))
        *screenx = x;
    if (y != trunc(*screeny))
        *screeny = y;

The behaviour of this code does not match its comment for subpixel
coordinates between -1 and 0. For example, if *screenx is -0.5, the
preceding code would (correctly) clamp x to 0, but this would not be
detected by this condition, since 0 == trunc(-0.5), leaving *screenx
at -0.5, out of bounds.

This causes undesirable behaviour in GTK3 code using xi2, where negative
subpixel coordinates like this would (to all appearances randomly)
remove the focus from windows aligned with the zero boundary when the
mouse hits the left or top screen boundaries.

The other occurences of trunc in miPointerSetPosition have a more subtle
effect which would prevent proper clamping if there is a pointer limit
at a negative integer rather than at 0. This patch changes these to
floor for consistency.

Signed-off-by: Willem Jan Palenstijn <wjp@usecode.org>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1451>
(cherry picked from commit 0ee4ed286e)
2024-04-05 13:46:40 +10:00
..
Makefile.am mi: Fold micursor.c into mipointer.c 2014-10-27 15:45:29 -04:00
meson.build meson: hide C API if Xorg is disabled (like autotools) 2021-03-11 00:22:36 +00:00
mi.h mi: Add a callback to notify driver about input event submission 2020-09-24 17:33:22 +00:00
miarc.c Fix spelling/wording issues 2020-07-05 13:07:33 -07:00
mibitblt.c Revert "mi: Shortcut miDoCopy/miCopyArea based on clipList" 2021-01-29 13:51:06 +00:00
micmap.c Fix spelling/wording issues 2020-07-05 13:07:33 -07:00
micmap.h Introduce a consistent coding style 2012-03-21 13:54:42 -07:00
micoord.h mi: Remove semi-arbitrary arch awareness in packed coordinate macros 2014-07-28 12:20:44 -07:00
micopy.c Revert "mi: Shortcut miDoCopy/miCopyArea based on clipList" 2021-01-29 13:51:06 +00:00
midash.c Drop trailing whitespaces 2014-11-12 10:25:00 +10:00
midispcur.c cursor: drop ARGB_CURSOR 2015-06-30 12:17:51 +10:00
mieq.c Implement gesture processing logic 2021-05-30 13:26:42 +03:00
miexpose.c Avoid sequences of malloc(0) / free() by checking the length. 2021-03-08 20:32:54 +00:00
mifillarc.c mi: Partial pie-slice filled arcs may need more space for spans 2015-04-13 18:41:26 -07:00
mifillarc.h mi: Unexport arc fill implementation details 2014-10-27 15:45:21 -04:00
mifillrct.c Convert mi & miext to new *allocarray functions 2015-04-21 16:58:08 -07:00
mifpoly.h Drop trailing whitespaces 2014-11-12 10:25:00 +10:00
migc.c fb: Remove 24bpp support (v3) 2017-03-17 15:14:42 -04:00
migc.h mi: Add include guards to migc.h 2017-02-16 15:10:32 -05:00
miglblt.c Fix spelling/wording issues 2020-07-05 13:07:33 -07:00
miinitext.c xquartz: Call PseudoramiXExtensionInit() through InitOutput() just like xwin 2021-04-07 16:11:59 -07:00
miinitext.h mi: List extensions in usage message 2021-01-29 12:52:09 +00:00
miline.h Introduce a consistent coding style 2012-03-21 13:54:42 -07:00
mioverlay.c mioverlay.c: remove shadowed pScreen. 2015-08-17 18:23:40 -07:00
mioverlay.h Introduce a consistent coding style 2012-03-21 13:54:42 -07:00
mipointer.c mi: fix rounding issues around zero in miPointerSetPosition 2024-04-05 13:46:40 +10:00
mipointer.h Fix spelling/wording issues 2020-07-05 13:07:33 -07:00
mipointrst.h dix: Update some comments to reflect the new non-SIGIO input model 2016-06-08 11:36:32 -04:00
mipoly.c Convert mi & miext to new *allocarray functions 2015-04-21 16:58:08 -07:00
mipoly.h Drop trailing whitespaces 2014-11-12 10:25:00 +10:00
mipolypnt.c Convert mi & miext to new *allocarray functions 2015-04-21 16:58:08 -07:00
mipolyrect.c Convert mi & miext to new *allocarray functions 2015-04-21 16:58:08 -07:00
mipolyseg.c Drop trailing whitespaces 2014-11-12 10:25:00 +10:00
mipolytext.c Drop trailing whitespaces 2014-11-12 10:25:00 +10:00
mipushpxl.c Drop trailing whitespaces 2014-11-12 10:25:00 +10:00
miscanfill.h Introduce a consistent coding style 2012-03-21 13:54:42 -07:00
miscrinit.c Fix spelling/wording issues 2020-07-05 13:07:33 -07:00
misprite.c misprite: Stop wrapping GetImage/GetSpans 2019-10-30 16:26:01 +00:00
misprite.h Introduce a consistent coding style 2012-03-21 13:54:42 -07:00
mistruct.h Drop trailing whitespaces 2014-11-12 10:25:00 +10:00
mivalidate.h Introduce a consistent coding style 2012-03-21 13:54:42 -07:00
mivaltree.c Drop trailing whitespaces 2014-11-12 10:25:00 +10:00
miwideline.c mi: Always initialize edge1 and edge2 in miLineArc 2015-08-17 18:50:25 -07:00
miwideline.h mi: Fold mispans.c into miwideline.c 2014-10-27 15:45:22 -04:00
miwindow.c dix: Restore PaintWindow screen hook 2015-07-08 16:41:28 -04:00
mizerarc.c Convert mi & miext to new *allocarray functions 2015-04-21 16:58:08 -07:00
mizerarc.h Introduce a consistent coding style 2012-03-21 13:54:42 -07:00
mizerclip.c Drop trailing whitespaces 2014-11-12 10:25:00 +10:00
mizerline.c Fix spelling/wording issues 2020-07-05 13:07:33 -07:00