summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHavoc Pennington <hp@redhat.com>2003-09-29 23:21:41 +0000
committerHavoc Pennington <hp@src.gnome.org>2003-09-29 23:21:41 +0000
commit89ca4aab3d2c80902165974e9f79fd3dd2100dd4 (patch)
treeda902a68a0203cbac99c0efeb9edf63e6d6b78cc
parenta4dc0d581a91303f821653cb038e56a9220cbac8 (diff)
downloadmetacity-89ca4aab3d2c80902165974e9f79fd3dd2100dd4.tar.gz
a little program to test size hints, for now just a 0x0 min size to verify
2003-09-29 Havoc Pennington <hp@redhat.com> * src/wm-tester/test-size-hints.c: a little program to test size hints, for now just a 0x0 min size to verify bug #113320
-rw-r--r--ChangeLog5
-rw-r--r--src/wm-tester/Makefile.am6
-rw-r--r--src/wm-tester/test-size-hints.c134
3 files changed, 144 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 2934106a..7ade54ee 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
2003-09-29 Havoc Pennington <hp@redhat.com>
+ * src/wm-tester/test-size-hints.c: a little program to test size
+ hints, for now just a 0x0 min size to verify bug #113320
+
+2003-09-29 Havoc Pennington <hp@redhat.com>
+
* src/async-getprop.c (async_get_property_handler): attempt to fix
this to return the data as an array of long even on 64-bit as with
XGetWindowProperty() breakage, bug #114035, credit to Gwenole
diff --git a/src/wm-tester/Makefile.am b/src/wm-tester/Makefile.am
index ffecdcc3..e0c3048e 100644
--- a/src/wm-tester/Makefile.am
+++ b/src/wm-tester/Makefile.am
@@ -13,9 +13,13 @@ focus_window_SOURCES= \
test_resizing_SOURCES= \
test-resizing.c
-noinst_PROGRAMS=wm-tester test-gravity test-resizing focus-window
+test_size_hints_SOURCES= \
+ test-size-hints.c
+
+noinst_PROGRAMS=wm-tester test-gravity test-resizing focus-window test-size-hints
wm_tester_LDADD= @METACITY_LIBS@
test_gravity_LDADD= @METACITY_LIBS@
test_resizing_LDADD= @METACITY_LIBS@
+test_size_hints_LDADD= @METACITY_LIBS@
focus_window_LDADD= @METACITY_LIBS@ \ No newline at end of file
diff --git a/src/wm-tester/test-size-hints.c b/src/wm-tester/test-size-hints.c
new file mode 100644
index 00000000..1bf55126
--- /dev/null
+++ b/src/wm-tester/test-size-hints.c
@@ -0,0 +1,134 @@
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+#include <stdlib.h>
+#include <glib.h>
+
+static Bool
+all_events (Display *display,
+ XEvent *event,
+ XPointer arg)
+{
+ return True;
+}
+
+#if 0
+static void
+get_size (Display *d, Drawable draw,
+ int *xp, int *yp, int *widthp, int *heightp)
+{
+ int x, y;
+ unsigned int width, height, border, depth;
+ Window root;
+
+ XGetGeometry (d, draw, &root, &x, &y, &width, &height, &border, &depth);
+
+ if (xp)
+ *xp = x;
+ if (yp)
+ *yp = y;
+ if (widthp)
+ *widthp = width;
+ if (*heightp)
+ *heightp = height;
+}
+#endif
+
+int
+main (int argc, char **argv)
+{
+ Display *d;
+ Window zero_min_size;
+ XSizeHints hints;
+ int screen;
+ XEvent ev;
+ int x, y, width, height;
+ Pixmap pix;
+ GC gc;
+ XGCValues gc_vals;
+ gboolean redraw_pending;
+
+ d = XOpenDisplay (NULL);
+
+ screen = DefaultScreen (d);
+
+ x = 0;
+ y = 0;
+ width = 100;
+ height = 100;
+
+ zero_min_size = XCreateSimpleWindow (d, RootWindow (d, screen),
+ x, y, width, height, 0,
+ WhitePixel (d, screen),
+ WhitePixel (d, screen));
+
+ XSelectInput (d, zero_min_size,
+ ButtonPressMask | ExposureMask | StructureNotifyMask);
+
+ hints.flags = PMinSize;
+
+ hints.min_width = 0;
+ hints.min_height = 0;
+
+ XSetWMNormalHints (d, zero_min_size, &hints);
+ XMapWindow (d, zero_min_size);
+
+ redraw_pending = FALSE;
+ while (1)
+ {
+ XNextEvent (d, &ev);
+
+ switch (ev.xany.type)
+ {
+ case ButtonPress:
+ if (ev.xbutton.button == 1)
+ {
+ g_print ("Exiting on button 1 press\n");
+ exit (0);
+ }
+ break;
+
+ case ConfigureNotify:
+ x = ev.xconfigure.x;
+ y = ev.xconfigure.y;
+ width = ev.xconfigure.width;
+ height = ev.xconfigure.height;
+
+ redraw_pending = TRUE;
+ break;
+
+ case Expose:
+ redraw_pending = TRUE;
+ break;
+
+ default:
+ break;
+ }
+
+ /* Primitive event compression */
+ if (XCheckIfEvent (d, &ev, all_events, NULL))
+ {
+ XPutBackEvent (d, &ev);
+ }
+ else if (redraw_pending)
+ {
+ pix = XCreatePixmap (d, zero_min_size, width, height,
+ DefaultDepth (d, screen));
+
+ gc_vals.foreground = WhitePixel (d, screen);
+
+ gc = XCreateGC (d, pix, GCForeground, &gc_vals);
+
+ XFillRectangle (d, pix, gc, 0, 0, width, height);
+
+ XCopyArea (d, pix, zero_min_size, gc, 0, 0, width, height, 0, 0);
+
+ XFreePixmap (d, pix);
+ XFreeGC (d, gc);
+
+ redraw_pending = FALSE;
+ }
+ }
+
+ return 0;
+}
+