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: Gerald Combs <gerald@xxxxxxxxxxxxx>
Date: Fri, 25 May 2007 09:14:49 -0700
The problem with only checking against GDK_CONTROL_MASK and
GDK_MOD1_MASK (a.k.a. "Alt") is that we miss all the other strange and
funky modifier keys that we might encounter.  On a Mac here, holding
down the command key generates an event->state value of 0x10000010
(GDK_MOD2_MASK | GDK_META_MASK).

As you point out below, we should be checking against event->state
instead of event->keyval.  I'll check in a fix.

Martin Mathieson wrote:
> 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
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Wireshark-dev mailing list
> Wireshark-dev@xxxxxxxxxxxxx
> http://www.wireshark.org/mailman/listinfo/wireshark-dev