* The Keymap::IsDeadKey() of the Keymap preferences which was the main source
of BKeymap was not compatible with IsDeadKey() of the other Keymap incarnations. * Now, I've renamed IsDeadKey() to DeadKey(), and introduced a new ActiveDeadKey() method that works like the other former IsDeadKey(). * This fixes the dead key problems my earlier BKeymap work introduced. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36400 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
0e3ac47627
commit
b19e758b80
@ -28,9 +28,10 @@ public:
|
||||
bool IsModifierKey(uint32 keyCode) const;
|
||||
uint32 Modifier(uint32 keyCode) const;
|
||||
uint32 KeyForModifier(uint32 modifier) const;
|
||||
uint8 IsDeadKey(uint32 keyCode,
|
||||
uint32 modifiers,
|
||||
bool* isEnabled = NULL) const;
|
||||
uint8 ActiveDeadKey(uint32 keyCode,
|
||||
uint32 modifiers) const;
|
||||
uint8 DeadKey(uint32 keyCode, uint32 modifiers,
|
||||
bool* _isEnabled) const;
|
||||
bool IsDeadSecondKey(uint32 keyCode,
|
||||
uint32 modifiers,
|
||||
uint8 activeDeadKey) const;
|
||||
|
@ -28,8 +28,9 @@ public:
|
||||
bool IsModifierKey(uint32 keyCode) const;
|
||||
uint32 Modifier(uint32 keyCode) const;
|
||||
uint32 KeyForModifier(uint32 modifier) const;
|
||||
uint8 IsDeadKey(uint32 keyCode,
|
||||
uint32 modifiers,
|
||||
uint8 ActiveDeadKey(uint32 keyCode,
|
||||
uint32 modifiers) const;
|
||||
uint8 DeadKey(uint32 keyCode, uint32 modifiers,
|
||||
bool* isEnabled = NULL) const;
|
||||
bool IsDeadSecondKey(uint32 keyCode,
|
||||
uint32 modifiers,
|
||||
|
@ -398,7 +398,7 @@ KeyboardDevice::_ControlThread()
|
||||
|
||||
uint8 newDeadKey = 0;
|
||||
if (activeDeadKey == 0 || !isKeyDown)
|
||||
newDeadKey = fKeymap.IsDeadKey(keycode, fModifiers);
|
||||
newDeadKey = fKeymap.ActiveDeadKey(keycode, fModifiers);
|
||||
|
||||
char* string = NULL;
|
||||
char* rawString = NULL;
|
||||
|
@ -147,7 +147,7 @@ keyboard_reader(void* arg)
|
||||
|
||||
uint8 newDeadKey = 0;
|
||||
if (activeDeadKey == 0 || !isKeyDown)
|
||||
newDeadKey = keymap.IsDeadKey(keycode, modifiers);
|
||||
newDeadKey = keymap.ActiveDeadKey(keycode, modifiers);
|
||||
|
||||
char* string = NULL;
|
||||
int32 numBytes = 0;
|
||||
|
@ -247,12 +247,26 @@ BKeymap::KeyForModifier(uint32 modifier) const
|
||||
}
|
||||
|
||||
|
||||
/*! Checks whether a key is an active dead key.
|
||||
*/
|
||||
uint8
|
||||
BKeymap::ActiveDeadKey(uint32 keyCode, uint32 modifiers) const
|
||||
{
|
||||
bool enabled;
|
||||
uint8 deadKey = DeadKey(keyCode, modifiers, &enabled);
|
||||
if (deadKey == 0 || !enabled)
|
||||
return 0;
|
||||
|
||||
return deadKey;
|
||||
}
|
||||
|
||||
|
||||
/*! Checks whether a key is a dead key.
|
||||
If it is, the enabled/disabled state of that dead key will be passed
|
||||
out via isEnabled (isEnabled is not touched for non-dead keys).
|
||||
*/
|
||||
uint8
|
||||
BKeymap::IsDeadKey(uint32 keyCode, uint32 modifiers, bool* _isEnabled) const
|
||||
BKeymap::DeadKey(uint32 keyCode, uint32 modifiers, bool* _isEnabled) const
|
||||
{
|
||||
uint32 tableMask = 0;
|
||||
int32 offset = Offset(keyCode, modifiers, &tableMask);
|
||||
@ -510,10 +524,10 @@ BKeymap::DeadKeyIndex(int32 offset) const
|
||||
return 0;
|
||||
|
||||
uint32 numBytes = fChars[offset];
|
||||
if (!numBytes)
|
||||
if (!numBytes || numBytes > 4)
|
||||
return 0;
|
||||
|
||||
char chars[4];
|
||||
char chars[5];
|
||||
strncpy(chars, &fChars[offset + 1], numBytes);
|
||||
chars[numBytes] = 0;
|
||||
|
||||
@ -527,19 +541,15 @@ BKeymap::DeadKeyIndex(int32 offset) const
|
||||
|
||||
uint8 result = 0;
|
||||
for (int32 i = 0; i < 5; i++) {
|
||||
if (offset == deadOffsets[i]) {
|
||||
result = i + 1;
|
||||
break;
|
||||
}
|
||||
if (offset == deadOffsets[i])
|
||||
return i + 1;
|
||||
|
||||
uint32 deadNumBytes = fChars[deadOffsets[i]];
|
||||
if (!deadNumBytes)
|
||||
continue;
|
||||
|
||||
if (strncmp(chars, &fChars[deadOffsets[i] + 1], deadNumBytes) == 0) {
|
||||
result = i + 1;
|
||||
break;
|
||||
}
|
||||
if (strncmp(chars, &fChars[deadOffsets[i] + 1], deadNumBytes) == 0)
|
||||
return i + 1;
|
||||
}
|
||||
|
||||
return result;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2009, Axel Dörfler, axeld@pinc-software.de.
|
||||
* Copyright 2009-2010, Axel Dörfler, axeld@pinc-software.de.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
@ -159,7 +159,7 @@ KeyboardLayoutView::MouseDown(BPoint point)
|
||||
if (fKeymap != NULL) {
|
||||
bool isEnabled = false;
|
||||
uint8 deadKey
|
||||
= fKeymap->IsDeadKey(key->code, fModifiers, &isEnabled);
|
||||
= fKeymap->DeadKey(key->code, fModifiers, &isEnabled);
|
||||
if (deadKey > 0) {
|
||||
fKeymap->SetDeadKeyEnabled(key->code, fModifiers, !isEnabled);
|
||||
_InvalidateKey(key);
|
||||
@ -585,7 +585,7 @@ KeyboardLayoutView::_DrawKey(BView* view, BRect updateRect, const Key* key,
|
||||
char text[32];
|
||||
if (fKeymap != NULL) {
|
||||
_GetKeyLabel(key, text, sizeof(text), keyKind);
|
||||
deadKey = fKeymap->IsDeadKey(key->code, fModifiers, &isDeadKeyEnabled);
|
||||
deadKey = fKeymap->DeadKey(key->code, fModifiers, &isDeadKeyEnabled);
|
||||
secondDeadKey = fKeymap->IsDeadSecondKey(key->code, fModifiers,
|
||||
fDeadKey);
|
||||
} else {
|
||||
@ -945,7 +945,7 @@ KeyboardLayoutView::_HandleDeadKey(uint32 key, int32 modifiers)
|
||||
return false;
|
||||
|
||||
bool isEnabled = false;
|
||||
int32 deadKey = fKeymap->IsDeadKey(key, modifiers, &isEnabled);
|
||||
int32 deadKey = fKeymap->DeadKey(key, modifiers, &isEnabled);
|
||||
if (fDeadKey != deadKey) {
|
||||
if (isEnabled) {
|
||||
Invalidate();
|
||||
|
Loading…
x
Reference in New Issue
Block a user