aboutsummaryrefslogtreecommitdiffstats
path: root/src/newt/native/X11RandR13.c
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2015-03-09 15:45:36 +0100
committerSven Gothel <[email protected]>2015-03-09 15:45:36 +0100
commit0adbc977ac7848e8092fa1d58174d0a37aabb86b (patch)
tree3917a3cd756df3fdaa4320bfc4ebc9c32bb43f71 /src/newt/native/X11RandR13.c
parentf0f6ee411efb97d34c443c070bb640c8d8a8333f (diff)
Bug 1142 - NEWT: Add support to retrieve the primary MonitorDevice
Support added for - Windows - X11 XRandR 1.3 - OSX Note: Our whole MonitorMode association handling is currently _not_ dynamic. - only on Windows we actually use native unique ID, which might not change (adapter and monitor idx) - On OSX and X11 we simply use indices, but if monitor setup changes - they refer to different instances. In case it is desired to cover dynamic monitor setup change, we need to address this issue in a new bug entry.
Diffstat (limited to 'src/newt/native/X11RandR13.c')
-rw-r--r--src/newt/native/X11RandR13.c29
1 files changed, 22 insertions, 7 deletions
diff --git a/src/newt/native/X11RandR13.c b/src/newt/native/X11RandR13.c
index 1d721efcb..4f52ad190 100644
--- a/src/newt/native/X11RandR13.c
+++ b/src/newt/native/X11RandR13.c
@@ -61,16 +61,23 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_RandR13_freeScreenResources0
#define SAFE_STRING(s) (NULL==s?"":s)
-static void dumpOutputs(const char *prefix, Display *dpy, XRRScreenResources *resources, int noutput, RROutput * outputs) {
- int i, j;
- fprintf(stderr, "%s %p: Output count %d\n", prefix, resources, noutput);
+static void dumpOutputs(const char *prefix, Display *dpy, int screen_idx, XRRScreenResources *resources, int noutput, RROutput * outputs) {
+ int i, j, primIdx=0;
+ Window root = RootWindow(dpy, screen_idx);
+ RROutput pxid = XRRGetOutputPrimary (dpy, root);
+ fprintf(stderr, "%s %p: Output[count %d, prim %#lx]\n", prefix, resources, noutput, pxid);
for(i=0; i<noutput; i++) {
+ int isPrim =0;
RROutput output = outputs[i];
+ if ( None != pxid && pxid == output ) {
+ primIdx = i;
+ isPrim = 1;
+ }
XRROutputInfo * xrrOutputInfo = XRRGetOutputInfo (dpy, resources, output);
- fprintf(stderr, " Output[%d]: id %#lx, crtx 0x%lX, name %s (%d), %lux%lu, ncrtc %d, nclone %d, nmode %d (preferred %d)\n",
+ fprintf(stderr, " Output[%d]: id %#lx, crtx 0x%lX, name %s (%d), %lux%lu, ncrtc %d, nclone %d, nmode %d (preferred %d), primary %d\n",
i, output, xrrOutputInfo->crtc, SAFE_STRING(xrrOutputInfo->name), xrrOutputInfo->nameLen,
xrrOutputInfo->mm_width, xrrOutputInfo->mm_height,
- xrrOutputInfo->ncrtc, xrrOutputInfo->nclone, xrrOutputInfo->nmode, xrrOutputInfo->npreferred);
+ xrrOutputInfo->ncrtc, xrrOutputInfo->nclone, xrrOutputInfo->nmode, xrrOutputInfo->npreferred, isPrim);
for(j=0; j<xrrOutputInfo->ncrtc; j++) {
fprintf(stderr, " Output[%d].Crtc[%d].id %#lx\n", i, j, xrrOutputInfo->crtcs[j]);
}
@@ -145,7 +152,7 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_RandR13_dumpInfo0
XRRFreeCrtcInfo(xrrCrtcInfo);
}
- dumpOutputs("XRRScreenResources.outputs", dpy, resources, resources->noutput, resources->outputs);
+ dumpOutputs("XRRScreenResources.outputs", dpy, (int)screen_idx, resources, resources->noutput, resources->outputs);
fprintf(stderr, "XRRScreenResources %p: Mode count %d\n", resources, resources->nmode);
for(i=0; i<resources->nmode; i++) {
@@ -421,7 +428,14 @@ JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_RandR13_getMonitorDevice
return NULL;
}
+ Window root = RootWindow(dpy, 0); // FIXME screen_idx);
+ RROutput pxid = XRRGetOutputPrimary (dpy, root);
+ int isPrimary = 0;
+
RROutput output = xrrCrtcInfo->outputs[0];
+ if ( None != pxid && pxid == output ) {
+ isPrimary = 1;
+ }
XRROutputInfo * xrrOutputInfo = XRRGetOutputInfo (dpy, resources, output);
int numModes = xrrOutputInfo->nmode;
@@ -431,7 +445,8 @@ JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_RandR13_getMonitorDevice
prop[propIndex++] = propCount;
prop[propIndex++] = crt_idx;
- prop[propIndex++] = 0; // is_clone, does not work: 0 < xrrOutputInfo->nclone ? 1 : 0;
+ prop[propIndex++] = 0; // isClone, does not work: 0 < xrrOutputInfo->nclone ? 1 : 0;
+ prop[propIndex++] = isPrimary;
prop[propIndex++] = xrrOutputInfo->mm_width;
prop[propIndex++] = xrrOutputInfo->mm_height;
prop[propIndex++] = xrrCrtcInfo->x; // rotated viewport pixel units