Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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?

Thanks

share|improve this question

1 Answer 1

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

 
discard

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.