emacs-diffs
[Top][All Lists]
Advanced

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

master 6058daedf7: Pass core scroll wheel events outside the edit widget


From: Po Lu
Subject: master 6058daedf7: Pass core scroll wheel events outside the edit widget to Emacs on GTK
Date: Thu, 3 Mar 2022 20:44:38 -0500 (EST)

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

    Pass core scroll wheel events outside the edit widget to Emacs on GTK
    
    * src/xterm.c (x_construct_mouse_click): Translate coordinates
    if the event window is not the edit widget window.
    (handle_one_xevent): Treat core scroll wheel events specially,
    if mouse_or_wdesc_frame did not find the frame.
---
 src/xterm.c | 45 +++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 43 insertions(+), 2 deletions(-)

diff --git a/src/xterm.c b/src/xterm.c
index 2563fb31a5..b9a4328c29 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -6813,6 +6813,10 @@ x_construct_mouse_click (struct input_event *result,
                          const XButtonEvent *event,
                          struct frame *f)
 {
+  int x = event->x;
+  int y = event->y;
+  Window dummy;
+
   /* Make the event type NO_EVENT; we'll change that when we decide
      otherwise.  */
   result->kind = MOUSE_CLICK_EVENT;
@@ -6824,8 +6828,16 @@ x_construct_mouse_click (struct input_event *result,
                          ? up_modifier
                          : down_modifier));
 
-  XSETINT (result->x, event->x);
-  XSETINT (result->y, event->y);
+  /* If result->window is not the frame's edit widget (which can
+     happen with GTK+ scroll bars, for example), translate the
+     coordinates so they appear at the correct position.  */
+  if (event->window != FRAME_X_WINDOW (f))
+    XTranslateCoordinates (FRAME_X_DISPLAY (f),
+                          event->window, FRAME_X_WINDOW (f),
+                          x, y, &x, &y, &dummy);
+
+  XSETINT (result->x, x);
+  XSETINT (result->y, y);
   XSETFRAME (result->frame_or_window, f);
   result->arg = Qnil;
   return Qnil;
@@ -11275,6 +11287,35 @@ handle_one_xevent (struct x_display_info *dpyinfo,
          }
 
 #ifdef USE_GTK
+       if (!f)
+         {
+           f = x_any_window_to_frame (dpyinfo, event->xbutton.window);
+
+           if (event->xbutton.button > 3
+               && event->xbutton.button < 9
+               && f)
+             {
+               if (ignore_next_mouse_click_timeout)
+                 {
+                   if (event->type == ButtonPress
+                       && event->xbutton.time > 
ignore_next_mouse_click_timeout)
+                     {
+                       ignore_next_mouse_click_timeout = 0;
+                       x_construct_mouse_click (&inev.ie, &event->xbutton, f);
+                     }
+                   if (event->type == ButtonRelease)
+                     ignore_next_mouse_click_timeout = 0;
+                 }
+               else
+                 x_construct_mouse_click (&inev.ie, &event->xbutton, f);
+
+               *finish = X_EVENT_DROP;
+               goto OTHER;
+             }
+           else
+             f = NULL;
+         }
+
         if (f && xg_event_is_for_scrollbar (f, event, false))
           f = 0;
 #endif



reply via email to

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