mfwm

A tiling fork of dylanaraps sowm.
git clone git://depsterr.com/git/mfwm
Log | Files | Refs | README | LICENSE

commit b05b4e8d588284c501ce6e38ee6c286a30588fc3
parent 27fafaf963bf5607d357306e89accab0a81277bc
Author: Dylan Araps <dylan.araps@gmail.com>
Date:   Sat, 12 Oct 2019 21:34:43 +0300

docs: update

Diffstat:
Msowm.c | 284++++++++++++++++++++++++++++++++++++++++----------------------------------------
1 file changed, 142 insertions(+), 142 deletions(-)

diff --git a/sowm.c b/sowm.c @@ -88,6 +88,70 @@ static void (*events[LASTEvent])(XEvent *e) = { [MotionNotify] = notify_motion }; +void notify_destroy(XEvent *e) { + win_del(e->xdestroywindow.window); +} + +void notify_enter(XEvent *e) { + XSetInputFocus(dis, e->xcrossing.window, RevertToParent, CurrentTime); +} + +void notify_motion(XEvent *e) { + XButtonEvent bu = e->xbutton; + + if (start.subwindow != None) { + int xdiff = bu.x_root - start.x_root; + int ydiff = bu.y_root - start.y_root; + + XMoveResizeWindow(dis, start.subwindow, + attr.x + (start.button==1 ? xdiff : 0), + attr.y + (start.button==1 ? ydiff : 0), + attr.width + (start.button==3 ? xdiff : 0), + attr.height + (start.button==3 ? ydiff : 0)); + } +} + +void key_grab() { + KeyCode code; + + for(int i=0; i < sizeof(keys)/sizeof(*keys); ++i) + if ((code = XKeysymToKeycode(dis, keys[i].keysym))) + XGrabKey(dis, code, keys[i].mod, root, + True, GrabModeAsync, GrabModeAsync); +} + +void key_press(XEvent *e) { + XKeyEvent ke = e->xkey; + KeySym keysym = XKeycodeToKeysym(dis,ke.keycode,0); + + for(int i=0; i < sizeof(keys)/sizeof(*keys); ++i) { + if (keys[i].keysym == keysym && keys[i].mod == ke.state) + keys[i].function(keys[i].arg); + } +} + +void button_press(XEvent *e) { + XButtonEvent bu = e->xbutton; + + if (bu.subwindow != None) { + XGetWindowAttributes(dis, bu.subwindow, &attr); + XRaiseWindow(dis, bu.subwindow); + start = bu; + } +} + +void button_release() { + start.subwindow = None; +} + +Window win_current() { + Window focused; + int revert_to; + + XGetInputFocus(dis, &focused, &revert_to); + return focused; +} + void win_add(Window w) { client *c, *t; @@ -113,30 +177,46 @@ void win_add(Window w) { ws_save(desk); } -void ws_go(const Arg arg) { +void win_del(Window w) { client *c; - int tmp = desk; - if (arg.i == desk) return; + for WIN { + if (c->win != w) continue; - ws_save(desk); - ws_sel(arg.i); + if (!c->prev && !c->next) { + free(head); - if (head) for WIN XMapWindow(dis, c->win); + head = 0; - ws_sel(tmp); + ws_save(desk); + return; + } - if (head) for WIN XUnmapWindow(dis, c->win); + if (!c->prev) { + head = c->next; + c->next->prev = 0; + } - ws_sel(arg.i); + else if (!c->next) { + c->prev->next = 0; + } + + else { + c->prev->next = c->next; + c->next->prev = c->prev; + } + + free(c); + ws_save(desk); + return; + } } -Window win_current() { - Window focused; - int revert_to; +void win_kill() { + Window cur = win_current(); - XGetInputFocus(dis, &focused, &revert_to); - return focused; + if (cur != root) + XKillClient(dis, cur); } void win_center(Window w) { @@ -148,14 +228,6 @@ void win_center(Window w) { XMoveWindow(dis, w, x, y); } -void win_center_current() { - win_center(win_current()); -} - -void win_fs_current() { - win_fs(win_current()); -} - void win_fs(Window w) { client *c; @@ -199,81 +271,69 @@ void win_to_ws(const Arg arg) { ws_save(tmp); } -void notify_destroy(XEvent *e) { - win_del(e->xdestroywindow.window); -} +void win_next() { + Window cur = win_current(); + client *c; -void configure_request(XEvent *e) { - XConfigureRequestEvent *ev = &e->xconfigurerequest; - XWindowChanges wc; + if (head) { + for WIN if (c->win == cur) break; - wc.x = ev->x; - wc.y = ev->y; - wc.width = ev->width; - wc.height = ev->height; - wc.sibling = ev->above; - wc.stack_mode = ev->detail; + c = c->next; - XConfigureWindow(dis, ev->window, ev->value_mask, &wc); -} + if (!c) c = head; -void notify_enter(XEvent *e) { - XSetInputFocus(dis, e->xcrossing.window, RevertToParent, CurrentTime); + XSetInputFocus(dis, c->win, RevertToParent, CurrentTime); + XRaiseWindow(dis, c->win); + } } -void key_grab() { - KeyCode code; +void win_fs_current() { + win_fs(win_current()); +} - for(int i=0; i < sizeof(keys)/sizeof(*keys); ++i) - if ((code = XKeysymToKeycode(dis, keys[i].keysym))) - XGrabKey(dis, code, keys[i].mod, root, - True, GrabModeAsync, GrabModeAsync); +void win_center_current() { + win_center(win_current()); } -void key_press(XEvent *e) { - XKeyEvent ke = e->xkey; - KeySym keysym = XKeycodeToKeysym(dis,ke.keycode,0); +void ws_go(const Arg arg) { + client *c; + int tmp = desk; - for(int i=0; i < sizeof(keys)/sizeof(*keys); ++i) { - if (keys[i].keysym == keysym && keys[i].mod == ke.state) - keys[i].function(keys[i].arg); - } -} + if (arg.i == desk) return; -void button_press(XEvent *e) { - XButtonEvent bu = e->xbutton; + ws_save(desk); + ws_sel(arg.i); - if (bu.subwindow != None) { - XGetWindowAttributes(dis, bu.subwindow, &attr); - XRaiseWindow(dis, bu.subwindow); - start = bu; - } -} + if (head) for WIN XMapWindow(dis, c->win); -void notify_motion(XEvent *e) { - XButtonEvent bu = e->xbutton; + ws_sel(tmp); - if (start.subwindow != None) { - int xdiff = bu.x_root - start.x_root; - int ydiff = bu.y_root - start.y_root; + if (head) for WIN XUnmapWindow(dis, c->win); - XMoveResizeWindow(dis, start.subwindow, - attr.x + (start.button==1 ? xdiff : 0), - attr.y + (start.button==1 ? ydiff : 0), - attr.width + (start.button==3 ? xdiff : 0), - attr.height + (start.button==3 ? ydiff : 0)); - } + ws_sel(arg.i); } -void button_release() { - start.subwindow = None; +void ws_save(int i) { + ws_list[i].head = head; } -void win_kill() { - Window cur = win_current(); +void ws_sel(int i) { + head = ws_list[i].head; + desk = i; +} - if (cur != root) - XKillClient(dis, cur); +void configure_request(XEvent *e) { + XConfigureRequestEvent *ev = &e->xconfigurerequest; + XWindowChanges wc; + + wc.x = ev->x; + wc.y = ev->y; + wc.width = ev->width; + wc.height = ev->height; + wc.sibling = ev->above; + wc.stack_mode = ev->detail; + + XConfigureWindow(dis, ev->window, ev->value_mask, &wc); } void map_request(XEvent *e) { @@ -287,64 +347,12 @@ void map_request(XEvent *e) { win_add(ev->window); } -void win_next() { - Window cur = win_current(); - client *c; - - if (head) { - for WIN if (c->win == cur) break; - - c = c->next; - - if (!c) c = head; - - XSetInputFocus(dis, c->win, RevertToParent, CurrentTime); - XRaiseWindow(dis, c->win); - } -} - -void win_del(Window w) { - client *c; - - for WIN { - if (c->win != w) continue; - - if (!c->prev && !c->next) { - free(head); - - head = 0; - - ws_save(desk); - return; - } - - if (!c->prev) { - head = c->next; - c->next->prev = 0; - } - - else if (!c->next) { - c->prev->next = 0; - } - - else { - c->prev->next = c->next; - c->next->prev = c->prev; - } - - free(c); - ws_save(desk); - return; - } -} - -void ws_save(int i) { - ws_list[i].head = head; -} +void run(const Arg arg) { + if (fork()) return; + if (dis) close(ConnectionNumber(dis)); -void ws_sel(int i) { - head = ws_list[i].head; - desk = i; + setsid(); + execvp((char*)arg.com[0], (char**)arg.com); } void wm_setup() { @@ -367,14 +375,6 @@ void wm_setup() { EnterWindowMask|LeaveWindowMask); } -void run(const Arg arg) { - if (fork()) return; - if (dis) close(ConnectionNumber(dis)); - - setsid(); - execvp((char*)arg.com[0], (char**)arg.com); -} - void wm_init() { XEvent ev;