]>
Dogcows Code - chaz/openbox/blob - openbox/action.c
10 Action
*action_new(void (*func
)(union ActionData
*data
))
12 Action
*a
= g_new(Action
, 1);
15 /* deal with pointers */
16 if (func
== action_execute
)
17 a
->data
.execute
.path
= NULL
;
22 void action_free(Action
*a
)
24 /* deal with pointers */
25 if (a
->func
== action_execute
)
26 g_free(a
->data
.execute
.path
);
31 void action_execute(union ActionData
*data
)
34 if (!g_spawn_command_line_async(data
->execute
.path
, &e
)) {
35 g_warning("failed to execute '%s': %s",
36 data
->execute
.path
, e
->message
);
40 void action_focus(union ActionData
*data
)
42 client_focus(data
->client
.c
);
45 void action_unfocus (union ActionData
*data
)
47 client_unfocus(data
->client
.c
);
50 void action_iconify(union ActionData
*data
)
52 client_iconify(data
->client
.c
, TRUE
, TRUE
);
55 void action_focusraise(union ActionData
*data
)
57 client_focus(data
->client
.c
);
58 stacking_raise(data
->client
.c
);
61 void action_raise(union ActionData
*data
)
63 stacking_raise(data
->client
.c
);
66 void action_lower(union ActionData
*data
)
68 stacking_lower(data
->client
.c
);
71 void action_close(union ActionData
*data
)
73 client_close(data
->client
.c
);
76 void action_shade(union ActionData
*data
)
78 client_shade(data
->client
.c
, TRUE
);
81 void action_unshade(union ActionData
*data
)
83 client_shade(data
->client
.c
, FALSE
);
86 void action_toggle_shade(union ActionData
*data
)
88 client_shade(data
->client
.c
, !data
->client
.c
->shaded
);
91 void action_toggle_omnipresent(union ActionData
*data
)
93 client_set_desktop(data
->client
.c
, data
->client
.c
->desktop
== DESKTOP_ALL
?
94 screen_desktop
: DESKTOP_ALL
);
97 void action_move_relative(union ActionData
*data
)
99 Client
*c
= data
->relative
.c
;
100 client_configure(c
, Corner_TopLeft
,
101 c
->area
.x
+ data
->relative
.dx
,
102 c
->area
.y
+ data
->relative
.dy
,
103 c
->area
.width
, c
->area
.height
, TRUE
, TRUE
);
106 void action_resize_relative(union ActionData
*data
)
108 Client
*c
= data
->relative
.c
;
109 client_configure(c
, Corner_TopLeft
, c
->area
.x
, c
->area
.y
,
110 c
->area
.width
+ data
->relative
.dx
,
111 c
->area
.height
+ data
->relative
.dy
, TRUE
, TRUE
);
114 void action_maximize_full(union ActionData
*data
)
116 client_maximize(data
->client
.c
, TRUE
, 0, TRUE
);
119 void action_unmaximize_full(union ActionData
*data
)
121 client_maximize(data
->client
.c
, FALSE
, 0, TRUE
);
124 void action_toggle_maximize_full(union ActionData
*data
)
126 client_maximize(data
->client
.c
,
127 !(data
->client
.c
->max_horz
|| data
->client
.c
->max_vert
),
131 void action_maximize_horz(union ActionData
*data
)
133 client_maximize(data
->client
.c
, TRUE
, 1, TRUE
);
136 void action_unmaximize_horz(union ActionData
*data
)
138 client_maximize(data
->client
.c
, FALSE
, 1, TRUE
);
141 void action_toggle_maximize_horz(union ActionData
*data
)
143 client_maximize(data
->client
.c
, !data
->client
.c
->max_horz
, 1, TRUE
);
146 void action_maximize_vert(union ActionData
*data
)
148 client_maximize(data
->client
.c
, TRUE
, 2, TRUE
);
151 void action_unmaximize_vert(union ActionData
*data
)
153 client_maximize(data
->client
.c
, FALSE
, 2, TRUE
);
156 void action_toggle_maximize_vert(union ActionData
*data
)
158 client_maximize(data
->client
.c
, !data
->client
.c
->max_vert
, 2, TRUE
);
161 void action_send_to_desktop(union ActionData
*data
)
163 if (data
->sendto
.desktop
< screen_num_desktops
||
164 data
->sendto
.desktop
== DESKTOP_ALL
)
165 client_set_desktop(data
->sendto
.c
, data
->sendto
.desktop
);
168 void action_send_to_next_desktop(union ActionData
*data
)
172 d
= screen_desktop
+ 1;
173 if (d
>= screen_num_desktops
) {
174 if (!data
->sendtonextprev
.wrap
) return;
177 client_set_desktop(data
->sendtonextprev
.c
, d
);
178 if (data
->sendtonextprev
.follow
) screen_set_desktop(d
);
181 void action_send_to_previous_desktop(union ActionData
*data
)
185 d
= screen_desktop
- 1;
186 if (d
>= screen_num_desktops
) {
187 if (!data
->sendtonextprev
.wrap
) return;
188 d
= screen_num_desktops
- 1;
190 client_set_desktop(data
->sendtonextprev
.c
, d
);
191 if (data
->sendtonextprev
.follow
) screen_set_desktop(d
);
194 void action_desktop(union ActionData
*data
)
196 if (data
->desktop
.desk
< screen_num_desktops
||
197 data
->desktop
.desk
== DESKTOP_ALL
)
198 screen_set_desktop(data
->desktop
.desk
);
201 void action_next_desktop(union ActionData
*data
)
205 d
= screen_desktop
+ 1;
206 if (d
>= screen_num_desktops
) {
207 if (!data
->nextprevdesktop
.wrap
) return;
210 screen_set_desktop(d
);
213 void action_previous_desktop(union ActionData
*data
)
217 d
= screen_desktop
- 1;
218 if (d
>= screen_num_desktops
) {
219 if (!data
->nextprevdesktop
.wrap
) return;
220 d
= screen_num_desktops
- 1;
222 screen_set_desktop(d
);
225 static void cur_row_col(guint
*r
, guint
*c
)
227 switch (screen_desktop_layout
.orientation
) {
228 case Orientation_Horz
:
229 switch (screen_desktop_layout
.start_corner
) {
231 *r
= screen_desktop
/ screen_desktop_layout
.columns
;
232 *c
= screen_desktop
% screen_desktop_layout
.columns
;
234 case Corner_BottomLeft
:
235 *r
= screen_desktop_layout
.rows
- 1 -
236 screen_desktop
/ screen_desktop_layout
.columns
;
237 *c
= screen_desktop
% screen_desktop_layout
.columns
;
240 case Corner_TopRight
:
241 *r
= screen_desktop
/ screen_desktop_layout
.columns
;
242 *c
= screen_desktop_layout
.columns
- 1 -
243 screen_desktop
% screen_desktop_layout
.columns
;
245 case Corner_BottomRight
:
246 *r
= screen_desktop_layout
.rows
- 1 -
247 screen_desktop
/ screen_desktop_layout
.columns
;
248 *c
= screen_desktop_layout
.columns
- 1 -
249 screen_desktop
% screen_desktop_layout
.columns
;
253 case Orientation_Vert
:
254 switch (screen_desktop_layout
.start_corner
) {
256 *r
= screen_desktop
% screen_desktop_layout
.rows
;
257 *c
= screen_desktop
/ screen_desktop_layout
.rows
;
259 case Corner_BottomLeft
:
260 *r
= screen_desktop_layout
.rows
- 1 -
261 screen_desktop
% screen_desktop_layout
.rows
;
262 *c
= screen_desktop
/ screen_desktop_layout
.rows
;
265 case Corner_TopRight
:
266 *r
= screen_desktop
% screen_desktop_layout
.rows
;
267 *c
= screen_desktop_layout
.columns
- 1 -
268 screen_desktop
/ screen_desktop_layout
.rows
;
270 case Corner_BottomRight
:
271 *r
= screen_desktop_layout
.rows
- 1 -
272 screen_desktop
% screen_desktop_layout
.rows
;
273 *c
= screen_desktop_layout
.columns
- 1 -
274 screen_desktop
/ screen_desktop_layout
.rows
;
282 static guint
translate_row_col(guint r
, guint c
)
284 switch (screen_desktop_layout
.orientation
) {
285 case Orientation_Horz
:
286 switch (screen_desktop_layout
.start_corner
) {
288 return r
* screen_desktop_layout
.columns
+ c
;
289 case Corner_BottomLeft
:
290 return (screen_desktop_layout
.rows
- 1 - r
) *
291 screen_desktop_layout
.columns
+ c
;
292 case Corner_TopRight
:
293 return r
* screen_desktop_layout
.columns
+
294 (screen_desktop_layout
.columns
- 1 - c
);
295 case Corner_BottomRight
:
296 return (screen_desktop_layout
.rows
- 1 - r
) *
297 screen_desktop_layout
.columns
+
298 (screen_desktop_layout
.columns
- 1 - c
);
300 case Orientation_Vert
:
301 switch (screen_desktop_layout
.start_corner
) {
303 return c
* screen_desktop_layout
.rows
+ r
;
304 case Corner_BottomLeft
:
305 return c
* screen_desktop_layout
.rows
+
306 (screen_desktop_layout
.rows
- 1 - r
);
307 case Corner_TopRight
:
308 return (screen_desktop_layout
.columns
- 1 - c
) *
309 screen_desktop_layout
.rows
+ r
;
310 case Corner_BottomRight
:
311 return (screen_desktop_layout
.columns
- 1 - c
) *
312 screen_desktop_layout
.rows
+
313 (screen_desktop_layout
.rows
- 1 - r
);
316 g_assert_not_reached();
320 void action_next_desktop_column(union ActionData
*data
)
326 d
= translate_row_col(r
, c
);
327 if (d
>= screen_num_desktops
) {
328 if (!data
->nextprevdesktop
.wrap
) return;
331 if (d
>= screen_num_desktops
)
333 d
= translate_row_col(r
, c
);
334 if (d
< screen_num_desktops
)
335 screen_set_desktop(d
);
338 void action_previous_desktop_column(union ActionData
*data
)
344 d
= translate_row_col(r
, c
);
345 if (d
>= screen_num_desktops
) {
346 if (!data
->nextprevdesktop
.wrap
) return;
347 c
= screen_desktop_layout
.columns
- 1;
349 if (d
>= screen_num_desktops
)
351 d
= translate_row_col(r
, c
);
352 if (d
< screen_num_desktops
)
353 screen_set_desktop(d
);
356 void action_next_desktop_row(union ActionData
*data
)
362 d
= translate_row_col(r
, c
);
363 if (d
>= screen_num_desktops
) {
364 if (!data
->nextprevdesktop
.wrap
) return;
367 if (d
>= screen_num_desktops
)
369 d
= translate_row_col(r
, c
);
370 if (d
< screen_num_desktops
)
371 screen_set_desktop(d
);
374 void action_previous_desktop_row(union ActionData
*data
)
380 d
= translate_row_col(r
, c
);
381 if (d
>= screen_num_desktops
) {
382 if (!data
->nextprevdesktop
.wrap
) return;
383 c
= screen_desktop_layout
.rows
- 1;
385 if (d
>= screen_num_desktops
)
387 d
= translate_row_col(r
, c
);
388 if (d
< screen_num_desktops
)
389 screen_set_desktop(d
);
392 void action_toggle_decorations(union ActionData
*data
)
394 Client
*c
= data
->client
.c
;
395 c
->disabled_decorations
= c
->disabled_decorations
? 0 : ~0;
396 client_setup_decor_and_functions(c
);
399 void action_move(union ActionData
*data
)
401 Client
*c
= data
->move
.c
;
402 int x
= data
->move
.x
;
403 int y
= data
->move
.y
;
405 snap_move(c
, &x
, &y
, c
->frame
->area
.width
, c
->frame
->area
.height
);
407 frame_frame_gravity(c
->frame
, &x
, &y
); /* get where the client should be */
408 client_configure(c
, Corner_TopLeft
, x
, y
, c
->area
.width
, c
->area
.height
,
409 TRUE
, data
->move
.final
);
412 void action_resize(union ActionData
*data
)
414 Client
*c
= data
->resize
.c
;
415 int w
= data
->resize
.x
- c
->frame
->size
.left
- c
->frame
->size
.right
;
416 int h
= data
->resize
.y
- c
->frame
->size
.top
- c
->frame
->size
.bottom
;
418 /* XXX window snapping/struts */
420 client_configure(c
, data
->resize
.corner
, c
->area
.x
, c
->area
.y
, w
, h
,
421 TRUE
, data
->resize
.final
);
This page took 0.050998 seconds and 4 git commands to generate.