Hi, some remarks,
On Sat, Feb 24, 2007 at 07:44:38PM +0100, Jan Christoph Ebersbach wrote:
> +void
> +moveresize(const char *arg) {
> + if (!sel || !sel->isfloating || strlen(arg) == 0) { return; }
You should also return if the client isfixed.
> + int *rs_val = NULL;
> +
> + Client tmp_client;
> + tmp_client.x = sel->x;
> + tmp_client.y = sel->y;
> + tmp_client.w = sel->w;
> + tmp_client.h = sel->h;
Actually I don't understand why do you re-use Client here, why
not int x, y, w, h?
> + switch (arg[0])
> + {
> + case 'x': rs_val = &(tmp_client.x); break;
> + case 'y': rs_val = &(tmp_client.y); break;
> + case 'w': rs_val = &(tmp_client.w); break;
> + case 'h': rs_val = &(tmp_client.h); break;
> + default: return;
> + }
> +
> + if (arg[1] == '-' || arg[1] == '+')
> + /* relative resize instead of absolute */
> + (*rs_val) += atoi(arg+1);
> + else
> + (*rs_val) = atoi(arg+1);
Hmm, why all this complexity? Why not defining, a simple
if(sscanf(arg, "%d %d %d %d", &x, &y, &w, &h) != 4)
return;
This all with the format
moveresize("x y w h");
whereas all arguments are interpreted relatively (like in wmii),
e.g.:
moveresize("-32 0 0 0");
would perform a left-move of the specific client with 32 pixels.
So my version would probably look like (note untested):
void
moveresize(const char *arg) {
int x, y, w, h, nx, ny, nw, nh;
if(!sel || !sel->isfloating || sel->isfixed || !arg)
return;
if(sscanf(arg, "%d %d %d %d", &x, &y, &w, &h) != 4)
return;
nx = sel->x + x;
ny = sel->y + y;
nw = sel->w + w;
nh = sel->h + h;
resize(sel, nx, ny, nw, nh, True);
}
Also note, the last parameter should be True, because
keyboard-driven resizals won't behave correctly without
increment handling (and aspect ratio).
Regards,
-- Anselm R. Garbe >< http://www.suckless.org/ >< GPG key: 0D73F361Received on Sun Feb 25 2007 - 12:03:13 UTC
This archive was generated by hypermail 2.2.0 : Sun Jul 13 2008 - 14:38:14 UTC