]> Dogcows Code - chaz/openbox/commitdiff
the resistance resizing has been changed from "lock corner" to "the direction being...
authorDana Jansens <danakj@orodu.net>
Sat, 21 Jul 2007 00:09:12 +0000 (20:09 -0400)
committerDana Jansens <danakj@orodu.net>
Sat, 21 Jul 2007 00:10:20 +0000 (20:10 -0400)
openbox/moveresize.c
openbox/resist.c
openbox/resist.h

index 11cf563d4819c32bff3076b654fdee1ace9bedbd..c0ddcca89ef4ef29c0a0f44a967eb29a3a77acd3 100644 (file)
@@ -54,7 +54,6 @@ static gint start_x, start_y, start_cx, start_cy, start_cw, start_ch;
 static gint cur_x, cur_y, cur_w, cur_h;
 static guint button;
 static guint32 corner;
-static ObCorner lockcorner;
 static ObDirection edge_warp_dir = -1;
 static ObDirection key_resize_edge = -1;
 #ifdef SYNC
@@ -372,36 +371,37 @@ static gboolean sync_timeout_func(gpointer data)
 #endif
 
 static void calc_resize(gboolean keyboard, gint keydist, gint *dw, gint *dh,
-                        ObCorner cor)
+                        ObDirection dir)
 {
-    gint resist, x, y, lw, lh, ow, oh, nw, nh;
+    gint resist, x = 0, y = 0, lw, lh, ow, oh, nw, nh;
 
     ow = cur_w;
     oh = cur_h;
+    nw = ow + *dw;
+    nh = oh + *dh;
+
     /* resist_size_* needs the frame size */
-    nw = ow + *dw +
-        moveresize_client->frame->size.left +
+    nw += moveresize_client->frame->size.left +
         moveresize_client->frame->size.right;
-    nh = oh + *dh +
-        moveresize_client->frame->size.top +
+    nh += moveresize_client->frame->size.top +
         moveresize_client->frame->size.bottom;
 
     if (keyboard) resist = keydist - 1; /* resist for one key press */
     else resist = config_resist_win;
-    resist_size_windows(moveresize_client, resist, &nw, &nh, cor);
+    resist_size_windows(moveresize_client, resist, &nw, &nh, dir);
     if (!keyboard) resist = config_resist_edge;
-    resist_size_monitors(moveresize_client, resist, &nw, &nh, cor);
+    resist_size_monitors(moveresize_client, resist, &nw, &nh, dir);
 
     nw -= moveresize_client->frame->size.left +
         moveresize_client->frame->size.right;
     nh -= moveresize_client->frame->size.top +
         moveresize_client->frame->size.bottom;
 
-    /* see its actual size */
-    x = 0;
-    y = 0;
-    client_try_configure(moveresize_client, &x, &y, &nw, &nh, &lw, &lh, TRUE);
+    *dw = nw - ow;
+    *dh = nh - oh;
 
+    /* make sure it's a valid size */
+    client_try_configure(moveresize_client, &x, &y, &nw, &nh, &lw, &lh, TRUE);
 
     *dw = nw - ow;
     *dh = nh - oh;
@@ -533,7 +533,6 @@ static void resize_with_keys(gint keycode, gint state)
     gint dw = 0, dh = 0, pdx = 0, pdy = 0, opx, opy, px, py;
     gint dist = 0, resist = 0;
     ObDirection dir;
-    ObCorner cor;
 
     /* pick the edge if it needs to move */
     if (keycode == ob_keycode(OB_KEY_RIGHT)) {
@@ -646,17 +645,7 @@ static void resize_with_keys(gint keycode, gint state)
         }
     }
 
-    /* which corner is locked, for resistance */
-    if (key_resize_edge == OB_DIRECTION_WEST)
-        cor = OB_CORNER_TOPRIGHT;
-    else if (key_resize_edge == OB_DIRECTION_EAST)
-        cor = OB_CORNER_TOPLEFT;
-    else if (key_resize_edge == OB_DIRECTION_NORTH)
-        cor = OB_CORNER_BOTTOMLEFT;
-    else if (key_resize_edge == OB_DIRECTION_SOUTH)
-        cor = OB_CORNER_TOPLEFT;
-
-    calc_resize(TRUE, resist, &dw, &dh, cor);
+    calc_resize(TRUE, resist, &dw, &dh, dir);
     if (key_resize_edge == OB_DIRECTION_WEST)
         cur_x -= dw;
     else if (key_resize_edge == OB_DIRECTION_NORTH)
@@ -721,52 +710,53 @@ gboolean moveresize_event(XEvent *e)
             do_edge_warp(e->xmotion.x_root, e->xmotion.y_root);
         } else {
             gint dw, dh;
+            ObDirection dir;
 
             if (corner == prop_atoms.net_wm_moveresize_size_topleft) {
                 dw = -(e->xmotion.x_root - start_x);
                 dh = -(e->xmotion.y_root - start_y);
-                lockcorner = OB_CORNER_BOTTOMRIGHT;
+                dir = OB_DIRECTION_NORTHWEST;
             } else if (corner == prop_atoms.net_wm_moveresize_size_top) {
                 dw = 0;
                 dh = -(e->xmotion.y_root - start_y);
-                lockcorner = OB_CORNER_BOTTOMRIGHT;
+                dir = OB_DIRECTION_NORTH;
             } else if (corner == prop_atoms.net_wm_moveresize_size_topright) {
                 dw = (e->xmotion.x_root - start_x);
                 dh = -(e->xmotion.y_root - start_y);
-                lockcorner = OB_CORNER_BOTTOMLEFT;
+                dir = OB_DIRECTION_NORTHEAST;
             } else if (corner == prop_atoms.net_wm_moveresize_size_right) {
                 dw = (e->xmotion.x_root - start_x);
                 dh = 0;
-                lockcorner = OB_CORNER_BOTTOMLEFT;
+                dir = OB_DIRECTION_EAST;
             } else if (corner ==
                        prop_atoms.net_wm_moveresize_size_bottomright) {
                 dw = (e->xmotion.x_root - start_x);
                 dh = (e->xmotion.y_root - start_y);
-                lockcorner = OB_CORNER_TOPLEFT;
+                dir = OB_DIRECTION_SOUTHEAST;
             } else if (corner == prop_atoms.net_wm_moveresize_size_bottom) {
                 dw = 0;
                 dh = (e->xmotion.y_root - start_y);
-                lockcorner = OB_CORNER_TOPLEFT;
+                dir = OB_DIRECTION_SOUTH;
             } else if (corner ==
                        prop_atoms.net_wm_moveresize_size_bottomleft) {
                 dw = -(e->xmotion.x_root - start_x);
                 dh = (e->xmotion.y_root - start_y);
-                lockcorner = OB_CORNER_TOPRIGHT;
+                dir = OB_DIRECTION_SOUTHWEST;
             } else if (corner == prop_atoms.net_wm_moveresize_size_left) {
                 dw = -(e->xmotion.x_root - start_x);
                 dh = 0;
-                lockcorner = OB_CORNER_TOPRIGHT;
+                dir = OB_DIRECTION_WEST;
             } else if (corner == prop_atoms.net_wm_moveresize_size_keyboard) {
                 dw = (e->xmotion.x_root - start_x);
                 dh = (e->xmotion.y_root - start_y);
-                lockcorner = OB_CORNER_TOPLEFT;
+                dir = OB_DIRECTION_SOUTHEAST;
             } else
                 g_assert_not_reached();
 
             dw -= cur_w - start_cw;
             dh -= cur_h - start_ch;
 
-            calc_resize(FALSE, 0, &dw, &dh, lockcorner);
+            calc_resize(FALSE, 0, &dw, &dh, dir);
             cur_w += dw;
             cur_h += dh;
 
index fcd12ab4bc84123e1b2b5205799232cd6929fb9e..a3eee7b9102b7504985fa40bbca76095f7015cb5 100644 (file)
@@ -192,7 +192,7 @@ void resist_move_monitors(ObClient *c, gint resist, gint *x, gint *y)
 }
 
 void resist_size_windows(ObClient *c, gint resist, gint *w, gint *h,
-                         ObCorner corn)
+                         ObDirection dir)
 {
     GList *it;
     ObClient *target; /* target */
@@ -230,23 +230,28 @@ void resist_size_windows(ObClient *c, gint resist, gint *w, gint *h,
         if (snapx == NULL) {
             /* horizontal snapping */
             if (t < tb && b > tt) {
-                switch (corn) {
-                case OB_CORNER_TOPLEFT:
-                case OB_CORNER_BOTTOMLEFT:
+                switch (dir) {
+                case OB_DIRECTION_EAST:
+                case OB_DIRECTION_NORTHEAST:
+                case OB_DIRECTION_SOUTHEAST:
                     dlt = l;
                     drb = r + *w - c->frame->area.width;
                     if (r < tl && drb >= tl &&
                         drb < tl + resist)
                         *w = tl - l, snapx = target;
                     break;
-                case OB_CORNER_TOPRIGHT:
-                case OB_CORNER_BOTTOMRIGHT:
+                case OB_DIRECTION_WEST:
+                case OB_DIRECTION_NORTHWEST:
+                case OB_DIRECTION_SOUTHWEST:
                     dlt = l - *w + c->frame->area.width;
                     drb = r;
                     if (l > tr && dlt <= tr &&
                         dlt > tr - resist)
                         *w = r - tr, snapx = target;
                     break;
+                case OB_DIRECTION_NORTH:
+                case OB_DIRECTION_SOUTH:
+                    break;
                 }
             }
         }
@@ -254,23 +259,28 @@ void resist_size_windows(ObClient *c, gint resist, gint *w, gint *h,
         if (snapy == NULL) {
             /* vertical snapping */
             if (l < tr && r > tl) {
-                switch (corn) {
-                case OB_CORNER_TOPLEFT:
-                case OB_CORNER_TOPRIGHT:
+                switch (dir) {
+                case OB_DIRECTION_SOUTH:
+                case OB_DIRECTION_SOUTHWEST:
+                case OB_DIRECTION_SOUTHEAST:
                     dlt = t;
                     drb = b + *h - c->frame->area.height;
                     if (b < tt && drb >= tt &&
                         drb < tt + resist)
                         *h = tt - t, snapy = target;
                     break;
-                case OB_CORNER_BOTTOMLEFT:
-                case OB_CORNER_BOTTOMRIGHT:
+                case OB_DIRECTION_NORTH:
+                case OB_DIRECTION_NORTHWEST:
+                case OB_DIRECTION_NORTHEAST:
                     dlt = t - *h + c->frame->area.height;
                     drb = b;
                     if (t > tb && dlt <= tb &&
                         dlt > tb - resist)
                         *h = b - tb, snapy = target;
                     break;
+                case OB_DIRECTION_EAST:
+                case OB_DIRECTION_WEST:
+                    break;
                 }
             }
         }
@@ -281,7 +291,7 @@ void resist_size_windows(ObClient *c, gint resist, gint *w, gint *h,
 }
 
 void resist_size_monitors(ObClient *c, gint resist, gint *w, gint *h,
-                          ObCorner corn)
+                          ObDirection dir)
 {
     gint l, t, r, b; /* my left, top, right and bottom sides */
     gint dlt, drb; /* my destination left/top and right/bottom sides */
@@ -326,9 +336,10 @@ void resist_size_monitors(ObClient *c, gint resist, gint *w, gint *h,
         pb = RECT_BOTTOM(*parea);
 
         /* horizontal snapping */
-        switch (corn) {
-        case OB_CORNER_TOPLEFT:
-        case OB_CORNER_BOTTOMLEFT:
+        switch (dir) {
+        case OB_DIRECTION_EAST:
+        case OB_DIRECTION_NORTHEAST:
+        case OB_DIRECTION_SOUTHEAST:
             dlt = l;
             drb = r + *w - c->frame->area.width;
             if (r <= ar && drb > ar && drb <= ar + resist)
@@ -336,8 +347,9 @@ void resist_size_monitors(ObClient *c, gint resist, gint *w, gint *h,
             else if (r <= pr && drb > pr && drb <= pr + resist)
                 *w = pr - l + 1;
             break;
-        case OB_CORNER_TOPRIGHT:
-        case OB_CORNER_BOTTOMRIGHT:
+        case OB_DIRECTION_WEST:
+        case OB_DIRECTION_NORTHWEST:
+        case OB_DIRECTION_SOUTHWEST:
             dlt = l - *w + c->frame->area.width;
             drb = r;
             if (l >= al && dlt < al && dlt >= al - resist)
@@ -345,12 +357,16 @@ void resist_size_monitors(ObClient *c, gint resist, gint *w, gint *h,
             else if (l >= pl && dlt < pl && dlt >= pl - resist)
                 *w = r - pl + 1;
             break;
+        case OB_DIRECTION_NORTH:
+        case OB_DIRECTION_SOUTH:
+            break;
         }
 
         /* vertical snapping */
-        switch (corn) {
-        case OB_CORNER_TOPLEFT:
-        case OB_CORNER_TOPRIGHT:
+        switch (dir) {
+        case OB_DIRECTION_SOUTH:
+        case OB_DIRECTION_SOUTHWEST:
+        case OB_DIRECTION_SOUTHEAST:
             dlt = t;
             drb = b + *h - c->frame->area.height;
             if (b <= ab && drb > ab && drb <= ab + resist)
@@ -358,8 +374,9 @@ void resist_size_monitors(ObClient *c, gint resist, gint *w, gint *h,
             else if (b <= pb && drb > pb && drb <= pb + resist)
                 *h = pb - t + 1;
             break;
-        case OB_CORNER_BOTTOMLEFT:
-        case OB_CORNER_BOTTOMRIGHT:
+        case OB_DIRECTION_NORTH:
+        case OB_DIRECTION_NORTHWEST:
+        case OB_DIRECTION_NORTHEAST:
             dlt = t - *h + c->frame->area.height;
             drb = b;
             if (t >= at && dlt < at && dlt >= at - resist)
@@ -367,6 +384,9 @@ void resist_size_monitors(ObClient *c, gint resist, gint *w, gint *h,
             else if (t >= pt && dlt < pt && dlt >= pt - resist)
                 *h = b - pt + 1;
             break;
+        case OB_DIRECTION_WEST:
+        case OB_DIRECTION_EAST:
+            break;
         }
 
         g_free(area);
index d61e7f2e75768451ed8f82c8c8aa7cfeed6143d5..a2b3f1602c1fd52574830ff092b66d942a775dc5 100644 (file)
@@ -32,8 +32,8 @@ void resist_move_windows(struct _ObClient *c, gint resist, gint *x, gint *y);
 */
 void resist_move_monitors(struct _ObClient *c, gint resist, gint *x, gint *y);
 void resist_size_windows(struct _ObClient *c, gint resist, gint *w, gint *h,
-                         ObCorner corn);
+                         ObDirection dir);
 void resist_size_monitors(struct _ObClient *c, gint resist, gint *w, gint *h,
-                          ObCorner corn);
+                          ObDirection dir);
 
 #endif
This page took 0.033188 seconds and 4 git commands to generate.