summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPovilas Kanapickas <povilas@radix.lt>2020-12-19 22:45:43 +0200
committerPovilas Kanapickas <povilas@radix.lt>2021-01-06 01:49:41 +0000
commit54ab1574c26c783cac9878930d80a8f47800d9b7 (patch)
treeb1d59df1ada17d4a4c21987f7159b1b56bbbe5d9
parenta7301db9f4f7e62e21187ec36bbdae8ba68dcf52 (diff)
Accept list of events as a vector to SelectXI2Events
-rw-r--r--tests/common/helpers.cpp9
-rw-r--r--tests/common/helpers.h6
-rw-r--r--tests/lib/libXi.cpp8
-rw-r--r--tests/server/grab.cpp12
-rw-r--r--tests/server/input.cpp13
5 files changed, 15 insertions, 33 deletions
diff --git a/tests/common/helpers.cpp b/tests/common/helpers.cpp
index f6f35df..33fbf76 100644
--- a/tests/common/helpers.cpp
+++ b/tests/common/helpers.cpp
@@ -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);
}
diff --git a/tests/common/helpers.h b/tests/common/helpers.h
index 81aa79c..3576d93 100644
--- a/tests/common/helpers.h
+++ b/tests/common/helpers.h
@@ -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
diff --git a/tests/lib/libXi.cpp b/tests/lib/libXi.cpp
index 8212629..e6bb7fb 100644
--- a/tests/lib/libXi.cpp
+++ b/tests/lib/libXi.cpp
@@ -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);
diff --git a/tests/server/grab.cpp b/tests/server/grab.cpp
index eaf603c..367451a 100644
--- a/tests/server/grab.cpp
+++ b/tests/server/grab.cpp
@@ -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);
diff --git a/tests/server/input.cpp b/tests/server/input.cpp
index 9fd4bbd..51f7fc8 100644
--- a/tests/server/input.cpp
+++ b/tests/server/input.cpp
@@ -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);