refactor e_comp_screen and e_output sandbox/juyeon/devel
authorSooChan Lim <sc1.lim@samsung.com>
Wed, 1 Jun 2016 06:34:28 +0000 (15:34 +0900)
committerSooChan Lim <sc1.lim@samsung.com>
Wed, 1 Jun 2016 06:34:28 +0000 (15:34 +0900)
1. add E_Comp_Screen pointer to e_comp_screen
2. move E_Comp_Screen and E_Screen from e_output to e_comp_screen
2. move screen function from e_output to e_comp_screen
3. modify the prefix of the e_comp_screen functions

Change-Id: Ic7898d6bcd1accf804439b44ee31b61753f29ac3

src/bin/e_comp.h
src/bin/e_comp_canvas.c
src/bin/e_comp_hwc.c
src/bin/e_comp_screen.c
src/bin/e_comp_screen.h
src/bin/e_comp_wl.c
src/bin/e_includes.h
src/bin/e_output.c
src/bin/e_output.h

index 1ef83882c4f9230cab5505cb158d9365c838e20d..74ea3227de0d3c5f78c5fd5b891b9018c5e77a6a 100644 (file)
@@ -133,6 +133,7 @@ struct _E_Comp
    } autoclose;
 
    E_Launch_Screen   *launchscrn;
+   E_Comp_Screen *e_comp_screen;
 
    Eina_List *debug_rects;
    Eina_List *ignore_wins;
index dc2f36d0164b225aa62944cb57db2baf64eeeb5c..172b13a8dac82c87dff48ee0854c8f4b867a1fa9 100644 (file)
@@ -124,7 +124,7 @@ _e_comp_canvas_cb_zone_sort(const void *data1, const void *data2)
 static void
 _e_comp_canvas_resize(Ecore_Evas *ee EINA_UNUSED)
 {
-   e_output_screens_setup(e_comp->w, e_comp->h);
+   e_comp_screen_e_screens_setup(e_comp->e_comp_screen, e_comp->w, e_comp->h);
    e_comp_canvas_update();
 }
 
@@ -193,7 +193,7 @@ e_comp_canvas_init(int w, int h)
 
    e_comp->ee_win = ecore_evas_window_get(e_comp->ee);
 
-   screens = (Eina_List *)e_output_screens_get();
+   screens = (Eina_List *)e_comp_screen_e_screens_get(e_comp->e_comp_screen);
    if (screens)
      {
         E_Screen *scr;
@@ -375,7 +375,7 @@ e_comp_canvas_update(void)
    int i;
    Eina_Bool changed = EINA_FALSE;
 
-   screens = (Eina_List *)e_output_screens_get();
+   screens = (Eina_List *)e_comp_screen_e_screens_get(e_comp->e_comp_screen);
 
    if (screens)
      {
index 3886d1617e62c3d456093be8487709fb7c0cbf10..78a3c0687fc16acbbe51a7d1eb937d6776609662 100644 (file)
@@ -835,9 +835,12 @@ _e_comp_hwc_output_update_geom(E_Comp_Hwc_Output *hwc_output)
    Ecore_Drm_Device *dev;
    Ecore_Drm_Output *drm_output;
    E_Output *eout;
+   E_Comp_Screen *e_comp_screen;
    const Eina_List *l, *ll;
    int x, y, w, h;
 
+   e_comp_screen = e_comp->e_comp_screen;
+
    EINA_LIST_FOREACH(ecore_drm_devices_get(), l, dev)
      {
         EINA_LIST_FOREACH(e_comp_screen->outputs, ll, eout)
index f310c26d71687a291f8311ff71e0bb97f8fc5901..14ca236bc1c2c92c35214a539468cc7e88f4e81d 100644 (file)
@@ -7,6 +7,8 @@ static Eina_Bool session_state = EINA_FALSE;
 static Eina_Bool dont_set_ecore_drm_keymap = EINA_FALSE;
 static Eina_Bool dont_use_xkb_cache = EINA_FALSE;
 
+E_API int              E_EVENT_SCREEN_CHANGE = 0;
+
 static Eina_Bool
 _e_comp_screen_cb_activate(void *data EINA_UNUSED, int type EINA_UNUSED, void *event)
 {
@@ -56,8 +58,13 @@ _e_comp_screen_cb_output(void *data EINA_UNUSED, int type EINA_UNUSED, void *eve
    const Eina_List *l;
    E_Output *eout;
    Ecore_Drm_Event_Output *e;
+   E_Comp_Screen *e_comp_screen = NULL;
 
    if (!(e = event)) goto end;
+   if (!e_comp) goto end;
+   if (!e_comp->e_comp_screen) goto end;
+
+   e_comp_screen = e_comp->e_comp_screen;
 
    DBG("WL_DRM OUTPUT CHANGE");
 
@@ -196,8 +203,8 @@ _e_comp_screen_output_screen_get(Ecore_Drm_Output *output)
    return strdup(model);
 }
 
-EINTERN E_Comp_Screen *
-e_comp_screen_init_outputs(void)
+static E_Comp_Screen *
+_e_comp_screen_init_outputs(void)
 {
    Ecore_Drm_Device *dev;
    Ecore_Drm_Output *output;
@@ -341,16 +348,20 @@ e_comp_screen_init_outputs(void)
 }
 
 EINTERN void
-e_comp_screen_apply(void)
+_e_comp_screen_apply(E_Comp_Screen *e_comp_screen)
 {
    Ecore_Drm_Device *dev;
    Ecore_Drm_Output *out;
    E_Output *eout;
+
    const Eina_List *l, *ll;
    int nw, nh, pw, ph, ww, hh;
    int minw, minh, maxw, maxh;
    int top_priority = 0;
 
+   EINA_SAFETY_ON_NULL_RETURN(e_comp);
+   EINA_SAFETY_ON_NULL_RETURN(e_comp->e_comp_screen);
+
    /* TODO: what the actual fuck */
    nw = e_comp_screen->w;
    nh = e_comp_screen->h;
@@ -485,10 +496,229 @@ cleanup:
    TRACE_INPUT_END();
 }
 
+static void
+_e_comp_screen_config_eval(E_Comp_Screen *e_comp_screen)
+{
+   Eina_List *l;
+   E_Output *eout;
+   int minx, miny, maxx, maxy;
+
+   minx = 65535;
+   miny = 65535;
+   maxx = -65536;
+   maxy = -65536;
+
+   EINA_LIST_FOREACH(e_comp_screen->outputs, l, eout)
+     {
+        if (!eout->config.enabled) continue;
+        if (eout->config.geom.x < minx) minx = eout->config.geom.x;
+        if (eout->config.geom.y < miny) miny = eout->config.geom.y;
+        if ((eout->config.geom.x + eout->config.geom.w) > maxx)
+          maxx = eout->config.geom.x + eout->config.geom.w;
+        if ((eout->config.geom.y + eout->config.geom.h) > maxy)
+          maxy = eout->config.geom.y + eout->config.geom.h;
+        printf("OUTPUT: s: '%s' @ %i %i - %ix%i\n",
+               eout->info.name,
+               eout->config.geom.x, eout->config.geom.y,
+               eout->config.geom.w, eout->config.geom.h);
+     }
+   printf("OUTPUT:--- %i %i -> %i %i\n", minx, miny, maxx, maxy);
+   EINA_LIST_FOREACH(e_comp_screen->outputs, l, eout)
+     {
+        eout->config.geom.x -= minx;
+        eout->config.geom.y -= miny;
+     }
+   e_comp_screen->w = maxx - minx;
+   e_comp_screen->h = maxy - miny;
+}
+
+static void
+_e_comp_screen_config_maxsize(E_Comp_Screen *e_comp_screen)
+{
+   Eina_List *l;
+   E_Output *eout;
+   int maxx, maxy;
+
+   maxx = -65536;
+   maxy = -65536;
+   EINA_LIST_FOREACH(e_comp_screen->outputs, l, eout)
+     {
+        if (!eout->config.enabled) continue;
+        if ((eout->config.geom.x + eout->config.geom.w) > maxx)
+          maxx = eout->config.geom.x + eout->config.geom.w;
+        if ((eout->config.geom.y + eout->config.geom.h) > maxy)
+          maxy = eout->config.geom.y + eout->config.geom.h;
+        printf("OUTPUT: '%s': %i %i %ix%i\n",
+               eout->info.name,
+               eout->config.geom.x, eout->config.geom.y,
+               eout->config.geom.w, eout->config.geom.h);
+     }
+   printf("OUTPUT: result max: %ix%i\n", maxx, maxy);
+   e_comp_screen->w = maxx;
+   e_comp_screen->h = maxy;
+}
+
+static int
+_e_comp_screen_e_screen_sort_cb(const void *data1, const void *data2)
+{
+   const E_Output *s1 = data1, *s2 = data2;
+   int dif;
+
+   dif = -(s1->config.priority - s2->config.priority);
+   if (dif == 0)
+     {
+        dif = s1->config.geom.x - s2->config.geom.x;
+        if (dif == 0)
+          dif = s1->config.geom.y - s2->config.geom.y;
+     }
+   return dif;
+}
+
+static void
+_e_comp_screen_e_screen_free(E_Screen *scr)
+{
+   free(scr->id);
+   free(scr);
+}
+
+static void
+_e_comp_screen_e_screens_set(E_Comp_Screen *e_comp_screen, Eina_List *screens)
+{
+   E_FREE_LIST(e_comp_screen->e_screens, _e_comp_screen_e_screen_free);
+   e_comp_screen->e_screens = screens;
+}
+
+EINTERN void
+e_comp_screen_e_screens_setup(E_Comp_Screen *e_comp_screen, int rw, int rh)
+{
+   int i;
+   E_Screen *screen;
+   Eina_List *outputs = NULL, *outputs_rem;
+   Eina_List *e_screens = NULL;
+   Eina_List *l, *ll;
+   E_Output *eout, *s2, *s_chosen;
+   Eina_Bool removed;
+
+   if ((!e_comp_screen) || (!e_comp_screen->outputs)) goto out;
+   // put screens in tmp list
+   EINA_LIST_FOREACH(e_comp_screen->outputs, l, eout)
+     {
+        if ((eout->config.enabled) &&
+            (eout->config.geom.w > 0) &&
+            (eout->config.geom.h > 0))
+          {
+             outputs = eina_list_append(outputs, eout);
+          }
+     }
+   // remove overlapping screens - if a set of screens overlap, keep the
+   // smallest/lowest res
+   do
+     {
+        removed = EINA_FALSE;
+
+        EINA_LIST_FOREACH(outputs, l, eout)
+          {
+             outputs_rem = NULL;
+
+             EINA_LIST_FOREACH(l->next, ll, s2)
+               {
+                  if (E_INTERSECTS(eout->config.geom.x, eout->config.geom.y,
+                                   eout->config.geom.w, eout->config.geom.h,
+                                   s2->config.geom.x, s2->config.geom.y,
+                                   s2->config.geom.w, s2->config.geom.h))
+                    {
+                       if (!outputs_rem)
+                         outputs_rem = eina_list_append(outputs_rem, eout);
+                       outputs_rem = eina_list_append(outputs_rem, s2);
+                    }
+               }
+             // we have intersecting screens - choose the lowest res one
+             if (outputs_rem)
+               {
+                  removed = EINA_TRUE;
+                  // find the smallest screen (chosen one)
+                  s_chosen = NULL;
+                  EINA_LIST_FOREACH(outputs_rem, ll, s2)
+                    {
+                       if (!s_chosen) s_chosen = s2;
+                       else
+                         {
+                            if ((s_chosen->config.geom.w *
+                                 s_chosen->config.geom.h) >
+                                (s2->config.geom.w *
+                                 s2->config.geom.h))
+                              s_chosen = s2;
+                         }
+                    }
+                  // remove all from screens but the chosen one
+                  EINA_LIST_FREE(outputs_rem, s2)
+                    {
+                       if (s2 != s_chosen)
+                         outputs = eina_list_remove_list(outputs, l);
+                    }
+                  // break our list walk and try again
+                  break;
+               }
+          }
+     }
+   while (removed);
+   // sort screens by priority etc.
+   outputs = eina_list_sort(outputs, 0, _e_comp_screen_e_screen_sort_cb);
+   i = 0;
+   EINA_LIST_FOREACH(outputs, l, eout)
+     {
+        screen = E_NEW(E_Screen, 1);
+        screen->escreen = screen->screen = i;
+        screen->x = eout->config.geom.x;
+        screen->y = eout->config.geom.y;
+        screen->w = eout->config.geom.w;
+        screen->h = eout->config.geom.h;
+        if (eout->id) screen->id = strdup(eout->id);
+
+        e_screens = eina_list_append(e_screens, screen);
+        INF("E INIT: SCREEN: [%i][%i], %ix%i+%i+%i",
+            i, i, screen->w, screen->h, screen->x, screen->y);
+        i++;
+     }
+   eina_list_free(outputs);
+   // if we have NO screens at all (above - i will be 0) AND we have no
+   // existing screens set up in xinerama - then just say root window size
+   // is the entire screen. this should handle the case where you unplug ALL
+   // screens from an existing setup (unplug external monitors and/or close
+   // laptop lid), in which case as long as at least one screen is configured
+   // in xinerama, it will be left-as is until next time we re-eval screen
+   // setup and have at least one screen
+   printf("e_comp_screen_e_screens_setup............... %i %p\n", i, e_comp_screen->e_screens);
+   if ((i == 0) && (!e_comp_screen->e_screens))
+     {
+out:
+        screen = E_NEW(E_Screen, 1);
+        screen->escreen = screen->screen = 0;
+        screen->x = 0;
+        screen->y = 0;
+        if ((rw > 0) && (rh > 0))
+          screen->w = rw, screen->h = rh;
+        else
+          ecore_evas_screen_geometry_get(e_comp->ee, NULL, NULL, &screen->w, &screen->h);
+        e_screens = eina_list_append(e_screens, screen);
+     }
+   _e_comp_screen_e_screens_set(e_comp_screen, e_screens);
+}
+
+EINTERN const Eina_List *
+e_comp_screen_e_screens_get(E_Comp_Screen *e_comp_screen)
+{
+   EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_screen, NULL);
+
+   return e_comp_screen->e_screens;
+}
+
 E_API Eina_Bool
 e_comp_screen_init()
 {
    E_Comp *comp;
+   E_Comp_Screen *e_comp_screen = NULL;
+
    int w = 0, h = 0, scr_w = 1, scr_h = 1;
    struct xkb_context *ctx = NULL;
    struct xkb_keymap *map = NULL;
@@ -609,7 +839,22 @@ e_comp_screen_init()
         TRACE_DS_END();
         return EINA_FALSE;
      }
-   e_output_screens_setup(-1, -1);
+   if (!E_EVENT_SCREEN_CHANGE) E_EVENT_SCREEN_CHANGE = ecore_event_type_new();
+
+   e_comp_screen = _e_comp_screen_init_outputs();
+   e_comp->e_comp_screen = e_comp_screen;
+
+   // take current e_output config and apply it to the driver
+   _e_comp_screen_config_maxsize(e_comp_screen);
+   printf("OUTPUT: eval config...\n");
+   _e_comp_screen_config_eval(e_comp_screen);
+   printf("OUTPUT: really apply config...\n");
+   _e_comp_screen_apply(e_comp_screen);
+   printf("OUTPUT: done config...\n");
+
+   ecore_event_add(E_EVENT_SCREEN_CHANGE, NULL, NULL, NULL);
+
+   e_comp_screen_e_screens_setup(e_comp_screen, -1, -1);
    e_main_ts("\tE_Output Init Done");
 
    e_main_ts("\tE_Comp_Wl Init");
@@ -675,8 +920,13 @@ e_comp_screen_shutdown()
 {
    /* shutdown ecore_drm */
    /* ecore_drm_shutdown(); */
+
    e_output_shutdown();
 
+   // free up screen info
+   free(e_comp->e_comp_screen);
+   e_comp->e_comp_screen = NULL;
+
    dont_set_ecore_drm_keymap = EINA_FALSE;
    dont_use_xkb_cache = EINA_FALSE;
    E_FREE_LIST(event_handlers, ecore_event_handler_del);
index cba4dd605498accb35fd1d1a0d39baca141086b1..34a8c4ac62991911244f845acb9700a665fd8c83 100644 (file)
@@ -5,13 +5,34 @@
 #ifndef E_COMP_SCREEN_H
 #define E_COMP_SCREEN_H
 
+typedef struct _E_Comp_Screen   E_Comp_Screen;
+typedef struct _E_Screen        E_Screen;
 
-EINTERN void            e_comp_screen_apply(void);
-EINTERN E_Comp_Screen * e_comp_screen_init_outputs(void);
+struct _E_Comp_Screen
+{
+   Eina_List *outputs; // available screens
+   int        w, h; // virtual resolution (calculated)
+   unsigned char  ignore_hotplug_events;
+   unsigned char  ignore_acpi_events;
+   Eina_List *e_screens;
+};
+
+
+struct _E_Screen
+{
+   int screen, escreen;
+   int x, y, w, h;
+   char *id; // this is the same id we get from _E_Output so look it up there
+};
+
+extern E_API int E_EVENT_SCREEN_CHANGE;
 
 E_API Eina_Bool         e_comp_screen_init(void);
 E_API void              e_comp_screen_shutdown(void);
 
+EINTERN void              e_comp_screen_e_screens_setup(E_Comp_Screen *e_comp_screen, int rw, int rh);
+EINTERN const Eina_List * e_comp_screen_e_screens_get(E_Comp_Screen *e_comp_screen);
+
 #endif /*E_COMP_SCREEN_H*/
 
 #endif
index a7d3ac6412c9686b922ce442a98d5593ae1942be..3cbd8f4b50012b2d3a8e4e7aaa4edddf178bc944 100644 (file)
@@ -1756,9 +1756,12 @@ _e_comp_wl_cb_randr_change(void *data EINA_UNUSED, int type EINA_UNUSED, void *e
 {
    Eina_List *l;
    E_Output *eout;
+   E_Comp_Screen *e_comp_screen;
    unsigned int transform = WL_OUTPUT_TRANSFORM_NORMAL;
 
-   if (!e_comp_screen) return ECORE_CALLBACK_RENEW;
+   if (!e_comp) return ECORE_CALLBACK_RENEW;
+   if (!e_comp->e_comp_screen) return ECORE_CALLBACK_RENEW;
+   e_comp_screen = e_comp->e_comp_screen;
 
    EINA_LIST_FOREACH(e_comp_screen->outputs, l, eout)
      {
index 7cf869895005a9cfa23d8c51f884a47f81767743..cc753d78f32df3a33cf4d763b7072b56b5635682 100644 (file)
@@ -43,6 +43,7 @@
 #include "e_env.h"
 #include "e_log.h"
 #include "e_dbusmenu.h"
+#include "e_comp_screen.h"
 #include "e_comp.h"
 #include "e_comp_cfdata.h"
 #include "e_comp_canvas.h"
@@ -50,7 +51,6 @@
 #include "e_hints.h"
 #include "e_plane.h"
 #include "e_comp_hwc.h"
-#include "e_comp_screen.h"
 #include "e_output.h"
 
 #ifdef HAVE_WAYLAND
index 82ecd17da5b7a8236cbacc6cb9f696c5e32883d2..df0dd123ef2da0b0a0db52ffd33f0cb0d692ca28 100644 (file)
@@ -1,69 +1,29 @@
 #include "e.h"
 
-
-/////////////////////////////////////////////////////////////////////////
-static void                    _do_apply(void);
-static void                    _info_free(E_Comp_Screen *r);
-static void                    _screen_config_eval(void);
-static void                    _screen_config_maxsize(void);
-
-/////////////////////////////////////////////////////////////////////////
-
-E_API E_Comp_Screen   *e_comp_screen = NULL;
-
-E_API int              E_EVENT_SCREEN_CHANGE = 0;
-
-static Eina_List *all_screens = NULL; // e_screen list
-
-/////////////////////////////////////////////////////////////////////////
 EINTERN Eina_Bool
 e_output_init(void)
 {
-   if (!E_EVENT_SCREEN_CHANGE) E_EVENT_SCREEN_CHANGE = ecore_event_type_new();
-
-   e_comp_screen = e_comp_screen_init_outputs();
-
-   _do_apply();
-
-   ecore_event_add(E_EVENT_SCREEN_CHANGE, NULL, NULL, NULL);
+   // TODO: initialization e_outputs
 
    return EINA_TRUE;
 }
 
-EINTERN int
+EINTERN void
 e_output_shutdown(void)
 {
-   // free up screen info
-   _info_free(e_comp_screen);
-   e_comp_screen = NULL;
-
-   return 1;
-}
-
-/////////////////////////////////////////////////////////////////////////
-
-static void
-_do_apply(void)
-{
-   // take current e_output config and apply it to the driver
-   _screen_config_maxsize();
-   printf("OUTPUT: eval config...\n");
-   _screen_config_eval();
-   printf("OUTPUT: really apply config...\n");
-   e_comp_screen_apply();
-   printf("OUTPUT: done config...\n");
-}
-
-static void
-_info_free(E_Comp_Screen *r)
-{
+   // TODO: deinitialization e_outputs
    E_Output *eout;
    E_Output_Mode *m;
    E_Plane *ep;
+   Eina_List *outputs;
+
+   if (!e_comp) return;
+   if (!e_comp->e_comp_screen) return;
+
+   outputs = e_comp->e_comp_screen->outputs;
 
-   if (!r) return;
    // free up our output screen data
-   EINA_LIST_FREE(r->outputs, eout)
+   EINA_LIST_FREE(outputs, eout)
      {
         free(eout->id);
         free(eout->info.screen);
@@ -73,229 +33,20 @@ _info_free(E_Comp_Screen *r)
         EINA_LIST_FREE(eout->planes, ep) e_plane_free(ep);
         free(eout);
      }
-   free(r);
 }
 
-static void
-_screen_config_eval(void)
+EINTERN E_Output *
+e_output_find(const char *id)
 {
-   Eina_List *l;
    E_Output *eout;
-   int minx, miny, maxx, maxy;
-
-   minx = 65535;
-   miny = 65535;
-   maxx = -65536;
-   maxy = -65536;
-
-   EINA_LIST_FOREACH(e_comp_screen->outputs, l, eout)
-     {
-        if (!eout->config.enabled) continue;
-        if (eout->config.geom.x < minx) minx = eout->config.geom.x;
-        if (eout->config.geom.y < miny) miny = eout->config.geom.y;
-        if ((eout->config.geom.x + eout->config.geom.w) > maxx)
-          maxx = eout->config.geom.x + eout->config.geom.w;
-        if ((eout->config.geom.y + eout->config.geom.h) > maxy)
-          maxy = eout->config.geom.y + eout->config.geom.h;
-        printf("OUTPUT: s: '%s' @ %i %i - %ix%i\n",
-               eout->info.name,
-               eout->config.geom.x, eout->config.geom.y,
-               eout->config.geom.w, eout->config.geom.h);
-     }
-   printf("OUTPUT:--- %i %i -> %i %i\n", minx, miny, maxx, maxy);
-   EINA_LIST_FOREACH(e_comp_screen->outputs, l, eout)
-     {
-        eout->config.geom.x -= minx;
-        eout->config.geom.y -= miny;
-     }
-   e_comp_screen->w = maxx - minx;
-   e_comp_screen->h = maxy - miny;
-}
-
-static void
-_screen_config_maxsize(void)
-{
+   E_Comp_Screen *e_comp_screen;
    Eina_List *l;
-   E_Output *eout;
-   int maxx, maxy;
 
-   maxx = -65536;
-   maxy = -65536;
-   EINA_LIST_FOREACH(e_comp_screen->outputs, l, eout)
-     {
-        if (!eout->config.enabled) continue;
-        if ((eout->config.geom.x + eout->config.geom.w) > maxx)
-          maxx = eout->config.geom.x + eout->config.geom.w;
-        if ((eout->config.geom.y + eout->config.geom.h) > maxy)
-          maxy = eout->config.geom.y + eout->config.geom.h;
-        printf("OUTPUT: '%s': %i %i %ix%i\n",
-               eout->info.name,
-               eout->config.geom.x, eout->config.geom.y,
-               eout->config.geom.w, eout->config.geom.h);
-     }
-   printf("OUTPUT: result max: %ix%i\n", maxx, maxy);
-   e_comp_screen->w = maxx;
-   e_comp_screen->h = maxy;
-}
+   EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp, NULL);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp->e_comp_screen, NULL);
 
-static int
-_screen_sort_cb(const void *data1, const void *data2)
-{
-   const E_Output *s1 = data1, *s2 = data2;
-   int dif;
+   e_comp_screen = e_comp->e_comp_screen;
 
-   dif = -(s1->config.priority - s2->config.priority);
-   if (dif == 0)
-     {
-        dif = s1->config.geom.x - s2->config.geom.x;
-        if (dif == 0)
-          dif = s1->config.geom.y - s2->config.geom.y;
-     }
-   return dif;
-}
-
-static void
-_escreen_free(E_Screen *scr)
-{
-   free(scr->id);
-   free(scr);
-}
-
-void
-_escreens_set(Eina_List *screens)
-{
-   E_FREE_LIST(all_screens, _escreen_free);
-   all_screens = screens;
-}
-
-EINTERN void
-e_output_screens_setup(int rw, int rh)
-{
-   int i;
-   E_Screen *screen;
-   Eina_List *outputs = NULL, *outputs_rem;
-   Eina_List *e_screens = NULL;
-   Eina_List *l, *ll;
-   E_Output *eout, *s2, *s_chosen;
-   Eina_Bool removed;
-
-   if ((!e_comp_screen) || (!e_comp_screen->outputs)) goto out;
-   // put screens in tmp list
-   EINA_LIST_FOREACH(e_comp_screen->outputs, l, eout)
-     {
-        if ((eout->config.enabled) &&
-            (eout->config.geom.w > 0) &&
-            (eout->config.geom.h > 0))
-          {
-             outputs = eina_list_append(outputs, eout);
-          }
-     }
-   // remove overlapping screens - if a set of screens overlap, keep the
-   // smallest/lowest res
-   do
-     {
-        removed = EINA_FALSE;
-
-        EINA_LIST_FOREACH(outputs, l, eout)
-          {
-             outputs_rem = NULL;
-
-             EINA_LIST_FOREACH(l->next, ll, s2)
-               {
-                  if (E_INTERSECTS(eout->config.geom.x, eout->config.geom.y,
-                                   eout->config.geom.w, eout->config.geom.h,
-                                   s2->config.geom.x, s2->config.geom.y,
-                                   s2->config.geom.w, s2->config.geom.h))
-                    {
-                       if (!outputs_rem)
-                         outputs_rem = eina_list_append(outputs_rem, eout);
-                       outputs_rem = eina_list_append(outputs_rem, s2);
-                    }
-               }
-             // we have intersecting screens - choose the lowest res one
-             if (outputs_rem)
-               {
-                  removed = EINA_TRUE;
-                  // find the smallest screen (chosen one)
-                  s_chosen = NULL;
-                  EINA_LIST_FOREACH(outputs_rem, ll, s2)
-                    {
-                       if (!s_chosen) s_chosen = s2;
-                       else
-                         {
-                            if ((s_chosen->config.geom.w *
-                                 s_chosen->config.geom.h) >
-                                (s2->config.geom.w *
-                                 s2->config.geom.h))
-                              s_chosen = s2;
-                         }
-                    }
-                  // remove all from screens but the chosen one
-                  EINA_LIST_FREE(outputs_rem, s2)
-                    {
-                       if (s2 != s_chosen)
-                         outputs = eina_list_remove_list(outputs, l);
-                    }
-                  // break our list walk and try again
-                  break;
-               }
-          }
-     }
-   while (removed);
-   // sort screens by priority etc.
-   outputs = eina_list_sort(outputs, 0, _screen_sort_cb);
-   i = 0;
-   EINA_LIST_FOREACH(outputs, l, eout)
-     {
-        screen = E_NEW(E_Screen, 1);
-        screen->escreen = screen->screen = i;
-        screen->x = eout->config.geom.x;
-        screen->y = eout->config.geom.y;
-        screen->w = eout->config.geom.w;
-        screen->h = eout->config.geom.h;
-        if (eout->id) screen->id = strdup(eout->id);
-
-        e_screens = eina_list_append(e_screens, screen);
-        INF("E INIT: SCREEN: [%i][%i], %ix%i+%i+%i",
-            i, i, screen->w, screen->h, screen->x, screen->y);
-        i++;
-     }
-   eina_list_free(outputs);
-   // if we have NO screens at all (above - i will be 0) AND we have no
-   // existing screens set up in xinerama - then just say root window size
-   // is the entire screen. this should handle the case where you unplug ALL
-   // screens from an existing setup (unplug external monitors and/or close
-   // laptop lid), in which case as long as at least one screen is configured
-   // in xinerama, it will be left-as is until next time we re-eval screen
-   // setup and have at least one screen
-   printf("e_output_screens_setup............... %i %p\n", i, all_screens);
-   if ((i == 0) && (!all_screens))
-     {
-out:
-        screen = E_NEW(E_Screen, 1);
-        screen->escreen = screen->screen = 0;
-        screen->x = 0;
-        screen->y = 0;
-        if ((rw > 0) && (rh > 0))
-          screen->w = rw, screen->h = rh;
-        else
-          ecore_evas_screen_geometry_get(e_comp->ee, NULL, NULL, &screen->w, &screen->h);
-        e_screens = eina_list_append(e_screens, screen);
-     }
-   _escreens_set(e_screens);
-}
-
-EINTERN const Eina_List *
-e_output_screens_get(void)
-{
-   return all_screens;
-}
-
-EINTERN E_Output *
-e_output_find(const char *id)
-{
-   E_Output *eout;
-   Eina_List *l;
    EINA_LIST_FOREACH(e_comp_screen->outputs, l, eout)
      {
         if (!strcmp(eout->id, id)) return eout;
@@ -317,6 +68,12 @@ e_output_util_planes_print(void)
 {
    Eina_List *l, *ll, *p_l;
    E_Output * eout = NULL;
+   E_Comp_Screen *e_comp_screen = NULL;
+
+   EINA_SAFETY_ON_NULL_RETURN(e_comp);
+   EINA_SAFETY_ON_NULL_RETURN(e_comp->e_comp_screen);
+
+   e_comp_screen = e_comp->e_comp_screen;
 
    EINA_LIST_FOREACH_SAFE(e_comp_screen->outputs, l, ll, eout)
      {
index 2fdb54959b5d6d96bdbc326e9b093cbee8e74947..4f554d95c5bad9418f869417662d2398ee193e76 100644 (file)
@@ -1,9 +1,7 @@
 #ifdef E_TYPEDEFS
 
-typedef struct _E_Comp_Screen   E_Comp_Screen;
 typedef struct _E_Output        E_Output;
 typedef struct _E_Output_Mode   E_Output_Mode;
-typedef struct _E_Screen        E_Screen;
 
 #else
 #ifndef E_OUTPUT_H
@@ -11,14 +9,6 @@ typedef struct _E_Screen        E_Screen;
 
 #define E_OUTPUT_TYPE (int)0xE0b11002
 
-struct _E_Comp_Screen
-{
-   Eina_List *outputs; // available screens
-   int        w, h; // virtual resolution (calculated)
-   unsigned char  ignore_hotplug_events;
-   unsigned char  ignore_acpi_events;
-};
-
 struct _E_Output_Mode
 {
    int    w, h; // resolution width and height
@@ -52,21 +42,9 @@ struct _E_Output
    E_Zone              *zone;
 };
 
-struct _E_Screen
-{
-   int screen, escreen;
-   int x, y, w, h;
-   char *id; // this is the same id we get from _E_Output so look it up there
-};
-
-extern E_API E_Comp_Screen *e_comp_screen;
-extern E_API int E_EVENT_SCREEN_CHANGE;
-
 EINTERN Eina_Bool         e_output_init(void);
-EINTERN int               e_output_shutdown(void);
+EINTERN void              e_output_shutdown(void);
 EINTERN E_Output        * e_output_find(const char *id);
-EINTERN void              e_output_screens_setup(int rw, int rh);
-EINTERN const Eina_List * e_output_screens_get(void);
 E_API const Eina_List   * e_output_planes_get(E_Output *eout);
 E_API void                e_output_util_planes_print(void);