Fix when an external display is connected

This commit is contained in:
Stossy11 2025-06-01 22:20:53 +10:00
parent 6092551d20
commit 8259cc3dca
4 changed files with 30 additions and 5 deletions

BIN
.DS_Store vendored Normal file

Binary file not shown.

View File

@ -4,6 +4,11 @@
<dict> <dict>
<key>SchemeUserState</key> <key>SchemeUserState</key>
<dict> <dict>
<key>RyujinxHelper.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
<key>RyujinxKeyboard.xcscheme_^#shared#^_</key> <key>RyujinxKeyboard.xcscheme_^#shared#^_</key>
<dict> <dict>
<key>orderHint</key> <key>orderHint</key>

View File

@ -13,6 +13,24 @@ extern "C" {
#endif #endif
static char *keyboardInput = NULL; static char *keyboardInput = NULL;
UIWindowScene *getMainDeviceWindowScene() {
for (UIWindowScene *scene in UIApplication.sharedApplication.connectedScenes) {
if ([scene isKindOfClass:[UIWindowScene class]]) {
if (scene.screen == UIScreen.mainScreen) {
return scene;
}
}
}
for (UIWindowScene *scene in UIApplication.sharedApplication.connectedScenes) {
if ([scene isKindOfClass:[UIWindowScene class]]) {
return scene;
}
}
return nil;
}
void showKeyboardAlert(const char *title, const char *message, const char *placeholder) { void showKeyboardAlert(const char *title, const char *message, const char *placeholder) {
NSString *alertTitle = [NSString stringWithUTF8String:title]; NSString *alertTitle = [NSString stringWithUTF8String:title];
@ -20,8 +38,8 @@ void showKeyboardAlert(const char *title, const char *message, const char *place
NSString *alertPlaceholder = [NSString stringWithUTF8String:placeholder]; NSString *alertPlaceholder = [NSString stringWithUTF8String:placeholder];
dispatch_async(dispatch_get_main_queue(), ^{ dispatch_async(dispatch_get_main_queue(), ^{
UIWindowScene *activeScene = (UIWindowScene *)UIApplication.sharedApplication.connectedScenes.allObjects.firstObject; UIWindowScene *activeScene = getMainDeviceWindowScene();
if (!activeScene || ![activeScene isKindOfClass:[UIWindowScene class]]) { if (!activeScene) {
return; return;
} }
@ -63,7 +81,9 @@ void showKeyboardAlert(const char *title, const char *message, const char *place
UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"Cancel" UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"Cancel"
style:UIAlertActionStyleCancel style:UIAlertActionStyleCancel
handler:^(UIAlertAction *action) { handler:^(UIAlertAction *action) {
free(keyboardInput); if (keyboardInput) {
free(keyboardInput);
}
keyboardInput = strdup(""); keyboardInput = strdup("");
popupWindow.hidden = YES; popupWindow.hidden = YES;
@ -82,8 +102,8 @@ void showAlert(const char *title, const char *message, bool showCancel) {
NSString *alertMessage = [NSString stringWithUTF8String:message]; NSString *alertMessage = [NSString stringWithUTF8String:message];
dispatch_async(dispatch_get_main_queue(), ^{ dispatch_async(dispatch_get_main_queue(), ^{
UIWindowScene *activeScene = (UIWindowScene *)UIApplication.sharedApplication.connectedScenes.allObjects.firstObject; UIWindowScene *activeScene = getMainDeviceWindowScene();
if (!activeScene || ![activeScene isKindOfClass:[UIWindowScene class]]) { if (!activeScene) {
return; return;
} }