pantry/projects/x.org/x11/fixture.c
Max Howell 3a25c4a468 +x.org/x11
Closes #193
2023-03-16 11:16:51 -04:00

27 lines
952 B
C

#include <X11/Xlib.h>
#include <stdio.h>
int main() {
Display* disp = XOpenDisplay(NULL);
if (disp == NULL)
{
fprintf(stderr, "Unable to connect to display\\n");
return 0;
}
int screen_num = DefaultScreen(disp);
unsigned long background = BlackPixel(disp, screen_num);
unsigned long border = WhitePixel(disp, screen_num);
int width = 60, height = 40;
Window win = XCreateSimpleWindow(disp, DefaultRootWindow(disp), 0, 0, width, height, 2, border, background);
XSelectInput(disp, win, ButtonPressMask|StructureNotifyMask);
XMapWindow(disp, win); // display blank window
XGCValues values;
values.foreground = WhitePixel(disp, screen_num);
values.line_width = 1;
values.line_style = LineSolid;
GC pen = XCreateGC(disp, win, GCForeground|GCLineWidth|GCLineStyle, &values);
// draw two diagonal lines
XDrawLine(disp, win, pen, 0, 0, width, height);
XDrawLine(disp, win, pen, width, 0, 0, height);
return 0;
}