Krolyxon
Commit 45b2b45

Branches

Refs →

nsxiv45b2b45

Small refactorings

Author
Bert
Date
2011-01-17 20:14 +0100
Parent
75b143a
Commit
45b2b45285db636ece8fbb24890bd53d753e4eeb

+15 −9

3 files changed

  1. M app.c +1 −1
  2. M events.c +2 −2
  3. M window.c +12 −6
M app.c View
@@ -22,7 +22,7 @@
2222 #include "app.h"
2323
2424 void app_init(app_t *app) {
25− if (app == NULL)
25+ if (!app)
2626 return;
2727
2828 app->fileidx = 0;
M events.c View
@@ -30,7 +30,7 @@ void on_expose(app_t *app, XEvent *ev) {
3030 }
3131
3232 void on_configurenotify(app_t *app, XEvent *ev) {
33− if (app == NULL || ev == NULL)
33+ if (!app || !ev)
3434 return;
3535
3636 win_configure(&app->win, &ev->xconfigure);
@@ -40,7 +40,7 @@ void on_keypress(app_t *app, XEvent *ev) {
4040 KeySym keysym;
4141 XKeyEvent *kev;
4242
43− if (app == NULL || ev == NULL)
43+ if (!app || !ev)
4444 return;
4545
4646 kev = &ev->xkey;
M window.c View
@@ -27,6 +27,9 @@
2727 Display *dpy;
2828 int scr;
2929 int scrw, scrh;
30+Visual *vis;
31+Colormap cmap;
32+int depth;
3033 GC gc;
3134 XColor bgcol;
3235
@@ -35,7 +38,7 @@ void win_open(win_t *win) {
3538 XSetWindowAttributes attr;
3639 unsigned long mask;
3740
38− if (win == NULL)
41+ if (!win)
3942 return;
4043
4144 if (!(dpy = XOpenDisplay(NULL)))
@@ -45,6 +48,10 @@ void win_open(win_t *win) {
4548 scrw = DisplayWidth(dpy, scr);
4649 scrh = DisplayHeight(dpy, scr);
4750
51+ vis = DefaultVisual(dpy, scr);
52+ cmap = DefaultColormap(dpy, scr);
53+ depth = DefaultDepth(dpy, scr);
54+
4855 if (!XAllocNamedColor(dpy, DefaultColormap(dpy, scr), BG_COLOR,
4956 &bgcol, &bgcol))
5057 FATAL("could not allocate color: %s", BG_COLOR);
@@ -61,9 +68,8 @@ void win_open(win_t *win) {
6168 attr.save_under = False;
6269 mask = CWBackingStore | CWBackPixel | CWSaveUnder;
6370
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);
6773 if (win->xwin == None)
6874 FATAL("could not create window");
6975
@@ -84,7 +90,7 @@ void win_open(win_t *win) {
8490 }
8591
8692 void win_close(win_t *win) {
87− if (win == NULL)
93+ if (!win)
8894 return;
8995
9096 XDestroyWindow(dpy, win->xwin);
@@ -95,7 +101,7 @@ void win_close(win_t *win) {
95101 int win_configure(win_t *win, XConfigureEvent *cev) {
96102 int changed;
97103
98− if (win == NULL)
104+ if (!win)
99105 return 0;
100106
101107 changed = win->x != cev->x || win->y != cev->y ||