Add window filtering mechanism for remote Cocoa event monitoring
Moderate
Commit Hash:
6a3bc73c476cb0dba52b2c1b6073604b85fbf094
Commit Time: 2025-09-25 15:53:17+00:00
Impact Level: Moderate
Generated By: webview2-upstream-sentry
Upstream Review:
View Upstream Review 🔗
📋 Summary
This submission introduces a window filtering mechanism for the event monitoring functionality of remote cocoa windows. The DispatchMonitorEvent interface has been modified to add a boolean parameter, target_is_this_window, to indicate whether the event target matches the correct window. This parameter is passed from NativeWidgetNSWindowBridge through the mojom interface to the remote cocoa EventMonitor implementation, where proper filtering is performed. This change resolves the previous issue where the event monitoring code did not filter events by specific windows, which caused some callers to receive events from all windows. Additionally, a previously skipped unit test has been fixed, and some regression issues that occurred during the initial implementation of remote cocoa EventMonitor support have been addressed.
🎯 Impact Analysis
The impact of this change on WebView2Mac is mainly reflected in the following aspects:
1. **Interface Compatibility Impact**: The method signature of DispatchMonitorEvent has changed, with the addition of the target_is_this_window parameter. Since WebView2Mac inherits the NativeWidgetNSWindowHostHelper interface, if it implements this interface, the method signature needs to be updated to maintain compatibility.
2. **Event Filtering Mechanism Improvement**: The new filtering mechanism ensures that each window only receives events targeted at itself, which may improve the accuracy of event handling in WebView2Mac and prevent receiving irrelevant events from other windows.
3. **Functional Stability Enhancement**: The regression issue and unit tests of the remote cocoa EventMonitor have been fixed, which will improve the overall stability of the remote cocoa framework and indirectly benefit WebView2Mac, which depends on this framework.
Since WebView2Mac relies heavily on the remote cocoa framework for window management and event handling, these improvements should be beneficial. However, it should be noted that the interface changes may require corresponding code updates.
1. **Interface Compatibility Impact**: The method signature of DispatchMonitorEvent has changed, with the addition of the target_is_this_window parameter. Since WebView2Mac inherits the NativeWidgetNSWindowHostHelper interface, if it implements this interface, the method signature needs to be updated to maintain compatibility.
2. **Event Filtering Mechanism Improvement**: The new filtering mechanism ensures that each window only receives events targeted at itself, which may improve the accuracy of event handling in WebView2Mac and prevent receiving irrelevant events from other windows.
3. **Functional Stability Enhancement**: The regression issue and unit tests of the remote cocoa EventMonitor have been fixed, which will improve the overall stability of the remote cocoa framework and indirectly benefit WebView2Mac, which depends on this framework.
Since WebView2Mac relies heavily on the remote cocoa framework for window management and event handling, these improvements should be beneficial. However, it should be noted that the interface changes may require corresponding code updates.
Impacted Classes:
remote_cocoa::mojom::NativeWidgetNSWindowHost
remote_cocoa::NativeWidgetNSWindowBridge
views::NativeWidgetMacNSWindowHost
views::NativeWidgetMacEventMonitor::Client
views::EventMonitorRemoteCocoa
views::MenuPreTargetHandlerMac