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



commit 13ae421a4a2881c26a20f5fedf18fd2584342ab4
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 26c0682..8d44d75 100644
--- a/gdk/gdkinternals.h
+++ b/gdk/gdkinternals.h
@@ -195,6 +195,7 @@ struct _GdkWindowObject
   GdkDrawable *impl; /* window-system-specific delegate object */  
   
   GdkWindowObject *parent;
+  GdkVisual *visual;
 
   gpointer user_data;
 
@@ -328,7 +329,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);
@@ -559,7 +559,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 1605b39..cf43dfa 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 8e0798a..aa4a3f1 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;
@@ -1368,16 +1367,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);
@@ -1403,7 +1402,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)
@@ -1411,7 +1410,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
@@ -1776,7 +1775,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;
@@ -1811,13 +1809,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 89c0ea3..a726a8d 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)
@@ -844,19 +843,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);
 	    }
 	}
     }
@@ -1045,6 +1044,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 d41c5c6..6752f9f 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);
   
@@ -440,7 +441,6 @@ void
 _gdk_window_impl_new (GdkWindow     *window,
 		      GdkWindow     *real_parent,
 		      GdkScreen     *screen,
-		      GdkVisual     *visual,
 		      GdkEventMask   event_mask,
 		      GdkWindowAttr *attributes,
 		      gint           attributes_mask)
@@ -499,7 +499,6 @@ _gdk_window_impl_new (GdkWindow     *window,
       dwExStyle = 0;
 
       private->input_only = FALSE;
-      private->depth = visual->depth;
       
       if (attributes_mask & GDK_WA_COLORMAP)
 	{
@@ -693,6 +692,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 f27ffe0..b9d2b81 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);
   
@@ -693,7 +694,6 @@ void
 _gdk_window_impl_new (GdkWindow     *window,
 		      GdkWindow     *real_parent,
 		      GdkScreen     *screen,
-		      GdkVisual     *visual,
 		      GdkEventMask   event_mask,
 		      GdkWindowAttr *attributes,
 		      gint           attributes_mask)
@@ -732,7 +732,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)
     {
@@ -775,14 +775,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);
             }
 	}
       
@@ -923,6 +923,7 @@ GdkWindow *
 gdk_window_foreign_new_for_display (GdkDisplay     *display,
 				    GdkNativeWindow anid)
 {
+  GdkScreen *screen;
   GdkWindow *window;
   GdkWindowObject *private;
   GdkWindowImplX11 *impl;
@@ -956,16 +957,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]