@@ -11,26 +11,33 @@ typedef struct WaylandKdeMode
1111 int32_t width ;
1212 int32_t height ;
1313 int32_t refreshRate ;
14+ bool preferred ;
1415 struct kde_output_device_mode_v2 * pMode ;
1516} WaylandKdeMode ;
1617
17- static void waylandKdeSizeListener (void * data , FF_MAYBE_UNUSED struct kde_output_device_mode_v2 * _ , int32_t width , int32_t height )
18+ static void waylandKdeModeSizeListener (void * data , FF_MAYBE_UNUSED struct kde_output_device_mode_v2 * _ , int32_t width , int32_t height )
1819{
1920 WaylandKdeMode * mode = (WaylandKdeMode * ) data ;
2021 mode -> width = width ;
2122 mode -> height = height ;
2223}
2324
24- static void waylandKdeRefreshListener (void * data , FF_MAYBE_UNUSED struct kde_output_device_mode_v2 * _ , int32_t rate )
25+ static void waylandKdeModeRefreshListener (void * data , FF_MAYBE_UNUSED struct kde_output_device_mode_v2 * _ , int32_t rate )
2526{
2627 WaylandKdeMode * mode = (WaylandKdeMode * ) data ;
2728 mode -> refreshRate = rate ;
2829}
2930
31+ static void waylandKdeModePreferredListener (void * data , FF_MAYBE_UNUSED struct kde_output_device_mode_v2 * _ )
32+ {
33+ WaylandKdeMode * mode = (WaylandKdeMode * ) data ;
34+ mode -> preferred = true;
35+ }
36+
3037static const struct kde_output_device_mode_v2_listener modeListener = {
31- .size = waylandKdeSizeListener ,
32- .refresh = waylandKdeRefreshListener ,
33- .preferred = ( void * ) stubListener ,
38+ .size = waylandKdeModeSizeListener ,
39+ .refresh = waylandKdeModeRefreshListener ,
40+ .preferred = waylandKdeModePreferredListener ,
3441 .removed = (void * ) stubListener ,
3542};
3643
@@ -40,7 +47,7 @@ static void waylandKdeModeListener(void* data, FF_MAYBE_UNUSED struct kde_output
4047 if (!wldata -> internal ) return ;
4148
4249 WaylandKdeMode * newMode = ffListAdd ((FFlist * ) wldata -> internal );
43- newMode -> pMode = mode ;
50+ * newMode = ( WaylandKdeMode ) { . pMode = mode } ;
4451
4552 // Strangely, the listener is called only in this function, but not in `waylandKdeCurrentModeListener`
4653 wldata -> parent -> ffwl_proxy_add_listener ((struct wl_proxy * ) mode , (void (* * )(void )) & modeListener , newMode );
@@ -52,18 +59,24 @@ static void waylandKdeCurrentModeListener(void* data, FF_MAYBE_UNUSED struct kde
5259 WaylandDisplay * wldata = (WaylandDisplay * ) data ;
5360 if (!wldata -> internal ) return ;
5461
55- WaylandKdeMode * current = NULL ;
62+ int set = 0 ;
5663 FF_LIST_FOR_EACH (WaylandKdeMode , m , * (FFlist * ) wldata -> internal )
5764 {
5865 if (m -> pMode == mode )
5966 {
60- current = m ;
61- break ;
67+ wldata -> width = m -> width ;
68+ wldata -> height = m -> height ;
69+ wldata -> refreshRate = m -> refreshRate ;
70+ if (++ set == 2 ) break ;
71+ }
72+ else if (m -> preferred )
73+ {
74+ wldata -> preferredWidth = m -> width ;
75+ wldata -> preferredHeight = m -> height ;
76+ wldata -> preferredRefreshRate = m -> refreshRate ;
77+ if (++ set == 2 ) break ;
6278 }
6379 }
64- wldata -> width = current -> width ;
65- wldata -> height = current -> height ;
66- wldata -> refreshRate = current -> refreshRate ;
6780}
6881
6982static void waylandKdeScaleListener (void * data , FF_MAYBE_UNUSED struct kde_output_device_v2 * _ , wl_fixed_t scale )
@@ -164,9 +177,6 @@ void ffWaylandHandleKdeOutput(WaylandData* wldata, struct wl_registry* registry,
164177 FF_LIST_AUTO_DESTROY modes = ffListCreate (sizeof (WaylandKdeMode ));
165178 WaylandDisplay display = {
166179 .parent = wldata ,
167- .width = 0 ,
168- .height = 0 ,
169- .refreshRate = 0 ,
170180 .scale = 1 ,
171181 .transform = WL_OUTPUT_TRANSFORM_NORMAL ,
172182 .type = FF_DISPLAY_TYPE_UNKNOWN ,
@@ -191,6 +201,9 @@ void ffWaylandHandleKdeOutput(WaylandData* wldata, struct wl_registry* registry,
191201 display .refreshRate / 1000.0 ,
192202 (uint32_t ) (display .width / display .scale ),
193203 (uint32_t ) (display .height / display .scale ),
204+ (uint32_t ) display .preferredWidth ,
205+ (uint32_t ) display .preferredHeight ,
206+ display .preferredRefreshRate / 1000.0 ,
194207 rotation ,
195208 display .edidName .length
196209 ? & display .edidName
0 commit comments