sowm: Remove need for _current functions.

This commit is contained in:
Dylan Araps 2019-10-15 14:49:12 +03:00
parent bb59bd4f87
commit cc3ee24a01
No known key found for this signature in database
GPG Key ID: 46D62DD9F1DE636E
2 changed files with 20 additions and 43 deletions

View File

@ -15,8 +15,8 @@ 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_current, {0}}, {MOD, XK_c, win_center, {.i = 0}},
{MOD, XK_f, win_fs_current, {0}}, {MOD, XK_f, win_fs, {0}},
{Mod1Mask, XK_Tab, win_next, {0}}, {Mod1Mask, XK_Tab, win_next, {0}},
{MOD, XK_d, run, {.com = menu}}, {MOD, XK_d, run, {.com = menu}},

55
sowm.c
View File

@ -54,11 +54,9 @@ static void notify_enter(XEvent *e);
static void notify_motion(XEvent *e); static void notify_motion(XEvent *e);
static void run(const Arg arg); static void run(const Arg arg);
static void win_add(Window w); static void win_add(Window w);
static void win_center(Window w); static void win_center(const Arg arg);
static void win_center_current();
static void win_del(Window w); static void win_del(Window w);
static void win_fs(Window w); static void win_fs();
static void win_fs_current();
static void win_kill(); static void win_kill();
static void win_next(); static void win_next();
static void win_to_ws(const Arg arg); static void win_to_ws(const Arg arg);
@ -333,9 +331,12 @@ void win_kill() {
/* /*
This function simply centers the window passed as This function simply centers the window passed as
an argument. Nothing special going on here. an argument. If the argument is '0', use the
currently focused window.
*/ */
void win_center(Window w) { void win_center(const Arg arg) {
Window w = arg.i ? arg.i : win_current();
XGetWindowAttributes(d, w, &attr); XGetWindowAttributes(d, w, &attr);
XMoveWindow(d, w, sw / 2 - attr.width / 2, XMoveWindow(d, w, sw / 2 - attr.width / 2,
@ -343,7 +344,7 @@ void win_center(Window w) {
} }
/* /*
This function toggles the fullscreen stte for the This function toggles the fullscreen state for the
window passed as an argument. window passed as an argument.
The window's data stucture holds an integer which The window's data stucture holds an integer which
@ -354,16 +355,18 @@ void win_center(Window w) {
positioning is stored so it can be restored when positioning is stored so it can be restored when
the window is un-fullscreened. the window is un-fullscreened.
*/ */
void win_fs(Window w) { void win_fs() {
client *c; client *c;
for WIN if (c->w == w) { win_current();
for WIN if (c->w == cur) {
if ((c->f = c->f == 0 ? 1 : 0)) { if ((c->f = c->f == 0 ? 1 : 0)) {
XGetWindowAttributes(d, w, &c->a); XGetWindowAttributes(d, cur, &c->a);
XMoveResizeWindow(d, w, 0, 0, sw, sh); XMoveResizeWindow(d, cur, 0, 0, sw, sh);
} else } else
XMoveResizeWindow(d, w, c->a.x, c->a.y, c->a.width, c->a.height); XMoveResizeWindow(d, cur, c->a.x, c->a.y, c->a.width, c->a.height);
} }
} }
@ -421,32 +424,6 @@ void win_next() {
} }
} }
/*
This is a wrapper around the real function
to operate directly on the currently focused
window.
I'd rather this function not exist but it's
the simplest method of allowing its use in a
'config.h' defined keybinding.
*/
void win_fs_current() {
win_fs(win_current());
}
/*
This is a wrapper around the real function
to operate directly on the currently focused
window.
I'd rather this function not exist but it's
the simplest method of allowing its use in a
'config.h' defined keybinding.
*/
void win_center_current() {
win_center(win_current());
}
/* /*
This function changes the focus to another desktop. This function changes the focus to another desktop.
@ -531,7 +508,7 @@ void map_request(XEvent *e) {
XSelectInput(d, w, PropertyChangeMask|StructureNotifyMask| XSelectInput(d, w, PropertyChangeMask|StructureNotifyMask|
EnterWindowMask|FocusChangeMask); EnterWindowMask|FocusChangeMask);
win_center(w); win_center((Arg){.i = w});
XMapWindow(d, w); XMapWindow(d, w);
FOC(w); FOC(w);
win_add(w); win_add(w);