Huge thanks to our Platinum Members Endace and LiveAction,
and our Silver Member Veeam, for supporting the Wireshark Foundation and project.

Wireshark-dev: Re: [Wireshark-dev] Automatically setting focus for display filter control no lo

From: "Martin Mathieson" <martin.r.mathieson@xxxxxxxxxxxxxx>
Date: Fri, 25 May 2007 11:04:37 +0100
Wrong patch, try this one instead!

On 5/25/07, Martin Mathieson <martin.r.mathieson@xxxxxxxxxxxxxx> wrote:
Hi,
I think this regression is related to Gerald's change 21898, whose log
message was:

"Don't set the focus on the display filter entry when we're passed a
 contorl- or alt-modified character.  Fixes bug 1610."

I notice that pressing down control or alt doesn't affect the value of
event->keyval (holding down shift while pressing another key switches
off the 6th l.s.b.   -  e.g. 'a' will be 0x61 whereas shift+'a' is
0x41...)

Using event->state (of type enum GdkModifierType) instead seems to be
the way to go.

Does anyone see problems with the attached patch?

Best regards,
Martin

Index: main.c
===================================================================
--- main.c	(revision 21932)
+++ main.c	(working copy)
@@ -4274,7 +4274,6 @@
 #endif /* HAVE_AIRPCAP */
 
 #if GTK_MAJOR_VERSION >= 2
-#define NO_SHIFT_MOD_MASK (GDK_MODIFIER_MASK & ~(GDK_SHIFT_MASK|GDK_LOCK_MASK))
 static int
 top_level_key_pressed_cb(GtkCTree *ctree _U_, GdkEventKey *event, gpointer user_data _U_)
 {
@@ -4284,7 +4283,8 @@
     } else if (event->keyval == GDK_F7) {
 	packet_list_prev();
 	return TRUE;
-    } else if (event->keyval | NO_SHIFT_MOD_MASK) {
+    } else if ((event->state & GDK_CONTROL_MASK) |
+               (event->state & GDK_MOD1_MASK)) {
         return FALSE; /* Skip control, alt, and other modifiers */
     /*
      * A comment in gdkkeysyms.h says that it's autogenerated from