forked from enlightenment/efl
parent
0374b166e4
commit
a1bfc55891
|
@ -1559,6 +1559,87 @@ ecore_x_randr_crtcs_get(Ecore_X_Window root,
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @depricated bad naming. Use ecore_x_randr_window_crtcs_get instead.
|
||||||
|
* @brief get the CRTCs, which display a certain window
|
||||||
|
* @param window window the displaying CRTCs shall be found for
|
||||||
|
* @param num the number of CRTCs displaying the window
|
||||||
|
* @return array of CRTCs that display a certain window. NULL if no CRTCs
|
||||||
|
* was found that displays the specified window.
|
||||||
|
*/
|
||||||
|
EINA_DEPRECATED EAPI Ecore_X_Randr_Crtc *
|
||||||
|
ecore_x_randr_current_crtc_get(Ecore_X_Window window,
|
||||||
|
int *num)
|
||||||
|
{
|
||||||
|
return ecore_x_randr_window_crtcs_get(window, num);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @brief get the CRTCs, which display a certain window
|
||||||
|
* @param window window the displaying crtcs shall be found for
|
||||||
|
* @param num the number of crtcs displaying the window
|
||||||
|
* @return array of crtcs that display a certain window. NULL if no crtcs
|
||||||
|
* was found that displays the specified window.
|
||||||
|
* @since 1.2.0
|
||||||
|
*/
|
||||||
|
EAPI Ecore_X_Randr_Crtc *
|
||||||
|
ecore_x_randr_window_crtcs_get(Ecore_X_Window window,
|
||||||
|
int *num)
|
||||||
|
{
|
||||||
|
#ifdef ECORE_XCB_RANDR
|
||||||
|
Ecore_X_Window root;
|
||||||
|
Eina_Rectangle w_geo, c_geo;
|
||||||
|
Ecore_X_Randr_Crtc *crtcs, *ret;
|
||||||
|
Ecore_X_Randr_Mode mode;
|
||||||
|
int ncrtcs, noutputs, i, nret = 0;
|
||||||
|
xcb_translate_coordinates_cookie_t cookie;
|
||||||
|
xcb_translate_coordinates_reply_t *trans;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
||||||
|
CHECK_XCB_CONN;
|
||||||
|
|
||||||
|
#ifdef ECORE_XCB_RANDR
|
||||||
|
RANDR_CHECK_1_2_RET(NULL);
|
||||||
|
|
||||||
|
ecore_x_window_geometry_get(window, &w_geo.x, &w_geo.y, &w_geo.w, &w_geo.h);
|
||||||
|
|
||||||
|
root = ecore_x_window_root_get(window);
|
||||||
|
crtcs = ecore_x_randr_crtcs_get(root, &ncrtcs);
|
||||||
|
if (!crtcs) return NULL;
|
||||||
|
|
||||||
|
/* now get window RELATIVE to root window - thats what matters. */
|
||||||
|
cookie = xcb_translate_coordinates(_ecore_xcb_conn, window, root, 0, 0);
|
||||||
|
trans = xcb_translate_coordinates_reply(_ecore_xcb_conn, cookie, NULL);
|
||||||
|
w_geo.x = trans->dst_x;
|
||||||
|
w_geo.y = trans->dst_y;
|
||||||
|
free(trans);
|
||||||
|
|
||||||
|
for (i = 0, nret = 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], &c_geo.x, &c_geo.y,
|
||||||
|
&c_geo.w, &c_geo.h);
|
||||||
|
if (eina_rectangles_intersect(&w_geo, &c_geo))
|
||||||
|
{
|
||||||
|
ret = realloc(ret, (++nret *
|
||||||
|
sizeof(Ecore_X_Randr_Output)));
|
||||||
|
ret[nret] = crtcs[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
free(crtcs);
|
||||||
|
|
||||||
|
if (num) *num = nret;
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
#endif
|
||||||
|
if (num) *num = 0;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @brief get a CRTC's outputs.
|
* @brief get a CRTC's outputs.
|
||||||
* @param root the root window which's screen will be queried
|
* @param root the root window which's screen will be queried
|
||||||
|
@ -2305,13 +2386,9 @@ ecore_x_randr_window_outputs_get(Ecore_X_Window window,
|
||||||
{
|
{
|
||||||
#ifdef ECORE_XCB_RANDR
|
#ifdef ECORE_XCB_RANDR
|
||||||
Ecore_X_Window root;
|
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;
|
int ncrtcs, noutputs, i, nret = 0;
|
||||||
xcb_translate_coordinates_cookie_t cookie;
|
|
||||||
xcb_translate_coordinates_reply_t *trans;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
||||||
|
@ -2320,64 +2397,36 @@ ecore_x_randr_window_outputs_get(Ecore_X_Window window,
|
||||||
if (num) *num = 0;
|
if (num) *num = 0;
|
||||||
|
|
||||||
#ifdef ECORE_XCB_RANDR
|
#ifdef ECORE_XCB_RANDR
|
||||||
RANDR_CHECK_1_2_RET(NULL);
|
if (_randr_version < RANDR_1_2) goto _ecore_x_randr_current_output_get_fail;
|
||||||
|
|
||||||
ecore_x_window_geometry_get(window, &w_geo.x, &w_geo.y, &w_geo.w, &w_geo.h);
|
|
||||||
|
|
||||||
root = ecore_x_window_root_get(window);
|
root = ecore_x_window_root_get(window);
|
||||||
crtcs = ecore_x_randr_crtcs_get(root, &ncrtcs);
|
if (!(crtcs = ecore_x_randr_window_crtcs_get(window, &ncrtcs)))
|
||||||
if (!crtcs) return NULL;
|
goto _ecore_x_randr_current_output_get_fail;
|
||||||
|
|
||||||
/* now get window RELATIVE to root window - thats what matters. */
|
for (i = 0, nret = 0; i < ncrtcs; i++)
|
||||||
cookie = xcb_translate_coordinates(_ecore_xcb_conn, window, root, 0, 0);
|
|
||||||
trans = xcb_translate_coordinates_reply(_ecore_xcb_conn, cookie, NULL);
|
|
||||||
w_geo.x = trans->dst_x;
|
|
||||||
w_geo.y = trans->dst_y;
|
|
||||||
free(trans);
|
|
||||||
|
|
||||||
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], &c_geo.x, &c_geo.y,
|
outputs = ecore_x_randr_crtc_outputs_get(root, crtcs[i],
|
||||||
&c_geo.w, &c_geo.h);
|
&noutputs);
|
||||||
if (eina_rectangles_intersect(&w_geo, &c_geo))
|
if (!outputs)
|
||||||
{
|
goto _ecore_x_randr_current_output_get_fail_free;
|
||||||
outputs =
|
nret += noutputs;
|
||||||
ecore_x_randr_crtc_outputs_get(root, crtcs[i], &noutputs);
|
ret = realloc(ret, (nret * sizeof(Ecore_X_Randr_Output)));
|
||||||
/* The case below should be impossible, but for safety reasons
|
memcpy(&ret[nret], outputs, (noutputs * sizeof(Ecore_X_Randr_Output)));
|
||||||
* remains */
|
free(outputs);
|
||||||
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:
|
||||||
#endif
|
#endif
|
||||||
if (num) *num = 0;
|
if (num) *num = 0;
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
Loading…
Reference in New Issue