interrobang icon indicating copy to clipboard operation
interrobang copied to clipboard

Multiscreen: respect primary output

Open lahwaacz opened this issue 9 years ago • 3 comments

I don't like the suggestion from #21 much, the Xrandr extension allows setting primary output, which I think is to solve exactly the problem of static geometry configurations.

The solution which works quite well for me is to query the primary output, set the default position to (output->x, output->y) instead of (0,0) and set the default window width to the width of the output instead of the full screen:

...
#include <X11/extensions/Xrandr.h>
...

XRRScreenResources* res = XRRGetScreenResources(dpy, root);
RROutput output = XRRGetOutputPrimary(dpy, root);
if (output != 0) {
    XRROutputInfo* output_info = XRRGetOutputInfo(dpy, res, output);
    if (output_info->connection == RR_Connected && output_info->crtc != 0) {
        XRRCrtcInfo* crtc_info = XRRGetCrtcInfo (dpy, res, output_info->crtc);
        x += crtc_info->x;
        y += crtc_info->y;
        w = (w ? w : crtc_info->width);
        XRRFreeCrtcInfo(crtc_info);
    }
    XRRFreeOutputInfo(output_info);
}
XRRFreeScreenResources(res);

...

The part I haven't thought of yet is the behaviour of special (negative) values passed to geometry, which move the default position to the centre of the full screen. On the other hand when default position is not unconditionally (0,0), negative values make sense even for moving the position.

It would be nice to have this implemented in interrobang, even if not as a default option.

lahwaacz avatar Apr 12 '15 10:04 lahwaacz