diff options
author | David Walter Seikel | 2012-04-22 09:19:23 +1000 |
---|---|---|
committer | David Walter Seikel | 2012-04-22 09:19:23 +1000 |
commit | c963d75dfdeec11f82e79e727062fbf89afa2c04 (patch) | |
tree | 895633dbf641110be46f117c29890c49b3ffc0bd /libraries/ecore/src/lib/ecore_x/xlib/ecore_x_randr_12.c | |
parent | Adding the new extantz viewer and grid manager. (diff) | |
download | SledjHamr-c963d75dfdeec11f82e79e727062fbf89afa2c04.zip SledjHamr-c963d75dfdeec11f82e79e727062fbf89afa2c04.tar.gz SledjHamr-c963d75dfdeec11f82e79e727062fbf89afa2c04.tar.bz2 SledjHamr-c963d75dfdeec11f82e79e727062fbf89afa2c04.tar.xz |
Update EFL to latest beta.
Diffstat (limited to 'libraries/ecore/src/lib/ecore_x/xlib/ecore_x_randr_12.c')
-rw-r--r-- | libraries/ecore/src/lib/ecore_x/xlib/ecore_x_randr_12.c | 246 |
1 files changed, 191 insertions, 55 deletions
diff --git a/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_randr_12.c b/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_randr_12.c index 38218a5..ec23b3c 100644 --- a/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_randr_12.c +++ b/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_randr_12.c | |||
@@ -347,9 +347,9 @@ ecore_x_randr_modes_info_get(Ecore_X_Window root, | |||
347 | ret[i]->vSyncStart = res->modes[i].vSyncStart; | 347 | ret[i]->vSyncStart = res->modes[i].vSyncStart; |
348 | ret[i]->vSyncEnd = res->modes[i].vSyncEnd; | 348 | ret[i]->vSyncEnd = res->modes[i].vSyncEnd; |
349 | ret[i]->vTotal = res->modes[i].vTotal; | 349 | ret[i]->vTotal = res->modes[i].vTotal; |
350 | if ((ret[i]->name = (malloc(res->modes[i].nameLength)))) | 350 | if ((ret[i]->name = (malloc(res->modes[i].nameLength + 1)))) |
351 | strncpy(ret[i]->name, res->modes[i].name, | 351 | strncpy(ret[i]->name, res->modes[i].name, |
352 | res->modes[i].nameLength); | 352 | (res->modes[i].nameLength + 1)); |
353 | else | 353 | else |
354 | ret[i]->name = NULL; | 354 | ret[i]->name = NULL; |
355 | 355 | ||
@@ -380,6 +380,48 @@ ecore_x_randr_modes_info_get(Ecore_X_Window root, | |||
380 | } | 380 | } |
381 | 381 | ||
382 | /* | 382 | /* |
383 | * @brief add a mode to a display | ||
384 | * @param root window to which's screen's ressources are added | ||
385 | * @param mode_info | ||
386 | * @return Ecore_X_Randr_Mode of the added mode. Ecore_X_Randr_None if mode | ||
387 | * adding failed. | ||
388 | * @since 1.2.0 | ||
389 | */ | ||
390 | EAPI Ecore_X_Randr_Mode | ||
391 | ecore_x_randr_mode_info_add(Ecore_X_Window root, | ||
392 | Ecore_X_Randr_Mode_Info *mode_info) | ||
393 | { | ||
394 | #ifdef ECORE_XRANDR | ||
395 | RANDR_CHECK_1_2_RET(EINA_FALSE); | ||
396 | Ecore_X_Randr_Mode mode = Ecore_X_Randr_None; | ||
397 | |||
398 | if (_ecore_x_randr_root_validate(root) && mode_info) | ||
399 | mode = XRRCreateMode(_ecore_x_disp, root, (XRRModeInfo*)mode_info); | ||
400 | |||
401 | return mode; | ||
402 | #else | ||
403 | return Ecore_X_Randr_None; | ||
404 | #endif | ||
405 | } | ||
406 | |||
407 | /* | ||
408 | * @brief delete a mode from the display | ||
409 | * @param mode_info | ||
410 | * @since 1.2.0 | ||
411 | */ | ||
412 | EAPI void | ||
413 | ecore_x_randr_mode_del(Ecore_X_Randr_Mode mode) | ||
414 | { | ||
415 | #ifdef ECORE_XRANDR | ||
416 | RANDR_CHECK_1_2_RET(); | ||
417 | |||
418 | XRRDestroyMode(_ecore_x_disp, mode); | ||
419 | #else | ||
420 | return; | ||
421 | #endif | ||
422 | } | ||
423 | |||
424 | /* | ||
383 | * @brief get detailed information for a given mode id | 425 | * @brief get detailed information for a given mode id |
384 | * @param root window which's screen's ressources are queried | 426 | * @param root window which's screen's ressources are queried |
385 | * @param mode the XID which identifies the mode of interest | 427 | * @param mode the XID which identifies the mode of interest |
@@ -491,6 +533,83 @@ ecore_x_randr_crtcs_get(Ecore_X_Window root, | |||
491 | #endif | 533 | #endif |
492 | } | 534 | } |
493 | 535 | ||
536 | /* | ||
537 | * @deprecated bad naming. Use ecore_x_randr_window_crtcs_get instead. | ||
538 | * @brief get the CRTCs, which display a certain window | ||
539 | * @param window window the displaying crtcs shall be found for | ||
540 | * @param num the number of crtcs displaying the window | ||
541 | * @return array of crtcs that display a certain window. NULL if no crtcs | ||
542 | * was found that displays the specified window. | ||
543 | */ | ||
544 | EAPI Ecore_X_Randr_Crtc * | ||
545 | ecore_x_randr_current_crtc_get(Ecore_X_Window window, | ||
546 | int *num) | ||
547 | { | ||
548 | return ecore_x_randr_window_crtcs_get(window, num); | ||
549 | } | ||
550 | |||
551 | /* | ||
552 | * @brief get the CRTCs, which display a certain window | ||
553 | * @param window window the displaying crtcs shall be found for | ||
554 | * @param num the number of crtcs displaying the window | ||
555 | * @return array of crtcs that display a certain window. NULL if no crtcs | ||
556 | * was found that displays the specified window. | ||
557 | * @since 1.2.0 | ||
558 | */ | ||
559 | EAPI Ecore_X_Randr_Crtc * | ||
560 | ecore_x_randr_window_crtcs_get(Ecore_X_Window window, | ||
561 | int *num) | ||
562 | { | ||
563 | #ifdef ECORE_XRANDR | ||
564 | Ecore_X_Window root; | ||
565 | Eina_Rectangle w_geo, c_geo; | ||
566 | Ecore_X_Randr_Crtc *crtcs; | ||
567 | Ecore_X_Randr_Mode mode; | ||
568 | Ecore_X_Randr_Output *ret = NULL; | ||
569 | Window tw; | ||
570 | int ncrtcs, i, nret = 0, rx = 0, ry = 0; | ||
571 | |||
572 | if (_randr_version < RANDR_1_2) goto _ecore_x_randr_window_crtcs_get_fail; | ||
573 | |||
574 | ecore_x_window_geometry_get(window, | ||
575 | &w_geo.x, &w_geo.y, | ||
576 | &w_geo.w, &w_geo.h); | ||
577 | |||
578 | root = ecore_x_window_root_get(window); | ||
579 | crtcs = ecore_x_randr_crtcs_get(root, &ncrtcs); | ||
580 | if (!crtcs) goto _ecore_x_randr_window_crtcs_get_fail; | ||
581 | |||
582 | /* now get window RELATIVE to root window - thats what matters. */ | ||
583 | XTranslateCoordinates(_ecore_x_disp, window, root, 0, 0, &rx, &ry, &tw); | ||
584 | w_geo.x = rx; | ||
585 | w_geo.y = ry; | ||
586 | |||
587 | for (i = 0, nret = 0; i < ncrtcs; i++) | ||
588 | { | ||
589 | /* if crtc is not enabled, don't bother about it any further */ | ||
590 | mode = ecore_x_randr_crtc_mode_get(root, crtcs[i]); | ||
591 | if (mode == Ecore_X_Randr_None) continue; | ||
592 | |||
593 | ecore_x_randr_crtc_geometry_get(root, crtcs[i], | ||
594 | &c_geo.x, &c_geo.y, | ||
595 | &c_geo.w, &c_geo.h); | ||
596 | if (eina_rectangles_intersect(&w_geo, &c_geo)) | ||
597 | { | ||
598 | ret = realloc(ret, (sizeof(Ecore_X_Randr_Crtc) * ++nret)); | ||
599 | ret[nret] = crtcs[i]; | ||
600 | } | ||
601 | } | ||
602 | free(crtcs); | ||
603 | |||
604 | if (num) *num = nret; | ||
605 | return ret; | ||
606 | |||
607 | _ecore_x_randr_window_crtcs_get_fail: | ||
608 | #endif | ||
609 | if (num) *num = 0; | ||
610 | return NULL; | ||
611 | } | ||
612 | |||
494 | EAPI Ecore_X_Randr_Output * | 613 | EAPI Ecore_X_Randr_Output * |
495 | ecore_x_randr_outputs_get(Ecore_X_Window root, | 614 | ecore_x_randr_outputs_get(Ecore_X_Window root, |
496 | int *num) | 615 | int *num) |
@@ -1364,6 +1483,54 @@ ecore_x_randr_crtc_pos_relative_set(Ecore_X_Window root, | |||
1364 | #endif | 1483 | #endif |
1365 | } | 1484 | } |
1366 | 1485 | ||
1486 | /* | ||
1487 | * @brief add given mode to given output | ||
1488 | * @param output the output the mode is added to | ||
1489 | * @param mode the mode added to the output | ||
1490 | * @return EINA_FALSE if output or mode equal Ecore_X_Randr_None, else EINA_TRUE | ||
1491 | * Additionally, if xcb backend is used, the success of the addition is reported | ||
1492 | * back directly. | ||
1493 | * @since 1.2.0 | ||
1494 | */ | ||
1495 | EAPI Eina_Bool | ||
1496 | ecore_x_randr_output_mode_add(Ecore_X_Randr_Output output, | ||
1497 | Ecore_X_Randr_Mode mode) | ||
1498 | { | ||
1499 | #ifdef ECORE_XRANDR | ||
1500 | RANDR_CHECK_1_2_RET(EINA_FALSE); | ||
1501 | |||
1502 | if ((output == Ecore_X_Randr_None) || (mode == Ecore_X_Randr_None)) | ||
1503 | return EINA_FALSE; | ||
1504 | |||
1505 | XRRAddOutputMode(_ecore_x_disp, output, mode); | ||
1506 | return EINA_TRUE; | ||
1507 | #else | ||
1508 | return EINA_FALSE; | ||
1509 | #endif | ||
1510 | } | ||
1511 | |||
1512 | /* | ||
1513 | * @brief delete given mode from given output | ||
1514 | * @param output the output the mode is removed from | ||
1515 | * @param mode the mode removed from the output | ||
1516 | * @since 1.2.0 | ||
1517 | */ | ||
1518 | EAPI void | ||
1519 | ecore_x_randr_output_mode_del(Ecore_X_Randr_Output output, | ||
1520 | Ecore_X_Randr_Mode mode) | ||
1521 | { | ||
1522 | #ifdef ECORE_XRANDR | ||
1523 | RANDR_CHECK_1_2_RET(); | ||
1524 | |||
1525 | if ((output == Ecore_X_Randr_None) || (mode == Ecore_X_Randr_None)) | ||
1526 | return; | ||
1527 | |||
1528 | XRRDeleteOutputMode(_ecore_x_disp, output, mode); | ||
1529 | #else | ||
1530 | return; | ||
1531 | #endif | ||
1532 | } | ||
1533 | |||
1367 | EAPI Ecore_X_Randr_Mode * | 1534 | EAPI Ecore_X_Randr_Mode * |
1368 | ecore_x_randr_output_modes_get(Ecore_X_Window root, | 1535 | ecore_x_randr_output_modes_get(Ecore_X_Window root, |
1369 | Ecore_X_Randr_Output output, | 1536 | Ecore_X_Randr_Output output, |
@@ -2136,70 +2303,39 @@ ecore_x_randr_window_outputs_get(Ecore_X_Window window, | |||
2136 | { | 2303 | { |
2137 | #ifdef ECORE_XRANDR | 2304 | #ifdef ECORE_XRANDR |
2138 | Ecore_X_Window root; | 2305 | Ecore_X_Window root; |
2139 | Eina_Rectangle w_geo, c_geo; | ||
2140 | Ecore_X_Randr_Crtc *crtcs; | 2306 | Ecore_X_Randr_Crtc *crtcs; |
2141 | Ecore_X_Randr_Mode mode; | 2307 | Ecore_X_Randr_Output *outputs, *ret = NULL; |
2142 | Ecore_X_Randr_Output *outputs, *ret = NULL, *tret; | 2308 | int ncrtcs, noutputs, i, nret = 0; |
2143 | Window tw; | ||
2144 | int ncrtcs, noutputs, i, nret = 0, rx = 0, ry = 0; | ||
2145 | 2309 | ||
2146 | if (_randr_version < RANDR_1_2) goto _ecore_x_randr_current_output_get_fail; | 2310 | if (_randr_version < RANDR_1_2) goto _ecore_x_randr_current_output_get_fail; |
2147 | 2311 | ||
2148 | ecore_x_window_geometry_get(window, | ||
2149 | &w_geo.x, &w_geo.y, | ||
2150 | &w_geo.w, &w_geo.h); | ||
2151 | |||
2152 | root = ecore_x_window_root_get(window); | 2312 | root = ecore_x_window_root_get(window); |
2153 | crtcs = ecore_x_randr_crtcs_get(root, &ncrtcs); | 2313 | if (!(crtcs = ecore_x_randr_window_crtcs_get(window, &ncrtcs))) |
2154 | if (!crtcs) goto _ecore_x_randr_current_output_get_fail; | 2314 | goto _ecore_x_randr_current_output_get_fail; |
2155 | |||
2156 | /* now get window RELATIVE to root window - thats what matters. */ | ||
2157 | XTranslateCoordinates(_ecore_x_disp, window, root, 0, 0, &rx, &ry, &tw); | ||
2158 | w_geo.x = rx; | ||
2159 | w_geo.y = ry; | ||
2160 | 2315 | ||
2161 | for (i = 0; i < ncrtcs; i++) | 2316 | for (i = 0, nret = 0; i < ncrtcs; i++) |
2162 | { | 2317 | { |
2163 | /* if crtc is not enabled, don't bother about it any further */ | ||
2164 | mode = ecore_x_randr_crtc_mode_get(root, crtcs[i]); | ||
2165 | if (mode == Ecore_X_Randr_None) continue; | ||
2166 | 2318 | ||
2167 | ecore_x_randr_crtc_geometry_get(root, crtcs[i], | 2319 | outputs = ecore_x_randr_crtc_outputs_get(root, crtcs[i], |
2168 | &c_geo.x, &c_geo.y, | 2320 | &noutputs); |
2169 | &c_geo.w, &c_geo.h); | 2321 | if (!outputs) |
2170 | if (eina_rectangles_intersect(&w_geo, &c_geo)) | 2322 | goto _ecore_x_randr_current_output_get_fail_free; |
2171 | { | 2323 | nret += noutputs; |
2172 | outputs = ecore_x_randr_crtc_outputs_get(root, crtcs[i], | 2324 | ret = realloc(ret, (nret * sizeof(Ecore_X_Randr_Output))); |
2173 | &noutputs); | 2325 | memcpy(&ret[nret], outputs, (noutputs * sizeof(Ecore_X_Randr_Output))); |
2174 | /* The case below should be impossible, but for safety reasons | 2326 | free(outputs); |
2175 | * remains */ | ||
2176 | if (!outputs) | ||
2177 | { | ||
2178 | if (num) *num = 0; | ||
2179 | free(ret); | ||
2180 | free(crtcs); | ||
2181 | return NULL; | ||
2182 | } | ||
2183 | tret = realloc(ret, ((nret + noutputs) * sizeof(Ecore_X_Randr_Output))); | ||
2184 | if (!tret) | ||
2185 | { | ||
2186 | if (num) *num = 0; | ||
2187 | free(outputs); | ||
2188 | free(ret); | ||
2189 | free(crtcs); | ||
2190 | return NULL; | ||
2191 | } | ||
2192 | ret = tret; | ||
2193 | memcpy(&ret[nret], outputs, (noutputs * sizeof(Ecore_X_Randr_Output))); | ||
2194 | nret += noutputs; | ||
2195 | free(outputs); | ||
2196 | } | ||
2197 | } | 2327 | } |
2198 | free(crtcs); | 2328 | free(crtcs); |
2199 | 2329 | ||
2200 | if (num) *num = nret; | 2330 | if (num) |
2331 | *num = nret; | ||
2332 | |||
2201 | return ret; | 2333 | return ret; |
2202 | 2334 | ||
2335 | _ecore_x_randr_current_output_get_fail_free: | ||
2336 | free(outputs); | ||
2337 | free(crtcs); | ||
2338 | free(ret); | ||
2203 | _ecore_x_randr_current_output_get_fail: | 2339 | _ecore_x_randr_current_output_get_fail: |
2204 | #endif | 2340 | #endif |
2205 | if (num) *num = 0; | 2341 | if (num) *num = 0; |
@@ -2207,7 +2343,7 @@ _ecore_x_randr_current_output_get_fail: | |||
2207 | } | 2343 | } |
2208 | 2344 | ||
2209 | /* | 2345 | /* |
2210 | * @depricated bad naming. Use ecore_x_randr_window_outputs_get instead. | 2346 | * @deprecated bad naming. Use ecore_x_randr_window_outputs_get instead. |
2211 | * @brief get the outputs, which display a certain window | 2347 | * @brief get the outputs, which display a certain window |
2212 | * @param window window the displaying outputs shall be found for | 2348 | * @param window window the displaying outputs shall be found for |
2213 | * @param num the number of outputs displaying the window | 2349 | * @param num the number of outputs displaying the window |
@@ -2215,7 +2351,7 @@ _ecore_x_randr_current_output_get_fail: | |||
2215 | * was found that displays the specified window. | 2351 | * was found that displays the specified window. |
2216 | */ | 2352 | */ |
2217 | 2353 | ||
2218 | EINA_DEPRECATED EAPI Ecore_X_Randr_Output * | 2354 | EAPI Ecore_X_Randr_Output * |
2219 | ecore_x_randr_current_output_get(Ecore_X_Window window, | 2355 | ecore_x_randr_current_output_get(Ecore_X_Window window, |
2220 | int *num) | 2356 | int *num) |
2221 | { | 2357 | { |