1 /*
2 * Copyright (c) 2002,2003 Sasha Vasko <sasha at aftercode.net>
3 * Copyright (c) 1998 Rafal Wierzbicki <rafal@mcss.mcmaster.ca>
4 * Copyright (c) 1998 Sasha Vasko <sasha at aftercode.net>
5 * Copyright (c) 1998 Michal Vitecek <fuf@fuf.sh.cvut.cz>
6 * Copyright (c) 1998 Nat Makarevitch <nat@linux-france.com>
7 * Copyright (c) 1998 Mike Venaccio <venaccio@aero.und.edu>
8 * Copyright (c) 1998 Ethan Fischer <allanon@crystaltokyo.com>
9 * Copyright (c) 1998 Mike Venaccio <venaccio@aero.und.edu>
10 * Copyright (c) 1998 Chris Ridd <c.ridd@isode.com>
11 * Copyright (c) 1997 Raphael Goulais <velephys@hol.fr>
12 * Copyright (c) 1997 Guylhem Aznar <guylhem@oeil.qc.ca>
13 * Copyright (C) 1996 Frank Fejes
14 * Copyright (C) 1995 Bo Yang
15 * Copyright (C) 1993 Robert Nation
16 *
17 * This program is free software; you can redistribute it and/or modify
18 * it under the terms of the GNU General Public License as published by
19 * the Free Software Foundation; either version 2 of the License, or
20 * (at your option) any later version.
21 *
22 * This program is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
26 *
27 * You should have received a copy of the GNU General Public License
28 * along with this program; if not, write to the Free Software
29 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
30 *
31 */
32
33 /****************************************************************************
34 *
35 * Configure.c: reads the configuration files, interprets them,
36 * and sets up menus, bindings, colors, and fonts as specified
37 *
38 ***************************************************************************/
39
40 #define LOCAL_DEBUG
41 #include "../../configure.h"
42
43 #include "asinternals.h"
44
45 #include <unistd.h>
46
47 #include "dirtree.h"
48
49 #include "../../libAfterStep/session.h"
50 #include "../../libAfterStep/mystyle_property.h"
51 #include "../../libAfterStep/wmprops.h"
52 #include "../../libAfterStep/desktop_category.h"
53 #include "../../libAfterStep/kde.h"
54
55 #include "../../libAfterConf/afterconf.h"
56
57
58 typedef struct AfterStepConfig {
59 ASModuleConfig asmodule_config;
60 ASFlagType flags;
61 ASFlagType set_flags;
62
63 } AfterStepConfig;
64
65 #define AS_AFTERSTEP_CONFIG(p) AS_MODULE_CONFIG_TYPED(p,CONFIG_AfterStep_ID,AfterStepConfig)
66
67
68 static void
InitAfterStepConfig(ASModuleConfig * asm_config,Bool free_resources)69 InitAfterStepConfig (ASModuleConfig * asm_config, Bool free_resources)
70 {
71 AfterStepConfig *config = AS_AFTERSTEP_CONFIG (asm_config);
72 if (config) {
73 /* TODO */
74 if (free_resources) {
75 }
76 }
77 }
78
79 void
AfterStep_fs2config(ASModuleConfig * asmodule_config,FreeStorageElem * Storage)80 AfterStep_fs2config (ASModuleConfig * asmodule_config,
81 FreeStorageElem * Storage)
82 {
83 FreeStorageElem *pCurr;
84 ConfigItem item;
85 AfterStepConfig *config = AS_AFTERSTEP_CONFIG (asmodule_config);
86
87 if (config == NULL)
88 return;
89
90 item.memory = NULL;
91 for (pCurr = Storage; pCurr; pCurr = pCurr->next) {
92 if (pCurr->term == NULL)
93 continue;
94
95 if (pCurr->term->type == TT_FLAG) {
96 } else {
97 if (!ReadConfigItem (&item, pCurr))
98 continue;
99
100 switch (pCurr->term->id) {
101 default:
102 item.ok_to_free = 1;
103 }
104 }
105 }
106
107 ReadConfigItem (&item, NULL);
108 }
109
110 void
MergeAfterStepOptions(ASModuleConfig * asm_to,ASModuleConfig * asm_from)111 MergeAfterStepOptions (ASModuleConfig * asm_to, ASModuleConfig * asm_from)
112 {
113 /* int i ; */
114 START_TIME (option_time);
115
116 AfterStepConfig *to = AS_AFTERSTEP_CONFIG (asm_to);
117 AfterStepConfig *from = AS_AFTERSTEP_CONFIG (asm_from);
118 if (to && from) {
119
120 /* Need to merge new config with what we have already : */
121 /* now lets check the config sanity : */
122 /* mixing set and default flags : */
123 ASCF_MERGE_FLAGS (to, from);
124
125 }
126 SHOW_TIME ("to parsing", option_time);
127 }
128
129
130 flag_options_xref AfterStepConfigFlags[] = {
131 /* ASCF_DEFINE_MODULE_FLAG_XREF(WINLIST,FillRowsFirst,WinListConfig), */
132 {0, 0, 0}
133 };
134
135
136 int AfterStepBalloons[] =
137 { TITLE_BALLOON_ID_START, MENU_BALLOON_ID_START, 0 };
138
139 static ASModuleConfigClass _afterstep_config_class = { CONFIG_AfterStep_ID,
140 ASMC_HandlePublicLookOptions | ASMC_HandlePublicFeelOptions
141 /* |ASMC_HandleLookMyStyles */ ,
142 sizeof (AfterStepConfig),
143 "afterstep",
144 InitAfterStepConfig,
145 AfterStep_fs2config,
146 MergeAfterStepOptions,
147 &AfterStepSyntax,
148 &LookSyntax,
149 &FeelSyntax,
150 AfterStepConfigFlags,
151 offsetof (AfterStepConfig, set_flags),
152
153 AfterStepBalloons
154 };
155
156 ASModuleConfigClass *AfterStepConfigClass = &_afterstep_config_class;
157
158
ReloadConfig(ASFlagType what)159 void ReloadConfig (ASFlagType what)
160 {
161 ASBalloonLook *balloon_look;
162 ASModuleConfig *config =
163 parse_asmodule_config_all (AfterStepConfigClass);
164
165 /* apply it */
166 Print_balloonConfig (config->balloon_configs[0]);
167 balloon_look = create_balloon_look ();
168 balloon_config2look (&Scr.Look, balloon_look, config->balloon_configs[0],
169 "TitleButtonBalloon");
170 set_balloon_state_look (TitlebarBalloons, balloon_look);
171 destroy_balloon_look (balloon_look);
172
173 balloon_look = create_balloon_look ();
174 Print_balloonConfig (config->balloon_configs[1]);
175 balloon_config2look (&Scr.Look, balloon_look, config->balloon_configs[1],
176 "MenuBalloon");
177 set_balloon_state_look (MenuBalloons, balloon_look);
178 destroy_balloon_look (balloon_look);
179
180 PrintMyStyleDefinitions (config->style_defs);
181
182 destroy_ASModule_config (config);
183 }
184
185 #ifdef AFTERSTEP_CONFIG_TEST
186
187 ASBalloonState *MenuBalloons = NULL;
188 ASBalloonState *TitlebarBalloons = NULL;
189
main(int argc,char ** argv)190 int main (int argc, char **argv)
191 {
192
193 ASImageManager *old_image_manager = NULL;
194 ASFontManager *old_font_manager = NULL;
195 InitMyApp (CLASS_AFTERSTEP, argc, argv, NULL, NULL, 0);
196
197 AfterStepConfigClass->flags |= ASMC_HandleLookMyStyles;
198
199 LinkAfterStepConfig ();
200 if (ConnectX (ASDefaultScr, 0) < 0) {
201 show_error ("Hostile X server encountered - unable to proceed :-(");
202 return 1; /* failed to accure window management selection - other wm is running */
203 }
204 InitSession ();
205 MenuBalloons = create_balloon_state ();
206 TitlebarBalloons = create_balloon_state ();
207 ReloadASEnvironment (&old_image_manager, &old_font_manager, NULL, True,
208 True);
209 LoadColorScheme ();
210 ReloadConfig (0xFFFFFFFF);
211
212 }
213
214 #else
215
216
217 /* old look auxilary variables : */
218 static MyFont StdFont = { NULL }; /* font structure */
219 static MyFont WindowFont = { NULL }; /* font structure for window titles */
220 static MyFont IconFont = { NULL }; /* for icon labels */
221
222 /*
223 * the old-style look variables
224 */
225 static char *Stdfont = NULL;
226 static char *Windowfont = NULL;
227 static char *Iconfont = NULL;
228
229 static char *WindowForeColor[BACK_STYLES] = { NULL };
230 static char *WindowBackColor[BACK_STYLES] = { NULL };
231 static char *WindowGradient[BACK_STYLES] = { NULL };
232 static char *WindowPixmap[BACK_STYLES] = { NULL };
233 static char *MenuForeColor[MENU_BACK_STYLES] = { NULL };
234 static char *MenuBackColor[MENU_BACK_STYLES] = { NULL };
235 static char *MenuGradient[MENU_BACK_STYLES] = { NULL };
236 static char *MenuPixmap[MENU_BACK_STYLES] = { NULL };
237
238 static char *IconBgColor = NULL;
239 static char *IconTexColor = NULL;
240 static char *IconPixmapFile = NULL;
241
242 static char *TexTypes = NULL;
243 static int TitleTextType = 0;
244 static int TitleTextY = 0;
245 static int IconTexType = TEXTURE_BUILTIN;
246
247 static char *MenuPinOn = NULL;
248 static int MenuPinOnButton = -1;
249
250 static MyStyleDefinition *MyStyleList = NULL;
251 static MyFrameDefinition *MyFrameList = NULL;
252 static MyFrameDefinition *LegacyFrameDef = NULL;
253
254 static balloonConfig BalloonConfig =
255 { 0, 0, 0, 0, 0, 0, 0, 0, NULL, 0, 0 };
256 static balloonConfig MenuBalloonConfig =
257 { 0, 0, 0, 0, 0, 0, 0, 0, NULL, 0, 0 };
258
259 static char *MSWindowName[BACK_STYLES] = { NULL };
260 static char *MSMenuName[MENU_BACK_STYLES] = { NULL };
261
262 /* parsing handling functions for different data types : */
263
264 void SetInts (char *text, FILE * fd, char **arg1, int *arg2);
265 void SetInts2 (char *text, FILE * fd, char **arg1, int *arg2);
266 void SetFlag (char *text, FILE * fd, char **arg, int *another);
267 void SetLookFlag (char *text, FILE * fd, char **arg, int *another);
268 void SetFlag2 (char *text, FILE * fd, char **arg, int *var);
269 void SetLookFlag (char *text, FILE * fd, char **arg, int *junk);
270 void SetBox (char *text, FILE * fd, char **arg, int *junk);
271 void SetCursor (char *text, FILE * fd, char **arg, int *junk);
272 void SetCustomCursor (char *text, FILE * fd, char **arg, int *junk);
273 void SetButtonList (char *text, FILE * fd, char **arg1, int *arg2);
274 void SetTitleText (char *tline, FILE * fd, char **junk, int *junk2);
275 void SetTitleButton (char *tline, FILE * fd, char **junk, int *junk2);
276 void SetFramePart (char *text, FILE * fd, char **frame, int *id);
277 void SetModifier (char *text, FILE * fd, char **mod, int *junk2);
278 void SetTButtonOrder (char *text, FILE * fd, char **mod, int *junk2);
279
280 void assign_string (char *text, FILE * fd, char **arg, int *idx);
281 void assign_path (char *text, FILE * fd, char **arg, int *idx);
282 void assign_themable_path (char *text, FILE * fd, char **arg, int *idx);
283 void assign_pixmap (char *text, FILE * fd, char **arg, int *idx);
284 void assign_geometry (char *text, FILE * fd, char **geom, int *junk);
285 void obsolete (char *text, FILE * fd, char **arg, int *);
286
287 void deskback_parse (char *text, FILE * fd, char **junk, int *junk2);
288
289 /* main parsing function : */
290 void match_string (struct config *table, char *text, char *error_msg,
291 FILE * fd);
292
293 /* menu loading code : */
294 int MeltStartMenu (char *buf);
295
296 /* scratch variable : */
297 static int dummy;
298
299 static ASFeel TmpFeel;
300 static MyLook TmpLook;
301
302 /*
303 * Order is important here! if one keyword is the same as the first part of
304 * another keyword, the shorter one must come first!
305 */
306 struct config main_config[] = {
307 /* feel options */
308 {"StubbornIcons", SetFlag2, (char **)StubbornIcons, (int *)0},
309 {"StubbornPlacement", SetFlag2, (char **)StubbornPlacement, (int *)0},
310 {"StubbornIconPlacement", SetFlag2, (char **)StubbornIconPlacement,
311 (int *)0},
312 {"StickyIcons", SetFlag2, (char **)StickyIcons, (int *)0},
313 {"IconTitle", SetFlag2, (char **)IconTitle, (int *)0},
314 {"KeepIconWindows", SetFlag2, (char **)KeepIconWindows, (int *)0},
315 {"NoPPosition", SetFlag2, (char **)NoPPosition, (int *)0},
316 {"CirculateSkipIcons", SetFlag2, (char **)CirculateSkipIcons, (int *)0},
317 {"EdgeScroll", SetInts, (char **)&TmpFeel.EdgeScrollX,
318 &TmpFeel.EdgeScrollY},
319 {"RandomPlacement", SetFlag2, (char **)FEEL_DEPRECATED_RandomPlacement,
320 (int *)&(TmpFeel.deprecated_flags)},
321 {"SmartPlacement", SetFlag2, (char **)FEEL_DEPRECATED_SmartPlacement,
322 (int *)&(TmpFeel.deprecated_flags)},
323 {"DontMoveOff", obsolete, (char **)NULL, (int *)0},
324 {"DecorateTransients", SetFlag2, (char **)DecorateTransients, (int *)0},
325 {"CenterOnCirculate", SetFlag2, (char **)CenterOnCirculate, (int *)0},
326 {"AutoRaise", SetInts, (char **)&TmpFeel.AutoRaiseDelay, &dummy},
327 {"ClickTime", SetInts, (char **)&TmpFeel.ClickTime, &dummy},
328 {"OpaqueMove", SetInts, (char **)&TmpFeel.OpaqueMove, &dummy},
329 {"OpaqueResize", SetInts, (char **)&TmpFeel.OpaqueResize, &dummy},
330 {"XorValue", obsolete, (char **)NULL, &dummy},
331 {"Mouse", ParseMouseEntry, (char **)1, (int *)0},
332 {"Popup", ParsePopupEntry, (char **)1, (int *)0},
333 {"Function", ParseFunctionEntry, (char **)1, (int *)0},
334 {"Key", ParseKeyEntry, (char **)1, (int *)0},
335 {"ClickToFocus", SetFlag, (char **)ClickToFocus, (int *)EatFocusClick},
336 {"EatFocusClick", SetFlag2, (char **)EatFocusClick, (int *)0},
337 {"ClickToRaise", SetButtonList, (char **)NULL, (int *)0},
338 {"MenusHigh", obsolete, (char **)NULL, (int *)0},
339 {"SloppyFocus", SetFlag2, (char **)SloppyFocus, (int *)0},
340 {"PagingDefault", obsolete, (char **)NULL, NULL},
341 {"EdgeResistance", SetInts, (char **)&TmpFeel.EdgeResistanceScroll,
342 &TmpFeel.EdgeResistanceMove},
343 {"EdgeResistanceToDragging", SetInts,
344 (char **)&TmpFeel.EdgeResistanceDragScroll, NULL},
345 {"BackingStore", SetFlag2, (char **)BackingStore, (int *)0},
346 {"AppsBackingStore", SetFlag2, (char **)AppsBackingStore, (int *)0},
347 {"SaveUnders", SetFlag2, (char **)SaveUnders, (int *)0},
348 {"Xzap", SetInts, (char **)&TmpFeel.Xzap, (int *)&dummy},
349 {"Yzap", SetInts, (char **)&TmpFeel.Yzap, (int *)&dummy},
350 {"AutoReverse", SetInts, (char **)&TmpFeel.AutoReverse, (int *)&dummy},
351 {"AutoTabThroughDesks", SetFlag2, (char **)AutoTabThroughDesks, NULL},
352 {"MWMFunctionHints", obsolete, (char **)0, NULL},
353 {"MWMDecorHints", obsolete, (char **)0, NULL},
354 {"MWMHintOverride", obsolete, (char **)0, NULL},
355 {"FollowTitleChanges", SetFlag2, (char **)FollowTitleChanges, (int *)0},
356 {"PersistentMenus", SetFlag2, (char **)PersistentMenus, (int *)0},
357 {"NoSnapKey", SetModifier, (char **)&(TmpFeel.no_snaping_mod), (int *)0},
358 {"ScreenEdgeAttraction", SetInts, (char **)&TmpFeel.EdgeAttractionScreen,
359 &dummy},
360 {"WindowEdgeAttraction", SetInts, (char **)&TmpFeel.EdgeAttractionWindow,
361 &dummy},
362 {"DontRestoreFocus", SetFlag2, (char **)DontRestoreFocus, NULL},
363 {"WindowBox", windowbox_parse, (char **)NULL, (int *)NULL},
364 {"DefaultWindowBox", assign_string,
365 (char **)&(TmpFeel.default_window_box_name), (int *)0},
366 {"RecentSubmenuItems", SetInts, (char **)&TmpFeel.recent_submenu_items,
367 (int *)&dummy},
368 {"WinListSortOrder", SetInts, (char **)&TmpFeel.winlist_sort_order,
369 (int *)&dummy},
370 {"WinListHideIcons", SetFlag2, (char **)WinListHideIcons, NULL},
371 {"SuppressIcons", SetFlag2, (char **)SuppressIcons, NULL},
372 {"WarpPointer", SetFlag2, (char **)WarpPointer, NULL},
373
374 /* look options */
375 /* obsolete stuff */
376 {"Font", assign_string, &Stdfont, (int *)0},
377 {"WindowFont", assign_string, &Windowfont, (int *)0},
378 {"IconFont", assign_string, &Iconfont, (int *)0},
379 {"MTitleForeColor", assign_string, &MenuForeColor[MENU_BACK_TITLE],
380 (int *)0},
381 {"MTitleBackColor", assign_string, &MenuBackColor[MENU_BACK_TITLE],
382 (int *)0},
383 {"MenuForeColor", assign_string, &MenuForeColor[MENU_BACK_ITEM],
384 (int *)0},
385 {"MenuBackColor", assign_string, &MenuBackColor[MENU_BACK_ITEM],
386 (int *)0},
387 {"MenuHiForeColor", assign_string, &MenuForeColor[MENU_BACK_HILITE],
388 (int *)0},
389 {"MenuHiBackColor", assign_string, &MenuBackColor[MENU_BACK_HILITE],
390 (int *)0},
391 {"MenuStippleColor", assign_string, &MenuForeColor[MENU_BACK_STIPPLE],
392 (int *)0},
393 {"StdForeColor", assign_string, &WindowForeColor[BACK_UNFOCUSED],
394 (int *)0},
395 {"StdBackColor", assign_string, &WindowBackColor[BACK_UNFOCUSED],
396 (int *)0},
397 {"StickyForeColor", assign_string, &WindowForeColor[BACK_STICKY],
398 (int *)0},
399 {"StickyBackColor", assign_string, &WindowBackColor[BACK_STICKY],
400 (int *)0},
401 {"HiForeColor", assign_string, &WindowForeColor[BACK_FOCUSED], (int *)0},
402 {"HiBackColor", assign_string, &WindowBackColor[BACK_FOCUSED], (int *)0},
403 {"TextureTypes", assign_string, &TexTypes, (int *)0},
404 {"TextureMaxColors", obsolete, NULL, (int *)0},
405 {"TitleTextureColor", assign_string, &WindowGradient[BACK_FOCUSED], (int *)0}, /* title */
406 {"UTitleTextureColor", assign_string, &WindowGradient[BACK_UNFOCUSED], (int *)0}, /* unfoc tit */
407 {"STitleTextureColor", assign_string, &WindowGradient[BACK_STICKY], (int *)0}, /* stic tit */
408 {"MTitleTextureColor", assign_string, &MenuGradient[MENU_BACK_TITLE], (int *)0}, /* menu title */
409 {"MenuTextureColor", assign_string, &MenuGradient[MENU_BACK_ITEM], (int *)0}, /* menu items */
410 {"MenuHiTextureColor", assign_string, &MenuGradient[MENU_BACK_HILITE], (int *)0}, /* sel items */
411 {"MenuPixmap", assign_string, &MenuPixmap[MENU_BACK_ITEM], (int *)0}, /* menu entry */
412 {"MenuHiPixmap", assign_string, &MenuPixmap[MENU_BACK_HILITE], (int *)0}, /* hil m entr */
413 {"MTitlePixmap", assign_string, &MenuPixmap[MENU_BACK_TITLE], (int *)0}, /* menu title */
414 {"TitlePixmap", assign_string, &WindowPixmap[BACK_FOCUSED], (int *)0}, /* foc tit */
415 {"UTitlePixmap", assign_string, &WindowPixmap[BACK_UNFOCUSED], (int *)0}, /* unfoc tit */
416 {"STitlePixmap", assign_string, &WindowPixmap[BACK_STICKY], (int *)0}, /* stick tit */
417 {"MenuPinOff", obsolete, (char **)NULL, (int *)0},
418 {"TexturedHandle", obsolete, (char **)NULL, (int *)0},
419 {"TextGradientColor", obsolete, (char **)NULL, (int *)0}, /* title text */
420 {"GradientText", obsolete, (char **)NULL, (int *)0},
421
422 {"ButtonTextureType", SetInts, (char **)&IconTexType, (int *)&dummy},
423 {"ButtonBgColor", assign_string, &IconBgColor, (int *)0},
424 {"ButtonTextureColor", assign_string, &IconTexColor, (int *)0},
425 {"ButtonMaxColors", obsolete, (char **)NULL, NULL},
426 {"ButtonPixmap", assign_string, &IconPixmapFile, (int *)0},
427 {"ButtonNoBorder", SetLookFlag, (char **)IconNoBorder, NULL},
428 {"FrameNorth", SetFramePart, NULL, (int *)FR_N},
429 {"FrameSouth", SetFramePart, NULL, (int *)FR_S},
430 {"FrameEast", SetFramePart, NULL, (int *)FR_E},
431 {"FrameWest", SetFramePart, NULL, (int *)FR_W},
432 {"FrameNW", SetFramePart, NULL, (int *)FR_NW},
433 {"FrameNE", SetFramePart, NULL, (int *)FR_NE},
434 {"FrameSW", SetFramePart, NULL, (int *)FR_SW},
435 {"FrameSE", SetFramePart, NULL, (int *)FR_SE},
436 {"DecorateFrames", SetLookFlag, (char **)DecorateFrames, NULL},
437 {"TitleButtonBalloonBorderWidth", obsolete, NULL, NULL},
438 {"TitleButtonBalloonBorderColor", obsolete, NULL, NULL},
439 {"TitleTextMode", SetTitleText, (char **)1, (int *)0},
440
441 /* new stuff : */
442 {"IconBox", SetBox, (char **)0, (int *)0},
443 {"MyStyle", mystyle_parse, (char **)"afterstep", (int *)&MyStyleList},
444 {"MyBackground", myback_parse, (char **)"asetroot", NULL}, /* pretending to be asteroot here */
445 {"DeskBack", deskback_parse, NULL, NULL},
446 {"*asetrootDeskBack", deskback_parse, NULL, NULL}, /* pretending to be asteroot here */
447 {"MyFrame", myframe_parse, (char **)"afterstep", (int *)&MyFrameList},
448 {"DefaultFrame", assign_string, (char **)&TmpLook.DefaultFrameName,
449 (int *)0},
450 {"DontDrawBackground", SetLookFlag, (char **)DontDrawBackground, NULL},
451 {"CursorFore", assign_string, &TmpLook.CursorFore, (int *)0}, /* foreground color to be used for coloring pointer's cursor */
452 {"CursorBack", assign_string, &TmpLook.CursorBack, (int *)0}, /* background color to be used for coloring pointer's cursor */
453 /* this two a really from the feel */
454 {"CustomCursor", SetCustomCursor, (char **)0, (int *)0},
455 {"Cursor", SetCursor, (char **)0, (int *)0},
456 /***********************************/
457 {"IconsGrowVertically", SetLookFlag, (char **)IconsGrowVertically,
458 (int *)0},
459 {"MenuPinOn", assign_string, &MenuPinOn, (int *)0}, /* menu pin */
460 {"MArrowPixmap", assign_pixmap, (char **)&TmpLook.MenuArrow, (int *)0}, /* menu arrow */
461 {"TitlebarNoPush", SetLookFlag, (char **)TitlebarNoPush, NULL},
462 {"TextureMenuItemsIndividually", SetLookFlag, (char **)TxtrMenuItmInd,
463 NULL},
464 {"MenuMiniPixmaps", SetLookFlag, (char **)MenuMiniPixmaps, NULL},
465 {"MenuShowUnavailable", SetLookFlag, (char **)MenuShowUnavailable, NULL},
466 {"TitleTextAlign", SetInts, (char **)&TmpLook.TitleTextAlign, &dummy},
467 {"TitleButtonSpacingLeft", SetInts,
468 (char **)&TmpLook.TitleButtonSpacing[0], &dummy},
469 {"TitleButtonSpacingRight", SetInts,
470 (char **)&TmpLook.TitleButtonSpacing[1], &dummy},
471 {"TitleButtonSpacing", SetInts2, (char **)&TmpLook.TitleButtonSpacing[0],
472 &TmpLook.TitleButtonSpacing[1]},
473 {"TitleButtonXOffsetLeft", SetInts,
474 (char **)&TmpLook.TitleButtonXOffset[0], &dummy},
475 {"TitleButtonXOffsetRight", SetInts,
476 (char **)&TmpLook.TitleButtonXOffset[1], &dummy},
477 {"TitleButtonXOffset", SetInts2, (char **)&TmpLook.TitleButtonXOffset[0],
478 &TmpLook.TitleButtonXOffset[1]},
479 {"TitleButtonYOffsetLeft", SetInts,
480 (char **)&TmpLook.TitleButtonYOffset[0], &dummy},
481 {"TitleButtonYOffsetRight", SetInts,
482 (char **)&TmpLook.TitleButtonYOffset[1], &dummy},
483 {"TitleButtonYOffset", SetInts2, (char **)&TmpLook.TitleButtonYOffset[0],
484 &TmpLook.TitleButtonYOffset[1]},
485 {"TitleButtonStyle", SetInts, (char **)&TmpLook.TitleButtonStyle,
486 (int *)&dummy},
487 {"TitleButtonOrder", SetTButtonOrder, NULL, NULL},
488 {"ResizeMoveGeometry", assign_geometry,
489 (char **)&TmpLook.resize_move_geometry, (int *)0},
490 {"StartMenuSortMode", SetInts, (char **)&TmpLook.StartMenuSortMode,
491 (int *)&dummy},
492 {"DrawMenuBorders", SetInts, (char **)&TmpLook.DrawMenuBorders,
493 (int *)&dummy},
494 {"ButtonSize", SetInts, (char **)&TmpLook.ButtonWidth,
495 (int *)&TmpLook.ButtonHeight},
496 {"MinipixmapSize", SetInts, (char **)&TmpLook.minipixmap_width,
497 (int *)&TmpLook.minipixmap_height},
498 {"SeparateButtonTitle", SetLookFlag, (char **)SeparateButtonTitle, NULL},
499 {"RubberBand", SetInts, (char **)&TmpLook.RubberBand, &dummy},
500 {"DefaultStyle", assign_string, (char **)&MSWindowName[BACK_DEFAULT],
501 (int *)0},
502 {"FWindowStyle", assign_string, (char **)&MSWindowName[BACK_FOCUSED],
503 (int *)0},
504 {"UWindowStyle", assign_string, (char **)&MSWindowName[BACK_UNFOCUSED],
505 (int *)0},
506 {"SWindowStyle", assign_string, (char **)&MSWindowName[BACK_STICKY],
507 (int *)0},
508 {"MenuItemStyle", assign_string, (char **)&MSMenuName[MENU_BACK_ITEM],
509 (int *)0},
510 {"MenuTitleStyle", assign_string, (char **)&MSMenuName[MENU_BACK_TITLE],
511 (int *)0},
512 {"MenuHiliteStyle", assign_string,
513 (char **)&MSMenuName[MENU_BACK_HILITE], (int *)0},
514 {"MenuStippleStyle", assign_string,
515 (char **)&MSMenuName[MENU_BACK_STIPPLE], (int *)0},
516 {"MenuSubItemStyle", assign_string,
517 (char **)&MSMenuName[MENU_BACK_SUBITEM], (int *)0},
518 {"MenuHiTitleStyle", assign_string,
519 (char **)&MSMenuName[MENU_BACK_HITITLE], (int *)0},
520 {"MenuItemCompositionMethod", SetInts, (char **)&TmpLook.menu_icm,
521 &dummy},
522 {"MenuHiliteCompositionMethod", SetInts, (char **)&TmpLook.menu_hcm,
523 &dummy},
524 {"MenuStippleCompositionMethod", SetInts, (char **)&TmpLook.menu_scm,
525 &dummy},
526 {"MenuBalloonBorderHilite", bevel_parse, (char **)"afterstep",
527 (int *)&(MenuBalloonConfig.BorderHilite)},
528 {"MenuBalloonXOffset", SetInts, (char **)&(MenuBalloonConfig.XOffset),
529 NULL},
530 {"MenuBalloonYOffset", SetInts, (char **)&(MenuBalloonConfig.YOffset),
531 NULL},
532 {"MenuBalloonDelay", SetInts, (char **)&(MenuBalloonConfig.Delay), NULL},
533 {"MenuBalloonCloseDelay", SetInts,
534 (char **)&(MenuBalloonConfig.CloseDelay), NULL},
535 {"MenuBalloonStyle", assign_string, &(MenuBalloonConfig.Style), NULL},
536 {"MenuBalloonTextPaddingX", SetInts,
537 (char **)&(MenuBalloonConfig.TextPaddingX), NULL},
538 {"MenuBalloonTextPaddingY", SetInts,
539 (char **)&(MenuBalloonConfig.TextPaddingY), NULL},
540 {"MenuBalloons", SetFlag2, (char **)BALLOON_USED,
541 (int *)&(MenuBalloonConfig.set_flags)},
542 {"ShadeAnimationSteps", SetInts, (char **)&TmpFeel.ShadeAnimationSteps,
543 (int *)&dummy},
544 {"TitleButtonBalloonBorderHilite", bevel_parse, (char **)"afterstep",
545 (int *)&(BalloonConfig.BorderHilite)},
546 {"TitleButtonBalloonXOffset", SetInts, (char **)&(BalloonConfig.XOffset),
547 NULL},
548 {"TitleButtonBalloonYOffset", SetInts, (char **)&(BalloonConfig.YOffset),
549 NULL},
550 {"TitleButtonBalloonDelay", SetInts, (char **)&(BalloonConfig.Delay),
551 NULL},
552 {"TitleButtonBalloonCloseDelay", SetInts,
553 (char **)&(BalloonConfig.CloseDelay), NULL},
554 {"TitleButtonBalloonStyle", assign_string, &(BalloonConfig.Style), NULL},
555 {"TitleButtonBalloonTextPaddingX", SetInts,
556 (char **)&(BalloonConfig.TextPaddingX), NULL},
557 {"TitleButtonBalloonTextPaddingY", SetInts,
558 (char **)&(BalloonConfig.TextPaddingY), NULL},
559 {"TitleButtonBalloons", SetFlag2, (char **)BALLOON_USED,
560 (int *)&(BalloonConfig.set_flags)},
561 {"TitleButton", SetTitleButton, (char **)1, (int *)0},
562 {"KillBackgroundThreshold", SetInts,
563 (char **)&(TmpLook.KillBackgroundThreshold), NULL},
564 {"DontAnimateBackground", SetFlag2, (char **)DontAnimateBackground,
565 NULL},
566 {"CoverAnimationSteps", SetInts,
567 (char **)&(TmpFeel.desk_cover_animation_steps), NULL},
568 {"CoverAnimationType", SetInts,
569 (char **)&(TmpFeel.desk_cover_animation_type), NULL},
570 {"AnimateDeskChange", SetFlag2, (char **)AnimateDeskChange, NULL},
571 {"DontCoverDesktop", SetFlag2, (char **)DontCoverDesktop, NULL},
572 {"ButtonIconSpacing", SetInts, (char **)&TmpLook.ButtonIconSpacing,
573 &dummy},
574 {"ButtonBevel", bevel_parse, (char **)"afterstep",
575 (int *)&(TmpLook.ButtonBevel)},
576 {"ButtonAlign", align_parse, (char **)"afterstep",
577 (int *)&(TmpLook.ButtonAlign)},
578 {"", 0, (char **)0, (int *)0}
579 };
580
581 #define PARSE_BUFFER_SIZE MAXLINELENGTH
582 char *orig_tline = NULL;
583
584 /* the following values must not be reset other then by main
585 config reading routine
586 */
587 int curr_conf_line = -1;
588 char *curr_conf_file = NULL;
589
error_point()590 void error_point ()
591 {
592 fprintf (stderr, "AfterStep");
593 if (curr_conf_file)
594 fprintf (stderr, "(%s:%d)", curr_conf_file, curr_conf_line);
595 fprintf (stderr, ":");
596 }
597
tline_error(const char * err_text)598 void tline_error (const char *err_text)
599 {
600 error_point ();
601 fprintf (stderr, "%s in [%s]\n", err_text, orig_tline);
602 }
603
604 /***************************************************************
605 **************************************************************/
obsolete(char * text,FILE * fd,char ** arg,int * i)606 void obsolete (char *text, FILE * fd, char **arg, int *i)
607 {
608 tline_error ("This option is obsolete. ");
609 }
610
611 /***************************************************************
612 * get an icon
613 **************************************************************/
CheckImageManager()614 void CheckImageManager ()
615 {
616 if (Scr.image_manager == NULL)
617 reload_screen_image_manager (&Scr, NULL);
618 }
619
GetIconFromFile(char * file,MyIcon * icon,int max_colors)620 Bool GetIconFromFile (char *file, MyIcon * icon, int max_colors)
621 {
622 CheckImageManager ();
623 memset (icon, 0x00, sizeof (icon_t));
624 return load_icon (icon, file, Scr.image_manager);
625 }
626
GetASImageFromFile(char * file)627 ASImage *GetASImageFromFile (char *file)
628 {
629 ASImage *im;
630 CheckImageManager ();
631 LOCAL_DEBUG_OUT ("loading image from file \"%s\"", file);
632 im = get_asimage (Scr.image_manager, file, ASFLAGS_EVERYTHING, 100);
633 if (im == NULL)
634 show_error
635 ("failed to locate icon file \"%s\" in the IconPath and PixmapPath",
636 file);
637 return im;
638 }
639
640 /*
641 * Copies a string into a new, malloc'ed string
642 * Strips all data before the second quote. and strips trailing spaces and
643 * new lines
644 */
645
stripcpy3(const char * source,const Bool Warn)646 char *stripcpy3 (const char *source, const Bool Warn)
647 {
648 const char *orig_source = source;
649 while ((*source != '"') && (*source != 0))
650 source++;
651 if (*source != 0)
652 source++;
653 while ((*source != '"') && (*source != 0))
654 source++;
655 if (*source == 0) {
656 if (Warn)
657 show_warning ("bad binding [%s]", orig_source);
658 return 0;
659 }
660 source++;
661 return stripcpy (source);
662 }
663
664
665 /*
666 * initialize the old-style look variables
667 */
init_old_look_variables(Bool free_resources)668 void init_old_look_variables (Bool free_resources)
669 {
670 int i;
671 if (free_resources) {
672 /* the fonts */
673 if (Stdfont != NULL)
674 free (Stdfont);
675 if (Windowfont != NULL)
676 free (Windowfont);
677 if (Iconfont != NULL)
678 free (Iconfont);
679 for (i = 0; i < BACK_STYLES; ++i) {
680 if (WindowForeColor[i])
681 free (WindowForeColor[i]);
682 if (WindowBackColor[i])
683 free (WindowBackColor[i]);
684 if (WindowGradient[i])
685 free (WindowGradient[i]);
686 if (WindowPixmap[i])
687 free (WindowPixmap[i]);
688 }
689 for (i = 0; i < MENU_BACK_STYLES; ++i) {
690 if (MenuForeColor[i])
691 free (MenuForeColor[i]);
692 if (MenuBackColor[i])
693 free (MenuBackColor[i]);
694 if (MenuGradient[i])
695 free (MenuGradient[i]);
696 if (MenuPixmap[i])
697 free (MenuPixmap[i]);
698 }
699
700 if (IconBgColor)
701 free (IconBgColor);
702 if (IconTexColor)
703 free (IconTexColor);
704 if (IconPixmapFile)
705 free (IconPixmapFile);
706 if (TexTypes)
707 free (TexTypes);
708 }
709
710 /* the fonts */
711 Stdfont = NULL;
712 Windowfont = NULL;
713 Iconfont = NULL;
714
715 for (i = 0; i < BACK_STYLES; ++i) {
716 WindowForeColor[i] = NULL;
717 WindowBackColor[i] = NULL;
718 WindowGradient[i] = NULL;
719 WindowPixmap[i] = NULL;
720 }
721 for (i = 0; i < MENU_BACK_STYLES; ++i) {
722 MenuForeColor[i] = NULL;
723 MenuBackColor[i] = NULL;
724 MenuGradient[i] = NULL;
725 MenuPixmap[i] = NULL;
726 }
727 IconBgColor = NULL;
728 IconTexColor = NULL;
729 IconPixmapFile = NULL;
730 /* miscellaneous stuff */
731 TexTypes = NULL;
732 TitleTextType = 0;
733 TitleTextY = 0;
734 IconTexType = TEXTURE_BUILTIN;
735
736 }
737
738
739 /*
740 * merge the old variables into the new styles
741 * the new styles have precedence
742 */
merge_old_look_variables(MyLook * look)743 void merge_old_look_variables (MyLook * look)
744 {
745 char *button_style_names[BACK_STYLES] = { AS_ICON_TITLE_MYSTYLE,
746 AS_ICON_TITLE_UNFOCUS_MYSTYLE,
747 AS_ICON_TITLE_STICKY_MYSTYLE,
748 NULL,
749 "ButtonTitleDefault"
750 };
751 MyStyle *button_styles[BACK_STYLES];
752 int i;
753
754 for (i = 0; i < BACK_STYLES; ++i)
755 button_styles[i] =
756 mystyle_list_find (look->styles_list, button_style_names[i]);
757
758 /* the fonts */
759 if (Stdfont != NULL) {
760 if (load_font (Stdfont, &StdFont) == False)
761 exit (1);
762 else
763 for (i = MENU_BACK_ITEM; i < MENU_BACK_STYLES; ++i)
764 mystyle_inherit_font (look->MSMenu[i], &StdFont);
765 }
766 if (Windowfont != NULL) {
767 if (load_font (Windowfont, &WindowFont) == False)
768 exit (1);
769 for (i = 0; i < BACK_STYLES; ++i)
770 mystyle_inherit_font (look->MSWindow[i], &WindowFont);
771 mystyle_inherit_font (look->MSMenu[MENU_BACK_TITLE], &WindowFont);
772 }
773 if (Iconfont != NULL) {
774 if (load_font (Iconfont, &IconFont) == False)
775 exit (1);
776 for (i = 0; i < BACK_STYLES; ++i)
777 mystyle_inherit_font (button_styles[i], &IconFont);
778 }
779 /* the text type */
780 if (TitleTextType != 0) {
781 for (i = 0; i < BACK_STYLES; ++i)
782 if (look->MSWindow[i])
783 if (!get_flags (look->MSWindow[i]->set_flags, F_TEXTSTYLE)) {
784 set_flags (look->MSWindow[i]->text_style, TitleTextType);
785 set_flags (look->MSWindow[i]->user_flags, F_TEXTSTYLE);
786 set_flags (look->MSWindow[i]->set_flags, F_TEXTSTYLE);
787 }
788 }
789 /* the colors */
790 /* for black and white - ignore user choices */
791 /* for color - accept user choices */
792 if (Scr.d_depth > 1) {
793 int wtype[BACK_STYLES] = { 0 };
794 int mtype[MENU_BACK_STYLES] = { 0 };
795
796 for (i = 0; i < BACK_STYLES; ++i)
797 wtype[i] = -1;
798 for (i = 0; i < MENU_BACK_STYLES; ++i)
799 mtype[i] = -1;
800
801 if (TexTypes != NULL)
802 sscanf (TexTypes, "%i %i %i %i %i %i", &wtype[BACK_FOCUSED],
803 &wtype[BACK_UNFOCUSED], &wtype[BACK_STICKY],
804 &mtype[MENU_BACK_TITLE], &mtype[MENU_BACK_ITEM],
805 &mtype[MENU_BACK_HILITE]);
806
807 if (IconTexType == TEXTURE_BUILTIN)
808 IconTexType = -1;
809
810 /* check for missing 1.4.5.x keywords */
811 if (MenuForeColor[MENU_BACK_TITLE] == NULL
812 && WindowForeColor[BACK_FOCUSED] != NULL)
813 MenuForeColor[MENU_BACK_TITLE] =
814 mystrdup (WindowForeColor[BACK_FOCUSED]);
815 if (MenuBackColor[MENU_BACK_TITLE] == NULL
816 && WindowBackColor[BACK_FOCUSED] != NULL)
817 MenuBackColor[MENU_BACK_TITLE] =
818 mystrdup (WindowBackColor[BACK_FOCUSED]);
819 if (MenuForeColor[MENU_BACK_HILITE] == NULL
820 && WindowForeColor[BACK_FOCUSED] != NULL)
821 MenuForeColor[MENU_BACK_HILITE] =
822 mystrdup (WindowForeColor[BACK_FOCUSED]);
823 if (MenuBackColor[MENU_BACK_HILITE] == NULL
824 && MenuBackColor[MENU_BACK_ITEM] != NULL) {
825 mtype[MENU_BACK_HILITE] = mtype[MENU_BACK_ITEM];
826 MenuBackColor[MENU_BACK_HILITE] =
827 mystrdup (MenuBackColor[MENU_BACK_ITEM]);
828 if (MenuGradient[MENU_BACK_HILITE] == NULL
829 && MenuGradient[MENU_BACK_ITEM] != NULL)
830 MenuGradient[MENU_BACK_HILITE] =
831 mystrdup (MenuGradient[MENU_BACK_ITEM]);
832 if (MenuPixmap[MENU_BACK_HILITE] == NULL
833 && MenuPixmap[MENU_BACK_ITEM] != NULL)
834 MenuPixmap[MENU_BACK_HILITE] =
835 mystrdup (MenuPixmap[MENU_BACK_ITEM]);
836 }
837 for (i = 0; i < BACK_STYLES; ++i)
838 mystyle_merge_colors (look->MSWindow[i], wtype[i],
839 WindowForeColor[i], WindowBackColor[i],
840 WindowGradient[i], WindowPixmap[i]);
841 for (i = 0; i < MENU_BACK_STYLES; ++i)
842 mystyle_merge_colors (look->MSMenu[i], mtype[i], MenuForeColor[i],
843 MenuBackColor[i], MenuGradient[i],
844 MenuPixmap[i]);
845
846 {
847 MyStyle *button_pixmap =
848 mystyle_list_find (look->styles_list, AS_ICON_MYSTYLE);
849
850 /* icon styles automagically inherit from window title styles */
851 if (button_pixmap != NULL) {
852 mystyle_merge_styles (look->MSWindow[BACK_FOCUSED], button_pixmap,
853 0, 0);
854 mystyle_merge_colors (button_pixmap, IconTexType, NULL,
855 IconBgColor, IconTexColor, IconPixmapFile);
856 }
857 }
858 for (i = 0; i < BACK_STYLES; ++i)
859 if (button_styles[i] != NULL)
860 mystyle_merge_styles (look->MSWindow[i], button_styles[i], 0, 0);
861 }
862 init_old_look_variables (True); /* no longer need those strings !!!! */
863 }
864
865
866 /*
867 * Initialize feel variables
868 */
InitFeel(ASFeel * feel,Bool free_resources)869 void InitFeel (ASFeel * feel, Bool free_resources)
870 {
871 if (feel) {
872 if (free_resources)
873 destroy_asfeel (feel, True);
874 feel->magic = MAGIC_ASFEEL;
875 init_asfeel (feel);
876 }
877 }
878
merge_feel(ASFeel * to,ASFeel * from)879 void merge_feel (ASFeel * to, ASFeel * from)
880 {
881 to->deprecated_flags = from->deprecated_flags;
882 to->EdgeScrollX = from->EdgeScrollX;
883 to->EdgeScrollY = from->EdgeScrollY;
884 to->AutoRaiseDelay = from->AutoRaiseDelay;
885 to->ClickTime = from->ClickTime;
886 to->OpaqueMove = from->OpaqueMove;
887 to->OpaqueResize = from->OpaqueResize;
888 to->EdgeResistanceScroll = from->EdgeResistanceScroll;
889 to->EdgeResistanceMove = from->EdgeResistanceMove;
890 to->EdgeResistanceDragScroll = from->EdgeResistanceDragScroll;
891 to->Xzap = from->Xzap;
892 to->Yzap = from->Yzap;
893 to->AutoReverse = from->AutoReverse;
894 to->no_snaping_mod = from->no_snaping_mod;
895 to->EdgeAttractionScreen = from->EdgeAttractionScreen;
896 to->EdgeAttractionWindow = from->EdgeAttractionWindow;
897 to->default_window_box_name = from->default_window_box_name;
898 to->recent_submenu_items = from->recent_submenu_items;
899 to->winlist_sort_order = from->winlist_sort_order;
900 to->ShadeAnimationSteps = from->ShadeAnimationSteps;
901 to->desk_cover_animation_steps = from->desk_cover_animation_steps;
902 to->desk_cover_animation_type = from->desk_cover_animation_type;
903
904 }
905
ApplyFeel(ASFeel * feel)906 void ApplyFeel (ASFeel * feel)
907 {
908 check_screen_panframes (ASDefaultScr);
909
910 }
911
912 /*
913 * Initialize look variables
914 */
InitLook(MyLook * look,Bool free_resources)915 void InitLook (MyLook * look, Bool free_resources)
916 {
917 int i;
918 /* actuall MyLook cleanup : */
919
920 mylook_init (look, free_resources, LL_Everything);
921
922 /* other related things : */
923 if (free_resources) {
924 /* icons */
925 if (MenuPinOn != NULL)
926 free (MenuPinOn);
927 if (Scr.default_icon_box)
928 destroy_asiconbox (&(Scr.default_icon_box));
929 if (Scr.icon_boxes)
930 destroy_ashash (&(Scr.icon_boxes));
931
932 /* temporary old-style fonts : */
933 unload_font (&StdFont);
934 unload_font (&WindowFont);
935 unload_font (&IconFont);
936 DestroyMyStyleDefinitions (&MyStyleList);
937 DestroyMyFrameDefinitions (&MyFrameList);
938 if (LegacyFrameDef)
939 DestroyMyFrameDefinitions (&LegacyFrameDef);
940 if (BalloonConfig.Style)
941 free (BalloonConfig.Style);
942 for (i = 0; i < BACK_STYLES; ++i)
943 if (MSWindowName[i])
944 free (MSWindowName[i]);
945 for (i = 0; i < MENU_BACK_STYLES; ++i)
946 if (MSMenuName[i])
947 free (MSMenuName[i]);
948 }
949 MenuPinOn = NULL;
950 MenuPinOnButton = -1;
951
952 Scr.default_icon_box = NULL;
953 Scr.icon_boxes = NULL;
954
955 /* temporary old-style fonts : */
956 memset (&StdFont, 0x00, sizeof (MyFont));
957 memset (&WindowFont, 0x00, sizeof (MyFont));
958 memset (&IconFont, 0x00, sizeof (MyFont));
959
960 MyStyleList = NULL;
961 for (i = 0; i < BACK_STYLES; ++i)
962 MSWindowName[i] = NULL;
963 for (i = 0; i < MENU_BACK_STYLES; ++i)
964 MSMenuName[i] = NULL;
965
966 MyFrameList = NULL;
967 LegacyFrameDef = NULL;
968 memset (&BalloonConfig, 0x00, sizeof (BalloonConfig));
969 }
970
merge_look(MyLook * to,MyLook * from)971 void merge_look (MyLook * to, MyLook * from)
972 {
973 int i;
974 to->CursorFore = from->CursorFore;
975 to->CursorBack = from->CursorBack;
976 to->MenuArrow = from->MenuArrow;
977 to->TitleTextAlign = from->TitleTextAlign;
978 for (i = 0; i < 2; ++i) {
979 to->TitleButtonSpacing[i] = from->TitleButtonSpacing[i];
980 to->TitleButtonXOffset[i] = from->TitleButtonXOffset[i];
981 to->TitleButtonYOffset[i] = from->TitleButtonYOffset[i];
982 }
983 to->TitleButtonStyle = from->TitleButtonStyle;
984 to->resize_move_geometry = from->resize_move_geometry;
985 to->StartMenuSortMode = from->StartMenuSortMode;
986 to->DrawMenuBorders = from->DrawMenuBorders;
987 to->ButtonWidth = (from->ButtonWidth == 0) ? 64 : from->ButtonWidth;
988 to->ButtonHeight =
989 (from->ButtonHeight == 0) ? to->ButtonWidth : from->ButtonHeight;
990 to->ButtonIconSpacing = from->ButtonIconSpacing;
991 to->ButtonAlign = from->ButtonAlign;
992 to->ButtonBevel = from->ButtonBevel;
993
994 to->minipixmap_width =
995 (from->minipixmap_width == 0) ? 24 : from->minipixmap_width;
996 to->minipixmap_height =
997 (from->minipixmap_height ==
998 0) ? to->minipixmap_width : from->minipixmap_height;
999
1000
1001 to->DefaultFrameName = from->DefaultFrameName;
1002
1003 to->RubberBand = from->RubberBand;
1004 to->menu_icm = from->menu_icm;
1005 to->menu_hcm = from->menu_hcm;
1006 to->menu_scm = from->menu_scm;
1007 to->KillBackgroundThreshold = from->KillBackgroundThreshold;
1008 to->desktop_animation_tint = from->desktop_animation_tint;
1009 LOCAL_DEBUG_OUT ("desk_anime_tint = %lX", from->desktop_animation_tint);
1010 }
1011
1012
make_styles(MyLook * look)1013 void make_styles (MyLook * look)
1014 {
1015 /* make sure the globals are defined */
1016 char *style_names[BACK_STYLES] =
1017 { "FWindow", "UWindow", "SWindow", NULL, "default" };
1018 char *menu_style_names[MENU_BACK_STYLES] =
1019 { "MenuTitle", "MenuItem", "MenuHilite", "MenuStipple",
1020 "MenuSubItem", "MenuHiTitle" };
1021 int i;
1022
1023 for (i = 0; i < BACK_STYLES; ++i)
1024 if (MSWindowName[i])
1025 look->MSWindow[i] =
1026 mystyle_find_or_get_from_file (look->styles_list,
1027 MSWindowName[i]);
1028 if (look->MSWindow[BACK_DEFAULT] == NULL)
1029 look->MSWindow[BACK_DEFAULT] =
1030 mystyle_find_or_get_from_file (look->styles_list, "default");
1031
1032 /* this is the last resort : */
1033 if (look->MSWindow[BACK_DEFAULT] == NULL)
1034 look->MSWindow[BACK_DEFAULT] =
1035 mystyle_list_find_or_default (look->styles_list, "default");
1036
1037 for (i = 0; i < BACK_STYLES; ++i)
1038 if (look->MSWindow[i] == NULL && style_names[i])
1039 look->MSWindow[i] =
1040 mystyle_list_new (look->styles_list, style_names[i]);
1041
1042 for (i = 0; i < MENU_BACK_STYLES; ++i)
1043 if (MSMenuName[i])
1044 look->MSMenu[i] =
1045 mystyle_find_or_get_from_file (look->styles_list, MSMenuName[i]);
1046
1047 for (i = 0; i < MENU_BACK_STYLES; ++i)
1048 if (look->MSMenu[i] == NULL) {
1049 if (i == MENU_BACK_SUBITEM)
1050 look->MSMenu[i] = look->MSMenu[MENU_BACK_ITEM];
1051 else if (i == MENU_BACK_HITITLE)
1052 look->MSMenu[i] = look->MSWindow[BACK_FOCUSED];
1053 else
1054 look->MSMenu[i] =
1055 mystyle_list_new (look->styles_list, menu_style_names[i]);
1056 }
1057 if (mystyle_find_or_get_from_file (look->styles_list, "ButtonPixmap") ==
1058 NULL)
1059 mystyle_list_new (look->styles_list, "ButtonPixmap");
1060 if (mystyle_find_or_get_from_file (look->styles_list, "ButtonTitleFocus")
1061 == NULL)
1062 mystyle_list_new (look->styles_list, "ButtonTitleFocus");
1063 if (mystyle_find_or_get_from_file
1064 (look->styles_list, "ButtonTitleSticky") == NULL)
1065 mystyle_list_new (look->styles_list, "ButtonTitleSticky");
1066 if (mystyle_find_or_get_from_file
1067 (look->styles_list, "ButtonTitleUnfocus") == NULL)
1068 mystyle_list_new (look->styles_list, "ButtonTitleUnfocus");
1069 }
1070
add_myframe_from_def(MyLook * look,MyFrameDefinition * fd,ASFlagType default_title_align)1071 MyFrame *add_myframe_from_def (MyLook * look, MyFrameDefinition * fd,
1072 ASFlagType default_title_align)
1073 {
1074 ASHashTable *list = look->FramesList;
1075 MyFrame *frame;
1076 int i;
1077
1078 frame = get_flags (fd->flags, MYFRAME_INHERIT_DEFAULTS) ?
1079 create_default_myframe (default_title_align) : create_myframe ();
1080
1081 frame->name = mystrdup (fd->name);
1082 for (i = 0; i < fd->inheritance_num; ++i) {
1083 ASHashData hdata;
1084 if (get_hash_item
1085 (list, AS_HASHABLE (fd->inheritance_list[i]),
1086 &hdata.vptr) == ASH_Success)
1087 inherit_myframe (frame, hdata.vptr);
1088 }
1089 frame->parts_mask =
1090 (frame->parts_mask & (~fd->set_parts)) | fd->parts_mask;
1091 LOCAL_DEBUG_OUT ("parts_mask == 0x%lX", frame->parts_mask);
1092 frame->set_parts |= fd->set_parts;
1093 for (i = 0; i < FRAME_PARTS; ++i) {
1094 if (fd->parts[i])
1095 set_string (&(frame->part_filenames[i]), mystrdup (fd->parts[i]));
1096 if (get_flags (fd->set_part_size, 0x01 << i)) {
1097 frame->part_width[i] = max (fd->part_width[i], 1);
1098 frame->part_length[i] = max (fd->part_length[i], 1);
1099 }
1100 if (IsPartFBevelSet (fd, i))
1101 frame->part_fbevel[i] = fd->part_fbevel[i];
1102 if (IsPartUBevelSet (fd, i))
1103 frame->part_ubevel[i] = fd->part_ubevel[i];
1104 if (IsPartSBevelSet (fd, i))
1105 frame->part_sbevel[i] = fd->part_sbevel[i];
1106 if (get_flags (fd->set_part_align, 0x01 << i))
1107 frame->part_align[i] = fd->part_align[i];
1108 }
1109 frame->set_part_size |= fd->set_part_size;
1110 frame->set_part_bevel |= fd->set_part_bevel;
1111 frame->set_part_align |= fd->set_part_align;
1112
1113 for (i = 0; i < FRAME_PARTS; ++i)
1114 if (frame->part_filenames[i])
1115 if (!get_flags (frame->set_part_align, 0x01 << i)) {
1116 frame->part_align[i] = RESIZE_V | RESIZE_H;
1117 set_flags (frame->set_part_align, 0x01 << i);
1118 }
1119
1120 for (i = 0; i < BACK_STYLES; ++i) {
1121 if (fd->title_styles[i]) {
1122 set_string (&(frame->title_style_names[i]),
1123 mystrdup (fd->title_styles[i]));
1124 /* force load the MyStyle in question */
1125 mystyle_find_or_get_from_file (look->styles_list,
1126 fd->title_styles[i]);
1127 }
1128 if (fd->frame_styles[i]) {
1129 set_string (&(frame->frame_style_names[i]),
1130 mystrdup (fd->frame_styles[i]));
1131 /* force load the MyStyle in question */
1132 mystyle_find_or_get_from_file (look->styles_list,
1133 fd->title_styles[i]);
1134 }
1135 }
1136 if (get_flags (fd->set_title_attr, MYFRAME_TitleFBevelSet))
1137 frame->title_fbevel = fd->title_fbevel;
1138 if (get_flags (fd->set_title_attr, MYFRAME_TitleUBevelSet))
1139 frame->title_ubevel = fd->title_ubevel;
1140 if (get_flags (fd->set_title_attr, MYFRAME_TitleSBevelSet))
1141 frame->title_sbevel = fd->title_sbevel;
1142 if (get_flags (fd->set_title_attr, MYFRAME_TitleAlignSet))
1143 frame->title_align = fd->title_align;
1144 if (get_flags (fd->set_title_attr, MYFRAME_LeftBtnAlignSet))
1145 frame->left_btn_align = fd->left_btn_align;
1146 if (get_flags (fd->set_title_attr, MYFRAME_RightBtnAlignSet))
1147 frame->right_btn_align = fd->right_btn_align;
1148
1149 if (get_flags (fd->set_title_attr, MYFRAME_CondenseTitlebarSet))
1150 frame->condense_titlebar = fd->condense_titlebar;
1151 if (get_flags (fd->set_title_attr, MYFRAME_LeftTitlebarLayoutSet)) {
1152 frame->left_layout = fd->left_layout;
1153 LOCAL_DEBUG_OUT ("LeftTitlebarLayout = 0x%lX", fd->left_layout);
1154 }
1155 if (get_flags (fd->set_title_attr, MYFRAME_RightTitlebarLayoutSet))
1156 frame->right_layout = fd->right_layout;
1157 if (get_flags (fd->set_title_attr, MYFRAME_TitleFCMSet))
1158 frame->title_fcm = fd->title_fcm;
1159 if (get_flags (fd->set_title_attr, MYFRAME_TitleUCMSet))
1160 frame->title_ucm = fd->title_ucm;
1161 if (get_flags (fd->set_title_attr, MYFRAME_TitleSCMSet))
1162 frame->title_scm = fd->title_scm;
1163
1164 if (get_flags (fd->set_title_attr, MYFRAME_TitleFHueSet))
1165 parse_hue (fd->title_fhue, &(frame->title_fhue));
1166 if (get_flags (fd->set_title_attr, MYFRAME_TitleUHueSet))
1167 parse_hue (fd->title_uhue, &(frame->title_uhue));
1168 if (get_flags (fd->set_title_attr, MYFRAME_TitleSHueSet))
1169 parse_hue (fd->title_shue, &(frame->title_shue));
1170
1171 if (get_flags (fd->set_title_attr, MYFRAME_TitleFSatSet))
1172 frame->title_fsat = fd->title_fsat;
1173 if (get_flags (fd->set_title_attr, MYFRAME_TitleUSatSet))
1174 frame->title_usat = fd->title_usat;
1175 if (get_flags (fd->set_title_attr, MYFRAME_TitleSSatSet))
1176 frame->title_ssat = fd->title_ssat;
1177
1178 if (get_flags (fd->set_title_attr, MYFRAME_TitleHSpacingSet))
1179 frame->title_h_spacing = fd->title_h_spacing;
1180 if (get_flags (fd->set_title_attr, MYFRAME_TitleVSpacingSet))
1181 frame->title_v_spacing = fd->title_v_spacing;
1182
1183
1184 for (i = 0; i < MYFRAME_TITLE_BACKS; ++i) {
1185 if (get_flags
1186 (fd->set_title_attr, MYFRAME_TitleBackAlignSet_Start << i))
1187 frame->title_backs_align[i] = fd->title_backs_align[i];
1188
1189 if (fd->title_backs[i]) {
1190 set_string (&(frame->title_back_filenames[i]),
1191 mystrdup (fd->title_backs[i]));
1192 if (!get_flags
1193 (fd->set_title_attr, MYFRAME_TitleBackAlignSet_Start << i)) {
1194 frame->title_backs_align[i] = FIT_LABEL_WIDTH;
1195 set_flags (fd->set_title_attr,
1196 MYFRAME_TitleBackAlignSet_Start << i);
1197 }
1198 }
1199 }
1200 frame->set_title_attr |= fd->set_title_attr;
1201
1202 /* wee need to make sure that frame has such a
1203 * neccessary attributes as title align and title bevel : */
1204 if (!get_flags (frame->set_title_attr, MYFRAME_TitleFBevelSet))
1205 frame->title_fbevel = DEFAULT_TBAR_HILITE;
1206 if (!get_flags (frame->set_title_attr, MYFRAME_TitleUBevelSet))
1207 frame->title_ubevel = DEFAULT_TBAR_HILITE;
1208 if (!get_flags (frame->set_title_attr, MYFRAME_TitleSBevelSet))
1209 frame->title_sbevel = DEFAULT_TBAR_HILITE;
1210 if (!get_flags (frame->set_title_attr, MYFRAME_TitleAlignSet))
1211 frame->title_align = default_title_align;
1212
1213 if (!get_flags (frame->set_title_attr, MYFRAME_LeftBtnAlignSet))
1214 frame->left_btn_align = ALIGN_VCENTER;
1215 if (!get_flags (frame->set_title_attr, MYFRAME_RightBtnAlignSet))
1216 frame->right_btn_align = ALIGN_VCENTER;
1217
1218 set_flags (frame->set_title_attr,
1219 MYFRAME_TitleBevelSet | MYFRAME_TitleAlignSet);
1220
1221 frame->set_flags = fd->set_flags;
1222 frame->flags = fd->flags;
1223
1224
1225 if (add_hash_item (list, AS_HASHABLE (frame->name), frame) !=
1226 ASH_Success) {
1227 LOCAL_DEBUG_OUT
1228 ("failed to add frame with the name \"%s\", currently list holds %ld frames",
1229 frame->name, list->items_num);
1230 destroy_myframe (&frame);
1231 } else {
1232 LOCAL_DEBUG_OUT ("added frame with the name \"%s\"", frame->name);
1233 }
1234 return frame;
1235 }
1236
fix_menu_pin_on(MyLook * look)1237 void fix_menu_pin_on (MyLook * look)
1238 {
1239 if (MenuPinOn != NULL) {
1240 if (MenuPinOnButton < 0 || MenuPinOnButton >= TITLE_BUTTONS) {
1241 register int i = TITLE_BUTTONS;
1242
1243 while (--i >= 0) {
1244 if (look->buttons[i].unpressed.image == NULL
1245 && look->buttons[i].pressed.image == NULL)
1246 break;
1247 }
1248
1249 if (i >= 0) {
1250 if (GetIconFromFile
1251 (MenuPinOn, &(Scr.Look.buttons[i].unpressed), 0)) {
1252 int context = C_TButton0 << i;
1253 register int k;
1254 Scr.Look.buttons[i].width =
1255 Scr.Look.buttons[i].unpressed.image->width;
1256 Scr.Look.buttons[i].height =
1257 Scr.Look.buttons[i].unpressed.image->height;
1258 MenuPinOnButton = i;
1259
1260 if (Scr.Look.buttons[i].context == C_NO_CONTEXT)
1261 Scr.Look.buttons[i].context = context;
1262 context = Scr.Look.buttons[i].context;
1263 for (k = 0; k < TITLE_BUTTONS; ++k)
1264 if (Scr.Look.button_xref[k] == context)
1265 break;
1266 if (k == TITLE_BUTTONS) {
1267 while (--k >= 0)
1268 if (Scr.Look.button_xref[k] == C_NO_CONTEXT) {
1269 Scr.Look.button_xref[k] = context;
1270 break;
1271 }
1272 }
1273 if (k >= 0 && k < TITLE_BUTTONS)
1274 Scr.Look.ordered_buttons[k] = &(Scr.Look.buttons[i]);
1275 else
1276 show_warning
1277 ("there is no slot on the titlebar to place button %d into. Check yout TitleButtonOrder setting.",
1278 i);
1279 } else
1280 MenuPinOnButton = -1;
1281 }
1282 }
1283 if (MenuPinOnButton >= 0) {
1284 static char binding[128];
1285 sprintf (binding, "1 %d A PinMenu\n", MenuPinOnButton);
1286 /* also need to add mouse binding for this one */
1287 ParseMouseEntry (binding, NULL, NULL, NULL);
1288 }
1289 show_warning
1290 ("MenuPinOn setting is depreciated - instead add a Title button and bind PinMenu function to it.");
1291 }
1292 }
1293
FixLook(MyLook * look)1294 void FixLook (MyLook * look)
1295 {
1296 ASFlagType default_title_align = ALIGN_LEFT;
1297 int menu_font_size = 0;
1298 int i;
1299 #ifdef LOCAL_DEBUG
1300 LOCAL_DEBUG_OUT ("syncing %s", "");
1301 ASSync (False);
1302 #endif
1303 /* make sure all needed styles are created */
1304 #if defined(LOCAL_DEBUG) && !defined(NO_DEBUG_OUTPUT)
1305 PrintMyStyleDefinitions (MyStyleList);
1306 #endif
1307 LOCAL_DEBUG_OUT ("MyStyleList %p", MyStyleList);
1308 if (MyStyleList) {
1309 MyStyleDefinition *sd;
1310 for (sd = MyStyleList; sd != NULL; sd = sd->next) {
1311 LOCAL_DEBUG_OUT ("processing MyStyleDefinition %p", sd);
1312 mystyle_create_from_definition (look->styles_list, sd);
1313 }
1314 DestroyMyStyleDefinitions (&MyStyleList);
1315 }
1316 make_styles (look);
1317 #ifdef LOCAL_DEBUG
1318 LOCAL_DEBUG_OUT ("syncing %s", "");
1319 ASSync (False);
1320 #endif
1321
1322 /* merge pre-1.5 compatibility keywords */
1323 merge_old_look_variables (look);
1324 #ifdef LOCAL_DEBUG
1325 LOCAL_DEBUG_OUT ("syncing %s", "");
1326 ASSync (False);
1327 #endif
1328
1329 /* fill in remaining members with the default style */
1330 mystyle_list_fix_styles (look->styles_list);
1331 #ifdef LOCAL_DEBUG
1332 LOCAL_DEBUG_OUT ("syncing %s", "");
1333 ASSync (False);
1334 #endif
1335
1336 mylook_set_font_size_var (look);
1337
1338 for (i = 0; i < MENU_BACK_STYLES; ++i)
1339 if (look->MSMenu[i]) {
1340 int font_size = mystyle_get_font_height (look->MSMenu[i]);
1341 if (font_size > menu_font_size)
1342 menu_font_size = font_size;
1343 }
1344 asxml_var_insert (ASXMLVAR_MenuFontSize, menu_font_size);
1345
1346
1347 mystyle_list_set_property (Scr.wmprops, look->styles_list);
1348 #ifdef LOCAL_DEBUG
1349 LOCAL_DEBUG_OUT ("syncing %s", "");
1350 ASSync (False);
1351 #endif
1352
1353 if (look->TitleTextAlign == JUSTIFY_RIGHT)
1354 default_title_align = ALIGN_RIGHT;
1355 else if (look->TitleTextAlign == JUSTIFY_CENTER)
1356 default_title_align = ALIGN_CENTER;
1357
1358 if (look->DefaultFrameName == NULL)
1359 look->DefaultFrameName = mystrdup ("default");
1360 check_myframes_list (look);
1361
1362 /* update frame geometries */
1363 if (get_flags (look->flags, DecorateFrames)) {
1364 MyFrameDefinition *fd;
1365 MyFrame *frame;
1366 /* TODO: need to load the list as well (if we have any ) */
1367 #if defined(LOCAL_DEBUG) && !defined(NO_DEBUG_OUTPUT)
1368 PrintMyFrameDefinitions (MyFrameList, 1);
1369 #endif
1370 LOCAL_DEBUG_OUT ("MyFrameList %p", MyFrameList);
1371 for (fd = MyFrameList; fd != NULL; fd = fd->next) {
1372 LOCAL_DEBUG_OUT ("processing MyFrameDefinition %p", fd);
1373 if ((frame =
1374 add_myframe_from_def (look, fd,
1375 default_title_align | ALIGN_VCENTER)) !=
1376 NULL)
1377 myframe_load (frame, Scr.image_manager);
1378 }
1379 if (LegacyFrameDef) {
1380 LOCAL_DEBUG_OUT ("processing legacy MyFrameDefinition %p",
1381 LegacyFrameDef);
1382 LegacyFrameDef->name = mystrdup (look->DefaultFrameName);
1383 if ((frame =
1384 add_myframe_from_def (look, LegacyFrameDef,
1385 default_title_align | ALIGN_VCENTER)) !=
1386 NULL)
1387 myframe_load (frame, Scr.image_manager);
1388 }
1389 DestroyMyFrameDefinitions (&MyFrameList);
1390 DestroyMyFrameDefinitions (&LegacyFrameDef);
1391 LOCAL_DEBUG_OUT ("DefaultFrameName is \"%s\".",
1392 look->DefaultFrameName);
1393 }
1394
1395 if (myframe_find (look->DefaultFrameName) == NULL) {
1396 MyFrame *dmf =
1397 create_default_myframe (default_title_align | ALIGN_VCENTER);
1398 dmf->name = mystrdup (look->DefaultFrameName);
1399 if (add_hash_item (look->FramesList, AS_HASHABLE (dmf->name), dmf) !=
1400 ASH_Success)
1401 destroy_myframe (&dmf);
1402 }
1403 #ifdef LOCAL_DEBUG
1404 LOCAL_DEBUG_OUT ("syncing %s", "");
1405 ASSync (False);
1406 #endif
1407
1408 /* checking that all the buttons have assigned slots in the button xref : */
1409 for (i = 0; i < TITLE_BUTTONS; ++i) {
1410 if (Scr.Look.buttons[i].unpressed.image != NULL) {
1411 int context = C_TButton0 << i;
1412 register int k;
1413 if (Scr.Look.buttons[i].context == C_NO_CONTEXT)
1414 Scr.Look.buttons[i].context = context;
1415 context = Scr.Look.buttons[i].context;
1416 for (k = 0; k < TITLE_BUTTONS; ++k)
1417 if (Scr.Look.button_xref[k] == context)
1418 break;
1419 if (k == TITLE_BUTTONS) {
1420 while (--k >= 0)
1421 if (Scr.Look.button_xref[k] == C_NO_CONTEXT) {
1422 Scr.Look.button_xref[k] = context;
1423 break;
1424 }
1425 }
1426 if (k >= 0 && k < TITLE_BUTTONS)
1427 Scr.Look.ordered_buttons[k] = &(Scr.Look.buttons[i]);
1428 else
1429 show_warning
1430 ("there is no slot on the titlebar to place button %d into. Check yout TitleButtonOrder setting.",
1431 i);
1432 }
1433 }
1434
1435 /* checking sanity of the move-resize window geometry : */
1436 if ((look->resize_move_geometry.flags & (HeightValue | WidthValue)) !=
1437 (HeightValue | WidthValue)) {
1438 unsigned int width = 0;
1439 unsigned int height = 0;
1440 mystyle_get_text_size (look->MSWindow[BACK_FOCUSED],
1441 " +88888 x +88888 ", &width, &height);
1442 if (!get_flags (look->resize_move_geometry.flags, WidthValue))
1443 look->resize_move_geometry.width = width + SIZE_VINDENT * 2;
1444
1445 if (!get_flags (look->resize_move_geometry.flags, HeightValue))
1446 look->resize_move_geometry.height = height + SIZE_VINDENT * 2;
1447
1448 set_flags (look->resize_move_geometry.flags, HeightValue | WidthValue);
1449 }
1450 if (look->supported_hints == NULL) {
1451 look->supported_hints = create_hints_list ();
1452 enable_hints_support (look->supported_hints, HINTS_ICCCM);
1453 enable_hints_support (look->supported_hints, HINTS_Motif);
1454 enable_hints_support (look->supported_hints, HINTS_Gnome);
1455 enable_hints_support (look->supported_hints, HINTS_KDE);
1456 enable_hints_support (look->supported_hints, HINTS_ExtendedWM);
1457 enable_hints_support (look->supported_hints, HINTS_ASDatabase);
1458 enable_hints_support (look->supported_hints, HINTS_GroupLead);
1459 enable_hints_support (look->supported_hints, HINTS_Transient);
1460 }
1461 switch (look->TitleButtonStyle) {
1462 case 0:
1463 look->TitleButtonXOffset[0] = look->TitleButtonXOffset[1] = 3;
1464 look->TitleButtonYOffset[0] = look->TitleButtonYOffset[1] = 3;
1465 break;
1466 case 1:
1467 look->TitleButtonXOffset[0] = look->TitleButtonXOffset[1] = 1;
1468 look->TitleButtonYOffset[0] = look->TitleButtonYOffset[1] = 1;
1469 break;
1470 }
1471
1472 /* now we need to go through all the deskconfigs and create generic
1473 * MyBackground for those that alreadyu do not have one */
1474 if (look->desk_configs) {
1475 ASHashIterator it;
1476 if (start_hash_iteration (look->desk_configs, &it))
1477 do {
1478 MyDesktopConfig *dc = (MyDesktopConfig *) curr_hash_data (&it);
1479 MyBackground *myback = mylook_get_back (look, dc->back_name);
1480 LOCAL_DEBUG_OUT ("myback = %p, back_name = \"%s\"", myback,
1481 dc->back_name ? dc->back_name : "<NULL>");
1482 if (myback == NULL && dc->back_name != NULL) {
1483 myback = create_myback (dc->back_name);
1484 myback->type = MB_BackImage;
1485 myback->data = mystrdup (dc->back_name);
1486 add_myback (look, myback);
1487 }
1488 } while (next_hash_item (&it));
1489 } else if (!get_flags (Scr.Look.flags, DontDrawBackground)) {
1490 MyDesktopConfig *dc;
1491 MyBackground *myback;
1492 char *buf = safemalloc (strlen (DEFAULT_BACK_NAME) + 1);
1493
1494 sprintf (buf, DEFAULT_BACK_NAME, 0);
1495 dc = create_mydeskconfig (0, buf);
1496 free (buf);
1497
1498 add_deskconfig (&(Scr.Look), dc);
1499 myback = mylook_get_back (look, dc->back_name);
1500 if (myback == NULL) {
1501 myback = create_myback (dc->back_name);
1502 myback->type = MB_BackImage;
1503 add_myback (look, myback);
1504 }
1505 }
1506 #ifdef LOCAL_DEBUG
1507 LOCAL_DEBUG_OUT ("syncing %s", "");
1508 ASSync (False);
1509 #endif
1510 }
1511
1512
1513 /*
1514 * Initialize database variables
1515 */
1516
InitDatabase(Bool free_resources)1517 void InitDatabase (Bool free_resources)
1518 {
1519 if (free_resources) {
1520 destroy_asdb (&Database);
1521 /* XResources : */
1522 destroy_user_database ();
1523 } else
1524 Database = NULL;
1525 }
1526
1527 /*
1528 * Create/destroy window titlebar/buttons as necessary.
1529 */
redecorate_aswindow_iter_func(void * data,void * aux_data)1530 Bool redecorate_aswindow_iter_func (void *data, void *aux_data)
1531 {
1532 ASWindow *asw = (ASWindow *) data;
1533 if (asw) {
1534 /* need to invalidate all MyStyles at this point ??? */
1535
1536 invalidate_window_mystyles (asw);
1537
1538 redecorate_window (asw, False);
1539 if (asw->internal && asw->internal->on_look_feel_changed)
1540 asw->internal->on_look_feel_changed (asw->internal, &Scr.Feel,
1541 &Scr.Look, ASFLAGS_EVERYTHING);
1542 on_window_status_changed (asw, True);
1543 set_flags (asw->internal_flags, ASWF_PendingShapeRemoval);
1544 }
1545 return True;
1546 }
1547
advertise_tbar_props()1548 void advertise_tbar_props ()
1549 {
1550 ASTBarProps props;
1551 MyFrame *frame = myframe_find (NULL);
1552 MouseButton *btn;
1553 int i, k;
1554
1555 MyButton *close_btn = NULL;
1556 MyButton *maximize_btn = NULL;
1557 MyButton *minimize_btn = NULL;
1558 MyButton *shade_btn = NULL;
1559 MyButton *menu_btn = NULL;
1560 struct {
1561 Atom *kind, *kind_down;
1562 int func;
1563 MyButton **pbtn;
1564 } buttons[] = { {
1565 &_AS_BUTTON_CLOSE, &_AS_BUTTON_CLOSE_PRESSED, F_CLOSE, &close_btn}, {
1566 &_AS_BUTTON_CLOSE, &_AS_BUTTON_CLOSE_PRESSED, F_DELETE, &close_btn}, {
1567 &_AS_BUTTON_CLOSE, &_AS_BUTTON_CLOSE_PRESSED, F_DESTROY, &close_btn}, {
1568 &_AS_BUTTON_MAXIMIZE, &_AS_BUTTON_MAXIMIZE_PRESSED, F_MAXIMIZE,
1569 &maximize_btn}, {
1570 &_AS_BUTTON_MINIMIZE, &_AS_BUTTON_MINIMIZE_PRESSED, F_ICONIFY,
1571 &minimize_btn}, {
1572 &_AS_BUTTON_SHADE, &_AS_BUTTON_SHADE_PRESSED, F_SHADE, &shade_btn}, {
1573 &_AS_BUTTON_MENU, &_AS_BUTTON_MENU_PRESSED, F_POPUP, &menu_btn}, {
1574 0, 0, 0, NULL}};
1575
1576
1577 memset (&props, 0x00, sizeof (props));
1578 if (get_flags (frame->set_title_attr, MYFRAME_TitleAlignSet)) {
1579 props.align = frame->title_align;
1580 #if (NO_ALIGN==0)
1581 if (props.align == 0)
1582 props.align = ~ALIGN_MASK;
1583 #endif
1584 }
1585 if (get_flags
1586 (frame->set_title_attr,
1587 MYFRAME_TitleFBevelSet | MYFRAME_TitleUBevelSet)) {
1588 props.bevel = frame->title_fbevel | frame->title_ubevel;
1589 #if (NO_HILITE==0)
1590 if (props.bevel == 0)
1591 props.bevel = ~HILITE_MASK;
1592 #endif
1593 }
1594 props.title_h_spacing = frame->title_h_spacing;
1595 props.title_v_spacing = frame->title_v_spacing;
1596 props.buttons_h_border =
1597 max (Scr.Look.TitleButtonXOffset[0], Scr.Look.TitleButtonXOffset[1]);
1598 props.buttons_v_border =
1599 max (Scr.Look.TitleButtonYOffset[0], Scr.Look.TitleButtonYOffset[1]);
1600 props.buttons_spacing =
1601 max (Scr.Look.TitleButtonSpacing[0], Scr.Look.TitleButtonSpacing[1]);
1602
1603 for (btn = Scr.Feel.MouseButtonRoot; btn != NULL; btn = btn->NextButton)
1604 if ((btn->Context & C_TButtonAll)) {
1605 for (i = 0; buttons[i].pbtn != NULL; ++i) {
1606 if (btn->fdata->func == buttons[i].func && *(buttons[i].pbtn) == NULL) { /* now lets find that button in look : */
1607 for (k = 0; k < TITLE_BUTTONS; ++k)
1608 if (Scr.Look.buttons[k].unpressed.image != NULL &&
1609 (btn->Context & Scr.Look.buttons[k].context) != 0) {
1610 *(buttons[i].pbtn) = &(Scr.Look.buttons[k]);
1611 break;
1612 }
1613 break;
1614 }
1615 }
1616 }
1617 props.buttons_num = 0;
1618 for (i = 0; buttons[i].pbtn != NULL; ++i) {
1619 MyButton *b = *(buttons[i].pbtn);
1620 if (b) {
1621 ++props.buttons_num;
1622 if (b->pressed.image != NULL
1623 && b->pressed.image != b->unpressed.image)
1624 ++props.buttons_num;
1625 }
1626 }
1627 props.buttons =
1628 safemalloc (props.buttons_num * sizeof (struct ASButtonPropElem));
1629 k = 0;
1630 for (i = 0; buttons[i].pbtn != NULL; ++i) {
1631 MyButton *b = *(buttons[i].pbtn);
1632 if (b) {
1633 MyIcon *icon = &(b->unpressed);
1634 if (icon->pix == None)
1635 make_icon_pixmaps (icon, False);
1636
1637 props.buttons[k].kind = *(buttons[i].kind);
1638 props.buttons[k].pmap = icon->pix;
1639 props.buttons[k].mask = icon->mask;
1640 props.buttons[k].alpha = icon->alpha;
1641 ++k;
1642 if (b->pressed.image && b->pressed.image != b->unpressed.image) {
1643 icon = &(b->pressed);
1644 if (icon->pix == None)
1645 make_icon_pixmaps (icon, False);
1646 props.buttons[k].kind = *(buttons[i].kind_down);
1647 props.buttons[k].pmap = icon->pix;
1648 props.buttons[k].mask = icon->mask;
1649 props.buttons[k].alpha = icon->alpha;
1650 ++k;
1651 }
1652 }
1653 }
1654
1655 set_astbar_props (Scr.wmprops, &props);
1656 free (props.buttons);
1657 }
1658
1659
1660 /*************************************************************************/
1661 /* reading confiug files now : */
1662 /*************************************************************************/
ParseConfigFile(const char * file,char ** tline)1663 int ParseConfigFile (const char *file, char **tline)
1664 {
1665 FILE *fp = NULL;
1666 register char *ptr;
1667
1668 /* memory management for parsing buffer */
1669 if (file == NULL)
1670 return -1;
1671
1672 /* this should not happen, but still checking */
1673 if ((fp = fopen (file, "r")) == (FILE *) NULL) {
1674 show_error
1675 ("can't open config file [%s] - skipping it for now.\nMost likely you have incorrect permissions on the AfterStep configuration dir.",
1676 file);
1677 return -1;
1678 }
1679
1680 if (*tline == NULL)
1681 *tline = safemalloc (MAXLINELENGTH + 1);
1682
1683 curr_conf_file = (char *)file;
1684 curr_conf_line = 0;
1685 while (fgets (*tline, MAXLINELENGTH, fp)) {
1686 curr_conf_line++;
1687 /* prventing buffer overflow */
1688 *((*tline) + MAXLINELENGTH) = '\0';
1689 /* remove comments from the line */
1690 ptr = stripcomments (*tline);
1691 /* parsing the line */
1692 orig_tline = ptr;
1693 if (*ptr != '\0' && *ptr != '#')
1694 match_string (main_config, ptr, "error in config:", fp);
1695 }
1696 curr_conf_file = NULL;
1697 fclose (fp);
1698 return 1;
1699 }
1700
1701 /*****************************************************************************
1702 *****************************************************************************
1703 * This routine is responsible for reading and parsing the config file
1704 ****************************************************************************
1705 ****************************************************************************/
1706 /* MakeMenus - for those who can't remember LoadASConfig's real name */
LoadASConfig(int thisdesktop,ASFlagType what)1707 void LoadASConfig (int thisdesktop, ASFlagType what)
1708 {
1709 char *tline = NULL;
1710 ASImageManager *old_image_manager = NULL;
1711 ASFontManager *old_font_manager = NULL;
1712 FunctionData gtkrc_signal_func;
1713 FunctionData kde_signal_func;
1714 ASEvent dummy_event = { 0 };
1715
1716 init_func_data (>krc_signal_func);
1717 gtkrc_signal_func.func = F_SIGNAL_RELOAD_GTK_RCFILE;
1718 init_func_data (&kde_signal_func);
1719 kde_signal_func.func = F_KIPC_SEND_MESSAGE_ALL;
1720 kde_signal_func.func_val[0] = KIPC_PaletteChanged;
1721 kde_signal_func.func_val[1] = 0;
1722
1723 cover_desktop ();
1724
1725 #ifndef DIFFERENTLOOKNFEELFOREACHDESKTOP
1726 /* only one look & feel should be used */
1727 thisdesktop = 0;
1728 #endif /* !DIFFERENTLOOKNFEELFOREACHDESKTOP */
1729
1730 show_progress ("Loading configuration files ...");
1731 display_progress (True, "Loading configuration files ...");
1732 if (Session->overriding_file == NULL) {
1733 char *configfile;
1734 const char *const_configfile;
1735 if (get_flags (what, PARSE_BASE_CONFIG)) {
1736 if (ReloadASEnvironment
1737 (&old_image_manager, &old_font_manager, NULL,
1738 get_flags (what, PARSE_LOOK_CONFIG), True)) {
1739 if (!get_flags (what, PARSE_LOOK_CONFIG)) {
1740 if (old_image_manager != NULL || old_font_manager != NULL) {
1741 InitLook (&Scr.Look, True);
1742 set_flags (what, PARSE_LOOK_CONFIG);
1743 }
1744 } else
1745 clear_flags (what, PARSE_BASE_CONFIG);
1746 }
1747 } else if (get_flags (what, PARSE_LOOK_CONFIG)) { /* must reload Image manager so that changed images would get updated */
1748 reload_screen_image_manager (ASDefaultScr, &old_image_manager);
1749 }
1750
1751 if (get_flags (what, PARSE_LOOK_CONFIG)) {
1752 stop_all_background_xfer ();
1753 LoadColorScheme ();
1754
1755 /* now we can proceed to loading them look and theme */
1756 if ((const_configfile =
1757 get_session_file (Session, thisdesktop, F_CHANGE_LOOK,
1758 False)) != NULL) {
1759 InitLook (&Scr.Look, True);
1760
1761 memset (&TmpLook, 0x00, sizeof (TmpLook));
1762 TmpLook.magic = MAGIC_MYLOOK;
1763 InitLook (&TmpLook, False);
1764
1765 LOCAL_DEBUG_OUT ("desk_anime_tint = %lX",
1766 TmpLook.desktop_animation_tint);
1767 ParseConfigFile (const_configfile, &tline);
1768
1769
1770 LOCAL_DEBUG_OUT ("desk_anime_tint = %lX",
1771 TmpLook.desktop_animation_tint);
1772 show_progress ("LOOK configuration loaded from \"%s\" ...",
1773 const_configfile);
1774 display_progress (True, "LOOK configuration loaded from \"%s\".",
1775 const_configfile);
1776 #ifdef ASETROOT_FILE
1777 if (Scr.Look.desk_configs == NULL) { /* looks like there is no background information in the look file and we should be
1778 getting it from the asetroot file : */
1779
1780 if ((configfile =
1781 make_session_file (Session, ASETROOT_FILE,
1782 False)) != NULL) {
1783 ParseConfigFile (configfile, &tline);
1784 /* Save base filename to pass to modules */
1785 show_progress
1786 ("ROOT BACKGROUND configuration loaded from \"%s\" ...",
1787 configfile);
1788 display_progress (True,
1789 "ROOT BACKGROUND configuration loaded from \"%s\" .",
1790 configfile);
1791 free (configfile);
1792 }
1793 }
1794 #endif
1795 merge_look (&Scr.Look, &TmpLook);
1796 destroy_string (&(BalloonConfig.Style));
1797 destroy_string (&(MenuBalloonConfig.Style));
1798 } else {
1799 show_warning ("LOOK configuration file cannot be found!");
1800 display_progress (True,
1801 "LOOK configuration file cannot be found!");
1802 clear_flags (what, PARSE_LOOK_CONFIG);
1803 }
1804 if (UpdateGtkRC (Environment))
1805 ExecuteFunction (>krc_signal_func, &dummy_event, -1);
1806 if (!get_flags (Environment->flags, ASE_NoKDEGlobalsTheming))
1807 if (UpdateKCSRC ())
1808 ExecuteFunction (&kde_signal_func, &dummy_event, -1);
1809 }
1810 if (get_flags (what, PARSE_FEEL_CONFIG)) {
1811 if ((const_configfile =
1812 get_session_file (Session, thisdesktop, F_CHANGE_FEEL,
1813 False)) != NULL) {
1814 const char *ws_file = get_session_ws_file (Session, True);
1815 memset (&TmpFeel, 0x00, sizeof (TmpFeel));
1816 InitFeel (&TmpFeel, True);
1817 InitFeel (&Scr.Feel, True);
1818 if (tline == NULL)
1819 tline = safemalloc (MAXLINELENGTH + 1);
1820
1821 display_progress (True,
1822 "Reloading and merging desktop categories ...");
1823 ReloadCategories (False);
1824 UpdateCategoriesCache ();
1825
1826 display_progress (True,
1827 "Parsing menu entries and checking availability ...");
1828 MeltStartMenu (tline);
1829 display_progress (False, "Done..");
1830 ParseConfigFile (const_configfile, &tline);
1831 show_progress ("FEEL configuration loaded from \"%s\" ...",
1832 const_configfile);
1833 display_progress (True, "FEEL configuration loaded from \"%s\" .",
1834 const_configfile);
1835 if ((configfile =
1836 make_session_file (Session, AUTOEXEC_FILE, False)) != NULL) {
1837 ParseConfigFile (configfile, &tline);
1838 show_progress ("AUTOEXEC configuration loaded from \"%s\" ...",
1839 configfile);
1840 display_progress (True,
1841 "AUTOEXEC configuration loaded from \"%s\" .",
1842 configfile);
1843 free (configfile);
1844 } else {
1845 show_warning ("AUTOEXEC configuration file cannot be found!");
1846 display_progress (True,
1847 "AUTOEXEC configuration file cannot be found!");
1848 }
1849 if (ws_file != NULL) {
1850 ParseConfigFile (ws_file, &tline);
1851 show_progress
1852 ("WORKSPACE STATE configuration loaded from \"%s\" ...",
1853 ws_file);
1854 display_progress (True,
1855 "WORKSPACE STATE configuration loaded from \"%s\".",
1856 ws_file);
1857 } else {
1858 show_progress ("WORKSPACE STATE file cannot be found!");
1859 display_progress (True, "WORKSPACE STATE file cannot be found!");
1860 }
1861 merge_feel (&Scr.Feel, &TmpFeel);
1862 } else {
1863 show_warning ("FEEL configuration file cannot be found!");
1864 display_progress (True,
1865 "FEEL configuration file cannot be found!");
1866 clear_flags (what, PARSE_FEEL_CONFIG);
1867 }
1868 }
1869 if (get_flags (what, PARSE_DATABASE_CONFIG)) {
1870 if (!ReloadASDatabase ()) {
1871 display_progress (True,
1872 "DATABASE configuration file cannot be found!");
1873 clear_flags (what, PARSE_DATABASE_CONFIG);
1874 } else {
1875 configfile = make_session_file (Session, DATABASE_FILE, False);
1876 display_progress (True,
1877 "DATABASE configuration loaded from \"%s\" .",
1878 configfile);
1879 free (configfile);
1880 }
1881 }
1882 } else {
1883 ReloadASEnvironment (&old_image_manager, &old_font_manager, NULL, True,
1884 True);
1885
1886 LoadColorScheme ();
1887
1888 memset (&TmpLook, 0x00, sizeof (TmpLook));
1889 InitLook (&TmpLook, False);
1890 InitLook (&Scr.Look, True);
1891 memset (&TmpFeel, 0x00, sizeof (TmpFeel));
1892 InitFeel (&TmpFeel, False);
1893 InitFeel (&Scr.Feel, True);
1894 ParseConfigFile (Session->overriding_file, &tline);
1895 merge_look (&Scr.Look, &TmpLook);
1896 merge_feel (&Scr.Feel, &TmpFeel);
1897
1898 ReloadASDatabase ();
1899 show_progress ("AfterStep configuration loaded from \"%s\" ...",
1900 Session->overriding_file);
1901 display_progress (True, "AfterStep configuration loaded from \"%s\".",
1902 Session->overriding_file);
1903 what = PARSE_EVERYTHING;
1904 if (UpdateGtkRC (Environment))
1905 ExecuteFunction (>krc_signal_func, &dummy_event, -1);
1906 if (!get_flags (Environment->flags, ASE_NoKDEGlobalsTheming))
1907 UpdateKCSRC ();
1908 }
1909
1910 /* let's free the memory used for parsing */
1911 if (tline)
1912 free (tline);
1913 show_progress ("Done loading configuration.");
1914 display_progress (True, "Done loading configuration.");
1915
1916 check_desksize_sanity (ASDefaultScr);
1917 set_desktop_geometry_prop (Scr.wmprops, Scr.VxMax + Scr.MyDisplayWidth,
1918 Scr.VyMax + Scr.MyDisplayHeight);
1919
1920 if (get_flags (what, PARSE_FEEL_CONFIG)) {
1921 display_progress (True, "Applying Feel.");
1922 check_feel_sanity (&Scr.Feel);
1923 ApplyFeel (&Scr.Feel);
1924 asxml_var_insert (ASXMLVAR_MenuRecentSubmenuItems,
1925 Scr.Feel.recent_submenu_items);
1926 }
1927
1928 if (get_flags (what, PARSE_LOOK_CONFIG)) {
1929 FixLook (&Scr.Look);
1930
1931 asxml_var_insert (ASXMLVAR_IconButtonWidth, Scr.Look.ButtonWidth);
1932 asxml_var_insert (ASXMLVAR_IconButtonHeight, Scr.Look.ButtonHeight);
1933
1934 asxml_var_insert (ASXMLVAR_MinipixmapWidth, Scr.Look.minipixmap_width);
1935 asxml_var_insert (ASXMLVAR_MinipixmapHeight,
1936 Scr.Look.minipixmap_height);
1937
1938 asxml_var_insert (ASXMLVAR_MenuShowMinipixmaps,
1939 get_flags (Scr.Look.flags, MenuMiniPixmaps) ? 1 : 0);
1940 asxml_var_insert (ASXMLVAR_MenuShowUnavailable,
1941 get_flags (Scr.Look.flags,
1942 MenuShowUnavailable) ? 1 : 0);
1943 asxml_var_insert (ASXMLVAR_MenuTxtItemsInd,
1944 get_flags (Scr.Look.flags, TxtrMenuItmInd) ? 1 : 0);
1945
1946 if (thisdesktop == Scr.CurrentDesk) {
1947 MyBackground *new_back =
1948 get_desk_back_or_default (Scr.CurrentDesk, False);
1949 SendPacket (-1, M_NEW_BACKGROUND, 1, 1);
1950 if (new_back && new_back->loaded_im_name) {
1951 free (new_back->loaded_im_name);
1952 new_back->loaded_im_name = NULL;
1953 }
1954 change_desktop_background (Scr.CurrentDesk);
1955 }
1956 }
1957
1958 if (get_flags (what, PARSE_LOOK_CONFIG | PARSE_FEEL_CONFIG)) {
1959 ReloadConfig (what);
1960 }
1961
1962 if (get_flags
1963 (what, PARSE_BASE_CONFIG | PARSE_LOOK_CONFIG | PARSE_FEEL_CONFIG)) {
1964 int count = 0;
1965 ASHashIterator i;
1966 ARGB32 cursor_fore = ARGB32_White;
1967 ARGB32 cursor_back = ARGB32_Black;
1968
1969 fix_menu_pin_on (&Scr.Look);
1970
1971 /* also need to recolor cursors ! */
1972 if (Scr.Look.CursorFore)
1973 parse_argb_color (Scr.Look.CursorFore, &cursor_fore);
1974 if (Scr.Look.CursorBack)
1975 parse_argb_color (Scr.Look.CursorBack, &cursor_back);
1976 recolor_feel_cursors (&Scr.Feel, cursor_fore, cursor_back);
1977 XDefineCursor (dpy, Scr.Root, Scr.Feel.cursors[ASCUR_Default]);
1978
1979 display_progress (True,
1980 get_flags (Scr.Look.flags,
1981 MenuMiniPixmaps) ?
1982 "Reloading menu pixmaps :" :
1983 "Unloading menu pixmaps :");
1984 if (start_hash_iteration (Scr.Feel.Popups, &i))
1985 do {
1986 MenuData *md = curr_hash_data (&i);
1987 if (!get_flags (Scr.Look.flags, MenuMiniPixmaps))
1988 free_menu_pmaps (md);
1989 else {
1990 char *name = md->name;
1991 Bool newline = (count % 10 == 0);
1992 if (isdigit (name[0]))
1993 if (md->first != NULL && md->first->fdata->func == F_TITLE)
1994 name = md->first->item;
1995 display_progress (newline, newline ? " %s" : "%s", name);
1996 ++count;
1997
1998 reload_menu_pmaps (md, get_flags (what, PARSE_BASE_CONFIG));
1999 }
2000
2001 } while (next_hash_item (&i));
2002
2003 display_progress (True, "Advertising titlebar properties ...");
2004 advertise_tbar_props ();
2005 display_progress (False, "Done.");
2006 }
2007
2008 /* force update of window frames */
2009 if (get_flags
2010 (what,
2011 PARSE_BASE_CONFIG | PARSE_LOOK_CONFIG | PARSE_FEEL_CONFIG |
2012 PARSE_DATABASE_CONFIG)) {
2013 display_progress (True, "Redecorating client windows...");
2014 iterate_asbidirlist (Scr.Windows->clients,
2015 redecorate_aswindow_iter_func, NULL, NULL, False);
2016 display_progress (False, "Done.");
2017 }
2018
2019 if (old_image_manager && old_image_manager != Scr.image_manager) {
2020 display_progress (True, "Unloading old images...");
2021 if (Scr.RootImage && Scr.RootImage->imageman == old_image_manager) {
2022 safe_asimage_destroy (Scr.RootImage);
2023 Scr.RootImage = NULL;
2024 }
2025 destroy_image_manager (old_image_manager, False);
2026 display_progress (False, "Done.");
2027 }
2028 if (old_font_manager && old_font_manager != Scr.font_manager) {
2029 display_progress (True, "Unloading old fonts...");
2030 destroy_font_manager (old_font_manager, False);
2031 display_progress (False, "Done.");
2032 }
2033
2034 ConfigureNotifyLoop ();
2035
2036 remove_desktop_cover ();
2037
2038 validate_rootpmap_props (Scr.wmprops);
2039
2040 LOCAL_DEBUG_OUT ("TmpFeel.flags = 0x%lX, Scr.Feel.flags = 0x%lX",
2041 TmpFeel.flags, Scr.Feel.flags);
2042 }
2043
2044 /*****************************************************************************
2045 * This series of functions do actuall parsing of config options on per-line
2046 * basis :
2047 *****************************************************************************/
2048 /*****************************************************************************
2049 * Copies a text string from the config file to a specified location
2050 ****************************************************************************/
2051
assign_string(char * text,FILE * fd,char ** arg,int * junk)2052 void assign_string (char *text, FILE * fd, char **arg, int *junk)
2053 {
2054 if (*arg)
2055 free (*arg);
2056 *arg = stripcpy2 (text, 0);
2057 }
2058
2059 /*****************************************************************************
2060 *
2061 * Copies a PATH string from the config file to a specified location
2062 *
2063 ****************************************************************************/
2064
assign_themable_path(char * text,FILE * fd,char ** arg,int * junk)2065 void assign_themable_path (char *text, FILE * fd, char **arg, int *junk)
2066 {
2067 char *tmp = stripcpy (text);
2068 int tmp_len;
2069 char *as_theme_data = NULL; /*make_session_dir(Session, ICON_DIR, False); */
2070
2071 replaceEnvVar (&tmp);
2072 if (as_theme_data) {
2073 tmp_len = strlen (tmp);
2074 *arg = safemalloc (tmp_len + 1 + strlen (as_theme_data) + 1);
2075 strcpy (*arg, tmp);
2076 (*arg)[tmp_len] = ':';
2077 strcpy ((*arg) + tmp_len + 1, as_theme_data);
2078 free (tmp);
2079 free (as_theme_data);
2080 } else
2081 *arg = tmp;
2082 }
2083
2084
assign_path(char * text,FILE * fd,char ** arg,int * junk)2085 void assign_path (char *text, FILE * fd, char **arg, int *junk)
2086 {
2087 *arg = stripcpy (text);
2088 replaceEnvVar (arg);
2089 }
2090
assign_geometry(char * text,FILE * fd,char ** arg,int * junk)2091 void assign_geometry (char *text, FILE * fd, char **arg, int *junk)
2092 {
2093 ASGeometry *geom = (ASGeometry *) arg;
2094
2095 geom->x = geom->y = 0;
2096 geom->width = geom->height = 1;
2097 geom->flags = 0;
2098 parse_geometry (text, &(geom->x), &(geom->y), &(geom->width),
2099 &(geom->height), &(geom->flags));
2100 }
2101
2102 /*****************************************************************************
2103 * Loads a pixmap to the assigned location
2104 ****************************************************************************/
assign_pixmap(char * text,FILE * fd,char ** arg,int * junk)2105 void assign_pixmap (char *text, FILE * fd, char **arg, int *junk)
2106 {
2107 char *fname = NULL;
2108 if (parse_filename (text, &fname) != text) {
2109 MyIcon **picon = (MyIcon **) arg;
2110 *picon = safecalloc (1, sizeof (icon_t));
2111 GetIconFromFile (fname, *picon, -1);
2112 free (fname);
2113 }
2114 }
2115
2116 /****************************************************************************
2117 * Read TitleText Controls
2118 ****************************************************************************/
2119
SetTitleText(char * tline,FILE * fd,char ** junk,int * junk2)2120 void SetTitleText (char *tline, FILE * fd, char **junk, int *junk2)
2121 {
2122 int ttype, y;
2123
2124 sscanf (tline, "%d %d", &ttype, &y);
2125 TitleTextType = ttype;
2126 TitleTextY = y;
2127 }
2128
2129 /****************************************************************************
2130 *
2131 * Read Titlebar pixmap button
2132 *
2133 ****************************************************************************/
2134
SetTitleButton(char * tline,FILE * fd,char ** junk,int * junk2)2135 void SetTitleButton (char *tline, FILE * fd, char **junk, int *junk2)
2136 {
2137 int num;
2138 char *files[2] = { NULL, NULL };
2139 int offset = 0;
2140 int n;
2141
2142 if ((n = sscanf (tline, "%d", &num)) <= 0) {
2143 show_error
2144 ("wrong number of parameters given with TitleButton in [%s]",
2145 tline);
2146 return;
2147 }
2148 if (num < 0 || num >= TITLE_BUTTONS) {
2149 show_error ("invalid Titlebar button number: %d", num);
2150 return;
2151 }
2152
2153 /* going the hard way to prevent buffer overruns */
2154 while (isspace (tline[offset]))
2155 offset++;
2156 while (isdigit (tline[offset]))
2157 offset++;
2158 while (isspace (tline[offset]))
2159 offset++;
2160
2161 tline = parse_filename (&(tline[offset]), &(files[0]));
2162 offset = 0;
2163 while (isspace (tline[offset]))
2164 ++offset;
2165 if (tline[offset] != '\0')
2166 parse_filename (&(tline[offset]), &(files[1]));
2167
2168 if (!load_button (&(Scr.Look.buttons[num]), files, Scr.image_manager))
2169 show_error
2170 ("Failed to load image files specified for TitleButton %d [%s]",
2171 num, tline);
2172 if (files[0])
2173 free (files[0]);
2174 if (files[1])
2175 free (files[1]);
2176 }
2177
2178 /*****************************************************************************
2179 *
2180 * Changes a cursor def.
2181 *
2182 ****************************************************************************/
2183
SetCursor(char * text,FILE * fd,char ** arg,int * junk)2184 void SetCursor (char *text, FILE * fd, char **arg, int *junk)
2185 {
2186 int num, cursor_num, cursor_style;
2187
2188 num = sscanf (text, "%d %d", &cursor_num, &cursor_style);
2189 if ((num != 2) || (cursor_num >= MAX_CURSORS) || (cursor_num < 0))
2190 show_warning ("bad Cursor number in [%s]", text);
2191 else {
2192 Cursor new_c = XCreateFontCursor (dpy, cursor_style);
2193 if (new_c) {
2194 if (Scr.Feel.cursors[cursor_num]
2195 && Scr.Feel.cursors[cursor_num] !=
2196 Scr.standard_cursors[cursor_num])
2197 XFreeCursor (dpy, Scr.Feel.cursors[cursor_num]);
2198 Scr.Feel.cursors[cursor_num] = new_c;
2199 LOCAL_DEBUG_OUT ("New X Font cursor %lX created for cursor_num %d",
2200 new_c, cursor_num);
2201 }
2202 }
2203 }
2204
SetCustomCursor(char * text,FILE * fd,char ** arg,int * junk)2205 void SetCustomCursor (char *text, FILE * fd, char **arg, int *junk)
2206 {
2207 int num, cursor_num;
2208 char f_cursor[1024], f_mask[1024];
2209 Pixmap cursor = None, mask = None;
2210 unsigned int width, height;
2211 int x, y;
2212 XColor fore, back;
2213 char *path;
2214 Cursor new_c;
2215
2216 num = sscanf (text, "%d %s %s", &cursor_num, f_cursor, f_mask);
2217 if ((num != 3) || (cursor_num >= MAX_CURSORS) || (cursor_num < 0)) {
2218 show_warning ("bad Cursor number in [%s]", text);
2219 return;
2220 }
2221
2222 path = find_file (f_mask, Environment->cursor_path, R_OK);
2223 if (path) {
2224 XReadBitmapFile (dpy, Scr.Root, path, &width, &height, &mask, &x, &y);
2225 free (path);
2226 } else {
2227 show_warning ("Cursor mask requested in [%s] could not be found",
2228 text);
2229 return;
2230 }
2231
2232 path = find_file (f_cursor, Environment->cursor_path, R_OK);
2233 if (path) {
2234 XReadBitmapFile (dpy, Scr.Root, path, &width, &height, &cursor, &x,
2235 &y);
2236 free (path);
2237 } else {
2238 show_warning ("Cursor bitmap requested in [%s] could not be found",
2239 text);
2240 return;
2241 }
2242
2243 fore.pixel = Scr.asv->black_pixel;
2244 back.pixel = Scr.asv->white_pixel;
2245 XQueryColor (dpy, Scr.asv->colormap, &fore);
2246 XQueryColor (dpy, Scr.asv->colormap, &back);
2247
2248 if (cursor == None || mask == None) {
2249 show_warning
2250 ("Cursor mask or bitmap requested in [%s] could not be loaded",
2251 text);
2252 return;
2253 }
2254
2255 new_c = XCreatePixmapCursor (dpy, cursor, mask, &fore, &back, x, y);
2256 if (new_c) {
2257 if (Scr.Feel.cursors[cursor_num]
2258 && Scr.Feel.cursors[cursor_num] !=
2259 Scr.standard_cursors[cursor_num])
2260 XFreeCursor (dpy, Scr.Feel.cursors[cursor_num]);
2261 Scr.Feel.cursors[cursor_num] = new_c;
2262 LOCAL_DEBUG_OUT ("New Custom X cursor created for cursor_num %d",
2263 cursor_num);
2264 }
2265 XFreePixmap (dpy, mask);
2266 XFreePixmap (dpy, cursor);
2267 ASSync (False);
2268 LOCAL_DEBUG_OUT ("mask %lX and cursor %lX freed", mask, cursor);
2269 }
2270
2271 /*****************************************************************************
2272 *
2273 * Sets a boolean flag to true
2274 *
2275 ****************************************************************************/
2276
SetFlag(char * text,FILE * fd,char ** arg,int * another)2277 void SetFlag (char *text, FILE * fd, char **arg, int *another)
2278 {
2279 Scr.Feel.flags |= (unsigned long)arg;
2280 if (another) {
2281 long i = strtol (text, NULL, 0);
2282 if (i)
2283 Scr.Feel.flags |= (unsigned long)another;
2284 }
2285 }
2286
SetLookFlag(char * text,FILE * fd,char ** arg,int * another)2287 void SetLookFlag (char *text, FILE * fd, char **arg, int *another)
2288 {
2289 unsigned long *flags = (unsigned long *)another;
2290 char *ptr;
2291 int val = strtol (text, &ptr, 0);
2292
2293 if (flags == NULL)
2294 flags = &Scr.Look.flags;
2295 if (ptr != text && val == 0)
2296 *flags &= ~(unsigned long)arg;
2297 else
2298 *flags |= (unsigned long)arg;
2299 }
2300
SetFlag2(char * text,FILE * fd,char ** arg,int * var)2301 void SetFlag2 (char *text, FILE * fd, char **arg, int *var)
2302 {
2303 unsigned long *flags = (unsigned long *)var;
2304 char *ptr;
2305 int val = strtol (text, &ptr, 0);
2306
2307 if (flags == NULL)
2308 flags = &Scr.Feel.flags;
2309 if (ptr != text && val == 0)
2310 *flags &= ~(unsigned long)arg;
2311 else
2312 *flags |= (unsigned long)arg;
2313 }
2314
2315 /*****************************************************************************
2316 *
2317 * Reads in one or two integer values
2318 *
2319 ****************************************************************************/
2320
SetInts(char * text,FILE * fd,char ** arg1,int * arg2)2321 void SetInts (char *text, FILE * fd, char **arg1, int *arg2)
2322 {
2323 if (arg2 == NULL)
2324 sscanf (text, "%d", (int *)arg1);
2325 else
2326 sscanf (text, "%d%*c%d", (int *)arg1, (int *)arg2);
2327 /* LOCAL_DEBUG_OUT( "text=[%s], arg1=%p, Scr.Feel.Autoreverse = %p, res = %d", text, arg1, &(Scr.Feel.AutoReverse), *((int*)arg1) );*/
2328 }
2329
SetInts2(char * text,FILE * fd,char ** arg1,int * arg2)2330 void SetInts2 (char *text, FILE * fd, char **arg1, int *arg2)
2331 {
2332 sscanf (text, "%d", (int *)arg1);
2333 if (arg2)
2334 *arg2 = *(int *)arg1;
2335 /* LOCAL_DEBUG_OUT( "text=[%s], arg1=%p, Scr.Feel.Autoreverse = %p, res = %d", text, arg1, &(Scr.Feel.AutoReverse), *((int*)arg1) );*/
2336 }
2337
2338 /*****************************************************************************
2339 *
2340 * Reads in a list of mouse button numbers
2341 *
2342 ****************************************************************************/
2343
SetButtonList(char * text,FILE * fd,char ** arg1,int * arg2)2344 void SetButtonList (char *text, FILE * fd, char **arg1, int *arg2)
2345 {
2346 int i, b;
2347 char *next;
2348
2349 for (i = 0; i < MAX_MOUSE_BUTTONS; i++) {
2350 b = (int)strtol (text, &next, 0);
2351 if (next == text)
2352 break;
2353 text = next;
2354 if (*text == ',')
2355 text++;
2356 if ((b > 0) && (b <= MAX_MOUSE_BUTTONS))
2357 Scr.Feel.RaiseButtons |= 1 << b;
2358 }
2359 set_flags (Scr.Feel.flags, ClickToRaise);
2360 }
2361
2362
2363 /*****************************************************************************
2364 *
2365 * Reads Dimensions for an icon box from the config file
2366 *
2367 ****************************************************************************/
2368
SetBox(char * text,FILE * fd,char ** arg,int * junk)2369 void SetBox (char *text, FILE * fd, char **arg, int *junk)
2370 {
2371 int x1 = 0, y1 = 0, x2 = Scr.MyDisplayWidth, y2 = Scr.MyDisplayHeight;
2372 int num;
2373
2374 /* not a standard X11 geometry string : */
2375 num = sscanf (text, "%d%d%d%d", &x1, &y1, &x2, &y2);
2376
2377 /* check for negative locations */
2378 if (x1 < 0)
2379 x1 += Scr.MyDisplayWidth;
2380 if (y1 < 0)
2381 y1 += Scr.MyDisplayHeight;
2382
2383 if (x2 < 0)
2384 x2 += Scr.MyDisplayWidth;
2385 if (y2 < 0)
2386 y2 += Scr.MyDisplayHeight;
2387
2388 if (x1 >= x2 || y1 >= y2 ||
2389 x1 < 0 || x1 > Scr.MyDisplayWidth || x2 < 0
2390 || x2 > Scr.MyDisplayWidth || y1 < 0 || y1 > Scr.MyDisplayHeight
2391 || y2 < 0 || y2 > Scr.MyDisplayHeight) {
2392 show_error ("invalid IconBox '%s'", text);
2393 } else {
2394 int box_no = Scr.Look.configured_icon_areas_num;
2395 Scr.Look.configured_icon_areas =
2396 realloc (Scr.Look.configured_icon_areas,
2397 (box_no + 1) * sizeof (ASGeometry));
2398 Scr.Look.configured_icon_areas[box_no].x = x1;
2399 Scr.Look.configured_icon_areas[box_no].y = y1;
2400 Scr.Look.configured_icon_areas[box_no].width = x2 - x1;
2401 Scr.Look.configured_icon_areas[box_no].height = y2 - y1;
2402 Scr.Look.configured_icon_areas[box_no].flags =
2403 XValue | YValue | WidthValue | HeightValue;
2404 if (x1 > Scr.MyDisplayWidth - x2)
2405 Scr.Look.configured_icon_areas[box_no].flags |= XNegative;
2406 if (y1 > Scr.MyDisplayHeight - y2)
2407 Scr.Look.configured_icon_areas[box_no].flags |= YNegative;
2408 ++Scr.Look.configured_icon_areas_num;
2409 }
2410 }
2411
SetFramePart(char * text,FILE * fd,char ** frame,int * id)2412 void SetFramePart (char *text, FILE * fd, char **frame, int *id)
2413 {
2414 char *fname = NULL;
2415 if (parse_filename (text, &fname) != text) {
2416 union {
2417 int *ptr;
2418 int id;
2419 } ptr_id;
2420 ptr_id.ptr = id;
2421 if (LegacyFrameDef == NULL) {
2422 AddMyFrameDefinition (&LegacyFrameDef);
2423 LegacyFrameDef->name = mystrdup ("default");
2424 }
2425 show_warning
2426 ("Frame* definitions are deprecated in look. Please use MyFrame ... ~MyFrame structures instead.%s",
2427 "");
2428 set_string_value (&(LegacyFrameDef->parts[ptr_id.id]), fname,
2429 &(LegacyFrameDef->set_parts), (0x01 << ptr_id.id));
2430 set_flags (LegacyFrameDef->parts_mask, (0x01 << ptr_id.id));
2431 }
2432 }
2433
SetModifier(char * text,FILE * fd,char ** mod,int * junk2)2434 void SetModifier (char *text, FILE * fd, char **mod, int *junk2)
2435 {
2436 int *pmod = (int *)mod;
2437 if (pmod)
2438 *pmod = parse_modifier (text);
2439 }
2440
SetTButtonOrder(char * text,FILE * fd,char ** unused1,int * unused2)2441 void SetTButtonOrder (char *text, FILE * fd, char **unused1, int *unused2)
2442 {
2443 unsigned int *xref = (unsigned int *)&(Scr.Look.button_xref[0]);
2444 unsigned int *rbtn = (unsigned int *)&(Scr.Look.button_first_right);
2445 if (xref && rbtn) {
2446 register int i = 0, btn = 0;
2447 *rbtn = TITLE_BUTTONS;
2448 while (!isspace (text[i]) && text[i] != '\0') {
2449 int context = C_NO_CONTEXT;
2450 switch (text[i]) {
2451 case '0':
2452 context = C_TButton0;
2453 break;
2454 case '1':
2455 context = C_TButton1;
2456 break;
2457 case '2':
2458 context = C_TButton2;
2459 break;
2460 case '3':
2461 context = C_TButton3;
2462 break;
2463 case '4':
2464 context = C_TButton4;
2465 break;
2466 case '5':
2467 context = C_TButton5;
2468 break;
2469 case '6':
2470 context = C_TButton6;
2471 break;
2472 case '7':
2473 context = C_TButton7;
2474 break;
2475 case '8':
2476 context = C_TButton8;
2477 break;
2478 case '9':
2479 context = C_TButton9;
2480 break;
2481 case 'T':
2482 case 't':
2483 context = C_TITLE;
2484 break;
2485 default:
2486 show_warning
2487 ("invalid context specifier '%c' in TitleButtonOrder setting",
2488 text[i]);
2489 }
2490 if (context == C_TITLE) {
2491 *rbtn = btn;
2492 } else if (context != C_NO_CONTEXT) {
2493 xref[btn] = context;
2494
2495 if (++btn >= TITLE_BUTTONS)
2496 break;
2497 }
2498 ++i;
2499 }
2500 while (btn < TITLE_BUTTONS) {
2501 xref[btn] = C_NO_CONTEXT;
2502 ++btn;
2503 }
2504 }
2505 }
2506
2507
2508 /****************************************************************************
2509 *
2510 * These routines put together files from start directory
2511 *
2512 ***************************************************************************/
2513
2514 void dirtree_print_tree (dirtree_t * tree, int depth);
2515
MeltStartMenu(char * buf)2516 int MeltStartMenu (char *buf)
2517 {
2518 char *as_start = NULL;
2519 dirtree_t *tree;
2520
2521 switch (Scr.Look.StartMenuSortMode) {
2522 case SORTBYALPHA:
2523 dirtree_compar_list[0] = dirtree_compar_base_order;
2524 dirtree_compar_list[1] = dirtree_compar_order;
2525 dirtree_compar_list[2] = dirtree_compar_type;
2526 dirtree_compar_list[3] = dirtree_compar_alpha;
2527 dirtree_compar_list[4] = NULL;
2528 break;
2529
2530 case SORTBYDATE:
2531 dirtree_compar_list[0] = dirtree_compar_base_order;
2532 dirtree_compar_list[1] = dirtree_compar_order;
2533 dirtree_compar_list[2] = dirtree_compar_type;
2534 dirtree_compar_list[3] = dirtree_compar_mtime;
2535 dirtree_compar_list[4] = NULL;
2536 break;
2537
2538 default:
2539 dirtree_compar_list[0] = NULL;
2540 break;
2541 }
2542
2543 /*
2544 * Here we test the existence of various
2545 * directories used for the generation.
2546 */
2547
2548 as_start = make_session_dir (Session, START_DIR, False);
2549 tree = dirtree_new_from_dir (as_start);
2550 show_progress ("MENU loaded from \"%s\" ...", as_start);
2551 free (as_start);
2552
2553 #ifdef FIXED_DIR
2554 {
2555 char *as_fixeddir = make_session_dir (Session, FIXED_DIR, False);
2556
2557 if (CheckDir (as_fixeddir) == 0) {
2558 dirtree_t *fixed_tree = dirtree_new_from_dir (as_fixeddir);
2559
2560 free (as_fixeddir);
2561
2562 dirtree_move_children (tree, fixed_tree);
2563 dirtree_delete (fixed_tree);
2564 show_progress ("FIXED MENU loaded from \"%s\" ...", as_fixeddir);
2565 } else
2566 show_error ("unable to locate the fixed menu directory at \"%s\"",
2567 as_fixeddir);
2568 free (as_fixeddir);
2569 }
2570 #endif /* FIXED_DIR */
2571
2572 dirtree_parse_include (tree);
2573 dirtree_remove_order (tree);
2574 dirtree_merge (tree);
2575 dirtree_sort (tree);
2576 /* dirtree_print_tree( tree, 0) ; */
2577 dirtree_set_id (tree, 0);
2578 /* make sure one copy of the root menu uses the name "0" */
2579 (*tree).flags &= ~DIRTREE_KEEPNAME;
2580
2581 dirtree_make_menu2 (tree, buf, True);
2582 /* to keep backward compatibility, make a copy of the root menu with
2583 * the name "start" */
2584 {
2585 if ((*tree).name != NULL)
2586 free ((*tree).name);
2587 (*tree).name = mystrdup ("start");
2588 (*tree).flags |= DIRTREE_KEEPNAME;
2589 dirtree_make_menu2 (tree, buf, False);
2590 }
2591 /* cleaning up cache of the searcher */
2592 is_executable_in_path (NULL);
2593
2594 dirtree_delete (tree);
2595 return 0;
2596 }
2597
deskback_parse(char * text,FILE * fd,char ** junk,int * junk2)2598 void deskback_parse (char *text, FILE * fd, char **junk, int *junk2)
2599 {
2600 register int i = 0;
2601 int desk = atoi (text);
2602 char *data = NULL;
2603 MyDesktopConfig *dc = NULL;
2604
2605 if (!IsValidDesk (desk)) {
2606 show_error ("invalid desktop number in: \"%s\"", text);
2607 return;
2608 }
2609
2610 while (isdigit (text[i]))
2611 ++i;
2612 if (i == 0 || !isspace (text[i])) {
2613 show_error ("missing desktop number in: \"%s\"", text);
2614 return;
2615 }
2616
2617 while (isspace (text[i]))
2618 ++i;
2619 if (text[i] == '#')
2620 return;
2621
2622 data = stripcpy2 (&(text[i]), 0);
2623 if (data == NULL) {
2624 show_error
2625 ("DeskBack option with no name of the relevant MyBackground: \"%s\"",
2626 text);
2627 return;
2628 }
2629 LOCAL_DEBUG_OUT ("desk(%d)->data(\"%s\")->text(%s)", desk, data, text);
2630 dc = create_mydeskconfig (desk, data);
2631 add_deskconfig (&(Scr.Look), dc);
2632 free (data);
2633 }
2634
2635 /****************************************************************************
2636 *
2637 * Matches text from config to a table of strings, calls routine
2638 * indicated in table.
2639 *
2640 ****************************************************************************/
2641
2642 void
match_string(struct config * table,char * text,char * error_msg,FILE * fd)2643 match_string (struct config *table, char *text, char *error_msg, FILE * fd)
2644 {
2645 register int i;
2646 table = find_config (table, text);
2647 if (table != NULL) {
2648 i = strlen (table->keyword);
2649 while (isspace (text[i]))
2650 ++i;
2651 table->action (&(text[i]), fd, table->arg, table->arg2);
2652 } else
2653 tline_error (error_msg);
2654 }
2655
2656 #endif
2657