summaryrefslogtreecommitdiff
path: root/gdk
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2021-05-09 19:42:42 -0400
committerMatthias Clasen <mclasen@redhat.com>2021-05-10 07:19:26 -0400
commit7745f675834debe1128d2edf2cba43da16493d85 (patch)
treea35ed191865ba211ba909f25d5577f5b0b1c029f /gdk
parent374225ae6a72f0ec65f4b444bb8d24c1044f83cb (diff)
downloadgtk+-7745f675834debe1128d2edf2cba43da16493d85.tar.gz
broadway: Add a setter for display scale
This is useful when using Broadway as a headless display server. Fixes: #3934
Diffstat (limited to 'gdk')
-rw-r--r--gdk/broadway/gdkbroadwaydisplay.h4
-rw-r--r--gdk/broadway/gdkdisplay-broadway.c37
-rw-r--r--gdk/broadway/gdkdisplay-broadway.h1
3 files changed, 40 insertions, 2 deletions
diff --git a/gdk/broadway/gdkbroadwaydisplay.h b/gdk/broadway/gdkbroadwaydisplay.h
index b7293dc932..79e78c9a62 100644
--- a/gdk/broadway/gdkbroadwaydisplay.h
+++ b/gdk/broadway/gdkbroadwaydisplay.h
@@ -48,6 +48,10 @@ void gdk_broadway_display_show_keyboard (GdkBroadwayDis
GDK_AVAILABLE_IN_ALL
void gdk_broadway_display_hide_keyboard (GdkBroadwayDisplay *display);
+GDK_AVAILABLE_IN_4_4
+void gdk_broadway_display_set_surface_scale (GdkDisplay *display,
+ int scale);
+
G_END_DECLS
#endif /* __GDK_BROADWAY_DISPLAY_H__ */
diff --git a/gdk/broadway/gdkdisplay-broadway.c b/gdk/broadway/gdkdisplay-broadway.c
index 86e299d13a..29f2256323 100644
--- a/gdk/broadway/gdkdisplay-broadway.c
+++ b/gdk/broadway/gdkdisplay-broadway.c
@@ -94,10 +94,12 @@ _gdk_broadway_display_size_changed (GdkDisplay *display,
if (msg->width == current_size.width &&
msg->height == current_size.height &&
- msg->scale == broadway_display->scale_factor)
+ (msg->scale == broadway_display->scale_factor ||
+ broadway_display->fixed_scale))
return;
- broadway_display->scale_factor = msg->scale;
+ if (!broadway_display->fixed_scale)
+ broadway_display->scale_factor = msg->scale;
gdk_monitor_set_geometry (monitor, &(GdkRectangle) { 0, 0, msg->width, msg->height });
gdk_monitor_set_scale_factor (monitor, msg->scale);
@@ -328,6 +330,37 @@ gdk_broadway_display_hide_keyboard (GdkBroadwayDisplay *display)
_gdk_broadway_server_set_show_keyboard (display->server, FALSE);
}
+/**
+ * gdk_broadway_display_set_surface_scale:
+ * @display: (type GdkBroadwayDisplay): the display
+ * @scale: The new scale value, as an integer >= 1
+ *
+ * Forces a specific window scale for all windows on this display,
+ * instead of using the default or user configured scale. This
+ * is can be used to disable scaling support by setting @scale to
+ * 1, or to programmatically set the window scale.
+ *
+ * Once the scale is set by this call it will not change in
+ * response to later user configuration changes.
+ *
+ * Since: 4.4
+ */
+void
+gdk_broadway_display_set_surface_scale (GdkDisplay *display,
+ int scale)
+{
+ GdkBroadwayDisplay *self;
+
+ g_return_if_fail (GDK_IS_BROADWAY_DISPLAY (display));
+ g_return_if_fail (scale > 0);
+
+ self = GDK_BROADWAY_DISPLAY (display);
+
+ self->scale_factor = scale;
+ self->fixed_scale = TRUE;
+ gdk_monitor_set_scale_factor (self->monitor, scale);
+}
+
static GListModel *
gdk_broadway_display_get_monitors (GdkDisplay *display)
{
diff --git a/gdk/broadway/gdkdisplay-broadway.h b/gdk/broadway/gdkdisplay-broadway.h
index 78dfce9a06..1747f2cb0b 100644
--- a/gdk/broadway/gdkdisplay-broadway.h
+++ b/gdk/broadway/gdkdisplay-broadway.h
@@ -57,6 +57,7 @@ struct _GdkBroadwayDisplay
GListStore *monitors;
GdkMonitor *monitor;
int scale_factor;
+ gboolean fixed_scale;
GHashTable *texture_cache;