diff options
author | Owen Taylor <otaylor@redhat.com> | 2000-12-15 01:46:41 +0000 |
---|---|---|
committer | Owen Taylor <otaylor@src.gnome.org> | 2000-12-15 01:46:41 +0000 |
commit | 6e5a269f38ad682e116e94efac287fa4ddc46b7f (patch) | |
tree | 25b336984ac15be84beb85ff71b3d99c11b861ed | |
parent | 2142a98c9e8826323941ec3da2c75325ca00eb52 (diff) | |
download | gdk-pixbuf-6e5a269f38ad682e116e94efac287fa4ddc46b7f.tar.gz |
Add two virtualized functions gdk_drawable_get_clip_region - to get the
Thu Dec 14 20:22:31 2000 Owen Taylor <otaylor@redhat.com>
* gdk/{gdkdrawable.[ch],gdkpixmap.c,gdkwindow.c,x11/gdkwindow.c}:
Add two virtualized functions gdk_drawable_get_clip_region - to
get the clip region when drawing.
* gdk/gdkwindow.c (gdk_window_invalidate_rect): Rewrite to simple
use invalidate_region.
* gdk/gdkwindow.c (gdk_window_invalidate_region): Clip to visible
region.
* acconfig.h configure.in: Check for Xft. For now, assume
that if Xft is found, Pango was compiled with Xft support
as well.
* gdk/gdkcolor.h gdk/x11/gdkcolor-x11.c: Add
gdk_colormap_query_color().
* gdk/x11/gdkdrawable-x11.c (gdk_x11_draw_glyphs): Draw
with Xft if appropriate.
* gdk/x11/gdkpango-x11.c (gdk_pango_context_get): Create
a pangoxft context if we have XFT and the environment
variable GD_USE_XFT is set.
* gdk/x11/gdkx.h (struct _GdkGCX11): Cache the fg_pixel
and also possibly an XftDraw structure.
* gtk/gtkfontsel.c: Handle the case where the font from the
style doesn't match any of the fonts a bit better.
* gtk/testgtk.c: Add tabs between directional segments for
hebrew/arabic test. (Not really necessary, just a little
prettier.)
-rw-r--r-- | ChangeLog | 36 | ||||
-rw-r--r-- | ChangeLog.pre-2-0 | 36 | ||||
-rw-r--r-- | ChangeLog.pre-2-10 | 36 | ||||
-rw-r--r-- | ChangeLog.pre-2-2 | 36 | ||||
-rw-r--r-- | ChangeLog.pre-2-4 | 36 | ||||
-rw-r--r-- | ChangeLog.pre-2-6 | 36 | ||||
-rw-r--r-- | ChangeLog.pre-2-8 | 36 | ||||
-rw-r--r-- | acconfig.h | 1 | ||||
-rw-r--r-- | configure.in | 19 | ||||
-rw-r--r-- | gdk/gdkcolor.h | 3 | ||||
-rw-r--r-- | gdk/gdkdraw.c | 71 | ||||
-rw-r--r-- | gdk/gdkdrawable.h | 6 | ||||
-rw-r--r-- | gdk/gdkpixmap.c | 11 | ||||
-rw-r--r-- | gdk/gdkwindow.c | 180 | ||||
-rw-r--r-- | gdk/x11/gdkcolor-x11.c | 41 | ||||
-rw-r--r-- | gdk/x11/gdkdrawable-x11.c | 87 | ||||
-rw-r--r-- | gdk/x11/gdkgc-x11.c | 20 | ||||
-rw-r--r-- | gdk/x11/gdkgeometry-x11.c | 2 | ||||
-rw-r--r-- | gdk/x11/gdkmain-x11.c | 2 | ||||
-rw-r--r-- | gdk/x11/gdkpango-x11.c | 21 | ||||
-rw-r--r-- | gdk/x11/gdkprivate-x11.h | 8 | ||||
-rw-r--r-- | gdk/x11/gdkwindow-x11.c | 29 | ||||
-rw-r--r-- | gdk/x11/gdkx.h | 7 | ||||
-rw-r--r-- | gtk/gtkfontsel.c | 9 | ||||
-rw-r--r-- | gtk/testgtk.c | 4 | ||||
-rw-r--r-- | tests/testgtk.c | 4 |
26 files changed, 649 insertions, 128 deletions
@@ -1,3 +1,39 @@ +Thu Dec 14 20:22:31 2000 Owen Taylor <otaylor@redhat.com> + + * gdk/{gdkdrawable.[ch],gdkpixmap.c,gdkwindow.c,x11/gdkwindow.c}: + Add two virtualized functions gdk_drawable_get_clip_region - to + get the clip region when drawing. + + * gdk/gdkwindow.c (gdk_window_invalidate_rect): Rewrite to simple + use invalidate_region. + + * gdk/gdkwindow.c (gdk_window_invalidate_region): Clip to visible + region. + + * acconfig.h configure.in: Check for Xft. For now, assume + that if Xft is found, Pango was compiled with Xft support + as well. + + * gdk/gdkcolor.h gdk/x11/gdkcolor-x11.c: Add + gdk_colormap_query_color(). + + * gdk/x11/gdkdrawable-x11.c (gdk_x11_draw_glyphs): Draw + with Xft if appropriate. + + * gdk/x11/gdkpango-x11.c (gdk_pango_context_get): Create + a pangoxft context if we have XFT and the environment + variable GD_USE_XFT is set. + + * gdk/x11/gdkx.h (struct _GdkGCX11): Cache the fg_pixel + and also possibly an XftDraw structure. + + * gtk/gtkfontsel.c: Handle the case where the font from the + style doesn't match any of the fonts a bit better. + + * gtk/testgtk.c: Add tabs between directional segments for + hebrew/arabic test. (Not really necessary, just a little + prettier.) + 2000-12-14 Havoc Pennington <hp@redhat.com> * gtk/testtext.c (fill_file_buffer): fix unicode validation when diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0 index 73ab05d42..0f848f514 100644 --- a/ChangeLog.pre-2-0 +++ b/ChangeLog.pre-2-0 @@ -1,3 +1,39 @@ +Thu Dec 14 20:22:31 2000 Owen Taylor <otaylor@redhat.com> + + * gdk/{gdkdrawable.[ch],gdkpixmap.c,gdkwindow.c,x11/gdkwindow.c}: + Add two virtualized functions gdk_drawable_get_clip_region - to + get the clip region when drawing. + + * gdk/gdkwindow.c (gdk_window_invalidate_rect): Rewrite to simple + use invalidate_region. + + * gdk/gdkwindow.c (gdk_window_invalidate_region): Clip to visible + region. + + * acconfig.h configure.in: Check for Xft. For now, assume + that if Xft is found, Pango was compiled with Xft support + as well. + + * gdk/gdkcolor.h gdk/x11/gdkcolor-x11.c: Add + gdk_colormap_query_color(). + + * gdk/x11/gdkdrawable-x11.c (gdk_x11_draw_glyphs): Draw + with Xft if appropriate. + + * gdk/x11/gdkpango-x11.c (gdk_pango_context_get): Create + a pangoxft context if we have XFT and the environment + variable GD_USE_XFT is set. + + * gdk/x11/gdkx.h (struct _GdkGCX11): Cache the fg_pixel + and also possibly an XftDraw structure. + + * gtk/gtkfontsel.c: Handle the case where the font from the + style doesn't match any of the fonts a bit better. + + * gtk/testgtk.c: Add tabs between directional segments for + hebrew/arabic test. (Not really necessary, just a little + prettier.) + 2000-12-14 Havoc Pennington <hp@redhat.com> * gtk/testtext.c (fill_file_buffer): fix unicode validation when diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 73ab05d42..0f848f514 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,39 @@ +Thu Dec 14 20:22:31 2000 Owen Taylor <otaylor@redhat.com> + + * gdk/{gdkdrawable.[ch],gdkpixmap.c,gdkwindow.c,x11/gdkwindow.c}: + Add two virtualized functions gdk_drawable_get_clip_region - to + get the clip region when drawing. + + * gdk/gdkwindow.c (gdk_window_invalidate_rect): Rewrite to simple + use invalidate_region. + + * gdk/gdkwindow.c (gdk_window_invalidate_region): Clip to visible + region. + + * acconfig.h configure.in: Check for Xft. For now, assume + that if Xft is found, Pango was compiled with Xft support + as well. + + * gdk/gdkcolor.h gdk/x11/gdkcolor-x11.c: Add + gdk_colormap_query_color(). + + * gdk/x11/gdkdrawable-x11.c (gdk_x11_draw_glyphs): Draw + with Xft if appropriate. + + * gdk/x11/gdkpango-x11.c (gdk_pango_context_get): Create + a pangoxft context if we have XFT and the environment + variable GD_USE_XFT is set. + + * gdk/x11/gdkx.h (struct _GdkGCX11): Cache the fg_pixel + and also possibly an XftDraw structure. + + * gtk/gtkfontsel.c: Handle the case where the font from the + style doesn't match any of the fonts a bit better. + + * gtk/testgtk.c: Add tabs between directional segments for + hebrew/arabic test. (Not really necessary, just a little + prettier.) + 2000-12-14 Havoc Pennington <hp@redhat.com> * gtk/testtext.c (fill_file_buffer): fix unicode validation when diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index 73ab05d42..0f848f514 100644 --- a/ChangeLog.pre-2-2 +++ b/ChangeLog.pre-2-2 @@ -1,3 +1,39 @@ +Thu Dec 14 20:22:31 2000 Owen Taylor <otaylor@redhat.com> + + * gdk/{gdkdrawable.[ch],gdkpixmap.c,gdkwindow.c,x11/gdkwindow.c}: + Add two virtualized functions gdk_drawable_get_clip_region - to + get the clip region when drawing. + + * gdk/gdkwindow.c (gdk_window_invalidate_rect): Rewrite to simple + use invalidate_region. + + * gdk/gdkwindow.c (gdk_window_invalidate_region): Clip to visible + region. + + * acconfig.h configure.in: Check for Xft. For now, assume + that if Xft is found, Pango was compiled with Xft support + as well. + + * gdk/gdkcolor.h gdk/x11/gdkcolor-x11.c: Add + gdk_colormap_query_color(). + + * gdk/x11/gdkdrawable-x11.c (gdk_x11_draw_glyphs): Draw + with Xft if appropriate. + + * gdk/x11/gdkpango-x11.c (gdk_pango_context_get): Create + a pangoxft context if we have XFT and the environment + variable GD_USE_XFT is set. + + * gdk/x11/gdkx.h (struct _GdkGCX11): Cache the fg_pixel + and also possibly an XftDraw structure. + + * gtk/gtkfontsel.c: Handle the case where the font from the + style doesn't match any of the fonts a bit better. + + * gtk/testgtk.c: Add tabs between directional segments for + hebrew/arabic test. (Not really necessary, just a little + prettier.) + 2000-12-14 Havoc Pennington <hp@redhat.com> * gtk/testtext.c (fill_file_buffer): fix unicode validation when diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index 73ab05d42..0f848f514 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,39 @@ +Thu Dec 14 20:22:31 2000 Owen Taylor <otaylor@redhat.com> + + * gdk/{gdkdrawable.[ch],gdkpixmap.c,gdkwindow.c,x11/gdkwindow.c}: + Add two virtualized functions gdk_drawable_get_clip_region - to + get the clip region when drawing. + + * gdk/gdkwindow.c (gdk_window_invalidate_rect): Rewrite to simple + use invalidate_region. + + * gdk/gdkwindow.c (gdk_window_invalidate_region): Clip to visible + region. + + * acconfig.h configure.in: Check for Xft. For now, assume + that if Xft is found, Pango was compiled with Xft support + as well. + + * gdk/gdkcolor.h gdk/x11/gdkcolor-x11.c: Add + gdk_colormap_query_color(). + + * gdk/x11/gdkdrawable-x11.c (gdk_x11_draw_glyphs): Draw + with Xft if appropriate. + + * gdk/x11/gdkpango-x11.c (gdk_pango_context_get): Create + a pangoxft context if we have XFT and the environment + variable GD_USE_XFT is set. + + * gdk/x11/gdkx.h (struct _GdkGCX11): Cache the fg_pixel + and also possibly an XftDraw structure. + + * gtk/gtkfontsel.c: Handle the case where the font from the + style doesn't match any of the fonts a bit better. + + * gtk/testgtk.c: Add tabs between directional segments for + hebrew/arabic test. (Not really necessary, just a little + prettier.) + 2000-12-14 Havoc Pennington <hp@redhat.com> * gtk/testtext.c (fill_file_buffer): fix unicode validation when diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index 73ab05d42..0f848f514 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,39 @@ +Thu Dec 14 20:22:31 2000 Owen Taylor <otaylor@redhat.com> + + * gdk/{gdkdrawable.[ch],gdkpixmap.c,gdkwindow.c,x11/gdkwindow.c}: + Add two virtualized functions gdk_drawable_get_clip_region - to + get the clip region when drawing. + + * gdk/gdkwindow.c (gdk_window_invalidate_rect): Rewrite to simple + use invalidate_region. + + * gdk/gdkwindow.c (gdk_window_invalidate_region): Clip to visible + region. + + * acconfig.h configure.in: Check for Xft. For now, assume + that if Xft is found, Pango was compiled with Xft support + as well. + + * gdk/gdkcolor.h gdk/x11/gdkcolor-x11.c: Add + gdk_colormap_query_color(). + + * gdk/x11/gdkdrawable-x11.c (gdk_x11_draw_glyphs): Draw + with Xft if appropriate. + + * gdk/x11/gdkpango-x11.c (gdk_pango_context_get): Create + a pangoxft context if we have XFT and the environment + variable GD_USE_XFT is set. + + * gdk/x11/gdkx.h (struct _GdkGCX11): Cache the fg_pixel + and also possibly an XftDraw structure. + + * gtk/gtkfontsel.c: Handle the case where the font from the + style doesn't match any of the fonts a bit better. + + * gtk/testgtk.c: Add tabs between directional segments for + hebrew/arabic test. (Not really necessary, just a little + prettier.) + 2000-12-14 Havoc Pennington <hp@redhat.com> * gtk/testtext.c (fill_file_buffer): fix unicode validation when diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 73ab05d42..0f848f514 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,39 @@ +Thu Dec 14 20:22:31 2000 Owen Taylor <otaylor@redhat.com> + + * gdk/{gdkdrawable.[ch],gdkpixmap.c,gdkwindow.c,x11/gdkwindow.c}: + Add two virtualized functions gdk_drawable_get_clip_region - to + get the clip region when drawing. + + * gdk/gdkwindow.c (gdk_window_invalidate_rect): Rewrite to simple + use invalidate_region. + + * gdk/gdkwindow.c (gdk_window_invalidate_region): Clip to visible + region. + + * acconfig.h configure.in: Check for Xft. For now, assume + that if Xft is found, Pango was compiled with Xft support + as well. + + * gdk/gdkcolor.h gdk/x11/gdkcolor-x11.c: Add + gdk_colormap_query_color(). + + * gdk/x11/gdkdrawable-x11.c (gdk_x11_draw_glyphs): Draw + with Xft if appropriate. + + * gdk/x11/gdkpango-x11.c (gdk_pango_context_get): Create + a pangoxft context if we have XFT and the environment + variable GD_USE_XFT is set. + + * gdk/x11/gdkx.h (struct _GdkGCX11): Cache the fg_pixel + and also possibly an XftDraw structure. + + * gtk/gtkfontsel.c: Handle the case where the font from the + style doesn't match any of the fonts a bit better. + + * gtk/testgtk.c: Add tabs between directional segments for + hebrew/arabic test. (Not really necessary, just a little + prettier.) + 2000-12-14 Havoc Pennington <hp@redhat.com> * gtk/testtext.c (fill_file_buffer): fix unicode validation when diff --git a/acconfig.h b/acconfig.h index f9404016e..32fc21dbf 100644 --- a/acconfig.h +++ b/acconfig.h @@ -32,6 +32,7 @@ #undef HAVE_SYS_SELECT_H #undef HAVE_SYS_TIME_H #undef HAVE_XCONVERTCASE +#undef HAVE_XFT #undef NO_FD_SET diff --git a/configure.in b/configure.in index 2846aab07..7e4bb057a 100644 --- a/configure.in +++ b/configure.in @@ -398,6 +398,22 @@ if test "x$gdktarget" = "xx11"; then , $x_libs) + # + # Checks for Xft/XRender + # + have_xft=false + XFT_LIBS="" + AC_CHECK_LIB(Xrender, XRenderFindFormat, + AC_CHECK_LIB(Xft, XftFontOpen, have_xft=true, :, -lXrender $X_LIBS) + ,:,-lXext $X_LIBS) + + if $have_xft = 'true' ; then + X_LIBS="-lXft -lXrender -lXext $X_LIBS" + fi + + AC_DEFINE(HAVE_XFT) + AM_CONDITIONAL(HAVE_XFT, $have_xft) + # Check for XIM support. AC_CHECK_LIB(X11, XUnregisterIMInstantiateCallback, @@ -562,6 +578,9 @@ fi if test "x$gdktarget" = "xx11"; then PANGO_CFLAGS="`$PANGO_CONFIG --cflags pangox`" PANGO_LIBS="`$PANGO_CONFIG --libs pangox`" + if $have_xft = true ; then + PANGO_LIBS="$PANGO_LIBS -lpangoxft" + fi else PANGO_CFLAGS="`$PANGO_CONFIG --cflags pango`" PANGO_LIBS="`$PANGO_CONFIG --libs pango`" diff --git a/gdk/gdkcolor.h b/gdk/gdkcolor.h index 811d1cf93..07417f802 100644 --- a/gdk/gdkcolor.h +++ b/gdk/gdkcolor.h @@ -82,6 +82,9 @@ gboolean gdk_colormap_alloc_color (GdkColormap *colormap, void gdk_colormap_free_colors (GdkColormap *colormap, GdkColor *colors, gint ncolors); +void gdk_colormap_query_color (GdkColormap *colormap, + gulong pixel, + GdkColor *result); GdkVisual *gdk_colormap_get_visual (GdkColormap *colormap); diff --git a/gdk/gdkdraw.c b/gdk/gdkdraw.c index fcab539e5..a6fd64d28 100644 --- a/gdk/gdkdraw.c +++ b/gdk/gdkdraw.c @@ -29,12 +29,13 @@ #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); + gint x, + gint y, + gint width, + gint height, + gint *composite_x_offset, + gint *composite_y_offset); +static GdkRegion * gdk_drawable_real_get_visible_region (GdkDrawable *drawable); static void gdk_drawable_class_init (GdkDrawableClass *klass); @@ -70,6 +71,9 @@ static void gdk_drawable_class_init (GdkDrawableClass *klass) { klass->get_composite_drawable = gdk_drawable_real_get_composite_drawable; + /* Default implementation for clip and visible region is the same */ + klass->get_clip_region = gdk_drawable_real_get_visible_region; + klass->get_visible_region = gdk_drawable_real_get_visible_region; } /* Manipulation of drawables @@ -525,3 +529,58 @@ gdk_drawable_real_get_composite_drawable (GdkDrawable *drawable, return GDK_DRAWABLE (g_object_ref (G_OBJECT (drawable))); } + +/** + * gdk_drawable_get_clip_region: + * @drawable: a #GdkDrawable + * + * Computes the region of a drawable that potentially can be written + * to by drawing primitives. This region will not take into account + * the clip region for the GC, and may also not take into account + * other factors such as if the window is obscured by other windows, + * but no area outside of this region will be affected by drawing + * primitives. + * + * Return value: a #GdkRegion. This must be freed with gdk_region_destroy() + * when you are done. + **/ +GdkRegion * +gdk_drawable_get_clip_region (GdkDrawable *drawable) +{ + g_return_val_if_fail (GDK_IS_DRAWABLE (drawable), NULL); + + return GDK_DRAWABLE_GET_CLASS (drawable)->get_clip_region (drawable); +} + +/** + * gdk_drawable_get_visible_region: + * @drawable: + * + * Computes the region of a drawable that is potentially visible. + * This does not necessarily take into account if the window is + * obscured by other windows, but no area outside of this region + * is visible. + * + * Return value: a #GdkRegion. This must be freed with gdk_region_destroy() + * when you are done. + **/ +GdkRegion * +gdk_drawable_get_visible_region (GdkDrawable *drawable) +{ + g_return_val_if_fail (GDK_IS_DRAWABLE (drawable), NULL); + + return GDK_DRAWABLE_GET_CLASS (drawable)->get_visible_region (drawable); +} + +static GdkRegion * +gdk_drawable_real_get_visible_region (GdkDrawable *drawable) +{ + GdkRectangle rect; + + rect.x = 0; + rect.y = 0; + + gdk_drawable_get_size (drawable, &rect.width, &rect.height); + + return gdk_region_rectangle (&rect); +} diff --git a/gdk/gdkdrawable.h b/gdk/gdkdrawable.h index e177ca81a..a35830d23 100644 --- a/gdk/gdkdrawable.h +++ b/gdk/gdkdrawable.h @@ -120,6 +120,9 @@ struct _GdkDrawableClass gint width, gint height); + GdkRegion* (*get_clip_region) (GdkDrawable *drawable); + GdkRegion* (*get_visible_region) (GdkDrawable *drawable); + GdkDrawable* (*get_composite_drawable) (GdkDrawable *drawable, gint x, gint y, @@ -260,6 +263,9 @@ GdkImage* gdk_drawable_get_image (GdkDrawable *drawable, gint width, gint height); +GdkRegion *gdk_drawable_get_clip_region (GdkDrawable *drawable); +GdkRegion *gdk_drawable_get_visible_region (GdkDrawable *drawable); + #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/gdk/gdkpixmap.c b/gdk/gdkpixmap.c index 27fc5f631..320320c92 100644 --- a/gdk/gdkpixmap.c +++ b/gdk/gdkpixmap.c @@ -107,12 +107,11 @@ 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 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); diff --git a/gdk/gdkwindow.c b/gdk/gdkwindow.c index be6e8d013..42ded204b 100644 --- a/gdk/gdkwindow.c +++ b/gdk/gdkwindow.c @@ -136,12 +136,14 @@ static void gdk_window_real_set_colormap (GdkDrawable *drawable, 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); + gint x, + gint y, + gint width, + gint height, + gint *composite_x_offset, + gint *composite_y_offset); +static GdkRegion* gdk_window_get_clip_region (GdkDrawable *drawable); +static GdkRegion* gdk_window_get_visible_region (GdkDrawable *drawable); static void gdk_window_free_paint_stack (GdkWindow *window); @@ -217,6 +219,8 @@ gdk_window_class_init (GdkWindowObjectClass *klass) 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_clip_region = gdk_window_get_clip_region; + drawable_class->get_visible_region = gdk_window_get_visible_region; drawable_class->get_composite_drawable = gdk_window_get_composite_drawable; } @@ -1207,6 +1211,41 @@ gdk_window_get_composite_drawable (GdkDrawable *window, return tmp_pixmap; } +static GdkRegion* +gdk_window_get_clip_region (GdkDrawable *drawable) +{ + GdkWindowObject *private = (GdkWindowObject *)drawable; + GdkRegion *result; + + result = gdk_drawable_get_clip_region (private->impl); + + if (private->paint_stack) + { + GdkRegion *paint_region = gdk_region_new (); + GSList *tmp_list = private->paint_stack; + + while (tmp_list) + { + GdkWindowPaint *paint = tmp_list->data; + + gdk_region_union (paint_region, paint->region); + } + + gdk_region_intersect (result, paint_region); + gdk_region_destroy (paint_region); + } + + return result; +} + +static GdkRegion* +gdk_window_get_visible_region (GdkDrawable *drawable) +{ + GdkWindowObject *private = (GdkWindowObject*) drawable; + + return gdk_drawable_get_visible_region (private->impl); +} + static void gdk_window_draw_drawable (GdkDrawable *drawable, GdkGC *gc, @@ -1710,6 +1749,7 @@ gdk_window_invalidate_rect (GdkWindow *window, gboolean invalidate_children) { GdkRectangle window_rect; + GdkRegion *region; GdkWindowObject *private = (GdkWindowObject *)window; g_return_if_fail (window != NULL); @@ -1730,55 +1770,10 @@ gdk_window_invalidate_rect (GdkWindow *window, &window_rect.height); rect = &window_rect; } - - if (private->update_area) - { - gdk_region_union_with_rect (private->update_area, rect); - } - else - { - update_windows = g_slist_prepend (update_windows, window); - private->update_area = gdk_region_rectangle (rect); - - if (!private->update_freeze_count && !update_idle) - update_idle = g_idle_add_full (GDK_PRIORITY_REDRAW, - gdk_window_update_idle, NULL, NULL); - } - - - if (invalidate_children) - { - GList *tmp_list; - GdkRectangle child_rect, new_rect; - - tmp_list = private->children; - while (tmp_list) - { - GdkWindowObject *child = tmp_list->data; - tmp_list = tmp_list->next; - - if (!child->input_only) - { - gint width, height; - gdk_drawable_get_size (GDK_DRAWABLE (child), - &width, &height); - - child_rect.x = child->x; - child_rect.y = child->y; - child_rect.width = width; - child_rect.height = height; - - if (gdk_rectangle_intersect (rect, &child_rect, &new_rect)) - { - new_rect.x -= child_rect.x; - new_rect.y -= child_rect.y; - - gdk_window_invalidate_rect ((GdkWindow *)child, &new_rect, TRUE); - } - } - } - } + region = gdk_region_rectangle (rect); + gdk_window_invalidate_region (window, region, invalidate_children); + gdk_region_destroy (region); } void @@ -1787,6 +1782,7 @@ gdk_window_invalidate_region (GdkWindow *window, gboolean invalidate_children) { GdkWindowObject *private = (GdkWindowObject *)window; + GdkRegion *visible_region; g_return_if_fail (window != NULL); g_return_if_fail (GDK_IS_WINDOW (window)); @@ -1796,55 +1792,51 @@ gdk_window_invalidate_region (GdkWindow *window, if (private->input_only || !private->mapped) return; - - if (private->update_area) - { - gdk_region_union (private->update_area, region); - } - else - { - update_windows = g_slist_prepend (update_windows, window); - private->update_area = gdk_region_copy (region); - if (!private->update_freeze_count && !update_idle) - update_idle = g_idle_add_full (GDK_PRIORITY_REDRAW, - gdk_window_update_idle, NULL, NULL); - } + visible_region = gdk_drawable_get_visible_region (window); + gdk_region_intersect (visible_region, region); - if (invalidate_children) + if (!gdk_region_empty (region)) { - GList *tmp_list; - GdkRectangle child_rect; - GdkRegion *child_region; - - tmp_list = private->children; - while (tmp_list) + if (private->update_area) { - GdkWindowObject *child = tmp_list->data; - tmp_list = tmp_list->next; - - if (!child->input_only) + gdk_region_union (private->update_area, region); + } + else + { + update_windows = g_slist_prepend (update_windows, window); + private->update_area = gdk_region_copy (region); + + if (!private->update_freeze_count && !update_idle) + update_idle = g_idle_add_full (GDK_PRIORITY_REDRAW, + gdk_window_update_idle, NULL, NULL); + } + + if (invalidate_children) + { + GList *tmp_list; + + tmp_list = private->children; + while (tmp_list) { - gint width, height; - - gdk_drawable_get_size (GDK_DRAWABLE (child), - &width, &height); - - child_rect.x = child->x; - child_rect.y = child->y; - child_rect.width = width; - child_rect.height = height; - - child_region = gdk_region_rectangle (&child_rect); - gdk_region_intersect (child_region, region); + GdkWindowObject *child = tmp_list->data; + tmp_list = tmp_list->next; - if (!gdk_region_empty (child_region)) + if (!child->input_only) { - gdk_region_offset (child_region, - child_rect.x, - child_rect.y); + GdkRegion *child_region; + gint x, y; + + gdk_window_get_position ((GdkWindow *)child, &x, &y); + + /* This copy could be saved with a little more complexity */ + child_region = gdk_region_copy (region); + gdk_region_offset (child_region, -x, -y); + gdk_window_invalidate_region ((GdkWindow *)child, child_region, TRUE); + + gdk_region_destroy (child_region); } - - gdk_region_destroy (child_region); } } } diff --git a/gdk/x11/gdkcolor-x11.c b/gdk/x11/gdkcolor-x11.c index 9dff2d55f..a20a302d7 100644 --- a/gdk/x11/gdkcolor-x11.c +++ b/gdk/x11/gdkcolor-x11.c @@ -963,6 +963,47 @@ gdk_colormap_alloc_colors (GdkColormap *colormap, return nremaining; } +void +gdk_colormap_query_color (GdkColormap *colormap, + gulong pixel, + GdkColor *result) +{ + XColor xcolor; + GdkVisual *visual; + + g_return_if_fail (GDK_IS_COLORMAP (colormap)); + + visual = gdk_colormap_get_visual (colormap); + + switch (visual->type) { + case GDK_VISUAL_DIRECT_COLOR: + case GDK_VISUAL_TRUE_COLOR: + result->red = 65535. * (double)((pixel & visual->red_mask) >> visual->red_shift) / ((1 << visual->red_prec) - 1); + result->green = 65535. * (double)((pixel & visual->green_mask) >> visual->green_shift) / ((1 << visual->green_prec) - 1); + result->blue = 65535. * (double)((pixel & visual->blue_mask) >> visual->blue_shift) / ((1 << visual->blue_prec) - 1); + break; + case GDK_VISUAL_STATIC_GRAY: + case GDK_VISUAL_GRAYSCALE: + result->red = result->green = result->blue = 65535. * (double)pixel/((1<<visual->depth) - 1); + break; + case GDK_VISUAL_STATIC_COLOR: + xcolor.pixel = pixel; + XQueryColor (GDK_DISPLAY (), GDK_COLORMAP_XCOLORMAP (colormap), &xcolor); + result->red = xcolor.red; + result->green = xcolor.green; + result->blue = xcolor.blue; + break; + case GDK_VISUAL_PSEUDO_COLOR: + result->red = colormap->colors[pixel].red; + result->green = colormap->colors[pixel].green; + result->blue = colormap->colors[pixel].blue; + break; + default: + g_assert_not_reached (); + break; + } +} + gboolean gdk_color_change (GdkColormap *colormap, GdkColor *color) diff --git a/gdk/x11/gdkdrawable-x11.c b/gdk/x11/gdkdrawable-x11.c index 9eaf0ad96..ed3f2003e 100644 --- a/gdk/x11/gdkdrawable-x11.c +++ b/gdk/x11/gdkdrawable-x11.c @@ -25,9 +25,15 @@ */ #include "gdkprivate-x11.h" +#include "gdkregion-generic.h" + #include <pango/pangox.h> #include <config.h> +#if HAVE_XFT +#include <pango/pangoxft.h> +#endif + #include <stdlib.h> #if defined (HAVE_IPC_H) && defined (HAVE_SHM_H) && defined (HAVE_XSHM_H) @@ -564,6 +570,40 @@ gdk_x11_draw_lines (GdkDrawable *drawable, g_free (tmp_points); } +#if HAVE_XFT +static void +update_xft_draw_clip (GdkGC *gc) +{ + GdkGCX11 *private = GDK_GC_X11 (gc); + int i; + + if (private->xft_draw) + { + if (private->clip_region) + { + GdkRegionBox *boxes = private->clip_region->rects; + Region region = XCreateRegion (); + + for (i=0; i<private->clip_region->numRects; i++) + { + XRectangle rect; + + rect.x = CLAMP (boxes[i].x1 + gc->clip_x_origin, G_MINSHORT, G_MAXSHORT); + rect.y = CLAMP (boxes[i].y1 + gc->clip_y_origin, G_MINSHORT, G_MAXSHORT); + rect.width = CLAMP (boxes[i].x2 + gc->clip_x_origin, G_MINSHORT, G_MAXSHORT) - rect.x; + rect.height = CLAMP (boxes[i].y2 + gc->clip_y_origin, G_MINSHORT, G_MAXSHORT) - rect.y; + XUnionRectWithRegion (&rect, region, region); + } + + XftDrawSetClip (private->xft_draw, region); + XDestroyRegion (region); + } + else + XftDrawSetClip (private->xft_draw, NULL); + } +} +#endif + static void gdk_x11_draw_glyphs (GdkDrawable *drawable, GdkGC *gc, @@ -576,10 +616,49 @@ gdk_x11_draw_glyphs (GdkDrawable *drawable, impl = GDK_DRAWABLE_IMPL_X11 (drawable); - pango_x_render (impl->xdisplay, - impl->xid, - GDK_GC_GET_XGC (gc), - font, glyphs, x, y); +#if HAVE_XFT + if (PANGO_XFT_IS_FONT (font)) + { + GdkGCX11 *gc_x11 = GDK_GC_X11 (gc); + XftColor xft_color; + GdkColormap *cmap; + GdkColor color; + + cmap = gdk_gc_get_colormap (gc); + + _gdk_x11_gc_flush (gc); + + if (!gc_x11->xft_draw) + { + gc_x11->xft_draw = XftDrawCreate (impl->xdisplay, + impl->xid, + GDK_VISUAL_XVISUAL (gdk_colormap_get_visual (cmap)), + GDK_COLORMAP_XCOLORMAP (cmap)); + update_xft_draw_clip (gc); + } + + else + { + XftDrawChange (gc_x11->xft_draw, impl->xid); + update_xft_draw_clip (gc); + } + + gdk_colormap_query_color (cmap, gc_x11->fg_pixel, &color); + + xft_color.color.red = color.red; + xft_color.color.green = color.green; + xft_color.color.blue = color.blue; + xft_color.color.alpha = 0xffff; + + pango_xft_render (gc_x11->xft_draw, &xft_color, + font, glyphs, x, y); + } + else +#endif /* !HAVE_XFT */ + pango_x_render (impl->xdisplay, + impl->xid, + GDK_GC_GET_XGC (gc), + font, glyphs, x, y); } static void diff --git a/gdk/x11/gdkgc-x11.c b/gdk/x11/gdkgc-x11.c index ad3dc65ca..8d3dcdae4 100644 --- a/gdk/x11/gdkgc-x11.c +++ b/gdk/x11/gdkgc-x11.c @@ -24,8 +24,14 @@ * GTK+ at ftp://ftp.gtk.org/pub/gtk/. */ +#include <config.h> + +#if HAVE_XFT +#include <pango/pangoxft.h> +#endif + #include "gdkgc.h" -#include "gdkx.h" +#include "gdkprivate-x11.h" #include "gdkregion-generic.h" #include <string.h> @@ -107,6 +113,11 @@ gdk_gc_x11_finalize (GObject *object) gdk_region_destroy (x11_gc->clip_region); XFreeGC (GDK_GC_XDISPLAY (x11_gc), GDK_GC_XGC (x11_gc)); + +#if HAVE_XFT + if (x11_gc->xft_draw) + XftDrawDestroy (x11_gc->xft_draw); +#endif G_OBJECT_CLASS (parent_class)->finalize (object); } @@ -148,6 +159,9 @@ _gdk_x11_gc_new (GdkDrawable *drawable, private->dirty_mask |= GDK_GC_DIRTY_TS; } + if (values_mask & GDK_GC_FOREGROUND) + private->fg_pixel = values->foreground.pixel; + xvalues.function = GXcopy; xvalues.fill_style = FillSolid; xvalues.arc_mode = ArcPieSlice; @@ -386,6 +400,9 @@ gdk_x11_gc_set_values (GdkGC *gc, } } + if (values_mask & GDK_GC_FOREGROUND) + x11_gc->fg_pixel = values->foreground.pixel; + gdk_x11_gc_values_to_xvalues (values, values_mask, &xvalues, &xvalues_mask); XChangeGC (GDK_GC_XDISPLAY (gc), @@ -717,4 +734,5 @@ gdk_gc_copy (GdkGC *dst_gc, GdkGC *src_gc) x11_dst_gc->clip_region = NULL; x11_dst_gc->dirty_mask = x11_src_gc->dirty_mask; + x11_dst_gc->fg_pixel = x11_src_gc->fg_pixel; } diff --git a/gdk/x11/gdkgeometry-x11.c b/gdk/x11/gdkgeometry-x11.c index 5fc19a2d0..e65717084 100644 --- a/gdk/x11/gdkgeometry-x11.c +++ b/gdk/x11/gdkgeometry-x11.c @@ -382,7 +382,7 @@ _gdk_window_move_resize_child (GdkWindow *window, } static void -gdk_window_compute_position (GdkWindowImplX11 *window, +gdk_window_compute_position (GdkWindowImplX11 *window, GdkWindowParentPos *parent_pos, GdkXPositionInfo *info) { diff --git a/gdk/x11/gdkmain-x11.c b/gdk/x11/gdkmain-x11.c index 3c3479053..b189cd6a5 100644 --- a/gdk/x11/gdkmain-x11.c +++ b/gdk/x11/gdkmain-x11.c @@ -257,6 +257,8 @@ gdk_x11_convert_grab_status (gint status) } g_assert_not_reached(); + + return 0; } /* diff --git a/gdk/x11/gdkpango-x11.c b/gdk/x11/gdkpango-x11.c index a432921e0..09e44f445 100644 --- a/gdk/x11/gdkpango-x11.c +++ b/gdk/x11/gdkpango-x11.c @@ -17,12 +17,31 @@ * Boston, MA 02111-1307, USA. */ +#include <config.h> +#include <stdlib.h> + #include "gdkprivate-x11.h" #include "gdkpango.h" #include <pango/pangox.h> +#ifdef HAVE_XFT +#include <pango/pangoxft.h> +#endif PangoContext * gdk_pango_context_get (void) { - return pango_x_get_context (GDK_DISPLAY ()); +#ifdef HAVE_XFT + static gint use_xft = -1; + if (use_xft == -1) + { + char *val = g_getenv ("GDK_USE_XFT"); + + use_xft = val && (atoi (val) != 0); + } + + if (use_xft) + return pango_xft_get_context (GDK_DISPLAY (), DefaultScreen (GDK_DISPLAY ())); + else +#endif /* HAVE_XFT */ + return pango_x_get_context (GDK_DISPLAY ()); } diff --git a/gdk/x11/gdkprivate-x11.h b/gdk/x11/gdkprivate-x11.h index 2a53104be..70aa809b6 100644 --- a/gdk/x11/gdkprivate-x11.h +++ b/gdk/x11/gdkprivate-x11.h @@ -43,9 +43,11 @@ gint gdk_send_xevent (Window window, gboolean propagate, glong event_mask, XEvent *event_send); -GdkGC * _gdk_x11_gc_new (GdkDrawable *drawable, - GdkGCValues *values, - GdkGCValuesMask values_mask); + +GdkGC *_gdk_x11_gc_new (GdkDrawable *drawable, + GdkGCValues *values, + GdkGCValuesMask values_mask); + GdkColormap * gdk_colormap_lookup (Colormap xcolormap); GdkVisual * gdk_visual_lookup (Visual *xvisual); diff --git a/gdk/x11/gdkwindow-x11.c b/gdk/x11/gdkwindow-x11.c index 3aee23b03..f5e511bce 100644 --- a/gdk/x11/gdkwindow-x11.c +++ b/gdk/x11/gdkwindow-x11.c @@ -83,10 +83,11 @@ static gboolean gdk_window_icon_name_set (GdkWindow *window); static GdkColormap* gdk_window_impl_x11_get_colormap (GdkDrawable *drawable); static void gdk_window_impl_x11_set_colormap (GdkDrawable *drawable, - GdkColormap *cmap); -static void gdk_window_impl_x11_get_size (GdkDrawable *drawable, - gint *width, - gint *height); + GdkColormap *cmap); +static void gdk_window_impl_x11_get_size (GdkDrawable *drawable, + gint *width, + gint *height); +static GdkRegion* gdk_window_impl_x11_get_visible_region (GdkDrawable *drawable); static void gdk_window_impl_x11_init (GdkWindowImplX11 *window); static void gdk_window_impl_x11_class_init (GdkWindowImplX11Class *klass); static void gdk_window_impl_x11_finalize (GObject *object); @@ -147,6 +148,10 @@ gdk_window_impl_x11_class_init (GdkWindowImplX11Class *klass) drawable_class->set_colormap = gdk_window_impl_x11_set_colormap; drawable_class->get_colormap = gdk_window_impl_x11_get_colormap; drawable_class->get_size = gdk_window_impl_x11_get_size; + + /* Visible and clip regions are the same */ + drawable_class->get_clip_region = gdk_window_impl_x11_get_visible_region; + drawable_class->get_visible_region = gdk_window_impl_x11_get_visible_region; } static void @@ -235,6 +240,22 @@ gdk_window_impl_x11_get_size (GdkDrawable *drawable, *height = GDK_WINDOW_IMPL_X11 (drawable)->height; } +static GdkRegion* +gdk_window_impl_x11_get_visible_region (GdkDrawable *drawable) +{ + GdkWindowImplX11 *impl = GDK_WINDOW_IMPL_X11 (drawable); + GdkRectangle result_rect; + + result_rect.x = 0; + result_rect.y = 0; + result_rect.width = impl->width; + result_rect.height = impl->height; + + gdk_rectangle_intersect (&result_rect, &impl->position_info.clip_rect, &result_rect); + + return gdk_region_rectangle (&result_rect); +} + void _gdk_windowing_window_init (void) { diff --git a/gdk/x11/gdkx.h b/gdk/x11/gdkx.h index 697afea9a..336bd35f3 100644 --- a/gdk/x11/gdkx.h +++ b/gdk/x11/gdkx.h @@ -36,7 +36,6 @@ #include <gdk/x11/gdkwindow-x11.h> #include <gdk/x11/gdkpixmap-x11.h> -typedef struct _GdkGCXData GdkGCXData; typedef struct _GdkColormapPrivateX11 GdkColormapPrivateX11; typedef struct _GdkCursorPrivate GdkCursorPrivate; typedef struct _GdkFontPrivateX GdkFontPrivateX; @@ -120,6 +119,12 @@ struct _GdkGCX11 Display *xdisplay; GdkRegion *clip_region; guint dirty_mask; + + /* We can't conditionalize on HAVE_XFT here, so we simply always + * have this here as a gpointer. + */ + gpointer xft_draw; + gulong fg_pixel; }; struct _GdkGCX11Class diff --git a/gtk/gtkfontsel.c b/gtk/gtkfontsel.c index fa50c68a6..06f8367b9 100644 --- a/gtk/gtkfontsel.c +++ b/gtk/gtkfontsel.c @@ -559,7 +559,7 @@ gtk_font_selection_show_available_styles (GtkFontSelection *fontsel) { PangoFontDescription **descs; int n_descs, i; - gint match_row = 0; + gint match_row = -1; gchar *str; pango_context_list_fonts (gtk_widget_get_pango_context (GTK_WIDGET (fontsel)), @@ -590,8 +590,11 @@ gtk_font_selection_show_available_styles (GtkFontSelection *fontsel) } gtk_clist_select_row (GTK_CLIST (fontsel->font_style_clist), match_row, 0); - gtk_clist_get_text (GTK_CLIST (fontsel->font_style_clist), match_row, 0, &str); - gtk_entry_set_text (GTK_ENTRY (fontsel->font_style_entry), str); + if (match_row >= 0) + { + gtk_clist_get_text (GTK_CLIST (fontsel->font_style_clist), match_row, 0, &str); + gtk_entry_set_text (GTK_ENTRY (fontsel->font_style_entry), str); + } gtk_clist_thaw (GTK_CLIST(fontsel->font_style_clist)); diff --git a/gtk/testgtk.c b/gtk/testgtk.c index 636e98c5d..5a12f67e1 100644 --- a/gtk/testgtk.c +++ b/gtk/testgtk.c @@ -2057,8 +2057,8 @@ void create_labels (void) gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); frame = gtk_frame_new ("Bidirection Label"); - label = gtk_label_new ("Arabic السلام عليكم\n" - "Hebrew שלום"); + label = gtk_label_new ("Arabic السلام عليكم\n" + "Hebrew שלום"); gtk_widget_set_direction (label, GTK_TEXT_DIR_RTL); gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_RIGHT); gtk_container_add (GTK_CONTAINER (frame), label); diff --git a/tests/testgtk.c b/tests/testgtk.c index 636e98c5d..5a12f67e1 100644 --- a/tests/testgtk.c +++ b/tests/testgtk.c @@ -2057,8 +2057,8 @@ void create_labels (void) gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); frame = gtk_frame_new ("Bidirection Label"); - label = gtk_label_new ("Arabic السلام عليكم\n" - "Hebrew שלום"); + label = gtk_label_new ("Arabic السلام عليكم\n" + "Hebrew שלום"); gtk_widget_set_direction (label, GTK_TEXT_DIR_RTL); gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_RIGHT); gtk_container_add (GTK_CONTAINER (frame), label); |