[evince] libview: Only accept focus on annot windows when pointer is on the window



commit 8a635b0b7d54cecc864299c8decbcc51b3c068a9
Author: Carlos Garcia Campos <carlosgc gnome org>
Date:   Sun Feb 20 12:11:19 2011 +0100

    libview: Only accept focus on annot windows when pointer is on the window
    
    It prevents focus stealing when scrolling with keyboard. See bug #623829.

 libview/ev-annotation-window.c |   22 +++++++++++++++++++++-
 1 files changed, 21 insertions(+), 1 deletions(-)
---
diff --git a/libview/ev-annotation-window.c b/libview/ev-annotation-window.c
index f47d9f6..8776dd4 100644
--- a/libview/ev-annotation-window.c
+++ b/libview/ev-annotation-window.c
@@ -378,7 +378,7 @@ ev_annotation_window_init (EvAnnotationWindow *window)
 
 	gtk_container_set_border_width (GTK_CONTAINER (window), 2);
 
-	gtk_window_set_accept_focus (GTK_WINDOW (window), TRUE);
+	gtk_window_set_accept_focus (GTK_WINDOW (window), FALSE);
 	gtk_window_set_decorated (GTK_WINDOW (window), FALSE);
 	gtk_window_set_skip_taskbar_hint (GTK_WINDOW (window), TRUE);
 	gtk_window_set_skip_pager_hint (GTK_WINDOW (window), TRUE);
@@ -511,6 +511,24 @@ ev_annotation_window_focus_out_event (GtkWidget     *widget,
 	return FALSE;
 }
 
+static gboolean
+ev_annotation_window_enter_notify_event (GtkWidget        *widget,
+                                         GdkEventCrossing *event)
+{
+        gtk_window_set_accept_focus (GTK_WINDOW (widget), TRUE);
+
+        return FALSE;
+}
+
+static gboolean
+ev_annotation_window_leave_notify_event (GtkWidget        *widget,
+                                         GdkEventCrossing *event)
+{
+        gtk_window_set_accept_focus (GTK_WINDOW (widget), FALSE);
+
+        return FALSE;
+}
+
 static void
 ev_annotation_window_class_init (EvAnnotationWindowClass *klass)
 {
@@ -525,6 +543,8 @@ ev_annotation_window_class_init (EvAnnotationWindowClass *klass)
 	gtk_widget_class->configure_event = ev_annotation_window_configure_event;
 	gtk_widget_class->focus_in_event = ev_annotation_window_focus_in_event;
 	gtk_widget_class->focus_out_event = ev_annotation_window_focus_out_event;
+        gtk_widget_class->enter_notify_event = ev_annotation_window_enter_notify_event;
+        gtk_widget_class->leave_notify_event = ev_annotation_window_leave_notify_event;
 
 	g_object_class_install_property (g_object_class,
 					 PROP_ANNOTATION,



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