void XRRConfiguration::ToggleDisplayMode(bool bFullscreen) { if (!bValid || !screenResources || !outputInfo || !crtcInfo || !fullMode) return; if (bFullscreen == bIsFullscreen) return; XGrabServer(dpy); if (bFullscreen) { XRRSetCrtcConfig(dpy, screenResources, outputInfo->crtc, CurrentTime, crtcInfo->x, crtcInfo->y, fullMode, crtcInfo->rotation, crtcInfo->outputs, crtcInfo->noutput); XRRSetScreenSize(dpy, win, fs_fb_width, fs_fb_height, fs_fb_width_mm, fs_fb_height_mm); bIsFullscreen = true; } else { XRRSetCrtcConfig(dpy, screenResources, outputInfo->crtc, CurrentTime, crtcInfo->x, crtcInfo->y, crtcInfo->mode, crtcInfo->rotation, crtcInfo->outputs, crtcInfo->noutput); XRRSetScreenSize(dpy, win, fb_width, fb_height, fb_width_mm, fb_height_mm); bIsFullscreen = false; } XUngrabServer(dpy); XSync(dpy, false); }
/* * Class: jogamp_newt_driver_x11_RandR13 * Method: setScreenViewport0 * Signature: (JIJIIII)Z */ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_x11_RandR13_setScreenViewport0 (JNIEnv *env, jclass clazz, jlong display, jint screen_idx, jlong screenResources, jint x, jint y, jint width, jint height) { Display * dpy = (Display *) (intptr_t) display; Window root = RootWindow(dpy, (int)screen_idx); XRRScreenResources *resources = (XRRScreenResources *) (intptr_t) screenResources; jboolean res = JNI_FALSE; if( NULL == resources ) { // n/a return JNI_FALSE; } XRRSetScreenSize (dpy, root, width, height, DisplayWidthMM(dpy, screen_idx), DisplayHeightMM(dpy, screen_idx)); return JNI_TRUE; }
void gnome_rr_screen_set_size (GnomeRRScreen *screen, int width, int height, int mm_width, int mm_height) { g_return_if_fail (screen != NULL); #ifdef HAVE_RANDR gdk_error_trap_push (); XRRSetScreenSize (screen->xdisplay, screen->xroot, width, height, mm_width, mm_height); gdk_flush (); gdk_error_trap_pop (); /* ignore error */ #endif }
void mate_rr_screen_set_size (MateRRScreen *screen, int width, int height, int mm_width, int mm_height) { g_return_if_fail (screen != NULL); #ifdef HAVE_RANDR gdk_error_trap_push (); XRRSetScreenSize (screen->xdisplay, screen->xroot, width, height, mm_width, mm_height); #if GTK_CHECK_VERSION (3, 0, 0) gdk_error_trap_pop_ignored (); #else gdk_flush (); gdk_error_trap_pop (); /* ignore error */ #endif #endif }
/* * Class: jogamp_newt_driver_x11_RandR13 * Method: setMonitorMode0 * Signature: (JJJIIIII)Z */ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_x11_RandR13_setMonitorMode0 (JNIEnv *env, jclass clazz, jlong display, jint screen_idx, jlong screenResources, jlong monitorInfo, jint crt_id, jint jmode_id, jint rotation, jint x, jint y) { jboolean res = JNI_FALSE; Display * dpy = (Display *) (intptr_t) display; Window root = RootWindow(dpy, (int)screen_idx); XRRScreenResources *resources = (XRRScreenResources *) (intptr_t) screenResources; RRCrtc crtc = findRRCrtc( resources, (RRCrtc)(intptr_t)crt_id ); if( 0 == crtc ) { // n/a DBG_PRINT("RandR13_setMonitorMode0.0: n/a: resources %p (%d), crt_id %#lx \n", resources, (NULL == resources ? 0 : resources->ncrtc), (RRCrtc)(intptr_t)crt_id); return res; } XRRCrtcInfo *xrrCrtcInfo = (XRRCrtcInfo *) (intptr_t) monitorInfo; if( NULL == xrrCrtcInfo ) { // n/a DBG_PRINT("RandR13_setMonitorMode0.1: n/a: resources %p (%d), xrrCrtcInfo %p, crtc %#lx\n", resources, (NULL == resources ? 0 : resources->ncrtc), xrrCrtcInfo, crtc); return res; } if( None == xrrCrtcInfo->mode || 0 == xrrCrtcInfo->noutput ) { // disabled DBG_PRINT("RandR13_setMonitorMode0: disabled: mode %d, noutput %d\n", xrrCrtcInfo->mode, xrrCrtcInfo->noutput); return res; } if( 0 >= jmode_id ) { // oops .. DBG_PRINT("RandR13_setMonitorMode0: inv. modeId: modeId %d\n", jmode_id); return res; } RRMode mode_id = (RRMode)(intptr_t)jmode_id; XRRModeInfo *mode_info = findMode(resources, mode_id); if( NULL == mode_info ) { // oops .. DBG_PRINT("RandR13_setMonitorMode0: inv. mode_id: mode_id %#lx\n", mode_id); return res; } if( 0 > x || 0 > y ) { x = xrrCrtcInfo->x; y = xrrCrtcInfo->y; } Rotation xrotation = NewtScreen_Degree2XRotation(env, rotation); int rot_change = xrrCrtcInfo->rotation != xrotation; DBG_PRINT("RandR13_setMonitorMode0: crt %#lx, noutput %d -> 0x%X, mode %#lx -> %#lx, pos %d / %d, rotation %d -> %d (change %d)\n", crtc, xrrCrtcInfo->noutput, xrrCrtcInfo->outputs[0], xrrCrtcInfo->mode, mode_id, x, y, (int)xrrCrtcInfo->rotation, (int)xrotation, rot_change); XRRSelectInput (dpy, root, RRScreenChangeNotifyMask); Status status = RRSetConfigSuccess; int pre_fb_width=0, pre_fb_height=0; int fb_width=0, fb_height=0; int fb_width_mm=0, fb_height_mm=0; crtc_t *root_crtc = get_screen_size1(dpy, root, &fb_width, &fb_height, resources, crtc, xrrCrtcInfo, xrotation, x, y, mode_info); Bool fb_change = get_screen_sizemm(dpy, screen_idx, fb_width, fb_height, &fb_width_mm, &fb_height_mm, &pre_fb_width, &pre_fb_height); DBG_PRINT("RandR13_setMonitorMode0: crt %#lx, fb[change %d: %d x %d -> %d x %d [%d x %d mm]\n", crtc, fb_change, pre_fb_width, pre_fb_height, fb_width, fb_height, fb_width_mm, fb_height_mm); if(fb_change) { // Disable CRTC first, since new size differs from current // and we shall avoid invalid intermediate configuration (see spec)! #if 0 { // Disable all CRTCs (Not required!) crtc_t * iter_crtc; for(iter_crtc=root_crtc; RRSetConfigSuccess == status && NULL!=iter_crtc; iter_crtc=iter_crtc->next) { if( None == iter_crtc->mode_id || NULL == iter_crtc->mode_info || 0 == iter_crtc->crtc_info->noutput ) { // disabled continue; } status = XRRSetCrtcConfig (dpy, resources, iter_crtc->crtc_id, CurrentTime, 0, 0, None, RR_Rotate_0, NULL, 0); } } #else status = XRRSetCrtcConfig (dpy, resources, crtc, CurrentTime, 0, 0, None, RR_Rotate_0, NULL, 0); #endif DBG_PRINT("RandR13_setMonitorMode0: crt %#lx disable: %d -> %d\n", crtc, status, RRSetConfigSuccess == status); if( RRSetConfigSuccess == status ) { XRRSetScreenSize (dpy, root, fb_width, fb_height, fb_width_mm, fb_height_mm); DBG_PRINT("RandR13_setMonitorMode0: crt %#lx screen-size\n", crtc); } } if( RRSetConfigSuccess == status ) { #if 0 { // Enable/Set all CRTCs (Not required!) crtc_t * iter_crtc; for(iter_crtc=root_crtc; RRSetConfigSuccess == status && NULL!=iter_crtc; iter_crtc=iter_crtc->next) { if( None == iter_crtc->mode_id || NULL == iter_crtc->mode_info || 0 == iter_crtc->crtc_info->noutput ) { // disabled continue; } status = XRRSetCrtcConfig( dpy, resources, iter_crtc->crtc_id, CurrentTime, iter_crtc->x, iter_crtc->y, iter_crtc->mode_id, iter_crtc->rotation, iter_crtc->crtc_info->outputs, iter_crtc->crtc_info->noutput ); } } #else status = XRRSetCrtcConfig( dpy, resources, crtc, CurrentTime, x, y, mode_id, xrotation, xrrCrtcInfo->outputs, xrrCrtcInfo->noutput ); #endif DBG_PRINT("RandR13_setMonitorMode0: crt %#lx set-config: %d -> %d\n", crtc, status, RRSetConfigSuccess == status); } res = status == RRSetConfigSuccess; DBG_PRINT("RandR13_setMonitorMode0: FIN: %d -> ok %d\n", status, res); destroyCrtcChain(root_crtc, crtc); root_crtc=NULL; return res; }