]>
Dogcows Code - chaz/openbox/blob - openbox/actions/if.c
1 #include "openbox/actions.h"
2 #include "openbox/misc.h"
3 #include "openbox/client.h"
4 #include "openbox/frame.h"
5 #include "openbox/screen.h"
6 #include "openbox/focus.h"
26 static gpointer
setup_func(xmlNodePtr node
);
27 static void free_func(gpointer options
);
28 static gboolean
run_func(ObActionsData
*data
, gpointer options
);
30 void action_if_startup(void)
32 actions_register("If", setup_func
, free_func
, run_func
);
35 static gpointer
setup_func(xmlNodePtr node
)
40 o
= g_new0(Options
, 1);
42 if ((n
= obt_parse_find_node(node
, "shaded"))) {
43 if (obt_parse_node_bool(n
))
48 if ((n
= obt_parse_find_node(node
, "maximized"))) {
49 if (obt_parse_node_bool(n
))
52 o
->maxfull_off
= TRUE
;
54 if ((n
= obt_parse_find_node(node
, "maximizedhorizontal"))) {
55 if (obt_parse_node_bool(n
))
58 o
->maxhorz_off
= TRUE
;
60 if ((n
= obt_parse_find_node(node
, "maximizedvertical"))) {
61 if (obt_parse_node_bool(n
))
64 o
->maxvert_off
= TRUE
;
66 if ((n
= obt_parse_find_node(node
, "iconified"))) {
67 if (obt_parse_node_bool(n
))
72 if ((n
= obt_parse_find_node(node
, "focused"))) {
73 if (obt_parse_node_bool(n
))
79 if ((n
= obt_parse_find_node(node
, "then"))) {
82 m
= obt_parse_find_node(n
->children
, "action");
84 ObActionsAct
*action
= actions_parse(m
);
85 if (action
) o
->thenacts
= g_slist_append(o
->thenacts
, action
);
86 m
= obt_parse_find_node(m
->next
, "action");
89 if ((n
= obt_parse_find_node(node
, "else"))) {
92 m
= obt_parse_find_node(n
->children
, "action");
94 ObActionsAct
*action
= actions_parse(m
);
95 if (action
) o
->elseacts
= g_slist_append(o
->elseacts
, action
);
96 m
= obt_parse_find_node(m
->next
, "action");
103 static void free_func(gpointer options
)
105 Options
*o
= options
;
107 while (o
->thenacts
) {
108 actions_act_unref(o
->thenacts
->data
);
109 o
->thenacts
= g_slist_delete_link(o
->thenacts
, o
->thenacts
);
111 while (o
->elseacts
) {
112 actions_act_unref(o
->elseacts
->data
);
113 o
->elseacts
= g_slist_delete_link(o
->elseacts
, o
->elseacts
);
119 /* Always return FALSE because its not interactive */
120 static gboolean
run_func(ObActionsData
*data
, gpointer options
)
122 Options
*o
= options
;
124 ObClient
*c
= data
->client
;
126 if ((!o
->shaded_on
|| (c
&& c
->shaded
)) &&
127 (!o
->shaded_off
|| (c
&& !c
->shaded
)) &&
128 (!o
->iconic_on
|| (c
&& c
->iconic
)) &&
129 (!o
->iconic_off
|| (c
&& !c
->iconic
)) &&
130 (!o
->maxhorz_on
|| (c
&& c
->max_horz
)) &&
131 (!o
->maxhorz_off
|| (c
&& !c
->max_horz
)) &&
132 (!o
->maxvert_on
|| (c
&& c
->max_vert
)) &&
133 (!o
->maxvert_off
|| (c
&& !c
->max_vert
)) &&
134 (!o
->maxfull_on
|| (c
&& c
->max_vert
&& c
->max_horz
)) &&
135 (!o
->maxfull_off
|| (c
&& !(c
->max_vert
&& c
->max_horz
))) &&
136 (!o
->focused
|| (c
&& (c
== focus_client
))) &&
137 (!o
->unfocused
|| (c
&& !(c
== focus_client
))))
144 actions_run_acts(acts
, data
->uact
, data
->state
,
145 data
->x
, data
->y
, data
->button
,
146 data
->context
, data
->client
);
This page took 0.046282 seconds and 4 git commands to generate.