docs: update

This commit is contained in:
Dylan Araps 2019-10-12 18:43:30 +03:00
parent 06b8abeb5b
commit cfdaadc71a

47
sowm.c
View File

@ -70,7 +70,7 @@ static void wm_setup();
static client *head; static client *head;
static desktop desktops[10]; static desktop desktops[10];
static int curr_desk, screen, sh, sw; static int desk = 1, sh, sw;
static Display *dis; static Display *dis;
static Window root; static Window root;
@ -113,19 +113,19 @@ void win_add(Window w) {
t->next = c; t->next = c;
} }
ws_save(curr_desk); ws_save(desk);
} }
void ws_go(const Arg arg) { void ws_go(const Arg arg) {
client *c; client *c;
if (arg.i == curr_desk) if (arg.i == desk)
return; return;
if (head != NULL) if (head != NULL)
for(c=head;c;c=c->next) XUnmapWindow(dis, c->win); for(c=head;c;c=c->next) XUnmapWindow(dis, c->win);
ws_save(curr_desk); ws_save(desk);
ws_sel(arg.i); ws_sel(arg.i);
if (head != NULL) if (head != NULL)
@ -185,19 +185,19 @@ void win_fs(Window w) {
} }
void win_to_ws(const Arg arg) { void win_to_ws(const Arg arg) {
int tmp = curr_desk; int tmp = desk;
Window current = win_current(); Window cur = win_current();
if (arg.i == tmp) if (arg.i == tmp)
return; return;
ws_sel(arg.i); ws_sel(arg.i);
win_add(current); win_add(cur);
ws_save(arg.i); ws_save(arg.i);
ws_sel(tmp); ws_sel(tmp);
XUnmapWindow(dis, current); XUnmapWindow(dis, cur);
win_del(current); win_del(cur);
ws_save(tmp); ws_save(tmp);
} }
@ -286,10 +286,10 @@ void button_release() {
} }
void win_kill() { void win_kill() {
Window current = win_current(); Window cur = win_current();
if (current != root) if (cur != root)
XKillClient(dis, current); XKillClient(dis, cur);
} }
void map_request(XEvent *e) { void map_request(XEvent *e) {
@ -304,12 +304,12 @@ void map_request(XEvent *e) {
} }
void win_next() { void win_next() {
Window current = win_current(); Window cur = win_current();
client *c; client *c;
if (head != NULL) { if (head != NULL) {
for(c=head;c;c=c->next) for(c=head;c;c=c->next)
if (c->win == current) break; if (c->win == cur) break;
c = c->next; c = c->next;
@ -331,7 +331,7 @@ void win_del(Window w) {
head = NULL; head = NULL;
ws_save(curr_desk); ws_save(desk);
return; return;
} }
@ -350,7 +350,7 @@ void win_del(Window w) {
} }
free(c); free(c);
ws_save(curr_desk); ws_save(desk);
return; return;
} }
} }
@ -361,17 +361,16 @@ void ws_save(int i) {
void ws_sel(int i) { void ws_sel(int i) {
head = desktops[i].head; head = desktops[i].head;
desk = i;
curr_desk = i;
} }
void wm_setup() { void wm_setup() {
signal(SIGCHLD, SIG_IGN); signal(SIGCHLD, SIG_IGN);
screen = DefaultScreen(dis); int s = DefaultScreen(dis);
root = RootWindow(dis, screen); root = RootWindow(dis, s);
sw = XDisplayWidth(dis, screen); sw = XDisplayWidth(dis, s);
sh = XDisplayHeight(dis, screen); sh = XDisplayHeight(dis, s);
key_grab(); key_grab();
@ -379,7 +378,6 @@ void wm_setup() {
desktops[i].head = NULL; desktops[i].head = NULL;
const Arg arg = {.i = 1}; const Arg arg = {.i = 1};
curr_desk = arg.i;
ws_go(arg); ws_go(arg);
XSelectInput(dis, root, SubstructureNotifyMask|SubstructureRedirectMask| XSelectInput(dis, root, SubstructureNotifyMask|SubstructureRedirectMask|
@ -397,9 +395,6 @@ void run(const Arg arg) {
void wm_init() { void wm_init() {
XEvent ev; XEvent ev;
XGrabKey(dis, XKeysymToKeycode(dis, XStringToKeysym("F1")), Mod4Mask,
DefaultRootWindow(dis), True, GrabModeAsync, GrabModeAsync);
XGrabButton(dis, 1, Mod4Mask, DefaultRootWindow(dis), True, XGrabButton(dis, 1, Mod4Mask, DefaultRootWindow(dis), True,
ButtonPressMask|ButtonReleaseMask|PointerMotionMask, GrabModeAsync, GrabModeAsync, None, None); ButtonPressMask|ButtonReleaseMask|PointerMotionMask, GrabModeAsync, GrabModeAsync, None, None);