forked from enlightenment/efl
parent
9c50cdec34
commit
ddc72506e0
|
@ -1412,12 +1412,22 @@ struct _Ecore_X_Screen_Size
|
|||
int width, height;
|
||||
};
|
||||
|
||||
typedef struct _Ecore_X_Screen_Refresh_Rate Ecore_X_Screen_Refresh_Rate;
|
||||
struct _Ecore_X_Screen_Refresh_Rate
|
||||
{
|
||||
int rate;
|
||||
};
|
||||
|
||||
EAPI int ecore_x_randr_events_select(Ecore_X_Window win, int on);
|
||||
EAPI Ecore_X_Screen_Size *ecore_x_randr_screen_sizes_get(Ecore_X_Window root, int *num);
|
||||
EAPI Ecore_X_Screen_Size ecore_x_randr_current_screen_size_get(Ecore_X_Window root);
|
||||
EAPI int ecore_x_randr_screen_size_set(Ecore_X_Window root,
|
||||
Ecore_X_Screen_Size size);
|
||||
|
||||
EAPI Ecore_X_Screen_Refresh_Rate *ecore_x_randr_screen_refresh_rates_get(Ecore_X_Window root, int size_id, int *num);
|
||||
EAPI Ecore_X_Screen_Refresh_Rate ecore_x_randr_current_screen_refresh_rate_get(Ecore_X_Window root);
|
||||
|
||||
EAPI int ecore_x_randr_screen_refresh_rate_set(Ecore_X_Window root, Ecore_X_Screen_Refresh_Rate rate);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -71,6 +71,7 @@ ecore_x_randr_current_screen_size_get(Ecore_X_Window root)
|
|||
ret.width = sizes[size_index].width;
|
||||
ret.height = sizes[size_index].height;
|
||||
}
|
||||
XRRFreeScreenConfigInfo(sc);
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
@ -93,7 +94,7 @@ ecore_x_randr_screen_size_set(Ecore_X_Window root, Ecore_X_Screen_Size size)
|
|||
}
|
||||
}
|
||||
if (size_index == -1) return 0;
|
||||
|
||||
|
||||
printf("Size: %d\n", size_index);
|
||||
sc = XRRGetScreenInfo(_ecore_x_disp, root);
|
||||
if (XRRSetScreenConfig(_ecore_x_disp, sc,
|
||||
|
@ -110,3 +111,104 @@ ecore_x_randr_screen_size_set(Ecore_X_Window root, Ecore_X_Screen_Size size)
|
|||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
EAPI Ecore_X_Screen_Refresh_Rate
|
||||
ecore_x_randr_current_screen_refresh_rate_get(Ecore_X_Window root)
|
||||
{
|
||||
Ecore_X_Screen_Refresh_Rate ret = { -1 };
|
||||
#ifdef ECORE_XRANDR
|
||||
XRRScreenConfiguration *sc;
|
||||
|
||||
sc = XRRGetScreenInfo(_ecore_x_disp, root);
|
||||
if (!sc)
|
||||
{
|
||||
printf("ERROR: Couldn't get screen information for %d\n", root);
|
||||
return ret;
|
||||
}
|
||||
ret.rate = XRRConfigCurrentRate(sc);
|
||||
XRRFreeScreenConfigInfo(sc);
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
||||
EAPI Ecore_X_Screen_Refresh_Rate *
|
||||
ecore_x_randr_screen_refresh_rates_get(Ecore_X_Window root, int size_id, int *num)
|
||||
{
|
||||
#ifdef ECORE_XRANDR
|
||||
Ecore_X_Screen_Refresh_Rate *ret = NULL;
|
||||
XRRScreenConfiguration *sc;
|
||||
//SizeID size_index;
|
||||
//Rotation rotation;
|
||||
short *rates;
|
||||
int i, n;
|
||||
|
||||
if (num) *num = 0;
|
||||
|
||||
sc = XRRGetScreenInfo(_ecore_x_disp, root);
|
||||
if (!sc)
|
||||
{
|
||||
printf("ERROR: Couldn't get screen information for %d\n", root);
|
||||
return ret;
|
||||
}
|
||||
|
||||
//size_index = XRRConfigCurrentConfiguration(sc, &rotation);
|
||||
|
||||
rates = XRRRates(_ecore_x_disp, XRRRootToScreen(_ecore_x_disp, root), size_id, &n);
|
||||
ret = calloc(n, sizeof(Ecore_X_Screen_Refresh_Rate));
|
||||
if (!ret)
|
||||
{
|
||||
XRRFreeScreenConfigInfo(sc);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (num) *num = n;
|
||||
for (i = 0; i < n; i++)
|
||||
{
|
||||
ret[i].rate = rates[i];
|
||||
}
|
||||
XRRFreeScreenConfigInfo(sc);
|
||||
return ret;
|
||||
#else
|
||||
if (num) *num = 0;
|
||||
return NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
EAPI int
|
||||
ecore_x_randr_screen_refresh_rate_set(Ecore_X_Window root, Ecore_X_Screen_Refresh_Rate rate)
|
||||
{
|
||||
#ifdef ECORE_XRANDR
|
||||
XRRScreenConfiguration *sc;
|
||||
XRRScreenSize *sizes;
|
||||
Rotation rotation;
|
||||
SizeID size_index;
|
||||
int n;
|
||||
|
||||
sc = XRRGetScreenInfo(_ecore_x_disp, root);
|
||||
if (!sc)
|
||||
{
|
||||
printf("ERROR: Couldn't set screen refresh rate for %d\n", root);
|
||||
return 0;
|
||||
}
|
||||
|
||||
size_index = XRRConfigCurrentConfiguration(sc, &rotation);
|
||||
sizes = XRRSizes(_ecore_x_disp, XRRRootToScreen(_ecore_x_disp, root), &n);
|
||||
if (size_index < n)
|
||||
{
|
||||
if (XRRSetScreenConfigAndRate(_ecore_x_disp, sc,
|
||||
root, size_index,
|
||||
RR_Rotate_0, rate.rate, CurrentTime))
|
||||
{
|
||||
printf("ERROR: Can't set new screen size and refresh rate!\n");
|
||||
XRRFreeScreenConfigInfo(sc);
|
||||
return 0;
|
||||
}
|
||||
XRRFreeScreenConfigInfo(sc);
|
||||
return 1;
|
||||
}
|
||||
XRRFreeScreenConfigInfo(sc);
|
||||
return 0;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue