diff options
author | Dmitry Antipov <dmantipov@yandex.ru> | 2014-06-22 09:00:14 +0400 |
---|---|---|
committer | Dmitry Antipov <dmantipov@yandex.ru> | 2014-06-22 09:00:14 +0400 |
commit | b0358ef86903ac021110b54ee1acce11211c200f (patch) | |
tree | a57eaedb410d4ba6d838fcf1fb188716f08a1eed /src/xfns.c | |
parent | 38852a76958ec456e01420ae2b26240d9f3bc63c (diff) | |
download | emacs-b0358ef86903ac021110b54ee1acce11211c200f.tar.gz |
* xmenu.c (mouse_position_for_popup):
* xselect.c (mouse_position_for_drop): Do not duplicate ...
* xfns.c (x_relative_mouse_position): ... and prefer this function.
* menu.c (Fx_popup_menu):
* xselect.c (x_handle_dnd_message): Adjust users.
* menu.h (mouse_position_for_popup): Remove prototype.
* xterm.h (x_relative_mouse_position): Add prototype.
* xterm.c (x_find_topmost_parent): Break from the loop and do not
call XFree if XQueryTree returns zero.
Diffstat (limited to 'src/xfns.c')
-rw-r--r-- | src/xfns.c | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/src/xfns.c b/src/xfns.c index a7caa53e522..c3d9900207f 100644 --- a/src/xfns.c +++ b/src/xfns.c @@ -330,8 +330,43 @@ x_real_positions (struct frame *f, int *xptr, int *yptr) *yptr = real_y; } - +/* Get the mouse position in frame relative coordinates. */ + +void +x_relative_mouse_position (struct frame *f, int *x, int *y) +{ + Window root, dummy_window; + int dummy; + + eassert (FRAME_X_P (f)); + + block_input (); + + XQueryPointer (FRAME_X_DISPLAY (f), + DefaultRootWindow (FRAME_X_DISPLAY (f)), + /* The root window which contains the pointer. */ + &root, + + /* Window pointer is on, not used */ + &dummy_window, + + /* The position on that root window. */ + x, y, + + /* x/y in dummy_window coordinates, not used. */ + &dummy, &dummy, + + /* Modifier keys and pointer buttons, about which + we don't care. */ + (unsigned int *) &dummy); + + unblock_input (); + + /* Translate root window coordinates to window coordinates. */ + *x -= f->left_pos + FRAME_OUTER_TO_INNER_DIFF_X (f); + *y -= f->top_pos + FRAME_OUTER_TO_INNER_DIFF_Y (f); +} /* Gamma-correct COLOR on frame F. */ |