]> Dogcows Code - chaz/openbox/blobdiff - openbox/moveresize.c
don't resist when resizing terminals with the keyboard
[chaz/openbox] / openbox / moveresize.c
index 81e7cb007d0d36d3a49447f99e41c2d96ded8672..11cf563d4819c32bff3076b654fdee1ace9bedbd 100644 (file)
@@ -72,7 +72,7 @@ static gboolean sync_timeout_func(gpointer data);
 static void client_dest(ObClient *client, gpointer data)
 {
     if (moveresize_client == client)
-        moveresize_end(TRUE);    
+        moveresize_end(TRUE);
 }
 
 void moveresize_startup(gboolean reconfig)
@@ -167,14 +167,14 @@ void moveresize_start(ObClient *c, gint x, gint y, guint b, guint32 cnr)
     moveresize_client = c;
     start_cx = c->area.x;
     start_cy = c->area.y;
+    start_cw = c->area.width;
+    start_ch = c->area.height;
     /* these adjustments for the size_inc make resizing a terminal more
        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_cw = c->area.width + c->size_inc.width / 2;
-    start_ch = c->area.height + c->size_inc.height / 2;
-    start_x = x;
-    start_y = y;
+    start_x = x - (mv ? 0 : c->size_inc.width / 2);
+    start_y = y - (mv ? 0 : c->size_inc.height / 2);
     corner = cnr;
     button = b;
     key_resize_edge = -1;
@@ -531,7 +531,7 @@ static void move_with_keys(gint keycode, gint state)
 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;
+    gint dist = 0, resist = 0;
     ObDirection dir;
     ObCorner cor;
 
@@ -595,18 +595,30 @@ static void resize_with_keys(gint keycode, gint state)
         gint distw, disth;
 
         /* control means fine grained */
-        if (moveresize_client->size_inc.width > 1)
+        if (moveresize_client->size_inc.width > 1) {
             distw = moveresize_client->size_inc.width;
-        else if (state & modkeys_key_to_mask(OB_MODKEY_KEY_CONTROL))
+            resist = 1;
+        }
+        else if (state & modkeys_key_to_mask(OB_MODKEY_KEY_CONTROL)) {
             distw = 1;
-        else
+            resist = 1;
+        }
+        else {
             distw = KEY_DIST;
-        if (moveresize_client->size_inc.height > 1)
+            resist = KEY_DIST;
+        }
+        if (moveresize_client->size_inc.height > 1) {
             disth = moveresize_client->size_inc.height;
-        else if (state & modkeys_key_to_mask(OB_MODKEY_KEY_CONTROL))
+            resist = 1;
+        }
+        else if (state & modkeys_key_to_mask(OB_MODKEY_KEY_CONTROL)) {
             disth = 1;
-        else
+            resist = 1;
+        }
+        else {
             disth = KEY_DIST;
+            resist = KEY_DIST;
+        }
 
         if (key_resize_edge == OB_DIRECTION_WEST) {
             if (dir == OB_DIRECTION_WEST)
@@ -644,7 +656,7 @@ static void resize_with_keys(gint keycode, gint state)
     else if (key_resize_edge == OB_DIRECTION_SOUTH)
         cor = OB_CORNER_TOPLEFT;
 
-    calc_resize(TRUE, dist, &dw, &dh, cor);
+    calc_resize(TRUE, resist, &dw, &dh, cor);
     if (key_resize_edge == OB_DIRECTION_WEST)
         cur_x -= dw;
     else if (key_resize_edge == OB_DIRECTION_NORTH)
@@ -661,7 +673,7 @@ static void resize_with_keys(gint keycode, gint state)
         pdy = -dh;
     else if (key_resize_edge == OB_DIRECTION_SOUTH)
         pdy = dh;
-    
+
     screen_pointer_pos(&opx, &opy);
     XWarpPointer(ob_display, None, None, 0, 0, 0, 0, pdx, pdy);
     /* steal the motion events this causes */
@@ -716,13 +728,13 @@ gboolean moveresize_event(XEvent *e)
                 lockcorner = OB_CORNER_BOTTOMRIGHT;
             } else if (corner == prop_atoms.net_wm_moveresize_size_top) {
                 dw = 0;
-                dh = (e->xmotion.y_root - start_y);
+                dh = -(e->xmotion.y_root - start_y);
                 lockcorner = OB_CORNER_BOTTOMRIGHT;
             } 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;
-            } else if (corner == prop_atoms.net_wm_moveresize_size_right) { 
+            } else if (corner == prop_atoms.net_wm_moveresize_size_right) {
                 dw = (e->xmotion.x_root - start_x);
                 dh = 0;
                 lockcorner = OB_CORNER_BOTTOMLEFT;
This page took 0.027718 seconds and 4 git commands to generate.