Rémi Bernon : winex11.drv: Use XIValuatorClassInfo instead of a custom struct.

Alexandre Julliard julliard at winehq.org
Mon Oct 25 16:30:07 CDT 2021


Module: wine
Branch: master
Commit: da11387857f69d8bf68de56197390052f680f283
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=da11387857f69d8bf68de56197390052f680f283

Author: Rémi Bernon <rbernon at codeweavers.com>
Date:   Mon Oct 25 11:51:53 2021 +0200

winex11.drv: Use XIValuatorClassInfo instead of a custom struct.

Signed-off-by: Rémi Bernon <rbernon at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/winex11.drv/mouse.c  | 18 +++---------------
 dlls/winex11.drv/window.c |  3 +++
 dlls/winex11.drv/x11drv.h | 16 +++++++---------
 3 files changed, 13 insertions(+), 24 deletions(-)

diff --git a/dlls/winex11.drv/mouse.c b/dlls/winex11.drv/mouse.c
index 2243261e0b8..c6daa30392c 100644
--- a/dlls/winex11.drv/mouse.c
+++ b/dlls/winex11.drv/mouse.c
@@ -262,25 +262,13 @@ static void update_relative_valuators(XIAnyClassInfo **valuators, int n_valuator
     for (i = 0; i < n_valuators; i++)
     {
         XIValuatorClassInfo *class = (XIValuatorClassInfo *)valuators[i];
-        struct x11drv_valuator_data *valuator_data = NULL;
-
         if (valuators[i]->type != XIValuatorClass) continue;
         if (class->label == x11drv_atom( Rel_X ) ||
             (!class->label && class->number == 0 && class->mode == XIModeRelative))
-        {
-            valuator_data = &thread_data->x_rel_valuator;
-        }
+            thread_data->x_rel_valuator = *class;
         else if (class->label == x11drv_atom( Rel_Y ) ||
                  (!class->label && class->number == 1 && class->mode == XIModeRelative))
-        {
-            valuator_data = &thread_data->y_rel_valuator;
-        }
-
-        if (valuator_data) {
-            valuator_data->number = class->number;
-            valuator_data->min = class->min;
-            valuator_data->max = class->max;
-        }
+            thread_data->y_rel_valuator = *class;
     }
 }
 #endif
@@ -638,7 +626,7 @@ static BOOL map_raw_event_coords( XIRawEvent *event, INPUT *input )
 {
     struct x11drv_thread_data *thread_data = x11drv_thread_data();
     const double *values = event->valuators.values;
-    struct x11drv_valuator_data *x_rel, *y_rel;
+    XIValuatorClassInfo *x_rel, *y_rel;
     double dx = 0, dy = 0, val;
     RECT virtual_rect;
     int i;
diff --git a/dlls/winex11.drv/window.c b/dlls/winex11.drv/window.c
index 7ec2639e309..bcb0b8044bc 100644
--- a/dlls/winex11.drv/window.c
+++ b/dlls/winex11.drv/window.c
@@ -36,6 +36,9 @@
 #ifdef HAVE_LIBXSHAPE
 #include <X11/extensions/shape.h>
 #endif /* HAVE_LIBXSHAPE */
+#ifdef HAVE_X11_EXTENSIONS_XINPUT2_H
+#include <X11/extensions/XInput2.h>
+#endif
 
 /* avoid conflict with field names in included win32 headers */
 #undef Status
diff --git a/dlls/winex11.drv/x11drv.h b/dlls/winex11.drv/x11drv.h
index e82ee921830..962fe373833 100644
--- a/dlls/winex11.drv/x11drv.h
+++ b/dlls/winex11.drv/x11drv.h
@@ -32,6 +32,9 @@
 #include <X11/Xresource.h>
 #include <X11/Xutil.h>
 #include <X11/Xatom.h>
+#ifdef HAVE_X11_EXTENSIONS_XINPUT2_H
+#include <X11/extensions/XInput2.h>
+#endif
 
 #define BOOL X_BOOL
 #define BYTE X_BYTE
@@ -314,13 +317,6 @@ struct x11drv_escape_flush_gl_drawable
  * X11 USER driver
  */
 
-struct x11drv_valuator_data
-{
-    double min;
-    double max;
-    int number;
-};
-
 struct x11drv_thread_data
 {
     Display *display;
@@ -335,13 +331,15 @@ struct x11drv_thread_data
     Window   clip_window;          /* window used for cursor clipping */
     HWND     clip_hwnd;            /* message window stored in desktop while clipping is active */
     DWORD    clip_reset;           /* time when clipping was last reset */
+#ifdef HAVE_X11_EXTENSIONS_XINPUT2_H
     enum { xi_unavailable = -1, xi_unknown, xi_disabled, xi_enabled } xi2_state; /* XInput2 state */
     void    *xi2_devices;          /* list of XInput2 devices (valid when state is enabled) */
     int      xi2_device_count;
-    struct x11drv_valuator_data x_rel_valuator;
-    struct x11drv_valuator_data y_rel_valuator;
+    XIValuatorClassInfo x_rel_valuator;
+    XIValuatorClassInfo y_rel_valuator;
     int      xi2_core_pointer;     /* XInput2 core pointer id */
     int      xi2_current_slave;    /* Current slave driving the Core pointer */
+#endif /* HAVE_X11_EXTENSIONS_XINPUT2_H */
 };
 
 extern struct x11drv_thread_data *x11drv_init_thread_data(void) DECLSPEC_HIDDEN;




More information about the wine-cvs mailing list