summaryrefslogtreecommitdiff
path: root/gdk
diff options
context:
space:
mode:
authorOwen Taylor <otaylor@redhat.com>2001-07-18 20:09:28 +0000
committerOwen Taylor <otaylor@src.gnome.org>2001-07-18 20:09:28 +0000
commit94239d144e223cacbffceeb804e44ceedbf2f6b1 (patch)
tree2fa88432d1fd763b2650e0b546a732586e96e82b /gdk
parent03496763290dfdc11277e8ae8ef065e02b05f7bd (diff)
downloadgdk-pixbuf-94239d144e223cacbffceeb804e44ceedbf2f6b1.tar.gz
Add a function gdk_window_get_internal_paint_info(), so that using X
Fri Jul 13 15:33:32 2001 Owen Taylor <otaylor@redhat.com> * gdk/gdkwindow.[ch]: Add a function gdk_window_get_internal_paint_info(), so that using X functions on a GdkWindow is possible, if a little hairy. * gdk/gdkgc.c (gdk_gc_offset): Add a function to offset the clip and ts_origin of a GC, so that external parties can offset/restore a GC, when using gdk_window_get_internal_paint_info().
Diffstat (limited to 'gdk')
-rw-r--r--gdk/gdkgc.c33
-rw-r--r--gdk/gdkgc.h3
-rw-r--r--gdk/gdkwindow.c53
-rw-r--r--gdk/gdkwindow.h5
4 files changed, 94 insertions, 0 deletions
diff --git a/gdk/gdkgc.c b/gdk/gdkgc.c
index f87b7b37c..127a692b1 100644
--- a/gdk/gdkgc.c
+++ b/gdk/gdkgc.c
@@ -367,6 +367,39 @@ gdk_gc_set_dashes (GdkGC *gc,
}
/**
+ * gdk_gc_offset:
+ * @gc: a #GdkGC
+ * @x_offset: amount by which to offset the GC in the X direction
+ * @y_offset: amount by which to offset the GC in the Y direction
+ *
+ * Offset attributes such as the clip and tile-stipple origins
+ * of the GC so that drawing at x - x_offset, y - y_offset with
+ * the offset GC has the same effect as drawing at x, y with the original
+ * GC.
+ **/
+void
+gdk_gc_offset (GdkGC *gc,
+ gint x_offset,
+ gint y_offset)
+{
+ if (x_offset != 0 || y_offset != 0)
+ {
+ GdkGCValues values;
+
+ values.clip_x_origin = gc->clip_x_origin - x_offset;
+ values.clip_y_origin = gc->clip_y_origin - y_offset;
+ values.ts_x_origin = gc->ts_x_origin - x_offset;
+ values.ts_y_origin = gc->ts_y_origin - y_offset;
+
+ gdk_gc_set_values (gc, &values,
+ GDK_GC_CLIP_X_ORIGIN |
+ GDK_GC_CLIP_Y_ORIGIN |
+ GDK_GC_TS_X_ORIGIN |
+ GDK_GC_TS_Y_ORIGIN);
+ }
+}
+
+/**
* gdk_gc_set_colormap:
* @gc: a #GdkGC
* @colormap: a #GdkColormap
diff --git a/gdk/gdkgc.h b/gdk/gdkgc.h
index b18c7fffb..e55a41e0e 100644
--- a/gdk/gdkgc.h
+++ b/gdk/gdkgc.h
@@ -237,6 +237,9 @@ void gdk_gc_set_dashes (GdkGC *gc,
gint dash_offset,
gint8 dash_list[],
gint n);
+void gdk_gc_offset (GdkGC *gc,
+ gint x_offset,
+ gint y_offset);
void gdk_gc_copy (GdkGC *dst_gc,
GdkGC *src_gc);
diff --git a/gdk/gdkwindow.c b/gdk/gdkwindow.c
index 59183b204..2f82576c0 100644
--- a/gdk/gdkwindow.c
+++ b/gdk/gdkwindow.c
@@ -979,6 +979,59 @@ gdk_window_get_offsets (GdkWindow *window,
_gdk_windowing_window_get_offsets (window, x_offset, y_offset);
}
+/**
+ * gdk_window_get_internal_paint_info:
+ * @window: a #GdkWindow
+ * @real_drawable: location to store the drawable to which drawing should be done.
+ * @x_offset: location to store the X offset between coordinates in @window, and
+ * the underlying window system primitive coordinates for *@real_drawable.
+ * @y_offset: location to store the Y offset between coordinates in @window, and
+ * the underlying window system primitive coordinates for *@real_drawable.
+ *
+ * If you bypass the GDK layer and use windowing system primitives to
+ * draw directly onto a #GdkWindow, then you need to deal with two
+ * details: there may be an offset between GDK coordinates and windowing
+ * system coordinates, and GDK may have redirected drawing to a offscreen
+ * pixmap as the result of a gdk_window_begin_paint_region() calls.
+ * This function allows retrieving the information you need to compensate
+ * for these effects.
+ *
+ * This function exposes details of the GDK implementation, and is thus
+ * likely to change in future releases of GDK.
+ **/
+void
+gdk_window_get_internal_paint_info (GdkWindow *window,
+ GdkDrawable **real_drawable,
+ gint *x_offset,
+ gint *y_offset)
+{
+ gint x_off, y_off;
+
+ GdkWindowObject *private;
+
+ g_return_if_fail (GDK_IS_WINDOW (window));
+
+ private = (GdkWindowObject *)window;
+
+ if (real_drawable)
+ {
+ if (private->paint_stack)
+ {
+ GdkWindowPaint *paint = private->paint_stack->data;
+ *real_drawable = paint->pixmap;
+ }
+ else
+ *real_drawable = window;
+ }
+
+ gdk_window_get_offsets (window, &x_off, &y_off);
+
+ if (x_offset)
+ *x_offset = x_off;
+ if (y_offset)
+ *y_offset = y_off;
+}
+
#define OFFSET_GC(gc) \
gint x_offset, y_offset; \
gint old_clip_x = gc->clip_x_origin; \
diff --git a/gdk/gdkwindow.h b/gdk/gdkwindow.h
index 6ea64594a..03263adef 100644
--- a/gdk/gdkwindow.h
+++ b/gdk/gdkwindow.h
@@ -507,6 +507,11 @@ void gdk_window_constrain_size (GdkGeometry *geometry,
gint *new_width,
gint *new_height);
+void gdk_window_get_internal_paint_info (GdkWindow *window,
+ GdkDrawable **real_drawable,
+ gint *x_offset,
+ gint *y_offset);
+
GdkPointerHooks *gdk_set_pointer_hooks (const GdkPointerHooks *new_hooks);
#ifdef __cplusplus