xopendisplay no display varibale declared

Glynn Clements glynn at gclements.plus.com
Wed Sep 22 13:52:35 PDT 2010


yoni dana wrote:

> Thanks for display. I pass as a parameter :0.0 and it works.
> But if i have a problem if two screen are connected to the computer or
> remote desktop connection,

What problem?

> The reason i need to use XOpenDisplay is to retrieve screen resolution.
> Is there another way to do it

Any X application needs to know which X server to connect to.

The resolution is a property of a screen, not a display (which can
have multiple screens). Once you have a connection to a display, you
can determine the number of screens with the ScreenCount() macro, and
you can get a reference to an individual screen with the
ScreenOfDisplay() macro.

Or you can get the default screen via DefaultScreenOfDisplay(), and
run the program with a display of e.g. ":0.1" (the number after the
dot specifies the default screen).

With remote-desktop protocols such as VNC, it may be impossible to
determine the resolution of the physical screen. This may not even be
a meaningful question, as there won't be a physical screen when no
viewer is connected, and there will be multiple physical screens when
multiple viewers are connected.

-- 
Glynn Clements <glynn at gclements.plus.com>



More information about the xorg mailing list