GitLab will be down for maintenance this Sunday 13th June, from approx 7-11am UTC. This is for a PostgreSQL migration. See the tracker issue for more informations.

Commit 54ab1574 authored by Povilas Kanapickas's avatar Povilas Kanapickas
Browse files

Accept list of events as a vector to SelectXI2Events

parent a7301db9
Pipeline #251881 passed with stages
in 1 minute and 31 seconds
......@@ -297,19 +297,14 @@ int double_cmp(double a, double b, int precision)
return (ai > bi) ? 1 : (ai < bi) ? -1 : 0;
}
void SelectXI2Events(::Display *dpy, int deviceid, Window win, ...)
void SelectXI2Events(::Display *dpy, int deviceid, Window win, const std::vector<int>& evtypes)
{
va_list arg;
int evtype;
XIEventMask mask;
unsigned char m[XIMaskLen(XI_LASTEVENT)] = {0};
mask.deviceid = deviceid;
mask.mask_len = XIMaskLen(XI_LASTEVENT);
mask.mask = m;
va_start(arg, win);
while ((evtype = va_arg(arg, int)) != -1)
for (auto evtype : evtypes)
XISetMask(mask.mask, evtype);
va_end(arg);
XISelectEvents(dpy, win, &mask, 1);
}
......@@ -181,9 +181,9 @@ bool SearchFileForString(const std::string &path, const std::string &substring);
int double_cmp(double a, double b, int precision = 2);
/**
* Select for the list of events given in the varargs. Last element must be
* -1.
* Select for the list of events given in the evtypes.
*/
void SelectXI2Events(Display *dpy, int deviceid, Window win, ...);
void SelectXI2Events(Display *dpy, int deviceid, Window win,
const std::vector<int>& evtypes);
#endif
......@@ -121,8 +121,7 @@ TEST_F(libXiTest, SerialNumberNotGarbage)
/* XIDeviceEvent */
SelectXI2Events(dpy, VIRTUAL_CORE_POINTER_ID, DefaultRootWindow(dpy),
XI_Motion, -1);
SelectXI2Events(dpy, VIRTUAL_CORE_POINTER_ID, DefaultRootWindow(dpy), { XI_Motion });
Dev(0).RelMotion(-1, 0);
Dev(0).RelMotion(-1, 0);
......@@ -139,8 +138,7 @@ TEST_F(libXiTest, SerialNumberNotGarbage)
/* XIRawEvent */
XSync(dpy, True);
SelectXI2Events(dpy, VIRTUAL_CORE_POINTER_ID, DefaultRootWindow(dpy),
XI_RawMotion, -1);
SelectXI2Events(dpy, VIRTUAL_CORE_POINTER_ID, DefaultRootWindow(dpy), { XI_RawMotion });
Dev(0).RelMotion(-1, 0);
Dev(0).RelMotion(-1, 0);
......@@ -160,7 +158,7 @@ TEST_F(libXiTest, SerialNumberNotGarbage)
/* XIPropertyEvent, XIHierarchyEvent */
XSync(dpy, True);
SelectXI2Events(dpy, XIAllDevices, DefaultRootWindow(dpy),
XI_HierarchyChanged, XI_PropertyEvent, -1);
{ XI_HierarchyChanged, XI_PropertyEvent });
int deviceid;
FindInputDeviceByName(dpy, "--device--", &deviceid);
......
......@@ -927,10 +927,7 @@ TEST_F(TouchGrabTest, ActivePointerGrabOverPointerSelection)
Window win = CreateWindow(dpy1, DefaultRootWindow(dpy1));
SelectXI2Events(dpy1, XIAllMasterDevices, win,
XI_ButtonPress,
XI_ButtonRelease,
XI_Motion,
-1);
{ XI_ButtonPress, XI_ButtonRelease, XI_Motion });
GrabPointer(dpy2, VIRTUAL_CORE_POINTER_ID, win);
TouchDev().TouchBegin(200, 200, 0);
......@@ -1266,12 +1263,7 @@ TEST_F(TouchGrabTestOnLegacyClient, ActivePointerGrabUngrabDuringTouch)
Window win = CreateWindow(dpy, DefaultRootWindow(dpy));
SelectXI2Events(dpy, XIAllMasterDevices, win,
XI_ButtonPress,
XI_ButtonRelease,
XI_Enter,
XI_Leave,
XI_Motion,
-1);
{ XI_ButtonPress, XI_ButtonRelease, XI_Enter, XI_Leave, XI_Motion });
TouchDev().TouchBegin(200, 200, 0);
TouchDev().TouchUpdate(202, 202, 0);
......
......@@ -270,7 +270,7 @@ TEST_P(SmoothScrollingTest, SmoothScrolling)
}
SelectXI2Events(dpy, VIRTUAL_CORE_POINTER_ID, DefaultRootWindow(dpy),
XI_ButtonPress, XI_ButtonRelease, XI_Motion, -1);
{ XI_ButtonPress, XI_ButtonRelease, XI_Motion });
xorg::testing::inputtest::Valuators valuators;
valuators.Set(axis, scroll_amount);
......@@ -349,7 +349,7 @@ TEST_P(SmoothScrollingTest, SmoothScrollingButtonInverted)
}
SelectXI2Events(dpy, VIRTUAL_CORE_POINTER_ID, DefaultRootWindow(dpy),
XI_ButtonPress, XI_ButtonRelease, XI_Motion, -1);
{ XI_ButtonPress, XI_ButtonRelease, XI_Motion });
xorg::testing::inputtest::Valuators valuators;
valuators.Set(axis, scroll_amount);
......@@ -1090,8 +1090,7 @@ TEST_F(KeyboardTest, FocusTestAttachedSlave)
Window win = CreateWindow(dpy, None, 0, 0, 10, 10);
XISetFocus(dpy, VIRTUAL_CORE_KEYBOARD_ID, win, CurrentTime);
SelectXI2Events(dpy, VIRTUAL_CORE_KEYBOARD_ID, win,
XI_KeyPress, XI_KeyRelease, -1);
SelectXI2Events(dpy, VIRTUAL_CORE_KEYBOARD_ID, win, { XI_KeyPress, XI_KeyRelease });
Dev(0).KeyDown(KEY_A);
Dev(0).KeyUp(KEY_A);
......@@ -1121,8 +1120,7 @@ TEST_F(KeyboardTest, FocusTestAttachedSlaveSeparateFocus)
ASSERT_TRUE(FindInputDeviceByName(dpy, "--device-kbd--", &deviceid));
Window win = CreateWindow(dpy, None, 0, 0, 10, 10);
SelectXI2Events(dpy, deviceid, win,
XI_KeyPress, XI_KeyRelease, -1);
SelectXI2Events(dpy, deviceid, win, { XI_KeyPress, XI_KeyRelease });
Dev(0).KeyDown(KEY_A);
Dev(0).KeyUp(KEY_A);
......@@ -1165,8 +1163,7 @@ TEST_F(KeyboardTest, FocusTestFloatingSlave)
Window win = CreateWindow(dpy, None, 0, 0, 10, 10);
XISetFocus(dpy, VIRTUAL_CORE_KEYBOARD_ID, win, CurrentTime);
SelectXI2Events(dpy, deviceid, win,
XI_KeyPress, XI_KeyRelease, -1);
SelectXI2Events(dpy, deviceid, win, { XI_KeyPress, XI_KeyRelease });
Dev(0).KeyDown(KEY_A);
Dev(0).KeyUp(KEY_A);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment