summaryrefslogtreecommitdiff
path: root/gdk/x11
diff options
context:
space:
mode:
authorOwen Taylor <otaylor@redhat.com>2000-06-26 22:55:42 +0000
committerOwen Taylor <otaylor@src.gnome.org>2000-06-26 22:55:42 +0000
commit2bb4bcff5d757075502019b0838677c9895ee5b7 (patch)
treea0a87e3be5ee54a526f57d8dfef7623d646702dc /gdk/x11
parentd872631baef94ce39ce76c5b86d1f42865cd2968 (diff)
downloadgdk-pixbuf-2bb4bcff5d757075502019b0838677c9895ee5b7.tar.gz
If possible, create only a single shm segment and use multiple parts of it
Mon Jun 26 18:53:31 2000 Owen Taylor <otaylor@redhat.com> * gdk/gdkrgb.c: If possible, create only a single shm segment and use multiple parts of it instead of creating a bunch of separate segments, since the maximum number of segments per system is not large. (This might be worth backporting to GTK+-1.2.x if we make a new release ) * gdk/gdkrgb.c: Localize a bunch of variables into the GdkRgbInfo structure in preparation for per-colormap GdkRGB. * gdk/x11/gdkimage-x11.c (gdk_image_new): Don't set gdk_use_xshm to False when we get EINVAL from shmget so that the caller of gdk_image_new can retry with a smaller segment size.
Diffstat (limited to 'gdk/x11')
-rw-r--r--gdk/x11/gdkimage-x11.c58
1 files changed, 34 insertions, 24 deletions
diff --git a/gdk/x11/gdkimage-x11.c b/gdk/x11/gdkimage-x11.c
index e9730dba2..ad42dc583 100644
--- a/gdk/x11/gdkimage-x11.c
+++ b/gdk/x11/gdkimage-x11.c
@@ -53,6 +53,8 @@
#include <X11/extensions/XShm.h>
#endif /* USE_SHM */
+#include <errno.h>
+
#include "gdk.h" /* For gdk_error_trap_* / gdk_flush_* */
#include "gdkimage.h"
#include "gdkprivate.h"
@@ -142,28 +144,28 @@ gdk_image_new_bitmap(GdkVisual *visual, gpointer data, gint w, gint h)
* Desc: create a new bitmap image
*/
{
- Visual *xvisual;
- GdkImage *image;
- GdkImagePrivateX11 *private;
- image = GDK_IMAGE (g_type_create_instance (gdk_image_get_type ()));
- private = PRIVATE_DATA (image);
- private->xdisplay = gdk_display;
- image->type = GDK_IMAGE_NORMAL;
- image->visual = visual;
- image->width = w;
- image->height = h;
- image->depth = 1;
- xvisual = ((GdkVisualPrivate*) visual)->xvisual;
- private->ximage = XCreateImage(private->xdisplay, xvisual, 1, XYBitmap,
- 0, 0, w ,h, 8, 0);
- private->ximage->data = data;
- private->ximage->bitmap_bit_order = MSBFirst;
- private->ximage->byte_order = MSBFirst;
- image->byte_order = MSBFirst;
- image->mem = private->ximage->data;
- image->bpl = private->ximage->bytes_per_line;
- image->bpp = 1;
- return(image);
+ Visual *xvisual;
+ GdkImage *image;
+ GdkImagePrivateX11 *private;
+ image = GDK_IMAGE (g_type_create_instance (gdk_image_get_type ()));
+ private = PRIVATE_DATA (image);
+ private->xdisplay = gdk_display;
+ image->type = GDK_IMAGE_NORMAL;
+ image->visual = visual;
+ image->width = w;
+ image->height = h;
+ image->depth = 1;
+ xvisual = ((GdkVisualPrivate*) visual)->xvisual;
+ private->ximage = XCreateImage(private->xdisplay, xvisual, 1, XYBitmap,
+ 0, 0, w ,h, 8, 0);
+ private->ximage->data = data;
+ private->ximage->bitmap_bit_order = MSBFirst;
+ private->ximage->byte_order = MSBFirst;
+ image->byte_order = MSBFirst;
+ image->mem = private->ximage->data;
+ image->bpl = private->ximage->bytes_per_line;
+ image->bpp = 1;
+ return(image);
} /* gdk_image_new_bitmap() */
static int
@@ -265,13 +267,21 @@ gdk_image_new (GdkImageType type,
if (x_shm_info->shmid == -1)
{
- g_warning ("shmget failed!");
+ /* EINVAL indicates, most likely, that the segment we asked for
+ * is bigger than SHMMAX, so we don't treat it as a permanently
+ * fatal error. ENOSPC and ENOMEM may also indicate this, but
+ * more likely are permanent errors.
+ */
+ if (errno != EINVAL)
+ {
+ g_warning ("shmget failed!");
+ gdk_use_xshm = False;
+ }
XDestroyImage (private->ximage);
g_free (private->x_shm_info);
g_free (image);
- gdk_use_xshm = False;
return NULL;
}