From 245b40b816150a2186a93e8914eacd80e2d0aa14 Mon Sep 17 00:00:00 2001 From: Carsten Haitzler Date: Sat, 19 Mar 2005 17:31:42 +0000 Subject: [PATCH] fix pager to work when windows are moved from zone to zone :) add xinerama faking command-line options and help. SVN revision: 13795 --- src/bin/e_error.c | 48 ++++++++++++++---- src/bin/e_main.c | 27 ++++++++++ src/bin/e_xinerama.c | 17 +++++++ src/bin/e_xinerama.h | 1 + src/modules/pager/e_mod_main.c | 90 +++++++++++++++++++++++++++------- 5 files changed, 154 insertions(+), 29 deletions(-) diff --git a/src/bin/e_error.c b/src/bin/e_error.c index d60390475..6fc36a031 100644 --- a/src/bin/e_error.c +++ b/src/bin/e_error.c @@ -59,12 +59,14 @@ e_error_message_manager_show(E_Manager *man, char *title, char *txt) int error_w, error_h; Evas_List *l, *shapelist = NULL; Evas_Coord maxw, maxh; + E_Container *con; + int x, y; error_w = 400; error_h = 200; - ee = ecore_evas_software_x11_new(NULL, man->win, - (man->w - error_w) / 2, (man->h - error_h) / 2, - error_w, error_h); + x = (man->w - error_w) / 2; + y = (man->h - error_h) / 2; + ee = ecore_evas_software_x11_new(NULL, man->win, x, y, error_w, error_h); ecore_evas_software_x11_direct_resize_set(ee, 1); e_canvas_add(ee); @@ -83,8 +85,7 @@ e_error_message_manager_show(E_Manager *man, char *title, char *txt) Evas_Coord tw, th; char *newstr; - if (o) - evas_object_del(o); + if (o) evas_object_del(o); maxw = 0; maxh = 0; @@ -207,17 +208,30 @@ e_error_message_manager_show(E_Manager *man, char *title, char *txt) evas_object_layer_set(o, -10); evas_object_show(o); - ecore_evas_move(ee, (man->w - error_w) / 2, (man->h - error_h) / 2); + x = (man->w - error_w) / 2; + y = (man->h - error_h) / 2; + con = e_manager_container_current_get(man); + if (con) + { + E_Zone *zone; + + zone = e_container_zone_number_get(con, 0); + if (zone) + { + x = zone->x + ((zone->w - error_w) / 2); + y = zone->y + ((zone->h - error_h) / 2); + } + } + ecore_evas_move(ee, x, y); ecore_evas_resize(ee, error_w, error_h); for (l = man->containers; l; l = l->next) { - E_Container *con; E_Container_Shape *es; con = l->data; es = e_container_shape_add(con); - e_container_shape_move(es, (man->w - error_w) / 2, (man->h - error_h) / 2); + e_container_shape_move(es, x, y); e_container_shape_resize(es, error_w, error_h); e_container_shape_show(es); shapelist = evas_list_append(shapelist, es); @@ -279,7 +293,21 @@ e_error_message_manager_show(E_Manager *man, char *title, char *txt) evas_object_resize(o, error_w, error_h); evas_object_show(o); - ecore_evas_move(ee, (man->w - error_w) / 2, (man->h - error_h) / 2); + x = (man->w - error_w) / 2; + y = (man->h - error_h) / 2; + con = e_manager_container_current_get(man); + if (con) + { + E_Zone *zone; + + zone = e_container_zone_number_get(con, 0); + if (zone) + { + x = zone->x + ((zone->w - error_w) / 2); + y = zone->y + ((zone->h - error_h) / 2); + } + } + ecore_evas_move(ee, x, y); ecore_evas_resize(ee, error_w, error_h); for (l = man->containers; l; l = l->next) @@ -289,7 +317,7 @@ e_error_message_manager_show(E_Manager *man, char *title, char *txt) con = l->data; es = e_container_shape_add(con); - e_container_shape_move(es, (man->w - error_w) / 2, (man->h - error_h) / 2); + e_container_shape_move(es, x, y); e_container_shape_resize(es, error_w, error_h); e_container_shape_show(es); shapelist = evas_list_append(shapelist, es); diff --git a/src/bin/e_main.c b/src/bin/e_main.c index 09c523657..88fbb2389 100644 --- a/src/bin/e_main.c +++ b/src/bin/e_main.c @@ -90,6 +90,33 @@ main(int argc, char **argv) snprintf(buf, sizeof(buf), "DISPLAY=%s", argv[i]); putenv(buf); } + else if ((!strcmp(argv[i], "-fake-xinerama-screen")) && (i < (argc - 1))) + { + int x, y, w, h; + + i++; + /* WWxHH+XX+YY */ + if (sscanf(argv[i], "%ix%i+%i+%i", &w, &h, &x, &y) == 4) + e_xinerama_fake_screen_add(x, y, w, h); + } + else if ((!strcmp(argv[i], "-h")) || + (!strcmp(argv[i], "-help")) || + (!strcmp(argv[i], "--help"))) + { + printf + ("Options:\n" + "\t-display DISPLAY\n" + "\t\tConnect to display named DISPLAY.\n" + "\t\tEG: -display :1.0\n" + "\t-fake-xinerama-screen WxH+X+Y\n" + "\t\tAdd a FAKE xinerama screen (instead of the real ones)\n" + "\t\tgiven the geometry. Add as many as you like. They all\n" + "\t\treplace the real xinerama screens, if any. This can\n" + "\t\tbe used to simulate xinerama.\n" + "\t\tEG: -fake-xinerama-screen 800x600+0+0 -fake-xinerama-screen 800x600+800+0\n" + ); + exit(0); + } } /* fix up DISPLAY to be :N.0 if no .screen is in it */ diff --git a/src/bin/e_xinerama.c b/src/bin/e_xinerama.c index c9e9dae5c..5d099e659 100644 --- a/src/bin/e_xinerama.c +++ b/src/bin/e_xinerama.c @@ -8,6 +8,7 @@ static void _e_xinerama_update(void); static Evas_List *all_screens = NULL; static Evas_List *chosen_screens = NULL; +static Evas_List *fake_screens = NULL; int e_xinerama_init(void) @@ -33,15 +34,31 @@ e_xinerama_update(void) const Evas_List * e_xinerama_screens_get(void) { + if (fake_screens) return fake_screens; return chosen_screens; } const Evas_List * e_xinerama_screens_all_get(void) { + if (fake_screens) return fake_screens; return all_screens; } +void +e_xinerama_fake_screen_add(int x, int y, int w, int h) +{ + E_Screen *scr; + + scr = calloc(1, sizeof(E_Screen)); + scr->screen = evas_list_count(fake_screens); + scr->x = x; + scr->y = y; + scr->w = w; + scr->h = h; + fake_screens = evas_list_append(fake_screens, scr); +} + /* local subsystem functions */ static void _e_xinerama_clean(void) diff --git a/src/bin/e_xinerama.h b/src/bin/e_xinerama.h index f7f617cff..1f4cf3efd 100644 --- a/src/bin/e_xinerama.h +++ b/src/bin/e_xinerama.h @@ -20,6 +20,7 @@ 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); +EAPI void e_xinerama_fake_screen_add(int x, int y, int w, int h); #endif #endif diff --git a/src/modules/pager/e_mod_main.c b/src/modules/pager/e_mod_main.c index 1f3fdce25..e6920f362 100644 --- a/src/modules/pager/e_mod_main.c +++ b/src/modules/pager/e_mod_main.c @@ -935,41 +935,93 @@ _pager_face_cb_event_border_desk_set(void *data, int type, void *event) face = data; ev = event; - if (face->zone != ev->border->zone) return 1; - if (ev->border->sticky) return 1; - - for (l = face->desks; l; l = l->next) + /* if this pager is not for the zone of the border */ + if (face->zone != ev->border->zone) { - pd = l->data; - if (ev->border->desk != pd->desk) + /* look at all desks in the pager */ + for (l = face->desks; l; l = l->next) { + pd = l->data; + /* find this border in this desk */ pw = _pager_desk_border_find(pd, ev->border); if (pw) { + /* if it is found - remove it. it does not belong in this + * pager as it probably moves zones */ pd->wins = evas_list_remove(pd->wins, pw); _pager_window_free(pw); } } - else + return 1; + } + /* and this pager zone is for this border */ + /* see if the window is in this pager at all */ + pw = _pager_face_border_find(face, ev->border); + /* is it sticky */ + if (ev->border->sticky) + { + /* if its sticky and in this pager - its already everywhere, so abort + * doing anything else */ + if (pw) return 1; + } + + /* its not sticky but its in the pager */ + if (pw) + { + for (l = face->desks; l; l = l->next) { + pd = l->data; + /* if the border is not meant to be on this desk - remove */ pw = _pager_desk_border_find(pd, ev->border); - if (pw) found = 1; + if (ev->border->desk != pd->desk) + { + if (pw) + { + pd->wins = evas_list_remove(pd->wins, pw); + _pager_window_free(pw); + } + } + /* it is meant to be here */ + else + { + /* mark it as found */ + if (pw) found = 1; + } + } + /* if the border was not found on the appropriate desk, we have + * to move it to the right desk */ + if (!found) + { + /* find the window */ + pw = _pager_face_border_find(face, ev->border); + /* find the pager desk of the target desk */ + pd = _pager_face_desk_find(face, ev->border->desk); + if ((pw) && (pd)) + { + /* remove it from whatever desk it was on */ + pw->desk->wins = evas_list_remove(pw->desk->wins, pw); + e_layout_unpack(pw->window_object); + + /* add it to the one its MEANT to be on */ + pw->desk = pd; + pd->wins = evas_list_append(pd->wins, pw); + e_layout_pack(pd->layout_object, pw->window_object); + e_layout_child_raise(pw->window_object); + _pager_window_move(face, pw); + } } } - if (!found) + /* the border isnt in this pager at all - it must have moved zones */ + else { - pw = _pager_face_border_find(face, ev->border); + /* find the pager desk it needs to go to */ pd = _pager_face_desk_find(face, ev->border->desk); - if ((pw) && (pd)) + if (pd) { - pw->desk->wins = evas_list_remove(pw->desk->wins, pw); - e_layout_unpack(pw->window_object); - - pw->desk = pd; - pd->wins = evas_list_append(pd->wins, pw); - e_layout_pack(pd->layout_object, pw->window_object); - e_layout_child_raise(pw->window_object); - _pager_window_move(face, pw); + /* create it and add it */ + pw = _pager_window_new(pd, ev->border); + if (pw) + pd->wins = evas_list_append(pd->wins, pw); } } return 1;