예제 #1
0
XRRConfiguration::XRRConfiguration(Display *_dpy, Window _win)
	: dpy(_dpy)
	, win(_win)
	, screenResources(nullptr), outputInfo(nullptr), crtcInfo(nullptr)
	, fullMode(0)
	, fs_fb_width(0), fs_fb_height(0), fs_fb_width_mm(0), fs_fb_height_mm(0)
	, bValid(true), bIsFullscreen(false)
{
	int XRRMajorVersion, XRRMinorVersion;

	if (!XRRQueryVersion(dpy, &XRRMajorVersion, &XRRMinorVersion) ||
	    (XRRMajorVersion < 1 || (XRRMajorVersion == 1 && XRRMinorVersion < 3)))
	{
		WARN_LOG(VIDEO, "XRRExtension not supported.");
		bValid = false;
		return;
	}

	screenResources = XRRGetScreenResourcesCurrent(dpy, win);

	screen = DefaultScreen(dpy);
	fb_width = DisplayWidth(dpy, screen);
	fb_height = DisplayHeight(dpy, screen);
	fb_width_mm = DisplayWidthMM(dpy, screen);
	fb_height_mm = DisplayHeightMM(dpy, screen);

	INFO_LOG(VIDEO, "XRRExtension-Version %d.%d", XRRMajorVersion, XRRMinorVersion);
	Update();
}
예제 #2
0
파일: clipping.c 프로젝트: tomby42/prg-xws
/*
 * Pøipojit k serveru, zjistit o nìm informace
 */
static void open_display(void)
{
    display_name = XDisplayName(NULL);
    if(!(display = XOpenDisplay(display_name))) {
	fprintf(stderr, "Cannot connect to X server \"%s\"\n", display_name);
	exit(1);
    }
    debug("Connected to X server \"%s\"\n", display_name);
    
    screen_num = DefaultScreen(display);
    screen = DefaultScreenOfDisplay(display);
    debug("Default screen number is %d\n", screen_num);
    
    screen_width = DisplayWidth(display, screen_num);
    screen_height = DisplayHeight(display, screen_num);
    screen_width_mm = DisplayWidthMM(display, screen_num);
    screen_height_mm = DisplayHeightMM(display, screen_num);
    debug("Screen size is %ux%u pixels, %ux%u mm\n", screen_width,
	  screen_height, screen_width_mm, screen_height_mm);
    
    root = RootWindow(display, screen_num);
    black = BlackPixel(display, screen_num);
    white = WhitePixel(display, screen_num);
    debug("Root window ID is %#lx, black is %#lx, white is %#lx\n", root,
	  black, white);

    def_gc = DefaultGC(display, screen_num);
    /* Toto volání XQueryFont() do def_font->fid neulo¾í ID fontu, ale
     * grafického kontextu! Nevím, jak získat ID nebo jméno standardního
     * fontu. */
    if(!(def_font = XQueryFont(display, XGContextFromGC(def_gc)))) {
	fprintf(stderr, "XQueryFont() failed\n");
	exit(1);
    }
}
예제 #3
0
bool x11_get_metrics(void *data,
      enum display_metric_types type, float *value)
{
   unsigned     screen_no  = 0;
   Display           *dpy  = (Display*)XOpenDisplay(NULL);
   int pixels_x            = DisplayWidth(dpy, screen_no);
   int pixels_y            = DisplayHeight(dpy, screen_no);
   int physical_width      = DisplayWidthMM(dpy, screen_no);
   int physical_height     = DisplayHeightMM(dpy, screen_no);

   (void)pixels_y;

   XCloseDisplay(dpy);

   switch (type)
   {
      case DISPLAY_METRIC_MM_WIDTH:
         *value = (float)physical_width;
         break;
      case DISPLAY_METRIC_MM_HEIGHT:
         *value = (float)physical_height;
         break;
      case DISPLAY_METRIC_DPI:
         *value = ((((float)pixels_x) * 25.4) / ((float)physical_width));
         break;
      case DISPLAY_METRIC_NONE:
      default:
         *value = 0;
         return false;
   }

   return true;
}
예제 #4
0
파일: porting.cpp 프로젝트: racam/minetest
static float calcDisplayDensity()
{
	const char* current_display = getenv("DISPLAY");

	if (current_display != NULL) {
			Display * x11display = XOpenDisplay(current_display);

			if (x11display != NULL) {
				/* try x direct */
				float dpi_height =
						floor(DisplayHeight(x11display, 0) /
								(DisplayHeightMM(x11display, 0) * 0.039370) + 0.5);
				float dpi_width =
						floor(DisplayWidth(x11display, 0) /
								(DisplayWidthMM(x11display, 0) * 0.039370) +0.5);

				XCloseDisplay(x11display);

				return std::max(dpi_height,dpi_width) / 96.0;
			}
		}

	/* return manually specified dpi */
	return g_settings->getFloat("screen_dpi")/96.0;
}
예제 #5
0
QSize MythXDisplay::GetDisplayDimensions(void)
{
    MythXLocker locker(this);
    int displayWidthMM  = DisplayWidthMM( m_disp, m_screen_num);
    int displayHeightMM = DisplayHeightMM(m_disp, m_screen_num);
    return QSize(displayWidthMM, displayHeightMM);
}
예제 #6
0
파일: gravity.c 프로젝트: tomby42/prg-xws
/*
 * Pøipojit k serveru, zjistit o nìm informace
 */
static void open_display(void)
{
    display_name = XDisplayName(NULL);
    if(!(display = XOpenDisplay(display_name))) {
        fprintf(stderr, "Cannot connect to X server \"%s\"\n", display_name);
        exit(1);
    }
    debug("Connected to X server \"%s\"\n", display_name);

    screen_num = DefaultScreen(display);
    screen = DefaultScreenOfDisplay(display);
    debug("Default screen number is %d\n", screen_num);

    screen_width = DisplayWidth(display, screen_num);
    screen_height = DisplayHeight(display, screen_num);
    screen_width_mm = DisplayWidthMM(display, screen_num);
    screen_height_mm = DisplayHeightMM(display, screen_num);
    debug("Screen size is %ux%u pixels, %ux%u mm\n", screen_width,
          screen_height, screen_width_mm, screen_height_mm);

    root = RootWindow(display, screen_num);
    black = BlackPixel(display, screen_num);
    white = WhitePixel(display, screen_num);
    debug("Root window ID is %#lx, black is %#lx, white is %#lx\n", root,
          black, white);

    def_gc = DefaultGC(display, screen_num);
    if(!(def_font = XQueryFont(display, XGContextFromGC(def_gc)))) {
        fprintf(stderr, "XQueryFont() failed\n");
        exit(1);
    }
}
예제 #7
0
파일: cdxnative.c 프로젝트: LuaDist/cd
void cdGetScreenSize(int *width, int *height, double *width_mm, double *height_mm)
{
  static int first = 1;
  static int dpy_width, dpy_height, dpy_width_mm, dpy_height_mm;

  if (first)
  {
    Display* drv_display = XOpenDisplay(NULL);
    int drv_screen  = DefaultScreen (drv_display);

    dpy_width = DisplayWidth(drv_display,drv_screen);
    dpy_height = DisplayHeight(drv_display,drv_screen);
    dpy_width_mm = DisplayWidthMM(drv_display,drv_screen);
    dpy_height_mm = DisplayHeightMM(drv_display,drv_screen);

    XCloseDisplay(drv_display);

    first = 0;
  }

  if (width) *width = dpy_width;
  if (height) *height = dpy_height;
  if (width_mm) *width_mm = dpy_width_mm;
  if (height_mm) *height_mm = dpy_height_mm;
}
예제 #8
0
파일: x11_init.c 프로젝트: hgl888/glfw
// Retrieve system content scale via folklore heuristics
//
static void getSystemContentScale(float* xscale, float* yscale)
{
    // NOTE: Fall back to the display-wide DPI instead of RandR monitor DPI if
    //       Xft.dpi retrieval below fails as we don't currently have an exact
    //       policy for which monitor a window is considered to "be on"
    float xdpi = DisplayWidth(_glfw.x11.display, _glfw.x11.screen) *
        25.4f / DisplayWidthMM(_glfw.x11.display, _glfw.x11.screen);
    float ydpi = DisplayHeight(_glfw.x11.display, _glfw.x11.screen) *
        25.4f / DisplayHeightMM(_glfw.x11.display, _glfw.x11.screen);

    // NOTE: Basing the scale on Xft.dpi where available should provide the most
    //       consistent user experience (matches Qt, Gtk, etc), although not
    //       always the most accurate one
    char* rms = XResourceManagerString(_glfw.x11.display);
    if (rms)
    {
        XrmDatabase db = XrmGetStringDatabase(rms);
        if (db)
        {
            XrmValue value;
            char* type = NULL;

            if (XrmGetResource(db, "Xft.dpi", "Xft.Dpi", &type, &value))
            {
                if (type && strcmp(type, "String") == 0)
                    xdpi = ydpi = atof(value.addr);
            }

            XrmDestroyDatabase(db);
        }
    }

    *xscale = xdpi / 96.f;
    *yscale = ydpi / 96.f;
}
예제 #9
0
파일: iupunix_info.c 프로젝트: LuaDist/iup
float iupdrvGetScreenDpi(void)
{
  float dpi;
  Display* drv_display = (Display*)iupdrvGetDisplay();
  int screen = XDefaultScreen(drv_display);
  dpi = ((float)DisplayHeight(drv_display, screen) / (float)DisplayHeightMM(drv_display, screen));
  return dpi * 25.4f;  /* mm to inch */
}
예제 #10
0
파일: utils.cpp 프로젝트: LuaDist/wxwidgets
void wxDisplaySizeMM(int *width, int *height)
{
    Display *dpy = (Display*) wxGetDisplay();

    if ( width )
        *width = DisplayWidthMM(dpy, DefaultScreen (dpy));
    if ( height )
        *height = DisplayHeightMM(dpy, DefaultScreen (dpy));
}
예제 #11
0
static void
gst_vaapi_display_x11_get_size_mm(
    GstVaapiDisplay *display,
    guint           *pwidth,
    guint           *pheight
)
{
    GstVaapiDisplayX11Private * const priv =
        GST_VAAPI_DISPLAY_X11(display)->priv;
    guint width_mm, height_mm;

    if (!priv->x11_display)
        return;

    width_mm  = DisplayWidthMM(priv->x11_display, priv->x11_screen);
    height_mm = DisplayHeightMM(priv->x11_display, priv->x11_screen);

#ifdef HAVE_XRANDR
    /* XXX: fix up physical size if the display is rotated */
    if (priv->use_xrandr) {
        XRRScreenConfiguration *xrr_config = NULL;
        XRRScreenSize *xrr_sizes;
        Window win;
        int num_xrr_sizes, size_id, screen;
        Rotation rotation;

        do {
            win    = DefaultRootWindow(priv->x11_display);
            screen = XRRRootToScreen(priv->x11_display, win);

            xrr_config = XRRGetScreenInfo(priv->x11_display, win);
            if (!xrr_config)
                break;

            size_id = XRRConfigCurrentConfiguration(xrr_config, &rotation);
            if (rotation == RR_Rotate_0 || rotation == RR_Rotate_180)
                break;

            xrr_sizes = XRRSizes(priv->x11_display, screen, &num_xrr_sizes);
            if (!xrr_sizes || size_id >= num_xrr_sizes)
                break;

            width_mm  = xrr_sizes[size_id].mheight;
            height_mm = xrr_sizes[size_id].mwidth;
        } while (0);
        if (xrr_config)
            XRRFreeScreenConfigInfo(xrr_config);
    }
#endif

    if (pwidth)
        *pwidth = width_mm;

    if (pheight)
        *pheight = height_mm;
}
예제 #12
0
static Bool get_screen_sizemm(Display *dpy, int screen_idx,
                              int fb_width, int fb_height,
                              int *fb_width_mm, int *fb_height_mm,
                              int *pre_fb_width, int *pre_fb_height) {
    *pre_fb_width = DisplayWidth (dpy, screen_idx);
    *pre_fb_height = DisplayHeight (dpy, screen_idx);
    Bool fb_change;
    if (fb_width != *pre_fb_width || fb_height != *pre_fb_height ) {
        float dpi = (25.4 * *pre_fb_height) / DisplayHeightMM(dpy, screen_idx);
        *fb_width_mm = (25.4 * fb_width) / dpi;
        *fb_height_mm = (25.4 * fb_height) / dpi;
        fb_change = True;
    } else {
        *fb_width_mm = DisplayWidthMM (dpy, screen_idx);
        *fb_height_mm = DisplayHeightMM (dpy, screen_idx);
        fb_change = False;
    }
    return fb_change;
}
예제 #13
0
/*
 * StripMisc_init
 *
 *      Initializes global constants.
 */
void    StripMisc_init  (Display *display, int screen)
{
  horizontal_pixels_per_mm = 
    ((float)DisplayWidth(display, screen) /
     (float)DisplayWidthMM(display, screen));

  vertical_pixels_per_mm = 
    ((float)DisplayHeight(display, screen) /
     (float)DisplayHeightMM(display, screen));
}
예제 #14
0
파일: vo_x11.c 프로젝트: jih488/dtplayer_c
/* Xlib font utils define */
static XFontStruct *LoadQueryScalableFont (Display * dpy, int screen, char *name, int size)
{
    int i, j, field;
    char newname[500];          /* big enough for a long font name */
    int res_x, res_y;           /* resolution values for this screen */
    /* catch obvious errors */
    if ((name == NULL) || (name[0] != '-'))
        return NULL;
    /* calculate our screen resolution in dots per inch. 25.4mm = 1 inch */
    res_x = DisplayWidth (dpy, screen) / (DisplayWidthMM (dpy, screen) / 25.4);
    res_y = DisplayHeight (dpy, screen) / (DisplayHeightMM (dpy, screen) / 25.4);
    /* copy the font name, changing the scalable fields as we do so */
    for (i = j = field = 0; name[i] != '\0' && field <= 14; i++)
    {
        newname[j++] = name[i];
        if (name[i] == '-')
        {
            field++;
            switch (field)
            {
            case 7:            /* pixel size */
            case 12:           /* average width */
                /* change from "-0-" to "-*-" */
                newname[j] = '*';
                j++;
                if (name[i + 1] != '\0')
                    i++;
                break;
            case 8:            /* point size */
                /* change from "-0-" to "-<size>-" */
                sprintf (&newname[j], "%d", size);
                while (newname[j] != '\0')
                    j++;
                if (name[i + 1] != '\0')
                    i++;
                break;
            case 9:            /* x-resolution */
            case 10:           /* y-resolution */
                /* change from an unspecified resolution to res_x or res_y */
                sprintf (&newname[j], "%d", (field == 9) ? res_x : res_y);
                while (newname[j] != '\0')
                    j++;
                while ((name[i + 1] != '-') && (name[i + 1] != '\0'))
                    i++;
                break;
            }
        }
    }
    newname[j] = '\0';
    /* if there aren't 14 hyphens, it isn't a well formed name */
    if (field != 14)
        return NULL;
    return XLoadQueryFont (dpy, newname);
}
예제 #15
0
int NvCtrlGetScreenHeightMM(NvCtrlAttributeHandle *handle)
{
    NvCtrlAttributePrivateHandle *h;

    if (!handle) return -1;

    h = (NvCtrlAttributePrivateHandle *) handle;

    if (h->target_type != NV_CTRL_TARGET_TYPE_X_SCREEN) return -1;

    return DisplayHeightMM(h->dpy, h->target_id);
    
} /* NvCtrlGetScreenHeightMM() */
예제 #16
0
/*
 * 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;
}
예제 #17
0
파일: X11RandR13.c 프로젝트: 465060874/jogl
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));
    }
}
static void
gst_vaapi_display_x11_get_size_mm(
    GstVaapiDisplay *display,
    guint           *pwidth,
    guint           *pheight
)
{
    GstVaapiDisplayX11Private * const priv =
        GST_VAAPI_DISPLAY_X11(display)->priv;

    if (!priv->x11_display)
        return;

    if (pwidth)
        *pwidth = DisplayWidthMM(priv->x11_display, priv->x11_screen);

    if (pheight)
        *pheight = DisplayHeightMM(priv->x11_display, priv->x11_screen);
}
예제 #19
0
파일: qxlibscreen.cpp 프로젝트: RS102839/qt
QXlibScreen::QXlibScreen()
        : mFormat(QImage::Format_RGB32)
#if !defined(QT_NO_OPENGL) && defined(QT_OPENGL_ES_2)
        , mEGLDisplay(0)
#endif
{
    char *display_name = getenv("DISPLAY");
    Display *display = XOpenDisplay(display_name);
    mDisplay = new QXlibDisplay(display);


#ifndef DONT_USE_MIT_SHM
    int MIT_SHM_extension_supported = XShmQueryExtension (mDisplay->nativeDisplay());
    Q_ASSERT(MIT_SHM_extension_supported == True);
#endif
    original_x_errhandler = XSetErrorHandler(qt_x_errhandler);

    if (qgetenv("DO_X_SYNCHRONIZE").toInt())
        XSynchronize(mDisplay->nativeDisplay(), true);

    mScreen = DefaultScreen(mDisplay->nativeDisplay());
    XSelectInput(mDisplay->nativeDisplay(),rootWindow(), KeymapStateMask | EnterWindowMask | LeaveWindowMask | PropertyChangeMask);
    int width = DisplayWidth(mDisplay->nativeDisplay(), mScreen);
    int height = DisplayHeight(mDisplay->nativeDisplay(), mScreen);
    mGeometry = QRect(0,0,width,height);

    int physicalWidth = DisplayWidthMM(mDisplay->nativeDisplay(), mScreen);
    int physicalHeight = DisplayHeightMM(mDisplay->nativeDisplay(), mScreen);
    mPhysicalSize = QSize(physicalWidth,physicalHeight);

    int xSocketNumber = XConnectionNumber(mDisplay->nativeDisplay());

    mDepth = DefaultDepth(mDisplay->nativeDisplay(),mScreen);
#ifdef MYX11_DEBUG
    qDebug() << "X socket:"<< xSocketNumber;
#endif
    QSocketNotifier *sock = new QSocketNotifier(xSocketNumber, QSocketNotifier::Read, this);
    connect(sock, SIGNAL(activated(int)), this, SLOT(eventDispatcher()));

    mCursor = new QXlibCursor(this);
    mKeyboard = new QXlibKeyboard(this);
}
예제 #20
0
static void
get_dpi(Display *dpy, int screen, int *x, int *y)
{
    double xres, yres;

    /*
     * there are 2.54 centimeters to an inch; so there are 25.4 millimeters.
     *
     *     dpi = N pixels / (M millimeters / (25.4 millimeters / 1 inch))
     *         = N pixels / (M inch / 25.4)
     *         = N * 25.4 pixels / M inch
     */
    xres = ((((double) DisplayWidth(dpy, screen))  * 25.4) /
            ((double) DisplayWidthMM(dpy, screen)));
    yres = ((((double) DisplayHeight(dpy, screen)) * 25.4) /
            ((double) DisplayHeightMM(dpy, screen)));

    *x = (int) (xres + 0.5);
    *y = (int) (yres + 0.5);
}
예제 #21
0
display display::from_window(window const* w)
{
	Window root = w? *w : g_root;
	display result;
	if (randr.is_available)
	{
		XRRScreenResources* sr = XRRGetScreenResources(g_display, root);
		RROutput primary = XRRGetOutputPrimary(g_display, g_root);
		result = init(sr, primary);
		XRRFreeScreenResources(sr);
	}
	else
	{
		result.scale = 1;
		result.color_depth = XDefaultDepth(g_display, g_screen);
		result.color_depth_per_component = result.color_depth >= 24? 8 : 0;
		result.rect = result.work_rect = rectangle<int>(0, 0,
			DisplayWidthMM(g_display, g_screen), DisplayHeightMM(g_display, g_screen));
	}
	return result;
}
main()
{
	Display * display;
	int       screen;
	char *    display_name=NULL;
	Window    root;
	Visual*   visual;

	/* Connect to X display server.		*/
	display=XOpenDisplay(display_name);

	/* Get screen ID			*/
	screen=DefaultScreen(display);


	printf("\n\tInformation extracted from the X server\n");
	printf("\t---------------------------------------\n\n");

	printf(" X server by \'%s\'\n",        ServerVendor(display));

	printf(" X Server protocol %d\n",      ProtocolVersion(display));

	printf(" X server Release %d\n",       VendorRelease(display));

	printf(" Screen is %dmm high.\n",      DisplayHeightMM(display, screen));

	printf(" Screen is %dmm wide.\n",      DisplayWidthMM(display, screen));

	printf(" Screen is %d pixels high.\n", DisplayHeight(display, screen));

	printf(" Screen is %d pixels wide.\n", DisplayWidth(display, screen));

	visual = DefaultVisual(display,screen);
	printf(" %3d Colour map entries", visual->map_entries);
	printf(" (Number of colours on the screen at one time).\n");

	printf(" %3d Display planes (bits per screen pixel).\n", DisplayPlanes(display, screen));

	printf(" There is %d screen(s).\n", ScreenCount (display));
}
예제 #23
0
int __aa_X_getsize(struct aa_context *c,struct xdriverdata *d)
{
    unsigned int px, py;
    int tmp;
    Window wtmp;
    XSync(d->dp, 0);
    XGetGeometry(d->dp, d->wi, &wtmp, &tmp, &tmp, &px, &py, (unsigned int *) &tmp, (unsigned int *) &tmp);
    tmp = 0;
    if (px != d->pixelwidth || py != d->pixelheight)
	tmp = 1;
    d->pixelwidth = px;
    d->pixelheight = py;
    if (tmp) {
	if (d->pixmapmode)
	    XFreePixmap(d->dp, d->pi);
	if (!getenv("AABlink"))
	  d->pi = XCreatePixmap(d->dp, d->wi, d->pixelwidth, d->pixelheight, DefaultDepth(d->dp, d->screen));
	else
	  d->pi = BadAlloc;
	if (d->pi == BadAlloc) {
	    d->pixmapmode = 0;
	    XSetWindowBackground(d->dp, d->wi, d->inverted ? d->invertedblack : d->black);
	} else {
	    d->pixmapmode = 1;
	    XFillRectangle(d->dp, d->pi, d->blackGC, 0, 0, d->pixelwidth, d->pixelheight);
	    XSetWindowBackgroundPixmap(d->dp, d->wi, d->pi);
	}
	c->driverparams.mmwidth = DisplayWidthMM(d->dp, d->screen) * d->pixelwidth / DisplayWidth(d->dp, d->screen);
	c->driverparams.mmheight = DisplayHeightMM(d->dp, d->screen) * d->pixelheight / DisplayHeight(d->dp, d->screen);
	if (d->previoust != NULL)
	    free(d->previoust), free(d->previousa);
	d->previoust=NULL;
	d->previousa=NULL;
	X_flush(c);
	XFlush(d->dp);
    }
    XSync(d->dp, 0);
    return (tmp);
}
예제 #24
0
QSize UIDisplay::GetPhysicalSizePriv(void)
{
    int displayWidthMM  = 400;
    int displayHeightMM = 225;

    // TODO use display when needed
    const char *displaystring = NULL;
    Display* display = XOpenDisplay(displaystring);

    if (display)
    {
        int screen  = DefaultScreen(display);
        displayWidthMM  = DisplayWidthMM (display, screen);
        displayHeightMM = DisplayHeightMM(display, screen);
        XCloseDisplay(display);
    }
    else
    {
        LOG(VB_GENERAL, LOG_ERR, "Failed to open X display.");
    }

    return QSize(displayWidthMM, displayHeightMM);
}
예제 #25
0
int getScreenResolution() {
	int result;
#ifdef VAR_HAS_UI
#ifdef ANDROID
	result = 160;
	int tmp;
	char buf[PROP_VALUE_MAX];
	if (__system_property_get("qemu.sf.lcd_density", buf) > 0) {
		if (sscanf(buf, "%d", &tmp)) {
			result = tmp;
		}
	} else if (__system_property_get("ro.sf.lcd_density", buf) > 0) {
		if (sscanf(buf, "%d", &tmp)) {
			result = tmp;
		}
	}
#else
    #ifdef osx
	result = 0;
	#else
	    Display *display = XOpenDisplay(NULL);
	    int scr = 0;
		double xres = ((((double) DisplayWidth(display,scr)) * 25.4) /
	        ((double) DisplayWidthMM(display,scr)));
	    double yres = ((((double) DisplayHeight(display,scr)) * 25.4) /
	        ((double) DisplayHeightMM(display,scr)));
	    int xr = (int) (xres + 0.5);
	    int yr = (int) (yres + 0.5);
        result = MIN(xr, yr);
	    XCloseDisplay(display);
	#endif
#endif
#else
    result = 0;
#endif
	return result;
}
예제 #26
0
	unsigned platform_abstraction::screen_dpi(bool x_requested)
	{
#ifdef NANA_WINDOWS
		auto hdc = ::GetDC(nullptr);
		auto dots = static_cast<unsigned>(::GetDeviceCaps(hdc, (x_requested ? LOGPIXELSX : LOGPIXELSY)));
		::ReleaseDC(nullptr, hdc);
		return dots;
#else
		auto & spec = ::nana::detail::platform_spec::instance();
		auto disp = spec.open_display();
		auto screen = ::XDefaultScreen(disp);

		double dots = 0.5;

		if (x_requested)
			dots += ((((double)DisplayWidth(disp, screen)) * 25.4) /
			((double)DisplayWidthMM(disp, screen)));
		else
			dots += ((((double)DisplayHeight(disp, screen)) * 25.4) /
			((double)DisplayHeightMM(disp, screen)));

		return static_cast<unsigned>(dots);
#endif
	}
예제 #27
0
/* CENTRY */
int GLUTAPIENTRY
glutGet(GLenum param)
{
    Window win, root;
    int x, y, value;
    unsigned int width, height, border, depth;

    switch (param) {
    case GLUT_INIT_WINDOW_X:
        return __glutInitX;
    case GLUT_INIT_WINDOW_Y:
        return __glutInitY;
    case GLUT_INIT_WINDOW_WIDTH:
        return __glutInitWidth;
    case GLUT_INIT_WINDOW_HEIGHT:
        return __glutInitHeight;
    case GLUT_INIT_DISPLAY_MODE:
        return __glutDisplayMode;
    case GLUT_WINDOW_X:
        XTranslateCoordinates(__glutDisplay, __glutCurrentWindow->win,
                              __glutRoot, 0, 0, &x, &y, &win);
        return x;
    case GLUT_WINDOW_Y:
        XTranslateCoordinates(__glutDisplay, __glutCurrentWindow->win,
                              __glutRoot, 0, 0, &x, &y, &win);
        return y;
    case GLUT_WINDOW_WIDTH:
        if (!__glutCurrentWindow->reshape) {
            XGetGeometry(__glutDisplay, __glutCurrentWindow->win,
                         &root, &x, &y,
                         &width, &height, &border, &depth);
            return width;
        }
        return __glutCurrentWindow->width;
    case GLUT_WINDOW_HEIGHT:
        if (!__glutCurrentWindow->reshape) {
            XGetGeometry(__glutDisplay, __glutCurrentWindow->win,
                         &root, &x, &y,
                         &width, &height, &border, &depth);
            return height;
        }
        return __glutCurrentWindow->height;
#ifdef __OS2__
#define GET_CONFIG(attrib) \
  { if (__glutCurrentWindow->renderWin == __glutCurrentWindow->win)  \
       glXGetConfig( __glutCurrentWindow->vis, attrib, &value); \
    else  \
    glXGetConfig(__glutCurrentWindow->overlay->vis, attrib, &value); \
  } \

#else

#define GET_CONFIG(attrib) { \
  if (__glutCurrentWindow->renderWin == __glutCurrentWindow->win) { \
    glXGetConfig(__glutDisplay, __glutCurrentWindow->vis, \
      attrib, &value); \
  } else { \
    glXGetConfig(__glutDisplay, __glutCurrentWindow->overlay->vis, \
      attrib, &value); \
  } \
}
#endif

    case GLUT_WINDOW_BUFFER_SIZE:
        GET_CONFIG(GLX_BUFFER_SIZE);
        return value;
    case GLUT_WINDOW_STENCIL_SIZE:
        GET_CONFIG(GLX_STENCIL_SIZE);
        return value;
    case GLUT_WINDOW_DEPTH_SIZE:
        GET_CONFIG(GLX_DEPTH_SIZE);
        return value;
    case GLUT_WINDOW_RED_SIZE:
        GET_CONFIG(GLX_RED_SIZE);
        return value;
    case GLUT_WINDOW_GREEN_SIZE:
        GET_CONFIG(GLX_GREEN_SIZE);
        return value;
    case GLUT_WINDOW_BLUE_SIZE:
        GET_CONFIG(GLX_BLUE_SIZE);
        return value;
    case GLUT_WINDOW_ALPHA_SIZE:
        GET_CONFIG(GLX_ALPHA_SIZE);
        return value;
    case GLUT_WINDOW_ACCUM_RED_SIZE:
        GET_CONFIG(GLX_ACCUM_RED_SIZE);
        return value;
    case GLUT_WINDOW_ACCUM_GREEN_SIZE:
        GET_CONFIG(GLX_ACCUM_GREEN_SIZE);
        return value;
    case GLUT_WINDOW_ACCUM_BLUE_SIZE:
        GET_CONFIG(GLX_ACCUM_BLUE_SIZE);
        return value;
    case GLUT_WINDOW_ACCUM_ALPHA_SIZE:
        GET_CONFIG(GLX_ACCUM_ALPHA_SIZE);
        return value;
    case GLUT_WINDOW_DOUBLEBUFFER:
        GET_CONFIG(GLX_DOUBLEBUFFER);
        return value;
    case GLUT_WINDOW_RGBA:
        GET_CONFIG(GLX_RGBA);
        return value;
    case GLUT_WINDOW_COLORMAP_SIZE:
        GET_CONFIG(GLX_RGBA);
        if (value) {
            return 0;
        } else {
#if defined(_WIN32) || defined(__OS2__)
            /* KLUDGE: we always assume 256 colors in CI mode on
               Win32 */
            return 256;
#else
            if (__glutCurrentWindow->renderWin == __glutCurrentWindow->win) {
                return __glutCurrentWindow->vis->visual->map_entries;
            } else {
                return __glutCurrentWindow->overlay->vis->visual->map_entries;
            }
#endif /* _WIN32 */
        }
    case GLUT_WINDOW_PARENT:
        return __glutCurrentWindow->parent ?
               __glutCurrentWindow->parent->num + 1 : 0;
    case GLUT_WINDOW_NUM_CHILDREN:
    {
        int num = 0;
        GLUTwindow *children = __glutCurrentWindow->children;

        while (children) {
            num++;
            children = children->siblings;
        }
        return num;
    }
    case GLUT_WINDOW_NUM_SAMPLES:
#if defined(GLX_VERSION_1_1) && defined(GLX_SGIS_multisample)
        if (__glutIsSupportedByGLX("GLX_SGIS_multisample")) {
            GET_CONFIG(GLX_SAMPLES_SGIS);
            return value;
        } else {
            return 0;
        }
#else
        /* Independent of GLX server support, multisampling not
           supported by GLX client-side. */
        return 0;
#endif
    case GLUT_WINDOW_STEREO:
        GET_CONFIG(GLX_STEREO);
        return value;
    case GLUT_WINDOW_CURSOR:
        return __glutCurrentWindow->cursor;
    case GLUT_SCREEN_WIDTH:
        return DisplayWidth(__glutDisplay, __glutScreen);
    case GLUT_SCREEN_HEIGHT:
        return DisplayHeight(__glutDisplay, __glutScreen);
    case GLUT_SCREEN_WIDTH_MM:
        return DisplayWidthMM(__glutDisplay, __glutScreen);
    case GLUT_SCREEN_HEIGHT_MM:
        return DisplayHeightMM(__glutDisplay, __glutScreen);
    case GLUT_MENU_NUM_ITEMS:
        return __glutCurrentMenu->num;
    case GLUT_DISPLAY_MODE_POSSIBLE:
    {
        XVisualInfo *vi;
        Bool dummy, visAlloced;
        void *fbc;

#if defined(_WIN32)
        /* Our fake glXChooseVisual (which is called by
           __glutDetermineVisual) needs an HDC to work with, so grab one
           from the "root" window. */
        XHDC = GetDC(GetDesktopWindow());
#endif
        vi = __glutDetermineWindowVisual(&dummy, &visAlloced, &fbc);
#if defined(_WIN32)
        ReleaseDC(GetDesktopWindow(), XHDC);
#endif
        if (vi) {
            if (visAlloced)
                XFree(vi);
            return 1;
        }
        return 0;
    }
    case GLUT_ELAPSED_TIME:
    {
#ifdef OLD_VMS
        struct timeval6 elapsed, beginning, now;
#else
        struct timeval elapsed, beginning, now;
#endif

        __glutInitTime(&beginning);
        GETTIMEOFDAY(&now);
        TIMEDELTA(elapsed, now, beginning);
        /* Return elapsed milliseconds. */
#if defined(__vms) && ( __VMS_VER < 70000000 )
        return (int) (elapsed.val / TICKS_PER_MILLISECOND);
#else
        return (int) ((elapsed.tv_sec * 1000) + (elapsed.tv_usec / 1000));
#endif
    }
    case GLUT_WINDOW_FORMAT_ID:
#if defined(__OS2__)
        return wglGetPixelFormat(__glutCurrentWindow->hdc);
#elif defined(_WIN32)
        return GetPixelFormat(__glutCurrentWindow->hdc);
#else
        if (__glutCurrentWindow->renderWin == __glutCurrentWindow->win) {
            return (int) __glutCurrentWindow->vis->visualid;
        } else {
            return (int) __glutCurrentWindow->overlay->vis->visualid;
        }
#endif
    default:
        __glutWarning("invalid glutGet parameter: %d", param);
        return -1;
    }
}
예제 #28
0
/*
 * A call to this function should initialize all the display stuff...
 */
void fgInitialize( const char* displayName )
{
#if TARGET_HOST_UNIX_X11
    fgDisplay.Display = XOpenDisplay( displayName );

    if( fgDisplay.Display == NULL )
        fgError( "failed to open display '%s'", XDisplayName( displayName ) );

#if !defined(USE_EGL)
    if( !glXQueryExtension( fgDisplay.Display, NULL, NULL ) )
        fgError( "OpenGL GLX extension not supported by display '%s'",
            XDisplayName( displayName ) );
#endif

    fgDisplay.Screen = DefaultScreen( fgDisplay.Display );
    fgDisplay.RootWindow = RootWindow(
        fgDisplay.Display,
        fgDisplay.Screen
    );

    fgDisplay.ScreenWidth  = DisplayWidth(
        fgDisplay.Display,
        fgDisplay.Screen
    );
    fgDisplay.ScreenHeight = DisplayHeight(
        fgDisplay.Display,
        fgDisplay.Screen
    );

    fgDisplay.ScreenWidthMM = DisplayWidthMM(
        fgDisplay.Display,
        fgDisplay.Screen
    );
    fgDisplay.ScreenHeightMM = DisplayHeightMM(
        fgDisplay.Display,
        fgDisplay.Screen
    );

    fgDisplay.Connection = ConnectionNumber( fgDisplay.Display );

    /*
     * Create the window deletion atom
     */
    fgDisplay.DeleteWindow = XInternAtom(
        fgDisplay.Display,
        "WM_DELETE_WINDOW",
        FALSE
    );

#elif TARGET_HOST_WIN32

    WNDCLASS wc;
    ATOM atom;

    /*
     * What we need to do is to initialize the fgDisplay global structure here.
     */
    fgDisplay.Instance = GetModuleHandle( NULL );

    atom = GetClassInfo( fgDisplay.Instance, TEXT("GLUT|ES"), &wc );
    if( atom == 0 )
    {
        ZeroMemory( &wc, sizeof(WNDCLASS) );

        /*
         * Each of the windows should have its own device context, and we
         * want redraw events during Vertical and Horizontal Resizes by
         * the user.
         *
         * XXX Old code had "| CS_DBCLCKS" commented out.  Plans for the
         * XXX future?  Dead-end idea?
         */
#ifdef _WIN32_WCE
        wc.style          = 0;
#else
		wc.style		  = CS_OWNDC | CS_HREDRAW | CS_VREDRAW;
#endif
        wc.lpfnWndProc    = fgWindowProc;
        wc.cbClsExtra     = 0;
        wc.cbWndExtra     = 0;
        wc.hInstance      = fgDisplay.Instance;
#ifndef _WIN32_WCE
        wc.hIcon          = LoadIcon( fgDisplay.Instance, "GLUT_ICON" );
        if (!wc.hIcon)
          wc.hIcon        = LoadIcon( NULL, IDI_WINLOGO );
#endif
        wc.hCursor        = LoadCursor( NULL, IDC_ARROW );
        wc.hbrBackground  = (HBRUSH)GetStockObject(BLACK_BRUSH);;
        wc.lpszMenuName   = NULL;
        wc.lpszClassName  = TEXT("GLUT|ES");

        /*
         * Register the window class
         */
        atom = RegisterClass( &wc );
        assert( atom );
    }

    /*
     * The screen dimensions can be obtained via GetSystemMetrics() calls
     */
    fgDisplay.ScreenWidth  = GetSystemMetrics( SM_CXSCREEN );
    fgDisplay.ScreenHeight = GetSystemMetrics( SM_CYSCREEN );

    {
        HWND desktop = GetDesktopWindow( );
        HDC  context = GetDC( desktop );

        fgDisplay.ScreenWidthMM  = GetDeviceCaps( context, HORZSIZE );
        fgDisplay.ScreenHeightMM = GetDeviceCaps( context, VERTSIZE );

        ReleaseDC( desktop, context );
    }

#endif

	__glInit();
#ifndef _WIN32_WCE
    fgJoystickInit( 0 );
#endif

    fgState.Initialised = GL_TRUE;
}
예제 #29
0
/*
 * A call to this function should initialize all the display stuff...
 */
static void fghInitialize( const char* displayName )
{
#if TARGET_HOST_POSIX_X11
    fgDisplay.Display = XOpenDisplay( displayName );

    if( fgDisplay.Display == NULL )
        fgError( "failed to open display '%s'", XDisplayName( displayName ) );

    if( !glXQueryExtension( fgDisplay.Display, NULL, NULL ) )
        fgError( "OpenGL GLX extension not supported by display '%s'",
            XDisplayName( displayName ) );

    fgDisplay.Screen = DefaultScreen( fgDisplay.Display );
    fgDisplay.RootWindow = RootWindow(
        fgDisplay.Display,
        fgDisplay.Screen
    );

    fgDisplay.ScreenWidth  = DisplayWidth(
        fgDisplay.Display,
        fgDisplay.Screen
    );
    fgDisplay.ScreenHeight = DisplayHeight(
        fgDisplay.Display,
        fgDisplay.Screen
    );

    fgDisplay.ScreenWidthMM = DisplayWidthMM(
        fgDisplay.Display,
        fgDisplay.Screen
    );
    fgDisplay.ScreenHeightMM = DisplayHeightMM(
        fgDisplay.Display,
        fgDisplay.Screen
    );

    fgDisplay.Connection = ConnectionNumber( fgDisplay.Display );

    /* Create the window deletion atom */
    fgDisplay.DeleteWindow = fghGetAtom("WM_DELETE_WINDOW");

    /* Create the state and full screen atoms */
    fgDisplay.State           = None;
    fgDisplay.StateFullScreen = None;

    if (fghNetWMSupported())
    {
      const Atom supported = fghGetAtom("_NET_SUPPORTED");
      const Atom state     = fghGetAtom("_NET_WM_STATE");
      
      /* Check if the state hint is supported. */
      if (fgHintPresent(fgDisplay.RootWindow, supported, state))
      {
        const Atom full_screen = fghGetAtom("_NET_WM_STATE_FULLSCREEN");
        
        fgDisplay.State = state;
        
        /* Check if the window manager supports full screen. */
        /**  Check "_NET_WM_ALLOWED_ACTIONS" on our window instead? **/
        if (fgHintPresent(fgDisplay.RootWindow, supported, full_screen))
        {
          fgDisplay.StateFullScreen = full_screen;
        }
      }
    }

#elif TARGET_HOST_MS_WINDOWS

    WNDCLASS wc;
    ATOM atom;

    /* What we need to do is to initialize the fgDisplay global structure here. */
    fgDisplay.Instance = GetModuleHandle( NULL );
    fgDisplay.DisplayName= displayName ? strdup(displayName) : 0 ;
    atom = GetClassInfo( fgDisplay.Instance, _T("FREEGLUT"), &wc );

    if( atom == 0 )
    {
        ZeroMemory( &wc, sizeof(WNDCLASS) );

        /*
         * Each of the windows should have its own device context, and we
         * want redraw events during Vertical and Horizontal Resizes by
         * the user.
         *
         * XXX Old code had "| CS_DBCLCKS" commented out.  Plans for the
         * XXX future?  Dead-end idea?
         */
        wc.lpfnWndProc    = fgWindowProc;
        wc.cbClsExtra     = 0;
        wc.cbWndExtra     = 0;
        wc.hInstance      = fgDisplay.Instance;
        wc.hIcon          = LoadIcon( fgDisplay.Instance, _T("GLUT_ICON") );

#if defined(_WIN32_WCE)
        wc.style          = CS_HREDRAW | CS_VREDRAW;
#else
        wc.style          = CS_OWNDC | CS_HREDRAW | CS_VREDRAW;
        if (!wc.hIcon)
          wc.hIcon        = LoadIcon( NULL, IDI_WINLOGO );
#endif

        wc.hCursor        = LoadCursor( NULL, IDC_ARROW );
        wc.hbrBackground  = NULL;
        wc.lpszMenuName   = NULL;
        wc.lpszClassName  = _T("FREEGLUT");

        /* Register the window class */
        atom = RegisterClass( &wc );
        FREEGLUT_INTERNAL_ERROR_EXIT ( atom, "Window Class Not Registered", "fghInitialize" );
    }

    /* The screen dimensions can be obtained via GetSystemMetrics() calls */
    fgDisplay.ScreenWidth  = GetSystemMetrics( SM_CXSCREEN );
    fgDisplay.ScreenHeight = GetSystemMetrics( SM_CYSCREEN );

    {
        HWND desktop = GetDesktopWindow( );
        HDC  context = GetDC( desktop );

        fgDisplay.ScreenWidthMM  = GetDeviceCaps( context, HORZSIZE );
        fgDisplay.ScreenHeightMM = GetDeviceCaps( context, VERTSIZE );

        ReleaseDC( desktop, context );
    }
    /* If we have a DisplayName try to use it for metrics */
    if( fgDisplay.DisplayName )
    {
        HDC context = CreateDC(fgDisplay.DisplayName,0,0,0);
        if( context )
        {
	    fgDisplay.ScreenWidth  = GetDeviceCaps( context, HORZRES );
	    fgDisplay.ScreenHeight = GetDeviceCaps( context, VERTRES );
	    fgDisplay.ScreenWidthMM  = GetDeviceCaps( context, HORZSIZE );
	    fgDisplay.ScreenHeightMM = GetDeviceCaps( context, VERTSIZE );
	    DeleteDC(context);
        }
        else
	    fgWarning("fghInitialize: "
		      "CreateDC failed, Screen size info may be incorrect\n"
          "This is quite likely caused by a bad '-display' parameter");
      
    }
    /* Set the timer granularity to 1 ms */
    timeBeginPeriod ( 1 );

#endif

    fgState.Initialised = GL_TRUE;

    /* Avoid registering atexit callback on Win32 as it results in an access
     * violation due to calling into a module which has been unloaded.
     * Any cleanup isn't needed on Windows anyway, the OS takes care of it.c
     * see: http://blogs.msdn.com/b/oldnewthing/archive/2012/01/05/10253268.aspx
     */
#if ( TARGET_HOST_MS_WINDOWS == 0 )
    atexit(fgDeinitialize);
#endif

    /* InputDevice uses GlutTimerFunc(), so fgState.Initialised must be TRUE */
    fgInitialiseInputDevices();
}
예제 #30
0
static gboolean
clutter_backend_x11_post_parse (ClutterBackend  *backend,
                                GError         **error)
{
  ClutterBackendX11 *backend_x11 = CLUTTER_BACKEND_X11 (backend);
  ClutterSettings *settings;
  Atom atoms[N_ATOM_NAMES];
  double dpi;

  if (_foreign_dpy)
    backend_x11->xdpy = _foreign_dpy;

  /* Only open connection if not already set by prior call to
   * clutter_x11_set_display()
   */
  if (backend_x11->xdpy == NULL)
    {
      if (clutter_display_name != NULL &&
          *clutter_display_name != '\0')
	{
	  CLUTTER_NOTE (BACKEND, "XOpenDisplay on '%s'", clutter_display_name);

	  backend_x11->xdpy = XOpenDisplay (clutter_display_name);
          if (backend_x11->xdpy == NULL)
            {
              g_set_error (error, CLUTTER_INIT_ERROR,
                           CLUTTER_INIT_ERROR_BACKEND,
                           "Unable to open display '%s'",
                           clutter_display_name);
              return FALSE;
            }
	}
      else
	{
	  g_set_error_literal (error, CLUTTER_INIT_ERROR,
                               CLUTTER_INIT_ERROR_BACKEND,
                               "Unable to open display. You have to set the "
                               "DISPLAY environment variable, or use the "
                               "--display command line argument");
	  return FALSE;
	}
    }

  g_assert (backend_x11->xdpy != NULL);

  CLUTTER_NOTE (BACKEND, "Getting the X screen");

  settings = clutter_settings_get_default ();

  /* add event filter for Cogl events */
  clutter_x11_add_filter (cogl_xlib_filter, backend);

  if (clutter_screen == -1)
    backend_x11->xscreen = DefaultScreenOfDisplay (backend_x11->xdpy);
  else
    backend_x11->xscreen = ScreenOfDisplay (backend_x11->xdpy,
                                            clutter_screen);

  backend_x11->xscreen_num = XScreenNumberOfScreen (backend_x11->xscreen);
  backend_x11->xscreen_width = WidthOfScreen (backend_x11->xscreen);
  backend_x11->xscreen_height = HeightOfScreen (backend_x11->xscreen);

  backend_x11->xwin_root = RootWindow (backend_x11->xdpy,
                                       backend_x11->xscreen_num);

  backend_x11->display_name = g_strdup (clutter_display_name);

  dpi = (((double) DisplayHeight (backend_x11->xdpy, backend_x11->xscreen_num) * 25.4)
      / (double) DisplayHeightMM (backend_x11->xdpy, backend_x11->xscreen_num));

  g_object_set (settings, "font-dpi", (int) dpi * 1024, NULL);

  /* create XSETTINGS client */
  backend_x11->xsettings =
    _clutter_xsettings_client_new (backend_x11->xdpy,
                                   backend_x11->xscreen_num,
                                   clutter_backend_x11_xsettings_notify,
                                   NULL,
                                   backend_x11);

  /* add event filter for XSETTINGS events */
  clutter_x11_add_filter (xsettings_filter, backend_x11);

  if (clutter_synchronise)
    XSynchronize (backend_x11->xdpy, True);

  XInternAtoms (backend_x11->xdpy,
                (char **) atom_names, N_ATOM_NAMES,
                False, atoms);

  backend_x11->atom_NET_WM_PID = atoms[0];
  backend_x11->atom_NET_WM_PING = atoms[1];
  backend_x11->atom_NET_WM_STATE = atoms[2];
  backend_x11->atom_NET_WM_STATE_FULLSCREEN = atoms[3];
  backend_x11->atom_NET_WM_USER_TIME = atoms[4];
  backend_x11->atom_WM_PROTOCOLS = atoms[5];
  backend_x11->atom_WM_DELETE_WINDOW = atoms[6];
  backend_x11->atom_XEMBED = atoms[7];
  backend_x11->atom_XEMBED_INFO = atoms[8];
  backend_x11->atom_NET_WM_NAME = atoms[9];
  backend_x11->atom_UTF8_STRING = atoms[10];

  g_free (clutter_display_name);

  CLUTTER_NOTE (BACKEND,
                "X Display '%s'[%p] opened (screen:%d, root:%u, dpi:%f)",
                backend_x11->display_name,
                backend_x11->xdpy,
                backend_x11->xscreen_num,
                (unsigned int) backend_x11->xwin_root,
                clutter_backend_get_resolution (backend));

  return TRUE;
}