From 799b23dab51822bd9a4156497c0fe4236bd53c76 Mon Sep 17 00:00:00 2001 From: Andy Spencer Date: Fri, 16 Sep 2011 23:36:08 +0000 Subject: [PATCH] Better tiling support --- sys-x11.c | 4 +--- wm-wmii.c | 34 +++++++++++++++++++++++++++++----- 2 files changed, 30 insertions(+), 8 deletions(-) diff --git a/sys-x11.c b/sys-x11.c index ad12cec..08e80e9 100644 --- a/sys-x11.c +++ b/sys-x11.c @@ -181,6 +181,7 @@ void process_event(int type, XEvent *ev, win_t *root) { Display *dpy = root->sys->dpy; win_t *win = NULL; + printf("event: %d\n", type); /* Common data for all these events ... */ ptr_t ptr; mod_t mod; @@ -195,7 +196,6 @@ void process_event(int type, XEvent *ev, win_t *root) } /* Split based on event */ - printf("event: %d\n", type); if (type == KeyPress) { while (XCheckTypedEvent(dpy, KeyPress, ev)); KeySym sym = XKeycodeToKeysym(dpy, ev->xkey.keycode, 0); @@ -336,7 +336,6 @@ win_t *sys_init(void) { Display *dpy; Window xid; - if (!(dpy = XOpenDisplay(NULL))) error("Unable to get display"); if (!(xid = DefaultRootWindow(dpy))) @@ -344,7 +343,6 @@ win_t *sys_init(void) atoms[wm_proto] = XInternAtom(dpy, "WM_PROTOCOLS", False); atoms[wm_focus] = XInternAtom(dpy, "WM_TAKE_FOCUS", False); XSelectInput(dpy, xid, SubstructureRedirectMask|SubstructureNotifyMask); - //XSetInputFocus(dpy, None, RevertToNone, CurrentTime); return win_find(dpy, xid, 1); } diff --git a/wm-wmii.c b/wm-wmii.c index 1b01648..88789e6 100644 --- a/wm-wmii.c +++ b/wm-wmii.c @@ -212,16 +212,40 @@ int wm_handle_ptr(win_t *cwin, ptr_t ptr) { //printf("wm_handle_ptr: %p - %d,%d %d,%d (%d) -- \n", // cwin, ptr.x, ptr.y, ptr.rx, ptr.ry, move_mode); + if (move_mode == none) return 0; - win_t *mwin = move_win; + + /* Tiling */ int dx = ptr.rx - move_prev.rx; int dy = ptr.ry - move_prev.ry; move_prev = ptr; - if (move_mode == move) - sys_move(mwin, mwin->x+dx, mwin->y+dy, mwin->w, mwin->h); - else if (move_mode == resize) - sys_move(mwin, mwin->x, mwin->y, mwin->w+dx, mwin->h+dy); + if (move_mode == resize) { + list_t *row = move_win->wm->row; + list_t *col = move_win->wm->col; + list_t *lower = row->next; + list_t *right = col->next; + if (lower) { + ((win_t*)row->data)->h += dy; + ((win_t*)lower->data)->h -= dy; + } + if (right) { + ((col_t*)col->data)->width += dx; + ((col_t*)right->data)->width -= dx; + } + arrange(wm_cols); + } + + /* Floating */ + //win_t *mwin = move_win; + //int dx = ptr.rx - move_prev.rx; + //int dy = ptr.ry - move_prev.ry; + //move_prev = ptr; + //if (move_mode == move) + // sys_move(mwin, mwin->x+dx, mwin->y+dy, mwin->w, mwin->h); + //else if (move_mode == resize) + // sys_move(mwin, mwin->x, mwin->y, mwin->w+dx, mwin->h+dy); + return 0; } -- 2.43.2