e-modules/comp-scale:

- when initiating scale with keyboard select the previous 
  (winlist like switching between two windows) 
- added pointer warp to window when selecting with keyboard
- fix scale fade window using setting from pager
- fix handle input events only for input win 


SVN revision: 57611
This commit is contained in:
Hannes Janetzek 2011-03-09 03:27:07 +00:00
parent 1a90295eea
commit 0cf410b864
3 changed files with 242 additions and 176 deletions

View File

@ -82,7 +82,6 @@ collections
type: RECT;
mouse_events: 0;
description { state: "default" 0.0;
visible: 1;
color: 255 255 255 255;
rel1 {
relative: -1.0 -1.0;
@ -93,10 +92,9 @@ collections
offset: 9999 9999;
}
}
description { state: "visible" 0.0;
description { state: "faded" 0.0;
inherit: "default" 0.0;
visible: 1;
color: 255 255 255 255;
color: 200 200 200 235;
}
}
part { name: "shadow";
@ -131,96 +129,31 @@ collections
part {
name: "e.swallow.win";
type: SWALLOW;
description {
clip_to: "clipper";
description {
state: "default" 0.0;
color: 255 255 255 255;
}
}
/* part {
* name: "icon";
* mouse_events: 0;
* type: IMAGE;
* description {
* state: "default" 0.0;
* aspect: 1.0 1.0;
* aspect_preference: BOTH;
* rel1.relative;
*
* rel1.offset: 2 2;
* rel2.offset: -3 -3;
* image.normal: "module_icon.png";
* }
* description {
* state: "bigger" 0.0;
* inherit: "default" 0.0;
* rel1.offset: -2 -2;
* rel2.offset: 3 3;
* }
* } */
part {
name: "over_clip";
mouse_events: 0;
type: RECT;
description {
state: "default" 0.0;
color: 0 0 0 0;
}
description {
state: "visible" 0.0;
color: 255 255 255 255;
}
}
part {
name: "over";
mouse_events: 1;
type: RECT;
clip_to: "over_clip";
description {
state: "default" 0.0;
color: 0 0 0 30;
}
description {
state: "focused" 0.0;
color: 255 255 255 30;
}
}
}
programs {
program {
name: "mouse_in";
signal: "mouse,in";
source: "e";
action: STATE_SET "focused" 0.0;
transition: ACCELERATE 0.1;
target: "over";
action: STATE_SET "default" 0.0;
transition: LINEAR 0.2;
target: "clipper";
}
program {
name: "mouse_out";
signal: "mouse,out";
source: "e";
action: STATE_SET "default" 0.0;
transition: DECELERATE 0.1;
target: "over";
}
program {
name: "fade_in";
signal: "show";
source: "e";
action: STATE_SET "visible" 0.0;
transition: DECELERATE 0.3;
target: "over_clip";
}
program {
name: "fade_out";
signal: "hide";
source: "e";
action: STATE_SET "default" 0.0;
transition: ACCELERATE 0.1;
target: "over_clip";
action: STATE_SET "faded" 0.0;
transition: LINEAR 0.4;
target: "clipper";
}
}
}
group {
name: "modules/scale/desk";

View File

@ -12,7 +12,6 @@ struct _Item
E_Desk *desk;
E_Comp_Win *cw;
E_Manager *man;
int alpha;
double x;
double y;
@ -72,6 +71,8 @@ static E_Desk *current_desk = NULL;
static int min_x, min_y, max_x, max_y;
static double desk_w, desk_h;
static double zoom = 0.0;
static int mouse_activated = 0;
static int mouse_x, mouse_y;
static void
_pager_place_desks(double scale)
@ -153,7 +154,9 @@ _pager_redraw(void *data)
{
EINA_LIST_FOREACH(items, l, it)
{
if ((it->desk != current_desk) &&
a = 255.0;
if ((it->desk != current_desk) &&
(it->desk != previous_desk))
{
double ax = it->cur_x - it->x;
@ -162,16 +165,10 @@ _pager_redraw(void *data)
double by = it->bd_y - it->y;
a = (1.0 - sqrt(ax*ax + ay*ay) /
sqrt(bx*bx + by*by)) * 220;
}
else
{
//a = 220.0 + (35.0 * in);
a = 255.0;
sqrt(bx*bx + by*by)) * 255.0;
}
it->alpha = a;
evas_object_color_set(it->o_win, a, a, a, a);
evas_object_color_set(it->o, a, a, a, a);
}
}
@ -234,6 +231,7 @@ _pager_out()
EINA_LIST_FOREACH(items, l, it)
{
edje_object_signal_emit(it->o, "hide", "e");
edje_object_signal_emit(it->o, "mouse,in", "e");
it->bd_x = it->bd->x + (it->desk->x - current_desk->x) * zone->w;
it->bd_y = it->bd->y + (it->desk->y - current_desk->y) * zone->h;
}
@ -280,8 +278,6 @@ _pager_finish()
e_config->desk_flip_animate_mode = tmp;
}
/* _pager_place_windows(1.0); */
EINA_LIST_FREE(items, it)
_pager_win_del(it);
@ -355,7 +351,6 @@ _pager_win_cb_mouse_down(void *data, Evas *e, Evas_Object *obj, void *event_info
else if (ev->button == 1)
{
e_border_raise(it->bd);
e_border_focus_set(it->bd, 1, 1);
evas_object_raise(it->o);
@ -488,6 +483,11 @@ _pager_win_cb_mouse_in(void *data, Evas *e, Evas_Object *obj, void *event_info)
{
Item *it = data;
if (!mouse_activated)
return;
mouse_activated = 0;
if (selected_item && (it != selected_item))
{
edje_object_signal_emit(selected_item->o, "mouse,out", "e");
@ -502,6 +502,8 @@ static void
_pager_win_cb_mouse_out(void *data, Evas *e, Evas_Object *obj, void *event_info)
{
/* Item *it = data; */
if (!mouse_activated)
return;
if (selected_item)
{
@ -617,7 +619,6 @@ _pager_win_new(Evas *e, E_Manager *man, E_Manager_Comp_Source *src)
it->desk = it->bd->desk;
it->man = man;
it->cw = cw;
it->alpha = 255.0;
e_object_ref(E_OBJECT(it->bd));
e_manager_comp_src_hidden_set(man, src, EINA_TRUE);
@ -666,9 +667,7 @@ _pager_win_new(Evas *e, E_Manager *man, E_Manager_Comp_Source *src)
it->cur_h = it->bd->h;
if (it->desk != current_desk)
{
e_border_show(it->bd);
}
e_border_show(it->bd);
_pager_win_final_position_set(it);
@ -679,6 +678,11 @@ _pager_win_new(Evas *e, E_Manager *man, E_Manager_Comp_Source *src)
edje_object_signal_emit(it->o, "show", "e");
if (it->bd != e_border_focused_get())
edje_object_signal_emit(it->o, "mouse,out", "e");
else
selected_item = it;
if (scale_state)
_pager_redraw(NULL);
}
@ -688,6 +692,22 @@ _pager_cb_mouse_move(void *data, int type, void *event)
{
Ecore_Event_Mouse_Move *ev = event;
if (ev->window != input_win)
return ECORE_CALLBACK_PASS_ON;
if (!scale_state)
return ECORE_CALLBACK_PASS_ON;
if (mouse_x < 0)
{
mouse_x = ev->x;
mouse_y = ev->y;
return ECORE_CALLBACK_PASS_ON;
}
if ((mouse_x == ev->x) || (mouse_y == ev->y))
return ECORE_CALLBACK_PASS_ON;
mouse_activated = 1;
evas_event_feed_mouse_move((Evas *) data, ev->x, ev->y,
ev->timestamp, NULL);
@ -700,6 +720,12 @@ _pager_cb_mouse_up(void *data, int type, void *event)
Ecore_Event_Mouse_Button *ev = event;
Evas_Button_Flags flags = EVAS_BUTTON_NONE;
if (ev->window != input_win)
return ECORE_CALLBACK_PASS_ON;
if (!scale_state)
return ECORE_CALLBACK_PASS_ON;
evas_event_feed_mouse_up((Evas *)data, ev->buttons,
flags, ev->timestamp, NULL);
@ -735,7 +761,7 @@ _pager_cb_mouse_down(void *data, int type, void *event)
if (desk)
_pager_desk_select(desk);
}
_pager_out();
return ECORE_CALLBACK_PASS_ON;
}
@ -800,17 +826,14 @@ _pager_switch(const char *params)
desk = e_desk_at_xy_get(zone, desk_x, desk_y);
if (desk) _pager_desk_select(desk);
if (!scale_state)
{
Eina_List *l;
Item *it;
EINA_LIST_FOREACH(items, l, it)
{
it->alpha = 255.0;
evas_object_color_set(it->o_win, 255.0, 255.0, 255.0, 255.0);
}
}
/* if (!scale_state)
* {
* Eina_List *l;
* Item *it;
*
* EINA_LIST_FOREACH(items, l, it)
* evas_object_color_set(it->o, 255.0, 255.0, 255.0, 255.0);
* } */
}
static Eina_Bool
@ -905,6 +928,10 @@ _pager_run(E_Manager *man)
Ecore_Event_Handler *h;
Evas *e;
mouse_activated = 0;
mouse_x = -1;
mouse_y = -1;
if (input_win) return EINA_FALSE;
e = e_manager_comp_evas_get(man);
@ -996,7 +1023,7 @@ _pager_run(E_Manager *man)
EINA_LIST_FOREACH(items, l, it)
if (it->bd->desk != current_desk)
evas_object_color_set(it->o_win, 0, 0, 0, 0);
evas_object_color_set(it->o, 0, 0, 0, 0);
}
evas_event_feed_mouse_in(e, ecore_x_current_time_get(), NULL);
@ -1043,7 +1070,7 @@ _pager_handler(void *data, const char *name, const char *info, int val,
Evas *e;
if (!scale_state) return;
if (strcmp(name, "comp.manager")) return;
DBG("handler... '%s' '%s'\n", name, info);

View File

@ -96,6 +96,11 @@ static int show_all_desks = EINA_FALSE;
static int send_to_desk = EINA_FALSE;
static int scale_layout;
static int init_method = 0;
static int mouse_activated = 0;
static int mouse_x, mouse_y;
static int warp_x, warp_y, warp_pointer;
static double warp_start;
static Ecore_Animator *warp_animator = NULL;
static void
_scale_place_windows(double scale)
@ -115,6 +120,28 @@ _scale_place_windows(double scale)
}
}
static Eina_Bool
_scale_warp_pointer(void *data)
{
Item *it = selected_item;
if (it)
{
double in = (ecore_time_get() - warp_start) / 0.25;
if (in > 1.0) in = 1.0;
ecore_x_pointer_warp(it->bd->zone->container->win,
(double)warp_x * (1.0 - in) + (double)(it->x + it->w/2) * in,
(double)warp_y * (1.0 - in) + (double)(it->y + it->h/2) * in);
if (in < 1.0)
return ECORE_CALLBACK_RENEW;
}
warp_animator = NULL;
return ECORE_CALLBACK_CANCEL;
}
static Eina_Bool
_scale_redraw(void *data)
{
@ -161,6 +188,14 @@ _scale_redraw(void *data)
}
}
if (warp_pointer && selected_item)
{
it = selected_item;
ecore_x_pointer_warp(it->bd->zone->container->win,
(double)warp_x * (1.0 - in) + (double)(it->bd->x + it->bd->w/2) * in,
(double)warp_y * (1.0 - in) + (double)(it->bd->y + it->bd->h/2) * in);
}
if (scale_conf->fade_popups)
{
a = 255.0 * in;
@ -259,6 +294,12 @@ _scale_out(int mode)
if (!scale_animator)
scale_animator = ecore_animator_add(_scale_redraw, NULL);
if (warp_animator)
{
ecore_animator_del(warp_animator);
warp_animator = NULL;
}
if (selected_item)
{
it = selected_item;
@ -268,23 +309,38 @@ _scale_out(int mode)
if ((init_method == GO_KEY) && (e_config->focus_policy != E_FOCUS_CLICK))
{
int slide = e_config->pointer_slide;
int focus = e_config->focus_policy;
/* int slide = e_config->pointer_slide;
* int focus = e_config->focus_policy;
* double warp_speed = e_config->winlist_warp_speed;
*
* e_config->pointer_slide = 1;
* e_config->focus_policy = E_FOCUS_MOUSE;
* e_config->winlist_warp_speed = duration/2.0;
*
* e_border_focus_set_with_pointer(it->bd);
*
* e_config->pointer_slide = slide;
* e_config->focus_policy = focus;
* e_config->winlist_warp_speed = warp_speed; */
/* ecore_x_pointer_warp(it->bd->zone->container->win,
* it->bd->zone->x + it->bd->x + bd->w/2,
* it->bd->zone->y + it->bd->y + bd->h/2); */
e_config->pointer_slide = 1;
e_config->focus_policy = E_FOCUS_MOUSE;
e_border_focus_set_with_pointer(it->bd);
e_config->pointer_slide = slide;
e_config->focus_policy = focus;
warp_pointer = 1;
ecore_x_pointer_xy_get(it->bd->zone->container->win, &warp_x, &warp_y);
e_border_focus_set(it->bd, 1, 1);
}
else
e_border_focus_set(it->bd, 1, 1);
{
e_border_focus_set(it->bd, 1, 1);
}
edje_object_signal_emit(it->o, "hide", "e");
}
EINA_LIST_FOREACH(items, l, it)
edje_object_signal_emit(it->o, "mouse,in", "e");
scale_state = EINA_FALSE;
}
@ -350,10 +406,22 @@ _scale_win_cb_mouse_in(void *data, Evas *e, Evas_Object *obj, void *event_info)
{
Item *it = data;
if (!mouse_activated)
return;
if (!scale_state)
return;
if (it == selected_item)
return;
mouse_activated = 0;
if (selected_item)
edje_object_signal_emit(selected_item->o, "mouse,out", "e");
edje_object_signal_emit(it->o, "mouse,in", "e");
selected_item = it;
}
static void
@ -361,10 +429,14 @@ _scale_win_cb_mouse_out(void *data, Evas *e, Evas_Object *obj, void *event_info)
{
Item *it = data;
if (!mouse_activated)
return;
if (!scale_state)
return;
edje_object_signal_emit(it->o, "mouse,out", "e");
if (it == selected_item)
edje_object_signal_emit(it->o, "mouse,out", "e");
}
static void
@ -1321,45 +1393,15 @@ _scale_place_natural()
}
}
#if 0
static Item *
_scale_item_select(int direction)
static void
_scale_warp_animator_run(Item *it)
{
double min;
Item *last, *min;
Eina_List *l;
ecore_x_pointer_xy_get(it->bd->zone->container->win, &warp_x, &warp_y);
warp_start = ecore_time_get();
if (direction == DIR_RIGHT)
{
EINA_LIST_FOREACH(items, l, it2)
{
}
}
else if (direction == DIR_LEFT)
{
EINA_LIST_FOREACH(items, l, it2)
{
}
}
else if (direction == DIR_UP)
{
EINA_LIST_FOREACH(items, l, it2)
{
}
}
else if (direction == DIR_DOWN)
{
EINA_LIST_FOREACH(items, l, it2)
{
}
}
if (!warp_animator)
warp_animator = ecore_animator_add(_scale_warp_pointer, it);
}
#endif
static void
_scale_switch(const char *params)
@ -1376,7 +1418,7 @@ _scale_switch(const char *params)
if ((!sel->next) || (!sel->prev))
return;
if (!strcmp(params, "_next"))
{
it = sel->next;
@ -1388,11 +1430,11 @@ _scale_switch(const char *params)
else if (!strcmp(params, "_left"))
{
it = sel->prev;
if (it->slot_y != sel->slot_y)
{
it = sel;
while(sel->slot_y == it->next->slot_y)
{
it = it->next;
@ -1403,7 +1445,7 @@ _scale_switch(const char *params)
else if (!strcmp(params, "_right"))
{
it = sel->next;
if (it->slot_y != sel->slot_y)
{
it = sel;
@ -1417,7 +1459,7 @@ _scale_switch(const char *params)
else if (!strcmp(params, "_up"))
{
it = sel;
while((sel->slot_y == it->slot_y) ||
(sel->slot_x < it->slot_x))
{
@ -1428,7 +1470,7 @@ _scale_switch(const char *params)
else if (!strcmp(params, "_down"))
{
it = sel;
while((sel->slot_y == it->slot_y) ||
(sel->slot_x > it->slot_x))
{
@ -1442,14 +1484,17 @@ _scale_switch(const char *params)
edje_object_signal_emit(sel->o, "mouse,out", "e");
edje_object_signal_emit(it->o, "mouse,in", "e");
e_border_focus_set(it->bd, 1, 1);
selected_item = it;
_scale_warp_animator_run(it);
}
static Eina_Bool
_scale_cb_key_down(void *data, int type, void *event)
{
Ecore_Event_Key *ev = event;
printf("key down\n");
if (ev->window != input_win)
return ECORE_CALLBACK_PASS_ON;
@ -1549,7 +1594,12 @@ _scale_run(E_Manager *man)
int i;
Item *it;
E_Border *bd;
mouse_activated = 0;
mouse_x = -1;
mouse_y = -1;
warp_pointer = 0;
e = e_manager_comp_evas_get(man);
if (!e) return EINA_FALSE;
@ -1689,31 +1739,59 @@ _scale_run(E_Manager *man)
DBG("time: %f\n", ecore_time_get() - start_time);
evas_event_feed_mouse_in(e, ecore_x_current_time_get(), NULL);
evas_event_feed_mouse_move(e, -1000000, -1000000,
ecore_x_current_time_get(), NULL);
it = NULL;
bd = NULL;
bd = e_border_focused_get();
if (init_method == GO_KEY)
{
E_Border *bd2 = NULL;
EINA_LIST_FOREACH(items, l , it)
if (it->bd == bd) break;
EINA_LIST_FOREACH(e_border_focus_stack_get(), l, bd)
if ((bd != bd2) && (bd->desk == current_desk))
{
if (!bd2) bd2 = bd;
else break;
}
if (!bd) bd = bd2;
}
else
{
EINA_LIST_FOREACH(e_border_focus_stack_get(), l, bd)
if (bd->desk == current_desk) break;
}
if (bd)
{
EINA_LIST_FOREACH(items, l, it)
if (it->bd == bd) break;
}
if (it)
selected_item = it;
else
selected_item = eina_list_data_get(items);
edje_object_signal_emit(selected_item->o, "mouse,in", "e");
if (scale_conf->pager_fade_windows)
EINA_LIST_FOREACH(items, l, it)
{
EINA_LIST_FOREACH(items, l, it)
if (it->bd->desk != current_desk)
evas_object_color_set(it->o, 0, 0, 0, 0);
if (it != selected_item)
edje_object_signal_emit(it->o, "mouse,out", "e");
if (scale_conf->fade_windows)
{
if (it->bd->desk != current_desk)
evas_object_color_set(it->o, 0, 0, 0, 0);
}
}
_scale_in();
if (init_method == GO_KEY)
_scale_warp_animator_run(selected_item);
evas_event_feed_mouse_in(e, ecore_x_current_time_get(), NULL);
evas_event_feed_mouse_move(e, -1000000, -1000000,
ecore_x_current_time_get(), NULL);
return EINA_TRUE;
}
@ -1723,6 +1801,28 @@ _scale_cb_mouse_move(void *data, int type, void *event)
{
Ecore_Event_Mouse_Move *ev = event;
/* wtf?! dont need move events when nothing is moving */
if (ev->window != input_win)
return ECORE_CALLBACK_PASS_ON;
if (!scale_state)
return ECORE_CALLBACK_PASS_ON;
if (warp_animator)
return ECORE_CALLBACK_PASS_ON;
if (mouse_x < 0)
{
mouse_x = ev->x;
mouse_y = ev->y;
return ECORE_CALLBACK_PASS_ON;
}
if ((mouse_x == ev->x) || (mouse_y == ev->y))
return ECORE_CALLBACK_PASS_ON;
mouse_activated = 1;
printf("mouse move %d %d\n", ev->x, ev->y);
evas_event_feed_mouse_move((Evas *) data, ev->x, ev->y, ev->timestamp, NULL);
return ECORE_CALLBACK_PASS_ON;
@ -1736,6 +1836,9 @@ _scale_cb_mouse_down(void *data, int type, void *event)
Eina_List *l;
Item *it;
if (ev->window != input_win)
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;
@ -1759,6 +1862,9 @@ _scale_cb_mouse_up(void *data, int type, void *event)
Ecore_Event_Mouse_Button *ev = event;
Evas_Button_Flags flags = EVAS_BUTTON_NONE;
if (ev->window != input_win)
return ECORE_CALLBACK_PASS_ON;
evas_event_feed_mouse_up((Evas *)data, ev->buttons, flags, ev->timestamp, NULL);
return ECORE_CALLBACK_PASS_ON;
@ -1816,7 +1922,7 @@ _scale_handler(void *data, const char *name, const char *info, int val,
if (strcmp(name, "comp.manager")) return;
DBG("handler... '%s' '%s'\n", name, info);
/* XXX disabled for now. */
return;