+
+ // Normally we take the state of modifiers directly from the low level GDK
+ // event but unfortunately GDK uses a different convention from MSW for the
+ // key events corresponding to the modifier keys themselves: in it, when
+ // e.g. Shift key is pressed, GDK_SHIFT_MASK is not set while it is set
+ // when Shift is released. Under MSW the situation is exactly reversed and
+ // the modifier corresponding to the key is set when it is pressed and
+ // unset when it is released. To ensure consistent behaviour between
+ // platforms (and because it seems to make slightly more sense, although
+ // arguably both behaviours are reasonable) we follow MSW here.
+ //
+ // Final notice: we set the flags to the desired value instead of just
+ // inverting them because they are not set correctly (i.e. in the same way
+ // as for the real events generated by the user) for wxUIActionSimulator-
+ // produced events and it seems better to keep that class code the same
+ // among all platforms and fix the discrepancy here instead of adding
+ // wxGTK-specific code to wxUIActionSimulator.
+ const bool isPress = gdk_event->type == GDK_KEY_PRESS;
+ switch ( gdk_event->keyval )
+ {
+ case GDK_Shift_L:
+ case GDK_Shift_R:
+ event.m_shiftDown = isPress;
+ break;
+
+ case GDK_Control_L:
+ case GDK_Control_R:
+ event.m_controlDown = isPress;
+ break;
+
+ case GDK_Alt_L:
+ case GDK_Alt_R:
+ event.m_altDown = isPress;
+ break;
+
+ case GDK_Meta_L:
+ case GDK_Meta_R:
+ case GDK_Super_L:
+ case GDK_Super_R:
+ event.m_metaDown = isPress;
+ break;
+ }
+