From e1ac525ddff37e7aedf656334d97f1708bbad926 Mon Sep 17 00:00:00 2001 From: Adrien Destugues Date: Sun, 31 Jul 2011 14:45:55 +0000 Subject: [PATCH] * 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 --- src/servers/input/InputServer.cpp | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/servers/input/InputServer.cpp b/src/servers/input/InputServer.cpp index f6a837c204..c2140e10de 100644 --- a/src/servers/input/InputServer.cpp +++ b/src/servers/input/InputServer.cpp @@ -1016,12 +1016,17 @@ InputServer::SetNextMethod(bool direction) gInputMethodListLocker.Lock(); int32 index = gInputMethodList.IndexOf(fActiveMethod); + int32 oldIndex = index; + index += (direction ? 1 : -1); if (index < -1) index = gInputMethodList.CountItems() - 1; if (index >= gInputMethodList.CountItems()) index = -1; + + if (index == oldIndex) + return B_BAD_INDEX; BInputServerMethod *method = &gKeymapMethod; @@ -1460,6 +1465,9 @@ InputServer::_UpdateMouseAndKeys(EventList& events) // we scan for Alt+Space key down events which means we change // to next input 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, fKeyInfo.key_states[KEY_Spacebar >> 3])); @@ -1470,12 +1478,13 @@ InputServer::_UpdateMouseAndKeys(EventList& events) if (((fKeyInfo.modifiers & B_COMMAND_KEY) != 0 && byte == ' ') || byte == B_HANKAKU_ZENKAKU) { - SetNextMethod(!(fKeyInfo.modifiers & B_SHIFT_KEY)); - - // this event isn't sent to the user - events.RemoveItemAt(index); - delete event; - continue; + if (SetNextMethod(!(fKeyInfo.modifiers & B_SHIFT_KEY)) == B_OK) + { + // this event isn't sent to the user + events.RemoveItemAt(index); + delete event; + continue; + } } break; }