test.c (1683B)
1 #include <stdio.h> 2 #include <stdlib.h> 3 #include <stdint.h> 4 #include <X11/Xlib.h> 5 #include <X11/Xutil.h> 6 #include <X11/Xos.h> 7 #include "text.h" 8 int main(int argc, const char * argv[]) 9 { 10 11 Display *display; 12 int screen; 13 Window window; 14 GC gc; 15 16 unsigned long black, white; 17 Colormap colormap; 18 display = XOpenDisplay((char *)0); 19 screen = DefaultScreen(display); 20 colormap = DefaultColormap(display, screen); 21 black = BlackPixel(display, screen); 22 white = WhitePixel(display, screen); 23 window = XCreateSimpleWindow(display, DefaultRootWindow(display), 0, 0, 1366, 512, 0, black, white); 24 XSetStandardProperties(display, window, "Random Window", NULL, None, NULL, 0, NULL); 25 XSelectInput(display, window, ExposureMask|ButtonPressMask|KeyPressMask); 26 gc = XCreateGC(display, window, 0, 0); 27 XSetBackground(display, gc, black); 28 XSetForeground(display, gc, black); 29 XClearWindow(display, window); 30 XMapRaised(display, window); 31 32 Pixmap pix = 33 34 XCopyArea(display, pix, window, gc, 0, 0, b_w, b_h, 0, 0); 35 36 XEvent event; 37 KeySym key; 38 char text[255]; 39 40 while(1) 41 { 42 XNextEvent(display, &event); 43 if (event.type == KeyPress && XLookupString(&event.xkey, text, 255, &key, 0) == 1) 44 { 45 XCopyArea(display, pix, window, gc, 0, 0, b_w, b_h, 0, 0); 46 if (text[0] == 'q') 47 { 48 XFreeGC(display, gc); 49 XFreeColormap(display, colormap); 50 XDestroyWindow(display, window); 51 XCloseDisplay(display); 52 exit(0); 53 } 54 } 55 } 56 57 free(fontBuffer); 58 free(bitmap); 59 60 return 0; 61 }