[gtk+/gtk-3-22] wayland: scale down reported monitor geometry
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/gtk-3-22] wayland: scale down reported monitor geometry
- Date: Fri, 27 Oct 2017 20:13:00 +0000 (UTC)
commit 8ef20c0e2f4728b8d0f3bede51cc56e1f9b94982
Author: Olivier Fourdan <ofourdan redhat com>
Date: Tue Jun 27 11:12:57 2017 +0200
wayland: scale down reported monitor geometry
According to the documentation, gdk_monitor_get_geometry() reports the
monitor geometry in ”application pixels”, not in ”device pixels”,
meaning that the actual device resolution needs to be scaled down by the
scale factor of the output.
x11 backend does that downscaling, whereas Wayland backend did not,
causing a discrepancy depending on the backend used.
https://bugzilla.gnome.org/show_bug.cgi?id=783995
gdk/wayland/gdkscreen-wayland.c | 15 ++++++++++++++-
1 files changed, 14 insertions(+), 1 deletions(-)
---
diff --git a/gdk/wayland/gdkscreen-wayland.c b/gdk/wayland/gdkscreen-wayland.c
index b8516ee..9af09d4 100644
--- a/gdk/wayland/gdkscreen-wayland.c
+++ b/gdk/wayland/gdkscreen-wayland.c
@@ -1050,11 +1050,22 @@ output_handle_scale (void *data,
int32_t scale)
{
GdkWaylandMonitor *monitor = (GdkWaylandMonitor *)data;
+ GdkRectangle previous_geometry;
+ int previous_scale;
+ int width;
+ int height;
GDK_NOTE (MISC,
g_message ("handle scale output %d, scale %d", monitor->id, scale));
+ gdk_monitor_get_geometry (GDK_MONITOR (monitor), &previous_geometry);
+ previous_scale = gdk_monitor_get_scale_factor (GDK_MONITOR (monitor));
+
+ width = previous_geometry.width * previous_scale;
+ height = previous_geometry.height * previous_scale;
+
gdk_monitor_set_scale_factor (GDK_MONITOR (monitor), scale);
+ gdk_monitor_set_size (GDK_MONITOR (monitor), width / scale, height / scale);
if (GDK_MONITOR (monitor)->geometry.width != 0 && monitor->version < OUTPUT_VERSION_WITH_DONE)
{
@@ -1072,6 +1083,7 @@ output_handle_mode (void *data,
int refresh)
{
GdkWaylandMonitor *monitor = (GdkWaylandMonitor *)data;
+ int scale;
GDK_NOTE (MISC,
g_message ("handle mode output %d, size %d %d, rate %d",
@@ -1080,7 +1092,8 @@ output_handle_mode (void *data,
if ((flags & WL_OUTPUT_MODE_CURRENT) == 0)
return;
- gdk_monitor_set_size (GDK_MONITOR (monitor), width, height);
+ scale = gdk_monitor_get_scale_factor (GDK_MONITOR (monitor));
+ gdk_monitor_set_size (GDK_MONITOR (monitor), width / scale, height / scale);
gdk_monitor_set_refresh_rate (GDK_MONITOR (monitor), refresh);
if (width != 0 && monitor->version < OUTPUT_VERSION_WITH_DONE)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]