Although my previous patch (see explanation below) did in fact solve the
(very annoying) mouse grab problem, it changed the behaviour of
evolution.  The previous patch made the user have to click the text in
the minicard for the label to highlight.  This new patch does not change
evolution's behaviour, and also fixes an additional bug of evolution
grabbing the mouse when the user double or more clicks with the middle
mouse button in the minicard. 

To fix bugg #16462, the patch makes the e_minicard_label_event() (in
addressbook/gui/widgets/e-minicard-label.c) handle the GDK_BUTTON_PRESS
event properly.  Before, the e_minicard_label_event() would always call
gtk_signal_emit_by_name with a GDK_BUTTON_PRESS, when in fact, it should
only call gtk_signal_emit_by_name when the event was a single click and
when the label did not have the focus yet.  Checking both of these
conditions fixes the mouse grab problem (you can now double, triple,
quadruple or more click and do massive random clicking all throughout
the minicard without it grabbing the mouse). 

The patch to fix the double middle mouse click grab is simply making
e_minicard_event() in e-minicard.c use only button 1 in the
GDK_BUTTON_PRESS processing, where before it would allow both. 
Otherwise, the behaviour for the middle mouse click is what the user
would expect (highlights the label, and pastes if the middle click
occured in the text).

To apply the patch, put the patch in the directory above the
toplevel evolution source directory (eg
/usr/local/src/evo-bug16462.patch-v2), then cd into the toplevel evolution
source directory (eg 'cd /usr/local/src/evolution-1.0.2), then run 'cat
../evo-bug16462.patch-v2 | patch -p1'. 

Please apply this patch-- from my testing it is very robust and will
help a lot of people. 

James Strandboge 

On Tue, 2002-03-19 at 23:43, James D Strandboge wrote: 
> This bug is regarding evolution doing a gdk type grab on the mouse
> without ungrabbing it when a contact is triple clicked. 
> 
> I can reproduce this at will: 
> Open contacts 
> View/Current View/Address Cards 
> Adjust the width of the e-minicards so that you can see everything 
> Triple click in one of the fields of a minicard 
> 
> Results: 
> mouse turns to crosshair and is movable, but can't click anything.  You
> have to close evo for it to release the mouse. 
> Keyboard control is still present, so you can use Meta keys to close
> everything down. 
> 
> 
> In trying to debug this, I noticed that: 
> 1) the other views are unaffected-- only Address Cards view 
> 2) triple (or more) clicking on the title of the minicard works fine 
> 3) quadruple clicking in the affected part of the mincard also worked
> fine 
> 
> After MUCH searching and debugging, I found that the e-minicard-label
> was taking the GDK_BUTTON_PRESS and GDK_BUTTON_RELEASE and not passing
> them up to its parent. 
> 
<snip>

-- 
Email:        [EMAIL PROTECTED]
GPG/PGP ID:   26384A3A
Fingerprint:  D9FF DF4A 2D46 A353 A289  E8F5 AA75 DCBE 2638 4A3A
diff -Naur evolution-1.0.2-original/addressbook/gui/widgets/e-minicard-label.c evolution-1.0.2/addressbook/gui/widgets/e-minicard-label.c
--- evolution-1.0.2-original/addressbook/gui/widgets/e-minicard-label.c	Wed Mar 20 13:19:32 2002
+++ evolution-1.0.2/addressbook/gui/widgets/e-minicard-label.c	Thu Mar 21 12:21:32 2002
@@ -335,8 +335,39 @@
 	  }
       }
       break;
-    case GDK_BUTTON_PRESS:
-    case GDK_BUTTON_RELEASE: 
+
+    case GDK_BUTTON_PRESS: {
+        gboolean return_val;
+        GdkEvent *next_event;
+
+        /* don't do anything if we already have the focus, but say we
+         * did */
+        if ( e_minicard_label->has_focus )
+                return TRUE;
+
+        /* if no pending events, process the event */
+        if (!gdk_events_pending()) {
+                gtk_signal_emit_by_name(GTK_OBJECT(e_minicard_label->field), "event", event, &return_val);
+                return return_val;
+        }
+
+        next_event = gdk_event_peek();
+        if(next_event != NULL) { 
+                /* since the current event is GDK_BUTTON_PRESS, if the
+                 * next one is GDK_BUTTON_RELEASE, we have a valid
+                 * single click, so process */
+                if (next_event->type == GDK_BUTTON_RELEASE) {
+                        gdk_event_free(next_event);
+                        gtk_signal_emit_by_name(GTK_OBJECT(e_minicard_label->field), "event", event, &return_val);
+                        return return_val;
+                }
+
+                gdk_event_free(next_event);
+        }
+        return TRUE;
+        break;
+    }
+      
     case GDK_MOTION_NOTIFY:
     case GDK_ENTER_NOTIFY:
     case GDK_LEAVE_NOTIFY: {
diff -Naur evolution-1.0.2-original/addressbook/gui/widgets/e-minicard.c evolution-1.0.2/addressbook/gui/widgets/e-minicard.c
--- evolution-1.0.2-original/addressbook/gui/widgets/e-minicard.c	Tue Oct 30 00:00:24 2001
+++ evolution-1.0.2/addressbook/gui/widgets/e-minicard.c	Thu Mar 21 12:00:33 2002
@@ -537,7 +537,7 @@
 		}
 		break;
 	case GDK_BUTTON_PRESS: {
-		if (1 <= event->button.button && event->button.button <= 2) {
+		if (event->button.button == 1) {
 			int ret_val = e_minicard_selected(e_minicard, event);
 			GdkEventMask mask = ((1 << (4 + event->button.button)) |
 					     GDK_POINTER_MOTION_MASK |

Attachment: signature.asc
Description: This is a digitally signed message part

Reply via email to