1 #include "openbox/actions.h"
2 #include "openbox/event.h"
3 #include "openbox/focus_cycle.h"
4 #include "openbox/openbox.h"
5 #include "openbox/misc.h"
10 gboolean dock_windows;
11 gboolean desktop_windows;
12 ObDirection direction;
16 static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node);
17 static void free_func(gpointer options);
18 static gboolean run_func(ObActionsData *data, gpointer options);
19 static gboolean i_input_func(guint initial_state,
23 static void i_cancel_func(gpointer options);
25 static void end_cycle(gboolean cancel, guint state, Options *o);
27 void action_directionalcyclewindows_startup()
29 actions_register("DirectionalCycleWindows",
37 static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
42 o = g_new0(Options, 1);
45 if ((n = parse_find_node("dialog", node)))
46 o->dialog = parse_bool(doc, n);
47 if ((n = parse_find_node("panels", node)))
48 o->dock_windows = parse_bool(doc, n);
49 if ((n = parse_find_node("desktop", node)))
50 o->desktop_windows = parse_bool(doc, n);
51 if ((n = parse_find_node("direction", node))) {
52 gchar *s = parse_string(doc, n);
53 if (!g_ascii_strcasecmp(s, "north"))
54 o->direction = OB_DIRECTION_NORTH;
55 else if (!g_ascii_strcasecmp(s, "northwest"))
56 o->direction = OB_DIRECTION_NORTHWEST;
57 else if (!g_ascii_strcasecmp(s, "northeast"))
58 o->direction = OB_DIRECTION_NORTHEAST;
59 else if (!g_ascii_strcasecmp(s, "west"))
60 o->direction = OB_DIRECTION_WEST;
61 else if (!g_ascii_strcasecmp(s, "east"))
62 o->direction = OB_DIRECTION_EAST;
63 else if (!g_ascii_strcasecmp(s, "south"))
64 o->direction = OB_DIRECTION_NORTH;
65 else if (!g_ascii_strcasecmp(s, "southwest"))
66 o->direction = OB_DIRECTION_NORTHWEST;
67 else if (!g_ascii_strcasecmp(s, "southeast"))
68 o->direction = OB_DIRECTION_NORTHEAST;
72 if ((n = parse_find_node("actions", node))) {
75 m = parse_find_node("action", n->xmlChildrenNode);
77 ObActionsAct *action = actions_parse(i, doc, m);
78 if (action) o->actions = g_slist_prepend(o->actions, action);
79 m = parse_find_node("action", m->next);
85 static void free_func(gpointer options)
92 static gboolean run_func(ObActionsData *data, gpointer options)
96 /* if using focus_delay, stop the timer now so that focus doesn't go moving
98 event_halt_focus_delay();
100 focus_directional_cycle(o->direction,
110 static gboolean i_input_func(guint initial_state,
115 if (e->type == KeyPress) {
116 /* Escape cancels no matter what */
117 if (e->xkey.keycode == ob_keycode(OB_KEY_ESCAPE)) {
118 end_cycle(TRUE, e->xkey.state, options);
122 /* There were no modifiers and they pressed enter */
123 else if (e->xkey.keycode == ob_keycode(OB_KEY_RETURN) &&
126 end_cycle(FALSE, e->xkey.state, options);
130 /* They released the modifiers */
131 else if (e->type == KeyRelease && initial_state &&
132 (e->xkey.state & initial_state) == 0)
134 end_cycle(FALSE, e->xkey.state, options);
141 static void i_cancel_func(gpointer options)
143 end_cycle(TRUE, 0, options);
146 static void end_cycle(gboolean cancel, guint state, Options *o)
148 struct _ObClient *ft;
150 ft = focus_directional_cycle(o->direction,
158 actions_run_acts(o->actions, OB_USER_ACTION_KEYBOARD_KEY,
159 state, -1, -1, 0, OB_FRAME_CONTEXT_NONE, ft);