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"
25 static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node);
26 static void free_func(gpointer options);
27 static gboolean run_func(ObActionsData *data, gpointer options);
29 void action_if_startup()
31 actions_register("If",
38 static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
43 o = g_new0(Options, 1);
45 if ((n = parse_find_node("shaded", node))) {
46 if (parse_bool(doc, n))
51 if ((n = parse_find_node("maximized", node))) {
52 if (parse_bool(doc, n))
55 o->maxfull_off = TRUE;
57 if ((n = parse_find_node("maximizedhorizontal", node))) {
58 if (parse_bool(doc, n))
61 o->maxhorz_off = TRUE;
63 if ((n = parse_find_node("maximizedvertical", node))) {
64 if (parse_bool(doc, n))
67 o->maxvert_off = TRUE;
69 if ((n = parse_find_node("iconified", node))) {
70 if (parse_bool(doc, n))
75 if ((n = parse_find_node("focused", node))) {
76 if (parse_bool(doc, n))
82 if ((n = parse_find_node("then", node))) {
85 m = parse_find_node("action", n->xmlChildrenNode);
87 ObActionsAct *action = actions_parse(i, doc, m);
88 if (action) o->thenacts = g_slist_prepend(o->thenacts, action);
89 m = parse_find_node("action", m->next);
92 if ((n = parse_find_node("else", node))) {
95 m = parse_find_node("action", n->xmlChildrenNode);
97 ObActionsAct *action = actions_parse(i, doc, m);
98 if (action) o->elseacts = g_slist_prepend(o->elseacts, action);
99 m = parse_find_node("action", m->next);
106 static void free_func(gpointer options)
108 Options *o = options;
113 /* Always return FALSE because its not interactive */
114 static gboolean run_func(ObActionsData *data, gpointer options)
116 Options *o = options;
118 ObClient *c = data->client;
120 if ((!o->shaded_on || (c && c->shaded)) &&
121 (!o->shaded_off || (c && !c->shaded)) &&
122 (!o->iconic_on || (c && c->iconic)) &&
123 (!o->iconic_off || (c && !c->iconic)) &&
124 (!o->maxhorz_on || (c && c->max_horz)) &&
125 (!o->maxhorz_off || (c && !c->max_horz)) &&
126 (!o->maxvert_on || (c && c->max_vert)) &&
127 (!o->maxvert_off || (c && !c->max_vert)) &&
128 (!o->maxfull_on || (c && c->max_vert && c->max_horz)) &&
129 (!o->maxfull_off || (c && !(c->max_vert && c->max_horz))) &&
130 (!o->focused || (c && !(c == focus_client))) &&
131 (!o->unfocused || (c && !(c != focus_client))))
138 actions_run_acts(acts, data->uact, data->state,
139 data->x, data->y, data->button,
140 data->context, data->client);