[PATCH] Make some GDK functions accept GdkDrawable instead of GdkWindow
- From: Kristian Rietveld <kris gtk org>
- To: GTK Development list <gtk-devel-list gnome org>
- Cc: tml iki fi
- Subject: [PATCH] Make some GDK functions accept GdkDrawable instead of GdkWindow
- Date: 10 Nov 2002 12:38:50 +0100
Hello,
I also mailed about this half a year ago, but didn't get a response. So
I'm resending this before it is too late (:
Some functions in GDK, gdk_pixmap_new for example, should accept a
GdkDrawable, but only accept a GdkWindow at the moment. Attached patch
fixes this in "general GDK" and the X11 backend. It is against the HEAD
branch.
I'm not sure if this fix is okay for other backends. According to Sven,
it wouldn't introduce any problems for the DirectFB backend (yes, I
dived in my archives :). But I was browsing through the source of the
win32 backend, and saw things like
GDK_WINDOW_HWND (window)
and I don't know if it's possible to get a Hwnd from every possible
drawable.
I already committed a likewise patch, only modifying the functions in
the X11 backend on stable:
Sat Apr 20 16:49:26 2002 Kristian Rietveld <kris gtk org>
* gdk/x11/gdkpixmap-x11.c (gdk_pixmap_new): replace
GDK_IS_WINDOW with GDK_IS_DRAWABLE in the assert, only check
GDK_WINDOW_DESTROYED if window is a GdkWindow,
(gdk_bitmap_create_from_data): ditto,
(gdk_pixmap_create_from_data): ditto
So I think it is important to fix this up before 2.2.0 goes out.
thanks,
Kris
Index: gdkwindow.c
===================================================================
RCS file: /cvs/gnome/gtk+/gdk/gdkwindow.c,v
retrieving revision 1.135
diff -u -p -r1.135 gdkwindow.c
--- gdkwindow.c 21 Mar 2002 15:04:41 -0000 1.135
+++ gdkwindow.c 21 Apr 2002 13:59:00 -0000
@@ -1393,7 +1393,7 @@ gdk_window_draw_text_wc (GdkDrawable
}
static GdkDrawable*
-gdk_window_get_composite_drawable (GdkDrawable *window,
+gdk_window_get_composite_drawable (GdkDrawable *drawable,
gint x,
gint y,
gint width,
@@ -1401,7 +1401,7 @@ gdk_window_get_composite_drawable (GdkDr
gint *composite_x_offset,
gint *composite_y_offset)
{
- GdkWindowObject *private = (GdkWindowObject *)window;
+ GdkWindowObject *private = (GdkWindowObject *)drawable;
GdkWindowPaint *paint;
GdkRegion *buffered_region;
GSList *tmp_list;
@@ -1413,14 +1413,15 @@ gdk_window_get_composite_drawable (GdkDr
gint windowing_x_offset, windowing_y_offset;
gint buffer_x_offset, buffer_y_offset;
- if (GDK_WINDOW_DESTROYED (window) || private->paint_stack == NULL)
+ if ((GDK_IS_WINDOW (drawable) && GDK_WINDOW_DESTROYED (drawable))
+ || private->paint_stack == NULL)
{
/* No backing store */
- _gdk_windowing_window_get_offsets (window,
+ _gdk_windowing_window_get_offsets (drawable,
composite_x_offset,
composite_y_offset);
- return GDK_DRAWABLE (g_object_ref (G_OBJECT (window)));
+ return GDK_DRAWABLE (g_object_ref (G_OBJECT (drawable)));
}
buffered_region = NULL;
@@ -1466,20 +1467,20 @@ gdk_window_get_composite_drawable (GdkDr
{
gdk_region_destroy (buffered_region);
- _gdk_windowing_window_get_offsets (window,
+ _gdk_windowing_window_get_offsets (drawable,
composite_x_offset,
composite_y_offset);
- return GDK_DRAWABLE (g_object_ref (G_OBJECT (window)));
+ return GDK_DRAWABLE (g_object_ref (G_OBJECT (drawable)));
}
- tmp_pixmap = gdk_pixmap_new (window,
+ tmp_pixmap = gdk_pixmap_new (drawable,
width, height,
-1);
tmp_gc = gdk_gc_new (tmp_pixmap);
- _gdk_windowing_window_get_offsets (window,
+ _gdk_windowing_window_get_offsets (drawable,
&windowing_x_offset,
&windowing_y_offset);
@@ -1974,8 +1975,6 @@ gdk_window_real_get_visual (GdkDrawable
static gint
gdk_window_real_get_depth (GdkDrawable *drawable)
{
- gint depth;
-
g_return_val_if_fail (GDK_IS_WINDOW (drawable), 0);
return ((GdkWindowObject *)GDK_WINDOW (drawable))->depth;
Index: gdkpixmap.c
===================================================================
RCS file: /cvs/gnome/gtk+/gdk/gdkpixmap.c,v
retrieving revision 1.39
diff -u -p -r1.39 gdkpixmap.c
--- gdkpixmap.c 4 Jan 2002 05:57:58 -0000 1.39
+++ gdkpixmap.c 21 Apr 2002 13:59:01 -0000
@@ -543,7 +543,7 @@ gdk_pixmap_colormap_new_from_pixbuf (Gdk
}
GdkPixmap*
-gdk_pixmap_colormap_create_from_xpm (GdkWindow *window,
+gdk_pixmap_colormap_create_from_xpm (GdkDrawable *drawable,
GdkColormap *colormap,
GdkBitmap **mask,
GdkColor *transparent_color,
@@ -552,12 +552,12 @@ gdk_pixmap_colormap_create_from_xpm (Gdk
GdkPixbuf *pixbuf;
GdkPixmap *pixmap;
- g_return_val_if_fail (window != NULL || colormap != NULL, NULL);
- g_return_val_if_fail (window == NULL || GDK_IS_WINDOW (window), NULL);
+ g_return_val_if_fail (drawable != NULL || colormap != NULL, NULL);
+ g_return_val_if_fail (drawable == NULL || GDK_IS_DRAWABLE (drawable), NULL);
g_return_val_if_fail (colormap == NULL || GDK_IS_COLORMAP (colormap), NULL);
if (colormap == NULL)
- colormap = gdk_drawable_get_colormap (window);
+ colormap = gdk_drawable_get_colormap (drawable);
pixbuf = gdk_pixbuf_new_from_file (filename, NULL);
if (!pixbuf)
@@ -571,17 +571,17 @@ gdk_pixmap_colormap_create_from_xpm (Gdk
}
GdkPixmap*
-gdk_pixmap_create_from_xpm (GdkWindow *window,
- GdkBitmap **mask,
- GdkColor *transparent_color,
+gdk_pixmap_create_from_xpm (GdkDrawable *drawable,
+ GdkBitmap **mask,
+ GdkColor *transparent_color,
const gchar *filename)
{
- return gdk_pixmap_colormap_create_from_xpm (window, NULL, mask,
+ return gdk_pixmap_colormap_create_from_xpm (drawable, NULL, mask,
transparent_color, filename);
}
GdkPixmap*
-gdk_pixmap_colormap_create_from_xpm_d (GdkWindow *window,
+gdk_pixmap_colormap_create_from_xpm_d (GdkDrawable *drawable,
GdkColormap *colormap,
GdkBitmap **mask,
GdkColor *transparent_color,
@@ -590,12 +590,12 @@ gdk_pixmap_colormap_create_from_xpm_d (G
GdkPixbuf *pixbuf;
GdkPixmap *pixmap;
- g_return_val_if_fail (window != NULL || colormap != NULL, NULL);
- g_return_val_if_fail (window == NULL || GDK_IS_WINDOW (window), NULL);
+ g_return_val_if_fail (drawable != NULL || colormap != NULL, NULL);
+ g_return_val_if_fail (drawable == NULL || GDK_IS_DRAWABLE (drawable), NULL);
g_return_val_if_fail (colormap == NULL || GDK_IS_COLORMAP (colormap), NULL);
if (colormap == NULL)
- colormap = gdk_drawable_get_colormap (window);
+ colormap = gdk_drawable_get_colormap (drawable);
pixbuf = gdk_pixbuf_new_from_xpm_data ((const char **)data);
if (!pixbuf)
@@ -609,12 +609,12 @@ gdk_pixmap_colormap_create_from_xpm_d (G
}
GdkPixmap*
-gdk_pixmap_create_from_xpm_d (GdkWindow *window,
- GdkBitmap **mask,
- GdkColor *transparent_color,
- gchar **data)
+gdk_pixmap_create_from_xpm_d (GdkDrawable *drawable,
+ GdkBitmap **mask,
+ GdkColor *transparent_color,
+ gchar **data)
{
- return gdk_pixmap_colormap_create_from_xpm_d (window, NULL, mask,
+ return gdk_pixmap_colormap_create_from_xpm_d (drawable, NULL, mask,
transparent_color, data);
}
Index: gdkpixmap.h
===================================================================
RCS file: /cvs/gnome/gtk+/gdk/gdkpixmap.h,v
retrieving revision 1.10
diff -u -p -r1.10 gdkpixmap.h
--- gdkpixmap.h 18 Oct 2001 20:23:16 -0000 1.10
+++ gdkpixmap.h 21 Apr 2002 13:59:01 -0000
@@ -38,15 +38,15 @@ GType gdk_pixmap_get_type
/* Pixmaps
*/
-GdkPixmap* gdk_pixmap_new (GdkWindow *window,
- gint width,
- gint height,
- gint depth);
-GdkBitmap* gdk_bitmap_create_from_data (GdkWindow *window,
+GdkPixmap* gdk_pixmap_new (GdkDrawable *drawable,
+ gint width,
+ gint height,
+ gint depth);
+GdkBitmap* gdk_bitmap_create_from_data (GdkDrawable *drawable,
const gchar *data,
gint width,
gint height);
-GdkPixmap* gdk_pixmap_create_from_data (GdkWindow *window,
+GdkPixmap* gdk_pixmap_create_from_data (GdkDrawable *drawable,
const gchar *data,
gint width,
gint height,
@@ -54,20 +54,20 @@ GdkPixmap* gdk_pixmap_create_from_data (
GdkColor *fg,
GdkColor *bg);
-GdkPixmap* gdk_pixmap_create_from_xpm (GdkWindow *window,
+GdkPixmap* gdk_pixmap_create_from_xpm (GdkDrawable *drawable,
GdkBitmap **mask,
GdkColor *transparent_color,
const gchar *filename);
-GdkPixmap* gdk_pixmap_colormap_create_from_xpm (GdkWindow *window,
+GdkPixmap* gdk_pixmap_colormap_create_from_xpm (GdkDrawable *drawable,
GdkColormap *colormap,
GdkBitmap **mask,
GdkColor *transparent_color,
const gchar *filename);
-GdkPixmap* gdk_pixmap_create_from_xpm_d (GdkWindow *window,
+GdkPixmap* gdk_pixmap_create_from_xpm_d (GdkDrawable *drawable,
GdkBitmap **mask,
GdkColor *transparent_color,
gchar **data);
-GdkPixmap* gdk_pixmap_colormap_create_from_xpm_d (GdkWindow *window,
+GdkPixmap* gdk_pixmap_colormap_create_from_xpm_d (GdkDrawable *drawable,
GdkColormap *colormap,
GdkBitmap **mask,
GdkColor *transparent_color,
Index: x11/gdkpixmap-x11.c
===================================================================
RCS file: /cvs/gnome/gtk+/gdk/x11/gdkpixmap-x11.c,v
retrieving revision 1.47
diff -u -p -r1.47 gdkpixmap-x11.c
--- x11/gdkpixmap-x11.c 20 Apr 2002 14:45:28 -0000 1.47
+++ x11/gdkpixmap-x11.c 21 Apr 2002 13:59:01 -0000
@@ -52,8 +52,8 @@ typedef struct
} _GdkPixmapInfo;
static void gdk_pixmap_impl_x11_get_size (GdkDrawable *drawable,
- gint *width,
- gint *height);
+ gint *width,
+ gint *height);
static void gdk_pixmap_impl_x11_init (GdkPixmapImplX11 *pixmap);
static void gdk_pixmap_impl_x11_class_init (GdkPixmapImplX11Class *klass);
@@ -151,10 +151,10 @@ gdk_pixmap_impl_x11_get_size (GdkDrawa
}
GdkPixmap*
-gdk_pixmap_new (GdkWindow *window,
- gint width,
- gint height,
- gint depth)
+gdk_pixmap_new (GdkDrawable *drawable,
+ gint width,
+ gint height,
+ gint depth)
{
GdkPixmap *pixmap;
GdkDrawableImplX11 *draw_impl;
@@ -162,17 +162,17 @@ gdk_pixmap_new (GdkWindow *window,
GdkColormap *cmap;
gint window_depth;
- g_return_val_if_fail (window == NULL || GDK_IS_DRAWABLE (window), NULL);
- g_return_val_if_fail ((window != NULL) || (depth != -1), NULL);
+ g_return_val_if_fail (drawable == NULL || GDK_IS_DRAWABLE (drawable), NULL);
+ g_return_val_if_fail ((drawable != NULL) || (depth != -1), NULL);
g_return_val_if_fail ((width != 0) && (height != 0), NULL);
- if (!window)
- window = _gdk_parent_root;
+ if (!drawable)
+ drawable = _gdk_parent_root;
- if (GDK_IS_WINDOW (window) && GDK_WINDOW_DESTROYED (window))
+ if (GDK_IS_WINDOW (drawable) && GDK_WINDOW_DESTROYED (drawable))
return NULL;
- window_depth = gdk_drawable_get_depth (GDK_DRAWABLE (window));
+ window_depth = gdk_drawable_get_depth (GDK_DRAWABLE (drawable));
if (depth == -1)
depth = window_depth;
@@ -181,9 +181,9 @@ gdk_pixmap_new (GdkWindow *window,
pix_impl = GDK_PIXMAP_IMPL_X11 (GDK_PIXMAP_OBJECT (pixmap)->impl);
draw_impl->wrapper = GDK_DRAWABLE (pixmap);
- draw_impl->xdisplay = GDK_WINDOW_XDISPLAY (window);
+ draw_impl->xdisplay = GDK_WINDOW_XDISPLAY (drawable);
draw_impl->xid = XCreatePixmap (GDK_PIXMAP_XDISPLAY (pixmap),
- GDK_WINDOW_XID (window),
+ GDK_WINDOW_XID (drawable),
width, height, depth);
pix_impl->is_foreign = FALSE;
@@ -193,7 +193,7 @@ gdk_pixmap_new (GdkWindow *window,
if (depth == window_depth)
{
- cmap = gdk_drawable_get_colormap (window);
+ cmap = gdk_drawable_get_colormap (drawable);
if (cmap)
gdk_drawable_set_colormap (pixmap, cmap);
}
@@ -204,7 +204,7 @@ gdk_pixmap_new (GdkWindow *window,
}
GdkPixmap *
-gdk_bitmap_create_from_data (GdkWindow *window,
+gdk_bitmap_create_from_data (GdkDrawable *drawable,
const gchar *data,
gint width,
gint height)
@@ -215,12 +215,12 @@ gdk_bitmap_create_from_data (GdkWindow
g_return_val_if_fail (data != NULL, NULL);
g_return_val_if_fail ((width != 0) && (height != 0), NULL);
- g_return_val_if_fail (window == NULL || GDK_IS_DRAWABLE (window), NULL);
+ g_return_val_if_fail (drawable == NULL || GDK_IS_DRAWABLE (drawable), NULL);
- if (!window)
- window = _gdk_parent_root;
+ if (!drawable)
+ drawable = _gdk_parent_root;
- if (GDK_IS_WINDOW (window) && GDK_WINDOW_DESTROYED (window))
+ if (GDK_IS_WINDOW (drawable) && GDK_WINDOW_DESTROYED (drawable))
return NULL;
pixmap = g_object_new (gdk_pixmap_get_type (), NULL);
@@ -233,9 +233,9 @@ gdk_bitmap_create_from_data (GdkWindow
pix_impl->height = height;
GDK_PIXMAP_OBJECT (pixmap)->depth = 1;
- draw_impl->xdisplay = GDK_WINDOW_XDISPLAY (window);
- draw_impl->xid = XCreateBitmapFromData (GDK_WINDOW_XDISPLAY (window),
- GDK_WINDOW_XID (window),
+ draw_impl->xdisplay = GDK_WINDOW_XDISPLAY (drawable);
+ draw_impl->xid = XCreateBitmapFromData (GDK_WINDOW_XDISPLAY (drawable),
+ GDK_WINDOW_XID (drawable),
(char *)data, width, height);
gdk_xid_table_insert (&draw_impl->xid, pixmap);
@@ -244,7 +244,7 @@ gdk_bitmap_create_from_data (GdkWindow
}
GdkPixmap*
-gdk_pixmap_create_from_data (GdkWindow *window,
+gdk_pixmap_create_from_data (GdkDrawable *drawable,
const gchar *data,
gint width,
gint height,
@@ -256,21 +256,21 @@ gdk_pixmap_create_from_data (GdkWindow
GdkDrawableImplX11 *draw_impl;
GdkPixmapImplX11 *pix_impl;
- g_return_val_if_fail (window == NULL || GDK_IS_DRAWABLE (window), NULL);
+ g_return_val_if_fail (drawable == NULL || GDK_IS_DRAWABLE (drawable), NULL);
g_return_val_if_fail (data != NULL, NULL);
g_return_val_if_fail (fg != NULL, NULL);
g_return_val_if_fail (bg != NULL, NULL);
- g_return_val_if_fail ((window != NULL) || (depth != -1), NULL);
+ g_return_val_if_fail ((drawable != NULL) || (depth != -1), NULL);
g_return_val_if_fail ((width != 0) && (height != 0), NULL);
- if (!window)
- window = _gdk_parent_root;
+ if (!drawable)
+ drawable = _gdk_parent_root;
- if (GDK_IS_WINDOW (window) && GDK_WINDOW_DESTROYED (window))
+ if (GDK_IS_WINDOW (drawable) && GDK_WINDOW_DESTROYED (drawable))
return NULL;
if (depth == -1)
- depth = gdk_drawable_get_visual (window)->depth;
+ depth = gdk_drawable_get_visual (drawable)->depth;
pixmap = g_object_new (gdk_pixmap_get_type (), NULL);
draw_impl = GDK_DRAWABLE_IMPL_X11 (GDK_PIXMAP_OBJECT (pixmap)->impl);
@@ -282,9 +282,9 @@ gdk_pixmap_create_from_data (GdkWindow
pix_impl->height = height;
GDK_PIXMAP_OBJECT (pixmap)->depth = depth;
- draw_impl->xdisplay = GDK_DRAWABLE_XDISPLAY (window);
- draw_impl->xid = XCreatePixmapFromBitmapData (GDK_WINDOW_XDISPLAY (window),
- GDK_WINDOW_XID (window),
+ draw_impl->xdisplay = GDK_DRAWABLE_XDISPLAY (drawable);
+ draw_impl->xid = XCreatePixmapFromBitmapData (GDK_WINDOW_XDISPLAY (drawable),
+ GDK_WINDOW_XID (drawable),
(char *)data, width, height,
fg->pixel, bg->pixel, depth);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]