Skip to content

Commit

Permalink
Android: VncCanvasActivity: fix cuttext sending
Browse files Browse the repository at this point in the history
mClipboardManager.hasText() would return false on non-antique
Android versions. onWindowFocusChange() is the right place, see
https://developer.android.com/reference/android/content/ClipboardManager#hasPrimaryClip()

re #252
  • Loading branch information
bk138 committed Jan 26, 2025
1 parent adb0f6d commit acb8547
Showing 1 changed file with 10 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -487,17 +487,6 @@ protected void onResume() {
super.onResume();
// needed for the GLSurfaceView
vncCanvas.onResume();

// get Android clipboard contents
if (mClipboardManager.hasText()) {
try {
vncCanvas.vncConn.sendCutText(mClipboardManager.getText().toString());
}
catch(NullPointerException e) {
//unused
}
}

}

/**
Expand Down Expand Up @@ -840,6 +829,16 @@ public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
if (hasFocus) {
hideSystemUI();

// get Android clipboard contents
if (mClipboardManager.hasText()) {
try {
vncCanvas.vncConn.sendCutText(mClipboardManager.getText().toString());
}
catch(NullPointerException e) {
//unused
}
}
}
}

Expand Down

0 comments on commit acb8547

Please sign in to comment.