]> Dogcows Code - chaz/openbox/blobdiff - openbox/moveresize.c
make the default screen-edge resistance 20 (double what it is for windows)
[chaz/openbox] / openbox / moveresize.c
index de87d485c707b9cd8c0fc35bd67df873041c8cf9..b43aa57626b942629615643f6b125edb5e60386e 100644 (file)
@@ -79,8 +79,13 @@ void moveresize_start(ObClient *c, int x, int y, guint b, guint32 cnr)
     moveresize_client = c;
     start_cx = c->frame->area.x;
     start_cy = c->frame->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. and this
+       is one large mother fucking comment. */
+    start_cw = c->area.width + (c->size_inc.width + 1) / 2;
+    start_ch = c->area.height + (c->size_inc.height + 1) / 2;
     start_x = x;
     start_y = y;
     corner = cnr;
@@ -164,10 +169,12 @@ static void do_move(gboolean resist)
     Rect *a;
 
     if (resist)
-        resist_move(moveresize_client, &cur_x, &cur_y);
+        resist_move_windows(moveresize_client, &cur_x, &cur_y);
+    resist_move_monitors(moveresize_client, &cur_x, &cur_y);
 
     /* get where the client should be */
     frame_frame_gravity(moveresize_client->frame, &cur_x, &cur_y);
+    g_message("%d %d", cur_x, cur_y);
     client_configure(moveresize_client, OB_CORNER_TOPLEFT, cur_x, cur_y,
                      start_cw, start_ch, TRUE, FALSE);
 
@@ -181,21 +188,21 @@ static void do_move(gboolean resist)
 
 static void do_resize(gboolean resist)
 {
-    if (resist) {
-        /* resist_size needs the frame size */
-        cur_x += moveresize_client->frame->size.left +
-            moveresize_client->frame->size.right;
-        cur_y += moveresize_client->frame->size.top +
-            moveresize_client->frame->size.bottom;
-
-        resist_size(moveresize_client, &cur_x, &cur_y, lockcorner);
-
-        cur_x -= moveresize_client->frame->size.left +
-            moveresize_client->frame->size.right;
-        cur_y -= moveresize_client->frame->size.top +
-            moveresize_client->frame->size.bottom;
-    }
-    
+    /* resist_size_* needs the frame size */
+    cur_x += moveresize_client->frame->size.left +
+        moveresize_client->frame->size.right;
+    cur_y += moveresize_client->frame->size.top +
+        moveresize_client->frame->size.bottom;
+
+    if (resist)
+        resist_size_windows(moveresize_client, &cur_x, &cur_y, lockcorner);
+    resist_size_monitors(moveresize_client, &cur_x, &cur_y, lockcorner);
+
+    cur_x -= moveresize_client->frame->size.left +
+        moveresize_client->frame->size.right;
+    cur_y -= moveresize_client->frame->size.top +
+        moveresize_client->frame->size.bottom;
     client_configure(moveresize_client, lockcorner, 
                      moveresize_client->area.x, moveresize_client->area.y,
                      cur_x, cur_y, TRUE, FALSE);
@@ -222,6 +229,7 @@ void moveresize_event(XEvent *e)
         }
     } else if (e->type == MotionNotify) {
         if (moving) {
+            g_message("root %d start %d", e->xmotion.x_root, start_x);
             cur_x = start_cx + e->xmotion.x_root - start_x;
             cur_y = start_cy + e->xmotion.y_root - start_y;
             do_move(TRUE);
@@ -276,7 +284,7 @@ void moveresize_event(XEvent *e)
             moveresize_end(FALSE);
         else {
             if (corner == prop_atoms.net_wm_moveresize_size_keyboard) {
-                int dx = 0, dy = 0;
+                int dx = 0, dy = 0, ox = cur_x, oy = cur_y;
 
                 if (e->xkey.keycode == ob_keycode(OB_KEY_RIGHT))
                     dx = MAX(4, moveresize_client->size_inc.width);
@@ -292,10 +300,24 @@ void moveresize_event(XEvent *e)
                 cur_x += dx;
                 cur_y += dy;
                 XWarpPointer(ob_display, None, None, 0, 0, 0, 0, dx, dy);
+                /* steal the motion events this causes */
+                XSync(ob_display, FALSE);
+                {
+                    XEvent ce;
+                    while (XCheckTypedEvent(ob_display, MotionNotify, &ce));
+                }
 
                 do_resize(FALSE);
+
+                /* because the cursor moves even though the window does
+                   not nessesarily (resistance), this adjusts where the curor
+                   thinks it started so that it keeps up with where the window
+                   actually is */
+                start_x += dx - (cur_x - ox);
+                start_y += dy - (cur_y - oy);
             } else if (corner == prop_atoms.net_wm_moveresize_move_keyboard) {
-                int dx = 0, dy = 0;
+                int dx = 0, dy = 0, ox = cur_x, oy = cur_y;
+                int opx, px, opy, py;
 
                 if (e->xkey.keycode == ob_keycode(OB_KEY_RIGHT))
                     dx = 4;
@@ -310,9 +332,24 @@ void moveresize_event(XEvent *e)
 
                 cur_x += dx;
                 cur_y += dy;
+                screen_pointer_pos(&opx, &opy);
                 XWarpPointer(ob_display, None, None, 0, 0, 0, 0, dx, dy);
+                /* steal the motion events this causes */
+                XSync(ob_display, FALSE);
+                {
+                    XEvent ce;
+                    while (XCheckTypedEvent(ob_display, MotionNotify, &ce));
+                }
+                screen_pointer_pos(&px, &py);
 
                 do_move(FALSE);
+
+                /* because the cursor moves even though the window does
+                   not nessesarily (resistance), this adjusts where the curor
+                   thinks it started so that it keeps up with where the window
+                   actually is */
+                start_x += (px - opx) - (cur_x - ox);
+                start_y += (py - opy) - (cur_y - oy);
             }
         }
     }
This page took 0.026994 seconds and 4 git commands to generate.