5 #include "parser/parse.h"
7 gboolean config_focus_new;
8 gboolean config_focus_follow;
9 gboolean config_focus_last;
10 gboolean config_focus_last_on_desktop;
11 gboolean config_focus_popup;
15 gchar *config_title_layout;
17 int config_desktops_num;
18 GSList *config_desktops_names;
20 gboolean config_redraw_resize;
22 ObStackingLayer config_dock_layer;
23 gboolean config_dock_floating;
24 ObDirection config_dock_pos;
27 ObOrientation config_dock_orient;
28 gboolean config_dock_hide;
29 guint config_dock_hide_timeout;
31 gint config_mouse_threshold;
32 gint config_mouse_dclicktime;
37 <action name="ChangeDesktop">
44 static void parse_key(xmlDocPtr doc, xmlNodePtr node, GList *keylist)
51 n = parse_find_node("keybind", node);
53 if (parse_attr_string("key", n, &key)) {
54 keylist = g_list_append(keylist, key);
56 parse_key(doc, n->xmlChildrenNode, keylist);
58 it = g_list_last(keylist);
60 keylist = g_list_delete_link(keylist, it);
62 n = parse_find_node("keybind", n->next);
65 nact = parse_find_node("action", node);
67 if ((action = action_parse(doc, nact))) {
68 /* validate that its okay for a key binding */
69 if (action->func == action_moveresize &&
70 action->data.moveresize.corner !=
71 prop_atoms.net_wm_moveresize_move_keyboard &&
72 action->data.moveresize.corner !=
73 prop_atoms.net_wm_moveresize_size_keyboard) {
79 keyboard_bind(keylist, action);
81 nact = parse_find_node("action", nact->next);
86 static void parse_keyboard(xmlDocPtr doc, xmlNodePtr node, void *d)
88 parse_key(doc, node->xmlChildrenNode, NULL);
92 static int dclicktime;
95 <context name="Titlebar">
96 <mousebind button="Left" action="Press">
97 <action name="Raise"></action>
103 static void parse_mouse(xmlDocPtr doc, xmlNodePtr node, void *d)
105 xmlNodePtr n, nbut, nact;
111 node = node->xmlChildrenNode;
113 if ((n = parse_find_node("dragThreshold", node)))
114 threshold = parse_int(doc, n);
115 if ((n = parse_find_node("doubleClickTime", node)))
116 dclicktime = parse_int(doc, n);
118 n = parse_find_node("context", node);
120 if (!parse_attr_string("name", n, &contextstr))
122 nbut = parse_find_node("mousebind", n->xmlChildrenNode);
124 if (!parse_attr_string("button", nbut, &buttonstr))
126 if (parse_attr_contains("press", nbut, "action"))
127 mact = MouseAction_Press;
128 else if (parse_attr_contains("release", nbut, "action"))
129 mact = MouseAction_Release;
130 else if (parse_attr_contains("click", nbut, "action"))
131 mact = MouseAction_Click;
132 else if (parse_attr_contains("doubleclick", nbut,"action"))
133 mact = MouseAction_DClick;
134 else if (parse_attr_contains("drag", nbut, "action"))
135 mact = MouseAction_Motion;
138 nact = parse_find_node("action", nbut->xmlChildrenNode);
140 if ((action = action_parse(doc, nact))) {
141 /* validate that its okay for a mouse binding*/
142 if (mact == MouseAction_Motion) {
143 if (action->func != action_moveresize ||
144 action->data.moveresize.corner ==
145 prop_atoms.net_wm_moveresize_move_keyboard ||
146 action->data.moveresize.corner ==
147 prop_atoms.net_wm_moveresize_size_keyboard) {
152 if (action->func == action_moveresize &&
153 action->data.moveresize.corner !=
154 prop_atoms.net_wm_moveresize_move_keyboard &&
155 action->data.moveresize.corner !=
156 prop_atoms.net_wm_moveresize_size_keyboard) {
162 mouse_bind(buttonstr, contextstr, mact, action);
164 nact = parse_find_node("action", nact->next);
168 nbut = parse_find_node("mousebind", nbut->next);
172 n = parse_find_node("context", n->next);
176 static void parse_focus(xmlDocPtr doc, xmlNodePtr node, void *d)
180 node = node->xmlChildrenNode;
182 if ((n = parse_find_node("focusNew", node)))
183 config_focus_new = parse_bool(doc, n);
184 if ((n = parse_find_node("followMouse", node)))
185 config_focus_follow = parse_bool(doc, n);
186 if ((n = parse_find_node("focusLast", node)))
187 config_focus_last = parse_bool(doc, n);
188 if ((n = parse_find_node("focusLastOnDesktop", node)))
189 config_focus_last_on_desktop = parse_bool(doc, n);
190 if ((n = parse_find_node("cyclingDialog", node)))
191 config_focus_popup = parse_bool(doc, n);
194 static void parse_theme(xmlDocPtr doc, xmlNodePtr node, void *d)
198 node = node->xmlChildrenNode;
200 if ((n = parse_find_node("theme", node))) {
201 g_free(config_theme);
202 config_theme = parse_string(doc, n);
204 if ((n = parse_find_node("titlelayout", node))) {
205 g_free(config_title_layout);
206 config_title_layout = parse_string(doc, n);
210 static void parse_desktops(xmlDocPtr doc, xmlNodePtr node, void *d)
214 node = node->xmlChildrenNode;
216 if ((n = parse_find_node("number", node)))
217 config_desktops_num = parse_int(doc, n);
218 if ((n = parse_find_node("names", node))) {
222 for (it = config_desktops_names; it; it = it->next)
224 g_slist_free(config_desktops_names);
225 config_desktops_names = NULL;
227 nname = parse_find_node("name", n->xmlChildrenNode);
229 config_desktops_names = g_slist_append(config_desktops_names,
230 parse_string(doc, nname));
231 nname = parse_find_node("name", nname->next);
236 static void parse_resize(xmlDocPtr doc, xmlNodePtr node, void *d)
240 node = node->xmlChildrenNode;
242 if ((n = parse_find_node("drawContents", node)))
243 config_redraw_resize = parse_bool(doc, n);
246 static void parse_dock(xmlDocPtr doc, xmlNodePtr node, void *d)
250 node = node->xmlChildrenNode;
252 if ((n = parse_find_node("position", node))) {
253 if (parse_contains("TopLeft", doc, n))
254 config_dock_floating = FALSE,
255 config_dock_pos = OB_DIRECTION_NORTHWEST;
256 else if (parse_contains("Top", doc, n))
257 config_dock_floating = FALSE,
258 config_dock_pos = OB_DIRECTION_NORTH;
259 else if (parse_contains("TopRight", doc, n))
260 config_dock_floating = FALSE,
261 config_dock_pos = OB_DIRECTION_NORTHEAST;
262 else if (parse_contains("Right", doc, n))
263 config_dock_floating = FALSE,
264 config_dock_pos = OB_DIRECTION_EAST;
265 else if (parse_contains("BottomRight", doc, n))
266 config_dock_floating = FALSE,
267 config_dock_pos = OB_DIRECTION_SOUTHEAST;
268 else if (parse_contains("Bottom", doc, n))
269 config_dock_floating = FALSE,
270 config_dock_pos = OB_DIRECTION_SOUTH;
271 else if (parse_contains("BottomLeft", doc, n))
272 config_dock_floating = FALSE,
273 config_dock_pos = OB_DIRECTION_SOUTHWEST;
274 else if (parse_contains("Left", doc, n))
275 config_dock_floating = FALSE,
276 config_dock_pos = OB_DIRECTION_WEST;
277 else if (parse_contains("Floating", doc, n))
278 config_dock_floating = TRUE;
280 if (config_dock_floating) {
281 if ((n = parse_find_node("floatingX", node)))
282 config_dock_x = parse_int(doc, n);
283 if ((n = parse_find_node("floatingY", node)))
284 config_dock_y = parse_int(doc, n);
286 if ((n = parse_find_node("stacking", node))) {
287 if (parse_contains("top", doc, n))
288 config_dock_layer = OB_STACKING_LAYER_TOP;
289 else if (parse_contains("normal", doc, n))
290 config_dock_layer = OB_STACKING_LAYER_NORMAL;
291 else if (parse_contains("bottom", doc, n))
292 config_dock_layer = OB_STACKING_LAYER_BELOW;
294 if ((n = parse_find_node("direction", node))) {
295 if (parse_contains("horizontal", doc, n))
296 config_dock_orient = OB_ORIENTATION_HORZ;
297 else if (parse_contains("vertical", doc, n))
298 config_dock_orient = OB_ORIENTATION_VERT;
300 if ((n = parse_find_node("autoHide", node)))
301 config_dock_hide = parse_bool(doc, n);
302 if ((n = parse_find_node("hideTimeout", node)))
303 config_dock_hide_timeout = parse_int(doc, n);
306 void config_startup()
308 config_focus_new = TRUE;
309 config_focus_follow = FALSE;
310 config_focus_last = TRUE;
311 config_focus_last_on_desktop = TRUE;
312 config_focus_popup = TRUE;
314 parse_register("focus", parse_focus, NULL);
318 config_title_layout = g_strdup("NLIMC");
320 parse_register("theme", parse_theme, NULL);
322 config_desktops_num = 4;
323 config_desktops_names = NULL;
325 parse_register("desktops", parse_desktops, NULL);
327 config_redraw_resize = TRUE;
329 parse_register("resize", parse_resize, NULL);
331 config_dock_layer = OB_STACKING_LAYER_TOP;
332 config_dock_pos = OB_DIRECTION_NORTHEAST;
333 config_dock_floating = FALSE;
336 config_dock_orient = OB_ORIENTATION_VERT;
337 config_dock_hide = FALSE;
338 config_dock_hide_timeout = 3000;
340 parse_register("dock", parse_dock, NULL);
342 parse_register("keyboard", parse_keyboard, NULL);
344 config_mouse_threshold = 3;
345 config_mouse_dclicktime = 200;
347 parse_register("mouse", parse_mouse, NULL);
350 void config_shutdown()
354 g_free(config_theme);
356 for (it = config_desktops_names; it; it = it->next)
358 g_slist_free(config_desktops_names);