summaryrefslogtreecommitdiff
path: root/gdk/x11
diff options
context:
space:
mode:
authorHavoc Pennington <hp@redhat.com>2001-03-02 20:02:17 +0000
committerHavoc Pennington <hp@src.gnome.org>2001-03-02 20:02:17 +0000
commit8860615d9a41a550ad830c78a6d2dd63340e0f1d (patch)
treea37fa2b7bbf51a08d8744d0540e5f3f5be0ee86b /gdk/x11
parentb0052ec843ab9acc77408d256a5a43d4332f0a70 (diff)
downloadgtk+-8860615d9a41a550ad830c78a6d2dd63340e0f1d.tar.gz
use _gdk_region_get_xrectangles()
2001-03-02 Havoc Pennington <hp@redhat.com> * gdk/x11/gdkgc-x11.c (_gdk_x11_gc_flush): use _gdk_region_get_xrectangles() * gdk/x11/gdkmain-x11.c (_gdk_region_get_xrectangles): new function * gtk/testgtk.c (create_shapes): add test for shape_combine_region * gdk/x11/gdkwindow-x11.c (gdk_window_shape_combine_region): new function, contributed by Ron Steinke * gdk/x11/gdkevents-x11.c (gdk_wmspec_supported): rename gdk_net_wm_supports * gdk/gdkregion-generic.c (gdk_region_get_rectangles): New function, contributed by Ron Steinke * gtk/gtkentry.c (gtk_entry_get_layout_offsets): New function, used to line up the text in the entry when using the entry for editable sheet cell hacks * gtk/testgtk.c (create_entry): test the activate_default setting on GtkEntry * gtk/gtkentry.c (gtk_entry_set_activates_default): New function to cause the entry to activate the default button for a dialog when activated (gtk_entry_get_activates_default): new function
Diffstat (limited to 'gdk/x11')
-rw-r--r--gdk/x11/gdkevents-x11.c4
-rw-r--r--gdk/x11/gdkgc-x11.c26
-rw-r--r--gdk/x11/gdkmain-x11.c24
-rw-r--r--gdk/x11/gdkprivate-x11.h6
-rw-r--r--gdk/x11/gdkwindow-x11.c65
-rw-r--r--gdk/x11/gdkx.h2
6 files changed, 109 insertions, 18 deletions
diff --git a/gdk/x11/gdkevents-x11.c b/gdk/x11/gdkevents-x11.c
index 7056d9bc75..94153d7f64 100644
--- a/gdk/x11/gdkevents-x11.c
+++ b/gdk/x11/gdkevents-x11.c
@@ -1756,7 +1756,7 @@ gdk_x11_get_server_time (GdkWindow *window)
gboolean
-gdk_wmspec_supported (GdkAtom property)
+gdk_net_wm_supports (GdkAtom property)
{
static GdkAtom wmspec_check_atom = 0;
static GdkAtom wmspec_supported_atom = 0;
@@ -1840,7 +1840,7 @@ gdk_wmspec_supported (GdkAtom property)
XFree (xwindow);
/* since wmspec_check_window != None this isn't infinite. ;-) */
- return gdk_wmspec_supported (property);
+ return gdk_net_wm_supports (property);
}
diff --git a/gdk/x11/gdkgc-x11.c b/gdk/x11/gdkgc-x11.c
index 8d3dcdae49..34f90a0d28 100644
--- a/gdk/x11/gdkgc-x11.c
+++ b/gdk/x11/gdkgc-x11.c
@@ -190,21 +190,19 @@ _gdk_x11_gc_flush (GdkGC *gc)
gc->clip_x_origin, gc->clip_y_origin);
else
{
- XRectangle *rectangles = g_new (XRectangle, private->clip_region->numRects);
- GdkRegionBox *boxes = private->clip_region->rects;
- int i;
-
- for (i=0; i<private->clip_region->numRects; i++)
- {
- rectangles[i].x = CLAMP (boxes[i].x1 + gc->clip_x_origin, G_MINSHORT, G_MAXSHORT);
- rectangles[i].y = CLAMP (boxes[i].y1 + gc->clip_y_origin, G_MINSHORT, G_MAXSHORT);
- rectangles[i].width = CLAMP (boxes[i].x2 + gc->clip_x_origin, G_MINSHORT, G_MAXSHORT) - rectangles[i].x;
- rectangles[i].height = CLAMP (boxes[i].y2 + gc->clip_y_origin, G_MINSHORT, G_MAXSHORT) - rectangles[i].y;
- }
+ XRectangle *rectangles;
+ gint n_rects;
+
+ _gdk_region_get_xrectangles (private->clip_region,
+ gc->clip_x_origin,
+ gc->clip_y_origin,
+ &rectangles,
+ &n_rects);
- XSetClipRectangles(GDK_GC_XDISPLAY (gc), GDK_GC_XGC (gc), 0, 0, rectangles,
- private->clip_region->numRects, YXBanded);
-
+ XSetClipRectangles (GDK_GC_XDISPLAY (gc), GDK_GC_XGC (gc), 0, 0,
+ rectangles,
+ n_rects, YXBanded);
+
g_free (rectangles);
}
}
diff --git a/gdk/x11/gdkmain-x11.c b/gdk/x11/gdkmain-x11.c
index 1f395e390d..ff6fa309cc 100644
--- a/gdk/x11/gdkmain-x11.c
+++ b/gdk/x11/gdkmain-x11.c
@@ -53,6 +53,7 @@
#include "gdkprivate-x11.h"
#include "gdkinternals.h"
+#include "gdkregion-generic.h"
#include "gdkinputprivate.h"
#include <pango/pangox.h>
@@ -737,3 +738,26 @@ gdk_send_xevent (Window window, gboolean propagate, glong event_mask,
return result && !gdk_error_code;
}
+
+void
+_gdk_region_get_xrectangles (GdkRegion *region,
+ gint x_offset,
+ gint y_offset,
+ XRectangle **rects,
+ gint *n_rects)
+{
+ XRectangle *rectangles = g_new (XRectangle, region->numRects);
+ GdkRegionBox *boxes = region->rects;
+ gint i;
+
+ for (i = 0; i < region->numRects; i++)
+ {
+ rectangles[i].x = CLAMP (boxes[i].x1 + x_offset, G_MINSHORT, G_MAXSHORT);
+ rectangles[i].y = CLAMP (boxes[i].y1 + y_offset, G_MINSHORT, G_MAXSHORT);
+ rectangles[i].width = CLAMP (boxes[i].x2 + x_offset, G_MINSHORT, G_MAXSHORT) - rectangles[i].x;
+ rectangles[i].height = CLAMP (boxes[i].y2 + y_offset, G_MINSHORT, G_MAXSHORT) - rectangles[i].y;
+ }
+
+ *rects = rectangles;
+ *n_rects = region->numRects;
+}
diff --git a/gdk/x11/gdkprivate-x11.h b/gdk/x11/gdkprivate-x11.h
index 70aa809b66..0d03177fd3 100644
--- a/gdk/x11/gdkprivate-x11.h
+++ b/gdk/x11/gdkprivate-x11.h
@@ -86,6 +86,12 @@ void _gdk_window_process_expose (GdkWindow *window,
void _gdk_selection_window_destroyed (GdkWindow *window);
gboolean _gdk_selection_filter_clear_event (XSelectionClearEvent *event);
+void _gdk_region_get_xrectangles (GdkRegion *region,
+ gint x_offset,
+ gint y_offset,
+ XRectangle **rects,
+ gint *n_rects);
+
extern GdkDrawableClass _gdk_x11_drawable_class;
extern gboolean gdk_use_xshm;
extern Atom gdk_wm_delete_window;
diff --git a/gdk/x11/gdkwindow-x11.c b/gdk/x11/gdkwindow-x11.c
index 548bb587c4..077880fc17 100644
--- a/gdk/x11/gdkwindow-x11.c
+++ b/gdk/x11/gdkwindow-x11.c
@@ -1066,7 +1066,7 @@ gdk_window_focus (GdkWindow *window,
if (GDK_WINDOW_DESTROYED (window))
return;
- if (gdk_wmspec_supported (gdk_atom_intern ("_NET_ACTIVE_WINDOW", FALSE)))
+ if (gdk_net_wm_supports (gdk_atom_intern ("_NET_ACTIVE_WINDOW", FALSE)))
{
XEvent xev;
@@ -1831,6 +1831,8 @@ gdk_window_have_shape_ext (void)
return (have_shape == YES);
}
+#define WARN_SHAPE_TOO_BIG() g_warning ("GdkWindow is too large to allow the use of shape masks or shape regions.")
+
/*
* This needs the X11 shape extension.
* If not available, shaped windows will look
@@ -1842,6 +1844,7 @@ gdk_window_shape_combine_mask (GdkWindow *window,
gint x, gint y)
{
Pixmap pixmap;
+ gint xoffset, yoffset;
g_return_if_fail (window != NULL);
g_return_if_fail (GDK_IS_WINDOW (window));
@@ -1849,6 +1852,14 @@ gdk_window_shape_combine_mask (GdkWindow *window,
#ifdef HAVE_SHAPE_EXT
if (GDK_WINDOW_DESTROYED (window))
return;
+
+ _gdk_windowing_window_get_offsets (window, &xoffset, &yoffset);
+
+ if (xoffset != 0 || yoffset != 0)
+ {
+ WARN_SHAPE_TOO_BIG ();
+ return;
+ }
if (gdk_window_have_shape_ext ())
{
@@ -1874,6 +1885,58 @@ gdk_window_shape_combine_mask (GdkWindow *window,
}
void
+gdk_window_shape_combine_region (GdkWindow *window,
+ GdkRegion *shape_region,
+ gint offset_x,
+ gint offset_y)
+{
+ gint xoffset, yoffset;
+
+ g_return_if_fail (GDK_IS_WINDOW (window));
+
+#ifdef HAVE_SHAPE_EXT
+ if (GDK_WINDOW_DESTROYED (window))
+ return;
+
+ _gdk_windowing_window_get_offsets (window, &xoffset, &yoffset);
+
+ if (xoffset != 0 || yoffset != 0)
+ {
+ WARN_SHAPE_TOO_BIG ();
+ return;
+ }
+
+ if (shape_region == NULL)
+ {
+ /* Use NULL mask to unset the shape */
+ gdk_window_shape_combine_mask (window, NULL, 0, 0);
+ return;
+ }
+
+ if (gdk_window_have_shape_ext ())
+ {
+ gint n_rects = 0;
+ XRectangle *xrects = NULL;
+
+ _gdk_region_get_xrectangles (shape_region,
+ 0, 0,
+ &xrects, &n_rects);
+
+ XShapeCombineRectangles (GDK_WINDOW_XDISPLAY (window),
+ GDK_WINDOW_XID (window),
+ ShapeBounding,
+ offset_x, offset_y,
+ xrects, n_rects,
+ ShapeSet,
+ YXBanded);
+
+ g_free (xrects);
+ }
+#endif /* HAVE_SHAPE_EXT */
+}
+
+
+void
gdk_window_set_override_redirect (GdkWindow *window,
gboolean override_redirect)
{
diff --git a/gdk/x11/gdkx.h b/gdk/x11/gdkx.h
index 628d32206f..acb6202675 100644
--- a/gdk/x11/gdkx.h
+++ b/gdk/x11/gdkx.h
@@ -186,7 +186,7 @@ gpointer gdk_xid_table_lookup (XID xid);
guint32 gdk_x11_get_server_time (GdkWindow *window);
/* returns TRUE if we support the given WM spec feature */
-gboolean gdk_wmspec_supported (GdkAtom property);
+gboolean gdk_net_wm_supports (GdkAtom property);
#define gdk_window_lookup(xid) ((GdkWindow*) gdk_xid_table_lookup (xid))
#define gdk_pixmap_lookup(xid) ((GdkPixmap*) gdk_xid_table_lookup (xid))