ecore-wayland: Fix ecore_wl_screen_size_get function to handle more
authorChris Michael <cp.michael@samsung.com>
Tue, 26 Aug 2014 15:08:38 +0000 (11:08 -0400)
committerChris Michael <cp.michael@samsung.com>
Tue, 26 Aug 2014 15:11:21 +0000 (11:11 -0400)
than one output.

ecore_wl_screen_size_get function Should take into account all
existing outputs. Modify code to loop outputs and add up the sizes.

@fix

Signed-off-by: Chris Michael <cp.michael@samsung.com>
src/lib/ecore_wayland/ecore_wl.c

index fe6ad5b..d6e0d4a 100644 (file)
@@ -308,6 +308,10 @@ _ecore_wl_subcompositor_get(void)
 EAPI void
 ecore_wl_screen_size_get(int *w, int *h)
 {
+   Ecore_Wl_Output *out;
+   Eina_Inlist *tmp;
+   int ow = 0, oh = 0;
+
    LOGFN(__FILE__, __LINE__, __FUNCTION__);
 
    if (w) *w = 0;
@@ -317,7 +321,6 @@ ecore_wl_screen_size_get(int *w, int *h)
 
    _ecore_wl_init_wait();
 
-   // XXX: this code is dumb - screen size doesnt allow for > 1 output.
    // the first sync is in case registry replies are not back yet
    if (!_ecore_wl_disp->output)
      {
@@ -326,22 +329,26 @@ ecore_wl_screen_size_get(int *w, int *h)
         if (!_ecore_wl_disp->output) ecore_wl_sync();
      }
 
-   if (!_ecore_wl_disp->output) return;
-
-   switch (_ecore_wl_disp->output->transform)
+   EINA_INLIST_FOREACH_SAFE(_ecore_wl_disp->outputs, tmp, out)
      {
-      case WL_OUTPUT_TRANSFORM_90:
-      case WL_OUTPUT_TRANSFORM_270:
-      case WL_OUTPUT_TRANSFORM_FLIPPED_90:
-      case WL_OUTPUT_TRANSFORM_FLIPPED_270:
-         /* Swap width and height */
-         if (w) *w = _ecore_wl_disp->output->allocation.h;
-         if (h) *h = _ecore_wl_disp->output->allocation.w;
-         break;
-      default:
-         if (w) *w = _ecore_wl_disp->output->allocation.w;
-         if (h) *h = _ecore_wl_disp->output->allocation.h;
+        switch (out->transform)
+          {
+           case WL_OUTPUT_TRANSFORM_90:
+           case WL_OUTPUT_TRANSFORM_270:
+           case WL_OUTPUT_TRANSFORM_FLIPPED_90:
+           case WL_OUTPUT_TRANSFORM_FLIPPED_270:
+             /* Swap width and height */
+             ow += out->allocation.h;
+             oh += out->allocation.w;
+             break;
+           default:
+             ow += out->allocation.w;
+             oh += out->allocation.h;
+          }
      }
+
+   if (w) *w = ow;
+   if (h) *h = oh;
 }
 
 /* @since 1.2 */