/* NOTE: When compiling the 32-bit version of the library, in addition to being *compiledasaregularsourcefile,thisfileisalsoincludedby *gdkkeys-win32-impl-wow64.ctogenerateanalternateversionofthecode *intendedforrunningona64-bitkernel.Becauseofthewaykeyboardlayout *DLLsworkonWindows,wehavetogeneratetwoversionsanddecideatruntime *whichcodepathtoexecute.Youcanreadmoreaboutthespecificsbelow,in
* the section about KBD_LONG_POINTER. */
if (entry->VirtualKey == vk)
{
gboolean have_sgcaps = FALSE;
WCHAR best_char = WCH_NONE;
BYTE best_modifiers = 0; int best_score = -1;
gboolean best_is_dead = FALSE; int level;
/* Take toggled keys into account. For example, capslock normally inverts the
* state of KBDSHIFT (with some exceptions). */
/* Key supporting capslock */ if ((entry->Attributes & CAPLOK) && /* Ignore capslock if any modifiers other than shift are pressed. *E.g.ontheGermanlayout,CapsLock+AltGr+qisthesameas
* AltGr + q ('@'), but NOT the same as Shift + AltGr + q (not mapped). */
!(mod_bits & ~KBDSHIFT) &&
(lock_bits & CAPLOK))
mod_bits ^= KBDSHIFT;
/* In the Swiss German layout, CapsLock + key is different from Shift + key *forsomekeys.Forsuchkeys,thecharactersforactivecapslockare
* in the next entry. */ if ((entry->Attributes & SGCAPS) &&
(lock_bits & CAPLOK))
have_sgcaps = TRUE;
/* I'm not totally sure how kanalok behaves, for now I assume that there
* aren't any special cases. */ if ((entry->Attributes & KANALOK) &&
(lock_bits & KANALOK))
mod_bits ^= KBDKANA;
/* We try to find the entry with the most matching modifiers */ for (level = 0; level < n_levels; ++level)
{
BYTE candidate_modbits = info->level_to_modbits[level];
gboolean candidate_is_dead = FALSE;
WCHAR c; int score;
if (candidate_modbits & ~mod_bits) continue;
/* Some keys have bogus mappings for the control key, e.g. Ctrl + *Backspace=Delete,Ctrl+[=0x1BorevenCtrl+Shift+6= *0x1EonaUSkeyboard.Sowehavetoignoreallcasesof *Ctrlthataren'tpartofAltGr.
*/ if ((candidate_modbits & KBDCTRL) && !(candidate_modbits & KBDALT)) continue;
c = entry->wch[level]; if (c == WCH_DEAD || have_sgcaps)
{ /* Next entry contains the undead/capslocked keys */
PVK_TO_WCHARS next_entry;
next_entry = (PVK_TO_WCHARS) ((PBYTE) wch_table->pVkToWchars.ptr
+ entry_size * (entry_index + 1));
c = next_entry->wch[level];
candidate_is_dead = TRUE;
}
if (c == WCH_DEAD || c == WCH_LGTR || c == WCH_NONE) continue;
modifiers = tables->pCharModifiers.ptr; for (i = 0; i <= modifiers->wMaxModBits; ++i)
{ if (modifiers->ModNumber[i] != SHFT_INVALID &&
modifiers->ModNumber[i] != 0/* Workaround for buggy layouts*/)
{ if (modifiers->ModNumber[i] > info->max_level)
info->max_level = modifiers->ModNumber[i];
info->level_to_modbits[modifiers->ModNumber[i]] = i;
}
}
info->max_modbit_value = modifiers->wMaxModBits;
/* For convenience, we add 256 identity-mapped entries corresponding to the VKs. *Thisallowsustoreturnapointertothemfromthe`gdk_keysym_to_key_entry` *function.
*/
/* Lookup table to find entry for a VK in O(1). */
/* Only add the first entry, as some layouts (Swiss German) contain
* multiple successive entries for the same VK (SGCAPS). */ if (info->vk_lookup_table[entry->VirtualKey].table < 0)
{
info->vk_lookup_table[entry->VirtualKey].table = table_idx;
info->vk_lookup_table[entry->VirtualKey].index = entry_idx;
}
/* Create reverse lookup entries to find a VK+modifier combinations
* that results in a given character. */ for (level = 0; level < n_levels; ++level)
{
GdkWin32KeymapKeyEntry key_entry = {0};
WCHAR c = entry->wch[level]; int inserted_idx;
gintptr next_idx;
/* There can be multiple combinations that produce the same character. *Westorealloftheminalinkedlist. *Checkifwealreadyhaveanentryforthecharacter,sowecanchain
* them together. */ if (g_hash_table_lookup_extended (info->reverse_lookup_table,
GINT_TO_POINTER (c),
NULL, (gpointer*)&next_idx))
{
key_entry.next = next_idx;
} else
{
key_entry.next = -1;
}
/* We store the KeyEntry in an array. In the hash table we only store
* the index. */
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.