#include #include #include #include #include #include #include #include #include "pipe.h" Display* display; Window win; GC gc; static int height = 17; static int width = 1000; static float width_ratio = 1; static int err_code = 1; void die(const char* fmt, ...) { va_list args; va_start(args, fmt); vfprintf(stderr, fmt, args); va_end(args); putc('\n', stderr); exit(err_code); } void draw_bar(void) { } void init(void) { display = XOpenDisplay(NULL); if (display == NULL) { die("could not open X display"); } XSetWindowAttributes win_attr = { .override_redirect = 1, .background_pixel = 0x202020, .event_mask = ExposureMask | PropertyChangeMask, }; Screen* screen = DefaultScreenOfDisplay(display); width = WidthOfScreen(screen); win = XCreateWindow( display, DefaultRootWindow(display), 0, 0, width, height, 0, CopyFromParent, InputOutput, CopyFromParent, CWOverrideRedirect | CWBackPixel | CWEventMask, &win_attr ); XMapRaised(display, win); gc = XCreateGC(display, win, 0, NULL); XSetForeground(display, gc, 0xFFFFFF); XFlush(display); } void deinit(void) { XUnmapWindow(display, win); XDestroyWindow(display, win); } int main(void) { init_pipe(); init(); while (true) { XEvent ev; XNextEvent(display, &ev); XDrawLine(display, win, gc, 0, 0, width, height); XFlush(display); await_change(); } deinit(); return 0; }