forked from enlightenment/enlightenment
Window cleanup function and menu entry.
SVN revision: 14742
This commit is contained in:
parent
078e74e14c
commit
1468632978
|
@ -29,6 +29,7 @@ static void _e_int_menus_apps_run (void *data, E_Menu *m, E_Menu_Item
|
|||
static void _e_int_menus_clients_pre_cb (void *data, E_Menu *m);
|
||||
static void _e_int_menus_clients_free_hook (void *obj);
|
||||
static void _e_int_menus_clients_item_cb (void *data, E_Menu *m, E_Menu_Item *mi);
|
||||
static void _e_int_menus_clients_cleanup_cb (void *data, E_Menu *m, E_Menu_Item *mi);
|
||||
static void _e_int_menus_desktops_pre_cb (void *data, E_Menu *m);
|
||||
static void _e_int_menus_desktops_item_cb (void *data, E_Menu *m, E_Menu_Item *mi);
|
||||
static void _e_int_menus_desktops_row_add_cb (void *data, E_Menu *m, E_Menu_Item *mi);
|
||||
|
@ -491,6 +492,12 @@ _e_int_menus_clients_pre_cb(void *data, E_Menu *m)
|
|||
bd->client.icccm.class);
|
||||
if (a) e_menu_item_icon_edje_set(mi, a->path, "icon");
|
||||
}
|
||||
mi = e_menu_item_new(m);
|
||||
e_menu_item_label_set(mi, _("Cleanup Windows"));
|
||||
e_menu_item_icon_edje_set(mi,
|
||||
e_path_find(path_icons, "default.edj"),
|
||||
"windows");
|
||||
e_menu_item_callback_set(mi, _e_int_menus_clients_cleanup_cb, zone);
|
||||
e_object_free_attach_func_set(E_OBJECT(m), _e_int_menus_clients_free_hook);
|
||||
e_object_data_set(E_OBJECT(m), borders);
|
||||
}
|
||||
|
@ -526,6 +533,14 @@ _e_int_menus_clients_item_cb(void *data, E_Menu *m, E_Menu_Item *mi)
|
|||
e_border_focus_set(bd, 1, 1);
|
||||
}
|
||||
|
||||
static void
|
||||
_e_int_menus_clients_cleanup_cb(void *data, E_Menu *m, E_Menu_Item *mi)
|
||||
{
|
||||
E_Zone *zone = data;
|
||||
|
||||
e_place_zone_region_smart_cleanup(zone);
|
||||
}
|
||||
|
||||
static void
|
||||
_e_int_menus_gadgets_pre_cb(void *data, E_Menu *m)
|
||||
{
|
||||
|
|
|
@ -3,6 +3,59 @@
|
|||
*/
|
||||
#include "e.h"
|
||||
|
||||
void
|
||||
e_place_zone_region_smart_cleanup(E_Zone *zone)
|
||||
{
|
||||
E_Desk *desk;
|
||||
Evas_List *l, *borders = NULL;
|
||||
|
||||
E_OBJECT_CHECK(zone);
|
||||
desk = e_desk_current_get(zone);
|
||||
for (l = e_border_clients_get(); l; l = l->next)
|
||||
{
|
||||
E_Border *border;
|
||||
|
||||
border = l->data;
|
||||
/* Build a list of windows on this desktop and not iconified. */
|
||||
if ((border->desk == desk) && !(border->iconic))
|
||||
{
|
||||
int area;
|
||||
Evas_List *ll;
|
||||
|
||||
/* Ordering windows largest to smallest gives better results */
|
||||
area = border->w * border->h;
|
||||
for (ll = borders; ll; ll = ll->next)
|
||||
{
|
||||
int testarea;
|
||||
E_Border *bd = ll->data;
|
||||
|
||||
testarea = bd->w * bd->h;
|
||||
/* Insert the border if larger than the current border */
|
||||
if (area >= testarea)
|
||||
{
|
||||
borders = evas_list_prepend_relative(borders, border, bd);
|
||||
break;
|
||||
}
|
||||
}
|
||||
/* Looped over all borders without placing, so place at end */
|
||||
if (!ll) borders = evas_list_append(borders, border);
|
||||
}
|
||||
}
|
||||
|
||||
/* Loop over the borders moving each one using the smart placement */
|
||||
while (borders)
|
||||
{
|
||||
int new_x, new_y;
|
||||
E_Border *border;
|
||||
|
||||
border = borders->data;
|
||||
e_place_zone_region_smart(zone, borders, border->x, border->y,
|
||||
border->w, border->h, &new_x, &new_y);
|
||||
e_border_move(border, new_x, new_y);
|
||||
borders = evas_list_remove(borders, border);
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
e_place_zone_region_smart(E_Zone *zone, Evas_List *skiplist, int x, int y, int w, int h, int *rx, int *ry)
|
||||
{
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#ifndef E_PLACE_H
|
||||
#define E_PLACE_H
|
||||
|
||||
EAPI void e_place_zone_region_smart_cleanup(E_Zone *zone);
|
||||
EAPI int e_place_zone_region_smart(E_Zone *zone, Evas_List *skiplist, int x, int y, int w, int h, int *rx, int *ry);
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue