/* * Class: jogamp_newt_driver_x11_RandR13 * Method: getMonitorCurrentMode0 * Signature: (JJ)[I */ JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_RandR13_getMonitorCurrentMode0 (JNIEnv *env, jclass clazz, jlong screenResources, jlong monitorInfo) { XRRScreenResources *resources = (XRRScreenResources *) (intptr_t) screenResources; XRRCrtcInfo *xrrCrtcInfo = (XRRCrtcInfo *) (intptr_t) monitorInfo; if( NULL == resources || NULL == xrrCrtcInfo ) { // n/a return NULL; } if( None == xrrCrtcInfo->mode || 0 == xrrCrtcInfo->noutput ) { // disabled return NULL; } RRMode modeId = xrrCrtcInfo->mode; XRRModeInfo *mode = findMode(resources, modeId); if( NULL == mode ) { // oops .. return NULL; } unsigned int dots = mode->hTotal * mode->vTotal; int refresh = (int) ( getVRefresh(mode) * 100.0f ); // Hz * 100 int flags = 0; if (mode->modeFlags & RR_Interlace) { flags |= FLAG_INTERLACE; } if (mode->modeFlags & RR_DoubleScan) { flags |= FLAG_DOUBLESCAN; } jint prop[ NUM_MONITOR_MODE_PROPERTIES_ALL ]; int propIndex = 0; prop[propIndex++] = NUM_MONITOR_MODE_PROPERTIES_ALL; prop[propIndex++] = mode->width; prop[propIndex++] = mode->height; prop[propIndex++] = 32; // TODO: XRandR > 1.4 may support bpp prop[propIndex++] = refresh; prop[propIndex++] = flags; prop[propIndex++] = mode->id; prop[propIndex++] = NewtScreen_XRotation2Degree(env, xrrCrtcInfo->rotation); jintArray properties = (*env)->NewIntArray(env, NUM_MONITOR_MODE_PROPERTIES_ALL); if (properties == NULL) { NewtCommon_throwNewRuntimeException(env, "Could not allocate int array of size %d", NUM_MONITOR_MODE_PROPERTIES_ALL); } (*env)->SetIntArrayRegion(env, properties, 0, NUM_MONITOR_MODE_PROPERTIES_ALL, prop); return properties; }
JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_RandR13_dumpInfo0 (JNIEnv *env, jclass clazz, jlong display, jint screen_idx, jlong screenResources) { Display * dpy = (Display *) (intptr_t) display; Window root = RootWindow(dpy, (int)screen_idx); XRRScreenResources *resources = (XRRScreenResources *) (intptr_t) screenResources; int pos[] = { 0, 0 } ; int i, j, minWidth, minHeight, maxWidth, maxHeight; int vs_width = DisplayWidth(dpy, screen_idx); int vs_height = DisplayHeight(dpy, screen_idx); int vs_width_mm = DisplayWidthMM(dpy, screen_idx); int vs_height_mm = DisplayHeightMM(dpy, screen_idx); fprintf(stderr, "ScreenVirtualSize: %dx%d %dx%d mm\n", vs_width, vs_height, vs_width_mm, vs_height_mm); XRRGetScreenSizeRange (dpy, root, &minWidth, &minHeight, &maxWidth, &maxHeight); fprintf(stderr, "XRRGetScreenSizeRange: %dx%d .. %dx%d\n", minWidth, minHeight, maxWidth, maxHeight); if( NULL == resources ) { fprintf(stderr, "XRRScreenResources NULL\n"); return; } fprintf(stderr, "XRRScreenResources %p: Crtc count %d\n", resources, resources->ncrtc); for(i=0; i<resources->ncrtc; i++) { RRCrtc crtc = resources->crtcs[i]; XRRCrtcInfo *xrrCrtcInfo = XRRGetCrtcInfo (dpy, resources, crtc); fprintf(stderr, "Crtc[%d] %#lx: %d/%d %dx%d, rot 0x%X, mode.id %#lx\n", i, crtc, xrrCrtcInfo->x, xrrCrtcInfo->y, xrrCrtcInfo->width, xrrCrtcInfo->height, xrrCrtcInfo->rotations, xrrCrtcInfo->mode); for(j=0; j<xrrCrtcInfo->noutput; j++) { fprintf(stderr, " Crtc[%d].Output[%d].id %#lx\n", i, j, xrrCrtcInfo->outputs[j]); dumpOutput(" ", dpy, screen_idx, resources, j, xrrCrtcInfo->outputs[j]); } XRRFreeCrtcInfo(xrrCrtcInfo); } 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++) { XRRModeInfo *mode = &resources->modes[i]; unsigned int dots = mode->hTotal * mode->vTotal; float refresh = getVRefresh(mode); fprintf(stderr, "Mode[%d, id %#lx]: %ux%u@%f, name %s\n", i, mode->id, mode->width, mode->height, refresh, SAFE_STRING(mode->name)); } }
/* * Class: jogamp_newt_driver_x11_RandR13 * Method: getMonitorMode0 * Signature: (JI)[I */ JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_RandR13_getMonitorMode0 (JNIEnv *env, jclass clazz, jlong screenResources, jint mode_idx) { XRRScreenResources *resources = (XRRScreenResources *) (intptr_t) screenResources; if( NULL == resources || mode_idx >= resources->nmode ) { return NULL; } XRRModeInfo *mode = &resources->modes[mode_idx]; unsigned int dots = mode->hTotal * mode->vTotal; int refresh = (int) ( getVRefresh(mode) * 100.0f ); // Hz * 100 int flags = 0; if (mode->modeFlags & RR_Interlace) { flags |= FLAG_INTERLACE; } if (mode->modeFlags & RR_DoubleScan) { flags |= FLAG_DOUBLESCAN; } jint prop[ NUM_MONITOR_MODE_PROPERTIES_ALL ]; int propIndex = 0; prop[propIndex++] = NUM_MONITOR_MODE_PROPERTIES_ALL; prop[propIndex++] = mode->width; prop[propIndex++] = mode->height; prop[propIndex++] = 32; // TODO: XRandR > 1.4 may support bpp prop[propIndex++] = refresh; prop[propIndex++] = flags; prop[propIndex++] = mode->id; prop[propIndex++] = -1; // rotation placeholder jintArray properties = (*env)->NewIntArray(env, NUM_MONITOR_MODE_PROPERTIES_ALL); if (properties == NULL) { NewtCommon_throwNewRuntimeException(env, "Could not allocate int array of size %d", NUM_MONITOR_MODE_PROPERTIES_ALL); } (*env)->SetIntArrayRegion(env, properties, 0, NUM_MONITOR_MODE_PROPERTIES_ALL, prop); return properties; }