emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] trunk r117375: * xmenu.c (mouse_position_for_popup):


From: Dmitry Antipov
Subject: [Emacs-diffs] trunk r117375: * xmenu.c (mouse_position_for_popup):
Date: Sun, 22 Jun 2014 05:01:18 +0000
User-agent: Bazaar (2.6b2)

------------------------------------------------------------
revno: 117375
revision-id: address@hidden
parent: address@hidden
committer: Dmitry Antipov <address@hidden>
branch nick: trunk
timestamp: Sun 2014-06-22 09:00:14 +0400
message:
  * 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.
modified:
  src/ChangeLog                  changelog-20091113204419-o5vbwnq5f7feedwu-1438
  src/menu.c                     menu.c-20091113204419-o5vbwnq5f7feedwu-8676
  src/menu.h                     menu.h-20091113204419-o5vbwnq5f7feedwu-8702
  src/xfns.c                     xfns.c-20091113204419-o5vbwnq5f7feedwu-274
  src/xmenu.c                    xmenu.c-20091113204419-o5vbwnq5f7feedwu-161
  src/xselect.c                  xselect.c-20091113204419-o5vbwnq5f7feedwu-543
  src/xterm.c                    xterm.c-20091113204419-o5vbwnq5f7feedwu-244
  src/xterm.h                    xterm.h-20091113204419-o5vbwnq5f7feedwu-228
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog     2014-06-21 19:45:59 +0000
+++ b/src/ChangeLog     2014-06-22 05:00:14 +0000
@@ -1,3 +1,15 @@
+2014-06-22  Dmitry Antipov  <address@hidden>
+
+       * 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  <address@hidden>
 
        * indent.c (Fvertical_motion): Doc fix.

=== modified file 'src/menu.c'
--- a/src/menu.c        2014-06-13 14:42:43 +0000
+++ b/src/menu.c        2014-06-22 05:00:14 +0000
@@ -1233,7 +1233,7 @@
          {
            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);

=== modified file 'src/menu.h'
--- a/src/menu.h        2014-06-08 18:27:22 +0000
+++ b/src/menu.h        2014-06-22 05:00:14 +0000
@@ -54,9 +54,6 @@
 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 **);

=== modified file 'src/xfns.c'
--- a/src/xfns.c        2014-06-17 16:09:19 +0000
+++ b/src/xfns.c        2014-06-22 05:00:14 +0000
@@ -330,8 +330,43 @@
   *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.  */
 

=== modified file 'src/xmenu.c'
--- a/src/xmenu.c       2014-06-08 18:27:22 +0000
+++ b/src/xmenu.c       2014-06-22 05:00:14 +0000
@@ -139,53 +139,6 @@
 }
 
 #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
 

=== modified file 'src/xselect.c'
--- a/src/xselect.c     2014-01-01 07:43:34 +0000
+++ b/src/xselect.c     2014-06-22 05:00:14 +0000
@@ -2373,43 +2373,6 @@
                                      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 @@
                                         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;

=== modified file 'src/xterm.c'
--- a/src/xterm.c       2014-06-17 16:09:19 +0000
+++ b/src/xterm.c       2014-06-22 05:00:14 +0000
@@ -358,8 +358,10 @@
       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;

=== modified file 'src/xterm.h'
--- a/src/xterm.h       2014-06-17 16:09:19 +0000
+++ b/src/xterm.h       2014-06-22 05:00:14 +0000
@@ -914,6 +914,7 @@
 /* From xfns.c.  */
 
 extern void x_free_gcs (struct frame *);
+extern void x_relative_mouse_position (struct frame *, int *, int *);
 
 /* From xrdb.c.  */
 


reply via email to

[Prev in Thread] Current Thread [Next in Thread]