static void get_screen_size0(Display * dpy, Window root, crtc_t * root_crtc, int *io_scrn_width, int *io_scrn_height) { int fb_width = *io_scrn_width; int fb_height = *io_scrn_height; crtc_t *crtc; for (crtc = root_crtc; NULL != crtc; crtc = crtc->next) { if( None == crtc->mode_id || NULL == crtc->mode_info || 0 == crtc->crtc_info->noutput ) { // disabled continue; } XRRModeInfo *mode_info = crtc->mode_info; int x, y, w, h; box_t bounds; mode_geometry (mode_info, crtc->rotation, &crtc->transform.transform, &bounds); x = crtc->x + bounds.x1; y = crtc->y + bounds.y1; w = bounds.x2 - bounds.x1; h = bounds.y2 - bounds.y1; /* fit fb to crtc */ XRRPanning *pan; if (x + w > fb_width) { fb_width = x + w; } if (y + h > fb_height) { fb_height = y + h; } pan = crtc->panning_info; if (pan && pan->left + pan->width > fb_width) { fb_width = pan->left + pan->width; } if (pan && pan->top + pan->height > fb_height) { fb_height = pan->top + pan->height; } } int minWidth=0, minHeight=0, maxWidth=0, maxHeight=0; if( 1 != XRRGetScreenSizeRange (dpy, root, &minWidth, &minHeight, &maxWidth, &maxHeight) ) { // Use defaults in case of error .. minWidth=8; minHeight=8; maxWidth=16384; maxHeight=16384; } if( fb_width < minWidth ) { fb_width = minWidth; } else if( fb_width > maxWidth ) { fb_width = maxWidth; } if( fb_height < minHeight ) { fb_height = minHeight; } else if( fb_height > maxHeight ) { fb_height = maxHeight; } *io_scrn_width = fb_width; *io_scrn_height = fb_height; }
void XRandRScreen::update() { Display *display = QX11Info::display(); int screen = DefaultScreen(display); Window rootWindow = XRootWindow(display, screen); XRRGetScreenSizeRange (display, rootWindow, &m_minSize.rwidth(), &m_minSize.rheight(), &m_maxSize.rwidth(), &m_maxSize.rheight()); m_currentSize = QSize(DisplayWidth(display, screen),DisplayHeight(display, screen)); }
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: getScreenResources0 * Signature: (JI)J */ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_x11_RandR13_getScreenResources0 (JNIEnv *env, jclass clazz, jlong display, jint screen_idx) { Display *dpy = (Display *) (intptr_t) display; Window root = RootWindow(dpy, (int)screen_idx); /* Bug 1183 * XRRGetScreenResourcesCurrent (or XRRGetScreenResources) * _occasionally_ reports empty data * unless XRRGetScreenSizeRange has been called once. */ int minWidth, minHeight, maxWidth, maxHeight; XRRGetScreenSizeRange ( dpy, root, &minWidth, &minHeight, &maxWidth, &maxHeight); XRRScreenResources *res = XRRGetScreenResourcesCurrent( dpy, root); // 1.3 // XRRScreenResources *res = XRRGetScreenResources( dpy, root); // 1.2 return (jlong) (intptr_t) res; }
static void get_resolution(Enna_Buffer *b) { XRRScreenConfiguration *sc; Window root; Display *dpy; short rate; int screen; int minWidth, maxWidth, minHeight, maxHeight; dpy = XOpenDisplay(":0.0"); if (!dpy) return; screen = DefaultScreen(dpy); if (screen >= ScreenCount(dpy)) return; root = RootWindow(dpy, screen); if (root < 0) return; sc = XRRGetScreenInfo(dpy, root); if (!sc) return; rate = XRRConfigCurrentRate(sc); XRRGetScreenSizeRange(dpy, root, &minWidth, &minHeight, &maxWidth, &maxHeight); enna_buffer_append(b, "<hilight>"); enna_buffer_append(b, _("Screen resolution:")); enna_buffer_appendf(b, "</hilight> %dx%d ", DisplayWidth(dpy, screen), DisplayHeight(dpy, screen)); enna_buffer_append(b, _("at")); enna_buffer_appendf(b, " %d Hz (", rate); enna_buffer_append(b, _("min:")); enna_buffer_appendf(b, " %dx%d, ", minWidth, minHeight); enna_buffer_append(b, _("max:")); enna_buffer_appendf(b, " %dx%d)<br>", maxWidth, maxHeight); XCloseDisplay(dpy); }
static gboolean fill_out_screen_info (Display *xdisplay, Window xroot, ScreenInfo *info, gboolean needs_reprobe, GError **error) { #ifdef HAVE_RANDR XRRScreenResources *resources; g_assert (xdisplay != NULL); g_assert (info != NULL); /* First update the screen resources */ if (needs_reprobe) resources = XRRGetScreenResources (xdisplay, xroot); else { /* XRRGetScreenResourcesCurrent is less expensive than * XRRGetScreenResources, however it is available only * in RandR 1.3 or higher */ #if (RANDR_MAJOR > 1 || (RANDR_MAJOR == 1 && RANDR_MINOR >= 3)) /* Runtime check for RandR 1.3 or higher */ if (info->screen->rr_major_version == 1 && info->screen->rr_minor_version >= 3) resources = XRRGetScreenResourcesCurrent (xdisplay, xroot); else resources = XRRGetScreenResources (xdisplay, xroot); #else resources = XRRGetScreenResources (xdisplay, xroot); #endif } if (resources) { if (!fill_screen_info_from_resources (info, resources, error)) return FALSE; } else { g_set_error (error, MATE_RR_ERROR, MATE_RR_ERROR_RANDR_ERROR, /* Translators: a CRTC is a CRT Controller (this is X terminology). */ _("could not get the screen resources (CRTCs, outputs, modes)")); return FALSE; } /* Then update the screen size range. We do this after XRRGetScreenResources() so that * the X server will already have an updated view of the outputs. */ if (needs_reprobe) { gboolean success; gdk_error_trap_push (); success = XRRGetScreenSizeRange (xdisplay, xroot, &(info->min_width), &(info->min_height), &(info->max_width), &(info->max_height)); gdk_flush (); if (gdk_error_trap_pop ()) { g_set_error (error, MATE_RR_ERROR, MATE_RR_ERROR_UNKNOWN, _("unhandled X error while getting the range of screen sizes")); return FALSE; } if (!success) { g_set_error (error, MATE_RR_ERROR, MATE_RR_ERROR_RANDR_ERROR, _("could not get the range of screen sizes")); return FALSE; } } else { mate_rr_screen_get_ranges (info->screen, &(info->min_width), &(info->max_width), &(info->min_height), &(info->max_height)); } info->primary = None; #if (RANDR_MAJOR > 1 || (RANDR_MAJOR == 1 && RANDR_MINOR >= 3)) /* Runtime check for RandR 1.3 or higher */ if (info->screen->rr_major_version == 1 && info->screen->rr_minor_version >= 3) { gdk_error_trap_push (); info->primary = XRRGetOutputPrimary (xdisplay, xroot); #if GTK_CHECK_VERSION (3, 0, 0) gdk_error_trap_pop_ignored (); #else gdk_flush (); gdk_error_trap_pop (); /* ignore error */ #endif } #endif return TRUE; #else return FALSE; #endif /* HAVE_RANDR */ }