summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShawn Betts <sabetts@gmail.com>2009-04-13 05:33:47 -0700
committerShawn Betts <sabetts@gmail.com>2009-04-13 05:33:47 -0700
commitc7b3817c222952196b11825076c902d6dd1da455 (patch)
treecc974ae03a4d81818551df347479f10b369e0379
parentbd7aa51699f49cf7a67c403ba7f2ba3738fcf644 (diff)
downloadratpoison-c7b3817c222952196b11825076c902d6dd1da455.zip
make ratinfo and ratrelinfo work with ratpoison -c and return coordinates relative to current frame when there's no window
* update docs
-rw-r--r--doc/ratpoison.12
-rw-r--r--doc/ratpoison.texi2
-rw-r--r--src/actions.c20
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 *