6 #include "parser/parse.h"
8 gboolean config_focus_new
;
9 gboolean config_focus_follow
;
10 gboolean config_focus_last
;
11 gboolean config_focus_last_on_desktop
;
12 gboolean config_focus_popup
;
13 gboolean config_desktop_popup
;
17 gchar
*config_title_layout
;
19 int config_desktops_num
;
20 GSList
*config_desktops_names
;
22 gboolean config_redraw_resize
;
24 ObStackingLayer config_dock_layer
;
25 gboolean config_dock_floating
;
26 ObDirection config_dock_pos
;
29 ObOrientation config_dock_orient
;
30 gboolean config_dock_hide
;
31 guint config_dock_hide_timeout
;
33 guint config_keyboard_reset_keycode
;
34 guint config_keyboard_reset_state
;
36 gint config_mouse_threshold
;
37 gint config_mouse_dclicktime
;
39 gchar
*config_menu_path
;
41 gint config_resist_win
;
42 gint config_resist_edge
;
44 gchar
*expand_tilde(const gchar
*f
)
51 return g_strconcat(g_get_home_dir(), f
+1, NULL
);
57 <action name="ChangeDesktop">
64 static void parse_key(ObParseInst
*i
, xmlDocPtr doc
, xmlNodePtr node
,
72 if ((n
= parse_find_node("chainQuitKey", node
))) {
73 key
= parse_string(doc
, n
);
74 translate_key(key
, &config_keyboard_reset_state
,
75 &config_keyboard_reset_keycode
);
79 n
= parse_find_node("keybind", node
);
81 if (parse_attr_string("key", n
, &key
)) {
82 keylist
= g_list_append(keylist
, key
);
84 parse_key(i
, doc
, n
->xmlChildrenNode
, keylist
);
86 it
= g_list_last(keylist
);
88 keylist
= g_list_delete_link(keylist
, it
);
90 n
= parse_find_node("keybind", n
->next
);
93 nact
= parse_find_node("action", node
);
95 if ((action
= action_parse(doc
, nact
))) {
96 /* validate that its okay for a key binding */
97 if (action
->func
== action_moveresize
&&
98 action
->data
.moveresize
.corner
!=
99 prop_atoms
.net_wm_moveresize_move_keyboard
&&
100 action
->data
.moveresize
.corner
!=
101 prop_atoms
.net_wm_moveresize_size_keyboard
) {
107 keyboard_bind(keylist
, action
);
109 nact
= parse_find_node("action", nact
->next
);
114 static void parse_keyboard(ObParseInst
*i
, xmlDocPtr doc
, xmlNodePtr node
,
117 parse_key(i
, doc
, node
->xmlChildrenNode
, NULL
);
122 <context name="Titlebar">
123 <mousebind button="Left" action="Press">
124 <action name="Raise"></action>
130 static void parse_mouse(ObParseInst
*i
, xmlDocPtr doc
, xmlNodePtr node
,
133 xmlNodePtr n
, nbut
, nact
;
139 node
= node
->xmlChildrenNode
;
141 if ((n
= parse_find_node("dragThreshold", node
)))
142 config_mouse_threshold
= parse_int(doc
, n
);
143 if ((n
= parse_find_node("doubleClickTime", node
)))
144 config_mouse_dclicktime
= parse_int(doc
, n
);
146 n
= parse_find_node("context", node
);
148 if (!parse_attr_string("name", n
, &contextstr
))
150 nbut
= parse_find_node("mousebind", n
->xmlChildrenNode
);
152 if (!parse_attr_string("button", nbut
, &buttonstr
))
154 if (parse_attr_contains("press", nbut
, "action"))
155 mact
= OB_MOUSE_ACTION_PRESS
;
156 else if (parse_attr_contains("release", nbut
, "action"))
157 mact
= OB_MOUSE_ACTION_RELEASE
;
158 else if (parse_attr_contains("click", nbut
, "action"))
159 mact
= OB_MOUSE_ACTION_CLICK
;
160 else if (parse_attr_contains("doubleclick", nbut
,"action"))
161 mact
= OB_MOUSE_ACTION_DOUBLE_CLICK
;
162 else if (parse_attr_contains("drag", nbut
, "action"))
163 mact
= OB_MOUSE_ACTION_MOTION
;
166 nact
= parse_find_node("action", nbut
->xmlChildrenNode
);
168 if ((action
= action_parse(doc
, nact
))) {
169 /* validate that its okay for a mouse binding*/
170 if (mact
== OB_MOUSE_ACTION_MOTION
) {
171 if (action
->func
!= action_moveresize
||
172 action
->data
.moveresize
.corner
==
173 prop_atoms
.net_wm_moveresize_move_keyboard
||
174 action
->data
.moveresize
.corner
==
175 prop_atoms
.net_wm_moveresize_size_keyboard
) {
180 if (action
->func
== action_moveresize
&&
181 action
->data
.moveresize
.corner
!=
182 prop_atoms
.net_wm_moveresize_move_keyboard
&&
183 action
->data
.moveresize
.corner
!=
184 prop_atoms
.net_wm_moveresize_size_keyboard
) {
190 mouse_bind(buttonstr
, contextstr
, mact
, action
);
192 nact
= parse_find_node("action", nact
->next
);
196 nbut
= parse_find_node("mousebind", nbut
->next
);
200 n
= parse_find_node("context", n
->next
);
204 static void parse_focus(ObParseInst
*i
, xmlDocPtr doc
, xmlNodePtr node
,
209 node
= node
->xmlChildrenNode
;
211 if ((n
= parse_find_node("focusNew", node
)))
212 config_focus_new
= parse_bool(doc
, n
);
213 if ((n
= parse_find_node("followMouse", node
)))
214 config_focus_follow
= parse_bool(doc
, n
);
215 if ((n
= parse_find_node("focusLast", node
)))
216 config_focus_last
= parse_bool(doc
, n
);
217 if ((n
= parse_find_node("focusLastOnDesktop", node
)))
218 config_focus_last_on_desktop
= parse_bool(doc
, n
);
219 if ((n
= parse_find_node("cyclingDialog", node
)))
220 config_focus_popup
= parse_bool(doc
, n
);
223 static void parse_theme(ObParseInst
*i
, xmlDocPtr doc
, xmlNodePtr node
,
228 node
= node
->xmlChildrenNode
;
230 if ((n
= parse_find_node("theme", node
))) {
231 g_free(config_theme
);
232 config_theme
= parse_string(doc
, n
);
234 if ((n
= parse_find_node("titlelayout", node
))) {
235 g_free(config_title_layout
);
236 config_title_layout
= parse_string(doc
, n
);
240 static void parse_desktops(ObParseInst
*i
, xmlDocPtr doc
, xmlNodePtr node
,
245 node
= node
->xmlChildrenNode
;
247 if ((n
= parse_find_node("number", node
)))
248 config_desktops_num
= parse_int(doc
, n
);
249 if ((n
= parse_find_node("names", node
))) {
253 for (it
= config_desktops_names
; it
; it
= it
->next
)
255 g_slist_free(config_desktops_names
);
256 config_desktops_names
= NULL
;
258 nname
= parse_find_node("name", n
->xmlChildrenNode
);
260 config_desktops_names
= g_slist_append(config_desktops_names
,
261 parse_string(doc
, nname
));
262 nname
= parse_find_node("name", nname
->next
);
265 if ((n
= parse_find_node("cyclingDialog", node
)))
266 config_desktop_popup
= parse_bool(doc
, n
);
269 static void parse_resize(ObParseInst
*i
, xmlDocPtr doc
, xmlNodePtr node
,
274 node
= node
->xmlChildrenNode
;
276 if ((n
= parse_find_node("drawContents", node
)))
277 config_redraw_resize
= parse_bool(doc
, n
);
280 static void parse_dock(ObParseInst
*i
, xmlDocPtr doc
, xmlNodePtr node
, void *d
)
284 node
= node
->xmlChildrenNode
;
286 if ((n
= parse_find_node("position", node
))) {
287 if (parse_contains("TopLeft", doc
, n
))
288 config_dock_floating
= FALSE
,
289 config_dock_pos
= OB_DIRECTION_NORTHWEST
;
290 else if (parse_contains("Top", doc
, n
))
291 config_dock_floating
= FALSE
,
292 config_dock_pos
= OB_DIRECTION_NORTH
;
293 else if (parse_contains("TopRight", doc
, n
))
294 config_dock_floating
= FALSE
,
295 config_dock_pos
= OB_DIRECTION_NORTHEAST
;
296 else if (parse_contains("Right", doc
, n
))
297 config_dock_floating
= FALSE
,
298 config_dock_pos
= OB_DIRECTION_EAST
;
299 else if (parse_contains("BottomRight", doc
, n
))
300 config_dock_floating
= FALSE
,
301 config_dock_pos
= OB_DIRECTION_SOUTHEAST
;
302 else if (parse_contains("Bottom", doc
, n
))
303 config_dock_floating
= FALSE
,
304 config_dock_pos
= OB_DIRECTION_SOUTH
;
305 else if (parse_contains("BottomLeft", doc
, n
))
306 config_dock_floating
= FALSE
,
307 config_dock_pos
= OB_DIRECTION_SOUTHWEST
;
308 else if (parse_contains("Left", doc
, n
))
309 config_dock_floating
= FALSE
,
310 config_dock_pos
= OB_DIRECTION_WEST
;
311 else if (parse_contains("Floating", doc
, n
))
312 config_dock_floating
= TRUE
;
314 if (config_dock_floating
) {
315 if ((n
= parse_find_node("floatingX", node
)))
316 config_dock_x
= parse_int(doc
, n
);
317 if ((n
= parse_find_node("floatingY", node
)))
318 config_dock_y
= parse_int(doc
, n
);
320 if ((n
= parse_find_node("stacking", node
))) {
321 if (parse_contains("top", doc
, n
))
322 config_dock_layer
= OB_STACKING_LAYER_TOP
;
323 else if (parse_contains("normal", doc
, n
))
324 config_dock_layer
= OB_STACKING_LAYER_NORMAL
;
325 else if (parse_contains("bottom", doc
, n
))
326 config_dock_layer
= OB_STACKING_LAYER_BELOW
;
328 if ((n
= parse_find_node("direction", node
))) {
329 if (parse_contains("horizontal", doc
, n
))
330 config_dock_orient
= OB_ORIENTATION_HORZ
;
331 else if (parse_contains("vertical", doc
, n
))
332 config_dock_orient
= OB_ORIENTATION_VERT
;
334 if ((n
= parse_find_node("autoHide", node
)))
335 config_dock_hide
= parse_bool(doc
, n
);
336 if ((n
= parse_find_node("hideTimeout", node
)))
337 config_dock_hide_timeout
= parse_int(doc
, n
);
340 static void parse_menu(ObParseInst
*i
, xmlDocPtr doc
, xmlNodePtr node
, void *d
)
344 node
= node
->xmlChildrenNode
;
345 if ((n
= parse_find_node("location", node
))) {
348 c
= parse_string(doc
, n
);
349 config_menu_path
= expand_tilde(c
);
354 static void parse_resistance(ObParseInst
*i
, xmlDocPtr doc
, xmlNodePtr node
,
359 node
= node
->xmlChildrenNode
;
360 if ((n
= parse_find_node("strength", node
)))
361 config_resist_win
= parse_int(doc
, n
);
362 if ((n
= parse_find_node("screen_edge_strength", node
)))
363 config_resist_edge
= parse_int(doc
, n
);
366 void config_startup(ObParseInst
*i
)
368 config_focus_new
= TRUE
;
369 config_focus_follow
= FALSE
;
370 config_focus_last
= TRUE
;
371 config_focus_last_on_desktop
= TRUE
;
372 config_focus_popup
= TRUE
;
374 parse_register(i
, "focus", parse_focus
, NULL
);
378 config_title_layout
= g_strdup("NLIMC");
380 parse_register(i
, "theme", parse_theme
, NULL
);
382 config_desktops_num
= 4;
383 config_desktops_names
= NULL
;
384 config_desktop_popup
= TRUE
;
386 parse_register(i
, "desktops", parse_desktops
, NULL
);
388 config_redraw_resize
= TRUE
;
390 parse_register(i
, "resize", parse_resize
, NULL
);
392 config_dock_layer
= OB_STACKING_LAYER_TOP
;
393 config_dock_pos
= OB_DIRECTION_NORTHEAST
;
394 config_dock_floating
= FALSE
;
397 config_dock_orient
= OB_ORIENTATION_VERT
;
398 config_dock_hide
= FALSE
;
399 config_dock_hide_timeout
= 3000;
401 parse_register(i
, "dock", parse_dock
, NULL
);
403 translate_key("C-g", &config_keyboard_reset_state
,
404 &config_keyboard_reset_keycode
);
406 parse_register(i
, "keyboard", parse_keyboard
, NULL
);
408 config_mouse_threshold
= 3;
409 config_mouse_dclicktime
= 200;
411 parse_register(i
, "mouse", parse_mouse
, NULL
);
413 config_resist_win
= 10;
414 config_resist_edge
= 10;
416 parse_register(i
, "resistance", parse_resistance
, NULL
);
418 config_menu_path
= NULL
;
420 parse_register(i
, "menu", parse_menu
, NULL
);
423 void config_shutdown()
427 g_free(config_theme
);
429 for (it
= config_desktops_names
; it
; it
= it
->next
)
431 g_slist_free(config_desktops_names
);