forked from enlightenment/efl
Improve implementation of ecore_x_randr_window_crtcs_get
SVN revision: 68349
This commit is contained in:
parent
a681840432
commit
29c8ede450
|
@ -2302,71 +2302,38 @@ ecore_x_randr_window_outputs_get(Ecore_X_Window window,
|
||||||
int *num)
|
int *num)
|
||||||
{
|
{
|
||||||
#ifdef ECORE_XRANDR
|
#ifdef ECORE_XRANDR
|
||||||
Ecore_X_Window root;
|
|
||||||
Eina_Rectangle w_geo, c_geo;
|
|
||||||
Ecore_X_Randr_Crtc *crtcs;
|
Ecore_X_Randr_Crtc *crtcs;
|
||||||
Ecore_X_Randr_Mode mode;
|
Ecore_X_Randr_Output *outputs, *ret = NULL;
|
||||||
Ecore_X_Randr_Output *outputs, *ret = NULL, *tret;
|
int ncrtcs, noutputs, i, nret = 0;
|
||||||
Window tw;
|
|
||||||
int ncrtcs, noutputs, i, nret = 0, rx = 0, ry = 0;
|
|
||||||
|
|
||||||
if (_randr_version < RANDR_1_2) goto _ecore_x_randr_current_output_get_fail;
|
if (_randr_version < RANDR_1_2) goto _ecore_x_randr_current_output_get_fail;
|
||||||
|
|
||||||
ecore_x_window_geometry_get(window,
|
if (!(crtcs = ecore_x_randr_window_crtcs_get(window, num)))
|
||||||
&w_geo.x, &w_geo.y,
|
goto _ecore_x_randr_current_output_get_fail;
|
||||||
&w_geo.w, &w_geo.h);
|
|
||||||
|
|
||||||
root = ecore_x_window_root_get(window);
|
for (i = 0, nret = 0; i < ncrtcs; i++)
|
||||||
crtcs = ecore_x_randr_crtcs_get(root, &ncrtcs);
|
|
||||||
if (!crtcs) goto _ecore_x_randr_current_output_get_fail;
|
|
||||||
|
|
||||||
/* now get window RELATIVE to root window - thats what matters. */
|
|
||||||
XTranslateCoordinates(_ecore_x_disp, window, root, 0, 0, &rx, &ry, &tw);
|
|
||||||
w_geo.x = rx;
|
|
||||||
w_geo.y = ry;
|
|
||||||
|
|
||||||
for (i = 0; i < ncrtcs; i++)
|
|
||||||
{
|
{
|
||||||
/* if crtc is not enabled, don't bother about it any further */
|
|
||||||
mode = ecore_x_randr_crtc_mode_get(root, crtcs[i]);
|
|
||||||
if (mode == Ecore_X_Randr_None) continue;
|
|
||||||
|
|
||||||
ecore_x_randr_crtc_geometry_get(root, crtcs[i],
|
outputs = ecore_x_randr_crtc_outputs_get(root, crtcs[i],
|
||||||
&c_geo.x, &c_geo.y,
|
&noutputs);
|
||||||
&c_geo.w, &c_geo.h);
|
if (!outputs)
|
||||||
if (eina_rectangles_intersect(&w_geo, &c_geo))
|
goto _ecore_x_randr_current_output_get_fail_free;
|
||||||
{
|
nret += noutputs;
|
||||||
outputs = ecore_x_randr_crtc_outputs_get(root, crtcs[i],
|
ret = realloc(ret, (nret * sizeof(Ecore_X_Randr_Output)));
|
||||||
&noutputs);
|
memcpy(&ret[nret], outputs, (noutputs * sizeof(Ecore_X_Randr_Output)));
|
||||||
/* The case below should be impossible, but for safety reasons
|
free(outputs);
|
||||||
* remains */
|
|
||||||
if (!outputs)
|
|
||||||
{
|
|
||||||
if (num) *num = 0;
|
|
||||||
free(ret);
|
|
||||||
free(crtcs);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
tret = realloc(ret, ((nret + noutputs) * sizeof(Ecore_X_Randr_Output)));
|
|
||||||
if (!tret)
|
|
||||||
{
|
|
||||||
if (num) *num = 0;
|
|
||||||
free(outputs);
|
|
||||||
free(ret);
|
|
||||||
free(crtcs);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
ret = tret;
|
|
||||||
memcpy(&ret[nret], outputs, (noutputs * sizeof(Ecore_X_Randr_Output)));
|
|
||||||
nret += noutputs;
|
|
||||||
free(outputs);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
free(crtcs);
|
free(crtcs);
|
||||||
|
|
||||||
if (num) *num = nret;
|
if (num)
|
||||||
|
*num = nret;
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
_ecore_x_randr_current_output_get_fail_free:
|
||||||
|
free(outputs);
|
||||||
|
free(crtcs);
|
||||||
|
free(ret);
|
||||||
_ecore_x_randr_current_output_get_fail:
|
_ecore_x_randr_current_output_get_fail:
|
||||||
#endif
|
#endif
|
||||||
if (num) *num = 0;
|
if (num) *num = 0;
|
||||||
|
|
Loading…
Reference in New Issue