sowm: use simpler structure for storing workspaces.

This commit is contained in:
Dylan Araps 2019-10-17 18:45:47 +03:00
parent 0ae4e7918f
commit cada809f65
No known key found for this signature in database
GPG Key ID: 46D62DD9F1DE636E
2 changed files with 9 additions and 15 deletions

View File

@ -2,7 +2,7 @@
<a href="https://user-images.githubusercontent.com/6799467/66687576-9747c200-ec72-11e9-947d-5b96753eab03.jpg"><img src="https://user-images.githubusercontent.com/6799467/66687576-9747c200-ec72-11e9-947d-5b96753eab03.jpg" width="43%" align="right"></a>
An itsy bitsy floating window manager (*250~ sloc / 24kb compiled!*).
An itsy bitsy floating window manager (*240~ sloc / 24kb compiled!*).
- Floating only.
- Fullscreen toggle.

22
sowm.c
View File

@ -20,16 +20,11 @@ struct key {
const Arg arg;
};
typedef struct client client;
struct client{
client *next, *prev;
Window w;
typedef struct client {
struct client *next, *prev;
int f, wx, wy;
unsigned int ww, wh;
};
typedef struct desktop desktop;
struct desktop{client *list;};
unsigned int w, ww, wh;
} client;
static void button_press(XEvent *e);
static void button_release();
@ -50,8 +45,7 @@ static void win_to_ws(const Arg arg);
static void ws_go(const Arg arg);
static int xerror() { return 0;}
static client *list = {0};
static desktop ws_list[10];
static client *list = {0}, *ws_list[10] = {0};
static int ws = 1, sw, sh, wx, wy;
static unsigned int ww, wh;
@ -74,8 +68,8 @@ static void (*events[LASTEvent])(XEvent *e) = {
#define win (client *c=list;c;c=c->next)
#define win_focus(W) XSetInputFocus(d, W, RevertToParent, CurrentTime)
#define ws_save(W) ws_list[W].list = list
#define ws_sel(W) list = ws_list[ws = W].list
#define ws_save(W) ws_list[W] = list
#define ws_sel(W) list = ws_list[ws = W]
#define win_size(W, gx, gy, gw, gh) \
XGetGeometry(d, W, &(Window){0}, gx, gy, gw, gh, \
@ -186,7 +180,7 @@ void win_del(Window w) {
}
void win_kill() {
if (win_current() != root) XKillClient(d, cur);
if (win_current() ^ root) XKillClient(d, cur);
}
void win_center(const Arg arg) {