]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix reporting of wheel events on top of GTK scroll bars
authorPo Lu <luangruo@yahoo.com>
Tue, 1 Mar 2022 10:38:08 +0000 (18:38 +0800)
committerPo Lu <luangruo@yahoo.com>
Tue, 1 Mar 2022 10:38:08 +0000 (18:38 +0800)
* src/gtkutil.c (xg_update_scrollbar_pos):
(xg_update_horizontal_scrollbar_pos): Stop ensuring the window
is native.
(xg_event_is_for_scrollbar): New variable `for_valuator'.
All callers changed.
* src/gtkutil.h: Update prototypes.
* src/xterm.c (handle_one_xevent): Drop all valuator change
events destined for scroll bars.

src/gtkutil.c
src/gtkutil.h
src/pgtkterm.c
src/xterm.c

index d4726014c019fa035b3a1c8fe7a568b1428368ea..4f9907f795abb4e80c2fc6e2d354c2015855815a 100644 (file)
@@ -4637,11 +4637,6 @@ xg_update_scrollbar_pos (struct frame *f,
           gtk_widget_set_size_request (wscroll, width, height);
         }
 
-#if !defined HAVE_PGTK && GTK_CHECK_VERSION (2, 18, 0)
-       if (!gdk_window_ensure_native (gtk_widget_get_window (wscroll)))
-         emacs_abort ();
-#endif
-
       if (oldx != -1 && oldw > 0 && oldh > 0)
         {
           /* Clear under old scroll bar position.  */
@@ -4741,11 +4736,6 @@ xg_update_horizontal_scrollbar_pos (struct frame *f,
         pgtk_clear_area (f, oldx, oldy, oldw, oldh);
 #endif
 
-#if !defined HAVE_PGTK && GTK_CHECK_VERSION (2, 18, 0)
-       if (!gdk_window_ensure_native (gtk_widget_get_window (wscroll)))
-         emacs_abort ();
-#endif
-
       /* GTK does not redraw until the main loop is entered again, but
          if there are no X events pending we will not enter it.  So we sync
          here to get some events.  */
@@ -4911,7 +4901,8 @@ xg_set_toolkit_horizontal_scroll_bar_thumb (struct scroll_bar *bar,
    frame.  This function does additional checks.  */
 
 bool
-xg_event_is_for_scrollbar (struct frame *f, const EVENT *event)
+xg_event_is_for_scrollbar (struct frame *f, const EVENT *event,
+                          bool for_valuator)
 {
   bool retval = 0;
 
@@ -4924,7 +4915,8 @@ xg_event_is_for_scrollbar (struct frame *f, const EVENT *event)
             && (event->xgeneric.evtype == XI_ButtonPress
                 && xev->detail < 4))
            || (event->type == ButtonPress
-               && event->xbutton.button < 4)))
+               && event->xbutton.button < 4)
+           || for_valuator))
 #else
   if (f
 #ifndef HAVE_PGTK
index b74244d84d04db51e9f7a01abfd3ffdf0dbb48cb..63ecac079074324f86ce9d1e9489d82659962022 100644 (file)
@@ -148,7 +148,8 @@ extern void xg_set_toolkit_horizontal_scroll_bar_thumb (struct scroll_bar *bar,
                                                        int portion,
                                                        int position,
                                                        int whole);
-extern bool xg_event_is_for_scrollbar (struct frame *, const EVENT *);
+extern bool xg_event_is_for_scrollbar (struct frame *, const EVENT *,
+                                      bool for_valuator);
 extern int xg_get_default_scrollbar_width (struct frame *f);
 extern int xg_get_default_scrollbar_height (struct frame *f);
 
index 54b65ac54e41125b585a2452ee556e241ceb0776..84e20235fd05bfb694df1a890a92d3bb77c25c9f 100644 (file)
@@ -5957,7 +5957,7 @@ motion_notify_event (GtkWidget * widget, GdkEvent * event,
       clear_mouse_face (hlinfo);
     }
 
-  if (f && xg_event_is_for_scrollbar (f, event))
+  if (f && xg_event_is_for_scrollbar (f, event, false))
     f = 0;
   if (f)
     {
index ec17203fcdb8ab1ba2a36cb4e3fa328976db1b82..f5ce42fc2703e0a7b0871264c6df3a8dfea134e1 100644 (file)
@@ -10899,7 +10899,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
        f = mouse_or_wdesc_frame (dpyinfo, event->xmotion.window);
 
 #ifdef USE_GTK
-        if (f && xg_event_is_for_scrollbar (f, event))
+        if (f && xg_event_is_for_scrollbar (f, event, false))
           f = 0;
 #endif
 #ifdef HAVE_XWIDGETS
@@ -11203,7 +11203,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
        memset (&compose_status, 0, sizeof (compose_status));
        dpyinfo->last_mouse_glyph_frame = NULL;
 
-       f = mouse_or_wdesc_frame (dpyinfo, event->xmotion.window);
+       f = mouse_or_wdesc_frame (dpyinfo, event->xbutton.window);
        if (f && event->xbutton.type == ButtonPress
            && !popup_activated ()
            && !x_window_to_scroll_bar (event->xbutton.display,
@@ -11228,7 +11228,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
          }
 
 #ifdef USE_GTK
-        if (f && xg_event_is_for_scrollbar (f, event))
+        if (f && xg_event_is_for_scrollbar (f, event, false))
           f = 0;
 #endif
         if (f)
@@ -11733,7 +11733,6 @@ handle_one_xevent (struct x_display_info *dpyinfo,
                      int scroll_height;
                      Lisp_Object window;
 
-
                      /* See the comment on top of
                         x_init_master_valuators for more details on how
                         scroll wheel movement is reported on XInput 2.  */
@@ -11763,6 +11762,11 @@ handle_one_xevent (struct x_display_info *dpyinfo,
                                }
                            }
 
+#ifdef USE_GTK
+                         if (f && xg_event_is_for_scrollbar (f, event, true))
+                           *finish = X_EVENT_DROP;
+#endif
+
                          if (FRAME_X_WINDOW (f) != xev->event)
                            XTranslateCoordinates (dpyinfo->display,
                                                   xev->event, FRAME_X_WINDOW (f),
@@ -11882,11 +11886,6 @@ handle_one_xevent (struct x_display_info *dpyinfo,
                          inev.ie.arg = list3 (Qnil,
                                               make_float (total_x),
                                               make_float (total_y));
-
-#ifdef USE_GTK
-                         if (f && xg_event_is_for_scrollbar (f, event))
-                           *finish = X_EVENT_DROP;
-#endif
                        }
                      else
                        {
@@ -11953,7 +11952,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
              f = mouse_or_wdesc_frame (dpyinfo, xev->event);
 
 #ifdef USE_GTK
-             if (f && xg_event_is_for_scrollbar (f, event))
+             if (f && xg_event_is_for_scrollbar (f, event, false))
                f = 0;
 #endif
              if (f)
@@ -12138,7 +12137,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
                }
 
 #ifdef USE_GTK
-             if (f && xg_event_is_for_scrollbar (f, event))
+             if (f && xg_event_is_for_scrollbar (f, event, false))
                f = 0;
 #endif