How to get notified about the monitor scale change?

Hi,

The subject pretty much says it all?

I’d like to know how to do it in both GTK3 and GTK4, please.

What I’m looking for is to get notified when the user clicks on the different scale factor in the Settings → Display panel, or move the application window to a different monitor that is HighDPI or back.

Thank you.

Hi, guys,

There is no such signal?

Thank you.

You only get scale factors:

Use the GObject::notify signal for those properties to get notifications.

In general, what you’re asking is entirely immaterial: GTK will take care of it for you, and adjust all the coordinates and sizes depending on the scale factor from the system. The only time you have to care is if you’re dealing with direct OpenGL rendering.

@ebassi ,

Thx.

I’m running on X with GNOME and GTK3.24 with OpenRC on Gentoo Linux.

In the “Settings →Display” panel I have 2 buttons: 100% and 200% for the “Scale”.

II also have a dialog which is very tall.

If I set my laptop monitor to be 200%, start my app and go to that dialog it will not display fully.

But if I go back to Settings and select 100% for the scale that dialog will not be resized.

Hence the question - how to get notified about that change.

Is it the same for working with 2 different monitors or situation there is different?

Thank you.

@ebassi,

Does this signal called notify:gtk-widget-scale? The one you referenced in your reply?

Thank you.

The signal is notify::scale-factor on GtkWidget, and notify::scale on GdkSurface.

You really need to understand how property notification works on GObject: it’s a core functionality of the whole framework.

This topic was automatically closed 45 days after the last reply. New replies are no longer allowed.