summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2021-01-17 05:23:22 +0000
committerMatthias Clasen <mclasen@redhat.com>2021-01-17 05:23:22 +0000
commit1b961a9ae2ae262f97288e5da6e437d5502c4808 (patch)
tree5b80cc1f1db0821ee8c4dab5c2f0cc37b0a5c6ce
parent61a7ebf980f1287e5f84ebdd0776f908169b3a3b (diff)
parentf14762b026c4b55b1ba06f327f1414f7c634f59f (diff)
downloadgtk+-1b961a9ae2ae262f97288e5da6e437d5502c4808.tar.gz
Merge branch 'surface-scale' into 'master'
Surface scale Closes #3578 See merge request GNOME/gtk!3085
-rw-r--r--gdk/gdksurface.c12
-rw-r--r--gdk/wayland/gdksurface-wayland.c16
-rw-r--r--gdk/x11/gdksurface-x11.c2
-rw-r--r--gtk/gtknative.c16
4 files changed, 43 insertions, 3 deletions
diff --git a/gdk/gdksurface.c b/gdk/gdksurface.c
index 5488aa45f7..f6919f3028 100644
--- a/gdk/gdksurface.c
+++ b/gdk/gdksurface.c
@@ -92,6 +92,7 @@ enum {
PROP_MAPPED,
PROP_WIDTH,
PROP_HEIGHT,
+ PROP_SCALE_FACTOR,
LAST_PROP
};
@@ -551,6 +552,13 @@ gdk_surface_class_init (GdkSurfaceClass *klass)
0, G_MAXINT, 0,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
+ properties[PROP_SCALE_FACTOR] =
+ g_param_spec_int ("scale-factor",
+ P_("Scale factor"),
+ P_("Scale factor"),
+ 1, G_MAXINT, 1,
+ G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
+
g_object_class_install_properties (object_class, LAST_PROP, properties);
/**
@@ -782,6 +790,10 @@ gdk_surface_get_property (GObject *object,
g_value_set_int (value, surface->height);
break;
+ case PROP_SCALE_FACTOR:
+ g_value_set_int (value, gdk_surface_get_scale_factor (surface));
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
diff --git a/gdk/wayland/gdksurface-wayland.c b/gdk/wayland/gdksurface-wayland.c
index dd0d1891fa..c114c04f29 100644
--- a/gdk/wayland/gdksurface-wayland.c
+++ b/gdk/wayland/gdksurface-wayland.c
@@ -389,10 +389,13 @@ gdk_wayland_surface_update_size (GdkSurface *surface,
int scale)
{
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
+ gboolean width_changed, height_changed, scale_changed;
- if ((surface->width == width) &&
- (surface->height == height) &&
- (impl->scale == scale))
+ width_changed = surface->width != width;
+ height_changed = surface->height != height;
+ scale_changed = impl->scale != scale;
+
+ if (!width_changed && !height_changed && !scale_changed)
return;
surface->width = width;
@@ -405,6 +408,13 @@ gdk_wayland_surface_update_size (GdkSurface *surface,
wl_surface_set_buffer_scale (impl->display_server.wl_surface, scale);
gdk_surface_invalidate_rect (surface, NULL);
+
+ if (width_changed)
+ g_object_notify (G_OBJECT (surface), "width");
+ if (height_changed)
+ g_object_notify (G_OBJECT (surface), "height");
+ if (scale_changed)
+ g_object_notify (G_OBJECT (surface), "scale-factor");
}
static const char *
diff --git a/gdk/x11/gdksurface-x11.c b/gdk/x11/gdksurface-x11.c
index 207c34e419..feecf917a2 100644
--- a/gdk/x11/gdksurface-x11.c
+++ b/gdk/x11/gdksurface-x11.c
@@ -2013,6 +2013,8 @@ _gdk_x11_surface_set_surface_scale (GdkSurface *surface,
surface->height * impl->surface_scale);
gdk_surface_invalidate_rect (surface, NULL);
+
+ g_object_notify (G_OBJECT (surface), "scale-factor");
}
void
diff --git a/gtk/gtknative.c b/gtk/gtknative.c
index 1f6ed48f3a..aefe911831 100644
--- a/gtk/gtknative.c
+++ b/gtk/gtknative.c
@@ -30,6 +30,7 @@ typedef struct _GtkNativePrivate
{
gulong update_handler_id;
gulong layout_handler_id;
+ gulong scale_changed_handler_id;
} GtkNativePrivate;
static GQuark quark_gtk_native_private;
@@ -109,12 +110,21 @@ surface_layout_cb (GdkSurface *surface,
}
static void
+scale_changed_cb (GdkSurface *surface,
+ GParamSpec *pspec,
+ GtkNative *native)
+{
+ _gtk_widget_scale_changed (GTK_WIDGET (native));
+}
+
+static void
verify_priv_unrealized (gpointer user_data)
{
GtkNativePrivate *priv = user_data;
g_warn_if_fail (priv->update_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);
}
@@ -146,6 +156,11 @@ gtk_native_realize (GtkNative *self)
priv->layout_handler_id = g_signal_connect (surface, "layout",
G_CALLBACK (surface_layout_cb),
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),
quark_gtk_native_private,
priv,
@@ -174,6 +189,7 @@ gtk_native_unrealize (GtkNative *self)
g_clear_signal_handler (&priv->update_handler_id, clock);
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);
}