Commit b0358ef8 authored by Dmitry Antipov's avatar Dmitry Antipov

* 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.
parent 38852a76
2014-06-22 Dmitry Antipov <dmantipov@yandex.ru>
* 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.
2014-06-21 Eli Zaretskii <eliz@gnu.org>
* indent.c (Fvertical_motion): Doc fix.
......
......@@ -1233,7 +1233,7 @@ no quit occurs and `x-popup-menu' returns nil. */)
{
int cur_x, cur_y;
mouse_position_for_popup (new_f, &cur_x, &cur_y);
x_relative_mouse_position (new_f, &cur_x, &cur_y);
/* cur_x/y may be negative, so use make_number. */
x = make_number (cur_x);
y = make_number (cur_y);
......
......@@ -54,9 +54,6 @@ extern widget_value *make_widget_value (const char *, char *, bool, Lisp_Object)
extern widget_value *digest_single_submenu (int, int, bool);
#endif
#ifdef HAVE_X_WINDOWS
extern void mouse_position_for_popup (struct frame *f, int *x, int *y);
#endif
#if defined (HAVE_X_WINDOWS) || defined (MSDOS)
extern Lisp_Object x_menu_show (struct frame *, int, int, int,
Lisp_Object, const char **);
......
......@@ -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. */
......
......@@ -139,53 +139,6 @@ menubar_id_to_frame (LWLIB_ID id)
}
#endif
#ifdef HAVE_X_WINDOWS
/* Return the mouse position in *X and *Y. The coordinates are window
relative for the edit window in frame F.
This is for Fx_popup_menu. The mouse_position_hook can not
be used for X, as it returns window relative coordinates
for the window where the mouse is in. This could be the menu bar,
the scroll bar or the edit window. Fx_popup_menu needs to be
sure it is the edit window. */
void
mouse_position_for_popup (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 ();
/* x_menu_show expects window coordinates, not root window
coordinates. Translate. */
*x -= f->left_pos + FRAME_OUTER_TO_INNER_DIFF_X (f);
*y -= f->top_pos + FRAME_OUTER_TO_INNER_DIFF_Y (f);
}
#endif /* HAVE_X_WINDOWS */
#ifndef MSDOS
......
......@@ -2373,43 +2373,6 @@ x_property_data_to_lisp (struct frame *f, const unsigned char *data,
data, size * format_bytes, type, format);
}
/* Get the mouse position in frame relative coordinates. */
static void
mouse_position_for_drop (struct frame *f, int *x, int *y)
{
Window root, dummy_window;
int dummy;
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);
/* Absolute to relative. */
*x -= f->left_pos + FRAME_OUTER_TO_INNER_DIFF_X (f);
*y -= f->top_pos + FRAME_OUTER_TO_INNER_DIFF_Y (f);
unblock_input ();
}
DEFUN ("x-get-atom-name", Fx_get_atom_name,
Sx_get_atom_name, 1, 2, 0,
doc: /* Return the X atom name for VALUE as a string.
......@@ -2529,7 +2492,7 @@ x_handle_dnd_message (struct frame *f, const XClientMessageEvent *event,
event->format,
size));
mouse_position_for_drop (f, &x, &y);
x_relative_mouse_position (f, &x, &y);
bufp->kind = DRAG_N_DROP_EVENT;
bufp->frame_or_window = frame;
bufp->timestamp = CurrentTime;
......
......@@ -358,8 +358,10 @@ x_find_topmost_parent (struct frame *f)
unsigned int nchildren;
win = wi;
XQueryTree (dpy, win, &root, &wi, &children, &nchildren);
XFree (children);
if (XQueryTree (dpy, win, &root, &wi, &children, &nchildren))
XFree (children);
else
break;
}
return win;
......
......@@ -914,6 +914,7 @@ struct selection_input_event
/* From xfns.c. */
extern void x_free_gcs (struct frame *);
extern void x_relative_mouse_position (struct frame *, int *, int *);
/* From xrdb.c. */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment