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