summaryrefslogtreecommitdiff
path: root/mcwm.c
diff options
context:
space:
mode:
authorMichael Cardell Widerkrantz <mc@hack.org>2010-07-17 23:34:27 +0200
committerMichael Cardell Widerkrantz <mc@hack.org>2010-07-17 23:34:27 +0200
commit32753c6361efe893005572939ac08488fe9f4183 (patch)
tree30642baf8699d03637a1d36403c94c9c0fd9aa20 /mcwm.c
parent6c7b8997d94e948b91c874a4352a031ba3eaf408 (diff)
downloadmcwm-32753c6361efe893005572939ac08488fe9f4183.zip
Keep pointer position relative window when moving with keyboard.
Diffstat (limited to 'mcwm.c')
-rw-r--r--mcwm.c30
1 files changed, 23 insertions, 7 deletions
diff --git a/mcwm.c b/mcwm.c
index 64559d9..394c7b6 100644
--- a/mcwm.c
+++ b/mcwm.c
@@ -1537,10 +1537,13 @@ void mouseresize(xcb_drawable_t win, int rel_x, int rel_y)
void movestep(struct client *client, char direction)
{
xcb_get_geometry_reply_t *geom;
- int x;
- int y;
- int width;
- int height;
+ xcb_query_pointer_reply_t *pointer;
+ int16_t start_x;
+ int16_t start_y;
+ int16_t x;
+ int16_t y;
+ uint16_t width;
+ uint16_t height;
xcb_drawable_t win;
if (NULL == client)
@@ -1549,6 +1552,19 @@ void movestep(struct client *client, char direction)
}
win = client->id;
+
+ pointer = xcb_query_pointer_reply(
+ conn, xcb_query_pointer(conn, win), 0);
+
+ if (NULL == pointer)
+ {
+ return;
+ }
+
+ start_x = pointer->win_x;
+ start_y = pointer->win_y;
+
+ free(pointer);
raisewindow(win);
@@ -1611,9 +1627,9 @@ void movestep(struct client *client, char direction)
break;
} /* switch direction */
- /* Move cursor into the middle of the window after moving. */
+ /* Move pointer back to where it was, relative to the window. */
xcb_warp_pointer(conn, XCB_NONE, win, 0, 0, 0, 0,
- width / 2, height / 2);
+ start_x, start_y);
xcb_flush(conn);
@@ -1990,7 +2006,7 @@ void events(void)
}
else
{
- xcb_query_pointer_reply_t *pointer;
+ xcb_query_pointer_reply_t *pointer;
/* We're moving or resizing. */