- fix #543046 - Using scroll bar in emacs highlights/selects text

This commit is contained in:
Daniel Novotny 2009-12-02 16:51:52 +00:00
parent a9aba1d400
commit cc45bcb129
2 changed files with 88 additions and 1 deletions

82
emacs-23.1-scroll.patch Normal file
View File

@ -0,0 +1,82 @@
diff -up emacs-23.1/src/gtkutil.c.scroll emacs-23.1/src/gtkutil.c
--- emacs-23.1/src/gtkutil.c.scroll 2009-06-21 06:38:15.000000000 +0200
+++ emacs-23.1/src/gtkutil.c 2009-12-02 17:10:08.000000000 +0100
@@ -3401,6 +3401,38 @@ xg_set_toolkit_scroll_bar_thumb (bar, po
}
}
+/* 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
diff -up emacs-23.1/src/gtkutil.h.scroll emacs-23.1/src/gtkutil.h
--- emacs-23.1/src/gtkutil.h.scroll 2009-06-21 06:38:15.000000000 +0200
+++ emacs-23.1/src/gtkutil.h 2009-12-02 17:10:08.000000000 +0100
@@ -180,6 +180,8 @@ extern void xg_set_toolkit_scroll_bar_th
int position,
int whole));
+extern int xg_event_is_for_scrollbar P_ ((FRAME_PTR f, XEvent *event));
+
extern void update_frame_tool_bar P_ ((FRAME_PTR f));
extern void free_frame_tool_bar P_ ((FRAME_PTR f));
diff -up emacs-23.1/src/xterm.c.scroll emacs-23.1/src/xterm.c
--- emacs-23.1/src/xterm.c.scroll 2009-06-21 06:38:20.000000000 +0200
+++ emacs-23.1/src/xterm.c 2009-12-02 17:13:24.000000000 +0100
@@ -6743,6 +6743,12 @@ handle_one_xevent (dpyinfo, eventp, fini
clear_mouse_face (dpyinfo);
}
+
+#ifdef USE_GTK
+ if (f && xg_event_is_for_scrollbar (f, &event))
+ f = 0;
+#endif
+
if (f)
{
@@ -6899,6 +6905,11 @@ handle_one_xevent (dpyinfo, eventp, fini
else
f = x_window_to_frame (dpyinfo, event.xbutton.window);
+#ifdef USE_GTK
+ if (f && xg_event_is_for_scrollbar (f, &event))
+ f = 0;
+#endif
+
if (f)
{
/* Is this in the tool-bar? */

View File

@ -4,7 +4,7 @@ Summary: GNU Emacs text editor
Name: emacs
Epoch: 1
Version: 23.1
Release: 12%{?dist}
Release: 13%{?dist}
License: GPLv3+
URL: http://www.gnu.org/software/emacs/
Group: Applications/Editors
@ -29,6 +29,7 @@ Patch3: rpm-spec-mode-utc.patch
Patch4: emacs-gtk.patch
Patch5: emacs-23.1-xdg.patch
Patch6: emacs-23.1-cpp.patch
Patch7: emacs-23.1-scroll.patch
Buildroot: %{_tmppath}/%{name}-%{version}-root
BuildRequires: atk-devel, cairo-devel, desktop-file-utils, freetype-devel, fontconfig-devel, dbus-devel, giflib-devel, glibc-devel, gtk2-devel, libpng-devel
@ -121,6 +122,7 @@ Emacs packages or see some elisp examples.
%patch4 -p1 -b .gtk
%patch5 -p1 -b .xdg
%patch6 -p1
%patch7 -p1 -b .scroll
# install rest of site-lisp files
( cd site-lisp
@ -383,6 +385,9 @@ alternatives --install %{_bindir}/etags emacs.etags %{_bindir}/etags.emacs 80 \
%dir %{_datadir}/emacs/%{version}
%changelog
* Wed Dec 02 2009 Daniel Novotny <dnovotny@redhat.com> 1:23.1-13
- fix #543046 - Using scroll bar in emacs highlights/selects text
* Mon Nov 30 2009 Daniel Novotny <dnovotny@redhat.com> 1:23.1-12
- fixed FTBFS in F12 and higher (#540921)