All pastes #213738 Raw Edit

Anonymous

public c v1 · immutable
#213738 ·published 2006-10-21 16:18 UTC
rendered paste body
#include <stdio.h>  //fprintf ()#include <stdlib.h> //EXIT_{SUCCESS,FAILURE}#include <X11/Xlib.h>#include "util.h"int main (int argc, char * argv[]){	Display * display;	Window mainWindow, rootWindow;	Screen * screen;	GC gc;	LayoutInfo li;	ContentsInfo ci;	int width, height;	XEvent event;	int eventLoopEnd;	/**	 * Connection to X server.	 */		display = XOpenDisplay (NULL);	if (display == NULL) {		fprintf (stderr,				"Could not connect to display %s.",				getenv ("DISPLAY")				);		return EXIT_FAILURE;	}#ifdef DEBUG	XSynchronize (display, True);#endif	/**	 * Getting dimensions of screen	 */	screen = DefaultScreenOfDisplay (display);	rootWindow = RootWindowOfScreen (screen);	ci.width    =  WidthOfScreen (screen);	ci.height   = HeightOfScreen (screen);	ci.widthMM  = WidthMMOfScreen (screen);	ci.heightMM = HeightMMOfScreen (screen);	mainWindow = XCreateSimpleWindow (display,			rootWindow,			ci.width/3,			ci.height/3,			ci.width/3,			ci.height/3,			0,			BlackPixelOfScreen (screen),			WhitePixelOfScreen (screen)			);	XMapWindow (display, mainWindow);	XSelectInput (display, mainWindow,			ExposureMask |			StructureNotifyMask |			ButtonPressMask |			KeyPressMask			);	eventLoopEnd = 0;	gc = CreateGC (display, mainWindow);	width = height = 15;	while (!eventLoopEnd) {		XNextEvent (display, &event);		switch (event.type) {			case CreateNotify:				break;			case KeyPress:			case ButtonPress:				XDestroyWindow (display, mainWindow);				break;			case DestroyNotify:				eventLoopEnd = 1;				break;			case ConfigureNotify:				(void) ComputeLayout (							event.xconfigure.width,							event.xconfigure.height,							width,							height,							&li);				break;			case Expose:				Redraw (display, mainWindow, gc,							&li, &ci);				break;			default:				fprintf (stdout, "Unprocessed event of type %d.\n",						event.type);				break;		}	}	return EXIT_SUCCESS;}