[gtk/broadway-display-scale] broadway: Add a setter for display scale
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/broadway-display-scale] broadway: Add a setter for display scale
- Date: Sun, 9 May 2021 23:43:36 +0000 (UTC)
commit 6837e6e565b6dd871e223f356845f1be463f8f9d
Author: Matthias Clasen <mclasen redhat com>
Date: Sun May 9 19:42:42 2021 -0400
broadway: Add a setter for display scale
This is useful when using Broadway as a headless
display server.
Fixes: #3934
gdk/broadway/gdkbroadwaydisplay.h | 4 ++++
gdk/broadway/gdkdisplay-broadway.c | 38 ++++++++++++++++++++++++++++++++++++--
gdk/broadway/gdkdisplay-broadway.h | 1 +
3 files changed, 41 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..c4b54d53d4 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,38 @@ 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)
+{
+ GdkMonitor *monitor;
+
+ g_return_if_fail (GDK_IS_BROADWAY_DISPLAY (display));
+ g_return_if_fail (scale > 0);
+
+ monitor = broadway_display->monitor;
+
+ broadway_display->scale_factor = msg->scale;
+ broadway_display->fixed_scale = TRUE;
+
+ gdk_monitor_set_scale_factor (monitor, msg->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;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]