]> Dogcows Code - chaz/openbox/blob - openbox/config.c
Fix some keyboard control issues.
[chaz/openbox] / openbox / config.c
1 #include "config.h"
2 #include "parser/parse.h"
3
4 gboolean config_focus_new;
5 gboolean config_focus_follow;
6 gboolean config_focus_last;
7 gboolean config_focus_last_on_desktop;
8 gboolean config_focus_popup;
9
10 char *config_theme;
11
12 int config_desktops_num;
13 GSList *config_desktops_names;
14
15 gboolean config_opaque_move;
16 gboolean config_opaque_resize;
17
18 ObStackingLayer config_dock_layer;
19 gboolean config_dock_floating;
20 ObDirection config_dock_pos;
21 gint config_dock_x;
22 gint config_dock_y;
23 ObOrientation config_dock_orient;
24 gboolean config_dock_hide;
25 guint config_dock_hide_timeout;
26
27 static void parse_focus(xmlDocPtr doc, xmlNodePtr node, void *d)
28 {
29 xmlNodePtr n;
30
31 node = node->xmlChildrenNode;
32
33 if ((n = parse_find_node("focusNew", node)))
34 config_focus_new = parse_bool(doc, n);
35 if ((n = parse_find_node("followMouse", node)))
36 config_focus_follow = parse_bool(doc, n);
37 if ((n = parse_find_node("focusLast", node)))
38 config_focus_last = parse_bool(doc, n);
39 if ((n = parse_find_node("focusLastOnDesktop", node)))
40 config_focus_last_on_desktop = parse_bool(doc, n);
41 if ((n = parse_find_node("cyclingDialog", node)))
42 config_focus_popup = parse_bool(doc, n);
43 }
44
45 static void parse_theme(xmlDocPtr doc, xmlNodePtr node, void *d)
46 {
47 xmlNodePtr n;
48
49 node = node->xmlChildrenNode;
50
51 if ((n = parse_find_node("theme", node))) {
52 g_free(config_theme);
53 config_theme = parse_string(doc, n);
54 }
55 }
56
57 static void parse_desktops(xmlDocPtr doc, xmlNodePtr node, void *d)
58 {
59 xmlNodePtr n;
60
61 node = node->xmlChildrenNode;
62
63 if ((n = parse_find_node("number", node)))
64 config_desktops_num = parse_int(doc, n);
65 if ((n = parse_find_node("names", node))) {
66 GSList *it;
67 xmlNodePtr nname;
68
69 for (it = config_desktops_names; it; it = it->next)
70 g_free(it->data);
71 g_slist_free(config_desktops_names);
72 config_desktops_names = NULL;
73
74 nname = parse_find_node("name", n->xmlChildrenNode);
75 while (nname) {
76 config_desktops_names = g_slist_append(config_desktops_names,
77 parse_string(doc, nname));
78 nname = parse_find_node("name", nname->next);
79 }
80 }
81 }
82
83 static void parse_moveresize(xmlDocPtr doc, xmlNodePtr node, void *d)
84 {
85 xmlNodePtr n;
86
87 node = node->xmlChildrenNode;
88
89 if ((n = parse_find_node("opaqueMove", node)))
90 config_opaque_move = parse_bool(doc, n);
91 if ((n = parse_find_node("opaqueResize", node)))
92 config_opaque_resize = parse_bool(doc, n);
93 }
94
95 static void parse_dock(xmlDocPtr doc, xmlNodePtr node, void *d)
96 {
97 xmlNodePtr n;
98
99 node = node->xmlChildrenNode;
100
101 if ((n = parse_find_node("position", node))) {
102 if (parse_contains("TopLeft", doc, n))
103 config_dock_floating = FALSE,
104 config_dock_pos = OB_DIRECTION_NORTHWEST;
105 else if (parse_contains("Top", doc, n))
106 config_dock_floating = FALSE,
107 config_dock_pos = OB_DIRECTION_NORTH;
108 else if (parse_contains("TopRight", doc, n))
109 config_dock_floating = FALSE,
110 config_dock_pos = OB_DIRECTION_NORTHEAST;
111 else if (parse_contains("Right", doc, n))
112 config_dock_floating = FALSE,
113 config_dock_pos = OB_DIRECTION_EAST;
114 else if (parse_contains("BottomRight", doc, n))
115 config_dock_floating = FALSE,
116 config_dock_pos = OB_DIRECTION_SOUTHEAST;
117 else if (parse_contains("Bottom", doc, n))
118 config_dock_floating = FALSE,
119 config_dock_pos = OB_DIRECTION_SOUTH;
120 else if (parse_contains("BottomLeft", doc, n))
121 config_dock_floating = FALSE,
122 config_dock_pos = OB_DIRECTION_SOUTHWEST;
123 else if (parse_contains("Left", doc, n))
124 config_dock_floating = FALSE,
125 config_dock_pos = OB_DIRECTION_WEST;
126 else if (parse_contains("Floating", doc, n))
127 config_dock_floating = TRUE;
128 }
129 if (config_dock_floating) {
130 if ((n = parse_find_node("floatingX", node)))
131 config_dock_x = parse_int(doc, n);
132 if ((n = parse_find_node("floatingY", node)))
133 config_dock_y = parse_int(doc, n);
134 }
135 if ((n = parse_find_node("stacking", node))) {
136 if (parse_contains("top", doc, n))
137 config_dock_layer = OB_STACKING_LAYER_TOP;
138 else if (parse_contains("normal", doc, n))
139 config_dock_layer = OB_STACKING_LAYER_NORMAL;
140 else if (parse_contains("bottom", doc, n))
141 config_dock_layer = OB_STACKING_LAYER_BELOW;
142 }
143 if ((n = parse_find_node("direction", node))) {
144 if (parse_contains("horizontal", doc, n))
145 config_dock_orient = OB_ORIENTATION_HORZ;
146 else if (parse_contains("vertical", doc, n))
147 config_dock_orient = OB_ORIENTATION_VERT;
148 }
149 if ((n = parse_find_node("autoHide", node)))
150 config_dock_hide = parse_bool(doc, n);
151 if ((n = parse_find_node("hideTimeout", node)))
152 config_dock_hide_timeout = parse_int(doc, n);
153 }
154
155 void config_startup()
156 {
157 config_focus_new = TRUE;
158 config_focus_follow = FALSE;
159 config_focus_last = TRUE;
160 config_focus_last_on_desktop = TRUE;
161 config_focus_popup = TRUE;
162
163 parse_register("focus", parse_focus, NULL);
164
165 config_theme = NULL;
166
167 parse_register("theme", parse_theme, NULL);
168
169 config_desktops_num = 4;
170 config_desktops_names = NULL;
171
172 parse_register("desktops", parse_desktops, NULL);
173
174 config_opaque_move = TRUE;
175 config_opaque_resize = TRUE;
176
177 parse_register("moveresize", parse_moveresize, NULL);
178
179 config_dock_layer = OB_STACKING_LAYER_TOP;
180 config_dock_pos = OB_DIRECTION_NORTHEAST;
181 config_dock_floating = FALSE;
182 config_dock_x = 0;
183 config_dock_y = 0;
184 config_dock_orient = OB_ORIENTATION_VERT;
185 config_dock_hide = FALSE;
186 config_dock_hide_timeout = 3000;
187
188 parse_register("dock", parse_dock, NULL);
189 }
190
191 void config_shutdown()
192 {
193 GSList *it;
194
195 g_free(config_theme);
196
197 for (it = config_desktops_names; it; it = it->next)
198 g_free(it->data);
199 g_slist_free(config_desktops_names);
200 }
This page took 0.041972 seconds and 4 git commands to generate.