x11: Normalize x11xinput2 touch x to be 1.0 at width (thanks, Zach!).
authorRyan C. Gordon <icculus@icculus.org>
Sun, 24 Jun 2018 13:57:22 -0400
changeset 12029dfebed374d73
parent 12028 8aa5a79c8805
child 12030 c0c4ba22a685
x11: Normalize x11xinput2 touch x to be 1.0 at width (thanks, Zach!).

"Applications (such as SDL's testgesture) do "event.tfinger.x * window_width"
to find window coord. Currently the X11 XInput2 backend expects application
to do "event.tfinger.x * (window_width-1)" instead.

X11 XInput2 touch events are normalized so x is 1.0 at "width - 1" but other
SDL backends appear to have x be 1.0 at "width". Same issue for touch event
y with regards to height."

Fixes Bugzilla #4183.
src/video/x11/SDL_x11xinput2.c
     1.1 --- a/src/video/x11/SDL_x11xinput2.c	Thu Jun 14 06:12:12 2018 +0000
     1.2 +++ b/src/video/x11/SDL_x11xinput2.c	Sun Jun 24 13:57:22 2018 -0400
     1.3 @@ -83,16 +83,8 @@
     1.4      for (i = 0; i < videodata->numwindows; i++) {
     1.5          SDL_WindowData *d = videodata->windowlist[i];
     1.6          if (d->xwindow == window) {
     1.7 -            if (d->window->w == 1) {
     1.8 -                *out_x = 0.5f;
     1.9 -            } else {
    1.10 -                *out_x = in_x / (d->window->w - 1);
    1.11 -            }
    1.12 -            if (d->window->h == 1) {
    1.13 -                *out_y = 0.5f;
    1.14 -            } else {
    1.15 -                *out_y = in_y / (d->window->h - 1);
    1.16 -            }
    1.17 +            *out_x = in_x / d->window->w;
    1.18 +            *out_y = in_y / d->window->h;
    1.19              return;
    1.20          }
    1.21      }