Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <X11/Xlib.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- int main(void) {
- Display *d;
- Window w, ww;
- XEvent e;
- int s;
- int width = 100, height = 100;
- d = XOpenDisplay(NULL);
- if (d == NULL) {
- fprintf(stderr, "Cannot open display\n");
- exit(1);
- }
- s = DefaultScreen(d);
- w = XCreateSimpleWindow(d, RootWindow(d, s), 10, 10, 120, 120, 1,
- WhitePixel(d, s), BlackPixel(d, s));
- ww = XCreateSimpleWindow(d, w, 10, 10, width, height, 1, BlackPixel(d, s), WhitePixel(d, s));
- XSelectInput(d, w, ExposureMask | KeyPressMask | StructureNotifyMask );
- XSelectInput(d, ww, ExposureMask | KeyPressMask);
- XMapWindow(d, w);
- XMapWindow(d, ww);
- while (1) {
- XNextEvent(d, &e);
- if (e.type == Expose) {
- XFillRectangle(d, ww, DefaultGC(d, s), 20, 20, 10, 10);
- XFillRectangle(d, ww, DefaultGC(d, s), width-30, height-30, 10, 10);
- XFillRectangle(d, ww, DefaultGC(d, s), 20, height-30, 10, 10);
- XFillRectangle(d, ww, DefaultGC(d, s), width-30, 20, 10, 10);
- }
- if (e.type == KeyPress)
- break;
- if (e.type == ConfigureNotify) {
- width = e.xconfigure.width - 20;
- if (width < 100) width = 100;
- height = e.xconfigure.height - 20;
- if (height < 100) height = 100;
- XMoveResizeWindow (d, ww, 10, 10, width, height);
- }
- }
- XCloseDisplay(d);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement