Re-enable the "find" dialog
2000-10-23 Havoc Pennington <hp@redhat.com> * gtk/testtext.c: Re-enable the "find" dialog * gtk/testgtk.c: Add test for gdk_drawable_get_image * gdk/gdkwindow.c (gdk_window_begin_paint_region): Fix bug where the arguments to gdk_draw_drawable were in the wrong order (gdk_window_paint_init_bg): This function was ignoring the init_region, instead of clipping to it, so the entire backing pixmap was cleared on every begin_paint() (gdk_window_begin_paint_region): Hmm, the same list-walking bug was in here again, the loop kept using the same GtkWindowPaint over and over. (gdk_window_begin_paint_region): Fix a bug where we had two x_offset instead of x_offset and y_offset * gdk/gdkdraw.c (gdk_drawable_get_image): get composite drawable before we get the image. (gdk_draw_drawable): get the composite before we draw the drawable. (gdk_drawable_real_get_composite_drawable): default get_composite_drawable implementation that returns the drawable itself * gdk/gdkdrawable.h (struct _GdkDrawableClass ): Add get_composite_drawable virtual function * gdk/gdkwindow.c (gdk_window_begin_paint_region): Fix a cheesy list-walking bug * gdk/x11/gdkdrawable-x11.c (gdk_x11_draw_drawable): Add a hack to make this work if the source drawable is a GdkDrawableImplX11 instead of a public drawable type. This is really broken; the problem is that GdkDrawable needs a virtual method get_xid(), but of course that doesn't work in practice. Enter RTTI. Also, improve mismatched depth message. * gdk/gdkpixmap.c (gdk_pixmap_get_image): Implement get_image for GdkPixmap * gdk/x11/gdkdrawable-x11.c (gdk_drawable_impl_x11_class_init): install _gdk_x11_get_image as our implementation of get_image * gdk/x11/gdkimage-x11.c (gdk_image_get): Rename to _gdk_x11_get_image and export for use in gdkdrawable-x11.c * gdk/gdkimage.c (gdk_image_get): Make this just a wrapper around gdk_drawable_get_image * gdk/gdkdraw.c (gdk_drawable_get_image): call virtual get_image * gdk/gdkdrawable.h (struct _GdkDrawableClass ): Virtualize get_image * gtk/gtktreestore.c (gtk_tree_store_get_node): remove weird trailing semicolon after for loop
This commit is contained in:
committed by
Havoc Pennington
parent
ce821b23f5
commit
86b5c82a97
@ -28,6 +28,16 @@
|
||||
#include "gdkinternals.h"
|
||||
#include "gdkwindow.h"
|
||||
|
||||
static GdkDrawable* gdk_drawable_real_get_composite_drawable (GdkDrawable *drawable,
|
||||
gint x,
|
||||
gint y,
|
||||
gint width,
|
||||
gint height,
|
||||
gint *composite_x_offset,
|
||||
gint *composite_y_offset);
|
||||
|
||||
static void gdk_drawable_class_init (GdkDrawableClass *klass);
|
||||
|
||||
GType
|
||||
gdk_drawable_get_type (void)
|
||||
{
|
||||
@ -40,7 +50,7 @@ gdk_drawable_get_type (void)
|
||||
sizeof (GdkDrawableClass),
|
||||
(GBaseInitFunc) NULL,
|
||||
(GBaseFinalizeFunc) NULL,
|
||||
(GClassInitFunc) NULL,
|
||||
(GClassInitFunc) gdk_drawable_class_init,
|
||||
NULL, /* class_finalize */
|
||||
NULL, /* class_data */
|
||||
sizeof (GdkDrawable),
|
||||
@ -56,6 +66,12 @@ gdk_drawable_get_type (void)
|
||||
return object_type;
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_drawable_class_init (GdkDrawableClass *klass)
|
||||
{
|
||||
klass->get_composite_drawable = gdk_drawable_real_get_composite_drawable;
|
||||
}
|
||||
|
||||
/* Manipulation of drawables
|
||||
*/
|
||||
|
||||
@ -323,6 +339,10 @@ gdk_draw_drawable (GdkDrawable *drawable,
|
||||
gint width,
|
||||
gint height)
|
||||
{
|
||||
GdkDrawable *composite;
|
||||
gint composite_x_offset = 0;
|
||||
gint composite_y_offset = 0;
|
||||
|
||||
g_return_if_fail (GDK_IS_DRAWABLE (drawable));
|
||||
g_return_if_fail (src != NULL);
|
||||
g_return_if_fail (GDK_IS_GC (gc));
|
||||
@ -340,9 +360,22 @@ gdk_draw_drawable (GdkDrawable *drawable,
|
||||
height = real_height;
|
||||
}
|
||||
|
||||
GDK_DRAWABLE_GET_CLASS (drawable)->draw_drawable (drawable, gc, src,
|
||||
xsrc, ysrc, xdest, ydest,
|
||||
|
||||
composite =
|
||||
GDK_DRAWABLE_GET_CLASS (src)->get_composite_drawable (src,
|
||||
xsrc, ysrc,
|
||||
width, height,
|
||||
&composite_x_offset,
|
||||
&composite_y_offset);
|
||||
|
||||
|
||||
GDK_DRAWABLE_GET_CLASS (drawable)->draw_drawable (drawable, gc, composite,
|
||||
xsrc - composite_x_offset,
|
||||
ysrc - composite_y_offset,
|
||||
xdest, ydest,
|
||||
width, height);
|
||||
|
||||
g_object_unref (G_OBJECT (composite));
|
||||
}
|
||||
|
||||
void
|
||||
@ -430,7 +463,6 @@ gdk_draw_glyphs (GdkDrawable *drawable,
|
||||
gint y,
|
||||
PangoGlyphString *glyphs)
|
||||
{
|
||||
|
||||
g_return_if_fail (GDK_IS_DRAWABLE (drawable));
|
||||
g_return_if_fail (GDK_IS_GC (gc));
|
||||
|
||||
@ -439,3 +471,54 @@ gdk_draw_glyphs (GdkDrawable *drawable,
|
||||
}
|
||||
|
||||
|
||||
GdkImage*
|
||||
gdk_drawable_get_image (GdkDrawable *drawable,
|
||||
gint x,
|
||||
gint y,
|
||||
gint width,
|
||||
gint height)
|
||||
{
|
||||
GdkDrawable *composite;
|
||||
gint composite_x_offset = 0;
|
||||
gint composite_y_offset = 0;
|
||||
GdkImage *retval;
|
||||
|
||||
g_return_val_if_fail (GDK_IS_DRAWABLE (drawable), NULL);
|
||||
g_return_val_if_fail (x >= 0, NULL);
|
||||
g_return_val_if_fail (y >= 0, NULL);
|
||||
g_return_val_if_fail (width >= 0, NULL);
|
||||
g_return_val_if_fail (height >= 0, NULL);
|
||||
|
||||
composite =
|
||||
GDK_DRAWABLE_GET_CLASS (drawable)->get_composite_drawable (drawable,
|
||||
x, y,
|
||||
width, height,
|
||||
&composite_x_offset,
|
||||
&composite_y_offset);
|
||||
|
||||
retval = GDK_DRAWABLE_GET_CLASS (composite)->get_image (composite,
|
||||
x - composite_x_offset,
|
||||
y - composite_y_offset,
|
||||
width, height);
|
||||
|
||||
g_object_unref (G_OBJECT (composite));
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
static GdkDrawable*
|
||||
gdk_drawable_real_get_composite_drawable (GdkDrawable *drawable,
|
||||
gint x,
|
||||
gint y,
|
||||
gint width,
|
||||
gint height,
|
||||
gint *composite_x_offset,
|
||||
gint *composite_y_offset)
|
||||
{
|
||||
g_return_val_if_fail (GDK_IS_DRAWABLE (drawable), NULL);
|
||||
|
||||
*composite_x_offset = 0;
|
||||
*composite_y_offset = 0;
|
||||
|
||||
return GDK_DRAWABLE (g_object_ref (G_OBJECT (drawable)));
|
||||
}
|
||||
|
||||
@ -113,6 +113,21 @@ struct _GdkDrawableClass
|
||||
|
||||
GdkColormap* (*get_colormap) (GdkDrawable *drawable);
|
||||
GdkVisual* (*get_visual) (GdkDrawable *drawable);
|
||||
|
||||
GdkImage* (*get_image) (GdkDrawable *drawable,
|
||||
gint x,
|
||||
gint y,
|
||||
gint width,
|
||||
gint height);
|
||||
|
||||
GdkDrawable* (*get_composite_drawable) (GdkDrawable *drawable,
|
||||
gint x,
|
||||
gint y,
|
||||
gint width,
|
||||
gint height,
|
||||
gint *composite_x_offset,
|
||||
gint *composite_y_offset);
|
||||
|
||||
};
|
||||
|
||||
GType gdk_drawable_get_type (void);
|
||||
@ -239,6 +254,12 @@ void gdk_draw_layout (GdkDrawable *drawable,
|
||||
gint y,
|
||||
PangoLayout *layout);
|
||||
|
||||
GdkImage* gdk_drawable_get_image (GdkDrawable *drawable,
|
||||
gint x,
|
||||
gint y,
|
||||
gint width,
|
||||
gint height);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
@ -43,3 +43,19 @@ gdk_image_unref (GdkImage *image)
|
||||
|
||||
g_object_unref (G_OBJECT (image));
|
||||
}
|
||||
|
||||
GdkImage*
|
||||
gdk_image_get (GdkWindow *window,
|
||||
gint x,
|
||||
gint y,
|
||||
gint width,
|
||||
gint height)
|
||||
{
|
||||
g_return_val_if_fail (GDK_IS_DRAWABLE (window), NULL);
|
||||
g_return_val_if_fail (x >= 0, NULL);
|
||||
g_return_val_if_fail (y >= 0, NULL);
|
||||
g_return_val_if_fail (width >= 0, NULL);
|
||||
g_return_val_if_fail (height >= 0, NULL);
|
||||
|
||||
return gdk_drawable_get_image (window, x, y, width, height);
|
||||
}
|
||||
|
||||
@ -107,6 +107,13 @@ static void gdk_pixmap_real_get_size (GdkDrawable *drawable,
|
||||
gint *width,
|
||||
gint *height);
|
||||
|
||||
static GdkImage* gdk_pixmap_get_image (GdkDrawable *drawable,
|
||||
gint x,
|
||||
gint y,
|
||||
gint width,
|
||||
gint height);
|
||||
|
||||
|
||||
static GdkVisual* gdk_pixmap_real_get_visual (GdkDrawable *drawable);
|
||||
static gint gdk_pixmap_real_get_depth (GdkDrawable *drawable);
|
||||
static void gdk_pixmap_real_set_colormap (GdkDrawable *drawable,
|
||||
@ -181,6 +188,7 @@ gdk_pixmap_class_init (GdkPixmapObjectClass *klass)
|
||||
drawable_class->set_colormap = gdk_pixmap_real_set_colormap;
|
||||
drawable_class->get_colormap = gdk_pixmap_real_get_colormap;
|
||||
drawable_class->get_visual = gdk_pixmap_real_get_visual;
|
||||
drawable_class->get_image = gdk_pixmap_get_image;
|
||||
}
|
||||
|
||||
static void
|
||||
@ -410,6 +418,19 @@ gdk_pixmap_real_get_colormap (GdkDrawable *drawable)
|
||||
return gdk_drawable_get_colormap (((GdkPixmapObject*)drawable)->impl);
|
||||
}
|
||||
|
||||
static GdkImage*
|
||||
gdk_pixmap_get_image (GdkDrawable *drawable,
|
||||
gint x,
|
||||
gint y,
|
||||
gint width,
|
||||
gint height)
|
||||
{
|
||||
g_return_val_if_fail (GDK_IS_PIXMAP (drawable), NULL);
|
||||
|
||||
return gdk_drawable_get_image (((GdkPixmapObject*)drawable)->impl,
|
||||
x, y, width, height);
|
||||
}
|
||||
|
||||
#define PACKED_COLOR(c) ((((c)->red & 0xff) << 8) | ((c)->green & 0xff) | ((c)->blue >> 8))
|
||||
|
||||
static GdkPixmap *
|
||||
|
||||
221
gdk/gdkwindow.c
221
gdk/gdkwindow.c
@ -28,6 +28,8 @@
|
||||
#include "gdkinternals.h"
|
||||
#include "gdk.h" /* For gdk_rectangle_union() */
|
||||
#include "gdkpixmap.h"
|
||||
#include "gdkdrawable.h"
|
||||
#include "gdkpixmap.h"
|
||||
|
||||
#ifndef USE_BACKING_STORE
|
||||
#ifndef GDK_WINDOWING_WIN32
|
||||
@ -120,6 +122,12 @@ static void gdk_window_draw_image (GdkDrawable *drawable,
|
||||
gint width,
|
||||
gint height);
|
||||
|
||||
static GdkImage* gdk_window_get_image (GdkDrawable *drawable,
|
||||
gint x,
|
||||
gint y,
|
||||
gint width,
|
||||
gint height);
|
||||
|
||||
|
||||
static void gdk_window_real_get_size (GdkDrawable *drawable,
|
||||
gint *width,
|
||||
@ -130,7 +138,15 @@ static gint gdk_window_real_get_depth (GdkDrawable *drawable);
|
||||
static void gdk_window_real_set_colormap (GdkDrawable *drawable,
|
||||
GdkColormap *cmap);
|
||||
static GdkColormap* gdk_window_real_get_colormap (GdkDrawable *drawable);
|
||||
|
||||
|
||||
static GdkDrawable* gdk_window_get_composite_drawable (GdkDrawable *drawable,
|
||||
gint x,
|
||||
gint y,
|
||||
gint width,
|
||||
gint height,
|
||||
gint *composite_x_offset,
|
||||
gint *composite_y_offset);
|
||||
|
||||
static void gdk_window_free_paint_stack (GdkWindow *window);
|
||||
|
||||
static void gdk_window_init (GdkWindowObject *window);
|
||||
@ -204,6 +220,8 @@ gdk_window_class_init (GdkWindowObjectClass *klass)
|
||||
drawable_class->set_colormap = gdk_window_real_set_colormap;
|
||||
drawable_class->get_colormap = gdk_window_real_get_colormap;
|
||||
drawable_class->get_visual = gdk_window_real_get_visual;
|
||||
drawable_class->get_image = gdk_window_get_image;
|
||||
drawable_class->get_composite_drawable = gdk_window_get_composite_drawable;
|
||||
}
|
||||
|
||||
static void
|
||||
@ -650,12 +668,20 @@ gdk_window_paint_init_bg (GdkWindow *window,
|
||||
GdkRegion *init_region)
|
||||
{
|
||||
GdkGC *tmp_gc;
|
||||
|
||||
|
||||
tmp_gc = gdk_window_get_bg_gc (window, paint);
|
||||
|
||||
gdk_region_offset (init_region,
|
||||
- paint->x_offset,
|
||||
- paint->y_offset);
|
||||
gdk_gc_set_clip_region (tmp_gc, init_region);
|
||||
|
||||
gdk_draw_rectangle (paint->pixmap, tmp_gc, TRUE, 0, 0, -1, -1);
|
||||
gdk_gc_unref (tmp_gc);
|
||||
}
|
||||
|
||||
|
||||
|
||||
#include "x11/gdkx.h"
|
||||
void
|
||||
gdk_window_begin_paint_region (GdkWindow *window,
|
||||
GdkRegion *region)
|
||||
@ -697,11 +723,13 @@ gdk_window_begin_paint_region (GdkWindow *window,
|
||||
|
||||
if (new_rect.width > old_rect.width || new_rect.height > old_rect.height)
|
||||
{
|
||||
paint->pixmap = gdk_pixmap_new (window, new_rect.width, new_rect.height, -1);
|
||||
paint->pixmap = gdk_pixmap_new (window,
|
||||
new_rect.width, new_rect.height, -1);
|
||||
tmp_gc = gdk_gc_new (paint->pixmap);
|
||||
gdk_draw_drawable (paint->pixmap, tmp_gc, tmp_paint->pixmap,
|
||||
0, 0, old_rect.width, old_rect.height,
|
||||
old_rect.x - new_rect.x, old_rect.y - new_rect.y);
|
||||
0, 0,
|
||||
old_rect.x - new_rect.x, old_rect.y - new_rect.y,
|
||||
old_rect.width, old_rect.height);
|
||||
gdk_gc_unref (tmp_gc);
|
||||
gdk_drawable_unref (tmp_paint->pixmap);
|
||||
|
||||
@ -711,13 +739,13 @@ gdk_window_begin_paint_region (GdkWindow *window,
|
||||
tmp_list = private->paint_stack;
|
||||
while (tmp_list)
|
||||
{
|
||||
tmp_paint = private->paint_stack->data;
|
||||
tmp_paint = tmp_list->data;
|
||||
gdk_region_subtract (init_region, tmp_paint->region);
|
||||
|
||||
tmp_paint->pixmap = paint->pixmap;
|
||||
tmp_paint->x_offset = paint->x_offset;
|
||||
tmp_paint->y_offset = paint->x_offset;
|
||||
|
||||
tmp_paint->y_offset = paint->y_offset;
|
||||
|
||||
tmp_list = tmp_list->next;
|
||||
}
|
||||
}
|
||||
@ -730,7 +758,7 @@ gdk_window_begin_paint_region (GdkWindow *window,
|
||||
tmp_list = private->paint_stack;
|
||||
while (tmp_list)
|
||||
{
|
||||
tmp_paint = private->paint_stack->data;
|
||||
tmp_paint = tmp_list->data;
|
||||
gdk_region_subtract (init_region, tmp_paint->region);
|
||||
|
||||
tmp_list = tmp_list->next;
|
||||
@ -746,6 +774,7 @@ gdk_window_begin_paint_region (GdkWindow *window,
|
||||
|
||||
if (!gdk_region_empty (init_region))
|
||||
gdk_window_paint_init_bg (window, paint, init_region);
|
||||
|
||||
gdk_region_destroy (init_region);
|
||||
|
||||
private->paint_stack = g_slist_prepend (private->paint_stack, paint);
|
||||
@ -796,7 +825,7 @@ gdk_window_end_paint (GdkWindow *window)
|
||||
{
|
||||
GdkWindowPaint *tmp_paint = tmp_list->data;
|
||||
gdk_region_subtract (tmp_paint->region, paint->region);
|
||||
|
||||
|
||||
tmp_list = tmp_list->next;
|
||||
}
|
||||
}
|
||||
@ -1048,6 +1077,138 @@ gdk_window_draw_text_wc (GdkDrawable *drawable,
|
||||
RESTORE_GC (gc);
|
||||
}
|
||||
|
||||
static GdkDrawable*
|
||||
gdk_window_get_composite_drawable (GdkDrawable *window,
|
||||
gint x,
|
||||
gint y,
|
||||
gint width,
|
||||
gint height,
|
||||
gint *composite_x_offset,
|
||||
gint *composite_y_offset)
|
||||
{
|
||||
GdkWindowObject *private = (GdkWindowObject *)window;
|
||||
GdkWindowPaint *paint;
|
||||
GdkRegion *buffered_region;
|
||||
GSList *tmp_list;
|
||||
GdkPixmap *buffer;
|
||||
GdkPixmap *tmp_pixmap;
|
||||
GdkRectangle rect;
|
||||
GdkRegion *rect_region;
|
||||
GdkGC *tmp_gc;
|
||||
gint windowing_x_offset, windowing_y_offset;
|
||||
gint buffer_x_offset, buffer_y_offset;
|
||||
|
||||
if (GDK_WINDOW_DESTROYED (window) || private->paint_stack == NULL)
|
||||
{
|
||||
/* No backing store */
|
||||
_gdk_windowing_window_get_offsets (window,
|
||||
composite_x_offset,
|
||||
composite_y_offset);
|
||||
|
||||
return GDK_DRAWABLE (g_object_ref (G_OBJECT (window)));
|
||||
}
|
||||
|
||||
buffered_region = NULL;
|
||||
buffer = NULL;
|
||||
|
||||
/* All GtkWindowPaint structs have the same pixmap and offsets, just
|
||||
* get the first one. (should probably be cleaned up so that the
|
||||
* pixmap is stored in the window)
|
||||
*/
|
||||
paint = private->paint_stack->data;
|
||||
buffer = paint->pixmap;
|
||||
buffer_x_offset = paint->x_offset;
|
||||
buffer_y_offset = paint->y_offset;
|
||||
|
||||
tmp_list = private->paint_stack;
|
||||
while (tmp_list != NULL)
|
||||
{
|
||||
paint = tmp_list->data;
|
||||
|
||||
if (buffered_region == NULL)
|
||||
buffered_region = gdk_region_copy (paint->region);
|
||||
else
|
||||
gdk_region_union (buffered_region, paint->region);
|
||||
|
||||
tmp_list = g_slist_next (tmp_list);
|
||||
}
|
||||
|
||||
/* See if the buffered part is overlapping the part we want
|
||||
* to get
|
||||
*/
|
||||
rect.x = x;
|
||||
rect.y = y;
|
||||
rect.width = width;
|
||||
rect.height = height;
|
||||
|
||||
rect_region = gdk_region_rectangle (&rect);
|
||||
|
||||
gdk_region_intersect (buffered_region, rect_region);
|
||||
|
||||
gdk_region_destroy (rect_region);
|
||||
|
||||
if (gdk_region_empty (buffered_region))
|
||||
{
|
||||
gdk_region_destroy (buffered_region);
|
||||
|
||||
_gdk_windowing_window_get_offsets (window,
|
||||
composite_x_offset,
|
||||
composite_y_offset);
|
||||
|
||||
return GDK_DRAWABLE (g_object_ref (G_OBJECT (window)));
|
||||
}
|
||||
|
||||
tmp_pixmap = gdk_pixmap_new (window,
|
||||
width, height,
|
||||
-1);
|
||||
|
||||
tmp_gc = gdk_gc_new (tmp_pixmap);
|
||||
|
||||
_gdk_windowing_window_get_offsets (window,
|
||||
&windowing_x_offset,
|
||||
&windowing_y_offset);
|
||||
|
||||
/* Copy the current window contents */
|
||||
gdk_draw_drawable (tmp_pixmap,
|
||||
tmp_gc,
|
||||
private->impl,
|
||||
x - windowing_x_offset,
|
||||
y - windowing_y_offset,
|
||||
0, 0,
|
||||
width, height);
|
||||
|
||||
/* Make buffered_region relative to the tmp_pixmap */
|
||||
gdk_region_offset (buffered_region,
|
||||
- x,
|
||||
- y);
|
||||
|
||||
/* Set the clip mask to avoid drawing over non-buffered areas of
|
||||
* tmp_pixmap.
|
||||
*/
|
||||
|
||||
gdk_gc_set_clip_region (tmp_gc, buffered_region);
|
||||
gdk_region_destroy (buffered_region);
|
||||
|
||||
/* Draw backing pixmap onto the tmp_pixmap, offsetting
|
||||
* appropriately.
|
||||
*/
|
||||
gdk_draw_drawable (tmp_pixmap,
|
||||
tmp_gc,
|
||||
buffer,
|
||||
x - buffer_x_offset,
|
||||
y - buffer_y_offset,
|
||||
0, 0,
|
||||
width, height);
|
||||
|
||||
/* Set these to location of tmp_pixmap within the window */
|
||||
*composite_x_offset = x;
|
||||
*composite_y_offset = y;
|
||||
|
||||
g_object_unref (G_OBJECT (tmp_gc));
|
||||
|
||||
return tmp_pixmap;
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_window_draw_drawable (GdkDrawable *drawable,
|
||||
GdkGC *gc,
|
||||
@ -1061,21 +1222,25 @@ gdk_window_draw_drawable (GdkDrawable *drawable,
|
||||
{
|
||||
GdkWindowObject *private = (GdkWindowObject *)drawable;
|
||||
OFFSET_GC (gc);
|
||||
|
||||
|
||||
if (GDK_WINDOW_DESTROYED (drawable))
|
||||
return;
|
||||
|
||||
|
||||
/* If we have a backing pixmap draw to that */
|
||||
if (private->paint_stack)
|
||||
{
|
||||
GdkWindowPaint *paint = private->paint_stack->data;
|
||||
gdk_draw_drawable (paint->pixmap, gc, src, xsrc, ysrc,
|
||||
gdk_draw_drawable (paint->pixmap, gc,
|
||||
src, xsrc, ysrc,
|
||||
xdest - x_offset, ydest - y_offset, width, height);
|
||||
|
||||
}
|
||||
else
|
||||
gdk_draw_drawable (private->impl, gc, src, xsrc, ysrc,
|
||||
gdk_draw_drawable (private->impl, gc,
|
||||
src, xsrc, ysrc,
|
||||
xdest - x_offset, ydest - y_offset,
|
||||
width, height);
|
||||
|
||||
RESTORE_GC (gc);
|
||||
}
|
||||
|
||||
@ -1403,6 +1568,32 @@ gdk_window_real_get_colormap (GdkDrawable *drawable)
|
||||
|
||||
return gdk_drawable_get_colormap (((GdkWindowObject*)drawable)->impl);
|
||||
}
|
||||
|
||||
static GdkImage*
|
||||
gdk_window_get_image (GdkDrawable *drawable,
|
||||
gint x,
|
||||
gint y,
|
||||
gint width,
|
||||
gint height)
|
||||
{
|
||||
gint x_offset, y_offset;
|
||||
|
||||
g_return_val_if_fail (GDK_IS_WINDOW (drawable), NULL);
|
||||
|
||||
if (GDK_WINDOW_DESTROYED (drawable))
|
||||
return NULL;
|
||||
|
||||
/* If we're here, a composite image was not necessary, so
|
||||
* we can ignore the paint stack.
|
||||
*/
|
||||
|
||||
_gdk_windowing_window_get_offsets (drawable, &x_offset, &y_offset);
|
||||
|
||||
return gdk_drawable_get_image (((GdkWindowObject*)drawable)->impl,
|
||||
x - x_offset,
|
||||
y - y_offset,
|
||||
width, height);
|
||||
}
|
||||
|
||||
/* Code for dirty-region queueing
|
||||
*/
|
||||
|
||||
@ -121,6 +121,8 @@ static GdkColormap* gdk_x11_get_colormap (GdkDrawable *drawable);
|
||||
|
||||
static gint gdk_x11_get_depth (GdkDrawable *drawable);
|
||||
|
||||
static GdkVisual* gdk_x11_get_visual (GdkDrawable *drawable);
|
||||
|
||||
static void gdk_drawable_impl_x11_class_init (GdkDrawableImplX11Class *klass);
|
||||
|
||||
static gpointer parent_class = NULL;
|
||||
@ -177,6 +179,9 @@ gdk_drawable_impl_x11_class_init (GdkDrawableImplX11Class *klass)
|
||||
drawable_class->get_colormap = gdk_x11_get_colormap;
|
||||
|
||||
drawable_class->get_depth = gdk_x11_get_depth;
|
||||
drawable_class->get_visual = gdk_x11_get_visual;
|
||||
|
||||
drawable_class->get_image = _gdk_x11_get_image;
|
||||
}
|
||||
|
||||
/*****************************************************
|
||||
@ -412,13 +417,19 @@ gdk_x11_draw_drawable (GdkDrawable *drawable,
|
||||
int src_depth = gdk_drawable_get_depth (src);
|
||||
int dest_depth = gdk_drawable_get_depth (drawable);
|
||||
GdkDrawableImplX11 *impl;
|
||||
|
||||
GdkDrawableImplX11 *src_impl;
|
||||
|
||||
impl = GDK_DRAWABLE_IMPL_X11 (drawable);
|
||||
|
||||
if (GDK_IS_DRAWABLE_IMPL_X11 (src))
|
||||
src_impl = GDK_DRAWABLE_IMPL_X11 (src);
|
||||
else
|
||||
src_impl = NULL;
|
||||
|
||||
if (src_depth == 1)
|
||||
{
|
||||
XCopyArea (impl->xdisplay,
|
||||
GDK_DRAWABLE_XID (src),
|
||||
src_impl ? src_impl->xid : GDK_DRAWABLE_XID (src),
|
||||
impl->xid,
|
||||
GDK_GC_GET_XGC (gc),
|
||||
xsrc, ysrc,
|
||||
@ -428,7 +439,7 @@ gdk_x11_draw_drawable (GdkDrawable *drawable,
|
||||
else if (dest_depth != 0 && src_depth == dest_depth)
|
||||
{
|
||||
XCopyArea (impl->xdisplay,
|
||||
GDK_DRAWABLE_XID (src),
|
||||
src_impl ? src_impl->xid : GDK_DRAWABLE_XID (src),
|
||||
impl->xid,
|
||||
GDK_GC_GET_XGC (gc),
|
||||
xsrc, ysrc,
|
||||
@ -436,7 +447,8 @@ gdk_x11_draw_drawable (GdkDrawable *drawable,
|
||||
xdest, ydest);
|
||||
}
|
||||
else
|
||||
g_warning ("Attempt to copy between drawables of mismatched depths!\n");
|
||||
g_warning ("Attempt to draw a drawable with depth %d to a drawable with depth %d",
|
||||
src_depth, dest_depth);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -603,3 +615,8 @@ gdk_x11_get_depth (GdkDrawable *drawable)
|
||||
return gdk_drawable_get_depth (GDK_DRAWABLE_IMPL_X11 (drawable)->wrapper);
|
||||
}
|
||||
|
||||
static GdkVisual*
|
||||
gdk_x11_get_visual (GdkDrawable *drawable)
|
||||
{
|
||||
return gdk_drawable_get_visual (GDK_DRAWABLE_IMPL_X11 (drawable)->wrapper);
|
||||
}
|
||||
|
||||
@ -650,7 +650,7 @@ gdk_gc_set_clip_rectangle (GdkGC *gc,
|
||||
gc->clip_y_origin = 0;
|
||||
|
||||
x11_gc->dirty_mask |= GDK_GC_DIRTY_CLIP;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gdk_gc_set_clip_region (GdkGC *gc,
|
||||
|
||||
@ -371,31 +371,44 @@ gdk_image_new (GdkImageType type,
|
||||
}
|
||||
|
||||
GdkImage*
|
||||
gdk_image_get (GdkWindow *window,
|
||||
gint x,
|
||||
gint y,
|
||||
gint width,
|
||||
gint height)
|
||||
_gdk_x11_get_image (GdkDrawable *drawable,
|
||||
gint x,
|
||||
gint y,
|
||||
gint width,
|
||||
gint height)
|
||||
{
|
||||
GdkImage *image;
|
||||
GdkImagePrivateX11 *private;
|
||||
GdkDrawableImplX11 *impl;
|
||||
GdkVisual *visual;
|
||||
|
||||
g_return_val_if_fail (GDK_IS_DRAWABLE_IMPL_X11 (drawable), NULL);
|
||||
|
||||
g_return_val_if_fail (GDK_IS_DRAWABLE (window), NULL);
|
||||
visual = gdk_drawable_get_visual (drawable);
|
||||
|
||||
if (GDK_IS_WINDOW (window) && GDK_WINDOW_DESTROYED (window))
|
||||
return NULL;
|
||||
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");
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
impl = GDK_DRAWABLE_IMPL_X11 (drawable);
|
||||
|
||||
image = g_object_new (gdk_image_get_type (), NULL);
|
||||
private = PRIVATE_DATA (image);
|
||||
|
||||
private->xdisplay = gdk_display;
|
||||
private->ximage = XGetImage (private->xdisplay,
|
||||
GDK_DRAWABLE_XID (window),
|
||||
impl->xid,
|
||||
x, y, width, height,
|
||||
AllPlanes, ZPixmap);
|
||||
|
||||
image->type = GDK_IMAGE_NORMAL;
|
||||
image->visual = gdk_window_get_visual (window);
|
||||
image->visual = visual;
|
||||
image->width = width;
|
||||
image->height = height;
|
||||
image->depth = private->ximage->depth;
|
||||
|
||||
@ -149,6 +149,7 @@ gdk_pixmap_new (GdkWindow *window,
|
||||
GdkPixmap *pixmap;
|
||||
GdkDrawableImplX11 *draw_impl;
|
||||
GdkPixmapImplX11 *pix_impl;
|
||||
GdkColormap *cmap;
|
||||
|
||||
g_return_val_if_fail (window == NULL || GDK_IS_WINDOW (window), NULL);
|
||||
g_return_val_if_fail ((window != NULL) || (depth != -1), NULL);
|
||||
@ -177,9 +178,16 @@ gdk_pixmap_new (GdkWindow *window,
|
||||
pix_impl->width = width;
|
||||
pix_impl->height = height;
|
||||
GDK_PIXMAP_OBJECT (pixmap)->depth = depth;
|
||||
|
||||
if (window)
|
||||
{
|
||||
cmap = gdk_drawable_get_colormap (window);
|
||||
if (cmap)
|
||||
gdk_drawable_set_colormap (pixmap, cmap);
|
||||
}
|
||||
|
||||
gdk_xid_table_insert (&GDK_PIXMAP_XID (pixmap), pixmap);
|
||||
|
||||
|
||||
return pixmap;
|
||||
}
|
||||
|
||||
|
||||
@ -49,6 +49,12 @@ GdkVisual * gdk_visual_lookup (Visual *xvisual);
|
||||
|
||||
void gdk_window_add_colormap_windows (GdkWindow *window);
|
||||
|
||||
GdkImage* _gdk_x11_get_image (GdkDrawable *drawable,
|
||||
gint x,
|
||||
gint y,
|
||||
gint width,
|
||||
gint height);
|
||||
|
||||
/* Please see gdkwindow.c for comments on how to use */
|
||||
Window gdk_window_xid_at (Window base,
|
||||
gint bx,
|
||||
|
||||
Reference in New Issue
Block a user