- if (e->xkey.keycode == button_right)
- cur_x += 4;
- else if (e->xkey.keycode == button_left)
- cur_x -= 4;
- else if (e->xkey.keycode == button_down)
- cur_y += 4;
- else if (e->xkey.keycode == button_up)
- cur_y -= 4;
- else
- return;
- do_move();
+ gint dx = 0, dy = 0, ox = cur_x, oy = cur_y;
+ gint opx, px, opy, py;
+
+ if (e->xkey.keycode == ob_keycode(OB_KEY_RIGHT))
+ dx = KEY_DIST;
+ else if (e->xkey.keycode == ob_keycode(OB_KEY_LEFT))
+ dx = -KEY_DIST;
+ else if (e->xkey.keycode == ob_keycode(OB_KEY_DOWN))
+ dy = KEY_DIST;
+ else /* if (e->xkey.keycode == ob_keycode(OB_KEY_UP)) */
+ dy = -KEY_DIST;
+
+ 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(TRUE);
+
+ /* 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);
+
+ used = TRUE;