[haiku-commits] r42521 - haiku/trunk/src/servers/input

  • From: pulkomandy@xxxxxxxxxxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sun, 31 Jul 2011 16:45:55 +0200 (CEST)

Author: pulkomandy
Date: 2011-07-31 16:45:55 +0200 (Sun, 31 Jul 2011)
New Revision: 42521
Changeset: https://dev.haiku-os.org/changeset/42521
Ticket: https://dev.haiku-os.org/ticket/6468

Modified:
   haiku/trunk/src/servers/input/InputServer.cpp
Log:
 * 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.


Modified: haiku/trunk/src/servers/input/InputServer.cpp
===================================================================
--- haiku/trunk/src/servers/input/InputServer.cpp       2011-07-31 02:15:21 UTC 
(rev 42520)
+++ haiku/trunk/src/servers/input/InputServer.cpp       2011-07-31 14:45:55 UTC 
(rev 42521)
@@ -1016,12 +1016,17 @@
        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 @@
                                // 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 @@
 
                                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;
                }


Other related posts: