Skip to content

Commit

Permalink
mac: fix unexpected return of forcePosition
Browse files Browse the repository at this point in the history
Int32(VO_WIN_FORCE_POS) == 1, regardless of `--force-window-position`
  • Loading branch information
NekoAsakura committed Dec 12, 2024
1 parent f4a35a0 commit 0e0059f
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions video/out/mac/common.swift
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class Common: NSObject {
}

func initWindow(_ vo: UnsafeMutablePointer<vo>, _ previousActiveApp: NSRunningApplication?) {
let (targetScreen, wr, _) = getInitProperties(vo)
let (targetScreen, wr, forcePosition) = getInitProperties(vo)

guard let view = self.view else {
log.error("Something went wrong, no View was initialized")
Expand Down Expand Up @@ -104,6 +104,12 @@ class Common: NSObject {
window.setMinimized(minimized)
window.makeMain()
window.makeKey()
window.isMovable = !forcePosition
if forcePosition {
NSEvent.addLocalMonitorForEvents(matching: [.leftMouseDragged]) { [weak self] event in

Check failure on line 109 in video/out/mac/common.swift

View workflow job for this annotation

GitHub Actions / swift-lint

Unused Closure Parameter Violation: Unused parameter in a closure should be replaced with _ (unused_closure_parameter)
return nil
}
}

view.layer?.contentsScale = window.backingScaleFactor

Expand Down Expand Up @@ -411,6 +417,7 @@ class Common: NSObject {

func getWindowGeometry(forScreen screen: NSScreen,
videoOut vo: UnsafeMutablePointer<vo>) -> (NSRect, Bool) {
let option = OptionHelper(vo, vo.pointee.global)
let r = screen.convertRectToBacking(screen.frame)
let targetFrame = option.mac.macos_geometry_calculation == FRAME_VISIBLE
? screen.visibleFrame : screen.frame
Expand All @@ -437,7 +444,7 @@ class Common: NSObject {
let y = CGFloat(-geo.win.y1)
let x = CGFloat(geo.win.x0)
let wr = screen.convertRectFromBacking(NSRect(x: x, y: y, width: width, height: height))
return (wr, Bool(geo.flags & Int32(VO_WIN_FORCE_POS)))
return (wr, Bool(geo.flags & Int32(option.vo.force_window_position)))
}

func getInitProperties(_ vo: UnsafeMutablePointer<vo>) -> (NSScreen, NSRect, Bool) {
Expand Down

0 comments on commit 0e0059f

Please sign in to comment.