winlist: add actions to move to window on the left/right/up/down

SVN revision: 50096
This commit is contained in:
Boris Faure 2010-07-07 21:36:23 +00:00
parent 6f75a8d25c
commit 682783f271
3 changed files with 592 additions and 22 deletions

View File

@ -35,6 +35,14 @@ e_modapi_init(E_Module *m)
"next", NULL, 0);
e_action_predef_name_set(_("Window : List"), _("Previous Window"),
"winlist", "prev", NULL, 0);
e_action_predef_name_set(_("Window : List"), _("Window on the Left"),
"winlist", "left", NULL, 0);
e_action_predef_name_set(_("Window : List"), _("Window Down"),
"winlist", "down", NULL, 0);
e_action_predef_name_set(_("Window : List"), _("Window Up"),
"winlist", "up", NULL, 0);
e_action_predef_name_set(_("Window : List"), _("Window on the Right"),
"winlist", "right", NULL, 0);
}
e_module_delayed_set(m, 1);
return m;
@ -48,6 +56,10 @@ e_modapi_shutdown(E_Module *m)
{
e_action_predef_name_del(_("Window : List"), _("Previous Window"));
e_action_predef_name_del(_("Window : List"), _("Next Window"));
e_action_predef_name_del(_("Window : List"), _("Window on the Left"));
e_action_predef_name_del(_("Window : List"), _("Window Down"));
e_action_predef_name_del(_("Window : List"), _("Window Up"));
e_action_predef_name_del(_("Window : List"), _("Window on the Right"));
e_action_del("winlist");
act = NULL;
}
@ -94,6 +106,22 @@ _e_mod_action_winlist_cb(E_Object *obj, const char *params)
if (!e_winlist_show(zone))
e_winlist_prev();
}
else if (!strcmp(params, "left"))
{
e_winlist_left(zone);
}
else if (!strcmp(params, "down"))
{
e_winlist_down(zone);
}
else if (!strcmp(params, "up"))
{
e_winlist_up(zone);
}
else if (!strcmp(params, "right"))
{
e_winlist_right(zone);
}
}
else
{
@ -138,6 +166,22 @@ _e_mod_action_winlist_mouse_cb(E_Object *obj, const char *params, Ecore_Event_Mo
else
e_winlist_prev();
}
else if (!strcmp(params, "left"))
{
e_winlist_left(zone);
}
else if (!strcmp(params, "down"))
{
e_winlist_down(zone);
}
else if (!strcmp(params, "up"))
{
e_winlist_up(zone);
}
else if (!strcmp(params, "right"))
{
e_winlist_right(zone);
}
}
else
{
@ -184,6 +228,22 @@ _e_mod_action_winlist_key_cb(E_Object *obj, const char *params, Ecore_Event_Key
else
e_winlist_prev();
}
else if (!strcmp(params, "left"))
{
e_winlist_left(zone);
}
else if (!strcmp(params, "down"))
{
e_winlist_down(zone);
}
else if (!strcmp(params, "up"))
{
e_winlist_up(zone);
}
else if (!strcmp(params, "right"))
{
e_winlist_right(zone);
}
}
else
{

View File

@ -65,6 +65,8 @@ static double scroll_align = 0.0;
static Ecore_Timer *warp_timer = NULL;
static Ecore_Timer *scroll_timer = NULL;
static Ecore_Animator *animator = NULL;
static const Ecore_X_Window *win = NULL;
static E_Border *bd_next = NULL;
/* externally accessible functions */
int
@ -358,6 +360,474 @@ e_winlist_prev(void)
_e_winlist_activate();
}
void
e_winlist_left(E_Zone *zone)
{
int x, y, w, h;
Eina_List *l;
E_Desk *desk;
E_Border *bd_orig;
int delta = 9999999;
int center;
bd_next = NULL;
E_OBJECT_CHECK_RETURN(zone, 0);
E_OBJECT_TYPE_CHECK_RETURN(zone, E_ZONE_TYPE, 0);
bd_orig = e_border_focused_get();
if (!bd_orig) return;
center = bd_orig->x + bd_orig->w/2;
desk = e_desk_current_get(zone);
e_border_focus_track_freeze();
for (l = e_border_focus_stack_get(); l; l = l->next)
{
E_Border *bd = l->data;
E_Winlist_Win *ww;
Evas_Coord mw, mh;
Evas_Object *o;
int center_next;
int delta_next;
if (bd == bd_orig) continue;
if ((!bd->client.icccm.accepts_focus) &&
(!bd->client.icccm.take_focus)) continue;
if (bd->client.netwm.state.skip_taskbar) continue;
if (bd->user_skip_winlist) continue;
if (bd->iconic)
{
if (!e_config->winlist_list_show_iconified) continue;
if ((bd->zone != zone) &&
(!e_config->winlist_list_show_other_screen_iconified)) continue;
if ((bd->desk != desk) &&
(!e_config->winlist_list_show_other_desk_iconified)) continue;
}
else
{
if (bd->sticky)
{
if ((bd->zone != zone) &&
(!e_config->winlist_list_show_other_screen_windows)) continue;
}
else
{
if (bd->desk != desk)
{
if ((bd->zone) && (bd->zone != zone))
{
if (!e_config->winlist_list_show_other_screen_windows)
continue;
}
else if (!e_config->winlist_list_show_other_desk_windows)
continue;
}
}
}
/* bd is suitable */
center_next = bd->x + bd->w/2;
if (center_next >= center) continue;
delta_next = bd_orig->x - (bd->x + bd->w);
if (delta_next < 0) delta = center - center_next;
if (delta_next >= 0 && delta_next < delta)
{
bd_next = bd;
delta = delta_next;
}
}
e_border_focus_track_thaw();
if (bd_next)
{
if (!bd_orig->lock_focus_out)
e_border_focus_set(bd_orig, 0, 0);
if ((e_config->focus_policy != E_FOCUS_CLICK) ||
(e_config->winlist_warp_at_end) ||
(e_config->winlist_warp_while_selecting))
{
warp_to_x = bd_next->x + (bd_next->w / 2);
if (warp_to_x < (bd_next->zone->x + 1))
warp_to_x = bd_next->zone->x + ((bd_next->x + bd_next->w - bd_next->zone->x) / 2);
else if (warp_to_x >= (bd_next->zone->x + bd_next->zone->w - 1))
warp_to_x = (bd_next->zone->x + bd_next->zone->w + bd_next->x) / 2;
warp_to_y = bd_next->y + (bd_next->h / 2);
if (warp_to_y < (bd_next->zone->y + 1))
warp_to_y = bd_next->zone->y + ((bd_next->y + bd_next->h - bd_next->zone->y) / 2);
else if (warp_to_y >= (bd_next->zone->y + bd_next->zone->h - 1))
warp_to_y = (bd_next->zone->y + bd_next->zone->h + bd_next->y) / 2;
}
ecore_x_pointer_xy_get(zone->container->win, &warp_x, &warp_y);
win = &zone->container->win;
e_border_focus_latest_set(bd_next);
warp_to = 1;
if (!warp_timer)
warp_timer = ecore_timer_add(0.01, _e_winlist_warp_timer, NULL);
if (!animator)
animator = ecore_animator_add(_e_winlist_animator, NULL);
if ((!bd_next->lock_user_stacking) && (e_config->winlist_list_raise_while_selecting))
e_border_raise(bd_next);
if ((!bd_next->lock_focus_out) && (e_config->winlist_list_focus_while_selecting))
e_border_focus_set(bd_next, 1, 1);
}
}
void
e_winlist_down(E_Zone *zone)
{
int x, y, w, h;
Eina_List *l;
E_Desk *desk;
E_Border *bd_orig;
int delta = 9999999;
int center;
bd_next = NULL;
E_OBJECT_CHECK_RETURN(zone, 0);
E_OBJECT_TYPE_CHECK_RETURN(zone, E_ZONE_TYPE, 0);
bd_orig = e_border_focused_get();
if (!bd_orig) return;
center = bd_orig->y + bd_orig->h/2;
desk = e_desk_current_get(zone);
e_border_focus_track_freeze();
for (l = e_border_focus_stack_get(); l; l = l->next)
{
E_Border *bd = l->data;
E_Winlist_Win *ww;
Evas_Coord mw, mh;
Evas_Object *o;
int center_next;
int delta_next;
if (bd == bd_orig) continue;
if ((!bd->client.icccm.accepts_focus) &&
(!bd->client.icccm.take_focus)) continue;
if (bd->client.netwm.state.skip_taskbar) continue;
if (bd->user_skip_winlist) continue;
if (bd->iconic)
{
if (!e_config->winlist_list_show_iconified) continue;
if ((bd->zone != zone) &&
(!e_config->winlist_list_show_other_screen_iconified)) continue;
if ((bd->desk != desk) &&
(!e_config->winlist_list_show_other_desk_iconified)) continue;
}
else
{
if (bd->sticky)
{
if ((bd->zone != zone) &&
(!e_config->winlist_list_show_other_screen_windows)) continue;
}
else
{
if (bd->desk != desk)
{
if ((bd->zone) && (bd->zone != zone))
{
if (!e_config->winlist_list_show_other_screen_windows)
continue;
}
else if (!e_config->winlist_list_show_other_desk_windows)
continue;
}
}
}
/* bd is suitable */
center_next = bd->y + bd->h/2;
if (center_next <= center) continue;
delta_next = bd->y - (bd_orig->y + bd_orig->h);
if (delta_next < 0) delta = center - center_next;
if (delta_next >= 0 && delta_next < delta)
{
bd_next = bd;
delta = delta_next;
}
}
e_border_focus_track_thaw();
if (bd_next)
{
if (!bd_orig->lock_focus_out)
e_border_focus_set(bd_orig, 0, 0);
if ((e_config->focus_policy != E_FOCUS_CLICK) ||
(e_config->winlist_warp_at_end) ||
(e_config->winlist_warp_while_selecting))
{
warp_to_x = bd_next->x + (bd_next->w / 2);
if (warp_to_x < (bd_next->zone->x + 1))
warp_to_x = bd_next->zone->x + ((bd_next->x + bd_next->w - bd_next->zone->x) / 2);
else if (warp_to_x >= (bd_next->zone->x + bd_next->zone->w - 1))
warp_to_x = (bd_next->zone->x + bd_next->zone->w + bd_next->x) / 2;
warp_to_y = bd_next->y + (bd_next->h / 2);
if (warp_to_y < (bd_next->zone->y + 1))
warp_to_y = bd_next->zone->y + ((bd_next->y + bd_next->h - bd_next->zone->y) / 2);
else if (warp_to_y >= (bd_next->zone->y + bd_next->zone->h - 1))
warp_to_y = (bd_next->zone->y + bd_next->zone->h + bd_next->y) / 2;
}
ecore_x_pointer_xy_get(zone->container->win, &warp_x, &warp_y);
win = &zone->container->win;
e_border_focus_latest_set(bd_next);
warp_to = 1;
if (!warp_timer)
warp_timer = ecore_timer_add(0.01, _e_winlist_warp_timer, NULL);
if (!animator)
animator = ecore_animator_add(_e_winlist_animator, NULL);
if ((!bd_next->lock_user_stacking) && (e_config->winlist_list_raise_while_selecting))
e_border_raise(bd_next);
if ((!bd_next->lock_focus_out) && (e_config->winlist_list_focus_while_selecting))
e_border_focus_set(bd_next, 1, 1);
}
}
void
e_winlist_up(E_Zone *zone)
{
int x, y, w, h;
Eina_List *l;
E_Desk *desk;
E_Border *bd_orig;
int delta = 9999999;
int center;
bd_next = NULL;
E_OBJECT_CHECK_RETURN(zone, 0);
E_OBJECT_TYPE_CHECK_RETURN(zone, E_ZONE_TYPE, 0);
bd_orig = e_border_focused_get();
if (!bd_orig) return;
center = bd_orig->y + bd_orig->h/2;
desk = e_desk_current_get(zone);
e_border_focus_track_freeze();
for (l = e_border_focus_stack_get(); l; l = l->next)
{
E_Border *bd = l->data;
E_Winlist_Win *ww;
Evas_Coord mw, mh;
Evas_Object *o;
int center_next;
int delta_next;
if (bd == bd_orig) continue;
if ((!bd->client.icccm.accepts_focus) &&
(!bd->client.icccm.take_focus)) continue;
if (bd->client.netwm.state.skip_taskbar) continue;
if (bd->user_skip_winlist) continue;
if (bd->iconic)
{
if (!e_config->winlist_list_show_iconified) continue;
if ((bd->zone != zone) &&
(!e_config->winlist_list_show_other_screen_iconified)) continue;
if ((bd->desk != desk) &&
(!e_config->winlist_list_show_other_desk_iconified)) continue;
}
else
{
if (bd->sticky)
{
if ((bd->zone != zone) &&
(!e_config->winlist_list_show_other_screen_windows)) continue;
}
else
{
if (bd->desk != desk)
{
if ((bd->zone) && (bd->zone != zone))
{
if (!e_config->winlist_list_show_other_screen_windows)
continue;
}
else if (!e_config->winlist_list_show_other_desk_windows)
continue;
}
}
}
/* bd is suitable */
center_next = bd->y + bd->h/2;
if (center_next >= center) continue;
delta_next = bd_orig->y - (bd->y + bd->h);
if (delta_next < 0) delta = center - center_next;
if (delta_next >= 0 && delta_next < delta)
{
bd_next = bd;
delta = delta_next;
}
}
e_border_focus_track_thaw();
if (bd_next)
{
if (!bd_orig->lock_focus_out)
e_border_focus_set(bd_orig, 0, 0);
if ((e_config->focus_policy != E_FOCUS_CLICK) ||
(e_config->winlist_warp_at_end) ||
(e_config->winlist_warp_while_selecting))
{
warp_to_x = bd_next->x + (bd_next->w / 2);
if (warp_to_x < (bd_next->zone->x + 1))
warp_to_x = bd_next->zone->x + ((bd_next->x + bd_next->w - bd_next->zone->x) / 2);
else if (warp_to_x >= (bd_next->zone->x + bd_next->zone->w - 1))
warp_to_x = (bd_next->zone->x + bd_next->zone->w + bd_next->x) / 2;
warp_to_y = bd_next->y + (bd_next->h / 2);
if (warp_to_y < (bd_next->zone->y + 1))
warp_to_y = bd_next->zone->y + ((bd_next->y + bd_next->h - bd_next->zone->y) / 2);
else if (warp_to_y >= (bd_next->zone->y + bd_next->zone->h - 1))
warp_to_y = (bd_next->zone->y + bd_next->zone->h + bd_next->y) / 2;
}
ecore_x_pointer_xy_get(zone->container->win, &warp_x, &warp_y);
win = &zone->container->win;
e_border_focus_latest_set(bd_next);
warp_to = 1;
if (!warp_timer)
warp_timer = ecore_timer_add(0.01, _e_winlist_warp_timer, NULL);
if (!animator)
animator = ecore_animator_add(_e_winlist_animator, NULL);
if ((!bd_next->lock_user_stacking) && (e_config->winlist_list_raise_while_selecting))
e_border_raise(bd_next);
if ((!bd_next->lock_focus_out) && (e_config->winlist_list_focus_while_selecting))
e_border_focus_set(bd_next, 1, 1);
}
}
void
e_winlist_right(E_Zone *zone)
{
int x, y, w, h;
Eina_List *l;
E_Desk *desk;
E_Border *bd_orig;
int delta = 9999999;
int center;
bd_next = NULL;
E_OBJECT_CHECK_RETURN(zone, 0);
E_OBJECT_TYPE_CHECK_RETURN(zone, E_ZONE_TYPE, 0);
bd_orig = e_border_focused_get();
if (!bd_orig) return;
center = bd_orig->x + bd_orig->w/2;
desk = e_desk_current_get(zone);
e_border_focus_track_freeze();
for (l = e_border_focus_stack_get(); l; l = l->next)
{
E_Border *bd = l->data;
E_Winlist_Win *ww;
Evas_Coord mw, mh;
Evas_Object *o;
int center_next;
int delta_next;
if (bd == bd_orig) continue;
if ((!bd->client.icccm.accepts_focus) &&
(!bd->client.icccm.take_focus)) continue;
if (bd->client.netwm.state.skip_taskbar) continue;
if (bd->user_skip_winlist) continue;
if (bd->iconic)
{
if (!e_config->winlist_list_show_iconified) continue;
if ((bd->zone != zone) &&
(!e_config->winlist_list_show_other_screen_iconified)) continue;
if ((bd->desk != desk) &&
(!e_config->winlist_list_show_other_desk_iconified)) continue;
}
else
{
if (bd->sticky)
{
if ((bd->zone != zone) &&
(!e_config->winlist_list_show_other_screen_windows)) continue;
}
else
{
if (bd->desk != desk)
{
if ((bd->zone) && (bd->zone != zone))
{
if (!e_config->winlist_list_show_other_screen_windows)
continue;
}
else if (!e_config->winlist_list_show_other_desk_windows)
continue;
}
}
}
/* bd is suitable */
center_next = bd->x + bd->w/2;
if (center_next <= center) continue;
delta_next = bd->x - (bd_orig->x + bd_orig->w);
if (delta_next < 0) delta = center_next - center;
if (delta_next >= 0 && delta_next < delta)
{
bd_next = bd;
delta = delta_next;
}
}
e_border_focus_track_thaw();
if (bd_next)
{
if (!bd_orig->lock_focus_out)
e_border_focus_set(bd_orig, 0, 0);
if ((e_config->focus_policy != E_FOCUS_CLICK) ||
(e_config->winlist_warp_at_end) ||
(e_config->winlist_warp_while_selecting))
{
warp_to_x = bd_next->x + (bd_next->w / 2);
if (warp_to_x < (bd_next->zone->x + 1))
warp_to_x = bd_next->zone->x + ((bd_next->x + bd_next->w - bd_next->zone->x) / 2);
else if (warp_to_x >= (bd_next->zone->x + bd_next->zone->w - 1))
warp_to_x = (bd_next->zone->x + bd_next->zone->w + bd_next->x) / 2;
warp_to_y = bd_next->y + (bd_next->h / 2);
if (warp_to_y < (bd_next->zone->y + 1))
warp_to_y = bd_next->zone->y + ((bd_next->y + bd_next->h - bd_next->zone->y) / 2);
else if (warp_to_y >= (bd_next->zone->y + bd_next->zone->h - 1))
warp_to_y = (bd_next->zone->y + bd_next->zone->h + bd_next->y) / 2;
}
ecore_x_pointer_xy_get(zone->container->win, &warp_x, &warp_y);
win = &zone->container->win;
e_border_focus_latest_set(bd_next);
warp_to = 1;
if (!warp_timer)
warp_timer = ecore_timer_add(0.01, _e_winlist_warp_timer, NULL);
if (!animator)
animator = ecore_animator_add(_e_winlist_animator, NULL);
if ((!bd_next->lock_user_stacking) && (e_config->winlist_list_raise_while_selecting))
e_border_raise(bd_next);
if ((!bd_next->lock_focus_out) && (e_config->winlist_list_focus_while_selecting))
e_border_focus_set(bd_next, 1, 1);
}
}
void
e_winlist_modifiers_set(int mod)
{
@ -597,6 +1067,7 @@ _e_winlist_activate(void)
if (e_config->winlist_warp_while_selecting)
{
ecore_x_pointer_xy_get(winlist->zone->container->win, &warp_x, &warp_y);
win = &winlist->zone->container->win;
e_border_focus_latest_set(ww->border);
warp_to = 1;
if (!warp_timer)
@ -1014,8 +1485,7 @@ _e_winlist_animator(__UNUSED__ void *data)
warp_y = warp_to_y;
warp_to = 0;
}
ecore_x_pointer_warp(winlist->zone->container->win,
warp_x, warp_y);
if (win) ecore_x_pointer_warp(*win, warp_x, warp_y);
}
if (scroll_to)
{
@ -1032,6 +1502,42 @@ _e_winlist_animator(__UNUSED__ void *data)
}
if ((warp_to) || (scroll_to)) return ECORE_CALLBACK_RENEW;
animator = NULL;
if (bd_next)
{
if (bd_next->iconic)
{
if (!bd_next->lock_user_iconify)
e_border_uniconify(bd_next);
}
if (bd_next->shaded)
{
if (!bd_next->lock_user_shade)
e_border_unshade(bd_next, bd_next->shade.dir);
}
else if (bd_next->desk)
{
if (!bd_next->sticky) e_desk_show(bd_next->desk);
}
if (!bd_next->lock_user_stacking)
e_border_raise(bd_next);
if (!bd_next->lock_focus_out)
{
e_border_focus_set(bd_next, 1, 1);
e_border_focus_latest_set(bd_next);
}
if ((e_config->focus_policy != E_FOCUS_CLICK) ||
(e_config->winlist_warp_at_end) ||
(e_config->winlist_warp_while_selecting))
ecore_x_pointer_warp(bd_next->zone->container->win, warp_to_x, warp_to_y);
bd_next = NULL;
if (warp_timer)
{
ecore_timer_del(warp_timer);
warp_timer = NULL;
}
}
win = NULL;
return ECORE_CALLBACK_CANCEL;
}

View File

@ -14,6 +14,10 @@ int e_winlist_show(E_Zone *zone);
void e_winlist_hide(void);
void e_winlist_next(void);
void e_winlist_prev(void);
void e_winlist_left(E_Zone *zone);
void e_winlist_right(E_Zone *zone);
void e_winlist_down(E_Zone *zone);
void e_winlist_up(E_Zone *zone);
void e_winlist_modifiers_set(int mod);
#endif