auto import from //branches/cupcake/...@132276
diff --git a/src/com/android/launcher/Launcher.java b/src/com/android/launcher/Launcher.java
index 4252dae..58fcd5a 100644
--- a/src/com/android/launcher/Launcher.java
+++ b/src/com/android/launcher/Launcher.java
@@ -355,11 +355,21 @@
         }
         return handled;
     }
+    private boolean acceptFilter() {
+        final Configuration configuration = getResources().getConfiguration();
+        final boolean keyboardShowing = configuration.keyboardHidden !=
+                Configuration.KEYBOARDHIDDEN_YES;
+        final boolean hasKeyboard = configuration.keyboard != Configuration.KEYBOARD_NOKEYS;
+        final InputMethodManager inputManager = (InputMethodManager)
+                getSystemService(Context.INPUT_METHOD_SERVICE);
+        return (hasKeyboard && keyboardShowing) ||
+                (!hasKeyboard && !inputManager.isFullscreenMode());
+    }
 
     @Override
     public boolean onKeyDown(int keyCode, KeyEvent event) {
         boolean handled = super.onKeyDown(keyCode, event);
-        if (!handled && keyCode != KeyEvent.KEYCODE_ENTER) {
+        if (!handled && acceptFilter() && keyCode != KeyEvent.KEYCODE_ENTER) {
             boolean gotKey = TextKeyListener.getInstance().onKeyDown(mWorkspace, mDefaultKeySsb,
                     keyCode, event);
             if (gotKey && mDefaultKeySsb != null && mDefaultKeySsb.length() > 0) {
@@ -861,8 +871,10 @@
                 startWallpaper();
                 return true;
             case MENU_SEARCH:
-                if (!mWorkspace.snapToSearch()) {
-                    onSearchRequested();
+                if (mWorkspace.snapToSearch()) {
+                    closeDrawer(true);          // search gadget: get drawer out of the way
+                } else {
+                    onSearchRequested();        // no search gadget: use system search UI
                 }
                 return true;
             case MENU_NOTIFICATIONS: