#include #include #include #include #include #include int main (void) { Display * display; int screen, count; Window root, window; Atom atoms [3]; XSizeHints hints; XEvent event; /* Open the display and create a window */ display = XOpenDisplay (0); if (! display) { printf ("XOpenDisplay error.\n"); return 1; } screen = DefaultScreen (display); root = RootWindow (display, screen); window = XCreateSimpleWindow (display, root, 0, 0, 400, 300, 0, 0, 0); /* Tell it to maximize */ atoms [0] = XInternAtom (display, "_NET_WM_STATE", 0); atoms [1] = XInternAtom (display, "_NET_WM_STATE_MAXIMIZED_HORZ", 0); atoms [2] = XInternAtom (display, "_NET_WM_STATE_MAXIMIZED_VERT", 0); XChangeProperty (display, window, atoms [0], XA_ATOM, 32, PropModeReplace, (unsigned char *) (atoms + 1), 2); /* Map it */ XMapWindow (display, window); /* Wait 5 seconds */ for (count = 0; count < 5; count ++) { while (XPending (display)) XNextEvent (display, & event); sleep (1); } /* Force it to 400x300 */ hints.flags = PMinSize | PMaxSize; hints.min_width = 400; hints.min_height = 300; hints.max_width = 400; hints.max_height = 300; XSetWMNormalHints (display, window, & hints); /* Wait another 15 seconds */ for (count = 0; count < 15; count ++) { while (XPending (display)) XNextEvent (display, & event); sleep (1); } /* Shut everything down */ XDestroyWindow (display, window); XCloseDisplay (display); return 0; }