From 4a2050e220adabd09ecfadac99f208dc31b5ff12 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Thu, 30 Jul 2020 17:37:19 +0200 Subject: [PATCH] gdk/x11: Make device type a X11 detail The only legit uses of device types are here in gdk/x11, move the concept of device type to X11, so we can drop it from public API. --- gdk/x11/gdkdevice-xi2.c | 16 +++++++++++++++- gdk/x11/gdkdevicemanager-xi2.c | 19 ++++++++++--------- gdk/x11/gdkx11device-xi2.h | 10 ++++++++++ 3 files changed, 35 insertions(+), 10 deletions(-) diff --git a/gdk/x11/gdkdevice-xi2.c b/gdk/x11/gdkdevice-xi2.c index 83e6bb6b43..0a239f2d8a 100644 --- a/gdk/x11/gdkdevice-xi2.c +++ b/gdk/x11/gdkdevice-xi2.c @@ -50,6 +50,7 @@ struct _GdkX11DeviceXI2 int device_id; GArray *scroll_valuators; double *last_axes; + GdkX11DeviceType device_type; }; struct _GdkX11DeviceXI2Class @@ -190,7 +191,7 @@ gdk_x11_device_xi2_set_surface_cursor (GdkDevice *device, GdkX11DeviceXI2 *device_xi2 = GDK_X11_DEVICE_XI2 (device); /* Non-logical devices don't have a cursor */ - if (gdk_device_get_device_type (device) != GDK_DEVICE_TYPE_LOGICAL) + if (device_xi2->device_type != GDK_X11_DEVICE_TYPE_LOGICAL) return; if (cursor) @@ -773,3 +774,16 @@ gdk_x11_device_xi2_store_axes (GdkX11DeviceXI2 *device, else device->last_axes = NULL; } + +GdkX11DeviceType +gdk_x11_device_xi2_get_device_type (GdkX11DeviceXI2 *device) +{ + return device->device_type; +} + +void +gdk_x11_device_xi2_set_device_type (GdkX11DeviceXI2 *device, + GdkX11DeviceType type) +{ + device->device_type = type; +} diff --git a/gdk/x11/gdkdevicemanager-xi2.c b/gdk/x11/gdkdevicemanager-xi2.c index 5620e8ef87..3f5b855cf4 100644 --- a/gdk/x11/gdkdevicemanager-xi2.c +++ b/gdk/x11/gdkdevicemanager-xi2.c @@ -471,7 +471,7 @@ create_device (GdkX11DeviceManagerXI2 *device_manager, { GdkInputSource input_source; GdkInputSource touch_source; - GdkDeviceType type; + GdkX11DeviceType type; GdkDevice *device; int num_touches = 0; char *vendor_id = NULL, *product_id = NULL; @@ -515,15 +515,15 @@ create_device (GdkX11DeviceManagerXI2 *device_manager, { case XIMasterKeyboard: case XIMasterPointer: - type = GDK_DEVICE_TYPE_LOGICAL; + type = GDK_X11_DEVICE_TYPE_LOGICAL; break; case XISlaveKeyboard: case XISlavePointer: - type = GDK_DEVICE_TYPE_PHYSICAL; + type = GDK_X11_DEVICE_TYPE_PHYSICAL; break; case XIFloatingSlave: default: - type = GDK_DEVICE_TYPE_FLOATING; + type = GDK_X11_DEVICE_TYPE_FLOATING; break; } @@ -545,7 +545,6 @@ create_device (GdkX11DeviceManagerXI2 *device_manager, device = g_object_new (GDK_TYPE_X11_DEVICE_XI2, "name", dev->name, - "type", type, "source", input_source, "has-cursor", (dev->use == XIMasterPointer), "display", display, @@ -554,6 +553,7 @@ create_device (GdkX11DeviceManagerXI2 *device_manager, "product-id", product_id, "num-touches", num_touches, NULL); + gdk_x11_device_xi2_set_device_type ((GdkX11DeviceXI2 *) device, type); translate_device_classes (display, device, dev->classes, dev->num_classes); g_free (vendor_id); @@ -652,13 +652,14 @@ static void detach_from_seat (GdkDevice *device) { GdkSeat *seat = gdk_device_get_seat (device); + GdkX11DeviceXI2 *device_xi2 = (GdkX11DeviceXI2 *) device; if (!seat) return; - if (gdk_device_get_device_type (device) == GDK_DEVICE_TYPE_LOGICAL) + if (gdk_x11_device_xi2_get_device_type (device_xi2) == GDK_X11_DEVICE_TYPE_LOGICAL) gdk_display_remove_seat (gdk_device_get_display (device), seat); - else if (gdk_device_get_device_type (device) == GDK_DEVICE_TYPE_PHYSICAL) + else if (gdk_x11_device_xi2_get_device_type (device_xi2) == GDK_X11_DEVICE_TYPE_PHYSICAL) gdk_seat_default_remove_physical_device (GDK_SEAT_DEFAULT (seat), device); } @@ -1711,7 +1712,7 @@ gdk_x11_device_manager_xi2_translate_event (GdkEventTranslator *translator, * source device, we need to explicitly ignore the first event in * order to get the correct delta for the second. */ - if (gdk_device_get_device_type (device) != GDK_DEVICE_TYPE_PHYSICAL && + if (gdk_x11_device_xi2_get_device_type ((GdkX11DeviceXI2 *) device) != GDK_X11_DEVICE_TYPE_PHYSICAL && scroll_valuators_changed (GDK_X11_DEVICE_XI2 (source_device), &xev->valuators, &delta_x, &delta_y)) { @@ -1886,7 +1887,7 @@ gdk_x11_device_manager_xi2_translate_event (GdkEventTranslator *translator, xev->detail != XINotifyInferior && xev->mode != XINotifyPassiveUngrab && GDK_IS_TOPLEVEL (surface)) { - if (gdk_device_get_device_type (source_device) != GDK_DEVICE_TYPE_LOGICAL) + if (gdk_x11_device_xi2_get_device_type ((GdkX11DeviceXI2 *) device) != GDK_X11_DEVICE_TYPE_LOGICAL) _gdk_device_xi2_reset_scroll_valuators (GDK_X11_DEVICE_XI2 (source_device)); else { diff --git a/gdk/x11/gdkx11device-xi2.h b/gdk/x11/gdkx11device-xi2.h index e65a528a4c..169e71f254 100644 --- a/gdk/x11/gdkx11device-xi2.h +++ b/gdk/x11/gdkx11device-xi2.h @@ -32,9 +32,19 @@ G_BEGIN_DECLS typedef struct _GdkX11DeviceXI2 GdkX11DeviceXI2; typedef struct _GdkX11DeviceXI2Class GdkX11DeviceXI2Class; +typedef enum { + GDK_X11_DEVICE_TYPE_LOGICAL, + GDK_X11_DEVICE_TYPE_PHYSICAL, + GDK_X11_DEVICE_TYPE_FLOATING +} GdkX11DeviceType; + GDK_AVAILABLE_IN_ALL GType gdk_x11_device_xi2_get_type (void) G_GNUC_CONST; +GdkX11DeviceType gdk_x11_device_xi2_get_device_type (GdkX11DeviceXI2 *device); +void gdk_x11_device_xi2_set_device_type (GdkX11DeviceXI2 *device, + GdkX11DeviceType type); + G_END_DECLS #endif /* __GDK_X11_DEVICE_XI2_H__ */