chiark / gitweb /
Imported Upstream version 1.0.0
[e16] / src / mod-misc.c
1 /*
2  * Copyright (C) 2003-2008 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 HAVE_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 #ifdef ENABLE_THEME_TRANSPARENCY
68 extern const EModule ModTransparency;
69 #endif
70 extern const EModule ModWarplist;
71 extern const EModule ModWindowMatch;
72
73 const EModule      *p_modules[] = {
74    &ModAclass,
75    &ModBackgrounds,
76    &ModButtons,
77 #if USE_COMPOSITE
78    &ModCompMgr,
79    &ModMagwin,
80 #endif
81    &ModCursors,
82    &ModDesktops,
83    &ModEwins,
84    &ModEffects,
85    &ModFocus,
86 #if USE_GLX
87    &ModGlwin,
88 #endif
89    &ModGroups,
90    &ModIconboxes,
91    &ModImageclass,
92    &ModLocale,
93    &ModMenus,
94    &ModMisc,
95    &ModPagers,
96    &ModSlideouts,
97 #if HAVE_SOUND
98    &ModSound,
99 #endif
100    &ModTextclass,
101    &ModTheme,
102    &ModTooltips,
103 #ifdef ENABLE_THEME_TRANSPARENCY
104    &ModTransparency,
105 #endif
106    &ModWarplist,
107    &ModWindowMatch,
108 };
109 int                 n_modules = sizeof(p_modules) / sizeof(EModule *);
110
111 #if 0
112 static void
113 MiscSighan(int sig, void *prm __UNUSED__)
114 {
115    switch (sig)
116      {
117      case ESIGNAL_START:
118         break;
119      }
120 }
121 #endif
122
123 static void
124 _CfgImageCacheSize(void *item __UNUSED__, const char *value)
125 {
126    int                 size_old, size_new;
127
128    if (!value || !value[0])
129       return;
130
131    size_new = atoi(value);
132    size_old = EImageSetCacheSize(size_new);
133    IpcPrintf("Image cache size %u->%u byte\n", size_old, size_new);
134 }
135
136 static const CfgItem MiscCfgItems[] = {
137
138    CFG_ITEM_INT(Conf, animation.step, 10),
139
140    CFG_ITEM_INT(Conf, buttons.move_resistance, 10),
141
142    CFG_ITEM_BOOL(Conf, dialogs.headers, 0),
143    CFG_ITEM_BOOL(Conf, dialogs.button_image, 0),
144
145    CFG_ITEM_BOOL(Conf, dock.enable, 1),
146    CFG_ITEM_BOOL(Conf, dock.sticky, 1),
147    CFG_ITEM_INT(Conf, dock.dirmode, DOCK_DOWN),
148    CFG_ITEM_INT(Conf, dock.startx, 0),
149    CFG_ITEM_INT(Conf, dock.starty, 0),
150
151    CFG_ITEM_BOOL(Conf, hints.set_xroot_info_on_root_window, 0),
152
153    CFG_ITEM_INT(Conf, movres.mode_move, 0),
154    CFG_ITEM_INT(Conf, movres.mode_resize, 2),
155    CFG_ITEM_INT(Conf, movres.mode_info, 1),
156    CFG_ITEM_INT(Conf, movres.mode_maximize_default, 1),
157    CFG_ITEM_HEX(Conf, movres.color, 0x00ff0000),
158    CFG_ITEM_BOOL(Conf, movres.avoid_server_grab, 1),
159    CFG_ITEM_BOOL(Conf, movres.update_while_moving, 0),
160    CFG_ITEM_BOOL(Conf, movres.enable_sync_request, 0),
161    CFG_ITEM_BOOL(Conf, movres.dragbar_nocover, 0),
162
163    CFG_ITEM_INT(Conf, opacity.menus, 85),
164    CFG_ITEM_INT(Conf, opacity.movres, 60),
165    CFG_ITEM_INT(Conf, opacity.tooltips, 80),
166    CFG_ITEM_INT(Conf, opacity.focused, 100),
167    CFG_ITEM_INT(Conf, opacity.unfocused, 100),
168
169    CFG_ITEM_BOOL(Conf, place.manual, 0),
170    CFG_ITEM_BOOL(Conf, place.manual_mouse_pointer, 0),
171    CFG_ITEM_BOOL(Conf, place.center_if_desk_full, 0),
172    CFG_ITEM_BOOL(Conf, place.ignore_struts, 0),
173    CFG_ITEM_BOOL(Conf, place.raise_fullscreen, 0),
174    CFG_ITEM_BOOL(Conf, place.slidein, 0),
175    CFG_ITEM_BOOL(Conf, place.cleanupslide, 1),
176    CFG_ITEM_INT(Conf, place.slidemode, 0),
177    CFG_ITEM_INT(Conf, place.slidespeedmap, 6000),
178    CFG_ITEM_INT(Conf, place.slidespeedcleanup, 8000),
179
180    CFG_ITEM_BOOL(Conf, session.enable_script, 0),
181    CFG_ITEM_STR(Conf, session.script),
182    CFG_ITEM_BOOL(Conf, session.enable_logout_dialog, 1),
183    CFG_ITEM_BOOL(Conf, session.enable_reboot_halt, 0),
184    CFG_ITEM_STR(Conf, session.cmd_reboot),
185    CFG_ITEM_STR(Conf, session.cmd_halt),
186
187    CFG_ITEM_BOOL(Conf, shading.animate, 1),
188    CFG_ITEM_INT(Conf, shading.speed, 8000),
189
190    CFG_ITEM_BOOL(Conf, snap.enable, 1),
191    CFG_ITEM_INT(Conf, snap.edge_snap_dist, 8),
192    CFG_ITEM_INT(Conf, snap.screen_snap_dist, 32),
193
194    CFG_ITEM_BOOL(Conf, startup.firsttime, 1),
195    CFG_ITEM_BOOL(Conf, startup.animate, 1),
196
197    CFG_ITEM_BOOL(Conf, testing.argb_internal_objects, 0),
198    CFG_ITEM_BOOL(Conf, testing.argb_internal_clients, 0),
199    CFG_ITEM_BOOL(Conf, testing.argb_clients, 0),
200    CFG_ITEM_BOOL(Conf, testing.argb_clients_inherit_attr, 0),
201    CFG_FUNC_INT(Conf, testing.image_cache_size, -1, _CfgImageCacheSize),
202    CFG_ITEM_INT(Conf, testing.mask_alpha_threshold, 8),
203    CFG_ITEM_BOOL(Conf, testing.enable_startup_id, 1),
204    CFG_ITEM_BOOL(Conf, testing.use_render_for_scaling, 0),
205    CFG_ITEM_BOOL(Conf, testing.bindings_reload, 1),
206    CFG_ITEM_HEX(Conf, testing.no_sync_mask, 0),
207
208    CFG_ITEM_BOOL(Conf, autosave, 1),
209    CFG_ITEM_BOOL(Conf, memory_paranoia, 1),
210    CFG_ITEM_BOOL(Conf, save_under, 0),
211    CFG_ITEM_BOOL(Conf, difftime, 0),
212 };
213 #define N_CFG_ITEMS ((int)(sizeof(MiscCfgItems)/sizeof(CfgItem)))
214
215 /* Stuff not elsewhere */
216 const EModule       ModMisc = {
217    "misc", NULL,
218    NULL,
219    {0, NULL},
220    {N_CFG_ITEMS, MiscCfgItems}
221 };
222
223 void
224 autosave(void)
225 {
226    if (!Mode.wm.save_ok)
227       return;
228
229    if (EDebug(EDBUG_TYPE_SESSION))
230       Eprintf("autosave\n");
231
232    SnapshotsSaveReal(NULL);
233
234    /* Save the configuration parameters */
235    ConfigurationSave();
236 }