summarylogtreecommitdiffstats
path: root/4947.patch
blob: db17ead5d5a58279f789929dfb7c57ef54ca76b8 (plain)
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
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
From ee42a8156180a15b24efc9e5c2a14935befb9d1d Mon Sep 17 00:00:00 2001
From: Alexandros Frantzis <alexandros.frantzis@collabora.com>
Date: Tue, 16 Jan 2024 10:40:15 +0200
Subject: [PATCH 1/7] winewayland.drv: Advertise common display modes.

The reporting of non-current wl_output modes is deprecated, and most
compositors now report only the current display mode.

Since Wayland doesn't allow clients to directly change the hardware
display mode, we can safely make some common display modes available to
applications.
---
 dlls/winewayland.drv/wayland_output.c | 94 ++++++++++++++++++++++++---
 1 file changed, 85 insertions(+), 9 deletions(-)

diff --git a/dlls/winewayland.drv/wayland_output.c b/dlls/winewayland.drv/wayland_output.c
index f5941c10f6f..0dfc1d974e4 100644
--- a/dlls/winewayland.drv/wayland_output.c
+++ b/dlls/winewayland.drv/wayland_output.c
@@ -40,6 +40,54 @@ static uint32_t next_output_id = 0;
 #define WAYLAND_OUTPUT_CHANGED_LOGICAL_XY 0x04
 #define WAYLAND_OUTPUT_CHANGED_LOGICAL_WH 0x08
 
+static const struct { int32_t width; int32_t height; } common_modes[] = {
+    { 320,  200}, /* CGA 16:10 */
+    { 320,  240}, /* QVGA 4:3 */
+    { 400,  300}, /* qSVGA 4:3 */
+    { 480,  320}, /* HVGA 3:2 */
+    { 512,  384}, /* MAC 4:3 */
+    { 640,  360}, /* nHD 16:9 */
+    { 640,  400}, /* VESA-0100h 16:10 */
+    { 640,  480}, /* VGA 4:3 */
+    { 720,  480}, /* WVGA 3:2 */
+    { 720,  576}, /* PAL 5:4 */
+    { 768,  480}, /* WVGA 16:10 */
+    { 768,  576}, /* PAL* 4:3 */
+    { 800,  600}, /* SVGA 4:3 */
+    { 854,  480}, /* FWVGA 16:9 */
+    { 960,  540}, /* qHD 16:9 */
+    { 960,  640}, /* DVGA 3:2 */
+    {1024,  576}, /* WSVGA 16:9 */
+    {1024,  640}, /* WSVGA 16:10 */
+    {1024,  768}, /* XGA 4:3 */
+    {1152,  864}, /* XGA+ 4:3 */
+    {1280,  720}, /* HD 16:9 */
+    {1280,  768}, /* WXGA 5:3 */
+    {1280,  800}, /* WXGA 16:10 */
+    {1280,  960}, /* SXGA- 4:3 */
+    {1280, 1024}, /* SXGA 5:4 */
+    {1366,  768}, /* FWXGA 16:9 */
+    {1400, 1050}, /* SXGA+ 4:3 */
+    {1440,  900}, /* WSXGA 16:10 */
+    {1600,  900}, /* HD+ 16:9 */
+    {1600, 1200}, /* UXGA 4:3 */
+    {1680, 1050}, /* WSXGA+ 16:10 */
+    {1920, 1080}, /* FHD 16:9 */
+    {1920, 1200}, /* WUXGA 16:10 */
+    {2048, 1152}, /* QWXGA 16:9 */
+    {2048, 1536}, /* QXGA 4:3 */
+    {2560, 1440}, /* QHD 16:9 */
+    {2560, 1600}, /* WQXGA 16:10 */
+    {2560, 2048}, /* QSXGA 5:4 */
+    {2880, 1620}, /* 3K 16:9 */
+    {3200, 1800}, /* QHD+ 16:9 */
+    {3200, 2400}, /* QUXGA 4:3 */
+    {3840, 2160}, /* 4K 16:9 */
+    {3840, 2400}, /* WQUXGA 16:10 */
+    {5120, 2880}, /* 5K 16:9 */
+    {7680, 4320}, /* 8K 16:9 */
+};
+
 /**********************************************************************
  *          Output handling
  */
@@ -102,6 +150,31 @@ static void wayland_output_state_add_mode(struct wayland_output_state *state,
     if (current) state->current_mode = mode;
 }
 
+static void wayland_output_state_add_common_modes(struct wayland_output_state *state)
+{
+    int i;
+
+    for (i = 0; i < ARRAY_SIZE(common_modes); i++)
+    {
+        int32_t width = common_modes[i].width;
+        int32_t height = common_modes[i].height;
+
+        /* Skip if this mode is larger than the current (native) mode. */
+        if (width > state->current_mode->width ||
+            height > state->current_mode->height)
+        {
+            TRACE("Skipping mode %dx%d (current: %dx%d)\n",
+                  width, height, state->current_mode->width,
+                  state->current_mode->height);
+            continue;
+        }
+
+        wayland_output_state_add_mode(state, width, height,
+                                      state->current_mode->refresh,
+                                      FALSE);
+    }
+}
+
 static void maybe_init_display_devices(void)
 {
     DWORD desktop_pid = 0;
@@ -136,14 +209,15 @@ static void wayland_output_done(struct wayland_output *output)
 
     if (output->pending_flags & WAYLAND_OUTPUT_CHANGED_MODES)
     {
-        RB_FOR_EACH_ENTRY(mode, &output->pending.modes, struct wayland_output_mode, entry)
-        {
-            wayland_output_state_add_mode(&output->current,
-                                          mode->width, mode->height, mode->refresh,
-                                          mode == output->pending.current_mode);
-        }
-        rb_destroy(&output->pending.modes, wayland_output_mode_free_rb, NULL);
+        rb_destroy(&output->current.modes, wayland_output_mode_free_rb, NULL);
+        output->current.modes = output->pending.modes;
+        output->current.current_mode = output->pending.current_mode;
+        if (!output->current.current_mode)
+            WARN("No current mode reported by compositor\n");
+        else
+            wayland_output_state_add_common_modes(&output->current);
         rb_init(&output->pending.modes, wayland_output_mode_cmp_rb);
+        output->pending.current_mode = NULL;
     }
 
     if (output->pending_flags & WAYLAND_OUTPUT_CHANGED_NAME)
@@ -206,11 +280,13 @@ static void output_handle_mode(void *data, struct wl_output *wl_output,
 {
     struct wayland_output *output = data;
 
+    /* Non-current mode information is deprecated. */
+    if (!(flags & WL_OUTPUT_MODE_CURRENT)) return;
+
     /* Windows apps don't expect a zero refresh rate, so use a default value. */
     if (refresh == 0) refresh = default_refresh;
 
-    wayland_output_state_add_mode(&output->pending, width, height, refresh,
-                                  (flags & WL_OUTPUT_MODE_CURRENT));
+    wayland_output_state_add_mode(&output->pending, width, height, refresh, TRUE);
 
     output->pending_flags |= WAYLAND_OUTPUT_CHANGED_MODES;
 }
-- 
GitLab


From a5deba20bed30dcbace5d234def95fdcd17e79ec Mon Sep 17 00:00:00 2001
From: Alexandros Frantzis <alexandros.frantzis@collabora.com>
Date: Thu, 25 Jan 2024 10:41:45 +0200
Subject: [PATCH 2/7] winewayland.drv: Advertise display modes for 8 bpp and 16
 bpp.

---
 dlls/winewayland.drv/display.c | 28 ++++++++++++++++++----------
 1 file changed, 18 insertions(+), 10 deletions(-)

diff --git a/dlls/winewayland.drv/display.c b/dlls/winewayland.drv/display.c
index ebe151ffab0..a8fcaf2a2f5 100644
--- a/dlls/winewayland.drv/display.c
+++ b/dlls/winewayland.drv/display.c
@@ -246,13 +246,14 @@ static void wayland_add_device_monitor(const struct gdi_device_manager *device_m
     device_manager->add_monitor(&monitor, param);
 }
 
-static void populate_devmode(struct wayland_output_mode *output_mode, DEVMODEW *mode)
+static void populate_devmode(struct wayland_output_mode *output_mode, DWORD bpp,
+                             DEVMODEW *mode)
 {
     mode->dmFields = DM_DISPLAYORIENTATION | DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT |
                      DM_DISPLAYFLAGS | DM_DISPLAYFREQUENCY;
     mode->dmDisplayOrientation = DMDO_DEFAULT;
     mode->dmDisplayFlags = 0;
-    mode->dmBitsPerPel = 32;
+    mode->dmBitsPerPel = bpp;
     mode->dmPelsWidth = output_mode->width;
     mode->dmPelsHeight = output_mode->height;
     mode->dmDisplayFrequency = output_mode->refresh / 1000;
@@ -261,21 +262,28 @@ static void populate_devmode(struct wayland_output_mode *output_mode, DEVMODEW *
 static void wayland_add_device_modes(const struct gdi_device_manager *device_manager,
                                      void *param, struct output_info *output_info)
 {
+    static const DWORD bpps[] = {32, 16, 8};
     struct wayland_output_mode *output_mode;
+    int i;
 
     RB_FOR_EACH_ENTRY(output_mode, &output_info->output->modes,
                       struct wayland_output_mode, entry)
     {
-        DEVMODEW mode = {.dmSize = sizeof(mode)};
-        BOOL mode_is_current = output_mode == output_info->output->current_mode;
-        populate_devmode(output_mode, &mode);
-        if (mode_is_current)
+        for (i = 0; i < ARRAY_SIZE(bpps); i++)
         {
-            mode.dmFields |= DM_POSITION;
-            mode.dmPosition.x = output_info->x;
-            mode.dmPosition.y = output_info->y;
+            DEVMODEW mode = {.dmSize = sizeof(mode)};
+            BOOL mode_is_current = output_mode == output_info->output->current_mode &&
+                                   bpps[i] == 32;
+
+            populate_devmode(output_mode, bpps[i], &mode);
+            if (mode_is_current)
+            {
+                mode.dmFields |= DM_POSITION;
+                mode.dmPosition.x = output_info->x;
+                mode.dmPosition.y = output_info->y;
+            }
+            device_manager->add_mode(&mode, mode_is_current, param);
         }
-        device_manager->add_mode(&mode, mode_is_current, param);
     }
 }
 
-- 
GitLab


From bac33e2f0f91891cc508905b61c23538e224c633 Mon Sep 17 00:00:00 2001
From: Alexandros Frantzis <alexandros.frantzis@collabora.com>
Date: Fri, 26 Jan 2024 11:19:11 +0200
Subject: [PATCH 3/7] winewayland.drv: Dissociate current display mode from
 Wayland native mode.

Refactor output_info to dissociate the current display mode from the
Wayland native display mode, in preparation for handling display mode changes.
---
 dlls/winewayland.drv/display.c | 36 ++++++++++++++++++++++------------
 1 file changed, 23 insertions(+), 13 deletions(-)

diff --git a/dlls/winewayland.drv/display.c b/dlls/winewayland.drv/display.c
index a8fcaf2a2f5..888c6e5aabb 100644
--- a/dlls/winewayland.drv/display.c
+++ b/dlls/winewayland.drv/display.c
@@ -51,6 +51,8 @@ struct output_info
 {
     int x, y;
     struct wayland_output_state *output;
+    struct wayland_output_mode *mode;
+    UINT bpp;
 };
 
 static int output_info_cmp_primary_x_y(const void *va, const void *vb)
@@ -71,10 +73,10 @@ static int output_info_cmp_primary_x_y(const void *va, const void *vb)
 
 static inline BOOL output_info_overlap(struct output_info *a, struct output_info *b)
 {
-    return b->x < a->x + a->output->current_mode->width &&
-           b->x + b->output->current_mode->width > a->x &&
-           b->y < a->y + a->output->current_mode->height &&
-           b->y + b->output->current_mode->height > a->y;
+    return b->x < a->x + a->mode->width &&
+           b->x + b->mode->width > a->x &&
+           b->y < a->y + a->mode->height &&
+           b->y + b->mode->height > a->y;
 }
 
 /* Map a point to one of the four quadrants of our 2d coordinate space:
@@ -156,16 +158,16 @@ static BOOL output_info_array_resolve_overlaps(struct wl_array *output_info_arra
             rel_x = (move->output->logical_x - anchor->output->logical_x +
                      (x_use_end ? move->output->logical_w : 0)) /
                     (double)anchor->output->logical_w;
-            move->x = anchor->x + anchor->output->current_mode->width * rel_x -
-                      (x_use_end ? move->output->current_mode->width : 0);
+            move->x = anchor->x + anchor->mode->width * rel_x -
+                      (x_use_end ? move->mode->width : 0);
 
             /* Similarly for the Y axis. */
             y_use_end = move->output->logical_y < anchor->output->logical_y;
             rel_y = (move->output->logical_y - anchor->output->logical_y +
                      (y_use_end ? move->output->logical_h : 0)) /
                     (double)anchor->output->logical_h;
-            move->y = anchor->y + anchor->output->current_mode->height * rel_y -
-                      (y_use_end ? move->output->current_mode->height : 0);
+            move->y = anchor->y + anchor->mode->height * rel_y -
+                      (y_use_end ? move->mode->height : 0);
         }
     }
 
@@ -231,8 +233,8 @@ static void wayland_add_device_monitor(const struct gdi_device_manager *device_m
     struct gdi_monitor monitor = {0};
 
     SetRect(&monitor.rc_monitor, output_info->x, output_info->y,
-            output_info->x + output_info->output->current_mode->width,
-            output_info->y + output_info->output->current_mode->height);
+            output_info->x + output_info->mode->width,
+            output_info->y + output_info->mode->height);
 
     /* We don't have a direct way to get the work area in Wayland. */
     monitor.rc_work = monitor.rc_monitor;
@@ -272,8 +274,8 @@ static void wayland_add_device_modes(const struct gdi_device_manager *device_man
         for (i = 0; i < ARRAY_SIZE(bpps); i++)
         {
             DEVMODEW mode = {.dmSize = sizeof(mode)};
-            BOOL mode_is_current = output_mode == output_info->output->current_mode &&
-                                   bpps[i] == 32;
+            BOOL mode_is_current = output_mode == output_info->mode &&
+                                   bpps[i] == output_info->bpp;
 
             populate_devmode(output_mode, bpps[i], &mode);
             if (mode_is_current)
@@ -287,6 +289,14 @@ static void wayland_add_device_modes(const struct gdi_device_manager *device_man
     }
 }
 
+static void output_info_init(struct output_info *output_info,
+                             struct wayland_output *output)
+{
+    output_info->output = &output->current;
+    output_info->mode = output->current.current_mode;
+    output_info->bpp = 32;
+}
+
 /***********************************************************************
  *      UpdateDisplayDevices (WAYLAND.@)
  */
@@ -312,7 +322,7 @@ BOOL WAYLAND_UpdateDisplayDevices(const struct gdi_device_manager *device_manage
     {
         if (!output->current.current_mode) continue;
         output_info = wl_array_add(&output_info_array, sizeof(*output_info));
-        if (output_info) output_info->output = &output->current;
+        if (output_info) output_info_init(output_info, output);
         else ERR("Failed to allocate space for output_info\n");
     }
 
-- 
GitLab


From 8b38be18592fb0538efee64a46e4de9a7321d34b Mon Sep 17 00:00:00 2001
From: Alexandros Frantzis <alexandros.frantzis@collabora.com>
Date: Thu, 25 Jan 2024 12:06:54 +0200
Subject: [PATCH 4/7] winewayland.drv: Respect current device mode on display
 device updates.

Since Wayland doesn't support mode changes, we let win32u handle them by
just recording them in the registry, and we use that information as the
authoritative source for the current mode when updating the devices.
---
 dlls/win32u/sysparams.c        | 29 ++++++++++++++++++++-
 dlls/winewayland.drv/display.c | 47 +++++++++++++++++++++++++++++++---
 include/wine/gdi_driver.h      |  1 +
 3 files changed, 72 insertions(+), 5 deletions(-)

diff --git a/dlls/win32u/sysparams.c b/dlls/win32u/sysparams.c
index e2c5b10da9e..694c41cb317 100644
--- a/dlls/win32u/sysparams.c
+++ b/dlls/win32u/sysparams.c
@@ -1253,8 +1253,8 @@ static void add_gpu( const struct gdi_gpu *gpu, void *param )
     {
         ctx->mutex = get_display_device_init_mutex();
         pthread_mutex_lock( &display_lock );
-        prepare_devices();
     }
+    if (gpu_index == 0) prepare_devices();
 
     sprintf( buffer, "PCI\\VEN_%04X&DEV_%04X&SUBSYS_%08X&REV_%02X\\%08X",
              gpu->vendor_id, gpu->device_id, gpu->subsys_id, gpu->revision_id, gpu_index );
@@ -1634,12 +1634,33 @@ static void add_mode( const DEVMODEW *mode, BOOL current, void *param )
     }
 }
 
+static struct display_device *find_adapter_device_by_id( UINT index );
+
+static BOOL get_adapter( UINT adapter_idx, DEVMODEW *mode, void *param )
+{
+    struct device_manager_ctx *ctx = param;
+    struct display_device *device;
+    struct adapter *adapter = NULL;
+
+    if (!ctx->mutex)
+    {
+        ctx->mutex = get_display_device_init_mutex();
+        pthread_mutex_lock( &display_lock );
+    }
+
+    if (!(device = find_adapter_device_by_id( adapter_idx ))) return FALSE;
+    adapter = CONTAINING_RECORD( device, struct adapter, dev );
+
+    return adapter_get_current_settings( adapter, mode );
+}
+
 static const struct gdi_device_manager device_manager =
 {
     add_gpu,
     add_adapter,
     add_monitor,
     add_mode,
+    get_adapter,
 };
 
 static void reset_display_manager_ctx( struct device_manager_ctx *ctx )
@@ -1899,12 +1920,18 @@ static void desktop_add_mode( const DEVMODEW *mode, BOOL current, void *param )
     }
 }
 
+static BOOL desktop_get_adapter( UINT id, DEVMODEW *mode, void *param )
+{
+    return FALSE;
+}
+
 static const struct gdi_device_manager desktop_device_manager =
 {
     desktop_add_gpu,
     desktop_add_adapter,
     desktop_add_monitor,
     desktop_add_mode,
+    desktop_get_adapter,
 };
 
 static BOOL desktop_update_display_devices( BOOL force, struct device_manager_ctx *ctx )
diff --git a/dlls/winewayland.drv/display.c b/dlls/winewayland.drv/display.c
index 888c6e5aabb..584732a73db 100644
--- a/dlls/winewayland.drv/display.c
+++ b/dlls/winewayland.drv/display.c
@@ -289,12 +289,47 @@ static void wayland_add_device_modes(const struct gdi_device_manager *device_man
     }
 }
 
+static struct wayland_output_mode *get_matching_output_mode(struct wayland_output *output,
+                                                            DEVMODEW *devmode)
+{
+    struct wayland_output_mode *output_mode;
+
+    RB_FOR_EACH_ENTRY(output_mode, &output->current.modes,
+                      struct wayland_output_mode, entry)
+    {
+        if (devmode->dmPelsWidth == output_mode->width &&
+            devmode->dmPelsHeight == output_mode->height &&
+            output_mode->refresh / 1000 == devmode->dmDisplayFrequency)
+         {
+            return output_mode;
+         }
+    }
+
+    return NULL;
+}
+
 static void output_info_init(struct output_info *output_info,
-                             struct wayland_output *output)
+                             struct wayland_output *output,
+                             int adapter_id,
+                             const struct gdi_device_manager *device_manager,
+                             void *param)
 {
+    DEVMODEW devmode = {.dmSize = sizeof(devmode)};
+    struct wayland_output_mode *mode;
+
     output_info->output = &output->current;
-    output_info->mode = output->current.current_mode;
-    output_info->bpp = 32;
+
+    if (device_manager->get_adapter(adapter_id, &devmode, param) &&
+        (mode = get_matching_output_mode(output, &devmode)))
+    {
+        output_info->mode = mode;
+        output_info->bpp = devmode.dmBitsPerPel;
+    }
+    else
+    {
+        output_info->mode = output->current.current_mode;
+        output_info->bpp = 32;
+    }
 }
 
 /***********************************************************************
@@ -322,8 +357,11 @@ BOOL WAYLAND_UpdateDisplayDevices(const struct gdi_device_manager *device_manage
     {
         if (!output->current.current_mode) continue;
         output_info = wl_array_add(&output_info_array, sizeof(*output_info));
-        if (output_info) output_info_init(output_info, output);
+        /* TODO: Don't assume that the order of devices matches the order
+         * of the outputs in the list. */
+        if (output_info) output_info_init(output_info, output, output_id, device_manager, param);
         else ERR("Failed to allocate space for output_info\n");
+        output_id++;
     }
 
     output_info_array_arrange_physical_coords(&output_info_array);
@@ -331,6 +369,7 @@ BOOL WAYLAND_UpdateDisplayDevices(const struct gdi_device_manager *device_manage
     /* Populate GDI devices. */
     wayland_add_device_gpu(device_manager, param);
 
+    output_id = 0;
     wl_array_for_each(output_info, &output_info_array)
     {
         wayland_add_device_adapter(device_manager, param, output_id);
diff --git a/include/wine/gdi_driver.h b/include/wine/gdi_driver.h
index bd827c31cb1..d3679377344 100644
--- a/include/wine/gdi_driver.h
+++ b/include/wine/gdi_driver.h
@@ -275,6 +275,7 @@ struct gdi_device_manager
     void (*add_adapter)( const struct gdi_adapter *adapter, void *param );
     void (*add_monitor)( const struct gdi_monitor *monitor, void *param );
     void (*add_mode)( const DEVMODEW *mode, BOOL current, void *param );
+    BOOL (*get_adapter)( UINT id, DEVMODEW *mode, void *param );
 };
 
 #define WINE_DM_UNSUPPORTED 0x80000000
-- 
GitLab


From 9252671be93e24ab266ee7b1f996748b1e34b0b9 Mon Sep 17 00:00:00 2001
From: Alexandros Frantzis <alexandros.frantzis@collabora.com>
Date: Tue, 16 Jan 2024 10:36:58 +0200
Subject: [PATCH 5/7] winewayland.drv: Associate each GDI adapter with its
 Wayland output.

Introduce and use driver data for GDI adapters to associate each
adapter with its corresponding Wayland output.

Use this association to ensure we get the proper current display
mode for each output, when updating the display devices.
---
 dlls/win32u/sysparams.c        | 36 +++++++++++++++++++++++---
 dlls/winewayland.drv/display.c | 47 +++++++++++++++++++++++-----------
 include/wine/gdi_driver.h      |  4 ++-
 3 files changed, 68 insertions(+), 19 deletions(-)

diff --git a/dlls/win32u/sysparams.c b/dlls/win32u/sysparams.c
index 694c41cb317..9b01c3c1513 100644
--- a/dlls/win32u/sysparams.c
+++ b/dlls/win32u/sysparams.c
@@ -183,6 +183,7 @@ static const WCHAR linkedW[] = {'L','i','n','k','e','d',0};
 static const WCHAR symbolic_link_valueW[] =
     {'S','y','m','b','o','l','i','c','L','i','n','k','V','a','l','u','e',0};
 static const WCHAR state_flagsW[] = {'S','t','a','t','e','F','l','a','g','s',0};
+static const WCHAR driver_dataW[] = {'D','r','i','v','e','r','D','a','t','a',0};
 static const WCHAR gpu_idW[] = {'G','P','U','I','D',0};
 static const WCHAR hardware_idW[] = {'H','a','r','d','w','a','r','e','I','D',0};
 static const WCHAR device_descW[] = {'D','e','v','i','c','e','D','e','s','c',0};
@@ -243,6 +244,8 @@ struct adapter
     const WCHAR *config_key;
     unsigned int mode_count;
     DEVMODEW *modes;
+    unsigned char *driver_data;
+    UINT driver_data_len;
 };
 
 #define MONITOR_INFO_HAS_MONITOR_ID 0x00000001
@@ -476,6 +479,7 @@ static void adapter_release( struct adapter *adapter )
     if (!InterlockedDecrement( &adapter->refcount ))
     {
         free( adapter->modes );
+        free( adapter->driver_data );
         free( adapter );
     }
 }
@@ -760,6 +764,21 @@ static BOOL read_display_adapter_settings( unsigned int index, struct adapter *i
     if (query_reg_value( hkey, state_flagsW, value, sizeof(buffer) ) && value->Type == REG_DWORD)
         info->dev.state_flags = *(const DWORD *)value->Data;
 
+    /* DriverData */
+    if (query_reg_value( hkey, driver_dataW, value, sizeof(buffer) ) && value->Type == REG_BINARY)
+    {
+        info->driver_data = malloc( value->DataLength );
+        if (info->driver_data)
+        {
+            memcpy( info->driver_data, value->Data, value->DataLength );
+            info->driver_data_len = value->DataLength;
+        }
+        else
+        {
+            info->driver_data_len = 0;
+        }
+    }
+
     /* Interface name */
     info->dev.interface_name[0] = 0;
 
@@ -1479,6 +1498,11 @@ static void add_adapter( const struct gdi_adapter *adapter, void *param )
                    (lstrlenW( ctx->gpuid ) + 1) * sizeof(WCHAR) );
     set_reg_value( ctx->adapter_key, state_flagsW, REG_DWORD, &adapter->state_flags,
                    sizeof(adapter->state_flags) );
+    if (adapter->driver_data && adapter->driver_data_len)
+    {
+        set_reg_value( ctx->adapter_key, driver_dataW, REG_BINARY,
+                       adapter->driver_data, adapter->driver_data_len );
+    }
 }
 
 static void add_monitor( const struct gdi_monitor *monitor, void *param )
@@ -1636,7 +1660,7 @@ static void add_mode( const DEVMODEW *mode, BOOL current, void *param )
 
 static struct display_device *find_adapter_device_by_id( UINT index );
 
-static BOOL get_adapter( UINT adapter_idx, DEVMODEW *mode, void *param )
+static BOOL get_adapter( UINT adapter_idx, DEVMODEW *mode, void *data, UINT *data_len, void *param )
 {
     struct device_manager_ctx *ctx = param;
     struct display_device *device;
@@ -1651,7 +1675,13 @@ static BOOL get_adapter( UINT adapter_idx, DEVMODEW *mode, void *param )
     if (!(device = find_adapter_device_by_id( adapter_idx ))) return FALSE;
     adapter = CONTAINING_RECORD( device, struct adapter, dev );
 
-    return adapter_get_current_settings( adapter, mode );
+    if (!adapter_get_current_settings( adapter, mode )) return FALSE;
+
+    *data_len = min( *data_len, adapter->driver_data_len );
+    if (data && adapter->driver_data)
+        memcpy( data, adapter->driver_data, *data_len );
+
+    return TRUE;
 }
 
 static const struct gdi_device_manager device_manager =
@@ -1920,7 +1950,7 @@ static void desktop_add_mode( const DEVMODEW *mode, BOOL current, void *param )
     }
 }
 
-static BOOL desktop_get_adapter( UINT id, DEVMODEW *mode, void *param )
+static BOOL desktop_get_adapter( UINT id, DEVMODEW *mode, void *data, UINT *data_len, void *param )
 {
     return FALSE;
 }
diff --git a/dlls/winewayland.drv/display.c b/dlls/winewayland.drv/display.c
index 584732a73db..ab7f7599659 100644
--- a/dlls/winewayland.drv/display.c
+++ b/dlls/winewayland.drv/display.c
@@ -47,6 +47,11 @@ void wayland_init_display_devices(BOOL force)
     NtUserGetDisplayConfigBufferSizes(QDC_ONLY_ACTIVE_PATHS, &num_path, &num_mode);
 }
 
+struct wayland_adapter_data
+{
+    char output_name[64];
+};
+
 struct output_info
 {
     int x, y;
@@ -213,14 +218,21 @@ static void wayland_add_device_gpu(const struct gdi_device_manager *device_manag
 }
 
 static void wayland_add_device_adapter(const struct gdi_device_manager *device_manager,
-                                       void *param, INT output_id)
+                                       void *param, INT output_id,
+                                       struct output_info *output_info)
 {
     struct gdi_adapter adapter;
+    struct wayland_adapter_data data;
+
     adapter.id = output_id;
     adapter.state_flags = DISPLAY_DEVICE_ATTACHED_TO_DESKTOP;
     if (output_id == 0)
         adapter.state_flags |= DISPLAY_DEVICE_PRIMARY_DEVICE;
 
+    lstrcpynA(data.output_name, output_info->output->name, sizeof(data.output_name));
+    adapter.driver_data = &data;
+    adapter.driver_data_len = sizeof(data);
+
     TRACE("id=0x%s state_flags=0x%x\n",
           wine_dbgstr_longlong(adapter.id), (UINT)adapter.state_flags);
 
@@ -310,25 +322,32 @@ static struct wayland_output_mode *get_matching_output_mode(struct wayland_outpu
 
 static void output_info_init(struct output_info *output_info,
                              struct wayland_output *output,
-                             int adapter_id,
                              const struct gdi_device_manager *device_manager,
                              void *param)
 {
     DEVMODEW devmode = {.dmSize = sizeof(devmode)};
     struct wayland_output_mode *mode;
+    struct wayland_adapter_data data;
+    UINT data_len = sizeof(data);
+    UINT id = 0;
 
     output_info->output = &output->current;
+    output_info->mode = output->current.current_mode;
+    output_info->bpp = 32;
 
-    if (device_manager->get_adapter(adapter_id, &devmode, param) &&
-        (mode = get_matching_output_mode(output, &devmode)))
-    {
-        output_info->mode = mode;
-        output_info->bpp = devmode.dmBitsPerPel;
-    }
-    else
+    while (device_manager->get_adapter(id, &devmode, &data, &data_len, param))
     {
-        output_info->mode = output->current.current_mode;
-        output_info->bpp = 32;
+        if (data_len == sizeof(data) &&
+            !strcmp(output->current.name, data.output_name))
+        {
+            if ((mode = get_matching_output_mode(output, &devmode)))
+            {
+                output_info->mode = mode;
+                output_info->bpp = devmode.dmBitsPerPel;
+            }
+        }
+        data_len = sizeof(data);
+        ++id;
     }
 }
 
@@ -359,9 +378,8 @@ BOOL WAYLAND_UpdateDisplayDevices(const struct gdi_device_manager *device_manage
         output_info = wl_array_add(&output_info_array, sizeof(*output_info));
         /* TODO: Don't assume that the order of devices matches the order
          * of the outputs in the list. */
-        if (output_info) output_info_init(output_info, output, output_id, device_manager, param);
+        if (output_info) output_info_init(output_info, output, device_manager, param);
         else ERR("Failed to allocate space for output_info\n");
-        output_id++;
     }
 
     output_info_array_arrange_physical_coords(&output_info_array);
@@ -369,10 +387,9 @@ BOOL WAYLAND_UpdateDisplayDevices(const struct gdi_device_manager *device_manage
     /* Populate GDI devices. */
     wayland_add_device_gpu(device_manager, param);
 
-    output_id = 0;
     wl_array_for_each(output_info, &output_info_array)
     {
-        wayland_add_device_adapter(device_manager, param, output_id);
+        wayland_add_device_adapter(device_manager, param, output_id, output_info);
         wayland_add_device_monitor(device_manager, param, output_info);
         wayland_add_device_modes(device_manager, param, output_info);
         output_id++;
diff --git a/include/wine/gdi_driver.h b/include/wine/gdi_driver.h
index d3679377344..202a164d070 100644
--- a/include/wine/gdi_driver.h
+++ b/include/wine/gdi_driver.h
@@ -258,6 +258,8 @@ struct gdi_adapter
 {
     ULONG_PTR id;
     DWORD state_flags;
+    void *driver_data;
+    UINT driver_data_len;
 };
 
 struct gdi_monitor
@@ -275,7 +277,7 @@ struct gdi_device_manager
     void (*add_adapter)( const struct gdi_adapter *adapter, void *param );
     void (*add_monitor)( const struct gdi_monitor *monitor, void *param );
     void (*add_mode)( const DEVMODEW *mode, BOOL current, void *param );
-    BOOL (*get_adapter)( UINT id, DEVMODEW *mode, void *param );
+    BOOL (*get_adapter)( UINT id, DEVMODEW *mode, void *data, UINT *data_len, void *param );
 };
 
 #define WINE_DM_UNSUPPORTED 0x80000000
-- 
GitLab


From 0bd3a469e4745ce1c9474b63b2c5d5e68e4a4634 Mon Sep 17 00:00:00 2001
From: Alexandros Frantzis <alexandros.frantzis@collabora.com>
Date: Thu, 25 Jan 2024 15:21:22 +0200
Subject: [PATCH 6/7] winewayland.drv: Adjust window scaling based on the
 monitor display mode.

Emulate the visual effect of a display mode change, by scaling the window according
to the ratios of the native vs current mode.

We provide the adapter scaling information to the driver as part of the adapter
driver data so it's consistent across all processes.
---
 dlls/win32u/main.c                |  6 ++++++
 dlls/win32u/sysparams.c           | 17 +++++++++++++++++
 dlls/win32u/win32syscalls.h       | 14 ++++++++------
 dlls/win32u/win32u.spec           |  1 +
 dlls/winewayland.drv/display.c    |  9 ++++-----
 dlls/winewayland.drv/waylanddrv.h |  7 +++++++
 dlls/winewayland.drv/window.c     | 17 +++++++++++++++++
 dlls/wow64win/user.c              |  6 ++++++
 include/ntuser.h                  |  1 +
 9 files changed, 67 insertions(+), 11 deletions(-)

diff --git a/dlls/win32u/main.c b/dlls/win32u/main.c
index 2dc66e5df11..432f3fa892a 100644
--- a/dlls/win32u/main.c
+++ b/dlls/win32u/main.c
@@ -2140,6 +2140,12 @@ HWND SYSCALL_API NtUserWindowFromPoint( LONG x, LONG y )
     __ASM_SYSCALL_FUNC( __id_NtUserWindowFromPoint );
 }
 
+BOOL SYSCALL_API __wine_get_adapter_driver_data( UNICODE_STRING *devname,
+                                                 void *data, UINT *data_len )
+{
+    __ASM_SYSCALL_FUNC( __id___wine_get_adapter_driver_data );
+}
+
 BOOL SYSCALL_API __wine_get_file_outline_text_metric( const WCHAR *path, TEXTMETRICW *otm,
                                                       UINT *em_square, WCHAR *face_name )
 {
diff --git a/dlls/win32u/sysparams.c b/dlls/win32u/sysparams.c
index 9b01c3c1513..65437801970 100644
--- a/dlls/win32u/sysparams.c
+++ b/dlls/win32u/sysparams.c
@@ -6631,3 +6631,20 @@ NTSTATUS WINAPI NtUserDisplayConfigGetDeviceInfo( DISPLAYCONFIG_DEVICE_INFO_HEAD
         return STATUS_INVALID_PARAMETER;
     }
 }
+
+void WINAPI __wine_get_adapter_driver_data( UNICODE_STRING *devname, void *data, UINT *data_len )
+{
+    struct adapter *adapter;
+
+    if ((adapter = find_adapter( devname )))
+    {
+        *data_len = min( *data_len, adapter->driver_data_len );
+        if (data && adapter->driver_data)
+            memcpy( data, adapter->driver_data, *data_len );
+        adapter_release( adapter );
+    }
+    else
+    {
+        *data_len = 0;
+    }
+}
diff --git a/dlls/win32u/win32u.spec b/dlls/win32u/win32u.spec
index 24dccb6ec1d..18c973941e1 100644
--- a/dlls/win32u/win32u.spec
+++ b/dlls/win32u/win32u.spec
@@ -1323,3 +1323,4 @@
 @ stdcall -syscall __wine_get_icm_profile(long long ptr ptr)
 @ stdcall -syscall __wine_get_file_outline_text_metric(wstr ptr ptr ptr)
 @ stdcall -syscall __wine_send_input(long ptr ptr)
+@ stdcall -syscall __wine_get_adapter_driver_data(ptr ptr ptr)
diff --git a/dlls/winewayland.drv/display.c b/dlls/winewayland.drv/display.c
index ab7f7599659..eba592a585e 100644
--- a/dlls/winewayland.drv/display.c
+++ b/dlls/winewayland.drv/display.c
@@ -47,11 +47,6 @@ void wayland_init_display_devices(BOOL force)
     NtUserGetDisplayConfigBufferSizes(QDC_ONLY_ACTIVE_PATHS, &num_path, &num_mode);
 }
 
-struct wayland_adapter_data
-{
-    char output_name[64];
-};
-
 struct output_info
 {
     int x, y;
@@ -230,6 +225,10 @@ static void wayland_add_device_adapter(const struct gdi_device_manager *device_m
         adapter.state_flags |= DISPLAY_DEVICE_PRIMARY_DEVICE;
 
     lstrcpynA(data.output_name, output_info->output->name, sizeof(data.output_name));
+    data.scale_width = ((double)output_info->output->current_mode->width) /
+                       output_info->mode->width;
+    data.scale_height = ((double)output_info->output->current_mode->height) /
+                        output_info->mode->height;
     adapter.driver_data = &data;
     adapter.driver_data_len = sizeof(data);
 
diff --git a/dlls/winewayland.drv/waylanddrv.h b/dlls/winewayland.drv/waylanddrv.h
index 0883c43f1ff..48de2fb8c3f 100644
--- a/dlls/winewayland.drv/waylanddrv.h
+++ b/dlls/winewayland.drv/waylanddrv.h
@@ -215,6 +215,13 @@ struct wayland_shm_buffer
     HRGN damage_region;
 };
 
+struct wayland_adapter_data
+{
+    char output_name[64];
+    /* How much larger the native mode is compared to current mode. */
+    double scale_width, scale_height;
+};
+
 /**********************************************************************
  *          Wayland initialization
  */
diff --git a/dlls/winewayland.drv/window.c b/dlls/winewayland.drv/window.c
index ac5da371e5c..ae63b66b83e 100644
--- a/dlls/winewayland.drv/window.c
+++ b/dlls/winewayland.drv/window.c
@@ -162,6 +162,8 @@ static void wayland_win_data_get_config(struct wayland_win_data *data,
                                         struct wayland_window_config *conf)
 {
     enum wayland_surface_config_state window_state = 0;
+    MONITORINFOEXW mi = {.cbSize = sizeof(mi)};
+    HMONITOR hmon;
     DWORD style;
 
     conf->rect = data->window_rect;
@@ -187,6 +189,21 @@ static void wayland_win_data_get_config(struct wayland_win_data *data,
     conf->scale = NtUserGetDpiForWindow(data->hwnd) / 96.0;
     conf->visible = (style & WS_VISIBLE) == WS_VISIBLE;
     conf->managed = data->managed;
+
+    /* Adjust the window scale for the current display mode. */
+    if ((hmon = NtUserMonitorFromWindow(data->hwnd, MONITOR_DEFAULTTOPRIMARY)) &&
+        NtUserGetMonitorInfo(hmon, (MONITORINFO *)&mi))
+    {
+        struct wayland_adapter_data adapter_data;
+        UINT adapter_data_len = sizeof(adapter_data);
+        UNICODE_STRING dev;
+
+        RtlInitUnicodeString(&dev, mi.szDevice);
+        __wine_get_adapter_driver_data(&dev, &adapter_data, &adapter_data_len);
+
+        if (adapter_data_len == sizeof(adapter_data))
+            conf->scale /= min(adapter_data.scale_width, adapter_data.scale_height);
+    }
 }
 
 static void wayland_win_data_update_wayland_surface(struct wayland_win_data *data)
diff --git a/dlls/wow64win/user.c b/dlls/wow64win/user.c
index 2dd811578f5..446856eecce 100644
--- a/dlls/wow64win/user.c
+++ b/dlls/wow64win/user.c
@@ -4874,3 +4874,9 @@ NTSTATUS WINAPI wow64___wine_send_input( UINT *args )
     ERR( "not supported\n" );
     return 0;
 }
+
+NTSTATUS WINAPI wow64___wine_get_adapter_driver_data( UINT *args )
+{
+    ERR( "not supported\n" );
+    return 0;
+}
diff --git a/include/ntuser.h b/include/ntuser.h
index 31b93ef36e9..70f46bf14b6 100644
--- a/include/ntuser.h
+++ b/include/ntuser.h
@@ -1406,5 +1406,6 @@ static inline BOOL NtUserShowOwnedPopups( HWND hwnd, BOOL show )
 
 /* Wine extensions */
 W32KAPI BOOL WINAPI __wine_send_input( HWND hwnd, const INPUT *input, const RAWINPUT *rawinput );
+W32KAPI void WINAPI __wine_get_adapter_driver_data( UNICODE_STRING *devname, void *data, UINT *data_len );
 
 #endif /* _NTUSER_ */
-- 
GitLab


From 1aaeaeaac9a66ea5aaa66e5782d7d25fdfb1c7be Mon Sep 17 00:00:00 2001
From: Alexandros Frantzis <alexandros.frantzis@collabora.com>
Date: Fri, 26 Jan 2024 16:04:15 +0200
Subject: [PATCH 7/7] winewayland.drv: Refresh surfaces after display
 configuration.

Since a display reconfiguration may affect the compositor side scaling
which we apply to a surface, instruct all surfaces to refresh themselves
by committing an updated state based on the latest window state.
---
 dlls/winewayland.drv/display.c    |  5 +++++
 dlls/winewayland.drv/waylanddrv.h |  1 +
 dlls/winewayland.drv/window.c     | 21 +++++++++++++++++++++
 3 files changed, 27 insertions(+)

diff --git a/dlls/winewayland.drv/display.c b/dlls/winewayland.drv/display.c
index eba592a585e..3eb60354081 100644
--- a/dlls/winewayland.drv/display.c
+++ b/dlls/winewayland.drv/display.c
@@ -398,5 +398,10 @@ BOOL WAYLAND_UpdateDisplayDevices(const struct gdi_device_manager *device_manage
 
     pthread_mutex_unlock(&process_wayland.output_mutex);
 
+    /* Refresh all windows to ensure they have been committed with proper
+     * scaling applied. */
+    if (process_wayland.initialized)
+        NtUserPostMessage(HWND_BROADCAST, WM_WAYLAND_REFRESH, 0, 0);
+
     return TRUE;
 }
diff --git a/dlls/winewayland.drv/waylanddrv.h b/dlls/winewayland.drv/waylanddrv.h
index 48de2fb8c3f..ae423047240 100644
--- a/dlls/winewayland.drv/waylanddrv.h
+++ b/dlls/winewayland.drv/waylanddrv.h
@@ -62,6 +62,7 @@ enum wayland_window_message
     WM_WAYLAND_INIT_DISPLAY_DEVICES = WM_WINE_FIRST_DRIVER_MSG,
     WM_WAYLAND_CONFIGURE,
     WM_WAYLAND_SET_FOREGROUND,
+    WM_WAYLAND_REFRESH,
 };
 
 enum wayland_surface_config_state
diff --git a/dlls/winewayland.drv/window.c b/dlls/winewayland.drv/window.c
index ae63b66b83e..6695e3e3830 100644
--- a/dlls/winewayland.drv/window.c
+++ b/dlls/winewayland.drv/window.c
@@ -631,6 +631,24 @@ static void wayland_configure_window(HWND hwnd)
     NtUserSetWindowPos(hwnd, 0, 0, 0, window_width, window_height, flags);
 }
 
+static void wayland_refresh_window(HWND hwnd)
+{
+    struct wayland_win_data *data;
+
+    if (!(data = wayland_win_data_get(hwnd))) return;
+
+    if (data->wayland_surface)
+    {
+        pthread_mutex_lock(&data->wayland_surface->mutex);
+        wayland_win_data_get_config(data, &data->wayland_surface->window);
+        if (wayland_surface_reconfigure(data->wayland_surface))
+            wl_surface_commit(data->wayland_surface->wl_surface);
+        pthread_mutex_unlock(&data->wayland_surface->mutex);
+    }
+
+    wayland_win_data_release(data);
+}
+
 /**********************************************************************
  *           WAYLAND_WindowMessage
  */
@@ -648,6 +666,9 @@ LRESULT WAYLAND_WindowMessage(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
     case WM_WAYLAND_SET_FOREGROUND:
         NtUserSetForegroundWindow(hwnd);
         return 0;
+    case WM_WAYLAND_REFRESH:
+        wayland_refresh_window(hwnd);
+        return 0;
     default:
         FIXME("got window msg %x hwnd %p wp %lx lp %lx\n", msg, hwnd, (long)wp, lp);
         return 0;
-- 
GitLab