[Development] Wayland: getting a screen's fractional scale before the first window exists
Henry Skoglund
henry at tungware.se
Mon Aug 24 19:09:03 CEST 2026
On 2026-08-24 18:27, Fatih Uzunoğlu wrote:
> Hello,
>
> Regarding:
>
> > until the surface is configured by the compositor
>
> I am not sure if the protocol guarantees when
> `wl_surface::preferred_buffer_scale` is sent (or
> `wp_fractional_scale_v1::preferred_scale` in fractional scale case),
> but if in practice major compositors send the scale within one or two
> event loop cycles, then for the sake of application's convenience
> maybe `QWindow::create()` may do one or two arbitrary
> `wl_display_roundtrip()` after the initial commit just to expect the
> compositor to send the scale.
>
> The waiting time here would probably be negligible, and in turn the
> application can immediately use the proper scale since the roundtrip
> call is blocking, provided that the compositor sent it.
>
That's pretty good advice for any Qt application I think.
I only use QWidgets apps, but for those I do a QTimer::singleshot(20
milliseconds) from MainWindow's constructor. Then in the timer code I
can reliable get the screen geometry/geometries (instead of the 640x480
when inside the ctor).
Rgrds Henry
P.S. Also easier to autostart or quit the app then, since QApplication's
event loop starts efter MainWindow's ctor.
More information about the Development
mailing list