aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDmitry Antipov2014-06-22 09:00:14 +0400
committerDmitry Antipov2014-06-22 09:00:14 +0400
commitb0358ef86903ac021110b54ee1acce11211c200f (patch)
treea57eaedb410d4ba6d838fcf1fb188716f08a1eed /src
parent38852a76958ec456e01420ae2b26240d9f3bc63c (diff)
downloademacs-b0358ef86903ac021110b54ee1acce11211c200f.tar.gz
emacs-b0358ef86903ac021110b54ee1acce11211c200f.zip
* 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')
-rw-r--r--src/ChangeLog12
-rw-r--r--src/menu.c2
-rw-r--r--src/menu.h3
-rw-r--r--src/xfns.c37
-rw-r--r--src/xmenu.c47
-rw-r--r--src/xselect.c39
-rw-r--r--src/xterm.c6
-rw-r--r--src/xterm.h1
8 files changed, 55 insertions, 92 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index c845568ddcf..ca45462cab3 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,15 @@
12014-06-22 Dmitry Antipov <dmantipov@yandex.ru>
2
3 * xmenu.c (mouse_position_for_popup):
4 * xselect.c (mouse_position_for_drop): Do not duplicate ...
5 * xfns.c (x_relative_mouse_position): ... and prefer this function.
6 * menu.c (Fx_popup_menu):
7 * xselect.c (x_handle_dnd_message): Adjust users.
8 * menu.h (mouse_position_for_popup): Remove prototype.
9 * xterm.h (x_relative_mouse_position): Add prototype.
10 * xterm.c (x_find_topmost_parent): Break from the loop and do not
11 call XFree if XQueryTree returns zero.
12
12014-06-21 Eli Zaretskii <eliz@gnu.org> 132014-06-21 Eli Zaretskii <eliz@gnu.org>
2 14
3 * indent.c (Fvertical_motion): Doc fix. 15 * indent.c (Fvertical_motion): Doc fix.
diff --git a/src/menu.c b/src/menu.c
index 460dc7967b5..a523cfc6010 100644
--- a/src/menu.c
+++ b/src/menu.c
@@ -1233,7 +1233,7 @@ no quit occurs and `x-popup-menu' returns nil. */)
1233 { 1233 {
1234 int cur_x, cur_y; 1234 int cur_x, cur_y;
1235 1235
1236 mouse_position_for_popup (new_f, &cur_x, &cur_y); 1236 x_relative_mouse_position (new_f, &cur_x, &cur_y);
1237 /* cur_x/y may be negative, so use make_number. */ 1237 /* cur_x/y may be negative, so use make_number. */
1238 x = make_number (cur_x); 1238 x = make_number (cur_x);
1239 y = make_number (cur_y); 1239 y = make_number (cur_y);
diff --git a/src/menu.h b/src/menu.h
index 643ff40fef8..30a89bead26 100644
--- a/src/menu.h
+++ b/src/menu.h
@@ -54,9 +54,6 @@ extern widget_value *make_widget_value (const char *, char *, bool, Lisp_Object)
54extern widget_value *digest_single_submenu (int, int, bool); 54extern widget_value *digest_single_submenu (int, int, bool);
55#endif 55#endif
56 56
57#ifdef HAVE_X_WINDOWS
58extern void mouse_position_for_popup (struct frame *f, int *x, int *y);
59#endif
60#if defined (HAVE_X_WINDOWS) || defined (MSDOS) 57#if defined (HAVE_X_WINDOWS) || defined (MSDOS)
61extern Lisp_Object x_menu_show (struct frame *, int, int, int, 58extern Lisp_Object x_menu_show (struct frame *, int, int, int,
62 Lisp_Object, const char **); 59 Lisp_Object, const char **);
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)
330 *yptr = real_y; 330 *yptr = real_y;
331} 331}
332 332
333 333/* Get the mouse position in frame relative coordinates. */
334
335void
336x_relative_mouse_position (struct frame *f, int *x, int *y)
337{
338 Window root, dummy_window;
339 int dummy;
340
341 eassert (FRAME_X_P (f));
342
343 block_input ();
344
345 XQueryPointer (FRAME_X_DISPLAY (f),
346 DefaultRootWindow (FRAME_X_DISPLAY (f)),
334 347
348 /* The root window which contains the pointer. */
349 &root,
350
351 /* Window pointer is on, not used */
352 &dummy_window,
353
354 /* The position on that root window. */
355 x, y,
356
357 /* x/y in dummy_window coordinates, not used. */
358 &dummy, &dummy,
359
360 /* Modifier keys and pointer buttons, about which
361 we don't care. */
362 (unsigned int *) &dummy);
363
364 unblock_input ();
365
366 /* Translate root window coordinates to window coordinates. */
367 *x -= f->left_pos + FRAME_OUTER_TO_INNER_DIFF_X (f);
368 *y -= f->top_pos + FRAME_OUTER_TO_INNER_DIFF_Y (f);
369}
335 370
336/* Gamma-correct COLOR on frame F. */ 371/* Gamma-correct COLOR on frame F. */
337 372
diff --git a/src/xmenu.c b/src/xmenu.c
index 2d41350e737..e04a801ef71 100644
--- a/src/xmenu.c
+++ b/src/xmenu.c
@@ -139,53 +139,6 @@ menubar_id_to_frame (LWLIB_ID id)
139} 139}
140 140
141#endif 141#endif
142
143#ifdef HAVE_X_WINDOWS
144/* Return the mouse position in *X and *Y. The coordinates are window
145 relative for the edit window in frame F.
146 This is for Fx_popup_menu. The mouse_position_hook can not
147 be used for X, as it returns window relative coordinates
148 for the window where the mouse is in. This could be the menu bar,
149 the scroll bar or the edit window. Fx_popup_menu needs to be
150 sure it is the edit window. */
151void
152mouse_position_for_popup (struct frame *f, int *x, int *y)
153{
154 Window root, dummy_window;
155 int dummy;
156
157 eassert (FRAME_X_P (f));
158
159 block_input ();
160
161 XQueryPointer (FRAME_X_DISPLAY (f),
162 DefaultRootWindow (FRAME_X_DISPLAY (f)),
163
164 /* The root window which contains the pointer. */
165 &root,
166
167 /* Window pointer is on, not used */
168 &dummy_window,
169
170 /* The position on that root window. */
171 x, y,
172
173 /* x/y in dummy_window coordinates, not used. */
174 &dummy, &dummy,
175
176 /* Modifier keys and pointer buttons, about which
177 we don't care. */
178 (unsigned int *) &dummy);
179
180 unblock_input ();
181
182 /* x_menu_show expects window coordinates, not root window
183 coordinates. Translate. */
184 *x -= f->left_pos + FRAME_OUTER_TO_INNER_DIFF_X (f);
185 *y -= f->top_pos + FRAME_OUTER_TO_INNER_DIFF_Y (f);
186}
187
188#endif /* HAVE_X_WINDOWS */
189 142
190#ifndef MSDOS 143#ifndef MSDOS
191 144
diff --git a/src/xselect.c b/src/xselect.c
index 28f2d770a77..89ec1da30b2 100644
--- a/src/xselect.c
+++ b/src/xselect.c
@@ -2373,43 +2373,6 @@ x_property_data_to_lisp (struct frame *f, const unsigned char *data,
2373 data, size * format_bytes, type, format); 2373 data, size * format_bytes, type, format);
2374} 2374}
2375 2375
2376/* Get the mouse position in frame relative coordinates. */
2377
2378static void
2379mouse_position_for_drop (struct frame *f, int *x, int *y)
2380{
2381 Window root, dummy_window;
2382 int dummy;
2383
2384 block_input ();
2385
2386 XQueryPointer (FRAME_X_DISPLAY (f),
2387 DefaultRootWindow (FRAME_X_DISPLAY (f)),
2388
2389 /* The root window which contains the pointer. */
2390 &root,
2391
2392 /* Window pointer is on, not used */
2393 &dummy_window,
2394
2395 /* The position on that root window. */
2396 x, y,
2397
2398 /* x/y in dummy_window coordinates, not used. */
2399 &dummy, &dummy,
2400
2401 /* Modifier keys and pointer buttons, about which
2402 we don't care. */
2403 (unsigned int *) &dummy);
2404
2405
2406 /* Absolute to relative. */
2407 *x -= f->left_pos + FRAME_OUTER_TO_INNER_DIFF_X (f);
2408 *y -= f->top_pos + FRAME_OUTER_TO_INNER_DIFF_Y (f);
2409
2410 unblock_input ();
2411}
2412
2413DEFUN ("x-get-atom-name", Fx_get_atom_name, 2376DEFUN ("x-get-atom-name", Fx_get_atom_name,
2414 Sx_get_atom_name, 1, 2, 0, 2377 Sx_get_atom_name, 1, 2, 0,
2415 doc: /* Return the X atom name for VALUE as a string. 2378 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,
2529 event->format, 2492 event->format,
2530 size)); 2493 size));
2531 2494
2532 mouse_position_for_drop (f, &x, &y); 2495 x_relative_mouse_position (f, &x, &y);
2533 bufp->kind = DRAG_N_DROP_EVENT; 2496 bufp->kind = DRAG_N_DROP_EVENT;
2534 bufp->frame_or_window = frame; 2497 bufp->frame_or_window = frame;
2535 bufp->timestamp = CurrentTime; 2498 bufp->timestamp = CurrentTime;
diff --git a/src/xterm.c b/src/xterm.c
index c817174bb3f..a7f77bdb282 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -358,8 +358,10 @@ x_find_topmost_parent (struct frame *f)
358 unsigned int nchildren; 358 unsigned int nchildren;
359 359
360 win = wi; 360 win = wi;
361 XQueryTree (dpy, win, &root, &wi, &children, &nchildren); 361 if (XQueryTree (dpy, win, &root, &wi, &children, &nchildren))
362 XFree (children); 362 XFree (children);
363 else
364 break;
363 } 365 }
364 366
365 return win; 367 return win;
diff --git a/src/xterm.h b/src/xterm.h
index 6f6441a7f68..6d80d1253ae 100644
--- a/src/xterm.h
+++ b/src/xterm.h
@@ -914,6 +914,7 @@ struct selection_input_event
914/* From xfns.c. */ 914/* From xfns.c. */
915 915
916extern void x_free_gcs (struct frame *); 916extern void x_free_gcs (struct frame *);
917extern void x_relative_mouse_position (struct frame *, int *, int *);
917 918
918/* From xrdb.c. */ 919/* From xrdb.c. */
919 920