Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added the options "once" and "strict" to the actions GrowTo* and MoveTo* #8

Open
wants to merge 19 commits into
base: work
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
2c34c10
Use the BSEARCH() macro in overlap placement
danakj Sep 1, 2013
1d665d4
Remove now-incorrect comment
danakj Sep 1, 2013
92f649b
Created a 'GrowToFill' action. (Bug 3356)
deters Aug 28, 2010
ef0b3b0
Clean up the FillToEdge action implementation
danakj Sep 1, 2013
59b18a9
Allow FillToEdge to grow when all its edges are blocked.
danakj Sep 1, 2013
c96dc60
Adding 'once' option to GrowToEdge action.
deters Sep 2, 2013
7ecec5c
Code cleanup.
deters Sep 3, 2013
beac74e
Merge remote-tracking branch 'upstream/work' into growtofill_option
deters Sep 3, 2013
936aea1
Merge remote-tracking branch 'upstream/work' into growtofill_option
deters Sep 4, 2013
47390a5
Fixed problem during merge.
deters Sep 4, 2013
933b5a8
Merge branch 'growtofill_option' of https://github.com/deters/openbox…
deters Sep 4, 2013
01b59e6
Added option "strict" to GrowTo* actions.
deters Sep 4, 2013
8118f07
Added the option "once" to the action "MoveToEdge".
deters Sep 4, 2013
86e6fb3
Added the option "once" to the action "MoveToEdge".
deters Sep 4, 2013
4dd037b
Merge branch 'growtofill_option' of https://github.com/deters/openbox…
deters Sep 4, 2013
760389f
Merge branch 'growtofill_option' of https://github.com/deters/openbox…
deters Sep 4, 2013
3654d76
Merge branch 'growtofill_option' of https://github.com/deters/openbox…
deters Sep 4, 2013
f157630
Merge branch 'growtofill_option' of https://github.com/deters/openbox…
deters Sep 4, 2013
520ac7c
Merge branch 'growtofill_option' of https://github.com/deters/openbox…
deters Sep 4, 2013
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions data/rc.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,8 @@
<xsd:element minOccurs="0" name="here" type="ob:bool"/>
<xsd:element minOccurs="0" name="linear" type="ob:bool"/>
<xsd:element minOccurs="0" name="group" type="ob:bool"/>
<xsd:element minOccurs="0" name="once" type="ob:bool"/>
<xsd:element minOccurs="0" name="strict" type="ob:bool"/>
</xsd:all>
<xsd:attribute name="name" type="ob:actionname" use="required"/>
</xsd:complexType>
Expand Down
34 changes: 31 additions & 3 deletions openbox/actions/growtoedge.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ typedef struct {
ObDirection dir;
gboolean shrink;
gboolean fill;
gboolean once;
gboolean strict;
} Options;

static gpointer setup_grow_func(xmlNodePtr node);
Expand Down Expand Up @@ -62,6 +64,12 @@ static gpointer setup_func(xmlNodePtr node)
g_free(s);
}

if ((n = obt_xml_find_node(node, "once")))
o->once = obt_xml_node_bool(n);

if ((n = obt_xml_find_node(node, "strict")))
o->strict = obt_xml_node_bool(n);

return o;
}

Expand Down Expand Up @@ -207,15 +215,23 @@ static gboolean run_func(ObActionsData *data, gpointer options)

/* If all the edges are blocked, then allow them to jump past their
current block points. */
do_grow_all_edges(data, CLIENT_RESIZE_GROW);
if (!o->once)
do_grow_all_edges(data, CLIENT_RESIZE_GROW);

return FALSE;
}

if (!o->shrink) {
gint x, y, w, h;

/* Try grow. */
client_find_resize_directional(data->client,
if (o->once)
client_find_resize_directional(data->client,
o->dir,
CLIENT_RESIZE_GROW_IF_NOT_ON_EDGE,
&x, &y, &w, &h);
else
client_find_resize_directional(data->client,
o->dir,
CLIENT_RESIZE_GROW,
&x, &y, &w, &h);
Expand All @@ -224,7 +240,11 @@ static gboolean run_func(ObActionsData *data, gpointer options)
return FALSE;
}

/* We couldn't grow, so try shrink! */
/* We couldn't grow, so try shrink!
Except when on strict mode. */
if (o->strict)
return FALSE;

ObDirection opposite =
(o->dir == OB_DIRECTION_NORTH ? OB_DIRECTION_SOUTH :
(o->dir == OB_DIRECTION_SOUTH ? OB_DIRECTION_NORTH :
Expand Down Expand Up @@ -278,6 +298,8 @@ static gpointer setup_north_func(xmlNodePtr node)
Options *o = g_slice_new0(Options);
o->shrink = FALSE;
o->dir = OB_DIRECTION_NORTH;
o->once = FALSE;
o->strict = FALSE;
return o;
}

Expand All @@ -286,6 +308,8 @@ static gpointer setup_south_func(xmlNodePtr node)
Options *o = g_slice_new0(Options);
o->shrink = FALSE;
o->dir = OB_DIRECTION_SOUTH;
o->once = FALSE;
o->strict = FALSE;
return o;
}

Expand All @@ -294,6 +318,8 @@ static gpointer setup_east_func(xmlNodePtr node)
Options *o = g_slice_new0(Options);
o->shrink = FALSE;
o->dir = OB_DIRECTION_EAST;
o->once = FALSE;
o->strict = FALSE;
return o;
}

Expand All @@ -302,5 +328,7 @@ static gpointer setup_west_func(xmlNodePtr node)
Options *o = g_slice_new0(Options);
o->shrink = FALSE;
o->dir = OB_DIRECTION_WEST;
o->once = FALSE;
o->strict = FALSE;
return o;
}
14 changes: 13 additions & 1 deletion openbox/actions/movetoedge.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

typedef struct {
ObDirection dir;
gboolean once;
} Options;

static gpointer setup_func(xmlNodePtr node);
Expand Down Expand Up @@ -53,6 +54,9 @@ static gpointer setup_func(xmlNodePtr node)
g_free(s);
}

if ((n = obt_xml_find_node(node, "once")))
o->once = obt_xml_node_bool(n);

return o;
}

Expand All @@ -69,7 +73,11 @@ static gboolean run_func(ObActionsData *data, gpointer options)
if (data->client) {
gint x, y;

client_find_move_directional(data->client, o->dir, &x, &y);
if (o->once)
client_find_move_directional(data->client, o->dir, CLIENT_MOVE_MOVE_IF_NOT_ON_EDGE, &x, &y);
else
client_find_move_directional(data->client, o->dir, CLIENT_MOVE_MOVE, &x, &y);

if (x != data->client->area.x || y != data->client->area.y) {
actions_client_move(data, TRUE);
client_move(data->client, x, y);
Expand All @@ -85,27 +93,31 @@ static gpointer setup_north_func(xmlNodePtr node)
{
Options *o = g_slice_new0(Options);
o->dir = OB_DIRECTION_NORTH;
o->once = FALSE;
return o;
}

static gpointer setup_south_func(xmlNodePtr node)
{
Options *o = g_slice_new0(Options);
o->dir = OB_DIRECTION_SOUTH;
o->once = FALSE;
return o;
}

static gpointer setup_east_func(xmlNodePtr node)
{
Options *o = g_slice_new0(Options);
o->dir = OB_DIRECTION_EAST;
o->once = FALSE;
return o;
}

static gpointer setup_west_func(xmlNodePtr node)
{
Options *o = g_slice_new0(Options);
o->dir = OB_DIRECTION_WEST;
o->once = FALSE;
return o;
}

31 changes: 30 additions & 1 deletion openbox/client.c
Original file line number Diff line number Diff line change
Expand Up @@ -4468,7 +4468,7 @@ void client_find_edge_directional(ObClient *self, ObDirection dir,
g_slice_free(Rect, a);
}

void client_find_move_directional(ObClient *self, ObDirection dir,
void client_find_move_directional(ObClient *self, ObDirection dir, ObClientDirectionalMoveType move_type,
gint *x, gint *y)
{
gint head, size;
Expand All @@ -4478,24 +4478,52 @@ void client_find_move_directional(ObClient *self, ObDirection dir,
switch (dir) {
case OB_DIRECTION_EAST:
head = RECT_RIGHT(self->frame->area);
switch (move_type) {
case CLIENT_MOVE_MOVE_IF_NOT_ON_EDGE:
head -= 1;
break;
case CLIENT_MOVE_MOVE:
break;
}
size = self->frame->area.width;
e_start = RECT_TOP(self->frame->area);
e_size = self->frame->area.height;
break;
case OB_DIRECTION_WEST:
head = RECT_LEFT(self->frame->area);
switch (move_type) {
case CLIENT_MOVE_MOVE_IF_NOT_ON_EDGE:
head += 1;
break;
case CLIENT_MOVE_MOVE:
break;
}
size = self->frame->area.width;
e_start = RECT_TOP(self->frame->area);
e_size = self->frame->area.height;
break;
case OB_DIRECTION_NORTH:
head = RECT_TOP(self->frame->area);
switch (move_type) {
case CLIENT_MOVE_MOVE_IF_NOT_ON_EDGE:
head += 1;
break;
case CLIENT_MOVE_MOVE:
break;
}
size = self->frame->area.height;
e_start = RECT_LEFT(self->frame->area);
e_size = self->frame->area.width;
break;
case OB_DIRECTION_SOUTH:
head = RECT_BOTTOM(self->frame->area);
switch (move_type) {
case CLIENT_MOVE_MOVE_IF_NOT_ON_EDGE:
head -= 1;
break;
case CLIENT_MOVE_MOVE:
break;
}
size = self->frame->area.height;
e_start = RECT_LEFT(self->frame->area);
e_size = self->frame->area.width;
Expand All @@ -4506,6 +4534,7 @@ void client_find_move_directional(ObClient *self, ObDirection dir,

client_find_edge_directional(self, dir, head, size,
e_start, e_size, &e, &near);

*x = self->frame->area.x;
*y = self->frame->area.y;
switch (dir) {
Expand Down
8 changes: 7 additions & 1 deletion openbox/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,13 @@ void client_find_edge_directional(ObClient *self, ObDirection dir,
gint my_head, gint my_tail,
gint my_edge_start, gint my_edge_size,
gint *dest, gboolean *near_edge);
void client_find_move_directional(ObClient *self, ObDirection dir,

typedef enum {
CLIENT_MOVE_MOVE,
CLIENT_MOVE_MOVE_IF_NOT_ON_EDGE,
} ObClientDirectionalMoveType;

void client_find_move_directional(ObClient *self, ObDirection dir, ObClientDirectionalMoveType move_type,
gint *x, gint *y);

typedef enum {
Expand Down
2 changes: 1 addition & 1 deletion openbox/moveresize.c
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,7 @@ static void move_with_keys(KeySym sym, guint state)
else /* sym == XK_Up */
dir = OB_DIRECTION_NORTH;

client_find_move_directional(moveresize_client, dir, &x, &y);
client_find_move_directional(moveresize_client, dir, CLIENT_MOVE_MOVE, &x, &y);
dx = x - moveresize_client->area.x;
dy = y - moveresize_client->area.y;
} else {
Expand Down