fix: restore window and keyboard interactions with queue
This commit is contained in:
@@ -98,6 +98,46 @@ private enum CLIInstanceCheck {
|
||||
return nil
|
||||
}
|
||||
|
||||
static func windowSnapshot(_ window: NSWindow?) -> [String: Any] {
|
||||
guard let window, let content = window.contentView else { return [:] }
|
||||
func surface(in view: NSView) -> NSView? {
|
||||
if view.identifier?.rawValue == "PlaybackSurface" { return view }
|
||||
return view.subviews.lazy.compactMap { surface(in: $0) }.first
|
||||
}
|
||||
var result: [String: Any] = [
|
||||
"width": window.frame.width, "height": window.frame.height,
|
||||
"minWidth": window.minSize.width, "minHeight": window.minSize.height,
|
||||
"maxWidth": window.maxSize.width, "maxHeight": window.maxSize.height,
|
||||
"contentMinWidth": window.contentMinSize.width, "contentMinHeight": window.contentMinSize.height,
|
||||
"contentMaxWidth": window.contentMaxSize.width, "contentMaxHeight": window.contentMaxSize.height,
|
||||
"aspectWidth": window.aspectRatio.width, "aspectHeight": window.aspectRatio.height,
|
||||
"resizable": window.styleMask.contains(.resizable),
|
||||
]
|
||||
if let surface = surface(in: content) {
|
||||
func hit(_ point: NSPoint) -> NSView? {
|
||||
content.hitTest(surface.convert(point, to: content.superview))
|
||||
}
|
||||
result["videoOwnsMouse"] = hit(NSPoint(x: surface.bounds.midX, y: surface.bounds.midY)) === surface
|
||||
result["controlsOwnMouse"] = hit(NSPoint(x: surface.bounds.midX, y: 46)) !== surface
|
||||
result["sidebarOwnsMouse"] = hit(NSPoint(x: surface.bounds.maxX + 130, y: surface.bounds.midY)) !== surface
|
||||
result["videoWidth"] = surface.bounds.width
|
||||
result["videoHeight"] = surface.bounds.height
|
||||
result["surfaceMovesOnMouseDown"] = surface.mouseDownCanMoveWindow
|
||||
let edges = [NSPoint(x: 1, y: content.bounds.midY),
|
||||
NSPoint(x: content.bounds.maxX - 1, y: content.bounds.midY),
|
||||
NSPoint(x: content.bounds.midX, y: 1),
|
||||
NSPoint(x: content.bounds.midX, y: content.bounds.maxY - 1)]
|
||||
let targets = edges.map { point in
|
||||
content.hitTest(content.convert(point, to: content.superview))
|
||||
}
|
||||
result["edgeTargets"] = targets.map { $0.map { String(describing: type(of: $0)) } ?? "native window" }
|
||||
result["edgesAvoidDragSurface"] = targets.allSatisfy { target in
|
||||
target !== surface && !(target.map { String(describing: type(of: $0)).contains("ChromeView") } ?? false)
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
static func run(_ configuration: URL) {
|
||||
let settings = try! JSONSerialization.jsonObject(with: Data(contentsOf: configuration)) as! [String: String]
|
||||
let directory = URL(fileURLWithPath: settings["directory"]!, isDirectory: true)
|
||||
@@ -147,6 +187,9 @@ private enum CLIInstanceCheck {
|
||||
switch action {
|
||||
case "youtube":
|
||||
model.openYouTube(command["url"] as! String)
|
||||
case "queue":
|
||||
model.showsQueue = command["visible"] as! Bool
|
||||
model.revealControls()
|
||||
case "caption":
|
||||
guard let view = window.contentView, let selector = captionSelector(in: view),
|
||||
let cell = selector.cell as? NSPopUpButtonCell, let menu = selector.menu else {
|
||||
@@ -252,6 +295,8 @@ private enum CLIInstanceCheck {
|
||||
"mainWindow": windows.first?.isMainWindow ?? false,
|
||||
"editorText": editorText,
|
||||
"compact": model.isCompact,
|
||||
"showsQueue": model.showsQueue,
|
||||
"window": windowSnapshot(windows.first),
|
||||
"onTop": model.isOnTop,
|
||||
]
|
||||
do {
|
||||
|
||||
Reference in New Issue
Block a user