static void
x_free_xi_devices (struct x_display_info *dpyinfo)
{
+#ifdef HAVE_XINPUT2_2
struct xi_touch_point_t *tem, *last;
+#endif
block_input ();
{
for (int i = 0; i < dpyinfo->num_devices; ++i)
{
+#ifdef HAVE_XINPUT2_1
xfree (dpyinfo->devices[i].valuators);
+#endif
+#ifdef HAVE_XINPUT2_2
tem = dpyinfo->devices[i].touchpoints;
while (tem)
{
tem = tem->next;
xfree (last);
}
+#endif
}
xfree (dpyinfo->devices);
if (device->enabled)
{
+#ifdef HAVE_XINPUT2_1
int actual_valuator_count = 0;
+#endif
+
struct xi_device_t *xi_device = &dpyinfo->devices[actual_devices++];
xi_device->device_id = device->deviceid;
xi_device->grab = 0;
+
+#ifdef HAVE_XINPUT2_1
xi_device->valuators =
xmalloc (sizeof *xi_device->valuators * device->num_classes);
+#endif
+#ifdef HAVE_XINPUT2_2
xi_device->touchpoints = NULL;
+#endif
+
xi_device->master_p = (device->use == XIMasterKeyboard
|| device->use == XIMasterPointer);
+#ifdef HAVE_XINPUT2_2
xi_device->direct_p = false;
+#endif
for (int c = 0; c < device->num_classes; ++c)
{
}
}
+#ifdef HAVE_XINPUT2_1
xi_device->scroll_valuator_count = actual_valuator_count;
+#endif
}
}
unblock_input ();
}
+#ifdef HAVE_XINPUT2_1
/* Return the delta of the scroll valuator VALUATOR_NUMBER under
DEVICE_ID in the display DPYINFO with VALUE. The valuator's
valuator will be set to VALUE afterwards. In case no scroll
return DBL_MAX;
}
+#endif
+
struct xi_device_t *
xi_device_from_id (struct x_display_info *dpyinfo, int deviceid)
{
return NULL;
}
-#endif /* XI_TouchBegin */
+#endif /* HAVE_XINPUT2_2 */
+
+#ifdef HAVE_XINPUT2_1
static void
xi_reset_scroll_valuators_for_device_id (struct x_display_info *dpyinfo, int id,
return;
}
+#endif /* HAVE_XINPUT2_1 */
+
#endif
#ifdef USE_CAIRO
XIFocusInEvent *focusin = (XIFocusInEvent *) xi_event;
XIFocusOutEvent *focusout = (XIFocusOutEvent *) xi_event;
XIDeviceChangedEvent *device_changed = (XIDeviceChangedEvent *) xi_event;
+#ifdef HAVE_XINPUT2_1
XIValuatorState *states;
double *values;
bool found_valuator = false;
+#endif
/* A fake XMotionEvent for x_note_mouse_movement. */
XMotionEvent ev;
if (!any)
any = x_any_window_to_frame (dpyinfo, enter->event);
+#ifdef HAVE_XINPUT2_1
xi_reset_scroll_valuators_for_device_id (dpyinfo, enter->deviceid,
true);
+#endif
{
#ifdef HAVE_XWIDGETS
records of each valuator's value whenever the pointer
moves out of a frame (and not into one of its
children, which we know about). */
+#ifdef HAVE_XINPUT2_1
if (leave->detail != XINotifyInferior && any)
xi_reset_scroll_valuators_for_device_id (dpyinfo,
enter->deviceid, false);
+#endif
#ifdef HAVE_XWIDGETS
{
{
struct xi_device_t *device;
+#ifdef HAVE_XINPUT2_1
states = &xev->valuators;
values = states->values;
+#endif
+
device = xi_device_from_id (dpyinfo, xev->deviceid);
if (!device)
goto XI_OTHER;
#endif
+#ifdef HAVE_XINPUT2_1
#ifdef HAVE_XWIDGETS
struct xwidget_view *xv = xwidget_view_from_window (xev->event);
double xv_total_x = 0.0;
#ifdef HAVE_XWIDGETS
}
#endif
+#endif /* HAVE_XINPUT2_1 */
ev.x = lrint (xev->event_x);
ev.y = lrint (xev->event_y);
struct xwidget_view *xvw;
#endif
-#ifdef XIPointerEmulated
+#ifdef HAVE_XINPUT2_1
/* Ignore emulated scroll events when XI2 native
scroll events are present. */
if (xev->flags & XIPointerEmulated)
case XI_DeviceChanged:
{
struct xi_device_t *device;
+#ifdef HAVE_XINPUT2_2
struct xi_touch_point_t *tem, *last;
+#endif
int c;
#ifdef HAVE_XINPUT2_1
int i;
/* Free data that we will regenerate from new
information. */
+#ifdef HAVE_XINPUT2_1
device->valuators = xrealloc (device->valuators,
(device_changed->num_classes
* sizeof *device->valuators));
device->scroll_valuator_count = 0;
+#endif
+#ifdef HAVE_XINPUT2_2
device->direct_p = false;
+#endif
for (c = 0; c < device_changed->num_classes; ++c)
{
}
#endif
+#ifdef HAVE_XINPUT2_2
/* The device is no longer a DirectTouch device, so
remove any touchpoints that we might have
recorded. */
device->touchpoints = NULL;
}
+#endif
goto XI_OTHER;
}
};
#endif /* HAVE_X11R6_XIM */
+#ifdef HAVE_XINPUT2
+#if HAVE_XISCROLLCLASSINFO_TYPE && defined XIScrollClass
+#define HAVE_XINPUT2_1
+#endif
+#if HAVE_XITOUCHCLASSINFO_TYPE && defined XITouchClass
+#define HAVE_XINPUT2_2
+#endif
+#if HAVE_XIBARRIERRELEASEPOINTERINFO_DEVICEID && defined XIBarrierPointerReleased
+#define HAVE_XINPUT2_3
+#endif
+#if HAVE_XIGESTURECLASSINFO_TYPE && defined XIGestureClass
+#define HAVE_XINPUT2_4
+#endif
+#endif
+
/* Structure recording X pixmap and reference count.
If REFCOUNT is 0 then this record is free to be reused. */
};
#ifdef HAVE_XINPUT2
+
+#ifdef HAVE_XINPUT2_1
struct xi_scroll_valuator_t
{
bool invalid_p;
int number;
int horizontal;
};
+#endif
+#ifdef HAVE_XINPUT2_2
struct xi_touch_point_t
{
struct xi_touch_point_t *next;
int number;
double x, y;
};
+#endif
struct xi_device_t
{
int device_id;
+#ifdef HAVE_XINPUT2_1
int scroll_valuator_count;
+#endif
int grab;
bool master_p;
+#ifdef HAVE_XINPUT2_2
bool direct_p;
+#endif
+#ifdef HAVE_XINPUT2_1
struct xi_scroll_valuator_t *valuators;
+#endif
+#ifdef HAVE_XINPUT2_2
struct xi_touch_point_t *touchpoints;
+#endif
};
#endif
(nr).width = (rwidth), \
(nr).height = (rheight))
-#ifdef HAVE_XINPUT2
-#if HAVE_XISCROLLCLASSINFO_TYPE && defined XIScrollClass
-#define HAVE_XINPUT2_1
-#endif
-#if HAVE_XITOUCHCLASSINFO_TYPE && defined XITouchClass
-#define HAVE_XINPUT2_2
-#endif
-#if HAVE_XIBARRIERRELEASEPOINTERINFO_DEVICEID && defined XIBarrierPointerReleased
-#define HAVE_XINPUT2_3
-#endif
-#if HAVE_XIGESTURECLASSINFO_TYPE && defined XIGestureClass
-#define HAVE_XINPUT2_4
-#endif
-#endif
-
INLINE_HEADER_END
#endif /* XTERM_H */