Enlightenment CVS committal Author : raster Project : e17 Module : apps/e
Dir : e17/apps/e/src/bin Modified Files: e.h e_border.c e_border.h e_int_menus.c e_int_menus.h Log Message: lost windows men TODO... answer seb's todo q. :) =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/e/src/bin/e.h,v retrieving revision 1.22 retrieving revision 1.23 diff -u -3 -r1.22 -r1.23 --- e.h 11 Jun 2005 13:32:29 -0000 1.22 +++ e.h 19 Jun 2005 12:35:05 -0000 1.23 @@ -60,6 +60,7 @@ #define E_FN_DEL(_fn, _h) if (_h) { _fn(_h); _h = NULL; } #define E_INTERSECTS(x, y, w, h, xx, yy, ww, hh) (((x) < ((xx) + (ww))) && ((y) < ((yy) + (hh))) && (((x) + (w)) > (xx)) && (((y) + (h)) > (yy))) #define E_INSIDE(x, y, xx, yy, ww, hh) (((x) < ((xx) + (ww))) && ((y) < ((yy) + (hh))) && ((x) >= (xx)) && ((y) >= (yy))) +#define E_CONTAINS(x, y, w, h, xx, yy, ww, hh) (((xx) >= (x)) && (((x) + (w)) <= ((xx) + (ww))) && ((yy) >= (y)) && (((y) + (h)) <= ((yy) + (hh)))) #define E_SPANS_COMMON(x1, w1, x2, w2) (!((((x2) + (w2)) <= (x1)) || ((x2) >= ((x1) + (w1))))) #define E_REALLOC(p, s, n) p = realloc(p, sizeof(s) * n) #define E_NEW(s, n) calloc(n, sizeof(s)) =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/e/src/bin/e_border.c,v retrieving revision 1.271 retrieving revision 1.272 diff -u -3 -r1.271 -r1.272 --- e_border.c 18 Jun 2005 15:49:23 -0000 1.271 +++ e_border.c 19 Jun 2005 12:35:05 -0000 1.272 @@ -1778,6 +1778,68 @@ return focus_stack; } +Evas_List * +e_border_lost_windows_get(E_Zone *zone) +{ + Evas_List *list = NULL, *l; + int loss_overlap = 5; + + for (l = borders; l; l = l->next) + { + E_Border *bd; + + bd = l->data; + if (bd->zone) + { + if ((bd->zone == zone) || + (bd->zone->container == zone->container)) + { + if (!E_INTERSECTS(bd->zone->x + loss_overlap, + bd->zone->y + loss_overlap, + bd->zone->w - (2 * loss_overlap), + bd->zone->h - (2 * loss_overlap), + bd->x, bd->y, bd->w, bd->h)) + { + list = evas_list_append(list, bd); + } + else if ((!E_CONTAINS(bd->zone->x, bd->zone->y, + bd->zone->w, bd->zone->h, + bd->x, bd->y, bd->w, bd->h)) && + (bd->shaped)) + { + Ecore_X_Rectangle *rect; + int i, num; + + rect = ecore_x_window_shape_rectangles_get(bd->win, &num); + if (rect) + { + int ok; + + ok = 0; + for (i = 0; i < num; i++) + { + if (E_INTERSECTS(bd->zone->x + loss_overlap, + bd->zone->y + loss_overlap, + bd->zone->w - (2 * loss_overlap), + bd->zone->h - (2 * loss_overlap), + rect[i].x, rect[i].y, + rect[i].width, rect[i].height)) + { + ok = 1; + break; + } + } + free(rect); + if (!ok) + list = evas_list_append(list, bd); + } + } + } + } + } + return list; +} + /* local subsystem functions */ static void _e_border_free(E_Border *bd) =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/e/src/bin/e_border.h,v retrieving revision 1.76 retrieving revision 1.77 diff -u -3 -r1.76 -r1.77 --- e_border.h 18 Jun 2005 12:51:00 -0000 1.76 +++ e_border.h 19 Jun 2005 12:35:05 -0000 1.77 @@ -454,6 +454,7 @@ EAPI void e_border_button_bindings_grab_all(void); EAPI Evas_List *e_border_focus_stack_get(void); +EAPI Evas_List *e_border_lost_windows_get(E_Zone *zone); extern EAPI int E_EVENT_BORDER_RESIZE; extern EAPI int E_EVENT_BORDER_MOVE; =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/e/src/bin/e_int_menus.c,v retrieving revision 1.67 retrieving revision 1.68 diff -u -3 -r1.67 -r1.68 --- e_int_menus.c 11 Jun 2005 13:32:29 -0000 1.67 +++ e_int_menus.c 19 Jun 2005 12:35:05 -0000 1.68 @@ -15,6 +15,7 @@ E_Menu *gadgets; E_Menu *themes; E_Menu *config; + E_Menu *lost_clients; }; /* local subsystem functions */ @@ -42,6 +43,9 @@ static void _e_int_menus_gadgets_edit_mode_cb(void *data, E_Menu *m, E_Menu_Item *mi); static void _e_int_menus_themes_pre_cb (void *data, E_Menu *m); static void _e_int_menus_themes_edit_mode_cb (void *data, E_Menu *m, E_Menu_Item *mi); +static void _e_int_menus_lost_clients_pre_cb (void *data, E_Menu *m); +static void _e_int_menus_lost_clients_free_hook (void *obj); +static void _e_int_menus_lost_clients_item_cb (void *data, E_Menu *m, E_Menu_Item *mi); /* externally accessible functions */ E_Menu * @@ -97,6 +101,15 @@ IF_FREE(s); e_menu_item_submenu_set(mi, subm); + subm = e_int_menus_lost_clients_new(); + dat->lost_clients = subm; + mi = e_menu_item_new(m); + e_menu_item_label_set(mi, _("Lost Windows")); + s = e_path_find(path_icons, "default.edj"); + e_menu_item_icon_edje_set(mi, s, "lost_windows"); + IF_FREE(s); + e_menu_item_submenu_set(mi, subm); + subm = e_int_menus_gadgets_new(); dat->gadgets = subm; mi = e_menu_item_new(m); @@ -245,6 +258,16 @@ return m; } +E_Menu * +e_int_menus_lost_clients_new(void) +{ + E_Menu *m; + + m = e_menu_new(); + e_menu_pre_activate_callback_set(m, _e_int_menus_lost_clients_pre_cb, NULL); + return m; +} + /* local subsystem functions */ static void _e_int_menus_main_del_hook(void *obj) @@ -263,6 +286,7 @@ e_object_del(E_OBJECT(dat->gadgets)); e_object_del(E_OBJECT(dat->themes)); e_object_del(E_OBJECT(dat->config)); + e_object_del(E_OBJECT(dat->lost_clients)); free(dat); } } @@ -529,7 +553,7 @@ else if (bd->client.icccm.title) e_menu_item_label_set(mi, bd->client.icccm.title); else - e_menu_item_label_set(mi, "No name!!"); + e_menu_item_label_set(mi, _("No name!!")); /* ref the border as we implicitly unref it in the callback */ e_object_ref(E_OBJECT(bd)); e_menu_item_callback_set(mi, _e_int_menus_clients_item_cb, bd); @@ -569,7 +593,6 @@ } } - static void _e_int_menus_clients_item_cb(void *data, E_Menu *m, E_Menu_Item *mi) { @@ -737,3 +760,81 @@ restart = 1; ecore_main_loop_quit(); } + +static void +_e_int_menus_lost_clients_pre_cb(void *data, E_Menu *m) +{ + E_Menu_Item *mi; + Evas_List *l, *borders = NULL; + E_Menu *root; + E_Zone *zone = NULL; + char *s; + + e_menu_pre_activate_callback_set(m, NULL, NULL); + root = e_menu_root_get(m); + /* get the current clients */ + if (root) + zone = root->zone; + borders = e_border_lost_windows_get(zone); + + if (!borders) + { + /* FIXME here we want nothing, but that crashes!!! */ + mi = e_menu_item_new(m); + e_menu_item_label_set(mi, _("(No Windows)")); + return; + } + for (l = borders; l; l = l->next) + { + E_Border *bd = l->data; + E_App *a; + + mi = e_menu_item_new(m); + if (bd->client.netwm.name) + e_menu_item_label_set(mi, bd->client.netwm.name); + else if (bd->client.icccm.title) + e_menu_item_label_set(mi, bd->client.icccm.title); + else + e_menu_item_label_set(mi, _("No name!!")); + /* ref the border as we implicitly unref it in the callback */ + e_object_ref(E_OBJECT(bd)); + e_menu_item_callback_set(mi, _e_int_menus_lost_clients_item_cb, bd); + a = e_app_window_name_class_find(bd->client.icccm.name, + bd->client.icccm.class); + if (a) e_menu_item_icon_edje_set(mi, a->path, "icon"); + } + e_object_free_attach_func_set(E_OBJECT(m), _e_int_menus_lost_clients_free_hook); + e_object_data_set(E_OBJECT(m), borders); +} + +static void +_e_int_menus_lost_clients_free_hook(void *obj) +{ + E_Menu *m; + Evas_List *borders; + + m = obj; + borders = e_object_data_get(E_OBJECT(m)); + while (borders) + { + E_Border *bd; + + bd = borders->data; + borders = evas_list_remove_list(borders, borders); + e_object_unref(E_OBJECT(bd)); + } +} + + +static void +_e_int_menus_lost_clients_item_cb(void *data, E_Menu *m, E_Menu_Item *mi) +{ + E_Border *bd = data; + + E_OBJECT_CHECK(bd); + if (bd->iconic) e_border_uniconify(bd); + if (bd->desk) e_desk_show(bd->desk); + e_border_move(bd, bd->zone->x + ((bd->zone->w - bd->w) / 2), bd->zone->y + ((bd->zone->h - bd->h) / 2)); + e_border_raise(bd); + e_border_focus_set(bd, 1, 1); +} =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/e/src/bin/e_int_menus.h,v retrieving revision 1.12 retrieving revision 1.13 diff -u -3 -r1.12 -r1.13 --- e_int_menus.h 9 Jun 2005 22:24:36 -0000 1.12 +++ e_int_menus.h 19 Jun 2005 12:35:05 -0000 1.13 @@ -14,6 +14,7 @@ EAPI E_Menu *e_int_menus_config_apps_new(void); EAPI E_Menu *e_int_menus_gadgets_new(void); EAPI E_Menu *e_int_menus_themes_new(void); +EAPI E_Menu *e_int_menus_lost_clients_new(void); #endif #endif ------------------------------------------------------- SF.Net email is sponsored by: Discover Easy Linux Migration Strategies from IBM. Find simple to follow Roadmaps, straightforward articles, informative Webcasts and more! Get everything you need to get up to speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs