1 /*
2 * Copyright (C) 2003-2021 Kim Woelders
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to
6 * deal in the Software without restriction, including without limitation the
7 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8 * sell copies of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies of the Software, its documentation and marketing & publicity
13 * materials, and acknowledgment shall be given in the documentation, materials
14 * and software packages that this Software was used.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
20 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 */
23 #include "E.h"
24 #include "dialog.h"
25 #include "eimage.h"
26 #include "emodule.h"
27 #include "settings.h"
28 #include "snaps.h"
29
30 /***********************************************************************
31 * *** should all go elsewhere ***
32 **********************************************************************/
33
34 /* Use static module list for now */
35 extern const EModule ModAclass;
36 extern const EModule ModBackgrounds;
37 extern const EModule ModButtons;
38
39 #if USE_COMPOSITE
40 extern const EModule ModCompMgr;
41 extern const EModule ModMagwin;
42 #endif
43 #if USE_GLX
44 extern const EModule ModGlwin;
45 #endif
46 extern const EModule ModCursors;
47 extern const EModule ModDesktops;
48 extern const EModule ModEffects;
49 extern const EModule ModEwins;
50 extern const EModule ModFocus;
51 extern const EModule ModGroups;
52 extern const EModule ModImageclass;
53 extern const EModule ModIconboxes;
54 extern const EModule ModLocale;
55 extern const EModule ModMenus;
56 extern const EModule ModMisc;
57 extern const EModule ModPagers;
58 extern const EModule ModSlideouts;
59
60 #if ENABLE_SOUND
61 extern const EModule ModSound;
62 #endif
63 extern const EModule ModTextclass;
64 extern const EModule ModTheme;
65 extern const EModule ModTooltips;
66
67 extern const EModule ModWarplist;
68 extern const EModule ModWindowMatch;
69
70 const EModule *const p_modules[] = {
71 &ModAclass,
72 &ModBackgrounds,
73 &ModButtons,
74 #if USE_COMPOSITE
75 &ModCompMgr,
76 &ModMagwin,
77 #endif
78 &ModCursors,
79 &ModDesktops,
80 &ModEwins,
81 &ModEffects,
82 &ModFocus,
83 #if USE_GLX
84 &ModGlwin,
85 #endif
86 &ModGroups,
87 &ModIconboxes,
88 &ModImageclass,
89 &ModLocale,
90 &ModMenus,
91 &ModMisc,
92 &ModPagers,
93 &ModSlideouts,
94 #if ENABLE_SOUND
95 &ModSound,
96 #endif
97 &ModTextclass,
98 &ModTheme,
99 &ModTooltips,
100 &ModWarplist,
101 &ModWindowMatch,
102 };
103 int n_modules = E_ARRAY_SIZE(p_modules);
104
105 #if 0
106 static void
107 MiscSighan(int sig, void *prm __UNUSED__)
108 {
109 switch (sig)
110 {
111 case ESIGNAL_START:
112 break;
113 }
114 }
115 #endif
116
117 static void
_CfgImageCacheSize(void * item __UNUSED__,const char * value)118 _CfgImageCacheSize(void *item __UNUSED__, const char *value)
119 {
120 if (!value || !value[0])
121 return;
122
123 EImageSetCacheSize(atoi(value));
124 }
125
126 static void
_CfgXImageCacheCount(void * item __UNUSED__,const char * value)127 _CfgXImageCacheCount(void *item __UNUSED__, const char *value)
128 {
129 if (!value || !value[0])
130 return;
131
132 EImageSetXImageCacheSize(atoi(value), -1);
133 }
134
135 static const CfgItem MiscCfgItems[] = {
136
137 CFG_ITEM_INT(Conf, animation.step, 10),
138
139 CFG_ITEM_INT(Conf, buttons.move_resistance, 10),
140
141 CFG_ITEM_BOOL(Conf, dialogs.headers, 0),
142 CFG_ITEM_BOOL(Conf, dialogs.button_image, 0),
143
144 CFG_ITEM_BOOL(Conf, dock.enable, 1),
145 CFG_ITEM_BOOL(Conf, dock.sticky, 1),
146 CFG_ITEM_INT(Conf, dock.dirmode, DOCK_DOWN),
147 CFG_ITEM_INT(Conf, dock.startx, 0),
148 CFG_ITEM_INT(Conf, dock.starty, 0),
149
150 CFG_ITEM_BOOL(Conf, hints.set_xroot_info_on_root_window, 0),
151
152 CFG_ITEM_BOOL(Conf, log.difftime, 0),
153 CFG_ITEM_BOOL(Conf, log.dest, 0),
154
155 CFG_ITEM_INT(Conf, magwin.zoom_res, 4),
156
157 CFG_ITEM_INT(Conf, movres.mode_move, MR_OPAQUE),
158 CFG_ITEM_INT(Conf, movres.mode_resize, MR_BOX),
159 CFG_ITEM_INT(Conf, movres.mode_info, 1),
160 CFG_ITEM_INT(Conf, movres.mode_maximize_default, 1),
161 CFG_ITEM_HEX(Conf, movres.color, 0x00ff0000),
162 CFG_ITEM_BOOL(Conf, movres.avoid_server_grab, 1),
163 CFG_ITEM_BOOL(Conf, movres.update_while_moving, 0),
164 CFG_ITEM_BOOL(Conf, movres.enable_sync_request, 0),
165 CFG_ITEM_BOOL(Conf, movres.dragbar_nocover, 0),
166 CFG_ITEM_BOOL(Conf, movres.enable_smart_max_hv, 0),
167 CFG_ITEM_BOOL(Conf, movres.maximize_animate, 0),
168 CFG_ITEM_INT(Conf, movres.maximize_speed, 6000),
169
170 CFG_ITEM_INT(Conf, opacity.menus, 85),
171 CFG_ITEM_INT(Conf, opacity.movres, 60),
172 CFG_ITEM_INT(Conf, opacity.tooltips, 80),
173 CFG_ITEM_INT(Conf, opacity.focused, 100),
174 CFG_ITEM_INT(Conf, opacity.unfocused, 100),
175
176 CFG_ITEM_BOOL(Conf, place.manual, 0),
177 CFG_ITEM_BOOL(Conf, place.manual_mouse_pointer, 0),
178 CFG_ITEM_BOOL(Conf, place.center_if_desk_full, 0),
179 CFG_ITEM_BOOL(Conf, place.ignore_struts, 0),
180 CFG_ITEM_BOOL(Conf, place.ignore_struts_fullscreen, 0),
181 CFG_ITEM_BOOL(Conf, place.ignore_struts_maximize, 0),
182 CFG_ITEM_BOOL(Conf, place.raise_fullscreen, 0),
183 CFG_ITEM_BOOL(Conf, place.slidein, 0),
184 CFG_ITEM_BOOL(Conf, place.cleanupslide, 1),
185 CFG_ITEM_INT(Conf, place.slidemode, 0),
186 CFG_ITEM_INT(Conf, place.slidespeedmap, 6000),
187 CFG_ITEM_INT(Conf, place.slidespeedcleanup, 8000),
188
189 CFG_ITEM_BOOL(Conf, session.enable_script, 0),
190 CFG_ITEM_STR(Conf, session.script),
191 CFG_ITEM_BOOL(Conf, session.enable_logout_dialog, 1),
192 CFG_ITEM_BOOL(Conf, session.enable_reboot_halt, 0),
193 CFG_ITEM_STR(Conf, session.cmd_reboot),
194 CFG_ITEM_STR(Conf, session.cmd_halt),
195
196 CFG_ITEM_BOOL(Conf, shading.animate, 1),
197 CFG_ITEM_INT(Conf, shading.speed, 8000),
198
199 CFG_ITEM_BOOL(Conf, snap.enable, 1),
200 CFG_ITEM_INT(Conf, snap.edge_snap_dist, 8),
201 CFG_ITEM_INT(Conf, snap.screen_snap_dist, 32),
202
203 CFG_ITEM_BOOL(Conf, startup.firsttime, 1),
204 CFG_ITEM_BOOL(Conf, startup.animate, 1),
205
206 CFG_ITEM_BOOL(Conf, testing.argb_internal_objects, 0),
207 CFG_ITEM_BOOL(Conf, testing.argb_internal_clients, 0),
208 CFG_ITEM_BOOL(Conf, testing.argb_clients, 0),
209 CFG_ITEM_BOOL(Conf, testing.argb_clients_inherit_attr, 0),
210 CFG_FUNC_INT(Conf, testing.image_cache_size, -1, _CfgImageCacheSize),
211 CFG_FUNC_INT(Conf, testing.ximage_cache_count, -1, _CfgXImageCacheCount),
212 CFG_ITEM_INT(Conf, testing.mask_alpha_threshold, 8),
213 CFG_ITEM_BOOL(Conf, testing.enable_startup_id, 1),
214 CFG_ITEM_BOOL(Conf, testing.use_render_for_scaling, 0),
215 CFG_ITEM_BOOL(Conf, testing.bindings_reload, 1),
216 CFG_ITEM_HEX(Conf, testing.no_sync_mask, 0),
217
218 CFG_ITEM_BOOL(Conf, autosave, 1),
219 CFG_ITEM_BOOL(Conf, memory_paranoia, 1),
220 CFG_ITEM_BOOL(Conf, save_under, 0),
221 };
222
223 /* Stuff not elsewhere */
224 const EModule ModMisc = {
225 "misc", NULL,
226 NULL,
227 {0, NULL},
228 MOD_ITEMS(MiscCfgItems)
229 };
230
231 void
autosave(void)232 autosave(void)
233 {
234 if (!Mode.wm.save_ok)
235 return;
236
237 if (EDebug(EDBUG_TYPE_SESSION))
238 Eprintf("%s\n", __func__);
239
240 SnapshotsSaveReal();
241
242 /* Save the configuration parameters */
243 ConfigurationSave();
244 }
245