Skip to content

基于自定义规则的番剧采集APP,支持流媒体在线观看,支持弹幕,支持实时超分辨率。

fix(macos): prevent click-through on inactive window (#2073)

Huiyu Gao9d573af521d4
diff --git a/macos/Runner/MainFlutterWindow.swift b/macos/Runner/MainFlutterWindow.swift
index 8ead7d30..87151b59 100644
--- a/macos/Runner/MainFlutterWindow.swift
+++ b/macos/Runner/MainFlutterWindow.swift
@@ -20,4 +20,17 @@ class MainFlutterWindow: NSWindow {
super.order(place, relativeTo: otherWin)
hiddenWindowAtLaunch()
}
+
+ override func sendEvent(_ event: NSEvent) {
+ if !isKeyWindow,
+ event.type == .leftMouseDown || event.type == .rightMouseDown || event.type == .otherMouseDown,
+ let contentView = self.contentView,
+ let hit = contentView.superview?.hitTest(event.locationInWindow),
+ hit == contentView || hit.isDescendant(of: contentView) {
+ NSApp.activate(ignoringOtherApps: true)
+ self.makeKeyAndOrderFront(nil)
+ return
+ }
+ super.sendEvent(event)
+ }
}