Calling Xrandr functions in C++ code

Tomas Carnecky tom at
Mon Nov 10 10:28:03 PST 2008

On 11/10/2008 07:02 PM, Garbs, Leigh Steven (LARC-D107)[UNISYS 
> Hello all!
> I’m trying to use Xrandr to get a display to change resolution, refresh
> rate, and/or turn interlacing on or off, and I’d like to do this with
> C++. I’ve found plenty of websites with tutorials on how to do this from
> the command line, but I haven’t seen anything on how to directly use
> Xrandr functions from code besides the man page. I suppose I could try
> and use system calls to use Xrandr from the command line, but if
> possible I’d rather not. What complicates this further is the fact that
> I’ve never done any X Window programming, so some of the terminology is
> lost on me.
> Is there anywhere I can go for hints on how to do this, or am I stuck
> with the man page?

The xrandr commandline utility uses then libXrandr library. See 'man 3 
Xrandr' for the C functions you can use from your C++ application. You 
can also take a look at the xrandr source code (you can see the source 
for example here:


More information about the xorg mailing list