0

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

1 Answer 1

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .