Hello, I recently bought a big monitor, and with that I started to miss some way of moving windows quickly to where I wanted them. I generally want the windows to line up nicely, so I've coded a new action that lets you "push" a window up/down/left/right until it collides with another window. I've been using the code for several weeks now and I'm very happy with it. I hope it can be useful for someone else too, so please consider including it in the repository.
Index: src/bin/e_actions.c =================================================================== RCS file: /var/cvs/e/e17/apps/e/src/bin/e_actions.c,v retrieving revision 1.89 diff -u -3 -r1.89 e_actions.c --- src/bin/e_actions.c 29 Dec 2006 02:56:25 -0000 1.89 +++ src/bin/e_actions.c 5 Jan 2007 00:51:06 -0000 @@ -728,6 +728,90 @@ } /***************************************************************************/ +ACT_FN_GO(window_push) +{ + if (!obj) obj = E_OBJECT(e_border_focused_get()); + if (!obj) return; + if (obj->type != E_BORDER_TYPE) + { + obj = E_OBJECT(e_border_focused_get()); + if (!obj) return; + } + + if (params) + { + E_Border *bd, *cur; + E_Border_List *bd_list; + E_Direction dir; + int x, y; + + if (strcmp(params, "left") == 0) + dir = E_DIRECTION_LEFT; + else if (strcmp(params, "right") == 0) + dir = E_DIRECTION_RIGHT; + else if (strcmp(params, "up") == 0) + dir = E_DIRECTION_UP; + else if (strcmp(params, "down") == 0) + dir = E_DIRECTION_DOWN; + else + return; + + bd = (E_Border *)obj; + + /* Target x and y. */ + x = bd->x; + y = bd->y; + + if (dir == E_DIRECTION_LEFT) + x = 0; + else if (dir == E_DIRECTION_RIGHT) + x = bd->zone->w - bd->w; + else if (dir == E_DIRECTION_UP) + y = 0; + else // dir == E_DIRECTION_DOWN + y = bd->zone->h - bd->h; + + bd_list = e_container_border_list_first(bd->zone->container); + cur = e_container_border_list_next(bd_list); + + while (cur != NULL) + { + if ((bd->desk == cur->desk) && (bd != cur)) + { + if ((dir == E_DIRECTION_LEFT) + && (cur->x + cur->w < bd->x) + && (E_SPANS_COMMON(bd->y, bd->h, cur->y, cur->h))) + x = MAX(x, cur->x + cur->w); + else if ((dir == E_DIRECTION_RIGHT) + && (cur->x > bd->x + bd->w) + && (E_SPANS_COMMON(bd->y, bd->h, cur->y, cur->h))) + x = MIN(x, cur->x - bd->w); + else if ((dir == E_DIRECTION_UP) + && (cur->y + cur->h < bd->y) + && (E_SPANS_COMMON(bd->x, bd->w, cur->x, cur->w))) + y = MAX(y, cur->y + cur->h); + else if ((dir == E_DIRECTION_DOWN) + && (cur->y > bd->y + bd->h) + && (E_SPANS_COMMON(bd->x, bd->w, cur->x, cur->w))) + y = MIN(y, cur->y - bd->h); + } + cur = e_container_border_list_next(bd_list); + } + e_container_border_list_free(bd_list); + + if ((x != bd->x) || (y != bd->y)) + { + e_border_move(bd, x, y); + + if (e_config->focus_policy != E_FOCUS_CLICK) + ecore_x_pointer_warp(bd->zone->container->win, + bd->x + (bd->w / 2), + bd->y + (bd->h / 2)); + } + } +} + +/***************************************************************************/ ACT_FN_GO(window_drag_icon) { if (!obj) obj = E_OBJECT(e_border_focused_get()); @@ -1949,6 +2033,11 @@ ACT_GO(window_resize_by); e_action_predef_name_set(_("Window : Actions"), "Resize By...", "window_resize_by", NULL, "syntax: W H, example: 100 150", 1); + + /* window_push */ + ACT_GO(window_push); + e_action_predef_name_set(_("Window : Actions"), "Push in Direction...", "window_push", NULL, + "syntax: direction, example: up, down, left, right", 1); /* window_drag_icon */ ACT_GO(window_drag_icon);
-- Martin Geisler --- <mgeisler@mgeisler.net> --- http://mgeisler.net Read, write, create Exif data in PHP with PEL: http://pel.sf.net Take control of your webserver with PHP Shell: http://phpshell.sf.net
Attachment:
pgpkQ7T_juUCA.pgp
Description: PGP signature