| @@ -27,6 +27,9 @@ |
| 27 | 27 | | Display *dpy; |
| 28 | 28 | | int scr; |
| 29 | 29 | | int scrw, scrh; |
| 30 | + | Visual *vis; |
| 31 | + | Colormap cmap; |
| 32 | + | int depth; |
| 30 | 33 | | GC gc; |
| 31 | 34 | | XColor bgcol; |
| 32 | 35 | | |
| @@ -35,7 +38,7 @@ void win_open(win_t *win) { |
| 35 | 38 | | XSetWindowAttributes attr; |
| 36 | 39 | | unsigned long mask; |
| 37 | 40 | | |
| 38 | | − | if (win == NULL) |
| 41 | + | if (!win) |
| 39 | 42 | | return; |
| 40 | 43 | | |
| 41 | 44 | | if (!(dpy = XOpenDisplay(NULL))) |
| @@ -45,6 +48,10 @@ void win_open(win_t *win) { |
| 45 | 48 | | scrw = DisplayWidth(dpy, scr); |
| 46 | 49 | | scrh = DisplayHeight(dpy, scr); |
| 47 | 50 | | |
| 51 | + | vis = DefaultVisual(dpy, scr); |
| 52 | + | cmap = DefaultColormap(dpy, scr); |
| 53 | + | depth = DefaultDepth(dpy, scr); |
| 54 | + | |
| 48 | 55 | | if (!XAllocNamedColor(dpy, DefaultColormap(dpy, scr), BG_COLOR, |
| 49 | 56 | | &bgcol, &bgcol)) |
| 50 | 57 | | FATAL("could not allocate color: %s", BG_COLOR); |
| @@ -61,9 +68,8 @@ void win_open(win_t *win) { |
| 61 | 68 | | attr.save_under = False; |
| 62 | 69 | | mask = CWBackingStore | CWBackPixel | CWSaveUnder; |
| 63 | 70 | | |
| 64 | | − | win->xwin = XCreateWindow(dpy, RootWindow(dpy, scr), |
| 65 | | − | win->x, win->y, win->w, win->h, 0, DefaultDepth(dpy, scr), InputOutput, |
| 66 | | − | DefaultVisual(dpy, scr), mask, &attr); |
| 71 | + | win->xwin = XCreateWindow(dpy, RootWindow(dpy, scr), win->x, win->y, |
| 72 | + | win->w, win->h, 0, depth, InputOutput, vis, mask, &attr); |
| 67 | 73 | | if (win->xwin == None) |
| 68 | 74 | | FATAL("could not create window"); |
| 69 | 75 | | |
| @@ -84,7 +90,7 @@ void win_open(win_t *win) { |
| 84 | 90 | | } |
| 85 | 91 | | |
| 86 | 92 | | void win_close(win_t *win) { |
| 87 | | − | if (win == NULL) |
| 93 | + | if (!win) |
| 88 | 94 | | return; |
| 89 | 95 | | |
| 90 | 96 | | XDestroyWindow(dpy, win->xwin); |
| @@ -95,7 +101,7 @@ void win_close(win_t *win) { |
| 95 | 101 | | int win_configure(win_t *win, XConfigureEvent *cev) { |
| 96 | 102 | | int changed; |
| 97 | 103 | | |
| 98 | | − | if (win == NULL) |
| 104 | + | if (!win) |
| 99 | 105 | | return 0; |
| 100 | 106 | | |
| 101 | 107 | | changed = win->x != cev->x || win->y != cev->y || |