emacs-diffs
[Top][All Lists]
Advanced

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

master b90192b50e: Fix more calls to XQueryPointer for MPX


From: Po Lu
Subject: master b90192b50e: Fix more calls to XQueryPointer for MPX
Date: Thu, 18 Aug 2022 22:06:44 -0400 (EDT)

branch: master
commit b90192b50e59ff987ef2102c1538e94b7864b1fd
Author: Po Lu <luangruo@yahoo.com>
Commit: Po Lu <luangruo@yahoo.com>

    Fix more calls to XQueryPointer for MPX
    
    * src/xterm.c (x_dnd_begin_drag_and_drop): Set DND devices to -1
    if XI2 is not supported on the given display.
    (x_query_pointer): Make wrapper around x_query_pointer_1.
    (x_query_pointer_1): Split off most of x_query_pointer to this
    function.  Allow a specific client pointer to be specified.
    (x_dnd_update_tooltip_now, x_dnd_update_state): Use
    x_query_pointer_1 with the right device instead of
    XQueryPointer.
---
 src/xterm.c | 77 +++++++++++++++++++++++++++++++++++++++++++++++--------------
 1 file changed, 60 insertions(+), 17 deletions(-)

diff --git a/src/xterm.c b/src/xterm.c
index a329ca59d0..12c7b7d4dc 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -12186,6 +12186,11 @@ x_dnd_begin_drag_and_drop (struct frame *f, Time time, 
Atom xaction,
       if (device)
        x_dnd_keyboard_device = device->attachment;
     }
+  else
+    {
+      x_dnd_pointer_device = -1;
+      x_dnd_keyboard_device = -1;
+    }
 
 #endif
 
@@ -13401,18 +13406,17 @@ get_keysym_name (int keysym)
   return value;
 }
 
-/* Like XQueryPointer, but always use the right client pointer
-   device.  */
-
-Bool
-x_query_pointer (Display *dpy, Window w, Window *root_return,
-                Window *child_return, int *root_x_return,
-                int *root_y_return, int *win_x_return,
-                int *win_y_return, unsigned int *mask_return)
+static Bool
+x_query_pointer_1 (struct x_display_info *dpyinfo,
+                  int client_pointer_device, Window w,
+                  Window *root_return, Window *child_return,
+                  int *root_x_return, int *root_y_return,
+                  int *win_x_return, int *win_y_return,
+                  unsigned int *mask_return)
 {
   Bool rc;
+  Display *dpy;
 #ifdef HAVE_XINPUT2
-  struct x_display_info *dpyinfo;
   bool had_errors;
   XIModifierState modifiers;
   XIButtonState buttons;
@@ -13421,9 +13425,10 @@ x_query_pointer (Display *dpy, Window w, Window 
*root_return,
   unsigned int state;
 #endif
 
+  dpy = dpyinfo->display;
+
 #ifdef HAVE_XINPUT2
-  dpyinfo = x_display_info_for_display (dpy);
-  if (dpyinfo && dpyinfo->client_pointer_device != -1)
+  if (client_pointer_device != -1)
     {
       /* Catch errors caused by the device going away.  This is not
         very expensive, since XIQueryPointer will sync anyway.  */
@@ -13463,6 +13468,31 @@ x_query_pointer (Display *dpy, Window w, Window 
*root_return,
   return rc;
 }
 
+Bool
+x_query_pointer (Display *dpy, Window w, Window *root_return,
+                Window *child_return, int *root_x_return,
+                int *root_y_return, int *win_x_return,
+                int *win_y_return, unsigned int *mask_return)
+{
+  struct x_display_info *dpyinfo;
+
+  dpyinfo = x_display_info_for_display (dpy);
+
+  if (!dpyinfo)
+    emacs_abort ();
+
+#ifdef HAVE_XINPUT2
+  return x_query_pointer_1 (dpyinfo, dpyinfo->client_pointer_device,
+                           w, root_return, child_return, root_x_return,
+                           root_y_return, win_x_return, win_y_return,
+                           mask_return);
+#else
+  return x_query_pointer_1 (dpyinfo, -1, w, root_return, child_return,
+                           root_x_return, root_y_return, win_x_return,
+                           win_y_return, mask_return);
+#endif
+}
+
 /* Mouse clicks and mouse movement.  Rah.
 
    Formerly, we used PointerMotionHintMask (in standard_event_mask)
@@ -16902,11 +16932,19 @@ x_dnd_update_tooltip_now (void)
 
   dpyinfo = FRAME_DISPLAY_INFO (x_dnd_frame);
 
+#ifndef HAVE_XINPUT2
   rc = XQueryPointer (dpyinfo->display,
                      dpyinfo->root_window,
                      &root, &child, &root_x,
                      &root_y, &win_x, &win_y,
                      &mask);
+#else
+  rc = x_query_pointer_1 (dpyinfo, x_dnd_pointer_device,
+                         dpyinfo->root_window,
+                         &root, &child, &root_x,
+                         &root_y, &win_x, &win_y,
+                         &mask);
+#endif
 
   if (rc)
     x_dnd_update_tooltip_position (root_x, root_y);
@@ -16926,12 +16964,17 @@ x_dnd_update_state (struct x_display_info *dpyinfo, 
Time timestamp)
   xm_drop_start_message dsmsg;
   bool was_frame;
 
-  if (XQueryPointer (dpyinfo->display,
-                    dpyinfo->root_window,
-                    &dummy, &dummy_child,
-                    &root_x, &root_y,
-                    &dummy_x, &dummy_y,
-                    &dummy_mask))
+  if (x_query_pointer_1 (dpyinfo,
+#ifdef HAVE_XINPUT2
+                        x_dnd_pointer_device,
+#else
+                        -1,
+#endif
+                        dpyinfo->root_window,
+                        &dummy, &dummy_child,
+                        &root_x, &root_y,
+                        &dummy_x, &dummy_y,
+                        &dummy_mask))
     {
       target = x_dnd_get_target_window (dpyinfo, root_x,
                                        root_y, &target_proto,



reply via email to

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