Exemplo n.º 1
0
void
egg_keymap_resolve_virtual_modifiers (GdkKeymap              *keymap,
                                      EggVirtualModifierType  virtual_mods,
                                      GdkModifierType        *concrete_mods)
{
  GdkModifierType concrete;
  int i;
  const EggModmap *modmap;

  g_return_if_fail (GDK_IS_KEYMAP (keymap));
  g_return_if_fail (concrete_mods != NULL);
  
  modmap = egg_keymap_get_modmap (keymap);
  
  /* Not so sure about this algorithm. */
  
  concrete = 0;
  i = 0;
  while (i < EGG_MODMAP_ENTRY_LAST)
    {
      if (modmap->mapping[i] & virtual_mods)
        concrete |= (1 << i);

      ++i;
    }

  *concrete_mods = concrete;
}
Exemplo n.º 2
0
void
egg_keymap_virtualize_modifiers (GdkKeymap              *keymap,
                                 GdkModifierType         concrete_mods,
                                 EggVirtualModifierType *virtual_mods)
{
    GdkModifierType virtual;
    int i;
    const EggModmap *modmap;

    g_return_if_fail (GDK_IS_KEYMAP (keymap));
    g_return_if_fail (virtual_mods != NULL);

    modmap = egg_keymap_get_modmap (keymap);

    /* Not so sure about this algorithm. */
    virtual = 0;
    i = 0;
    while (i < EGG_MODMAP_ENTRY_LAST) {
        if ((1 << i) & concrete_mods) {
            EggVirtualModifierType cleaned;
            cleaned = modmap->mapping[i] & ~(EGG_VIRTUAL_MOD2_MASK |
                                             EGG_VIRTUAL_MOD3_MASK |
                                             EGG_VIRTUAL_MOD4_MASK |
                                             EGG_VIRTUAL_MOD5_MASK);
            if (cleaned != 0) {
                virtual |= cleaned;
            } else {
                /* Rather than dropping mod2->mod5 if not bound,
                 * go ahead and use the concrete names
                 */
				virtual |= modmap->mapping[i];
            }
        }