]> git.eshelyaron.com Git - emacs.git/commitdiff
Pass core scroll wheel events outside the edit widget to Emacs on GTK
authorPo Lu <luangruo@yahoo.com>
Fri, 4 Mar 2022 01:42:33 +0000 (09:42 +0800)
committerPo Lu <luangruo@yahoo.com>
Fri, 4 Mar 2022 01:43:52 +0000 (09:43 +0800)
* 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

index 2563fb31a5e8cfdc77a36596b511be7cf83ea796..b9a4328c29226c0939243404fce8e7d18db7f4c5 100644 (file)
@@ -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