Commit afea3dd0cda56691072167fab52e551d9c034b44

Ran Benita 2018-01-27T20:42:44

test/interactive-wayland: replace tabs with spaces Match the style of all other files. Signed-off-by: Ran Benita <ran234@gmail.com>

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
diff --git a/test/interactive-wayland.c b/test/interactive-wayland.c
index 95775b4..f9bcc3d 100644
--- a/test/interactive-wayland.c
+++ b/test/interactive-wayland.c
@@ -38,35 +38,35 @@
 #include <wayland-util.h>
 
 struct interactive_dpy {
-	struct wl_display *dpy;
-	struct wl_compositor *compositor;
-	struct zxdg_shell_v6 *shell;
-	struct wl_shm *shm;
-	uint32_t shm_format;
+    struct wl_display *dpy;
+    struct wl_compositor *compositor;
+    struct zxdg_shell_v6 *shell;
+    struct wl_shm *shm;
+    uint32_t shm_format;
 
-	struct xkb_context *ctx;
+    struct xkb_context *ctx;
 
-	struct wl_surface *wl_surf;
-	struct zxdg_surface_v6 *xdg_surf;
-	struct zxdg_toplevel_v6 *xdg_top;
+    struct wl_surface *wl_surf;
+    struct zxdg_surface_v6 *xdg_surf;
+    struct zxdg_toplevel_v6 *xdg_top;
 
-	struct wl_list seats;
+    struct wl_list seats;
 };
 
 struct interactive_seat {
-	struct interactive_dpy *inter;
+    struct interactive_dpy *inter;
 
-	struct wl_seat *wl_seat;
-	struct wl_keyboard *wl_kbd;
-	struct wl_pointer *wl_pointer;
-	uint32_t version; /* ... of wl_seat */
-	uint32_t global_name; /* an ID of sorts */
-	char *name_str; /* a descriptor */
+    struct wl_seat *wl_seat;
+    struct wl_keyboard *wl_kbd;
+    struct wl_pointer *wl_pointer;
+    uint32_t version; /* ... of wl_seat */
+    uint32_t global_name; /* an ID of sorts */
+    char *name_str; /* a descriptor */
 
-	struct xkb_keymap *keymap;
-	struct xkb_state *state;
+    struct xkb_keymap *keymap;
+    struct xkb_state *state;
 
-	struct wl_list link;
+    struct wl_list link;
 };
 
 static bool terminate;
@@ -75,10 +75,10 @@ static bool terminate;
 static int
 create_tmpfile_cloexec(char *tmpname)
 {
-	int fd = mkostemp(tmpname, O_CLOEXEC);
-	if (fd >= 0)
-		unlink(tmpname);
-	return fd;
+    int fd = mkostemp(tmpname, O_CLOEXEC);
+    if (fd >= 0)
+        unlink(tmpname);
+    return fd;
 }
 #else
 /* The following utility functions are taken from Weston's
@@ -86,40 +86,40 @@ create_tmpfile_cloexec(char *tmpname)
 static int
 os_fd_set_cloexec(int fd)
 {
-	long flags;
+    long flags;
 
-	if (fd == -1)
-		return -1;
+    if (fd == -1)
+        return -1;
 
-	flags = fcntl(fd, F_GETFD);
-	if (flags == -1)
-		return -1;
+    flags = fcntl(fd, F_GETFD);
+    if (flags == -1)
+        return -1;
 
-	if (fcntl(fd, F_SETFD, flags | FD_CLOEXEC) == -1)
-		return -1;
+    if (fcntl(fd, F_SETFD, flags | FD_CLOEXEC) == -1)
+        return -1;
 
-	return 0;
+    return 0;
 }
 
 static int
 set_cloexec_or_close(int fd)
 {
-	if (os_fd_set_cloexec(fd) != 0) {
-		close(fd);
-		return -1;
-	}
-	return fd;
+    if (os_fd_set_cloexec(fd) != 0) {
+        close(fd);
+        return -1;
+    }
+    return fd;
 }
 
 static int
 create_tmpfile_cloexec(char *tmpname)
 {
-	int fd = mkstemp(tmpname);
-	if (fd >= 0) {
-		fd = set_cloexec_or_close(fd);
-		unlink(tmpname);
-	}
-	return fd;
+    int fd = mkstemp(tmpname);
+    if (fd >= 0) {
+        fd = set_cloexec_or_close(fd);
+        unlink(tmpname);
+    }
+    return fd;
 }
 #endif
 
@@ -147,210 +147,210 @@ create_tmpfile_cloexec(char *tmpname)
 static int
 os_create_anonymous_file(off_t size)
 {
-	static const char template[] = "/weston-shared-XXXXXX";
-	const char *path;
-	char *name;
-	int fd;
-	int ret;
+    static const char template[] = "/weston-shared-XXXXXX";
+    const char *path;
+    char *name;
+    int fd;
+    int ret;
 
-	path = getenv("XDG_RUNTIME_DIR");
-	if (!path) {
-		errno = ENOENT;
-		return -1;
-	}
+    path = getenv("XDG_RUNTIME_DIR");
+    if (!path) {
+        errno = ENOENT;
+        return -1;
+    }
 
-	name = malloc(strlen(path) + sizeof(template));
-	if (!name)
-		return -1;
+    name = malloc(strlen(path) + sizeof(template));
+    if (!name)
+        return -1;
 
-	strcpy(name, path);
-	strcat(name, template);
+    strcpy(name, path);
+    strcat(name, template);
 
-	fd = create_tmpfile_cloexec(name);
+    fd = create_tmpfile_cloexec(name);
 
-	free(name);
+    free(name);
 
-	if (fd < 0)
-		return -1;
+    if (fd < 0)
+        return -1;
 
 #ifdef HAVE_POSIX_FALLOCATE
-	ret = posix_fallocate(fd, 0, size);
-	if (ret != 0) {
-		close(fd);
-		errno = ret;
-		return -1;
-	}
+    ret = posix_fallocate(fd, 0, size);
+    if (ret != 0) {
+        close(fd);
+        errno = ret;
+        return -1;
+    }
 #else
-	ret = ftruncate(fd, size);
-	if (ret < 0) {
-		close(fd);
-		return -1;
-	}
+    ret = ftruncate(fd, size);
+    if (ret < 0) {
+        close(fd);
+        return -1;
+    }
 #endif
 
-	return fd;
+    return fd;
 }
 
 static void
 buffer_release(void *data, struct wl_buffer *buffer)
 {
-	wl_buffer_destroy(buffer);
+    wl_buffer_destroy(buffer);
 }
 
 static const struct wl_buffer_listener buffer_listener = {
-	buffer_release
+    buffer_release
 };
 
 static void
 buffer_create(struct interactive_dpy *inter, uint32_t width, uint32_t height)
 {
-	struct wl_shm_pool *pool;
-	struct wl_buffer *buf;
-	struct wl_region *opaque;
-	uint32_t stride;
-	size_t size;
-	void *map;
-	int fd;
-
-	switch (inter->shm_format) {
-	case WL_SHM_FORMAT_ARGB8888:
-	case WL_SHM_FORMAT_XRGB8888:
-	case WL_SHM_FORMAT_ABGR8888:
-	case WL_SHM_FORMAT_XBGR8888:
-		stride = width * 4;
-		break;
-	case WL_SHM_FORMAT_RGB565:
-	case WL_SHM_FORMAT_BGR565:
-		stride = width * 2;
-		break;
-        default:
-		fprintf(stderr, "Unsupported SHM format %d\n", inter->shm_format);
-		exit(1);
-	}
-
-	size = stride * height;
-	fd = os_create_anonymous_file(size);
-	if (fd < 0) {
-		fprintf(stderr, "Couldn't create surface buffer\n");
-		exit(1);
-	}
-
-	map = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
-	if (map == MAP_FAILED) {
-		fprintf(stderr, "Couldn't mmap surface buffer\n");
-		exit(1);
-	}
-	memset(map, 0xff, size);
-	munmap(map, size);
-
-	pool = wl_shm_create_pool(inter->shm, fd, size);
-	buf = wl_shm_pool_create_buffer(pool, 0, width, height, stride,
-	                                inter->shm_format);
-	wl_buffer_add_listener(buf, &buffer_listener, inter);
-
-	wl_surface_attach(inter->wl_surf, buf, 0, 0);
-	wl_surface_damage(inter->wl_surf, 0, 0, width, height);
-
-	opaque = wl_compositor_create_region(inter->compositor);
-	wl_region_add(opaque, 0, 0, width, height);
-	wl_surface_set_opaque_region(inter->wl_surf, opaque);
-	wl_region_destroy(opaque);
-
-	wl_shm_pool_destroy(pool);
-	close(fd);
+    struct wl_shm_pool *pool;
+    struct wl_buffer *buf;
+    struct wl_region *opaque;
+    uint32_t stride;
+    size_t size;
+    void *map;
+    int fd;
+
+    switch (inter->shm_format) {
+    case WL_SHM_FORMAT_ARGB8888:
+    case WL_SHM_FORMAT_XRGB8888:
+    case WL_SHM_FORMAT_ABGR8888:
+    case WL_SHM_FORMAT_XBGR8888:
+        stride = width * 4;
+        break;
+    case WL_SHM_FORMAT_RGB565:
+    case WL_SHM_FORMAT_BGR565:
+        stride = width * 2;
+        break;
+    default:
+        fprintf(stderr, "Unsupported SHM format %d\n", inter->shm_format);
+        exit(1);
+    }
+
+    size = stride * height;
+    fd = os_create_anonymous_file(size);
+    if (fd < 0) {
+        fprintf(stderr, "Couldn't create surface buffer\n");
+        exit(1);
+    }
+
+    map = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
+    if (map == MAP_FAILED) {
+        fprintf(stderr, "Couldn't mmap surface buffer\n");
+        exit(1);
+    }
+    memset(map, 0xff, size);
+    munmap(map, size);
+
+    pool = wl_shm_create_pool(inter->shm, fd, size);
+    buf = wl_shm_pool_create_buffer(pool, 0, width, height, stride,
+                                    inter->shm_format);
+    wl_buffer_add_listener(buf, &buffer_listener, inter);
+
+    wl_surface_attach(inter->wl_surf, buf, 0, 0);
+    wl_surface_damage(inter->wl_surf, 0, 0, width, height);
+
+    opaque = wl_compositor_create_region(inter->compositor);
+    wl_region_add(opaque, 0, 0, width, height);
+    wl_surface_set_opaque_region(inter->wl_surf, opaque);
+    wl_region_destroy(opaque);
+
+    wl_shm_pool_destroy(pool);
+    close(fd);
 }
 
 static void
 surface_configure(void *data, struct zxdg_surface_v6 *surface,
-		  uint32_t serial)
+                  uint32_t serial)
 {
-	struct interactive_dpy *inter = data;
+    struct interactive_dpy *inter = data;
 
-	zxdg_surface_v6_ack_configure(inter->xdg_surf, serial);
-	wl_surface_commit(inter->wl_surf);
+    zxdg_surface_v6_ack_configure(inter->xdg_surf, serial);
+    wl_surface_commit(inter->wl_surf);
 }
 
 static const struct zxdg_surface_v6_listener surface_listener = {
-	surface_configure,
+    surface_configure,
 };
 
 static void
 toplevel_configure(void *data, struct zxdg_toplevel_v6 *toplevel,
-		   int32_t width, int32_t height, struct wl_array *states)
+                   int32_t width, int32_t height, struct wl_array *states)
 {
-	struct interactive_dpy *inter = data;
+    struct interactive_dpy *inter = data;
 
-	if (width == 0)
-		width = 200;
-	if (height == 0)
-		height = 200;
+    if (width == 0)
+        width = 200;
+    if (height == 0)
+        height = 200;
 
-	buffer_create(inter, width, height);
+    buffer_create(inter, width, height);
 }
 
 static void
 toplevel_close(void *data, struct zxdg_toplevel_v6 *toplevel)
 {
-	terminate = true;
+    terminate = true;
 }
 
 static const struct zxdg_toplevel_v6_listener toplevel_listener = {
-	toplevel_configure,
-	toplevel_close
+    toplevel_configure,
+    toplevel_close
 };
 
 static void surface_create(struct interactive_dpy *inter)
 {
-	inter->wl_surf = wl_compositor_create_surface(inter->compositor);
-	inter->xdg_surf = zxdg_shell_v6_get_xdg_surface(inter->shell,
-	                                                inter->wl_surf);
-	zxdg_surface_v6_add_listener(inter->xdg_surf, &surface_listener, inter);
-	inter->xdg_top = zxdg_surface_v6_get_toplevel(inter->xdg_surf);
-	zxdg_toplevel_v6_add_listener(inter->xdg_top, &toplevel_listener, inter);
-	zxdg_toplevel_v6_set_title(inter->xdg_top, "xkbcommon event tester");
-	zxdg_toplevel_v6_set_app_id(inter->xdg_top,
-				    "org.xkbcommon.test.interactive-wayland");
-	wl_surface_commit(inter->wl_surf);
+    inter->wl_surf = wl_compositor_create_surface(inter->compositor);
+    inter->xdg_surf = zxdg_shell_v6_get_xdg_surface(inter->shell,
+                                                    inter->wl_surf);
+    zxdg_surface_v6_add_listener(inter->xdg_surf, &surface_listener, inter);
+    inter->xdg_top = zxdg_surface_v6_get_toplevel(inter->xdg_surf);
+    zxdg_toplevel_v6_add_listener(inter->xdg_top, &toplevel_listener, inter);
+    zxdg_toplevel_v6_set_title(inter->xdg_top, "xkbcommon event tester");
+    zxdg_toplevel_v6_set_app_id(inter->xdg_top,
+                                "org.xkbcommon.test.interactive-wayland");
+    wl_surface_commit(inter->wl_surf);
 }
 
 static void
 shell_ping(void *data, struct zxdg_shell_v6 *shell, uint32_t serial)
 {
-	zxdg_shell_v6_pong(shell, serial);
+    zxdg_shell_v6_pong(shell, serial);
 }
 
 static const struct zxdg_shell_v6_listener shell_listener = {
-	shell_ping
+    shell_ping
 };
 
 static void
 kbd_keymap(void *data, struct wl_keyboard *wl_kbd, uint32_t format,
            int fd, uint32_t size)
 {
-	struct interactive_seat *seat = data;
-	void *buf;
+    struct interactive_seat *seat = data;
+    void *buf;
 
-	buf = mmap(NULL, size, PROT_READ, MAP_SHARED, fd, 0);
-	if (buf == MAP_FAILED) {
-		fprintf(stderr, "Failed to mmap keymap: %d\n", errno);
-		close(fd);
-		return;
-	}
+    buf = mmap(NULL, size, PROT_READ, MAP_SHARED, fd, 0);
+    if (buf == MAP_FAILED) {
+        fprintf(stderr, "Failed to mmap keymap: %d\n", errno);
+        close(fd);
+        return;
+    }
 
-	seat->keymap = xkb_keymap_new_from_buffer(seat->inter->ctx, buf, size - 1,
-	                                          XKB_KEYMAP_FORMAT_TEXT_V1, 0);
-	munmap(buf, size);
-	close(fd);
-	if (!seat->keymap) {
-		fprintf(stderr, "Failed to compile keymap!\n");
-		return;
-	}
+    seat->keymap = xkb_keymap_new_from_buffer(seat->inter->ctx, buf, size - 1,
+                                              XKB_KEYMAP_FORMAT_TEXT_V1, 0);
+    munmap(buf, size);
+    close(fd);
+    if (!seat->keymap) {
+        fprintf(stderr, "Failed to compile keymap!\n");
+        return;
+    }
 
-	seat->state = xkb_state_new(seat->keymap);
-	if (!seat->state) {
-		fprintf(stderr, "Failed to create XKB state!\n");
-		return;
-	}
+    seat->state = xkb_state_new(seat->keymap);
+    if (!seat->state) {
+        fprintf(stderr, "Failed to create XKB state!\n");
+        return;
+    }
 }
 
 static void
@@ -369,29 +369,29 @@ static void
 kbd_key(void *data, struct wl_keyboard *wl_kbd, uint32_t serial, uint32_t time,
         uint32_t key, uint32_t state)
 {
-	struct interactive_seat *seat = data;
+    struct interactive_seat *seat = data;
 
-	if (state != WL_KEYBOARD_KEY_STATE_PRESSED)
-		return;
+    if (state != WL_KEYBOARD_KEY_STATE_PRESSED)
+        return;
 
-	printf("%s: ", seat->name_str);
-	test_print_keycode_state(seat->state, NULL, key + 8,
-                                 XKB_CONSUMED_MODE_XKB);
+    printf("%s: ", seat->name_str);
+    test_print_keycode_state(seat->state, NULL, key + 8,
+                             XKB_CONSUMED_MODE_XKB);
 
-	/* Exit on ESC. */
-	if (xkb_state_key_get_one_sym(seat->state, key + 8) == XKB_KEY_Escape)
-		terminate = true;
+    /* Exit on ESC. */
+    if (xkb_state_key_get_one_sym(seat->state, key + 8) == XKB_KEY_Escape)
+        terminate = true;
 }
 
 static void
 kbd_modifiers(void *data, struct wl_keyboard *wl_kbd, uint32_t serial,
-	      uint32_t mods_depressed, uint32_t mods_latched,
-	      uint32_t mods_locked, uint32_t group)
+              uint32_t mods_depressed, uint32_t mods_latched,
+              uint32_t mods_locked, uint32_t group)
 {
-	struct interactive_seat *seat = data;
+    struct interactive_seat *seat = data;
 
-	xkb_state_update_mask(seat->state, mods_depressed, mods_latched,
-	                      mods_locked, 0, 0, group);
+    xkb_state_update_mask(seat->state, mods_depressed, mods_latched,
+                          mods_locked, 0, 0, group);
 }
 
 static void
@@ -401,12 +401,12 @@ kbd_repeat_info(void *data, struct wl_keyboard *wl_kbd, int32_t rate,
 }
 
 static const struct wl_keyboard_listener kbd_listener = {
-	kbd_keymap,
-	kbd_enter,
-	kbd_leave,
-	kbd_key,
-	kbd_modifiers,
-	kbd_repeat_info
+    kbd_keymap,
+    kbd_enter,
+    kbd_leave,
+    kbd_key,
+    kbd_modifiers,
+    kbd_repeat_info
 };
 
 static void
@@ -431,9 +431,9 @@ static void
 pointer_button(void *data, struct wl_pointer *wl_pointer, uint32_t serial,
                uint32_t time, uint32_t button, uint32_t state)
 {
-	struct interactive_seat *seat = data;
+    struct interactive_seat *seat = data;
 
-	zxdg_toplevel_v6_move(seat->inter->xdg_top, seat->wl_seat, serial);
+    zxdg_toplevel_v6_move(seat->inter->xdg_top, seat->wl_seat, serial);
 }
 
 static void
@@ -465,246 +465,246 @@ pointer_axis_discrete(void *data, struct wl_pointer *wl_pointer, uint32_t time,
 }
 
 static const struct wl_pointer_listener pointer_listener = {
-	pointer_enter,
-	pointer_leave,
-	pointer_motion,
-	pointer_button,
-	pointer_axis,
-	pointer_frame,
-	pointer_axis_source,
-	pointer_axis_stop,
-	pointer_axis_discrete
+    pointer_enter,
+    pointer_leave,
+    pointer_motion,
+    pointer_button,
+    pointer_axis,
+    pointer_frame,
+    pointer_axis_source,
+    pointer_axis_stop,
+    pointer_axis_discrete
 };
 
 static void
 seat_capabilities(void *data, struct wl_seat *wl_seat, uint32_t caps)
 {
-	struct interactive_seat *seat = data;
-
-	if (!seat->wl_kbd && (caps & WL_SEAT_CAPABILITY_KEYBOARD)) {
-		seat->wl_kbd = wl_seat_get_keyboard(seat->wl_seat);
-		wl_keyboard_add_listener(seat->wl_kbd, &kbd_listener, seat);
-	}
-	else if (seat->wl_kbd && !(caps & WL_SEAT_CAPABILITY_KEYBOARD)) {
-		if (seat->version >= WL_SEAT_RELEASE_SINCE_VERSION)
-			wl_keyboard_release(seat->wl_kbd);
-		else
-			wl_keyboard_destroy(seat->wl_kbd);
-
-		xkb_state_unref(seat->state);
-		xkb_keymap_unref(seat->keymap);
-
-		seat->state = NULL;
-		seat->keymap = NULL;
-		seat->wl_kbd = NULL;
-	}
-
-	if (!seat->wl_pointer && (caps & WL_SEAT_CAPABILITY_POINTER)) {
-		seat->wl_pointer = wl_seat_get_pointer(seat->wl_seat);
-		wl_pointer_add_listener(seat->wl_pointer, &pointer_listener,
-		                        seat);
-	}
-	else if (seat->wl_pointer && !(caps & WL_SEAT_CAPABILITY_POINTER)) {
-		if (seat->version >= WL_SEAT_RELEASE_SINCE_VERSION)
-			wl_pointer_release(seat->wl_pointer);
-		else
-			wl_pointer_destroy(seat->wl_pointer);
-		seat->wl_pointer = NULL;
-	}
+    struct interactive_seat *seat = data;
+
+    if (!seat->wl_kbd && (caps & WL_SEAT_CAPABILITY_KEYBOARD)) {
+        seat->wl_kbd = wl_seat_get_keyboard(seat->wl_seat);
+        wl_keyboard_add_listener(seat->wl_kbd, &kbd_listener, seat);
+    }
+    else if (seat->wl_kbd && !(caps & WL_SEAT_CAPABILITY_KEYBOARD)) {
+        if (seat->version >= WL_SEAT_RELEASE_SINCE_VERSION)
+            wl_keyboard_release(seat->wl_kbd);
+        else
+            wl_keyboard_destroy(seat->wl_kbd);
+
+        xkb_state_unref(seat->state);
+        xkb_keymap_unref(seat->keymap);
+
+        seat->state = NULL;
+        seat->keymap = NULL;
+        seat->wl_kbd = NULL;
+    }
+
+    if (!seat->wl_pointer && (caps & WL_SEAT_CAPABILITY_POINTER)) {
+        seat->wl_pointer = wl_seat_get_pointer(seat->wl_seat);
+        wl_pointer_add_listener(seat->wl_pointer, &pointer_listener,
+                                seat);
+    }
+    else if (seat->wl_pointer && !(caps & WL_SEAT_CAPABILITY_POINTER)) {
+        if (seat->version >= WL_SEAT_RELEASE_SINCE_VERSION)
+            wl_pointer_release(seat->wl_pointer);
+        else
+            wl_pointer_destroy(seat->wl_pointer);
+        seat->wl_pointer = NULL;
+    }
 }
 
 static void
 seat_name(void *data, struct wl_seat *wl_seat, const char *name)
 {
-	struct interactive_seat *seat = data;
+    struct interactive_seat *seat = data;
 
-	free(seat->name_str);
-	seat->name_str = strdup(name);
+    free(seat->name_str);
+    seat->name_str = strdup(name);
 }
 
 static const struct wl_seat_listener seat_listener = {
-	seat_capabilities,
-	seat_name
+    seat_capabilities,
+    seat_name
 };
 
 static void
 seat_create(struct interactive_dpy *inter, struct wl_registry *registry,
             uint32_t name, uint32_t version)
 {
-	int ret;
-	struct interactive_seat *seat = calloc(1, sizeof(*seat));
+    int ret;
+    struct interactive_seat *seat = calloc(1, sizeof(*seat));
 
-	seat->global_name = name;
-	seat->inter = inter;
-	seat->wl_seat = wl_registry_bind(registry, name, &wl_seat_interface,
-	                                 MAX(version, 5));
-	wl_seat_add_listener(seat->wl_seat, &seat_listener, seat);
-	ret = asprintf(&seat->name_str, "seat:%d",
-		       wl_proxy_get_id((struct wl_proxy *) seat->wl_seat));
-	assert(ret >= 0);
-	wl_list_insert(&inter->seats, &seat->link);
+    seat->global_name = name;
+    seat->inter = inter;
+    seat->wl_seat = wl_registry_bind(registry, name, &wl_seat_interface,
+                                     MAX(version, 5));
+    wl_seat_add_listener(seat->wl_seat, &seat_listener, seat);
+    ret = asprintf(&seat->name_str, "seat:%d",
+                   wl_proxy_get_id((struct wl_proxy *) seat->wl_seat));
+    assert(ret >= 0);
+    wl_list_insert(&inter->seats, &seat->link);
 }
 
 static void
 seat_destroy(struct interactive_seat *seat)
 {
-	if (seat->wl_kbd) {
-		if (seat->version >= WL_SEAT_RELEASE_SINCE_VERSION)
-			wl_keyboard_release(seat->wl_kbd);
-		else
-			wl_keyboard_destroy(seat->wl_kbd);
+    if (seat->wl_kbd) {
+        if (seat->version >= WL_SEAT_RELEASE_SINCE_VERSION)
+            wl_keyboard_release(seat->wl_kbd);
+        else
+            wl_keyboard_destroy(seat->wl_kbd);
 
-		xkb_state_unref(seat->state);
-		xkb_keymap_unref(seat->keymap);
-	}
+        xkb_state_unref(seat->state);
+        xkb_keymap_unref(seat->keymap);
+    }
 
-	if (seat->wl_pointer) {
-		if (seat->version >= WL_SEAT_RELEASE_SINCE_VERSION)
-			wl_pointer_release(seat->wl_pointer);
-		else
-			wl_pointer_destroy(seat->wl_pointer);
-	}
+    if (seat->wl_pointer) {
+        if (seat->version >= WL_SEAT_RELEASE_SINCE_VERSION)
+            wl_pointer_release(seat->wl_pointer);
+        else
+            wl_pointer_destroy(seat->wl_pointer);
+    }
 
-	if (seat->version >= WL_SEAT_RELEASE_SINCE_VERSION)
-		wl_seat_release(seat->wl_seat);
-	else
-		wl_seat_destroy(seat->wl_seat);
+    if (seat->version >= WL_SEAT_RELEASE_SINCE_VERSION)
+        wl_seat_release(seat->wl_seat);
+    else
+        wl_seat_destroy(seat->wl_seat);
 
-	free(seat->name_str);
-	wl_list_remove(&seat->link);
-	free(seat);
+    free(seat->name_str);
+    wl_list_remove(&seat->link);
+    free(seat);
 }
 
 static void
 registry_global(void *data, struct wl_registry *registry, uint32_t name,
-		const char *interface, uint32_t version)
-{
-	struct interactive_dpy *inter = data;
-
-	if (strcmp(interface, "wl_seat") == 0) {
-		seat_create(inter, registry, name, version);
-	}
-	else if (strcmp(interface, "zxdg_shell_v6") == 0) {
-		inter->shell = wl_registry_bind(registry, name,
-		                                &zxdg_shell_v6_interface,
-		                                MAX(version, 1));
-		zxdg_shell_v6_add_listener(inter->shell, &shell_listener, inter);
-	}
-	else if (strcmp(interface, "wl_compositor") == 0) {
-		inter->compositor = wl_registry_bind(registry, name,
-		                                     &wl_compositor_interface,
-						     MAX(version, 1));
-	}
-	else if (strcmp(interface, "wl_shm") == 0) {
-		inter->shm = wl_registry_bind(registry, name, &wl_shm_interface,
-                                              MAX(version, 1));
-	}
+                const char *interface, uint32_t version)
+{
+    struct interactive_dpy *inter = data;
+
+    if (strcmp(interface, "wl_seat") == 0) {
+        seat_create(inter, registry, name, version);
+    }
+    else if (strcmp(interface, "zxdg_shell_v6") == 0) {
+        inter->shell = wl_registry_bind(registry, name,
+                                        &zxdg_shell_v6_interface,
+                                        MAX(version, 1));
+        zxdg_shell_v6_add_listener(inter->shell, &shell_listener, inter);
+    }
+    else if (strcmp(interface, "wl_compositor") == 0) {
+        inter->compositor = wl_registry_bind(registry, name,
+                                             &wl_compositor_interface,
+                                             MAX(version, 1));
+    }
+    else if (strcmp(interface, "wl_shm") == 0) {
+        inter->shm = wl_registry_bind(registry, name, &wl_shm_interface,
+                                      MAX(version, 1));
+    }
 }
 
 static void
 registry_delete(void *data, struct wl_registry *registry, uint32_t name)
 {
-	struct interactive_dpy *inter = data;
-	struct interactive_seat *seat, *tmp;
+    struct interactive_dpy *inter = data;
+    struct interactive_seat *seat, *tmp;
 
-	wl_list_for_each_safe(seat, tmp, &inter->seats, link) {
-		if (seat->global_name != name)
-			continue;
+    wl_list_for_each_safe(seat, tmp, &inter->seats, link) {
+        if (seat->global_name != name)
+            continue;
 
-		seat_destroy(seat);
-	}
+        seat_destroy(seat);
+    }
 }
 
 static const struct wl_registry_listener registry_listener = {
-	registry_global,
-	registry_delete
+    registry_global,
+    registry_delete
 };
 
 static void
 dpy_disconnect(struct interactive_dpy *inter)
 {
-	struct interactive_seat *seat, *tmp;
+    struct interactive_seat *seat, *tmp;
 
-	wl_list_for_each_safe(seat, tmp, &inter->seats, link)
-		seat_destroy(seat);
+    wl_list_for_each_safe(seat, tmp, &inter->seats, link)
+        seat_destroy(seat);
 
-	if (inter->xdg_surf)
-		zxdg_surface_v6_destroy(inter->xdg_surf);
-	if (inter->xdg_top)
-		zxdg_toplevel_v6_destroy(inter->xdg_top);
-	if (inter->wl_surf)
-		wl_surface_destroy(inter->wl_surf);
-	if (inter->shell)
-		zxdg_shell_v6_destroy(inter->shell);
-	if (inter->compositor)
-		wl_compositor_destroy(inter->compositor);
-	if (inter->shm)
-		wl_shm_destroy(inter->shm);
+    if (inter->xdg_surf)
+        zxdg_surface_v6_destroy(inter->xdg_surf);
+    if (inter->xdg_top)
+        zxdg_toplevel_v6_destroy(inter->xdg_top);
+    if (inter->wl_surf)
+        wl_surface_destroy(inter->wl_surf);
+    if (inter->shell)
+        zxdg_shell_v6_destroy(inter->shell);
+    if (inter->compositor)
+        wl_compositor_destroy(inter->compositor);
+    if (inter->shm)
+        wl_shm_destroy(inter->shm);
 
-	/* Do one last roundtrip to try to destroy our wl_buffer. */
-	wl_display_roundtrip(inter->dpy);
+    /* Do one last roundtrip to try to destroy our wl_buffer. */
+    wl_display_roundtrip(inter->dpy);
 
-	xkb_context_unref(inter->ctx);
-	wl_display_disconnect(inter->dpy);
+    xkb_context_unref(inter->ctx);
+    wl_display_disconnect(inter->dpy);
 }
 
 int
 main(int argc, char *argv[])
 {
-	int ret;
-	struct interactive_dpy inter;
-	struct wl_registry *registry;
-
-	setlocale(LC_ALL, "");
-
-	memset(&inter, 0, sizeof(inter));
-	wl_list_init(&inter.seats);
-
-	inter.dpy = wl_display_connect(NULL);
-	if (!inter.dpy) {
-		fprintf(stderr, "Couldn't connect to Wayland server\n");
-		ret = -1;
-		goto err_out;
-	}
-
-	inter.ctx = test_get_context(0);
-	if (!inter.ctx) {
-		ret = -1;
-		fprintf(stderr, "Couldn't create xkb context\n");
-		goto err_out;
-	}
-
-	registry = wl_display_get_registry(inter.dpy);
-	wl_registry_add_listener(registry, &registry_listener, &inter);
-
-	/* The first roundtrip gets the list of advertised globals. */
-	wl_display_roundtrip(inter.dpy);
-
-	/* The second roundtrip dispatches the events sent after binding, e.g.
-	 * after binding to wl_seat globals in the first roundtrip, we will get
-	 * the wl_seat::capabilities event in this roundtrip. */
-	wl_display_roundtrip(inter.dpy);
-
-	if (!inter.shell || !inter.shm || !inter.compositor) {
-		fprintf(stderr, "Required Wayland interfaces %s%s%s unsupported\n",
-		        (inter.shell) ? "" : "xdg_shell ",
-			(inter.shm) ? "" : "wl_shm",
-			(inter.compositor) ? "" : "wl_compositor");
-                ret = -1;
-		goto err_conn;
-	}
-
-	surface_create(&inter);
-
-	test_disable_stdin_echo();
-	do {
-		ret = wl_display_dispatch(inter.dpy);
-	} while (ret >= 0 && !terminate);
-	test_enable_stdin_echo();
-
-	wl_registry_destroy(registry);
+    int ret;
+    struct interactive_dpy inter;
+    struct wl_registry *registry;
+
+    setlocale(LC_ALL, "");
+
+    memset(&inter, 0, sizeof(inter));
+    wl_list_init(&inter.seats);
+
+    inter.dpy = wl_display_connect(NULL);
+    if (!inter.dpy) {
+        fprintf(stderr, "Couldn't connect to Wayland server\n");
+        ret = -1;
+        goto err_out;
+    }
+
+    inter.ctx = test_get_context(0);
+    if (!inter.ctx) {
+        ret = -1;
+        fprintf(stderr, "Couldn't create xkb context\n");
+        goto err_out;
+    }
+
+    registry = wl_display_get_registry(inter.dpy);
+    wl_registry_add_listener(registry, &registry_listener, &inter);
+
+    /* The first roundtrip gets the list of advertised globals. */
+    wl_display_roundtrip(inter.dpy);
+
+    /* The second roundtrip dispatches the events sent after binding, e.g.
+     * after binding to wl_seat globals in the first roundtrip, we will get
+     * the wl_seat::capabilities event in this roundtrip. */
+    wl_display_roundtrip(inter.dpy);
+
+    if (!inter.shell || !inter.shm || !inter.compositor) {
+        fprintf(stderr, "Required Wayland interfaces %s%s%s unsupported\n",
+                (inter.shell) ? "" : "xdg_shell ",
+                (inter.shm) ? "" : "wl_shm",
+                (inter.compositor) ? "" : "wl_compositor");
+        ret = -1;
+        goto err_conn;
+    }
+
+    surface_create(&inter);
+
+    test_disable_stdin_echo();
+    do {
+        ret = wl_display_dispatch(inter.dpy);
+    } while (ret >= 0 && !terminate);
+    test_enable_stdin_echo();
+
+    wl_registry_destroy(registry);
 err_conn:
-	dpy_disconnect(&inter);
+    dpy_disconnect(&inter);
 err_out:
-	exit(ret >= 0 ? EXIT_SUCCESS : EXIT_FAILURE);
+    exit(ret >= 0 ? EXIT_SUCCESS : EXIT_FAILURE);
 }