mutter/src/wm-tester/test-size-hints.c
Elijah Newren 32d4bd6b63 Patch from Kjartan Maraas to fix a lot of tiny issues (unused variable
2006-01-20  Elijah Newren  <newren gmail com>

	* src/async-getprop.c:
	* src/common.h:
	* src/display.c:
	* src/eggaccelerators.c:
	* src/frames.c:
	* src/gradient.c:
	* src/iconcache.c:
	* src/keybindings.c:
	* src/metaaccellabel.c:
	* src/place.c:
	* src/prefs.c:
	* src/preview-widget.c:
	* src/screen.c:
	* src/session.c:
	* src/stack.c:
	* src/tabpopup.c:
	* src/theme-viewer.c:
	* src/theme.c:
	* src/window-props.c:
	* src/window.c:
	* src/workspace.c:
	* src/tools/metacity-window-demo.c:
	* src/wm-tester/test-gravity.c:
	* src/wm-tester/test-resizing.c:
	* src/wm-tester/test-size-hints.c:
	Patch from Kjartan Maraas to fix a lot of tiny issues (unused
	variable removal, making unused variables used again, correction
	of types passed/declared for printf arguments, removal of unneeded
	breaks and returns, dead code removal, dead code revival, renaming
	to prevent shadowed variables, declaring unexported functions as
	static) spotted by the intel compiler.  #321439
2006-01-20 22:03:56 +00:00

137 lines
2.9 KiB
C

#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;
}
}
/* This program has an infinite loop above so a return statement would
* just cause compiler warnings.
*/
}