[gtk+/rendering-cleanup: 120/141] gdk: store the visual in the GdkWindowObject



commit f0470d6ec6b2586b08aa566c1a178347fa34ff64
Author: Benjamin Otte <otte redhat com>
Date:   Sun Aug 29 01:05:59 2010 +0200

    gdk: store the visual in the GdkWindowObject

 gdk/gdkinternals.h            |    3 +--
 gdk/gdkoffscreenwindow.c      |    5 ++---
 gdk/gdkwindow.c               |   15 ++++++---------
 gdk/quartz/gdkwindow-quartz.c |    8 ++++----
 gdk/win32/gdkwindow-win32.c   |    4 ++--
 gdk/x11/gdkwindow-x11.c       |   15 ++++++++++-----
 6 files changed, 25 insertions(+), 25 deletions(-)
---
diff --git a/gdk/gdkinternals.h b/gdk/gdkinternals.h
index 2869364..1dd00dc 100644
--- a/gdk/gdkinternals.h
+++ b/gdk/gdkinternals.h
@@ -193,6 +193,7 @@ struct _GdkWindowObject
   GdkDrawable *impl; /* window-system-specific delegate object */  
   
   GdkWindowObject *parent;
+  GdkVisual *visual;
 
   gpointer user_data;
 
@@ -326,7 +327,6 @@ cairo_surface_t * _gdk_drawable_create_cairo_surface (GdkDrawable *drawable,
 void       _gdk_window_impl_new          (GdkWindow      *window,
 					  GdkWindow      *real_parent,
 					  GdkScreen      *screen,
-					  GdkVisual      *visual,
 					  GdkEventMask    event_mask,
                                           GdkWindowAttr  *attributes,
                                           gint            attributes_mask);
@@ -557,7 +557,6 @@ GdkWindow *_gdk_window_get_input_window_for_event (GdkWindow *native_window,
 GType gdk_offscreen_window_get_type (void);
 void       _gdk_offscreen_window_new                 (GdkWindow     *window,
 						      GdkScreen     *screen,
-						      GdkVisual     *visual,
 						      GdkWindowAttr *attributes,
 						      gint           attributes_mask);
 
diff --git a/gdk/gdkoffscreenwindow.c b/gdk/gdkoffscreenwindow.c
index e231f62..37cf41b 100644
--- a/gdk/gdkoffscreenwindow.c
+++ b/gdk/gdkoffscreenwindow.c
@@ -175,7 +175,6 @@ gdk_offscreen_window_get_visual (GdkDrawable    *drawable)
 void
 _gdk_offscreen_window_new (GdkWindow     *window,
 			   GdkScreen     *screen,
-			   GdkVisual     *visual,
 			   GdkWindowAttr *attributes,
 			   gint           attributes_mask)
 {
@@ -202,13 +201,13 @@ _gdk_offscreen_window_new (GdkWindow     *window,
     offscreen->colormap = g_object_ref (attributes->colormap);
   else
     {
-      if (gdk_screen_get_system_visual (screen) == visual)
+      if (gdk_screen_get_system_visual (screen) == private->visual)
 	{
 	  offscreen->colormap = gdk_screen_get_system_colormap (screen);
 	  g_object_ref (offscreen->colormap);
 	}
       else
-	offscreen->colormap = gdk_colormap_new (visual, FALSE);
+	offscreen->colormap = gdk_colormap_new (private->visual, FALSE);
     }
 
   offscreen->surface = gdk_window_create_similar_surface ((GdkWindow *)private->parent,
diff --git a/gdk/gdkwindow.c b/gdk/gdkwindow.c
index 82bd971..c992132 100644
--- a/gdk/gdkwindow.c
+++ b/gdk/gdkwindow.c
@@ -1257,7 +1257,6 @@ gdk_window_new (GdkWindow     *parent,
   GdkWindow *window;
   GdkWindowObject *private;
   GdkScreen *screen;
-  GdkVisual *visual;
   int x, y;
   gboolean native;
   GdkEventMask event_mask;
@@ -1367,16 +1366,16 @@ gdk_window_new (GdkWindow     *parent,
     }
 
   if (attributes_mask & GDK_WA_VISUAL)
-    visual = attributes->visual;
+    private->visual = attributes->visual;
   else
-    visual = gdk_screen_get_system_visual (screen);
+    private->visual = gdk_screen_get_system_visual (screen);
 
   private->event_mask = attributes->event_mask;
 
   if (attributes->wclass == GDK_INPUT_OUTPUT)
     {
       private->input_only = FALSE;
-      private->depth = visual->depth;
+      private->depth = private->visual->depth;
 
       /* XXX: Cache this somehow? */
       private->background = cairo_pattern_create_rgb (0, 0, 0);
@@ -1402,7 +1401,7 @@ gdk_window_new (GdkWindow     *parent,
 
   if (gdk_window_is_offscreen (private))
     {
-      _gdk_offscreen_window_new (window, screen, visual, attributes, attributes_mask);
+      _gdk_offscreen_window_new (window, screen, attributes, attributes_mask);
       private->impl_window = private;
     }
   else if (native)
@@ -1410,7 +1409,7 @@ gdk_window_new (GdkWindow     *parent,
       event_mask = get_native_event_mask (private);
 
       /* Create the impl */
-      _gdk_window_impl_new (window, real_parent, screen, visual, event_mask, attributes, attributes_mask);
+      _gdk_window_impl_new (window, real_parent, screen, event_mask, attributes, attributes_mask);
       private->impl_window = private;
 
       /* This will put the native window topmost in the native parent, which may
@@ -1774,7 +1773,6 @@ gdk_window_ensure_native (GdkWindow *window)
   GdkWindowObject *impl_window;
   GdkDrawable *new_impl, *old_impl;
   GdkScreen *screen;
-  GdkVisual *visual;
   GdkWindowAttr attributes;
   GdkWindowObject *above;
   GList listhead;
@@ -1809,13 +1807,12 @@ gdk_window_ensure_native (GdkWindow *window)
   gdk_window_drop_cairo_surface (private);
 
   screen = gdk_drawable_get_screen (window);
-  visual = gdk_drawable_get_visual (window);
 
   attributes.colormap = gdk_drawable_get_colormap (window);
 
   old_impl = private->impl;
   _gdk_window_impl_new (window, (GdkWindow *)private->parent,
-			screen, visual,
+			screen,
 			get_native_event_mask (private),
 			&attributes, GDK_WA_COLORMAP);
   new_impl = private->impl;
diff --git a/gdk/quartz/gdkwindow-quartz.c b/gdk/quartz/gdkwindow-quartz.c
index 4692432..3f0b2e4 100644
--- a/gdk/quartz/gdkwindow-quartz.c
+++ b/gdk/quartz/gdkwindow-quartz.c
@@ -802,7 +802,6 @@ void
 _gdk_window_impl_new (GdkWindow     *window,
 		      GdkWindow     *real_parent,
 		      GdkScreen     *screen,
-		      GdkVisual     *visual,
 		      GdkEventMask   event_mask,
 		      GdkWindowAttr *attributes,
 		      gint           attributes_mask)
@@ -843,19 +842,19 @@ _gdk_window_impl_new (GdkWindow     *window,
 	}
       else
 	{
-	  if (visual == gdk_screen_get_system_visual (_gdk_screen))
+	  if (private->visual == gdk_screen_get_system_visual (_gdk_screen))
 	    {
 	      draw_impl->colormap = gdk_screen_get_system_colormap (_gdk_screen);
 	      g_object_ref (draw_impl->colormap);
 	    }
-	  else if (visual == gdk_screen_get_rgba_visual (_gdk_screen))
+	  else if (private->visual == gdk_screen_get_rgba_visual (_gdk_screen))
 	    {
 	      draw_impl->colormap = gdk_screen_get_rgba_colormap (_gdk_screen);
 	      g_object_ref (draw_impl->colormap);
 	    }
 	  else
 	    {
-	      draw_impl->colormap = gdk_colormap_new (visual, FALSE);
+	      draw_impl->colormap = gdk_colormap_new (private->visual, FALSE);
 	    }
 	}
     }
@@ -1043,6 +1042,7 @@ _gdk_windowing_window_init (void)
   private = (GdkWindowObject *)_gdk_root;
   private->impl = g_object_new (_gdk_window_impl_get_type (), NULL);
   private->impl_window = private;
+  private->visual = gdk_screen_get_system_visual (_gdk_screen);
 
   impl = GDK_WINDOW_IMPL_QUARTZ (GDK_WINDOW_OBJECT (_gdk_root)->impl);
 
diff --git a/gdk/win32/gdkwindow-win32.c b/gdk/win32/gdkwindow-win32.c
index 0ec688b..69be5aa 100644
--- a/gdk/win32/gdkwindow-win32.c
+++ b/gdk/win32/gdkwindow-win32.c
@@ -236,6 +236,7 @@ _gdk_windowing_window_init (GdkScreen *screen)
   private = (GdkWindowObject *)_gdk_root;
   private->impl = g_object_new (_gdk_window_impl_get_type (), NULL);
   private->impl_window = private;
+  private->visual = gdk_screen_get_system_visual (screen);
 
   draw_impl = GDK_DRAWABLE_IMPL_WIN32 (private->impl);
   
@@ -428,7 +429,6 @@ void
 _gdk_window_impl_new (GdkWindow     *window,
 		      GdkWindow     *real_parent,
 		      GdkScreen     *screen,
-		      GdkVisual     *visual,
 		      GdkEventMask   event_mask,
 		      GdkWindowAttr *attributes,
 		      gint           attributes_mask)
@@ -486,7 +486,6 @@ _gdk_window_impl_new (GdkWindow     *window,
       dwExStyle = 0;
 
       private->input_only = FALSE;
-      private->depth = visual->depth;
       
       if (attributes_mask & GDK_WA_COLORMAP)
 	{
@@ -679,6 +678,7 @@ gdk_window_foreign_new_for_display (GdkDisplay      *display,
 
   window = g_object_new (GDK_TYPE_WINDOW, NULL);
   private = (GdkWindowObject *)window;
+  private->visual = gdk_screen_get_system_visual (_gdk_screen);
   private->impl = g_object_new (_gdk_window_impl_get_type (), NULL);
   impl = GDK_WINDOW_IMPL_WIN32 (private->impl);
   draw_impl = GDK_DRAWABLE_IMPL_WIN32 (private->impl);
diff --git a/gdk/x11/gdkwindow-x11.c b/gdk/x11/gdkwindow-x11.c
index 01bff86..718ed27 100644
--- a/gdk/x11/gdkwindow-x11.c
+++ b/gdk/x11/gdkwindow-x11.c
@@ -470,6 +470,7 @@ _gdk_windowing_window_init (GdkScreen * screen)
   private = (GdkWindowObject *) screen_x11->root_window;
   private->impl = g_object_new (_gdk_window_impl_get_type (), NULL);
   private->impl_window = private;
+  private->visual = gdk_screen_get_system_visual (screen);
 
   draw_impl = GDK_DRAWABLE_IMPL_X11 (private->impl);
   
@@ -689,7 +690,6 @@ void
 _gdk_window_impl_new (GdkWindow     *window,
 		      GdkWindow     *real_parent,
 		      GdkScreen     *screen,
-		      GdkVisual     *visual,
 		      GdkEventMask   event_mask,
 		      GdkWindowAttr *attributes,
 		      gint           attributes_mask)
@@ -728,7 +728,7 @@ _gdk_window_impl_new (GdkWindow     *window,
 
   xattributes_mask = 0;
 
-  xvisual = ((GdkVisualPrivate*) visual)->xvisual;
+  xvisual = ((GdkVisualPrivate*) private->visual)->xvisual;
   
   if (attributes_mask & GDK_WA_NOREDIR)
     {
@@ -770,14 +770,14 @@ _gdk_window_impl_new (GdkWindow     *window,
         }
       else
 	{
-	  if ((((GdkVisualPrivate *)gdk_screen_get_system_visual (screen))->xvisual) ==  xvisual)
+	  if ((((GdkVisualPrivate *)gdk_screen_get_system_visual (screen))->xvisual) == xvisual)
             {
 	      draw_impl->colormap = gdk_screen_get_system_colormap (screen);
               g_object_ref (draw_impl->colormap);
             }
 	  else
             {
-              draw_impl->colormap = gdk_colormap_new (visual, FALSE);
+              draw_impl->colormap = gdk_colormap_new (private->visual, FALSE);
             }
 	}
       
@@ -917,6 +917,7 @@ GdkWindow *
 gdk_window_foreign_new_for_display (GdkDisplay     *display,
 				    GdkNativeWindow anid)
 {
+  GdkScreen *screen;
   GdkWindow *window;
   GdkWindowObject *private;
   GdkWindowImplX11 *impl;
@@ -950,16 +951,20 @@ gdk_window_foreign_new_for_display (GdkDisplay     *display,
   if (children)
     XFree (children);
   
+  screen = _gdk_x11_display_screen_for_xrootwin (display, root);
+
   window = g_object_new (GDK_TYPE_WINDOW, NULL);
 
   private = (GdkWindowObject *) window;
   private->impl = g_object_new (_gdk_window_impl_get_type (), NULL);
   private->impl_window = private;
+  private->visual = gdk_x11_screen_lookup_visual (screen,
+                                                  XVisualIDFromVisual (attrs.visual));
 
   impl = GDK_WINDOW_IMPL_X11 (private->impl);
   draw_impl = GDK_DRAWABLE_IMPL_X11 (private->impl);
   draw_impl->wrapper = GDK_DRAWABLE (window);
-  draw_impl->screen = _gdk_x11_display_screen_for_xrootwin (display, root);
+  draw_impl->screen = screen;
   
   private->parent = gdk_xid_table_lookup_for_display (display, parent);
   



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