Inconsistent Screen Indexes

On Ignition 7.9.11, I’m finding the screen indexes reported by system.gui.getScreens() are inconsistent across multiple workstations.

These Windows 10 workstations each have 5 monitors. The OS Display Settings for each workstation all identify the displays in the same pattern:

  [5]
[4] [3]
[2] [1]

However, when calling system.gui.getScreens() in Ignition, I’m getting varied results…
Workstation 1:

  [1]
[4] [3]
[2] [0]

Workstation 2:

  [0]
[4] [3]
[2] [1]

To be clear, indexing start at 0 or 1 is not the issue, it’s the order that I need to be consistent to support certain features in my project. What could cause this discrepancy between PCs? What controls the Java screen indexes?

I'm still a bit of a newbie on this front, but messed with it a bit on a project.

The OS determines the monitor order. On the project I had, I had to set a particular order for the TVs to be turned on so that Windows would put them in the right order.

1 Like

As stated above, the order the monitors are listed in the OS is correct and consistent between workstations. That’s why I’m confused as to how Ignition is reporting differing locations with the same underlying monitor config.

As Phil has stated elsewhere, sun, moon, stars, etc.

However, I believe it sources from java.awt.GraphicsEnvironment. I don’t know how it puts things in order, possibly in hardware names.

getScreens() should probably also return the x and y properties from the bounds to give the location in the desktop space. In single monitor apps, they’d always be 0,0, but for my three-monitor setup, I get this:

def getScreens():
	import java.awt.GraphicsEnvironment as GE
	g_env = GE.getLocalGraphicsEnvironment()
	screenDevices = g_env.getScreenDevices()

	output = []
	count = 0

	for device in screenDevices:
		config = device.getDefaultConfiguration()
		bounds = config.getBounds()
		output.append((count, bounds.width, bounds.height, bounds.x, bounds.y))
		count += 1

	return output
		
print getScreens()
3 Likes

Thanks @JordanCClark, I was about to start praying to the old gods again.

With your script, I discovered my monitor locations aren’t in a clean grid. Apparently It’s impossible to get the displays to snap into a 4x4 grid in the Display Settings drag-and-drop utility (very cool Microsoft!), they always have some location imperfection of 2-5 px.

I want to avoid having to configure pixel-perfect monitor locations in the registry, so instead I’m using sorted to sort the output of getScreens() by their vertical and horizontal locations. Then I’m assembling a dictionary to map between the expected OS screen indexes and the Java indexes.

Actually, I’m more impresssed you have a fancy-schmancy 5 monitor setup. Heh. :wink:

Also added to the ideas forum, if you want to upvote.

https://ideas.inductiveautomation.com/ignition-features-and-ideas/p/systemguigetscreens-xy-values

1 Like