mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-28 14:31:10 +00:00
native: Listen for scale changes
Connect to change notification for the surface scale-factor property, and update the widgets when it changes. Fixes: #3578
This commit is contained in:
parent
aefc630d29
commit
e905f7ff7c
@ -30,6 +30,7 @@ typedef struct _GtkNativePrivate
|
|||||||
{
|
{
|
||||||
gulong update_handler_id;
|
gulong update_handler_id;
|
||||||
gulong layout_handler_id;
|
gulong layout_handler_id;
|
||||||
|
gulong scale_changed_handler_id;
|
||||||
} GtkNativePrivate;
|
} GtkNativePrivate;
|
||||||
|
|
||||||
static GQuark quark_gtk_native_private;
|
static GQuark quark_gtk_native_private;
|
||||||
@ -108,6 +109,14 @@ surface_layout_cb (GdkSurface *surface,
|
|||||||
gtk_native_queue_relayout (native);
|
gtk_native_queue_relayout (native);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
scale_changed_cb (GdkSurface *surface,
|
||||||
|
GParamSpec *pspec,
|
||||||
|
GtkNative *native)
|
||||||
|
{
|
||||||
|
_gtk_widget_scale_changed (GTK_WIDGET (native));
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
verify_priv_unrealized (gpointer user_data)
|
verify_priv_unrealized (gpointer user_data)
|
||||||
{
|
{
|
||||||
@ -115,6 +124,7 @@ verify_priv_unrealized (gpointer user_data)
|
|||||||
|
|
||||||
g_warn_if_fail (priv->update_handler_id == 0);
|
g_warn_if_fail (priv->update_handler_id == 0);
|
||||||
g_warn_if_fail (priv->layout_handler_id == 0);
|
g_warn_if_fail (priv->layout_handler_id == 0);
|
||||||
|
g_warn_if_fail (priv->scale_changed_handler_id == 0);
|
||||||
|
|
||||||
g_free (priv);
|
g_free (priv);
|
||||||
}
|
}
|
||||||
@ -146,6 +156,11 @@ gtk_native_realize (GtkNative *self)
|
|||||||
priv->layout_handler_id = g_signal_connect (surface, "layout",
|
priv->layout_handler_id = g_signal_connect (surface, "layout",
|
||||||
G_CALLBACK (surface_layout_cb),
|
G_CALLBACK (surface_layout_cb),
|
||||||
self);
|
self);
|
||||||
|
|
||||||
|
priv->scale_changed_handler_id = g_signal_connect (surface, "notify::scale-factor",
|
||||||
|
G_CALLBACK (scale_changed_cb),
|
||||||
|
self);
|
||||||
|
|
||||||
g_object_set_qdata_full (G_OBJECT (self),
|
g_object_set_qdata_full (G_OBJECT (self),
|
||||||
quark_gtk_native_private,
|
quark_gtk_native_private,
|
||||||
priv,
|
priv,
|
||||||
@ -174,6 +189,7 @@ gtk_native_unrealize (GtkNative *self)
|
|||||||
|
|
||||||
g_clear_signal_handler (&priv->update_handler_id, clock);
|
g_clear_signal_handler (&priv->update_handler_id, clock);
|
||||||
g_clear_signal_handler (&priv->layout_handler_id, surface);
|
g_clear_signal_handler (&priv->layout_handler_id, surface);
|
||||||
|
g_clear_signal_handler (&priv->scale_changed_handler_id, surface);
|
||||||
|
|
||||||
g_object_set_qdata (G_OBJECT (self), quark_gtk_native_private, NULL);
|
g_object_set_qdata (G_OBJECT (self), quark_gtk_native_private, NULL);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user