Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions UILib/Provider/GREYUIWindowProvider.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,22 @@
#import "GREYFatalAsserts.h"
#import "GREYAppleInternals.h"

/** @return The first responder view by searching from @c view. */
static UIView* GetFirstResponderSubview(UIView* view) {
if ([view isFirstResponder]) {
return view;
}

for (UIView* subview in [view subviews]) {
UIView* firstResponder = GetFirstResponderSubview(subview);
if (firstResponder) {
return firstResponder;
}
}

return nil;
}

UIWindow *GREYGetApplicationKeyWindow(UIApplication *application) {
// New API only available on Xcode 13+
#if (defined(__MAC_OS_X_VERSION_MAX_ALLOWED) && __MAC_OS_X_VERSION_MAX_ALLOWED >= 120000) || \
Expand Down Expand Up @@ -131,6 +147,14 @@ + (NSArray *)windowsFromLevelOfWindow:(UIWindow *)window withStatusBar:(BOOL)inc
[windows addObject:keyWindow];
}

if (@available(iOS 16, *)) {
UIResponder* firstResponder = GetFirstResponderSubview(keyWindow);
UIView* inputView = firstResponder.inputView;
if (inputView) {
[windows addObject:inputView.window];
}
}

if (includeStatusBar) {
UIWindow *statusBarWindow;
// Add the status bar if asked for.
Expand Down