commit 5c075a359ac137f622103337ae3ab42f1e1e681f
parent b48c9b6add7d059b2b2e0816d6f90c2d2f38fc48
Author: Dylan Araps <dylan.araps@gmail.com>
Date:   Sat, 19 Oct 2019 08:14:03 +0300
sowm: simpler center
Diffstat:
2 files changed, 8 insertions(+), 10 deletions(-)
diff --git a/config.def.h b/config.def.h
@@ -15,7 +15,7 @@ const char* colors[]  = {"bud", "/home/goldie/Pictures/Wallpapers", 0};
 
 static struct key keys[] = {
     {MOD,      XK_q,   win_kill,   {0}},
-    {MOD,      XK_c,   win_center, {.w = 0}},
+    {MOD,      XK_c,   win_center, {0}},
     {MOD,      XK_f,   win_fs,     {0}},
     {Mod1Mask, XK_Tab, win_next,   {0}},
 
diff --git a/sowm.c b/sowm.c
@@ -36,7 +36,7 @@ static void notify_enter(XEvent *e);
 static void notify_motion(XEvent *e);
 static void run(const Arg arg);
 static void win_add(Window w);
-static void win_center(const Arg arg);
+static void win_center();
 static void win_del(Window w);
 static void win_fs();
 static void win_kill();
@@ -168,14 +168,12 @@ void win_kill() {
     if (cur) XKillClient(d, cur->w);
 }
 
-void win_center(const Arg arg) {
-    Window w = arg.w ? arg.w : cur->w;
-
-    if (!w) return;
+void win_center() {
+    if (!cur) return;
 
-    win_size(w, &(int){0}, &(int){0}, &ww, &wh);
+    win_size(cur->w, &(int){0}, &(int){0}, &ww, &wh);
 
-    XMoveWindow(d, w, (sw - ww) / 2, (sh - wh) / 2);
+    XMoveWindow(d, cur->w, (sw - ww) / 2, (sh - wh) / 2);
 }
 
 void win_fs() {
@@ -251,11 +249,11 @@ void map_request(XEvent *e) {
     XSelectInput(d, w, StructureNotifyMask|EnterWindowMask);
     win_size(w, &wx, &wy, &ww, &wh);
     win_add(w);
+    win_focus(list->prev);
 
-    if (wx + wy == 0) win_center((Arg){.i = w});
+    if (wx + wy == 0) win_center();
 
     XMapWindow(d, w);
-    win_focus(list->prev);
 }
 
 void run(const Arg arg) {