* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
-#include "../config.h"
+
+/*
+ * 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/.
+ */
+
+#include "config.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
if (depth == -1)
depth = gdk_window_get_visual (window)->depth;
- private = g_new (GdkWindowPrivate, 1);
+ private = g_new0 (GdkWindowPrivate, 1);
pixmap = (GdkPixmap*) private;
private->xdisplay = window_private->xdisplay;
}
GdkPixmap *
-gdk_bitmap_create_from_data (GdkWindow *window,
- gchar *data,
- gint width,
- gint height)
+gdk_bitmap_create_from_data (GdkWindow *window,
+ const gchar *data,
+ gint width,
+ gint height)
{
GdkPixmap *pixmap;
GdkWindowPrivate *private;
if (window_private->destroyed)
return NULL;
- private = g_new (GdkWindowPrivate, 1);
+ private = g_new0 (GdkWindowPrivate, 1);
pixmap = (GdkPixmap*) private;
private->parent = NULL;
private->xwindow = XCreateBitmapFromData (private->xdisplay,
window_private->xwindow,
- data, width, height);
+ (char *)data, width, height);
gdk_xid_table_insert (&private->xwindow, pixmap);
}
GdkPixmap*
-gdk_pixmap_create_from_data (GdkWindow *window,
- gchar *data,
- gint width,
- gint height,
- gint depth,
- GdkColor *fg,
- GdkColor *bg)
+gdk_pixmap_create_from_data (GdkWindow *window,
+ const gchar *data,
+ gint width,
+ gint height,
+ gint depth,
+ GdkColor *fg,
+ GdkColor *bg)
{
GdkPixmap *pixmap;
GdkWindowPrivate *private;
if (depth == -1)
depth = gdk_window_get_visual (window)->depth;
- private = g_new (GdkWindowPrivate, 1);
+ private = g_new0 (GdkWindowPrivate, 1);
pixmap = (GdkPixmap*) private;
private->parent = NULL;
private->xwindow = XCreatePixmapFromBitmapData (private->xdisplay,
window_private->xwindow,
- data, width, height,
+ (char *)data, width, height,
fg->pixel, bg->pixel, depth);
gdk_xid_table_insert (&private->xwindow, pixmap);
color_name = gdk_pixmap_extract_color (buffer);
- if (color_name == NULL ||
+ if (color_name == NULL || g_strcasecmp (color_name, "None") == 0 ||
gdk_color_parse (color_name, &color->color) == FALSE)
{
color->color = *transparent_color;
transparent_color, data);
}
+GdkPixmap*
+gdk_pixmap_foreign_new (guint32 anid)
+{
+ GdkPixmap *pixmap;
+ GdkWindowPrivate *window_private;
+ GdkWindowPrivate *private;
+ Pixmap xpixmap;
+ Window root_return;
+ unsigned int x_ret, y_ret, w_ret, h_ret, bw_ret, depth_ret;
+
+ /* check to make sure we were passed something at
+ least a little sane */
+ g_return_val_if_fail((anid != 0), NULL);
+
+ /* set the pixmap to the passed in value */
+ xpixmap = anid;
+ /* get the root window */
+ window_private = &gdk_root_parent;
+
+ /* get information about the Pixmap to fill in the structure for
+ the gdk window */
+ if (!XGetGeometry(window_private->xdisplay, xpixmap, &root_return,
+ &x_ret, &y_ret, &w_ret, &h_ret, &bw_ret, &depth_ret))
+ return NULL;
+
+ /* allocate a new gdk pixmap */
+ private = g_new(GdkWindowPrivate, 1);
+ pixmap = (GdkPixmap *)private;
+
+ private->xdisplay = window_private->xdisplay;
+ private->window_type = GDK_WINDOW_PIXMAP;
+ private->xwindow = xpixmap;
+ private->colormap = NULL;
+ private->parent = NULL;
+ private->x = 0;
+ private->y = 0;
+ private->width = w_ret;
+ private->height = h_ret;
+ private->resize_count = 0;
+ private->ref_count = 1;
+ private->destroyed = 0;
+
+ gdk_xid_table_insert(&private->xwindow, pixmap);
+
+ return pixmap;
+}
+
GdkPixmap*
gdk_pixmap_ref (GdkPixmap *pixmap)
{
gdk_pixmap_unref (GdkPixmap *pixmap)
{
GdkWindowPrivate *private = (GdkWindowPrivate *)pixmap;
- g_return_if_fail(pixmap != NULL);
+ g_return_if_fail (pixmap != NULL);
+ g_return_if_fail (private->ref_count > 0);
private->ref_count -= 1;
if (private->ref_count == 0)