Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need to programatically obtain screen rotation. I'm using Qt and the X extension XRandr. I'm trying the following:

Display *dpy;
Window root;
XRRScreenConfiguration *conf;
Rotation rotation;

int screen;

dpy = QX11Info::display();
root =  QX11Info::appRootWindow();
conf = XRRGetScreenInfo(dpy, root);
screen = DefaultScreen(dpy);
XRRRotations(dpy, screen, &rotation);

qDebug() << "CURRENT ROTATION:" << rotation;

The problem is that independently of the current screen orientation, set through Displays settings app from Ubuntu, the CURRENT ROTATION output is always 1.

Does anyone knows why?


share|improve this question

I finally found the answer to this. I'm using Qt. Some of the calls are from Qt to get the Window and Screen of X11.

Display *dpy;
Window root = this->winId();
dpy = QX11Info::display();

XRRScreenResources *scrres = XRRGetScreenResources(dpy, root);
XRRCrtcInfo *crtcInfo = XRRGetCrtcInfo(dpy, scrres, *scrres->crtcs);

crtcInfo->rotation can be 1, 2, 4, or 8

Hope this helps someone in the future.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.