centralised xinerama code - now we can put intellligent selection (partly

there) and manual selection into 1 place.


SVN revision: 13645
This commit is contained in:
Carsten Haitzler 2005-03-07 09:56:49 +00:00
parent d495a1d951
commit 5c4db9320e
4 changed files with 133 additions and 115 deletions

View File

@ -44,7 +44,7 @@ e_container_new(E_Manager *man)
E_Zone *zone; E_Zone *zone;
Evas_Object *o; Evas_Object *o;
char name[40]; char name[40];
int i, n; Evas_List *l, *screens;
con = E_OBJECT_ALLOC(E_Container, E_CONTAINER_TYPE, _e_container_free); con = E_OBJECT_ALLOC(E_Container, E_CONTAINER_TYPE, _e_container_free);
if (!con) return NULL; if (!con) return NULL;
@ -82,36 +82,14 @@ e_container_new(E_Manager *man)
snprintf(name, sizeof(name), "Container %d", con->num); snprintf(name, sizeof(name), "Container %d", con->num);
con->name = strdup(name); con->name = strdup(name);
n = ecore_x_xinerama_screen_count_get(); screens = (Evas_List *)e_xinerama_screens_get();
if (n == 0) for (l = screens; l; l = l->next)
zone = e_zone_new(con, 0, 0, 0, con->w, con->h);
else
{ {
for (i = 0; i < n; i++) E_Screen *scr;
{
int zx, zy, zw, zh;
int skip;
Evas_List *l;
if (ecore_x_xinerama_screen_geometry_get(i, &zx, &zy, &zw, &zh)) scr = l->data;
{ zone = e_zone_new(con, scr->screen, scr->x, scr->y, scr->w, scr->h);
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);
}
}
}
con->gadman = e_gadman_new(con); con->gadman = e_gadman_new(con);
return con; return con;
@ -468,43 +446,35 @@ static void
_e_container_resize_handle(E_Container *con) _e_container_resize_handle(E_Container *con)
{ {
E_Event_Container_Resize *ev; E_Event_Container_Resize *ev;
Evas_List *l; Evas_List *l, *screens;
int n, i;
ev = calloc(1, sizeof(E_Event_Container_Resize)); ev = calloc(1, sizeof(E_Event_Container_Resize));
ev->container = con; ev->container = con;
/* FIXME: Handle resizing of zones if container is resized */
n = ecore_x_xinerama_screen_count_get(); e_xinerama_update();
if (n == 0)
{ screens = (Evas_List *)e_xinerama_screens_get();
if (con->zones) for (l = screens; l; l = l->next)
{ {
E_Screen *scr;
E_Zone *zone; E_Zone *zone;
zone = con->zones->data; scr = l->data;
e_zone_move(zone, 0, 0); zone = e_container_zone_number_get(con, scr->screen);
e_zone_resize(zone, con->w, con->h); if (zone)
} {
e_zone_move(zone, scr->x, scr->y);
e_zone_resize(zone, scr->w, scr->h);
} }
else else
{ {
for (i = 0; i < n; i++) zone = e_zone_new(con, scr->screen, scr->x, scr->y, scr->w, scr->h);
{ }
int zx, zy, zw, zh; /* FIXME: what if a zone exists for a screen that doesn't exist?
* not sure this will ever happen...
*/
}
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);
}
}
}
}
e_gadman_container_resize(con->gadman); e_gadman_container_resize(con->gadman);
e_object_ref(E_OBJECT(con)); e_object_ref(E_OBJECT(con));
ecore_event_add(E_EVENT_CONTAINER_RESIZE, ev, _e_container_event_container_resize_free, NULL); ecore_event_add(E_EVENT_CONTAINER_RESIZE, ev, _e_container_event_container_resize_free, NULL);

View File

@ -25,7 +25,7 @@ e_init_init(void)
Ecore_X_Window *roots; Ecore_X_Window *roots;
int num; int num;
Evas_Object *o; Evas_Object *o;
int n; Evas_List *l, *screens;
num = 0; num = 0;
roots = ecore_x_window_root_list(&num); roots = ecore_x_window_root_list(&num);
@ -50,62 +50,38 @@ e_init_init(void)
ecore_evas_raise(_e_init_ecore_evas); ecore_evas_raise(_e_init_ecore_evas);
ecore_evas_show(_e_init_ecore_evas); ecore_evas_show(_e_init_ecore_evas);
n = ecore_x_xinerama_screen_count_get(); screens = (Evas_List *)e_xinerama_screens_get();
if (n == 0) for (l = screens; l; l = l->next)
{ {
o = edje_object_add(_e_init_evas); E_Screen *scr;
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;
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); o = edje_object_add(_e_init_evas);
edje_object_file_set(o, edje_object_file_set(o,
/* FIXME: "init.eet" needs to come from config */ /* FIXME: "init.eet" needs to come from config */
e_path_find(path_init, "init.eet"), e_path_find(path_init, "init.eet"),
"init/splash"); "init/splash");
evas_object_move(o, x, y); evas_object_move(o, scr->x, scr->y);
evas_object_resize(o, w, h); evas_object_resize(o, scr->w, scr->h);
evas_object_show(o); evas_object_show(o);
_e_init_object = o; _e_init_object = o;
} }
/* Only add extra screen if it doesn't overlap with the main screen */ /* other screens */
/* FIXME: What if extra screens overlap? Maybe zones should be else
* initialized before we come here? */
else if (!E_INTERSECTS(x, y, w, h,
mx, my, mw, mh))
{ {
o = edje_object_add(_e_init_evas); o = edje_object_add(_e_init_evas);
edje_object_file_set(o, edje_object_file_set(o,
/* FIXME: "init.eet" needs to come from config */ /* FIXME: "init.eet" needs to come from config */
e_path_find(path_init, "init.eet"), e_path_find(path_init, "init.eet"),
"init/extra_screen"); "init/extra_screen");
evas_object_move(o, x, y); evas_object_move(o, scr->x, scr->y);
evas_object_resize(o, w, h); evas_object_resize(o, scr->w, scr->h);
evas_object_show(o); evas_object_show(o);
} }
} }
}
free(roots); free(roots);
return 1; return 1;

View File

@ -23,6 +23,26 @@ e_xinerama_shutdown(void)
return 1; 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 static void
_e_xinerama_clean(void) _e_xinerama_clean(void)
{ {
@ -33,7 +53,6 @@ _e_xinerama_clean(void)
} }
while (chosen_screens) while (chosen_screens)
{ {
free(chosen_screens->data);
chosen_screens = evas_list_remove_list(chosen_screens, chosen_screens); chosen_screens = evas_list_remove_list(chosen_screens, chosen_screens);
} }
} }
@ -41,14 +60,17 @@ _e_xinerama_clean(void)
static void static void
_e_xinerama_update(void) _e_xinerama_update(void)
{ {
int i, n; int n;
Ecore_X_Window root, *roots; Ecore_X_Window *roots;
Evas_List *l;
_e_xinerama_clean(); _e_xinerama_clean();
roots = ecore_x_window_root_list(&n); roots = ecore_x_window_root_list(&n);
if (roots) if (roots)
{ {
int i;
int rw, rh; int rw, rh;
Ecore_X_Window root;
/* more than 1 root window - xinerama wont be active */ /* more than 1 root window - xinerama wont be active */
if (n > 1) if (n > 1)
@ -101,4 +123,51 @@ _e_xinerama_update(void)
} }
} }
/* now go through all_screens... and build a list of chosen screens */ /* 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);
}
}
} }

View File

@ -17,6 +17,9 @@ struct _E_Screen
EAPI int e_xinerama_init(void); EAPI int e_xinerama_init(void);
EAPI int e_xinerama_shutdown(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
#endif #endif