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(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node);
27 static void free_func(gpointer options);
28 static gboolean run_func(ObActionsData *data, gpointer options);
30 void action_if_startup()
32 actions_register("If",
39 static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
44 o = g_new0(Options, 1);
46 if ((n = parse_find_node("shaded", node))) {
47 if (parse_bool(doc, n))
52 if ((n = parse_find_node("maximized", node))) {
53 if (parse_bool(doc, n))
56 o->maxfull_off = TRUE;
58 if ((n = parse_find_node("maximizedhorizontal", node))) {
59 if (parse_bool(doc, n))
62 o->maxhorz_off = TRUE;
64 if ((n = parse_find_node("maximizedvertical", node))) {
65 if (parse_bool(doc, n))
68 o->maxvert_off = TRUE;
70 if ((n = parse_find_node("iconified", node))) {
71 if (parse_bool(doc, n))
76 if ((n = parse_find_node("focused", node))) {
77 if (parse_bool(doc, n))
83 if ((n = parse_find_node("then", node))) {
86 m = parse_find_node("action", n->xmlChildrenNode);
88 ObActionsAct *action = actions_parse(i, doc, m);
89 if (action) o->thenacts = g_slist_prepend(o->thenacts, action);
90 m = parse_find_node("action", m->next);
93 if ((n = parse_find_node("else", node))) {
96 m = parse_find_node("action", n->xmlChildrenNode);
98 ObActionsAct *action = actions_parse(i, doc, m);
99 if (action) o->elseacts = g_slist_prepend(o->elseacts, action);
100 m = parse_find_node("action", m->next);
107 static void free_func(gpointer options)
109 Options *o = options;
114 /* Always return FALSE because its not interactive */
115 static gboolean run_func(ObActionsData *data, gpointer options)
117 Options *o = options;
119 ObClient *c = data->client;
121 if ((!o->shaded_on || (c && c->shaded)) &&
122 (!o->shaded_off || (c && !c->shaded)) &&
123 (!o->iconic_on || (c && c->iconic)) &&
124 (!o->iconic_off || (c && !c->iconic)) &&
125 (!o->maxhorz_on || (c && c->max_horz)) &&
126 (!o->maxhorz_off || (c && !c->max_horz)) &&
127 (!o->maxvert_on || (c && c->max_vert)) &&
128 (!o->maxvert_off || (c && !c->max_vert)) &&
129 (!o->maxfull_on || (c && c->max_vert && c->max_horz)) &&
130 (!o->maxfull_off || (c && !(c->max_vert && c->max_horz))) &&
131 (!o->focused || (c && (c == focus_client))) &&
132 (!o->unfocused || (c && !(c == focus_client))))
139 actions_run_acts(acts, data->uact, data->state,
140 data->x, data->y, data->button,
141 data->context, data->client);