diff src/gtkutil.c @ 105880:5910e0380daf

Fix bug #4870, issues 3 and 4. * gtkutil.c (xg_event_is_for_scrollbar): New function (bug#4870). * gtkutil.h: Declare xg_event_is_for_scrollbar (bug#4870). * xterm.c (handle_one_xevent): Call xg_event_is_for_scrollbar for ButtonPressRelease and MotionNotify (bug#4870).
author Jan Djärv <jan.h.d@swipnet.se>
date Fri, 06 Nov 2009 08:30:43 +0000
parents 964ff7cbc8a6
children 45191c90be7e
line wrap: on
line diff
--- a/src/gtkutil.c	Fri Nov 06 07:50:54 2009 +0000
+++ b/src/gtkutil.c	Fri Nov 06 08:30:43 2009 +0000
@@ -3371,6 +3371,38 @@
     }
 }
 
+/* Return non-zero if EVENT is for a scroll bar in frame F.
+   When the same X window is used for several Gtk+ widgets, we cannot
+   say for sure based on the X window alone if an event is for the
+   frame.  This function does additional checks.
+
+   Return non-zero if the event is for a scroll bar, zero otherwise.  */
+
+int
+xg_event_is_for_scrollbar (f, event)
+     FRAME_PTR f;
+     XEvent *event;
+{
+  int retval = 0;
+
+  if (f && event->type == ButtonPress)
+    {
+      /* Check if press occurred outside the edit widget.  */
+      GdkDisplay *gdpy = gdk_x11_lookup_xdisplay (FRAME_X_DISPLAY (f));
+      retval = gdk_display_get_window_at_pointer (gdpy, NULL, NULL)
+        != f->output_data.x->edit_widget->window;
+    }
+  else if (f && (event->type != ButtonRelease || event->type != MotionNotify))
+    {
+      /* If we are releasing or moving the scroll bar, it has the grab.  */
+      retval = gtk_grab_get_current () != 0
+        && gtk_grab_get_current () != f->output_data.x->edit_widget;
+    }
+
+  return retval;
+}
+
+
 
 /***********************************************************************
                       Tool bar functions