Post

Replies

Boosts

Views

Activity

NSScreen frame location with multiple monitors
I have a Mac Studio 2023 M2 Max Running Sonoma 14.6.1 Developing in XCode 16.1 It seems that the NSScreen frame settings may be incorrect. The frame settings received from NSScreen.screens don't seem to match up with the Desktop arrangement settings in the Settings. Apologies in advance for this long post! for screen in NSScreen.screens { let name = screen.localizedName Globals.logger.debug("Globals initializeScreens - screen \(i) '\(name, privacy: .public)'") Globals.logger.debug("Globals initializeScreens - '\(screen.debugDescription, privacy: .public)'") } This is what I receive in the log: Globals initializeScreens - '<NSScreen: 0x600000ef4240; name="PHL 346E2C"; backingScaleFactor=1.000000; frame={{0, 0}, {3440, 1440}}; visibleFrame={{0, 0}, {3440, 1415}}>' Globals initializeScreens - screen 2 'Blackmagic (1)' Globals initializeScreens - '<NSScreen: 0x600000ef42a0; name="Blackmagic (1)"; backingScaleFactor=1.000000; frame={{-3840, 0}, {1920, 1080}}; visibleFrame={{-3840, 0}, {1920, 1055}}>' Globals initializeScreens - screen 3 'Blackmagic (4)' Globals initializeScreens - '<NSScreen: 0x600000ef4360; name="Blackmagic (4)"; backingScaleFactor=1.000000; frame={{-1920, 0}, {1920, 1080}}; visibleFrame={{-1920, 0}, {1920, 1055}}>' Globals initializeScreens - screen 4 'Blackmagic (2)' Globals initializeScreens - '<NSScreen: 0x600000ef43c0; name="Blackmagic (2)"; backingScaleFactor=1.000000; frame={{5360, 0}, {1920, 1080}}; visibleFrame={{5360, 0}, {1920, 1055}}>' Globals initializeScreens - screen 5 'Blackmagic (3)' Globals initializeScreens - '<NSScreen: 0x600000ef4420; name="Blackmagic (3)"; backingScaleFactor=1.000000; frame={{3440, 0}, {1920, 1080}}; visibleFrame={{3440, 0}, {1920, 1055}}>' It looks like the frame settings for Blackmagic (2) and Blackmagic (4) are switched. The setup has five monitors. Four are using the USB-C Digital AV Multiport Adapters. The output for these are streamed into a rack of A/V equipment using BlackMagic Design mini converters and monitors. My Swift application allows users to open four movies, one for each of the AV Adapters. The movies can then be played back in sync for later processing by the A/V equipment. Here are some screen captures that show my display settings. Blackmagic (1) and Blackmagic (2) are to the left of the main screen. Blackmagic (3) and Blackmagic(4) are to the right of the main screen. The desktop is hard to see but is correct. The wallpaper settings are all correct. The wallpaper is correctly ordered when displayed on the monitors. After opening the movies and using the NSScreen frame settings, the displays are incorrectly ordered. Test B and Test D are switched, which is what I would expect given the NSScreen frame values. Any ideas? I've tried re-arranging the desktops, rebooting, etc. but no luck. The code that changes the screen location is similar to this post on Stack Overflow public func setDisplay( screen: NSScreen ) { Globals.logger.log("MovieWindowController - setDisplay = \(screen.localizedName, privacy: .public)") Globals.logger.debug("MovieWindowController - setDisplay - '\(screen.debugDescription, privacy: .public)'") let dx = CGFloat(Constants.midX) let dy = CGFloat(Constants.midY) var pos = NSPoint() pos.x = screen.visibleFrame.midX - dx pos.y = screen.visibleFrame.midY - dy Globals.logger.debug("MovieWindowController - setDisplay - x = '\(pos.x, privacy: .public)', y = '\(pos.y, privacy: .public)'") window?.setFrameOrigin(pos) } The log show just what I would expect given the incorrect frame values. MovieWindowController - setDisplay = Blackmagic (1) MovieWindowController - setDisplay - '<NSScreen: 0x6000018e8420; name="Blackmagic (1)"; backingScaleFactor=1.000000; frame={{-3840, 0}, {1920, 1080}}; visibleFrame={{-3840, 0}, {1920, 1055}}>' MovieWindowController - setDisplay - x = '-3840.000000', y = '-12.500000' MovieWindowController - setDisplay = Blackmagic (2) MovieWindowController - setDisplay - '<NSScreen: 0x6000018a10e0; name="Blackmagic (2)"; backingScaleFactor=1.000000; frame={{5360, 0}, {1920, 1080}}; visibleFrame={{5360, 0}, {1920, 1055}}>' MovieWindowController - setDisplay - x = '5360.000000', y = '-12.500000' MovieWindowController - setDisplay = Blackmagic (3) MovieWindowController - setDisplay - '<NSScreen: 0x6000018cc8a0; name="Blackmagic (3)"; backingScaleFactor=1.000000; frame={{3440, 0}, {1920, 1080}}; visibleFrame={{3440, 0}, {1920, 1055}}>' MovieWindowController - setDisplay - x = '3440.000000', y = '-12.500000' MovieWindowController - setDisplay = Blackmagic (4) MovieWindowController - setDisplay - '<NSScreen: 0x6000018c9ce0; name="Blackmagic (4)"; backingScaleFactor=1.000000; frame={{-1920, 0}, {1920, 1080}}; visibleFrame={{-1920, 0}, {1920, 1055}}>' MovieWindowController - setDisplay - x = '-1920.000000', y = '-12.500000' Am I correct? I think this is driving me crazy! Thanks in advance! Edit: The mouse behavior is correct in moving across the displays!
2
0
100
5d
Send TCP request to server and wait for response or timeout
Hi, all! I've read this post and it helped get me started. My application needs to send a request to a server and receive a response. If no response is received within some timeout, it should return an error string. Apple’s TCP sample code More specifically, the server will usually return a string with something like '200 ok' or perhaps data specific to an inquiry request. The 'send' and 'startReceive' functions work perfectly, but the application needs to wait for the response and interpret the data before continuing. I guess the ideal would be to create a wrapper function around the 'send' and 'startReceive' that would return the String response or an error message if the response was not received before a timeout. So pass in a request string and timeout seconds value and receive a string. I have no idea what the proper way of doing this. I didn't see any Tags for network related questions, so macOS it is! Thanks for reading! Pete
0
0
306
Jan ’23
CIKernel call - performance hit and memory leak
I've been struggling with a bug with a Metal CIKernel call. The kernel looks like this: extern "C" float4 FeedbackIn(coreimage::sampler src, coreimage::sampler gradient, coreimage::sampler feedback, float time, float threshold, float optionValue, coreimage::destination dest ) {       float4 input = src.sample(src.coord());       return input; } The call from Swift looks like this: let result = ciKernel!.apply(extent: self.inputImage!.extent,                   roiCallback: { [self]          (index, rect) -> CGRect in            let roiRect = rect.insetBy(dx: -1 * range, dy: -1 * range )            return roiRect          },           arguments: [self.inputImage!, gradient!, feedback!, time, threshold, scaledOption])         //       CIImage,      CIImage,  CIImage,  Float, Float,   Float When I remove the 'feedback' from the Kernel and corresponding argument from the list in the Swift code, there is no issue. With the code as displayed, the export function will gradually slow down and memory size increase in Instruments Leaks. Instruments Leaks does not show any leaks. I am running Xcode 13.3, macOS 12.1.1 on an iMac (Retina 5K, 27-inch, Late 2015). Any insight on this is greatly appreciated! I don't know if passing the third CIImage is allowed or this is a bug. Thanks to all in advance!
10
0
806
Apr ’22
Edit and play back HDR video with AVFoundation - WWDC20-10009 - Export dialog hangs at 100%
I have downloaded and run this example. The Export command seems to hang when it hits 100%. Unfortunately I'm a noob and can't find the cause of the problem. The dialog processing seems a bit confusing for a new guy, I certainly don't pretend to understand the use of class, structs, etc. in this part of the example code. I have been able to understand the metal processing, custom filters, etc. I am running Mac OS 12.2.1, Xcode 13.3 Thanks to all for reading! Somehow I was not able to add the tag for this in the 'search for a tag' on the web page.
2
0
617
Mar ’22