From 5c4db9320e6ba028ff66d620d87caf4b0ec16420 Mon Sep 17 00:00:00 2001 From: Carsten Haitzler Date: Mon, 7 Mar 2005 09:56:49 +0000 Subject: [PATCH] centralised xinerama code - now we can put intellligent selection (partly there) and manual selection into 1 place. SVN revision: 13645 --- src/bin/e_container.c | 84 ++++++++++++++----------------------------- src/bin/e_init.c | 80 +++++++++++++++-------------------------- src/bin/e_xinerama.c | 75 ++++++++++++++++++++++++++++++++++++-- src/bin/e_xinerama.h | 9 +++-- 4 files changed, 133 insertions(+), 115 deletions(-) diff --git a/src/bin/e_container.c b/src/bin/e_container.c index 5d36d9e03..6cce74635 100644 --- a/src/bin/e_container.c +++ b/src/bin/e_container.c @@ -44,7 +44,7 @@ e_container_new(E_Manager *man) E_Zone *zone; Evas_Object *o; char name[40]; - int i, n; + Evas_List *l, *screens; con = E_OBJECT_ALLOC(E_Container, E_CONTAINER_TYPE, _e_container_free); if (!con) return NULL; @@ -82,36 +82,14 @@ e_container_new(E_Manager *man) snprintf(name, sizeof(name), "Container %d", con->num); con->name = strdup(name); - n = ecore_x_xinerama_screen_count_get(); - if (n == 0) - zone = e_zone_new(con, 0, 0, 0, con->w, con->h); - else + screens = (Evas_List *)e_xinerama_screens_get(); + for (l = screens; l; l = l->next) { - for (i = 0; i < n; i++) - { - int zx, zy, zw, zh; - int skip; - Evas_List *l; - - if (ecore_x_xinerama_screen_geometry_get(i, &zx, &zy, &zw, &zh)) - { - skip = 0; - for (l = con->zones; l; l = l->next) - { - zone = l->data; - if (E_INTERSECTS(zone->x, zone->y, zone->w, zone->h, - zx, zy, zw, zh)) - { - skip = 1; - break; - } - } - if (!skip) - zone = e_zone_new(con, i, zx, zy, zw, zh); - } - } + E_Screen *scr; + + scr = l->data; + zone = e_zone_new(con, scr->screen, scr->x, scr->y, scr->w, scr->h); } - con->gadman = e_gadman_new(con); return con; @@ -468,43 +446,35 @@ static void _e_container_resize_handle(E_Container *con) { E_Event_Container_Resize *ev; - Evas_List *l; - int n, i; + Evas_List *l, *screens; ev = calloc(1, sizeof(E_Event_Container_Resize)); ev->container = con; - /* FIXME: Handle resizing of zones if container is resized */ - n = ecore_x_xinerama_screen_count_get(); - if (n == 0) + + e_xinerama_update(); + + screens = (Evas_List *)e_xinerama_screens_get(); + for (l = screens; l; l = l->next) { - if (con->zones) + E_Screen *scr; + E_Zone *zone; + + scr = l->data; + zone = e_container_zone_number_get(con, scr->screen); + if (zone) { - E_Zone *zone; - - zone = con->zones->data; - e_zone_move(zone, 0, 0); - e_zone_resize(zone, con->w, con->h); + e_zone_move(zone, scr->x, scr->y); + e_zone_resize(zone, scr->w, scr->h); } - } - else - { - for (i = 0; i < n; i++) + else { - int zx, zy, zw, zh; - - if (ecore_x_xinerama_screen_geometry_get(i, &zx, &zy, &zw, &zh)) - { - E_Zone *zone; - - zone = e_container_zone_number_get(con, i); - if (zone) - { - e_zone_move(zone, zx, zy); - e_zone_resize(zone, zw, zh); - } - } + zone = e_zone_new(con, scr->screen, scr->x, scr->y, scr->w, scr->h); } + /* FIXME: what if a zone exists for a screen that doesn't exist? + * not sure this will ever happen... + */ } + e_gadman_container_resize(con->gadman); e_object_ref(E_OBJECT(con)); ecore_event_add(E_EVENT_CONTAINER_RESIZE, ev, _e_container_event_container_resize_free, NULL); diff --git a/src/bin/e_init.c b/src/bin/e_init.c index c3020c127..ae56754c2 100644 --- a/src/bin/e_init.c +++ b/src/bin/e_init.c @@ -25,7 +25,7 @@ e_init_init(void) Ecore_X_Window *roots; int num; Evas_Object *o; - int n; + Evas_List *l, *screens; num = 0; roots = ecore_x_window_root_list(&num); @@ -50,60 +50,36 @@ e_init_init(void) ecore_evas_raise(_e_init_ecore_evas); ecore_evas_show(_e_init_ecore_evas); - n = ecore_x_xinerama_screen_count_get(); - if (n == 0) + screens = (Evas_List *)e_xinerama_screens_get(); + for (l = screens; l; l = l->next) { - o = edje_object_add(_e_init_evas); - edje_object_file_set(o, - /* FIXME: "init.eet" needs to come from config */ - e_path_find(path_init, "init.eet"), - "init/splash"); - evas_object_move(o, 0, 0); - evas_object_resize(o, w, h); - evas_object_show(o); - _e_init_object = o; - } - else - { - int i; - int mx, my, mw, mh; + E_Screen *scr; - for (i = 0; i < n; i++) + scr = l->data; + /* first screen */ + if (l == screens) { - ecore_x_xinerama_screen_geometry_get(i, &x, &y, &w, &h); - if (i == 0) - { - /* Remeber the size and placement of the first window */ - mx = x; - my = y; - mw = w; - mh = h; - /* Init splash */ - o = edje_object_add(_e_init_evas); - edje_object_file_set(o, - /* FIXME: "init.eet" needs to come from config */ - e_path_find(path_init, "init.eet"), - "init/splash"); - evas_object_move(o, x, y); - evas_object_resize(o, w, h); - evas_object_show(o); - _e_init_object = o; - } - /* Only add extra screen if it doesn't overlap with the main screen */ - /* FIXME: What if extra screens overlap? Maybe zones should be - * initialized before we come here? */ - else if (!E_INTERSECTS(x, y, w, h, - mx, my, mw, mh)) - { - o = edje_object_add(_e_init_evas); - edje_object_file_set(o, - /* FIXME: "init.eet" needs to come from config */ - e_path_find(path_init, "init.eet"), - "init/extra_screen"); - evas_object_move(o, x, y); - evas_object_resize(o, w, h); - evas_object_show(o); - } + o = edje_object_add(_e_init_evas); + edje_object_file_set(o, + /* FIXME: "init.eet" needs to come from config */ + e_path_find(path_init, "init.eet"), + "init/splash"); + evas_object_move(o, scr->x, scr->y); + evas_object_resize(o, scr->w, scr->h); + evas_object_show(o); + _e_init_object = o; + } + /* other screens */ + else + { + o = edje_object_add(_e_init_evas); + edje_object_file_set(o, + /* FIXME: "init.eet" needs to come from config */ + e_path_find(path_init, "init.eet"), + "init/extra_screen"); + evas_object_move(o, scr->x, scr->y); + evas_object_resize(o, scr->w, scr->h); + evas_object_show(o); } } diff --git a/src/bin/e_xinerama.c b/src/bin/e_xinerama.c index f77b15e0d..e310f97bd 100644 --- a/src/bin/e_xinerama.c +++ b/src/bin/e_xinerama.c @@ -23,6 +23,26 @@ e_xinerama_shutdown(void) return 1; } +void +e_xinerama_update(void) +{ + _e_xinerama_clean(); + _e_xinerama_update(); +} + +const Evas_List * +e_xinerama_screens_get(void) +{ + return chosen_screens; +} + +const Evas_List * +e_xinerama_screens_all_get(void) +{ + return all_screens; +} + +/* local subsystem functions */ static void _e_xinerama_clean(void) { @@ -33,7 +53,6 @@ _e_xinerama_clean(void) } while (chosen_screens) { - free(chosen_screens->data); chosen_screens = evas_list_remove_list(chosen_screens, chosen_screens); } } @@ -41,14 +60,17 @@ _e_xinerama_clean(void) static void _e_xinerama_update(void) { - int i, n; - Ecore_X_Window root, *roots; + int n; + Ecore_X_Window *roots; + Evas_List *l; _e_xinerama_clean(); roots = ecore_x_window_root_list(&n); if (roots) { + int i; int rw, rh; + Ecore_X_Window root; /* more than 1 root window - xinerama wont be active */ if (n > 1) @@ -101,4 +123,51 @@ _e_xinerama_update(void) } } /* now go through all_screens... and build a list of chosen screens */ + for (l = all_screens; l; l = l->next) + { + Evas_List *ll; + E_Screen *scr; + int add = 0; + Evas_List *removes; + + scr = l->data; + add = 1; + removes = NULL; + /* does this screen intersect with any we have chosen? */ + for (ll = chosen_screens; ll; ll = ll->next) + { + E_Screen *scr2; + + scr2 = ll->data; + /* if they intersect */ + if (E_INTERSECTS(scr->x, scr->y, scr->w, scr->h, + scr2->x, scr2->y, scr2->w, scr2->h)) + { + int sz, sz2; + + /* calculate pixel area */ + sz = scr->w * scr->h; + sz2 = scr2->w * scr2->h; + /* if the one we already have is bigger, DONT add the new */ + if (sz2 > sz) + add = 0; + /* add the old to a list to remove */ + else + removes = evas_list_append(removes, scr); + } + } + /* if there are screens to remove - remove them */ + while (removes) + { + chosen_screens = evas_list_remove(chosen_screens, removes->data); + removes = evas_list_remove_list(removes, removes); + } + /* if this screen is to be added, add it */ + if (add) + { + printf("E17 INIT: XINERAMA CHOSEN: [%i], %ix%i+%i+%i\n", + scr->screen, scr->w, scr->h, scr->x, scr->y); + chosen_screens = evas_list_append(chosen_screens, scr); + } + } } diff --git a/src/bin/e_xinerama.h b/src/bin/e_xinerama.h index 066d443c6..f7f617cff 100644 --- a/src/bin/e_xinerama.h +++ b/src/bin/e_xinerama.h @@ -15,8 +15,11 @@ struct _E_Screen int x, y, w, h; }; -EAPI int e_xinerama_init(void); -EAPI int e_xinerama_shutdown(void); - +EAPI int e_xinerama_init(void); +EAPI int e_xinerama_shutdown(void); +EAPI void e_xinerama_update(void); +EAPI const Evas_List *e_xinerama_screens_get(void); +EAPI const Evas_List *e_xinerama_screens_all_get(void); + #endif #endif