mirror of
https://github.com/moonlight-stream/moonlight-android.git
synced 2026-04-20 23:40:11 +00:00
Ungrab meta key capture when toggling input capture
This commit is contained in:
@@ -1126,17 +1126,25 @@ public class Game extends Activity implements SurfaceHolder.Callback,
|
|||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setInputGrabState(boolean grab) {
|
||||||
|
// Grab/ungrab the mouse cursor
|
||||||
|
if (grab) {
|
||||||
|
inputCaptureProvider.disableCapture();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
inputCaptureProvider.enableCapture();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Grab/ungrab system keyboard shortcuts
|
||||||
|
setMetaKeyCaptureState(grab);
|
||||||
|
|
||||||
|
grabbedInput = grab;
|
||||||
|
}
|
||||||
|
|
||||||
private final Runnable toggleGrab = new Runnable() {
|
private final Runnable toggleGrab = new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (grabbedInput) {
|
setInputGrabState(!grabbedInput);
|
||||||
inputCaptureProvider.disableCapture();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
inputCaptureProvider.enableCapture();
|
|
||||||
}
|
|
||||||
|
|
||||||
grabbedInput = !grabbedInput;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1881,11 +1889,8 @@ public class Game extends Activity implements SurfaceHolder.Callback,
|
|||||||
// Let the display go to sleep now
|
// Let the display go to sleep now
|
||||||
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
||||||
|
|
||||||
// Enable cursor visibility again
|
// Ungrab input
|
||||||
inputCaptureProvider.disableCapture();
|
setInputGrabState(false);
|
||||||
|
|
||||||
// Disable meta key capture
|
|
||||||
setMetaKeyCaptureState(false);
|
|
||||||
|
|
||||||
if (!displayedFailureDialog) {
|
if (!displayedFailureDialog) {
|
||||||
displayedFailureDialog = true;
|
displayedFailureDialog = true;
|
||||||
@@ -1995,16 +2000,13 @@ public class Game extends Activity implements SurfaceHolder.Callback,
|
|||||||
h.postDelayed(new Runnable() {
|
h.postDelayed(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
inputCaptureProvider.enableCapture();
|
setInputGrabState(true);
|
||||||
}
|
}
|
||||||
}, 500);
|
}, 500);
|
||||||
|
|
||||||
// Keep the display on
|
// Keep the display on
|
||||||
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
||||||
|
|
||||||
// Enable meta key capture
|
|
||||||
setMetaKeyCaptureState(true);
|
|
||||||
|
|
||||||
// Update GameManager state to indicate we're in game
|
// Update GameManager state to indicate we're in game
|
||||||
UiHelper.notifyStreamConnected(Game.this);
|
UiHelper.notifyStreamConnected(Game.this);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user