Beispiel #1
0
/*
 * @brief gets a screen's primary output's possible sizes
 * @param root window which's primary output will be queried
 * @param num number of sizes reported as supported by the screen's primary output
 * @return an array of sizes reported as supported by the screen's primary output or - if query failed - NULL
 */
EAPI Ecore_X_Randr_Screen_Size_MM *
ecore_x_randr_screen_primary_output_sizes_get(Ecore_X_Window root, int *num)
{
#ifdef ECORE_XRANDR
   Ecore_X_Randr_Screen_Size_MM *ret = NULL;
   XRRScreenSize *sizes;
   int i, n;

   /* we don't have to free sizes, because they're hold in a cache inside X*/
   sizes =
      XRRSizes(_ecore_x_disp, XRRRootToScreen(_ecore_x_disp,
                                                    root), &n);
   if ((!sizes) || (n <= 0)) return NULL;
   ret = calloc(n, sizeof(Ecore_X_Randr_Screen_Size_MM));
   if (!ret)
      return NULL;

   if (num)
      *num = n;

   for (i = 0; i < n; i++)
     {
        ret[i].width = sizes[i].width;
        ret[i].height = sizes[i].height;
        ret[i].width_mm = sizes[i].mwidth;
        ret[i].height_mm = sizes[i].mheight;
     }
   return ret;
#else /* ifdef ECORE_XRANDR */
   return NULL;
#endif /* ifdef ECORE_XRANDR */
} /* ecore_x_randr_screen_primary_output_sizes_get */
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;
}
Beispiel #3
0
/*
 * @param root window which's primary output will be queried
 * @return the current orientation of the root window's screen primary output
 */
EAPI Ecore_X_Randr_Orientation
ecore_x_randr_screen_primary_output_orientation_get(Ecore_X_Window root)
{
#ifdef ECORE_XRANDR
   Rotation crot = Ecore_X_Randr_None;
   XRRRotations(_ecore_x_disp, XRRRootToScreen(_ecore_x_disp,
                                                     root), &crot);
   return crot;
#else /* ifdef ECORE_XRANDR */
   return Ecore_X_Randr_None;
#endif /* ifdef ECORE_XRANDR */
} /* ecore_x_randr_screen_primary_output_orientation_get */
Beispiel #4
0
/*
 * @param root window which's primary output will be queried
 */
EAPI Ecore_X_Randr_Orientation
ecore_x_randr_screen_primary_output_orientations_get(Ecore_X_Window root)
{
#ifdef ECORE_XRANDR
   Rotation rot = Ecore_X_Randr_None, crot;

   LOGFN(__FILE__, __LINE__, __FUNCTION__);
   rot =
      XRRRotations(_ecore_x_disp, XRRRootToScreen(_ecore_x_disp,
                                                        root), &crot);
   return rot;
#else /* ifdef ECORE_XRANDR */
   return Ecore_X_Randr_None;
#endif /* ifdef ECORE_XRANDR */
} /* ecore_x_randr_screen_primary_output_orientations_get */
Beispiel #5
0
/*
 * @brief get the current set size of a given screen's primary output
 * @param root window which's primary output will be queried
 * @param w the current size's width
 * @param h the current size's height
 * @param w_mm the current size's width in mm
 * @param h_mm the current size's height in mm
 * @param size_index of current set size to be used with ecore_x_randr_primary_output_size_set()
 */
EAPI void
ecore_x_randr_screen_primary_output_current_size_get(Ecore_X_Window root,
                                                     int           *w,
                                                     int           *h,
                                                     int           *w_mm,
                                                     int           *h_mm,
                                                     int           *size_index)
{
#ifdef ECORE_XRANDR
   XRRScreenSize *sizes;
   XRRScreenConfiguration *sc = NULL;
   int index;
   Rotation orientation;
   int n;

   if (!(sc = XRRGetScreenInfo(_ecore_x_disp, root)))
     {
        ERR("Couldn't get screen information for %d", root);
        return;
     }

   index = XRRConfigCurrentConfiguration(sc, &orientation);

   sizes =
      XRRSizes(_ecore_x_disp, XRRRootToScreen(_ecore_x_disp,
                                                    root), &n);
   if ((index < n) && (index >= 0))
     {
        if (w)
           *w = sizes[index].width;

        if (h)
           *h = sizes[index].height;

        if (w_mm)
           *w_mm = sizes[index].mwidth;

        if (h_mm)
           *h_mm = sizes[index].mheight;

        if (size_index)
           *size_index = index;
     }

   XRRFreeScreenConfigInfo(sc);
#endif /* ifdef ECORE_XRANDR */
} /* ecore_x_randr_screen_primary_output_current_size_get */
Beispiel #6
0
/*
 * @brief sets a given screen's primary output size, but disables all other outputs at the same time
 * @param root window which's primary output will be queried
 * @param size_index within the list of sizes reported as supported by the root window's screen primary output
 * @return EINA_TRUE on success, EINA_FALSE on failure due to e.g. invalid times
 */
EAPI Eina_Bool
ecore_x_randr_screen_primary_output_size_set(Ecore_X_Window root,
                                             int            size_index)
{
#ifdef ECORE_XRANDR
   XRRScreenConfiguration *sc = NULL;
   XRRScreenSize *sizes;
   Eina_Bool ret = EINA_FALSE;
   int nsizes = 0;

   if (size_index >= 0 && _ecore_x_randr_root_validate(root))
     {
        sizes =
           XRRSizes(_ecore_x_disp, XRRRootToScreen(_ecore_x_disp,
                                                         root), &nsizes);

        if (size_index < nsizes)
          {
             sc = XRRGetScreenInfo(_ecore_x_disp, root);
             if (!XRRSetScreenConfig(_ecore_x_disp, sc,
                                     root, size_index,
                                     ECORE_X_RANDR_ORIENTATION_ROT_0, CurrentTime))
               {
                  ret = EINA_TRUE;
               }

             if (sc)
                XRRFreeScreenConfigInfo(sc);
          }
     }

   return ret;
#else /* ifdef ECORE_XRANDR */
   return EINA_FALSE;
#endif /* ifdef ECORE_XRANDR */
} /* ecore_x_randr_screen_primary_output_size_set */