1 #include "openbox/actions.h"
2 #include "openbox/event.h"
3 #include "openbox/focus_cycle.h"
4 #include "openbox/openbox.h"
10 gboolean dock_windows;
11 gboolean desktop_windows;
12 gboolean all_desktops;
17 static gboolean cycling = FALSE;
19 static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node);
20 static void free_func(gpointer options);
21 static gboolean run_func(ObActionsData *data, gpointer options);
22 static gboolean i_input_func(guint initial_state,
26 static void i_cancel_func(gpointer options);
28 static void end_cycle(gboolean cancel, guint state, Options *o);
30 void action_cyclewindows_startup()
32 actions_register("CycleWindows",
40 static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
45 o = g_new0(Options, 1);
49 if ((n = parse_find_node("forward", node)))
50 o->forward = parse_bool(doc, n);
51 if ((n = parse_find_node("linear", node)))
52 o->linear = parse_bool(doc, n);
53 if ((n = parse_find_node("dialog", node)))
54 o->dialog = parse_bool(doc, n);
55 if ((n = parse_find_node("panels", node)))
56 o->dock_windows = parse_bool(doc, n);
57 if ((n = parse_find_node("desktop", node)))
58 o->desktop_windows = parse_bool(doc, n);
59 if ((n = parse_find_node("allDesktops", node)))
60 o->all_desktops = parse_bool(doc, n);
62 if ((n = parse_find_node("finalactions", node))) {
65 m = parse_find_node("action", n->xmlChildrenNode);
67 ObActionsAct *action = actions_parse(i, doc, m);
68 if (action) o->actions = g_slist_prepend(o->actions, action);
69 m = parse_find_node("action", m->next);
75 static void free_func(gpointer options)
82 static gboolean run_func(ObActionsData *data, gpointer options)
86 /* if using focus_delay, stop the timer now so that focus doesn't go moving
88 event_halt_focus_delay();
90 focus_cycle(o->forward,
103 static gboolean i_input_func(guint initial_state,
108 if (e->type == KeyPress) {
109 /* Escape cancels no matter what */
110 if (e->xkey.keycode == ob_keycode(OB_KEY_ESCAPE)) {
111 end_cycle(TRUE, e->xkey.state, options);
115 /* There were no modifiers and they pressed enter */
116 else if (e->xkey.keycode == ob_keycode(OB_KEY_RETURN) &&
119 end_cycle(FALSE, e->xkey.state, options);
123 /* They released the modifiers */
124 else if (e->type == KeyRelease && initial_state &&
125 (e->xkey.state & initial_state) == 0)
127 end_cycle(FALSE, e->xkey.state, options);
134 static void i_cancel_func(gpointer options)
136 /* we get cancelled when we move focus, but we're not cycling anymore, so
139 end_cycle(TRUE, 0, options);
142 static void end_cycle(gboolean cancel, guint state, Options *o)
144 struct _ObClient *ft;
146 ft = focus_cycle(o->forward,
156 actions_run_acts(o->actions, OB_USER_ACTION_KEYBOARD_KEY,
157 state, -1, -1, 0, OB_FRAME_CONTEXT_NONE, ft);