diff options
Diffstat (limited to 'gdk/x11')
-rw-r--r-- | gdk/x11/Makefile.am | 4 | ||||
-rw-r--r-- | gdk/x11/gdkcolor-x11.c | 226 | ||||
-rw-r--r-- | gdk/x11/gdkcursor-x11.c | 9 | ||||
-rw-r--r-- | gdk/x11/gdkdnd-x11.c | 224 | ||||
-rw-r--r-- | gdk/x11/gdkdrawable-x11.c | 439 | ||||
-rw-r--r-- | gdk/x11/gdkdrawable-x11.h | 73 | ||||
-rw-r--r-- | gdk/x11/gdkevents-x11.c | 32 | ||||
-rw-r--r-- | gdk/x11/gdkgc-x11.c | 219 | ||||
-rw-r--r-- | gdk/x11/gdkgeometry-x11.c | 394 | ||||
-rw-r--r-- | gdk/x11/gdkglobals-x11.c | 6 | ||||
-rw-r--r-- | gdk/x11/gdkim-x11.c | 6 | ||||
-rw-r--r-- | gdk/x11/gdkimage-x11.c | 218 | ||||
-rw-r--r-- | gdk/x11/gdkinput.c | 8 | ||||
-rw-r--r-- | gdk/x11/gdkmain-x11.c | 19 | ||||
-rw-r--r-- | gdk/x11/gdkpixmap-x11.c | 225 | ||||
-rw-r--r-- | gdk/x11/gdkpixmap-x11.h | 70 | ||||
-rw-r--r-- | gdk/x11/gdkprivate-x11.h | 25 | ||||
-rw-r--r-- | gdk/x11/gdkproperty-x11.c | 18 | ||||
-rw-r--r-- | gdk/x11/gdkselection-x11.c | 18 | ||||
-rw-r--r-- | gdk/x11/gdkwindow-x11.c | 750 | ||||
-rw-r--r-- | gdk/x11/gdkwindow-x11.h | 89 | ||||
-rw-r--r-- | gdk/x11/gdkx.h | 124 |
22 files changed, 1925 insertions, 1271 deletions
diff --git a/gdk/x11/Makefile.am b/gdk/x11/Makefile.am index 1e8e1ad103..5cca5f4224 100644 --- a/gdk/x11/Makefile.am +++ b/gdk/x11/Makefile.am @@ -83,7 +83,7 @@ gxid_LDADD = $(LDADDS) endif install-data-local: - ../../$(MKINSTALLDIRS) $(includedir)/gdk + $(MKINSTALLDIRS) $(includedir)/gdk $(INSTALL_DATA) $(srcdir)/gdkx.h $(includedir)/gdk - ../../$(MKINSTALLDIRS) $(includedir)/gdk/x11 + $(MKINSTALLDIRS) $(includedir)/gdk/x11 $(INSTALL_DATA) $(srcdir)/gdkprivate-x11.h $(includedir)/gdk/x11 diff --git a/gdk/x11/gdkcolor-x11.c b/gdk/x11/gdkcolor-x11.c index 156933cec4..d32f85451e 100644 --- a/gdk/x11/gdkcolor-x11.c +++ b/gdk/x11/gdkcolor-x11.c @@ -29,6 +29,8 @@ #include "gdkcolor.h" #include "gdkprivate-x11.h" +#define GDK_COLORMAP_PRIVATE_DATA(cmap) ((GdkColormapPrivateX11 *) GDK_COLORMAP (cmap)->windowing_data) + static gint gdk_colormap_match_color (GdkColormap *cmap, GdkColor *color, const gchar *available); @@ -38,36 +40,113 @@ static guint gdk_colormap_hash (Colormap *cmap); static gint gdk_colormap_cmp (Colormap *a, Colormap *b); +static void gdk_colormap_init (GdkColormap *colormap); +static void gdk_colormap_class_init (GdkColormapClass *klass); +static void gdk_colormap_finalize (GObject *object); + +static gpointer parent_class = NULL; + static GHashTable *colormap_hash = NULL; +GType +gdk_colormap_get_type (void) +{ + static GType object_type = 0; + + if (!object_type) + { + static const GTypeInfo object_info = + { + sizeof (GdkColormapClass), + (GBaseInitFunc) NULL, + (GBaseFinalizeFunc) NULL, + (GClassInitFunc) gdk_colormap_class_init, + NULL, /* class_finalize */ + NULL, /* class_data */ + sizeof (GdkColormap), + 0, /* n_preallocs */ + (GInstanceInitFunc) gdk_colormap_init, + }; + + object_type = g_type_register_static (G_TYPE_OBJECT, + "GdkColormap", + &object_info); + } + + return object_type; +} + +static void +gdk_colormap_init (GdkColormap *colormap) +{ + GdkColormapPrivateX11 *private; + + private = g_new (GdkColormapPrivateX11, 1); + + colormap->windowing_data = private; + + private->xdisplay = gdk_display; + private->hash = NULL; + private->last_sync_time = 0; + private->info = NULL; + + colormap->size = 0; + colormap->colors = NULL; +} + +static void +gdk_colormap_class_init (GdkColormapClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + + parent_class = g_type_class_peek_parent (klass); + + object_class->finalize = gdk_colormap_finalize; +} + +static void +gdk_colormap_finalize (GObject *object) +{ + GdkColormap *colormap = GDK_COLORMAP (object); + GdkColormapPrivateX11 *private = GDK_COLORMAP_PRIVATE_DATA (colormap); + + gdk_colormap_remove (colormap); + + XFreeColormap (private->xdisplay, private->xcolormap); + + if (private->hash) + g_hash_table_destroy (private->hash); + + g_free (private->info); + g_free (colormap->colors); + + G_OBJECT_CLASS (parent_class)->finalize (object); +} GdkColormap* gdk_colormap_new (GdkVisual *visual, gboolean private_cmap) { GdkColormap *colormap; - GdkColormapPrivateX *private; + GdkColormapPrivateX11 *private; Visual *xvisual; int size; int i; + /* FIXME when object properties settle down, there needs to be some + * kind of default construction (and construct-only arguments) + */ + g_return_val_if_fail (visual != NULL, NULL); - private = g_new (GdkColormapPrivateX, 1); - colormap = (GdkColormap*) private; + colormap = GDK_COLORMAP (g_type_create_instance (gdk_colormap_get_type ())); + private = GDK_COLORMAP_PRIVATE_DATA (colormap); - private->xdisplay = gdk_display; - private->base.visual = visual; - private->base.ref_count = 1; - - private->hash = NULL; - private->last_sync_time = 0; - private->info = NULL; + colormap->visual = visual; xvisual = ((GdkVisualPrivate*) visual)->xvisual; colormap->size = visual->colormap_size; - colormap->colors = NULL; switch (visual->type) { @@ -145,22 +224,6 @@ gdk_colormap_new (GdkVisual *visual, return colormap; } -void -_gdk_colormap_real_destroy (GdkColormap *colormap) -{ - GdkColormapPrivateX *private = (GdkColormapPrivateX*) colormap; - - gdk_colormap_remove (colormap); - XFreeColormap (private->xdisplay, private->xcolormap); - - if (private->hash) - g_hash_table_destroy (private->hash); - - g_free (private->info); - g_free (colormap->colors); - g_free (colormap); -} - #define MIN_SYNC_TIME 2 void @@ -168,12 +231,12 @@ gdk_colormap_sync (GdkColormap *colormap, gboolean force) { time_t current_time; - GdkColormapPrivateX *private = (GdkColormapPrivateX *)colormap; + GdkColormapPrivateX11 *private = GDK_COLORMAP_PRIVATE_DATA (colormap); XColor *xpalette; gint nlookup; gint i; - g_return_if_fail (colormap != NULL); + g_return_if_fail (GDK_IS_COLORMAP (colormap)); current_time = time (NULL); if (!force && ((current_time - private->last_sync_time) < MIN_SYNC_TIME)) @@ -215,35 +278,34 @@ GdkColormap* gdk_colormap_get_system (void) { static GdkColormap *colormap = NULL; - GdkColormapPrivateX *private; + GdkColormapPrivateX11 *private; if (!colormap) { - private = g_new (GdkColormapPrivateX, 1); - colormap = (GdkColormap*) private; + colormap = GDK_COLORMAP (g_type_create_instance (gdk_colormap_get_type ())); + private = GDK_COLORMAP_PRIVATE_DATA (colormap); private->xdisplay = gdk_display; private->xcolormap = DefaultColormap (gdk_display, gdk_screen); - private->base.visual = gdk_visual_get_system (); + colormap->visual = gdk_visual_get_system (); private->private_val = FALSE; - private->base.ref_count = 1; private->hash = NULL; private->last_sync_time = 0; private->info = NULL; colormap->colors = NULL; - colormap->size = private->base.visual->colormap_size; + colormap->size = colormap->visual->colormap_size; - if ((private->base.visual->type == GDK_VISUAL_GRAYSCALE) || - (private->base.visual->type == GDK_VISUAL_PSEUDO_COLOR)) + if ((colormap->visual->type == GDK_VISUAL_GRAYSCALE) || + (colormap->visual->type == GDK_VISUAL_PSEUDO_COLOR)) { private->info = g_new0 (GdkColorInfo, colormap->size); colormap->colors = g_new (GdkColor, colormap->size); private->hash = g_hash_table_new ((GHashFunc) gdk_color_hash, (GCompareFunc) gdk_color_equal); - + gdk_colormap_sync (colormap, TRUE); } @@ -263,7 +325,7 @@ void gdk_colormap_change (GdkColormap *colormap, gint ncolors) { - GdkColormapPrivateX *private; + GdkColormapPrivateX11 *private; GdkVisual *visual; XColor *palette; gint shift; @@ -271,12 +333,12 @@ gdk_colormap_change (GdkColormap *colormap, int size; int i; - g_return_if_fail (colormap != NULL); + g_return_if_fail (GDK_IS_COLORMAP (colormap)); palette = g_new (XColor, ncolors); - private = (GdkColormapPrivateX*) colormap; - switch (private->base.visual->type) + private = GDK_COLORMAP_PRIVATE_DATA (colormap); + switch (colormap->visual->type) { case GDK_VISUAL_GRAYSCALE: case GDK_VISUAL_PSEUDO_COLOR: @@ -293,7 +355,7 @@ gdk_colormap_change (GdkColormap *colormap, break; case GDK_VISUAL_DIRECT_COLOR: - visual = private->base.visual; + visual = colormap->visual; shift = visual->red_shift; max_colors = 1 << visual->red_prec; @@ -350,13 +412,13 @@ gdk_colors_alloc (GdkColormap *colormap, gulong *pixels, gint npixels) { - GdkColormapPrivateX *private; + GdkColormapPrivateX11 *private; gint return_val; gint i; - g_return_val_if_fail (colormap != NULL, 0); + g_return_val_if_fail (GDK_IS_COLORMAP (colormap), 0); - private = (GdkColormapPrivateX*) colormap; + private = GDK_COLORMAP_PRIVATE_DATA (colormap); return_val = XAllocColorCells (private->xdisplay, private->xcolormap, contiguous, planes, nplanes, pixels, npixels); @@ -408,18 +470,18 @@ gdk_colors_free (GdkColormap *colormap, gint in_npixels, gulong planes) { - GdkColormapPrivateX *private; + GdkColormapPrivateX11 *private; gulong *pixels; gint npixels = 0; gint i; - g_return_if_fail (colormap != NULL); + g_return_if_fail (GDK_IS_COLORMAP (colormap)); g_return_if_fail (in_pixels != NULL); - private = (GdkColormapPrivateX*) colormap; + private = GDK_COLORMAP_PRIVATE_DATA (colormap); - if ((private->base.visual->type != GDK_VISUAL_PSEUDO_COLOR) && - (private->base.visual->type != GDK_VISUAL_GRAYSCALE)) + if ((colormap->visual->type != GDK_VISUAL_PSEUDO_COLOR) && + (colormap->visual->type != GDK_VISUAL_GRAYSCALE)) return; pixels = g_new (gulong, in_npixels); @@ -456,18 +518,18 @@ gdk_colormap_free_colors (GdkColormap *colormap, GdkColor *colors, gint ncolors) { - GdkColormapPrivateX *private; + GdkColormapPrivateX11 *private; gulong *pixels; gint npixels = 0; gint i; - g_return_if_fail (colormap != NULL); + g_return_if_fail (GDK_IS_COLORMAP (colormap)); g_return_if_fail (colors != NULL); - private = (GdkColormapPrivateX*) colormap; + private = GDK_COLORMAP_PRIVATE_DATA (colormap); - if ((private->base.visual->type != GDK_VISUAL_PSEUDO_COLOR) && - (private->base.visual->type != GDK_VISUAL_GRAYSCALE)) + if ((colormap->visual->type != GDK_VISUAL_PSEUDO_COLOR) && + (colormap->visual->type != GDK_VISUAL_GRAYSCALE)) return; pixels = g_new (gulong, ncolors); @@ -509,10 +571,10 @@ gdk_colormap_alloc1 (GdkColormap *colormap, GdkColor *color, GdkColor *ret) { - GdkColormapPrivateX *private; + GdkColormapPrivateX11 *private; XColor xcolor; - private = (GdkColormapPrivateX*) colormap; + private = GDK_COLORMAP_PRIVATE_DATA (colormap); xcolor.red = color->red; xcolor.green = color->green; @@ -561,12 +623,12 @@ gdk_colormap_alloc_colors_writeable (GdkColormap *colormap, gboolean best_match, gboolean *success) { - GdkColormapPrivateX *private; + GdkColormapPrivateX11 *private; gulong *pixels; Status status; gint i, index; - private = (GdkColormapPrivateX*) colormap; + private = GDK_COLORMAP_PRIVATE_DATA (colormap); if (private->private_val) { @@ -619,13 +681,13 @@ gdk_colormap_alloc_colors_private (GdkColormap *colormap, gboolean best_match, gboolean *success) { - GdkColormapPrivateX *private; + GdkColormapPrivateX11 *private; gint i, index; XColor *store = g_new (XColor, ncolors); gint nstore = 0; gint nremaining = 0; - private = (GdkColormapPrivateX*) colormap; + private = GDK_COLORMAP_PRIVATE_DATA (colormap); index = -1; /* First, store the colors we have room for */ @@ -698,12 +760,12 @@ gdk_colormap_alloc_colors_shared (GdkColormap *colormap, gboolean best_match, gboolean *success) { - GdkColormapPrivateX *private; + GdkColormapPrivateX11 *private; gint i, index; gint nremaining = 0; gint nfailed = 0; - private = (GdkColormapPrivateX*) colormap; + private = GDK_COLORMAP_PRIVATE_DATA (colormap); index = -1; for (i=0; i<ncolors; i++) @@ -790,12 +852,12 @@ gdk_colormap_alloc_colors_pseudocolor (GdkColormap *colormap, gboolean best_match, gboolean *success) { - GdkColormapPrivateX *private; + GdkColormapPrivateX11 *private; GdkColor *lookup_color; gint i; gint nremaining = 0; - private = (GdkColormapPrivateX*) colormap; + private = GDK_COLORMAP_PRIVATE_DATA (colormap); /* Check for an exact match among previously allocated colors */ @@ -837,23 +899,23 @@ gdk_colormap_alloc_colors (GdkColormap *colormap, gboolean best_match, gboolean *success) { - GdkColormapPrivateX *private; + GdkColormapPrivateX11 *private; GdkVisual *visual; gint i; gint nremaining = 0; XColor xcolor; - g_return_val_if_fail (colormap != NULL, FALSE); + g_return_val_if_fail (GDK_IS_COLORMAP (colormap), FALSE); g_return_val_if_fail (colors != NULL, FALSE); - private = (GdkColormapPrivateX*) colormap; + private = GDK_COLORMAP_PRIVATE_DATA (colormap); for (i=0; i<ncolors; i++) { success[i] = FALSE; } - switch (private->base.visual->type) + switch (colormap->visual->type) { case GDK_VISUAL_PSEUDO_COLOR: case GDK_VISUAL_GRAYSCALE: @@ -867,7 +929,7 @@ gdk_colormap_alloc_colors (GdkColormap *colormap, case GDK_VISUAL_DIRECT_COLOR: case GDK_VISUAL_TRUE_COLOR: - visual = private->base.visual; + visual = colormap->visual; for (i=0; i<ncolors; i++) { @@ -905,10 +967,10 @@ gboolean gdk_color_change (GdkColormap *colormap, GdkColor *color) { - GdkColormapPrivateX *private; + GdkColormapPrivateX11 *private; XColor xcolor; - g_return_val_if_fail (colormap != NULL, FALSE); + g_return_val_if_fail (GDK_IS_COLORMAP (colormap), FALSE); g_return_val_if_fail (color != NULL, FALSE); xcolor.pixel = color->pixel; @@ -917,7 +979,7 @@ gdk_color_change (GdkColormap *colormap, xcolor.blue = color->blue; xcolor.flags = DoRed | DoGreen | DoBlue; - private = (GdkColormapPrivateX*) colormap; + private = GDK_COLORMAP_PRIVATE_DATA (colormap); XStoreColor (private->xdisplay, private->xcolormap, &xcolor); return TRUE; @@ -930,7 +992,7 @@ GdkColormap* gdkx_colormap_get (Colormap xcolormap) { GdkColormap *colormap; - GdkColormapPrivateX *private; + GdkColormapPrivateX11 *private; colormap = gdk_colormap_lookup (xcolormap); if (colormap) @@ -939,12 +1001,12 @@ gdkx_colormap_get (Colormap xcolormap) if (xcolormap == DefaultColormap (gdk_display, gdk_screen)) return gdk_colormap_get_system (); - private = g_new (GdkColormapPrivateX, 1); - colormap = (GdkColormap*) private; + colormap = GDK_COLORMAP (g_type_create_instance (gdk_colormap_get_type ())); + private = GDK_COLORMAP_PRIVATE_DATA (colormap); private->xdisplay = gdk_display; private->xcolormap = xcolormap; - private->base.visual = NULL; + colormap->visual = NULL; private->private_val = TRUE; /* To do the following safely, we would have to have some way of finding @@ -1035,13 +1097,13 @@ gdk_colormap_lookup (Colormap xcolormap) static void gdk_colormap_add (GdkColormap *cmap) { - GdkColormapPrivateX *private; + GdkColormapPrivateX11 *private; if (!colormap_hash) colormap_hash = g_hash_table_new ((GHashFunc) gdk_colormap_hash, (GCompareFunc) gdk_colormap_cmp); - private = (GdkColormapPrivateX*)cmap; + private = GDK_COLORMAP_PRIVATE_DATA (cmap); g_hash_table_insert (colormap_hash, &private->xcolormap, cmap); } @@ -1049,13 +1111,13 @@ gdk_colormap_add (GdkColormap *cmap) static void gdk_colormap_remove (GdkColormap *cmap) { - GdkColormapPrivateX *private; + GdkColormapPrivateX11 *private; if (!colormap_hash) colormap_hash = g_hash_table_new ((GHashFunc) gdk_colormap_hash, (GCompareFunc) gdk_colormap_cmp); - private = (GdkColormapPrivateX *)cmap; + private = GDK_COLORMAP_PRIVATE_DATA (cmap); g_hash_table_remove (colormap_hash, &private->xcolormap); } diff --git a/gdk/x11/gdkcursor-x11.c b/gdk/x11/gdkcursor-x11.c index d0a580cccd..277bd2e264 100644 --- a/gdk/x11/gdkcursor-x11.c +++ b/gdk/x11/gdkcursor-x11.c @@ -29,6 +29,8 @@ #include "gdkx.h" #include "gdkcursor.h" +#include "gdkpixmap-x11.h" +#include <gdk/gdkpixmap.h> GdkCursor* gdk_cursor_new (GdkCursorType cursor_type) @@ -62,12 +64,13 @@ gdk_cursor_new_from_pixmap (GdkPixmap *source, Cursor xcursor; XColor xfg, xbg; - g_return_val_if_fail (source != NULL, NULL); + g_return_val_if_fail (GDK_IS_PIXMAP (source), NULL); + g_return_val_if_fail (GDK_IS_PIXMAP (mask), NULL); g_return_val_if_fail (fg != NULL, NULL); g_return_val_if_fail (bg != NULL, NULL); - source_pixmap = GDK_DRAWABLE_XID (source); - mask_pixmap = GDK_DRAWABLE_XID (mask); + source_pixmap = GDK_PIXMAP_XID (source); + mask_pixmap = GDK_PIXMAP_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 8509b3220e..05faffd556 100644 --- a/gdk/x11/gdkdnd-x11.c +++ b/gdk/x11/gdkdnd-x11.c @@ -34,7 +34,7 @@ #include "gdkinternals.h" #include "gdkprivate-x11.h" -typedef struct _GdkDragContextPrivate GdkDragContextPrivate; +typedef struct _GdkDragContextPrivateX11 GdkDragContextPrivateX11; typedef enum { GDK_DRAG_STATUS_DRAG, @@ -58,7 +58,7 @@ typedef struct { /* Structure that holds information about a drag in progress. * this is used on both source and destination sides. */ -struct _GdkDragContextPrivate { +struct _GdkDragContextPrivateX11 { GdkDragContext context; GdkAtom motif_selection; @@ -82,6 +82,8 @@ struct _GdkDragContextPrivate { GdkWindowCache *window_cache; }; +#define PRIVATE_DATA(context) ((GdkDragContextPrivateX11 *) GDK_DRAG_CONTEXT (context)->windowing_data) + GdkDragContext *current_dest_drag = NULL; /* Forward declarations */ @@ -121,66 +123,115 @@ static void xdnd_manage_source_filter (GdkDragContext *context, GdkWindow *window, gboolean add_filter); -/* Drag Contexts */ +static void gdk_drag_context_init (GdkDragContext *dragcontext); +static void gdk_drag_context_class_init (GdkDragContextClass *klass); +static void gdk_drag_context_finalize (GObject *object); +static gpointer parent_class = NULL; static GList *contexts; -GdkDragContext * -gdk_drag_context_new (void) +GType +gdk_drag_context_get_type (void) { - GdkDragContextPrivate *result; + static GType object_type = 0; + + if (!object_type) + { + static const GTypeInfo object_info = + { + sizeof (GdkDragContextClass), + (GBaseInitFunc) NULL, + (GBaseFinalizeFunc) NULL, + (GClassInitFunc) gdk_drag_context_class_init, + NULL, /* class_finalize */ + NULL, /* class_data */ + sizeof (GdkDragContext), + 0, /* n_preallocs */ + (GInstanceInitFunc) gdk_drag_context_init, + }; + + object_type = g_type_register_static (G_TYPE_OBJECT, + "GdkDragContext", + &object_info); + } + + return object_type; +} - result = g_new0 (GdkDragContextPrivate, 1); +static void +gdk_drag_context_init (GdkDragContext *dragcontext) +{ + GdkDragContextPrivateX11 *private; - result->ref_count = 1; + private = g_new0 (GdkDragContextPrivateX11, 1); - contexts = g_list_prepend (contexts, result); + dragcontext->windowing_data = private; - return (GdkDragContext *)result; + contexts = g_list_prepend (contexts, dragcontext); } -void -gdk_drag_context_ref (GdkDragContext *context) +static void +gdk_drag_context_class_init (GdkDragContextClass *klass) { - g_return_if_fail (context != NULL); + GObjectClass *object_class = G_OBJECT_CLASS (klass); + + parent_class = g_type_class_peek_parent (klass); - ((GdkDragContextPrivate *)context)->ref_count++; + object_class->finalize = gdk_drag_context_finalize; } -void -gdk_drag_context_unref (GdkDragContext *context) +static void +gdk_drag_context_finalize (GObject *object) { - GdkDragContextPrivate *private = (GdkDragContextPrivate *)context; - - g_return_if_fail (context != NULL); - g_return_if_fail (private->ref_count > 0); - - private->ref_count--; + GdkDragContext *context = GDK_DRAG_CONTEXT (object); + GdkDragContextPrivateX11 *private = PRIVATE_DATA (context); - if (private->ref_count == 0) + g_list_free (context->targets); + + if (context->source_window) { - g_dataset_destroy (private); + if ((context->protocol == GDK_DRAG_PROTO_XDND) && + !context->is_source) + xdnd_manage_source_filter (context, context->source_window, FALSE); - g_list_free (context->targets); + gdk_window_unref (context->source_window); + } + + if (context->dest_window) + gdk_window_unref (context->dest_window); + + if (private->window_cache) + gdk_window_cache_destroy (private->window_cache); + + contexts = g_list_remove (contexts, context); - if (context->source_window) - { - if ((context->protocol == GDK_DRAG_PROTO_XDND) && - !context->is_source) - xdnd_manage_source_filter (context, context->source_window, FALSE); + g_free (private); + + G_OBJECT_CLASS (parent_class)->finalize (object); +} - gdk_window_unref (context->source_window); - } +/* Drag Contexts */ + +GdkDragContext * +gdk_drag_context_new (void) +{ + return GDK_DRAG_CONTEXT (g_type_create_instance (gdk_drag_context_get_type ())); +} + +void +gdk_drag_context_ref (GdkDragContext *context) +{ + g_return_if_fail (GDK_IS_DRAG_CONTEXT (context)); - if (context->dest_window) - gdk_window_unref (context->dest_window); + g_object_ref (G_OBJECT (context)); +} - if (private->window_cache) - gdk_window_cache_destroy (private->window_cache); +void +gdk_drag_context_unref (GdkDragContext *context) +{ + g_return_if_fail (GDK_IS_DRAG_CONTEXT (context)); - contexts = g_list_remove (contexts, private); - g_free (private); - } + g_object_unref (G_OBJECT (context)); } static GdkDragContext * @@ -190,19 +241,19 @@ gdk_drag_context_find (gboolean is_source, { GList *tmp_list = contexts; GdkDragContext *context; - GdkDragContextPrivate *private; + GdkDragContextPrivateX11 *private; Window context_dest_xid; while (tmp_list) { context = (GdkDragContext *)tmp_list->data; - private = (GdkDragContextPrivate *)context; + private = PRIVATE_DATA (context); context_dest_xid = context->dest_window ? - (private->drop_xid ? - private->drop_xid : - GDK_DRAWABLE_XID (context->dest_window)) : - None; + (private->drop_xid ? + private->drop_xid : + GDK_DRAWABLE_XID (context->dest_window)) : + None; if ((!context->is_source == !is_source) && ((source_xid == None) || (context->source_window && @@ -1250,7 +1301,7 @@ motif_dnd_get_flags (GdkDragContext *context) static void motif_set_targets (GdkDragContext *context) { - GdkDragContextPrivate *private = (GdkDragContextPrivate *)context; + GdkDragContextPrivateX11 *private = PRIVATE_DATA (context); MotifDragInitiatorInfo info; gint i; static GdkAtom motif_drag_initiator_info = GDK_NONE; @@ -1334,7 +1385,7 @@ motif_send_enter (GdkDragContext *context, guint32 time) { XEvent xev; - GdkDragContextPrivate *private = (GdkDragContextPrivate *)context; + GdkDragContextPrivateX11 *private = PRIVATE_DATA (context); xev.xclient.type = ClientMessage; xev.xclient.message_type = gdk_atom_intern ("_MOTIF_DRAG_AND_DROP_MESSAGE", FALSE); @@ -1393,7 +1444,7 @@ motif_send_motion (GdkDragContext *context, { gboolean retval; XEvent xev; - GdkDragContextPrivate *private = (GdkDragContextPrivate *)context; + GdkDragContextPrivateX11 *private = PRIVATE_DATA (context); xev.xclient.type = ClientMessage; xev.xclient.message_type = gdk_atom_intern ("_MOTIF_DRAG_AND_DROP_MESSAGE", FALSE); @@ -1436,7 +1487,7 @@ static void motif_send_drop (GdkDragContext *context, guint32 time) { XEvent xev; - GdkDragContextPrivate *private = (GdkDragContextPrivate *)context; + GdkDragContextPrivateX11 *private = PRIVATE_DATA (context); xev.xclient.type = ClientMessage; xev.xclient.message_type = gdk_atom_intern ("_MOTIF_DRAG_AND_DROP_MESSAGE", FALSE); @@ -1537,7 +1588,7 @@ motif_drag_context_new (GdkWindow *dest_window, guint32 atom) { GdkDragContext *new_context; - GdkDragContextPrivate *private; + GdkDragContextPrivateX11 *private; /* FIXME, current_dest_drag really shouldn't be NULL'd * if we error below. @@ -1554,7 +1605,7 @@ motif_drag_context_new (GdkWindow *dest_window, } new_context = gdk_drag_context_new (); - private = (GdkDragContextPrivate *)new_context; + private = PRIVATE_DATA (new_context); new_context->protocol = GDK_DRAG_PROTO_MOTIF; new_context->is_source = FALSE; @@ -1651,7 +1702,7 @@ motif_motion (GdkEvent *event, gint16 x_root, gint16 y_root) { - GdkDragContextPrivate *private; + GdkDragContextPrivateX11 *private; GDK_NOTE(DND, g_message ("Motif DND motion: flags: %#4x time: %d (%d, %d)", flags, timestamp, x_root, y_root)); @@ -1660,7 +1711,7 @@ motif_motion (GdkEvent *event, (current_dest_drag->protocol == GDK_DRAG_PROTO_MOTIF) && (timestamp >= current_dest_drag->start_time)) { - private = (GdkDragContextPrivate *)current_dest_drag; + private = PRIVATE_DATA (current_dest_drag); event->dnd.type = GDK_DRAG_MOTION; event->dnd.context = current_dest_drag; @@ -1689,7 +1740,7 @@ motif_operation_changed (GdkEvent *event, guint16 flags, guint32 timestamp) { - GdkDragContextPrivate *private; + GdkDragContextPrivateX11 *private; GDK_NOTE(DND, g_message ("Motif DND operation changed: flags: %#4x time: %d", flags, timestamp)); @@ -1704,7 +1755,7 @@ motif_operation_changed (GdkEvent *event, gdk_drag_context_ref (current_dest_drag); event->dnd.time = timestamp; - private = (GdkDragContextPrivate *)current_dest_drag; + private = PRIVATE_DATA (current_dest_drag); motif_dnd_translate_flags (current_dest_drag, flags); @@ -1768,7 +1819,7 @@ motif_drag_status (GdkEvent *event, if (context) { - GdkDragContextPrivate *private = (GdkDragContextPrivate *)context; + GdkDragContextPrivateX11 *private = PRIVATE_DATA (context); if ((private->drag_status == GDK_DRAG_STATUS_MOTION_WAIT) || (private->drag_status == GDK_DRAG_STATUS_ACTION_WAIT)) private->drag_status = GDK_DRAG_STATUS_DRAG; @@ -1967,7 +2018,7 @@ xdnd_status_filter (GdkXEvent *xev, context = gdk_drag_context_find (TRUE, xevent->xclient.window, dest_window); if (context) { - GdkDragContextPrivate *private = (GdkDragContextPrivate *)context; + GdkDragContextPrivateX11 *private = PRIVATE_DATA (context); if (private->drag_status == GDK_DRAG_STATUS_MOTION_WAIT) private->drag_status = GDK_DRAG_STATUS_DRAG; @@ -2020,7 +2071,7 @@ xdnd_finished_filter (GdkXEvent *xev, static void xdnd_set_targets (GdkDragContext *context) { - GdkDragContextPrivate *private = (GdkDragContextPrivate *)context; + GdkDragContextPrivateX11 *private = PRIVATE_DATA (context); GdkAtom *atomlist; GList *tmp_list = context->targets; gint i; @@ -2049,7 +2100,7 @@ xdnd_set_targets (GdkDragContext *context) static void xdnd_set_actions (GdkDragContext *context) { - GdkDragContextPrivate *private = (GdkDragContextPrivate *)context; + GdkDragContextPrivateX11 *private = PRIVATE_DATA (context); GdkAtom *atomlist; gint i; gint n_atoms; @@ -2119,7 +2170,7 @@ static void xdnd_send_enter (GdkDragContext *context) { XEvent xev; - GdkDragContextPrivate *private = (GdkDragContextPrivate *)context; + GdkDragContextPrivateX11 *private = PRIVATE_DATA (context); xev.xclient.type = ClientMessage; xev.xclient.message_type = gdk_atom_intern ("XdndEnter", FALSE); @@ -2171,7 +2222,7 @@ xdnd_send_leave (GdkDragContext *context) { XEvent xev; - GdkDragContextPrivate *private = (GdkDragContextPrivate *)context; + GdkDragContextPrivateX11 *private = PRIVATE_DATA (context); xev.xclient.type = ClientMessage; xev.xclient.message_type = gdk_atom_intern ("XdndLeave", FALSE); @@ -2199,7 +2250,7 @@ xdnd_send_leave (GdkDragContext *context) static void xdnd_send_drop (GdkDragContext *context, guint32 time) { - GdkDragContextPrivate *private = (GdkDragContextPrivate *)context; + GdkDragContextPrivateX11 *private = PRIVATE_DATA (context); XEvent xev; xev.xclient.type = ClientMessage; @@ -2232,7 +2283,7 @@ xdnd_send_motion (GdkDragContext *context, GdkDragAction action, guint32 time) { - GdkDragContextPrivate *private = (GdkDragContextPrivate *)context; + GdkDragContextPrivateX11 *private = PRIVATE_DATA (context); XEvent xev; xev.xclient.type = ClientMessage; @@ -2365,7 +2416,7 @@ xdnd_read_actions (GdkDragContext *context) for (i=0; i<nitems; i++) context->actions |= xdnd_action_from_atom (data[i]); - ((GdkDragContextPrivate *)context)->xdnd_have_actions = TRUE; + (PRIVATE_DATA (context))->xdnd_have_actions = TRUE; #ifdef G_ENABLE_DEBUG if (gdk_debug_flags & GDK_DEBUG_DND) @@ -2423,16 +2474,10 @@ xdnd_manage_source_filter (GdkDragContext *context, gboolean add_filter) { gint old_warnings = 0; /* quiet gcc */ - - gboolean is_foreign = GDK_DRAWABLE_TYPE (window); - if (is_foreign) - { - old_warnings = gdk_error_warnings; - gdk_error_warnings = 0; - } + gdk_error_trap_push (); - if (!GDK_DRAWABLE_DESTROYED (window)) + if (!GDK_WINDOW_DESTROYED (window)) { if (add_filter) { @@ -2454,11 +2499,8 @@ xdnd_manage_source_filter (GdkDragContext *context, } } - if (is_foreign) - { - gdk_flush(); - gdk_error_warnings = old_warnings; - } + gdk_flush (); + gdk_error_trap_pop (); } static GdkFilterReturn @@ -2558,7 +2600,7 @@ xdnd_enter_filter (GdkXEvent *xev, gdk_drag_context_ref (new_context); current_dest_drag = new_context; - ((GdkDragContextPrivate *)new_context)->xdnd_selection = + (PRIVATE_DATA (new_context))->xdnd_selection = gdk_atom_intern ("XdndSelection", FALSE); return GDK_FILTER_TRANSLATE; @@ -2620,14 +2662,14 @@ xdnd_position_filter (GdkXEvent *xev, event->dnd.time = time; current_dest_drag->suggested_action = xdnd_action_from_atom (action); - if (!((GdkDragContextPrivate *)current_dest_drag)->xdnd_have_actions) + if (!(PRIVATE_DATA (current_dest_drag))->xdnd_have_actions) current_dest_drag->actions = current_dest_drag->suggested_action; event->dnd.x_root = x_root; event->dnd.y_root = y_root; - ((GdkDragContextPrivate *)current_dest_drag)->last_x = x_root; - ((GdkDragContextPrivate *)current_dest_drag)->last_y = y_root; + (PRIVATE_DATA (current_dest_drag))->last_x = x_root; + (PRIVATE_DATA (current_dest_drag))->last_y = y_root; return GDK_FILTER_TRANSLATE; } @@ -2652,8 +2694,8 @@ xdnd_drop_filter (GdkXEvent *xev, (current_dest_drag->protocol == GDK_DRAG_PROTO_XDND) && (GDK_DRAWABLE_XID (current_dest_drag->source_window) == source_window)) { - GdkDragContextPrivate *private; - private = (GdkDragContextPrivate *)current_dest_drag; + GdkDragContextPrivateX11 *private; + private = PRIVATE_DATA (current_dest_drag); event->dnd.type = GDK_DROP_START; @@ -2843,7 +2885,7 @@ gdk_drag_find_window (GdkDragContext *context, GdkWindow **dest_window, GdkDragProtocol *protocol) { - GdkDragContextPrivate *private = (GdkDragContextPrivate *)context; + GdkDragContextPrivateX11 *private = PRIVATE_DATA (context); Window dest; g_return_if_fail (context != NULL); @@ -2899,7 +2941,7 @@ gdk_drag_motion (GdkDragContext *context, GdkDragAction possible_actions, guint32 time) { - GdkDragContextPrivate *private = (GdkDragContextPrivate *)context; + GdkDragContextPrivateX11 *private = PRIVATE_DATA (context); g_return_val_if_fail (context != NULL, FALSE); @@ -3073,12 +3115,12 @@ gdk_drag_status (GdkDragContext *context, GdkDragAction action, guint32 time) { - GdkDragContextPrivate *private; + GdkDragContextPrivateX11 *private; XEvent xev; g_return_if_fail (context != NULL); - private = (GdkDragContextPrivate *)context; + private = PRIVATE_DATA (context); context->action = action; @@ -3167,11 +3209,11 @@ gdk_drop_reply (GdkDragContext *context, gboolean ok, guint32 time) { - GdkDragContextPrivate *private; + GdkDragContextPrivateX11 *private; g_return_if_fail (context != NULL); - private = (GdkDragContextPrivate *)context; + private = PRIVATE_DATA (context); if (context->protocol == GDK_DRAG_PROTO_MOTIF) { @@ -3291,9 +3333,9 @@ gdk_drag_get_selection (GdkDragContext *context) g_return_val_if_fail (context != NULL, GDK_NONE); if (context->protocol == GDK_DRAG_PROTO_MOTIF) - return ((GdkDragContextPrivate *)context)->motif_selection; + return (PRIVATE_DATA (context))->motif_selection; else if (context->protocol == GDK_DRAG_PROTO_XDND) - return ((GdkDragContextPrivate *)context)->xdnd_selection; + return (PRIVATE_DATA (context))->xdnd_selection; else return GDK_NONE; } diff --git a/gdk/x11/gdkdrawable-x11.c b/gdk/x11/gdkdrawable-x11.c index 91cc77647a..6ed59558af 100644 --- a/gdk/x11/gdkdrawable-x11.c +++ b/gdk/x11/gdkdrawable-x11.c @@ -26,161 +26,196 @@ #include "gdkprivate-x11.h" #include <pango/pangox.h> +#include <config.h> -static void gdk_x11_drawable_destroy (GdkDrawable *drawable); - -static void gdk_x11_draw_rectangle (GdkDrawable *drawable, - GdkGC *gc, - gint filled, - gint x, - gint y, - gint width, - gint height); -static void gdk_x11_draw_arc (GdkDrawable *drawable, - GdkGC *gc, - gint filled, - gint x, - gint y, - gint width, - gint height, - gint angle1, - gint angle2); -static void gdk_x11_draw_polygon (GdkDrawable *drawable, - GdkGC *gc, - gint filled, - GdkPoint *points, - gint npoints); -static void gdk_x11_draw_text (GdkDrawable *drawable, - GdkFont *font, - GdkGC *gc, - gint x, - gint y, - const gchar *text, - gint text_length); -static void gdk_x11_draw_text_wc (GdkDrawable *drawable, - GdkFont *font, - GdkGC *gc, - gint x, - gint y, - const GdkWChar *text, - gint text_length); -static void gdk_x11_draw_drawable (GdkDrawable *drawable, - GdkGC *gc, - GdkPixmap *src, - gint xsrc, - gint ysrc, - gint xdest, - gint ydest, - gint width, - gint height); -static void gdk_x11_draw_points (GdkDrawable *drawable, - GdkGC *gc, - GdkPoint *points, - gint npoints); -static void gdk_x11_draw_segments (GdkDrawable *drawable, - GdkGC *gc, - GdkSegment *segs, - gint nsegs); -static void gdk_x11_draw_lines (GdkDrawable *drawable, - GdkGC *gc, - GdkPoint *points, - gint npoints); -static void gdk_x11_draw_glyphs (GdkDrawable *drawable, - GdkGC *gc, - PangoFont *font, - gint x, - gint y, - PangoGlyphString *glyphs); - -GdkDrawableClass _gdk_x11_drawable_class = { - gdk_x11_drawable_destroy, - _gdk_x11_gc_new, - gdk_x11_draw_rectangle, - gdk_x11_draw_arc, - gdk_x11_draw_polygon, - gdk_x11_draw_text, - gdk_x11_draw_text_wc, - gdk_x11_draw_drawable, - gdk_x11_draw_points, - gdk_x11_draw_segments, - gdk_x11_draw_lines, - gdk_x11_draw_glyphs, -}; +#include <stdlib.h> -/***************************************************** - * X11 specific implementations of generic functions * - *****************************************************/ +#if defined (HAVE_IPC_H) && defined (HAVE_SHM_H) && defined (HAVE_XSHM_H) +#define USE_SHM +#endif -GdkColormap* -gdk_drawable_get_colormap (GdkDrawable *drawable) +#ifdef USE_SHM +#include <X11/extensions/XShm.h> +#endif /* USE_SHM */ + +#include "gdkprivate-x11.h" +#include "gdkdrawable-x11.h" +#include "gdkpixmap-x11.h" + +static void gdk_x11_draw_rectangle (GdkDrawable *drawable, + GdkGC *gc, + gint filled, + gint x, + gint y, + gint width, + gint height); +static void gdk_x11_draw_arc (GdkDrawable *drawable, + GdkGC *gc, + gint filled, + gint x, + gint y, + gint width, + gint height, + gint angle1, + gint angle2); +static void gdk_x11_draw_polygon (GdkDrawable *drawable, + GdkGC *gc, + gint filled, + GdkPoint *points, + gint npoints); +static void gdk_x11_draw_text (GdkDrawable *drawable, + GdkFont *font, + GdkGC *gc, + gint x, + gint y, + const gchar *text, + gint text_length); +static void gdk_x11_draw_text_wc (GdkDrawable *drawable, + GdkFont *font, + GdkGC *gc, + gint x, + gint y, + const GdkWChar *text, + gint text_length); +static void gdk_x11_draw_drawable (GdkDrawable *drawable, + GdkGC *gc, + GdkPixmap *src, + gint xsrc, + gint ysrc, + gint xdest, + gint ydest, + gint width, + gint height); +static void gdk_x11_draw_points (GdkDrawable *drawable, + GdkGC *gc, + GdkPoint *points, + gint npoints); +static void gdk_x11_draw_segments (GdkDrawable *drawable, + GdkGC *gc, + GdkSegment *segs, + gint nsegs); +static void gdk_x11_draw_lines (GdkDrawable *drawable, + GdkGC *gc, + GdkPoint *points, + gint npoints); +static void gdk_x11_draw_glyphs (GdkDrawable *drawable, + GdkGC *gc, + PangoFont *font, + gint x, + gint y, + PangoGlyphString *glyphs); +static void gdk_x11_draw_image (GdkDrawable *drawable, + GdkGC *gc, + GdkImage *image, + gint xsrc, + gint ysrc, + gint xdest, + gint ydest, + gint width, + gint height); + +static void gdk_x11_set_colormap (GdkDrawable *drawable, + GdkColormap *colormap); + +static GdkColormap* gdk_x11_get_colormap (GdkDrawable *drawable); + +static gint gdk_x11_get_depth (GdkDrawable *drawable); + +static void gdk_drawable_impl_x11_class_init (GdkDrawableImplX11Class *klass); + +static gpointer parent_class = NULL; + +GType +gdk_drawable_impl_x11_get_type (void) { - 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); - } + static GType object_type = 0; - return drawable_private->colormap; + if (!object_type) + { + static const GTypeInfo object_info = + { + sizeof (GdkDrawableImplX11Class), + (GBaseInitFunc) NULL, + (GBaseFinalizeFunc) NULL, + (GClassInitFunc) gdk_drawable_impl_x11_class_init, + NULL, /* class_finalize */ + NULL, /* class_data */ + sizeof (GdkDrawableImplX11), + 0, /* n_preallocs */ + (GInstanceInitFunc) NULL, + }; + + object_type = g_type_register_static (GDK_TYPE_DRAWABLE, + "GdkDrawableImplX11", + &object_info); } - return NULL; + return object_type; } -void -gdk_drawable_set_colormap (GdkDrawable *drawable, - GdkColormap *colormap) +static void +gdk_drawable_impl_x11_class_init (GdkDrawableImplX11Class *klass) { - GdkDrawablePrivate *drawable_private; - GdkColormapPrivateX *colormap_private; - - g_return_if_fail (drawable != NULL); - g_return_if_fail (colormap != NULL); + GdkDrawableClass *drawable_class = GDK_DRAWABLE_CLASS (klass); + + parent_class = g_type_class_peek_parent (klass); + + drawable_class->create_gc = _gdk_x11_gc_new; + drawable_class->draw_rectangle = gdk_x11_draw_rectangle; + drawable_class->draw_arc = gdk_x11_draw_arc; + drawable_class->draw_polygon = gdk_x11_draw_polygon; + drawable_class->draw_text = gdk_x11_draw_text; + drawable_class->draw_text_wc = gdk_x11_draw_text_wc; + drawable_class->draw_drawable = gdk_x11_draw_drawable; + drawable_class->draw_points = gdk_x11_draw_points; + drawable_class->draw_segments = gdk_x11_draw_segments; + drawable_class->draw_lines = gdk_x11_draw_lines; + drawable_class->draw_glyphs = gdk_x11_draw_glyphs; + drawable_class->draw_image = gdk_x11_draw_image; - drawable_private = (GdkDrawablePrivate *)drawable; - colormap_private = (GdkColormapPrivateX *)colormap; - - if (!GDK_DRAWABLE_DESTROYED (drawable)) - { - if (GDK_IS_WINDOW (drawable)) - { - g_return_if_fail (colormap_private->base.visual != - ((GdkColormapPrivate *)(drawable_private->colormap))->visual); + drawable_class->set_colormap = gdk_x11_set_colormap; + drawable_class->get_colormap = gdk_x11_get_colormap; - XSetWindowColormap (GDK_DRAWABLE_XDISPLAY (drawable), - GDK_DRAWABLE_XID (drawable), - colormap_private->xcolormap); - } + drawable_class->get_depth = gdk_x11_get_depth; +} - if (drawable_private->colormap) - gdk_colormap_unref (drawable_private->colormap); - drawable_private->colormap = colormap; - gdk_colormap_ref (drawable_private->colormap); +/***************************************************** + * X11 specific implementations of generic functions * + *****************************************************/ - if (GDK_IS_WINDOW (drawable) && - drawable_private->window_type != GDK_WINDOW_TOPLEVEL) - gdk_window_add_colormap_windows (drawable); - } +static GdkColormap* +gdk_x11_get_colormap (GdkDrawable *drawable) +{ + GdkDrawableImplX11 *impl; + + impl = GDK_DRAWABLE_IMPL_X11 (drawable); + + return impl->colormap; } -/* Drawing - */ -static void -gdk_x11_drawable_destroy (GdkDrawable *drawable) +static void +gdk_x11_set_colormap (GdkDrawable *drawable, + GdkColormap *colormap) { + GdkDrawableImplX11 *impl; + + g_return_if_fail (colormap != NULL); + + impl = GDK_DRAWABLE_IMPL_X11 (drawable); + + if (impl->colormap == colormap) + return; + if (impl->colormap) + gdk_colormap_unref (impl->colormap); + impl->colormap = colormap; + if (impl->colormap) + gdk_colormap_ref (impl->colormap); } +/* Drawing + */ + static void gdk_x11_draw_rectangle (GdkDrawable *drawable, GdkGC *gc, @@ -190,11 +225,15 @@ gdk_x11_draw_rectangle (GdkDrawable *drawable, gint width, gint height) { + GdkDrawableImplX11 *impl; + + impl = GDK_DRAWABLE_IMPL_X11 (drawable); + if (filled) - XFillRectangle (GDK_DRAWABLE_XDISPLAY (drawable), GDK_DRAWABLE_XID (drawable), + XFillRectangle (impl->xdisplay, impl->xid, GDK_GC_GET_XGC (gc), x, y, width, height); else - XDrawRectangle (GDK_DRAWABLE_XDISPLAY (drawable), GDK_DRAWABLE_XID (drawable), + XDrawRectangle (impl->xdisplay, impl->xid, GDK_GC_GET_XGC (gc), x, y, width, height); } @@ -209,11 +248,16 @@ gdk_x11_draw_arc (GdkDrawable *drawable, gint angle1, gint angle2) { + GdkDrawableImplX11 *impl; + + impl = GDK_DRAWABLE_IMPL_X11 (drawable); + + if (filled) - XFillArc (GDK_DRAWABLE_XDISPLAY (drawable), GDK_DRAWABLE_XID (drawable), + XFillArc (impl->xdisplay, impl->xid, GDK_GC_GET_XGC (gc), x, y, width, height, angle1, angle2); else - XDrawArc (GDK_DRAWABLE_XDISPLAY (drawable), GDK_DRAWABLE_XID (drawable), + XDrawArc (impl->xdisplay, impl->xid, GDK_GC_GET_XGC (gc), x, y, width, height, angle1, angle2); } @@ -226,7 +270,11 @@ gdk_x11_draw_polygon (GdkDrawable *drawable, { XPoint *tmp_points; gint tmp_npoints, i; + GdkDrawableImplX11 *impl; + impl = GDK_DRAWABLE_IMPL_X11 (drawable); + + if (!filled && (points[0].x != points[npoints-1].x || points[0].y != points[npoints-1].y)) { @@ -248,10 +296,10 @@ gdk_x11_draw_polygon (GdkDrawable *drawable, } if (filled) - XFillPolygon (GDK_DRAWABLE_XDISPLAY (drawable), GDK_DRAWABLE_XID (drawable), + XFillPolygon (impl->xdisplay, impl->xid, GDK_GC_GET_XGC (gc), tmp_points, tmp_npoints, Complex, CoordModeOrigin); else - XDrawLines (GDK_DRAWABLE_XDISPLAY (drawable), GDK_DRAWABLE_XID (drawable), + XDrawLines (impl->xdisplay, impl->xid, GDK_GC_GET_XGC (gc), tmp_points, tmp_npoints, CoordModeOrigin); g_free (tmp_points); @@ -272,25 +320,29 @@ gdk_x11_draw_text (GdkDrawable *drawable, const gchar *text, gint text_length) { + GdkDrawableImplX11 *impl; + + impl = GDK_DRAWABLE_IMPL_X11 (drawable); + if (font->type == GDK_FONT_FONT) { XFontStruct *xfont = (XFontStruct *) GDK_FONT_XFONT (font); - XSetFont(GDK_DRAWABLE_XDISPLAY (drawable), GDK_GC_GET_XGC (gc), xfont->fid); + XSetFont(impl->xdisplay, GDK_GC_GET_XGC (gc), xfont->fid); if ((xfont->min_byte1 == 0) && (xfont->max_byte1 == 0)) { - XDrawString (GDK_DRAWABLE_XDISPLAY (drawable), GDK_DRAWABLE_XID (drawable), + XDrawString (impl->xdisplay, impl->xid, GDK_GC_GET_XGC (gc), x, y, text, text_length); } else { - XDrawString16 (GDK_DRAWABLE_XDISPLAY (drawable), GDK_DRAWABLE_XID (drawable), + XDrawString16 (impl->xdisplay, impl->xid, GDK_GC_GET_XGC (gc), x, y, (XChar2b *) text, text_length / 2); } } else if (font->type == GDK_FONT_FONTSET) { XFontSet fontset = (XFontSet) GDK_FONT_XFONT (font); - XmbDrawString (GDK_DRAWABLE_XDISPLAY (drawable), GDK_DRAWABLE_XID (drawable), + XmbDrawString (impl->xdisplay, impl->xid, fontset, GDK_GC_GET_XGC (gc), x, y, text, text_length); } else @@ -306,15 +358,19 @@ gdk_x11_draw_text_wc (GdkDrawable *drawable, const GdkWChar *text, gint text_length) { + GdkDrawableImplX11 *impl; + + impl = GDK_DRAWABLE_IMPL_X11 (drawable); + if (font->type == GDK_FONT_FONT) { XFontStruct *xfont = (XFontStruct *) GDK_FONT_XFONT (font); gchar *text_8bit; gint i; - XSetFont(GDK_DRAWABLE_XDISPLAY (drawable), GDK_GC_GET_XGC (gc), xfont->fid); + XSetFont(impl->xdisplay, GDK_GC_GET_XGC (gc), xfont->fid); text_8bit = g_new (gchar, text_length); for (i=0; i<text_length; i++) text_8bit[i] = text[i]; - XDrawString (GDK_DRAWABLE_XDISPLAY (drawable), GDK_DRAWABLE_XID (drawable), + XDrawString (impl->xdisplay, impl->xid, GDK_GC_GET_XGC (gc), x, y, text_8bit, text_length); g_free (text_8bit); } @@ -322,7 +378,7 @@ gdk_x11_draw_text_wc (GdkDrawable *drawable, { if (sizeof(GdkWChar) == sizeof(wchar_t)) { - XwcDrawString (GDK_DRAWABLE_XDISPLAY (drawable), GDK_DRAWABLE_XID (drawable), + XwcDrawString (impl->xdisplay, impl->xid, (XFontSet) GDK_FONT_XFONT (font), GDK_GC_GET_XGC (gc), x, y, (wchar_t *)text, text_length); } @@ -332,7 +388,7 @@ gdk_x11_draw_text_wc (GdkDrawable *drawable, gint i; text_wchar = g_new (wchar_t, text_length); for (i=0; i<text_length; i++) text_wchar[i] = text[i]; - XwcDrawString (GDK_DRAWABLE_XDISPLAY (drawable), GDK_DRAWABLE_XID (drawable), + XwcDrawString (impl->xdisplay, impl->xid, (XFontSet) GDK_FONT_XFONT (font), GDK_GC_GET_XGC (gc), x, y, text_wchar, text_length); g_free (text_wchar); @@ -355,12 +411,15 @@ gdk_x11_draw_drawable (GdkDrawable *drawable, { int src_depth = gdk_drawable_get_depth (src); int dest_depth = gdk_drawable_get_depth (drawable); + GdkDrawableImplX11 *impl; + impl = GDK_DRAWABLE_IMPL_X11 (drawable); + if (src_depth == 1) { - XCopyArea (GDK_DRAWABLE_XDISPLAY (drawable), + XCopyArea (impl->xdisplay, GDK_DRAWABLE_XID (src), - GDK_DRAWABLE_XID (drawable), + impl->xid, GDK_GC_GET_XGC (gc), xsrc, ysrc, width, height, @@ -368,9 +427,9 @@ gdk_x11_draw_drawable (GdkDrawable *drawable, } else if (dest_depth != 0 && src_depth == dest_depth) { - XCopyArea (GDK_DRAWABLE_XDISPLAY (drawable), + XCopyArea (impl->xdisplay, GDK_DRAWABLE_XID (src), - GDK_DRAWABLE_XID (drawable), + impl->xid, GDK_GC_GET_XGC (gc), xsrc, ysrc, width, height, @@ -386,13 +445,18 @@ gdk_x11_draw_points (GdkDrawable *drawable, GdkPoint *points, gint npoints) { + GdkDrawableImplX11 *impl; + + impl = GDK_DRAWABLE_IMPL_X11 (drawable); + + /* We special-case npoints == 1, because X will merge multiple * consecutive XDrawPoint requests into a PolyPoint request */ if (npoints == 1) { - XDrawPoint (GDK_DRAWABLE_XDISPLAY (drawable), - GDK_DRAWABLE_XID (drawable), + XDrawPoint (impl->xdisplay, + impl->xid, GDK_GC_GET_XGC (gc), points[0].x, points[0].y); } @@ -407,8 +471,8 @@ gdk_x11_draw_points (GdkDrawable *drawable, tmp_points[i].y = points[i].y; } - XDrawPoints (GDK_DRAWABLE_XDISPLAY (drawable), - GDK_DRAWABLE_XID (drawable), + XDrawPoints (impl->xdisplay, + impl->xid, GDK_GC_GET_XGC (gc), tmp_points, npoints, @@ -424,12 +488,17 @@ gdk_x11_draw_segments (GdkDrawable *drawable, GdkSegment *segs, gint nsegs) { + GdkDrawableImplX11 *impl; + + impl = GDK_DRAWABLE_IMPL_X11 (drawable); + + /* We special-case nsegs == 1, because X will merge multiple * consecutive XDrawLine requests into a PolySegment request */ if (nsegs == 1) { - XDrawLine (GDK_DRAWABLE_XDISPLAY (drawable), GDK_DRAWABLE_XID (drawable), + XDrawLine (impl->xdisplay, impl->xid, GDK_GC_GET_XGC (gc), segs[0].x1, segs[0].y1, segs[0].x2, segs[0].y2); } @@ -446,8 +515,8 @@ gdk_x11_draw_segments (GdkDrawable *drawable, tmp_segs[i].y2 = segs[i].y2; } - XDrawSegments (GDK_DRAWABLE_XDISPLAY (drawable), - GDK_DRAWABLE_XID (drawable), + XDrawSegments (impl->xdisplay, + impl->xid, GDK_GC_GET_XGC (gc), tmp_segs, nsegs); @@ -463,15 +532,19 @@ gdk_x11_draw_lines (GdkDrawable *drawable, { gint i; XPoint *tmp_points = g_new (XPoint, npoints); + GdkDrawableImplX11 *impl; + + impl = GDK_DRAWABLE_IMPL_X11 (drawable); + for (i=0; i<npoints; i++) { tmp_points[i].x = points[i].x; tmp_points[i].y = points[i].y; } - XDrawLines (GDK_DRAWABLE_XDISPLAY (drawable), - GDK_DRAWABLE_XID (drawable), + XDrawLines (impl->xdisplay, + impl->xid, GDK_GC_GET_XGC (gc), tmp_points, npoints, CoordModeOrigin); @@ -487,8 +560,46 @@ gdk_x11_draw_glyphs (GdkDrawable *drawable, gint y, PangoGlyphString *glyphs) { - pango_x_render (GDK_DRAWABLE_XDISPLAY (drawable), - GDK_DRAWABLE_XID (drawable), + GdkDrawableImplX11 *impl; + + impl = GDK_DRAWABLE_IMPL_X11 (drawable); + + pango_x_render (impl->xdisplay, + impl->xid, GDK_GC_GET_XGC (gc), font, glyphs, x, y); } + +static void +gdk_x11_draw_image (GdkDrawable *drawable, + GdkGC *gc, + GdkImage *image, + gint xsrc, + gint ysrc, + gint xdest, + gint ydest, + gint width, + gint height) +{ + GdkDrawableImplX11 *impl; + + impl = GDK_DRAWABLE_IMPL_X11 (drawable); + + if (image->type == GDK_IMAGE_SHARED) + XShmPutImage (impl->xdisplay, impl->xid, + GDK_GC_GET_XGC (gc), GDK_IMAGE_XIMAGE (image), + xsrc, ysrc, xdest, ydest, width, height, False); + else + XPutImage (impl->xdisplay, impl->xid, + GDK_GC_GET_XGC (gc), GDK_IMAGE_XIMAGE (image), + xsrc, ysrc, xdest, ydest, width, height); +} + +static gint +gdk_x11_get_depth (GdkDrawable *drawable) +{ + /* This is a bit bogus but I'm not sure the other way is better */ + + return gdk_drawable_get_depth (GDK_DRAWABLE_IMPL_X11 (drawable)->wrapper); +} + diff --git a/gdk/x11/gdkdrawable-x11.h b/gdk/x11/gdkdrawable-x11.h new file mode 100644 index 0000000000..d0e3d552e1 --- /dev/null +++ b/gdk/x11/gdkdrawable-x11.h @@ -0,0 +1,73 @@ +/* GDK - The GIMP Drawing Kit + * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +/* + * Modified by the GTK+ Team and others 1997-1999. See the AUTHORS + * file for a list of people on the GTK+ Team. See the ChangeLog + * files for a list of changes. These files are distributed with + * GTK+ at ftp://ftp.gtk.org/pub/gtk/. + */ + +#ifndef __GDK_DRAWABLE_X11_H__ +#define __GDK_DRAWABLE_X11_H__ + +#include <gdk/gdkdrawable.h> + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/* Drawable implementation for X11 + */ + +typedef struct _GdkDrawableImplX11 GdkDrawableImplX11; +typedef struct _GdkDrawableImplX11Class GdkDrawableImplX11Class; + +#define GDK_TYPE_DRAWABLE_IMPL_X11 (gdk_drawable_impl_x11_get_type ()) +#define GDK_DRAWABLE_IMPL_X11(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_DRAWABLE_IMPL_X11, GdkDrawableImplX11)) +#define GDK_DRAWABLE_IMPL_X11_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_DRAWABLE_IMPL_X11, GdkDrawableImplX11Class)) +#define GDK_IS_DRAWABLE_IMPL_X11(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_DRAWABLE_IMPL_X11)) +#define GDK_IS_DRAWABLE_IMPL_X11_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_DRAWABLE_IMPL_X11)) +#define GDK_DRAWABLE_IMPL_X11_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_DRAWABLE_IMPL_X11, GdkDrawableImplX11Class)) + +struct _GdkDrawableImplX11 +{ + GdkDrawable parent_instance; + + GdkDrawable *wrapper; + + GdkColormap *colormap; + + Window xid; + Display *xdisplay; +}; + +struct _GdkDrawableImplX11Class +{ + GdkDrawableClass parent_class; + +}; + +GType gdk_drawable_impl_x11_get_type (void); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* __GDK_DRAWABLE_X11_H__ */ diff --git a/gdk/x11/gdkevents-x11.c b/gdk/x11/gdkevents-x11.c index 7036b96cec..b9e0285c50 100644 --- a/gdk/x11/gdkevents-x11.c +++ b/gdk/x11/gdkevents-x11.c @@ -261,7 +261,7 @@ gdk_event_translate (GdkEvent *event, { GdkWindow *window; - GdkWindowPrivate *window_private; + GdkWindowObject *window_private; static XComposeStatus compose; KeySym keysym; int charcount; @@ -297,7 +297,7 @@ gdk_event_translate (GdkEvent *event, window = gdk_window_lookup (xevent->xany.window); /* FIXME: window might be a GdkPixmap!!! */ - window_private = (GdkWindowPrivate *) window; + window_private = (GdkWindowObject *) window; if (window != NULL) gdk_window_ref (window); @@ -305,10 +305,10 @@ gdk_event_translate (GdkEvent *event, event->any.window = window; event->any.send_event = xevent->xany.send_event ? TRUE : FALSE; - if (window_private && GDK_DRAWABLE_DESTROYED (window)) + if (window_private && GDK_WINDOW_DESTROYED (window)) { if (xevent->type != DestroyNotify) - return FALSE; + return FALSE; } else { @@ -329,7 +329,7 @@ gdk_event_translate (GdkEvent *event, #ifdef USE_XIM if (window == NULL && gdk_xim_window && xevent->type == KeyPress && - !GDK_DRAWABLE_DESTROYED (gdk_xim_window)) + !GDK_WINDOW_DESTROYED (gdk_xim_window)) { /* * If user presses a key in Preedit or Status window, keypress event @@ -344,7 +344,7 @@ gdk_event_translate (GdkEvent *event, GdkFilterReturn result; window = gdk_xim_window; - window_private = (GdkWindowPrivate *) window; + window_private = (GdkWindowObject *) window; gdk_window_ref (window); event->any.window = window; @@ -626,7 +626,7 @@ gdk_event_translate (GdkEvent *event, /* Tell XInput stuff about it if appropriate */ if (window_private && - !GDK_DRAWABLE_DESTROYED (window) && + !GDK_WINDOW_DESTROYED (window) && (window_private->extension_events != 0) && gdk_input_vtable.enter_event) gdk_input_vtable.enter_event (&xevent->xcrossing, window); @@ -937,9 +937,9 @@ gdk_event_translate (GdkEvent *event, event->any.type = GDK_DESTROY; event->any.window = window; - return_val = window_private && !GDK_DRAWABLE_DESTROYED (window); + return_val = window_private && !GDK_WINDOW_DESTROYED (window); - if (window && GDK_DRAWABLE_XID (window) != GDK_ROOT_WINDOW()) + if (window && GDK_WINDOW_XID (window) != GDK_ROOT_WINDOW()) gdk_window_destroy_notify (window); break; @@ -992,16 +992,16 @@ gdk_event_translate (GdkEvent *event, xevent->xconfigure.override_redirect, !window ? " (discarding)" - : GDK_DRAWABLE_TYPE (window) == GDK_WINDOW_CHILD + : GDK_WINDOW_TYPE (window) == GDK_WINDOW_CHILD ? " (discarding child)" : "")); if (window && - !GDK_DRAWABLE_DESTROYED (window) && + !GDK_WINDOW_DESTROYED (window) && (window_private->extension_events != 0) && gdk_input_vtable.configure_event) gdk_input_vtable.configure_event (&xevent->xconfigure, window); - if (!window || GDK_DRAWABLE_TYPE (window) == GDK_WINDOW_CHILD) + if (!window || GDK_WINDOW_TYPE (window) == GDK_WINDOW_CHILD) return_val = FALSE; else { @@ -1012,7 +1012,7 @@ gdk_event_translate (GdkEvent *event, if (!xevent->xconfigure.x && !xevent->xconfigure.y && - !GDK_DRAWABLE_DESTROYED (window)) + !GDK_WINDOW_DESTROYED (window)) { gint tx = 0; gint ty = 0; @@ -1042,8 +1042,8 @@ gdk_event_translate (GdkEvent *event, } window_private->x = event->configure.x; window_private->y = event->configure.y; - window_private->drawable.width = xevent->xconfigure.width; - window_private->drawable.height = xevent->xconfigure.height; + GDK_WINDOW_IMPL_X11 (window_private->impl)->width = xevent->xconfigure.width; + GDK_WINDOW_IMPL_X11 (window_private->impl)->height = xevent->xconfigure.height; if (window_private->resize_count > 1) window_private->resize_count -= 1; } @@ -1177,7 +1177,7 @@ gdk_event_translate (GdkEvent *event, /* something else - (e.g., a Xinput event) */ if (window_private && - !window_private->drawable.destroyed && + !GDK_WINDOW_DESTROYED (window_private) && (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/gdkgc-x11.c b/gdk/x11/gdkgc-x11.c index e68eaab9a1..80e285f856 100644 --- a/gdk/x11/gdkgc-x11.c +++ b/gdk/x11/gdkgc-x11.c @@ -12,8 +12,7 @@ static void gdk_x11_gc_values_to_xvalues (GdkGCValues *values, XGCValues *xvalues, unsigned long *xvalues_mask, gboolean initial); - -static void gdk_x11_gc_destroy (GdkGC *gc); + static void gdk_x11_gc_get_values (GdkGC *gc, GdkGCValues *values); static void gdk_x11_gc_set_values (GdkGC *gc, @@ -21,15 +20,70 @@ static void gdk_x11_gc_set_values (GdkGC *gc, GdkGCValuesMask values_mask); static void gdk_x11_gc_set_dashes (GdkGC *gc, gint dash_offset, - gchar dash_list[], + gint8 dash_list[], gint n); -static GdkGCClass gdk_x11_gc_class = { - gdk_x11_gc_destroy, - gdk_x11_gc_get_values, - gdk_x11_gc_set_values, - gdk_x11_gc_set_dashes -}; +static void gdk_gc_x11_class_init (GdkGCX11Class *klass); +static void gdk_gc_x11_finalize (GObject *object); + +static gpointer parent_class = NULL; + +GType +gdk_gc_x11_get_type (void) +{ + static GType object_type = 0; + + if (!object_type) + { + static const GTypeInfo object_info = + { + sizeof (GdkGCX11Class), + (GBaseInitFunc) NULL, + (GBaseFinalizeFunc) NULL, + (GClassInitFunc) gdk_gc_x11_class_init, + NULL, /* class_finalize */ + NULL, /* class_data */ + sizeof (GdkGCX11), + 0, /* n_preallocs */ + (GInstanceInitFunc) NULL, + }; + + object_type = g_type_register_static (GDK_TYPE_GC, + "GdkGCX11", + &object_info); + } + + return object_type; +} + +static void +gdk_gc_x11_class_init (GdkGCX11Class *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + GdkGCClass *gc_class = GDK_GC_CLASS (klass); + + parent_class = g_type_class_peek_parent (klass); + + object_class->finalize = gdk_gc_x11_finalize; + + gc_class->get_values = gdk_x11_gc_get_values; + gc_class->set_values = gdk_x11_gc_set_values; + gc_class->set_dashes = gdk_x11_gc_set_dashes; +} + +static void +gdk_gc_x11_finalize (GObject *object) +{ + GdkGCX11 *x11_gc = GDK_GC_X11 (object); + + if (x11_gc->clip_region) + gdk_region_destroy (x11_gc->clip_region); + + XFreeGC (GDK_GC_XDISPLAY (x11_gc), GDK_GC_XGC (x11_gc)); + + G_OBJECT_CLASS (parent_class)->finalize (object); +} + GdkGC * _gdk_x11_gc_new (GdkDrawable *drawable, @@ -37,33 +91,34 @@ _gdk_x11_gc_new (GdkDrawable *drawable, GdkGCValuesMask values_mask) { GdkGC *gc; - GdkGCPrivate *private; - GdkGCXData *data; + GdkGCX11 *private; XGCValues xvalues; unsigned long xvalues_mask; - gc = gdk_gc_alloc (); - private = (GdkGCPrivate *)gc; + /* NOTICE that the drawable here has to be the impl drawable, + * not the publically-visible drawables. + */ + g_return_val_if_fail (GDK_IS_DRAWABLE_IMPL_X11 (drawable), NULL); - private->klass = &gdk_x11_gc_class; - private->klass_data = data = g_new (GdkGCXData, 1); + gc = GDK_GC (g_type_create_instance (gdk_gc_x11_get_type ())); + private = GDK_GC_X11 (gc); - data->dirty_mask = 0; - data->clip_region = NULL; + private->dirty_mask = 0; + private->clip_region = NULL; - GDK_GC_XDATA (gc)->xdisplay = GDK_DRAWABLE_XDISPLAY (drawable); + private->xdisplay = GDK_DRAWABLE_IMPL_X11 (drawable)->xdisplay; if (values_mask & (GDK_GC_CLIP_X_ORIGIN | GDK_GC_CLIP_Y_ORIGIN)) { values_mask &= ~(GDK_GC_CLIP_X_ORIGIN | GDK_GC_CLIP_Y_ORIGIN); - data->dirty_mask |= GDK_GC_DIRTY_CLIP; + private->dirty_mask |= GDK_GC_DIRTY_CLIP; } if (values_mask & (GDK_GC_TS_X_ORIGIN | GDK_GC_TS_Y_ORIGIN)) { values_mask &= ~(GDK_GC_TS_X_ORIGIN | GDK_GC_TS_Y_ORIGIN); - data->dirty_mask |= GDK_GC_DIRTY_TS; + private->dirty_mask |= GDK_GC_DIRTY_TS; } xvalues.function = GXcopy; @@ -75,62 +130,51 @@ _gdk_x11_gc_new (GdkDrawable *drawable, gdk_x11_gc_values_to_xvalues (values, values_mask, &xvalues, &xvalues_mask, TRUE); - data->xgc = XCreateGC (GDK_GC_XDISPLAY (gc), - GDK_DRAWABLE_XID (drawable), - xvalues_mask, &xvalues); + private->xgc = XCreateGC (GDK_GC_XDISPLAY (gc), + GDK_DRAWABLE_IMPL_X11 (drawable)->xid, + xvalues_mask, &xvalues); return gc; } -static void -gdk_x11_gc_destroy (GdkGC *gc) -{ - if (GDK_GC_XDATA (gc)->clip_region) - gdk_region_destroy (GDK_GC_XDATA (gc)->clip_region); - - XFreeGC (GDK_GC_XDISPLAY (gc), GDK_GC_XGC (gc)); - g_free (GDK_GC_XDATA (gc)); -} - GC _gdk_x11_gc_flush (GdkGC *gc) { - GdkGCPrivate *private = (GdkGCPrivate *)gc; - GdkGCXData *data = GDK_GC_XDATA (gc); + GdkGCX11 *private = GDK_GC_X11 (gc); - if (data->dirty_mask & GDK_GC_DIRTY_CLIP) + if (private->dirty_mask & GDK_GC_DIRTY_CLIP) { - if (!data->clip_region) + if (!private->clip_region) XSetClipOrigin (GDK_GC_XDISPLAY (gc), GDK_GC_XGC (gc), - private->clip_x_origin, private->clip_y_origin); + gc->clip_x_origin, gc->clip_y_origin); else { - XRectangle *rectangles = g_new (XRectangle, data->clip_region->numRects); - GdkRegionBox *boxes = data->clip_region->rects; + XRectangle *rectangles = g_new (XRectangle, private->clip_region->numRects); + GdkRegionBox *boxes = private->clip_region->rects; int i; - for (i=0; i<data->clip_region->numRects; i++) + for (i=0; i<private->clip_region->numRects; i++) { - rectangles[i].x = CLAMP (boxes[i].x1 + private->clip_x_origin, G_MINSHORT, G_MAXSHORT); - rectangles[i].y = CLAMP (boxes[i].y1 + private->clip_y_origin, G_MINSHORT, G_MAXSHORT); - rectangles[i].width = CLAMP (boxes[i].x2 + private->clip_x_origin, G_MINSHORT, G_MAXSHORT) - rectangles[i].x; - rectangles[i].height = CLAMP (boxes[i].y2 + private->clip_y_origin, G_MINSHORT, G_MAXSHORT) - rectangles[i].y; + rectangles[i].x = CLAMP (boxes[i].x1 + gc->clip_x_origin, G_MINSHORT, G_MAXSHORT); + rectangles[i].y = CLAMP (boxes[i].y1 + gc->clip_y_origin, G_MINSHORT, G_MAXSHORT); + rectangles[i].width = CLAMP (boxes[i].x2 + gc->clip_x_origin, G_MINSHORT, G_MAXSHORT) - rectangles[i].x; + rectangles[i].height = CLAMP (boxes[i].y2 + gc->clip_y_origin, G_MINSHORT, G_MAXSHORT) - rectangles[i].y; } XSetClipRectangles(GDK_GC_XDISPLAY (gc), GDK_GC_XGC (gc), 0, 0, rectangles, - data->clip_region->numRects, YXBanded); + private->clip_region->numRects, YXBanded); g_free (rectangles); } } - if (data->dirty_mask & GDK_GC_DIRTY_TS) + if (private->dirty_mask & GDK_GC_DIRTY_TS) { XSetTSOrigin (GDK_GC_XDISPLAY (gc), GDK_GC_XGC (gc), - private->ts_x_origin, private->ts_y_origin); + gc->ts_x_origin, gc->ts_y_origin); } - data->dirty_mask = 0; + private->dirty_mask = 0; return GDK_GC_XGC (gc); } @@ -286,32 +330,32 @@ gdk_x11_gc_set_values (GdkGC *gc, GdkGCValues *values, GdkGCValuesMask values_mask) { - GdkGCXData *data; + GdkGCX11 *x11_gc; XGCValues xvalues; unsigned long xvalues_mask = 0; - g_return_if_fail (gc != NULL); + g_return_if_fail (GDK_IS_GC (gc)); - data = GDK_GC_XDATA (gc); + x11_gc = GDK_GC_X11 (gc); if (values_mask & (GDK_GC_CLIP_X_ORIGIN | GDK_GC_CLIP_Y_ORIGIN)) { values_mask &= ~(GDK_GC_CLIP_X_ORIGIN | GDK_GC_CLIP_Y_ORIGIN); - data->dirty_mask |= GDK_GC_DIRTY_CLIP; + x11_gc->dirty_mask |= GDK_GC_DIRTY_CLIP; } if (values_mask & (GDK_GC_TS_X_ORIGIN | GDK_GC_TS_Y_ORIGIN)) { values_mask &= ~(GDK_GC_TS_X_ORIGIN | GDK_GC_TS_Y_ORIGIN); - data->dirty_mask |= GDK_GC_DIRTY_TS; + x11_gc->dirty_mask |= GDK_GC_DIRTY_TS; } if (values_mask & GDK_GC_CLIP_MASK) { - if (data->clip_region) + if (x11_gc->clip_region) { - gdk_region_destroy (data->clip_region); - data->clip_region = NULL; + gdk_region_destroy (x11_gc->clip_region); + x11_gc->clip_region = NULL; } } @@ -326,10 +370,10 @@ gdk_x11_gc_set_values (GdkGC *gc, static void gdk_x11_gc_set_dashes (GdkGC *gc, gint dash_offset, - gchar dash_list[], + gint8 dash_list[], gint n) { - g_return_if_fail (gc != NULL); + g_return_if_fail (GDK_IS_GC (gc)); g_return_if_fail (dash_list != NULL); XSetDashes (GDK_GC_XDISPLAY (gc), GDK_GC_XGC (gc), @@ -343,6 +387,17 @@ gdk_x11_gc_values_to_xvalues (GdkGCValues *values, unsigned long *xvalues_mask, gboolean initial) { + if (mask & GDK_GC_EXPOSURES) + xvalues->graphics_exposures = values->graphics_exposures; + else + xvalues->graphics_exposures = False; + *xvalues_mask |= GCGraphicsExposures; + + /* Optimization for the common case (gdk_gc_new()) */ + if (values == NULL || + mask == 0) + return; + if (mask & GDK_GC_FOREGROUND) { xvalues->foreground = values->foreground.pixel; @@ -560,64 +615,62 @@ void gdk_gc_set_clip_rectangle (GdkGC *gc, GdkRectangle *rectangle) { - GdkGCPrivate *private = (GdkGCPrivate *)gc; - GdkGCXData *data; + GdkGCX11 *x11_gc; - g_return_if_fail (gc != NULL); + g_return_if_fail (GDK_IS_GC (gc)); - data = GDK_GC_XDATA (gc); + x11_gc = GDK_GC_X11 (gc); - if (data->clip_region) - gdk_region_destroy (data->clip_region); + if (x11_gc->clip_region) + gdk_region_destroy (x11_gc->clip_region); if (rectangle) - data->clip_region = gdk_region_rectangle (rectangle); + x11_gc->clip_region = gdk_region_rectangle (rectangle); else { - data->clip_region = NULL; + x11_gc->clip_region = NULL; XSetClipMask (GDK_GC_XDISPLAY (gc), GDK_GC_XGC (gc), None); } - private->clip_x_origin = 0; - private->clip_y_origin = 0; + gc->clip_x_origin = 0; + gc->clip_y_origin = 0; - data->dirty_mask |= GDK_GC_DIRTY_CLIP; + x11_gc->dirty_mask |= GDK_GC_DIRTY_CLIP; } void gdk_gc_set_clip_region (GdkGC *gc, GdkRegion *region) { - GdkGCPrivate *private = (GdkGCPrivate *)gc; - GdkGCXData *data; + GdkGCX11 *x11_gc; - g_return_if_fail (gc != NULL); + g_return_if_fail (GDK_IS_GC (gc)); - data = GDK_GC_XDATA (gc); + x11_gc = GDK_GC_X11 (gc); - if (data->clip_region) - gdk_region_destroy (data->clip_region); + if (x11_gc->clip_region) + gdk_region_destroy (x11_gc->clip_region); if (region) - data->clip_region = gdk_region_copy (region); + x11_gc->clip_region = gdk_region_copy (region); else { - data->clip_region = NULL; + x11_gc->clip_region = NULL; XSetClipMask (GDK_GC_XDISPLAY (gc), GDK_GC_XGC (gc), None); } - private->clip_x_origin = 0; - private->clip_y_origin = 0; + gc->clip_x_origin = 0; + gc->clip_y_origin = 0; - data->dirty_mask |= GDK_GC_DIRTY_CLIP; + x11_gc->dirty_mask |= GDK_GC_DIRTY_CLIP; } void gdk_gc_copy (GdkGC *dst_gc, GdkGC *src_gc) { - g_return_if_fail (dst_gc != NULL); - g_return_if_fail (src_gc != NULL); + g_return_if_fail (GDK_IS_GC_X11 (dst_gc)); + g_return_if_fail (GDK_IS_GC_X11 (src_gc)); XCopyGC (GDK_GC_XDISPLAY (src_gc), GDK_GC_XGC (src_gc), ~((~1) << GCLastBit), GDK_GC_XGC (dst_gc)); diff --git a/gdk/x11/gdkgeometry-x11.c b/gdk/x11/gdkgeometry-x11.c index 8bf26453f3..5cf3129462 100644 --- a/gdk/x11/gdkgeometry-x11.c +++ b/gdk/x11/gdkgeometry-x11.c @@ -62,10 +62,10 @@ struct _GdkWindowParentPos GdkRectangle clip_rect; }; -static void gdk_window_compute_position (GdkWindow *window, +static void gdk_window_compute_position (GdkWindowImplX11 *window, GdkWindowParentPos *parent_pos, GdkXPositionInfo *info); -static void gdk_window_compute_parent_pos (GdkWindow *window, +static void gdk_window_compute_parent_pos (GdkWindowImplX11 *window, GdkWindowParentPos *parent_pos); static void gdk_window_premove (GdkWindow *window, GdkWindowParentPos *parent_pos); @@ -87,27 +87,26 @@ _gdk_windowing_window_get_offsets (GdkWindow *window, gint *x_offset, gint *y_offset) { - GdkWindowPrivate *private = (GdkWindowPrivate *)window; - GdkWindowXData *data = (GdkWindowXData *)private->drawable.klass_data; + GdkWindowImplX11 *impl = + GDK_WINDOW_IMPL_X11 (GDK_WINDOW_OBJECT (window)->impl); - *x_offset = data->position_info.x_offset; - *y_offset = data->position_info.y_offset; + *x_offset = impl->position_info.x_offset; + *y_offset = impl->position_info.y_offset; } void _gdk_window_init_position (GdkWindow *window) { - GdkWindowPrivate *private = (GdkWindowPrivate *)window; - GdkWindowXData *data; GdkWindowParentPos parent_pos; - - g_return_if_fail (window != NULL); + GdkWindowImplX11 *impl; + g_return_if_fail (GDK_IS_WINDOW (window)); - - data = (GdkWindowXData *)private->drawable.klass_data; - - gdk_window_compute_parent_pos (window, &parent_pos); - gdk_window_compute_position (window, &parent_pos, &data->position_info); + + impl = + GDK_WINDOW_IMPL_X11 (GDK_WINDOW_OBJECT (window)->impl); + + gdk_window_compute_parent_pos (impl, &parent_pos); + gdk_window_compute_position (impl, &parent_pos, &impl->position_info); } /** @@ -131,33 +130,33 @@ gdk_window_scroll (GdkWindow *window, gint dx, gint dy) { - GdkWindowPrivate *private = (GdkWindowPrivate *)window; gboolean can_guffaw_scroll = FALSE; - GdkWindowXData *data; + GdkWindowImplX11 *impl; + GdkWindowObject *obj; - g_return_if_fail (window != NULL); g_return_if_fail (GDK_IS_WINDOW (window)); - if (GDK_DRAWABLE_DESTROYED (window)) + obj = GDK_WINDOW_OBJECT (window); + + impl = GDK_WINDOW_IMPL_X11 (obj->impl); + + if (GDK_WINDOW_DESTROYED (window)) return; - data = (GdkWindowXData *)private->drawable.klass_data; - /* We can guffaw scroll if we are a child window, and the parent * does not extend beyond our edges. */ - - if (GDK_DRAWABLE_TYPE (private) == GDK_WINDOW_CHILD) + + if (GDK_WINDOW_TYPE (window) == GDK_WINDOW_CHILD) { - GdkWindowPrivate *parent_private = (GdkWindowPrivate *)private->parent; - - can_guffaw_scroll = (private->x <= 0 && - private->y <= 0 && - private->x + private->drawable.width >= parent_private->drawable.width && - private->y + private->drawable.height >= parent_private->drawable.height); + GdkWindowImplX11 *parent_impl = GDK_WINDOW_IMPL_X11 (obj->parent->impl); + can_guffaw_scroll = (obj->x <= 0 && + obj->y <= 0 && + obj->x + impl->width >= parent_impl->width && + obj->y + impl->height >= parent_impl->height); } - if (!private->children || !can_guffaw_scroll) + if (!obj->children || !can_guffaw_scroll) { /* Use XCopyArea, then move any children later */ @@ -165,12 +164,12 @@ gdk_window_scroll (GdkWindow *window, GdkRegion *invalidate_region; GdkRectangle dest_rect; - invalidate_region = gdk_region_rectangle (&data->position_info.clip_rect); + invalidate_region = gdk_region_rectangle (&impl->position_info.clip_rect); - dest_rect = data->position_info.clip_rect; + dest_rect = impl->position_info.clip_rect; dest_rect.x += dx; dest_rect.y += dy; - gdk_rectangle_intersect (&dest_rect, &data->position_info.clip_rect, &dest_rect); + gdk_rectangle_intersect (&dest_rect, &impl->position_info.clip_rect, &dest_rect); if (dest_rect.width > 0 && dest_rect.height > 0) { @@ -185,29 +184,30 @@ gdk_window_scroll (GdkWindow *window, gdk_window_queue_translation (window, dx, dy); values.graphics_exposures = True; - gc = XCreateGC (GDK_DRAWABLE_XDISPLAY (window), GDK_DRAWABLE_XID (window), + gc = XCreateGC (GDK_WINDOW_XDISPLAY (window), + GDK_WINDOW_XID (window), GCGraphicsExposures, &values); - XCopyArea (GDK_DRAWABLE_XDISPLAY (window), - GDK_DRAWABLE_XID (window), - GDK_DRAWABLE_XID (window), + XCopyArea (GDK_WINDOW_XDISPLAY (window), + GDK_WINDOW_XID (window), + GDK_WINDOW_XID (window), gc, dest_rect.x - dx, dest_rect.y - dy, dest_rect.width, dest_rect.height, dest_rect.x, dest_rect.y); - XFreeGC (GDK_DRAWABLE_XDISPLAY (window), gc); + XFreeGC (GDK_WINDOW_XDISPLAY (window), gc); } gdk_window_invalidate_region (window, invalidate_region, TRUE); gdk_region_destroy (invalidate_region); - tmp_list = private->children; + tmp_list = obj->children; while (tmp_list) { - private = tmp_list->data; + GdkWindow * child = GDK_WINDOW (tmp_list->data); - gdk_window_move (tmp_list->data, private->x + dx, private->y + dy); + gdk_window_move (child, obj->x + dx, obj->y + dy); tmp_list = tmp_list->next; } @@ -227,10 +227,10 @@ _gdk_window_move_resize_child (GdkWindow *window, gint width, gint height) { - GdkWindowPrivate *private = (GdkWindowPrivate *)window; + GdkWindowImplX11 *impl; + GdkWindowObject *obj; GdkXPositionInfo new_info; GdkWindowParentPos parent_pos; - GdkWindowXData *data; GList *tmp_list; gint d_xoffset, d_yoffset; @@ -241,35 +241,36 @@ _gdk_window_move_resize_child (GdkWindow *window, g_return_if_fail (window != NULL); g_return_if_fail (GDK_IS_WINDOW (window)); - data = (GdkWindowXData *)private->drawable.klass_data; - - dx = x - private->x; - dy = y - private->y; + impl = GDK_WINDOW_IMPL_X11 (GDK_WINDOW_OBJECT (window)->impl); + obj = GDK_WINDOW_OBJECT (window); + + dx = x - obj->x; + dy = y - obj->y; is_move = dx != 0 || dy != 0; - is_resize = private->drawable.width != width || private->drawable.height != height; + is_resize = impl->width != width || impl->height != height; if (!is_move && !is_resize) return; - private->x = x; - private->y = y; - private->drawable.width = width; - private->drawable.height = height; + obj->x = x; + obj->y = y; + impl->width = width; + impl->height = height; - gdk_window_compute_parent_pos (window, &parent_pos); - gdk_window_compute_position (window, &parent_pos, &new_info); + gdk_window_compute_parent_pos (impl, &parent_pos); + gdk_window_compute_position (impl, &parent_pos, &new_info); - gdk_window_clip_changed (window, &data->position_info.clip_rect, &new_info.clip_rect); + gdk_window_clip_changed (window, &impl->position_info.clip_rect, &new_info.clip_rect); - parent_pos.x += private->x; - parent_pos.y += private->y; + parent_pos.x += obj->x; + parent_pos.y += obj->y; parent_pos.x11_x += new_info.x; parent_pos.x11_y += new_info.y; parent_pos.clip_rect = new_info.clip_rect; - d_xoffset = new_info.x_offset - data->position_info.x_offset; - d_yoffset = new_info.y_offset - data->position_info.y_offset; + d_xoffset = new_info.x_offset - impl->position_info.x_offset; + d_yoffset = new_info.y_offset - impl->position_info.y_offset; if (d_xoffset != 0 || d_yoffset != 0) { @@ -282,57 +283,57 @@ _gdk_window_move_resize_child (GdkWindow *window, if (d_xoffset < 0) { - new_x0 = data->position_info.x + d_xoffset; - new_x1 = data->position_info.x + data->position_info.width; + new_x0 = impl->position_info.x + d_xoffset; + new_x1 = impl->position_info.x + impl->position_info.width; } else { - new_x0 = data->position_info.x; - new_x1 = data->position_info.x + new_info.width + d_xoffset; + new_x0 = impl->position_info.x; + new_x1 = impl->position_info.x + new_info.width + d_xoffset; } if (d_yoffset < 0) { - new_y0 = data->position_info.y + d_yoffset; - new_y1 = data->position_info.y + data->position_info.height; + new_y0 = impl->position_info.y + d_yoffset; + new_y1 = impl->position_info.y + impl->position_info.height; } else { - new_y0 = data->position_info.y; - new_y1 = data->position_info.y + new_info.height + d_yoffset; + new_y0 = impl->position_info.y; + new_y1 = impl->position_info.y + new_info.height + d_yoffset; } - XMoveResizeWindow (GDK_DRAWABLE_XDISPLAY (window), - GDK_DRAWABLE_XID (window), + XMoveResizeWindow (GDK_WINDOW_XDISPLAY (window), + GDK_WINDOW_XID (window), new_x0, new_y0, new_x1 - new_x0, new_y1 - new_y0); - tmp_list = private->children; + tmp_list = obj->children; while (tmp_list) { gdk_window_premove (tmp_list->data, &parent_pos); tmp_list = tmp_list->next; } - XMoveWindow (GDK_DRAWABLE_XDISPLAY (window), - GDK_DRAWABLE_XID (window), + XMoveWindow (GDK_WINDOW_XDISPLAY (window), + GDK_WINDOW_XID (window), new_x0 + dx, new_y0 + dy); if (d_xoffset > 0 || d_yoffset > 0) gdk_window_queue_translation (window, MAX (d_xoffset, 0), MAX (d_yoffset, 0)); - XMoveResizeWindow (GDK_DRAWABLE_XDISPLAY (window), - GDK_DRAWABLE_XID (window), + XMoveResizeWindow (GDK_WINDOW_XDISPLAY (window), + GDK_WINDOW_XID (window), new_info.x, new_info.y, new_info.width, new_info.height); - if (data->position_info.no_bg) + if (impl->position_info.no_bg) gdk_window_tmp_reset_bg (window); - if (!data->position_info.mapped && new_info.mapped && private->mapped) - XMapWindow (GDK_DRAWABLE_XDISPLAY (window), GDK_DRAWABLE_XID (window)); + if (!impl->position_info.mapped && new_info.mapped && obj->mapped) + XMapWindow (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XID (window)); - data->position_info = new_info; + impl->position_info = new_info; - tmp_list = private->children; + tmp_list = obj->children; while (tmp_list) { gdk_window_postmove (tmp_list->data, &parent_pos); @@ -344,10 +345,10 @@ _gdk_window_move_resize_child (GdkWindow *window, if (is_move && is_resize) gdk_window_set_static_gravities (window, FALSE); - if (data->position_info.mapped && !new_info.mapped) - XUnmapWindow (GDK_DRAWABLE_XDISPLAY (window), GDK_DRAWABLE_XID (window)); + if (impl->position_info.mapped && !new_info.mapped) + XUnmapWindow (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XID (window)); - tmp_list = private->children; + tmp_list = obj->children; while (tmp_list) { gdk_window_premove (tmp_list->data, &parent_pos); @@ -355,87 +356,91 @@ _gdk_window_move_resize_child (GdkWindow *window, } if (is_resize) - XMoveResizeWindow (GDK_DRAWABLE_XDISPLAY (window), - GDK_DRAWABLE_XID (window), + XMoveResizeWindow (GDK_WINDOW_XDISPLAY (window), + GDK_WINDOW_XID (window), new_info.x, new_info.y, new_info.width, new_info.height); else - XMoveWindow (GDK_DRAWABLE_XDISPLAY (window), - GDK_DRAWABLE_XID (window), + XMoveWindow (GDK_WINDOW_XDISPLAY (window), + GDK_WINDOW_XID (window), new_info.x, new_info.y); - tmp_list = private->children; + tmp_list = obj->children; while (tmp_list) { gdk_window_postmove (tmp_list->data, &parent_pos); tmp_list = tmp_list->next; } - if (data->position_info.no_bg) + if (impl->position_info.no_bg) gdk_window_tmp_reset_bg (window); - if (!data->position_info.mapped && new_info.mapped && private->mapped) - XMapWindow (GDK_DRAWABLE_XDISPLAY (window), GDK_DRAWABLE_XID (window)); + if (!impl->position_info.mapped && new_info.mapped && obj->mapped) + XMapWindow (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XID (window)); - data->position_info = new_info; + impl->position_info = new_info; } } static void -gdk_window_compute_position (GdkWindow *window, +gdk_window_compute_position (GdkWindowImplX11 *window, GdkWindowParentPos *parent_pos, GdkXPositionInfo *info) { - GdkWindowPrivate *private = (GdkWindowPrivate *)window; + GdkWindowObject *wrapper; int parent_x_offset; int parent_y_offset; + + g_return_if_fail (GDK_IS_WINDOW_IMPL_X11 (window)); + + wrapper = GDK_WINDOW_OBJECT (GDK_DRAWABLE_IMPL_X11 (window)->wrapper); info->big = FALSE; - if (private->drawable.width <= 32768) + if (window->width <= 32768) { - info->width = private->drawable.width; - info->x = parent_pos->x + private->x - parent_pos->x11_x; + info->width = window->width; + info->x = parent_pos->x + wrapper->x - parent_pos->x11_x; } else { info->big = TRUE; info->width = 32768; - if (parent_pos->x + private->x < -16384) + if (parent_pos->x + wrapper->x < -16384) { - if (parent_pos->x + private->x + private->drawable.width < 16384) - info->x = parent_pos->x + private->x + private->drawable.width - 32768 - parent_pos->x11_x; + if (parent_pos->x + wrapper->x + window->width < 16384) + info->x = parent_pos->x + wrapper->x + window->width - 32768 - parent_pos->x11_x; else info->x = -16384 - parent_pos->x11_y; } else - info->x = parent_pos->x + private->x - parent_pos->x11_x; + info->x = parent_pos->x + wrapper->x - parent_pos->x11_x; } - if (private->drawable.height <= 32768) + if (window->height <= 32768) { - info->height = private->drawable.height; - info->y = parent_pos->y + private->y - parent_pos->x11_y; + info->height = window->height; + info->y = parent_pos->y + wrapper->y - parent_pos->x11_y; } else { info->big = TRUE; info->height = 32768; - if (parent_pos->y + private->y < -16384) + if (parent_pos->y + wrapper->y < -16384) { - if (parent_pos->y + private->y + private->drawable.height < 16384) - info->y = parent_pos->y + private->y + private->drawable.height - 32768 - parent_pos->x11_y; + if (parent_pos->y + wrapper->y + window->height < 16384) + info->y = parent_pos->y + wrapper->y + window->height - 32768 - parent_pos->x11_y; else info->y = -16384 - parent_pos->x11_y; } else - info->y = parent_pos->y + private->y - parent_pos->x11_y; + info->y = parent_pos->y + wrapper->y - parent_pos->x11_y; } parent_x_offset = parent_pos->x11_x - parent_pos->x; parent_y_offset = parent_pos->x11_y - parent_pos->y; - info->x_offset = parent_x_offset + info->x - private->x; - info->y_offset = parent_y_offset + info->y - private->y; + info->x_offset = parent_x_offset + info->x - wrapper->x; + info->y_offset = parent_y_offset + info->y - wrapper->y; /* We don't considering the clipping of toplevel windows and their immediate children * by their parents, and simply always map those windows. @@ -446,24 +451,24 @@ gdk_window_compute_position (GdkWindow *window, else if (info->x + parent_x_offset < parent_pos->clip_rect.x + parent_pos->clip_rect.width - 65536 || info->x + info->width + parent_x_offset > parent_pos->clip_rect.x + 65536 || info->y + parent_y_offset < parent_pos->clip_rect.y + parent_pos->clip_rect.height - 65536 || - info->y + info->width + parent_y_offset > parent_pos->clip_rect.y + 65536) + info->y + info->height + parent_y_offset > parent_pos->clip_rect.y + 65536) info->mapped = FALSE; else info->mapped = TRUE; info->no_bg = FALSE; - if (GDK_DRAWABLE_TYPE (private) == GDK_WINDOW_CHILD) + if (GDK_WINDOW_TYPE (wrapper) == GDK_WINDOW_CHILD) { - info->clip_rect.x = private->x; - info->clip_rect.y = private->y; - info->clip_rect.width = private->drawable.width; - info->clip_rect.height = private->drawable.height; + info->clip_rect.x = wrapper->x; + info->clip_rect.y = wrapper->y; + info->clip_rect.width = window->width; + info->clip_rect.height = window->height; gdk_rectangle_intersect (&info->clip_rect, &parent_pos->clip_rect, &info->clip_rect); - info->clip_rect.x -= private->x; - info->clip_rect.y -= private->y; + info->clip_rect.x -= wrapper->x; + info->clip_rect.y -= wrapper->y; } else { @@ -475,16 +480,21 @@ gdk_window_compute_position (GdkWindow *window, } static void -gdk_window_compute_parent_pos (GdkWindow *window, +gdk_window_compute_parent_pos (GdkWindowImplX11 *window, GdkWindowParentPos *parent_pos) { - GdkWindowPrivate *private = (GdkWindowPrivate *)window; - GdkWindowXData *data; + GdkWindowObject *wrapper; + GdkWindowObject *parent; GdkRectangle tmp_clip; int clip_xoffset = 0; int clip_yoffset = 0; + g_return_if_fail (GDK_IS_WINDOW_IMPL_X11 (window)); + + wrapper = + GDK_WINDOW_OBJECT (GDK_DRAWABLE_IMPL_X11 (window)->wrapper); + parent_pos->x = 0; parent_pos->y = 0; parent_pos->x11_x = 0; @@ -506,27 +516,27 @@ gdk_window_compute_parent_pos (GdkWindow *window, parent_pos->clip_rect.width = G_MAXINT; parent_pos->clip_rect.height = G_MAXINT; - private = (GdkWindowPrivate *)private->parent; - while (private && private->drawable.window_type == GDK_WINDOW_CHILD) + parent = (GdkWindowObject *)wrapper->parent; + while (parent && parent->window_type == GDK_WINDOW_CHILD) { - data = (GdkWindowXData *)private->drawable.klass_data; - + GdkWindowImplX11 *impl = GDK_WINDOW_IMPL_X11 (parent->impl); + tmp_clip.x = - clip_xoffset; tmp_clip.y = - clip_yoffset; - tmp_clip.width = private->drawable.width; - tmp_clip.height = private->drawable.height; + tmp_clip.width = impl->width; + tmp_clip.height = impl->height; gdk_rectangle_intersect (&parent_pos->clip_rect, &tmp_clip, &parent_pos->clip_rect); - parent_pos->x += private->x; - parent_pos->y += private->y; - parent_pos->x11_x += data->position_info.x; - parent_pos->x11_y += data->position_info.y; + parent_pos->x += parent->x; + parent_pos->y += parent->y; + parent_pos->x11_x += impl->position_info.x; + parent_pos->x11_y += impl->position_info.y; - clip_xoffset += private->x; - clip_yoffset += private->y; + clip_xoffset += parent->x; + clip_yoffset += parent->y; - private = (GdkWindowPrivate *)private->parent; + parent = (GdkWindowObject *)parent->parent; } } @@ -534,28 +544,31 @@ static void gdk_window_premove (GdkWindow *window, GdkWindowParentPos *parent_pos) { - GdkWindowPrivate *private = (GdkWindowPrivate *)window; - GdkWindowXData *data = GDK_WINDOW_XDATA (window); + GdkWindowImplX11 *impl; + GdkWindowObject *obj; GdkXPositionInfo new_info; GList *tmp_list; gint d_xoffset, d_yoffset; GdkWindowParentPos this_pos; + + obj = (GdkWindowObject *) window; + impl = GDK_WINDOW_IMPL_X11 (obj->impl); - gdk_window_compute_position (window, parent_pos, &new_info); + gdk_window_compute_position (impl, parent_pos, &new_info); - gdk_window_clip_changed (window, &data->position_info.clip_rect, &new_info.clip_rect); + gdk_window_clip_changed (window, &impl->position_info.clip_rect, &new_info.clip_rect); - this_pos.x = parent_pos->x + private->x; - this_pos.y = parent_pos->y + private->y; + this_pos.x = parent_pos->x + obj->x; + this_pos.y = parent_pos->y + obj->y; this_pos.x11_x = parent_pos->x11_x + new_info.x; this_pos.x11_y = parent_pos->x11_y + new_info.y; this_pos.clip_rect = new_info.clip_rect; - if (data->position_info.mapped && !new_info.mapped) + if (impl->position_info.mapped && !new_info.mapped) XUnmapWindow (GDK_DRAWABLE_XDISPLAY (window), GDK_DRAWABLE_XID (window)); - d_xoffset = new_info.x_offset - data->position_info.x_offset; - d_yoffset = new_info.y_offset - data->position_info.y_offset; + d_xoffset = new_info.x_offset - impl->position_info.x_offset; + d_yoffset = new_info.y_offset - impl->position_info.y_offset; if (d_xoffset != 0 || d_yoffset != 0) { @@ -566,24 +579,24 @@ gdk_window_premove (GdkWindow *window, if (d_xoffset < 0) { - new_x0 = data->position_info.x + d_xoffset; - new_x1 = data->position_info.x + data->position_info.width; + new_x0 = impl->position_info.x + d_xoffset; + new_x1 = impl->position_info.x + impl->position_info.width; } else { - new_x0 = data->position_info.x; - new_x1 = data->position_info.x + new_info.width + d_xoffset; + new_x0 = impl->position_info.x; + new_x1 = impl->position_info.x + new_info.width + d_xoffset; } if (d_yoffset < 0) { - new_y0 = data->position_info.y + d_yoffset; - new_y1 = data->position_info.y + data->position_info.height; + new_y0 = impl->position_info.y + d_yoffset; + new_y1 = impl->position_info.y + impl->position_info.height; } else { - new_y0 = data->position_info.y; - new_y1 = data->position_info.y + new_info.height + d_yoffset; + new_y0 = impl->position_info.y; + new_y1 = impl->position_info.y + new_info.height + d_yoffset; } XMoveResizeWindow (GDK_DRAWABLE_XDISPLAY (window), @@ -591,7 +604,7 @@ gdk_window_premove (GdkWindow *window, new_x0, new_y0, new_x1 - new_x0, new_y1 - new_y0); } - tmp_list = private->children; + tmp_list = obj->children; while (tmp_list) { gdk_window_premove (tmp_list->data, &this_pos); @@ -603,23 +616,26 @@ static void gdk_window_postmove (GdkWindow *window, GdkWindowParentPos *parent_pos) { - GdkWindowPrivate *private = (GdkWindowPrivate *)window; - GdkWindowXData *data = (GdkWindowXData *)private->drawable.klass_data; + GdkWindowImplX11 *impl; + GdkWindowObject *obj; GdkXPositionInfo new_info; GList *tmp_list; gint d_xoffset, d_yoffset; GdkWindowParentPos this_pos; + + obj = (GdkWindowObject *) window; + impl = GDK_WINDOW_IMPL_X11 (obj->impl); - gdk_window_compute_position (window, parent_pos, &new_info); + gdk_window_compute_position (impl, parent_pos, &new_info); - this_pos.x = parent_pos->x + private->x; - this_pos.y = parent_pos->y + private->y; + this_pos.x = parent_pos->x + obj->x; + this_pos.y = parent_pos->y + obj->y; this_pos.x11_x = parent_pos->x11_x + new_info.x; this_pos.x11_y = parent_pos->x11_y + new_info.y; this_pos.clip_rect = new_info.clip_rect; - d_xoffset = new_info.x_offset - data->position_info.x_offset; - d_yoffset = new_info.y_offset - data->position_info.y_offset; + d_xoffset = new_info.x_offset - impl->position_info.x_offset; + d_yoffset = new_info.y_offset - impl->position_info.y_offset; if (d_xoffset != 0 || d_yoffset != 0) { @@ -631,15 +647,15 @@ gdk_window_postmove (GdkWindow *window, new_info.x, new_info.y, new_info.width, new_info.height); } - if (!data->position_info.mapped && new_info.mapped && private->mapped) + if (!impl->position_info.mapped && new_info.mapped && obj->mapped) XMapWindow (GDK_DRAWABLE_XDISPLAY (window), GDK_DRAWABLE_XID (window)); - if (data->position_info.no_bg) + if (impl->position_info.no_bg) gdk_window_tmp_reset_bg (window); - data->position_info = new_info; + impl->position_info = new_info; - tmp_list = private->children; + tmp_list = obj->children; while (tmp_list) { gdk_window_postmove (tmp_list->data, &this_pos); @@ -684,12 +700,13 @@ _gdk_window_process_expose (GdkWindow *window, gulong serial, GdkRectangle *area) { - GdkWindowXData *data = GDK_WINDOW_XDATA (window); + GdkWindowImplX11 *impl; GdkRegion *invalidate_region = gdk_region_rectangle (area); GdkRegion *clip_region; - GSList *tmp_list = translate_queue; + impl = GDK_WINDOW_IMPL_X11 (GDK_WINDOW_OBJECT (window)->impl); + while (tmp_list) { GdkWindowQueueItem *item = tmp_list->data; @@ -720,7 +737,7 @@ _gdk_window_process_expose (GdkWindow *window, } } - clip_region = gdk_region_rectangle (&data->position_info.clip_rect); + clip_region = gdk_region_rectangle (&impl->position_info.clip_rect); gdk_region_intersect (invalidate_region, clip_region); if (!gdk_region_empty (invalidate_region)) @@ -733,12 +750,15 @@ _gdk_window_process_expose (GdkWindow *window, static void gdk_window_tmp_unset_bg (GdkWindow *window) { - GdkWindowPrivate *private = (GdkWindowPrivate *)window; - GdkWindowXData *data = GDK_WINDOW_XDATA (window); + GdkWindowImplX11 *impl; + GdkWindowObject *obj; + + obj = (GdkWindowObject *) window; + impl = GDK_WINDOW_IMPL_X11 (obj->impl); - data->position_info.no_bg = TRUE; + impl->position_info.no_bg = TRUE; - if (private->bg_pixmap != GDK_NO_BG) + if (obj->bg_pixmap != GDK_NO_BG) XSetWindowBackgroundPixmap (GDK_DRAWABLE_XDISPLAY (window), GDK_DRAWABLE_XID (window), None); } @@ -746,22 +766,25 @@ gdk_window_tmp_unset_bg (GdkWindow *window) static void gdk_window_tmp_reset_bg (GdkWindow *window) { - GdkWindowPrivate *private = (GdkWindowPrivate *)window; - GdkWindowXData *data = GDK_WINDOW_XDATA (window); + GdkWindowImplX11 *impl; + GdkWindowObject *obj; - data->position_info.no_bg = FALSE; + obj = (GdkWindowObject *) window; + impl = GDK_WINDOW_IMPL_X11 (obj->impl); - if (private->bg_pixmap == GDK_NO_BG) + impl->position_info.no_bg = FALSE; + + if (obj->bg_pixmap == GDK_NO_BG) return; - if (private->bg_pixmap) + if (obj->bg_pixmap) { Pixmap xpixmap; - if (private->bg_pixmap == GDK_PARENT_RELATIVE_BG) + if (obj->bg_pixmap == GDK_PARENT_RELATIVE_BG) xpixmap = ParentRelative; else - xpixmap = GDK_DRAWABLE_XID (private->bg_pixmap); + xpixmap = GDK_DRAWABLE_XID (obj->bg_pixmap); XSetWindowBackgroundPixmap (GDK_DRAWABLE_XDISPLAY (window), GDK_DRAWABLE_XID (window), xpixmap); @@ -770,28 +793,31 @@ gdk_window_tmp_reset_bg (GdkWindow *window) { XSetWindowBackground (GDK_DRAWABLE_XDISPLAY (window), GDK_DRAWABLE_XID (window), - private->bg_color.pixel); + obj->bg_color.pixel); } } static void gdk_window_clip_changed (GdkWindow *window, GdkRectangle *old_clip, GdkRectangle *new_clip) { - GdkWindowPrivate *private = (GdkWindowPrivate *)window; - + GdkWindowImplX11 *impl; + GdkWindowObject *obj; GdkRegion *old_clip_region; GdkRegion *new_clip_region; - - if (private->input_only) + + if (((GdkWindowObject *)window)->input_only) return; - + + obj = (GdkWindowObject *) window; + impl = GDK_WINDOW_IMPL_X11 (obj->impl); + old_clip_region = gdk_region_rectangle (old_clip); new_clip_region = gdk_region_rectangle (new_clip); /* Trim invalid region of window to new clip rectangle */ - if (private->update_area) - gdk_region_intersect (private->update_area, new_clip_region); + if (obj->update_area) + gdk_region_intersect (obj->update_area, new_clip_region); /* Invalidate newly exposed portion of window */ diff --git a/gdk/x11/gdkglobals-x11.c b/gdk/x11/gdkglobals-x11.c index 9a3d6c5f95..52d284861c 100644 --- a/gdk/x11/gdkglobals-x11.c +++ b/gdk/x11/gdkglobals-x11.c @@ -50,6 +50,6 @@ GdkICPrivate *gdk_xim_ic; /* currently using IC */ #endif /* USE_XIM */ GdkWindow *gdk_xim_window; /* currently using Widow */ -GdkWindowPrivate *gdk_xgrab_window = NULL; /* Window that currently holds the - * x pointer grab - */ +GdkWindowObject *gdk_xgrab_window = NULL; /* Window that currently holds the + * x pointer grab + */ diff --git a/gdk/x11/gdkim-x11.c b/gdk/x11/gdkim-x11.c index 0d309a768d..f07f9b50c6 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 || - GDK_DRAWABLE_DESTROYED (attr->client_window)) + GDK_WINDOW_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 && - GDK_DRAWABLE_DESTROYED (attr->preedit_pixmap)) + GDK_WINDOW_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 && - GDK_DRAWABLE_DESTROYED (attr->status_pixmap)) + GDK_WINDOW_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 2972e7a4ee..e9730dba2e 100644 --- a/gdk/x11/gdkimage-x11.c +++ b/gdk/x11/gdkimage-x11.c @@ -58,37 +58,70 @@ #include "gdkprivate.h" #include "gdkprivate-x11.h" -static void gdk_x11_image_destroy (GdkImage *image); -static void gdk_image_put_normal (GdkImage *image, - GdkDrawable *drawable, - GdkGC *gc, - gint xsrc, - gint ysrc, - gint xdest, - gint ydest, - gint width, - gint height); -static void gdk_image_put_shared (GdkImage *image, - GdkDrawable *drawable, - GdkGC *gc, - gint xsrc, - gint ysrc, - gint xdest, - gint ydest, - gint width, - gint height); - -static GdkImageClass image_class_normal = { - gdk_x11_image_destroy, - gdk_image_put_normal -}; - -static GdkImageClass image_class_shared = { - gdk_x11_image_destroy, - gdk_image_put_shared -}; - static GList *image_list = NULL; +static gpointer parent_class = NULL; + +static void gdk_x11_image_destroy (GdkImage *image); +static void gdk_image_init (GdkImage *image); +static void gdk_image_class_init (GdkImageClass *klass); +static void gdk_image_finalize (GObject *object); + +#define PRIVATE_DATA(image) ((GdkImagePrivateX11 *) GDK_IMAGE (image)->windowing_data) + +GType +gdk_image_get_type (void) +{ + static GType object_type = 0; + + if (!object_type) + { + static const GTypeInfo object_info = + { + sizeof (GdkImageClass), + (GBaseInitFunc) NULL, + (GBaseFinalizeFunc) NULL, + (GClassInitFunc) gdk_image_class_init, + NULL, /* class_finalize */ + NULL, /* class_data */ + sizeof (GdkImage), + 0, /* n_preallocs */ + (GInstanceInitFunc) gdk_image_init, + }; + + object_type = g_type_register_static (G_TYPE_OBJECT, + "GdkImage", + &object_info); + } + + return object_type; +} + +static void +gdk_image_init (GdkImage *image) +{ + image->windowing_data = g_new0 (GdkImagePrivateX11, 1); + +} + +static void +gdk_image_class_init (GdkImageClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + + parent_class = g_type_class_peek_parent (klass); + + object_class->finalize = gdk_image_finalize; +} + +static void +gdk_image_finalize (GObject *object) +{ + GdkImage *image = GDK_IMAGE (object); + + gdk_x11_image_destroy (image); + + G_OBJECT_CLASS (parent_class)->finalize (object); +} void @@ -111,12 +144,10 @@ gdk_image_new_bitmap(GdkVisual *visual, gpointer data, gint w, gint h) { Visual *xvisual; GdkImage *image; - GdkImagePrivateX *private; - private = g_new(GdkImagePrivateX, 1); - image = (GdkImage *) private; + GdkImagePrivateX11 *private; + image = GDK_IMAGE (g_type_create_instance (gdk_image_get_type ())); + private = PRIVATE_DATA (image); private->xdisplay = gdk_display; - private->base.ref_count = 1; - private->base.klass = &image_class_normal; image->type = GDK_IMAGE_NORMAL; image->visual = visual; image->width = w; @@ -160,7 +191,7 @@ gdk_image_check_xshm(Display *display) } void -gdk_image_init (void) +_gdk_windowing_image_init (void) { if (gdk_use_xshm) { @@ -178,7 +209,7 @@ gdk_image_new (GdkImageType type, gint height) { GdkImage *image; - GdkImagePrivateX *private; + GdkImagePrivateX11 *private; #ifdef USE_SHM XShmSegmentInfo *x_shm_info; #endif /* USE_SHM */ @@ -194,10 +225,10 @@ gdk_image_new (GdkImageType type, break; default: - private = g_new (GdkImagePrivateX, 1); - image = (GdkImage*) private; + image = GDK_IMAGE (g_type_create_instance (gdk_image_get_type ())); + + private = PRIVATE_DATA (image); - private->base.ref_count = 1; private->xdisplay = gdk_display; image->type = type; @@ -214,8 +245,6 @@ gdk_image_new (GdkImageType type, #ifdef USE_SHM if (gdk_use_xshm) { - private->base.klass = &image_class_shared; - private->x_shm_info = g_new (XShmSegmentInfo, 1); x_shm_info = private->x_shm_info; @@ -305,8 +334,6 @@ gdk_image_new (GdkImageType type, return NULL; #endif /* USE_SHM */ case GDK_IMAGE_NORMAL: - private->base.klass = &image_class_normal; - private->ximage = XCreateImage (private->xdisplay, xvisual, visual->depth, ZPixmap, 0, 0, width, height, 32, 0); @@ -342,18 +369,16 @@ gdk_image_get (GdkWindow *window, gint height) { GdkImage *image; - GdkImagePrivateX *private; + GdkImagePrivateX11 *private; - g_return_val_if_fail (window != NULL, NULL); + g_return_val_if_fail (GDK_IS_WINDOW (window), NULL); - if (GDK_DRAWABLE_DESTROYED (window)) + if (GDK_WINDOW_DESTROYED (window)) return NULL; - private = g_new (GdkImagePrivateX, 1); - image = (GdkImage*) private; + image = GDK_IMAGE (g_type_create_instance (gdk_image_get_type ())); + private = PRIVATE_DATA (image); - private->base.ref_count = 1; - private->base.klass = &image_class_normal; private->xdisplay = gdk_display; private->ximage = XGetImage (private->xdisplay, GDK_DRAWABLE_XID (window), @@ -387,11 +412,11 @@ gdk_image_get_pixel (GdkImage *image, gint y) { guint32 pixel; - GdkImagePrivateX *private; + GdkImagePrivateX11 *private; - g_return_val_if_fail (image != NULL, 0); + g_return_val_if_fail (GDK_IS_IMAGE (image), 0); - private = (GdkImagePrivateX *) image; + private = PRIVATE_DATA (image); pixel = XGetPixel (private->ximage, x, y); @@ -404,11 +429,11 @@ gdk_image_put_pixel (GdkImage *image, gint y, guint32 pixel) { - GdkImagePrivateX *private; + GdkImagePrivateX11 *private; - g_return_if_fail (image != NULL); + g_return_if_fail (GDK_IS_IMAGE (image)); - private = (GdkImagePrivateX *) image; + private = PRIVATE_DATA (image); pixel = XPutPixel (private->ximage, x, y, pixel); } @@ -416,14 +441,21 @@ gdk_image_put_pixel (GdkImage *image, static void gdk_x11_image_destroy (GdkImage *image) { - GdkImagePrivateX *private; + GdkImagePrivateX11 *private; #ifdef USE_SHM XShmSegmentInfo *x_shm_info; #endif /* USE_SHM */ - g_return_if_fail (image != NULL); + g_return_if_fail (GDK_IS_IMAGE (image)); - private = (GdkImagePrivateX*) image; + private = PRIVATE_DATA (image); + + if (private == NULL) /* This means that gdk_image_exit() destroyed the + * image already, and now we're called a second + * time from _finalize() + */ + return; + switch (image->type) { case GDK_IMAGE_NORMAL: @@ -441,7 +473,8 @@ gdk_x11_image_destroy (GdkImage *image) shmdt (x_shm_info->shmaddr); g_free (private->x_shm_info); - + private->x_shm_info = NULL; + image_list = g_list_remove (image_list, image); #else /* USE_SHM */ g_error ("trying to destroy shared memory image when gdk was compiled without shared memory support"); @@ -453,65 +486,6 @@ gdk_x11_image_destroy (GdkImage *image) g_assert_not_reached (); } - g_free (image); -} - -static void -gdk_image_put_normal (GdkImage *image, - GdkDrawable *drawable, - GdkGC *gc, - gint xsrc, - gint ysrc, - gint xdest, - gint ydest, - gint width, - gint height) -{ - GdkImagePrivateX *image_private; - - g_return_if_fail (drawable != NULL); - g_return_if_fail (image != NULL); - g_return_if_fail (gc != NULL); - - if (GDK_DRAWABLE_DESTROYED (drawable)) - return; - image_private = (GdkImagePrivateX*) image; - - g_return_if_fail (image->type == GDK_IMAGE_NORMAL); - - XPutImage (GDK_DRAWABLE_XDISPLAY (drawable), GDK_DRAWABLE_XID (drawable), - GDK_GC_GET_XGC (gc), image_private->ximage, - xsrc, ysrc, xdest, ydest, width, height); -} - -static void -gdk_image_put_shared (GdkImage *image, - GdkDrawable *drawable, - GdkGC *gc, - gint xsrc, - gint ysrc, - gint xdest, - gint ydest, - gint width, - gint height) -{ -#ifdef USE_SHM - GdkImagePrivateX *image_private; - - g_return_if_fail (drawable != NULL); - g_return_if_fail (image != NULL); - g_return_if_fail (gc != NULL); - - if (GDK_DRAWABLE_DESTROYED (drawable)) - return; - image_private = (GdkImagePrivateX*) image; - - g_return_if_fail (image->type == GDK_IMAGE_SHARED); - - XShmPutImage (GDK_DRAWABLE_XDISPLAY (drawable), GDK_DRAWABLE_XID (drawable), - GDK_GC_GET_XGC (gc), image_private->ximage, - xsrc, ysrc, xdest, ydest, width, height, False); -#else /* USE_SHM */ - g_error ("trying to draw shared memory image when gdk was compiled without shared memory support"); -#endif /* USE_SHM */ + g_free (private); + image->windowing_data = NULL; } diff --git a/gdk/x11/gdkinput.c b/gdk/x11/gdkinput.c index cb2dd269c7..4ee51b3154 100644 --- a/gdk/x11/gdkinput.c +++ b/gdk/x11/gdkinput.c @@ -115,7 +115,7 @@ gdk_input_motion_events (GdkWindow *window, g_return_val_if_fail (window != NULL, NULL); g_return_val_if_fail (GDK_IS_WINDOW (window), NULL); - if (GDK_DRAWABLE_DESTROYED (window)) + if (GDK_WINDOW_DESTROYED (window)) return NULL; if (deviceid == GDK_CORE_POINTER) @@ -200,15 +200,15 @@ void gdk_input_set_extension_events (GdkWindow *window, gint mask, GdkExtensionMode mode) { - GdkWindowPrivate *window_private; + GdkWindowObject *window_private; GList *tmp_list; GdkInputWindow *iw; g_return_if_fail (window != NULL); g_return_if_fail (GDK_IS_WINDOW (window)); - window_private = (GdkWindowPrivate*) window; - if (GDK_DRAWABLE_DESTROYED (window)) + window_private = (GdkWindowObject*) window; + if (GDK_WINDOW_DESTROYED (window)) return; if (mode == GDK_EXTENSION_EVENTS_NONE) diff --git a/gdk/x11/gdkmain-x11.c b/gdk/x11/gdkmain-x11.c index 7ce8a3b35d..b266a67e22 100644 --- a/gdk/x11/gdkmain-x11.c +++ b/gdk/x11/gdkmain-x11.c @@ -49,6 +49,7 @@ #include "gdkprivate-x11.h" #include "gdkinternals.h" #include "gdkinputprivate.h" +#include <pango/pangox.h> typedef struct _GdkPredicate GdkPredicate; typedef struct _GdkErrorTrap GdkErrorTrap; @@ -246,12 +247,12 @@ gdk_pointer_grab (GdkWindow * window, cursor_private = (GdkCursorPrivate*) cursor; - xwindow = GDK_DRAWABLE_XID (window); + xwindow = GDK_WINDOW_XID (window); - if (!confine_to || GDK_DRAWABLE_DESTROYED (confine_to)) + if (!confine_to || GDK_WINDOW_DESTROYED (confine_to)) xconfine_to = None; else - xconfine_to = GDK_DRAWABLE_XID (confine_to); + xconfine_to = GDK_WINDOW_XID (confine_to); if (!cursor) xcursor = None; @@ -277,8 +278,8 @@ gdk_pointer_grab (GdkWindow * window, if (return_val == Success) { - if (!GDK_DRAWABLE_DESTROYED (window)) - return_val = XGrabPointer (GDK_DRAWABLE_XDISPLAY (window), + if (!GDK_WINDOW_DESTROYED (window)) + return_val = XGrabPointer (GDK_WINDOW_XDISPLAY (window), xwindow, owner_events, xevent_mask, @@ -291,7 +292,7 @@ gdk_pointer_grab (GdkWindow * window, } if (return_val == GrabSuccess) - gdk_xgrab_window = (GdkWindowPrivate *)window; + gdk_xgrab_window = (GdkWindowObject *)window; return return_val; } @@ -370,9 +371,9 @@ gdk_keyboard_grab (GdkWindow * window, g_return_val_if_fail (window != NULL, 0); g_return_val_if_fail (GDK_IS_WINDOW (window), 0); - if (!GDK_DRAWABLE_DESTROYED (window)) - return XGrabKeyboard (GDK_DRAWABLE_XDISPLAY (window), - GDK_DRAWABLE_XID (window), + if (!GDK_WINDOW_DESTROYED (window)) + return XGrabKeyboard (GDK_WINDOW_XDISPLAY (window), + GDK_WINDOW_XID (window), owner_events, GrabModeAsync, GrabModeAsync, time); diff --git a/gdk/x11/gdkpixmap-x11.c b/gdk/x11/gdkpixmap-x11.c index 326d0702be..b8ee30872a 100644 --- a/gdk/x11/gdkpixmap-x11.c +++ b/gdk/x11/gdkpixmap-x11.c @@ -32,7 +32,8 @@ #include <unistd.h> #include <X11/Xlib.h> -#include "gdkpixmap.h" +#include <gdk/gdkpixmap.h> +#include "gdkpixmap-x11.h" #include "gdkprivate-x11.h" typedef struct @@ -49,42 +50,92 @@ typedef struct gulong pixels[1]; } _GdkPixmapInfo; -GdkDrawableClass _gdk_x11_pixmap_class; +static void gdk_pixmap_impl_x11_get_size (GdkDrawable *drawable, + gint *width, + gint *height); -static void -gdk_x11_pixmap_destroy (GdkPixmap *pixmap) -{ - XFreePixmap (GDK_DRAWABLE_XDISPLAY (pixmap), GDK_DRAWABLE_XID (pixmap)); - gdk_xid_table_remove (GDK_DRAWABLE_XID (pixmap)); +static void gdk_pixmap_impl_x11_init (GdkPixmapImplX11 *pixmap); +static void gdk_pixmap_impl_x11_class_init (GdkPixmapImplX11Class *klass); +static void gdk_pixmap_impl_x11_finalize (GObject *object); - g_free (GDK_DRAWABLE_XDATA (pixmap)); -} +static gpointer parent_class = NULL; -static GdkDrawable * -gdk_x11_pixmap_alloc (void) +GType +gdk_pixmap_impl_x11_get_type (void) { - GdkDrawable *drawable; - GdkDrawablePrivate *private; - - static GdkDrawableClass klass; - static gboolean initialized = FALSE; + static GType object_type = 0; - if (!initialized) + if (!object_type) { - initialized = TRUE; + static const GTypeInfo object_info = + { + sizeof (GdkPixmapImplX11Class), + (GBaseInitFunc) NULL, + (GBaseFinalizeFunc) NULL, + (GClassInitFunc) gdk_pixmap_impl_x11_class_init, + NULL, /* class_finalize */ + NULL, /* class_data */ + sizeof (GdkPixmapImplX11), + 0, /* n_preallocs */ + (GInstanceInitFunc) gdk_pixmap_impl_x11_init, + }; - klass = _gdk_x11_drawable_class; - klass.destroy = gdk_x11_pixmap_destroy; + object_type = g_type_register_static (GDK_TYPE_DRAWABLE_IMPL_X11, + "GdkPixmapImplX11", + &object_info); } + + return object_type; +} - drawable = gdk_drawable_alloc (); - private = (GdkDrawablePrivate *)drawable; - private->klass = &klass; - private->klass_data = g_new (GdkDrawableXData, 1); - private->window_type = GDK_DRAWABLE_PIXMAP; +GType +_gdk_pixmap_impl_get_type (void) +{ + return gdk_pixmap_impl_x11_get_type (); +} + +static void +gdk_pixmap_impl_x11_init (GdkPixmapImplX11 *impl) +{ + impl->width = 1; + impl->height = 1; +} + +static void +gdk_pixmap_impl_x11_class_init (GdkPixmapImplX11Class *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + GdkDrawableClass *drawable_class = GDK_DRAWABLE_CLASS (klass); + + parent_class = g_type_class_peek_parent (klass); + + object_class->finalize = gdk_pixmap_impl_x11_finalize; + + drawable_class->get_size = gdk_pixmap_impl_x11_get_size; +} + +static void +gdk_pixmap_impl_x11_finalize (GObject *object) +{ + GdkPixmapImplX11 *impl = GDK_PIXMAP_IMPL_X11 (object); + GdkPixmap *wrapper = GDK_PIXMAP (GDK_DRAWABLE_IMPL_X11 (impl)->wrapper); + + XFreePixmap (GDK_PIXMAP_XDISPLAY (wrapper), GDK_PIXMAP_XID (wrapper)); + gdk_xid_table_remove (GDK_PIXMAP_XID (wrapper)); + + G_OBJECT_CLASS (parent_class)->finalize (object); +} - return drawable; +static void +gdk_pixmap_impl_x11_get_size (GdkDrawable *drawable, + gint *width, + gint *height) +{ + if (width) + *width = GDK_PIXMAP_IMPL_X11 (drawable)->width; + if (height) + *height = GDK_PIXMAP_IMPL_X11 (drawable)->height; } GdkPixmap* @@ -94,8 +145,9 @@ gdk_pixmap_new (GdkWindow *window, gint depth) { GdkPixmap *pixmap; - GdkDrawablePrivate *private; - + GdkDrawableImplX11 *draw_impl; + GdkPixmapImplX11 *pix_impl; + 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); @@ -103,24 +155,27 @@ gdk_pixmap_new (GdkWindow *window, if (!window) window = gdk_parent_root; - if (GDK_DRAWABLE_DESTROYED (window)) + if (GDK_WINDOW_DESTROYED (window)) return NULL; if (depth == -1) - depth = gdk_drawable_get_visual (window)->depth; + depth = gdk_drawable_get_depth (GDK_DRAWABLE (window)); - pixmap = gdk_x11_pixmap_alloc (); - private = (GdkDrawablePrivate *)pixmap; - - GDK_DRAWABLE_XDATA (private)->xdisplay = GDK_DRAWABLE_XDISPLAY (window); - GDK_DRAWABLE_XDATA (private)->xid = XCreatePixmap (GDK_DRAWABLE_XDISPLAY (pixmap), - GDK_DRAWABLE_XID (window), - width, height, depth); - private->width = width; - private->height = height; - private->depth = depth; + pixmap = GDK_PIXMAP (g_type_create_instance (gdk_pixmap_get_type ())); + draw_impl = GDK_DRAWABLE_IMPL_X11 (GDK_PIXMAP_OBJECT (pixmap)->impl); + pix_impl = GDK_PIXMAP_IMPL_X11 (GDK_PIXMAP_OBJECT (pixmap)->impl); + draw_impl->wrapper = GDK_DRAWABLE (pixmap); + + draw_impl->xdisplay = GDK_WINDOW_XDISPLAY (window); + draw_impl->xid = XCreatePixmap (GDK_PIXMAP_XDISPLAY (pixmap), + GDK_WINDOW_XID (window), + width, height, depth); + + pix_impl->width = width; + pix_impl->height = height; + GDK_PIXMAP_OBJECT (pixmap)->depth = depth; - gdk_xid_table_insert (&GDK_DRAWABLE_XID (pixmap), pixmap); + gdk_xid_table_insert (&GDK_PIXMAP_XID (pixmap), pixmap); return pixmap; } @@ -132,8 +187,9 @@ gdk_bitmap_create_from_data (GdkWindow *window, gint height) { GdkPixmap *pixmap; - GdkDrawablePrivate *private; - + GdkDrawableImplX11 *draw_impl; + GdkPixmapImplX11 *pix_impl; + 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); @@ -141,23 +197,25 @@ gdk_bitmap_create_from_data (GdkWindow *window, if (!window) window = gdk_parent_root; - if (GDK_DRAWABLE_DESTROYED (window)) + if (GDK_WINDOW_DESTROYED (window)) return NULL; - pixmap = gdk_x11_pixmap_alloc (); - private = (GdkDrawablePrivate *)pixmap; + pixmap = GDK_PIXMAP (g_type_create_instance (gdk_pixmap_get_type ())); + draw_impl = GDK_DRAWABLE_IMPL_X11 (GDK_PIXMAP_OBJECT (pixmap)->impl); + pix_impl = GDK_PIXMAP_IMPL_X11 (GDK_PIXMAP_OBJECT (pixmap)->impl); + draw_impl->wrapper = GDK_DRAWABLE (pixmap); - private->width = width; - private->height = height; - private->depth = 1; + pix_impl->width = width; + pix_impl->height = height; + GDK_PIXMAP_OBJECT (pixmap)->depth = 1; - GDK_DRAWABLE_XDATA (private)->xdisplay = GDK_DRAWABLE_XDISPLAY (window); - GDK_DRAWABLE_XDATA (private)->xid = XCreateBitmapFromData (GDK_DRAWABLE_XDISPLAY (window), - GDK_DRAWABLE_XID (window), - (char *)data, width, height); - - gdk_xid_table_insert (&GDK_DRAWABLE_XID (pixmap), pixmap); + draw_impl->xdisplay = GDK_WINDOW_XDISPLAY (window); + draw_impl->xid = XCreateBitmapFromData (GDK_WINDOW_XDISPLAY (window), + GDK_WINDOW_XID (window), + (char *)data, width, height); + gdk_xid_table_insert (&GDK_PIXMAP_XID (pixmap), pixmap); + return pixmap; } @@ -171,7 +229,8 @@ gdk_pixmap_create_from_data (GdkWindow *window, GdkColor *bg) { GdkPixmap *pixmap; - GdkDrawablePrivate *private; + GdkDrawableImplX11 *draw_impl; + GdkPixmapImplX11 *pix_impl; g_return_val_if_fail (window == NULL || GDK_IS_WINDOW (window), NULL); g_return_val_if_fail (data != NULL, NULL); @@ -183,26 +242,28 @@ gdk_pixmap_create_from_data (GdkWindow *window, if (!window) window = gdk_parent_root; - if (GDK_DRAWABLE_DESTROYED (window)) + if (GDK_WINDOW_DESTROYED (window)) return NULL; if (depth == -1) depth = gdk_drawable_get_visual (window)->depth; - pixmap = gdk_x11_pixmap_alloc (); - private = (GdkDrawablePrivate *)pixmap; - - private->width = width; - private->height = height; - private->depth = depth; + pixmap = GDK_PIXMAP (g_type_create_instance (gdk_pixmap_get_type ())); + draw_impl = GDK_DRAWABLE_IMPL_X11 (GDK_PIXMAP_OBJECT (pixmap)->impl); + pix_impl = GDK_PIXMAP_IMPL_X11 (GDK_PIXMAP_OBJECT (pixmap)->impl); + draw_impl->wrapper = GDK_DRAWABLE (pixmap); + + pix_impl->width = width; + pix_impl->height = height; + GDK_PIXMAP_OBJECT (pixmap)->depth = depth; - GDK_DRAWABLE_XDATA (private)->xdisplay = GDK_DRAWABLE_XDISPLAY (window); - GDK_DRAWABLE_XDATA (private)->xid = XCreatePixmapFromBitmapData (GDK_DRAWABLE_XDISPLAY (window), - GDK_DRAWABLE_XID (window), - (char *)data, width, height, - fg->pixel, bg->pixel, depth); + draw_impl->xdisplay = GDK_DRAWABLE_XDISPLAY (window); + draw_impl->xid = XCreatePixmapFromBitmapData (GDK_WINDOW_XDISPLAY (window), + GDK_WINDOW_XID (window), + (char *)data, width, height, + fg->pixel, bg->pixel, depth); - gdk_xid_table_insert (&GDK_DRAWABLE_XID (pixmap), pixmap); + gdk_xid_table_insert (&GDK_PIXMAP_XID (pixmap), pixmap); return pixmap; } @@ -483,7 +544,7 @@ _gdk_pixmap_create_from_xpm (GdkWindow *window, visual = gdk_drawable_get_visual (window); } else - visual = ((GdkColormapPrivate *)colormap)->visual; + visual = colormap->visual; buffer = (*get_buf) (op_header, handle); if (buffer == NULL) @@ -779,7 +840,8 @@ GdkPixmap* gdk_pixmap_foreign_new (GdkNativeWindow anid) { GdkPixmap *pixmap; - GdkDrawablePrivate *private; + GdkDrawableImplX11 *draw_impl; + GdkPixmapImplX11 *pix_impl; Pixmap xpixmap; Window root_return; unsigned int x_ret, y_ret, w_ret, h_ret, bw_ret, depth_ret; @@ -797,18 +859,21 @@ gdk_pixmap_foreign_new (GdkNativeWindow anid) xpixmap, &root_return, &x_ret, &y_ret, &w_ret, &h_ret, &bw_ret, &depth_ret)) return NULL; - - pixmap = gdk_x11_pixmap_alloc (); - private = (GdkDrawablePrivate *)pixmap; - GDK_DRAWABLE_XDATA (private)->xdisplay = GDK_DISPLAY (); - GDK_DRAWABLE_XDATA (private)->xid = xpixmap; + pixmap = GDK_PIXMAP (g_type_create_instance (gdk_pixmap_get_type ())); + draw_impl = GDK_DRAWABLE_IMPL_X11 (GDK_PIXMAP_OBJECT (pixmap)->impl); + pix_impl = GDK_PIXMAP_IMPL_X11 (GDK_PIXMAP_OBJECT (pixmap)->impl); + draw_impl->wrapper = GDK_DRAWABLE (pixmap); + + + draw_impl->xdisplay = GDK_DISPLAY (); + draw_impl->xid = xpixmap; - private->width = w_ret; - private->height = h_ret; - private->depth = depth_ret; + pix_impl->width = w_ret; + pix_impl->height = h_ret; + GDK_PIXMAP_OBJECT (pixmap)->depth = depth_ret; - gdk_xid_table_insert(&GDK_DRAWABLE_XID (pixmap), pixmap); + gdk_xid_table_insert(&GDK_PIXMAP_XID (pixmap), pixmap); return pixmap; } diff --git a/gdk/x11/gdkpixmap-x11.h b/gdk/x11/gdkpixmap-x11.h new file mode 100644 index 0000000000..0087553ba7 --- /dev/null +++ b/gdk/x11/gdkpixmap-x11.h @@ -0,0 +1,70 @@ +/* GDK - The GIMP Drawing Kit + * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +/* + * Modified by the GTK+ Team and others 1997-1999. See the AUTHORS + * file for a list of people on the GTK+ Team. See the ChangeLog + * files for a list of changes. These files are distributed with + * GTK+ at ftp://ftp.gtk.org/pub/gtk/. + */ + +#ifndef __GDK_PIXMAP_X11_H__ +#define __GDK_PIXMAP_X11_H__ + +#include <gdk/x11/gdkdrawable-x11.h> +#include <gdk/gdkpixmap.h> + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/* Pixmap implementation for X11 + */ + +typedef struct _GdkPixmapImplX11 GdkPixmapImplX11; +typedef struct _GdkPixmapImplX11Class GdkPixmapImplX11Class; + +#define GDK_TYPE_PIXMAP_IMPL_X11 (gdk_pixmap_impl_x11_get_type ()) +#define GDK_PIXMAP_IMPL_X11(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_PIXMAP_IMPL_X11, GdkPixmapImplX11)) +#define GDK_PIXMAP_IMPL_X11_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_PIXMAP_IMPL_X11, GdkPixmapImplX11Class)) +#define GDK_IS_PIXMAP_IMPL_X11(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_PIXMAP_IMPL_X11)) +#define GDK_IS_PIXMAP_IMPL_X11_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_PIXMAP_IMPL_X11)) +#define GDK_PIXMAP_IMPL_X11_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_PIXMAP_IMPL_X11, GdkPixmapImplX11Class)) + +struct _GdkPixmapImplX11 +{ + GdkDrawableImplX11 parent_instance; + + gint width; + gint height; +}; + +struct _GdkPixmapImplX11Class +{ + GdkDrawableImplX11Class parent_class; + +}; + +GType gdk_pixmap_impl_x11_get_type (void); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* __GDK_PIXMAP_X11_H__ */ diff --git a/gdk/x11/gdkprivate-x11.h b/gdk/x11/gdkprivate-x11.h index e61e7e28c6..5c84355fd7 100644 --- a/gdk/x11/gdkprivate-x11.h +++ b/gdk/x11/gdkprivate-x11.h @@ -63,16 +63,15 @@ Window gdk_window_xid_at_coords (gint x, gboolean excl_child); /* Routines from gdkgeometry-x11.c */ - -void _gdk_window_init_position (GdkWindow *window); -void _gdk_window_move_resize_child (GdkWindow *window, - gint x, - gint y, - gint width, - gint height); -void _gdk_window_process_expose (GdkWindow *window, - gulong serial, - GdkRectangle *area); +void _gdk_window_init_position (GdkWindow *window); +void _gdk_window_move_resize_child (GdkWindow *window, + gint x, + gint y, + gint width, + gint height); +void _gdk_window_process_expose (GdkWindow *window, + gulong serial, + GdkRectangle *area); extern GdkDrawableClass _gdk_x11_drawable_class; extern gboolean gdk_use_xshm; @@ -85,9 +84,9 @@ extern gboolean gdk_null_window_warnings; extern const int gdk_nevent_masks; extern const int gdk_event_mask_table[]; -extern GdkWindowPrivate *gdk_xgrab_window; /* Window that currently holds the - * x pointer grab - */ +extern GdkWindowObject *gdk_xgrab_window; /* Window that currently holds the + * x pointer grab + */ #ifdef USE_XIM extern GdkICPrivate *gdk_xim_ic; /* currently using IC */ diff --git a/gdk/x11/gdkproperty-x11.c b/gdk/x11/gdkproperty-x11.c index 58b51a9712..4d338fe95b 100644 --- a/gdk/x11/gdkproperty-x11.c +++ b/gdk/x11/gdkproperty-x11.c @@ -117,11 +117,11 @@ gdk_property_get (GdkWindow *window, if (window) { - if (GDK_DRAWABLE_DESTROYED (window)) + if (GDK_WINDOW_DESTROYED (window)) return FALSE; - xdisplay = GDK_DRAWABLE_XDISPLAY (window); - xwindow = GDK_DRAWABLE_XID (window); + xdisplay = GDK_WINDOW_XDISPLAY (window); + xwindow = GDK_WINDOW_XID (window); } else { @@ -206,11 +206,11 @@ gdk_property_change (GdkWindow *window, if (window) { - if (GDK_DRAWABLE_DESTROYED (window)) + if (GDK_WINDOW_DESTROYED (window)) return; - xdisplay = GDK_DRAWABLE_XDISPLAY (window); - xwindow = GDK_DRAWABLE_XID (window); + xdisplay = GDK_WINDOW_XDISPLAY (window); + xwindow = GDK_WINDOW_XID (window); } else { @@ -234,11 +234,11 @@ gdk_property_delete (GdkWindow *window, if (window) { - if (GDK_DRAWABLE_DESTROYED (window)) + if (GDK_WINDOW_DESTROYED (window)) return; - xdisplay = GDK_DRAWABLE_XDISPLAY (window); - xwindow = GDK_DRAWABLE_XID (window); + xdisplay = GDK_WINDOW_XDISPLAY (window); + xwindow = GDK_WINDOW_XID (window); } else { diff --git a/gdk/x11/gdkselection-x11.c b/gdk/x11/gdkselection-x11.c index 31a6eb0b91..f0916db072 100644 --- a/gdk/x11/gdkselection-x11.c +++ b/gdk/x11/gdkselection-x11.c @@ -45,11 +45,11 @@ gdk_selection_owner_set (GdkWindow *owner, if (owner) { - if (GDK_DRAWABLE_DESTROYED (owner)) + if (GDK_WINDOW_DESTROYED (owner)) return FALSE; - xdisplay = GDK_DRAWABLE_XDISPLAY (owner); - xwindow = GDK_DRAWABLE_XID (owner); + xdisplay = GDK_WINDOW_XDISPLAY (owner); + xwindow = GDK_WINDOW_XID (owner); } else { @@ -80,11 +80,11 @@ gdk_selection_convert (GdkWindow *requestor, GdkAtom target, guint32 time) { - if (GDK_DRAWABLE_DESTROYED (requestor)) + if (GDK_WINDOW_DESTROYED (requestor)) return; - XConvertSelection (GDK_DRAWABLE_XDISPLAY (requestor), selection, target, - gdk_selection_property, GDK_DRAWABLE_XID (requestor), time); + XConvertSelection (GDK_WINDOW_XDISPLAY (requestor), selection, target, + gdk_selection_property, GDK_WINDOW_XID (requestor), time); } gint @@ -107,12 +107,12 @@ gdk_selection_property_get (GdkWindow *requestor, should be) it would be a win to try first with a buffer of moderate length, to avoid two round trips to the server */ - if (GDK_DRAWABLE_DESTROYED (requestor)) + if (GDK_WINDOW_DESTROYED (requestor)) return 0; t = NULL; - XGetWindowProperty (GDK_DRAWABLE_XDISPLAY (requestor), - GDK_DRAWABLE_XID (requestor), + XGetWindowProperty (GDK_WINDOW_XDISPLAY (requestor), + GDK_WINDOW_XID (requestor), gdk_selection_property, 0, 0, False, AnyPropertyType, &prop_type, &prop_format, &nitems, &nbytes, &t); diff --git a/gdk/x11/gdkwindow-x11.c b/gdk/x11/gdkwindow-x11.c index fe6da9b237..8f6964101a 100644 --- a/gdk/x11/gdkwindow-x11.c +++ b/gdk/x11/gdkwindow-x11.c @@ -37,6 +37,7 @@ #include "gdkregion.h" #include "gdkinternals.h" #include "MwmUtil.h" +#include "gdkwindow-x11.h" #include <stdlib.h> #include <stdio.h> @@ -79,79 +80,192 @@ static void gdk_window_set_static_win_gravity (GdkWindow *window, gboolean on); static gboolean gdk_window_have_shape_ext (void); -GdkDrawableClass _gdk_windowing_window_class; +static GdkColormap* gdk_window_impl_x11_get_colormap (GdkDrawable *drawable); +static void gdk_window_impl_x11_set_colormap (GdkDrawable *drawable, + GdkColormap *cmap); +static void gdk_window_impl_x11_get_size (GdkDrawable *drawable, + gint *width, + gint *height); +static void gdk_window_impl_x11_init (GdkWindowImplX11 *window); +static void gdk_window_impl_x11_class_init (GdkWindowImplX11Class *klass); +static void gdk_window_impl_x11_finalize (GObject *object); -static void -gdk_x11_window_destroy (GdkDrawable *drawable) +static gpointer parent_class = NULL; + +GType +gdk_window_impl_x11_get_type (void) { - if (!GDK_DRAWABLE_DESTROYED (drawable)) + static GType object_type = 0; + + if (!object_type) { - if (GDK_DRAWABLE_TYPE (drawable) != GDK_WINDOW_FOREIGN) - { - g_warning ("losing last reference to undestroyed window\n"); - _gdk_window_destroy (drawable, FALSE); - } - else - /* We use TRUE here, to keep us from actually calling - * XDestroyWindow() on the window - */ - _gdk_window_destroy (drawable, TRUE); + static const GTypeInfo object_info = + { + sizeof (GdkWindowImplX11Class), + (GBaseInitFunc) NULL, + (GBaseFinalizeFunc) NULL, + (GClassInitFunc) gdk_window_impl_x11_class_init, + NULL, /* class_finalize */ + NULL, /* class_data */ + sizeof (GdkWindowImplX11), + 0, /* n_preallocs */ + (GInstanceInitFunc) gdk_window_impl_x11_init, + }; - gdk_xid_table_remove (GDK_DRAWABLE_XID (drawable)); + object_type = g_type_register_static (GDK_TYPE_DRAWABLE_IMPL_X11, + "GdkWindowImplX11", + &object_info); } + + return object_type; +} + +GType +_gdk_window_impl_get_type (void) +{ + return gdk_window_impl_x11_get_type (); +} - g_free (GDK_DRAWABLE_XDATA (drawable)); +static void +gdk_window_impl_x11_init (GdkWindowImplX11 *impl) +{ + impl->width = 1; + impl->height = 1; } -static GdkWindow * -gdk_x11_window_alloc (void) +static void +gdk_window_impl_x11_class_init (GdkWindowImplX11Class *klass) { - GdkWindow *window; - GdkWindowPrivate *private; + GObjectClass *object_class = G_OBJECT_CLASS (klass); + GdkDrawableClass *drawable_class = GDK_DRAWABLE_CLASS (klass); - static gboolean initialized = FALSE; + parent_class = g_type_class_peek_parent (klass); + + object_class->finalize = gdk_window_impl_x11_finalize; - if (!initialized) + drawable_class->set_colormap = gdk_window_impl_x11_set_colormap; + drawable_class->get_colormap = gdk_window_impl_x11_get_colormap; + drawable_class->get_size = gdk_window_impl_x11_get_size; +} + +static void +gdk_window_impl_x11_finalize (GObject *object) +{ + GdkWindowObject *wrapper; + GdkDrawableImplX11 *draw_impl; + GdkWindowImplX11 *window_impl; + + g_return_if_fail (GDK_IS_WINDOW_IMPL_X11 (object)); + + draw_impl = GDK_DRAWABLE_IMPL_X11 (object); + window_impl = GDK_WINDOW_IMPL_X11 (object); + + wrapper = (GdkWindowObject*) draw_impl->wrapper; + + if (!GDK_WINDOW_DESTROYED (wrapper)) { - initialized = TRUE; + gdk_xid_table_remove (draw_impl->xid); + } + + G_OBJECT_CLASS (parent_class)->finalize (object); +} - _gdk_windowing_window_class = _gdk_x11_drawable_class; - _gdk_windowing_window_class.destroy = gdk_x11_window_destroy; +static GdkColormap* +gdk_window_impl_x11_get_colormap (GdkDrawable *drawable) +{ + GdkDrawableImplX11 *drawable_impl; + GdkWindowImplX11 *window_impl; + + g_return_val_if_fail (GDK_IS_WINDOW_IMPL_X11 (drawable), NULL); + + drawable_impl = GDK_DRAWABLE_IMPL_X11 (drawable); + window_impl = GDK_WINDOW_IMPL_X11 (drawable); + + if (!((GdkWindowObject *) drawable_impl->wrapper)->input_only && + drawable_impl->colormap == NULL) + { + XWindowAttributes window_attributes; + + XGetWindowAttributes (drawable_impl->xdisplay, + drawable_impl->xid, + &window_attributes); + drawable_impl->colormap = + gdk_colormap_lookup (window_attributes.colormap); } + + return drawable_impl->colormap; +} + +static void +gdk_window_impl_x11_set_colormap (GdkDrawable *drawable, + GdkColormap *cmap) +{ + GdkWindowImplX11 *impl; + GdkDrawableImplX11 *draw_impl; + + g_return_if_fail (GDK_IS_WINDOW_IMPL_X11 (drawable)); + g_return_if_fail (gdk_colormap_get_visual (cmap) != gdk_drawable_get_visual (drawable)); - window = _gdk_window_alloc (); - private = (GdkWindowPrivate *)window; + impl = GDK_WINDOW_IMPL_X11 (drawable); + draw_impl = GDK_DRAWABLE_IMPL_X11 (drawable); - private->drawable.klass = &_gdk_window_class; - private->drawable.klass_data = g_new (GdkWindowXData, 1); + GDK_DRAWABLE_GET_CLASS (draw_impl)->set_colormap (drawable, cmap); + + XSetWindowColormap (draw_impl->xdisplay, + draw_impl->xid, + GDK_COLORMAP_XCOLORMAP (cmap)); - return window; + if (((GdkWindowObject*)draw_impl->wrapper)->window_type != + GDK_WINDOW_TOPLEVEL) + gdk_window_add_colormap_windows (GDK_WINDOW (draw_impl->wrapper)); +} + + +static void +gdk_window_impl_x11_get_size (GdkDrawable *drawable, + gint *width, + gint *height) +{ + g_return_if_fail (GDK_IS_WINDOW_IMPL_X11 (drawable)); + + if (width) + *width = GDK_WINDOW_IMPL_X11 (drawable)->width; + if (height) + *height = GDK_WINDOW_IMPL_X11 (drawable)->height; } void -gdk_window_init (void) +_gdk_windowing_window_init (void) { - GdkWindowPrivate *private; + GdkWindowObject *private; + GdkWindowImplX11 *impl; + GdkDrawableImplX11 *draw_impl; XWindowAttributes xattributes; unsigned int width; unsigned int height; unsigned int border_width; unsigned int depth; int x, y; + + g_assert (gdk_parent_root == NULL); XGetGeometry (gdk_display, gdk_root_window, &gdk_root_window, &x, &y, &width, &height, &border_width, &depth); XGetWindowAttributes (gdk_display, gdk_root_window, &xattributes); - gdk_parent_root = gdk_x11_window_alloc (); - private = (GdkWindowPrivate *)gdk_parent_root; + gdk_parent_root = GDK_WINDOW (g_type_create_instance (GDK_TYPE_WINDOW)); + private = (GdkWindowObject *)gdk_parent_root; + impl = GDK_WINDOW_IMPL_X11 (private->impl); + draw_impl = GDK_DRAWABLE_IMPL_X11 (private->impl); - GDK_DRAWABLE_XDATA (gdk_parent_root)->xdisplay = gdk_display; - GDK_DRAWABLE_XDATA (gdk_parent_root)->xid = gdk_root_window; - - private->drawable.window_type = GDK_WINDOW_ROOT; - private->drawable.width = width; - private->drawable.height = height; + draw_impl->xdisplay = gdk_display; + draw_impl->xid = gdk_root_window; + draw_impl->wrapper = GDK_DRAWABLE (private); + + private->window_type = GDK_WINDOW_ROOT; + private->depth = depth; + impl->width = width; + impl->height = height; gdk_xid_table_insert (&gdk_root_window, gdk_parent_root); } @@ -164,8 +278,10 @@ gdk_window_new (GdkWindow *parent, gint attributes_mask) { GdkWindow *window; - GdkWindowPrivate *private; - GdkWindowPrivate *parent_private; + GdkWindowObject *private; + GdkWindowObject *parent_private; + GdkWindowImplX11 *impl; + GdkDrawableImplX11 *draw_impl; GdkVisual *visual; Window xparent; @@ -186,19 +302,24 @@ gdk_window_new (GdkWindow *parent, if (!parent) parent = gdk_parent_root; + + g_return_val_if_fail (GDK_IS_WINDOW (parent), NULL); - parent_private = (GdkWindowPrivate*) parent; - if (GDK_DRAWABLE_DESTROYED (parent)) + parent_private = (GdkWindowObject*) parent; + if (GDK_WINDOW_DESTROYED (parent)) return NULL; - xparent = GDK_DRAWABLE_XID (parent); + xparent = GDK_WINDOW_XID (parent); - window = gdk_x11_window_alloc (); - private = (GdkWindowPrivate *)window; - - GDK_DRAWABLE_XDATA (window)->xdisplay = GDK_DRAWABLE_XDISPLAY (parent); + window = GDK_WINDOW (g_type_create_instance (GDK_TYPE_WINDOW)); + private = (GdkWindowObject *)window; + impl = GDK_WINDOW_IMPL_X11 (private->impl); + draw_impl = GDK_DRAWABLE_IMPL_X11 (private->impl); + draw_impl->wrapper = GDK_DRAWABLE (window); + + draw_impl->xdisplay = GDK_WINDOW_XDISPLAY (parent); - private->parent = parent; + private->parent = (GdkWindowObject *)parent; xattributes_mask = 0; @@ -214,12 +335,12 @@ gdk_window_new (GdkWindow *parent, private->x = x; private->y = y; - 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; + impl->width = (attributes->width > 1) ? (attributes->width) : (1); + impl->height = (attributes->height > 1) ? (attributes->height) : (1); + private->window_type = attributes->window_type; - _gdk_window_init_position (window); - if (GDK_WINDOW_XDATA (window)->position_info.big) + _gdk_window_init_position (GDK_WINDOW (private)); + if (impl->position_info.big) private->guffaw_gravity = TRUE; if (attributes_mask & GDK_WA_VISUAL) @@ -259,16 +380,26 @@ gdk_window_new (GdkWindow *parent, depth = visual->depth; private->input_only = FALSE; - private->drawable.depth = depth; + private->depth = depth; if (attributes_mask & GDK_WA_COLORMAP) - private->drawable.colormap = attributes->colormap; + { + draw_impl->colormap = attributes->colormap; + gdk_colormap_ref (attributes->colormap); + } else { if ((((GdkVisualPrivate*)gdk_visual_get_system ())->xvisual) == xvisual) - private->drawable.colormap = gdk_colormap_get_system (); + { + draw_impl->colormap = + gdk_colormap_get_system (); + gdk_colormap_ref (draw_impl->colormap); + } else - private->drawable.colormap = gdk_colormap_new (visual, False); + { + draw_impl->colormap = + gdk_colormap_new (visual, FALSE); + } } private->bg_color.pixel = BlackPixel (gdk_display, gdk_screen); @@ -286,29 +417,29 @@ gdk_window_new (GdkWindow *parent, xattributes_mask |= CWBitGravity; - switch (private->drawable.window_type) + switch (private->window_type) { case GDK_WINDOW_TOPLEVEL: - xattributes.colormap = GDK_COLORMAP_XCOLORMAP (private->drawable.colormap); + xattributes.colormap = GDK_COLORMAP_XCOLORMAP (draw_impl->colormap); xattributes_mask |= CWColormap; xparent = gdk_root_window; break; case GDK_WINDOW_CHILD: - xattributes.colormap = GDK_COLORMAP_XCOLORMAP (private->drawable.colormap); + xattributes.colormap = GDK_COLORMAP_XCOLORMAP (draw_impl->colormap); xattributes_mask |= CWColormap; break; case GDK_WINDOW_DIALOG: - xattributes.colormap = GDK_COLORMAP_XCOLORMAP (private->drawable.colormap); + xattributes.colormap = GDK_COLORMAP_XCOLORMAP (draw_impl->colormap); xattributes_mask |= CWColormap; xparent = gdk_root_window; break; case GDK_WINDOW_TEMP: - xattributes.colormap = GDK_COLORMAP_XCOLORMAP (private->drawable.colormap); + xattributes.colormap = GDK_COLORMAP_XCOLORMAP (draw_impl->colormap); xattributes_mask |= CWColormap; xparent = gdk_root_window; @@ -321,29 +452,26 @@ gdk_window_new (GdkWindow *parent, case GDK_WINDOW_ROOT: g_error ("cannot make windows of type GDK_WINDOW_ROOT"); break; - case GDK_WINDOW_PIXMAP: - g_error ("cannot make windows of type GDK_WINDOW_PIXMAP (use gdk_pixmap_new)"); - break; } } else { depth = 0; + private->depth = 0; class = InputOnly; private->input_only = TRUE; - private->drawable.colormap = NULL; + draw_impl->colormap = NULL; } - GDK_DRAWABLE_XDATA (private)->xid = XCreateWindow (GDK_DRAWABLE_XDISPLAY (parent), - xparent, - x, y, private->drawable.width, private->drawable.height, - 0, depth, class, xvisual, - xattributes_mask, &xattributes); + draw_impl->xid = XCreateWindow (GDK_WINDOW_XDISPLAY (parent), + xparent, + x, y, + impl->width, impl->height, + 0, depth, class, xvisual, + xattributes_mask, &xattributes); + gdk_drawable_ref (window); - gdk_xid_table_insert (&GDK_DRAWABLE_XID (window), window); - - if (private->drawable.colormap) - gdk_colormap_ref (private->drawable.colormap); + gdk_xid_table_insert (&GDK_WINDOW_XID (window), window); gdk_window_set_cursor (window, ((attributes_mask & GDK_WA_CURSOR) ? (attributes->cursor) : @@ -352,22 +480,22 @@ gdk_window_new (GdkWindow *parent, if (parent_private) parent_private->children = g_list_prepend (parent_private->children, window); - switch (private->drawable.window_type) + switch (GDK_WINDOW_TYPE (private)) { case GDK_WINDOW_DIALOG: - XSetTransientForHint (GDK_DRAWABLE_XDISPLAY (window), - GDK_DRAWABLE_XID (window), + XSetTransientForHint (GDK_WINDOW_XDISPLAY (window), + GDK_WINDOW_XID (window), xparent); case GDK_WINDOW_TOPLEVEL: case GDK_WINDOW_TEMP: - XSetWMProtocols (GDK_DRAWABLE_XDISPLAY (window), - GDK_DRAWABLE_XID (window), + XSetWMProtocols (GDK_WINDOW_XDISPLAY (window), + GDK_WINDOW_XID (window), gdk_wm_window_protocols, 2); break; case GDK_WINDOW_CHILD: if ((attributes->wclass == GDK_INPUT_OUTPUT) && - (private->drawable.colormap != gdk_colormap_get_system ()) && - (private->drawable.colormap != gdk_window_get_colormap (gdk_window_get_toplevel (window)))) + (draw_impl->colormap != gdk_colormap_get_system ()) && + (draw_impl->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); @@ -380,8 +508,8 @@ gdk_window_new (GdkWindow *parent, } size_hints.flags = PSize; - size_hints.width = private->drawable.width; - size_hints.height = private->drawable.height; + size_hints.width = impl->width; + size_hints.height = impl->height; wm_hints.flags = InputHint | StateHint | WindowGroupHint; wm_hints.window_group = gdk_leader_window; @@ -392,19 +520,19 @@ gdk_window_new (GdkWindow *parent, * attention to PSize, and even if they do, is this the * correct value??? */ - XSetWMNormalHints (GDK_DRAWABLE_XDISPLAY (window), - GDK_DRAWABLE_XID (window), + XSetWMNormalHints (GDK_WINDOW_XDISPLAY (window), + GDK_WINDOW_XID (window), &size_hints); - XSetWMHints (GDK_DRAWABLE_XDISPLAY (window), - GDK_DRAWABLE_XID (window), + XSetWMHints (GDK_WINDOW_XDISPLAY (window), + GDK_WINDOW_XID (window), &wm_hints); if (!wm_client_leader_atom) wm_client_leader_atom = gdk_atom_intern ("WM_CLIENT_LEADER", FALSE); - XChangeProperty (GDK_DRAWABLE_XDISPLAY (window), - GDK_DRAWABLE_XID (window), + XChangeProperty (GDK_WINDOW_XDISPLAY (window), + GDK_WINDOW_XID (window), wm_client_leader_atom, XA_WINDOW, 32, PropModeReplace, (guchar*) &gdk_leader_window, 1); @@ -414,8 +542,8 @@ gdk_window_new (GdkWindow *parent, else title = g_get_prgname (); - XmbSetWMProperties (GDK_DRAWABLE_XDISPLAY (window), - GDK_DRAWABLE_XID (window), + XmbSetWMProperties (GDK_WINDOW_XDISPLAY (window), + GDK_WINDOW_XID (window), title, title, NULL, 0, NULL, NULL, NULL); @@ -425,8 +553,8 @@ gdk_window_new (GdkWindow *parent, class_hint = XAllocClassHint (); class_hint->res_name = attributes->wmclass_name; class_hint->res_class = attributes->wmclass_class; - XSetClassHint (GDK_DRAWABLE_XDISPLAY (window), - GDK_DRAWABLE_XID (window), + XSetClassHint (GDK_WINDOW_XDISPLAY (window), + GDK_WINDOW_XID (window), class_hint); XFree (class_hint); } @@ -438,8 +566,10 @@ GdkWindow * gdk_window_foreign_new (GdkNativeWindow anid) { GdkWindow *window; - GdkWindowPrivate *private; - GdkWindowPrivate *parent_private; + GdkWindowObject *private; + GdkWindowObject *parent_private; + GdkWindowImplX11 *impl; + GdkDrawableImplX11 *draw_impl; XWindowAttributes attrs; Window root, parent; Window *children = NULL; @@ -461,29 +591,33 @@ gdk_window_foreign_new (GdkNativeWindow anid) if (children) XFree (children); - window = gdk_x11_window_alloc (); - private = (GdkWindowPrivate *)window; - + window = GDK_WINDOW (g_type_create_instance (GDK_TYPE_WINDOW)); + private = (GdkWindowObject *)window; + impl = GDK_WINDOW_IMPL_X11 (private->impl); + draw_impl = GDK_DRAWABLE_IMPL_X11 (private->impl); + draw_impl->wrapper = GDK_DRAWABLE (window); + private->parent = gdk_xid_table_lookup (parent); - parent_private = (GdkWindowPrivate *)private->parent; + parent_private = (GdkWindowObject *)private->parent; if (parent_private) parent_private->children = g_list_prepend (parent_private->children, window); - - GDK_DRAWABLE_XDATA (window)->xid = anid; - GDK_DRAWABLE_XDATA (window)->xdisplay = gdk_display; + + draw_impl->xid = anid; + draw_impl->xdisplay = gdk_display; private->x = attrs.x; private->y = attrs.y; - private->drawable.width = attrs.width; - private->drawable.height = attrs.height; - private->drawable.window_type = GDK_WINDOW_FOREIGN; - private->drawable.destroyed = FALSE; + impl->width = attrs.width; + impl->height = attrs.height; + private->window_type = GDK_WINDOW_FOREIGN; + private->destroyed = FALSE; private->mapped = (attrs.map_state != IsUnmapped); + private->depth = attrs.depth; gdk_drawable_ref (window); - gdk_xid_table_insert (&GDK_DRAWABLE_XID (window), window); + gdk_xid_table_insert (&GDK_WINDOW_XID (window), window); return window; } @@ -493,12 +627,14 @@ _gdk_windowing_window_destroy (GdkWindow *window, gboolean recursing, gboolean foreign_destroy) { - GdkWindowPrivate *private = (GdkWindowPrivate *)window; + GdkWindowObject *private = (GdkWindowObject *)window; + g_return_if_fail (GDK_IS_WINDOW (window)); + if (private->extension_events != 0) gdk_input_window_destroy (window); - if (private->drawable.window_type == GDK_WINDOW_FOREIGN) + if (private->window_type == GDK_WINDOW_FOREIGN) { if (!foreign_destroy && (private->parent != NULL)) { @@ -513,21 +649,21 @@ _gdk_windowing_window_destroy (GdkWindow *window, gdk_window_reparent (window, NULL, 0, 0); xevent.type = ClientMessage; - xevent.window = GDK_DRAWABLE_XID (window); + xevent.window = GDK_WINDOW_XID (window); xevent.message_type = gdk_wm_protocols; xevent.format = 32; xevent.data.l[0] = gdk_wm_delete_window; xevent.data.l[1] = CurrentTime; - XSendEvent (GDK_DRAWABLE_XDISPLAY (window), - GDK_DRAWABLE_XID (window), + XSendEvent (GDK_WINDOW_XDISPLAY (window), + GDK_WINDOW_XID (window), False, 0, (XEvent *)&xevent); gdk_flush (); gdk_error_trap_pop (); } } else if (!recursing && !foreign_destroy) - XDestroyWindow (GDK_DRAWABLE_XDISPLAY (window), GDK_DRAWABLE_XID (window)); + XDestroyWindow (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XID (window)); } /* This function is called when the XWindow is really gone. @@ -537,68 +673,68 @@ gdk_window_destroy_notify (GdkWindow *window) { g_return_if_fail (window != NULL); - if (!GDK_DRAWABLE_DESTROYED (window)) + if (!GDK_WINDOW_DESTROYED (window)) { - if (GDK_DRAWABLE_TYPE(window) != GDK_WINDOW_FOREIGN) - g_warning ("GdkWindow %#lx unexpectedly destroyed", GDK_DRAWABLE_XID (window)); + if (GDK_WINDOW_TYPE(window) != GDK_WINDOW_FOREIGN) + g_warning ("GdkWindow %#lx unexpectedly destroyed", GDK_WINDOW_XID (window)); _gdk_window_destroy (window, TRUE); } - gdk_xid_table_remove (GDK_DRAWABLE_XID (window)); + gdk_xid_table_remove (GDK_WINDOW_XID (window)); gdk_drawable_unref (window); } void gdk_window_show (GdkWindow *window) { - GdkWindowPrivate *private; + GdkWindowObject *private; - g_return_if_fail (window != NULL); + g_return_if_fail (GDK_IS_WINDOW (window)); - private = (GdkWindowPrivate*) window; - if (!private->drawable.destroyed) + private = (GdkWindowObject*) window; + if (!private->destroyed) { private->mapped = TRUE; - XRaiseWindow (GDK_DRAWABLE_XDISPLAY (window), - GDK_DRAWABLE_XID (window)); + XRaiseWindow (GDK_WINDOW_XDISPLAY (window), + GDK_WINDOW_XID (window)); - if (GDK_WINDOW_XDATA (window)->position_info.mapped) - XMapWindow (GDK_DRAWABLE_XDISPLAY (window), - GDK_DRAWABLE_XID (window)); + if (GDK_WINDOW_IMPL_X11 (private->impl)->position_info.mapped) + XMapWindow (GDK_WINDOW_XDISPLAY (window), + GDK_WINDOW_XID (window)); } } void gdk_window_hide (GdkWindow *window) { - GdkWindowPrivate *private; + GdkWindowObject *private; g_return_if_fail (window != NULL); - private = (GdkWindowPrivate*) window; - if (!private->drawable.destroyed) + private = (GdkWindowObject*) window; + if (!private->destroyed) { private->mapped = FALSE; _gdk_window_clear_update_area (window); - XUnmapWindow (GDK_DRAWABLE_XDISPLAY (window), - GDK_DRAWABLE_XID (window)); + XUnmapWindow (GDK_WINDOW_XDISPLAY (window), + GDK_WINDOW_XID (window)); } } void gdk_window_withdraw (GdkWindow *window) { - GdkWindowPrivate *private; + GdkWindowObject *private; g_return_if_fail (window != NULL); - private = (GdkWindowPrivate*) window; - if (!private->drawable.destroyed) - XWithdrawWindow (GDK_DRAWABLE_XDISPLAY (window), - GDK_DRAWABLE_XID (window), 0); + private = (GdkWindowObject*) window; + if (!private->destroyed) + XWithdrawWindow (GDK_WINDOW_XDISPLAY (window), + GDK_WINDOW_XID (window), 0); } void @@ -606,13 +742,16 @@ gdk_window_move (GdkWindow *window, gint x, gint y) { - GdkWindowPrivate *private = (GdkWindowPrivate *)window; - + GdkWindowObject *private = (GdkWindowObject *)window; + GdkWindowImplX11 *impl; + g_return_if_fail (window != NULL); g_return_if_fail (GDK_IS_WINDOW (window)); + impl = GDK_WINDOW_IMPL_X11 (private->impl); + gdk_window_move_resize (window, x, y, - private->drawable.width, private->drawable.height); + impl->width, impl->height); } void @@ -620,7 +759,7 @@ gdk_window_resize (GdkWindow *window, gint width, gint height) { - GdkWindowPrivate *private; + GdkWindowObject *private; g_return_if_fail (window != NULL); g_return_if_fail (GDK_IS_WINDOW (window)); @@ -630,17 +769,17 @@ gdk_window_resize (GdkWindow *window, if (height < 1) height = 1; - private = (GdkWindowPrivate*) window; + private = (GdkWindowObject*) window; - if (!GDK_DRAWABLE_DESTROYED (window)) + if (!GDK_WINDOW_DESTROYED (window)) { - if (GDK_DRAWABLE_TYPE (private) == GDK_WINDOW_CHILD) + if (GDK_WINDOW_TYPE (private) == GDK_WINDOW_CHILD) _gdk_window_move_resize_child (window, private->x, private->y, width, height); else { - XResizeWindow (GDK_DRAWABLE_XDISPLAY (window), - GDK_DRAWABLE_XID (window), + XResizeWindow (GDK_WINDOW_XDISPLAY (window), + GDK_WINDOW_XID (window), width, height); private->resize_count += 1; } @@ -654,7 +793,7 @@ gdk_window_move_resize (GdkWindow *window, gint width, gint height) { - GdkWindowPrivate *private; + GdkWindowObject *private; g_return_if_fail (window != NULL); g_return_if_fail (GDK_IS_WINDOW (window)); @@ -664,16 +803,16 @@ gdk_window_move_resize (GdkWindow *window, if (height < 1) height = 1; - private = (GdkWindowPrivate*) window; + private = (GdkWindowObject*) window; - if (!GDK_DRAWABLE_DESTROYED (window)) + if (!GDK_WINDOW_DESTROYED (window)) { - if (GDK_DRAWABLE_TYPE (private) == GDK_WINDOW_CHILD) + if (GDK_WINDOW_TYPE (private) == GDK_WINDOW_CHILD) _gdk_window_move_resize_child (window, x, y, width, height); else { - XMoveResizeWindow (GDK_DRAWABLE_XDISPLAY (window), - GDK_DRAWABLE_XID (window), + XMoveResizeWindow (GDK_WINDOW_XDISPLAY (window), + GDK_WINDOW_XID (window), x, y, width, height); } } @@ -685,9 +824,9 @@ gdk_window_reparent (GdkWindow *window, gint x, gint y) { - GdkWindowPrivate *window_private; - GdkWindowPrivate *parent_private; - GdkWindowPrivate *old_parent_private; + GdkWindowObject *window_private; + GdkWindowObject *parent_private; + GdkWindowObject *old_parent_private; g_return_if_fail (window != NULL); g_return_if_fail (GDK_IS_WINDOW (window)); @@ -697,17 +836,17 @@ gdk_window_reparent (GdkWindow *window, if (!new_parent) new_parent = gdk_parent_root; - window_private = (GdkWindowPrivate*) window; - old_parent_private = (GdkWindowPrivate*)window_private->parent; - parent_private = (GdkWindowPrivate*) new_parent; + window_private = (GdkWindowObject*) window; + old_parent_private = (GdkWindowObject*)window_private->parent; + parent_private = (GdkWindowObject*) new_parent; - if (!GDK_DRAWABLE_DESTROYED (window) && !GDK_DRAWABLE_DESTROYED (new_parent)) - XReparentWindow (GDK_DRAWABLE_XDISPLAY (window), - GDK_DRAWABLE_XID (window), - GDK_DRAWABLE_XID (new_parent), + if (!GDK_WINDOW_DESTROYED (window) && !GDK_WINDOW_DESTROYED (new_parent)) + XReparentWindow (GDK_WINDOW_XDISPLAY (window), + GDK_WINDOW_XID (window), + GDK_WINDOW_XID (new_parent), x, y); - window_private->parent = new_parent; + window_private->parent = (GdkWindowObject *)new_parent; if (old_parent_private) old_parent_private->children = g_list_remove (old_parent_private->children, window); @@ -730,8 +869,8 @@ _gdk_windowing_window_clear_area (GdkWindow *window, g_return_if_fail (window != NULL); g_return_if_fail (GDK_IS_WINDOW (window)); - if (!GDK_DRAWABLE_DESTROYED (window)) - XClearArea (GDK_DRAWABLE_XDISPLAY (window), GDK_DRAWABLE_XID (window), + if (!GDK_WINDOW_DESTROYED (window)) + XClearArea (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XID (window), x, y, width, height, False); } @@ -745,8 +884,8 @@ _gdk_windowing_window_clear_area_e (GdkWindow *window, g_return_if_fail (window != NULL); g_return_if_fail (GDK_IS_WINDOW (window)); - if (!GDK_DRAWABLE_DESTROYED (window)) - XClearArea (GDK_DRAWABLE_XDISPLAY (window), GDK_DRAWABLE_XID (window), + if (!GDK_WINDOW_DESTROYED (window)) + XClearArea (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XID (window), x, y, width, height, True); } @@ -756,8 +895,8 @@ gdk_window_raise (GdkWindow *window) g_return_if_fail (window != NULL); g_return_if_fail (GDK_IS_WINDOW (window)); - if (!GDK_DRAWABLE_DESTROYED (window)) - XRaiseWindow (GDK_DRAWABLE_XDISPLAY (window), GDK_DRAWABLE_XID (window)); + if (!GDK_WINDOW_DESTROYED (window)) + XRaiseWindow (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XID (window)); } void @@ -766,8 +905,8 @@ gdk_window_lower (GdkWindow *window) g_return_if_fail (window != NULL); g_return_if_fail (GDK_IS_WINDOW (window)); - if (!GDK_DRAWABLE_DESTROYED (window)) - XLowerWindow (GDK_DRAWABLE_XDISPLAY (window), GDK_DRAWABLE_XID (window)); + if (!GDK_WINDOW_DESTROYED (window)) + XLowerWindow (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XID (window)); } void @@ -785,7 +924,7 @@ gdk_window_set_hints (GdkWindow *window, g_return_if_fail (window != NULL); g_return_if_fail (GDK_IS_WINDOW (window)); - if (GDK_DRAWABLE_DESTROYED (window)) + if (GDK_WINDOW_DESTROYED (window)) return; size_hints.flags = 0; @@ -814,8 +953,8 @@ 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 (GDK_DRAWABLE_XDISPLAY (window), - GDK_DRAWABLE_XID (window), + XSetWMNormalHints (GDK_WINDOW_XDISPLAY (window), + GDK_WINDOW_XID (window), &size_hints); } @@ -829,7 +968,7 @@ gdk_window_set_geometry_hints (GdkWindow *window, g_return_if_fail (window != NULL); g_return_if_fail (GDK_IS_WINDOW (window)); - if (GDK_DRAWABLE_DESTROYED (window)) + if (GDK_WINDOW_DESTROYED (window)) return; size_hints.flags = 0; @@ -901,8 +1040,8 @@ 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 (GDK_DRAWABLE_XDISPLAY (window), - GDK_DRAWABLE_XID (window), + XSetWMNormalHints (GDK_WINDOW_XDISPLAY (window), + GDK_WINDOW_XID (window), &size_hints); } @@ -913,9 +1052,9 @@ gdk_window_set_title (GdkWindow *window, g_return_if_fail (window != NULL); g_return_if_fail (GDK_IS_WINDOW (window)); - if (!GDK_DRAWABLE_DESTROYED (window)) - XmbSetWMProperties (GDK_DRAWABLE_XDISPLAY (window), - GDK_DRAWABLE_XID (window), + if (!GDK_WINDOW_DESTROYED (window)) + XmbSetWMProperties (GDK_WINDOW_XDISPLAY (window), + GDK_WINDOW_XID (window), title, title, NULL, 0, NULL, NULL, NULL); } @@ -926,14 +1065,14 @@ gdk_window_set_role (GdkWindow *window, g_return_if_fail (window != NULL); g_return_if_fail (GDK_IS_WINDOW (window)); - if (!GDK_DRAWABLE_DESTROYED (window)) + if (!GDK_WINDOW_DESTROYED (window)) { if (role) - XChangeProperty (GDK_DRAWABLE_XDISPLAY (window), GDK_DRAWABLE_XID (window), + XChangeProperty (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_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), + XDeleteProperty (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XID (window), gdk_atom_intern ("WM_WINDOW_ROLE", FALSE)); } } @@ -942,33 +1081,33 @@ void gdk_window_set_transient_for (GdkWindow *window, GdkWindow *parent) { - GdkWindowPrivate *private; - GdkWindowPrivate *parent_private; + GdkWindowObject *private; + GdkWindowObject *parent_private; g_return_if_fail (window != NULL); g_return_if_fail (GDK_IS_WINDOW (window)); - private = (GdkWindowPrivate*) window; - parent_private = (GdkWindowPrivate*) parent; + private = (GdkWindowObject*) window; + parent_private = (GdkWindowObject*) parent; - if (!GDK_DRAWABLE_DESTROYED (window) && !GDK_DRAWABLE_DESTROYED (parent)) - XSetTransientForHint (GDK_DRAWABLE_XDISPLAY (window), - GDK_DRAWABLE_XID (window), - GDK_DRAWABLE_XID (parent)); + if (!GDK_WINDOW_DESTROYED (window) && !GDK_WINDOW_DESTROYED (parent)) + XSetTransientForHint (GDK_WINDOW_XDISPLAY (window), + GDK_WINDOW_XID (window), + GDK_WINDOW_XID (parent)); } void gdk_window_set_background (GdkWindow *window, GdkColor *color) { - GdkWindowPrivate *private = (GdkWindowPrivate *)window; + GdkWindowObject *private = (GdkWindowObject *)window; g_return_if_fail (window != NULL); g_return_if_fail (GDK_IS_WINDOW (window)); - if (!GDK_DRAWABLE_DESTROYED (window)) - XSetWindowBackground (GDK_DRAWABLE_XDISPLAY (window), - GDK_DRAWABLE_XID (window), color->pixel); + if (!GDK_WINDOW_DESTROYED (window)) + XSetWindowBackground (GDK_WINDOW_XDISPLAY (window), + GDK_WINDOW_XID (window), color->pixel); private->bg_color = *color; @@ -986,7 +1125,7 @@ gdk_window_set_back_pixmap (GdkWindow *window, GdkPixmap *pixmap, gboolean parent_relative) { - GdkWindowPrivate *private = (GdkWindowPrivate *)window; + GdkWindowObject *private = (GdkWindowObject *)window; Pixmap xpixmap; g_return_if_fail (window != NULL); @@ -1009,7 +1148,7 @@ gdk_window_set_back_pixmap (GdkWindow *window, { gdk_pixmap_ref (pixmap); private->bg_pixmap = pixmap; - xpixmap = GDK_DRAWABLE_XID (pixmap); + xpixmap = GDK_PIXMAP_XID (pixmap); } else { @@ -1018,9 +1157,9 @@ gdk_window_set_back_pixmap (GdkWindow *window, } } - if (!GDK_DRAWABLE_DESTROYED (window)) - XSetWindowBackgroundPixmap (GDK_DRAWABLE_XDISPLAY (window), - GDK_DRAWABLE_XID (window), xpixmap); + if (!GDK_WINDOW_DESTROYED (window)) + XSetWindowBackgroundPixmap (GDK_WINDOW_XDISPLAY (window), + GDK_WINDOW_XID (window), xpixmap); } void @@ -1040,9 +1179,9 @@ gdk_window_set_cursor (GdkWindow *window, else xcursor = cursor_private->xcursor; - if (!GDK_DRAWABLE_DESTROYED (window)) - XDefineCursor (GDK_DRAWABLE_XDISPLAY (window), - GDK_DRAWABLE_XID (window), + if (!GDK_WINDOW_DESTROYED (window)) + XDefineCursor (GDK_WINDOW_XDISPLAY (window), + GDK_WINDOW_XID (window), xcursor); } @@ -1067,10 +1206,10 @@ gdk_window_get_geometry (GdkWindow *window, if (!window) window = gdk_parent_root; - if (!GDK_DRAWABLE_DESTROYED (window)) + if (!GDK_WINDOW_DESTROYED (window)) { - XGetGeometry (GDK_DRAWABLE_XDISPLAY (window), - GDK_DRAWABLE_XID (window), + XGetGeometry (GDK_WINDOW_XDISPLAY (window), + GDK_WINDOW_XID (window), &root, &tx, &ty, &twidth, &theight, &tborder_width, &tdepth); if (x) @@ -1098,10 +1237,10 @@ gdk_window_get_origin (GdkWindow *window, g_return_val_if_fail (window != NULL, 0); - if (!GDK_DRAWABLE_DESTROYED (window)) + if (!GDK_WINDOW_DESTROYED (window)) { - return_val = XTranslateCoordinates (GDK_DRAWABLE_XDISPLAY (window), - GDK_DRAWABLE_XID (window), + return_val = XTranslateCoordinates (GDK_WINDOW_XDISPLAY (window), + GDK_WINDOW_XID (window), gdk_root_window, 0, 0, &tx, &ty, &child); @@ -1136,13 +1275,13 @@ gdk_window_get_deskrelative_origin (GdkWindow *window, g_return_val_if_fail (window != NULL, 0); g_return_val_if_fail (GDK_IS_WINDOW (window), 0); - if (!GDK_DRAWABLE_DESTROYED (window)) + if (!GDK_WINDOW_DESTROYED (window)) { if (!atom) atom = gdk_atom_intern ("ENLIGHTENMENT_DESKTOP", FALSE); - win = GDK_DRAWABLE_XID (window); + win = GDK_WINDOW_XID (window); - while (XQueryTree (GDK_DRAWABLE_XDISPLAY (window), win, &root, &parent, + while (XQueryTree (GDK_WINDOW_XDISPLAY (window), win, &root, &parent, &child, (unsigned int *)&num_children)) { if ((child) && (num_children > 0)) @@ -1157,7 +1296,7 @@ gdk_window_get_deskrelative_origin (GdkWindow *window, break; data_return = NULL; - XGetWindowProperty (GDK_DRAWABLE_XDISPLAY (window), win, atom, 0, 0, + XGetWindowProperty (GDK_WINDOW_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) @@ -1167,8 +1306,8 @@ gdk_window_get_deskrelative_origin (GdkWindow *window, } } - return_val = XTranslateCoordinates (GDK_DRAWABLE_XDISPLAY (window), - GDK_DRAWABLE_XID (window), + return_val = XTranslateCoordinates (GDK_WINDOW_XDISPLAY (window), + GDK_WINDOW_XID (window), win, 0, 0, &tx, &ty, &root); @@ -1187,7 +1326,7 @@ gdk_window_get_root_origin (GdkWindow *window, gint *x, gint *y) { - GdkWindowPrivate *private; + GdkWindowObject *private; Window xwindow; Window xparent; Window root; @@ -1197,25 +1336,25 @@ gdk_window_get_root_origin (GdkWindow *window, g_return_if_fail (window != NULL); g_return_if_fail (GDK_IS_WINDOW (window)); - private = (GdkWindowPrivate*) window; + private = (GdkWindowObject*) window; if (x) *x = 0; if (y) *y = 0; - if (GDK_DRAWABLE_DESTROYED (window)) + if (GDK_WINDOW_DESTROYED (window)) return; - while (private->parent && ((GdkWindowPrivate*) private->parent)->parent) - private = (GdkWindowPrivate*) private->parent; - if (GDK_DRAWABLE_DESTROYED (window)) + while (private->parent && ((GdkWindowObject*) private->parent)->parent) + private = (GdkWindowObject*) private->parent; + if (GDK_WINDOW_DESTROYED (window)) return; - xparent = GDK_DRAWABLE_XID (window); + xparent = GDK_WINDOW_XID (window); do { xwindow = xparent; - if (!XQueryTree (GDK_DRAWABLE_XDISPLAY (window), xwindow, + if (!XQueryTree (GDK_WINDOW_XDISPLAY (window), xwindow, &root, &xparent, &children, &nchildren)) return; @@ -1230,7 +1369,7 @@ gdk_window_get_root_origin (GdkWindow *window, unsigned int ww, wh, wb, wd; int wx, wy; - if (XGetGeometry (GDK_DRAWABLE_XDISPLAY (window), xwindow, &root, &wx, &wy, &ww, &wh, &wb, &wd)) + if (XGetGeometry (GDK_WINDOW_XDISPLAY (window), xwindow, &root, &wx, &wy, &ww, &wh, &wb, &wd)) { if (x) *x = wx; @@ -1263,9 +1402,9 @@ gdk_window_get_pointer (GdkWindow *window, _gdk_windowing_window_get_offsets (window, &xoffset, &yoffset); return_val = NULL; - if (!GDK_DRAWABLE_DESTROYED (window) && - XQueryPointer (GDK_DRAWABLE_XDISPLAY (window), - GDK_DRAWABLE_XID (window), + if (!GDK_WINDOW_DESTROYED (window) && + XQueryPointer (GDK_WINDOW_XDISPLAY (window), + GDK_WINDOW_XID (window), &root, &child, &rootx, &rooty, &winx, &winy, &xmask)) { if (child) @@ -1320,45 +1459,6 @@ gdk_window_at_pointer (gint *win_x, return window; } -GList* -gdk_window_get_children (GdkWindow *window) -{ - GdkWindow *child; - GList *children; - Window root; - Window parent; - Window *xchildren; - unsigned int nchildren; - unsigned int i; - - g_return_val_if_fail (window != NULL, NULL); - g_return_val_if_fail (GDK_IS_WINDOW (window), NULL); - - if (GDK_DRAWABLE_DESTROYED (window)) - return NULL; - - XQueryTree (GDK_DRAWABLE_XDISPLAY (window), - GDK_DRAWABLE_XID (window), - &root, &parent, &xchildren, &nchildren); - - children = NULL; - - if (nchildren > 0) - { - for (i = 0; i < nchildren; i++) - { - child = gdk_window_lookup (xchildren[i]); - if (child) - children = g_list_prepend (children, child); - } - - if (xchildren) - XFree (xchildren); - } - - return children; -} - GdkEventMask gdk_window_get_events (GdkWindow *window) { @@ -1369,12 +1469,12 @@ gdk_window_get_events (GdkWindow *window) g_return_val_if_fail (window != NULL, 0); g_return_val_if_fail (GDK_IS_WINDOW (window), 0); - if (GDK_DRAWABLE_DESTROYED (window)) + if (GDK_WINDOW_DESTROYED (window)) return 0; else { - XGetWindowAttributes (GDK_DRAWABLE_XDISPLAY (window), - GDK_DRAWABLE_XID (window), + XGetWindowAttributes (GDK_WINDOW_XDISPLAY (window), + GDK_WINDOW_XID (window), &attrs); event_mask = 0; @@ -1398,7 +1498,7 @@ gdk_window_set_events (GdkWindow *window, g_return_if_fail (window != NULL); g_return_if_fail (GDK_IS_WINDOW (window)); - if (!GDK_DRAWABLE_DESTROYED (window)) + if (!GDK_WINDOW_DESTROYED (window)) { xevent_mask = StructureNotifyMask; for (i = 0; i < gdk_nevent_masks; i++) @@ -1407,8 +1507,8 @@ gdk_window_set_events (GdkWindow *window, xevent_mask |= gdk_event_mask_table[i]; } - XSelectInput (GDK_DRAWABLE_XDISPLAY (window), - GDK_DRAWABLE_XID (window), + XSelectInput (GDK_WINDOW_XDISPLAY (window), + GDK_WINDOW_XID (window), xevent_mask); } } @@ -1425,19 +1525,19 @@ gdk_window_add_colormap_windows (GdkWindow *window) g_return_if_fail (GDK_IS_WINDOW (window)); toplevel = gdk_window_get_toplevel (window); - if (GDK_DRAWABLE_DESTROYED (toplevel)) + if (GDK_WINDOW_DESTROYED (toplevel)) return; old_windows = NULL; - if (!XGetWMColormapWindows (GDK_DRAWABLE_XDISPLAY (toplevel), - GDK_DRAWABLE_XID (toplevel), + if (!XGetWMColormapWindows (GDK_WINDOW_XDISPLAY (toplevel), + GDK_WINDOW_XID (toplevel), &old_windows, &count)) { count = 0; } for (i = 0; i < count; i++) - if (old_windows[i] == GDK_DRAWABLE_XID (window)) + if (old_windows[i] == GDK_WINDOW_XID (window)) { XFree (old_windows); return; @@ -1447,10 +1547,10 @@ gdk_window_add_colormap_windows (GdkWindow *window) for (i = 0; i < count; i++) new_windows[i] = old_windows[i]; - new_windows[count] = GDK_DRAWABLE_XID (window); + new_windows[count] = GDK_WINDOW_XID (window); - XSetWMColormapWindows (GDK_DRAWABLE_XDISPLAY (toplevel), - GDK_DRAWABLE_XID (toplevel), + XSetWMColormapWindows (GDK_WINDOW_XDISPLAY (toplevel), + GDK_WINDOW_XID (toplevel), new_windows, count + 1); g_free (new_windows); @@ -1492,14 +1592,14 @@ gdk_window_shape_combine_mask (GdkWindow *window, g_return_if_fail (GDK_IS_WINDOW (window)); #ifdef HAVE_SHAPE_EXT - if (GDK_DRAWABLE_DESTROYED (window)) + if (GDK_WINDOW_DESTROYED (window)) return; if (gdk_window_have_shape_ext ()) { if (mask) { - pixmap = GDK_DRAWABLE_XID (mask); + pixmap = GDK_PIXMAP_XID (mask); } else { @@ -1508,8 +1608,8 @@ gdk_window_shape_combine_mask (GdkWindow *window, pixmap = None; } - XShapeCombineMask (GDK_DRAWABLE_XDISPLAY (window), - GDK_DRAWABLE_XID (window), + XShapeCombineMask (GDK_WINDOW_XDISPLAY (window), + GDK_WINDOW_XID (window), ShapeBounding, x, y, pixmap, @@ -1527,11 +1627,11 @@ gdk_window_set_override_redirect (GdkWindow *window, g_return_if_fail (window != NULL); g_return_if_fail (GDK_IS_WINDOW (window)); - if (GDK_DRAWABLE_DESTROYED (window)) + if (GDK_WINDOW_DESTROYED (window)) { attr.override_redirect = (override_redirect == FALSE)?False:True; - XChangeWindowAttributes (GDK_DRAWABLE_XDISPLAY (window), - GDK_DRAWABLE_XID (window), + XChangeWindowAttributes (GDK_WINDOW_XDISPLAY (window), + GDK_WINDOW_XID (window), CWOverrideRedirect, &attr); } @@ -1548,34 +1648,34 @@ gdk_window_set_icon (GdkWindow *window, g_return_if_fail (window != NULL); g_return_if_fail (GDK_IS_WINDOW (window)); - if (GDK_DRAWABLE_DESTROYED (window)) + if (GDK_WINDOW_DESTROYED (window)) return; - wm_hints = XGetWMHints (GDK_DRAWABLE_XDISPLAY (window), - GDK_DRAWABLE_XID (window)); + wm_hints = XGetWMHints (GDK_WINDOW_XDISPLAY (window), + GDK_WINDOW_XID (window)); if (!wm_hints) wm_hints = XAllocWMHints (); if (icon_window != NULL) { wm_hints->flags |= IconWindowHint; - wm_hints->icon_window = GDK_DRAWABLE_XID (icon_window); + wm_hints->icon_window = GDK_WINDOW_XID (icon_window); } if (pixmap != NULL) { wm_hints->flags |= IconPixmapHint; - wm_hints->icon_pixmap = GDK_DRAWABLE_XID (pixmap); + wm_hints->icon_pixmap = GDK_PIXMAP_XID (pixmap); } if (mask != NULL) { wm_hints->flags |= IconMaskHint; - wm_hints->icon_mask = GDK_DRAWABLE_XID (mask); + wm_hints->icon_mask = GDK_PIXMAP_XID (mask); } - XSetWMHints (GDK_DRAWABLE_XDISPLAY (window), - GDK_DRAWABLE_XID (window), wm_hints); + XSetWMHints (GDK_WINDOW_XDISPLAY (window), + GDK_WINDOW_XID (window), wm_hints); XFree (wm_hints); } @@ -1589,10 +1689,10 @@ gdk_window_set_icon_name (GdkWindow *window, g_return_if_fail (window != NULL); g_return_if_fail (GDK_IS_WINDOW (window)); - if (GDK_DRAWABLE_DESTROYED (window)) + if (GDK_WINDOW_DESTROYED (window)) return; - res = XmbTextListToTextProperty (GDK_DRAWABLE_XDISPLAY (window), + res = XmbTextListToTextProperty (GDK_WINDOW_XDISPLAY (window), &name, 1, XStdICCTextStyle, &property); if (res < 0) @@ -1601,8 +1701,8 @@ gdk_window_set_icon_name (GdkWindow *window, return; } - XSetWMIconName (GDK_DRAWABLE_XDISPLAY (window), - GDK_DRAWABLE_XID (window), + XSetWMIconName (GDK_WINDOW_XDISPLAY (window), + GDK_WINDOW_XID (window), &property); if (property.value) @@ -1620,19 +1720,19 @@ gdk_window_set_group (GdkWindow *window, g_return_if_fail (leader != NULL); g_return_if_fail (GDK_IS_WINDOW (leader)); - if (GDK_DRAWABLE_DESTROYED (window) || GDK_DRAWABLE_DESTROYED (leader)) + if (GDK_WINDOW_DESTROYED (window) || GDK_WINDOW_DESTROYED (leader)) return; - wm_hints = XGetWMHints (GDK_DRAWABLE_XDISPLAY (window), - GDK_DRAWABLE_XID (window)); + wm_hints = XGetWMHints (GDK_WINDOW_XDISPLAY (window), + GDK_WINDOW_XID (window)); if (!wm_hints) wm_hints = XAllocWMHints (); wm_hints->flags |= WindowGroupHint; - wm_hints->window_group = GDK_DRAWABLE_XID (leader); + wm_hints->window_group = GDK_WINDOW_XID (leader); - XSetWMHints (GDK_DRAWABLE_XDISPLAY (window), - GDK_DRAWABLE_XID (window), wm_hints); + XSetWMHints (GDK_WINDOW_XDISPLAY (window), + GDK_WINDOW_XID (window), wm_hints); XFree (wm_hints); } @@ -1647,14 +1747,14 @@ gdk_window_set_mwm_hints (GdkWindow *window, gulong nitems; gulong bytes_after; - if (GDK_DRAWABLE_DESTROYED (window)) + if (GDK_WINDOW_DESTROYED (window)) return; if (!hints_atom) - hints_atom = XInternAtom (GDK_DRAWABLE_XDISPLAY (window), + hints_atom = XInternAtom (GDK_WINDOW_XDISPLAY (window), _XA_MOTIF_WM_HINTS, FALSE); - XGetWindowProperty (GDK_DRAWABLE_XDISPLAY (window), GDK_DRAWABLE_XID (window), + XGetWindowProperty (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XID (window), hints_atom, 0, sizeof (MotifWmHints)/sizeof (long), False, AnyPropertyType, &type, &format, &nitems, &bytes_after, (guchar **)&hints); @@ -1675,7 +1775,7 @@ gdk_window_set_mwm_hints (GdkWindow *window, } } - XChangeProperty (GDK_DRAWABLE_XDISPLAY (window), GDK_DRAWABLE_XID (window), + XChangeProperty (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XID (window), hints_atom, hints_atom, 32, PropModeReplace, (guchar *)hints, sizeof (MotifWmHints)/sizeof (long)); @@ -2032,10 +2132,10 @@ gdk_window_set_child_shapes (GdkWindow *window) g_return_if_fail (GDK_IS_WINDOW (window)); #ifdef HAVE_SHAPE_EXT - if (!GDK_DRAWABLE_DESTROYED (window) && + if (!GDK_WINDOW_DESTROYED (window) && gdk_window_have_shape_ext ()) - gdk_propagate_shapes (GDK_DRAWABLE_XDISPLAY (window), - GDK_DRAWABLE_XID (window), FALSE); + gdk_propagate_shapes (GDK_WINDOW_XDISPLAY (window), + GDK_WINDOW_XID (window), FALSE); #endif } @@ -2046,10 +2146,10 @@ gdk_window_merge_child_shapes (GdkWindow *window) g_return_if_fail (GDK_IS_WINDOW (window)); #ifdef HAVE_SHAPE_EXT - if (!GDK_DRAWABLE_DESTROYED (window) && + if (!GDK_WINDOW_DESTROYED (window) && gdk_window_have_shape_ext ()) - gdk_propagate_shapes (GDK_DRAWABLE_XDISPLAY (window), - GDK_DRAWABLE_XID (window), TRUE); + gdk_propagate_shapes (GDK_WINDOW_XDISPLAY (window), + GDK_WINDOW_XID (window), TRUE); #endif } @@ -2125,8 +2225,8 @@ gdk_window_set_static_bit_gravity (GdkWindow *window, gboolean on) xattributes.bit_gravity = StaticGravity; xattributes_mask |= CWBitGravity; xattributes.bit_gravity = on ? StaticGravity : ForgetGravity; - XChangeWindowAttributes (GDK_DRAWABLE_XDISPLAY (window), - GDK_DRAWABLE_XID (window), + XChangeWindowAttributes (GDK_WINDOW_XDISPLAY (window), + GDK_WINDOW_XID (window), CWBitGravity, &xattributes); } @@ -2139,8 +2239,8 @@ gdk_window_set_static_win_gravity (GdkWindow *window, gboolean on) xattributes.win_gravity = on ? StaticGravity : NorthWestGravity; - XChangeWindowAttributes (GDK_DRAWABLE_XDISPLAY (window), - GDK_DRAWABLE_XID (window), + XChangeWindowAttributes (GDK_WINDOW_XDISPLAY (window), + GDK_WINDOW_XID (window), CWWinGravity, &xattributes); } @@ -2160,7 +2260,7 @@ gboolean gdk_window_set_static_gravities (GdkWindow *window, gboolean use_static) { - GdkWindowPrivate *private = (GdkWindowPrivate *)window; + GdkWindowObject *private = (GdkWindowObject *)window; GList *tmp_list; g_return_val_if_fail (window != NULL, FALSE); @@ -2174,7 +2274,7 @@ gdk_window_set_static_gravities (GdkWindow *window, private->guffaw_gravity = use_static; - if (!GDK_DRAWABLE_DESTROYED (window)) + if (!GDK_WINDOW_DESTROYED (window)) { gdk_window_set_static_bit_gravity (window, use_static); @@ -2262,7 +2362,6 @@ gdk_window_xid_at_coords (gint x, gboolean excl_child) { GdkWindow *window; - GdkDrawablePrivate *private; Display *xdisplay; Window *list = NULL; Window root, child = 0, parent_win = 0, root_win = 0; @@ -2270,9 +2369,8 @@ gdk_window_xid_at_coords (gint x, int i; window = gdk_parent_root; - private = (GdkDrawablePrivate*) window; - xdisplay = GDK_DRAWABLE_XDISPLAY (private); - root = GDK_DRAWABLE_XID (private); + xdisplay = GDK_WINDOW_XDISPLAY (window); + root = GDK_WINDOW_XID (window); num = g_list_length (excludes); XGrabServer (xdisplay); diff --git a/gdk/x11/gdkwindow-x11.h b/gdk/x11/gdkwindow-x11.h new file mode 100644 index 0000000000..3e35c5a162 --- /dev/null +++ b/gdk/x11/gdkwindow-x11.h @@ -0,0 +1,89 @@ +/* GDK - The GIMP Drawing Kit + * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +/* + * Modified by the GTK+ Team and others 1997-1999. See the AUTHORS + * file for a list of people on the GTK+ Team. See the ChangeLog + * files for a list of changes. These files are distributed with + * GTK+ at ftp://ftp.gtk.org/pub/gtk/. + */ + +#ifndef __GDK_WINDOW_X11_H__ +#define __GDK_WINDOW_X11_H__ + +#include <gdk/x11/gdkdrawable-x11.h> + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +typedef struct _GdkXPositionInfo GdkXPositionInfo; + +struct _GdkXPositionInfo +{ + gint x; + gint y; + gint width; + gint height; + gint x_offset; /* Offsets to add to X coordinates within window */ + gint y_offset; /* to get GDK coodinates within window */ + gboolean big : 1; + gboolean mapped : 1; + gboolean no_bg : 1; /* Set when the window background is temporarily + * unset during resizing and scaling */ + GdkRectangle clip_rect; /* visible rectangle of window */ +}; + + +/* Window implementation for X11 + */ + +typedef struct _GdkWindowImplX11 GdkWindowImplX11; +typedef struct _GdkWindowImplX11Class GdkWindowImplX11Class; + +#define GDK_TYPE_WINDOW_IMPL_X11 (gdk_window_impl_x11_get_type ()) +#define GDK_WINDOW_IMPL_X11(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_WINDOW_IMPL_X11, GdkWindowImplX11)) +#define GDK_WINDOW_IMPL_X11_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_WINDOW_IMPL_X11, GdkWindowImplX11Class)) +#define GDK_IS_WINDOW_IMPL_X11(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_WINDOW_IMPL_X11)) +#define GDK_IS_WINDOW_IMPL_X11_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_WINDOW_IMPL_X11)) +#define GDK_WINDOW_IMPL_X11_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_WINDOW_IMPL_X11, GdkWindowImplX11Class)) + +struct _GdkWindowImplX11 +{ + GdkDrawableImplX11 parent_instance; + + gint width; + gint height; + + GdkXPositionInfo position_info; +}; + +struct _GdkWindowImplX11Class +{ + GdkDrawableImplX11Class parent_class; + +}; + +GType gdk_window_impl_x11_get_type (void); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* __GDK_WINDOW_X11_H__ */ diff --git a/gdk/x11/gdkx.h b/gdk/x11/gdkx.h index 29d8e8fb4d..a418e25e27 100644 --- a/gdk/x11/gdkx.h +++ b/gdk/x11/gdkx.h @@ -33,59 +33,20 @@ #include <X11/Xlib.h> #include <X11/Xutil.h> -typedef struct _GdkGCXData GdkGCXData; -typedef struct _GdkDrawableXData GdkDrawableXData; -typedef struct _GdkWindowXData GdkWindowXData; -typedef struct _GdkXPositionInfo GdkXPositionInfo; -typedef struct _GdkColormapPrivateX GdkColormapPrivateX; -typedef struct _GdkCursorPrivate GdkCursorPrivate; -typedef struct _GdkFontPrivateX GdkFontPrivateX; -typedef struct _GdkImagePrivateX GdkImagePrivateX; -typedef struct _GdkVisualPrivate GdkVisualPrivate; +#include <gdk/x11/gdkwindow-x11.h> +#include <gdk/x11/gdkpixmap-x11.h> + +typedef struct _GdkGCXData GdkGCXData; +typedef struct _GdkColormapPrivateX11 GdkColormapPrivateX11; +typedef struct _GdkCursorPrivate GdkCursorPrivate; +typedef struct _GdkFontPrivateX GdkFontPrivateX; +typedef struct _GdkImagePrivateX11 GdkImagePrivateX11; +typedef struct _GdkVisualPrivate GdkVisualPrivate; #ifdef USE_XIM typedef struct _GdkICPrivate GdkICPrivate; #endif /* USE_XIM */ -#define GDK_DRAWABLE_XDATA(win) ((GdkDrawableXData *)(((GdkDrawablePrivate*)(win))->klass_data)) -#define GDK_WINDOW_XDATA(win) ((GdkWindowXData *)(((GdkDrawablePrivate*)(win))->klass_data)) -#define GDK_GC_XDATA(gc) ((GdkGCXData *)(((GdkGCPrivate*)(gc))->klass_data)) - -struct _GdkGCXData -{ - GC xgc; - Display *xdisplay; - GdkRegion *clip_region; - guint dirty_mask; -}; - -struct _GdkDrawableXData -{ - Window xid; - Display *xdisplay; -}; - -struct _GdkXPositionInfo -{ - gint x; - gint y; - gint width; - gint height; - gint x_offset; /* Offsets to add to X coordinates within window */ - gint y_offset; /* to get GDK coodinates within window */ - gboolean big : 1; - gboolean mapped : 1; - gboolean no_bg : 1; /* Set when the window background is temporarily - * unset during resizing and scaling */ - GdkRectangle clip_rect; /* visible rectangle of window */ -}; - -struct _GdkWindowXData -{ - GdkDrawableXData drawable_data; - GdkXPositionInfo position_info; -}; - struct _GdkCursorPrivate { GdkCursor cursor; @@ -110,10 +71,8 @@ struct _GdkVisualPrivate Visual *xvisual; }; -struct _GdkColormapPrivateX +struct _GdkColormapPrivateX11 { - GdkColormapPrivate base; - Colormap xcolormap; Display *xdisplay; gint private_val; @@ -123,10 +82,8 @@ struct _GdkColormapPrivateX time_t last_sync_time; }; -struct _GdkImagePrivateX +struct _GdkImagePrivateX11 { - GdkImagePrivate base; - XImage *ximage; Display *xdisplay; gpointer x_shm_info; @@ -144,25 +101,56 @@ struct _GdkICPrivate #endif /* USE_XIM */ + +typedef struct _GdkGCX11 GdkGCX11; +typedef struct _GdkGCX11Class GdkGCX11Class; + +#define GDK_TYPE_GC_X11 (gdk_gc_x11_get_type ()) +#define GDK_GC_X11(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_GC_X11, GdkGCX11)) +#define GDK_GC_X11_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_GC_X11, GdkGCX11Class)) +#define GDK_IS_GC_X11(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_GC_X11)) +#define GDK_IS_GC_X11_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_GC_X11)) +#define GDK_GC_X11_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_GC_X11, GdkGCX11Class)) + +struct _GdkGCX11 +{ + GdkGC parent_instance; + + GC xgc; + Display *xdisplay; + GdkRegion *clip_region; + guint dirty_mask; +}; + +struct _GdkGCX11Class +{ + GdkGCClass parent_class; + +}; + +GType gdk_gc_x11_get_type (void); + #define GDK_ROOT_WINDOW() gdk_root_window #define GDK_ROOT_PARENT() ((GdkWindow *)gdk_parent_root) #define GDK_DISPLAY() gdk_display -#define GDK_DRAWABLE_XDISPLAY(win) (GDK_DRAWABLE_XDATA(win)->xdisplay) -#define GDK_DRAWABLE_XID(win) (GDK_DRAWABLE_XDATA(win)->xid) -#define GDK_IMAGE_XDISPLAY(image) (((GdkImagePrivate*) image)->xdisplay) -#define GDK_IMAGE_XIMAGE(image) (((GdkImagePrivate*) image)->ximage) -#define GDK_GC_XDISPLAY(gc) (GDK_GC_XDATA(gc)->xdisplay) -#define GDK_COLORMAP_XDISPLAY(cmap) (((GdkColormapPrivateX *)cmap)->xdisplay) -#define GDK_COLORMAP_XCOLORMAP(cmap) (((GdkColormapPrivateX *)cmap)->xcolormap) -#define GDK_VISUAL_XVISUAL(vis) (((GdkVisualPrivate*) vis)->xvisual) -#define GDK_FONT_XDISPLAY(font) (((GdkFontPrivate*) font)->xdisplay) +#define GDK_WINDOW_XDISPLAY(win) (GDK_DRAWABLE_IMPL_X11(((GdkWindowObject *)win)->impl)->xdisplay) +#define GDK_WINDOW_XID(win) (GDK_DRAWABLE_IMPL_X11(((GdkWindowObject *)win)->impl)->xid) +#define GDK_PIXMAP_XDISPLAY(win) (GDK_DRAWABLE_IMPL_X11(((GdkPixmapObject *)win)->impl)->xdisplay) +#define GDK_PIXMAP_XID(win) (GDK_DRAWABLE_IMPL_X11(((GdkPixmapObject *)win)->impl)->xid) +#define GDK_DRAWABLE_XDISPLAY(win) (GDK_IS_WINDOW (win) ? GDK_WINDOW_XDISPLAY (win) : GDK_PIXMAP_XDISPLAY (win)) +#define GDK_DRAWABLE_XID(win) (GDK_IS_WINDOW (win) ? GDK_WINDOW_XID (win) : GDK_PIXMAP_XID (win)) +#define GDK_IMAGE_XDISPLAY(image) (((GdkImagePrivateX11 *) GDK_IMAGE (image)->windowing_data)->xdisplay) +#define GDK_IMAGE_XIMAGE(image) (((GdkImagePrivateX11 *) GDK_IMAGE (image)->windowing_data)->ximage) +#define GDK_GC_XDISPLAY(gc) (GDK_GC_X11(gc)->xdisplay) +#define GDK_COLORMAP_XDISPLAY(cmap) (((GdkColormapPrivateX11 *)GDK_COLORMAP (cmap)->windowing_data)->xdisplay) +#define GDK_COLORMAP_XCOLORMAP(cmap) (((GdkColormapPrivateX11 *)GDK_COLORMAP (cmap)->windowing_data)->xcolormap) +#define GDK_VISUAL_XVISUAL(vis) (((GdkVisualPrivate *) vis)->xvisual) +#define GDK_FONT_XDISPLAY(font) (((GdkFontPrivate *) font)->xdisplay) #define GDK_FONT_XFONT(font) (((GdkFontPrivateX *)font)->xfont) -#define GDK_GC_XGC(gc) (GDK_GC_XDATA(gc)->xgc) -#define GDK_GC_GET_XGC(gc) (GDK_GC_XDATA(gc)->dirty_mask ? _gdk_x11_gc_flush (gc) : GDK_GC_XGC (gc)) - -#define GDK_WINDOW_XWINDOW GDK_DRAWABLE_XID -#define GDK_WINDOW_XDISPLAY GDK_DRAWABLE_XDISPLAY +#define GDK_GC_XGC(gc) (GDK_GC_X11(gc)->xgc) +#define GDK_GC_GET_XGC(gc) (GDK_GC_X11(gc)->dirty_mask ? _gdk_x11_gc_flush (gc) : GDK_GC_XGC (gc)) +#define GDK_WINDOW_XWINDOW GDK_DRAWABLE_XID extern Display *gdk_display; extern Window gdk_root_window; |