summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRon Steinke <rsteinke@src.gnome.org>2001-07-23 21:28:38 +0000
committerRon Steinke <rsteinke@src.gnome.org>2001-07-23 21:28:38 +0000
commit9cfd92ef66b4c3661cd9dee8d6f91de8a1ef7a17 (patch)
treefea195cb232164439b1db9d1b96d2c491ff7a55f
parent5f50d1fd7297e1851630c7e53d60b997a5b95125 (diff)
downloadgdk-pixbuf-9cfd92ef66b4c3661cd9dee8d6f91de8a1ef7a17.tar.gz
Added a check on the colormap depth to gdk_drawable_set_colormap()
* gdk/gdkdraw.c: Added a check on the colormap depth to gdk_drawable_set_colormap() * gdk/x11/gdkimage-x11.c: combination of Mathias Hasselmann's patch to fix colorsel and my patch to fix gdk_drawable_get_image() for pixmaps without visuals (more specifically, bitmaps) * gdk/x11/gdkpixmap-x11.c: Fixed gdk_pixmap_new() so it doesn't set a colormap with the wrong depth
-rw-r--r--ChangeLog11
-rw-r--r--ChangeLog.pre-2-011
-rw-r--r--ChangeLog.pre-2-1011
-rw-r--r--ChangeLog.pre-2-211
-rw-r--r--ChangeLog.pre-2-411
-rw-r--r--ChangeLog.pre-2-611
-rw-r--r--ChangeLog.pre-2-811
-rw-r--r--gdk/gdkdraw.c2
-rw-r--r--gdk/x11/gdkimage-x11.c143
-rw-r--r--gdk/x11/gdkpixmap-x11.c6
10 files changed, 187 insertions, 41 deletions
diff --git a/ChangeLog b/ChangeLog
index ba38cf2a9..cedb7ab8d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2001-07-23 Ron Steinke <rsteinke@w-link.net>
+
+ * gdk/gdkdraw.c: Added a check on the colormap depth to
+ gdk_drawable_set_colormap()
+ * gdk/x11/gdkimage-x11.c: combination of Mathias Hasselmann's
+ patch to fix colorsel and my patch to fix gdk_drawable_get_image()
+ for pixmaps without visuals (more specifically, bitmaps)
+ * gdk/x11/gdkpixmap-x11.c: Fixed gdk_pixmap_new() so it
+ doesn't set a colormap with the wrong depth
+
+
2001-07-22 Anders Carlsson <andersca@gnome.org>
* gtk/gtktreeview.c (gtk_tree_view_class_init): Replace the
diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0
index ba38cf2a9..cedb7ab8d 100644
--- a/ChangeLog.pre-2-0
+++ b/ChangeLog.pre-2-0
@@ -1,3 +1,14 @@
+2001-07-23 Ron Steinke <rsteinke@w-link.net>
+
+ * gdk/gdkdraw.c: Added a check on the colormap depth to
+ gdk_drawable_set_colormap()
+ * gdk/x11/gdkimage-x11.c: combination of Mathias Hasselmann's
+ patch to fix colorsel and my patch to fix gdk_drawable_get_image()
+ for pixmaps without visuals (more specifically, bitmaps)
+ * gdk/x11/gdkpixmap-x11.c: Fixed gdk_pixmap_new() so it
+ doesn't set a colormap with the wrong depth
+
+
2001-07-22 Anders Carlsson <andersca@gnome.org>
* gtk/gtktreeview.c (gtk_tree_view_class_init): Replace the
diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10
index ba38cf2a9..cedb7ab8d 100644
--- a/ChangeLog.pre-2-10
+++ b/ChangeLog.pre-2-10
@@ -1,3 +1,14 @@
+2001-07-23 Ron Steinke <rsteinke@w-link.net>
+
+ * gdk/gdkdraw.c: Added a check on the colormap depth to
+ gdk_drawable_set_colormap()
+ * gdk/x11/gdkimage-x11.c: combination of Mathias Hasselmann's
+ patch to fix colorsel and my patch to fix gdk_drawable_get_image()
+ for pixmaps without visuals (more specifically, bitmaps)
+ * gdk/x11/gdkpixmap-x11.c: Fixed gdk_pixmap_new() so it
+ doesn't set a colormap with the wrong depth
+
+
2001-07-22 Anders Carlsson <andersca@gnome.org>
* gtk/gtktreeview.c (gtk_tree_view_class_init): Replace the
diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2
index ba38cf2a9..cedb7ab8d 100644
--- a/ChangeLog.pre-2-2
+++ b/ChangeLog.pre-2-2
@@ -1,3 +1,14 @@
+2001-07-23 Ron Steinke <rsteinke@w-link.net>
+
+ * gdk/gdkdraw.c: Added a check on the colormap depth to
+ gdk_drawable_set_colormap()
+ * gdk/x11/gdkimage-x11.c: combination of Mathias Hasselmann's
+ patch to fix colorsel and my patch to fix gdk_drawable_get_image()
+ for pixmaps without visuals (more specifically, bitmaps)
+ * gdk/x11/gdkpixmap-x11.c: Fixed gdk_pixmap_new() so it
+ doesn't set a colormap with the wrong depth
+
+
2001-07-22 Anders Carlsson <andersca@gnome.org>
* gtk/gtktreeview.c (gtk_tree_view_class_init): Replace the
diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4
index ba38cf2a9..cedb7ab8d 100644
--- a/ChangeLog.pre-2-4
+++ b/ChangeLog.pre-2-4
@@ -1,3 +1,14 @@
+2001-07-23 Ron Steinke <rsteinke@w-link.net>
+
+ * gdk/gdkdraw.c: Added a check on the colormap depth to
+ gdk_drawable_set_colormap()
+ * gdk/x11/gdkimage-x11.c: combination of Mathias Hasselmann's
+ patch to fix colorsel and my patch to fix gdk_drawable_get_image()
+ for pixmaps without visuals (more specifically, bitmaps)
+ * gdk/x11/gdkpixmap-x11.c: Fixed gdk_pixmap_new() so it
+ doesn't set a colormap with the wrong depth
+
+
2001-07-22 Anders Carlsson <andersca@gnome.org>
* gtk/gtktreeview.c (gtk_tree_view_class_init): Replace the
diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6
index ba38cf2a9..cedb7ab8d 100644
--- a/ChangeLog.pre-2-6
+++ b/ChangeLog.pre-2-6
@@ -1,3 +1,14 @@
+2001-07-23 Ron Steinke <rsteinke@w-link.net>
+
+ * gdk/gdkdraw.c: Added a check on the colormap depth to
+ gdk_drawable_set_colormap()
+ * gdk/x11/gdkimage-x11.c: combination of Mathias Hasselmann's
+ patch to fix colorsel and my patch to fix gdk_drawable_get_image()
+ for pixmaps without visuals (more specifically, bitmaps)
+ * gdk/x11/gdkpixmap-x11.c: Fixed gdk_pixmap_new() so it
+ doesn't set a colormap with the wrong depth
+
+
2001-07-22 Anders Carlsson <andersca@gnome.org>
* gtk/gtktreeview.c (gtk_tree_view_class_init): Replace the
diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8
index ba38cf2a9..cedb7ab8d 100644
--- a/ChangeLog.pre-2-8
+++ b/ChangeLog.pre-2-8
@@ -1,3 +1,14 @@
+2001-07-23 Ron Steinke <rsteinke@w-link.net>
+
+ * gdk/gdkdraw.c: Added a check on the colormap depth to
+ gdk_drawable_set_colormap()
+ * gdk/x11/gdkimage-x11.c: combination of Mathias Hasselmann's
+ patch to fix colorsel and my patch to fix gdk_drawable_get_image()
+ for pixmaps without visuals (more specifically, bitmaps)
+ * gdk/x11/gdkpixmap-x11.c: Fixed gdk_pixmap_new() so it
+ doesn't set a colormap with the wrong depth
+
+
2001-07-22 Anders Carlsson <andersca@gnome.org>
* gtk/gtktreeview.c (gtk_tree_view_class_init): Replace the
diff --git a/gdk/gdkdraw.c b/gdk/gdkdraw.c
index d05bb1b7f..b4de48a2f 100644
--- a/gdk/gdkdraw.c
+++ b/gdk/gdkdraw.c
@@ -198,6 +198,8 @@ gdk_drawable_set_colormap (GdkDrawable *drawable,
GdkColormap *cmap)
{
g_return_if_fail (GDK_IS_DRAWABLE (drawable));
+ g_return_if_fail (cmap == NULL || gdk_drawable_get_depth (drawable)
+ == cmap->visual->depth);
GDK_DRAWABLE_GET_CLASS (drawable)->set_colormap (drawable, cmap);
}
diff --git a/gdk/x11/gdkimage-x11.c b/gdk/x11/gdkimage-x11.c
index ac78afd50..b473fac67 100644
--- a/gdk/x11/gdkimage-x11.c
+++ b/gdk/x11/gdkimage-x11.c
@@ -382,6 +382,7 @@ _gdk_x11_get_image (GdkDrawable *drawable,
GdkDrawableImplX11 *impl;
GdkVisual *visual;
gboolean have_grab;
+ GdkRectangle req;
GdkRectangle window_rect;
XImage *ximage;
@@ -389,32 +390,29 @@ _gdk_x11_get_image (GdkDrawable *drawable,
visual = gdk_drawable_get_visual (drawable);
- if (visual == NULL)
- {
- g_warning ("To get the image from a drawable, the drawable "
- "must have a visual and colormap; calling "
- "gtk_drawable_set_colormap() on a drawable "
- "created without a colormap should solve this problem");
+ g_assert (visual || !GDK_IS_WINDOW (drawable));
- return NULL;
- }
-
impl = GDK_DRAWABLE_IMPL_X11 (drawable);
have_grab = FALSE;
- window_rect.x = x;
- window_rect.y = y;
- window_rect.width = width;
- window_rect.height = height;
+
if (GDK_IS_WINDOW (drawable))
{
GdkRectangle screen_rect;
+ Window child;
+
+ g_assert (visual);
have_grab = TRUE;
gdk_x11_grab_server ();
+
+ XTranslateCoordinates (GDK_DRAWABLE_XDISPLAY (drawable),
+ gdk_root_window,
+ GDK_DRAWABLE_XID (drawable),
+ 0, 0,
+ &screen_rect.x, &screen_rect.y,
+ &child);
- screen_rect.x = 0;
- screen_rect.y = 0;
screen_rect.width = gdk_screen_width ();
screen_rect.height = gdk_screen_height ();
@@ -428,42 +426,109 @@ _gdk_x11_get_image (GdkDrawable *drawable,
NULL);
if (gdk_error_trap_pop () ||
- !gdk_rectangle_intersect (&window_rect, &screen_rect,
+ !gdk_rectangle_intersect (&window_rect, &screen_rect,
&window_rect))
{
gdk_x11_ungrab_server ();
- return NULL;
+ return image = gdk_image_new (GDK_IMAGE_FASTEST,
+ visual,
+ width, height);
}
}
+ else
+ {
+ window_rect.x = 0;
+ window_rect.y = 0;
+ gdk_drawable_get_size (drawable,
+ &window_rect.width,
+ &window_rect.height);
+ }
+
+ req.x = x;
+ req.y = y;
+ req.width = width;
+ req.height = height;
+
+ /* window_rect specifies the part of drawable which we can get from
+ the server in window coordinates.
+ For pixmaps this is all of the pixmap, for windows it is just
+ the onscreen part. */
+ if (!gdk_rectangle_intersect (&req, &window_rect, &req) && visual)
+ {
+ if (have_grab)
+ gdk_x11_ungrab_server ();
+ return image = gdk_image_new (GDK_IMAGE_FASTEST,
+ visual,
+ width, height);
+ }
- image = gdk_image_new (GDK_IMAGE_FASTEST,
- visual,
- width, height);
+ if (req.x != x || req.y != y)
+ {
+ g_assert (GDK_IS_WINDOW (drawable));
+ g_assert (visual);
- if (image == NULL)
- return NULL;
+ image = gdk_image_new (GDK_IMAGE_FASTEST,
+ visual,
+ width, height);
+ if (image == NULL)
+ return NULL;
- private = PRIVATE_DATA (image);
-
- gdk_error_trap_push ();
+ private = PRIVATE_DATA (image);
- ximage = XGetSubImage (impl->xdisplay,
- impl->xid,
- x, y, width, height,
- AllPlanes, ZPixmap,
- private->ximage,
- x, y);
+ gdk_error_trap_push ();
- if (have_grab)
- gdk_x11_ungrab_server ();
-
- if (gdk_error_trap_pop () || ximage == NULL)
- {
- g_object_unref (G_OBJECT (image));
- return NULL;
+ ximage = XGetSubImage (impl->xdisplay,
+ impl->xid,
+ req.x, req.y, req.width, req.height,
+ AllPlanes, ZPixmap,
+ private->ximage,
+ req.x - x, req.y - y);
+
+ if (have_grab)
+ gdk_x11_ungrab_server ();
+
+ if (gdk_error_trap_pop () || ximage == NULL)
+ {
+ g_object_unref (G_OBJECT (image));
+ return NULL;
+ }
+
+ g_assert (ximage == private->ximage);
}
+ else
+ {
+
+ ximage = XGetImage (impl->xdisplay,
+ impl->xid,
+ x, y, width, height,
+ AllPlanes, ZPixmap);
+
+ if (!ximage)
+ {
+ if (have_grab)
+ gdk_x11_ungrab_server ();
+ return NULL;
+ }
- g_assert (ximage == private->ximage);
+ image = g_object_new (gdk_image_get_type (), NULL);
+
+ private = PRIVATE_DATA (image);
+
+ private->xdisplay = gdk_display;
+ private->ximage = ximage;
+
+ image->type = GDK_IMAGE_NORMAL;
+ image->visual = visual; /* May be NULL */
+ image->width = width;
+ image->height = height;
+ image->depth = gdk_drawable_get_depth (drawable);
+
+ image->mem = private->ximage->data;
+ image->bpl = private->ximage->bytes_per_line;
+ image->bits_per_pixel = private->ximage->bits_per_pixel;
+ image->bpp = (private->ximage->bits_per_pixel + 7) / 8;
+ image->byte_order = private->ximage->byte_order;
+ }
return image;
}
diff --git a/gdk/x11/gdkpixmap-x11.c b/gdk/x11/gdkpixmap-x11.c
index 03ef5888c..fe0b421a0 100644
--- a/gdk/x11/gdkpixmap-x11.c
+++ b/gdk/x11/gdkpixmap-x11.c
@@ -150,6 +150,7 @@ gdk_pixmap_new (GdkWindow *window,
GdkDrawableImplX11 *draw_impl;
GdkPixmapImplX11 *pix_impl;
GdkColormap *cmap;
+ gint window_depth;
g_return_val_if_fail (window == NULL || GDK_IS_WINDOW (window), NULL);
g_return_val_if_fail ((window != NULL) || (depth != -1), NULL);
@@ -161,8 +162,9 @@ gdk_pixmap_new (GdkWindow *window,
if (GDK_WINDOW_DESTROYED (window))
return NULL;
+ window_depth = gdk_drawable_get_depth (GDK_DRAWABLE (window));
if (depth == -1)
- depth = gdk_drawable_get_depth (GDK_DRAWABLE (window));
+ depth = window_depth;
pixmap = g_object_new (gdk_pixmap_get_type (), NULL);
draw_impl = GDK_DRAWABLE_IMPL_X11 (GDK_PIXMAP_OBJECT (pixmap)->impl);
@@ -179,7 +181,7 @@ gdk_pixmap_new (GdkWindow *window,
pix_impl->height = height;
GDK_PIXMAP_OBJECT (pixmap)->depth = depth;
- if (window)
+ if (depth == window_depth)
{
cmap = gdk_drawable_get_colormap (window);
if (cmap)