Deal with unknown flags from ClutterEvent.get_state()

When we get a ClutterModifierType from Clutter, it might contain
bits not in the enumeration. See bug 59771 for a similar problem
with GdkModifierType.

Add a wrapper Shell.get_event_state() around clutter_event_get_state()
to mask these bits out and only return approved bits.

https://bugzilla.gnome.org/show_bug.cgi?id=597735
This commit is contained in:
Owen W. Taylor
2009-10-07 17:20:33 -04:00
parent a81a16801d
commit ff39edd1ee
5 changed files with 24 additions and 3 deletions

View File

@ -998,3 +998,22 @@ shell_global_get_modifier_keys (ShellGlobal *global)
gdk_display_get_pointer (gdk_display_get_default (), NULL, NULL, NULL, &mods);
return mods & GDK_MODIFIER_MASK;
}
/**
* shell_get_event_state:
* @event: a #ClutterEvent
*
* Gets the current state of the event (the set of modifier keys that
* are pressed down). Thhis is a wrapper around
* clutter_event_get_state() that strips out any un-declared modifier
* flags, to make gjs happy; see
* https://bugzilla.gnome.org/show_bug.cgi?id=597292.
*
* Return value: the state from the event
*/
ClutterModifierType
shell_get_event_state (ClutterEvent *event)
{
ClutterModifierType state = clutter_event_get_state (event);
return state & CLUTTER_MODIFIER_MASK;
}