From 1509eaf8ad6cc2383fbac77b0ab75968d23fcda2 Mon Sep 17 00:00:00 2001 From: Jannik <72194488+JannikGM@users.noreply.github.com> Date: Mon, 29 Apr 2024 12:17:49 +0200 Subject: [PATCH] Use processIdentifier to allow multiple screens --- DeskPad/AppDelegate.swift | 4 ++-- DeskPad/Frontend/Screen/ScreenViewController.swift | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/DeskPad/AppDelegate.swift b/DeskPad/AppDelegate.swift index 8e044cc..34366fb 100644 --- a/DeskPad/AppDelegate.swift +++ b/DeskPad/AppDelegate.swift @@ -9,14 +9,14 @@ class AppDelegate: NSObject, NSApplicationDelegate { var window: NSWindow! func applicationDidFinishLaunching(_: Notification) { + let pid = ProcessInfo().processIdentifier let viewController = ScreenViewController() window = NSWindow(contentViewController: viewController) window.delegate = viewController - window.title = "DeskPad" + window.title = "DeskPad (" + String(pid) + ")" window.makeKeyAndOrderFront(nil) window.titlebarAppearsTransparent = true window.isMovableByWindowBackground = true - window.titleVisibility = .hidden window.backgroundColor = .white window.contentMinSize = CGSize(width: 400, height: 300) window.contentMaxSize = CGSize(width: 3840, height: 2160) diff --git a/DeskPad/Frontend/Screen/ScreenViewController.swift b/DeskPad/Frontend/Screen/ScreenViewController.swift index d36cd47..abbabc9 100644 --- a/DeskPad/Frontend/Screen/ScreenViewController.swift +++ b/DeskPad/Frontend/Screen/ScreenViewController.swift @@ -20,16 +20,17 @@ class ScreenViewController: SubscriberViewController, NSWindowDe override func viewDidLoad() { super.viewDidLoad() - + + let pid = ProcessInfo().processIdentifier let descriptor = CGVirtualDisplayDescriptor() descriptor.setDispatchQueue(DispatchQueue.main) - descriptor.name = "DeskPad Display" + descriptor.name = "DeskPad Display (" + String(pid) + ")" descriptor.maxPixelsWide = 3840 descriptor.maxPixelsHigh = 2160 descriptor.sizeInMillimeters = CGSize(width: 1600, height: 1000) descriptor.productID = 0x1234 descriptor.vendorID = 0x3456 - descriptor.serialNum = 0x0001 + descriptor.serialNum = uint32(pid) let display = CGVirtualDisplay(descriptor: descriptor) store.dispatch(ScreenViewAction.setDisplayID(display.displayID))