Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 73e35134 authored by Josep del Rio's avatar Josep del Rio
Browse files

Fix display id for desktop keyboard shotcuts

Currently we were passing the event display id to the SysUI
code that applies the shortcut actions, but the `INVALID_DISPLAY`
value is not supported, so we need to obtain it.

Bug: 318366520
Flag: NA
Test: Flashed on device
Change-Id: I63060e452de26e87060b5439ce5e82ee42a52900
parent b30ba815
Loading
Loading
Loading
Loading
+16 −2
Original line number Diff line number Diff line
@@ -3504,7 +3504,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                if (firstDown && event.isMetaPressed() && event.isCtrlPressed()) {
                    StatusBarManagerInternal statusbar = getStatusBarManagerInternal();
                    if (statusbar != null) {
                        statusbar.moveFocusedTaskToFullscreen(event.getDisplayId());
                        statusbar.moveFocusedTaskToFullscreen(getTargetDisplayIdForKeyEvent(event));
                        logKeyboardSystemsEvent(event, KeyboardLogEvent.MULTI_WINDOW_NAVIGATION);
                        return true;
                    }
@@ -3514,7 +3514,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                if (firstDown && event.isMetaPressed() && event.isCtrlPressed()) {
                    StatusBarManagerInternal statusbar = getStatusBarManagerInternal();
                    if (statusbar != null) {
                        statusbar.enterDesktop(event.getDisplayId());
                        statusbar.enterDesktop(getTargetDisplayIdForKeyEvent(event));
                        logKeyboardSystemsEvent(event, KeyboardLogEvent.DESKTOP_MODE);
                        return true;
                    }
@@ -6951,4 +6951,18 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                    == PERMISSION_GRANTED;
        }
    }

    private int getTargetDisplayIdForKeyEvent(KeyEvent event) {
        int displayId = event.getDisplayId();

        if (displayId == INVALID_DISPLAY) {
            displayId = mTopFocusedDisplayId;
        }

        if (displayId == INVALID_DISPLAY) {
            return DEFAULT_DISPLAY;
        } else {
            return displayId;
        }
    }
}