summaryrefslogtreecommitdiffstats
path: root/window.c
diff options
context:
space:
mode:
authorBert <ber.t@gmx.com>2011-01-17 20:14:15 +0100
committerBert <ber.t@gmx.com>2011-01-17 20:14:15 +0100
commit45b2b45285db636ece8fbb24890bd53d753e4eeb (patch)
tree465ca681fe85e30be12e11e81d7675707d47ba91 /window.c
parent75b143a5b0ee62db9b746ecc512855ff9d2f09ff (diff)
downloadnsxiv-45b2b45285db636ece8fbb24890bd53d753e4eeb.tar.zst
Small refactorings
Diffstat (limited to 'window.c')
-rw-r--r--window.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/window.c b/window.c
index 20b3ec6..649a60d 100644
--- a/window.c
+++ b/window.c
@@ -27,6 +27,9 @@
Display *dpy;
int scr;
int scrw, scrh;
+Visual *vis;
+Colormap cmap;
+int depth;
GC gc;
XColor bgcol;
@@ -35,7 +38,7 @@ void win_open(win_t *win) {
XSetWindowAttributes attr;
unsigned long mask;
- if (win == NULL)
+ if (!win)
return;
if (!(dpy = XOpenDisplay(NULL)))
@@ -45,6 +48,10 @@ void win_open(win_t *win) {
scrw = DisplayWidth(dpy, scr);
scrh = DisplayHeight(dpy, scr);
+ vis = DefaultVisual(dpy, scr);
+ cmap = DefaultColormap(dpy, scr);
+ depth = DefaultDepth(dpy, scr);
+
if (!XAllocNamedColor(dpy, DefaultColormap(dpy, scr), BG_COLOR,
&bgcol, &bgcol))
FATAL("could not allocate color: %s", BG_COLOR);
@@ -61,9 +68,8 @@ void win_open(win_t *win) {
attr.save_under = False;
mask = CWBackingStore | CWBackPixel | CWSaveUnder;
- win->xwin = XCreateWindow(dpy, RootWindow(dpy, scr),
- win->x, win->y, win->w, win->h, 0, DefaultDepth(dpy, scr), InputOutput,
- DefaultVisual(dpy, scr), mask, &attr);
+ win->xwin = XCreateWindow(dpy, RootWindow(dpy, scr), win->x, win->y,
+ win->w, win->h, 0, depth, InputOutput, vis, mask, &attr);
if (win->xwin == None)
FATAL("could not create window");
@@ -84,7 +90,7 @@ void win_open(win_t *win) {
}
void win_close(win_t *win) {
- if (win == NULL)
+ if (!win)
return;
XDestroyWindow(dpy, win->xwin);
@@ -95,7 +101,7 @@ void win_close(win_t *win) {
int win_configure(win_t *win, XConfigureEvent *cev) {
int changed;
- if (win == NULL)
+ if (!win)
return 0;
changed = win->x != cev->x || win->y != cev->y ||