Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XineramaQueryScreens only returns a PXineramaScreenInfo #41

Open
KenJean opened this issue Jan 23, 2022 · 1 comment
Open

XineramaQueryScreens only returns a PXineramaScreenInfo #41

KenJean opened this issue Jan 23, 2022 · 1 comment

Comments

@KenJean
Copy link

KenJean commented Jan 23, 2022

Just ran into this on a two-monitor set-up.

When invoking XineramaQueryScreens (in xinerama.nim,) the function merely returns a PXineramaScreenInfo - i.e. a pointer to a XineramaScreenInfo object.

The original C Xlib XineramaQueryScreens function returns a pointer to a pointer of PXineramaScreenInfo objects. (i.e. a pointer to an array of XineramaScreenInfo objects.) As it is now in Nim I can only access the first XineramaScreenInfo object, not the second.

I'm sure there is a way to force cast this PXineramaScreenInfo into an array of PXineramaScreenInfos. I'm not so up to speed with Nim yet, but I guess I can figure it out.

In any case, I thought I'd report this little quirk.

⇒ KJ

@KenJean
Copy link
Author

KenJean commented Jan 24, 2022

Figured out a way around the problem:

let pDisplay = XOpenDisplay(nil)
var numberOfMonitors: cint
let screenInfo = XineramaQueryScreens(pDisplay, numberOfMonitors.addr())
let arrayPointer = cast[ptr UncheckedArray[XineramaScreenInfo]](screenInfo)

Now arrayPointer can be used to access the metrics of each monitor, e.g.:

arrayPointer[0].width = width of the first monitor
arrayPointer[1].width = width of the second monitor

... just leaving a trail here in case someone does a web search on this.

⇒ KJ

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant