From f903bdf1a745021df882b4f5ba2724e7536a3c5d Mon Sep 17 00:00:00 2001 From: Owen Taylor Date: Sun, 3 Oct 1999 22:12:41 +0000 Subject: [PATCH] Fix a reference to window_private->destroyed. Sun Oct 3 18:13:44 1999 Owen Taylor * gtk/gtkwidget.c (gtk_reset_shapes_recurse): Fix a reference to window_private->destroyed. * gtk/gtkplug.c (gtk_plug_realize): Fix up a direct (ugly) setting of an internal GdkWindow member to use a _slightly_ cleaner macro. * gdk/gdkprivate.h: Split GdkWindowPrivate into GdkDrawablePrivate and GdkWindowPrivate. Add extra macros for accessing GDK_DRAWABLE_ components. * *.[ch]: Massive adjustments for the above, use the new macros in a lot of places. --- ChangeLog | 25 ++ ChangeLog.pre-2-0 | 25 ++ ChangeLog.pre-2-10 | 25 ++ ChangeLog.pre-2-2 | 25 ++ ChangeLog.pre-2-4 | 25 ++ ChangeLog.pre-2-6 | 25 ++ ChangeLog.pre-2-8 | 25 ++ gdk/TODO | 6 + gdk/gdk.c | 33 +- gdk/gdk.h | 2 + gdk/gdkcursor.c | 5 +- gdk/gdkdnd.c | 5 +- gdk/gdkdraw.c | 236 +++++++--- gdk/gdkdrawable.h | 25 +- gdk/gdkevents.c | 36 +- gdk/gdkgc.c | 37 +- gdk/gdkim.c | 6 +- gdk/gdkimage.c | 19 +- gdk/gdkinput.c | 14 +- gdk/gdkinputcommon.h | 14 +- gdk/gdkpixmap.c | 91 ++-- gdk/gdkprivate.h | 42 +- gdk/gdkproperty.c | 28 +- gdk/gdkselection.c | 31 +- gdk/gdktypes.h | 8 +- gdk/gdkwindow.c | 861 +++++++++++++++---------------------- gdk/gdkwindow.h | 21 +- gdk/gdkx.h | 6 +- gdk/x11/gdkcursor-x11.c | 5 +- gdk/x11/gdkdnd-x11.c | 5 +- gdk/x11/gdkevents-x11.c | 36 +- gdk/x11/gdkim-x11.c | 6 +- gdk/x11/gdkimage-x11.c | 19 +- gdk/x11/gdkinput-x11.c | 14 +- gdk/x11/gdkinput.c | 14 +- gdk/x11/gdkmain-x11.c | 33 +- gdk/x11/gdkpixmap-x11.c | 91 ++-- gdk/x11/gdkproperty-x11.c | 28 +- gdk/x11/gdkselection-x11.c | 31 +- gdk/x11/gdkwindow-x11.c | 861 +++++++++++++++---------------------- gdk/x11/gdkx.h | 6 +- gtk/gtkplug.c | 2 +- gtk/gtkwidget.c | 3 +- 43 files changed, 1355 insertions(+), 1500 deletions(-) diff --git a/ChangeLog b/ChangeLog index b413b3ebdd..9519b41a98 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,28 @@ +Sun Oct 3 18:13:44 1999 Owen Taylor + + * gtk/gtkwidget.c (gtk_reset_shapes_recurse): + Fix a reference to window_private->destroyed. + + * gtk/gtkplug.c (gtk_plug_realize): Fix up a direct + (ugly) setting of an internal GdkWindow member to use + a _slightly_ cleaner macro. + + * gdk/gdkprivate.h: Split GdkWindowPrivate into + GdkDrawablePrivate and GdkWindowPrivate. + Add extra macros for accessing GDK_DRAWABLE_ components. + + * *.[ch]: Massive adjustments for the above, use the + new macros in a lot of places. + +Sun Oct 3 15:16:24 1999 Owen Taylor + + * gdk/gdktypes.h: Make GdkDrawable the base type, + not GdkWindow. + +Sun Oct 3 15:08:44 1999 Owen Taylor + + * gdk/gdkdraw.c (gdk_drawable_get_data): Added new function. + Sun Oct 3 14:26:15 1999 Owen Taylor * gdk/gxid* gdk/x11/gxid*: Move files into x11 subdirectory. diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0 index b413b3ebdd..9519b41a98 100644 --- a/ChangeLog.pre-2-0 +++ b/ChangeLog.pre-2-0 @@ -1,3 +1,28 @@ +Sun Oct 3 18:13:44 1999 Owen Taylor + + * gtk/gtkwidget.c (gtk_reset_shapes_recurse): + Fix a reference to window_private->destroyed. + + * gtk/gtkplug.c (gtk_plug_realize): Fix up a direct + (ugly) setting of an internal GdkWindow member to use + a _slightly_ cleaner macro. + + * gdk/gdkprivate.h: Split GdkWindowPrivate into + GdkDrawablePrivate and GdkWindowPrivate. + Add extra macros for accessing GDK_DRAWABLE_ components. + + * *.[ch]: Massive adjustments for the above, use the + new macros in a lot of places. + +Sun Oct 3 15:16:24 1999 Owen Taylor + + * gdk/gdktypes.h: Make GdkDrawable the base type, + not GdkWindow. + +Sun Oct 3 15:08:44 1999 Owen Taylor + + * gdk/gdkdraw.c (gdk_drawable_get_data): Added new function. + Sun Oct 3 14:26:15 1999 Owen Taylor * gdk/gxid* gdk/x11/gxid*: Move files into x11 subdirectory. diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index b413b3ebdd..9519b41a98 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,28 @@ +Sun Oct 3 18:13:44 1999 Owen Taylor + + * gtk/gtkwidget.c (gtk_reset_shapes_recurse): + Fix a reference to window_private->destroyed. + + * gtk/gtkplug.c (gtk_plug_realize): Fix up a direct + (ugly) setting of an internal GdkWindow member to use + a _slightly_ cleaner macro. + + * gdk/gdkprivate.h: Split GdkWindowPrivate into + GdkDrawablePrivate and GdkWindowPrivate. + Add extra macros for accessing GDK_DRAWABLE_ components. + + * *.[ch]: Massive adjustments for the above, use the + new macros in a lot of places. + +Sun Oct 3 15:16:24 1999 Owen Taylor + + * gdk/gdktypes.h: Make GdkDrawable the base type, + not GdkWindow. + +Sun Oct 3 15:08:44 1999 Owen Taylor + + * gdk/gdkdraw.c (gdk_drawable_get_data): Added new function. + Sun Oct 3 14:26:15 1999 Owen Taylor * gdk/gxid* gdk/x11/gxid*: Move files into x11 subdirectory. diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index b413b3ebdd..9519b41a98 100644 --- a/ChangeLog.pre-2-2 +++ b/ChangeLog.pre-2-2 @@ -1,3 +1,28 @@ +Sun Oct 3 18:13:44 1999 Owen Taylor + + * gtk/gtkwidget.c (gtk_reset_shapes_recurse): + Fix a reference to window_private->destroyed. + + * gtk/gtkplug.c (gtk_plug_realize): Fix up a direct + (ugly) setting of an internal GdkWindow member to use + a _slightly_ cleaner macro. + + * gdk/gdkprivate.h: Split GdkWindowPrivate into + GdkDrawablePrivate and GdkWindowPrivate. + Add extra macros for accessing GDK_DRAWABLE_ components. + + * *.[ch]: Massive adjustments for the above, use the + new macros in a lot of places. + +Sun Oct 3 15:16:24 1999 Owen Taylor + + * gdk/gdktypes.h: Make GdkDrawable the base type, + not GdkWindow. + +Sun Oct 3 15:08:44 1999 Owen Taylor + + * gdk/gdkdraw.c (gdk_drawable_get_data): Added new function. + Sun Oct 3 14:26:15 1999 Owen Taylor * gdk/gxid* gdk/x11/gxid*: Move files into x11 subdirectory. diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index b413b3ebdd..9519b41a98 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,28 @@ +Sun Oct 3 18:13:44 1999 Owen Taylor + + * gtk/gtkwidget.c (gtk_reset_shapes_recurse): + Fix a reference to window_private->destroyed. + + * gtk/gtkplug.c (gtk_plug_realize): Fix up a direct + (ugly) setting of an internal GdkWindow member to use + a _slightly_ cleaner macro. + + * gdk/gdkprivate.h: Split GdkWindowPrivate into + GdkDrawablePrivate and GdkWindowPrivate. + Add extra macros for accessing GDK_DRAWABLE_ components. + + * *.[ch]: Massive adjustments for the above, use the + new macros in a lot of places. + +Sun Oct 3 15:16:24 1999 Owen Taylor + + * gdk/gdktypes.h: Make GdkDrawable the base type, + not GdkWindow. + +Sun Oct 3 15:08:44 1999 Owen Taylor + + * gdk/gdkdraw.c (gdk_drawable_get_data): Added new function. + Sun Oct 3 14:26:15 1999 Owen Taylor * gdk/gxid* gdk/x11/gxid*: Move files into x11 subdirectory. diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index b413b3ebdd..9519b41a98 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,28 @@ +Sun Oct 3 18:13:44 1999 Owen Taylor + + * gtk/gtkwidget.c (gtk_reset_shapes_recurse): + Fix a reference to window_private->destroyed. + + * gtk/gtkplug.c (gtk_plug_realize): Fix up a direct + (ugly) setting of an internal GdkWindow member to use + a _slightly_ cleaner macro. + + * gdk/gdkprivate.h: Split GdkWindowPrivate into + GdkDrawablePrivate and GdkWindowPrivate. + Add extra macros for accessing GDK_DRAWABLE_ components. + + * *.[ch]: Massive adjustments for the above, use the + new macros in a lot of places. + +Sun Oct 3 15:16:24 1999 Owen Taylor + + * gdk/gdktypes.h: Make GdkDrawable the base type, + not GdkWindow. + +Sun Oct 3 15:08:44 1999 Owen Taylor + + * gdk/gdkdraw.c (gdk_drawable_get_data): Added new function. + Sun Oct 3 14:26:15 1999 Owen Taylor * gdk/gxid* gdk/x11/gxid*: Move files into x11 subdirectory. diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index b413b3ebdd..9519b41a98 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,28 @@ +Sun Oct 3 18:13:44 1999 Owen Taylor + + * gtk/gtkwidget.c (gtk_reset_shapes_recurse): + Fix a reference to window_private->destroyed. + + * gtk/gtkplug.c (gtk_plug_realize): Fix up a direct + (ugly) setting of an internal GdkWindow member to use + a _slightly_ cleaner macro. + + * gdk/gdkprivate.h: Split GdkWindowPrivate into + GdkDrawablePrivate and GdkWindowPrivate. + Add extra macros for accessing GDK_DRAWABLE_ components. + + * *.[ch]: Massive adjustments for the above, use the + new macros in a lot of places. + +Sun Oct 3 15:16:24 1999 Owen Taylor + + * gdk/gdktypes.h: Make GdkDrawable the base type, + not GdkWindow. + +Sun Oct 3 15:08:44 1999 Owen Taylor + + * gdk/gdkdraw.c (gdk_drawable_get_data): Added new function. + Sun Oct 3 14:26:15 1999 Owen Taylor * gdk/gxid* gdk/x11/gxid*: Move files into x11 subdirectory. diff --git a/gdk/TODO b/gdk/TODO index 534c0aad90..6f6191d6d6 100644 --- a/gdk/TODO +++ b/gdk/TODO @@ -1,3 +1,9 @@ +General +======= + +- gdk_pointer_grab() and gdk_keyboard_grab() are logically member + functions of GdkWindow. + Dir structure for ports ======================= diff --git a/gdk/gdk.c b/gdk/gdk.c index 96e342f62c..87b15b6a91 100644 --- a/gdk/gdk.c +++ b/gdk/gdk.c @@ -47,6 +47,7 @@ #include "gdk.h" +#include "gdkx.h" #include "gdkprivate.h" #include "gdkinputprivate.h" @@ -493,10 +494,7 @@ gdk_pointer_grab (GdkWindow * window, GdkCursor * cursor, guint32 time) { - /* From gdkwindow.c */ gint return_val; - GdkWindowPrivate *window_private; - GdkWindowPrivate *confine_to_private; GdkCursorPrivate *cursor_private; guint xevent_mask; Window xwindow; @@ -505,17 +503,17 @@ gdk_pointer_grab (GdkWindow * window, int i; g_return_val_if_fail (window != NULL, 0); + g_return_val_if_fail (GDK_IS_WINDOW (window), 0); + g_return_val_if_fail (confine_to == NULL || GDK_IS_WINDOW (confine_to), 0); - window_private = (GdkWindowPrivate*) window; - confine_to_private = (GdkWindowPrivate*) confine_to; cursor_private = (GdkCursorPrivate*) cursor; - xwindow = window_private->xwindow; + xwindow = GDK_DRAWABLE_XID (window); - if (!confine_to || confine_to_private->destroyed) + if (!confine_to || GDK_DRAWABLE_DESTROYED (confine_to)) xconfine_to = None; else - xconfine_to = confine_to_private->xwindow; + xconfine_to = GDK_DRAWABLE_XID (confine_to); if (!cursor) xcursor = None; @@ -541,8 +539,8 @@ gdk_pointer_grab (GdkWindow * window, if (return_val == Success) { - if (!window_private->destroyed) - return_val = XGrabPointer (window_private->xdisplay, + if (!GDK_DRAWABLE_DESTROYED (window)) + return_val = XGrabPointer (GDK_DRAWABLE_XDISPLAY (window), xwindow, owner_events, xevent_mask, @@ -555,7 +553,7 @@ gdk_pointer_grab (GdkWindow * window, } if (return_val == GrabSuccess) - gdk_xgrab_window = window_private; + gdk_xgrab_window = (GdkWindowPrivate *)window; return return_val; } @@ -631,17 +629,12 @@ gdk_keyboard_grab (GdkWindow * window, gint owner_events, guint32 time) { - GdkWindowPrivate *window_private; - Window xwindow; - g_return_val_if_fail (window != NULL, 0); + g_return_val_if_fail (GDK_IS_WINDOW (window), 0); - window_private = (GdkWindowPrivate*) window; - xwindow = window_private->xwindow; - - if (!window_private->destroyed) - return XGrabKeyboard (window_private->xdisplay, - xwindow, + if (!GDK_DRAWABLE_DESTROYED (window)) + return XGrabKeyboard (GDK_DRAWABLE_XDISPLAY (window), + GDK_DRAWABLE_XID (window), owner_events, GrabModeAsync, GrabModeAsync, time); diff --git a/gdk/gdk.h b/gdk/gdk.h index ed18c73c77..6cf20f5c88 100644 --- a/gdk/gdk.h +++ b/gdk/gdk.h @@ -47,6 +47,8 @@ #include #include +#include + #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ diff --git a/gdk/gdkcursor.c b/gdk/gdkcursor.c index 6431c780ad..04260a2cde 100644 --- a/gdk/gdkcursor.c +++ b/gdk/gdkcursor.c @@ -27,6 +27,7 @@ #include #include +#include "gdkx.h" #include "gdkcursor.h" #include "gdkprivate.h" @@ -57,8 +58,8 @@ gdk_cursor_new_from_pixmap (GdkPixmap *source, GdkPixmap *mask, GdkColor *fg, Gd Cursor xcursor; XColor xfg, xbg; - source_pixmap = ((GdkPixmapPrivate *) source)->xwindow; - mask_pixmap = ((GdkPixmapPrivate *) mask)->xwindow; + source_pixmap = GDK_DRAWABLE_XID (source); + mask_pixmap = GDK_DRAWABLE_XID (mask); xfg.pixel = fg->pixel; xfg.red = fg->red; diff --git a/gdk/gdkdnd.c b/gdk/gdkdnd.c index 3788229245..a58da225b1 100644 --- a/gdk/gdkdnd.c +++ b/gdk/gdkdnd.c @@ -2416,9 +2416,8 @@ xdnd_manage_source_filter (GdkDragContext *context, gboolean add_filter) { gint old_warnings = 0; /* quiet gcc */ - GdkWindowPrivate *private = (GdkWindowPrivate *)window; - gboolean is_foreign = (private->window_type == GDK_WINDOW_FOREIGN); + gboolean is_foreign = GDK_DRAWABLE_TYPE (window); if (is_foreign) { @@ -2426,7 +2425,7 @@ xdnd_manage_source_filter (GdkDragContext *context, gdk_error_warnings = 0; } - if (!private->destroyed) + if (!GDK_DRAWABLE_DESTROYED (window)) { if (add_filter) { diff --git a/gdk/gdkdraw.c b/gdk/gdkdraw.c index 3583649fbe..6c8963a5b2 100644 --- a/gdk/gdkdraw.c +++ b/gdk/gdkdraw.c @@ -27,27 +27,145 @@ #include #include +#include "gdkx.h" #include "gdkdrawable.h" #include "gdkprivate.h" +#include "gdkwindow.h" +/* Manipulation of drawables + */ +void +gdk_drawable_set_data (GdkDrawable *drawable, + const gchar *key, + gpointer data, + GDestroyNotify destroy_func) +{ + g_dataset_set_data_full (drawable, key, data, destroy_func); +} + +void +gdk_drawable_get_data (GdkDrawable *drawable, + const gchar *key) +{ + g_dataset_get_data (drawable, key); +} + +GdkDrawableType +gdk_drawable_get_type (GdkDrawable *drawable) +{ + g_return_val_if_fail (drawable != NULL, (GdkDrawableType) -1); + + return GDK_DRAWABLE_TYPE (drawable); +} + +void +gdk_drawable_get_size (GdkDrawable *drawable, + gint *width, + gint *height) +{ + GdkDrawablePrivate *drawable_private; + + g_return_if_fail (drawable != NULL); + + drawable_private = (GdkDrawablePrivate*) drawable; + + if (width) + *width = drawable_private->width; + if (height) + *height = drawable_private->height; +} + +void +gdk_drawable_set_colormap (GdkDrawable *drawable, + GdkColormap *colormap) +{ + GdkDrawablePrivate *drawable_private; + GdkColormapPrivate *colormap_private; + + g_return_if_fail (drawable != NULL); + g_return_if_fail (colormap != NULL); + + drawable_private = (GdkDrawablePrivate*) drawable; + colormap_private = (GdkColormapPrivate*) colormap; + + if (!GDK_DRAWABLE_DESTROYED (drawable)) + { + if (GDK_IS_WINDOW (drawable)) + { + g_return_if_fail (colormap_private->visual != + ((GdkColormapPrivate *)(drawable_private->colormap))->visual); + + XSetWindowColormap (GDK_DRAWABLE_XDISPLAY (drawable), + GDK_DRAWABLE_XID (drawable), + colormap_private->xcolormap); + } + + if (drawable_private->colormap) + gdk_colormap_unref (drawable_private->colormap); + drawable_private->colormap = colormap; + gdk_colormap_ref (drawable_private->colormap); + + if (GDK_IS_WINDOW (drawable) && + drawable_private->window_type != GDK_WINDOW_TOPLEVEL) + gdk_window_add_colormap_windows (drawable); + } +} + +GdkColormap* +gdk_drawable_get_colormap (GdkDrawable *drawable) +{ + GdkDrawablePrivate *drawable_private; + XWindowAttributes window_attributes; + + g_return_val_if_fail (drawable != NULL, NULL); + drawable_private = (GdkDrawablePrivate*) drawable; + + if (!GDK_DRAWABLE_DESTROYED (drawable)) + { + if (drawable_private->colormap == NULL && + GDK_IS_WINDOW (drawable)) + { + XGetWindowAttributes (GDK_DRAWABLE_XDISPLAY (drawable), + GDK_DRAWABLE_XID (drawable), + &window_attributes); + drawable_private->colormap = gdk_colormap_lookup (window_attributes.colormap); + } + + return drawable_private->colormap; + } + + return NULL; +} + +GdkVisual* +gdk_drawable_get_visual (GdkDrawable *drawable) +{ + GdkColormap *colormap; + + g_return_val_if_fail (drawable != NULL, NULL); + + colormap = gdk_drawable_get_colormap (drawable); + return colormap ? gdk_colormap_get_visual (colormap) : NULL; +} + +/* Drawing + */ void gdk_draw_point (GdkDrawable *drawable, GdkGC *gc, gint x, gint y) { - GdkWindowPrivate *drawable_private; GdkGCPrivate *gc_private; g_return_if_fail (drawable != NULL); g_return_if_fail (gc != NULL); - drawable_private = (GdkWindowPrivate*) drawable; - if (drawable_private->destroyed) + if (GDK_DRAWABLE_DESTROYED (drawable)) return; gc_private = (GdkGCPrivate*) gc; - XDrawPoint (drawable_private->xdisplay, drawable_private->xwindow, + XDrawPoint (GDK_DRAWABLE_XDISPLAY (drawable), GDK_DRAWABLE_XID (drawable), gc_private->xgc, x, y); } @@ -59,18 +177,16 @@ gdk_draw_line (GdkDrawable *drawable, gint x2, gint y2) { - GdkWindowPrivate *drawable_private; GdkGCPrivate *gc_private; g_return_if_fail (drawable != NULL); g_return_if_fail (gc != NULL); - drawable_private = (GdkWindowPrivate*) drawable; - if (drawable_private->destroyed) + if (GDK_DRAWABLE_DESTROYED (drawable)) return; gc_private = (GdkGCPrivate*) gc; - XDrawLine (drawable_private->xdisplay, drawable_private->xwindow, + XDrawLine (GDK_DRAWABLE_XDISPLAY (drawable), GDK_DRAWABLE_XID (drawable), gc_private->xgc, x1, y1, x2, y2); } @@ -83,14 +199,14 @@ gdk_draw_rectangle (GdkDrawable *drawable, gint width, gint height) { - GdkWindowPrivate *drawable_private; + GdkDrawablePrivate *drawable_private; GdkGCPrivate *gc_private; g_return_if_fail (drawable != NULL); g_return_if_fail (gc != NULL); - drawable_private = (GdkWindowPrivate*) drawable; - if (drawable_private->destroyed) + drawable_private = (GdkDrawablePrivate*) drawable; + if (GDK_DRAWABLE_DESTROYED (drawable)) return; gc_private = (GdkGCPrivate*) gc; @@ -100,10 +216,10 @@ gdk_draw_rectangle (GdkDrawable *drawable, height = drawable_private->height; if (filled) - XFillRectangle (drawable_private->xdisplay, drawable_private->xwindow, + XFillRectangle (GDK_DRAWABLE_XDISPLAY (drawable), GDK_DRAWABLE_XID (drawable), gc_private->xgc, x, y, width, height); else - XDrawRectangle (drawable_private->xdisplay, drawable_private->xwindow, + XDrawRectangle (GDK_DRAWABLE_XDISPLAY (drawable), GDK_DRAWABLE_XID (drawable), gc_private->xgc, x, y, width, height); } @@ -118,14 +234,14 @@ gdk_draw_arc (GdkDrawable *drawable, gint angle1, gint angle2) { - GdkWindowPrivate *drawable_private; + GdkDrawablePrivate *drawable_private; GdkGCPrivate *gc_private; g_return_if_fail (drawable != NULL); g_return_if_fail (gc != NULL); - drawable_private = (GdkWindowPrivate*) drawable; - if (drawable_private->destroyed) + drawable_private = (GdkDrawablePrivate*) drawable; + if (GDK_DRAWABLE_DESTROYED (drawable)) return; gc_private = (GdkGCPrivate*) gc; @@ -135,10 +251,10 @@ gdk_draw_arc (GdkDrawable *drawable, height = drawable_private->height; if (filled) - XFillArc (drawable_private->xdisplay, drawable_private->xwindow, + XFillArc (GDK_DRAWABLE_XDISPLAY (drawable), GDK_DRAWABLE_XID (drawable), gc_private->xgc, x, y, width, height, angle1, angle2); else - XDrawArc (drawable_private->xdisplay, drawable_private->xwindow, + XDrawArc (GDK_DRAWABLE_XDISPLAY (drawable), GDK_DRAWABLE_XID (drawable), gc_private->xgc, x, y, width, height, angle1, angle2); } @@ -149,7 +265,6 @@ gdk_draw_polygon (GdkDrawable *drawable, GdkPoint *points, gint npoints) { - GdkWindowPrivate *drawable_private; GdkGCPrivate *gc_private; GdkPoint *local_points = points; gint local_npoints = npoints; @@ -158,14 +273,13 @@ gdk_draw_polygon (GdkDrawable *drawable, g_return_if_fail (drawable != NULL); g_return_if_fail (gc != NULL); - drawable_private = (GdkWindowPrivate*) drawable; - if (drawable_private->destroyed) + if (GDK_DRAWABLE_DESTROYED (drawable)) return; gc_private = (GdkGCPrivate*) gc; if (filled) { - XFillPolygon (drawable_private->xdisplay, drawable_private->xwindow, + XFillPolygon (GDK_DRAWABLE_XDISPLAY (drawable), GDK_DRAWABLE_XID (drawable), gc_private->xgc, (XPoint*) points, npoints, Complex, CoordModeOrigin); } else @@ -181,7 +295,7 @@ gdk_draw_polygon (GdkDrawable *drawable, local_points[npoints].y = points[0].y; } - XDrawLines (drawable_private->xdisplay, drawable_private->xwindow, + XDrawLines (GDK_DRAWABLE_XDISPLAY (drawable), GDK_DRAWABLE_XID (drawable), gc_private->xgc, (XPoint*) local_points, local_npoints, CoordModeOrigin); @@ -205,7 +319,6 @@ gdk_draw_string (GdkDrawable *drawable, gint y, const gchar *string) { - GdkWindowPrivate *drawable_private; GdkFontPrivate *font_private; GdkGCPrivate *gc_private; @@ -214,8 +327,7 @@ gdk_draw_string (GdkDrawable *drawable, g_return_if_fail (gc != NULL); g_return_if_fail (string != NULL); - drawable_private = (GdkWindowPrivate*) drawable; - if (drawable_private->destroyed) + if (GDK_DRAWABLE_DESTROYED (drawable)) return; gc_private = (GdkGCPrivate*) gc; font_private = (GdkFontPrivate*) font; @@ -223,15 +335,15 @@ gdk_draw_string (GdkDrawable *drawable, if (font->type == GDK_FONT_FONT) { XFontStruct *xfont = (XFontStruct *) font_private->xfont; - XSetFont(drawable_private->xdisplay, gc_private->xgc, xfont->fid); + XSetFont(GDK_DRAWABLE_XDISPLAY (drawable), gc_private->xgc, xfont->fid); if ((xfont->min_byte1 == 0) && (xfont->max_byte1 == 0)) { - XDrawString (drawable_private->xdisplay, drawable_private->xwindow, + XDrawString (GDK_DRAWABLE_XDISPLAY (drawable), GDK_DRAWABLE_XID (drawable), gc_private->xgc, x, y, string, strlen (string)); } else { - XDrawString16 (drawable_private->xdisplay, drawable_private->xwindow, + XDrawString16 (GDK_DRAWABLE_XDISPLAY (drawable), GDK_DRAWABLE_XID (drawable), gc_private->xgc, x, y, (XChar2b *) string, strlen (string) / 2); } @@ -239,7 +351,7 @@ gdk_draw_string (GdkDrawable *drawable, else if (font->type == GDK_FONT_FONTSET) { XFontSet fontset = (XFontSet) font_private->xfont; - XmbDrawString (drawable_private->xdisplay, drawable_private->xwindow, + XmbDrawString (GDK_DRAWABLE_XDISPLAY (drawable), GDK_DRAWABLE_XID (drawable), fontset, gc_private->xgc, x, y, string, strlen (string)); } else @@ -261,7 +373,6 @@ gdk_draw_text (GdkDrawable *drawable, const gchar *text, gint text_length) { - GdkWindowPrivate *drawable_private; GdkFontPrivate *font_private; GdkGCPrivate *gc_private; @@ -270,8 +381,7 @@ gdk_draw_text (GdkDrawable *drawable, g_return_if_fail (gc != NULL); g_return_if_fail (text != NULL); - drawable_private = (GdkWindowPrivate*) drawable; - if (drawable_private->destroyed) + if (GDK_DRAWABLE_DESTROYED (drawable)) return; gc_private = (GdkGCPrivate*) gc; font_private = (GdkFontPrivate*) font; @@ -279,22 +389,22 @@ gdk_draw_text (GdkDrawable *drawable, if (font->type == GDK_FONT_FONT) { XFontStruct *xfont = (XFontStruct *) font_private->xfont; - XSetFont(drawable_private->xdisplay, gc_private->xgc, xfont->fid); + XSetFont(GDK_DRAWABLE_XDISPLAY (drawable), gc_private->xgc, xfont->fid); if ((xfont->min_byte1 == 0) && (xfont->max_byte1 == 0)) { - XDrawString (drawable_private->xdisplay, drawable_private->xwindow, + XDrawString (GDK_DRAWABLE_XDISPLAY (drawable), GDK_DRAWABLE_XID (drawable), gc_private->xgc, x, y, text, text_length); } else { - XDrawString16 (drawable_private->xdisplay, drawable_private->xwindow, + XDrawString16 (GDK_DRAWABLE_XDISPLAY (drawable), GDK_DRAWABLE_XID (drawable), gc_private->xgc, x, y, (XChar2b *) text, text_length / 2); } } else if (font->type == GDK_FONT_FONTSET) { XFontSet fontset = (XFontSet) font_private->xfont; - XmbDrawString (drawable_private->xdisplay, drawable_private->xwindow, + XmbDrawString (GDK_DRAWABLE_XDISPLAY (drawable), GDK_DRAWABLE_XID (drawable), fontset, gc_private->xgc, x, y, text, text_length); } else @@ -310,7 +420,6 @@ gdk_draw_text_wc (GdkDrawable *drawable, const GdkWChar *text, gint text_length) { - GdkWindowPrivate *drawable_private; GdkFontPrivate *font_private; GdkGCPrivate *gc_private; @@ -319,8 +428,7 @@ gdk_draw_text_wc (GdkDrawable *drawable, g_return_if_fail (gc != NULL); g_return_if_fail (text != NULL); - drawable_private = (GdkWindowPrivate*) drawable; - if (drawable_private->destroyed) + if (GDK_DRAWABLE_DESTROYED (drawable)) return; gc_private = (GdkGCPrivate*) gc; font_private = (GdkFontPrivate*) font; @@ -330,10 +438,10 @@ gdk_draw_text_wc (GdkDrawable *drawable, XFontStruct *xfont = (XFontStruct *) font_private->xfont; gchar *text_8bit; gint i; - XSetFont(drawable_private->xdisplay, gc_private->xgc, xfont->fid); + XSetFont(GDK_DRAWABLE_XDISPLAY (drawable), gc_private->xgc, xfont->fid); text_8bit = g_new (gchar, text_length); for (i=0; ixdisplay, drawable_private->xwindow, + XDrawString (GDK_DRAWABLE_XDISPLAY (drawable), GDK_DRAWABLE_XID (drawable), gc_private->xgc, x, y, text_8bit, text_length); g_free (text_8bit); } @@ -341,7 +449,7 @@ gdk_draw_text_wc (GdkDrawable *drawable, { if (sizeof(GdkWChar) == sizeof(wchar_t)) { - XwcDrawString (drawable_private->xdisplay, drawable_private->xwindow, + XwcDrawString (GDK_DRAWABLE_XDISPLAY (drawable), GDK_DRAWABLE_XID (drawable), (XFontSet) font_private->xfont, gc_private->xgc, x, y, (wchar_t *)text, text_length); } @@ -351,7 +459,7 @@ gdk_draw_text_wc (GdkDrawable *drawable, gint i; text_wchar = g_new (wchar_t, text_length); for (i=0; ixdisplay, drawable_private->xwindow, + XwcDrawString (GDK_DRAWABLE_XDISPLAY (drawable), GDK_DRAWABLE_XID (drawable), (XFontSet) font_private->xfont, gc_private->xgc, x, y, text_wchar, text_length); g_free (text_wchar); @@ -372,28 +480,24 @@ gdk_draw_pixmap (GdkDrawable *drawable, gint width, gint height) { - GdkWindowPrivate *drawable_private; - GdkWindowPrivate *src_private; GdkGCPrivate *gc_private; g_return_if_fail (drawable != NULL); g_return_if_fail (src != NULL); g_return_if_fail (gc != NULL); - drawable_private = (GdkWindowPrivate*) drawable; - src_private = (GdkWindowPrivate*) src; - if (drawable_private->destroyed || src_private->destroyed) + if (GDK_DRAWABLE_DESTROYED (drawable) || GDK_DRAWABLE_DESTROYED (src)) return; gc_private = (GdkGCPrivate*) gc; if (width == -1) - width = src_private->width; + width = ((GdkDrawablePrivate *)src)->width; if (height == -1) - height = src_private->height; + height = ((GdkDrawablePrivate *)src)->height; - XCopyArea (drawable_private->xdisplay, - src_private->xwindow, - drawable_private->xwindow, + XCopyArea (GDK_DRAWABLE_XDISPLAY (drawable), + GDK_DRAWABLE_XID (src), + GDK_DRAWABLE_XID (drawable), gc_private->xgc, xsrc, ysrc, width, height, @@ -436,20 +540,18 @@ gdk_draw_points (GdkDrawable *drawable, GdkPoint *points, gint npoints) { - GdkWindowPrivate *drawable_private; GdkGCPrivate *gc_private; g_return_if_fail (drawable != NULL); g_return_if_fail ((points != NULL) && (npoints > 0)); g_return_if_fail (gc != NULL); - drawable_private = (GdkWindowPrivate*) drawable; - if (drawable_private->destroyed) + if (GDK_DRAWABLE_DESTROYED (drawable)) return; gc_private = (GdkGCPrivate*) gc; - XDrawPoints (drawable_private->xdisplay, - drawable_private->xwindow, + XDrawPoints (GDK_DRAWABLE_XDISPLAY (drawable), + GDK_DRAWABLE_XID (drawable), gc_private->xgc, (XPoint *) points, npoints, @@ -462,7 +564,6 @@ gdk_draw_segments (GdkDrawable *drawable, GdkSegment *segs, gint nsegs) { - GdkWindowPrivate *drawable_private; GdkGCPrivate *gc_private; if (nsegs <= 0) @@ -472,13 +573,12 @@ gdk_draw_segments (GdkDrawable *drawable, g_return_if_fail (segs != NULL); g_return_if_fail (gc != NULL); - drawable_private = (GdkWindowPrivate*) drawable; - if (drawable_private->destroyed) + if (GDK_DRAWABLE_DESTROYED (drawable)) return; gc_private = (GdkGCPrivate*) gc; - XDrawSegments (drawable_private->xdisplay, - drawable_private->xwindow, + XDrawSegments (GDK_DRAWABLE_XDISPLAY (drawable), + GDK_DRAWABLE_XID (drawable), gc_private->xgc, (XSegment *) segs, nsegs); @@ -490,7 +590,6 @@ gdk_draw_lines (GdkDrawable *drawable, GdkPoint *points, gint npoints) { - GdkWindowPrivate *drawable_private; GdkGCPrivate *gc_private; if (npoints <= 0) @@ -500,13 +599,12 @@ gdk_draw_lines (GdkDrawable *drawable, g_return_if_fail (points != NULL); g_return_if_fail (gc != NULL); - drawable_private = (GdkWindowPrivate*) drawable; - if (drawable_private->destroyed) + if (GDK_DRAWABLE_DESTROYED (drawable)) return; gc_private = (GdkGCPrivate*) gc; - XDrawLines (drawable_private->xdisplay, - drawable_private->xwindow, + XDrawLines (GDK_DRAWABLE_XDISPLAY (drawable), + GDK_DRAWABLE_XID (drawable), gc_private->xgc, (XPoint *) points, npoints, diff --git a/gdk/gdkdrawable.h b/gdk/gdkdrawable.h index 30b217264a..b3286c4823 100644 --- a/gdk/gdkdrawable.h +++ b/gdk/gdkdrawable.h @@ -34,15 +34,34 @@ typedef enum GDK_WINDOW_CHILD, GDK_WINDOW_DIALOG, GDK_WINDOW_TEMP, - GDK_WINDOW_PIXMAP, + GDK_DRAWABLE_PIXMAP, GDK_WINDOW_FOREIGN -} GdkWindowType; +} GdkDrawableType; -struct _GdkWindow +struct _GdkDrawable { gpointer user_data; }; +/* Manipulation of drawables + */ +GdkDrawableType gdk_drawable_get_type (GdkDrawable *window); + +void gdk_drawable_set_data (GdkDrawable *drawable, + const gchar *key, + gpointer data, + GDestroyNotify destroy_func); +void gdk_drawable_get_data (GdkDrawable *drawable, + const gchar *key); + +void gdk_drawable_get_size (GdkWindow *drawable, + gint *width, + gint *height); +void gdk_drawable_set_colormap (GdkDrawable *drawable, + GdkColormap *colormap); +GdkColormap* gdk_drawable_get_colormap (GdkDrawable *drawable); +GdkVisual* gdk_drawable_get_visual (GdkDrawable *drawable); + /* Drawing */ void gdk_draw_point (GdkDrawable *drawable, diff --git a/gdk/gdkevents.c b/gdk/gdkevents.c index 2adc09cb45..1738a0dbbe 100644 --- a/gdk/gdkevents.c +++ b/gdk/gdkevents.c @@ -286,11 +286,7 @@ graphics_expose_predicate (Display *display, XEvent *xevent, XPointer arg) { - GdkWindowPrivate *private = (GdkWindowPrivate*) arg; - - g_return_val_if_fail (private != NULL, False); - - if (xevent->xany.window == private->xwindow && + if (xevent->xany.window == GDK_DRAWABLE_XID (arg) && (xevent->xany.type == GraphicsExpose || xevent->xany.type == NoExpose)) return True; @@ -1009,6 +1005,8 @@ gdk_event_translate (GdkEvent *event, } window = gdk_window_lookup (xevent->xany.window); + /* FIXME: window might be a GdkPixmap!!! */ + window_private = (GdkWindowPrivate *) window; if (window != NULL) @@ -1017,7 +1015,7 @@ gdk_event_translate (GdkEvent *event, event->any.window = window; event->any.send_event = xevent->xany.send_event ? TRUE : FALSE; - if (window_private && window_private->destroyed) + if (window_private && GDK_DRAWABLE_DESTROYED (window)) { if (xevent->type != DestroyNotify) return FALSE; @@ -1040,7 +1038,7 @@ gdk_event_translate (GdkEvent *event, #ifdef USE_XIM if (window == NULL && gdk_xim_window && xevent->type == KeyPress && - !((GdkWindowPrivate *) gdk_xim_window)->destroyed) + !GDK_DRAWABLE_DESTROYED (gdk_xim_window)) { /* * If user presses a key in Preedit or Status window, keypress event @@ -1340,7 +1338,7 @@ gdk_event_translate (GdkEvent *event, /* Tell XInput stuff about it if appropriate */ if (window_private && - !window_private->destroyed && + !GDK_DRAWABLE_DESTROYED (window) && (window_private->extension_events != 0) && gdk_input_vtable.enter_event) gdk_input_vtable.enter_event (&xevent->xcrossing, window); @@ -1635,9 +1633,9 @@ gdk_event_translate (GdkEvent *event, event->any.type = GDK_DESTROY; event->any.window = window; - return_val = window_private && !window_private->destroyed; + return_val = window_private && !GDK_DRAWABLE_DESTROYED (window); - if (window && window_private->xwindow != GDK_ROOT_WINDOW()) + if (window && GDK_DRAWABLE_XID (window) != GDK_ROOT_WINDOW()) gdk_window_destroy_notify (window); break; @@ -1698,16 +1696,16 @@ gdk_event_translate (GdkEvent *event, xevent->xconfigure.override_redirect, !window ? " (discarding)" - : window_private->window_type == GDK_WINDOW_CHILD + : GDK_DRAWABLE_TYPE (window) == GDK_WINDOW_CHILD ? " (discarding child)" : "")); if (window && - !window_private->destroyed && + !GDK_DRAWABLE_DESTROYED (window) && (window_private->extension_events != 0) && gdk_input_vtable.configure_event) gdk_input_vtable.configure_event (&xevent->xconfigure, window); - if (!window || window_private->window_type == GDK_WINDOW_CHILD) + if (!window || GDK_DRAWABLE_TYPE (window) == GDK_WINDOW_CHILD) return_val = FALSE; else { @@ -1718,15 +1716,15 @@ gdk_event_translate (GdkEvent *event, if (!xevent->xconfigure.x && !xevent->xconfigure.y && - !window_private->destroyed) + !GDK_DRAWABLE_DESTROYED (window)) { gint tx = 0; gint ty = 0; Window child_window = 0; gdk_error_trap_push (); - if (XTranslateCoordinates (window_private->xdisplay, - window_private->xwindow, + if (XTranslateCoordinates (GDK_DRAWABLE_XDISPLAY (window), + GDK_DRAWABLE_XID (window), gdk_root_window, 0, 0, &tx, &ty, @@ -1748,8 +1746,8 @@ gdk_event_translate (GdkEvent *event, } window_private->x = event->configure.x; window_private->y = event->configure.y; - window_private->width = xevent->xconfigure.width; - window_private->height = xevent->xconfigure.height; + window_private->drawable.width = xevent->xconfigure.width; + window_private->drawable.height = xevent->xconfigure.height; if (window_private->resize_count > 1) window_private->resize_count -= 1; } @@ -1891,7 +1889,7 @@ gdk_event_translate (GdkEvent *event, /* something else - (e.g., a Xinput event) */ if (window_private && - !window_private->destroyed && + !window_private->drawable.destroyed && (window_private->extension_events != 0) && gdk_input_vtable.other_event) return_val = gdk_input_vtable.other_event(event, xevent, window); diff --git a/gdk/gdkgc.c b/gdk/gdkgc.c index b5f57b0ba8..e8772cfe9b 100644 --- a/gdk/gdkgc.c +++ b/gdk/gdkgc.c @@ -29,7 +29,7 @@ #include "gdkgc.h" #include "gdkprivate.h" - +#include "gdkx.h" GdkGC* gdk_gc_new (GdkWindow *window) @@ -42,7 +42,6 @@ gdk_gc_new_with_values (GdkWindow *window, GdkGCValues *values, GdkGCValuesMask values_mask) { - GdkWindowPrivate *window_private; GdkGC *gc; GdkGCPrivate *private; Window xwindow; @@ -51,15 +50,14 @@ gdk_gc_new_with_values (GdkWindow *window, g_return_val_if_fail (window != NULL, NULL); - window_private = (GdkWindowPrivate*) window; - if (window_private->destroyed) + if (GDK_DRAWABLE_DESTROYED (window)) return NULL; private = g_new (GdkGCPrivate, 1); gc = (GdkGC*) private; - xwindow = window_private->xwindow; - private->xdisplay = window_private->xdisplay; + xwindow = GDK_DRAWABLE_XID (window); + private->xdisplay = GDK_DRAWABLE_XDISPLAY (window); private->ref_count = 1; xvalues.function = GXcopy; @@ -157,17 +155,17 @@ gdk_gc_new_with_values (GdkWindow *window, } if (values_mask & GDK_GC_TILE) { - xvalues.tile = ((GdkPixmapPrivate*) values->tile)->xwindow; + xvalues.tile = GDK_DRAWABLE_XID (values->tile); xvalues_mask |= GCTile; } if (values_mask & GDK_GC_STIPPLE) { - xvalues.stipple = ((GdkPixmapPrivate*) values->stipple)->xwindow; + xvalues.stipple = GDK_DRAWABLE_XID (values->stipple); xvalues_mask |= GCStipple; } if (values_mask & GDK_GC_CLIP_MASK) { - xvalues.clip_mask = ((GdkPixmapPrivate*) values->clip_mask)->xwindow; + xvalues.clip_mask = GDK_DRAWABLE_XID (values->clip_mask); xvalues_mask |= GCClipMask; } if (values_mask & GDK_GC_SUBWINDOW) @@ -586,7 +584,6 @@ gdk_gc_set_tile (GdkGC *gc, GdkPixmap *tile) { GdkGCPrivate *private; - GdkPixmapPrivate *pixmap_private; Pixmap pixmap; g_return_if_fail (gc != NULL); @@ -595,10 +592,7 @@ gdk_gc_set_tile (GdkGC *gc, pixmap = None; if (tile) - { - pixmap_private = (GdkPixmapPrivate*) tile; - pixmap = pixmap_private->xwindow; - } + pixmap = GDK_DRAWABLE_XID (tile); XSetTile (private->xdisplay, private->xgc, pixmap); } @@ -608,7 +602,6 @@ gdk_gc_set_stipple (GdkGC *gc, GdkPixmap *stipple) { GdkGCPrivate *private; - GdkPixmapPrivate *pixmap_private; Pixmap pixmap; g_return_if_fail (gc != NULL); @@ -617,10 +610,7 @@ gdk_gc_set_stipple (GdkGC *gc, pixmap = None; if (stipple) - { - pixmap_private = (GdkPixmapPrivate*) stipple; - pixmap = pixmap_private->xwindow; - } + pixmap = GDK_DRAWABLE_XID (stipple); XSetStipple (private->xdisplay, private->xgc, pixmap); } @@ -663,14 +653,7 @@ gdk_gc_set_clip_mask (GdkGC *gc, g_return_if_fail (gc != NULL); if (mask) - { - GdkWindowPrivate *mask_private; - - mask_private = (GdkWindowPrivate*) mask; - if (mask_private->destroyed) - return; - xmask = mask_private->xwindow; - } + xmask = GDK_DRAWABLE_XID (mask); else xmask = None; diff --git a/gdk/gdkim.c b/gdk/gdkim.c index 020460f329..a13d1a6124 100644 --- a/gdk/gdkim.c +++ b/gdk/gdkim.c @@ -625,7 +625,7 @@ gdk_ic_new (GdkICAttr *attr, GdkICAttributesType mask) } if (attr->client_window == NULL || - ((GdkWindowPrivate *)attr->client_window)->destroyed) + GDK_DRAWABLE_DESTROYED (attr->client_window)) { g_warning ("Client_window is null or already destroyed.\n"); return NULL; @@ -1084,7 +1084,7 @@ gdk_ic_set_attr (GdkIC *ic, if (mask & GDK_IC_PREEDIT_PIXMAP) { if (attr->preedit_pixmap != NULL && - ((GdkPixmapPrivate *)attr->preedit_pixmap)->destroyed) + GDK_DRAWABLE_DESTROYED (attr->preedit_pixmap)) { g_warning ("Preedit pixmap is already destroyed.\n"); error |= GDK_IC_PREEDIT_PIXMAP; @@ -1171,7 +1171,7 @@ gdk_ic_set_attr (GdkIC *ic, if (mask & GDK_IC_STATUS_PIXMAP) { if (attr->status_pixmap != NULL && - ((GdkPixmapPrivate *)attr->status_pixmap)->destroyed) + GDK_DRAWABLE_DESTROYED (attr->status_pixmap)) { g_warning ("Preedit pixmap is already destroyed.\n"); error |= GDK_IC_STATUS_PIXMAP; diff --git a/gdk/gdkimage.c b/gdk/gdkimage.c index 769727a4b6..4facec7e75 100644 --- a/gdk/gdkimage.c +++ b/gdk/gdkimage.c @@ -56,6 +56,7 @@ #include "gdk.h" /* For gdk_error_trap_* / gdk_flush_* */ #include "gdkimage.h" #include "gdkprivate.h" +#include "gdkx.h" static void gdk_image_put_normal (GdkDrawable *drawable, @@ -331,12 +332,10 @@ gdk_image_get (GdkWindow *window, { GdkImage *image; GdkImagePrivate *private; - GdkWindowPrivate *win_private; g_return_val_if_fail (window != NULL, NULL); - win_private = (GdkWindowPrivate *) window; - if (win_private->destroyed) + if (GDK_DRAWABLE_DESTROYED (window)) return NULL; private = g_new (GdkImagePrivate, 1); @@ -345,7 +344,7 @@ gdk_image_get (GdkWindow *window, private->xdisplay = gdk_display; private->image_put = gdk_image_put_normal; private->ximage = XGetImage (private->xdisplay, - win_private->xwindow, + GDK_DRAWABLE_XID (window), x, y, width, height, AllPlanes, ZPixmap); @@ -455,7 +454,6 @@ gdk_image_put_normal (GdkDrawable *drawable, gint width, gint height) { - GdkWindowPrivate *drawable_private; GdkImagePrivate *image_private; GdkGCPrivate *gc_private; @@ -463,15 +461,14 @@ gdk_image_put_normal (GdkDrawable *drawable, g_return_if_fail (image != NULL); g_return_if_fail (gc != NULL); - drawable_private = (GdkWindowPrivate*) drawable; - if (drawable_private->destroyed) + if (GDK_DRAWABLE_DESTROYED (drawable)) return; image_private = (GdkImagePrivate*) image; gc_private = (GdkGCPrivate*) gc; g_return_if_fail (image->type == GDK_IMAGE_NORMAL); - XPutImage (drawable_private->xdisplay, drawable_private->xwindow, + XPutImage (GDK_DRAWABLE_XDISPLAY (drawable), GDK_DRAWABLE_XID (drawable), gc_private->xgc, image_private->ximage, xsrc, ysrc, xdest, ydest, width, height); } @@ -488,7 +485,6 @@ gdk_image_put_shared (GdkDrawable *drawable, gint height) { #ifdef USE_SHM - GdkWindowPrivate *drawable_private; GdkImagePrivate *image_private; GdkGCPrivate *gc_private; @@ -496,15 +492,14 @@ gdk_image_put_shared (GdkDrawable *drawable, g_return_if_fail (image != NULL); g_return_if_fail (gc != NULL); - drawable_private = (GdkWindowPrivate*) drawable; - if (drawable_private->destroyed) + if (GDK_DRAWABLE_DESTROYED (drawable)) return; image_private = (GdkImagePrivate*) image; gc_private = (GdkGCPrivate*) gc; g_return_if_fail (image->type == GDK_IMAGE_SHARED); - XShmPutImage (drawable_private->xdisplay, drawable_private->xwindow, + XShmPutImage (GDK_DRAWABLE_XDISPLAY (drawable), GDK_DRAWABLE_XID (drawable), gc_private->xgc, image_private->ximage, xsrc, ysrc, xdest, ydest, width, height, False); #else /* USE_SHM */ diff --git a/gdk/gdkinput.c b/gdk/gdkinput.c index 874a6cafe0..334c3d46d8 100644 --- a/gdk/gdkinput.c +++ b/gdk/gdkinput.c @@ -127,20 +127,20 @@ gdk_input_motion_events (GdkWindow *window, guint32 stop, gint *nevents_return) { - GdkWindowPrivate *window_private; XTimeCoord *xcoords; GdkTimeCoord *coords; int i; g_return_val_if_fail (window != NULL, NULL); - window_private = (GdkWindowPrivate *) window; - if (window_private->destroyed) + g_return_val_if_fail (GDK_IS_WINDOW (window), NULL); + + if (GDK_DRAWABLE_DESTROYED (window)) return NULL; if (deviceid == GDK_CORE_POINTER) { - xcoords = XGetMotionEvents (gdk_display, - window_private->xwindow, + xcoords = XGetMotionEvents (GDK_DRAWABLE_XDISPLAY (window), + GDK_DRAWABLE_XID (window), start, stop, nevents_return); if (xcoords) { @@ -224,8 +224,10 @@ gdk_input_set_extension_events (GdkWindow *window, gint mask, GdkInputWindow *iw; g_return_if_fail (window != NULL); + g_return_if_fail (GDK_IS_WINDOW (window)); + window_private = (GdkWindowPrivate*) window; - if (window_private->destroyed) + if (GDK_DRAWABLE_DESTROYED (window)) return; if (mode == GDK_EXTENSION_EVENTS_NONE) diff --git a/gdk/gdkinputcommon.h b/gdk/gdkinputcommon.h index edfc4ebd83..d9bb835b89 100644 --- a/gdk/gdkinputcommon.h +++ b/gdk/gdkinputcommon.h @@ -472,14 +472,14 @@ gdk_input_translate_coordinates (GdkDevicePrivate *gdkdev, gdouble *x, gdouble *y, gdouble *pressure, gdouble *xtilt, gdouble *ytilt) { - GdkWindowPrivate *win_priv; + GdkDrawablePrivate *drawable_priv; int x_axis, y_axis, pressure_axis, xtilt_axis, ytilt_axis; double device_width, device_height; double x_offset, y_offset, x_scale, y_scale; - win_priv = (GdkWindowPrivate *) input_window->window; + drawable_priv = (GdkDrawablePrivate *) input_window->window; x_axis = gdkdev->axis_for_use[GDK_AXIS_X]; y_axis = gdkdev->axis_for_use[GDK_AXIS_Y]; @@ -505,26 +505,26 @@ gdk_input_translate_coordinates (GdkDevicePrivate *gdkdev, double device_aspect = (device_height*gdkdev->axes[y_axis].resolution) / (device_width*gdkdev->axes[x_axis].resolution); - if (device_aspect * win_priv->width >= win_priv->height) + if (device_aspect * drawable_priv->width >= drawable_priv->height) { /* device taller than window */ - x_scale = win_priv->width / device_width; + x_scale = drawable_priv->width / device_width; y_scale = (x_scale * gdkdev->axes[x_axis].resolution) / gdkdev->axes[y_axis].resolution; x_offset = 0; y_offset = -(device_height * y_scale - - win_priv->height)/2; + drawable_priv->height)/2; } else { /* window taller than device */ - y_scale = win_priv->height / device_height; + y_scale = drawable_priv->height / device_height; x_scale = (y_scale * gdkdev->axes[y_axis].resolution) / gdkdev->axes[x_axis].resolution; y_offset = 0; - x_offset = - (device_width * x_scale - win_priv->width)/2; + x_offset = - (device_width * x_scale - drawable_priv->width)/2; } } diff --git a/gdk/gdkpixmap.c b/gdk/gdkpixmap.c index 5656b18a93..8ee69db9cd 100644 --- a/gdk/gdkpixmap.c +++ b/gdk/gdkpixmap.c @@ -34,6 +34,7 @@ #include "gdkpixmap.h" #include "gdkprivate.h" +#include "gdkx.h" typedef struct { @@ -56,36 +57,32 @@ gdk_pixmap_new (GdkWindow *window, gint depth) { GdkPixmap *pixmap; - GdkWindowPrivate *private; - GdkWindowPrivate *window_private; + GdkDrawablePrivate *private; + g_return_val_if_fail (window == NULL || GDK_IS_WINDOW (window), NULL); g_return_val_if_fail ((window != NULL) || (depth != -1), NULL); g_return_val_if_fail ((width != 0) && (height != 0), NULL); if (!window) window = (GdkWindow*) &gdk_root_parent; - window_private = (GdkWindowPrivate*) window; - if (window_private->destroyed) + if (GDK_DRAWABLE_DESTROYED (window)) return NULL; if (depth == -1) - depth = gdk_window_get_visual (window)->depth; + depth = gdk_drawable_get_visual (window)->depth; - private = g_new0 (GdkWindowPrivate, 1); + private = g_new0 (GdkDrawablePrivate, 1); pixmap = (GdkPixmap*) private; - private->xdisplay = window_private->xdisplay; - private->window_type = GDK_WINDOW_PIXMAP; - private->xwindow = XCreatePixmap (private->xdisplay, window_private->xwindow, + private->xdisplay = GDK_DRAWABLE_XDISPLAY (window); + private->window_type = GDK_DRAWABLE_PIXMAP; + private->xwindow = XCreatePixmap (private->xdisplay, + GDK_DRAWABLE_XID (window), width, height, depth); private->colormap = NULL; - private->parent = NULL; - private->x = 0; - private->y = 0; private->width = width; private->height = height; - private->resize_count = 0; private->ref_count = 1; private->destroyed = 0; @@ -101,35 +98,30 @@ gdk_bitmap_create_from_data (GdkWindow *window, gint height) { GdkPixmap *pixmap; - GdkWindowPrivate *private; - GdkWindowPrivate *window_private; + GdkDrawablePrivate *private; 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_WINDOW (window), NULL); if (!window) window = (GdkWindow*) &gdk_root_parent; - window_private = (GdkWindowPrivate*) window; - if (window_private->destroyed) + if (GDK_DRAWABLE_DESTROYED (window)) return NULL; - private = g_new0 (GdkWindowPrivate, 1); + private = g_new0 (GdkDrawablePrivate, 1); pixmap = (GdkPixmap*) private; - private->parent = NULL; - private->xdisplay = window_private->xdisplay; - private->window_type = GDK_WINDOW_PIXMAP; - private->x = 0; - private->y = 0; + private->xdisplay = GDK_DRAWABLE_XDISPLAY (window); + private->window_type = GDK_DRAWABLE_PIXMAP; private->width = width; private->height = height; - private->resize_count = 0; private->ref_count = 1; private->destroyed = FALSE; private->xwindow = XCreateBitmapFromData (private->xdisplay, - window_private->xwindow, + GDK_DRAWABLE_XID (window), (char *)data, width, height); gdk_xid_table_insert (&private->xwindow, pixmap); @@ -147,9 +139,9 @@ gdk_pixmap_create_from_data (GdkWindow *window, GdkColor *bg) { GdkPixmap *pixmap; - GdkWindowPrivate *private; - GdkWindowPrivate *window_private; + GdkDrawablePrivate *private; + g_return_val_if_fail (window == NULL || GDK_IS_WINDOW (window), 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); @@ -159,29 +151,24 @@ gdk_pixmap_create_from_data (GdkWindow *window, if (!window) window = (GdkWindow*) &gdk_root_parent; - window_private = (GdkWindowPrivate*) window; - if (window_private->destroyed) + if (GDK_DRAWABLE_DESTROYED (window)) return NULL; if (depth == -1) - depth = gdk_window_get_visual (window)->depth; + depth = gdk_drawable_get_visual (window)->depth; - private = g_new0 (GdkWindowPrivate, 1); + private = g_new0 (GdkDrawablePrivate, 1); pixmap = (GdkPixmap*) private; - private->parent = NULL; - private->xdisplay = window_private->xdisplay; - private->window_type = GDK_WINDOW_PIXMAP; - private->x = 0; - private->y = 0; + private->xdisplay = GDK_DRAWABLE_XDISPLAY (window); + private->window_type = GDK_DRAWABLE_PIXMAP; private->width = width; private->height = height; - private->resize_count = 0; private->ref_count = 1; private->destroyed = FALSE; private->xwindow = XCreatePixmapFromBitmapData (private->xdisplay, - window_private->xwindow, + GDK_DRAWABLE_XID (window), (char *)data, width, height, fg->pixel, bg->pixel, depth); @@ -460,8 +447,8 @@ _gdk_pixmap_create_from_xpm (GdkWindow *window, if (colormap == NULL) { - colormap = gdk_window_get_colormap (window); - visual = gdk_window_get_visual (window); + colormap = gdk_drawable_get_colormap (window); + visual = gdk_drawable_get_visual (window); } else visual = ((GdkColormapPrivate *)colormap)->visual; @@ -760,8 +747,7 @@ GdkPixmap* gdk_pixmap_foreign_new (guint32 anid) { GdkPixmap *pixmap; - GdkWindowPrivate *window_private; - GdkWindowPrivate *private; + GdkDrawablePrivate *private; Pixmap xpixmap; Window root_return; unsigned int x_ret, y_ret, w_ret, h_ret, bw_ret, depth_ret; @@ -772,29 +758,24 @@ gdk_pixmap_foreign_new (guint32 anid) /* set the pixmap to the passed in value */ xpixmap = anid; - /* get the root window */ - window_private = &gdk_root_parent; /* get information about the Pixmap to fill in the structure for the gdk window */ - if (!XGetGeometry(window_private->xdisplay, xpixmap, &root_return, + if (!XGetGeometry(GDK_DISPLAY(), + xpixmap, &root_return, &x_ret, &y_ret, &w_ret, &h_ret, &bw_ret, &depth_ret)) return NULL; /* allocate a new gdk pixmap */ - private = g_new(GdkWindowPrivate, 1); + private = g_new(GdkDrawablePrivate, 1); pixmap = (GdkPixmap *)private; - private->xdisplay = window_private->xdisplay; - private->window_type = GDK_WINDOW_PIXMAP; + private->xdisplay = GDK_DISPLAY(); + private->window_type = GDK_DRAWABLE_PIXMAP; private->xwindow = xpixmap; private->colormap = NULL; - private->parent = NULL; - private->x = 0; - private->y = 0; private->width = w_ret; private->height = h_ret; - private->resize_count = 0; private->ref_count = 1; private->destroyed = 0; @@ -806,8 +787,9 @@ gdk_pixmap_foreign_new (guint32 anid) GdkPixmap* gdk_pixmap_ref (GdkPixmap *pixmap) { - GdkWindowPrivate *private = (GdkWindowPrivate *)pixmap; + GdkDrawablePrivate *private = (GdkDrawablePrivate *)pixmap; g_return_val_if_fail (pixmap != NULL, NULL); + g_return_val_if_fail (GDK_IS_PIXMAP (private), NULL); private->ref_count += 1; return pixmap; @@ -816,8 +798,9 @@ gdk_pixmap_ref (GdkPixmap *pixmap) void gdk_pixmap_unref (GdkPixmap *pixmap) { - GdkWindowPrivate *private = (GdkWindowPrivate *)pixmap; + GdkDrawablePrivate *private = (GdkDrawablePrivate *)pixmap; g_return_if_fail (pixmap != NULL); + g_return_if_fail (GDK_IS_PIXMAP (private)); g_return_if_fail (private->ref_count > 0); private->ref_count -= 1; diff --git a/gdk/gdkprivate.h b/gdk/gdkprivate.h index 091ca44011..b7ec390147 100644 --- a/gdk/gdkprivate.h +++ b/gdk/gdkprivate.h @@ -43,18 +43,23 @@ #include #include -#define gdk_window_lookup(xid) ((GdkWindow*) gdk_xid_table_lookup (xid)) -#define gdk_pixmap_lookup(xid) ((GdkPixmap*) gdk_xid_table_lookup (xid)) -#define gdk_font_lookup(xid) ((GdkFont*) gdk_xid_table_lookup (xid)) - - #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ +#define GDK_DRAWABLE_TYPE(d) (((GdkDrawablePrivate *)d)->window_type) +#define GDK_IS_WINDOW(d) (GDK_DRAWABLE_TYPE(d) <= GDK_WINDOW_TEMP || \ + GDK_DRAWABLE_TYPE(d) == GDK_WINDOW_FOREIGN) +#define GDK_IS_PIXMAP(d) (GDK_DRAWABLE_TYPE(d) == GDK_DRAWABLE_PIXMAP) +#define GDK_DRAWABLE_DESTROYED(d) (((GdkDrawablePrivate *)d)->destroyed) +#define gdk_window_lookup(xid) ((GdkWindow*) gdk_xid_table_lookup (xid)) +#define gdk_pixmap_lookup(xid) ((GdkPixmap*) gdk_xid_table_lookup (xid)) +#define gdk_font_lookup(xid) ((GdkFont*) gdk_xid_table_lookup (xid)) + +typedef struct _GdkDrawablePrivate GdkDrawablePrivate; +/* typedef struct _GdkDrawablePrivate GdkPixmapPrivate; */ typedef struct _GdkWindowPrivate GdkWindowPrivate; -typedef struct _GdkWindowPrivate GdkPixmapPrivate; typedef struct _GdkImagePrivate GdkImagePrivate; typedef struct _GdkGCPrivate GdkGCPrivate; typedef struct _GdkColormapPrivate GdkColormapPrivate; @@ -66,21 +71,32 @@ typedef struct _GdkEventFilter GdkEventFilter; typedef struct _GdkClientFilter GdkClientFilter; typedef struct _GdkRegionPrivate GdkRegionPrivate; +struct _GdkDrawablePrivate +{ + GdkDrawable drawable; + + guint8 window_type; + guint ref_count; + + guint16 width; + guint16 height; + + Window xwindow; + Display *xdisplay; + GdkColormap *colormap; + + guint destroyed : 2; +}; struct _GdkWindowPrivate { + GdkDrawablePrivate drawable; + GdkWindow window; GdkWindow *parent; - Window xwindow; - Display *xdisplay; gint16 x; gint16 y; - guint16 width; - guint16 height; guint8 resize_count; - guint8 window_type; - guint ref_count; - guint destroyed : 2; guint mapped : 1; guint guffaw_gravity : 1; diff --git a/gdk/gdkproperty.c b/gdk/gdkproperty.c index 5a17abd769..b91b787d1b 100644 --- a/gdk/gdkproperty.c +++ b/gdk/gdkproperty.c @@ -28,6 +28,7 @@ #include #include +#include "gdkx.h" #include "gdkproperty.h" #include "gdkprivate.h" @@ -111,14 +112,11 @@ gdk_property_get (GdkWindow *window, if (window) { - GdkWindowPrivate *private; - - private = (GdkWindowPrivate*) window; - if (private->destroyed) + if (GDK_DRAWABLE_DESTROYED (window)) return FALSE; - xdisplay = private->xdisplay; - xwindow = private->xwindow; + xdisplay = GDK_WINDOW_XDISPLAY (window); + xwindow = GDK_WINDOW_XWINDOW (window); } else { @@ -200,14 +198,11 @@ gdk_property_change (GdkWindow *window, if (window) { - GdkWindowPrivate *private; - - private = (GdkWindowPrivate*) window; - if (private->destroyed) + if (GDK_DRAWABLE_DESTROYED (window)) return; - xdisplay = private->xdisplay; - xwindow = private->xwindow; + xdisplay = GDK_WINDOW_XDISPLAY (window); + xwindow = GDK_WINDOW_XWINDOW (window); } else { @@ -228,14 +223,11 @@ gdk_property_delete (GdkWindow *window, if (window) { - GdkWindowPrivate *private; - - private = (GdkWindowPrivate*) window; - if (private->destroyed) + if (GDK_DRAWABLE_DESTROYED (window)) return; - xdisplay = private->xdisplay; - xwindow = private->xwindow; + xdisplay = GDK_WINDOW_XDISPLAY (window); + xwindow = GDK_WINDOW_XWINDOW (window); } else { diff --git a/gdk/gdkselection.c b/gdk/gdkselection.c index ebffc3579c..e1272f4213 100644 --- a/gdk/gdkselection.c +++ b/gdk/gdkselection.c @@ -45,14 +45,11 @@ gdk_selection_owner_set (GdkWindow *owner, if (owner) { - GdkWindowPrivate *private; - - private = (GdkWindowPrivate*) owner; - if (private->destroyed) + if (GDK_DRAWABLE_DESTROYED (owner)) return FALSE; - xdisplay = private->xdisplay; - xwindow = private->xwindow; + xdisplay = GDK_DRAWABLE_XDISPLAY (owner); + xwindow = GDK_DRAWABLE_XID (owner); } else { @@ -83,16 +80,11 @@ gdk_selection_convert (GdkWindow *requestor, GdkAtom target, guint32 time) { - GdkWindowPrivate *private; - - g_return_if_fail (requestor != NULL); - - private = (GdkWindowPrivate*) requestor; - if (private->destroyed) + if (GDK_DRAWABLE_DESTROYED (requestor)) return; - XConvertSelection (private->xdisplay, selection, target, - gdk_selection_property, private->xwindow, time); + XConvertSelection (GDK_DRAWABLE_XDISPLAY (requestor), selection, target, + gdk_selection_property, GDK_DRAWABLE_XID (requestor), time); } gint @@ -101,7 +93,6 @@ gdk_selection_property_get (GdkWindow *requestor, GdkAtom *ret_type, gint *ret_format) { - GdkWindowPrivate *private; gulong nitems; gulong nbytes; gulong length; @@ -110,17 +101,18 @@ gdk_selection_property_get (GdkWindow *requestor, guchar *t = NULL; g_return_val_if_fail (requestor != NULL, 0); + g_return_val_if_fail (GDK_IS_WINDOW (requestor), 0); /* If retrieved chunks are typically small, (and the ICCCM says the should be) it would be a win to try first with a buffer of moderate length, to avoid two round trips to the server */ - private = (GdkWindowPrivate*) requestor; - if (private->destroyed) + if (GDK_DRAWABLE_DESTROYED (requestor)) return 0; t = NULL; - XGetWindowProperty (private->xdisplay, private->xwindow, + XGetWindowProperty (GDK_DRAWABLE_XDISPLAY (requestor), + GDK_DRAWABLE_XID (requestor), gdk_selection_property, 0, 0, False, AnyPropertyType, &prop_type, &prop_format, &nitems, &nbytes, &t); @@ -150,7 +142,8 @@ gdk_selection_property_get (GdkWindow *requestor, protocol, in which case the client has to make sure they'll be notified of PropertyChange events _before_ the property is deleted. Otherwise there's no guarantee we'll win the race ... */ - XGetWindowProperty (private->xdisplay, private->xwindow, + XGetWindowProperty (GDK_DRAWABLE_XDISPLAY (requestor), + GDK_DRAWABLE_XID (requestor), gdk_selection_property, 0, (nbytes + 3) / 4, False, AnyPropertyType, &prop_type, &prop_format, &nitems, &nbytes, &t); diff --git a/gdk/gdktypes.h b/gdk/gdktypes.h index 2584e49af3..e5483a6fe5 100644 --- a/gdk/gdktypes.h +++ b/gdk/gdktypes.h @@ -82,10 +82,10 @@ typedef struct _GdkImage GdkImage; typedef struct _GdkRegion GdkRegion; typedef struct _GdkVisual GdkVisual; -typedef struct _GdkWindow GdkBitmap; -typedef struct _GdkWindow GdkDrawable; -typedef struct _GdkWindow GdkPixmap; -typedef struct _GdkWindow GdkWindow; +typedef struct _GdkDrawable GdkDrawable; +typedef struct _GdkDrawable GdkBitmap; +typedef struct _GdkDrawable GdkPixmap; +typedef struct _GdkDrawable GdkWindow; typedef enum { diff --git a/gdk/gdkwindow.c b/gdk/gdkwindow.c index ddd5267eac..16bdb37d7c 100644 --- a/gdk/gdkwindow.c +++ b/gdk/gdkwindow.c @@ -34,6 +34,7 @@ #include "gdkwindow.h" #include "gdkinputprivate.h" #include "gdkprivate.h" +#include "gdkx.h" #include "MwmUtil.h" #include @@ -87,7 +88,7 @@ gdk_window_xid_at (Window base, gboolean excl_child) { GdkWindow *window; - GdkWindowPrivate *private; + GdkDrawablePrivate *private; Display *disp; Window *list = NULL; Window child = 0, parent_win = 0, root_win = 0; @@ -96,7 +97,7 @@ gdk_window_xid_at (Window base, int wx, wy; window = (GdkWindow*) &gdk_root_parent; - private = (GdkWindowPrivate*) window; + private = (GdkDrawablePrivate*) window; disp = private->xdisplay; if (!XGetGeometry (disp, base, &root_win, &wx, &wy, &ww, &wh, &wb, &wd)) return 0; @@ -152,15 +153,15 @@ gdk_window_xid_at_coords (gint x, gboolean excl_child) { GdkWindow *window; - GdkWindowPrivate *private; + GdkDrawablePrivate *private; Display *disp; Window *list = NULL; Window root, child = 0, parent_win = 0, root_win = 0; unsigned int num; int i; - + window = (GdkWindow*) &gdk_root_parent; - private = (GdkWindowPrivate*) window; + private = (GdkDrawablePrivate*) window; disp = private->xdisplay; root = private->xwindow; num = g_list_length (excludes); @@ -225,15 +226,15 @@ gdk_window_init (void) &x, &y, &width, &height, &border_width, &depth); XGetWindowAttributes (gdk_display, gdk_root_window, &xattributes); - gdk_root_parent.xwindow = gdk_root_window; - gdk_root_parent.xdisplay = gdk_display; - gdk_root_parent.window_type = GDK_WINDOW_ROOT; - gdk_root_parent.window.user_data = NULL; - gdk_root_parent.width = width; - gdk_root_parent.height = height; + gdk_root_parent.drawable.xwindow = gdk_root_window; + gdk_root_parent.drawable.xdisplay = gdk_display; + gdk_root_parent.drawable.window_type = GDK_WINDOW_ROOT; + gdk_root_parent.drawable.drawable.user_data = NULL; + gdk_root_parent.drawable.width = width; + gdk_root_parent.drawable.height = height; gdk_root_parent.children = NULL; - gdk_root_parent.colormap = NULL; - gdk_root_parent.ref_count = 1; + gdk_root_parent.drawable.colormap = NULL; + gdk_root_parent.drawable.ref_count = 1; gdk_xid_table_insert (&gdk_root_window, &gdk_root_parent); } @@ -268,23 +269,23 @@ gdk_window_new (GdkWindow *parent, parent = (GdkWindow*) &gdk_root_parent; parent_private = (GdkWindowPrivate*) parent; - if (parent_private->destroyed) + if (GDK_DRAWABLE_DESTROYED (parent)) return NULL; - xparent = parent_private->xwindow; - parent_display = parent_private->xdisplay; + xparent = parent_private->drawable.xwindow; + parent_display = parent_private->drawable.xdisplay; private = g_new (GdkWindowPrivate, 1); window = (GdkWindow*) private; private->parent = parent; - private->xdisplay = parent_display; - private->destroyed = FALSE; + private->drawable.xdisplay = parent_display; + private->drawable.destroyed = FALSE; private->mapped = FALSE; private->guffaw_gravity = FALSE; private->resize_count = 0; - private->ref_count = 1; + private->drawable.ref_count = 1; xattributes_mask = 0; if (attributes_mask & GDK_WA_X) @@ -299,9 +300,9 @@ gdk_window_new (GdkWindow *parent, private->x = x; private->y = y; - private->width = (attributes->width > 1) ? (attributes->width) : (1); - private->height = (attributes->height > 1) ? (attributes->height) : (1); - private->window_type = attributes->window_type; + private->drawable.width = (attributes->width > 1) ? (attributes->width) : (1); + private->drawable.height = (attributes->height > 1) ? (attributes->height) : (1); + private->drawable.window_type = attributes->window_type; private->extension_events = FALSE; private->filters = NULL; @@ -346,42 +347,42 @@ gdk_window_new (GdkWindow *parent, depth = visual->depth; if (attributes_mask & GDK_WA_COLORMAP) - private->colormap = attributes->colormap; + private->drawable.colormap = attributes->colormap; else { if ((((GdkVisualPrivate*)gdk_visual_get_system ())->xvisual) == xvisual) - private->colormap = gdk_colormap_get_system (); + private->drawable.colormap = gdk_colormap_get_system (); else - private->colormap = gdk_colormap_new (visual, False); + private->drawable.colormap = gdk_colormap_new (visual, False); } xattributes.background_pixel = BlackPixel (gdk_display, gdk_screen); xattributes.border_pixel = BlackPixel (gdk_display, gdk_screen); xattributes_mask |= CWBorderPixel | CWBackPixel; - switch (private->window_type) + switch (private->drawable.window_type) { case GDK_WINDOW_TOPLEVEL: - xattributes.colormap = ((GdkColormapPrivate*) private->colormap)->xcolormap; + xattributes.colormap = ((GdkColormapPrivate*) private->drawable.colormap)->xcolormap; xattributes_mask |= CWColormap; xparent = gdk_root_window; break; case GDK_WINDOW_CHILD: - xattributes.colormap = ((GdkColormapPrivate*) private->colormap)->xcolormap; + xattributes.colormap = ((GdkColormapPrivate*) private->drawable.colormap)->xcolormap; xattributes_mask |= CWColormap; break; case GDK_WINDOW_DIALOG: - xattributes.colormap = ((GdkColormapPrivate*) private->colormap)->xcolormap; + xattributes.colormap = ((GdkColormapPrivate*) private->drawable.colormap)->xcolormap; xattributes_mask |= CWColormap; xparent = gdk_root_window; break; case GDK_WINDOW_TEMP: - xattributes.colormap = ((GdkColormapPrivate*) private->colormap)->xcolormap; + xattributes.colormap = ((GdkColormapPrivate*) private->drawable.colormap)->xcolormap; xattributes_mask |= CWColormap; xparent = gdk_root_window; @@ -403,18 +404,18 @@ gdk_window_new (GdkWindow *parent, { depth = 0; class = InputOnly; - private->colormap = NULL; + private->drawable.colormap = NULL; } - private->xwindow = XCreateWindow (private->xdisplay, xparent, - x, y, private->width, private->height, + private->drawable.xwindow = XCreateWindow (private->drawable.xdisplay, xparent, + x, y, private->drawable.width, private->drawable.height, 0, depth, class, xvisual, xattributes_mask, &xattributes); gdk_window_ref (window); - gdk_xid_table_insert (&private->xwindow, window); + gdk_xid_table_insert (&private->drawable.xwindow, window); - if (private->colormap) - gdk_colormap_ref (private->colormap); + if (private->drawable.colormap) + gdk_colormap_ref (private->drawable.colormap); gdk_window_set_cursor (window, ((attributes_mask & GDK_WA_CURSOR) ? (attributes->cursor) : @@ -423,18 +424,18 @@ gdk_window_new (GdkWindow *parent, if (parent_private) parent_private->children = g_list_prepend (parent_private->children, window); - switch (private->window_type) + switch (private->drawable.window_type) { case GDK_WINDOW_DIALOG: - XSetTransientForHint (private->xdisplay, private->xwindow, xparent); + XSetTransientForHint (private->drawable.xdisplay, private->drawable.xwindow, xparent); case GDK_WINDOW_TOPLEVEL: case GDK_WINDOW_TEMP: - XSetWMProtocols (private->xdisplay, private->xwindow, gdk_wm_window_protocols, 2); + XSetWMProtocols (private->drawable.xdisplay, private->drawable.xwindow, gdk_wm_window_protocols, 2); break; case GDK_WINDOW_CHILD: if ((attributes->wclass == GDK_INPUT_OUTPUT) && - (private->colormap != gdk_colormap_get_system ()) && - (private->colormap != gdk_window_get_colormap (gdk_window_get_toplevel (window)))) + (private->drawable.colormap != gdk_colormap_get_system ()) && + (private->drawable.colormap != gdk_window_get_colormap (gdk_window_get_toplevel (window)))) { GDK_NOTE (MISC, g_message ("adding colormap window\n")); gdk_window_add_colormap_windows (window); @@ -447,8 +448,8 @@ gdk_window_new (GdkWindow *parent, } size_hints.flags = PSize; - size_hints.width = private->width; - size_hints.height = private->height; + size_hints.width = private->drawable.width; + size_hints.height = private->drawable.height; wm_hints.flags = InputHint | StateHint | WindowGroupHint; wm_hints.window_group = gdk_leader_window; @@ -459,14 +460,14 @@ gdk_window_new (GdkWindow *parent, * attention to PSize, and even if they do, is this the * correct value??? */ - XSetWMNormalHints (private->xdisplay, private->xwindow, &size_hints); + XSetWMNormalHints (private->drawable.xdisplay, private->drawable.xwindow, &size_hints); - XSetWMHints (private->xdisplay, private->xwindow, &wm_hints); + XSetWMHints (private->drawable.xdisplay, private->drawable.xwindow, &wm_hints); if (!wm_client_leader_atom) wm_client_leader_atom = gdk_atom_intern ("WM_CLIENT_LEADER", FALSE); - XChangeProperty (private->xdisplay, private->xwindow, + XChangeProperty (private->drawable.xdisplay, private->drawable.xwindow, wm_client_leader_atom, XA_WINDOW, 32, PropModeReplace, (guchar*) &gdk_leader_window, 1); @@ -476,7 +477,7 @@ gdk_window_new (GdkWindow *parent, else title = g_get_prgname (); - XmbSetWMProperties (private->xdisplay, private->xwindow, + XmbSetWMProperties (private->drawable.xdisplay, private->drawable.xwindow, title, title, NULL, 0, NULL, NULL, NULL); @@ -486,7 +487,7 @@ gdk_window_new (GdkWindow *parent, class_hint = XAllocClassHint (); class_hint->res_name = attributes->wmclass_name; class_hint->res_class = attributes->wmclass_class; - XSetClassHint (private->xdisplay, private->xwindow, class_hint); + XSetClassHint (private->drawable.xdisplay, private->drawable.xwindow, class_hint); XFree (class_hint); } @@ -530,21 +531,21 @@ gdk_window_foreign_new (guint32 anid) if (parent_private) parent_private->children = g_list_prepend (parent_private->children, window); - private->xwindow = anid; - private->xdisplay = gdk_display; + private->drawable.xwindow = anid; + private->drawable.xdisplay = gdk_display; private->x = attrs.x; private->y = attrs.y; - private->width = attrs.width; - private->height = attrs.height; + private->drawable.width = attrs.width; + private->drawable.height = attrs.height; private->resize_count = 0; - private->ref_count = 1; - private->window_type = GDK_WINDOW_FOREIGN; - private->destroyed = FALSE; + private->drawable.ref_count = 1; + private->drawable.window_type = GDK_WINDOW_FOREIGN; + private->drawable.destroyed = FALSE; private->mapped = (attrs.map_state != IsUnmapped); private->guffaw_gravity = FALSE; private->extension_events = 0; - private->colormap = NULL; + private->drawable.colormap = NULL; private->filters = NULL; private->children = NULL; @@ -552,7 +553,7 @@ gdk_window_foreign_new (guint32 anid) window->user_data = NULL; gdk_window_ref (window); - gdk_xid_table_insert (&private->xwindow, window); + gdk_xid_table_insert (&private->drawable.xwindow, window); return window; } @@ -578,14 +579,14 @@ gdk_window_internal_destroy (GdkWindow *window, private = (GdkWindowPrivate*) window; - switch (private->window_type) + switch (private->drawable.window_type) { case GDK_WINDOW_TOPLEVEL: case GDK_WINDOW_CHILD: case GDK_WINDOW_DIALOG: case GDK_WINDOW_TEMP: case GDK_WINDOW_FOREIGN: - if (!private->destroyed) + if (!private->drawable.destroyed) { if (private->parent) { @@ -594,7 +595,7 @@ gdk_window_internal_destroy (GdkWindow *window, parent_private->children = g_list_remove (parent_private->children, window); } - if (private->window_type != GDK_WINDOW_FOREIGN) + if (GDK_DRAWABLE_TYPE (window) != GDK_WINDOW_FOREIGN) { children = tmp = private->children; private->children = NULL; @@ -630,7 +631,7 @@ gdk_window_internal_destroy (GdkWindow *window, private->filters = NULL; } - if (private->window_type == GDK_WINDOW_FOREIGN) + if (private->drawable.window_type == GDK_WINDOW_FOREIGN) { if (our_destroy && (private->parent != NULL)) { @@ -645,26 +646,26 @@ gdk_window_internal_destroy (GdkWindow *window, gdk_window_reparent (window, NULL, 0, 0); xevent.type = ClientMessage; - xevent.window = private->xwindow; + xevent.window = private->drawable.xwindow; xevent.message_type = gdk_wm_protocols; xevent.format = 32; xevent.data.l[0] = gdk_wm_delete_window; xevent.data.l[1] = CurrentTime; - XSendEvent (private->xdisplay, private->xwindow, + XSendEvent (private->drawable.xdisplay, private->drawable.xwindow, False, 0, (XEvent *)&xevent); gdk_flush (); gdk_error_trap_pop (); } } else if (xdestroy) - XDestroyWindow (private->xdisplay, private->xwindow); + XDestroyWindow (private->drawable.xdisplay, private->drawable.xwindow); - if (private->colormap) - gdk_colormap_unref (private->colormap); + if (private->drawable.colormap) + gdk_colormap_unref (private->drawable.colormap); private->mapped = FALSE; - private->destroyed = TRUE; + private->drawable.destroyed = TRUE; } break; @@ -693,21 +694,17 @@ gdk_window_destroy (GdkWindow *window) void gdk_window_destroy_notify (GdkWindow *window) { - GdkWindowPrivate *private; - g_return_if_fail (window != NULL); - private = (GdkWindowPrivate*) window; - - if (!private->destroyed) + if (!GDK_DRAWABLE_DESTROYED (window)) { - if (private->window_type != GDK_WINDOW_FOREIGN) - g_warning ("GdkWindow %#lx unexpectedly destroyed", private->xwindow); + if (GDK_DRAWABLE_TYPE(window) != GDK_WINDOW_FOREIGN) + g_warning ("GdkWindow %#lx unexpectedly destroyed", GDK_DRAWABLE_XID (window)); gdk_window_internal_destroy (window, FALSE, FALSE); } - gdk_xid_table_remove (private->xwindow); + gdk_xid_table_remove (GDK_DRAWABLE_XID (window)); gdk_window_unref (window); } @@ -717,7 +714,7 @@ gdk_window_ref (GdkWindow *window) GdkWindowPrivate *private = (GdkWindowPrivate *)window; g_return_val_if_fail (window != NULL, NULL); - private->ref_count += 1; + private->drawable.ref_count += 1; return window; } @@ -726,15 +723,14 @@ gdk_window_unref (GdkWindow *window) { GdkWindowPrivate *private = (GdkWindowPrivate *)window; g_return_if_fail (window != NULL); - g_return_if_fail (private->ref_count > 0); - private->ref_count -= 1; - if (private->ref_count == 0) + private->drawable.ref_count -= 1; + if (private->drawable.ref_count == 0) { - if (!private->destroyed) + if (!private->drawable.destroyed) { - if (private->window_type == GDK_WINDOW_FOREIGN) - gdk_xid_table_remove (private->xwindow); + if (private->drawable.window_type == GDK_WINDOW_FOREIGN) + gdk_xid_table_remove (private->drawable.xwindow); else g_warning ("losing last reference to undestroyed window\n"); } @@ -751,11 +747,11 @@ gdk_window_show (GdkWindow *window) g_return_if_fail (window != NULL); private = (GdkWindowPrivate*) window; - if (!private->destroyed) + if (!private->drawable.destroyed) { private->mapped = TRUE; - XRaiseWindow (private->xdisplay, private->xwindow); - XMapWindow (private->xdisplay, private->xwindow); + XRaiseWindow (private->drawable.xdisplay, private->drawable.xwindow); + XMapWindow (private->drawable.xdisplay, private->drawable.xwindow); } } @@ -767,10 +763,10 @@ gdk_window_hide (GdkWindow *window) g_return_if_fail (window != NULL); private = (GdkWindowPrivate*) window; - if (!private->destroyed) + if (!private->drawable.destroyed) { private->mapped = FALSE; - XUnmapWindow (private->xdisplay, private->xwindow); + XUnmapWindow (private->drawable.xdisplay, private->drawable.xwindow); } } @@ -782,8 +778,8 @@ gdk_window_withdraw (GdkWindow *window) g_return_if_fail (window != NULL); private = (GdkWindowPrivate*) window; - if (!private->destroyed) - XWithdrawWindow (private->xdisplay, private->xwindow, 0); + if (!private->drawable.destroyed) + XWithdrawWindow (private->drawable.xdisplay, private->drawable.xwindow, 0); } void @@ -796,11 +792,11 @@ gdk_window_move (GdkWindow *window, g_return_if_fail (window != NULL); private = (GdkWindowPrivate*) window; - if (!private->destroyed) + if (!private->drawable.destroyed) { - XMoveWindow (private->xdisplay, private->xwindow, x, y); + XMoveWindow (private->drawable.xdisplay, private->drawable.xwindow, x, y); - if (private->window_type == GDK_WINDOW_CHILD) + if (private->drawable.window_type == GDK_WINDOW_CHILD) { private->x = x; private->y = y; @@ -816,26 +812,29 @@ gdk_window_resize (GdkWindow *window, GdkWindowPrivate *private; g_return_if_fail (window != NULL); + g_return_if_fail (GDK_IS_WINDOW (window)); if (width < 1) width = 1; if (height < 1) height = 1; - + private = (GdkWindowPrivate*) window; - if (!private->destroyed && + if (!private->drawable.destroyed && ((private->resize_count > 0) || - (private->width != (guint16) width) || - (private->height != (guint16) height))) + (private->drawable.width != (guint16) width) || + (private->drawable.height != (guint16) height))) { - XResizeWindow (private->xdisplay, private->xwindow, width, height); + XResizeWindow (GDK_DRAWABLE_XDISPLAY (private), + GDK_DRAWABLE_XID (private), + width, height); private->resize_count += 1; - if (private->window_type == GDK_WINDOW_CHILD) + if (GDK_DRAWABLE_TYPE (private) == GDK_WINDOW_CHILD) { - private->width = width; - private->height = height; + private->drawable.width = width; + private->drawable.height = height; } } } @@ -850,16 +849,20 @@ gdk_window_move_resize (GdkWindow *window, GdkWindowPrivate *private; g_return_if_fail (window != NULL); - + g_return_if_fail (GDK_IS_WINDOW (window)); + if (width < 1) width = 1; if (height < 1) height = 1; private = (GdkWindowPrivate*) window; - if (!private->destroyed) + + if (!GDK_DRAWABLE_DESTROYED (window)) { - XMoveResizeWindow (private->xdisplay, private->xwindow, x, y, width, height); + XMoveResizeWindow (GDK_DRAWABLE_XDISPLAY (window), + GDK_DRAWABLE_XID (window), + x, y, width, height); if (private->guffaw_gravity) { @@ -875,12 +878,12 @@ gdk_window_move_resize (GdkWindow *window, } } - if (private->window_type == GDK_WINDOW_CHILD) + if (GDK_DRAWABLE_TYPE (private) == GDK_WINDOW_CHILD) { private->x = x; private->y = y; - private->width = width; - private->height = height; + private->drawable.width = width; + private->drawable.height = height; } } } @@ -896,6 +899,9 @@ gdk_window_reparent (GdkWindow *window, GdkWindowPrivate *old_parent_private; g_return_if_fail (window != NULL); + g_return_if_fail (GDK_IS_WINDOW (window)); + g_return_if_fail (new_parent != NULL); + g_return_if_fail (GDK_IS_WINDOW (new_parent)); if (!new_parent) new_parent = (GdkWindow*) &gdk_root_parent; @@ -904,10 +910,10 @@ gdk_window_reparent (GdkWindow *window, old_parent_private = (GdkWindowPrivate*)window_private->parent; parent_private = (GdkWindowPrivate*) new_parent; - if (!window_private->destroyed && !parent_private->destroyed) - XReparentWindow (window_private->xdisplay, - window_private->xwindow, - parent_private->xwindow, + if (!GDK_DRAWABLE_DESTROYED (window) && !GDK_DRAWABLE_DESTROYED (new_parent)) + XReparentWindow (GDK_DRAWABLE_XDISPLAY (window), + GDK_DRAWABLE_XID (window), + GDK_DRAWABLE_XID (new_parent), x, y); window_private->parent = new_parent; @@ -926,14 +932,11 @@ gdk_window_reparent (GdkWindow *window, void gdk_window_clear (GdkWindow *window) { - GdkWindowPrivate *private; - g_return_if_fail (window != NULL); + g_return_if_fail (GDK_IS_WINDOW (window)); - private = (GdkWindowPrivate*) window; - - if (!private->destroyed) - XClearWindow (private->xdisplay, private->xwindow); + if (!GDK_DRAWABLE_DESTROYED (window)) + XClearWindow (GDK_DRAWABLE_XDISPLAY (window), GDK_DRAWABLE_XID (window)); } void @@ -943,14 +946,11 @@ gdk_window_clear_area (GdkWindow *window, gint width, gint height) { - GdkWindowPrivate *private; - g_return_if_fail (window != NULL); + g_return_if_fail (GDK_IS_WINDOW (window)); - private = (GdkWindowPrivate*) window; - - if (!private->destroyed) - XClearArea (private->xdisplay, private->xwindow, + if (!GDK_DRAWABLE_DESTROYED (window)) + XClearArea (GDK_DRAWABLE_XDISPLAY (window), GDK_DRAWABLE_XID (window), x, y, width, height, False); } @@ -961,76 +961,32 @@ gdk_window_clear_area_e (GdkWindow *window, gint width, gint height) { - GdkWindowPrivate *private; - g_return_if_fail (window != NULL); + g_return_if_fail (GDK_IS_WINDOW (window)); - private = (GdkWindowPrivate*) window; - - if (!private->destroyed) - XClearArea (private->xdisplay, private->xwindow, + if (!GDK_DRAWABLE_DESTROYED (window)) + XClearArea (GDK_DRAWABLE_XDISPLAY (window), GDK_DRAWABLE_XID (window), x, y, width, height, True); } -void -gdk_window_copy_area (GdkWindow *window, - GdkGC *gc, - gint x, - gint y, - GdkWindow *source_window, - gint source_x, - gint source_y, - gint width, - gint height) -{ - GdkWindowPrivate *src_private; - GdkWindowPrivate *dest_private; - GdkGCPrivate *gc_private; - - g_return_if_fail (window != NULL); - g_return_if_fail (gc != NULL); - - if (source_window == NULL) - source_window = window; - - src_private = (GdkWindowPrivate*) source_window; - dest_private = (GdkWindowPrivate*) window; - gc_private = (GdkGCPrivate*) gc; - - if (!src_private->destroyed && !dest_private->destroyed) - { - XCopyArea (dest_private->xdisplay, src_private->xwindow, dest_private->xwindow, - gc_private->xgc, - source_x, source_y, - width, height, - x, y); - } -} - void gdk_window_raise (GdkWindow *window) { - GdkWindowPrivate *private; - g_return_if_fail (window != NULL); + g_return_if_fail (GDK_IS_WINDOW (window)); - private = (GdkWindowPrivate*) window; - - if (!private->destroyed) - XRaiseWindow (private->xdisplay, private->xwindow); + if (!GDK_DRAWABLE_DESTROYED (window)) + XRaiseWindow (GDK_DRAWABLE_XDISPLAY (window), GDK_DRAWABLE_XID (window)); } void gdk_window_lower (GdkWindow *window) { - GdkWindowPrivate *private; - g_return_if_fail (window != NULL); + g_return_if_fail (GDK_IS_WINDOW (window)); - private = (GdkWindowPrivate*) window; - - if (!private->destroyed) - XLowerWindow (private->xdisplay, private->xwindow); + if (!GDK_DRAWABLE_DESTROYED (window)) + XLowerWindow (GDK_DRAWABLE_XDISPLAY (window), GDK_DRAWABLE_XID (window)); } void @@ -1052,13 +1008,12 @@ gdk_window_set_hints (GdkWindow *window, gint max_height, gint flags) { - GdkWindowPrivate *private; XSizeHints size_hints; g_return_if_fail (window != NULL); + g_return_if_fail (GDK_IS_WINDOW (window)); - private = (GdkWindowPrivate*) window; - if (private->destroyed) + if (GDK_DRAWABLE_DESTROYED (window)) return; size_hints.flags = 0; @@ -1087,7 +1042,9 @@ gdk_window_set_hints (GdkWindow *window, /* FIXME: Would it be better to delete this property of * flags == 0? It would save space on the server */ - XSetWMNormalHints (private->xdisplay, private->xwindow, &size_hints); + XSetWMNormalHints (GDK_DRAWABLE_XDISPLAY (window), + GDK_DRAWABLE_XID (window), + &size_hints); } void @@ -1095,13 +1052,12 @@ gdk_window_set_geometry_hints (GdkWindow *window, GdkGeometry *geometry, GdkWindowHints geom_mask) { - GdkWindowPrivate *private; XSizeHints size_hints; g_return_if_fail (window != NULL); + g_return_if_fail (GDK_IS_WINDOW (window)); - private = (GdkWindowPrivate*) window; - if (private->destroyed) + if (GDK_DRAWABLE_DESTROYED (window)) return; size_hints.flags = 0; @@ -1173,20 +1129,21 @@ gdk_window_set_geometry_hints (GdkWindow *window, /* FIXME: Would it be better to delete this property of * geom_mask == 0? It would save space on the server */ - XSetWMNormalHints (private->xdisplay, private->xwindow, &size_hints); + XSetWMNormalHints (GDK_DRAWABLE_XDISPLAY (window), + GDK_DRAWABLE_XID (window), + &size_hints); } void gdk_window_set_title (GdkWindow *window, const gchar *title) { - GdkWindowPrivate *private; - g_return_if_fail (window != NULL); + g_return_if_fail (GDK_IS_WINDOW (window)); - private = (GdkWindowPrivate*) window; - if (!private->destroyed) - XmbSetWMProperties (private->xdisplay, private->xwindow, + if (!GDK_DRAWABLE_DESTROYED (window)) + XmbSetWMProperties (GDK_DRAWABLE_XDISPLAY (window), + GDK_DRAWABLE_XID (window), title, title, NULL, 0, NULL, NULL, NULL); } @@ -1194,19 +1151,19 @@ void gdk_window_set_role (GdkWindow *window, const gchar *role) { - GdkWindowPrivate *private; - g_return_if_fail (window != NULL); - - private = (GdkWindowPrivate*) window; - - if (role) - XChangeProperty (private->xdisplay, private->xwindow, - gdk_atom_intern ("WM_WINDOW_ROLE", FALSE), XA_STRING, - 8, PropModeReplace, role, strlen (role)); - else - XDeleteProperty (private->xdisplay, private->xwindow, - gdk_atom_intern ("WM_WINDOW_ROLE", FALSE)); + g_return_if_fail (GDK_IS_WINDOW (window)); + + if (!GDK_DRAWABLE_DESTROYED (window)) + { + if (role) + XChangeProperty (GDK_DRAWABLE_XDISPLAY (window), GDK_DRAWABLE_XID (window), + gdk_atom_intern ("WM_WINDOW_ROLE", FALSE), XA_STRING, + 8, PropModeReplace, role, strlen (role)); + else + XDeleteProperty (GDK_DRAWABLE_XDISPLAY (window), GDK_DRAWABLE_XID (window), + gdk_atom_intern ("WM_WINDOW_ROLE", FALSE)); + } } void @@ -1217,26 +1174,27 @@ gdk_window_set_transient_for (GdkWindow *window, GdkWindowPrivate *parent_private; g_return_if_fail (window != NULL); + g_return_if_fail (GDK_IS_WINDOW (window)); private = (GdkWindowPrivate*) window; parent_private = (GdkWindowPrivate*) parent; - if (!private->destroyed && !parent_private->destroyed) - XSetTransientForHint (private->xdisplay, - private->xwindow, parent_private->xwindow); + if (!GDK_DRAWABLE_DESTROYED (window) && !GDK_DRAWABLE_DESTROYED (parent)) + XSetTransientForHint (GDK_DRAWABLE_XDISPLAY (window), + GDK_DRAWABLE_XID (window), + GDK_DRAWABLE_XID (parent)); } void gdk_window_set_background (GdkWindow *window, GdkColor *color) { - GdkWindowPrivate *private; - g_return_if_fail (window != NULL); + g_return_if_fail (GDK_IS_WINDOW (window)); - private = (GdkWindowPrivate*) window; - if (!private->destroyed) - XSetWindowBackground (private->xdisplay, private->xwindow, color->pixel); + if (!GDK_DRAWABLE_DESTROYED (window)) + XSetWindowBackground (GDK_DRAWABLE_XDISPLAY (window), + GDK_DRAWABLE_XID (window), color->pixel); } void @@ -1244,38 +1202,34 @@ gdk_window_set_back_pixmap (GdkWindow *window, GdkPixmap *pixmap, gint parent_relative) { - GdkWindowPrivate *window_private; - GdkPixmapPrivate *pixmap_private; Pixmap xpixmap; g_return_if_fail (window != NULL); - - window_private = (GdkWindowPrivate*) window; - pixmap_private = (GdkPixmapPrivate*) pixmap; + g_return_if_fail (GDK_IS_WINDOW (window)); if (pixmap) - xpixmap = pixmap_private->xwindow; + xpixmap = GDK_DRAWABLE_XID (pixmap); else xpixmap = None; if (parent_relative) xpixmap = ParentRelative; - if (!window_private->destroyed) - XSetWindowBackgroundPixmap (window_private->xdisplay, window_private->xwindow, xpixmap); + if (!GDK_DRAWABLE_DESTROYED (window)) + XSetWindowBackgroundPixmap (GDK_DRAWABLE_XDISPLAY (window), + GDK_DRAWABLE_XID (window), xpixmap); } void gdk_window_set_cursor (GdkWindow *window, GdkCursor *cursor) { - GdkWindowPrivate *window_private; GdkCursorPrivate *cursor_private; Cursor xcursor; g_return_if_fail (window != NULL); + g_return_if_fail (GDK_IS_WINDOW (window)); - window_private = (GdkWindowPrivate*) window; cursor_private = (GdkCursorPrivate*) cursor; if (!cursor) @@ -1283,37 +1237,10 @@ gdk_window_set_cursor (GdkWindow *window, else xcursor = cursor_private->xcursor; - if (!window_private->destroyed) - XDefineCursor (window_private->xdisplay, window_private->xwindow, xcursor); -} - -void -gdk_window_set_colormap (GdkWindow *window, - GdkColormap *colormap) -{ - GdkWindowPrivate *window_private; - GdkColormapPrivate *colormap_private; - - g_return_if_fail (window != NULL); - g_return_if_fail (colormap != NULL); - - window_private = (GdkWindowPrivate*) window; - colormap_private = (GdkColormapPrivate*) colormap; - - if (!window_private->destroyed) - { - XSetWindowColormap (window_private->xdisplay, - window_private->xwindow, - colormap_private->xcolormap); - - if (window_private->colormap) - gdk_colormap_unref (window_private->colormap); - window_private->colormap = colormap; - gdk_colormap_ref (window_private->colormap); - - if (window_private->window_type != GDK_WINDOW_TOPLEVEL) - gdk_window_add_colormap_windows (window); - } + if (!GDK_DRAWABLE_DESTROYED (window)) + XDefineCursor (GDK_DRAWABLE_XDISPLAY (window), + GDK_DRAWABLE_XID (window), + xcursor); } void @@ -1333,7 +1260,6 @@ gdk_window_get_geometry (GdkWindow *window, gint *height, gint *depth) { - GdkWindowPrivate *window_private; Window root; gint tx; gint ty; @@ -1342,14 +1268,15 @@ gdk_window_get_geometry (GdkWindow *window, guint tborder_width; guint tdepth; + g_return_if_fail (window == NULL || GDK_IS_WINDOW (window)); + if (!window) - window = (GdkWindow*) &gdk_root_parent; + window = (GdkWindow *) &gdk_root_parent; - window_private = (GdkWindowPrivate*) window; - - if (!window_private->destroyed) + if (!GDK_DRAWABLE_DESTROYED (window)) { - XGetGeometry (window_private->xdisplay, window_private->xwindow, + XGetGeometry (GDK_DRAWABLE_XDISPLAY (window), + GDK_DRAWABLE_XID (window), &root, &tx, &ty, &twidth, &theight, &tborder_width, &tdepth); if (x) @@ -1373,6 +1300,7 @@ gdk_window_get_position (GdkWindow *window, GdkWindowPrivate *window_private; g_return_if_fail (window != NULL); + g_return_if_fail (GDK_IS_WINDOW (window)); window_private = (GdkWindowPrivate*) window; @@ -1382,97 +1310,11 @@ gdk_window_get_position (GdkWindow *window, *y = window_private->y; } -void -gdk_window_get_size (GdkWindow *window, - gint *width, - gint *height) -{ - GdkWindowPrivate *window_private; - - g_return_if_fail (window != NULL); - - window_private = (GdkWindowPrivate*) window; - - if (width) - *width = window_private->width; - if (height) - *height = window_private->height; -} - -GdkVisual* -gdk_window_get_visual (GdkWindow *window) -{ - GdkWindowPrivate *window_private; - XWindowAttributes window_attributes; - - g_return_val_if_fail (window != NULL, NULL); - - window_private = (GdkWindowPrivate*) window; - /* Huh? ->parent is never set for a pixmap. We should just return - * null immeditately - */ - while (window_private && (window_private->window_type == GDK_WINDOW_PIXMAP)) - window_private = (GdkWindowPrivate*) window_private->parent; - - if (window_private && !window_private->destroyed) - { - if (window_private->colormap == NULL) - { - XGetWindowAttributes (window_private->xdisplay, - window_private->xwindow, - &window_attributes); - return gdk_visual_lookup (window_attributes.visual); - } - else - return ((GdkColormapPrivate *)window_private->colormap)->visual; - } - - return NULL; -} - -GdkColormap* -gdk_window_get_colormap (GdkWindow *window) -{ - GdkWindowPrivate *window_private; - XWindowAttributes window_attributes; - - g_return_val_if_fail (window != NULL, NULL); - window_private = (GdkWindowPrivate*) window; - - g_return_val_if_fail (window_private->window_type != GDK_WINDOW_PIXMAP, NULL); - if (!window_private->destroyed) - { - if (window_private->colormap == NULL) - { - XGetWindowAttributes (window_private->xdisplay, - window_private->xwindow, - &window_attributes); - return gdk_colormap_lookup (window_attributes.colormap); - } - else - return window_private->colormap; - } - - return NULL; -} - -GdkWindowType -gdk_window_get_type (GdkWindow *window) -{ - GdkWindowPrivate *window_private; - - g_return_val_if_fail (window != NULL, (GdkWindowType) -1); - - window_private = (GdkWindowPrivate*) window; - return window_private->window_type; -} - gint gdk_window_get_origin (GdkWindow *window, gint *x, gint *y) { - GdkWindowPrivate *private; gint return_val; Window child; gint tx = 0; @@ -1480,12 +1322,10 @@ gdk_window_get_origin (GdkWindow *window, g_return_val_if_fail (window != NULL, 0); - private = (GdkWindowPrivate*) window; - - if (!private->destroyed) + if (!GDK_DRAWABLE_DESTROYED (window)) { - return_val = XTranslateCoordinates (private->xdisplay, - private->xwindow, + return_val = XTranslateCoordinates (GDK_DRAWABLE_XDISPLAY (window), + GDK_DRAWABLE_XID (window), gdk_root_window, 0, 0, &tx, &ty, &child); @@ -1507,7 +1347,6 @@ gdk_window_get_deskrelative_origin (GdkWindow *window, gint *x, gint *y) { - GdkWindowPrivate *private; gboolean return_val = FALSE; gint num_children, format_return; Window win, *child, parent, root; @@ -1519,16 +1358,15 @@ gdk_window_get_deskrelative_origin (GdkWindow *window, guchar *data_return; g_return_val_if_fail (window != NULL, 0); + g_return_val_if_fail (GDK_IS_WINDOW (window), 0); - private = (GdkWindowPrivate*) window; - - if (!private->destroyed) + if (!GDK_DRAWABLE_DESTROYED (window)) { if (!atom) - atom = XInternAtom (private->xdisplay, "ENLIGHTENMENT_DESKTOP", False); - win = private->xwindow; + atom = gdk_atom_intern ("ENLIGHTENMENT_DESKTOP", FALSE); + win = GDK_DRAWABLE_XID (window); - while (XQueryTree (private->xdisplay, win, &root, &parent, + while (XQueryTree (GDK_DRAWABLE_XDISPLAY (window), win, &root, &parent, &child, (unsigned int *)&num_children)) { if ((child) && (num_children > 0)) @@ -1543,7 +1381,7 @@ gdk_window_get_deskrelative_origin (GdkWindow *window, break; data_return = NULL; - XGetWindowProperty (private->xdisplay, win, atom, 0, 0, + XGetWindowProperty (GDK_DRAWABLE_XDISPLAY (window), win, atom, 0, 0, False, XA_CARDINAL, &type_return, &format_return, &number_return, &bytes_after_return, &data_return); if (type_return == XA_CARDINAL) @@ -1553,8 +1391,8 @@ gdk_window_get_deskrelative_origin (GdkWindow *window, } } - return_val = XTranslateCoordinates (private->xdisplay, - private->xwindow, + return_val = XTranslateCoordinates (GDK_DRAWABLE_XDISPLAY (window), + GDK_DRAWABLE_XID (window), win, 0, 0, &tx, &ty, &root); @@ -1581,25 +1419,27 @@ gdk_window_get_root_origin (GdkWindow *window, unsigned int nchildren; g_return_if_fail (window != NULL); + g_return_if_fail (GDK_IS_WINDOW (window)); private = (GdkWindowPrivate*) window; if (x) *x = 0; if (y) *y = 0; - if (private->destroyed) + + if (GDK_DRAWABLE_DESTROYED (window)) return; while (private->parent && ((GdkWindowPrivate*) private->parent)->parent) private = (GdkWindowPrivate*) private->parent; - if (private->destroyed) + if (GDK_DRAWABLE_DESTROYED (window)) return; - xparent = private->xwindow; + xparent = GDK_DRAWABLE_XID (window); do { xwindow = xparent; - if (!XQueryTree (private->xdisplay, xwindow, + if (!XQueryTree (GDK_DRAWABLE_XDISPLAY (window), xwindow, &root, &xparent, &children, &nchildren)) return; @@ -1614,7 +1454,7 @@ gdk_window_get_root_origin (GdkWindow *window, unsigned int ww, wh, wb, wd; int wx, wy; - if (XGetGeometry (private->xdisplay, xwindow, &root, &wx, &wy, &ww, &wh, &wb, &wd)) + if (XGetGeometry (GDK_DRAWABLE_XDISPLAY (window), xwindow, &root, &wx, &wy, &ww, &wh, &wb, &wd)) { if (x) *x = wx; @@ -1630,7 +1470,6 @@ gdk_window_get_pointer (GdkWindow *window, gint *y, GdkModifierType *mask) { - GdkWindowPrivate *private; GdkWindow *return_val; Window root; Window child; @@ -1638,16 +1477,17 @@ gdk_window_get_pointer (GdkWindow *window, int winx = 0; int winy = 0; unsigned int xmask = 0; + + g_return_val_if_fail (window == NULL || GDK_IS_WINDOW (window), NULL); if (!window) window = (GdkWindow*) &gdk_root_parent; - private = (GdkWindowPrivate*) window; - return_val = NULL; - if (!private->destroyed && - XQueryPointer (private->xdisplay, private->xwindow, &root, &child, - &rootx, &rooty, &winx, &winy, &xmask)) + if (!GDK_DRAWABLE_DESTROYED (window) && + XQueryPointer (GDK_DRAWABLE_XDISPLAY (window), + GDK_DRAWABLE_XID (window), + &root, &child, &rootx, &rooty, &winx, &winy, &xmask)) { if (child) return_val = gdk_window_lookup (child); @@ -1678,20 +1518,20 @@ gdk_window_at_pointer (gint *win_x, private = &gdk_root_parent; - xwindow = private->xwindow; + xwindow = private->drawable.xwindow; - XGrabServer (private->xdisplay); + XGrabServer (private->drawable.xdisplay); while (xwindow) { xwindow_last = xwindow; - XQueryPointer (private->xdisplay, + XQueryPointer (private->drawable.xdisplay, xwindow, &root, &xwindow, &rootx, &rooty, &winx, &winy, &xmask); } - XUngrabServer (private->xdisplay); + XUngrabServer (private->drawable.xdisplay); window = gdk_window_lookup (xwindow_last); @@ -1707,6 +1547,7 @@ GdkWindow* gdk_window_get_parent (GdkWindow *window) { g_return_val_if_fail (window != NULL, NULL); + g_return_val_if_fail (GDK_IS_WINDOW (window), NULL); return ((GdkWindowPrivate*) window)->parent; } @@ -1717,22 +1558,18 @@ gdk_window_get_toplevel (GdkWindow *window) GdkWindowPrivate *private; g_return_val_if_fail (window != NULL, NULL); + g_return_val_if_fail (GDK_IS_WINDOW (window), NULL); + + private = (GdkWindowPrivate *)window; + while (GDK_DRAWABLE_TYPE (private) == GDK_WINDOW_CHILD) + private = (GdkWindowPrivate *)private->parent; - private = (GdkWindowPrivate*) window; - - while (private->window_type == GDK_WINDOW_CHILD) - { - window = ((GdkWindowPrivate*) window)->parent; - private = (GdkWindowPrivate*) window; - } - - return window; + return (GdkWindow *)window; } GList* gdk_window_get_children (GdkWindow *window) { - GdkWindowPrivate *private; GdkWindow *child; GList *children; Window root; @@ -1742,12 +1579,13 @@ gdk_window_get_children (GdkWindow *window) unsigned int i; g_return_val_if_fail (window != NULL, NULL); - - private = (GdkWindowPrivate*) window; - if (private->destroyed) + g_return_val_if_fail (GDK_IS_WINDOW (window), NULL); + + if (GDK_DRAWABLE_DESTROYED (window)) return NULL; - XQueryTree (private->xdisplay, private->xwindow, + XQueryTree (GDK_DRAWABLE_XDISPLAY (window), + GDK_DRAWABLE_XID (window), &root, &parent, &xchildren, &nchildren); children = NULL; @@ -1771,83 +1609,82 @@ gdk_window_get_children (GdkWindow *window) GdkEventMask gdk_window_get_events (GdkWindow *window) { - GdkWindowPrivate *private; XWindowAttributes attrs; GdkEventMask event_mask; int i; g_return_val_if_fail (window != NULL, 0); - - private = (GdkWindowPrivate*) window; - if (private->destroyed) + g_return_val_if_fail (GDK_IS_WINDOW (window), 0); + + if (GDK_DRAWABLE_DESTROYED (window)) return 0; - - XGetWindowAttributes (gdk_display, private->xwindow, - &attrs); - - event_mask = 0; - for (i = 0; i < gdk_nevent_masks; i++) + else { - if (attrs.your_event_mask & gdk_event_mask_table[i]) - event_mask |= 1 << (i + 1); - } + XGetWindowAttributes (GDK_DRAWABLE_XDISPLAY (window), + GDK_DRAWABLE_XID (window), + &attrs); + + event_mask = 0; + for (i = 0; i < gdk_nevent_masks; i++) + { + if (attrs.your_event_mask & gdk_event_mask_table[i]) + event_mask |= 1 << (i + 1); + } - return event_mask; + return event_mask; + } } void gdk_window_set_events (GdkWindow *window, GdkEventMask event_mask) { - GdkWindowPrivate *private; long xevent_mask; int i; g_return_if_fail (window != NULL); + g_return_if_fail (GDK_IS_WINDOW (window)); - private = (GdkWindowPrivate*) window; - if (private->destroyed) - return; - - xevent_mask = StructureNotifyMask; - for (i = 0; i < gdk_nevent_masks; i++) + if (!GDK_DRAWABLE_DESTROYED (window)) { - if (event_mask & (1 << (i + 1))) - xevent_mask |= gdk_event_mask_table[i]; + xevent_mask = StructureNotifyMask; + for (i = 0; i < gdk_nevent_masks; i++) + { + if (event_mask & (1 << (i + 1))) + xevent_mask |= gdk_event_mask_table[i]; + } + + XSelectInput (GDK_DRAWABLE_XDISPLAY (window), + GDK_DRAWABLE_XID (window), + xevent_mask); } - - XSelectInput (gdk_display, private->xwindow, - xevent_mask); } void gdk_window_add_colormap_windows (GdkWindow *window) { GdkWindow *toplevel; - GdkWindowPrivate *toplevel_private; - GdkWindowPrivate *window_private; Window *old_windows; Window *new_windows; int i, count; g_return_if_fail (window != NULL); + g_return_if_fail (GDK_IS_WINDOW (window)); toplevel = gdk_window_get_toplevel (window); - toplevel_private = (GdkWindowPrivate*) toplevel; - window_private = (GdkWindowPrivate*) window; - if (window_private->destroyed) + if (GDK_DRAWABLE_DESTROYED (toplevel)) return; old_windows = NULL; - if (!XGetWMColormapWindows (toplevel_private->xdisplay, - toplevel_private->xwindow, + if (!XGetWMColormapWindows (GDK_DRAWABLE_XDISPLAY (toplevel), + GDK_DRAWABLE_XID (toplevel), &old_windows, &count)) { count = 0; } for (i = 0; i < count; i++) - if (old_windows[i] == window_private->xwindow) + if (old_windows[i] == GDK_DRAWABLE_XID (window)) { XFree (old_windows); return; @@ -1857,10 +1694,10 @@ gdk_window_add_colormap_windows (GdkWindow *window) for (i = 0; i < count; i++) new_windows[i] = old_windows[i]; - new_windows[count] = window_private->xwindow; + new_windows[count] = GDK_DRAWABLE_XID (window); - XSetWMColormapWindows (toplevel_private->xdisplay, - toplevel_private->xwindow, + XSetWMColormapWindows (GDK_DRAWABLE_XDISPLAY (toplevel), + GDK_DRAWABLE_XID (toplevel), new_windows, count + 1); g_free (new_windows); @@ -1896,24 +1733,20 @@ gdk_window_shape_combine_mask (GdkWindow *window, GdkBitmap *mask, gint x, gint y) { - GdkWindowPrivate *window_private; Pixmap pixmap; g_return_if_fail (window != NULL); + g_return_if_fail (GDK_IS_WINDOW (window)); #ifdef HAVE_SHAPE_EXT - window_private = (GdkWindowPrivate*) window; - if (window_private->destroyed) + if (GDK_DRAWABLE_DESTROYED (window)) return; if (gdk_window_have_shape_ext ()) { if (mask) { - GdkWindowPrivate *pixmap_private; - - pixmap_private = (GdkWindowPrivate*) mask; - pixmap = (Pixmap) pixmap_private->xwindow; + pixmap = GDK_DRAWABLE_XID (mask); } else { @@ -1922,8 +1755,8 @@ gdk_window_shape_combine_mask (GdkWindow *window, pixmap = None; } - XShapeCombineMask (window_private->xdisplay, - window_private->xwindow, + XShapeCombineMask (GDK_DRAWABLE_XDISPLAY (window), + GDK_DRAWABLE_XID (window), ShapeBounding, x, y, pixmap, @@ -1941,8 +1774,11 @@ gdk_window_add_filter (GdkWindow *window, GList *tmp_list; GdkEventFilter *filter; + g_return_if_fail (window != NULL); + g_return_if_fail (GDK_IS_WINDOW (window)); + private = (GdkWindowPrivate*) window; - if (private && private->destroyed) + if (private && GDK_DRAWABLE_DESTROYED (window)) return; if (private) @@ -1977,6 +1813,9 @@ gdk_window_remove_filter (GdkWindow *window, GList *tmp_list, *node; GdkEventFilter *filter; + g_return_if_fail (window != NULL); + g_return_if_fail (GDK_IS_WINDOW (window)); + private = (GdkWindowPrivate*) window; if (private) @@ -2008,19 +1847,19 @@ void gdk_window_set_override_redirect (GdkWindow *window, gboolean override_redirect) { - GdkWindowPrivate *private; XSetWindowAttributes attr; g_return_if_fail (window != NULL); - private = (GdkWindowPrivate*) window; - if (private->destroyed) - return; - - attr.override_redirect = (override_redirect == FALSE)?False:True; - XChangeWindowAttributes (gdk_display, - ((GdkWindowPrivate *)window)->xwindow, - CWOverrideRedirect, - &attr); + g_return_if_fail (GDK_IS_WINDOW (window)); + + if (GDK_DRAWABLE_DESTROYED (window)) + { + attr.override_redirect = (override_redirect == FALSE)?False:True; + XChangeWindowAttributes (GDK_DRAWABLE_XDISPLAY (window), + GDK_DRAWABLE_XID (window), + CWOverrideRedirect, + &attr); + } } void @@ -2030,40 +1869,38 @@ gdk_window_set_icon (GdkWindow *window, GdkBitmap *mask) { XWMHints *wm_hints; - GdkWindowPrivate *window_private; - GdkWindowPrivate *private; g_return_if_fail (window != NULL); - window_private = (GdkWindowPrivate*) window; - if (window_private->destroyed) + g_return_if_fail (GDK_IS_WINDOW (window)); + + if (GDK_DRAWABLE_DESTROYED (window)) return; - wm_hints = XGetWMHints (window_private->xdisplay, window_private->xwindow); + wm_hints = XGetWMHints (GDK_DRAWABLE_XDISPLAY (window), + GDK_DRAWABLE_XID (window)); if (!wm_hints) wm_hints = XAllocWMHints (); if (icon_window != NULL) { - private = (GdkWindowPrivate *)icon_window; wm_hints->flags |= IconWindowHint; - wm_hints->icon_window = private->xwindow; + wm_hints->icon_window = GDK_DRAWABLE_XID (icon_window); } if (pixmap != NULL) { - private = (GdkWindowPrivate *)pixmap; wm_hints->flags |= IconPixmapHint; - wm_hints->icon_pixmap = private->xwindow; + wm_hints->icon_pixmap = GDK_DRAWABLE_XID (pixmap); } if (mask != NULL) { - private = (GdkWindowPrivate *)mask; wm_hints->flags |= IconMaskHint; - wm_hints->icon_mask = private->xwindow; + wm_hints->icon_mask = GDK_DRAWABLE_XID (mask); } - XSetWMHints (window_private->xdisplay, window_private->xwindow, wm_hints); + XSetWMHints (GDK_DRAWABLE_XDISPLAY (window), + GDK_DRAWABLE_XID (window), wm_hints); XFree (wm_hints); } @@ -2071,15 +1908,16 @@ void gdk_window_set_icon_name (GdkWindow *window, gchar * name) { - GdkWindowPrivate *window_private; XTextProperty property; gint res; g_return_if_fail (window != NULL); - window_private = (GdkWindowPrivate*) window; - if (window_private->destroyed) + g_return_if_fail (GDK_IS_WINDOW (window)); + + if (GDK_DRAWABLE_DESTROYED (window)) return; - res = XmbTextListToTextProperty (window_private->xdisplay, + + res = XmbTextListToTextProperty (GDK_DRAWABLE_XDISPLAY (window), &name, 1, XStdICCTextStyle, &property); if (res < 0) @@ -2088,7 +1926,8 @@ gdk_window_set_icon_name (GdkWindow *window, return; } - XSetWMIconName (window_private->xdisplay, window_private->xwindow, + XSetWMIconName (GDK_DRAWABLE_XDISPLAY (window), + GDK_DRAWABLE_XID (window), &property); if (property.value) @@ -2100,25 +1939,25 @@ gdk_window_set_group (GdkWindow *window, GdkWindow *leader) { XWMHints *wm_hints; - GdkWindowPrivate *window_private; - GdkWindowPrivate *private; g_return_if_fail (window != NULL); + g_return_if_fail (GDK_IS_WINDOW (window)); g_return_if_fail (leader != NULL); - window_private = (GdkWindowPrivate*) window; - if (window_private->destroyed) + g_return_if_fail (GDK_IS_WINDOW (leader)); + + if (GDK_DRAWABLE_DESTROYED (window) || GDK_DRAWABLE_DESTROYED (leader)) return; - private = (GdkWindowPrivate *)leader; - - wm_hints = XGetWMHints (window_private->xdisplay, window_private->xwindow); + wm_hints = XGetWMHints (GDK_DRAWABLE_XDISPLAY (window), + GDK_DRAWABLE_XID (window)); if (!wm_hints) wm_hints = XAllocWMHints (); wm_hints->flags |= WindowGroupHint; - wm_hints->window_group = private->xwindow; + wm_hints->window_group = GDK_DRAWABLE_XID (leader); - XSetWMHints (window_private->xdisplay, window_private->xwindow, wm_hints); + XSetWMHints (GDK_DRAWABLE_XDISPLAY (window), + GDK_DRAWABLE_XID (window), wm_hints); XFree (wm_hints); } @@ -2133,18 +1972,14 @@ gdk_window_set_mwm_hints (GdkWindow *window, gulong nitems; gulong bytes_after; - GdkWindowPrivate *window_private; - - g_return_if_fail (window != NULL); - window_private = (GdkWindowPrivate*) window; - if (window_private->destroyed) + if (GDK_DRAWABLE_DESTROYED (window)) return; if (!hints_atom) - hints_atom = XInternAtom (window_private->xdisplay, + hints_atom = XInternAtom (GDK_DRAWABLE_XDISPLAY (window), _XA_MOTIF_WM_HINTS, FALSE); - XGetWindowProperty (window_private->xdisplay, window_private->xwindow, + XGetWindowProperty (GDK_DRAWABLE_XDISPLAY (window), GDK_DRAWABLE_XID (window), hints_atom, 0, sizeof (MotifWmHints)/sizeof (long), False, AnyPropertyType, &type, &format, &nitems, &bytes_after, (guchar **)&hints); @@ -2165,7 +2000,7 @@ gdk_window_set_mwm_hints (GdkWindow *window, } } - XChangeProperty (window_private->xdisplay, window_private->xwindow, + XChangeProperty (GDK_DRAWABLE_XDISPLAY (window), GDK_DRAWABLE_XID (window), hints_atom, hints_atom, 32, PropModeReplace, (guchar *)hints, sizeof (MotifWmHints)/sizeof (long)); @@ -2179,6 +2014,9 @@ gdk_window_set_decorations (GdkWindow *window, { MotifWmHints hints; + g_return_if_fail (window != NULL); + g_return_if_fail (GDK_IS_WINDOW (window)); + hints.flags = MWM_HINTS_DECORATIONS; hints.decorations = decorations; @@ -2191,6 +2029,9 @@ gdk_window_set_functions (GdkWindow *window, { MotifWmHints hints; + g_return_if_fail (window != NULL); + g_return_if_fail (GDK_IS_WINDOW (window)); + hints.flags = MWM_HINTS_FUNCTIONS; hints.functions = functions; @@ -2529,34 +2370,28 @@ gdk_propagate_shapes (Display *disp, void gdk_window_set_child_shapes (GdkWindow *window) { - GdkWindowPrivate *private; - g_return_if_fail (window != NULL); + g_return_if_fail (GDK_IS_WINDOW (window)); #ifdef HAVE_SHAPE_EXT - private = (GdkWindowPrivate*) window; - if (private->destroyed) - return; - - if (gdk_window_have_shape_ext ()) - gdk_propagate_shapes (private->xdisplay, private->xwindow, FALSE); + if (!GDK_DRAWABLE_DESTROYED (window) && + gdk_window_have_shape_ext ()) + gdk_propagate_shapes (GDK_DRAWABLE_XDISPLAY (window), + GDK_DRAWABLE_XID (window), FALSE); #endif } void gdk_window_merge_child_shapes (GdkWindow *window) { - GdkWindowPrivate *private; - g_return_if_fail (window != NULL); + g_return_if_fail (GDK_IS_WINDOW (window)); #ifdef HAVE_SHAPE_EXT - private = (GdkWindowPrivate*) window; - if (private->destroyed) - return; - - if (gdk_window_have_shape_ext ()) - gdk_propagate_shapes (private->xdisplay, private->xwindow, TRUE); + if (!GDK_DRAWABLE_DESTROYED (window) && + gdk_window_have_shape_ext ()) + gdk_propagate_shapes (GDK_DRAWABLE_XDISPLAY (window), + GDK_DRAWABLE_XID (window), TRUE); #endif } @@ -2575,6 +2410,7 @@ gdk_window_is_visible (GdkWindow *window) GdkWindowPrivate *private = (GdkWindowPrivate *)window; g_return_val_if_fail (window != NULL, FALSE); + g_return_val_if_fail (GDK_IS_WINDOW (window), FALSE); return private->mapped; } @@ -2597,10 +2433,11 @@ gdk_window_is_viewable (GdkWindow *window) GdkWindowPrivate *private = (GdkWindowPrivate *)window; g_return_val_if_fail (window != NULL, FALSE); + g_return_val_if_fail (GDK_IS_WINDOW (window), FALSE); while (private && (private != &gdk_root_parent) && - (private->window_type != GDK_WINDOW_FOREIGN)) + (private->drawable.window_type != GDK_WINDOW_FOREIGN)) { if (!private->mapped) return FALSE; @@ -2611,16 +2448,6 @@ gdk_window_is_viewable (GdkWindow *window) return TRUE; } -void -gdk_drawable_set_data (GdkDrawable *drawable, - const gchar *key, - gpointer data, - GDestroyNotify destroy_func) -{ - g_dataset_set_data_full (drawable, key, data, destroy_func); -} - - /* Support for windows that can be guffaw-scrolled * (See http://www.gtk.org/~otaylor/whitepapers/guffaw-scrolling.txt) */ @@ -2685,29 +2512,27 @@ gdk_window_gravity_works (void) static void gdk_window_set_static_bit_gravity (GdkWindow *window, gboolean on) { - GdkWindowPrivate *private = (GdkWindowPrivate *)window; XSetWindowAttributes xattributes; g_return_if_fail (window != NULL); xattributes.bit_gravity = on ? StaticGravity : ForgetGravity; - XChangeWindowAttributes (private->xdisplay, - private->xwindow, + XChangeWindowAttributes (GDK_DRAWABLE_XDISPLAY (window), + GDK_DRAWABLE_XID (window), CWBitGravity, &xattributes); } static void gdk_window_set_static_win_gravity (GdkWindow *window, gboolean on) { - GdkWindowPrivate *private = (GdkWindowPrivate *)window; XSetWindowAttributes xattributes; g_return_if_fail (window != NULL); xattributes.win_gravity = on ? StaticGravity : NorthWestGravity; - XChangeWindowAttributes (private->xdisplay, - private->xwindow, + XChangeWindowAttributes (GDK_DRAWABLE_XDISPLAY (window), + GDK_DRAWABLE_XID (window), CWWinGravity, &xattributes); } @@ -2731,7 +2556,8 @@ gdk_window_set_static_gravities (GdkWindow *window, GList *tmp_list; g_return_val_if_fail (window != NULL, FALSE); - + g_return_val_if_fail (GDK_IS_WINDOW (window), FALSE); + if (!use_static == !private->guffaw_gravity) return TRUE; @@ -2740,14 +2566,17 @@ gdk_window_set_static_gravities (GdkWindow *window, private->guffaw_gravity = use_static; - gdk_window_set_static_bit_gravity (window, use_static); - - tmp_list = private->children; - while (tmp_list) + if (!GDK_DRAWABLE_DESTROYED (window)) { - gdk_window_set_static_win_gravity (window, use_static); + gdk_window_set_static_bit_gravity (window, use_static); - tmp_list = tmp_list->next; + tmp_list = private->children; + while (tmp_list) + { + gdk_window_set_static_win_gravity (window, use_static); + + tmp_list = tmp_list->next; + } } return TRUE; diff --git a/gdk/gdkwindow.h b/gdk/gdkwindow.h index 47f7444973..263ad2bb06 100644 --- a/gdk/gdkwindow.h +++ b/gdk/gdkwindow.h @@ -95,7 +95,7 @@ struct _GdkWindowAttr GdkWindowClass wclass; GdkVisual *visual; GdkColormap *colormap; - GdkWindowType window_type; + GdkDrawableType window_type; GdkCursor *cursor; gchar *wmclass_name; gchar *wmclass_class; @@ -157,15 +157,6 @@ void gdk_window_clear_area_e(GdkWindow *window, gint y, gint width, gint height); -void gdk_window_copy_area (GdkWindow *window, - GdkGC *gc, - gint x, - gint y, - GdkWindow *source_window, - gint source_x, - gint source_y, - gint width, - gint height); void gdk_window_raise (GdkWindow *window); void gdk_window_lower (GdkWindow *window); @@ -253,8 +244,6 @@ void gdk_window_set_back_pixmap (GdkWindow *window, gint parent_relative); void gdk_window_set_cursor (GdkWindow *window, GdkCursor *cursor); -void gdk_window_set_colormap (GdkWindow *window, - GdkColormap *colormap); void gdk_window_get_user_data (GdkWindow *window, gpointer *data); void gdk_window_get_geometry (GdkWindow *window, @@ -269,9 +258,6 @@ void gdk_window_get_position (GdkWindow *window, void gdk_window_get_size (GdkWindow *window, gint *width, gint *height); -GdkVisual* gdk_window_get_visual (GdkWindow *window); -GdkColormap* gdk_window_get_colormap (GdkWindow *window); -GdkWindowType gdk_window_get_type (GdkWindow *window); gint gdk_window_get_origin (GdkWindow *window, gint *x, gint *y); @@ -308,11 +294,6 @@ GList * gdk_window_get_toplevels (void); void gdk_window_register_dnd (GdkWindow *window); -void gdk_drawable_set_data (GdkDrawable *drawable, - const gchar *key, - gpointer data, - GDestroyNotify destroy_func); - #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/gdk/gdkx.h b/gdk/gdkx.h index 995c9dca97..4f142bd1ef 100644 --- a/gdk/gdkx.h +++ b/gdk/gdkx.h @@ -33,8 +33,10 @@ #define GDK_ROOT_WINDOW() gdk_root_window #define GDK_ROOT_PARENT() ((GdkWindow *)&gdk_root_parent) #define GDK_DISPLAY() gdk_display -#define GDK_WINDOW_XDISPLAY(win) (((GdkWindowPrivate*) win)->xdisplay) -#define GDK_WINDOW_XWINDOW(win) (((GdkWindowPrivate*) win)->xwindow) +#define GDK_DRAWABLE_XDISPLAY(win) (((GdkDrawablePrivate*) win)->xdisplay) +#define GDK_DRAWABLE_XID(win) (((GdkDrawablePrivate*) win)->xwindow) +#define GDK_WINDOW_XDISPLAY GDK_DRAWABLE_XDISPLAY +#define GDK_WINDOW_XWINDOW GDK_DRAWABLE_XID #define GDK_IMAGE_XDISPLAY(image) (((GdkImagePrivate*) image)->xdisplay) #define GDK_IMAGE_XIMAGE(image) (((GdkImagePrivate*) image)->ximage) #define GDK_GC_XDISPLAY(gc) (((GdkGCPrivate*) gc)->xdisplay) diff --git a/gdk/x11/gdkcursor-x11.c b/gdk/x11/gdkcursor-x11.c index 6431c780ad..04260a2cde 100644 --- a/gdk/x11/gdkcursor-x11.c +++ b/gdk/x11/gdkcursor-x11.c @@ -27,6 +27,7 @@ #include #include +#include "gdkx.h" #include "gdkcursor.h" #include "gdkprivate.h" @@ -57,8 +58,8 @@ gdk_cursor_new_from_pixmap (GdkPixmap *source, GdkPixmap *mask, GdkColor *fg, Gd Cursor xcursor; XColor xfg, xbg; - source_pixmap = ((GdkPixmapPrivate *) source)->xwindow; - mask_pixmap = ((GdkPixmapPrivate *) mask)->xwindow; + source_pixmap = GDK_DRAWABLE_XID (source); + mask_pixmap = GDK_DRAWABLE_XID (mask); xfg.pixel = fg->pixel; xfg.red = fg->red; diff --git a/gdk/x11/gdkdnd-x11.c b/gdk/x11/gdkdnd-x11.c index 3788229245..a58da225b1 100644 --- a/gdk/x11/gdkdnd-x11.c +++ b/gdk/x11/gdkdnd-x11.c @@ -2416,9 +2416,8 @@ xdnd_manage_source_filter (GdkDragContext *context, gboolean add_filter) { gint old_warnings = 0; /* quiet gcc */ - GdkWindowPrivate *private = (GdkWindowPrivate *)window; - gboolean is_foreign = (private->window_type == GDK_WINDOW_FOREIGN); + gboolean is_foreign = GDK_DRAWABLE_TYPE (window); if (is_foreign) { @@ -2426,7 +2425,7 @@ xdnd_manage_source_filter (GdkDragContext *context, gdk_error_warnings = 0; } - if (!private->destroyed) + if (!GDK_DRAWABLE_DESTROYED (window)) { if (add_filter) { diff --git a/gdk/x11/gdkevents-x11.c b/gdk/x11/gdkevents-x11.c index 2adc09cb45..1738a0dbbe 100644 --- a/gdk/x11/gdkevents-x11.c +++ b/gdk/x11/gdkevents-x11.c @@ -286,11 +286,7 @@ graphics_expose_predicate (Display *display, XEvent *xevent, XPointer arg) { - GdkWindowPrivate *private = (GdkWindowPrivate*) arg; - - g_return_val_if_fail (private != NULL, False); - - if (xevent->xany.window == private->xwindow && + if (xevent->xany.window == GDK_DRAWABLE_XID (arg) && (xevent->xany.type == GraphicsExpose || xevent->xany.type == NoExpose)) return True; @@ -1009,6 +1005,8 @@ gdk_event_translate (GdkEvent *event, } window = gdk_window_lookup (xevent->xany.window); + /* FIXME: window might be a GdkPixmap!!! */ + window_private = (GdkWindowPrivate *) window; if (window != NULL) @@ -1017,7 +1015,7 @@ gdk_event_translate (GdkEvent *event, event->any.window = window; event->any.send_event = xevent->xany.send_event ? TRUE : FALSE; - if (window_private && window_private->destroyed) + if (window_private && GDK_DRAWABLE_DESTROYED (window)) { if (xevent->type != DestroyNotify) return FALSE; @@ -1040,7 +1038,7 @@ gdk_event_translate (GdkEvent *event, #ifdef USE_XIM if (window == NULL && gdk_xim_window && xevent->type == KeyPress && - !((GdkWindowPrivate *) gdk_xim_window)->destroyed) + !GDK_DRAWABLE_DESTROYED (gdk_xim_window)) { /* * If user presses a key in Preedit or Status window, keypress event @@ -1340,7 +1338,7 @@ gdk_event_translate (GdkEvent *event, /* Tell XInput stuff about it if appropriate */ if (window_private && - !window_private->destroyed && + !GDK_DRAWABLE_DESTROYED (window) && (window_private->extension_events != 0) && gdk_input_vtable.enter_event) gdk_input_vtable.enter_event (&xevent->xcrossing, window); @@ -1635,9 +1633,9 @@ gdk_event_translate (GdkEvent *event, event->any.type = GDK_DESTROY; event->any.window = window; - return_val = window_private && !window_private->destroyed; + return_val = window_private && !GDK_DRAWABLE_DESTROYED (window); - if (window && window_private->xwindow != GDK_ROOT_WINDOW()) + if (window && GDK_DRAWABLE_XID (window) != GDK_ROOT_WINDOW()) gdk_window_destroy_notify (window); break; @@ -1698,16 +1696,16 @@ gdk_event_translate (GdkEvent *event, xevent->xconfigure.override_redirect, !window ? " (discarding)" - : window_private->window_type == GDK_WINDOW_CHILD + : GDK_DRAWABLE_TYPE (window) == GDK_WINDOW_CHILD ? " (discarding child)" : "")); if (window && - !window_private->destroyed && + !GDK_DRAWABLE_DESTROYED (window) && (window_private->extension_events != 0) && gdk_input_vtable.configure_event) gdk_input_vtable.configure_event (&xevent->xconfigure, window); - if (!window || window_private->window_type == GDK_WINDOW_CHILD) + if (!window || GDK_DRAWABLE_TYPE (window) == GDK_WINDOW_CHILD) return_val = FALSE; else { @@ -1718,15 +1716,15 @@ gdk_event_translate (GdkEvent *event, if (!xevent->xconfigure.x && !xevent->xconfigure.y && - !window_private->destroyed) + !GDK_DRAWABLE_DESTROYED (window)) { gint tx = 0; gint ty = 0; Window child_window = 0; gdk_error_trap_push (); - if (XTranslateCoordinates (window_private->xdisplay, - window_private->xwindow, + if (XTranslateCoordinates (GDK_DRAWABLE_XDISPLAY (window), + GDK_DRAWABLE_XID (window), gdk_root_window, 0, 0, &tx, &ty, @@ -1748,8 +1746,8 @@ gdk_event_translate (GdkEvent *event, } window_private->x = event->configure.x; window_private->y = event->configure.y; - window_private->width = xevent->xconfigure.width; - window_private->height = xevent->xconfigure.height; + window_private->drawable.width = xevent->xconfigure.width; + window_private->drawable.height = xevent->xconfigure.height; if (window_private->resize_count > 1) window_private->resize_count -= 1; } @@ -1891,7 +1889,7 @@ gdk_event_translate (GdkEvent *event, /* something else - (e.g., a Xinput event) */ if (window_private && - !window_private->destroyed && + !window_private->drawable.destroyed && (window_private->extension_events != 0) && gdk_input_vtable.other_event) return_val = gdk_input_vtable.other_event(event, xevent, window); diff --git a/gdk/x11/gdkim-x11.c b/gdk/x11/gdkim-x11.c index 020460f329..a13d1a6124 100644 --- a/gdk/x11/gdkim-x11.c +++ b/gdk/x11/gdkim-x11.c @@ -625,7 +625,7 @@ gdk_ic_new (GdkICAttr *attr, GdkICAttributesType mask) } if (attr->client_window == NULL || - ((GdkWindowPrivate *)attr->client_window)->destroyed) + GDK_DRAWABLE_DESTROYED (attr->client_window)) { g_warning ("Client_window is null or already destroyed.\n"); return NULL; @@ -1084,7 +1084,7 @@ gdk_ic_set_attr (GdkIC *ic, if (mask & GDK_IC_PREEDIT_PIXMAP) { if (attr->preedit_pixmap != NULL && - ((GdkPixmapPrivate *)attr->preedit_pixmap)->destroyed) + GDK_DRAWABLE_DESTROYED (attr->preedit_pixmap)) { g_warning ("Preedit pixmap is already destroyed.\n"); error |= GDK_IC_PREEDIT_PIXMAP; @@ -1171,7 +1171,7 @@ gdk_ic_set_attr (GdkIC *ic, if (mask & GDK_IC_STATUS_PIXMAP) { if (attr->status_pixmap != NULL && - ((GdkPixmapPrivate *)attr->status_pixmap)->destroyed) + GDK_DRAWABLE_DESTROYED (attr->status_pixmap)) { g_warning ("Preedit pixmap is already destroyed.\n"); error |= GDK_IC_STATUS_PIXMAP; diff --git a/gdk/x11/gdkimage-x11.c b/gdk/x11/gdkimage-x11.c index 769727a4b6..4facec7e75 100644 --- a/gdk/x11/gdkimage-x11.c +++ b/gdk/x11/gdkimage-x11.c @@ -56,6 +56,7 @@ #include "gdk.h" /* For gdk_error_trap_* / gdk_flush_* */ #include "gdkimage.h" #include "gdkprivate.h" +#include "gdkx.h" static void gdk_image_put_normal (GdkDrawable *drawable, @@ -331,12 +332,10 @@ gdk_image_get (GdkWindow *window, { GdkImage *image; GdkImagePrivate *private; - GdkWindowPrivate *win_private; g_return_val_if_fail (window != NULL, NULL); - win_private = (GdkWindowPrivate *) window; - if (win_private->destroyed) + if (GDK_DRAWABLE_DESTROYED (window)) return NULL; private = g_new (GdkImagePrivate, 1); @@ -345,7 +344,7 @@ gdk_image_get (GdkWindow *window, private->xdisplay = gdk_display; private->image_put = gdk_image_put_normal; private->ximage = XGetImage (private->xdisplay, - win_private->xwindow, + GDK_DRAWABLE_XID (window), x, y, width, height, AllPlanes, ZPixmap); @@ -455,7 +454,6 @@ gdk_image_put_normal (GdkDrawable *drawable, gint width, gint height) { - GdkWindowPrivate *drawable_private; GdkImagePrivate *image_private; GdkGCPrivate *gc_private; @@ -463,15 +461,14 @@ gdk_image_put_normal (GdkDrawable *drawable, g_return_if_fail (image != NULL); g_return_if_fail (gc != NULL); - drawable_private = (GdkWindowPrivate*) drawable; - if (drawable_private->destroyed) + if (GDK_DRAWABLE_DESTROYED (drawable)) return; image_private = (GdkImagePrivate*) image; gc_private = (GdkGCPrivate*) gc; g_return_if_fail (image->type == GDK_IMAGE_NORMAL); - XPutImage (drawable_private->xdisplay, drawable_private->xwindow, + XPutImage (GDK_DRAWABLE_XDISPLAY (drawable), GDK_DRAWABLE_XID (drawable), gc_private->xgc, image_private->ximage, xsrc, ysrc, xdest, ydest, width, height); } @@ -488,7 +485,6 @@ gdk_image_put_shared (GdkDrawable *drawable, gint height) { #ifdef USE_SHM - GdkWindowPrivate *drawable_private; GdkImagePrivate *image_private; GdkGCPrivate *gc_private; @@ -496,15 +492,14 @@ gdk_image_put_shared (GdkDrawable *drawable, g_return_if_fail (image != NULL); g_return_if_fail (gc != NULL); - drawable_private = (GdkWindowPrivate*) drawable; - if (drawable_private->destroyed) + if (GDK_DRAWABLE_DESTROYED (drawable)) return; image_private = (GdkImagePrivate*) image; gc_private = (GdkGCPrivate*) gc; g_return_if_fail (image->type == GDK_IMAGE_SHARED); - XShmPutImage (drawable_private->xdisplay, drawable_private->xwindow, + XShmPutImage (GDK_DRAWABLE_XDISPLAY (drawable), GDK_DRAWABLE_XID (drawable), gc_private->xgc, image_private->ximage, xsrc, ysrc, xdest, ydest, width, height, False); #else /* USE_SHM */ diff --git a/gdk/x11/gdkinput-x11.c b/gdk/x11/gdkinput-x11.c index edfc4ebd83..d9bb835b89 100644 --- a/gdk/x11/gdkinput-x11.c +++ b/gdk/x11/gdkinput-x11.c @@ -472,14 +472,14 @@ gdk_input_translate_coordinates (GdkDevicePrivate *gdkdev, gdouble *x, gdouble *y, gdouble *pressure, gdouble *xtilt, gdouble *ytilt) { - GdkWindowPrivate *win_priv; + GdkDrawablePrivate *drawable_priv; int x_axis, y_axis, pressure_axis, xtilt_axis, ytilt_axis; double device_width, device_height; double x_offset, y_offset, x_scale, y_scale; - win_priv = (GdkWindowPrivate *) input_window->window; + drawable_priv = (GdkDrawablePrivate *) input_window->window; x_axis = gdkdev->axis_for_use[GDK_AXIS_X]; y_axis = gdkdev->axis_for_use[GDK_AXIS_Y]; @@ -505,26 +505,26 @@ gdk_input_translate_coordinates (GdkDevicePrivate *gdkdev, double device_aspect = (device_height*gdkdev->axes[y_axis].resolution) / (device_width*gdkdev->axes[x_axis].resolution); - if (device_aspect * win_priv->width >= win_priv->height) + if (device_aspect * drawable_priv->width >= drawable_priv->height) { /* device taller than window */ - x_scale = win_priv->width / device_width; + x_scale = drawable_priv->width / device_width; y_scale = (x_scale * gdkdev->axes[x_axis].resolution) / gdkdev->axes[y_axis].resolution; x_offset = 0; y_offset = -(device_height * y_scale - - win_priv->height)/2; + drawable_priv->height)/2; } else { /* window taller than device */ - y_scale = win_priv->height / device_height; + y_scale = drawable_priv->height / device_height; x_scale = (y_scale * gdkdev->axes[y_axis].resolution) / gdkdev->axes[x_axis].resolution; y_offset = 0; - x_offset = - (device_width * x_scale - win_priv->width)/2; + x_offset = - (device_width * x_scale - drawable_priv->width)/2; } } diff --git a/gdk/x11/gdkinput.c b/gdk/x11/gdkinput.c index 874a6cafe0..334c3d46d8 100644 --- a/gdk/x11/gdkinput.c +++ b/gdk/x11/gdkinput.c @@ -127,20 +127,20 @@ gdk_input_motion_events (GdkWindow *window, guint32 stop, gint *nevents_return) { - GdkWindowPrivate *window_private; XTimeCoord *xcoords; GdkTimeCoord *coords; int i; g_return_val_if_fail (window != NULL, NULL); - window_private = (GdkWindowPrivate *) window; - if (window_private->destroyed) + g_return_val_if_fail (GDK_IS_WINDOW (window), NULL); + + if (GDK_DRAWABLE_DESTROYED (window)) return NULL; if (deviceid == GDK_CORE_POINTER) { - xcoords = XGetMotionEvents (gdk_display, - window_private->xwindow, + xcoords = XGetMotionEvents (GDK_DRAWABLE_XDISPLAY (window), + GDK_DRAWABLE_XID (window), start, stop, nevents_return); if (xcoords) { @@ -224,8 +224,10 @@ gdk_input_set_extension_events (GdkWindow *window, gint mask, GdkInputWindow *iw; g_return_if_fail (window != NULL); + g_return_if_fail (GDK_IS_WINDOW (window)); + window_private = (GdkWindowPrivate*) window; - if (window_private->destroyed) + if (GDK_DRAWABLE_DESTROYED (window)) return; if (mode == GDK_EXTENSION_EVENTS_NONE) diff --git a/gdk/x11/gdkmain-x11.c b/gdk/x11/gdkmain-x11.c index 96e342f62c..87b15b6a91 100644 --- a/gdk/x11/gdkmain-x11.c +++ b/gdk/x11/gdkmain-x11.c @@ -47,6 +47,7 @@ #include "gdk.h" +#include "gdkx.h" #include "gdkprivate.h" #include "gdkinputprivate.h" @@ -493,10 +494,7 @@ gdk_pointer_grab (GdkWindow * window, GdkCursor * cursor, guint32 time) { - /* From gdkwindow.c */ gint return_val; - GdkWindowPrivate *window_private; - GdkWindowPrivate *confine_to_private; GdkCursorPrivate *cursor_private; guint xevent_mask; Window xwindow; @@ -505,17 +503,17 @@ gdk_pointer_grab (GdkWindow * window, int i; g_return_val_if_fail (window != NULL, 0); + g_return_val_if_fail (GDK_IS_WINDOW (window), 0); + g_return_val_if_fail (confine_to == NULL || GDK_IS_WINDOW (confine_to), 0); - window_private = (GdkWindowPrivate*) window; - confine_to_private = (GdkWindowPrivate*) confine_to; cursor_private = (GdkCursorPrivate*) cursor; - xwindow = window_private->xwindow; + xwindow = GDK_DRAWABLE_XID (window); - if (!confine_to || confine_to_private->destroyed) + if (!confine_to || GDK_DRAWABLE_DESTROYED (confine_to)) xconfine_to = None; else - xconfine_to = confine_to_private->xwindow; + xconfine_to = GDK_DRAWABLE_XID (confine_to); if (!cursor) xcursor = None; @@ -541,8 +539,8 @@ gdk_pointer_grab (GdkWindow * window, if (return_val == Success) { - if (!window_private->destroyed) - return_val = XGrabPointer (window_private->xdisplay, + if (!GDK_DRAWABLE_DESTROYED (window)) + return_val = XGrabPointer (GDK_DRAWABLE_XDISPLAY (window), xwindow, owner_events, xevent_mask, @@ -555,7 +553,7 @@ gdk_pointer_grab (GdkWindow * window, } if (return_val == GrabSuccess) - gdk_xgrab_window = window_private; + gdk_xgrab_window = (GdkWindowPrivate *)window; return return_val; } @@ -631,17 +629,12 @@ gdk_keyboard_grab (GdkWindow * window, gint owner_events, guint32 time) { - GdkWindowPrivate *window_private; - Window xwindow; - g_return_val_if_fail (window != NULL, 0); + g_return_val_if_fail (GDK_IS_WINDOW (window), 0); - window_private = (GdkWindowPrivate*) window; - xwindow = window_private->xwindow; - - if (!window_private->destroyed) - return XGrabKeyboard (window_private->xdisplay, - xwindow, + if (!GDK_DRAWABLE_DESTROYED (window)) + return XGrabKeyboard (GDK_DRAWABLE_XDISPLAY (window), + GDK_DRAWABLE_XID (window), owner_events, GrabModeAsync, GrabModeAsync, time); diff --git a/gdk/x11/gdkpixmap-x11.c b/gdk/x11/gdkpixmap-x11.c index 5656b18a93..8ee69db9cd 100644 --- a/gdk/x11/gdkpixmap-x11.c +++ b/gdk/x11/gdkpixmap-x11.c @@ -34,6 +34,7 @@ #include "gdkpixmap.h" #include "gdkprivate.h" +#include "gdkx.h" typedef struct { @@ -56,36 +57,32 @@ gdk_pixmap_new (GdkWindow *window, gint depth) { GdkPixmap *pixmap; - GdkWindowPrivate *private; - GdkWindowPrivate *window_private; + GdkDrawablePrivate *private; + g_return_val_if_fail (window == NULL || GDK_IS_WINDOW (window), NULL); g_return_val_if_fail ((window != NULL) || (depth != -1), NULL); g_return_val_if_fail ((width != 0) && (height != 0), NULL); if (!window) window = (GdkWindow*) &gdk_root_parent; - window_private = (GdkWindowPrivate*) window; - if (window_private->destroyed) + if (GDK_DRAWABLE_DESTROYED (window)) return NULL; if (depth == -1) - depth = gdk_window_get_visual (window)->depth; + depth = gdk_drawable_get_visual (window)->depth; - private = g_new0 (GdkWindowPrivate, 1); + private = g_new0 (GdkDrawablePrivate, 1); pixmap = (GdkPixmap*) private; - private->xdisplay = window_private->xdisplay; - private->window_type = GDK_WINDOW_PIXMAP; - private->xwindow = XCreatePixmap (private->xdisplay, window_private->xwindow, + private->xdisplay = GDK_DRAWABLE_XDISPLAY (window); + private->window_type = GDK_DRAWABLE_PIXMAP; + private->xwindow = XCreatePixmap (private->xdisplay, + GDK_DRAWABLE_XID (window), width, height, depth); private->colormap = NULL; - private->parent = NULL; - private->x = 0; - private->y = 0; private->width = width; private->height = height; - private->resize_count = 0; private->ref_count = 1; private->destroyed = 0; @@ -101,35 +98,30 @@ gdk_bitmap_create_from_data (GdkWindow *window, gint height) { GdkPixmap *pixmap; - GdkWindowPrivate *private; - GdkWindowPrivate *window_private; + GdkDrawablePrivate *private; 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_WINDOW (window), NULL); if (!window) window = (GdkWindow*) &gdk_root_parent; - window_private = (GdkWindowPrivate*) window; - if (window_private->destroyed) + if (GDK_DRAWABLE_DESTROYED (window)) return NULL; - private = g_new0 (GdkWindowPrivate, 1); + private = g_new0 (GdkDrawablePrivate, 1); pixmap = (GdkPixmap*) private; - private->parent = NULL; - private->xdisplay = window_private->xdisplay; - private->window_type = GDK_WINDOW_PIXMAP; - private->x = 0; - private->y = 0; + private->xdisplay = GDK_DRAWABLE_XDISPLAY (window); + private->window_type = GDK_DRAWABLE_PIXMAP; private->width = width; private->height = height; - private->resize_count = 0; private->ref_count = 1; private->destroyed = FALSE; private->xwindow = XCreateBitmapFromData (private->xdisplay, - window_private->xwindow, + GDK_DRAWABLE_XID (window), (char *)data, width, height); gdk_xid_table_insert (&private->xwindow, pixmap); @@ -147,9 +139,9 @@ gdk_pixmap_create_from_data (GdkWindow *window, GdkColor *bg) { GdkPixmap *pixmap; - GdkWindowPrivate *private; - GdkWindowPrivate *window_private; + GdkDrawablePrivate *private; + g_return_val_if_fail (window == NULL || GDK_IS_WINDOW (window), 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); @@ -159,29 +151,24 @@ gdk_pixmap_create_from_data (GdkWindow *window, if (!window) window = (GdkWindow*) &gdk_root_parent; - window_private = (GdkWindowPrivate*) window; - if (window_private->destroyed) + if (GDK_DRAWABLE_DESTROYED (window)) return NULL; if (depth == -1) - depth = gdk_window_get_visual (window)->depth; + depth = gdk_drawable_get_visual (window)->depth; - private = g_new0 (GdkWindowPrivate, 1); + private = g_new0 (GdkDrawablePrivate, 1); pixmap = (GdkPixmap*) private; - private->parent = NULL; - private->xdisplay = window_private->xdisplay; - private->window_type = GDK_WINDOW_PIXMAP; - private->x = 0; - private->y = 0; + private->xdisplay = GDK_DRAWABLE_XDISPLAY (window); + private->window_type = GDK_DRAWABLE_PIXMAP; private->width = width; private->height = height; - private->resize_count = 0; private->ref_count = 1; private->destroyed = FALSE; private->xwindow = XCreatePixmapFromBitmapData (private->xdisplay, - window_private->xwindow, + GDK_DRAWABLE_XID (window), (char *)data, width, height, fg->pixel, bg->pixel, depth); @@ -460,8 +447,8 @@ _gdk_pixmap_create_from_xpm (GdkWindow *window, if (colormap == NULL) { - colormap = gdk_window_get_colormap (window); - visual = gdk_window_get_visual (window); + colormap = gdk_drawable_get_colormap (window); + visual = gdk_drawable_get_visual (window); } else visual = ((GdkColormapPrivate *)colormap)->visual; @@ -760,8 +747,7 @@ GdkPixmap* gdk_pixmap_foreign_new (guint32 anid) { GdkPixmap *pixmap; - GdkWindowPrivate *window_private; - GdkWindowPrivate *private; + GdkDrawablePrivate *private; Pixmap xpixmap; Window root_return; unsigned int x_ret, y_ret, w_ret, h_ret, bw_ret, depth_ret; @@ -772,29 +758,24 @@ gdk_pixmap_foreign_new (guint32 anid) /* set the pixmap to the passed in value */ xpixmap = anid; - /* get the root window */ - window_private = &gdk_root_parent; /* get information about the Pixmap to fill in the structure for the gdk window */ - if (!XGetGeometry(window_private->xdisplay, xpixmap, &root_return, + if (!XGetGeometry(GDK_DISPLAY(), + xpixmap, &root_return, &x_ret, &y_ret, &w_ret, &h_ret, &bw_ret, &depth_ret)) return NULL; /* allocate a new gdk pixmap */ - private = g_new(GdkWindowPrivate, 1); + private = g_new(GdkDrawablePrivate, 1); pixmap = (GdkPixmap *)private; - private->xdisplay = window_private->xdisplay; - private->window_type = GDK_WINDOW_PIXMAP; + private->xdisplay = GDK_DISPLAY(); + private->window_type = GDK_DRAWABLE_PIXMAP; private->xwindow = xpixmap; private->colormap = NULL; - private->parent = NULL; - private->x = 0; - private->y = 0; private->width = w_ret; private->height = h_ret; - private->resize_count = 0; private->ref_count = 1; private->destroyed = 0; @@ -806,8 +787,9 @@ gdk_pixmap_foreign_new (guint32 anid) GdkPixmap* gdk_pixmap_ref (GdkPixmap *pixmap) { - GdkWindowPrivate *private = (GdkWindowPrivate *)pixmap; + GdkDrawablePrivate *private = (GdkDrawablePrivate *)pixmap; g_return_val_if_fail (pixmap != NULL, NULL); + g_return_val_if_fail (GDK_IS_PIXMAP (private), NULL); private->ref_count += 1; return pixmap; @@ -816,8 +798,9 @@ gdk_pixmap_ref (GdkPixmap *pixmap) void gdk_pixmap_unref (GdkPixmap *pixmap) { - GdkWindowPrivate *private = (GdkWindowPrivate *)pixmap; + GdkDrawablePrivate *private = (GdkDrawablePrivate *)pixmap; g_return_if_fail (pixmap != NULL); + g_return_if_fail (GDK_IS_PIXMAP (private)); g_return_if_fail (private->ref_count > 0); private->ref_count -= 1; diff --git a/gdk/x11/gdkproperty-x11.c b/gdk/x11/gdkproperty-x11.c index 5a17abd769..b91b787d1b 100644 --- a/gdk/x11/gdkproperty-x11.c +++ b/gdk/x11/gdkproperty-x11.c @@ -28,6 +28,7 @@ #include #include +#include "gdkx.h" #include "gdkproperty.h" #include "gdkprivate.h" @@ -111,14 +112,11 @@ gdk_property_get (GdkWindow *window, if (window) { - GdkWindowPrivate *private; - - private = (GdkWindowPrivate*) window; - if (private->destroyed) + if (GDK_DRAWABLE_DESTROYED (window)) return FALSE; - xdisplay = private->xdisplay; - xwindow = private->xwindow; + xdisplay = GDK_WINDOW_XDISPLAY (window); + xwindow = GDK_WINDOW_XWINDOW (window); } else { @@ -200,14 +198,11 @@ gdk_property_change (GdkWindow *window, if (window) { - GdkWindowPrivate *private; - - private = (GdkWindowPrivate*) window; - if (private->destroyed) + if (GDK_DRAWABLE_DESTROYED (window)) return; - xdisplay = private->xdisplay; - xwindow = private->xwindow; + xdisplay = GDK_WINDOW_XDISPLAY (window); + xwindow = GDK_WINDOW_XWINDOW (window); } else { @@ -228,14 +223,11 @@ gdk_property_delete (GdkWindow *window, if (window) { - GdkWindowPrivate *private; - - private = (GdkWindowPrivate*) window; - if (private->destroyed) + if (GDK_DRAWABLE_DESTROYED (window)) return; - xdisplay = private->xdisplay; - xwindow = private->xwindow; + xdisplay = GDK_WINDOW_XDISPLAY (window); + xwindow = GDK_WINDOW_XWINDOW (window); } else { diff --git a/gdk/x11/gdkselection-x11.c b/gdk/x11/gdkselection-x11.c index ebffc3579c..e1272f4213 100644 --- a/gdk/x11/gdkselection-x11.c +++ b/gdk/x11/gdkselection-x11.c @@ -45,14 +45,11 @@ gdk_selection_owner_set (GdkWindow *owner, if (owner) { - GdkWindowPrivate *private; - - private = (GdkWindowPrivate*) owner; - if (private->destroyed) + if (GDK_DRAWABLE_DESTROYED (owner)) return FALSE; - xdisplay = private->xdisplay; - xwindow = private->xwindow; + xdisplay = GDK_DRAWABLE_XDISPLAY (owner); + xwindow = GDK_DRAWABLE_XID (owner); } else { @@ -83,16 +80,11 @@ gdk_selection_convert (GdkWindow *requestor, GdkAtom target, guint32 time) { - GdkWindowPrivate *private; - - g_return_if_fail (requestor != NULL); - - private = (GdkWindowPrivate*) requestor; - if (private->destroyed) + if (GDK_DRAWABLE_DESTROYED (requestor)) return; - XConvertSelection (private->xdisplay, selection, target, - gdk_selection_property, private->xwindow, time); + XConvertSelection (GDK_DRAWABLE_XDISPLAY (requestor), selection, target, + gdk_selection_property, GDK_DRAWABLE_XID (requestor), time); } gint @@ -101,7 +93,6 @@ gdk_selection_property_get (GdkWindow *requestor, GdkAtom *ret_type, gint *ret_format) { - GdkWindowPrivate *private; gulong nitems; gulong nbytes; gulong length; @@ -110,17 +101,18 @@ gdk_selection_property_get (GdkWindow *requestor, guchar *t = NULL; g_return_val_if_fail (requestor != NULL, 0); + g_return_val_if_fail (GDK_IS_WINDOW (requestor), 0); /* If retrieved chunks are typically small, (and the ICCCM says the should be) it would be a win to try first with a buffer of moderate length, to avoid two round trips to the server */ - private = (GdkWindowPrivate*) requestor; - if (private->destroyed) + if (GDK_DRAWABLE_DESTROYED (requestor)) return 0; t = NULL; - XGetWindowProperty (private->xdisplay, private->xwindow, + XGetWindowProperty (GDK_DRAWABLE_XDISPLAY (requestor), + GDK_DRAWABLE_XID (requestor), gdk_selection_property, 0, 0, False, AnyPropertyType, &prop_type, &prop_format, &nitems, &nbytes, &t); @@ -150,7 +142,8 @@ gdk_selection_property_get (GdkWindow *requestor, protocol, in which case the client has to make sure they'll be notified of PropertyChange events _before_ the property is deleted. Otherwise there's no guarantee we'll win the race ... */ - XGetWindowProperty (private->xdisplay, private->xwindow, + XGetWindowProperty (GDK_DRAWABLE_XDISPLAY (requestor), + GDK_DRAWABLE_XID (requestor), gdk_selection_property, 0, (nbytes + 3) / 4, False, AnyPropertyType, &prop_type, &prop_format, &nitems, &nbytes, &t); diff --git a/gdk/x11/gdkwindow-x11.c b/gdk/x11/gdkwindow-x11.c index ddd5267eac..16bdb37d7c 100644 --- a/gdk/x11/gdkwindow-x11.c +++ b/gdk/x11/gdkwindow-x11.c @@ -34,6 +34,7 @@ #include "gdkwindow.h" #include "gdkinputprivate.h" #include "gdkprivate.h" +#include "gdkx.h" #include "MwmUtil.h" #include @@ -87,7 +88,7 @@ gdk_window_xid_at (Window base, gboolean excl_child) { GdkWindow *window; - GdkWindowPrivate *private; + GdkDrawablePrivate *private; Display *disp; Window *list = NULL; Window child = 0, parent_win = 0, root_win = 0; @@ -96,7 +97,7 @@ gdk_window_xid_at (Window base, int wx, wy; window = (GdkWindow*) &gdk_root_parent; - private = (GdkWindowPrivate*) window; + private = (GdkDrawablePrivate*) window; disp = private->xdisplay; if (!XGetGeometry (disp, base, &root_win, &wx, &wy, &ww, &wh, &wb, &wd)) return 0; @@ -152,15 +153,15 @@ gdk_window_xid_at_coords (gint x, gboolean excl_child) { GdkWindow *window; - GdkWindowPrivate *private; + GdkDrawablePrivate *private; Display *disp; Window *list = NULL; Window root, child = 0, parent_win = 0, root_win = 0; unsigned int num; int i; - + window = (GdkWindow*) &gdk_root_parent; - private = (GdkWindowPrivate*) window; + private = (GdkDrawablePrivate*) window; disp = private->xdisplay; root = private->xwindow; num = g_list_length (excludes); @@ -225,15 +226,15 @@ gdk_window_init (void) &x, &y, &width, &height, &border_width, &depth); XGetWindowAttributes (gdk_display, gdk_root_window, &xattributes); - gdk_root_parent.xwindow = gdk_root_window; - gdk_root_parent.xdisplay = gdk_display; - gdk_root_parent.window_type = GDK_WINDOW_ROOT; - gdk_root_parent.window.user_data = NULL; - gdk_root_parent.width = width; - gdk_root_parent.height = height; + gdk_root_parent.drawable.xwindow = gdk_root_window; + gdk_root_parent.drawable.xdisplay = gdk_display; + gdk_root_parent.drawable.window_type = GDK_WINDOW_ROOT; + gdk_root_parent.drawable.drawable.user_data = NULL; + gdk_root_parent.drawable.width = width; + gdk_root_parent.drawable.height = height; gdk_root_parent.children = NULL; - gdk_root_parent.colormap = NULL; - gdk_root_parent.ref_count = 1; + gdk_root_parent.drawable.colormap = NULL; + gdk_root_parent.drawable.ref_count = 1; gdk_xid_table_insert (&gdk_root_window, &gdk_root_parent); } @@ -268,23 +269,23 @@ gdk_window_new (GdkWindow *parent, parent = (GdkWindow*) &gdk_root_parent; parent_private = (GdkWindowPrivate*) parent; - if (parent_private->destroyed) + if (GDK_DRAWABLE_DESTROYED (parent)) return NULL; - xparent = parent_private->xwindow; - parent_display = parent_private->xdisplay; + xparent = parent_private->drawable.xwindow; + parent_display = parent_private->drawable.xdisplay; private = g_new (GdkWindowPrivate, 1); window = (GdkWindow*) private; private->parent = parent; - private->xdisplay = parent_display; - private->destroyed = FALSE; + private->drawable.xdisplay = parent_display; + private->drawable.destroyed = FALSE; private->mapped = FALSE; private->guffaw_gravity = FALSE; private->resize_count = 0; - private->ref_count = 1; + private->drawable.ref_count = 1; xattributes_mask = 0; if (attributes_mask & GDK_WA_X) @@ -299,9 +300,9 @@ gdk_window_new (GdkWindow *parent, private->x = x; private->y = y; - private->width = (attributes->width > 1) ? (attributes->width) : (1); - private->height = (attributes->height > 1) ? (attributes->height) : (1); - private->window_type = attributes->window_type; + private->drawable.width = (attributes->width > 1) ? (attributes->width) : (1); + private->drawable.height = (attributes->height > 1) ? (attributes->height) : (1); + private->drawable.window_type = attributes->window_type; private->extension_events = FALSE; private->filters = NULL; @@ -346,42 +347,42 @@ gdk_window_new (GdkWindow *parent, depth = visual->depth; if (attributes_mask & GDK_WA_COLORMAP) - private->colormap = attributes->colormap; + private->drawable.colormap = attributes->colormap; else { if ((((GdkVisualPrivate*)gdk_visual_get_system ())->xvisual) == xvisual) - private->colormap = gdk_colormap_get_system (); + private->drawable.colormap = gdk_colormap_get_system (); else - private->colormap = gdk_colormap_new (visual, False); + private->drawable.colormap = gdk_colormap_new (visual, False); } xattributes.background_pixel = BlackPixel (gdk_display, gdk_screen); xattributes.border_pixel = BlackPixel (gdk_display, gdk_screen); xattributes_mask |= CWBorderPixel | CWBackPixel; - switch (private->window_type) + switch (private->drawable.window_type) { case GDK_WINDOW_TOPLEVEL: - xattributes.colormap = ((GdkColormapPrivate*) private->colormap)->xcolormap; + xattributes.colormap = ((GdkColormapPrivate*) private->drawable.colormap)->xcolormap; xattributes_mask |= CWColormap; xparent = gdk_root_window; break; case GDK_WINDOW_CHILD: - xattributes.colormap = ((GdkColormapPrivate*) private->colormap)->xcolormap; + xattributes.colormap = ((GdkColormapPrivate*) private->drawable.colormap)->xcolormap; xattributes_mask |= CWColormap; break; case GDK_WINDOW_DIALOG: - xattributes.colormap = ((GdkColormapPrivate*) private->colormap)->xcolormap; + xattributes.colormap = ((GdkColormapPrivate*) private->drawable.colormap)->xcolormap; xattributes_mask |= CWColormap; xparent = gdk_root_window; break; case GDK_WINDOW_TEMP: - xattributes.colormap = ((GdkColormapPrivate*) private->colormap)->xcolormap; + xattributes.colormap = ((GdkColormapPrivate*) private->drawable.colormap)->xcolormap; xattributes_mask |= CWColormap; xparent = gdk_root_window; @@ -403,18 +404,18 @@ gdk_window_new (GdkWindow *parent, { depth = 0; class = InputOnly; - private->colormap = NULL; + private->drawable.colormap = NULL; } - private->xwindow = XCreateWindow (private->xdisplay, xparent, - x, y, private->width, private->height, + private->drawable.xwindow = XCreateWindow (private->drawable.xdisplay, xparent, + x, y, private->drawable.width, private->drawable.height, 0, depth, class, xvisual, xattributes_mask, &xattributes); gdk_window_ref (window); - gdk_xid_table_insert (&private->xwindow, window); + gdk_xid_table_insert (&private->drawable.xwindow, window); - if (private->colormap) - gdk_colormap_ref (private->colormap); + if (private->drawable.colormap) + gdk_colormap_ref (private->drawable.colormap); gdk_window_set_cursor (window, ((attributes_mask & GDK_WA_CURSOR) ? (attributes->cursor) : @@ -423,18 +424,18 @@ gdk_window_new (GdkWindow *parent, if (parent_private) parent_private->children = g_list_prepend (parent_private->children, window); - switch (private->window_type) + switch (private->drawable.window_type) { case GDK_WINDOW_DIALOG: - XSetTransientForHint (private->xdisplay, private->xwindow, xparent); + XSetTransientForHint (private->drawable.xdisplay, private->drawable.xwindow, xparent); case GDK_WINDOW_TOPLEVEL: case GDK_WINDOW_TEMP: - XSetWMProtocols (private->xdisplay, private->xwindow, gdk_wm_window_protocols, 2); + XSetWMProtocols (private->drawable.xdisplay, private->drawable.xwindow, gdk_wm_window_protocols, 2); break; case GDK_WINDOW_CHILD: if ((attributes->wclass == GDK_INPUT_OUTPUT) && - (private->colormap != gdk_colormap_get_system ()) && - (private->colormap != gdk_window_get_colormap (gdk_window_get_toplevel (window)))) + (private->drawable.colormap != gdk_colormap_get_system ()) && + (private->drawable.colormap != gdk_window_get_colormap (gdk_window_get_toplevel (window)))) { GDK_NOTE (MISC, g_message ("adding colormap window\n")); gdk_window_add_colormap_windows (window); @@ -447,8 +448,8 @@ gdk_window_new (GdkWindow *parent, } size_hints.flags = PSize; - size_hints.width = private->width; - size_hints.height = private->height; + size_hints.width = private->drawable.width; + size_hints.height = private->drawable.height; wm_hints.flags = InputHint | StateHint | WindowGroupHint; wm_hints.window_group = gdk_leader_window; @@ -459,14 +460,14 @@ gdk_window_new (GdkWindow *parent, * attention to PSize, and even if they do, is this the * correct value??? */ - XSetWMNormalHints (private->xdisplay, private->xwindow, &size_hints); + XSetWMNormalHints (private->drawable.xdisplay, private->drawable.xwindow, &size_hints); - XSetWMHints (private->xdisplay, private->xwindow, &wm_hints); + XSetWMHints (private->drawable.xdisplay, private->drawable.xwindow, &wm_hints); if (!wm_client_leader_atom) wm_client_leader_atom = gdk_atom_intern ("WM_CLIENT_LEADER", FALSE); - XChangeProperty (private->xdisplay, private->xwindow, + XChangeProperty (private->drawable.xdisplay, private->drawable.xwindow, wm_client_leader_atom, XA_WINDOW, 32, PropModeReplace, (guchar*) &gdk_leader_window, 1); @@ -476,7 +477,7 @@ gdk_window_new (GdkWindow *parent, else title = g_get_prgname (); - XmbSetWMProperties (private->xdisplay, private->xwindow, + XmbSetWMProperties (private->drawable.xdisplay, private->drawable.xwindow, title, title, NULL, 0, NULL, NULL, NULL); @@ -486,7 +487,7 @@ gdk_window_new (GdkWindow *parent, class_hint = XAllocClassHint (); class_hint->res_name = attributes->wmclass_name; class_hint->res_class = attributes->wmclass_class; - XSetClassHint (private->xdisplay, private->xwindow, class_hint); + XSetClassHint (private->drawable.xdisplay, private->drawable.xwindow, class_hint); XFree (class_hint); } @@ -530,21 +531,21 @@ gdk_window_foreign_new (guint32 anid) if (parent_private) parent_private->children = g_list_prepend (parent_private->children, window); - private->xwindow = anid; - private->xdisplay = gdk_display; + private->drawable.xwindow = anid; + private->drawable.xdisplay = gdk_display; private->x = attrs.x; private->y = attrs.y; - private->width = attrs.width; - private->height = attrs.height; + private->drawable.width = attrs.width; + private->drawable.height = attrs.height; private->resize_count = 0; - private->ref_count = 1; - private->window_type = GDK_WINDOW_FOREIGN; - private->destroyed = FALSE; + private->drawable.ref_count = 1; + private->drawable.window_type = GDK_WINDOW_FOREIGN; + private->drawable.destroyed = FALSE; private->mapped = (attrs.map_state != IsUnmapped); private->guffaw_gravity = FALSE; private->extension_events = 0; - private->colormap = NULL; + private->drawable.colormap = NULL; private->filters = NULL; private->children = NULL; @@ -552,7 +553,7 @@ gdk_window_foreign_new (guint32 anid) window->user_data = NULL; gdk_window_ref (window); - gdk_xid_table_insert (&private->xwindow, window); + gdk_xid_table_insert (&private->drawable.xwindow, window); return window; } @@ -578,14 +579,14 @@ gdk_window_internal_destroy (GdkWindow *window, private = (GdkWindowPrivate*) window; - switch (private->window_type) + switch (private->drawable.window_type) { case GDK_WINDOW_TOPLEVEL: case GDK_WINDOW_CHILD: case GDK_WINDOW_DIALOG: case GDK_WINDOW_TEMP: case GDK_WINDOW_FOREIGN: - if (!private->destroyed) + if (!private->drawable.destroyed) { if (private->parent) { @@ -594,7 +595,7 @@ gdk_window_internal_destroy (GdkWindow *window, parent_private->children = g_list_remove (parent_private->children, window); } - if (private->window_type != GDK_WINDOW_FOREIGN) + if (GDK_DRAWABLE_TYPE (window) != GDK_WINDOW_FOREIGN) { children = tmp = private->children; private->children = NULL; @@ -630,7 +631,7 @@ gdk_window_internal_destroy (GdkWindow *window, private->filters = NULL; } - if (private->window_type == GDK_WINDOW_FOREIGN) + if (private->drawable.window_type == GDK_WINDOW_FOREIGN) { if (our_destroy && (private->parent != NULL)) { @@ -645,26 +646,26 @@ gdk_window_internal_destroy (GdkWindow *window, gdk_window_reparent (window, NULL, 0, 0); xevent.type = ClientMessage; - xevent.window = private->xwindow; + xevent.window = private->drawable.xwindow; xevent.message_type = gdk_wm_protocols; xevent.format = 32; xevent.data.l[0] = gdk_wm_delete_window; xevent.data.l[1] = CurrentTime; - XSendEvent (private->xdisplay, private->xwindow, + XSendEvent (private->drawable.xdisplay, private->drawable.xwindow, False, 0, (XEvent *)&xevent); gdk_flush (); gdk_error_trap_pop (); } } else if (xdestroy) - XDestroyWindow (private->xdisplay, private->xwindow); + XDestroyWindow (private->drawable.xdisplay, private->drawable.xwindow); - if (private->colormap) - gdk_colormap_unref (private->colormap); + if (private->drawable.colormap) + gdk_colormap_unref (private->drawable.colormap); private->mapped = FALSE; - private->destroyed = TRUE; + private->drawable.destroyed = TRUE; } break; @@ -693,21 +694,17 @@ gdk_window_destroy (GdkWindow *window) void gdk_window_destroy_notify (GdkWindow *window) { - GdkWindowPrivate *private; - g_return_if_fail (window != NULL); - private = (GdkWindowPrivate*) window; - - if (!private->destroyed) + if (!GDK_DRAWABLE_DESTROYED (window)) { - if (private->window_type != GDK_WINDOW_FOREIGN) - g_warning ("GdkWindow %#lx unexpectedly destroyed", private->xwindow); + if (GDK_DRAWABLE_TYPE(window) != GDK_WINDOW_FOREIGN) + g_warning ("GdkWindow %#lx unexpectedly destroyed", GDK_DRAWABLE_XID (window)); gdk_window_internal_destroy (window, FALSE, FALSE); } - gdk_xid_table_remove (private->xwindow); + gdk_xid_table_remove (GDK_DRAWABLE_XID (window)); gdk_window_unref (window); } @@ -717,7 +714,7 @@ gdk_window_ref (GdkWindow *window) GdkWindowPrivate *private = (GdkWindowPrivate *)window; g_return_val_if_fail (window != NULL, NULL); - private->ref_count += 1; + private->drawable.ref_count += 1; return window; } @@ -726,15 +723,14 @@ gdk_window_unref (GdkWindow *window) { GdkWindowPrivate *private = (GdkWindowPrivate *)window; g_return_if_fail (window != NULL); - g_return_if_fail (private->ref_count > 0); - private->ref_count -= 1; - if (private->ref_count == 0) + private->drawable.ref_count -= 1; + if (private->drawable.ref_count == 0) { - if (!private->destroyed) + if (!private->drawable.destroyed) { - if (private->window_type == GDK_WINDOW_FOREIGN) - gdk_xid_table_remove (private->xwindow); + if (private->drawable.window_type == GDK_WINDOW_FOREIGN) + gdk_xid_table_remove (private->drawable.xwindow); else g_warning ("losing last reference to undestroyed window\n"); } @@ -751,11 +747,11 @@ gdk_window_show (GdkWindow *window) g_return_if_fail (window != NULL); private = (GdkWindowPrivate*) window; - if (!private->destroyed) + if (!private->drawable.destroyed) { private->mapped = TRUE; - XRaiseWindow (private->xdisplay, private->xwindow); - XMapWindow (private->xdisplay, private->xwindow); + XRaiseWindow (private->drawable.xdisplay, private->drawable.xwindow); + XMapWindow (private->drawable.xdisplay, private->drawable.xwindow); } } @@ -767,10 +763,10 @@ gdk_window_hide (GdkWindow *window) g_return_if_fail (window != NULL); private = (GdkWindowPrivate*) window; - if (!private->destroyed) + if (!private->drawable.destroyed) { private->mapped = FALSE; - XUnmapWindow (private->xdisplay, private->xwindow); + XUnmapWindow (private->drawable.xdisplay, private->drawable.xwindow); } } @@ -782,8 +778,8 @@ gdk_window_withdraw (GdkWindow *window) g_return_if_fail (window != NULL); private = (GdkWindowPrivate*) window; - if (!private->destroyed) - XWithdrawWindow (private->xdisplay, private->xwindow, 0); + if (!private->drawable.destroyed) + XWithdrawWindow (private->drawable.xdisplay, private->drawable.xwindow, 0); } void @@ -796,11 +792,11 @@ gdk_window_move (GdkWindow *window, g_return_if_fail (window != NULL); private = (GdkWindowPrivate*) window; - if (!private->destroyed) + if (!private->drawable.destroyed) { - XMoveWindow (private->xdisplay, private->xwindow, x, y); + XMoveWindow (private->drawable.xdisplay, private->drawable.xwindow, x, y); - if (private->window_type == GDK_WINDOW_CHILD) + if (private->drawable.window_type == GDK_WINDOW_CHILD) { private->x = x; private->y = y; @@ -816,26 +812,29 @@ gdk_window_resize (GdkWindow *window, GdkWindowPrivate *private; g_return_if_fail (window != NULL); + g_return_if_fail (GDK_IS_WINDOW (window)); if (width < 1) width = 1; if (height < 1) height = 1; - + private = (GdkWindowPrivate*) window; - if (!private->destroyed && + if (!private->drawable.destroyed && ((private->resize_count > 0) || - (private->width != (guint16) width) || - (private->height != (guint16) height))) + (private->drawable.width != (guint16) width) || + (private->drawable.height != (guint16) height))) { - XResizeWindow (private->xdisplay, private->xwindow, width, height); + XResizeWindow (GDK_DRAWABLE_XDISPLAY (private), + GDK_DRAWABLE_XID (private), + width, height); private->resize_count += 1; - if (private->window_type == GDK_WINDOW_CHILD) + if (GDK_DRAWABLE_TYPE (private) == GDK_WINDOW_CHILD) { - private->width = width; - private->height = height; + private->drawable.width = width; + private->drawable.height = height; } } } @@ -850,16 +849,20 @@ gdk_window_move_resize (GdkWindow *window, GdkWindowPrivate *private; g_return_if_fail (window != NULL); - + g_return_if_fail (GDK_IS_WINDOW (window)); + if (width < 1) width = 1; if (height < 1) height = 1; private = (GdkWindowPrivate*) window; - if (!private->destroyed) + + if (!GDK_DRAWABLE_DESTROYED (window)) { - XMoveResizeWindow (private->xdisplay, private->xwindow, x, y, width, height); + XMoveResizeWindow (GDK_DRAWABLE_XDISPLAY (window), + GDK_DRAWABLE_XID (window), + x, y, width, height); if (private->guffaw_gravity) { @@ -875,12 +878,12 @@ gdk_window_move_resize (GdkWindow *window, } } - if (private->window_type == GDK_WINDOW_CHILD) + if (GDK_DRAWABLE_TYPE (private) == GDK_WINDOW_CHILD) { private->x = x; private->y = y; - private->width = width; - private->height = height; + private->drawable.width = width; + private->drawable.height = height; } } } @@ -896,6 +899,9 @@ gdk_window_reparent (GdkWindow *window, GdkWindowPrivate *old_parent_private; g_return_if_fail (window != NULL); + g_return_if_fail (GDK_IS_WINDOW (window)); + g_return_if_fail (new_parent != NULL); + g_return_if_fail (GDK_IS_WINDOW (new_parent)); if (!new_parent) new_parent = (GdkWindow*) &gdk_root_parent; @@ -904,10 +910,10 @@ gdk_window_reparent (GdkWindow *window, old_parent_private = (GdkWindowPrivate*)window_private->parent; parent_private = (GdkWindowPrivate*) new_parent; - if (!window_private->destroyed && !parent_private->destroyed) - XReparentWindow (window_private->xdisplay, - window_private->xwindow, - parent_private->xwindow, + if (!GDK_DRAWABLE_DESTROYED (window) && !GDK_DRAWABLE_DESTROYED (new_parent)) + XReparentWindow (GDK_DRAWABLE_XDISPLAY (window), + GDK_DRAWABLE_XID (window), + GDK_DRAWABLE_XID (new_parent), x, y); window_private->parent = new_parent; @@ -926,14 +932,11 @@ gdk_window_reparent (GdkWindow *window, void gdk_window_clear (GdkWindow *window) { - GdkWindowPrivate *private; - g_return_if_fail (window != NULL); + g_return_if_fail (GDK_IS_WINDOW (window)); - private = (GdkWindowPrivate*) window; - - if (!private->destroyed) - XClearWindow (private->xdisplay, private->xwindow); + if (!GDK_DRAWABLE_DESTROYED (window)) + XClearWindow (GDK_DRAWABLE_XDISPLAY (window), GDK_DRAWABLE_XID (window)); } void @@ -943,14 +946,11 @@ gdk_window_clear_area (GdkWindow *window, gint width, gint height) { - GdkWindowPrivate *private; - g_return_if_fail (window != NULL); + g_return_if_fail (GDK_IS_WINDOW (window)); - private = (GdkWindowPrivate*) window; - - if (!private->destroyed) - XClearArea (private->xdisplay, private->xwindow, + if (!GDK_DRAWABLE_DESTROYED (window)) + XClearArea (GDK_DRAWABLE_XDISPLAY (window), GDK_DRAWABLE_XID (window), x, y, width, height, False); } @@ -961,76 +961,32 @@ gdk_window_clear_area_e (GdkWindow *window, gint width, gint height) { - GdkWindowPrivate *private; - g_return_if_fail (window != NULL); + g_return_if_fail (GDK_IS_WINDOW (window)); - private = (GdkWindowPrivate*) window; - - if (!private->destroyed) - XClearArea (private->xdisplay, private->xwindow, + if (!GDK_DRAWABLE_DESTROYED (window)) + XClearArea (GDK_DRAWABLE_XDISPLAY (window), GDK_DRAWABLE_XID (window), x, y, width, height, True); } -void -gdk_window_copy_area (GdkWindow *window, - GdkGC *gc, - gint x, - gint y, - GdkWindow *source_window, - gint source_x, - gint source_y, - gint width, - gint height) -{ - GdkWindowPrivate *src_private; - GdkWindowPrivate *dest_private; - GdkGCPrivate *gc_private; - - g_return_if_fail (window != NULL); - g_return_if_fail (gc != NULL); - - if (source_window == NULL) - source_window = window; - - src_private = (GdkWindowPrivate*) source_window; - dest_private = (GdkWindowPrivate*) window; - gc_private = (GdkGCPrivate*) gc; - - if (!src_private->destroyed && !dest_private->destroyed) - { - XCopyArea (dest_private->xdisplay, src_private->xwindow, dest_private->xwindow, - gc_private->xgc, - source_x, source_y, - width, height, - x, y); - } -} - void gdk_window_raise (GdkWindow *window) { - GdkWindowPrivate *private; - g_return_if_fail (window != NULL); + g_return_if_fail (GDK_IS_WINDOW (window)); - private = (GdkWindowPrivate*) window; - - if (!private->destroyed) - XRaiseWindow (private->xdisplay, private->xwindow); + if (!GDK_DRAWABLE_DESTROYED (window)) + XRaiseWindow (GDK_DRAWABLE_XDISPLAY (window), GDK_DRAWABLE_XID (window)); } void gdk_window_lower (GdkWindow *window) { - GdkWindowPrivate *private; - g_return_if_fail (window != NULL); + g_return_if_fail (GDK_IS_WINDOW (window)); - private = (GdkWindowPrivate*) window; - - if (!private->destroyed) - XLowerWindow (private->xdisplay, private->xwindow); + if (!GDK_DRAWABLE_DESTROYED (window)) + XLowerWindow (GDK_DRAWABLE_XDISPLAY (window), GDK_DRAWABLE_XID (window)); } void @@ -1052,13 +1008,12 @@ gdk_window_set_hints (GdkWindow *window, gint max_height, gint flags) { - GdkWindowPrivate *private; XSizeHints size_hints; g_return_if_fail (window != NULL); + g_return_if_fail (GDK_IS_WINDOW (window)); - private = (GdkWindowPrivate*) window; - if (private->destroyed) + if (GDK_DRAWABLE_DESTROYED (window)) return; size_hints.flags = 0; @@ -1087,7 +1042,9 @@ gdk_window_set_hints (GdkWindow *window, /* FIXME: Would it be better to delete this property of * flags == 0? It would save space on the server */ - XSetWMNormalHints (private->xdisplay, private->xwindow, &size_hints); + XSetWMNormalHints (GDK_DRAWABLE_XDISPLAY (window), + GDK_DRAWABLE_XID (window), + &size_hints); } void @@ -1095,13 +1052,12 @@ gdk_window_set_geometry_hints (GdkWindow *window, GdkGeometry *geometry, GdkWindowHints geom_mask) { - GdkWindowPrivate *private; XSizeHints size_hints; g_return_if_fail (window != NULL); + g_return_if_fail (GDK_IS_WINDOW (window)); - private = (GdkWindowPrivate*) window; - if (private->destroyed) + if (GDK_DRAWABLE_DESTROYED (window)) return; size_hints.flags = 0; @@ -1173,20 +1129,21 @@ gdk_window_set_geometry_hints (GdkWindow *window, /* FIXME: Would it be better to delete this property of * geom_mask == 0? It would save space on the server */ - XSetWMNormalHints (private->xdisplay, private->xwindow, &size_hints); + XSetWMNormalHints (GDK_DRAWABLE_XDISPLAY (window), + GDK_DRAWABLE_XID (window), + &size_hints); } void gdk_window_set_title (GdkWindow *window, const gchar *title) { - GdkWindowPrivate *private; - g_return_if_fail (window != NULL); + g_return_if_fail (GDK_IS_WINDOW (window)); - private = (GdkWindowPrivate*) window; - if (!private->destroyed) - XmbSetWMProperties (private->xdisplay, private->xwindow, + if (!GDK_DRAWABLE_DESTROYED (window)) + XmbSetWMProperties (GDK_DRAWABLE_XDISPLAY (window), + GDK_DRAWABLE_XID (window), title, title, NULL, 0, NULL, NULL, NULL); } @@ -1194,19 +1151,19 @@ void gdk_window_set_role (GdkWindow *window, const gchar *role) { - GdkWindowPrivate *private; - g_return_if_fail (window != NULL); - - private = (GdkWindowPrivate*) window; - - if (role) - XChangeProperty (private->xdisplay, private->xwindow, - gdk_atom_intern ("WM_WINDOW_ROLE", FALSE), XA_STRING, - 8, PropModeReplace, role, strlen (role)); - else - XDeleteProperty (private->xdisplay, private->xwindow, - gdk_atom_intern ("WM_WINDOW_ROLE", FALSE)); + g_return_if_fail (GDK_IS_WINDOW (window)); + + if (!GDK_DRAWABLE_DESTROYED (window)) + { + if (role) + XChangeProperty (GDK_DRAWABLE_XDISPLAY (window), GDK_DRAWABLE_XID (window), + gdk_atom_intern ("WM_WINDOW_ROLE", FALSE), XA_STRING, + 8, PropModeReplace, role, strlen (role)); + else + XDeleteProperty (GDK_DRAWABLE_XDISPLAY (window), GDK_DRAWABLE_XID (window), + gdk_atom_intern ("WM_WINDOW_ROLE", FALSE)); + } } void @@ -1217,26 +1174,27 @@ gdk_window_set_transient_for (GdkWindow *window, GdkWindowPrivate *parent_private; g_return_if_fail (window != NULL); + g_return_if_fail (GDK_IS_WINDOW (window)); private = (GdkWindowPrivate*) window; parent_private = (GdkWindowPrivate*) parent; - if (!private->destroyed && !parent_private->destroyed) - XSetTransientForHint (private->xdisplay, - private->xwindow, parent_private->xwindow); + if (!GDK_DRAWABLE_DESTROYED (window) && !GDK_DRAWABLE_DESTROYED (parent)) + XSetTransientForHint (GDK_DRAWABLE_XDISPLAY (window), + GDK_DRAWABLE_XID (window), + GDK_DRAWABLE_XID (parent)); } void gdk_window_set_background (GdkWindow *window, GdkColor *color) { - GdkWindowPrivate *private; - g_return_if_fail (window != NULL); + g_return_if_fail (GDK_IS_WINDOW (window)); - private = (GdkWindowPrivate*) window; - if (!private->destroyed) - XSetWindowBackground (private->xdisplay, private->xwindow, color->pixel); + if (!GDK_DRAWABLE_DESTROYED (window)) + XSetWindowBackground (GDK_DRAWABLE_XDISPLAY (window), + GDK_DRAWABLE_XID (window), color->pixel); } void @@ -1244,38 +1202,34 @@ gdk_window_set_back_pixmap (GdkWindow *window, GdkPixmap *pixmap, gint parent_relative) { - GdkWindowPrivate *window_private; - GdkPixmapPrivate *pixmap_private; Pixmap xpixmap; g_return_if_fail (window != NULL); - - window_private = (GdkWindowPrivate*) window; - pixmap_private = (GdkPixmapPrivate*) pixmap; + g_return_if_fail (GDK_IS_WINDOW (window)); if (pixmap) - xpixmap = pixmap_private->xwindow; + xpixmap = GDK_DRAWABLE_XID (pixmap); else xpixmap = None; if (parent_relative) xpixmap = ParentRelative; - if (!window_private->destroyed) - XSetWindowBackgroundPixmap (window_private->xdisplay, window_private->xwindow, xpixmap); + if (!GDK_DRAWABLE_DESTROYED (window)) + XSetWindowBackgroundPixmap (GDK_DRAWABLE_XDISPLAY (window), + GDK_DRAWABLE_XID (window), xpixmap); } void gdk_window_set_cursor (GdkWindow *window, GdkCursor *cursor) { - GdkWindowPrivate *window_private; GdkCursorPrivate *cursor_private; Cursor xcursor; g_return_if_fail (window != NULL); + g_return_if_fail (GDK_IS_WINDOW (window)); - window_private = (GdkWindowPrivate*) window; cursor_private = (GdkCursorPrivate*) cursor; if (!cursor) @@ -1283,37 +1237,10 @@ gdk_window_set_cursor (GdkWindow *window, else xcursor = cursor_private->xcursor; - if (!window_private->destroyed) - XDefineCursor (window_private->xdisplay, window_private->xwindow, xcursor); -} - -void -gdk_window_set_colormap (GdkWindow *window, - GdkColormap *colormap) -{ - GdkWindowPrivate *window_private; - GdkColormapPrivate *colormap_private; - - g_return_if_fail (window != NULL); - g_return_if_fail (colormap != NULL); - - window_private = (GdkWindowPrivate*) window; - colormap_private = (GdkColormapPrivate*) colormap; - - if (!window_private->destroyed) - { - XSetWindowColormap (window_private->xdisplay, - window_private->xwindow, - colormap_private->xcolormap); - - if (window_private->colormap) - gdk_colormap_unref (window_private->colormap); - window_private->colormap = colormap; - gdk_colormap_ref (window_private->colormap); - - if (window_private->window_type != GDK_WINDOW_TOPLEVEL) - gdk_window_add_colormap_windows (window); - } + if (!GDK_DRAWABLE_DESTROYED (window)) + XDefineCursor (GDK_DRAWABLE_XDISPLAY (window), + GDK_DRAWABLE_XID (window), + xcursor); } void @@ -1333,7 +1260,6 @@ gdk_window_get_geometry (GdkWindow *window, gint *height, gint *depth) { - GdkWindowPrivate *window_private; Window root; gint tx; gint ty; @@ -1342,14 +1268,15 @@ gdk_window_get_geometry (GdkWindow *window, guint tborder_width; guint tdepth; + g_return_if_fail (window == NULL || GDK_IS_WINDOW (window)); + if (!window) - window = (GdkWindow*) &gdk_root_parent; + window = (GdkWindow *) &gdk_root_parent; - window_private = (GdkWindowPrivate*) window; - - if (!window_private->destroyed) + if (!GDK_DRAWABLE_DESTROYED (window)) { - XGetGeometry (window_private->xdisplay, window_private->xwindow, + XGetGeometry (GDK_DRAWABLE_XDISPLAY (window), + GDK_DRAWABLE_XID (window), &root, &tx, &ty, &twidth, &theight, &tborder_width, &tdepth); if (x) @@ -1373,6 +1300,7 @@ gdk_window_get_position (GdkWindow *window, GdkWindowPrivate *window_private; g_return_if_fail (window != NULL); + g_return_if_fail (GDK_IS_WINDOW (window)); window_private = (GdkWindowPrivate*) window; @@ -1382,97 +1310,11 @@ gdk_window_get_position (GdkWindow *window, *y = window_private->y; } -void -gdk_window_get_size (GdkWindow *window, - gint *width, - gint *height) -{ - GdkWindowPrivate *window_private; - - g_return_if_fail (window != NULL); - - window_private = (GdkWindowPrivate*) window; - - if (width) - *width = window_private->width; - if (height) - *height = window_private->height; -} - -GdkVisual* -gdk_window_get_visual (GdkWindow *window) -{ - GdkWindowPrivate *window_private; - XWindowAttributes window_attributes; - - g_return_val_if_fail (window != NULL, NULL); - - window_private = (GdkWindowPrivate*) window; - /* Huh? ->parent is never set for a pixmap. We should just return - * null immeditately - */ - while (window_private && (window_private->window_type == GDK_WINDOW_PIXMAP)) - window_private = (GdkWindowPrivate*) window_private->parent; - - if (window_private && !window_private->destroyed) - { - if (window_private->colormap == NULL) - { - XGetWindowAttributes (window_private->xdisplay, - window_private->xwindow, - &window_attributes); - return gdk_visual_lookup (window_attributes.visual); - } - else - return ((GdkColormapPrivate *)window_private->colormap)->visual; - } - - return NULL; -} - -GdkColormap* -gdk_window_get_colormap (GdkWindow *window) -{ - GdkWindowPrivate *window_private; - XWindowAttributes window_attributes; - - g_return_val_if_fail (window != NULL, NULL); - window_private = (GdkWindowPrivate*) window; - - g_return_val_if_fail (window_private->window_type != GDK_WINDOW_PIXMAP, NULL); - if (!window_private->destroyed) - { - if (window_private->colormap == NULL) - { - XGetWindowAttributes (window_private->xdisplay, - window_private->xwindow, - &window_attributes); - return gdk_colormap_lookup (window_attributes.colormap); - } - else - return window_private->colormap; - } - - return NULL; -} - -GdkWindowType -gdk_window_get_type (GdkWindow *window) -{ - GdkWindowPrivate *window_private; - - g_return_val_if_fail (window != NULL, (GdkWindowType) -1); - - window_private = (GdkWindowPrivate*) window; - return window_private->window_type; -} - gint gdk_window_get_origin (GdkWindow *window, gint *x, gint *y) { - GdkWindowPrivate *private; gint return_val; Window child; gint tx = 0; @@ -1480,12 +1322,10 @@ gdk_window_get_origin (GdkWindow *window, g_return_val_if_fail (window != NULL, 0); - private = (GdkWindowPrivate*) window; - - if (!private->destroyed) + if (!GDK_DRAWABLE_DESTROYED (window)) { - return_val = XTranslateCoordinates (private->xdisplay, - private->xwindow, + return_val = XTranslateCoordinates (GDK_DRAWABLE_XDISPLAY (window), + GDK_DRAWABLE_XID (window), gdk_root_window, 0, 0, &tx, &ty, &child); @@ -1507,7 +1347,6 @@ gdk_window_get_deskrelative_origin (GdkWindow *window, gint *x, gint *y) { - GdkWindowPrivate *private; gboolean return_val = FALSE; gint num_children, format_return; Window win, *child, parent, root; @@ -1519,16 +1358,15 @@ gdk_window_get_deskrelative_origin (GdkWindow *window, guchar *data_return; g_return_val_if_fail (window != NULL, 0); + g_return_val_if_fail (GDK_IS_WINDOW (window), 0); - private = (GdkWindowPrivate*) window; - - if (!private->destroyed) + if (!GDK_DRAWABLE_DESTROYED (window)) { if (!atom) - atom = XInternAtom (private->xdisplay, "ENLIGHTENMENT_DESKTOP", False); - win = private->xwindow; + atom = gdk_atom_intern ("ENLIGHTENMENT_DESKTOP", FALSE); + win = GDK_DRAWABLE_XID (window); - while (XQueryTree (private->xdisplay, win, &root, &parent, + while (XQueryTree (GDK_DRAWABLE_XDISPLAY (window), win, &root, &parent, &child, (unsigned int *)&num_children)) { if ((child) && (num_children > 0)) @@ -1543,7 +1381,7 @@ gdk_window_get_deskrelative_origin (GdkWindow *window, break; data_return = NULL; - XGetWindowProperty (private->xdisplay, win, atom, 0, 0, + XGetWindowProperty (GDK_DRAWABLE_XDISPLAY (window), win, atom, 0, 0, False, XA_CARDINAL, &type_return, &format_return, &number_return, &bytes_after_return, &data_return); if (type_return == XA_CARDINAL) @@ -1553,8 +1391,8 @@ gdk_window_get_deskrelative_origin (GdkWindow *window, } } - return_val = XTranslateCoordinates (private->xdisplay, - private->xwindow, + return_val = XTranslateCoordinates (GDK_DRAWABLE_XDISPLAY (window), + GDK_DRAWABLE_XID (window), win, 0, 0, &tx, &ty, &root); @@ -1581,25 +1419,27 @@ gdk_window_get_root_origin (GdkWindow *window, unsigned int nchildren; g_return_if_fail (window != NULL); + g_return_if_fail (GDK_IS_WINDOW (window)); private = (GdkWindowPrivate*) window; if (x) *x = 0; if (y) *y = 0; - if (private->destroyed) + + if (GDK_DRAWABLE_DESTROYED (window)) return; while (private->parent && ((GdkWindowPrivate*) private->parent)->parent) private = (GdkWindowPrivate*) private->parent; - if (private->destroyed) + if (GDK_DRAWABLE_DESTROYED (window)) return; - xparent = private->xwindow; + xparent = GDK_DRAWABLE_XID (window); do { xwindow = xparent; - if (!XQueryTree (private->xdisplay, xwindow, + if (!XQueryTree (GDK_DRAWABLE_XDISPLAY (window), xwindow, &root, &xparent, &children, &nchildren)) return; @@ -1614,7 +1454,7 @@ gdk_window_get_root_origin (GdkWindow *window, unsigned int ww, wh, wb, wd; int wx, wy; - if (XGetGeometry (private->xdisplay, xwindow, &root, &wx, &wy, &ww, &wh, &wb, &wd)) + if (XGetGeometry (GDK_DRAWABLE_XDISPLAY (window), xwindow, &root, &wx, &wy, &ww, &wh, &wb, &wd)) { if (x) *x = wx; @@ -1630,7 +1470,6 @@ gdk_window_get_pointer (GdkWindow *window, gint *y, GdkModifierType *mask) { - GdkWindowPrivate *private; GdkWindow *return_val; Window root; Window child; @@ -1638,16 +1477,17 @@ gdk_window_get_pointer (GdkWindow *window, int winx = 0; int winy = 0; unsigned int xmask = 0; + + g_return_val_if_fail (window == NULL || GDK_IS_WINDOW (window), NULL); if (!window) window = (GdkWindow*) &gdk_root_parent; - private = (GdkWindowPrivate*) window; - return_val = NULL; - if (!private->destroyed && - XQueryPointer (private->xdisplay, private->xwindow, &root, &child, - &rootx, &rooty, &winx, &winy, &xmask)) + if (!GDK_DRAWABLE_DESTROYED (window) && + XQueryPointer (GDK_DRAWABLE_XDISPLAY (window), + GDK_DRAWABLE_XID (window), + &root, &child, &rootx, &rooty, &winx, &winy, &xmask)) { if (child) return_val = gdk_window_lookup (child); @@ -1678,20 +1518,20 @@ gdk_window_at_pointer (gint *win_x, private = &gdk_root_parent; - xwindow = private->xwindow; + xwindow = private->drawable.xwindow; - XGrabServer (private->xdisplay); + XGrabServer (private->drawable.xdisplay); while (xwindow) { xwindow_last = xwindow; - XQueryPointer (private->xdisplay, + XQueryPointer (private->drawable.xdisplay, xwindow, &root, &xwindow, &rootx, &rooty, &winx, &winy, &xmask); } - XUngrabServer (private->xdisplay); + XUngrabServer (private->drawable.xdisplay); window = gdk_window_lookup (xwindow_last); @@ -1707,6 +1547,7 @@ GdkWindow* gdk_window_get_parent (GdkWindow *window) { g_return_val_if_fail (window != NULL, NULL); + g_return_val_if_fail (GDK_IS_WINDOW (window), NULL); return ((GdkWindowPrivate*) window)->parent; } @@ -1717,22 +1558,18 @@ gdk_window_get_toplevel (GdkWindow *window) GdkWindowPrivate *private; g_return_val_if_fail (window != NULL, NULL); + g_return_val_if_fail (GDK_IS_WINDOW (window), NULL); + + private = (GdkWindowPrivate *)window; + while (GDK_DRAWABLE_TYPE (private) == GDK_WINDOW_CHILD) + private = (GdkWindowPrivate *)private->parent; - private = (GdkWindowPrivate*) window; - - while (private->window_type == GDK_WINDOW_CHILD) - { - window = ((GdkWindowPrivate*) window)->parent; - private = (GdkWindowPrivate*) window; - } - - return window; + return (GdkWindow *)window; } GList* gdk_window_get_children (GdkWindow *window) { - GdkWindowPrivate *private; GdkWindow *child; GList *children; Window root; @@ -1742,12 +1579,13 @@ gdk_window_get_children (GdkWindow *window) unsigned int i; g_return_val_if_fail (window != NULL, NULL); - - private = (GdkWindowPrivate*) window; - if (private->destroyed) + g_return_val_if_fail (GDK_IS_WINDOW (window), NULL); + + if (GDK_DRAWABLE_DESTROYED (window)) return NULL; - XQueryTree (private->xdisplay, private->xwindow, + XQueryTree (GDK_DRAWABLE_XDISPLAY (window), + GDK_DRAWABLE_XID (window), &root, &parent, &xchildren, &nchildren); children = NULL; @@ -1771,83 +1609,82 @@ gdk_window_get_children (GdkWindow *window) GdkEventMask gdk_window_get_events (GdkWindow *window) { - GdkWindowPrivate *private; XWindowAttributes attrs; GdkEventMask event_mask; int i; g_return_val_if_fail (window != NULL, 0); - - private = (GdkWindowPrivate*) window; - if (private->destroyed) + g_return_val_if_fail (GDK_IS_WINDOW (window), 0); + + if (GDK_DRAWABLE_DESTROYED (window)) return 0; - - XGetWindowAttributes (gdk_display, private->xwindow, - &attrs); - - event_mask = 0; - for (i = 0; i < gdk_nevent_masks; i++) + else { - if (attrs.your_event_mask & gdk_event_mask_table[i]) - event_mask |= 1 << (i + 1); - } + XGetWindowAttributes (GDK_DRAWABLE_XDISPLAY (window), + GDK_DRAWABLE_XID (window), + &attrs); + + event_mask = 0; + for (i = 0; i < gdk_nevent_masks; i++) + { + if (attrs.your_event_mask & gdk_event_mask_table[i]) + event_mask |= 1 << (i + 1); + } - return event_mask; + return event_mask; + } } void gdk_window_set_events (GdkWindow *window, GdkEventMask event_mask) { - GdkWindowPrivate *private; long xevent_mask; int i; g_return_if_fail (window != NULL); + g_return_if_fail (GDK_IS_WINDOW (window)); - private = (GdkWindowPrivate*) window; - if (private->destroyed) - return; - - xevent_mask = StructureNotifyMask; - for (i = 0; i < gdk_nevent_masks; i++) + if (!GDK_DRAWABLE_DESTROYED (window)) { - if (event_mask & (1 << (i + 1))) - xevent_mask |= gdk_event_mask_table[i]; + xevent_mask = StructureNotifyMask; + for (i = 0; i < gdk_nevent_masks; i++) + { + if (event_mask & (1 << (i + 1))) + xevent_mask |= gdk_event_mask_table[i]; + } + + XSelectInput (GDK_DRAWABLE_XDISPLAY (window), + GDK_DRAWABLE_XID (window), + xevent_mask); } - - XSelectInput (gdk_display, private->xwindow, - xevent_mask); } void gdk_window_add_colormap_windows (GdkWindow *window) { GdkWindow *toplevel; - GdkWindowPrivate *toplevel_private; - GdkWindowPrivate *window_private; Window *old_windows; Window *new_windows; int i, count; g_return_if_fail (window != NULL); + g_return_if_fail (GDK_IS_WINDOW (window)); toplevel = gdk_window_get_toplevel (window); - toplevel_private = (GdkWindowPrivate*) toplevel; - window_private = (GdkWindowPrivate*) window; - if (window_private->destroyed) + if (GDK_DRAWABLE_DESTROYED (toplevel)) return; old_windows = NULL; - if (!XGetWMColormapWindows (toplevel_private->xdisplay, - toplevel_private->xwindow, + if (!XGetWMColormapWindows (GDK_DRAWABLE_XDISPLAY (toplevel), + GDK_DRAWABLE_XID (toplevel), &old_windows, &count)) { count = 0; } for (i = 0; i < count; i++) - if (old_windows[i] == window_private->xwindow) + if (old_windows[i] == GDK_DRAWABLE_XID (window)) { XFree (old_windows); return; @@ -1857,10 +1694,10 @@ gdk_window_add_colormap_windows (GdkWindow *window) for (i = 0; i < count; i++) new_windows[i] = old_windows[i]; - new_windows[count] = window_private->xwindow; + new_windows[count] = GDK_DRAWABLE_XID (window); - XSetWMColormapWindows (toplevel_private->xdisplay, - toplevel_private->xwindow, + XSetWMColormapWindows (GDK_DRAWABLE_XDISPLAY (toplevel), + GDK_DRAWABLE_XID (toplevel), new_windows, count + 1); g_free (new_windows); @@ -1896,24 +1733,20 @@ gdk_window_shape_combine_mask (GdkWindow *window, GdkBitmap *mask, gint x, gint y) { - GdkWindowPrivate *window_private; Pixmap pixmap; g_return_if_fail (window != NULL); + g_return_if_fail (GDK_IS_WINDOW (window)); #ifdef HAVE_SHAPE_EXT - window_private = (GdkWindowPrivate*) window; - if (window_private->destroyed) + if (GDK_DRAWABLE_DESTROYED (window)) return; if (gdk_window_have_shape_ext ()) { if (mask) { - GdkWindowPrivate *pixmap_private; - - pixmap_private = (GdkWindowPrivate*) mask; - pixmap = (Pixmap) pixmap_private->xwindow; + pixmap = GDK_DRAWABLE_XID (mask); } else { @@ -1922,8 +1755,8 @@ gdk_window_shape_combine_mask (GdkWindow *window, pixmap = None; } - XShapeCombineMask (window_private->xdisplay, - window_private->xwindow, + XShapeCombineMask (GDK_DRAWABLE_XDISPLAY (window), + GDK_DRAWABLE_XID (window), ShapeBounding, x, y, pixmap, @@ -1941,8 +1774,11 @@ gdk_window_add_filter (GdkWindow *window, GList *tmp_list; GdkEventFilter *filter; + g_return_if_fail (window != NULL); + g_return_if_fail (GDK_IS_WINDOW (window)); + private = (GdkWindowPrivate*) window; - if (private && private->destroyed) + if (private && GDK_DRAWABLE_DESTROYED (window)) return; if (private) @@ -1977,6 +1813,9 @@ gdk_window_remove_filter (GdkWindow *window, GList *tmp_list, *node; GdkEventFilter *filter; + g_return_if_fail (window != NULL); + g_return_if_fail (GDK_IS_WINDOW (window)); + private = (GdkWindowPrivate*) window; if (private) @@ -2008,19 +1847,19 @@ void gdk_window_set_override_redirect (GdkWindow *window, gboolean override_redirect) { - GdkWindowPrivate *private; XSetWindowAttributes attr; g_return_if_fail (window != NULL); - private = (GdkWindowPrivate*) window; - if (private->destroyed) - return; - - attr.override_redirect = (override_redirect == FALSE)?False:True; - XChangeWindowAttributes (gdk_display, - ((GdkWindowPrivate *)window)->xwindow, - CWOverrideRedirect, - &attr); + g_return_if_fail (GDK_IS_WINDOW (window)); + + if (GDK_DRAWABLE_DESTROYED (window)) + { + attr.override_redirect = (override_redirect == FALSE)?False:True; + XChangeWindowAttributes (GDK_DRAWABLE_XDISPLAY (window), + GDK_DRAWABLE_XID (window), + CWOverrideRedirect, + &attr); + } } void @@ -2030,40 +1869,38 @@ gdk_window_set_icon (GdkWindow *window, GdkBitmap *mask) { XWMHints *wm_hints; - GdkWindowPrivate *window_private; - GdkWindowPrivate *private; g_return_if_fail (window != NULL); - window_private = (GdkWindowPrivate*) window; - if (window_private->destroyed) + g_return_if_fail (GDK_IS_WINDOW (window)); + + if (GDK_DRAWABLE_DESTROYED (window)) return; - wm_hints = XGetWMHints (window_private->xdisplay, window_private->xwindow); + wm_hints = XGetWMHints (GDK_DRAWABLE_XDISPLAY (window), + GDK_DRAWABLE_XID (window)); if (!wm_hints) wm_hints = XAllocWMHints (); if (icon_window != NULL) { - private = (GdkWindowPrivate *)icon_window; wm_hints->flags |= IconWindowHint; - wm_hints->icon_window = private->xwindow; + wm_hints->icon_window = GDK_DRAWABLE_XID (icon_window); } if (pixmap != NULL) { - private = (GdkWindowPrivate *)pixmap; wm_hints->flags |= IconPixmapHint; - wm_hints->icon_pixmap = private->xwindow; + wm_hints->icon_pixmap = GDK_DRAWABLE_XID (pixmap); } if (mask != NULL) { - private = (GdkWindowPrivate *)mask; wm_hints->flags |= IconMaskHint; - wm_hints->icon_mask = private->xwindow; + wm_hints->icon_mask = GDK_DRAWABLE_XID (mask); } - XSetWMHints (window_private->xdisplay, window_private->xwindow, wm_hints); + XSetWMHints (GDK_DRAWABLE_XDISPLAY (window), + GDK_DRAWABLE_XID (window), wm_hints); XFree (wm_hints); } @@ -2071,15 +1908,16 @@ void gdk_window_set_icon_name (GdkWindow *window, gchar * name) { - GdkWindowPrivate *window_private; XTextProperty property; gint res; g_return_if_fail (window != NULL); - window_private = (GdkWindowPrivate*) window; - if (window_private->destroyed) + g_return_if_fail (GDK_IS_WINDOW (window)); + + if (GDK_DRAWABLE_DESTROYED (window)) return; - res = XmbTextListToTextProperty (window_private->xdisplay, + + res = XmbTextListToTextProperty (GDK_DRAWABLE_XDISPLAY (window), &name, 1, XStdICCTextStyle, &property); if (res < 0) @@ -2088,7 +1926,8 @@ gdk_window_set_icon_name (GdkWindow *window, return; } - XSetWMIconName (window_private->xdisplay, window_private->xwindow, + XSetWMIconName (GDK_DRAWABLE_XDISPLAY (window), + GDK_DRAWABLE_XID (window), &property); if (property.value) @@ -2100,25 +1939,25 @@ gdk_window_set_group (GdkWindow *window, GdkWindow *leader) { XWMHints *wm_hints; - GdkWindowPrivate *window_private; - GdkWindowPrivate *private; g_return_if_fail (window != NULL); + g_return_if_fail (GDK_IS_WINDOW (window)); g_return_if_fail (leader != NULL); - window_private = (GdkWindowPrivate*) window; - if (window_private->destroyed) + g_return_if_fail (GDK_IS_WINDOW (leader)); + + if (GDK_DRAWABLE_DESTROYED (window) || GDK_DRAWABLE_DESTROYED (leader)) return; - private = (GdkWindowPrivate *)leader; - - wm_hints = XGetWMHints (window_private->xdisplay, window_private->xwindow); + wm_hints = XGetWMHints (GDK_DRAWABLE_XDISPLAY (window), + GDK_DRAWABLE_XID (window)); if (!wm_hints) wm_hints = XAllocWMHints (); wm_hints->flags |= WindowGroupHint; - wm_hints->window_group = private->xwindow; + wm_hints->window_group = GDK_DRAWABLE_XID (leader); - XSetWMHints (window_private->xdisplay, window_private->xwindow, wm_hints); + XSetWMHints (GDK_DRAWABLE_XDISPLAY (window), + GDK_DRAWABLE_XID (window), wm_hints); XFree (wm_hints); } @@ -2133,18 +1972,14 @@ gdk_window_set_mwm_hints (GdkWindow *window, gulong nitems; gulong bytes_after; - GdkWindowPrivate *window_private; - - g_return_if_fail (window != NULL); - window_private = (GdkWindowPrivate*) window; - if (window_private->destroyed) + if (GDK_DRAWABLE_DESTROYED (window)) return; if (!hints_atom) - hints_atom = XInternAtom (window_private->xdisplay, + hints_atom = XInternAtom (GDK_DRAWABLE_XDISPLAY (window), _XA_MOTIF_WM_HINTS, FALSE); - XGetWindowProperty (window_private->xdisplay, window_private->xwindow, + XGetWindowProperty (GDK_DRAWABLE_XDISPLAY (window), GDK_DRAWABLE_XID (window), hints_atom, 0, sizeof (MotifWmHints)/sizeof (long), False, AnyPropertyType, &type, &format, &nitems, &bytes_after, (guchar **)&hints); @@ -2165,7 +2000,7 @@ gdk_window_set_mwm_hints (GdkWindow *window, } } - XChangeProperty (window_private->xdisplay, window_private->xwindow, + XChangeProperty (GDK_DRAWABLE_XDISPLAY (window), GDK_DRAWABLE_XID (window), hints_atom, hints_atom, 32, PropModeReplace, (guchar *)hints, sizeof (MotifWmHints)/sizeof (long)); @@ -2179,6 +2014,9 @@ gdk_window_set_decorations (GdkWindow *window, { MotifWmHints hints; + g_return_if_fail (window != NULL); + g_return_if_fail (GDK_IS_WINDOW (window)); + hints.flags = MWM_HINTS_DECORATIONS; hints.decorations = decorations; @@ -2191,6 +2029,9 @@ gdk_window_set_functions (GdkWindow *window, { MotifWmHints hints; + g_return_if_fail (window != NULL); + g_return_if_fail (GDK_IS_WINDOW (window)); + hints.flags = MWM_HINTS_FUNCTIONS; hints.functions = functions; @@ -2529,34 +2370,28 @@ gdk_propagate_shapes (Display *disp, void gdk_window_set_child_shapes (GdkWindow *window) { - GdkWindowPrivate *private; - g_return_if_fail (window != NULL); + g_return_if_fail (GDK_IS_WINDOW (window)); #ifdef HAVE_SHAPE_EXT - private = (GdkWindowPrivate*) window; - if (private->destroyed) - return; - - if (gdk_window_have_shape_ext ()) - gdk_propagate_shapes (private->xdisplay, private->xwindow, FALSE); + if (!GDK_DRAWABLE_DESTROYED (window) && + gdk_window_have_shape_ext ()) + gdk_propagate_shapes (GDK_DRAWABLE_XDISPLAY (window), + GDK_DRAWABLE_XID (window), FALSE); #endif } void gdk_window_merge_child_shapes (GdkWindow *window) { - GdkWindowPrivate *private; - g_return_if_fail (window != NULL); + g_return_if_fail (GDK_IS_WINDOW (window)); #ifdef HAVE_SHAPE_EXT - private = (GdkWindowPrivate*) window; - if (private->destroyed) - return; - - if (gdk_window_have_shape_ext ()) - gdk_propagate_shapes (private->xdisplay, private->xwindow, TRUE); + if (!GDK_DRAWABLE_DESTROYED (window) && + gdk_window_have_shape_ext ()) + gdk_propagate_shapes (GDK_DRAWABLE_XDISPLAY (window), + GDK_DRAWABLE_XID (window), TRUE); #endif } @@ -2575,6 +2410,7 @@ gdk_window_is_visible (GdkWindow *window) GdkWindowPrivate *private = (GdkWindowPrivate *)window; g_return_val_if_fail (window != NULL, FALSE); + g_return_val_if_fail (GDK_IS_WINDOW (window), FALSE); return private->mapped; } @@ -2597,10 +2433,11 @@ gdk_window_is_viewable (GdkWindow *window) GdkWindowPrivate *private = (GdkWindowPrivate *)window; g_return_val_if_fail (window != NULL, FALSE); + g_return_val_if_fail (GDK_IS_WINDOW (window), FALSE); while (private && (private != &gdk_root_parent) && - (private->window_type != GDK_WINDOW_FOREIGN)) + (private->drawable.window_type != GDK_WINDOW_FOREIGN)) { if (!private->mapped) return FALSE; @@ -2611,16 +2448,6 @@ gdk_window_is_viewable (GdkWindow *window) return TRUE; } -void -gdk_drawable_set_data (GdkDrawable *drawable, - const gchar *key, - gpointer data, - GDestroyNotify destroy_func) -{ - g_dataset_set_data_full (drawable, key, data, destroy_func); -} - - /* Support for windows that can be guffaw-scrolled * (See http://www.gtk.org/~otaylor/whitepapers/guffaw-scrolling.txt) */ @@ -2685,29 +2512,27 @@ gdk_window_gravity_works (void) static void gdk_window_set_static_bit_gravity (GdkWindow *window, gboolean on) { - GdkWindowPrivate *private = (GdkWindowPrivate *)window; XSetWindowAttributes xattributes; g_return_if_fail (window != NULL); xattributes.bit_gravity = on ? StaticGravity : ForgetGravity; - XChangeWindowAttributes (private->xdisplay, - private->xwindow, + XChangeWindowAttributes (GDK_DRAWABLE_XDISPLAY (window), + GDK_DRAWABLE_XID (window), CWBitGravity, &xattributes); } static void gdk_window_set_static_win_gravity (GdkWindow *window, gboolean on) { - GdkWindowPrivate *private = (GdkWindowPrivate *)window; XSetWindowAttributes xattributes; g_return_if_fail (window != NULL); xattributes.win_gravity = on ? StaticGravity : NorthWestGravity; - XChangeWindowAttributes (private->xdisplay, - private->xwindow, + XChangeWindowAttributes (GDK_DRAWABLE_XDISPLAY (window), + GDK_DRAWABLE_XID (window), CWWinGravity, &xattributes); } @@ -2731,7 +2556,8 @@ gdk_window_set_static_gravities (GdkWindow *window, GList *tmp_list; g_return_val_if_fail (window != NULL, FALSE); - + g_return_val_if_fail (GDK_IS_WINDOW (window), FALSE); + if (!use_static == !private->guffaw_gravity) return TRUE; @@ -2740,14 +2566,17 @@ gdk_window_set_static_gravities (GdkWindow *window, private->guffaw_gravity = use_static; - gdk_window_set_static_bit_gravity (window, use_static); - - tmp_list = private->children; - while (tmp_list) + if (!GDK_DRAWABLE_DESTROYED (window)) { - gdk_window_set_static_win_gravity (window, use_static); + gdk_window_set_static_bit_gravity (window, use_static); - tmp_list = tmp_list->next; + tmp_list = private->children; + while (tmp_list) + { + gdk_window_set_static_win_gravity (window, use_static); + + tmp_list = tmp_list->next; + } } return TRUE; diff --git a/gdk/x11/gdkx.h b/gdk/x11/gdkx.h index 995c9dca97..4f142bd1ef 100644 --- a/gdk/x11/gdkx.h +++ b/gdk/x11/gdkx.h @@ -33,8 +33,10 @@ #define GDK_ROOT_WINDOW() gdk_root_window #define GDK_ROOT_PARENT() ((GdkWindow *)&gdk_root_parent) #define GDK_DISPLAY() gdk_display -#define GDK_WINDOW_XDISPLAY(win) (((GdkWindowPrivate*) win)->xdisplay) -#define GDK_WINDOW_XWINDOW(win) (((GdkWindowPrivate*) win)->xwindow) +#define GDK_DRAWABLE_XDISPLAY(win) (((GdkDrawablePrivate*) win)->xdisplay) +#define GDK_DRAWABLE_XID(win) (((GdkDrawablePrivate*) win)->xwindow) +#define GDK_WINDOW_XDISPLAY GDK_DRAWABLE_XDISPLAY +#define GDK_WINDOW_XWINDOW GDK_DRAWABLE_XID #define GDK_IMAGE_XDISPLAY(image) (((GdkImagePrivate*) image)->xdisplay) #define GDK_IMAGE_XIMAGE(image) (((GdkImagePrivate*) image)->ximage) #define GDK_GC_XDISPLAY(gc) (((GdkGCPrivate*) gc)->xdisplay) diff --git a/gtk/gtkplug.c b/gtk/gtkplug.c index 515937b38b..4dc265560c 100644 --- a/gtk/gtkplug.c +++ b/gtk/gtkplug.c @@ -171,7 +171,7 @@ gtk_plug_realize (GtkWidget *widget) widget->window = gdk_window_new (NULL, &attributes, attributes_mask); } - ((GdkWindowPrivate *)widget->window)->window_type = GDK_WINDOW_TOPLEVEL; + GDK_DRAWABLE_TYPE (window) = GDK_WINDOW_TOPLEVEL; gdk_window_set_user_data (widget->window, window); widget->style = gtk_style_attach (widget->style, widget->window); diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index 7900e2ae6e..35693a68be 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -4784,7 +4784,8 @@ gtk_reset_shapes_recurse (GtkWidget *widget, private = (GdkWindowPrivate*) window; - if (private->destroyed) + /* FIXME: We do we need this check? */ + if (GDK_DRAWABLE_DESTROYED (window)) return; gdk_window_get_user_data (window, &data); if (data != widget)