Created
May 10, 2021 23:24
-
-
Save EmperorPenguin18/88459386479460217bdfd4aab68fdcfc to your computer and use it in GitHub Desktop.
Create an X window
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <X11/Xlib.h> | |
#include <assert.h> | |
#include <unistd.h> | |
#define NIL (0) | |
Display *dpy = XOpenDisplay(NIL); | |
assert(dpy); | |
int blackColor = BlackPixel(dpy, DefaultScreen(dpy)); | |
int whiteColor = WhitePixel(dpy, DefaultScreen(dpy)); | |
Window w = XCreateSimpleWindow(dpy, DefaultRootWindow(dpy), 0, 0, 200, 100, 0, blackColor, blackColor); | |
XSelectInput9dpy, w, StructureNotifyMask); | |
XMapWindow(dpy, w); | |
GC gc = XCreateGC(dpy, w, 0, NIL); | |
XSetForeground(dpy, gc, whiteColor); | |
for (;;) | |
{ | |
XEvent e; | |
XNextEvent(dpy, &e); | |
if (e.type == MapNotify) { break; } | |
} | |
XDrawLine(dpy, w, gc, 10, 60, 180, 20); | |
XFlush(dpy); | |
sleep(10); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment