+static void move_with_keys(gint keycode, gint state)
+{
+ gint dx = 0, dy = 0, ox = cur_x, oy = cur_y;
+ gint opx, px, opy, py;
+ gint dist = 0;
+
+ /* shift means jump to edge */
+ if (state & modkeys_key_to_mask(OB_MODKEY_KEY_SHIFT)) {
+ gint x, y;
+ ObDirection dir;
+
+ if (keycode == ob_keycode(OB_KEY_RIGHT))
+ dir = OB_DIRECTION_EAST;
+ else if (keycode == ob_keycode(OB_KEY_LEFT))
+ dir = OB_DIRECTION_WEST;
+ else if (keycode == ob_keycode(OB_KEY_DOWN))
+ dir = OB_DIRECTION_SOUTH;
+ else /* if (keycode == ob_keycode(OB_KEY_UP)) */
+ dir = OB_DIRECTION_NORTH;
+
+ client_find_move_directional(moveresize_client, dir, &x, &y);
+ dx = x - moveresize_client->area.x;
+ dy = y - moveresize_client->area.y;
+ } else {
+ /* control means fine grained */
+ if (state & modkeys_key_to_mask(OB_MODKEY_KEY_CONTROL))
+ dist = 1;
+ else
+ dist = KEY_DIST;
+
+ if (keycode == ob_keycode(OB_KEY_RIGHT))
+ dx = dist;
+ else if (keycode == ob_keycode(OB_KEY_LEFT))
+ dx = -dist;
+ else if (keycode == ob_keycode(OB_KEY_DOWN))
+ dy = dist;
+ else /* if (keycode == ob_keycode(OB_KEY_UP)) */
+ dy = -dist;
+ }
+
+ 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);
+
+ cur_x += dx;
+ cur_y += dy;
+ do_move(TRUE, dist);
+
+ /* 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);
+}
+