Skip to content

Commit

Permalink
clean up hello world. fuck - Xlib is horrible
Browse files Browse the repository at this point in the history
  • Loading branch information
ry committed Jun 11, 2008
1 parent c25c544 commit d42dd93
Showing 1 changed file with 24 additions and 12 deletions.
36 changes: 24 additions & 12 deletions hello_win.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,35 @@

int main(int argc, char *argv[])
{
Display *dpy;
Window win;
XClassHint class_hint;
if ((dpy = XOpenDisplay(NULL)) == NULL)
{

Display *display = XOpenDisplay(NULL);

if (display == NULL) {
printf("Unable to open display\n");
return 1;
}
win = XCreateSimpleWindow(dpy, DefaultRootWindow(dpy), 0, 0, \
400, 300, BlackPixel(dpy, DefaultScreen(dpy)), 35, \
WhitePixel(dpy, DefaultScreen(dpy)));
XStoreName(dpy, win, WIN_TITLE);

XClassHint class_hint;

int black_color = BlackPixel(display, DefaultScreen(display));
int white_color = WhitePixel(display, DefaultScreen(display));

Window window = XCreateSimpleWindow( display
, DefaultRootWindow(display)
, 0
, 0
, 400
, 300
, black_color
, 35
, white_color
);
XStoreName(display, window, WIN_TITLE);
class_hint.res_name = WIN_NAME;
class_hint.res_class = WIN_CLASS;
XSetClassHint(dpy, win, &class_hint);
XMapWindow(dpy, win);
XFlush(dpy);
XSetClassHint(display, window, &class_hint);
XMapWindow(display, window);
XFlush(display);
sleep(10);
return 0;
}

0 comments on commit d42dd93

Please sign in to comment.