* Don't eat alt+space if there is only one input method available (the shortcut is meant to switch input methods)

Makes it useable in applications and less confusing. Fixes #6468.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42521 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Adrien Destugues
2011-07-31 14:45:55 +00:00
parent a4506dd3e7
commit e1ac525ddf
+15 -6
View File
@@ -1016,6 +1016,8 @@ InputServer::SetNextMethod(bool direction)
gInputMethodListLocker.Lock(); gInputMethodListLocker.Lock();
int32 index = gInputMethodList.IndexOf(fActiveMethod); int32 index = gInputMethodList.IndexOf(fActiveMethod);
int32 oldIndex = index;
index += (direction ? 1 : -1); index += (direction ? 1 : -1);
if (index < -1) if (index < -1)
@@ -1023,6 +1025,9 @@ InputServer::SetNextMethod(bool direction)
if (index >= gInputMethodList.CountItems()) if (index >= gInputMethodList.CountItems())
index = -1; index = -1;
if (index == oldIndex)
return B_BAD_INDEX;
BInputServerMethod *method = &gKeymapMethod; BInputServerMethod *method = &gKeymapMethod;
if (index != -1) if (index != -1)
@@ -1461,6 +1466,9 @@ InputServer::_UpdateMouseAndKeys(EventList& events)
// to next input method // to next input method
// (pressing "shift" will let us switch to the previous method) // (pressing "shift" will let us switch to the previous method)
// If there is only one input method, SetNextMethod will return
// B_BAD_INDEX and the event will be forwarded to the user.
PRINT(("SanitizeEvents: %lx, %x\n", fKeyInfo.modifiers, PRINT(("SanitizeEvents: %lx, %x\n", fKeyInfo.modifiers,
fKeyInfo.key_states[KEY_Spacebar >> 3])); fKeyInfo.key_states[KEY_Spacebar >> 3]));
@@ -1470,12 +1478,13 @@ InputServer::_UpdateMouseAndKeys(EventList& events)
if (((fKeyInfo.modifiers & B_COMMAND_KEY) != 0 && byte == ' ') if (((fKeyInfo.modifiers & B_COMMAND_KEY) != 0 && byte == ' ')
|| byte == B_HANKAKU_ZENKAKU) { || byte == B_HANKAKU_ZENKAKU) {
SetNextMethod(!(fKeyInfo.modifiers & B_SHIFT_KEY)); if (SetNextMethod(!(fKeyInfo.modifiers & B_SHIFT_KEY)) == B_OK)
{
// this event isn't sent to the user // this event isn't sent to the user
events.RemoveItemAt(index); events.RemoveItemAt(index);
delete event; delete event;
continue; continue;
}
} }
break; break;
} }