mirror of
https://github.com/dylanaraps/sowm.git
synced 2026-10-01 05:25:23 +07:00
docs: update
This commit is contained in:
@@ -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,94 +271,6 @@ void win_to_ws(const Arg arg) {
|
||||
ws_save(tmp);
|
||||
}
|
||||
|
||||
void notify_destroy(XEvent *e) {
|
||||
win_del(e->xdestroywindow.window);
|
||||
}
|
||||
|
||||
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 notify_enter(XEvent *e) {
|
||||
XSetInputFocus(dis, e->xcrossing.window, RevertToParent, CurrentTime);
|
||||
}
|
||||
|
||||
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 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 button_release() {
|
||||
start.subwindow = None;
|
||||
}
|
||||
|
||||
void win_kill() {
|
||||
Window cur = win_current();
|
||||
|
||||
if (cur != root)
|
||||
XKillClient(dis, cur);
|
||||
}
|
||||
|
||||
void map_request(XEvent *e) {
|
||||
XMapRequestEvent *ev = &e->xmaprequest;
|
||||
|
||||
XSelectInput(dis, ev->window, PropertyChangeMask|StructureNotifyMask|
|
||||
EnterWindowMask|FocusChangeMask);
|
||||
win_center(ev->window);
|
||||
XMapWindow(dis, ev->window);
|
||||
XSetInputFocus(dis, ev->window, RevertToParent, CurrentTime);
|
||||
win_add(ev->window);
|
||||
}
|
||||
|
||||
void win_next() {
|
||||
Window cur = win_current();
|
||||
client *c;
|
||||
@@ -303,39 +287,30 @@ void win_next() {
|
||||
}
|
||||
}
|
||||
|
||||
void win_del(Window w) {
|
||||
void win_fs_current() {
|
||||
win_fs(win_current());
|
||||
}
|
||||
|
||||
void win_center_current() {
|
||||
win_center(win_current());
|
||||
}
|
||||
|
||||
void ws_go(const Arg arg) {
|
||||
client *c;
|
||||
int tmp = desk;
|
||||
|
||||
for WIN {
|
||||
if (c->win != w) continue;
|
||||
if (arg.i == desk) return;
|
||||
|
||||
if (!c->prev && !c->next) {
|
||||
free(head);
|
||||
ws_save(desk);
|
||||
ws_sel(arg.i);
|
||||
|
||||
head = 0;
|
||||
if (head) for WIN XMapWindow(dis, c->win);
|
||||
|
||||
ws_save(desk);
|
||||
return;
|
||||
}
|
||||
ws_sel(tmp);
|
||||
|
||||
if (!c->prev) {
|
||||
head = c->next;
|
||||
c->next->prev = 0;
|
||||
}
|
||||
if (head) for WIN XUnmapWindow(dis, c->win);
|
||||
|
||||
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;
|
||||
}
|
||||
ws_sel(arg.i);
|
||||
}
|
||||
|
||||
void ws_save(int i) {
|
||||
@@ -347,6 +322,39 @@ void ws_sel(int i) {
|
||||
desk = i;
|
||||
}
|
||||
|
||||
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) {
|
||||
XMapRequestEvent *ev = &e->xmaprequest;
|
||||
|
||||
XSelectInput(dis, ev->window, PropertyChangeMask|StructureNotifyMask|
|
||||
EnterWindowMask|FocusChangeMask);
|
||||
win_center(ev->window);
|
||||
XMapWindow(dis, ev->window);
|
||||
XSetInputFocus(dis, ev->window, RevertToParent, CurrentTime);
|
||||
win_add(ev->window);
|
||||
}
|
||||
|
||||
void run(const Arg arg) {
|
||||
if (fork()) return;
|
||||
if (dis) close(ConnectionNumber(dis));
|
||||
|
||||
setsid();
|
||||
execvp((char*)arg.com[0], (char**)arg.com);
|
||||
}
|
||||
|
||||
void wm_setup() {
|
||||
signal(SIGCHLD, SIG_IGN);
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user