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
);
104 <context name="Titlebar">
105 <mousebind button="Left" action="Press">
106 <action name="Raise"></action>
112 static void parse_mouse(xmlDocPtr doc
, xmlNodePtr node
, void *d
)
114 xmlNodePtr n
, nbut
, nact
;
120 node
= node
->xmlChildrenNode
;
122 if ((n
= parse_find_node("dragThreshold", node
)))
123 config_mouse_threshold
= parse_int(doc
, n
);
124 if ((n
= parse_find_node("doubleClickTime", node
)))
125 config_mouse_dclicktime
= parse_int(doc
, n
);
127 n
= parse_find_node("context", node
);
129 if (!parse_attr_string("name", n
, &contextstr
))
131 nbut
= parse_find_node("mousebind", n
->xmlChildrenNode
);
133 if (!parse_attr_string("button", nbut
, &buttonstr
))
135 if (parse_attr_contains("press", nbut
, "action"))
136 mact
= OB_MOUSE_ACTION_PRESS
;
137 else if (parse_attr_contains("release", nbut
, "action"))
138 mact
= OB_MOUSE_ACTION_RELEASE
;
139 else if (parse_attr_contains("click", nbut
, "action"))
140 mact
= OB_MOUSE_ACTION_CLICK
;
141 else if (parse_attr_contains("doubleclick", nbut
,"action"))
142 mact
= OB_MOUSE_ACTION_DOUBLE_CLICK
;
143 else if (parse_attr_contains("drag", nbut
, "action"))
144 mact
= OB_MOUSE_ACTION_MOTION
;
147 nact
= parse_find_node("action", nbut
->xmlChildrenNode
);
149 if ((action
= action_parse(doc
, nact
))) {
150 /* validate that its okay for a mouse binding*/
151 if (mact
== OB_MOUSE_ACTION_MOTION
) {
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
) {
161 if (action
->func
== action_moveresize
&&
162 action
->data
.moveresize
.corner
!=
163 prop_atoms
.net_wm_moveresize_move_keyboard
&&
164 action
->data
.moveresize
.corner
!=
165 prop_atoms
.net_wm_moveresize_size_keyboard
) {
171 mouse_bind(buttonstr
, contextstr
, mact
, action
);
173 nact
= parse_find_node("action", nact
->next
);
177 nbut
= parse_find_node("mousebind", nbut
->next
);
181 n
= parse_find_node("context", n
->next
);
185 static void parse_focus(xmlDocPtr doc
, xmlNodePtr node
, void *d
)
189 node
= node
->xmlChildrenNode
;
191 if ((n
= parse_find_node("focusNew", node
)))
192 config_focus_new
= parse_bool(doc
, n
);
193 if ((n
= parse_find_node("followMouse", node
)))
194 config_focus_follow
= parse_bool(doc
, n
);
195 if ((n
= parse_find_node("focusLast", node
)))
196 config_focus_last
= parse_bool(doc
, n
);
197 if ((n
= parse_find_node("focusLastOnDesktop", node
)))
198 config_focus_last_on_desktop
= parse_bool(doc
, n
);
199 if ((n
= parse_find_node("cyclingDialog", node
)))
200 config_focus_popup
= parse_bool(doc
, n
);
203 static void parse_theme(xmlDocPtr doc
, xmlNodePtr node
, void *d
)
207 node
= node
->xmlChildrenNode
;
209 if ((n
= parse_find_node("theme", node
))) {
210 g_free(config_theme
);
211 config_theme
= parse_string(doc
, n
);
213 if ((n
= parse_find_node("titlelayout", node
))) {
214 g_free(config_title_layout
);
215 config_title_layout
= parse_string(doc
, n
);
219 static void parse_desktops(xmlDocPtr doc
, xmlNodePtr node
, void *d
)
223 node
= node
->xmlChildrenNode
;
225 if ((n
= parse_find_node("number", node
)))
226 config_desktops_num
= parse_int(doc
, n
);
227 if ((n
= parse_find_node("names", node
))) {
231 for (it
= config_desktops_names
; it
; it
= it
->next
)
233 g_slist_free(config_desktops_names
);
234 config_desktops_names
= NULL
;
236 nname
= parse_find_node("name", n
->xmlChildrenNode
);
238 config_desktops_names
= g_slist_append(config_desktops_names
,
239 parse_string(doc
, nname
));
240 nname
= parse_find_node("name", nname
->next
);
243 if ((n
= parse_find_node("cyclingDialog", node
)))
244 config_desktop_popup
= parse_bool(doc
, n
);
247 static void parse_resize(xmlDocPtr doc
, xmlNodePtr node
, void *d
)
251 node
= node
->xmlChildrenNode
;
253 if ((n
= parse_find_node("drawContents", node
)))
254 config_redraw_resize
= parse_bool(doc
, n
);
257 static void parse_dock(xmlDocPtr doc
, xmlNodePtr node
, void *d
)
261 node
= node
->xmlChildrenNode
;
263 if ((n
= parse_find_node("position", node
))) {
264 if (parse_contains("TopLeft", doc
, n
))
265 config_dock_floating
= FALSE
,
266 config_dock_pos
= OB_DIRECTION_NORTHWEST
;
267 else if (parse_contains("Top", doc
, n
))
268 config_dock_floating
= FALSE
,
269 config_dock_pos
= OB_DIRECTION_NORTH
;
270 else if (parse_contains("TopRight", doc
, n
))
271 config_dock_floating
= FALSE
,
272 config_dock_pos
= OB_DIRECTION_NORTHEAST
;
273 else if (parse_contains("Right", doc
, n
))
274 config_dock_floating
= FALSE
,
275 config_dock_pos
= OB_DIRECTION_EAST
;
276 else if (parse_contains("BottomRight", doc
, n
))
277 config_dock_floating
= FALSE
,
278 config_dock_pos
= OB_DIRECTION_SOUTHEAST
;
279 else if (parse_contains("Bottom", doc
, n
))
280 config_dock_floating
= FALSE
,
281 config_dock_pos
= OB_DIRECTION_SOUTH
;
282 else if (parse_contains("BottomLeft", doc
, n
))
283 config_dock_floating
= FALSE
,
284 config_dock_pos
= OB_DIRECTION_SOUTHWEST
;
285 else if (parse_contains("Left", doc
, n
))
286 config_dock_floating
= FALSE
,
287 config_dock_pos
= OB_DIRECTION_WEST
;
288 else if (parse_contains("Floating", doc
, n
))
289 config_dock_floating
= TRUE
;
291 if (config_dock_floating
) {
292 if ((n
= parse_find_node("floatingX", node
)))
293 config_dock_x
= parse_int(doc
, n
);
294 if ((n
= parse_find_node("floatingY", node
)))
295 config_dock_y
= parse_int(doc
, n
);
297 if ((n
= parse_find_node("stacking", node
))) {
298 if (parse_contains("top", doc
, n
))
299 config_dock_layer
= OB_STACKING_LAYER_TOP
;
300 else if (parse_contains("normal", doc
, n
))
301 config_dock_layer
= OB_STACKING_LAYER_NORMAL
;
302 else if (parse_contains("bottom", doc
, n
))
303 config_dock_layer
= OB_STACKING_LAYER_BELOW
;
305 if ((n
= parse_find_node("direction", node
))) {
306 if (parse_contains("horizontal", doc
, n
))
307 config_dock_orient
= OB_ORIENTATION_HORZ
;
308 else if (parse_contains("vertical", doc
, n
))
309 config_dock_orient
= OB_ORIENTATION_VERT
;
311 if ((n
= parse_find_node("autoHide", node
)))
312 config_dock_hide
= parse_bool(doc
, n
);
313 if ((n
= parse_find_node("hideTimeout", node
)))
314 config_dock_hide_timeout
= parse_int(doc
, n
);
317 void config_startup()
319 config_focus_new
= TRUE
;
320 config_focus_follow
= FALSE
;
321 config_focus_last
= TRUE
;
322 config_focus_last_on_desktop
= TRUE
;
323 config_focus_popup
= TRUE
;
325 parse_register("focus", parse_focus
, NULL
);
329 config_title_layout
= g_strdup("NLIMC");
331 parse_register("theme", parse_theme
, NULL
);
333 config_desktops_num
= 4;
334 config_desktops_names
= NULL
;
335 config_desktop_popup
= TRUE
;
337 parse_register("desktops", parse_desktops
, NULL
);
339 config_redraw_resize
= TRUE
;
341 parse_register("resize", parse_resize
, NULL
);
343 config_dock_layer
= OB_STACKING_LAYER_TOP
;
344 config_dock_pos
= OB_DIRECTION_NORTHEAST
;
345 config_dock_floating
= FALSE
;
348 config_dock_orient
= OB_ORIENTATION_VERT
;
349 config_dock_hide
= FALSE
;
350 config_dock_hide_timeout
= 3000;
352 parse_register("dock", parse_dock
, NULL
);
354 translate_key("C-g", &config_keyboard_reset_state
,
355 &config_keyboard_reset_keycode
);
357 parse_register("keyboard", parse_keyboard
, NULL
);
359 config_mouse_threshold
= 3;
360 config_mouse_dclicktime
= 200;
362 parse_register("mouse", parse_mouse
, NULL
);
365 void config_shutdown()
369 g_free(config_theme
);
371 for (it
= config_desktops_names
; it
; it
= it
->next
)
373 g_slist_free(config_desktops_names
);