6 #include "parser/parse.h"
9 gboolean config_focus_new
;
10 gboolean config_focus_follow
;
11 gboolean config_focus_last
;
12 gboolean config_focus_last_on_desktop
;
16 gchar
*config_title_layout
;
18 int config_desktops_num
;
19 GSList
*config_desktops_names
;
21 gboolean config_redraw_resize
;
23 ObStackingLayer config_dock_layer
;
24 gboolean config_dock_floating
;
25 ObDirection config_dock_pos
;
28 ObOrientation config_dock_orient
;
29 gboolean config_dock_hide
;
30 guint config_dock_hide_timeout
;
32 guint config_keyboard_reset_keycode
;
33 guint config_keyboard_reset_state
;
35 gint config_mouse_threshold
;
36 gint config_mouse_dclicktime
;
38 GSList
*config_menu_files
;
40 gint config_resist_win
;
41 gint config_resist_edge
;
43 GSList
*config_urgent_actions
;
48 <action name="ChangeDesktop">
55 static void parse_key(ObParseInst
*i
, xmlDocPtr doc
, xmlNodePtr node
,
63 if ((n
= parse_find_node("chainQuitKey", node
))) {
64 key
= parse_string(doc
, n
);
65 translate_key(key
, &config_keyboard_reset_state
,
66 &config_keyboard_reset_keycode
);
70 n
= parse_find_node("keybind", node
);
72 if (parse_attr_string("key", n
, &key
)) {
73 keylist
= g_list_append(keylist
, key
);
75 parse_key(i
, doc
, n
->xmlChildrenNode
, keylist
);
77 it
= g_list_last(keylist
);
79 keylist
= g_list_delete_link(keylist
, it
);
81 n
= parse_find_node("keybind", n
->next
);
84 nact
= parse_find_node("action", node
);
86 if ((action
= action_parse(i
, doc
, nact
))) {
87 /* validate that its okay for a key binding */
88 if (action
->func
== action_moveresize
&&
89 action
->data
.moveresize
.corner
!=
90 prop_atoms
.net_wm_moveresize_move_keyboard
&&
91 action
->data
.moveresize
.corner
!=
92 prop_atoms
.net_wm_moveresize_size_keyboard
) {
98 keyboard_bind(keylist
, action
);
100 nact
= parse_find_node("action", nact
->next
);
105 static void parse_keyboard(ObParseInst
*i
, xmlDocPtr doc
, xmlNodePtr node
,
108 parse_key(i
, doc
, node
->xmlChildrenNode
, NULL
);
113 <context name="Titlebar">
114 <mousebind button="Left" action="Press">
115 <action name="Raise"></action>
121 static void parse_mouse(ObParseInst
*i
, xmlDocPtr doc
, xmlNodePtr node
,
124 xmlNodePtr n
, nbut
, nact
;
130 node
= node
->xmlChildrenNode
;
132 if ((n
= parse_find_node("dragThreshold", node
)))
133 config_mouse_threshold
= parse_int(doc
, n
);
134 if ((n
= parse_find_node("doubleClickTime", node
)))
135 config_mouse_dclicktime
= parse_int(doc
, n
);
137 n
= parse_find_node("context", node
);
139 if (!parse_attr_string("name", n
, &contextstr
))
141 nbut
= parse_find_node("mousebind", n
->xmlChildrenNode
);
143 if (!parse_attr_string("button", nbut
, &buttonstr
))
145 if (parse_attr_contains("press", nbut
, "action"))
146 mact
= OB_MOUSE_ACTION_PRESS
;
147 else if (parse_attr_contains("release", nbut
, "action"))
148 mact
= OB_MOUSE_ACTION_RELEASE
;
149 else if (parse_attr_contains("click", nbut
, "action"))
150 mact
= OB_MOUSE_ACTION_CLICK
;
151 else if (parse_attr_contains("doubleclick", nbut
,"action"))
152 mact
= OB_MOUSE_ACTION_DOUBLE_CLICK
;
153 else if (parse_attr_contains("drag", nbut
, "action"))
154 mact
= OB_MOUSE_ACTION_MOTION
;
157 nact
= parse_find_node("action", nbut
->xmlChildrenNode
);
159 if ((action
= action_parse(i
, doc
, nact
))) {
160 /* validate that its okay for a mouse binding*/
161 if (mact
== OB_MOUSE_ACTION_MOTION
) {
162 if (action
->func
!= action_moveresize
||
163 action
->data
.moveresize
.corner
==
164 prop_atoms
.net_wm_moveresize_move_keyboard
||
165 action
->data
.moveresize
.corner
==
166 prop_atoms
.net_wm_moveresize_size_keyboard
) {
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
) {
181 mouse_bind(buttonstr
, contextstr
, mact
, action
);
183 nact
= parse_find_node("action", nact
->next
);
187 nbut
= parse_find_node("mousebind", nbut
->next
);
191 n
= parse_find_node("context", n
->next
);
195 static void parse_focus(ObParseInst
*i
, xmlDocPtr doc
, xmlNodePtr node
,
200 node
= node
->xmlChildrenNode
;
202 if ((n
= parse_find_node("focusNew", node
)))
203 config_focus_new
= parse_bool(doc
, n
);
204 if ((n
= parse_find_node("followMouse", node
)))
205 config_focus_follow
= parse_bool(doc
, n
);
206 if ((n
= parse_find_node("focusLast", node
)))
207 config_focus_last
= parse_bool(doc
, n
);
208 if ((n
= parse_find_node("focusLastOnDesktop", node
)))
209 config_focus_last_on_desktop
= parse_bool(doc
, n
);
212 static void parse_theme(ObParseInst
*i
, xmlDocPtr doc
, xmlNodePtr node
,
217 node
= node
->xmlChildrenNode
;
219 if ((n
= parse_find_node("theme", node
))) {
222 g_free(config_theme
);
223 c
= parse_string(doc
, n
);
224 config_theme
= ob_expand_tilde(c
);
227 if ((n
= parse_find_node("titleLayout", node
))) {
228 g_free(config_title_layout
);
229 config_title_layout
= parse_string(doc
, n
);
233 static void parse_desktops(ObParseInst
*i
, xmlDocPtr doc
, xmlNodePtr node
,
238 node
= node
->xmlChildrenNode
;
240 if ((n
= parse_find_node("number", node
)))
241 config_desktops_num
= parse_int(doc
, n
);
242 if ((n
= parse_find_node("names", node
))) {
246 for (it
= config_desktops_names
; it
; it
= it
->next
)
248 g_slist_free(config_desktops_names
);
249 config_desktops_names
= NULL
;
251 nname
= parse_find_node("name", n
->xmlChildrenNode
);
253 config_desktops_names
= g_slist_append(config_desktops_names
,
254 parse_string(doc
, nname
));
255 nname
= parse_find_node("name", nname
->next
);
260 static void parse_resize(ObParseInst
*i
, xmlDocPtr doc
, xmlNodePtr node
,
265 node
= node
->xmlChildrenNode
;
267 if ((n
= parse_find_node("drawContents", node
)))
268 config_redraw_resize
= parse_bool(doc
, n
);
271 static void parse_dock(ObParseInst
*i
, xmlDocPtr doc
, xmlNodePtr node
, void *d
)
275 node
= node
->xmlChildrenNode
;
277 if ((n
= parse_find_node("position", node
))) {
278 if (parse_contains("TopLeft", doc
, n
))
279 config_dock_floating
= FALSE
,
280 config_dock_pos
= OB_DIRECTION_NORTHWEST
;
281 else if (parse_contains("Top", doc
, n
))
282 config_dock_floating
= FALSE
,
283 config_dock_pos
= OB_DIRECTION_NORTH
;
284 else if (parse_contains("TopRight", doc
, n
))
285 config_dock_floating
= FALSE
,
286 config_dock_pos
= OB_DIRECTION_NORTHEAST
;
287 else if (parse_contains("Right", doc
, n
))
288 config_dock_floating
= FALSE
,
289 config_dock_pos
= OB_DIRECTION_EAST
;
290 else if (parse_contains("BottomRight", doc
, n
))
291 config_dock_floating
= FALSE
,
292 config_dock_pos
= OB_DIRECTION_SOUTHEAST
;
293 else if (parse_contains("Bottom", doc
, n
))
294 config_dock_floating
= FALSE
,
295 config_dock_pos
= OB_DIRECTION_SOUTH
;
296 else if (parse_contains("BottomLeft", doc
, n
))
297 config_dock_floating
= FALSE
,
298 config_dock_pos
= OB_DIRECTION_SOUTHWEST
;
299 else if (parse_contains("Left", doc
, n
))
300 config_dock_floating
= FALSE
,
301 config_dock_pos
= OB_DIRECTION_WEST
;
302 else if (parse_contains("Floating", doc
, n
))
303 config_dock_floating
= TRUE
;
305 if (config_dock_floating
) {
306 if ((n
= parse_find_node("floatingX", node
)))
307 config_dock_x
= parse_int(doc
, n
);
308 if ((n
= parse_find_node("floatingY", node
)))
309 config_dock_y
= parse_int(doc
, n
);
311 if ((n
= parse_find_node("stacking", node
))) {
312 if (parse_contains("top", doc
, n
))
313 config_dock_layer
= OB_STACKING_LAYER_TOP
;
314 else if (parse_contains("normal", doc
, n
))
315 config_dock_layer
= OB_STACKING_LAYER_NORMAL
;
316 else if (parse_contains("bottom", doc
, n
))
317 config_dock_layer
= OB_STACKING_LAYER_BELOW
;
319 if ((n
= parse_find_node("direction", node
))) {
320 if (parse_contains("horizontal", doc
, n
))
321 config_dock_orient
= OB_ORIENTATION_HORZ
;
322 else if (parse_contains("vertical", doc
, n
))
323 config_dock_orient
= OB_ORIENTATION_VERT
;
325 if ((n
= parse_find_node("autoHide", node
)))
326 config_dock_hide
= parse_bool(doc
, n
);
327 if ((n
= parse_find_node("hideTimeout", node
)))
328 config_dock_hide_timeout
= parse_int(doc
, n
);
331 static void parse_menu(ObParseInst
*i
, xmlDocPtr doc
, xmlNodePtr node
, void *d
)
333 for (node
= node
->xmlChildrenNode
; node
; node
= node
->next
) {
334 if (!xmlStrcasecmp(node
->name
, (const xmlChar
*) "file")) {
337 c
= parse_string(doc
, node
);
338 config_menu_files
= g_slist_append(config_menu_files
,
345 static void parse_resistance(ObParseInst
*i
, xmlDocPtr doc
, xmlNodePtr node
,
350 node
= node
->xmlChildrenNode
;
351 if ((n
= parse_find_node("strength", node
)))
352 config_resist_win
= parse_int(doc
, n
);
353 if ((n
= parse_find_node("screen_edge_strength", node
)))
354 config_resist_edge
= parse_int(doc
, n
);
357 static void parse_urgent(ObParseInst
*i
, xmlDocPtr doc
, xmlNodePtr node
,
363 nact
= parse_find_node("action", node
->xmlChildrenNode
);
365 if ((action
= action_parse(i
, doc
, nact
))) {
366 /* validate that its okay for an urgent binding */
367 if (action
->func
== action_moveresize
&&
368 action
->data
.moveresize
.corner
!=
369 prop_atoms
.net_wm_moveresize_move_keyboard
&&
370 action
->data
.moveresize
.corner
!=
371 prop_atoms
.net_wm_moveresize_size_keyboard
) {
377 config_urgent_actions
= g_slist_append(config_urgent_actions
,
380 nact
= parse_find_node("action", nact
->next
);
384 void config_startup(ObParseInst
*i
)
386 config_focus_new
= TRUE
;
387 config_focus_follow
= FALSE
;
388 config_focus_last
= TRUE
;
389 config_focus_last_on_desktop
= TRUE
;
391 parse_register(i
, "focus", parse_focus
, NULL
);
395 config_title_layout
= g_strdup("NLIMC");
397 parse_register(i
, "theme", parse_theme
, NULL
);
399 config_desktops_num
= 4;
400 config_desktops_names
= NULL
;
402 parse_register(i
, "desktops", parse_desktops
, NULL
);
404 config_redraw_resize
= TRUE
;
406 parse_register(i
, "resize", parse_resize
, NULL
);
408 config_dock_layer
= OB_STACKING_LAYER_TOP
;
409 config_dock_pos
= OB_DIRECTION_NORTHEAST
;
410 config_dock_floating
= FALSE
;
413 config_dock_orient
= OB_ORIENTATION_VERT
;
414 config_dock_hide
= FALSE
;
415 config_dock_hide_timeout
= 3000;
417 parse_register(i
, "dock", parse_dock
, NULL
);
419 translate_key("C-g", &config_keyboard_reset_state
,
420 &config_keyboard_reset_keycode
);
422 parse_register(i
, "keyboard", parse_keyboard
, NULL
);
424 config_mouse_threshold
= 3;
425 config_mouse_dclicktime
= 200;
427 parse_register(i
, "mouse", parse_mouse
, NULL
);
429 config_resist_win
= 10;
430 config_resist_edge
= 10;
432 parse_register(i
, "resistance", parse_resistance
, NULL
);
434 config_menu_files
= NULL
;
436 parse_register(i
, "menu", parse_menu
, NULL
);
438 parse_register(i
, "urgent", parse_urgent
, NULL
);
441 void config_shutdown()
445 g_free(config_theme
);
447 for (it
= config_desktops_names
; it
; it
= g_slist_next(it
))
449 g_slist_free(config_desktops_names
);
451 for (it
= config_menu_files
; it
; it
= g_slist_next(it
))
453 g_slist_free(config_menu_files
);