Allow FillToEdge to grow when all its edges are blocked.

This change points out how useless the return value from client_find_resize_directional()
was, so it also removes that.

When all edges are blocked, the FillToEdge action will try to grow all four edges agin
without blocking any of them on their current edge. This more closely matches the
behaviour of the GrowToEdge action.
This commit is contained in:
Dana Jansens 2013-09-01 17:37:53 -04:00
parent f5e9df18a4
commit e6a0beb34b
3 changed files with 79 additions and 72 deletions

View file

@ -123,6 +123,58 @@ static gboolean do_grow(ObActionsData *data, gint x, gint y, gint w, gint h)
return FALSE; return FALSE;
} }
static gboolean do_grow_all_edges(ObActionsData* data,
ObClientDirectionalResizeType resize_type)
{
gint x, y, w, h;
gint temp_x, temp_y, temp_w, temp_h;
client_find_resize_directional(data->client,
OB_DIRECTION_NORTH,
resize_type,
&temp_x, &temp_y, &temp_w, &temp_h);
y = temp_y;
h = temp_h;
client_find_resize_directional(data->client,
OB_DIRECTION_SOUTH,
resize_type,
&temp_x, &temp_y, &temp_w, &temp_h);
h += temp_h - data->client->area.height;
client_find_resize_directional(data->client,
OB_DIRECTION_WEST,
resize_type,
&temp_x, &temp_y, &temp_w, &temp_h);
x = temp_x;
w = temp_w;
client_find_resize_directional(data->client,
OB_DIRECTION_EAST,
resize_type,
&temp_x, &temp_y, &temp_w, &temp_h);
w += temp_w - data->client->area.width;
/* When filling, we allow the window to move to an arbitrary x/y
position, since we'll be growing the other edge as well. */
int lw, lh;
client_try_configure(data->client, &x, &y, &w, &h, &lw, &lh, TRUE);
if (x == data->client->area.x &&
y == data->client->area.y &&
w == data->client->area.width &&
h == data->client->area.height)
{
return FALSE;
}
actions_client_move(data, TRUE);
client_move_resize(data->client, x, y, w, h);
actions_client_move(data, FALSE);
return TRUE;
}
static void free_func(gpointer o) static void free_func(gpointer o)
{ {
g_slice_free(Options, o); g_slice_free(Options, o);
@ -132,20 +184,16 @@ static void free_func(gpointer o)
static gboolean run_func(ObActionsData *data, gpointer options) static gboolean run_func(ObActionsData *data, gpointer options)
{ {
Options *o = options; Options *o = options;
gint x, y, w, h;
gint half;
if (!data->client) if (!data->client)
return FALSE; return FALSE;
if (data->client->shaded) {
gboolean doing_verical_resize = gboolean doing_verical_resize =
o->dir == OB_DIRECTION_NORTH || o->dir == OB_DIRECTION_NORTH ||
o->dir == OB_DIRECTION_SOUTH || o->dir == OB_DIRECTION_SOUTH ||
o->fill; o->fill;
if (doing_verical_resize) if (data->client->shaded && doing_verical_resize)
return FALSE; return FALSE;
}
if (o->fill) { if (o->fill) {
if (o->shrink) { if (o->shrink) {
@ -154,53 +202,18 @@ static gboolean run_func(ObActionsData *data, gpointer options)
return FALSE; return FALSE;
} }
ObClientDirectionalResizeType grow = CLIENT_RESIZE_GROW_IF_NOT_ON_EDGE; if (do_grow_all_edges(data, CLIENT_RESIZE_GROW_IF_NOT_ON_EDGE))
return FALSE;
gint temp_x; /* If all the edges are blocked, then allow them to jump past their
gint temp_y; current block points. */
gint temp_w; do_grow_all_edges(data, CLIENT_RESIZE_GROW);
gint temp_h;
client_find_resize_directional(data->client,
OB_DIRECTION_NORTH,
grow,
&temp_x, &temp_y, &temp_w, &temp_h);
y = temp_y;
h = temp_h;
client_find_resize_directional(data->client,
OB_DIRECTION_SOUTH,
grow,
&temp_x, &temp_y, &temp_w, &temp_h);
h += temp_h - data->client->area.height;
client_find_resize_directional(data->client,
OB_DIRECTION_WEST,
grow,
&temp_x, &temp_y, &temp_w, &temp_h);
x = temp_x;
w = temp_w;
client_find_resize_directional(data->client,
OB_DIRECTION_EAST,
grow,
&temp_x, &temp_y, &temp_w, &temp_h);
w += temp_w - data->client->area.width;
/* When filling, we allow the window to move to an arbitrary x/y
position, since we'll be growing the other edge as well. */
if (x != data->client->area.x || y != data->client->area.y ||
w != data->client->area.width || h != data->client->area.height)
{
actions_client_move(data, TRUE);
client_move_resize(data->client, x, y, w, h);
actions_client_move(data, FALSE);
}
return FALSE; return FALSE;
} }
if (!o->shrink) { if (!o->shrink) {
gint x, y, w, h;
/* Try grow. */ /* Try grow. */
client_find_resize_directional(data->client, client_find_resize_directional(data->client,
o->dir, o->dir,
@ -217,10 +230,15 @@ static gboolean run_func(ObActionsData *data, gpointer options)
(o->dir == OB_DIRECTION_SOUTH ? OB_DIRECTION_NORTH : (o->dir == OB_DIRECTION_SOUTH ? OB_DIRECTION_NORTH :
(o->dir == OB_DIRECTION_EAST ? OB_DIRECTION_WEST : (o->dir == OB_DIRECTION_EAST ? OB_DIRECTION_WEST :
OB_DIRECTION_EAST))); OB_DIRECTION_EAST)));
gint x, y, w, h;
gint half;
client_find_resize_directional(data->client, client_find_resize_directional(data->client,
opposite, opposite,
CLIENT_RESIZE_SHRINK, CLIENT_RESIZE_SHRINK,
&x, &y, &w, &h); &x, &y, &w, &h);
switch (opposite) { switch (opposite) {
case OB_DIRECTION_NORTH: case OB_DIRECTION_NORTH:
half = data->client->area.y + data->client->area.height / 2; half = data->client->area.y + data->client->area.height / 2;

View file

@ -4535,19 +4535,16 @@ void client_find_move_directional(ObClient *self, ObDirection dir,
frame_frame_gravity(self->frame, x, y); frame_frame_gravity(self->frame, x, y);
} }
gboolean client_find_resize_directional( void client_find_resize_directional(ObClient *self,
ObClient *self, ObDirection side,
ObDirection side, ObClientDirectionalResizeType resize_type,
ObClientDirectionalResizeType resize_type, gint *x, gint *y, gint *w, gint *h)
gint *x, gint *y, gint *w, gint *h)
{ {
gint head; gint head;
gint e, e_start, e_size, delta; gint e, e_start, e_size, delta;
gboolean near; gboolean near;
ObDirection dir; ObDirection dir;
gboolean changed = FALSE;
gboolean grow; gboolean grow;
switch (resize_type) { switch (resize_type) {
case CLIENT_RESIZE_GROW: case CLIENT_RESIZE_GROW:
@ -4647,27 +4644,23 @@ gboolean client_find_resize_directional(
if (grow == near) --e; if (grow == near) --e;
delta = e - RECT_RIGHT(self->frame->area); delta = e - RECT_RIGHT(self->frame->area);
*w += delta; *w += delta;
changed = delta ? TRUE : changed;
break; break;
case OB_DIRECTION_WEST: case OB_DIRECTION_WEST:
if (grow == near) ++e; if (grow == near) ++e;
delta = RECT_LEFT(self->frame->area) - e; delta = RECT_LEFT(self->frame->area) - e;
*x -= delta; *x -= delta;
*w += delta; *w += delta;
changed = delta ? TRUE : changed;
break; break;
case OB_DIRECTION_NORTH: case OB_DIRECTION_NORTH:
if (grow == near) ++e; if (grow == near) ++e;
delta = RECT_TOP(self->frame->area) - e; delta = RECT_TOP(self->frame->area) - e;
*y -= delta; *y -= delta;
*h += delta; *h += delta;
changed = delta ? TRUE : changed;
break; break;
case OB_DIRECTION_SOUTH: case OB_DIRECTION_SOUTH:
if (grow == near) --e; if (grow == near) --e;
delta = e - RECT_BOTTOM(self->frame->area); delta = e - RECT_BOTTOM(self->frame->area);
*h += delta; *h += delta;
changed = delta ? TRUE : changed;
break; break;
default: default:
g_assert_not_reached(); g_assert_not_reached();
@ -4675,7 +4668,6 @@ gboolean client_find_resize_directional(
frame_frame_gravity(self->frame, x, y); frame_frame_gravity(self->frame, x, y);
*w -= self->frame->size.left + self->frame->size.right; *w -= self->frame->size.left + self->frame->size.right;
*h -= self->frame->size.top + self->frame->size.bottom; *h -= self->frame->size.top + self->frame->size.bottom;
return changed;
} }
ObClient* client_under_pointer(void) ObClient* client_under_pointer(void)

View file

@ -496,14 +496,11 @@ typedef enum {
CLIENT_RESIZE_SHRINK, CLIENT_RESIZE_SHRINK,
} ObClientDirectionalResizeType; } ObClientDirectionalResizeType;
/*! Moves the client area passed in to grow/shrink the given edge. /*! Moves the client area passed in to grow/shrink the given edge. */
@return TRUE if any change was made to the client area. void client_find_resize_directional(ObClient *self,
*/ ObDirection side,
gboolean client_find_resize_directional( ObClientDirectionalResizeType resize_type,
ObClient *self, gint *x, gint *y, gint *w, gint *h);
ObDirection side,
ObClientDirectionalResizeType resize_type,
gint *x, gint *y, gint *w, gint *h);
/*! Fullscreen's or unfullscreen's the client window /*! Fullscreen's or unfullscreen's the client window
@param fs true if the window should be made fullscreen; false if it should @param fs true if the window should be made fullscreen; false if it should