SCREEN data (Swift vs Xojo)

I am attempting to replicate the logic in the SCREEN object from Xojo
All the data is correct EXCEPT for AVALIABLETOP and TOP

below is the results I get… 1st is Swift , 2nd is Xojo (both are same if only one number)

Screen #0
  Availble Left :    0 
   Availble Top :   80 |   25 <--DIFF
 Availble Width : 2560  
Availble Height : 1335 
           Left :    0
            Top :    0
          Width : 2560
         Height : 1440
          Depth :   24
Screen #1
  Availble Left : 2560
   Availble Top :  215 | 145
 Availble Width : 1920
Availble Height : 1080
           Left : 2560
            Top :  215 | 145
          Width : 1920
         Height : 1080
          Depth :   24
Screen #2
  Availble Left : -1920
   Availble Top :   205 | 155
 Availble Width :  1920
Availble Height :  1080
           Left : -1920
            Top :   205 | 155
          Width :  1920
         Height :  1080
          Depth :    24

This is the Xojo Code

Dim s As String
Dim i As Integer = 2
s = s + "Avail. Left=" + Str(Screen(i).AvailableLeft) + EndOfLine
s = s + "Avail. Top=" + Str(Screen(i).AvailableTop) + EndOfLine
s = s + "Avail. Width=" + Str(Screen(i).AvailableWidth) + EndOfLine
s = s + "Avail. Height=" + Str(Screen(i).AvailableHeight) + EndOfLine
s = s + " Left=" + Str(Screen(i).Left) + EndOfLine
s = s + "  Top=" + Str(Screen(i).Top) + EndOfLine
s = s + "  Width=" + Str(Screen(i).Width) + EndOfLine
s = s + "  Height=" + Str(Screen(i).Height) + EndOfLine
s = s + "  Depth=" + Str(Screen(i).depth) + EndOfLine
MsgBox(s)

This is the Swift Code

class ds$SCREEN : NSObject {
	private var zIndex  : Int = -1

	required public init?(coder: NSCoder) { fatalError("init(coder:) ds$SCREEN") }
	public init(screen:Int) {
		super.init()
		zIndex = screen
		show()
	}
	var availableHeight : Int { return Int(zScreen.visibleFrame.height) }
	var availableLeft   : Int { return Int(zScreen.visibleFrame.origin.x) }
	var availableTop    : Int { return Int(zScreen.visibleFrame.origin.y) }
	var availableWidth  : Int { return Int(zScreen.visibleFrame.width) }
	var left            : Int { return Int(zScreen.frame.origin.x) }
	var top             : Int { return Int(zScreen.frame.origin.y) }
	var height          : Int { return Int(zScreen.frame.height) }
	var width           : Int { return Int(zScreen.frame.width) }
	var depth           : Int { return zScreen.depth.bitsPerPixel }
	//
	// Screen data COULD change between calls
	//
	private var zScreen : NSScreen { return NSScreen.screens[zIndex] }
	public func show() {
		print("Screen #\(zIndex)")
		print("  Availble Left : \(availableLeft)")
		print("   Availble Top : \(availableTop)")
		print(" Availble Width : \(availableWidth)")
		print("Availble Height : \(availableHeight)")
		print("           Left : \(left)")
		print("            Top : \(top)")
		print("          Width : \(width)")
		print("         Height : \(height)")
		print("          Depth : \(depth)")
	}
}

public func initSCREEN() {
	screen.removeAll()
	let  screenArray = NSScreen.screens
	for i in(0...screenArray.count-1) {
		let temp = ds$SCREEN(screen:i)
		screen.append(temp)
	}
}

Note I tried both frame.origin.x and frame.minX … same results

I couldn’t tell if this was this a question? Was it why is your value different?

If so, the 80 is probably the height of the dock, in swift the origin might be bottom left?

That is what I begin thinking as well

which means the Swift AvailableHeight should be

frame.height-visibleframe.height-visibleframe.origin.y

which would be
1440-1335-80 or 25

That works for the MAIN screen where the dock/menubar are, but not for the other screens
Swift says the TOP for Screen #1 is 215, but Xojo says it is 145
there is no menu/dock so the height is 100% (1080px), so inverted coor or not, it doesn’t match

1080-1080-215 = -215 :frowning:

Are you able to slide the mouse along the bottom edge of your main screen and onto the bottom of your left screen or is there a lip? If you slide it along the bottom of the left screen back onto the main screen, does it appear around 215 pixels up the side of the main screen. Are the bottoms aligned?

so no, the tops are aligned…
the main screen is 1440 tall and the others are 1080 (a diff of 360)

And the white bit at the top of the middle screen depicts what? the menu?

yes (I assume you don’t have a mac then?)

I do but its in another room collecting dust and it takes about 10 minutes to get going and that fine detail on an os I dont use often doesnt stick in my brain, just tweaking a vm a mo to give me multiple monitors.

VMware isn’t letting me add multiple monitors to a mac vm :frowning:

Screen 2 is 205 up off the base of Screen 0, you could test this by putting a quick xojo app together that reports the mouse position on the screen as you move from the bottom of the left screen into the main screen. You will also be able to see where the top of the left screen meets up with the main screen by sliding across to the top of the left screen onto the main screen. The numbers will add you just need to figure out which numbers are the right ones to use basing it all on 0,0 being in the bottom left corner in swift.

The height of the menu can be worked out with Apple Developer Documentation so you don’t have to guess the height of the dock, which can be calculated from the remainder.

Side note, you can actually see the vertical offset difference between the two outside monitors on that screenshot you posted, one is ever so slightly at a different height than the other. This is reflected in the numbers you posted at the start, one screen is 215 and the other is 205 up from the 0.

assuming your observations are correct, then the values Xojo is reporting would be “wrong” then

Unless you align the bottoms or the tops for your tests it will be a pain to check the numbers, I’ll dig out my laptop later and set up a second screen on it and run some tests after figuring out how to install and run swift.

The question is… is Swift right? is Xojo right? Does Swift need some alterations to the function to get the “right” answer. Apple has really vague and incomplete information with ZERO examples

qt reacts like swift and not like Xojo. Could be an argument for Swift / Apple and not Xojo to be right.

is there a simple QT script I could try without any 3rd part installs?

Just looking at your screen 1 numbers:

If xojo is reporting screen1 145 down, then the bottom of screen1 is 1440-145 from the top of screen 0 for the value of swift. The screen is 1080 so that’s 1440-145-1080 = 215 which is the value you see in swift. 215 up from the bottom of screen0

Xojo is just reporting the values based on 0,0 being in the top left of screen0. The numbers are fine, they are just from different locations.

So to get the xojo numbers from swift do

1440 - 1080 - 215

which will give you how far down screen1 is from the top of screen0

what I’m finding out… everything is relative to MAIN… not absolutes

Well I hope you noticed that from your first post with the left pos of screen2 being -1920

left to right makes sense, and matchs Xojo, it was top that was the “issue”