2010-12-21 03:58:59 -08:00
|
|
|
#include <e.h>
|
|
|
|
#include "e_mod_main.h"
|
|
|
|
|
2011-02-21 07:52:24 -08:00
|
|
|
//TODO
|
2011-02-19 16:36:40 -08:00
|
|
|
//~ handle add, delete border
|
2011-02-21 07:52:24 -08:00
|
|
|
//~ how to handle/disable possible desk show events
|
|
|
|
// while scale is active?
|
|
|
|
//
|
2011-02-19 16:36:40 -08:00
|
|
|
|
2011-02-21 07:52:24 -08:00
|
|
|
/* #define DBG(...) */
|
|
|
|
#define DBG(...) printf(__VA_ARGS__)
|
2011-02-19 16:36:40 -08:00
|
|
|
|
2011-02-21 11:15:49 -08:00
|
|
|
#define SPACING 32
|
2011-02-21 07:52:24 -08:00
|
|
|
#define PLACE_RUNS 10000
|
|
|
|
#define GROW_RUNS 1000
|
|
|
|
#define SHRINK_RUNS 1000
|
|
|
|
#define GROW 6.0
|
2011-02-19 00:34:10 -08:00
|
|
|
|
2010-12-21 03:58:59 -08:00
|
|
|
static E_Gadcon_Client *_gc_init(E_Gadcon *gc, const char *name, const char *id, const char *style);
|
|
|
|
static void _gc_shutdown(E_Gadcon_Client *gcc);
|
|
|
|
static void _gc_orient(E_Gadcon_Client *gcc, E_Gadcon_Orient orient);
|
|
|
|
static char *_gc_label(E_Gadcon_Client_Class *client_class);
|
|
|
|
static const char *_gc_id_new(E_Gadcon_Client_Class *client_class);
|
|
|
|
static Evas_Object *_gc_icon(E_Gadcon_Client_Class *client_class, Evas *evas);
|
|
|
|
|
|
|
|
static void _scale_conf_new(void);
|
|
|
|
static void _scale_conf_free(void);
|
|
|
|
static Config_Item *_scale_conf_item_get(const char *id);
|
2011-02-19 16:36:40 -08:00
|
|
|
static void _scale_gc_cb_mouse_down(void *data, Evas *evas, Evas_Object *obj, void *event);
|
|
|
|
static void _scale_gc_cb_menu_post(void *data, E_Menu *menu);
|
|
|
|
static void _scale_gc_cb_menu_configure(void *data, E_Menu *mn, E_Menu_Item *mi);
|
2010-12-21 03:58:59 -08:00
|
|
|
|
2011-02-19 16:36:40 -08:00
|
|
|
static void _scale_finish(void);
|
|
|
|
static void _scale_in(void);
|
|
|
|
static void _scale_out(void);
|
2011-02-21 07:52:24 -08:00
|
|
|
|
2011-02-19 16:36:40 -08:00
|
|
|
static Eina_Bool _scale_cb_mouse_down(void *data, int type, void *event);
|
2011-02-21 07:52:24 -08:00
|
|
|
static Eina_Bool _scale_cb_mouse_move(void *data, int type, void *event);
|
2011-02-19 16:36:40 -08:00
|
|
|
|
2011-02-21 07:52:24 -08:00
|
|
|
static void _scale_win_delorig(void *data, Evas *e, Evas_Object *obj, void *event_info);
|
2011-02-19 16:36:40 -08:00
|
|
|
static void _scale_win_cb_intercept_move(void *data, Evas_Object *obj, Evas_Coord x, Evas_Coord y);
|
|
|
|
static void _scale_win_cb_intercept_resize(void *data, Evas_Object *obj, Evas_Coord x, Evas_Coord y);
|
2011-02-21 07:52:24 -08:00
|
|
|
static void _scale_win_cb_intercept_color(void *data, Evas_Object *obj, int r, int g, int b, int a);
|
|
|
|
static void _scale_win_cb_intercept_layer(void *data, Evas_Object *obj, int l);
|
2010-12-21 03:58:59 -08:00
|
|
|
|
|
|
|
typedef struct _Item Item;
|
|
|
|
|
|
|
|
struct _Item
|
|
|
|
{
|
2011-02-21 07:52:24 -08:00
|
|
|
Evas_Object *o, *o_win;
|
2010-12-21 03:58:59 -08:00
|
|
|
E_Border *bd;
|
|
|
|
E_Comp_Win *cw;
|
2011-02-19 00:34:10 -08:00
|
|
|
double scale;
|
2011-02-21 07:52:24 -08:00
|
|
|
int alpha;
|
2010-12-22 03:23:30 -08:00
|
|
|
|
2011-02-19 00:34:10 -08:00
|
|
|
double x;
|
|
|
|
double y;
|
|
|
|
double w;
|
|
|
|
double h;
|
2010-12-21 03:58:59 -08:00
|
|
|
|
2011-02-19 00:34:10 -08:00
|
|
|
double mx;
|
|
|
|
double my;
|
2011-02-19 16:36:40 -08:00
|
|
|
|
2011-02-21 07:52:24 -08:00
|
|
|
/* border origin (is moved when scale on another desk) */
|
2011-02-19 16:36:40 -08:00
|
|
|
double bd_x;
|
|
|
|
double bd_y;
|
|
|
|
|
2011-02-21 07:52:24 -08:00
|
|
|
/* current position to draw by compositor */
|
2011-02-19 16:36:40 -08:00
|
|
|
int cur_x, cur_y, cur_w, cur_h;
|
2011-02-21 07:52:24 -08:00
|
|
|
|
|
|
|
/* borders' desk distance to the current desk */
|
|
|
|
int dx, dy;
|
|
|
|
|
2011-02-19 16:36:40 -08:00
|
|
|
int overlaps;
|
2010-12-21 03:58:59 -08:00
|
|
|
};
|
|
|
|
|
2011-02-21 07:52:24 -08:00
|
|
|
static Ecore_X_Window input_win = 0;
|
|
|
|
static E_Msg_Handler *msg_handler = NULL;
|
|
|
|
static E_Action *act = NULL;
|
|
|
|
|
2010-12-21 03:58:59 -08:00
|
|
|
static Eina_List *items = NULL;
|
2011-02-19 00:34:10 -08:00
|
|
|
static Eina_List *popups = NULL;
|
2010-12-21 03:58:59 -08:00
|
|
|
static Eina_List *handlers = NULL;
|
2011-02-19 00:34:10 -08:00
|
|
|
static Ecore_Animator *scale_animator = NULL;
|
|
|
|
static Eina_Bool scale_state = EINA_FALSE;
|
|
|
|
static double start_time;
|
2011-02-21 07:52:24 -08:00
|
|
|
static E_Zone *zone = NULL;
|
2010-12-21 03:58:59 -08:00
|
|
|
static int max_x;
|
|
|
|
static int max_y;
|
|
|
|
static int min_x;
|
|
|
|
static int min_y;
|
2011-02-21 07:52:24 -08:00
|
|
|
static int max_width, max_height;
|
2011-02-19 00:34:10 -08:00
|
|
|
static int step_count;
|
2011-02-21 07:52:24 -08:00
|
|
|
static Item *background = NULL;
|
|
|
|
static Item *selected_item = NULL;
|
|
|
|
static E_Desk *current_desk = NULL;
|
|
|
|
static int show_all_desks = EINA_FALSE;
|
|
|
|
static int send_to_desk = EINA_FALSE;
|
2011-02-19 00:34:10 -08:00
|
|
|
|
2010-12-21 03:58:59 -08:00
|
|
|
static int
|
2011-02-21 07:52:24 -08:00
|
|
|
_scale_grow()
|
2010-12-21 03:58:59 -08:00
|
|
|
{
|
|
|
|
Item *it, *ot;
|
|
|
|
Eina_List *l, *ll;
|
|
|
|
|
|
|
|
int cont = 0;
|
2011-02-21 07:52:24 -08:00
|
|
|
int overlap, off;
|
2011-02-19 00:34:10 -08:00
|
|
|
double grow_l, grow_r, grow_d, grow_u;
|
2011-02-21 07:52:24 -08:00
|
|
|
|
|
|
|
if (show_all_desks)
|
|
|
|
off = scale_conf->desks_spacing;
|
|
|
|
else
|
|
|
|
off = scale_conf->spacing;
|
|
|
|
|
|
|
|
/* double mean = 0; */
|
|
|
|
/* EINA_LIST_FOREACH(items, l, it)
|
|
|
|
* mean += it->scale;
|
|
|
|
*
|
|
|
|
* mean /= (double) eina_list_count(items); */
|
2010-12-22 03:23:30 -08:00
|
|
|
|
2010-12-21 03:58:59 -08:00
|
|
|
EINA_LIST_FOREACH(items, l, it)
|
|
|
|
{
|
2011-02-19 00:34:10 -08:00
|
|
|
overlap = 0;
|
|
|
|
|
2011-02-19 16:36:40 -08:00
|
|
|
/* if (it->scale > mean)
|
|
|
|
* continue; */
|
2011-02-19 00:34:10 -08:00
|
|
|
|
2010-12-21 03:58:59 -08:00
|
|
|
if (it->w >= it->bd->w)
|
|
|
|
continue;
|
|
|
|
if (it->h >= it->bd->h)
|
|
|
|
continue;
|
|
|
|
|
2011-02-19 00:34:10 -08:00
|
|
|
if (it->bd->w > it->bd->h)
|
|
|
|
{
|
|
|
|
grow_l = grow_r = GROW;
|
|
|
|
grow_u = grow_d = GROW * (double)it->bd->h/(double)it->bd->w;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
grow_l = grow_r = GROW * (double)it->bd->w/(double)it->bd->h;
|
|
|
|
grow_u = grow_d = GROW;
|
|
|
|
}
|
2010-12-22 03:23:30 -08:00
|
|
|
|
2011-02-19 00:34:10 -08:00
|
|
|
if (it->x - grow_l < min_x)
|
2010-12-21 03:58:59 -08:00
|
|
|
grow_l = 0;
|
2011-02-19 00:34:10 -08:00
|
|
|
if (it->y - grow_u < min_y)
|
2010-12-21 03:58:59 -08:00
|
|
|
grow_u = 0;
|
2011-02-19 00:34:10 -08:00
|
|
|
if (it->x + it->w + grow_r > max_x)
|
2010-12-21 03:58:59 -08:00
|
|
|
grow_r = 0;
|
2011-02-19 00:34:10 -08:00
|
|
|
if (it->y + it->h + grow_d > max_y)
|
2010-12-21 03:58:59 -08:00
|
|
|
grow_d = 0;
|
2010-12-22 03:23:30 -08:00
|
|
|
|
2011-02-19 00:34:10 -08:00
|
|
|
if ((grow_l + grow_r) == 0)
|
2010-12-21 03:58:59 -08:00
|
|
|
continue;
|
2011-02-19 00:34:10 -08:00
|
|
|
if ((grow_u + grow_d) == 0)
|
2010-12-21 03:58:59 -08:00
|
|
|
continue;
|
2010-12-22 03:23:30 -08:00
|
|
|
|
2010-12-21 03:58:59 -08:00
|
|
|
EINA_LIST_FOREACH(items, ll, ot)
|
|
|
|
{
|
|
|
|
if (it == ot)
|
|
|
|
continue;
|
2011-02-21 07:52:24 -08:00
|
|
|
if (grow_l && E_INTERSECTS(it->x - grow_l - off ,it->y,
|
|
|
|
it->w + off*2, it->h + off*2,
|
|
|
|
ot->x, ot->y, ot->w, ot->h))
|
2010-12-21 03:58:59 -08:00
|
|
|
grow_l = 0;
|
|
|
|
|
2011-02-21 07:52:24 -08:00
|
|
|
if (grow_r && E_INTERSECTS(it->x - off, it->y - off,
|
|
|
|
it->w + grow_r + off*2, it->h + off*2,
|
|
|
|
ot->x, ot->y, ot->w, ot->h))
|
2010-12-21 03:58:59 -08:00
|
|
|
grow_r = 0;
|
|
|
|
|
2011-02-19 00:34:10 -08:00
|
|
|
if ((grow_l == 0) && (grow_r == 0) && (overlap = 1))
|
|
|
|
break;
|
|
|
|
|
2011-02-21 07:52:24 -08:00
|
|
|
if (grow_u && E_INTERSECTS(it->x - off, it->y - off - grow_u,
|
|
|
|
it->w + off*2, it->h + off*2,
|
|
|
|
ot->x, ot->y, ot->w, ot->h))
|
2011-02-19 00:34:10 -08:00
|
|
|
grow_u = 0;
|
|
|
|
|
2011-02-21 07:52:24 -08:00
|
|
|
if (grow_d && E_INTERSECTS(it->x - off, it->y - off,
|
|
|
|
it->w + off*2, it->h + grow_d + off*2,
|
|
|
|
ot->x, ot->y, ot->w, ot->h))
|
2010-12-21 03:58:59 -08:00
|
|
|
grow_d = 0;
|
|
|
|
|
2011-02-19 00:34:10 -08:00
|
|
|
if ((grow_u == 0) && (grow_d == 0) && (overlap = 1))
|
|
|
|
break;
|
2010-12-21 03:58:59 -08:00
|
|
|
}
|
|
|
|
|
2011-02-19 00:34:10 -08:00
|
|
|
if (overlap)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (it->bd->w > it->bd->h)
|
2010-12-22 03:23:30 -08:00
|
|
|
{
|
2011-02-21 07:52:24 -08:00
|
|
|
if ((grow_u > 0) && (grow_d > 0))
|
|
|
|
it->w += grow_l + grow_r;
|
|
|
|
else
|
|
|
|
it->w += MAX(grow_l, grow_r);
|
|
|
|
|
2011-02-19 00:34:10 -08:00
|
|
|
it->h = it->w * (double)it->bd->h / (double)it->bd->w;
|
2010-12-21 03:58:59 -08:00
|
|
|
}
|
2011-02-19 00:34:10 -08:00
|
|
|
else
|
|
|
|
{
|
2011-02-21 07:52:24 -08:00
|
|
|
if ((grow_r > 0) && (grow_l > 0))
|
|
|
|
it->h += grow_u + grow_d;
|
|
|
|
else
|
|
|
|
it->h += MAX(grow_u, grow_d);
|
|
|
|
|
2011-02-19 00:34:10 -08:00
|
|
|
it->w = it->h * (double)it->bd->w / (double)it->bd->h;
|
|
|
|
}
|
|
|
|
|
|
|
|
it->x -= grow_l;
|
|
|
|
it->y -= grow_u;
|
|
|
|
|
|
|
|
cont++;
|
2010-12-21 03:58:59 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
return cont;
|
|
|
|
}
|
|
|
|
|
2011-02-21 07:52:24 -08:00
|
|
|
static void
|
|
|
|
_scale_displace(Item *it, Item *ot, int disp)
|
|
|
|
{
|
|
|
|
/* cycle items with same center around to get even distribution.
|
|
|
|
dont try to understand this but these initial conditions
|
|
|
|
are important.. you can have up to 9 maximized windows.
|
|
|
|
if you can figure out more please tell me :) */
|
|
|
|
|
|
|
|
if (disp % 8 == 0)
|
|
|
|
{
|
|
|
|
// 1.
|
|
|
|
it->y -= 1;
|
|
|
|
it->x -= 1;
|
|
|
|
// 2.
|
|
|
|
ot->x += 1;
|
|
|
|
ot->y -= 1;
|
|
|
|
}
|
|
|
|
else if (disp % 8 == 1)
|
|
|
|
{
|
|
|
|
// 3.
|
|
|
|
ot->y += 1;
|
|
|
|
}
|
|
|
|
else if (disp % 8 == 2)
|
|
|
|
{
|
|
|
|
// 4.
|
|
|
|
ot->x -= 2;
|
|
|
|
ot->y += 2;
|
|
|
|
}
|
|
|
|
else if (disp % 8 == 3)
|
|
|
|
{
|
|
|
|
// 5.
|
|
|
|
ot->x += 2;
|
|
|
|
ot->y += 2;
|
|
|
|
}
|
|
|
|
else if (disp % 8 == 4)
|
|
|
|
{
|
|
|
|
// 6.
|
|
|
|
ot->x += 1;
|
|
|
|
ot->y += 1;
|
|
|
|
}
|
|
|
|
else if (disp % 8 == 5)
|
|
|
|
{
|
|
|
|
// 7.
|
|
|
|
ot->x -= 1;
|
|
|
|
ot->y += 1;
|
|
|
|
}
|
|
|
|
else if (disp % 8 == 6)
|
|
|
|
{
|
|
|
|
// 8.
|
|
|
|
ot->x -= 1;
|
|
|
|
ot->y -= 1;
|
|
|
|
}
|
|
|
|
else if (disp % 8 == 7)
|
|
|
|
{
|
|
|
|
ot->x += 1;
|
|
|
|
ot->y -= 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-12-21 03:58:59 -08:00
|
|
|
static int
|
2011-02-21 07:52:24 -08:00
|
|
|
_scale_place(int offset)
|
2010-12-21 03:58:59 -08:00
|
|
|
{
|
|
|
|
Item *it, *ot;
|
|
|
|
Eina_List *l, *ll;
|
|
|
|
int overlap = 0;
|
|
|
|
int outside = 0;
|
|
|
|
|
|
|
|
EINA_LIST_FOREACH(items, l, it)
|
2010-12-22 03:23:30 -08:00
|
|
|
{
|
2010-12-21 03:58:59 -08:00
|
|
|
it->mx = it->x;
|
|
|
|
it->my = it->y;
|
|
|
|
}
|
2010-12-22 03:23:30 -08:00
|
|
|
|
2011-02-19 00:34:10 -08:00
|
|
|
int disp = 0;
|
2011-02-21 07:52:24 -08:00
|
|
|
|
2010-12-21 03:58:59 -08:00
|
|
|
EINA_LIST_FOREACH(items, l, it)
|
2010-12-22 03:23:30 -08:00
|
|
|
{
|
2010-12-22 03:21:50 -08:00
|
|
|
EINA_LIST_FOREACH(items, ll, ot)
|
2010-12-21 03:58:59 -08:00
|
|
|
{
|
|
|
|
int w = it->w;
|
|
|
|
int h = it->h;
|
|
|
|
|
2010-12-22 03:21:50 -08:00
|
|
|
if (it == ot)
|
|
|
|
continue;
|
2010-12-22 03:23:30 -08:00
|
|
|
|
2011-02-21 07:52:24 -08:00
|
|
|
if (!E_INTERSECTS(it->x - offset, it->y - offset,
|
|
|
|
it->w + offset*2, it->h + offset*2,
|
2011-02-19 00:34:10 -08:00
|
|
|
ot->x, ot->y, ot->w, ot->h))
|
2010-12-21 03:58:59 -08:00
|
|
|
continue;
|
|
|
|
|
|
|
|
overlap += 1;
|
|
|
|
|
2011-02-19 16:36:40 -08:00
|
|
|
it->overlaps++;
|
2011-02-21 07:52:24 -08:00
|
|
|
|
2010-12-21 03:58:59 -08:00
|
|
|
if (it->x < ot->x)
|
|
|
|
w += it->x - ot->x;
|
|
|
|
if (w < 0) w = 0;
|
2010-12-22 03:23:30 -08:00
|
|
|
|
2010-12-21 03:58:59 -08:00
|
|
|
if (it->x + it->w > ot->x + ot->w)
|
|
|
|
w = ot->x + ot->w - it->x;
|
|
|
|
|
|
|
|
if (it->y < ot->y)
|
|
|
|
h += it->y - ot->y;
|
|
|
|
if (h < 0) h = 0;
|
2010-12-22 03:23:30 -08:00
|
|
|
|
2010-12-21 03:58:59 -08:00
|
|
|
if (it->y + it->h > ot->y + ot->h)
|
|
|
|
h = ot->y + ot->h - it->y;
|
|
|
|
|
2011-02-19 00:34:10 -08:00
|
|
|
double dist_y = (it->y + it->h/2) - (ot->y + ot->h/2);
|
|
|
|
double dist_x = (it->x + it->w/2) - (ot->x + ot->w/2);
|
2010-12-21 03:58:59 -08:00
|
|
|
|
|
|
|
if (dist_x == 0 && dist_y == 0)
|
|
|
|
{
|
2011-02-21 07:52:24 -08:00
|
|
|
_scale_displace(it, ot, disp);
|
2011-02-19 00:34:10 -08:00
|
|
|
disp++;
|
|
|
|
}
|
|
|
|
else if (w > h)
|
2010-12-21 03:58:59 -08:00
|
|
|
{
|
|
|
|
if (dist_y)
|
|
|
|
{
|
|
|
|
dist_y = (dist_y > 0 ? 2 : -2);
|
|
|
|
it->my += dist_y;
|
|
|
|
}
|
|
|
|
if (dist_x)
|
2010-12-22 03:23:30 -08:00
|
|
|
{
|
2010-12-21 03:58:59 -08:00
|
|
|
dist_x = (dist_x > 0 ? 1 : -1);
|
|
|
|
it->mx += dist_x;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else //if (w < h)
|
|
|
|
{
|
|
|
|
if (dist_y)
|
|
|
|
{
|
|
|
|
dist_y = (dist_y > 0 ? 1 : -1);
|
|
|
|
it->my += dist_y;
|
|
|
|
}
|
|
|
|
if (dist_x)
|
|
|
|
{
|
|
|
|
dist_x = (dist_x > 0 ? 2 : -2);
|
|
|
|
it->mx += dist_x;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-12-22 03:23:30 -08:00
|
|
|
}
|
2010-12-21 03:58:59 -08:00
|
|
|
|
|
|
|
EINA_LIST_FOREACH(items, l, it)
|
2010-12-22 03:23:30 -08:00
|
|
|
{
|
|
|
|
it->x = it->mx;
|
2010-12-21 03:58:59 -08:00
|
|
|
it->y = it->my;
|
2010-12-22 03:23:30 -08:00
|
|
|
|
2011-02-19 00:34:10 -08:00
|
|
|
if (it->x < min_x)
|
2010-12-21 03:58:59 -08:00
|
|
|
{
|
|
|
|
outside = 1;
|
2011-02-19 00:34:10 -08:00
|
|
|
it->x = min_x;
|
2010-12-21 03:58:59 -08:00
|
|
|
}
|
2010-12-22 03:23:30 -08:00
|
|
|
|
2010-12-21 03:58:59 -08:00
|
|
|
if (it->y < min_y)
|
|
|
|
{
|
|
|
|
outside = 1;
|
|
|
|
it->y = min_y;
|
|
|
|
}
|
2010-12-22 03:23:30 -08:00
|
|
|
|
2010-12-21 03:58:59 -08:00
|
|
|
if (it->x + it->w > max_x)
|
|
|
|
{
|
|
|
|
outside = 1;
|
|
|
|
it->x = max_x - it->w;
|
|
|
|
}
|
2010-12-22 03:23:30 -08:00
|
|
|
|
2010-12-21 03:58:59 -08:00
|
|
|
if (it->y + it->h > max_y)
|
|
|
|
{
|
|
|
|
outside = 1;
|
|
|
|
it->y = max_y - it->h;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-02-21 07:52:24 -08:00
|
|
|
if (!(overlap || outside))
|
|
|
|
return 0;
|
|
|
|
|
2011-02-19 00:34:10 -08:00
|
|
|
if (outside && (step_count++ > 50))
|
|
|
|
{
|
2011-02-21 07:52:24 -08:00
|
|
|
double zone_diag = sqrt(zone->w * zone->h);
|
2011-02-19 00:34:10 -08:00
|
|
|
double sw, sh;
|
|
|
|
step_count = 0;
|
|
|
|
EINA_LIST_FOREACH(items, l, it)
|
|
|
|
{
|
2011-02-19 16:36:40 -08:00
|
|
|
if (!it->overlaps)
|
|
|
|
continue;
|
2011-02-21 07:52:24 -08:00
|
|
|
|
2011-02-19 00:34:10 -08:00
|
|
|
if (it->scale <= 0.005)
|
|
|
|
continue;
|
|
|
|
|
2011-02-21 07:52:24 -08:00
|
|
|
it->scale -= it->scale *
|
|
|
|
(0.001 + (sqrt(it->bd->w * it->bd->h) / zone_diag) / 50.0);
|
|
|
|
|
2011-02-19 00:34:10 -08:00
|
|
|
sw = (double)it->bd->w * it->scale;
|
|
|
|
sh = (double)it->bd->h * it->scale;
|
|
|
|
it->x += (it->w - sw)/2.0;
|
|
|
|
it->y += (it->h - sh)/2.0;
|
|
|
|
it->w = sw;
|
|
|
|
it->h = sh;
|
2011-02-19 16:36:40 -08:00
|
|
|
|
|
|
|
it->overlaps = 0;
|
2011-02-19 00:34:10 -08:00
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return overlap || outside;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2011-02-21 07:52:24 -08:00
|
|
|
_scale_shrink()
|
2011-02-19 00:34:10 -08:00
|
|
|
{
|
|
|
|
Eina_List *l, *ll;
|
|
|
|
Item *it, *ot;
|
2011-02-21 07:52:24 -08:00
|
|
|
int shrunk = 0;
|
|
|
|
int off;
|
2011-02-21 11:15:49 -08:00
|
|
|
double move_x;
|
|
|
|
double move_y;
|
|
|
|
|
|
|
|
int min_x = zone->w;
|
|
|
|
int min_y = zone->h;
|
|
|
|
int max_x = 0;
|
|
|
|
int max_y = 0;
|
2010-12-22 03:23:30 -08:00
|
|
|
|
2011-02-21 07:52:24 -08:00
|
|
|
if (show_all_desks)
|
2011-02-21 11:15:49 -08:00
|
|
|
{
|
|
|
|
|
|
|
|
off = scale_conf->desks_spacing;
|
|
|
|
|
|
|
|
EINA_LIST_FOREACH(items, l, it)
|
|
|
|
{
|
|
|
|
if (it->x < min_x) min_x = it->x;
|
|
|
|
if (it->y < min_y) min_y = it->y;
|
|
|
|
if (it->x + it->w > max_x) max_x = it->x + it->w;
|
|
|
|
if (it->y + it->h > max_y) max_y = it->y + it->h;
|
|
|
|
}
|
|
|
|
}
|
2011-02-21 07:52:24 -08:00
|
|
|
else
|
|
|
|
off = scale_conf->spacing;
|
2011-02-19 00:34:10 -08:00
|
|
|
|
2011-02-21 11:15:49 -08:00
|
|
|
|
2011-02-19 00:34:10 -08:00
|
|
|
EINA_LIST_REVERSE_FOREACH(items, l, it)
|
|
|
|
{
|
2011-02-21 11:15:49 -08:00
|
|
|
if (show_all_desks)
|
|
|
|
{
|
|
|
|
move_x = ((it->x + it->w/2.0) - (min_x + (max_x - min_x)/2)) / 50.0;
|
|
|
|
move_y = ((it->y + it->h/2.0) - (min_y + (max_y - min_x)/2)) / 50.0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
move_x = ((it->x + it->w/2.0) - (double)(it->bd->x + it->bd->w/2.0)) / 10.0;
|
|
|
|
move_y = ((it->y + it->h/2.0) - (double)(it->bd->y + it->bd->h/2.0)) / 10.0;
|
|
|
|
}
|
|
|
|
|
2011-02-19 00:34:10 -08:00
|
|
|
if (!(move_y || move_x))
|
|
|
|
continue;
|
2011-02-21 07:52:24 -08:00
|
|
|
|
2011-02-19 00:34:10 -08:00
|
|
|
EINA_LIST_FOREACH(items, ll, ot)
|
|
|
|
{
|
|
|
|
if (it == ot) continue;
|
|
|
|
|
|
|
|
while(move_x)
|
2010-12-21 03:58:59 -08:00
|
|
|
{
|
2011-02-19 00:34:10 -08:00
|
|
|
if (E_INTERSECTS(it->x - move_x, it->y, it->w, it->h,
|
2011-02-19 16:36:40 -08:00
|
|
|
ot->x - off, ot->y - off, ot->w + off*2, ot->h + off*2))
|
2011-02-19 00:34:10 -08:00
|
|
|
move_x = move_x / 2.0;
|
|
|
|
else break;
|
2011-02-21 07:52:24 -08:00
|
|
|
}
|
2011-02-19 00:34:10 -08:00
|
|
|
|
|
|
|
while(move_y)
|
|
|
|
{
|
|
|
|
if (E_INTERSECTS(it->x, it->y - move_y, it->w, it->h,
|
2011-02-19 16:36:40 -08:00
|
|
|
ot->x - off, ot->y - off, ot->w + off*2, ot->h + off*2))
|
2011-02-19 00:34:10 -08:00
|
|
|
move_y = move_y / 2.0;
|
|
|
|
else break;
|
2010-12-21 03:58:59 -08:00
|
|
|
}
|
2011-02-21 07:52:24 -08:00
|
|
|
|
2011-02-19 00:34:10 -08:00
|
|
|
if (!(move_y || move_x)) break;
|
2010-12-21 03:58:59 -08:00
|
|
|
}
|
2011-02-21 07:52:24 -08:00
|
|
|
|
2011-02-19 00:34:10 -08:00
|
|
|
it->x -= move_x;
|
|
|
|
it->y -= move_y;
|
2010-12-22 03:23:30 -08:00
|
|
|
|
2011-02-19 00:34:10 -08:00
|
|
|
if (move_y || move_x)
|
|
|
|
shrunk = 1;
|
2010-12-21 03:58:59 -08:00
|
|
|
}
|
|
|
|
|
2011-02-19 00:34:10 -08:00
|
|
|
return shrunk;
|
2010-12-21 03:58:59 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
2011-02-21 07:52:24 -08:00
|
|
|
_scale_redraw(void *blah)
|
2010-12-21 03:58:59 -08:00
|
|
|
{
|
|
|
|
Eina_List *l;
|
|
|
|
Item *it;
|
2011-02-21 07:52:24 -08:00
|
|
|
double scale, a, in, duration;
|
|
|
|
|
|
|
|
if (show_all_desks)
|
|
|
|
duration = scale_conf->desks_duration;
|
|
|
|
else
|
|
|
|
duration = scale_conf->scale_duration;
|
|
|
|
|
2011-02-19 00:34:10 -08:00
|
|
|
if (scale_state)
|
2011-02-21 07:52:24 -08:00
|
|
|
scale = (ecore_time_get() - start_time) / duration;
|
2011-02-19 00:34:10 -08:00
|
|
|
else
|
2011-02-21 07:52:24 -08:00
|
|
|
scale = 1.0 - (ecore_time_get() - start_time) / duration;
|
2010-12-21 03:58:59 -08:00
|
|
|
|
2011-02-19 00:34:10 -08:00
|
|
|
if (scale > 1.0) scale = 1.0;
|
|
|
|
if (scale < 0.0) scale = 0.0;
|
2010-12-21 03:58:59 -08:00
|
|
|
|
2011-02-21 07:52:24 -08:00
|
|
|
/* in = cos(scale * M_PI_2); */
|
2010-12-22 03:23:30 -08:00
|
|
|
|
2011-02-21 07:52:24 -08:00
|
|
|
in = log(10) * scale;
|
|
|
|
in = 1.0 / exp(in*in);
|
2010-12-22 03:23:30 -08:00
|
|
|
|
2011-02-21 07:52:24 -08:00
|
|
|
EINA_LIST_FOREACH(items, l, it)
|
|
|
|
{
|
|
|
|
it->cur_w = it->bd->w * in + it->w * (1.0 - in);
|
|
|
|
it->cur_h = it->bd->h * in + it->h * (1.0 - in);
|
|
|
|
it->cur_x = it->bd_x * in + it->x * (1.0 - in);
|
|
|
|
it->cur_y = it->bd_y * in + it->y * (1.0 - in);
|
2011-02-19 00:34:10 -08:00
|
|
|
|
2011-02-19 16:36:40 -08:00
|
|
|
evas_object_move(it->o, it->cur_x, it->cur_y);
|
|
|
|
evas_object_resize(it->o, it->cur_w, it->cur_h);
|
2011-02-21 07:52:24 -08:00
|
|
|
|
|
|
|
evas_object_move(it->o_win, it->cur_x, it->cur_y);
|
|
|
|
evas_object_resize(it->o_win, it->cur_w, it->cur_h);
|
|
|
|
|
|
|
|
a = 255.0 * (1.0 - in);
|
|
|
|
evas_object_color_set(it->o, a, a, a, a);
|
|
|
|
|
|
|
|
if (!scale_conf->fade_windows)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if ((it->bd->desk != current_desk) && (selected_item != it))
|
|
|
|
{
|
|
|
|
double ax = it->cur_x - it->x;
|
|
|
|
double ay = it->cur_y - it->y;
|
|
|
|
double bx = it->bd_x - it->x;
|
|
|
|
double by = it->bd_y - it->y;
|
|
|
|
|
|
|
|
a = (1.0 - sqrt(ax*ax + ay*ay) / sqrt(bx*bx + by*by)) * 255;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
a = 255.0;
|
|
|
|
}
|
|
|
|
|
|
|
|
it->alpha = a;
|
|
|
|
evas_object_color_set(it->o_win, a, a, a, a);
|
2010-12-21 03:58:59 -08:00
|
|
|
}
|
2010-12-22 03:23:30 -08:00
|
|
|
|
2011-02-21 07:52:24 -08:00
|
|
|
if (scale_conf->fade_popups)
|
|
|
|
{
|
|
|
|
a = 255.0 * in;
|
|
|
|
|
|
|
|
EINA_LIST_FOREACH(popups, l, it)
|
|
|
|
evas_object_color_set(it->o_win, a, a, a, a);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (scale_conf->fade_desktop && background)
|
|
|
|
{
|
|
|
|
a = 255.0 * (0.5 + in/2.0);
|
|
|
|
|
|
|
|
evas_object_color_set(background->o_win, a, a, a, 255);
|
|
|
|
}
|
|
|
|
|
|
|
|
e_manager_comp_evas_update(e_manager_current_get());
|
2010-12-22 03:23:30 -08:00
|
|
|
|
2011-02-19 00:34:10 -08:00
|
|
|
if (scale < 1.0 && scale > 0.0)
|
2010-12-21 03:58:59 -08:00
|
|
|
return 1;
|
|
|
|
|
2011-02-19 00:34:10 -08:00
|
|
|
if (scale == 0.0)
|
2011-02-19 16:36:40 -08:00
|
|
|
_scale_finish();
|
2010-12-22 03:23:30 -08:00
|
|
|
|
2011-02-19 00:34:10 -08:00
|
|
|
scale_animator = NULL;
|
2010-12-21 03:58:59 -08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-02-19 00:34:10 -08:00
|
|
|
static void
|
|
|
|
_scale_in()
|
|
|
|
{
|
|
|
|
start_time = ecore_time_get();
|
|
|
|
scale_state = EINA_TRUE;
|
2011-02-21 07:52:24 -08:00
|
|
|
|
2011-02-19 00:34:10 -08:00
|
|
|
if (!scale_animator)
|
2011-02-21 07:52:24 -08:00
|
|
|
scale_animator = ecore_animator_add(_scale_redraw, NULL);
|
2011-02-19 00:34:10 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_scale_out()
|
|
|
|
{
|
2011-02-21 07:52:24 -08:00
|
|
|
double duration, now = ecore_time_get();
|
|
|
|
|
|
|
|
if (show_all_desks)
|
|
|
|
duration = scale_conf->desks_duration;
|
|
|
|
else
|
|
|
|
duration = scale_conf->scale_duration;
|
|
|
|
|
|
|
|
if (now - start_time < duration)
|
|
|
|
start_time = now - (duration - (now - start_time));
|
2011-02-19 00:34:10 -08:00
|
|
|
else
|
|
|
|
start_time = now;
|
|
|
|
|
|
|
|
if (!scale_animator)
|
2011-02-21 07:52:24 -08:00
|
|
|
scale_animator = ecore_animator_add(_scale_redraw, NULL);
|
2011-02-19 00:34:10 -08:00
|
|
|
|
|
|
|
scale_state = EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
2010-12-21 03:58:59 -08:00
|
|
|
static void
|
2011-02-19 16:36:40 -08:00
|
|
|
_scale_finish()
|
|
|
|
{
|
|
|
|
Ecore_Event_Handler *handler;
|
|
|
|
Item *it;
|
2011-02-21 07:52:24 -08:00
|
|
|
E_Desk *desk;
|
|
|
|
|
2011-02-19 16:36:40 -08:00
|
|
|
e_grabinput_release(input_win, input_win);
|
|
|
|
ecore_x_window_free(input_win);
|
|
|
|
input_win = 0;
|
|
|
|
|
2011-02-21 07:52:24 -08:00
|
|
|
desk = e_desk_current_get(zone);
|
|
|
|
|
|
|
|
if (selected_item && selected_item->bd->desk != desk)
|
|
|
|
{
|
|
|
|
if (send_to_desk)
|
|
|
|
{
|
|
|
|
e_border_desk_set(selected_item->bd, desk);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
int tmp = e_config->desk_flip_animate_mode;
|
|
|
|
|
|
|
|
desk = selected_item->bd->desk;
|
|
|
|
|
|
|
|
e_config->desk_flip_animate_mode = 0;
|
|
|
|
e_desk_show(desk);
|
|
|
|
e_config->desk_flip_animate_mode = tmp;
|
|
|
|
}
|
|
|
|
}
|
2011-02-19 16:36:40 -08:00
|
|
|
|
|
|
|
EINA_LIST_FREE(items, it)
|
|
|
|
{
|
2011-02-21 07:52:24 -08:00
|
|
|
evas_object_event_callback_del(it->o_win, EVAS_CALLBACK_DEL, _scale_win_delorig);
|
|
|
|
evas_object_intercept_move_callback_del(it->o_win, _scale_win_cb_intercept_move);
|
|
|
|
evas_object_intercept_resize_callback_del(it->o_win, _scale_win_cb_intercept_resize);
|
|
|
|
evas_object_intercept_color_set_callback_del(it->o_win, _scale_win_cb_intercept_color);
|
|
|
|
evas_object_intercept_layer_set_callback_del(it->o_win, _scale_win_cb_intercept_layer);
|
2011-02-19 16:36:40 -08:00
|
|
|
|
2011-02-21 07:52:24 -08:00
|
|
|
/* evas_object_clip_unset(it->o_win); */
|
|
|
|
/* edje_object_part_unswallow(it->o, it->o_win); */
|
|
|
|
evas_object_del(it->o);
|
2011-02-19 16:36:40 -08:00
|
|
|
|
2011-02-21 07:52:24 -08:00
|
|
|
if (it->bd->desk != desk)
|
|
|
|
{
|
|
|
|
e_border_hide(it->bd, 2);
|
|
|
|
evas_object_hide(it->o_win);
|
|
|
|
evas_object_color_set(it->o_win, 255, 255, 255, 255);
|
|
|
|
evas_object_move(it->o_win, it->bd->x, it->bd->y);
|
|
|
|
evas_object_resize(it->o_win, it->cw->w, it->cw->h);
|
|
|
|
}
|
2011-02-19 16:36:40 -08:00
|
|
|
|
2011-02-21 07:52:24 -08:00
|
|
|
e_object_unref(E_OBJECT(it->bd));
|
2011-02-19 16:36:40 -08:00
|
|
|
E_FREE(it);
|
|
|
|
}
|
|
|
|
|
|
|
|
EINA_LIST_FREE(popups, it)
|
|
|
|
{
|
2011-02-21 07:52:24 -08:00
|
|
|
evas_object_event_callback_del(it->o_win, EVAS_CALLBACK_DEL, _scale_win_delorig);
|
|
|
|
evas_object_color_set(it->o_win, 255, 255, 255, 255);
|
|
|
|
E_FREE(it);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (scale_conf->fade_desktop && background)
|
|
|
|
{
|
|
|
|
it = background;
|
|
|
|
evas_object_event_callback_del(it->o_win, EVAS_CALLBACK_DEL, _scale_win_delorig);
|
|
|
|
evas_object_color_set(it->o_win, 255, 255, 255, 255);
|
2011-02-19 16:36:40 -08:00
|
|
|
E_FREE(it);
|
|
|
|
}
|
|
|
|
|
|
|
|
EINA_LIST_FREE(handlers, handler)
|
|
|
|
ecore_event_handler_del(handler);
|
|
|
|
|
|
|
|
e_msg_handler_del(msg_handler);
|
|
|
|
msg_handler = NULL;
|
2011-02-21 07:52:24 -08:00
|
|
|
zone = NULL;
|
|
|
|
selected_item = NULL;
|
|
|
|
current_desk = NULL;
|
|
|
|
send_to_desk = EINA_FALSE;
|
|
|
|
show_all_desks = EINA_FALSE;
|
2011-02-19 16:36:40 -08:00
|
|
|
|
|
|
|
e_manager_comp_evas_update(e_manager_current_get());
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_scale_win_delorig(void *data, Evas *e, Evas_Object *obj, void *event_info)
|
2010-12-21 03:58:59 -08:00
|
|
|
{
|
|
|
|
Item *it = data;
|
|
|
|
|
2011-02-21 07:52:24 -08:00
|
|
|
evas_object_event_callback_del(it->o_win, EVAS_CALLBACK_DEL, _scale_win_delorig);
|
2010-12-22 03:23:30 -08:00
|
|
|
|
2011-02-21 07:52:24 -08:00
|
|
|
if (it->bd)
|
|
|
|
{
|
|
|
|
e_object_unref(E_OBJECT(it->bd));
|
|
|
|
_scale_out();
|
2011-02-19 16:36:40 -08:00
|
|
|
|
2011-02-21 07:52:24 -08:00
|
|
|
evas_object_intercept_move_callback_del(it->o_win, _scale_win_cb_intercept_move);
|
|
|
|
evas_object_intercept_resize_callback_del(it->o_win, _scale_win_cb_intercept_resize);
|
|
|
|
evas_object_intercept_color_set_callback_del(it->o_win, _scale_win_cb_intercept_color);
|
|
|
|
evas_object_intercept_layer_set_callback_del(it->o_win, _scale_win_cb_intercept_layer);
|
|
|
|
|
|
|
|
/* evas_object_clip_unset(it->o_win); */
|
|
|
|
/* edje_object_part_unswallow(it->o, it->o_win); */
|
|
|
|
evas_object_del(it->o);
|
|
|
|
|
|
|
|
items = eina_list_remove(items, it);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
popups = eina_list_remove(popups, it);
|
|
|
|
}
|
2011-02-19 16:36:40 -08:00
|
|
|
|
2010-12-21 03:58:59 -08:00
|
|
|
E_FREE(it);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2011-02-19 16:36:40 -08:00
|
|
|
_scale_win_cb_intercept_move(void *data, Evas_Object *obj, Evas_Coord x, Evas_Coord y)
|
2010-12-21 03:58:59 -08:00
|
|
|
{
|
2011-02-19 00:34:10 -08:00
|
|
|
Item *it = data;
|
2011-02-19 16:36:40 -08:00
|
|
|
|
|
|
|
evas_object_move(obj, it->cur_x, it->cur_y);
|
2010-12-21 03:58:59 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2011-02-19 16:36:40 -08:00
|
|
|
_scale_win_cb_intercept_resize(void *data, Evas_Object *obj, Evas_Coord w, Evas_Coord h)
|
2010-12-21 03:58:59 -08:00
|
|
|
{
|
|
|
|
Item *it = data;
|
2010-12-22 03:23:30 -08:00
|
|
|
|
2011-02-19 16:36:40 -08:00
|
|
|
evas_object_resize(obj, it->cur_w, it->cur_h);
|
2011-02-21 07:52:24 -08:00
|
|
|
}
|
2010-12-21 03:58:59 -08:00
|
|
|
|
2011-02-21 07:52:24 -08:00
|
|
|
static void
|
|
|
|
_scale_win_cb_intercept_color(void *data, Evas_Object *obj, int r, int g, int b, int a)
|
|
|
|
{
|
|
|
|
Item *it = data;
|
|
|
|
|
|
|
|
evas_object_color_set(obj, it->alpha, it->alpha, it->alpha, it->alpha);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_scale_win_cb_intercept_layer(void *data, Evas_Object *obj, int l)
|
|
|
|
{
|
|
|
|
Item *it = data;
|
|
|
|
|
|
|
|
evas_object_layer_set(it->o_win, l);
|
|
|
|
evas_object_stack_above(it->o, it->o_win);
|
2010-12-21 03:58:59 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2011-02-19 16:36:40 -08:00
|
|
|
_scale_win_new(Evas *e, E_Manager *man, E_Manager_Comp_Source *src, E_Desk *desk)
|
2010-12-21 03:58:59 -08:00
|
|
|
{
|
|
|
|
Item *it;
|
2010-12-22 03:23:30 -08:00
|
|
|
|
2010-12-21 03:58:59 -08:00
|
|
|
if (!e_manager_comp_src_image_get(man, src)) return;
|
|
|
|
|
|
|
|
E_Comp_Win *cw = (void*)src;
|
|
|
|
|
2011-02-21 07:52:24 -08:00
|
|
|
if (!cw->bd)
|
2011-02-19 00:34:10 -08:00
|
|
|
{
|
2011-02-21 07:52:24 -08:00
|
|
|
if (cw->win == zone->container->bg_win)
|
|
|
|
{
|
|
|
|
if (scale_conf->fade_desktop)
|
|
|
|
{
|
|
|
|
it = E_NEW(Item, 1);
|
|
|
|
it->o_win = e_manager_comp_src_shadow_get(man, src);
|
|
|
|
evas_object_event_callback_add(it->o_win, EVAS_CALLBACK_DEL, _scale_win_delorig, it);
|
|
|
|
background = it;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (scale_conf->fade_popups)
|
|
|
|
{
|
|
|
|
it = E_NEW(Item, 1);
|
|
|
|
it->o_win = e_manager_comp_src_shadow_get(man, src);
|
|
|
|
evas_object_event_callback_add(it->o_win, EVAS_CALLBACK_DEL, _scale_win_delorig, it);
|
|
|
|
|
|
|
|
popups = eina_list_append(popups, it);
|
|
|
|
}
|
2011-02-19 00:34:10 -08:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
2011-02-21 07:52:24 -08:00
|
|
|
|
2011-02-19 00:34:10 -08:00
|
|
|
if (!cw->bd) return;
|
2011-02-21 07:52:24 -08:00
|
|
|
|
|
|
|
if (cw->bd->zone != desk->zone)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if ((!show_all_desks) && (cw->bd->desk != desk))
|
2010-12-21 03:58:59 -08:00
|
|
|
return;
|
|
|
|
|
2010-12-22 03:21:50 -08:00
|
|
|
if (cw->bd->iconic)
|
|
|
|
return;
|
|
|
|
|
2010-12-21 03:58:59 -08:00
|
|
|
it = E_NEW(Item, 1);
|
2011-02-19 00:34:10 -08:00
|
|
|
it->scale = 1.0;
|
2011-02-19 16:36:40 -08:00
|
|
|
|
2011-02-21 07:52:24 -08:00
|
|
|
it->dx = cw->bd->desk->x - desk->x;
|
|
|
|
it->dy = cw->bd->desk->y - desk->y;
|
2011-02-19 16:36:40 -08:00
|
|
|
|
2011-02-21 07:52:24 -08:00
|
|
|
it->x = cw->bd->x + it->dx * desk->zone->w;
|
|
|
|
it->y = cw->bd->y + it->dy * desk->zone->h;
|
2010-12-21 03:58:59 -08:00
|
|
|
it->w = cw->bd->w;
|
|
|
|
it->h = cw->bd->h;
|
2011-02-19 16:36:40 -08:00
|
|
|
|
2011-02-21 07:52:24 -08:00
|
|
|
it->bd_x = it->x;
|
|
|
|
it->bd_y = it->y;
|
|
|
|
|
2011-02-19 16:36:40 -08:00
|
|
|
it->cur_x = it->x;
|
|
|
|
it->cur_y = it->y;
|
|
|
|
it->cur_w = it->w;
|
|
|
|
it->cur_h = it->h;
|
|
|
|
|
2011-02-21 07:52:24 -08:00
|
|
|
e_object_ref(E_OBJECT(cw->bd));
|
2010-12-21 03:58:59 -08:00
|
|
|
it->bd = cw->bd;
|
|
|
|
it->cw = cw;
|
|
|
|
|
2011-02-21 07:52:24 -08:00
|
|
|
it->o_win = e_manager_comp_src_shadow_get(man, src);
|
|
|
|
it->o = edje_object_add(e);
|
|
|
|
if (!e_theme_edje_object_set(it->o, "base/theme/modules/scale",
|
|
|
|
"modules/scale/win"))
|
|
|
|
edje_object_file_set(it->o, scale_conf->theme_path, "modules/scale/win");
|
|
|
|
|
|
|
|
evas_object_stack_above(it->o, it->o_win);
|
|
|
|
/* edje_object_part_swallow(it->o, "e.swallow.win", it->o_win); */
|
|
|
|
/* evas_object_clip_set(it->o_win, it->o);
|
|
|
|
* evas_object_move(it->o, it->x, it->y); */
|
|
|
|
|
|
|
|
evas_object_show(it->o);
|
|
|
|
|
|
|
|
evas_object_event_callback_add(it->o_win, EVAS_CALLBACK_DEL, _scale_win_delorig, it);
|
|
|
|
|
|
|
|
evas_object_intercept_move_callback_add(it->o_win, _scale_win_cb_intercept_move, it);
|
|
|
|
evas_object_intercept_resize_callback_add(it->o_win, _scale_win_cb_intercept_resize, it);
|
|
|
|
evas_object_intercept_color_set_callback_add(it->o_win, _scale_win_cb_intercept_color, it);
|
|
|
|
evas_object_intercept_layer_set_callback_add(it->o_win, _scale_win_cb_intercept_layer, it);
|
2010-12-22 03:23:30 -08:00
|
|
|
|
2011-02-19 16:36:40 -08:00
|
|
|
if (it->bd->desk != desk)
|
|
|
|
{
|
|
|
|
e_border_show(it->bd);
|
2011-02-21 07:52:24 -08:00
|
|
|
evas_object_move(it->o_win, it->x, it->y);
|
2011-02-19 16:36:40 -08:00
|
|
|
}
|
2010-12-22 03:23:30 -08:00
|
|
|
|
2010-12-21 03:58:59 -08:00
|
|
|
items = eina_list_append(items, it);
|
|
|
|
}
|
|
|
|
|
2011-02-19 16:36:40 -08:00
|
|
|
static int
|
|
|
|
_cb_sort_center(const void *d1, const void *d2)
|
2010-12-21 03:58:59 -08:00
|
|
|
{
|
2011-02-19 16:36:40 -08:00
|
|
|
const Item *it1 = d1;
|
|
|
|
const Item *it2 = d2;
|
2011-02-19 00:34:10 -08:00
|
|
|
|
2011-02-21 07:52:24 -08:00
|
|
|
double dx1 = ((it1->bd_x + it1->w/2.0) - (double)(max_width/2));
|
|
|
|
double dy1 = ((it1->bd_y + it1->h/2.0) - (double)(max_height/2));
|
|
|
|
|
|
|
|
double dx2 = ((it2->bd_x + it2->w/2.0) - (double)(max_width/2));
|
|
|
|
double dy2 = ((it2->bd_y + it2->h/2.0) - (double)(max_height/2));
|
2010-12-22 03:23:30 -08:00
|
|
|
|
2011-02-19 16:36:40 -08:00
|
|
|
return (sqrt(dx1*dx1 + dy1*dy1) < sqrt(dx2*dx2 + dy2*dy2)) ? -1 : 1;
|
2010-12-21 03:58:59 -08:00
|
|
|
}
|
|
|
|
|
2011-02-19 16:36:40 -08:00
|
|
|
void
|
|
|
|
scale_run(E_Manager *man)
|
2010-12-21 03:58:59 -08:00
|
|
|
{
|
2011-02-21 07:52:24 -08:00
|
|
|
Eina_List *l;
|
2010-12-21 03:58:59 -08:00
|
|
|
E_Manager_Comp_Source *src;
|
|
|
|
Evas *e;
|
2011-02-21 07:52:24 -08:00
|
|
|
int i, spacing, use_x, use_y, use_w, use_h;
|
2010-12-21 03:58:59 -08:00
|
|
|
|
2011-02-21 07:52:24 -08:00
|
|
|
zone = e_util_zone_current_get(e_manager_current_get());
|
|
|
|
current_desk = e_desk_current_get(zone);
|
|
|
|
Item *it;
|
|
|
|
|
|
|
|
start_time = ecore_time_get();
|
2010-12-22 03:23:30 -08:00
|
|
|
|
2010-12-21 03:58:59 -08:00
|
|
|
input_win = ecore_x_window_input_new(zone->container->win, 0, 0, 1, 1);
|
|
|
|
ecore_x_window_show(input_win);
|
|
|
|
if (!e_grabinput_get(input_win, 0, input_win))
|
|
|
|
{
|
|
|
|
ecore_x_window_free(input_win);
|
2010-12-22 03:23:30 -08:00
|
|
|
input_win = 0;
|
2010-12-21 03:58:59 -08:00
|
|
|
return;
|
|
|
|
}
|
2010-12-22 03:23:30 -08:00
|
|
|
|
2010-12-21 03:58:59 -08:00
|
|
|
handlers = eina_list_append
|
|
|
|
(handlers, ecore_event_handler_add
|
2011-02-19 16:36:40 -08:00
|
|
|
(ECORE_EVENT_MOUSE_BUTTON_DOWN, _scale_cb_mouse_down, NULL));
|
2010-12-21 03:58:59 -08:00
|
|
|
|
2011-02-21 07:52:24 -08:00
|
|
|
handlers = eina_list_append
|
|
|
|
(handlers, ecore_event_handler_add
|
|
|
|
(ECORE_EVENT_MOUSE_MOVE, _scale_cb_mouse_move, NULL));
|
|
|
|
|
2010-12-21 03:58:59 -08:00
|
|
|
e = e_manager_comp_evas_get(man);
|
2011-02-19 00:34:10 -08:00
|
|
|
|
2011-02-21 07:52:24 -08:00
|
|
|
if (show_all_desks)
|
|
|
|
spacing = scale_conf->desks_spacing;
|
|
|
|
else
|
|
|
|
spacing = scale_conf->spacing;
|
|
|
|
|
|
|
|
EINA_LIST_FOREACH((Eina_List *)e_manager_comp_src_list(man), l, src)
|
|
|
|
{
|
|
|
|
_scale_win_new(e, man, src, current_desk);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((eina_list_count(items) < 2) && (!show_all_desks))
|
|
|
|
{
|
|
|
|
_scale_finish();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (!scale_conf->fade_popups)
|
|
|
|
{
|
|
|
|
e_zone_useful_geometry_get(zone, &use_x, &use_y, &use_w, &use_h);
|
|
|
|
use_x += spacing;
|
|
|
|
use_y += spacing;
|
|
|
|
use_w += use_x - spacing*2;
|
|
|
|
use_h += use_y - spacing*2;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
use_x = use_y = spacing;
|
|
|
|
use_w = zone->w - spacing*2;
|
|
|
|
use_h = zone->h - spacing*2;
|
|
|
|
}
|
|
|
|
|
|
|
|
max_width = zone->w;
|
|
|
|
max_height = zone->h;
|
2011-02-19 00:34:10 -08:00
|
|
|
|
2011-02-21 07:52:24 -08:00
|
|
|
if (show_all_desks)
|
|
|
|
{
|
|
|
|
max_width = zone->h * zone->desk_x_count;
|
|
|
|
max_height = zone->w * zone->desk_y_count;
|
|
|
|
}
|
2010-12-21 03:58:59 -08:00
|
|
|
|
2011-02-21 07:52:24 -08:00
|
|
|
min_x = -zone->w * zone->desk_x_current;
|
|
|
|
min_y = -zone->h * zone->desk_y_current;
|
|
|
|
max_x = zone->w + zone->w * ((zone->desk_x_count - 1) - zone->desk_x_current);
|
|
|
|
max_y = zone->h + zone->h * ((zone->desk_y_count - 1) - zone->desk_y_current);
|
|
|
|
|
|
|
|
items = eina_list_sort(items, eina_list_count(items), _cb_sort_center);
|
2011-02-19 16:36:40 -08:00
|
|
|
|
2011-02-19 00:34:10 -08:00
|
|
|
step_count = 0;
|
2011-02-19 16:36:40 -08:00
|
|
|
i = 0;
|
|
|
|
|
2011-02-21 07:52:24 -08:00
|
|
|
if (scale_conf->grow && (spacing < SPACING))
|
|
|
|
spacing = SPACING;
|
|
|
|
if (scale_conf->tight && (spacing < SPACING))
|
|
|
|
spacing = SPACING;
|
|
|
|
|
|
|
|
while ((i++ < PLACE_RUNS) &&
|
|
|
|
(_scale_place(spacing) ||
|
|
|
|
(min_x < use_x) ||
|
|
|
|
(min_y < use_y) ||
|
|
|
|
(max_x > use_w) ||
|
|
|
|
(max_y > use_h)))
|
|
|
|
{
|
|
|
|
/* shrink region to visible region */
|
|
|
|
if (min_x < use_x) min_x += 2;
|
|
|
|
if (min_y < use_y) min_y += 2;
|
|
|
|
if (min_x > use_x) min_x = use_x;
|
|
|
|
if (min_y > use_y) min_y = use_y;
|
|
|
|
|
|
|
|
if (max_x > use_w) max_x -= 2;
|
|
|
|
if (max_y > use_h) max_y -= 2;
|
|
|
|
if (max_x < use_w) max_x = use_w;
|
|
|
|
if (max_y < use_h) max_y = use_h;
|
|
|
|
|
|
|
|
if (!show_all_desks)
|
|
|
|
continue;
|
2011-02-19 16:36:40 -08:00
|
|
|
|
2011-02-21 07:52:24 -08:00
|
|
|
/* move other desks windows into visible region */
|
|
|
|
EINA_LIST_FOREACH(items, l, it)
|
|
|
|
{
|
|
|
|
if ((min_x < use_x) && (it->dx < 0) && it->x < 0) it->x += 4.0;
|
|
|
|
if ((min_y < use_y) && (it->dy < 0) && it->y < 0) it->y += 4.0;
|
2010-12-21 03:58:59 -08:00
|
|
|
|
2011-02-21 07:52:24 -08:00
|
|
|
if ((max_x > use_w) && (it->dx > 0) && it->x > zone->w) it->x -= 4.0;
|
|
|
|
if ((max_y > use_h) && (it->dy > 0) && it->y > zone->h) it->y -= 4.0;
|
|
|
|
}
|
2010-12-21 03:58:59 -08:00
|
|
|
}
|
2010-12-22 03:23:30 -08:00
|
|
|
|
2011-02-21 07:52:24 -08:00
|
|
|
DBG("place %d\n", i);
|
|
|
|
|
2011-02-19 00:34:10 -08:00
|
|
|
if (scale_conf->grow)
|
2011-02-21 07:52:24 -08:00
|
|
|
{
|
2011-02-19 00:34:10 -08:00
|
|
|
i = 0;
|
2011-02-21 07:52:24 -08:00
|
|
|
while (i++ < GROW_RUNS && _scale_grow());
|
2011-02-19 16:36:40 -08:00
|
|
|
DBG("grow %d", i);
|
2010-12-21 03:58:59 -08:00
|
|
|
}
|
2010-12-22 03:23:30 -08:00
|
|
|
|
2011-02-19 00:34:10 -08:00
|
|
|
if (scale_conf->tight)
|
|
|
|
{
|
|
|
|
i = 0;
|
2011-02-21 07:52:24 -08:00
|
|
|
while (i++ < SHRINK_RUNS && _scale_shrink());
|
2011-02-19 00:34:10 -08:00
|
|
|
DBG("shrunk %d", i);
|
2011-02-21 07:52:24 -08:00
|
|
|
|
|
|
|
if (scale_conf->grow)
|
|
|
|
{
|
|
|
|
i = 0;
|
|
|
|
while (i++ < GROW_RUNS && _scale_grow());
|
|
|
|
DBG("grow %d", i);
|
|
|
|
}
|
|
|
|
|
2011-02-19 00:34:10 -08:00
|
|
|
}
|
2011-02-21 07:52:24 -08:00
|
|
|
|
|
|
|
if (show_all_desks)
|
|
|
|
{
|
|
|
|
/* center and move windows near visible desk
|
|
|
|
* to make the sliding smoother */
|
|
|
|
|
|
|
|
min_x = zone->w;
|
|
|
|
min_y = zone->h;
|
|
|
|
max_x = 0;
|
|
|
|
max_y = 0;
|
|
|
|
|
|
|
|
EINA_LIST_FOREACH(items, l, it)
|
|
|
|
{
|
|
|
|
if (it->x < min_x) min_x = it->x;
|
|
|
|
if (it->y < min_y) min_y = it->y;
|
|
|
|
if (it->x + it->w > max_x) max_x = it->x + it->w;
|
|
|
|
if (it->y + it->h > max_y) max_y = it->y + it->h;
|
|
|
|
}
|
|
|
|
|
|
|
|
EINA_LIST_FOREACH(items, l, it)
|
|
|
|
{
|
2011-02-21 08:10:00 -08:00
|
|
|
it->x = it->x - min_x + ((use_x + use_w) - (max_x - min_x))/2;
|
|
|
|
it->y = it->y - min_y + ((use_y + use_h) - (max_y - min_y))/2;
|
2011-02-21 07:52:24 -08:00
|
|
|
|
|
|
|
if (it->dx > 0) it->bd_x = zone->w + it->bd->x/4;
|
|
|
|
if (it->dy > 0) it->bd_y = zone->h + it->bd->y/4;
|
|
|
|
if (it->dx < 0) it->bd_x = -(zone->w - it->bd->x)/4;
|
|
|
|
if (it->dy < 0) it->bd_y = -(zone->h + it->bd->y)/4;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-02-19 16:36:40 -08:00
|
|
|
DBG("time: %f\n", ecore_time_get() - start_time);
|
2010-12-22 03:23:30 -08:00
|
|
|
|
2011-02-21 07:52:24 -08:00
|
|
|
_scale_in();
|
2010-12-21 03:58:59 -08:00
|
|
|
}
|
|
|
|
|
2011-02-19 00:34:10 -08:00
|
|
|
|
2011-02-19 16:36:40 -08:00
|
|
|
static Eina_Bool
|
2011-02-21 07:52:24 -08:00
|
|
|
_scale_cb_mouse_move(void *data, int type, void *event)
|
2011-02-19 16:36:40 -08:00
|
|
|
{
|
2011-02-21 07:52:24 -08:00
|
|
|
Ecore_Event_Mouse_Move *ev = event;
|
2011-02-19 16:36:40 -08:00
|
|
|
Item *it;
|
|
|
|
Eina_List *l;
|
|
|
|
|
|
|
|
if (ev->window != input_win)
|
|
|
|
return ECORE_CALLBACK_PASS_ON;
|
|
|
|
|
|
|
|
if (!scale_state)
|
|
|
|
return ECORE_CALLBACK_PASS_ON;
|
2011-02-21 07:52:24 -08:00
|
|
|
|
2011-02-19 16:36:40 -08:00
|
|
|
EINA_LIST_FOREACH(items, l, it)
|
2011-02-21 07:52:24 -08:00
|
|
|
if (E_INTERSECTS(ev->x, ev->y, 1, 1, it->x, it->y, it->w, it->h))
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (selected_item && (it != selected_item))
|
|
|
|
{
|
|
|
|
edje_object_signal_emit(selected_item->o, "mouse,out", "e");
|
|
|
|
selected_item = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (it)
|
2011-02-19 16:36:40 -08:00
|
|
|
{
|
2011-02-21 07:52:24 -08:00
|
|
|
edje_object_signal_emit(it->o, "mouse,in", "e");
|
|
|
|
selected_item = it;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ECORE_CALLBACK_PASS_ON;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
|
|
|
_scale_cb_mouse_down(void *data, int type, void *event)
|
|
|
|
{
|
|
|
|
Ecore_Event_Mouse_Button *ev = event;
|
|
|
|
Item *it, *ot;
|
|
|
|
Eina_List *l;
|
|
|
|
|
|
|
|
if (ev->window != input_win)
|
|
|
|
return ECORE_CALLBACK_PASS_ON;
|
|
|
|
|
|
|
|
if (!scale_state)
|
|
|
|
return ECORE_CALLBACK_PASS_ON;
|
|
|
|
|
|
|
|
EINA_LIST_FOREACH(items, l, it)
|
|
|
|
if (E_INTERSECTS(ev->x, ev->y, 1, 1, it->x, it->y, it->w, it->h))
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (!it)
|
|
|
|
{
|
|
|
|
_scale_out();
|
|
|
|
return ECORE_CALLBACK_PASS_ON;
|
|
|
|
}
|
|
|
|
|
|
|
|
e_border_raise(it->bd);
|
|
|
|
|
|
|
|
|
|
|
|
if (it->bd->desk != e_desk_current_get(it->bd->zone))
|
|
|
|
{
|
|
|
|
if (ev->buttons == 1)
|
2011-02-19 16:36:40 -08:00
|
|
|
{
|
2011-02-21 07:52:24 -08:00
|
|
|
selected_item = it;
|
|
|
|
current_desk = it->bd->desk;
|
|
|
|
|
|
|
|
EINA_LIST_FOREACH(items, l, ot)
|
|
|
|
{
|
|
|
|
if (ot->bd->desk == it->bd->desk)
|
|
|
|
{
|
|
|
|
ot->bd_x = ot->bd->x;
|
|
|
|
ot->bd_y = ot->bd->y;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (ot->dx > it->dx)
|
|
|
|
ot->bd_x = ot->bd->x + zone->w;
|
|
|
|
else if (ot->dx < it->dx)
|
|
|
|
ot->bd_x = ot->bd->x - zone->w;
|
|
|
|
|
|
|
|
if (ot->dy > it->dy)
|
|
|
|
ot->bd_y = ot->bd->y + zone->h;
|
|
|
|
else if (ot->dy < it->dy)
|
|
|
|
ot->bd_y = ot->bd->y - zone->h;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (ev->buttons == 3)
|
|
|
|
{
|
|
|
|
send_to_desk = EINA_TRUE;
|
|
|
|
selected_item = it;
|
|
|
|
it->bd_x = it->bd->x;
|
|
|
|
it->bd_y = it->bd->y;
|
2011-02-19 16:36:40 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
_scale_out();
|
2011-02-21 07:52:24 -08:00
|
|
|
|
2011-02-19 16:36:40 -08:00
|
|
|
return ECORE_CALLBACK_PASS_ON;
|
|
|
|
}
|
|
|
|
|
2010-12-21 03:58:59 -08:00
|
|
|
static void
|
2011-02-19 16:36:40 -08:00
|
|
|
_scale_handler(void *data, const char *name, const char *info, int val,
|
2011-02-21 07:52:24 -08:00
|
|
|
E_Object *obj, void *msgdata)
|
2010-12-21 03:58:59 -08:00
|
|
|
{
|
|
|
|
E_Manager *man = (E_Manager *)obj;
|
|
|
|
E_Manager_Comp_Source *src = (E_Manager_Comp_Source *)msgdata;
|
|
|
|
Evas *e;
|
|
|
|
|
2011-02-21 07:52:24 -08:00
|
|
|
/* DBG("handler... '%s' '%s'\n", name, info); */
|
2010-12-21 03:58:59 -08:00
|
|
|
if (strcmp(name, "comp.manager")) return;
|
2010-12-22 03:23:30 -08:00
|
|
|
|
2010-12-21 03:58:59 -08:00
|
|
|
e = e_manager_comp_evas_get(man);
|
|
|
|
if (!strcmp(info, "change.comp"))
|
|
|
|
{
|
2011-02-19 00:34:10 -08:00
|
|
|
if (!e) DBG("TTT: No comp manager\n");
|
|
|
|
else DBG("TTT: comp canvas = %p\n", e);
|
2010-12-21 03:58:59 -08:00
|
|
|
}
|
|
|
|
else if (!strcmp(info, "resize.comp"))
|
|
|
|
{
|
2011-02-19 00:34:10 -08:00
|
|
|
DBG("%s: %p | %p\n", info, man, src);
|
2010-12-21 03:58:59 -08:00
|
|
|
}
|
|
|
|
else if (!strcmp(info, "add.src"))
|
|
|
|
{
|
2011-02-19 00:34:10 -08:00
|
|
|
/* DBG("%s: %p | %p\n", info, man, src); */
|
2011-02-19 16:36:40 -08:00
|
|
|
_scale_win_new(e, man, src, e_desk_current_get(e_util_zone_current_get(man)));
|
2011-02-21 07:52:24 -08:00
|
|
|
|
2010-12-21 03:58:59 -08:00
|
|
|
}
|
|
|
|
else if (!strcmp(info, "del.src"))
|
|
|
|
{
|
2011-02-19 00:34:10 -08:00
|
|
|
DBG("%s: %p | %p\n", info, man, src);
|
2010-12-21 03:58:59 -08:00
|
|
|
}
|
|
|
|
else if (!strcmp(info, "config.src"))
|
|
|
|
{
|
2010-12-22 03:23:30 -08:00
|
|
|
|
2011-02-19 00:34:10 -08:00
|
|
|
DBG("%s: %p | %p\n", info, man, src);
|
2010-12-21 03:58:59 -08:00
|
|
|
}
|
2011-02-21 07:52:24 -08:00
|
|
|
/* else if (!strcmp(info, "visible.src"))
|
|
|
|
* {
|
|
|
|
* DBG("%s: %p | %p\n", info, man, src);
|
|
|
|
* } */
|
2010-12-21 03:58:59 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_e_mod_action_cb_edge(E_Object *obj, const char *params, E_Event_Zone_Edge *ev)
|
|
|
|
{
|
|
|
|
Eina_List *list, *l;
|
|
|
|
E_Manager *man;
|
|
|
|
|
2011-02-19 16:36:40 -08:00
|
|
|
msg_handler = e_msg_handler_add(_scale_handler, NULL);
|
2010-12-21 03:58:59 -08:00
|
|
|
list = e_manager_list();
|
2011-02-21 07:52:24 -08:00
|
|
|
|
|
|
|
if (params && !strcmp(params, "show_all_desks"))
|
|
|
|
show_all_desks = EINA_TRUE;
|
|
|
|
else
|
|
|
|
show_all_desks = EINA_FALSE;
|
|
|
|
|
2010-12-21 03:58:59 -08:00
|
|
|
EINA_LIST_FOREACH(list, l, man)
|
|
|
|
{
|
|
|
|
Evas *e = e_manager_comp_evas_get(man);
|
2011-02-19 16:36:40 -08:00
|
|
|
if (e) scale_run(man);
|
2010-12-21 03:58:59 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-02-19 00:34:10 -08:00
|
|
|
static void
|
|
|
|
_e_mod_action_cb(E_Object *obj, const char *params)
|
|
|
|
{
|
|
|
|
Eina_List *list, *l;
|
|
|
|
E_Manager *man;
|
|
|
|
|
2011-02-19 16:36:40 -08:00
|
|
|
msg_handler = e_msg_handler_add(_scale_handler, NULL);
|
2011-02-19 00:34:10 -08:00
|
|
|
list = e_manager_list();
|
2011-02-21 07:52:24 -08:00
|
|
|
|
|
|
|
if (params && !strcmp(params, "show_all_desks"))
|
|
|
|
show_all_desks = EINA_TRUE;
|
|
|
|
else
|
|
|
|
show_all_desks = EINA_FALSE;
|
|
|
|
|
2011-02-19 00:34:10 -08:00
|
|
|
EINA_LIST_FOREACH(list, l, man)
|
|
|
|
{
|
|
|
|
Evas *e = e_manager_comp_evas_get(man);
|
2011-02-19 16:36:40 -08:00
|
|
|
if (e) scale_run(man);
|
2011-02-19 00:34:10 -08:00
|
|
|
}
|
|
|
|
}
|
2010-12-21 03:58:59 -08:00
|
|
|
|
2011-02-19 16:36:40 -08:00
|
|
|
|
|
|
|
/* Module and Gadcon stuff */
|
|
|
|
|
|
|
|
typedef struct _Instance Instance;
|
|
|
|
|
|
|
|
struct _Instance
|
|
|
|
{
|
|
|
|
E_Gadcon_Client *gcc;
|
|
|
|
Evas_Object *o_scale;
|
|
|
|
E_Menu *menu;
|
|
|
|
Config_Item *conf_item;
|
|
|
|
};
|
|
|
|
|
|
|
|
static int uuid = 0;
|
|
|
|
static Eina_List *instances = NULL;
|
|
|
|
static E_Config_DD *conf_edd = NULL;
|
|
|
|
static E_Config_DD *conf_item_edd = NULL;
|
|
|
|
Config *scale_conf = NULL;
|
|
|
|
|
|
|
|
static const E_Gadcon_Client_Class _gc_class =
|
|
|
|
{
|
|
|
|
GADCON_CLIENT_CLASS_VERSION, "scale",
|
|
|
|
{_gc_init, _gc_shutdown, _gc_orient, _gc_label, _gc_icon,
|
|
|
|
_gc_id_new, NULL, NULL},
|
|
|
|
E_GADCON_CLIENT_STYLE_PLAIN
|
|
|
|
};
|
|
|
|
|
|
|
|
EAPI E_Module_Api e_modapi = {E_MODULE_API_VERSION, "Scale"};
|
|
|
|
|
2010-12-21 03:58:59 -08:00
|
|
|
EAPI void *
|
2010-12-22 03:23:30 -08:00
|
|
|
e_modapi_init(E_Module *m)
|
2010-12-21 03:58:59 -08:00
|
|
|
{
|
|
|
|
char buf[4096];
|
|
|
|
|
|
|
|
snprintf(buf, sizeof(buf), "%s/locale", e_module_dir_get(m));
|
|
|
|
bindtextdomain(PACKAGE, buf);
|
|
|
|
bind_textdomain_codeset(PACKAGE, "UTF-8");
|
|
|
|
|
|
|
|
snprintf(buf, sizeof(buf), "%s/e-module-scale.edj", m->dir);
|
|
|
|
|
2011-02-19 00:34:10 -08:00
|
|
|
e_configure_registry_category_add("appearance", 80, D_("Look"),
|
|
|
|
NULL, "preferences-look");
|
|
|
|
e_configure_registry_item_add("appearance/comp-scale", 110, D_("Composite Scale Windows"),
|
2010-12-21 03:58:59 -08:00
|
|
|
NULL, buf, e_int_config_scale_module);
|
|
|
|
|
|
|
|
conf_item_edd = E_CONFIG_DD_NEW("Config_Item", Config_Item);
|
|
|
|
#undef T
|
|
|
|
#undef D
|
|
|
|
#define T Config_Item
|
|
|
|
#define D conf_item_edd
|
|
|
|
E_CONFIG_VAL(D, T, id, STR);
|
|
|
|
E_CONFIG_VAL(D, T, switch2, INT);
|
|
|
|
|
|
|
|
conf_edd = E_CONFIG_DD_NEW("Config", Config);
|
|
|
|
#undef T
|
|
|
|
#undef D
|
|
|
|
#define T Config
|
|
|
|
#define D conf_edd
|
|
|
|
E_CONFIG_VAL(D, T, version, INT);
|
2011-02-19 00:34:10 -08:00
|
|
|
E_CONFIG_VAL(D, T, grow, UCHAR);
|
|
|
|
E_CONFIG_VAL(D, T, tight, UCHAR);
|
2011-02-21 07:52:24 -08:00
|
|
|
E_CONFIG_VAL(D, T, fade_popups, UCHAR);
|
|
|
|
E_CONFIG_VAL(D, T, fade_desktop, UCHAR);
|
|
|
|
E_CONFIG_VAL(D, T, fade_windows, UCHAR);
|
|
|
|
E_CONFIG_VAL(D, T, fade_desktop, UCHAR);
|
2011-02-19 00:34:10 -08:00
|
|
|
E_CONFIG_VAL(D, T, scale_duration, DOUBLE);
|
|
|
|
E_CONFIG_VAL(D, T, spacing, DOUBLE);
|
2011-02-21 07:52:24 -08:00
|
|
|
E_CONFIG_VAL(D, T, desks_duration, DOUBLE);
|
|
|
|
E_CONFIG_VAL(D, T, desks_spacing, DOUBLE);
|
2011-02-19 00:34:10 -08:00
|
|
|
E_CONFIG_LIST(D, T, conf_items, conf_item_edd);
|
2010-12-21 03:58:59 -08:00
|
|
|
|
|
|
|
scale_conf = e_config_domain_load("module.scale", conf_edd);
|
2010-12-22 03:23:30 -08:00
|
|
|
if (scale_conf)
|
2010-12-21 03:58:59 -08:00
|
|
|
{
|
2011-02-19 00:34:10 -08:00
|
|
|
if (!e_util_module_config_check(D_("Scale Windows"),
|
|
|
|
scale_conf->version,
|
|
|
|
MOD_CONFIG_FILE_EPOCH,
|
|
|
|
MOD_CONFIG_FILE_VERSION))
|
|
|
|
_scale_conf_free();
|
2010-12-21 03:58:59 -08:00
|
|
|
}
|
2011-02-21 07:52:24 -08:00
|
|
|
|
2010-12-21 03:58:59 -08:00
|
|
|
if (!scale_conf) _scale_conf_new();
|
|
|
|
|
|
|
|
scale_conf->module = m;
|
|
|
|
|
2011-02-21 07:52:24 -08:00
|
|
|
snprintf(buf, sizeof(buf), "%s/e-module-scale.edj",
|
|
|
|
scale_conf->module->dir);
|
|
|
|
scale_conf->theme_path = eina_stringshare_add(buf);
|
|
|
|
|
2010-12-21 03:58:59 -08:00
|
|
|
e_gadcon_provider_register(&_gc_class);
|
|
|
|
|
2011-02-19 00:34:10 -08:00
|
|
|
act = e_action_add("scale-windows");
|
2010-12-21 03:58:59 -08:00
|
|
|
if (act)
|
|
|
|
{
|
2011-02-19 00:34:10 -08:00
|
|
|
act->func.go = _e_mod_action_cb;
|
2010-12-21 03:58:59 -08:00
|
|
|
act->func.go_edge = _e_mod_action_cb_edge;
|
2011-02-19 00:34:10 -08:00
|
|
|
e_action_predef_name_set(D_("Desktop"), D_("Scale Windows"), "scale-windows", "", NULL, 0);
|
2011-02-21 07:52:24 -08:00
|
|
|
e_action_predef_name_set(D_("Desktop"), D_("Scale Windows / All Desktops"), "scale-windows", "show_all_desks", NULL, 0);
|
2010-12-21 03:58:59 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
return m;
|
|
|
|
}
|
|
|
|
|
2011-02-19 00:34:10 -08:00
|
|
|
|
2010-12-22 03:23:30 -08:00
|
|
|
EAPI int
|
|
|
|
e_modapi_shutdown(E_Module *m)
|
2010-12-21 03:58:59 -08:00
|
|
|
{
|
2011-02-19 00:34:10 -08:00
|
|
|
e_configure_registry_item_del("appearance/comp-scale");
|
|
|
|
e_configure_registry_category_del("appearance");
|
2010-12-21 03:58:59 -08:00
|
|
|
|
|
|
|
if (scale_conf->cfd) e_object_del(E_OBJECT(scale_conf->cfd));
|
|
|
|
scale_conf->cfd = NULL;
|
|
|
|
|
|
|
|
scale_conf->module = NULL;
|
|
|
|
e_gadcon_provider_unregister(&_gc_class);
|
|
|
|
|
2010-12-22 03:23:30 -08:00
|
|
|
while (scale_conf->conf_items)
|
2010-12-21 03:58:59 -08:00
|
|
|
{
|
|
|
|
Config_Item *ci = NULL;
|
|
|
|
ci = scale_conf->conf_items->data;
|
|
|
|
|
2010-12-22 03:23:30 -08:00
|
|
|
scale_conf->conf_items =
|
|
|
|
eina_list_remove_list(scale_conf->conf_items,
|
2010-12-21 03:58:59 -08:00
|
|
|
scale_conf->conf_items);
|
|
|
|
|
|
|
|
if (ci->id) eina_stringshare_del(ci->id);
|
|
|
|
E_FREE(ci);
|
|
|
|
}
|
|
|
|
|
2011-02-21 07:52:24 -08:00
|
|
|
eina_stringshare_del(scale_conf->theme_path);
|
2010-12-21 03:58:59 -08:00
|
|
|
E_FREE(scale_conf);
|
|
|
|
|
|
|
|
E_CONFIG_DD_FREE(conf_item_edd);
|
|
|
|
E_CONFIG_DD_FREE(conf_edd);
|
|
|
|
|
|
|
|
if (act)
|
|
|
|
{
|
|
|
|
e_action_predef_name_del(D_("Desktop"),
|
|
|
|
D_("Scale Windows"));
|
2011-02-19 00:34:10 -08:00
|
|
|
e_action_del("scale-windows");
|
2010-12-21 03:58:59 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2010-12-22 03:23:30 -08:00
|
|
|
EAPI int
|
|
|
|
e_modapi_save(E_Module *m)
|
2010-12-21 03:58:59 -08:00
|
|
|
{
|
|
|
|
e_config_domain_save("module.scale", conf_edd, scale_conf);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static E_Gadcon_Client *
|
2010-12-22 03:23:30 -08:00
|
|
|
_gc_init(E_Gadcon *gc, const char *name, const char *id, const char *style)
|
2010-12-21 03:58:59 -08:00
|
|
|
{
|
|
|
|
Instance *inst = NULL;
|
|
|
|
|
|
|
|
inst = E_NEW(Instance, 1);
|
|
|
|
inst->conf_item = _scale_conf_item_get(id);
|
|
|
|
|
|
|
|
inst->o_scale = edje_object_add(gc->evas);
|
2011-02-19 00:34:10 -08:00
|
|
|
|
2010-12-22 03:23:30 -08:00
|
|
|
if (!e_theme_edje_object_set(inst->o_scale, "base/theme/modules/scale",
|
2010-12-21 03:58:59 -08:00
|
|
|
"modules/scale/main"))
|
2011-02-21 07:52:24 -08:00
|
|
|
edje_object_file_set(inst->o_scale, scale_conf->theme_path, "modules/scale/main");
|
2010-12-21 03:58:59 -08:00
|
|
|
|
|
|
|
inst->gcc = e_gadcon_client_new(gc, name, id, style, inst->o_scale);
|
|
|
|
inst->gcc->data = inst;
|
|
|
|
|
2010-12-22 03:23:30 -08:00
|
|
|
evas_object_event_callback_add(inst->o_scale, EVAS_CALLBACK_MOUSE_DOWN,
|
2011-02-19 16:36:40 -08:00
|
|
|
_scale_gc_cb_mouse_down, inst);
|
2010-12-21 03:58:59 -08:00
|
|
|
|
|
|
|
instances = eina_list_append(instances, inst);
|
|
|
|
|
|
|
|
return inst->gcc;
|
|
|
|
}
|
|
|
|
|
2010-12-22 03:23:30 -08:00
|
|
|
static void
|
|
|
|
_gc_shutdown(E_Gadcon_Client *gcc)
|
2010-12-21 03:58:59 -08:00
|
|
|
{
|
|
|
|
Instance *inst = NULL;
|
|
|
|
|
|
|
|
if (!(inst = gcc->data)) return;
|
|
|
|
instances = eina_list_remove(instances, inst);
|
|
|
|
|
2010-12-22 03:23:30 -08:00
|
|
|
if (inst->menu)
|
2010-12-21 03:58:59 -08:00
|
|
|
{
|
|
|
|
e_menu_post_deactivate_callback_set(inst->menu, NULL, NULL);
|
|
|
|
e_object_del(E_OBJECT(inst->menu));
|
|
|
|
inst->menu = NULL;
|
|
|
|
}
|
2010-12-22 03:23:30 -08:00
|
|
|
if (inst->o_scale)
|
2010-12-21 03:58:59 -08:00
|
|
|
{
|
2010-12-22 03:23:30 -08:00
|
|
|
evas_object_event_callback_del(inst->o_scale, EVAS_CALLBACK_MOUSE_DOWN,
|
2011-02-19 16:36:40 -08:00
|
|
|
_scale_gc_cb_mouse_down);
|
2010-12-21 03:58:59 -08:00
|
|
|
evas_object_del(inst->o_scale);
|
|
|
|
}
|
|
|
|
E_FREE(inst);
|
|
|
|
}
|
|
|
|
|
2010-12-22 03:23:30 -08:00
|
|
|
static void
|
|
|
|
_gc_orient(E_Gadcon_Client *gcc, E_Gadcon_Orient orient)
|
2010-12-21 03:58:59 -08:00
|
|
|
{
|
|
|
|
e_gadcon_client_aspect_set(gcc, 16, 16);
|
|
|
|
e_gadcon_client_min_size_set(gcc, 16, 16);
|
|
|
|
}
|
|
|
|
|
|
|
|
static char *
|
2010-12-22 03:23:30 -08:00
|
|
|
_gc_label(E_Gadcon_Client_Class *client_class)
|
2010-12-21 03:58:59 -08:00
|
|
|
{
|
|
|
|
return D_("Scale");
|
|
|
|
}
|
|
|
|
|
|
|
|
static const char *
|
2010-12-22 03:23:30 -08:00
|
|
|
_gc_id_new(E_Gadcon_Client_Class *client_class)
|
2010-12-21 03:58:59 -08:00
|
|
|
{
|
|
|
|
Config_Item *ci = NULL;
|
|
|
|
|
|
|
|
ci = _scale_conf_item_get(NULL);
|
|
|
|
return ci->id;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Evas_Object *
|
2010-12-22 03:23:30 -08:00
|
|
|
_gc_icon(E_Gadcon_Client_Class *client_class, Evas *evas)
|
2010-12-21 03:58:59 -08:00
|
|
|
{
|
|
|
|
Evas_Object *o = NULL;
|
|
|
|
|
|
|
|
o = edje_object_add(evas);
|
|
|
|
|
2011-02-21 07:52:24 -08:00
|
|
|
edje_object_file_set(o, scale_conf->theme_path, "icon");
|
2010-12-21 03:58:59 -08:00
|
|
|
|
|
|
|
return o;
|
|
|
|
}
|
|
|
|
|
2010-12-22 03:23:30 -08:00
|
|
|
static void
|
|
|
|
_scale_conf_new(void)
|
2010-12-21 03:58:59 -08:00
|
|
|
{
|
|
|
|
scale_conf = E_NEW(Config, 1);
|
|
|
|
scale_conf->version = (MOD_CONFIG_FILE_EPOCH << 16);
|
|
|
|
|
|
|
|
#define IFMODCFG(v) if ((scale_conf->version & 0xffff) < v) {
|
|
|
|
#define IFMODCFGEND }
|
|
|
|
|
2011-02-21 07:52:24 -08:00
|
|
|
IFMODCFG(0x0001);
|
2011-02-21 08:10:00 -08:00
|
|
|
scale_conf->grow = 1;
|
2011-02-19 00:34:10 -08:00
|
|
|
scale_conf->tight = 1;
|
2011-02-21 07:52:24 -08:00
|
|
|
scale_conf->scale_duration = 0.4;
|
2011-02-21 08:10:00 -08:00
|
|
|
scale_conf->spacing = 10;
|
2011-02-21 07:52:24 -08:00
|
|
|
scale_conf->fade_windows = 1;
|
|
|
|
scale_conf->fade_popups = 0;
|
|
|
|
scale_conf->fade_desktop = 1;
|
|
|
|
scale_conf->desks_duration = 0.6;
|
2011-02-21 08:10:00 -08:00
|
|
|
scale_conf->desks_spacing = 44;
|
2010-12-21 03:58:59 -08:00
|
|
|
_scale_conf_item_get(NULL);
|
|
|
|
IFMODCFGEND;
|
|
|
|
|
|
|
|
scale_conf->version = MOD_CONFIG_FILE_VERSION;
|
|
|
|
|
|
|
|
e_config_save_queue();
|
|
|
|
}
|
|
|
|
|
2010-12-22 03:23:30 -08:00
|
|
|
static void
|
|
|
|
_scale_conf_free(void)
|
2010-12-21 03:58:59 -08:00
|
|
|
{
|
2010-12-22 03:23:30 -08:00
|
|
|
while (scale_conf->conf_items)
|
2010-12-21 03:58:59 -08:00
|
|
|
{
|
|
|
|
Config_Item *ci = NULL;
|
|
|
|
|
|
|
|
ci = scale_conf->conf_items->data;
|
2010-12-22 03:23:30 -08:00
|
|
|
scale_conf->conf_items =
|
|
|
|
eina_list_remove_list(scale_conf->conf_items,
|
2010-12-21 03:58:59 -08:00
|
|
|
scale_conf->conf_items);
|
|
|
|
if (ci->id) eina_stringshare_del(ci->id);
|
|
|
|
E_FREE(ci);
|
|
|
|
}
|
|
|
|
|
|
|
|
E_FREE(scale_conf);
|
|
|
|
}
|
|
|
|
|
|
|
|
static Config_Item *
|
2010-12-22 03:23:30 -08:00
|
|
|
_scale_conf_item_get(const char *id)
|
2010-12-21 03:58:59 -08:00
|
|
|
{
|
|
|
|
Eina_List *l = NULL;
|
|
|
|
Config_Item *ci = NULL;
|
|
|
|
char buf[128];
|
|
|
|
|
2010-12-22 03:23:30 -08:00
|
|
|
if (!id)
|
2010-12-21 03:58:59 -08:00
|
|
|
{
|
|
|
|
snprintf(buf, sizeof(buf), "%s.%d", _gc_class.name, ++uuid);
|
|
|
|
id = buf;
|
|
|
|
}
|
2010-12-22 03:23:30 -08:00
|
|
|
else
|
2010-12-21 03:58:59 -08:00
|
|
|
{
|
|
|
|
uuid++;
|
2010-12-22 03:23:30 -08:00
|
|
|
for (l = scale_conf->conf_items; l; l = l->next)
|
2010-12-21 03:58:59 -08:00
|
|
|
{
|
|
|
|
if (!(ci = l->data)) continue;
|
|
|
|
if ((ci->id) && (!strcmp(ci->id, id))) return ci;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ci = E_NEW(Config_Item, 1);
|
|
|
|
ci->id = eina_stringshare_add(id);
|
|
|
|
ci->switch2 = 0;
|
|
|
|
scale_conf->conf_items = eina_list_append(scale_conf->conf_items, ci);
|
|
|
|
return ci;
|
|
|
|
}
|
|
|
|
|
2010-12-22 03:23:30 -08:00
|
|
|
static void
|
2011-02-19 16:36:40 -08:00
|
|
|
_scale_gc_cb_mouse_down(void *data, Evas *evas, Evas_Object *obj, void *event)
|
2010-12-21 03:58:59 -08:00
|
|
|
{
|
|
|
|
Instance *inst = NULL;
|
|
|
|
Evas_Event_Mouse_Down *ev;
|
|
|
|
E_Zone *zone = NULL;
|
|
|
|
E_Menu_Item *mi = NULL;
|
|
|
|
int x, y;
|
|
|
|
|
|
|
|
if (!(inst = data)) return;
|
|
|
|
ev = event;
|
2011-02-21 07:52:24 -08:00
|
|
|
|
2010-12-21 03:58:59 -08:00
|
|
|
if (ev->button == 1)
|
|
|
|
{
|
2011-02-21 07:52:24 -08:00
|
|
|
_e_mod_action_cb(NULL, NULL);
|
2010-12-21 03:58:59 -08:00
|
|
|
}
|
2011-02-21 07:52:24 -08:00
|
|
|
else if (ev->button == 2)
|
|
|
|
{
|
|
|
|
_e_mod_action_cb(NULL, "show_all_desks");
|
|
|
|
}
|
|
|
|
else if ((ev->button == 3) && (!inst->menu))
|
2010-12-21 03:58:59 -08:00
|
|
|
{
|
|
|
|
E_Menu *ma, *mg;
|
|
|
|
|
|
|
|
zone = e_util_zone_current_get(e_manager_current_get());
|
|
|
|
|
|
|
|
ma = e_menu_new();
|
2011-02-19 16:36:40 -08:00
|
|
|
e_menu_post_deactivate_callback_set(ma, _scale_gc_cb_menu_post, inst);
|
2010-12-21 03:58:59 -08:00
|
|
|
inst->menu = ma;
|
|
|
|
|
|
|
|
mg = e_menu_new();
|
|
|
|
|
|
|
|
mi = e_menu_item_new(mg);
|
|
|
|
e_menu_item_label_set(mi, D_("Settings"));
|
|
|
|
e_util_menu_item_theme_icon_set(mi, "preferences-system");
|
2011-02-19 16:36:40 -08:00
|
|
|
e_menu_item_callback_set(mi, _scale_gc_cb_menu_configure, NULL);
|
2010-12-21 03:58:59 -08:00
|
|
|
|
|
|
|
e_gadcon_client_util_menu_items_append(inst->gcc, ma, mg, 0);
|
2011-02-21 07:52:24 -08:00
|
|
|
e_gadcon_canvas_zone_geometry_get(inst->gcc->gadcon, &x, &y,
|
2010-12-21 03:58:59 -08:00
|
|
|
NULL, NULL);
|
|
|
|
|
2011-02-21 07:52:24 -08:00
|
|
|
e_menu_activate_mouse(ma, zone, (x + ev->output.x),
|
|
|
|
(y + ev->output.y), 1, 1,
|
2010-12-21 03:58:59 -08:00
|
|
|
E_MENU_POP_DIRECTION_AUTO, ev->timestamp);
|
2011-02-21 07:52:24 -08:00
|
|
|
evas_event_feed_mouse_up(inst->gcc->gadcon->evas, ev->button,
|
2010-12-21 03:58:59 -08:00
|
|
|
EVAS_BUTTON_NONE, ev->timestamp, NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-12-22 03:23:30 -08:00
|
|
|
static void
|
2011-02-19 16:36:40 -08:00
|
|
|
_scale_gc_cb_menu_post(void *data, E_Menu *menu)
|
2010-12-21 03:58:59 -08:00
|
|
|
{
|
|
|
|
Instance *inst = NULL;
|
|
|
|
|
|
|
|
if (!(inst = data)) return;
|
|
|
|
if (!inst->menu) return;
|
|
|
|
e_object_del(E_OBJECT(inst->menu));
|
|
|
|
inst->menu = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* call configure from popup */
|
2010-12-22 03:23:30 -08:00
|
|
|
static void
|
2011-02-19 16:36:40 -08:00
|
|
|
_scale_gc_cb_menu_configure(void *data, E_Menu *mn, E_Menu_Item *mi)
|
2010-12-21 03:58:59 -08:00
|
|
|
{
|
|
|
|
if (!scale_conf) return;
|
|
|
|
if (scale_conf->cfd) return;
|
|
|
|
e_int_config_scale_module(mn->zone->container, NULL);
|
|
|
|
}
|
2011-02-21 07:52:24 -08:00
|
|
|
|