tmandry / Swindler

macOS window management library for Swift
https://tmandry.github.io/Swindler/docs/main/
MIT License
690 stars 66 forks source link

Setting frame can result unexpected coordinates #94

Closed romadryud closed 2 months ago

romadryud commented 1 year ago

Following code will produce following logs when created window goes off the screen:

print("addWindow x: \(newWindowSizes.x)")
setWindow(window: window, x: newWindowSizes.x, y: newWindowSizes.y, width: newWindowSizes.width, height: newWindowSizes.height)
        .done { newRect in
          self.windows.append(window)
          self.newWindowSizes.x = newRect.maxX
          print("new window created at minX: \(newRect.minX)")
        }
addWindow x: 3840.0
setWindow: 3840.0 1280.0
Frame changed from (1280.0, 0.0, 1280.0, 1055.0) to (3800.0, 0.0, 1280.0, 1055.0), external: false
new window created at minX: 3800.0

setWindow is just wrapper for window.frame.set(rect)

How I can debug this behaviour?

romadryud commented 1 year ago

@tmandry do you have any thoughts?

tmandry commented 1 year ago

Usually the accessibility APIs don't allow moving a window off-screen. (It is up to the application who owns the window to decide how to respond to the request, and by default it clamps the input so enough of the window remains on-screen.)