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 gpointer
setup_func(ObParseInst
*i
, xmlDocPtr doc
, xmlNodePtr node
);
18 static void free_func(gpointer options
);
19 static gboolean
run_func(ObActionsData
*data
, gpointer options
);
20 static gboolean
i_input_func(guint initial_state
,
24 static void i_cancel_func(gpointer options
);
26 static void end_cycle(gboolean cancel
, guint state
, Options
*o
);
28 void action_cyclewindows_startup()
30 actions_register("CycleWindows",
38 static gpointer
setup_func(ObParseInst
*i
, xmlDocPtr doc
, xmlNodePtr node
)
43 o
= g_new0(Options
, 1);
46 if ((n
= parse_find_node("forward", node
)))
47 o
->forward
= parse_bool(doc
, n
);
48 if ((n
= parse_find_node("linear", node
)))
49 o
->linear
= parse_bool(doc
, n
);
50 if ((n
= parse_find_node("dialog", node
)))
51 o
->dialog
= parse_bool(doc
, n
);
52 if ((n
= parse_find_node("panels", node
)))
53 o
->dock_windows
= parse_bool(doc
, n
);
54 if ((n
= parse_find_node("desktop", node
)))
55 o
->desktop_windows
= parse_bool(doc
, n
);
56 if ((n
= parse_find_node("allDesktops", node
)))
57 o
->all_desktops
= parse_bool(doc
, n
);
59 if ((n
= parse_find_node("actions", node
))) {
62 m
= parse_find_node("action", n
->xmlChildrenNode
);
64 ObActionsAct
*action
= actions_parse(i
, doc
, m
);
65 if (action
) o
->actions
= g_slist_prepend(o
->actions
, action
);
66 m
= parse_find_node("action", m
->next
);
72 static void free_func(gpointer options
)
79 static gboolean
run_func(ObActionsData
*data
, gpointer options
)
83 /* if using focus_delay, stop the timer now so that focus doesn't go moving
85 event_halt_focus_delay();
87 focus_cycle(o
->forward
,
99 static gboolean
i_input_func(guint initial_state
,
104 if (e
->type
== KeyPress
) {
105 /* Escape cancels no matter what */
106 if (e
->xkey
.keycode
== ob_keycode(OB_KEY_ESCAPE
)) {
107 end_cycle(TRUE
, e
->xkey
.state
, options
);
111 /* There were no modifiers and they pressed enter */
112 else if (e
->xkey
.keycode
== ob_keycode(OB_KEY_RETURN
) &&
115 end_cycle(FALSE
, e
->xkey
.state
, options
);
119 /* They released the modifiers */
120 else if (e
->type
== KeyRelease
&& initial_state
&&
121 (e
->xkey
.state
& initial_state
) == 0)
123 end_cycle(FALSE
, e
->xkey
.state
, options
);
130 static void i_cancel_func(gpointer options
)
132 end_cycle(TRUE
, 0, options
);
135 static void end_cycle(gboolean cancel
, guint state
, Options
*o
)
137 struct _ObClient
*ft
;
139 ft
= focus_cycle(o
->forward
,
149 actions_run_acts(o
->actions
, OB_USER_ACTION_KEYBOARD_KEY
,
150 state
, -1, -1, 0, OB_FRAME_CONTEXT_NONE
, ft
);