- if (e->xkey.keycode == button_right)
- cur_x += MAX(4, moveresize_client->size_inc.width);
- else if (e->xkey.keycode == button_left)
- cur_x -= MAX(4, moveresize_client->size_inc.width);
- else if (e->xkey.keycode == button_down)
- cur_y += MAX(4, moveresize_client->size_inc.height);
- else if (e->xkey.keycode == button_up)
- cur_y -= MAX(4, moveresize_client->size_inc.height);
- else
- return;
- do_resize();
+ gint 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);
+ else if (e->xkey.keycode == ob_keycode(OB_KEY_LEFT))
+ dx = -MAX(4, moveresize_client->size_inc.width);
+ else if (e->xkey.keycode == ob_keycode(OB_KEY_DOWN))
+ dy = MAX(4, moveresize_client->size_inc.height);
+ else /* if (e->xkey.keycode == ob_keycode(OB_KEY_UP)) */
+ dy = -MAX(4, moveresize_client->size_inc.height);
+
+ 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);
+
+ used = TRUE;