[gtk+/wip/window-scales] x11: Also change size on child windows when scale changes



commit c37478d8b61931bd8bf8c293f864d3cc643e848a
Author: Alexander Larsson <alexl redhat com>
Date:   Fri Jun 28 10:23:54 2013 +0200

    x11: Also change size on child windows when scale changes
    
    Any native windows need to also change size.
    We don't change the size of any foreign windows since we
    don't generally control these.

 gdk/x11/gdkwindow-x11.c |   61 +++++++++++++++++++++++++++++++++--------------
 1 files changed, 43 insertions(+), 18 deletions(-)
---
diff --git a/gdk/x11/gdkwindow-x11.c b/gdk/x11/gdkwindow-x11.c
index 6545944..cd9556d 100644
--- a/gdk/x11/gdkwindow-x11.c
+++ b/gdk/x11/gdkwindow-x11.c
@@ -1889,34 +1889,59 @@ gdk_window_x11_move_resize (GdkWindow *window,
     }
 }
 
+static void
+set_scale_recursive (GdkWindow *window, int scale)
+{
+  GdkWindow *child;
+  GList *l;
+
+  for (l = window->children; l; l = l->next)
+    {
+      child = l->data;
+
+      if (child->impl != window->impl)
+        _gdk_x11_window_set_window_scale (child, scale);
+      else
+        set_scale_recursive (child, scale);
+    }
+}
+
 void
 _gdk_x11_window_set_window_scale (GdkWindow *window,
                                  int scale)
 {
-  GdkWindowImplX11 *impl = GDK_WINDOW_IMPL_X11 (window->impl);
-  gboolean was_mapped;
+  GdkWindowImplX11 *impl;
   GdkToplevelX11 *toplevel;
   GdkWindowHints geom_mask;
 
-  was_mapped = GDK_WINDOW_IS_MAPPED (window);
-  if (was_mapped)
-    gdk_window_hide (window);
+  if (window->window_type == GDK_WINDOW_FOREIGN ||
+      window->window_type == GDK_WINDOW_OFFSCREEN)
+    return;
+
+  impl = GDK_WINDOW_IMPL_X11 (window->impl);
+
   impl->window_scale = scale;
+
   toplevel = _gdk_x11_window_get_toplevel (window);
-  /* These are affected by window scale: */
-  geom_mask = toplevel->last_geometry_hints_mask &
-    (GDK_HINT_MIN_SIZE | GDK_HINT_MAX_SIZE | GDK_HINT_BASE_SIZE | GDK_HINT_RESIZE_INC);
-  if (geom_mask)
-    gdk_window_set_geometry_hints (window,
-                                  &toplevel->last_geometry_hints,
-                                  geom_mask);
-  
+  if (toplevel)
+    {
+      /* These are affected by window scale: */
+      geom_mask = toplevel->last_geometry_hints_mask &
+        (GDK_HINT_MIN_SIZE | GDK_HINT_MAX_SIZE | GDK_HINT_BASE_SIZE | GDK_HINT_RESIZE_INC);
+      if (geom_mask)
+        gdk_window_set_geometry_hints (window,
+                                       &toplevel->last_geometry_hints,
+                                       geom_mask);
+    }
+
   XResizeWindow (GDK_WINDOW_XDISPLAY (window),
-                GDK_WINDOW_XID (window),
-                window->width * impl->window_scale,
-                window->height * impl->window_scale);
-  if (was_mapped)
-    gdk_window_show (window);
+                 GDK_WINDOW_XID (window),
+                 window->width * impl->window_scale,
+                 window->height * impl->window_scale);
+
+  gdk_window_invalidate_rect (window, NULL, TRUE);
+
+  set_scale_recursive (window, scale);
 }
 
 static gboolean


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