+ init(_ configuration: CaptureSessionConfiguration, frame: NSRect, button: NSRect) {
+ super.init(frame: frame)
+ preventResize = configuration.preventResize
+ preventMove = configuration.preventMove
+ autoStart = configuration.autoStart
+ self.button = button
+
+ for screen in NSScreen.screens {
+ print(screen.frame)
+ // BEFORE YOU WENT TO BED:
+ // You were checking which screen contains the button, so you can calculate the offset which should give you
+ // the location of the button, which you can then use to draw the button at the same offset whenever you need
+ // to change screen! This would keep the behavior of pressing the record button.
+ // If this does work, remember to then test it with a Hi DPI display, because we might need to adjust for pixel
+ // density.
+ // Finally, if it does work, make sure the alternate monitor still responds, by adjusting the behavior of the
+ // real button
+ if screen.frame.intersects(button) {
+ print("CONTAINS! ->")
+ let relativeX = screen.frame.width - button.maxX
+ let relativeY = screen.frame.height - button.maxY
+ print("The rect is at (\(relativeX), \(relativeY)) relative to the top right of the screen frame.")
+ } else {
+ print("NO CONTAINS ->")
+ }
+ print(button)
+ }
+
+ if configuration.x != nil || configuration.y != nil || configuration.width != nil || configuration.height != nil {
+ box = NSRect(
+ x: configuration.x ?? Int(frame.width / 2.0),
+ y: configuration.y ?? Int(frame.height / 2.0),
+ width: configuration.width ?? 400,
+ height: configuration.height ?? 400
+ )
+ }
+
+ if autoStart {
+ DispatchQueue.main.asyncAfter(deadline: .now() + 3.0) {
+ NotificationCenter.default.post(name: .startRecording, object: nil, userInfo: nil)
+ }
+ }
+ }
+
+ required init?(coder: NSCoder) {
+ fatalError("init(coder:) has not been implemented")
+ }
+
+ private var buttons: [NSRect] = []