]> Pileus Git - wmpus/commitdiff
Better tiling support
authorAndy Spencer <andy753421@gmail.com>
Fri, 16 Sep 2011 23:36:08 +0000 (23:36 +0000)
committerAndy Spencer <andy753421@gmail.com>
Fri, 16 Sep 2011 23:36:08 +0000 (23:36 +0000)
sys-x11.c
wm-wmii.c

index ad12cec699f7e47406839cdc4e45f58d54f59215..08e80e986c1f3dcb42c4fc8b7e9c5af52e9ca590 100644 (file)
--- 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);
 }
index 1b016487811f6b46694a38ae375ee76784dcdec6..88789e69a4f8a64a708148e8deaf3a2158312eb6 100644 (file)
--- 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;
 }