sowm: fixed all compiler warnings.

This commit is contained in:
Dylan Araps
2019-10-15 19:45:24 +03:00
parent c4e64e27b7
commit 5668ad1259
3 changed files with 13 additions and 14 deletions

View File

@@ -1,4 +1,4 @@
CFLAGS+= -std=c99 -Wall -Wno-deprecated-declarations -pedantic CFLAGS+= -std=c99 -Wall -Wextra -pedantic -Wno-deprecated-declarations
LDADD+= -lX11 LDADD+= -lX11
LDFLAGS= LDFLAGS=
PREFIX?= /usr PREFIX?= /usr
@@ -12,7 +12,7 @@ config.h:
cp config.def.h config.h cp config.def.h config.h
sowm: sowm.o sowm: sowm.o
$(CC) $(LDFLAGS) -Os -o $@ $+ $(LDADD) $(CC) $(LDFLAGS) -O3 -o $@ $+ $(LDADD)
install: all install: all
install -Dm 755 sowm $(DESTDIR)$(BINDIR)/sowm install -Dm 755 sowm $(DESTDIR)$(BINDIR)/sowm

View File

@@ -15,7 +15,7 @@ const char* colors[] = {"bud", "/home/goldie/Pictures/Wallpapers", 0};
static struct key keys[] = { static struct key keys[] = {
{MOD, XK_q, win_kill, {0}}, {MOD, XK_q, win_kill, {0}},
{MOD, XK_c, win_center, {.i = 0}}, {MOD, XK_c, win_center, {.w = 0}},
{MOD, XK_f, win_fs, {0}}, {MOD, XK_f, win_fs, {0}},
{Mod1Mask, XK_Tab, win_next, {0}}, {Mod1Mask, XK_Tab, win_next, {0}},

21
sowm.c
View File

@@ -23,6 +23,7 @@
typedef union { typedef union {
const char** com; const char** com;
const int i; const int i;
const Window w;
} Arg; } Arg;
struct key { struct key {
@@ -66,7 +67,7 @@ static void ws_sel(int i);
static client *list = {0}; static client *list = {0};
static desktop ws_list[10]; static desktop ws_list[10];
static int ws = 1, sh, sw, s, j; static int ws = 1, sh, sw, s;
static Display *d; static Display *d;
static Window root, cur; static Window root, cur;
@@ -110,7 +111,7 @@ static void (*events[LASTEvent])(XEvent *e) = {
the same value can be used as a variable directly afterwards. the same value can be used as a variable directly afterwards.
*/ */
Window win_current() { Window win_current() {
XGetInputFocus(d, &cur, &j); XGetInputFocus(d, &cur, (int[]){1});
return cur; return cur;
} }
@@ -193,7 +194,7 @@ void notify_motion(XEvent *e) {
void key_grab() { void key_grab() {
KeyCode code; KeyCode code;
for (int i=0; i < sizeof(keys)/sizeof(*keys); ++i) for (unsigned int i=0; i < sizeof(keys)/sizeof(*keys); ++i)
if ((code = XKeysymToKeycode(d, keys[i].keysym))) if ((code = XKeysymToKeycode(d, keys[i].keysym)))
XGrabKey(d, code, keys[i].mod, root, XGrabKey(d, code, keys[i].mod, root,
True, GrabModeAsync, GrabModeAsync); True, GrabModeAsync, GrabModeAsync);
@@ -214,7 +215,7 @@ void key_grab() {
void key_press(XEvent *e) { void key_press(XEvent *e) {
KeySym keysym = XKeycodeToKeysym(d, e->xkey.keycode, 0); KeySym keysym = XKeycodeToKeysym(d, e->xkey.keycode, 0);
for (int i=0; i < sizeof(keys)/sizeof(*keys); ++i) for (unsigned int i=0; i < sizeof(keys)/sizeof(*keys); ++i)
if (keys[i].keysym == keysym && keys[i].mod == e->xkey.state) if (keys[i].keysym == keysym && keys[i].mod == e->xkey.state)
keys[i].function(keys[i].arg); keys[i].function(keys[i].arg);
} }
@@ -258,8 +259,7 @@ void win_add(Window w) {
exit(1); exit(1);
if (!list) { if (!list) {
c->next = 0; c->next = c->prev = 0;
c->prev = 0;
c->w = w; c->w = w;
list = c; list = c;
@@ -335,7 +335,7 @@ void win_kill() {
currently focused window. currently focused window.
*/ */
void win_center(const Arg arg) { void win_center(const Arg arg) {
Window w = arg.i ? arg.i : win_current(); Window w = arg.w ? arg.w : win_current();
XGetWindowAttributes(d, w, &attr); XGetWindowAttributes(d, w, &attr);
@@ -468,7 +468,7 @@ void ws_save(int i) {
*/ */
void ws_sel(int i) { void ws_sel(int i) {
list = ws_list[i].list; list = ws_list[i].list;
ws = i; ws = i;
} }
/* /*
@@ -508,6 +508,7 @@ void map_request(XEvent *e) {
XSelectInput(d, w, PropertyChangeMask|StructureNotifyMask| XSelectInput(d, w, PropertyChangeMask|StructureNotifyMask|
EnterWindowMask|FocusChangeMask); EnterWindowMask|FocusChangeMask);
win_center((Arg){.i = w}); win_center((Arg){.i = w});
XMapWindow(d, w); XMapWindow(d, w);
FOC(w); FOC(w);
@@ -535,9 +536,7 @@ void run(const Arg arg) {
The only errors which are handled are failed memory The only errors which are handled are failed memory
allocations or a failure to open the display on start. allocations or a failure to open the display on start.
*/ */
int xerror(Display *d, XErrorEvent *e) { int xerror() { return 0; }
return 0;
}
/* /*
Initialize the window manager by registering all Initialize the window manager by registering all