[network/kdeconnect-android] src/main/java/org/kde/kdeconnect/plugins/mousepad: Fix "Show keyboard initially"

Albert Vaca Cintora <[email protected]>
Newsgroups gmane.comp.kde.cvs
Message-ID <[email protected]>
Git commit 5782337e5d460af4f5edb1adf3c3caf4b902af32 by Albert Vaca Cintora.
Committed on 29/07/2026 at 16:15.
Pushed by albertvaka into branch 'master'.

Fix "Show keyboard initially"

M  +16   -1    src/main/java/org/kde/kdeconnect/plugins/mousepad/MousePadActivity.java

https://invent.kde.org/network/kdeconnect-android/-/commit/5782337e5d460af4f5edb1adf3c3caf4b902af32

diff --git a/src/main/java/org/kde/kdeconnect/plugins/mousepad/MousePadActivity.java b/src/main/java/org/kde/kdeconnect/plugins/mousepad/MousePadActivity.java
index 27b84550b..ce60a377a 100644
--- a/src/main/java/org/kde/kdeconnect/plugins/mousepad/MousePadActivity.java
+++ b/src/main/java/org/kde/kdeconnect/plugins/mousepad/MousePadActivity.java
@@ -65,6 +65,7 @@ public class MousePadActivity
     private int gyroscopeSensitivity = 100;
     private boolean isScrolling = false;
     private double accumulatedDistanceY = 0;
+    private boolean pendingShowKeyboard = false;
 
     private GestureDetector mDetector;
     private SensorManager mSensorManager;
@@ -201,6 +202,15 @@ public class MousePadActivity
         super.onResume();
     }
 
+    @Override
+    public void onWindowFocusChanged(boolean hasFocus) {
+        super.onWindowFocusChanged(hasFocus);
+        if (hasFocus && pendingShowKeyboard) {
+            showKeyboard();
+            pendingShowKeyboard = false;
+        }
+    }
+
     @Override
     protected void onPause() {
         if (gyroEnabled) {
@@ -605,7 +615,12 @@ public class MousePadActivity
                 return;
         }
         if (prefs.getBoolean("pref_mousepad_show_keyboard", true)) {
-            showKeyboard();
+            if (hasWindowFocus()) {
+                showKeyboard();
+            } else {
+                // Defer until the window gains focus, see pendingShowKeyboard.
+                pendingShowKeyboard = true;
+            }
         } else {
             hideKeyboard();
         }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.