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
;
42 <action name="ChangeDesktop">
49 static void parse_key(xmlDocPtr doc
, xmlNodePtr node
, GList
*keylist
)
56 if ((n
= parse_find_node("chainQuitKey", node
))) {
57 key
= parse_string(doc
, n
);
58 translate_key(key
, &config_keyboard_reset_state
,
59 &config_keyboard_reset_keycode
);
62 n
= parse_find_node("keybind", node
);
64 if (parse_attr_string("key", n
, &key
)) {
65 keylist
= g_list_append(keylist
, key
);
67 parse_key(doc
, n
->xmlChildrenNode
, keylist
);
69 it
= g_list_last(keylist
);
71 keylist
= g_list_delete_link(keylist
, it
);
73 n
= parse_find_node("keybind", n
->next
);
76 nact
= parse_find_node("action", node
);
78 if ((action
= action_parse(doc
, nact
))) {
79 /* validate that its okay for a key binding */
80 if (action
->func
== action_moveresize
&&
81 action
->data
.moveresize
.corner
!=
82 prop_atoms
.net_wm_moveresize_move_keyboard
&&
83 action
->data
.moveresize
.corner
!=
84 prop_atoms
.net_wm_moveresize_size_keyboard
) {
90 keyboard_bind(keylist
, action
);
92 nact
= parse_find_node("action", nact
->next
);
97 static void parse_keyboard(xmlDocPtr doc
, xmlNodePtr node
, void *d
)
99 parse_key(doc
, node
->xmlChildrenNode
, NULL
);
102 static int threshold
;
103 static int dclicktime
;
106 <context name="Titlebar">
107 <mousebind button="Left" action="Press">
108 <action name="Raise"></action>
114 static void parse_mouse(xmlDocPtr doc
, xmlNodePtr node
, void *d
)
116 xmlNodePtr n
, nbut
, nact
;
122 node
= node
->xmlChildrenNode
;
124 if ((n
= parse_find_node("dragThreshold", node
)))
125 threshold
= parse_int(doc
, n
);
126 if ((n
= parse_find_node("doubleClickTime", node
)))
127 dclicktime
= parse_int(doc
, n
);
129 n
= parse_find_node("context", node
);
131 if (!parse_attr_string("name", n
, &contextstr
))
133 nbut
= parse_find_node("mousebind", n
->xmlChildrenNode
);
135 if (!parse_attr_string("button", nbut
, &buttonstr
))
137 if (parse_attr_contains("press", nbut
, "action"))
138 mact
= MouseAction_Press
;
139 else if (parse_attr_contains("release", nbut
, "action"))
140 mact
= MouseAction_Release
;
141 else if (parse_attr_contains("click", nbut
, "action"))
142 mact
= MouseAction_Click
;
143 else if (parse_attr_contains("doubleclick", nbut
,"action"))
144 mact
= MouseAction_DClick
;
145 else if (parse_attr_contains("drag", nbut
, "action"))
146 mact
= MouseAction_Motion
;
149 nact
= parse_find_node("action", nbut
->xmlChildrenNode
);
151 if ((action
= action_parse(doc
, nact
))) {
152 /* validate that its okay for a mouse binding*/
153 if (mact
== MouseAction_Motion
) {
154 if (action
->func
!= action_moveresize
||
155 action
->data
.moveresize
.corner
==
156 prop_atoms
.net_wm_moveresize_move_keyboard
||
157 action
->data
.moveresize
.corner
==
158 prop_atoms
.net_wm_moveresize_size_keyboard
) {
163 if (action
->func
== action_moveresize
&&
164 action
->data
.moveresize
.corner
!=
165 prop_atoms
.net_wm_moveresize_move_keyboard
&&
166 action
->data
.moveresize
.corner
!=
167 prop_atoms
.net_wm_moveresize_size_keyboard
) {
173 mouse_bind(buttonstr
, contextstr
, mact
, action
);
175 nact
= parse_find_node("action", nact
->next
);
179 nbut
= parse_find_node("mousebind", nbut
->next
);
183 n
= parse_find_node("context", n
->next
);
187 static void parse_focus(xmlDocPtr doc
, xmlNodePtr node
, void *d
)
191 node
= node
->xmlChildrenNode
;
193 if ((n
= parse_find_node("focusNew", node
)))
194 config_focus_new
= parse_bool(doc
, n
);
195 if ((n
= parse_find_node("followMouse", node
)))
196 config_focus_follow
= parse_bool(doc
, n
);
197 if ((n
= parse_find_node("focusLast", node
)))
198 config_focus_last
= parse_bool(doc
, n
);
199 if ((n
= parse_find_node("focusLastOnDesktop", node
)))
200 config_focus_last_on_desktop
= parse_bool(doc
, n
);
201 if ((n
= parse_find_node("cyclingDialog", node
)))
202 config_focus_popup
= parse_bool(doc
, n
);
205 static void parse_theme(xmlDocPtr doc
, xmlNodePtr node
, void *d
)
209 node
= node
->xmlChildrenNode
;
211 if ((n
= parse_find_node("theme", node
))) {
212 g_free(config_theme
);
213 config_theme
= parse_string(doc
, n
);
215 if ((n
= parse_find_node("titlelayout", node
))) {
216 g_free(config_title_layout
);
217 config_title_layout
= parse_string(doc
, n
);
221 static void parse_desktops(xmlDocPtr doc
, xmlNodePtr node
, void *d
)
225 node
= node
->xmlChildrenNode
;
227 if ((n
= parse_find_node("number", node
)))
228 config_desktops_num
= parse_int(doc
, n
);
229 if ((n
= parse_find_node("names", node
))) {
233 for (it
= config_desktops_names
; it
; it
= it
->next
)
235 g_slist_free(config_desktops_names
);
236 config_desktops_names
= NULL
;
238 nname
= parse_find_node("name", n
->xmlChildrenNode
);
240 config_desktops_names
= g_slist_append(config_desktops_names
,
241 parse_string(doc
, nname
));
242 nname
= parse_find_node("name", nname
->next
);
245 if ((n
= parse_find_node("cyclingDialog", node
)))
246 config_desktop_popup
= parse_bool(doc
, n
);
249 static void parse_resize(xmlDocPtr doc
, xmlNodePtr node
, void *d
)
253 node
= node
->xmlChildrenNode
;
255 if ((n
= parse_find_node("drawContents", node
)))
256 config_redraw_resize
= parse_bool(doc
, n
);
259 static void parse_dock(xmlDocPtr doc
, xmlNodePtr node
, void *d
)
263 node
= node
->xmlChildrenNode
;
265 if ((n
= parse_find_node("position", node
))) {
266 if (parse_contains("TopLeft", doc
, n
))
267 config_dock_floating
= FALSE
,
268 config_dock_pos
= OB_DIRECTION_NORTHWEST
;
269 else if (parse_contains("Top", doc
, n
))
270 config_dock_floating
= FALSE
,
271 config_dock_pos
= OB_DIRECTION_NORTH
;
272 else if (parse_contains("TopRight", doc
, n
))
273 config_dock_floating
= FALSE
,
274 config_dock_pos
= OB_DIRECTION_NORTHEAST
;
275 else if (parse_contains("Right", doc
, n
))
276 config_dock_floating
= FALSE
,
277 config_dock_pos
= OB_DIRECTION_EAST
;
278 else if (parse_contains("BottomRight", doc
, n
))
279 config_dock_floating
= FALSE
,
280 config_dock_pos
= OB_DIRECTION_SOUTHEAST
;
281 else if (parse_contains("Bottom", doc
, n
))
282 config_dock_floating
= FALSE
,
283 config_dock_pos
= OB_DIRECTION_SOUTH
;
284 else if (parse_contains("BottomLeft", doc
, n
))
285 config_dock_floating
= FALSE
,
286 config_dock_pos
= OB_DIRECTION_SOUTHWEST
;
287 else if (parse_contains("Left", doc
, n
))
288 config_dock_floating
= FALSE
,
289 config_dock_pos
= OB_DIRECTION_WEST
;
290 else if (parse_contains("Floating", doc
, n
))
291 config_dock_floating
= TRUE
;
293 if (config_dock_floating
) {
294 if ((n
= parse_find_node("floatingX", node
)))
295 config_dock_x
= parse_int(doc
, n
);
296 if ((n
= parse_find_node("floatingY", node
)))
297 config_dock_y
= parse_int(doc
, n
);
299 if ((n
= parse_find_node("stacking", node
))) {
300 if (parse_contains("top", doc
, n
))
301 config_dock_layer
= OB_STACKING_LAYER_TOP
;
302 else if (parse_contains("normal", doc
, n
))
303 config_dock_layer
= OB_STACKING_LAYER_NORMAL
;
304 else if (parse_contains("bottom", doc
, n
))
305 config_dock_layer
= OB_STACKING_LAYER_BELOW
;
307 if ((n
= parse_find_node("direction", node
))) {
308 if (parse_contains("horizontal", doc
, n
))
309 config_dock_orient
= OB_ORIENTATION_HORZ
;
310 else if (parse_contains("vertical", doc
, n
))
311 config_dock_orient
= OB_ORIENTATION_VERT
;
313 if ((n
= parse_find_node("autoHide", node
)))
314 config_dock_hide
= parse_bool(doc
, n
);
315 if ((n
= parse_find_node("hideTimeout", node
)))
316 config_dock_hide_timeout
= parse_int(doc
, n
);
319 void config_startup()
321 config_focus_new
= TRUE
;
322 config_focus_follow
= FALSE
;
323 config_focus_last
= TRUE
;
324 config_focus_last_on_desktop
= TRUE
;
325 config_focus_popup
= TRUE
;
327 parse_register("focus", parse_focus
, NULL
);
331 config_title_layout
= g_strdup("NLIMC");
333 parse_register("theme", parse_theme
, NULL
);
335 config_desktops_num
= 4;
336 config_desktops_names
= NULL
;
337 config_desktop_popup
= TRUE
;
339 parse_register("desktops", parse_desktops
, NULL
);
341 config_redraw_resize
= TRUE
;
343 parse_register("resize", parse_resize
, NULL
);
345 config_dock_layer
= OB_STACKING_LAYER_TOP
;
346 config_dock_pos
= OB_DIRECTION_NORTHEAST
;
347 config_dock_floating
= FALSE
;
350 config_dock_orient
= OB_ORIENTATION_VERT
;
351 config_dock_hide
= FALSE
;
352 config_dock_hide_timeout
= 3000;
354 parse_register("dock", parse_dock
, NULL
);
356 translate_key("C-g", &config_keyboard_reset_state
,
357 &config_keyboard_reset_keycode
);
359 parse_register("keyboard", parse_keyboard
, NULL
);
361 config_mouse_threshold
= 3;
362 config_mouse_dclicktime
= 200;
364 parse_register("mouse", parse_mouse
, NULL
);
367 void config_shutdown()
371 g_free(config_theme
);
373 for (it
= config_desktops_names
; it
; it
= it
->next
)
375 g_slist_free(config_desktops_names
);