Skip to content

Commit

Permalink
iOS: Fix gamepad detection when becoming firstResponder
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=269292

Reviewed by Brady Eidson.

Gamepads were only detected at initial load of the page if the WKWebView
were marked as the firstResponder, rather than detecting when the
WKWebView becomes or resigns the firstResponder.

This aligns the behaviour with WKWebView on macOS.

* Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView becomeFirstResponderForWebView]):
(-[WKContentView resignFirstResponderForWebView]):
Enable/disable checking for gamepads when the WKWebView becomes or
resigns firstResponder status.

Canonical link: https://commits.webkit.org/279124@main
  • Loading branch information
dpogue authored and cdumez committed May 22, 2024
1 parent 00d92c3 commit 24bc94e
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
#import "TextCheckerState.h"
#import "TextInputSPI.h"
#import "TextRecognitionUpdateResult.h"
#import "UIGamepadProvider.h"
#import "UIKitSPI.h"
#import "UIKitUtilities.h"
#import "WKActionSheetAssistant.h"
Expand Down Expand Up @@ -1885,6 +1886,10 @@ - (BOOL)becomeFirstResponderForWebView
[strongSelf stopDeferringInputViewUpdates:WebKit::InputViewUpdateDeferralSource::BecomeFirstResponder];
});

#if ENABLE(GAMEPAD)
WebKit::UIGamepadProvider::singleton().viewBecameActive(*_page);
#endif

_page->activityStateDidChange(WebCore::ActivityState::IsFocused, WebKit::WebPageProxy::ActivityStateChangeDispatchMode::Immediate);

if ([self canShowNonEmptySelectionView] || (!_suppressSelectionAssistantReasons && _activeTextInteractionCount))
Expand Down Expand Up @@ -1986,6 +1991,10 @@ - (BOOL)resignFirstResponderForWebView
[self _handleDOMPasteRequestWithResult:WebCore::DOMPasteAccessResponse::DeniedForGesture];
_page->activityStateDidChange(WebCore::ActivityState::IsFocused, WebKit::WebPageProxy::ActivityStateChangeDispatchMode::Immediate);

#if ENABLE(GAMEPAD)
WebKit::UIGamepadProvider::singleton().viewBecameInactive(*_page);
#endif

_isHandlingActiveKeyEvent = NO;
_isHandlingActivePressesEvent = NO;

Expand Down

0 comments on commit 24bc94e

Please sign in to comment.