4 * Copyright (c) Tuomo Valkonen 1999-2009.
6 * See the included file LICENSE for details.
12 #include <libtu/map.h>
13 #include <libtu/minmax.h>
14 #include <libtu/objp.h>
15 #include <libtu/map.h>
16 #include <libextl/readconfig.h>
29 StringIntMap frame_idxs
[]={
30 {"last", LLIST_INDEX_LAST
},
31 {"next", LLIST_INDEX_AFTER_CURRENT
},
32 {"next-act", LLIST_INDEX_AFTER_CURRENT_ACT
},
36 StringIntMap win_stackrq
[]={
37 {"ignore", IONCORE_WINDOWSTACKINGREQUEST_IGNORE
},
38 {"activate", IONCORE_WINDOWSTACKINGREQUEST_ACTIVATE
},
42 static bool get_winprop_fn_set
=FALSE
;
43 static ExtlFn get_winprop_fn
;
45 static bool get_layout_fn_set
=FALSE
;
46 static ExtlFn get_layout_fn
;
50 * Set ioncore basic settings. The table \var{tab} may contain the
53 * \begin{tabularx}{\linewidth}{lX}
54 * \tabhead{Field & Description}
55 * \var{opaque_resize} & (boolean) Controls whether interactive move and
56 * resize operations simply draw a rubberband during
57 * the operation (false) or immediately affect the
58 * object in question at every step (true). \\
59 * \var{warp} & (boolean) Should focusing operations move the
60 * pointer to the object to be focused? \\
61 * \var{switchto} & (boolean) Should a managing \type{WMPlex} switch
62 * to a newly mapped client window? \\
63 * \var{screen_notify} & (boolean) Should notification tooltips be displayed
64 * for hidden workspaces with activity? \\
65 * \var{frame_default_index} & (string) Specifies where to add new regions
66 * on the mutually exclusive list of a frame. One of
67 * \codestr{last}, \codestr{next}, (for after current),
68 * or \codestr{next-act}
69 * (for after current and anything with activity right
71 * \var{dblclick_delay} & (integer) Delay between clicks of a double click.\\
72 * \var{kbresize_delay} & (integer) Delay in milliseconds for ending keyboard
73 * resize mode after inactivity. \\
74 * \var{kbresize_t_max} & (integer) Controls keyboard resize acceleration.
75 * See description below for details. \\
76 * \var{kbresize_t_min} & (integer) See below. \\
77 * \var{kbresize_step} & (floating point) See below. \\
78 * \var{kbresize_maxacc} & (floating point) See below. \\
79 * \var{edge_resistance} & (integer) Resize edge resistance in pixels. \\
80 * \var{framed_transients} & (boolean) Put transients in nested frames. \\
81 * \var{float_placement_method} & (string) How to place floating frames.
82 * One of \codestr{udlr} (up-down, then left-right),
83 * \codestr{lrud} (left-right, then up-down), or
84 * \codestr{random}. \\
85 * \var{float_placement_padding} & (integer) Pixels between frames when
86 * \var{float_placement_method} is \codestr{udlr} or
88 * \var{mousefocus} & (string) Mouse focus mode:
89 * \codestr{disabled} or \codestr{sloppy}. \\
90 * \var{unsqueeze} & (boolean) Auto-unsqueeze transients/menus/queries/etc. \\
91 * \var{autoraise} & (boolean) Autoraise regions in groups on goto. \\
92 * \var{usertime_diff_current} & (integer) Controls switchto timeout. \\
93 * \var{usertime_diff_new} & (integer) Controls switchto timeout. \\
94 * \var{autosave_layout} & (boolean) Automatically save layout on restart and exit. \\
95 * \var{window_stacking_request} & (string) How to respond to window-stacking
96 * requests. \codestr{ignore} to do nothing,
97 * \codestr{activate} to set the activity flag on a
98 * window requesting to be stacked Above. \\
101 * When a keyboard resize function is called, and at most \var{kbresize_t_max}
102 * milliseconds has passed from a previous call, acceleration factor is reset
103 * to 1.0. Otherwise, if at least \var{kbresize_t_min} milliseconds have
104 * passed from the from previous acceleration update or reset the squere root
105 * of the acceleration factor is incremented by \var{kbresize_step}. The
106 * maximum acceleration factor (pixels/call modulo size hints) is given by
107 * \var{kbresize_maxacc}. The default values are (200, 50, 30, 100).
110 void ioncore_set(ExtlTab tab
)
117 extl_table_gets_b(tab
, "opaque_resize", &(ioncore_g
.opaque_resize
));
118 extl_table_gets_b(tab
, "warp", &(ioncore_g
.warp_enabled
));
119 extl_table_gets_b(tab
, "switchto", &(ioncore_g
.switchto_new
));
120 extl_table_gets_b(tab
, "screen_notify", &(ioncore_g
.screen_notify
));
121 extl_table_gets_b(tab
, "framed_transients", &(ioncore_g
.framed_transients
));
122 extl_table_gets_b(tab
, "unsqueeze", &(ioncore_g
.unsqueeze_enabled
));
123 extl_table_gets_b(tab
, "autoraise", &(ioncore_g
.autoraise
));
124 extl_table_gets_b(tab
, "autosave_layout", &(ioncore_g
.autosave_layout
));
126 if(extl_table_gets_s(tab
, "window_stacking_request", &tmp
)){
127 ioncore_g
.window_stacking_request
=stringintmap_value(win_stackrq
,
129 ioncore_g
.window_stacking_request
);
133 if(extl_table_gets_s(tab
, "frame_default_index", &tmp
)){
134 ioncore_g
.frame_default_index
=stringintmap_value(frame_idxs
,
136 ioncore_g
.frame_default_index
);
140 if(extl_table_gets_s(tab
, "mousefocus", &tmp
)){
141 if(strcmp(tmp
, "disabled")==0)
142 ioncore_g
.no_mousefocus
=TRUE
;
143 else if(strcmp(tmp
, "sloppy")==0)
144 ioncore_g
.no_mousefocus
=FALSE
;
148 if(extl_table_gets_i(tab
, "dblclick_delay", &dd
))
149 ioncore_g
.dblclick_delay
=maxof(0, dd
);
151 if(extl_table_gets_i(tab
, "usertime_diff_current", &dd
))
152 ioncore_g
.usertime_diff_current
=maxof(0, dd
);
154 if(extl_table_gets_i(tab
, "usertime_diff_new", &dd
))
155 ioncore_g
.usertime_diff_new
=maxof(0, dd
);
157 ioncore_set_moveres_accel(tab
);
159 ioncore_groupws_set(tab
);
161 /* Internal -- therefore undocumented above */
162 if(extl_table_gets_f(tab
, "_get_winprop", &fn
)){
163 if(get_winprop_fn_set
)
164 extl_unref_fn(get_winprop_fn
);
166 get_winprop_fn_set
=TRUE
;
169 if(extl_table_gets_f(tab
, "_get_layout", &fn
)){
170 if(get_layout_fn_set
)
171 extl_unref_fn(get_layout_fn
);
173 get_layout_fn_set
=TRUE
;
180 * Get ioncore basic settings. For details see \fnref{ioncore.set}.
184 ExtlTab
ioncore_get()
186 ExtlTab tab
=extl_create_table();
188 extl_table_sets_b(tab
, "opaque_resize", ioncore_g
.opaque_resize
);
189 extl_table_sets_b(tab
, "warp", ioncore_g
.warp_enabled
);
190 extl_table_sets_b(tab
, "switchto", ioncore_g
.switchto_new
);
191 extl_table_sets_i(tab
, "dblclick_delay", ioncore_g
.dblclick_delay
);
192 extl_table_sets_b(tab
, "screen_notify", ioncore_g
.screen_notify
);
193 extl_table_sets_b(tab
, "framed_transients", ioncore_g
.framed_transients
);
194 extl_table_sets_b(tab
, "unsqueeze", ioncore_g
.unsqueeze_enabled
);
195 extl_table_sets_b(tab
, "autoraise", ioncore_g
.autoraise
);
196 extl_table_sets_b(tab
, "autosave_layout", ioncore_g
.autosave_layout
);
198 extl_table_sets_s(tab
, "window_stacking_request",
199 stringintmap_key(win_stackrq
,
200 ioncore_g
.window_stacking_request
,
203 extl_table_sets_s(tab
, "frame_default_index",
204 stringintmap_key(frame_idxs
,
205 ioncore_g
.frame_default_index
,
208 extl_table_sets_s(tab
, "mousefocus", (ioncore_g
.no_mousefocus
212 ioncore_get_moveres_accel(tab
);
214 ioncore_groupws_get(tab
);
220 ExtlTab
ioncore_get_winprop(WClientWin
*cwin
)
222 ExtlTab tab
=extl_table_none();
224 if(get_winprop_fn_set
){
226 extl_call(get_winprop_fn
, "o", "t", cwin
, &tab
);
227 extl_unprotect(NULL
);
234 ExtlTab
ioncore_get_layout(const char *layout
)
236 ExtlTab tab
=extl_table_none();
238 if(get_layout_fn_set
){
240 extl_call(get_layout_fn
, "s", "t", layout
, &tab
);
241 extl_unprotect(NULL
);
249 * Get important directories (the fields \var{userdir},
250 * \var{sessiondir}, \var{searchpath} in the returned table).
254 ExtlTab
ioncore_get_paths(ExtlTab tab
)
256 tab
=extl_create_table();
257 extl_table_sets_s(tab
, "userdir", extl_userdir());
258 extl_table_sets_s(tab
, "sessiondir", extl_sessiondir());
259 extl_table_sets_s(tab
, "searchpath", extl_searchpath());
265 * Set important directories (the fields \var{sessiondir}, \var{searchpath}
269 bool ioncore_set_paths(ExtlTab tab
)
273 if(extl_table_gets_s(tab
, "userdir", &s
)){
274 warn(TR("User directory can not be set."));
279 if(extl_table_gets_s(tab
, "sessiondir", &s
)){
280 extl_set_sessiondir(s
);
285 if(extl_table_gets_s(tab
, "searchpath", &s
)){
286 extl_set_searchpath(s
);
295 /* Exports these in ioncore. */
298 * Lookup script \var{file}. If \var{try_in_dir} is set, it is tried
299 * before the standard search path.
302 EXTL_EXPORT_AS(ioncore
, lookup_script
)
303 char *extl_lookup_script(const char *file
, const char *sp
);
307 * Get a file name to save (session) data in. The string \var{basename}
308 * should contain no path or extension components.
311 EXTL_EXPORT_AS(ioncore
, get_savefile
)
312 char *extl_get_savefile(const char *basename
);
316 * Write \var{tab} in file with basename \var{basename} in the
320 EXTL_EXPORT_AS(ioncore
, write_savefile
)
321 bool extl_write_savefile(const char *basename
, ExtlTab tab
);
328 EXTL_EXPORT_AS(ioncore
, read_savefile
)
329 ExtlTab
extl_extl_read_savefile(const char *basename
);
333 bool ioncore_read_main_config(const char *cfgfile
)
339 cfgfile
="cfg_notion";
341 ret
=extl_read_config(cfgfile
, ".", TRUE
);
343 unset
+=(ioncore_screen_bindmap
->nbindings
==0);
344 unset
+=(ioncore_mplex_bindmap
->nbindings
==0);
345 unset
+=(ioncore_frame_bindmap
->nbindings
==0);
348 warn(TR("Some bindmaps were empty, loading ioncore_efbb."));
349 extl_read_config("ioncore_efbb", NULL
, TRUE
);
352 return (ret
&& unset
==0);