diff options
author | Jason Zaman <jason@perfinion.com> | 2018-05-25 11:37:45 +0800 |
---|---|---|
committer | Daniel Boles <dboles.src@gmail.com> | 2018-05-30 11:37:12 +0100 |
commit | 866050d0156722d1da0592c8c46aa586cb88e3fa (patch) | |
tree | 94933613f424b9cd22c0f480443816d0e045868d | |
parent | 7e0db63601f94ddff0fb187e7342d0f3205e91b5 (diff) | |
download | gtk+-866050d0156722d1da0592c8c46aa586cb88e3fa.tar.gz |
gtksocket: Adjust X sizes by scale-factor
X uses unscaled sizes, so they must be scaled properly. Otherwise
GtkSockets end up twice as big as they should be.
Closes: https://bugzilla.gnome.org/show_bug.cgi?id=765327
Signed-off-by: Jason Zaman <jason@perfinion.com>
Close !165
-rw-r--r-- | gtk/gtksocket.c | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/gtk/gtksocket.c b/gtk/gtksocket.c index 03cbf02543..91abb6a706 100644 --- a/gtk/gtksocket.c +++ b/gtk/gtksocket.c @@ -492,26 +492,28 @@ gtk_socket_size_request (GtkSocket *socket) GdkDisplay *display; XSizeHints hints; long supplied; + int scale; display = gtk_widget_get_display (GTK_WIDGET (socket)); gdk_x11_display_error_trap_push (display); private->request_width = 1; private->request_height = 1; - + scale = gtk_widget_get_scale_factor (GTK_WIDGET(socket)); + if (XGetWMNormalHints (GDK_WINDOW_XDISPLAY (private->plug_window), GDK_WINDOW_XID (private->plug_window), &hints, &supplied)) { if (hints.flags & PMinSize) { - private->request_width = MAX (hints.min_width, 1); - private->request_height = MAX (hints.min_height, 1); + private->request_width = MAX (hints.min_width / scale, 1); + private->request_height = MAX (hints.min_height / scale, 1); } else if (hints.flags & PBaseSize) { - private->request_width = MAX (hints.base_width, 1); - private->request_height = MAX (hints.base_height, 1); + private->request_width = MAX (hints.base_width / scale, 1); + private->request_height = MAX (hints.base_height / scale, 1); } } private->have_size = TRUE; @@ -573,7 +575,7 @@ gtk_socket_send_configure_event (GtkSocket *socket) GtkAllocation allocation; XConfigureEvent xconfigure; GdkDisplay *display; - gint x, y; + int x, y, scale; g_return_if_fail (socket->priv->plug_window != NULL); @@ -593,10 +595,11 @@ gtk_socket_send_configure_event (GtkSocket *socket) gdk_x11_display_error_trap_pop_ignored (display); gtk_widget_get_allocation (GTK_WIDGET(socket), &allocation); - xconfigure.x = x; - xconfigure.y = y; - xconfigure.width = allocation.width; - xconfigure.height = allocation.height; + scale = gtk_widget_get_scale_factor (GTK_WIDGET(socket)); + xconfigure.x = x * scale; + xconfigure.y = y * scale; + xconfigure.width = allocation.width * scale; + xconfigure.height = allocation.height * scale; xconfigure.border_width = 0; xconfigure.above = None; |