[gtk/gtk-3-22: 1/2] gtksocket: Adjust X sizes by scale-factor



commit c8b0a0dea5cd129d8e023443dde5e44319d4631d
Author: Jason Zaman <jason perfinion com>
Date:   Fri May 25 11:37:45 2018 +0800

    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>

 gtk/gtksocket.c | 23 +++++++++++++----------
 1 file 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;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]