gtk stucks with first observed scale factor on monitor object
I have a compositor without xdg-output and fractional scale support. It advertises scale = 2 on wl_output right from start yet gtk sets buffer_scale = 1 despite logging it gets scale = 2 from the compositor. The order of the events from the compositor is as follows:
[3148234.819] wl_output@9.geometry(0, 0, -1, -1, 0, "", "", 0)
[3148234.902] wl_output@9.mode(3, 768, 1180, 74999)
[3148234.942] wl_output@9.scale(2)
[3148234.967] wl_output@9.done()
Now, let's look at gtk code:
- Notice it calls gtk calls gdk_monitor_set_scale_factor when handling wl_output.scale: https://gitlab.gnome.org/GNOME/gtk/-/blob/main/gdk/wayland/gdkdisplay-wayland.c#L2607
- Notice apply_monitor_change uses gdk_monitor_get_scale_factor and gdk_monitor_set_scale: https://gitlab.gnome.org/GNOME/gtk/-/blob/main/gdk/wayland/gdkdisplay-wayland.c#L2437
- Notice it calls apply_monitor_change on wl_output.geometry and wl_output.mode if compositor doesn't have xdg-output support:
https://gitlab.gnome.org/GNOME/gtk/-/blob/main/gdk/wayland/gdkdisplay-wayland.c#L2579-2580
https://gitlab.gnome.org/GNOME/gtk/-/blob/main/gdk/wayland/gdkdisplay-wayland.c#L2633-2634 - Finally, look at gdk_monitor_set_scale{,_factor}:
https://gitlab.gnome.org/GNOME/gtk/-/blob/main/gdk/gdkmonitor.c#L654
https://gitlab.gnome.org/GNOME/gtk/-/blob/main/gdk/gdkmonitor.c#L635-636 - KA-BOOM!
It never updates the value after the first call to apply_monitor_change which gets called even before the first wl_output.scale which makes gtk stuck with scale = 1.
It feels like the code is written with the assumption that gdk_monitor_set_scale{,_factor} are independent of each other while they aren't and, moreover, one blocks another...
I don't really understand why it calls apply_monitor_change in wl_output.{geometry,mode} depending on xdg-output presence, though...