summaryrefslogtreecommitdiff
path: root/tools/libinput-debug-gui.c
diff options
context:
space:
mode:
authorweizhixiang <weizhixiang@uniontech.com>2021-05-19 21:09:30 +0900
committerPeter Hutterer <peter.hutterer@who-t.net>2021-05-24 04:11:32 +0000
commitcce59210159e2699a4f69d4c4a601a1bbc7cecfe (patch)
treef12113ea6ec30a37a04918f5259afa8792acc277 /tools/libinput-debug-gui.c
parent0cb570addd126648cd53d54591c6c34810738092 (diff)
downloadlibinput-cce59210159e2699a4f69d4c4a601a1bbc7cecfe.tar.gz
use ARRAY_FOR_EACH when traverse array
Signed-off-by: weizhixiang <weizhixiang@uniontech.com>
Diffstat (limited to 'tools/libinput-debug-gui.c')
-rw-r--r--tools/libinput-debug-gui.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/tools/libinput-debug-gui.c b/tools/libinput-debug-gui.c
index fc5af4d8..187567a6 100644
--- a/tools/libinput-debug-gui.c
+++ b/tools/libinput-debug-gui.c
@@ -1036,10 +1036,10 @@ static void
handle_event_device_notify(struct libinput_event *ev)
{
struct libinput_device *dev = libinput_event_get_device(ev);
+ struct libinput_device **device;
struct libinput *li;
struct window *w;
const char *type;
- size_t i;
li = libinput_event_get_context(ev);
w = libinput_get_user_data(li);
@@ -1060,17 +1060,17 @@ handle_event_device_notify(struct libinput_event *ev)
type);
if (libinput_event_get_type(ev) == LIBINPUT_EVENT_DEVICE_ADDED) {
- for (i = 0; i < ARRAY_LENGTH(w->devices); i++) {
- if (w->devices[i] == NULL) {
- w->devices[i] = libinput_device_ref(dev);
+ ARRAY_FOR_EACH(w->devices, device) {
+ if (*device == NULL) {
+ *device = libinput_device_ref(dev);
break;
}
}
} else {
- for (i = 0; i < ARRAY_LENGTH(w->devices); i++) {
- if (w->devices[i] == dev) {
- libinput_device_unref(w->devices[i]);
- w->devices[i] = NULL;
+ ARRAY_FOR_EACH(w->devices, device) {
+ if (*device == dev) {
+ libinput_device_unref(*device);
+ *device = NULL;
break;
}
}