4 * Copyright (c) Tuomo Valkonen 1999-2006.
6 * Ion is free software; you can redistribute it and/or modify it under
7 * the terms of the GNU Lesser General Public License as published by
8 * the Free Software Foundation; either version 2.1 of the License, or
9 * (at your option) any later version.
15 #include <libtu/map.h>
16 #include <libtu/minmax.h>
17 #include <libtu/objp.h>
18 #include <libtu/map.h>
19 #include <libextl/readconfig.h>
32 StringIntMap frame_idxs[]={
33 {"last", LLIST_INDEX_LAST},
34 {"next", LLIST_INDEX_AFTER_CURRENT},
35 {"next-act", LLIST_INDEX_AFTER_CURRENT_ACT},
41 * Set ioncore basic settings. The table \var{tab} may contain the
44 * \begin{tabularx}{\linewidth}{lX}
45 * \tabhead{Field & Description}
46 * \var{opaque_resize} & (boolean) Controls whether interactive move and
47 * resize operations simply draw a rubberband during
48 * the operation (false) or immediately affect the
49 * object in question at every step (true). \\
50 * \var{warp} & (boolean) Should focusing operations move the
51 * pointer to the object to be focused? \\
52 * \var{switchto} & (boolean) Should a managing \type{WMPlex} switch
53 * to a newly mapped client window? \\
54 * \var{screen_notify} & (boolean) Should notification tooltips be displayed
55 * for hidden workspaces with activity? \\
56 * \var{frame_default_index} & (string) Specifies where to add new regions
57 * on the mutually exclusive list of a frame. One of
58 * ''last'', ''next'' (for after current), ''next-act''
59 * (for after current and anything with activity right
61 * \var{dblclick_delay} & (integer) Delay between clicks of a double click.\\
62 * \var{kbresize_delay} & (integer) Delay in milliseconds for ending keyboard
63 * resize mode after inactivity. \\
64 * \var{kbresize_t_max} & (integer) Controls keyboard resize acceleration.
65 * See description below for details. \\
66 * \var{kbresize_t_min} & (integer) See below. \\
67 * \var{kbresize_step} & (floating point) See below. \\
68 * \var{kbresize_maxacc} & (floating point) See below. \\
69 * \var{framed_transients} & (boolean) Put transients in nested frames. \\
70 * \var{float_placement_method} & (string) How to place floating frames.
71 * One of ''udlr'' (up-down, then left-right),
72 * ''lrud'' (left-right, then up-down) or ''random''. \\
73 * \var{default_ws_params} & (table) Default workspace layout; the
74 * attach/creation parameters for a \type{WGroup}. \\
77 * When a keyboard resize function is called, and at most \var{kbresize_t_max}
78 * milliseconds has passed from a previous call, acceleration factor is reset
79 * to 1.0. Otherwise, if at least \var{kbresize_t_min} milliseconds have
80 * passed from the from previous acceleration update or reset the squere root
81 * of the acceleration factor is incremented by \var{kbresize_step}. The
82 * maximum acceleration factor (pixels/call modulo size hints) is given by
83 * \var{kbresize_maxacc}. The default values are (200, 50, 30, 100).
86 void ioncore_set(ExtlTab tab)
92 extl_table_gets_b(tab, "opaque_resize", &(ioncore_g.opaque_resize));
93 extl_table_gets_b(tab, "warp", &(ioncore_g.warp_enabled));
94 extl_table_gets_b(tab, "switchto", &(ioncore_g.switchto_new));
95 extl_table_gets_b(tab, "screen_notify", &(ioncore_g.screen_notify));
96 extl_table_gets_b(tab, "framed_transients", &(ioncore_g.framed_transients));
98 if(extl_table_gets_s(tab, "frame_default_index", &tmp)){
99 ioncore_g.frame_default_index=stringintmap_value(frame_idxs,
101 ioncore_g.frame_default_index);
105 if(extl_table_gets_i(tab, "dblclick_delay", &dd))
106 ioncore_g.dblclick_delay=maxof(0, dd);
108 ioncore_set_moveres_accel(tab);
110 ioncore_groupws_set(tab);
115 * Get ioncore basic settings. For details see \fnref{ioncore.set}.
119 ExtlTab ioncore_get()
121 ExtlTab tab=extl_create_table();
123 extl_table_sets_b(tab, "opaque_resize", ioncore_g.opaque_resize);
124 extl_table_sets_b(tab, "warp", ioncore_g.warp_enabled);
125 extl_table_sets_b(tab, "switchto", ioncore_g.switchto_new);
126 extl_table_sets_i(tab, "dblclick_delay", ioncore_g.dblclick_delay);
127 extl_table_sets_b(tab, "screen_notify", ioncore_g.screen_notify);
129 extl_table_sets_s(tab, "frame_default_index",
130 stringintmap_key(frame_idxs,
131 ioncore_g.frame_default_index,
134 ioncore_get_moveres_accel(tab);
136 ioncore_groupws_get(tab);
143 * Get important directories (userdir, sessiondir, searchpath).
147 ExtlTab ioncore_get_paths(ExtlTab tab)
149 tab=extl_create_table();
150 extl_table_sets_s(tab, "userdir", extl_userdir());
151 extl_table_sets_s(tab, "sessiondir", extl_sessiondir());
152 extl_table_sets_s(tab, "searchpath", extl_searchpath());
158 * Set important directories (sessiondir, searchpath).
161 bool ioncore_set_paths(ExtlTab tab)
165 if(extl_table_gets_s(tab, "userdir", &s)){
166 warn(TR("User directory can not be set."));
171 if(extl_table_gets_s(tab, "sessiondir", &s)){
172 extl_set_sessiondir(s);
177 if(extl_table_gets_s(tab, "searchpath", &s)){
178 extl_set_searchpath(s);
187 /* Exports these in ioncore. */
190 * Lookup script \var{file}. If \var{try_in_dir} is set, it is tried
191 * before the standard search path.
194 EXTL_EXPORT_AS(ioncore, lookup_script)
195 char *extl_lookup_script(const char *file, const char *sp);
199 * Get a file name to save (session) data in. The string \var{basename}
200 * should contain no path or extension components.
203 EXTL_EXPORT_AS(ioncore, get_savefile)
204 char *extl_get_savefile(const char *basename);
208 * Write \var{tab} in file with basename \var{basename} in the
212 EXTL_EXPORT_AS(ioncore, write_savefile)
213 bool extl_write_savefile(const char *basename, ExtlTab tab);
220 EXTL_EXPORT_AS(ioncore, read_savefile)
221 ExtlTab extl_extl_read_savefile(const char *basename);
225 bool ioncore_read_main_config(const char *cfgfile)
233 ret=extl_read_config(cfgfile, ".", TRUE);
235 unset+=(ioncore_rootwin_bindmap->nbindings==0);
236 unset+=(ioncore_mplex_bindmap->nbindings==0);
237 unset+=(ioncore_frame_bindmap->nbindings==0);
240 warn(TR("Some bindmaps were empty, loading ioncore_efbb."));
241 extl_read_config("ioncore_efbb", NULL, TRUE);
244 return (ret && unset==0);