]> Dogcows Code - chaz/openbox/blobdiff - openbox/moveresize.c
Change resizing terminals to work for top and left edges too, the code is a little...
[chaz/openbox] / openbox / moveresize.c
index b93871ba401fa094814728ae79656abb8e601eab..55a42c7fc6915d6fd8c09ef0f83bc670c2d4ae68 100644 (file)
@@ -120,6 +120,8 @@ void moveresize_start(ObClient *c, gint x, gint y, guint b, guint32 cnr)
     ObCursor cur;
     gboolean mv = (cnr == prop_atoms.net_wm_moveresize_move ||
                    cnr == prop_atoms.net_wm_moveresize_move_keyboard);
+    gint up = 1;
+    gint left = 1;
 
     if (moveresize_in_progress || !c->frame->visible ||
         !(mv ?
@@ -127,23 +129,28 @@ void moveresize_start(ObClient *c, gint x, gint y, guint b, guint32 cnr)
           (c->functions & OB_CLIENT_FUNC_RESIZE)))
         return;
 
-    if (cnr == prop_atoms.net_wm_moveresize_size_topleft)
+    if (cnr == prop_atoms.net_wm_moveresize_size_topleft) {
         cur = OB_CURSOR_NORTHWEST;
-    else if (cnr == prop_atoms.net_wm_moveresize_size_top)
+        up = left = -1;
+    } else if (cnr == prop_atoms.net_wm_moveresize_size_top) {
         cur = OB_CURSOR_NORTH;
-    else if (cnr == prop_atoms.net_wm_moveresize_size_topright)
+        up = -1;
+    } else if (cnr == prop_atoms.net_wm_moveresize_size_topright) {
         cur = OB_CURSOR_NORTHEAST;
-    else if (cnr == prop_atoms.net_wm_moveresize_size_right)
+        up = -1;
+    } else if (cnr == prop_atoms.net_wm_moveresize_size_right)
         cur = OB_CURSOR_EAST;
     else if (cnr == prop_atoms.net_wm_moveresize_size_bottomright)
         cur = OB_CURSOR_SOUTHEAST;
     else if (cnr == prop_atoms.net_wm_moveresize_size_bottom)
         cur = OB_CURSOR_SOUTH;
-    else if (cnr == prop_atoms.net_wm_moveresize_size_bottomleft)
+    else if (cnr == prop_atoms.net_wm_moveresize_size_bottomleft) {
         cur = OB_CURSOR_SOUTHWEST;
-    else if (cnr == prop_atoms.net_wm_moveresize_size_left)
+        left = -1;
+    } else if (cnr == prop_atoms.net_wm_moveresize_size_left) {
         cur = OB_CURSOR_WEST;
-    else if (cnr == prop_atoms.net_wm_moveresize_size_keyboard)
+        left = -1;
+    } else if (cnr == prop_atoms.net_wm_moveresize_size_keyboard)
         cur = OB_CURSOR_SOUTHEAST;
     else if (cnr == prop_atoms.net_wm_moveresize_move)
         cur = OB_CURSOR_MOVE;
@@ -172,8 +179,8 @@ void moveresize_start(ObClient *c, gint x, gint y, guint b, guint32 cnr)
        friendly. you essentially start the resize in the middle of the
        increment instead of at 0, so you have to move half an increment
        either way instead of a full increment one and 1 px the other. */
-    start_x = x - (mv ? 0 : c->size_inc.width / 2);
-    start_y = y - (mv ? 0 : c->size_inc.height / 2);
+    start_x = x - (mv ? 0 : left * c->size_inc.width / 2);
+    start_y = y - (mv ? 0 : up * c->size_inc.height / 2);
     corner = cnr;
     button = b;
     key_resize_edge = -1;
@@ -381,7 +388,9 @@ static void calc_resize(gboolean keyboard, gint keydist, gint *dw, gint *dh,
     nw = ow + *dw;
     nh = oh + *dh;
 
-    if (moveresize_client->max_ratio || moveresize_client->min_ratio) {
+    if (!keyboard &&
+        (moveresize_client->max_ratio || moveresize_client->min_ratio))
+    {
         switch (dir) {
         case OB_DIRECTION_NORTH:
         case OB_DIRECTION_SOUTH:
@@ -407,13 +416,13 @@ static void calc_resize(gboolean keyboard, gint keydist, gint *dw, gint *dh,
             }
             break;
         }
-    }
 
-    /* see its actual size (apply aspect ratios) */
-    client_try_configure(moveresize_client, &x, &y, &nw, &nh, &lw, &lh, TRUE);
-    trydw = nw - ow;
-    trydh = nh - oh;
-    g_print("trydw %d trydh %d\n", trydw, trydh);
+        /* see its actual size (apply aspect ratios) */
+        client_try_configure(moveresize_client, &x, &y, &nw, &nh, &lw, &lh,
+                             TRUE);
+        trydw = nw - ow;
+        trydh = nh - oh;
+    }
 
     /* resist_size_* needs the frame size */
     nw += moveresize_client->frame->size.left +
@@ -436,26 +445,30 @@ static void calc_resize(gboolean keyboard, gint keydist, gint *dw, gint *dh,
     *dh = nh - oh;
 
     /* take aspect ratios into account for resistance */
-    if (*dh != trydh) { /* got resisted */
-        /* resize the width based on the height */
-        if (moveresize_client->min_ratio) {
-            if (nh * moveresize_client->min_ratio > nw)
-                nw = (gint)(nh * moveresize_client->min_ratio);
-        }
-        if (moveresize_client->max_ratio) {
-            if (nh * moveresize_client->max_ratio < nw)
-                nw = (gint)(nh * moveresize_client->max_ratio);
-        }
-    }
-    if (*dw != trydw) { /* got resisted */
-        /* resize the height based on the width */
-        if (moveresize_client->min_ratio) {
-            if (nh * moveresize_client->min_ratio > nw)
-                nh = (gint)(nw / moveresize_client->min_ratio);
+    if (!keyboard &&
+        (moveresize_client->max_ratio || moveresize_client->min_ratio))
+    {
+        if (*dh != trydh) { /* got resisted */
+            /* resize the width based on the height */
+            if (moveresize_client->min_ratio) {
+                if (nh * moveresize_client->min_ratio > nw)
+                    nw = (gint)(nh * moveresize_client->min_ratio);
+            }
+            if (moveresize_client->max_ratio) {
+                if (nh * moveresize_client->max_ratio < nw)
+                    nw = (gint)(nh * moveresize_client->max_ratio);
+            }
         }
-        if (moveresize_client->max_ratio) {
-            if (nh * moveresize_client->max_ratio < nw)
-                nh = (gint)(nw / moveresize_client->max_ratio);
+        if (*dw != trydw) { /* got resisted */
+            /* resize the height based on the width */
+            if (moveresize_client->min_ratio) {
+                if (nh * moveresize_client->min_ratio > nw)
+                    nh = (gint)(nw / moveresize_client->min_ratio);
+            }
+            if (moveresize_client->max_ratio) {
+                if (nh * moveresize_client->max_ratio < nw)
+                    nh = (gint)(nw / moveresize_client->max_ratio);
+            }
         }
     }
 
This page took 0.031755 seconds and 4 git commands to generate.