]> Pileus Git - ~andy/gtk/commitdiff
New function to allow wrapping a native pixmap without a server roundtrip.
authorMatthias Clasen <mclasen@redhat.com>
Thu, 30 Mar 2006 04:08:51 +0000 (04:08 +0000)
committerMatthias Clasen <matthiasc@src.gnome.org>
Thu, 30 Mar 2006 04:08:51 +0000 (04:08 +0000)
2006-03-29  Matthias Clasen <mclasen@redhat.com>

        * gdk/gdk.symbols:
        * gdk/gdkpixmap.h:
        * gdk/win32/gdkpixmap-win32.c:
        * gdk/x11/gdkpixmap-x11.c (gdk_pixmap_foreign_new_for_screen):
        New function to allow wrapping a native pixmap without
        a server roundtrip.  (#334954, David Baron)

ChangeLog
ChangeLog.pre-2-10
docs/reference/gdk/gdk-sections.txt
gdk/gdk.symbols
gdk/gdkpixmap.h
gdk/win32/gdkpixmap-win32.c
gdk/x11/gdkpixmap-x11.c

index 42df3f9f00f861c2785d4a9f81aa3d01baf48039..9b4010964b95c2636c2eb0a2ab22c29c87141dbb 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2006-03-29  Matthias Clasen <mclasen@redhat.com>
 
+       * gdk/gdk.symbols:
+       * gdk/gdkpixmap.h:
+       * gdk/win32/gdkpixmap-win32.c:
+       * gdk/x11/gdkpixmap-x11.c (gdk_pixmap_foreign_new_for_screen):
+       New function to allow wrapping a native pixmap without
+       a server roundtrip.  (#334954, David Baron) 
+
        * gtk/gtk.symbols:
        * gtk/gtkrecent*.c: Fix some symbol aliasing glitches.
 
index 42df3f9f00f861c2785d4a9f81aa3d01baf48039..9b4010964b95c2636c2eb0a2ab22c29c87141dbb 100644 (file)
@@ -1,5 +1,12 @@
 2006-03-29  Matthias Clasen <mclasen@redhat.com>
 
+       * gdk/gdk.symbols:
+       * gdk/gdkpixmap.h:
+       * gdk/win32/gdkpixmap-win32.c:
+       * gdk/x11/gdkpixmap-x11.c (gdk_pixmap_foreign_new_for_screen):
+       New function to allow wrapping a native pixmap without
+       a server roundtrip.  (#334954, David Baron) 
+
        * gtk/gtk.symbols:
        * gtk/gtkrecent*.c: Fix some symbol aliasing glitches.
 
index 7576717bf67008924fd7ce8a5f8792ea5f15ed2a..ceb12dc33bcd2099a8f0a23e9dcf8525eb521b06 100644 (file)
@@ -1254,6 +1254,7 @@ gdkx_visual_get
 gdkx_colormap_get
 gdk_pixmap_foreign_new
 gdk_pixmap_foreign_new_for_display
+gdk_pixmap_foreign_new_for_screen
 gdk_window_foreign_new
 gdk_window_foreign_new_for_display
 gdk_xid_table_lookup
index 9f381a5e6e66e31dfa99d8ff4fb8b6e7cdcf262e..908c549c686a14a5910aaf97955092e60f231f85 100644 (file)
@@ -917,6 +917,7 @@ gdk_pixmap_get_type G_GNUC_CONST
 gdk_pixmap_create_from_data
 gdk_pixmap_foreign_new
 gdk_pixmap_foreign_new_for_display
+gdk_pixmap_foreign_new_for_screen
 gdk_pixmap_lookup
 gdk_pixmap_lookup_for_display
 gdk_pixmap_new
index dd34443c36c88e53a893e76cafb7d35612c11d17..1f9190b48948c500ea4508b0975ecee315916408 100644 (file)
@@ -108,6 +108,11 @@ GdkPixmap*    gdk_pixmap_foreign_new_for_display (GdkDisplay      *display,
                                                  GdkNativeWindow  anid);
 GdkPixmap*    gdk_pixmap_lookup_for_display      (GdkDisplay      *display,
                                                  GdkNativeWindow  anid);
+GdkPixmap*    gdk_pixmap_foreign_new_for_screen  (GdkScreen       *screen,
+                                                 GdkNativeWindow  anid,
+                                                 gint             width,
+                                                  gint             height,
+                                                  gint             depth);
 
 #ifndef GDK_DISABLE_DEPRECATED
 #define gdk_bitmap_ref                 gdk_drawable_ref
index 362ef0759bcef03ca2b5288df60b6540aee06e6e..29193aeb82bfc105d1663c11ef6def1c1b67da58 100644 (file)
@@ -446,6 +446,18 @@ gdk_pixmap_foreign_new_for_display (GdkDisplay      *display,
   return gdk_pixmap_foreign_new (anid);
 }
 
+GdkPixmap *
+gdk_pixmap_foreign_new_for_screen (GdkScreen       *screen,
+                                  GdkNativeWindow  anid,
+                                  gint             width,
+                                  gint             height,
+                                  gint             depth)
+{
+  g_return_val_if_fail (GDK_IS_SCREEN (screen), NULL);
+
+  return gdk_pixmap_foreign_new (anid);
+}
+
 GdkPixmap*
 gdk_pixmap_foreign_new (GdkNativeWindow anid)
 {
index 37849dd67bc66b6600771d4030d1b7093e3d27df..4f58653d444de79b91449e842692788abb8c8888 100644 (file)
@@ -344,11 +344,9 @@ GdkPixmap *
 gdk_pixmap_foreign_new_for_display (GdkDisplay      *display,
                                    GdkNativeWindow  anid)
 {
-  GdkPixmap *pixmap;
-  GdkDrawableImplX11 *draw_impl;
-  GdkPixmapImplX11 *pix_impl;
   Pixmap xpixmap;
   Window root_return;
+  GdkScreen *screen;
   int x_ret, y_ret;
   unsigned int w_ret, h_ret, bw_ret, depth_ret;
 
@@ -367,19 +365,66 @@ gdk_pixmap_foreign_new_for_display (GdkDisplay      *display,
                     xpixmap, &root_return,
                     &x_ret, &y_ret, &w_ret, &h_ret, &bw_ret, &depth_ret))
     return NULL;
+  
+  screen = _gdk_x11_display_screen_for_xrootwin (display, root_return);
+  return gdk_pixmap_foreign_new_for_screen (screen, anid, w_ret, h_ret, depth_ret);
+}
+
+/**
+ * gdk_pixmap_foreign_new_for_screen:
+ * @screen: a #GdkScreen
+ * @anid: a native pixmap handle
+ * @width: the width of the pixmap identified by @anid
+ * @height: the height of the pixmap identified by @anid
+ * @depth: the depth of the pixmap identified by @anid
+ *
+ * Wraps a native pixmap in a #GdkPixmap.
+ * This may fail if the pixmap has been destroyed.
+ *
+ * For example in the X backend, a native pixmap handle is an Xlib
+ * <type>XID</type>.
+ *
+ * This function is an alternative to gdk_pixmap_foreign_new_for_display()
+ * for cases where the dimensions of the pixmap are known. For the X
+ * backend, this avoids a roundtrip to the server.
+ *
+ * Return value: the newly-created #GdkPixmap wrapper for the 
+ *    native pixmap or %NULL if the pixmap has been destroyed.
+ * 
+ * Since: 2.10
+ */
+GdkPixmap *
+gdk_pixmap_foreign_new_for_screen (GdkScreen       *screen,
+                                  GdkNativeWindow  anid,
+                                  gint             width,
+                                  gint             height,
+                                  gint             depth)
+{
+  Pixmap xpixmap;
+  GdkPixmap *pixmap;
+  GdkDrawableImplX11 *draw_impl;
+  GdkPixmapImplX11 *pix_impl;
+
+  g_return_val_if_fail (GDK_IS_SCREEN (screen), NULL);
+  g_return_val_if_fail (anid != 0, NULL);
+  g_return_val_if_fail (width > 0, NULL);
+  g_return_val_if_fail (height > 0, NULL);
+  g_return_val_if_fail (depth > 0, NULL);
 
   pixmap = g_object_new (gdk_pixmap_get_type (), NULL);
   draw_impl = GDK_DRAWABLE_IMPL_X11 (GDK_PIXMAP_OBJECT (pixmap)->impl);
   pix_impl = GDK_PIXMAP_IMPL_X11 (GDK_PIXMAP_OBJECT (pixmap)->impl);
   draw_impl->wrapper = GDK_DRAWABLE (pixmap);
 
-  draw_impl->screen =  _gdk_x11_display_screen_for_xrootwin (display, root_return);
+  xpixmap = anid;
+  
+  draw_impl->screen = screen;
   draw_impl->xid = xpixmap;
 
   pix_impl->is_foreign = TRUE;
-  pix_impl->width = w_ret;
-  pix_impl->height = h_ret;
-  GDK_PIXMAP_OBJECT (pixmap)->depth = depth_ret;
+  pix_impl->width = width;
+  pix_impl->height = height;
+  GDK_PIXMAP_OBJECT (pixmap)->depth = depth;
   
   _gdk_xid_table_insert (display, &GDK_PIXMAP_XID (pixmap), pixmap);