summaryrefslogtreecommitdiff
path: root/src/modules/ecore_evas/engines/x/ecore_evas_x.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/modules/ecore_evas/engines/x/ecore_evas_x.c96
1 files changed, 75 insertions, 21 deletions
diff --git a/src/modules/ecore_evas/engines/x/ecore_evas_x.c b/src/modules/ecore_evas/engines/x/ecore_evas_x.c
index 542b3f82e9..88779a2a7c 100644
--- a/src/modules/ecore_evas/engines/x/ecore_evas_x.c
+++ b/src/modules/ecore_evas/engines/x/ecore_evas_x.c
@@ -3478,15 +3478,16 @@ _ecore_evas_x_avoid_damage_set(Ecore_Evas *ee, int on)
3478} 3478}
3479 3479
3480static void 3480static void
3481_ecore_evas_x_screen_geometry_get(const Ecore_Evas *ee EINA_UNUSED, int *x, int *y, int *w, int *h) 3481_ecore_evas_x_screen_geometry_get(const Ecore_Evas *ee, int *x, int *y, int *w, int *h)
3482{ 3482{
3483 int outnum = 0; 3483 int outnum = 0, i;
3484 int px = 0, py = 0, pw = 0, ph = 0; 3484 int px = 0, py = 0, pw = 0, ph = 0;
3485 Ecore_X_Window root; 3485 Ecore_X_Window root;
3486 Ecore_X_Randr_Output *out = NULL; 3486 Ecore_X_Randr_Output *out = NULL;
3487 Ecore_X_Randr_Crtc crtc; 3487 Ecore_X_Randr_Crtc crtc;
3488 unsigned int val[4] = { 0 }; 3488 unsigned int val[4] = { 0 };
3489 3489 Eina_Bool found = EINA_FALSE;
3490
3490 if (ecore_x_window_prop_card32_get 3491 if (ecore_x_window_prop_card32_get
3491 (ee->prop.window, ecore_x_atom_get("E_ZONE_GEOMETRY"), val, 4) == 4) 3492 (ee->prop.window, ecore_x_atom_get("E_ZONE_GEOMETRY"), val, 4) == 4)
3492 { 3493 {
@@ -3496,7 +3497,7 @@ _ecore_evas_x_screen_geometry_get(const Ecore_Evas *ee EINA_UNUSED, int *x, int
3496 if (h) *h = (int)val[3]; 3497 if (h) *h = (int)val[3];
3497 return; 3498 return;
3498 } 3499 }
3499 3500
3500 root = ecore_x_window_root_get(ee->prop.window); 3501 root = ecore_x_window_root_get(ee->prop.window);
3501 out = ecore_x_randr_window_outputs_get(ee->prop.window, &outnum); 3502 out = ecore_x_randr_window_outputs_get(ee->prop.window, &outnum);
3502 if (!out) 3503 if (!out)
@@ -3508,25 +3509,53 @@ norandr:
3508 ecore_x_window_size_get(root, w, h); 3509 ecore_x_window_size_get(root, w, h);
3509 return; 3510 return;
3510 } 3511 }
3511 crtc = ecore_x_randr_output_crtc_get(root, out[0]); 3512 for (i = 0; i < outnum; i++)
3512 if (!crtc) goto norandr; 3513 {
3513 ecore_x_randr_crtc_geometry_get(root, crtc, &px, &py, &pw, &ph); 3514 Eina_Rectangle winrect, outrect;
3514 if ((pw == 0) || (ph == 0)) goto norandr; 3515
3515 if (x) *x = px; 3516 crtc = ecore_x_randr_output_crtc_get(root, out[i]);
3516 if (y) *y = py; 3517 if (!crtc) continue;
3517 if (w) *w = pw; 3518 ecore_x_randr_crtc_geometry_get(root, crtc, &px, &py, &pw, &ph);
3518 if (h) *h = ph; 3519 if ((pw == 0) || (ph == 0)) continue;
3520 if ((i == 0) || (ecore_x_randr_primary_output_get(root) == out[i]))
3521 {
3522 found = EINA_TRUE;
3523 if (x) *x = px;
3524 if (y) *y = py;
3525 if (w) *w = pw;
3526 if (h) *h = ph;
3527 }
3528 winrect.x = ee->x + (ee->w / 2);
3529 winrect.y = ee->y + (ee->h / 2);
3530 winrect.w = 1;
3531 winrect.h = 1;
3532 outrect.x = px;
3533 outrect.y = py;
3534 outrect.w = pw;
3535 outrect.h = ph;
3536 if (eina_rectangles_intersect(&outrect, &winrect))
3537 {
3538 if (x) *x = px;
3539 if (y) *y = py;
3540 if (w) *w = pw;
3541 if (h) *h = ph;
3542 free(out);
3543 return;
3544 }
3545 }
3519 free(out); 3546 free(out);
3547 if (!found) goto norandr;
3520} 3548}
3521 3549
3522static void 3550static void
3523_ecore_evas_x_screen_dpi_get(const Ecore_Evas *ee, int *xdpi, int *ydpi) 3551_ecore_evas_x_screen_dpi_get(const Ecore_Evas *ee, int *xdpi, int *ydpi)
3524{ 3552{
3525 int scdpi, xmm = 0, ymm = 0, outnum = 0, w = 0, h = 0; 3553 int scdpi, xmm = 0, ymm = 0, outnum = 0, w = 0, h = 0;
3526 int px = 0, py = 0; 3554 int px = 0, py = 0, i;
3527 Ecore_X_Window root; 3555 Ecore_X_Window root;
3528 Ecore_X_Randr_Output *out = NULL; 3556 Ecore_X_Randr_Output *out = NULL;
3529 Ecore_X_Randr_Crtc crtc; 3557 Ecore_X_Randr_Crtc crtc;
3558 Eina_Bool found = EINA_FALSE;
3530 3559
3531 root = ecore_x_window_root_get(ee->prop.window); 3560 root = ecore_x_window_root_get(ee->prop.window);
3532 out = ecore_x_randr_window_outputs_get(ee->prop.window, &outnum); 3561 out = ecore_x_randr_window_outputs_get(ee->prop.window, &outnum);
@@ -3539,15 +3568,40 @@ norandr:
3539 if (ydpi) *ydpi = scdpi; 3568 if (ydpi) *ydpi = scdpi;
3540 return; 3569 return;
3541 } 3570 }
3542 crtc = ecore_x_randr_output_crtc_get(root, out[0]); 3571 for (i = 0; i < outnum; i++)
3543 if (!crtc) goto norandr; 3572 {
3544 ecore_x_randr_crtc_geometry_get(root, crtc, &px, &py, &w, &h); 3573 Eina_Rectangle winrect, outrect;
3545 if ((w == 0) || (h == 0)) goto norandr; 3574
3546 ecore_x_randr_output_size_mm_get(root, out[0], &xmm, &ymm); 3575 crtc = ecore_x_randr_output_crtc_get(root, out[i]);
3547 if ((xmm == 0) || (ymm == 0)) goto norandr; 3576 if (!crtc) continue;
3548 if (xdpi) *xdpi = (w * 254) / (xmm * 10); // 25.4mm / inch 3577 ecore_x_randr_crtc_geometry_get(root, crtc, &px, &py, &w, &h);
3549 if (ydpi) *ydpi = (h * 254) / (ymm * 10); // 25.4mm / inch 3578 if ((w == 0) || (h == 0)) continue;
3579 ecore_x_randr_output_size_mm_get(root, out[i], &xmm, &ymm);
3580 if ((xmm == 0) || (ymm == 0)) continue;
3581 if ((i == 0) || (ecore_x_randr_primary_output_get(root) == out[i]))
3582 {
3583 found = EINA_TRUE;
3584 if (xdpi) *xdpi = (w * 254) / (xmm * 10); // 25.4mm / inch
3585 if (ydpi) *ydpi = (h * 254) / (ymm * 10); // 25.4mm / inch
3586 }
3587 winrect.x = ee->x + (ee->w / 2);
3588 winrect.y = ee->y + (ee->h / 2);
3589 winrect.w = 1;
3590 winrect.h = 1;
3591 outrect.x = px;
3592 outrect.y = py;
3593 outrect.w = w;
3594 outrect.h = h;
3595 if (eina_rectangles_intersect(&outrect, &winrect))
3596 {
3597 if (xdpi) *xdpi = (w * 254) / (xmm * 10); // 25.4mm / inch
3598 if (ydpi) *ydpi = (h * 254) / (ymm * 10); // 25.4mm / inch
3599 free(out);
3600 return;
3601 }
3602 }
3550 free(out); 3603 free(out);
3604 if (!found) goto norandr;
3551} 3605}
3552 3606
3553static void 3607static void