From c7b3817c222952196b11825076c902d6dd1da455 Mon Sep 17 00:00:00 2001 From: Shawn Betts Date: Mon, 13 Apr 2009 05:33:47 -0700 Subject: make ratinfo and ratrelinfo work with ratpoison -c and return coordinates relative to current frame when there's no window * update docs --- doc/ratpoison.1 | 2 +- doc/ratpoison.texi | 2 +- src/actions.c | 20 ++++++++++++-------- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/doc/ratpoison.1 b/doc/ratpoison.1 index 12c31e0..60319a7 100644 --- a/doc/ratpoison.1 +++ b/doc/ratpoison.1 @@ -476,7 +476,7 @@ Quit ratpoison. .cmd ratinfo Display the x y coordinates of the rat cursor relative to the screen. .cmd ratrelinfo -Display the x y coordinates of the rat cursor relative to the window. +Display the x y coordinates of the rat cursor relative to the current window or current frame if no window is focused .cmd ratwarp x y Move the rat cursor to the position (\fIx\fP,\fIy\fP). .cmd ratrelwarp deltax deltay diff --git a/doc/ratpoison.texi b/doc/ratpoison.texi index 179b7e7..afc7d1a 100644 --- a/doc/ratpoison.texi +++ b/doc/ratpoison.texi @@ -1605,7 +1605,7 @@ Display the x y coordinates of the rat cursor relative to the screen. @end deffn @deffn ratrelinfo -Display the x y coordinates of the rat cursor relative to the window. +Display the x y coordinates of the rat cursor relative to the current window or current frame if no window is focused. @end deffn @deffn Command ratrelwarp @var{x} @var{y} diff --git a/src/actions.c b/src/actions.c index 3958938..4099392 100644 --- a/src/actions.c +++ b/src/actions.c @@ -3128,9 +3128,8 @@ cmd_ratinfo (int interactive, struct cmdarg **args) s = current_screen(); XQueryPointer (dpy, s->root, &root_win, &child_win, &mouse_x, &mouse_y, &root_x, &root_y, &mask); - marked_message_printf (0, 0, "%d %d", mouse_x, mouse_y ); - return cmdret_new (RET_SUCCESS, NULL); + return cmdret_new (RET_SUCCESS, "%d %d", mouse_x, mouse_y); } cmdret * @@ -3138,20 +3137,25 @@ cmd_ratrelinfo (int interactive, struct cmdarg **args) { rp_screen *s; rp_window *rpw; + rp_frame *f; Window root_win, child_win; int mouse_x, mouse_y, root_x, root_y; unsigned int mask; s = current_screen(); rpw = current_window(); + f = current_frame(); - if (!rpw) - return cmd_ratinfo (interactive, args); - - XQueryPointer (dpy, rpw->w, &root_win, &child_win, &mouse_x, &mouse_y, &root_x, &root_y, &mask); - marked_message_printf (0, 0, "%d %d", root_x, root_y ); + if (rpw) + XQueryPointer (dpy, rpw->w, &root_win, &child_win, &mouse_x, &mouse_y, &root_x, &root_y, &mask); + else + { + XQueryPointer (dpy, s->root, &root_win, &child_win, &mouse_x, &mouse_y, &root_x, &root_y, &mask); + root_x -= f->x; + root_y -= f->y; + } - return cmdret_new (RET_SUCCESS, NULL); + return cmdret_new (RET_SUCCESS, "%d %d", root_x, root_y); } cmdret * -- cgit v1.2.3