1 /* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
3 action.c for the Openbox window manager
4 Copyright (c) 2006 Mikael Magnusson
5 Copyright (c) 2003-2007 Dana Jansens
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 See the COPYING file for a copy of the GNU General Public License.
23 #include "focus_cycle.h"
24 #include "moveresize.h"
37 #include "startupnotify.h"
45 void setup_action_growtoedge_north(ObAction **a, ObUserAction uact)
47 (*a)->data.diraction.any.client_action = OB_CLIENT_ACTION_ALWAYS;
48 (*a)->data.diraction.direction = OB_DIRECTION_NORTH;
51 void setup_action_growtoedge_south(ObAction **a, ObUserAction uact)
53 (*a)->data.diraction.any.client_action = OB_CLIENT_ACTION_ALWAYS;
54 (*a)->data.diraction.direction = OB_DIRECTION_SOUTH;
57 void setup_action_growtoedge_east(ObAction **a, ObUserAction uact)
59 (*a)->data.diraction.any.client_action = OB_CLIENT_ACTION_ALWAYS;
60 (*a)->data.diraction.direction = OB_DIRECTION_EAST;
63 void setup_action_growtoedge_west(ObAction **a, ObUserAction uact)
65 (*a)->data.diraction.any.client_action = OB_CLIENT_ACTION_ALWAYS;
66 (*a)->data.diraction.direction = OB_DIRECTION_WEST;
69 void setup_action_top_layer(ObAction **a, ObUserAction uact)
71 (*a)->data.layer.any.client_action = OB_CLIENT_ACTION_ALWAYS;
72 (*a)->data.layer.layer = 1;
75 void setup_action_normal_layer(ObAction **a, ObUserAction uact)
77 (*a)->data.layer.any.client_action = OB_CLIENT_ACTION_ALWAYS;
78 (*a)->data.layer.layer = 0;
81 void setup_action_bottom_layer(ObAction **a, ObUserAction uact)
83 (*a)->data.layer.any.client_action = OB_CLIENT_ACTION_ALWAYS;
84 (*a)->data.layer.layer = -1;
87 void setup_client_action(ObAction **a, ObUserAction uact)
89 (*a)->data.any.client_action = OB_CLIENT_ACTION_ALWAYS;
92 ActionString actionstrings[] =
107 setup_action_growtoedge_north
112 setup_action_growtoedge_south
117 setup_action_growtoedge_west
122 setup_action_growtoedge_east
131 void action_unshaderaise(union ActionData *data)
133 if (data->client.any.c->shaded)
134 action_unshade(data);
139 void action_shadelower(union ActionData *data)
141 if (data->client.any.c->shaded)
147 void action_growtoedge(union ActionData *data)
149 gint x, y, width, height, dest;
150 ObClient *c = data->diraction.any.c;
153 a = screen_area(c->desktop, SCREEN_AREA_ALL_MONITORS, &c->frame->area);
154 x = c->frame->area.x;
155 y = c->frame->area.y;
156 /* get the unshaded frame's dimensions..if it is shaded */
157 width = c->area.width + c->frame->size.left + c->frame->size.right;
158 height = c->area.height + c->frame->size.top + c->frame->size.bottom;
160 switch(data->diraction.direction) {
161 case OB_DIRECTION_NORTH:
162 if (c->shaded) break; /* don't allow vertical resize if shaded */
164 dest = client_directional_edge_search(c, OB_DIRECTION_NORTH, FALSE);
168 height = c->frame->area.y + height - dest;
172 case OB_DIRECTION_WEST:
173 dest = client_directional_edge_search(c, OB_DIRECTION_WEST, FALSE);
177 width = c->frame->area.x + width - dest;
181 case OB_DIRECTION_SOUTH:
182 if (c->shaded) break; /* don't allow vertical resize if shaded */
184 dest = client_directional_edge_search(c, OB_DIRECTION_SOUTH, FALSE);
185 if (a->y + a->height == y + c->frame->area.height) {
186 height = c->frame->area.height / 2;
187 y = a->y + a->height - height;
189 height = dest - c->frame->area.y;
190 y += (height - c->frame->area.height) % c->size_inc.height;
191 height -= (height - c->frame->area.height) % c->size_inc.height;
193 case OB_DIRECTION_EAST:
194 dest = client_directional_edge_search(c, OB_DIRECTION_EAST, FALSE);
195 if (a->x + a->width == x + c->frame->area.width) {
196 width = c->frame->area.width / 2;
197 x = a->x + a->width - width;
199 width = dest - c->frame->area.x;
200 x += (width - c->frame->area.width) % c->size_inc.width;
201 width -= (width - c->frame->area.width) % c->size_inc.width;
204 g_assert_not_reached();
206 width -= c->frame->size.left + c->frame->size.right;
207 height -= c->frame->size.top + c->frame->size.bottom;
208 frame_frame_gravity(c->frame, &x, &y, width, height);
209 client_action_start(data);
210 client_move_resize(c, x, y, width, height);
211 client_action_end(data, FALSE);