summaryrefslogtreecommitdiff
path: root/gdk/x11/gdkimage-x11.c
diff options
context:
space:
mode:
authorOwen Taylor <otaylor@redhat.com>2002-08-01 15:28:40 +0000
committerOwen Taylor <otaylor@src.gnome.org>2002-08-01 15:28:40 +0000
commite5ae081ebea69057c9e9da5175869b87b0972ed0 (patch)
treee6be8246d4b84e8cfbe2c859de97683065211344 /gdk/x11/gdkimage-x11.c
parentd202b55bc05460d36b759de33b93cfea0f9870c7 (diff)
downloadgtk+-e5ae081ebea69057c9e9da5175869b87b0972ed0.tar.gz
Start implementing display/screen closing scheme; keep a flag for whether
Thu Aug 1 11:26:03 2002 Owen Taylor <otaylor@redhat.com> * gdk/gdkdisplay.[ch] gdk/gdkscreen.[ch] gdkinternals.h: Start implementing display/screen closing scheme; keep a flag for whether displays and screens are closed, call g_object_run_dispose(). Remove public gdk_screen_close(). * gdk/x11/gdkdisplay-x11.c gdk/x11/gdkscreen-x11.c: Add dispose() methods; move appropriate parts of the finalize there. * gdk/x11/gdkcolor-x11.c gdk/x11/gdkimage-x11.c gdk/x11/gdkmain-x11.c gdk/x11/gdkpango-x11.c gdk/x11/gdkpixmap-x11.c gdk/x11/gdkproperty-x11.c gdk/x11/gdkselection-x11.c gdk/x11/gdkwindow-x11.c: Start of making everything correctly ignore operations when a display has been closed. * gdk/x11/gdkwindow-x11.c (gdk_window_get_decorations): Handle decorations == NULL. * gdk/x11/gdkcolor-x11.c (gdk_colormap_remove): Remove unnecessary hash table creation. * gdk/x11/gdkinput.c gdk/x11/gdkinput-x11.c gdk/win32/gdkinput.c Fix up gdk_device_get_history - handle events, n_events == NULL, etc. * gdk/x11/gdkproperty-x11.c (gdk_property_get): Handle failure better. * gdk/x11/gdkselection-x11.c (gdk_selection_property_get): Handle failure better, handle data == NULL, move docs here, remove an excess round trip by asking for all selection data at once. * gdk/gdkselection.c gdk/win32/{x11,win32}/gdkselection-{x11,win32}.c gdk/{x11,win32}/gdkmain-{x11,win32}.c gdk/gdkdisplay.c: Move gdk_text_property_to_text_list(), gdk_string_to_compound_text(), gdk_display_set_sm_client_id() to display-independent part of GDK. * gdk/Makefile.am (gdk_c_sources): Sort gdkdisplay/screen.[ch] into the right place.
Diffstat (limited to 'gdk/x11/gdkimage-x11.c')
-rw-r--r--gdk/x11/gdkimage-x11.c80
1 files changed, 59 insertions, 21 deletions
diff --git a/gdk/x11/gdkimage-x11.c b/gdk/x11/gdkimage-x11.c
index 7836c06bd5..6bbff5fc30 100644
--- a/gdk/x11/gdkimage-x11.c
+++ b/gdk/x11/gdkimage-x11.c
@@ -142,28 +142,49 @@ _gdk_image_exit (void)
}
}
+/**
+ * gdk_image_new_bitmap:
+ * @visual: the #GdkVisual to use for the image.
+ * @data: the pixel data.
+ * @w: the width of the image in pixels.
+ * @h: the height of the image in pixels.
+ *
+ * Creates a new #GdkImage with a depth of 1 from the given data.
+ * <warning><para>THIS FUNCTION IS INCREDIBLY BROKEN. The passed-in data must
+ * be allocated by malloc() (NOT g_malloc()) and will be freed when the
+ * image is freed.</para></warning>
+ *
+ * Return value: a new #GdkImage.
+ **/
GdkImage *
gdk_image_new_bitmap(GdkVisual *visual, gpointer data, gint w, gint h)
-/*
- * Desc: create a new bitmap image
- */
{
Visual *xvisual;
GdkImage *image;
+ GdkDisplay *display;
GdkImagePrivateX11 *private;
+
image = g_object_new (gdk_image_get_type (), NULL);
private = PRIVATE_DATA (image);
private->screen = gdk_visual_get_screen (visual);
+ display = GDK_SCREEN_DISPLAY (private->screen);
+
image->type = GDK_IMAGE_NORMAL;
image->visual = visual;
image->width = w;
image->height = h;
image->depth = 1;
image->bits_per_pixel = 1;
- xvisual = ((GdkVisualPrivate*) visual)->xvisual;
- private->ximage = XCreateImage (GDK_SCREEN_XDISPLAY (private->screen),
- xvisual, 1, XYBitmap,
- 0, 0, w ,h, 8, 0);
+ if (display->closed)
+ private->ximage = NULL;
+ else
+ {
+ xvisual = ((GdkVisualPrivate*) visual)->xvisual;
+ private->ximage = XCreateImage (GDK_SCREEN_XDISPLAY (private->screen),
+ xvisual, 1, XYBitmap,
+ 0, 0, w ,h, 8, 0);
+ }
+
private->ximage->data = data;
private->ximage->bitmap_bit_order = MSBFirst;
private->ximage->byte_order = MSBFirst;
@@ -174,14 +195,14 @@ gdk_image_new_bitmap(GdkVisual *visual, gpointer data, gint w, gint h)
return(image);
} /* gdk_image_new_bitmap() */
-static int
-gdk_image_check_xshm(Display *display)
/*
* Desc: query the server for support for the MIT_SHM extension
* Return: 0 = not available
* 1 = shared XImage support available
* 2 = shared Pixmap support available also
*/
+static int
+gdk_image_check_xshm(Display *display)
{
#ifdef USE_SHM
int major, minor, ignore;
@@ -410,6 +431,9 @@ _gdk_x11_image_get_shm_pixmap (GdkImage *image)
GdkImagePrivateX11 *private = PRIVATE_DATA (image);
GdkDisplay *display = GDK_SCREEN_DISPLAY (private->screen);
+ if (display->closed)
+ return None;
+
#ifdef USE_SHM
/* Future: do we need one of these per-screen per-image? ShmPixmaps
* are the same for every screen, but can they be shared? Not a concern
@@ -500,7 +524,9 @@ _gdk_x11_copy_to_image (GdkDrawable *drawable,
impl = GDK_DRAWABLE_IMPL_X11 (drawable);
display = gdk_drawable_get_display (drawable);
xdisplay = gdk_x11_display_get_xdisplay (display);
-
+
+ if (display->closed)
+ return NULL;
have_grab = FALSE;
@@ -674,7 +700,10 @@ gdk_image_get_pixel (GdkImage *image,
private = PRIVATE_DATA (image);
- pixel = XGetPixel (private->ximage, x, y);
+ if (!private->screen->closed)
+ pixel = XGetPixel (private->ximage, x, y);
+ else
+ pixel = 0;
return pixel;
}
@@ -691,7 +720,8 @@ gdk_image_put_pixel (GdkImage *image,
private = PRIVATE_DATA (image);
- pixel = XPutPixel (private->ximage, x, y, pixel);
+ if (!private->screen->closed)
+ pixel = XPutPixel (private->ximage, x, y, pixel);
}
static void
@@ -717,20 +747,25 @@ gdk_x11_image_destroy (GdkImage *image)
switch (image->type)
{
case GDK_IMAGE_NORMAL:
- XDestroyImage (private->ximage);
+ if (!private->screen->closed)
+ XDestroyImage (private->ximage);
break;
case GDK_IMAGE_SHARED:
#ifdef USE_SHM
- gdk_display_sync (GDK_SCREEN_DISPLAY (private->screen));
+ if (!private->screen->closed)
+ {
+ gdk_display_sync (GDK_SCREEN_DISPLAY (private->screen));
- if (private->shm_pixmap)
- XFreePixmap (GDK_SCREEN_XDISPLAY (private->screen), private->shm_pixmap);
+ if (private->shm_pixmap)
+ XFreePixmap (GDK_SCREEN_XDISPLAY (private->screen), private->shm_pixmap);
- image_list = g_list_remove (image_list, image);
- XShmDetach (GDK_SCREEN_XDISPLAY (private->screen), private->x_shm_info);
- XDestroyImage (private->ximage);
+ XShmDetach (GDK_SCREEN_XDISPLAY (private->screen), private->x_shm_info);
+ XDestroyImage (private->ximage);
+ }
+ image_list = g_list_remove (image_list, image);
+
x_shm_info = private->x_shm_info;
shmdt (x_shm_info->shmaddr);
@@ -772,7 +807,10 @@ gdk_x11_image_get_ximage (GdkImage *image)
private = PRIVATE_DATA (image);
- return private->ximage;
+ if (private->screen->closed)
+ return NULL;
+ else
+ return private->ximage;
}
gint
@@ -781,7 +819,7 @@ _gdk_windowing_get_bits_for_depth (GdkDisplay *display,
{
XPixmapFormatValues *formats;
gint count, i;
-
+
formats = XListPixmapFormats (GDK_DISPLAY_XDISPLAY (display), &count);
for (i = 0; i < count; i++)