WPrefs: Cleaned dangerous function prototype usage
[wmaker-crm.git] / src / defaults.c
blob8d2fe225115421ffe3eea843f9e01b0d7e363822
1 /* defaults.c - manage configuration through defaults db
3 * Window Maker window manager
5 * Copyright (c) 1997-2003 Alfredo K. Kojima
6 * Copyright (c) 1998-2003 Dan Pascu
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 #include "wconfig.h"
25 #include <stdio.h>
26 #include <stdint.h>
27 #include <stdlib.h>
28 #include <unistd.h>
29 #include <string.h>
30 #include <strings.h>
31 #include <ctype.h>
32 #include <time.h>
33 #include <sys/types.h>
34 #include <sys/stat.h>
35 #include <fcntl.h>
36 #include <limits.h>
37 #include <signal.h>
39 #ifndef PATH_MAX
40 #define PATH_MAX DEFAULT_PATH_MAX
41 #endif
43 #include <X11/Xlib.h>
44 #include <X11/Xutil.h>
45 #include <X11/keysym.h>
47 #include <wraster.h>
49 #include "WindowMaker.h"
50 #include "framewin.h"
51 #include "window.h"
52 #include "texture.h"
53 #include "screen.h"
54 #include "resources.h"
55 #include "defaults.h"
56 #include "keybind.h"
57 #include "xmodifier.h"
58 #include "icon.h"
59 #include "main.h"
60 #include "actions.h"
61 #include "dock.h"
62 #include "workspace.h"
63 #include "properties.h"
64 #include "misc.h"
66 #define MAX_SHORTCUT_LENGTH 32
68 #ifndef GLOBAL_DEFAULTS_SUBDIR
69 #define GLOBAL_DEFAULTS_SUBDIR "WindowMaker"
70 #endif
72 /***** Global *****/
73 extern WDDomain *WDWindowMaker;
74 extern WDDomain *WDWindowAttributes;
75 extern WDDomain *WDRootMenu;
76 extern int wScreenCount;
77 extern WPreferences wPreferences;
78 extern WShortKey wKeyBindings[WKBD_LAST];
80 typedef struct {
81 char *key;
82 char *default_value;
83 void *extra_data;
84 void *addr;
85 int (*convert) ();
86 int (*update) ();
87 WMPropList *plkey;
88 WMPropList *plvalue; /* default value */
89 } WDefaultEntry;
91 /* used to map strings to integers */
92 typedef struct {
93 char *string;
94 short value;
95 char is_alias;
96 } WOptionEnumeration;
98 /* type converters */
99 static int getBool();
100 static int getInt();
101 static int getCoord();
102 static int getPathList();
103 static int getEnum();
104 static int getTexture();
105 static int getWSBackground();
106 static int getWSSpecificBackground();
107 static int getFont();
108 static int getColor();
109 static int getKeybind();
110 static int getModMask();
111 static int getPropList();
113 /* value setting functions */
114 static int setJustify();
115 static int setClearance();
116 static int setIfDockPresent();
117 static int setClipMergedInDock();
118 static int setWrapAppiconsInDock();
119 static int setStickyIcons();
120 static int setWidgetColor();
121 static int setIconTile();
122 static int setWinTitleFont();
123 static int setMenuTitleFont();
124 static int setMenuTextFont();
125 static int setIconTitleFont();
126 static int setIconTitleColor();
127 static int setIconTitleBack();
128 static int setFrameBorderWidth();
129 static int setFrameBorderColor();
130 static int setFrameSelectedBorderColor();
131 static int setLargeDisplayFont();
132 static int setWTitleColor();
133 static int setFTitleBack();
134 static int setPTitleBack();
135 static int setUTitleBack();
136 static int setResizebarBack();
137 static int setWorkspaceBack();
138 static int setWorkspaceSpecificBack();
139 static int setMenuTitleColor();
140 static int setMenuTextColor();
141 static int setMenuDisabledColor();
142 static int setMenuTitleBack();
143 static int setMenuTextBack();
144 static int setHightlight();
145 static int setHightlightText();
146 static int setKeyGrab();
147 static int setDoubleClick();
148 static int setIconPosition();
150 static int setClipTitleFont();
151 static int setClipTitleColor();
153 static int setMenuStyle();
154 static int setSwPOptions();
155 static int updateUsableArea();
157 static int setModifierKeyLabels();
159 extern Cursor wCursor[WCUR_LAST];
160 static int getCursor();
161 static int setCursor();
164 * Tables to convert strings to enumeration values.
165 * Values stored are char
168 /* WARNING: sum of length of all value strings must not exceed
169 * this value */
170 #define TOTAL_VALUES_LENGTH 80
172 #define REFRESH_WINDOW_TEXTURES (1<<0)
173 #define REFRESH_MENU_TEXTURE (1<<1)
174 #define REFRESH_MENU_FONT (1<<2)
175 #define REFRESH_MENU_COLOR (1<<3)
176 #define REFRESH_MENU_TITLE_TEXTURE (1<<4)
177 #define REFRESH_MENU_TITLE_FONT (1<<5)
178 #define REFRESH_MENU_TITLE_COLOR (1<<6)
179 #define REFRESH_WINDOW_TITLE_COLOR (1<<7)
180 #define REFRESH_WINDOW_FONT (1<<8)
181 #define REFRESH_ICON_TILE (1<<9)
182 #define REFRESH_ICON_FONT (1<<10)
183 #define REFRESH_WORKSPACE_BACK (1<<11)
185 #define REFRESH_BUTTON_IMAGES (1<<12)
187 #define REFRESH_ICON_TITLE_COLOR (1<<13)
188 #define REFRESH_ICON_TITLE_BACK (1<<14)
190 #define REFRESH_WORKSPACE_MENU (1<<15)
192 #define REFRESH_FRAME_BORDER REFRESH_MENU_FONT|REFRESH_WINDOW_FONT
194 static WOptionEnumeration seFocusModes[] = {
195 {"Manual", WKF_CLICK, 0}, {"ClickToFocus", WKF_CLICK, 1},
196 {"Sloppy", WKF_SLOPPY, 0}, {"SemiAuto", WKF_SLOPPY, 1}, {"Auto", WKF_SLOPPY, 1},
197 {NULL, 0, 0}
200 static WOptionEnumeration seTitlebarModes[] = {
201 {"new", TS_NEW, 0}, {"old", TS_OLD, 0},
202 {"next", TS_NEXT, 0}, {NULL, 0, 0}
205 static WOptionEnumeration seColormapModes[] = {
206 {"Manual", WCM_CLICK, 0}, {"ClickToFocus", WCM_CLICK, 1},
207 {"Auto", WCM_POINTER, 0}, {"FocusFollowMouse", WCM_POINTER, 1},
208 {NULL, 0, 0}
211 static WOptionEnumeration sePlacements[] = {
212 {"Auto", WPM_AUTO, 0},
213 {"Smart", WPM_SMART, 0},
214 {"Cascade", WPM_CASCADE, 0},
215 {"Random", WPM_RANDOM, 0},
216 {"Manual", WPM_MANUAL, 0},
217 {"Center", WPM_CENTER, 0},
218 {NULL, 0, 0}
221 static WOptionEnumeration seGeomDisplays[] = {
222 {"None", WDIS_NONE, 0},
223 {"Center", WDIS_CENTER, 0},
224 {"Corner", WDIS_TOPLEFT, 0},
225 {"Floating", WDIS_FRAME_CENTER, 0},
226 {"Line", WDIS_NEW, 0},
227 {NULL, 0, 0}
230 static WOptionEnumeration seSpeeds[] = {
231 {"UltraFast", SPEED_ULTRAFAST, 0},
232 {"Fast", SPEED_FAST, 0},
233 {"Medium", SPEED_MEDIUM, 0},
234 {"Slow", SPEED_SLOW, 0},
235 {"UltraSlow", SPEED_ULTRASLOW, 0},
236 {NULL, 0, 0}
239 static WOptionEnumeration seMouseButtonActions[] = {
240 {"None", WA_NONE, 0},
241 {"SelectWindows", WA_SELECT_WINDOWS, 0},
242 {"OpenApplicationsMenu", WA_OPEN_APPMENU, 0},
243 {"OpenWindowListMenu", WA_OPEN_WINLISTMENU, 0},
244 {NULL, 0, 0}
247 static WOptionEnumeration seMouseWheelActions[] = {
248 {"None", WA_NONE, 0},
249 {"SwitchWorkspaces", WA_SWITCH_WORKSPACES, 0},
250 {NULL, 0, 0}
253 static WOptionEnumeration seIconificationStyles[] = {
254 {"Zoom", WIS_ZOOM, 0},
255 {"Twist", WIS_TWIST, 0},
256 {"Flip", WIS_FLIP, 0},
257 {"None", WIS_NONE, 0},
258 {"random", WIS_RANDOM, 0},
259 {NULL, 0, 0}
262 static WOptionEnumeration seJustifications[] = {
263 {"Left", WTJ_LEFT, 0},
264 {"Center", WTJ_CENTER, 0},
265 {"Right", WTJ_RIGHT, 0},
266 {NULL, 0, 0}
269 static WOptionEnumeration seIconPositions[] = {
270 {"blv", IY_BOTTOM | IY_LEFT | IY_VERT, 0},
271 {"blh", IY_BOTTOM | IY_LEFT | IY_HORIZ, 0},
272 {"brv", IY_BOTTOM | IY_RIGHT | IY_VERT, 0},
273 {"brh", IY_BOTTOM | IY_RIGHT | IY_HORIZ, 0},
274 {"tlv", IY_TOP | IY_LEFT | IY_VERT, 0},
275 {"tlh", IY_TOP | IY_LEFT | IY_HORIZ, 0},
276 {"trv", IY_TOP | IY_RIGHT | IY_VERT, 0},
277 {"trh", IY_TOP | IY_RIGHT | IY_HORIZ, 0},
278 {NULL, 0, 0}
281 static WOptionEnumeration seMenuStyles[] = {
282 {"normal", MS_NORMAL, 0},
283 {"singletexture", MS_SINGLE_TEXTURE, 0},
284 {"flat", MS_FLAT, 0},
285 {NULL, 0, 0}
288 static WOptionEnumeration seDisplayPositions[] = {
289 {"none", WD_NONE, 0},
290 {"center", WD_CENTER, 0},
291 {"top", WD_TOP, 0},
292 {"bottom", WD_BOTTOM, 0},
293 {"topleft", WD_TOPLEFT, 0},
294 {"topright", WD_TOPRIGHT, 0},
295 {"bottomleft", WD_BOTTOMLEFT, 0},
296 {"bottomright", WD_BOTTOMRIGHT, 0},
297 {NULL, 0, 0}
300 static WOptionEnumeration seWorkspaceBorder[] = {
301 {"None", WB_NONE, 0},
302 {"LeftRight", WB_LEFTRIGHT, 0},
303 {"TopBottom", WB_TOPBOTTOM, 0},
304 {"AllDirections", WB_ALLDIRS, 0},
305 {NULL, 0, 0}
309 * ALL entries in the tables bellow, NEED to have a default value
310 * defined, and this value needs to be correct.
313 /* these options will only affect the window manager on startup
315 * static defaults can't access the screen data, because it is
316 * created after these defaults are read
318 WDefaultEntry staticOptionList[] = {
320 {"ColormapSize", "4", NULL,
321 &wPreferences.cmap_size, getInt, NULL, NULL, NULL},
322 {"DisableDithering", "NO", NULL,
323 &wPreferences.no_dithering, getBool, NULL, NULL, NULL},
324 {"IconSize", "64", NULL,
325 &wPreferences.icon_size, getInt, NULL, NULL, NULL},
326 {"ModifierKey", "Mod1", NULL,
327 &wPreferences.modifier_mask, getModMask, NULL, NULL, NULL},
328 {"DisableWSMouseActions", "NO", NULL,
329 &wPreferences.disable_root_mouse, getBool, NULL, NULL, NULL},
330 {"FocusMode", "manual", seFocusModes, /* have a problem when switching from */
331 &wPreferences.focus_mode, getEnum, NULL, NULL, NULL}, /* manual to sloppy without restart */
332 {"NewStyle", "new", seTitlebarModes,
333 &wPreferences.new_style, getEnum, NULL, NULL, NULL},
334 {"DisableDock", "NO", (void *)WM_DOCK,
335 NULL, getBool, setIfDockPresent, NULL, NULL},
336 {"DisableClip", "NO", (void *)WM_CLIP,
337 NULL, getBool, setIfDockPresent, NULL, NULL},
338 {"DisableDrawers", "NO", (void *)WM_DRAWER,
339 NULL, getBool, setIfDockPresent, NULL, NULL},
340 {"ClipMergedInDock", "NO", NULL,
341 NULL, getBool, setClipMergedInDock, NULL, NULL},
342 {"DisableMiniwindows", "NO", NULL,
343 &wPreferences.disable_miniwindows, getBool, NULL, NULL, NULL}
346 #define NUM2STRING_(x) #x
347 #define NUM2STRING(x) NUM2STRING_(x)
349 WDefaultEntry optionList[] = {
351 /* dynamic options */
353 {"IconPosition", "blh", seIconPositions,
354 &wPreferences.icon_yard, getEnum, setIconPosition, NULL, NULL},
355 {"IconificationStyle", "Zoom", seIconificationStyles,
356 &wPreferences.iconification_style, getEnum, NULL, NULL, NULL},
357 {"MouseLeftButtonAction", "SelectWindows", seMouseButtonActions,
358 &wPreferences.mouse_button1, getEnum, NULL, NULL, NULL},
359 {"MouseMiddleButtonAction", "OpenWindowListMenu", seMouseButtonActions,
360 &wPreferences.mouse_button2, getEnum, NULL, NULL, NULL},
361 {"MouseRightButtonAction", "OpenApplicationsMenu", seMouseButtonActions,
362 &wPreferences.mouse_button3, getEnum, NULL, NULL, NULL},
363 {"MouseWheelAction", "None", seMouseWheelActions,
364 &wPreferences.mouse_wheel, getEnum, NULL, NULL, NULL},
365 {"PixmapPath", DEF_PIXMAP_PATHS, NULL,
366 &wPreferences.pixmap_path, getPathList, NULL, NULL, NULL},
367 {"IconPath", DEF_ICON_PATHS, NULL,
368 &wPreferences.icon_path, getPathList, NULL, NULL, NULL},
369 {"ColormapMode", "auto", seColormapModes,
370 &wPreferences.colormap_mode, getEnum, NULL, NULL, NULL},
371 {"AutoFocus", "NO", NULL,
372 &wPreferences.auto_focus, getBool, NULL, NULL, NULL},
373 {"RaiseDelay", "0", NULL,
374 &wPreferences.raise_delay, getInt, NULL, NULL, NULL},
375 {"CirculateRaise", "NO", NULL,
376 &wPreferences.circ_raise, getBool, NULL, NULL, NULL},
377 {"Superfluous", "NO", NULL,
378 &wPreferences.superfluous, getBool, NULL, NULL, NULL},
379 {"AdvanceToNewWorkspace", "NO", NULL,
380 &wPreferences.ws_advance, getBool, NULL, NULL, NULL},
381 {"CycleWorkspaces", "NO", NULL,
382 &wPreferences.ws_cycle, getBool, NULL, NULL, NULL},
383 {"WorkspaceNameDisplayPosition", "center", seDisplayPositions,
384 &wPreferences.workspace_name_display_position, getEnum, NULL, NULL, NULL},
385 {"WorkspaceBorder", "None", seWorkspaceBorder,
386 &wPreferences.workspace_border_position, getEnum, updateUsableArea, NULL, NULL},
387 {"WorkspaceBorderSize", "0", NULL,
388 &wPreferences.workspace_border_size, getInt, updateUsableArea, NULL, NULL},
389 {"StickyIcons", "NO", NULL,
390 &wPreferences.sticky_icons, getBool, setStickyIcons, NULL, NULL},
391 {"SaveSessionOnExit", "NO", NULL,
392 &wPreferences.save_session_on_exit, getBool, NULL, NULL, NULL},
393 {"WrapMenus", "NO", NULL,
394 &wPreferences.wrap_menus, getBool, NULL, NULL, NULL},
395 {"ScrollableMenus", "NO", NULL,
396 &wPreferences.scrollable_menus, getBool, NULL, NULL, NULL},
397 {"MenuScrollSpeed", "medium", seSpeeds,
398 &wPreferences.menu_scroll_speed, getEnum, NULL, NULL, NULL},
399 {"IconSlideSpeed", "medium", seSpeeds,
400 &wPreferences.icon_slide_speed, getEnum, NULL, NULL, NULL},
401 {"ShadeSpeed", "medium", seSpeeds,
402 &wPreferences.shade_speed, getEnum, NULL, NULL, NULL},
403 {"BounceAppIconsWhenUrgent", "YES", NULL,
404 &wPreferences.bounce_appicons_when_urgent, getBool, NULL, NULL, NULL},
405 {"RaiseAppIconsWhenBouncing", "NO", NULL,
406 &wPreferences.raise_appicons_when_bouncing, getBool, NULL, NULL, NULL},
407 {"DoNotMakeAppIconsBounce", "NO", NULL,
408 &wPreferences.do_not_make_appicons_bounce, getBool, NULL, NULL, NULL},
409 {"DoubleClickTime", "250", (void *)&wPreferences.dblclick_time,
410 &wPreferences.dblclick_time, getInt, setDoubleClick, NULL, NULL},
411 {"ClipAutoraiseDelay", "600", NULL,
412 &wPreferences.clip_auto_raise_delay, getInt, NULL, NULL, NULL},
413 {"ClipAutolowerDelay", "1000", NULL,
414 &wPreferences.clip_auto_lower_delay, getInt, NULL, NULL, NULL},
415 {"ClipAutoexpandDelay", "600", NULL,
416 &wPreferences.clip_auto_expand_delay, getInt, NULL, NULL, NULL},
417 {"ClipAutocollapseDelay", "1000", NULL,
418 &wPreferences.clip_auto_collapse_delay, getInt, NULL, NULL, NULL},
419 {"WrapAppiconsInDock", "YES", NULL,
420 NULL, getBool, setWrapAppiconsInDock, NULL, NULL},
421 {"AlignSubmenus", "NO", NULL,
422 &wPreferences.align_menus, getBool, NULL, NULL, NULL},
423 {"ViKeyMenus", "NO", NULL,
424 &wPreferences.vi_key_menus, getBool, NULL, NULL, NULL},
425 {"OpenTransientOnOwnerWorkspace", "NO", NULL,
426 &wPreferences.open_transients_with_parent, getBool, NULL, NULL, NULL},
427 {"WindowPlacement", "auto", sePlacements,
428 &wPreferences.window_placement, getEnum, NULL, NULL, NULL},
429 {"IgnoreFocusClick", "NO", NULL,
430 &wPreferences.ignore_focus_click, getBool, NULL, NULL, NULL},
431 {"UseSaveUnders", "NO", NULL,
432 &wPreferences.use_saveunders, getBool, NULL, NULL, NULL},
433 {"OpaqueMove", "NO", NULL,
434 &wPreferences.opaque_move, getBool, NULL, NULL, NULL},
435 {"OpaqueResize", "NO", NULL,
436 &wPreferences.opaque_resize, getBool, NULL, NULL, NULL},
437 {"OpaqueMoveResizeKeyboard", "NO", NULL,
438 &wPreferences.opaque_move_resize_keyboard, getBool, NULL, NULL, NULL},
439 {"DisableAnimations", "NO", NULL,
440 &wPreferences.no_animations, getBool, NULL, NULL, NULL},
441 {"DontLinkWorkspaces", "NO", NULL,
442 &wPreferences.no_autowrap, getBool, NULL, NULL, NULL},
443 {"HighlightActiveApp", "YES", NULL,
444 &wPreferences.highlight_active_app, getBool, NULL, NULL, NULL},
445 {"AutoArrangeIcons", "NO", NULL,
446 &wPreferences.auto_arrange_icons, getBool, NULL, NULL, NULL},
447 {"NoWindowOverDock", "NO", NULL,
448 &wPreferences.no_window_over_dock, getBool, updateUsableArea, NULL, NULL},
449 {"NoWindowOverIcons", "NO", NULL,
450 &wPreferences.no_window_over_icons, getBool, updateUsableArea, NULL, NULL},
451 {"WindowPlaceOrigin", "(0, 0)", NULL,
452 &wPreferences.window_place_origin, getCoord, NULL, NULL, NULL},
453 {"ResizeDisplay", "corner", seGeomDisplays,
454 &wPreferences.size_display, getEnum, NULL, NULL, NULL},
455 {"MoveDisplay", "corner", seGeomDisplays,
456 &wPreferences.move_display, getEnum, NULL, NULL, NULL},
457 {"DontConfirmKill", "NO", NULL,
458 &wPreferences.dont_confirm_kill, getBool, NULL, NULL, NULL},
459 {"WindowTitleBalloons", "NO", NULL,
460 &wPreferences.window_balloon, getBool, NULL, NULL, NULL},
461 {"MiniwindowTitleBalloons", "NO", NULL,
462 &wPreferences.miniwin_balloon, getBool, NULL, NULL, NULL},
463 {"AppIconBalloons", "NO", NULL,
464 &wPreferences.appicon_balloon, getBool, NULL, NULL, NULL},
465 {"HelpBalloons", "NO", NULL,
466 &wPreferences.help_balloon, getBool, NULL, NULL, NULL},
467 {"EdgeResistance", "30", NULL,
468 &wPreferences.edge_resistance, getInt, NULL, NULL, NULL},
469 {"ResizeIncrement", "0", NULL,
470 &wPreferences.resize_increment, getInt, NULL, NULL, NULL},
471 {"Attraction", "NO", NULL,
472 &wPreferences.attract, getBool, NULL, NULL, NULL},
473 {"DisableBlinking", "NO", NULL,
474 &wPreferences.dont_blink, getBool, NULL, NULL, NULL},
475 {"SingleClickLaunch", "NO", NULL,
476 &wPreferences.single_click, getBool, NULL, NULL, NULL},
477 {"StrictWindozeCycle", "YES", NULL,
478 &wPreferences.strict_windoze_cycle, getBool, NULL, NULL, NULL},
480 /* style options */
482 {"MenuStyle", "normal", seMenuStyles,
483 &wPreferences.menu_style, getEnum, setMenuStyle, NULL, NULL},
484 {"WidgetColor", "(solid, gray)", NULL,
485 NULL, getTexture, setWidgetColor, NULL, NULL},
486 {"WorkspaceSpecificBack", "()", NULL,
487 NULL, getWSSpecificBackground, setWorkspaceSpecificBack, NULL, NULL},
488 /* WorkspaceBack must come after WorkspaceSpecificBack or
489 * WorkspaceBack wont know WorkspaceSpecificBack was also
490 * specified and 2 copies of wmsetbg will be launched */
491 {"WorkspaceBack", "(solid, black)", NULL,
492 NULL, getWSBackground, setWorkspaceBack, NULL, NULL},
493 {"SmoothWorkspaceBack", "NO", NULL,
494 NULL, getBool, NULL, NULL, NULL},
495 {"IconBack", "(solid, gray)", NULL,
496 NULL, getTexture, setIconTile, NULL, NULL},
497 {"TitleJustify", "center", seJustifications,
498 &wPreferences.title_justification, getEnum, setJustify, NULL, NULL},
499 {"WindowTitleFont", DEF_TITLE_FONT, NULL,
500 NULL, getFont, setWinTitleFont, NULL, NULL},
501 {"WindowTitleExtendSpace", DEF_WINDOW_TITLE_EXTEND_SPACE, NULL,
502 &wPreferences.window_title_clearance, getInt, setClearance, NULL, NULL},
503 {"WindowTitleMinHeight", "0", NULL,
504 &wPreferences.window_title_min_height, getInt, setClearance, NULL, NULL},
505 {"WindowTitleMaxHeight", NUM2STRING(INT_MAX), NULL,
506 &wPreferences.window_title_max_height, getInt, setClearance, NULL, NULL},
507 {"MenuTitleExtendSpace", DEF_MENU_TITLE_EXTEND_SPACE, NULL,
508 &wPreferences.menu_title_clearance, getInt, setClearance, NULL, NULL},
509 {"MenuTitleMinHeight", "0", NULL,
510 &wPreferences.menu_title_min_height, getInt, setClearance, NULL, NULL},
511 {"MenuTitleMaxHeight", NUM2STRING(INT_MAX), NULL,
512 &wPreferences.menu_title_max_height, getInt, setClearance, NULL, NULL},
513 {"MenuTextExtendSpace", DEF_MENU_TEXT_EXTEND_SPACE, NULL,
514 &wPreferences.menu_text_clearance, getInt, setClearance, NULL, NULL},
515 {"MenuTitleFont", DEF_MENU_TITLE_FONT, NULL,
516 NULL, getFont, setMenuTitleFont, NULL, NULL},
517 {"MenuTextFont", DEF_MENU_ENTRY_FONT, NULL,
518 NULL, getFont, setMenuTextFont, NULL, NULL},
519 {"IconTitleFont", DEF_ICON_TITLE_FONT, NULL,
520 NULL, getFont, setIconTitleFont, NULL, NULL},
521 {"ClipTitleFont", DEF_CLIP_TITLE_FONT, NULL,
522 NULL, getFont, setClipTitleFont, NULL, NULL},
523 {"ShowClipTitle", "YES", NULL,
524 &wPreferences.show_clip_title, getBool, NULL, NULL, NULL},
525 {"LargeDisplayFont", DEF_WORKSPACE_NAME_FONT, NULL,
526 NULL, getFont, setLargeDisplayFont, NULL, NULL},
527 {"HighlightColor", "white", NULL,
528 NULL, getColor, setHightlight, NULL, NULL},
529 {"HighlightTextColor", "black", NULL,
530 NULL, getColor, setHightlightText, NULL, NULL},
531 {"ClipTitleColor", "black", (void *)CLIP_NORMAL,
532 NULL, getColor, setClipTitleColor, NULL, NULL},
533 {"CClipTitleColor", "\"#454045\"", (void *)CLIP_COLLAPSED,
534 NULL, getColor, setClipTitleColor, NULL, NULL},
535 {"FTitleColor", "white", (void *)WS_FOCUSED,
536 NULL, getColor, setWTitleColor, NULL, NULL},
537 {"PTitleColor", "white", (void *)WS_PFOCUSED,
538 NULL, getColor, setWTitleColor, NULL, NULL},
539 {"UTitleColor", "black", (void *)WS_UNFOCUSED,
540 NULL, getColor, setWTitleColor, NULL, NULL},
541 {"FTitleBack", "(solid, black)", NULL,
542 NULL, getTexture, setFTitleBack, NULL, NULL},
543 {"PTitleBack", "(solid, \"#616161\")", NULL,
544 NULL, getTexture, setPTitleBack, NULL, NULL},
545 {"UTitleBack", "(solid, gray)", NULL,
546 NULL, getTexture, setUTitleBack, NULL, NULL},
547 {"ResizebarBack", "(solid, gray)", NULL,
548 NULL, getTexture, setResizebarBack, NULL, NULL},
549 {"MenuTitleColor", "white", NULL,
550 NULL, getColor, setMenuTitleColor, NULL, NULL},
551 {"MenuTextColor", "black", NULL,
552 NULL, getColor, setMenuTextColor, NULL, NULL},
553 {"MenuDisabledColor", "\"#616161\"", NULL,
554 NULL, getColor, setMenuDisabledColor, NULL, NULL},
555 {"MenuTitleBack", "(solid, black)", NULL,
556 NULL, getTexture, setMenuTitleBack, NULL, NULL},
557 {"MenuTextBack", "(solid, gray)", NULL,
558 NULL, getTexture, setMenuTextBack, NULL, NULL},
559 {"IconTitleColor", "white", NULL,
560 NULL, getColor, setIconTitleColor, NULL, NULL},
561 {"IconTitleBack", "black", NULL,
562 NULL, getColor, setIconTitleBack, NULL, NULL},
563 {"SwitchPanelImages", "(swtile.png, swback.png, 30, 40)", &wPreferences,
564 NULL, getPropList, setSwPOptions, NULL, NULL},
565 {"ModifierKeyLabels", "(\"Shift+\", \"Ctrl+\", \"Mod1+\", \"Mod2+\", \"Mod3+\", \"Mod4+\", \"Mod5+\")", &wPreferences,
566 NULL, getPropList, setModifierKeyLabels, NULL, NULL},
567 {"FrameBorderWidth", "1", NULL,
568 NULL, getInt, setFrameBorderWidth, NULL, NULL},
569 {"FrameBorderColor", "black", NULL,
570 NULL, getColor, setFrameBorderColor, NULL, NULL},
571 {"FrameSelectedBorderColor", "white", NULL,
572 NULL, getColor, setFrameSelectedBorderColor, NULL, NULL},
574 /* keybindings */
576 {"RootMenuKey", "None", (void *)WKBD_ROOTMENU,
577 NULL, getKeybind, setKeyGrab, NULL, NULL},
578 {"WindowListKey", "None", (void *)WKBD_WINDOWLIST,
579 NULL, getKeybind, setKeyGrab, NULL, NULL},
580 {"WindowMenuKey", "None", (void *)WKBD_WINDOWMENU,
581 NULL, getKeybind, setKeyGrab, NULL, NULL},
582 {"DockRaiseLowerKey", "None", (void*)WKBD_DOCKRAISELOWER,
583 NULL, getKeybind, setKeyGrab, NULL, NULL},
584 {"ClipRaiseLowerKey", "None", (void *)WKBD_CLIPRAISELOWER,
585 NULL, getKeybind, setKeyGrab, NULL, NULL},
586 {"MiniaturizeKey", "None", (void *)WKBD_MINIATURIZE,
587 NULL, getKeybind, setKeyGrab, NULL, NULL},
588 {"MinimizeAllKey", "None", (void *)WKBD_MINIMIZEALL,
589 NULL, getKeybind, setKeyGrab, NULL, NULL },
590 {"HideKey", "None", (void *)WKBD_HIDE,
591 NULL, getKeybind, setKeyGrab, NULL, NULL},
592 {"HideOthersKey", "None", (void *)WKBD_HIDE_OTHERS,
593 NULL, getKeybind, setKeyGrab, NULL, NULL},
594 {"MoveResizeKey", "None", (void *)WKBD_MOVERESIZE,
595 NULL, getKeybind, setKeyGrab, NULL, NULL},
596 {"CloseKey", "None", (void *)WKBD_CLOSE,
597 NULL, getKeybind, setKeyGrab, NULL, NULL},
598 {"MaximizeKey", "None", (void *)WKBD_MAXIMIZE,
599 NULL, getKeybind, setKeyGrab, NULL, NULL},
600 {"VMaximizeKey", "None", (void *)WKBD_VMAXIMIZE,
601 NULL, getKeybind, setKeyGrab, NULL, NULL},
602 {"HMaximizeKey", "None", (void *)WKBD_HMAXIMIZE,
603 NULL, getKeybind, setKeyGrab, NULL, NULL},
604 {"LHMaximizeKey", "None", (void*)WKBD_LHMAXIMIZE,
605 NULL, getKeybind, setKeyGrab, NULL, NULL},
606 {"RHMaximizeKey", "None", (void*)WKBD_RHMAXIMIZE,
607 NULL, getKeybind, setKeyGrab, NULL, NULL},
608 {"MaximusKey", "None", (void*)WKBD_MAXIMUS,
609 NULL, getKeybind, setKeyGrab, NULL, NULL},
610 {"RaiseKey", "\"Meta+Up\"", (void *)WKBD_RAISE,
611 NULL, getKeybind, setKeyGrab, NULL, NULL},
612 {"LowerKey", "\"Meta+Down\"", (void *)WKBD_LOWER,
613 NULL, getKeybind, setKeyGrab, NULL, NULL},
614 {"RaiseLowerKey", "None", (void *)WKBD_RAISELOWER,
615 NULL, getKeybind, setKeyGrab, NULL, NULL},
616 {"ShadeKey", "None", (void *)WKBD_SHADE,
617 NULL, getKeybind, setKeyGrab, NULL, NULL},
618 {"SelectKey", "None", (void *)WKBD_SELECT,
619 NULL, getKeybind, setKeyGrab, NULL, NULL},
620 {"FocusNextKey", "None", (void *)WKBD_FOCUSNEXT,
621 NULL, getKeybind, setKeyGrab, NULL, NULL},
622 {"FocusPrevKey", "None", (void *)WKBD_FOCUSPREV,
623 NULL, getKeybind, setKeyGrab, NULL, NULL},
624 {"GroupNextKey", "None", (void *)WKBD_GROUPNEXT,
625 NULL, getKeybind, setKeyGrab, NULL, NULL},
626 {"GroupPrevKey", "None", (void *)WKBD_GROUPPREV,
627 NULL, getKeybind, setKeyGrab, NULL, NULL},
628 {"NextWorkspaceKey", "None", (void *)WKBD_NEXTWORKSPACE,
629 NULL, getKeybind, setKeyGrab, NULL, NULL},
630 {"PrevWorkspaceKey", "None", (void *)WKBD_PREVWORKSPACE,
631 NULL, getKeybind, setKeyGrab, NULL, NULL},
632 {"LastWorkspaceKey", "None", (void *)WKBD_LASTWORKSPACE,
633 NULL, getKeybind, setKeyGrab, NULL, NULL},
634 {"NextWorkspaceLayerKey", "None", (void *)WKBD_NEXTWSLAYER,
635 NULL, getKeybind, setKeyGrab, NULL, NULL},
636 {"PrevWorkspaceLayerKey", "None", (void *)WKBD_PREVWSLAYER,
637 NULL, getKeybind, setKeyGrab, NULL, NULL},
638 {"Workspace1Key", "None", (void *)WKBD_WORKSPACE1,
639 NULL, getKeybind, setKeyGrab, NULL, NULL},
640 {"Workspace2Key", "None", (void *)WKBD_WORKSPACE2,
641 NULL, getKeybind, setKeyGrab, NULL, NULL},
642 {"Workspace3Key", "None", (void *)WKBD_WORKSPACE3,
643 NULL, getKeybind, setKeyGrab, NULL, NULL},
644 {"Workspace4Key", "None", (void *)WKBD_WORKSPACE4,
645 NULL, getKeybind, setKeyGrab, NULL, NULL},
646 {"Workspace5Key", "None", (void *)WKBD_WORKSPACE5,
647 NULL, getKeybind, setKeyGrab, NULL, NULL},
648 {"Workspace6Key", "None", (void *)WKBD_WORKSPACE6,
649 NULL, getKeybind, setKeyGrab, NULL, NULL},
650 {"Workspace7Key", "None", (void *)WKBD_WORKSPACE7,
651 NULL, getKeybind, setKeyGrab, NULL, NULL},
652 {"Workspace8Key", "None", (void *)WKBD_WORKSPACE8,
653 NULL, getKeybind, setKeyGrab, NULL, NULL},
654 {"Workspace9Key", "None", (void *)WKBD_WORKSPACE9,
655 NULL, getKeybind, setKeyGrab, NULL, NULL},
656 {"Workspace10Key", "None", (void *)WKBD_WORKSPACE10,
657 NULL, getKeybind, setKeyGrab, NULL, NULL},
658 {"MoveToWorkspace1Key", "None", (void *)WKBD_MOVE_WORKSPACE1,
659 NULL, getKeybind, setKeyGrab, NULL, NULL},
660 {"MoveToWorkspace2Key", "None", (void *)WKBD_MOVE_WORKSPACE2,
661 NULL, getKeybind, setKeyGrab, NULL, NULL},
662 {"MoveToWorkspace3Key", "None", (void *)WKBD_MOVE_WORKSPACE3,
663 NULL, getKeybind, setKeyGrab, NULL, NULL},
664 {"MoveToWorkspace4Key", "None", (void *)WKBD_MOVE_WORKSPACE4,
665 NULL, getKeybind, setKeyGrab, NULL, NULL},
666 {"MoveToWorkspace5Key", "None", (void *)WKBD_MOVE_WORKSPACE5,
667 NULL, getKeybind, setKeyGrab, NULL, NULL},
668 {"MoveToWorkspace6Key", "None", (void *)WKBD_MOVE_WORKSPACE6,
669 NULL, getKeybind, setKeyGrab, NULL, NULL},
670 {"MoveToWorkspace7Key", "None", (void *)WKBD_MOVE_WORKSPACE7,
671 NULL, getKeybind, setKeyGrab, NULL, NULL},
672 {"MoveToWorkspace8Key", "None", (void *)WKBD_MOVE_WORKSPACE8,
673 NULL, getKeybind, setKeyGrab, NULL, NULL},
674 {"MoveToWorkspace9Key", "None", (void *)WKBD_MOVE_WORKSPACE9,
675 NULL, getKeybind, setKeyGrab, NULL, NULL},
676 {"MoveToWorkspace10Key", "None", (void *)WKBD_MOVE_WORKSPACE10,
677 NULL, getKeybind, setKeyGrab, NULL, NULL},
678 {"MoveToNextWorkspaceKey", "None", (void *)WKBD_MOVE_NEXTWORKSPACE,
679 NULL, getKeybind, setKeyGrab, NULL, NULL},
680 {"MoveToPrevWorkspaceKey", "None", (void *)WKBD_MOVE_PREVWORKSPACE,
681 NULL, getKeybind, setKeyGrab, NULL, NULL},
682 {"MoveToLastWorkspaceKey", "None", (void *)WKBD_MOVE_LASTWORKSPACE,
683 NULL, getKeybind, setKeyGrab, NULL, NULL},
684 {"MoveToNextWorkspaceLayerKey", "None", (void *)WKBD_MOVE_NEXTWSLAYER,
685 NULL, getKeybind, setKeyGrab, NULL, NULL},
686 {"MoveToPrevWorkspaceLayerKey", "None", (void *)WKBD_MOVE_PREVWSLAYER,
687 NULL, getKeybind, setKeyGrab, NULL, NULL},
688 {"WindowShortcut1Key", "None", (void *)WKBD_WINDOW1,
689 NULL, getKeybind, setKeyGrab, NULL, NULL},
690 {"WindowShortcut2Key", "None", (void *)WKBD_WINDOW2,
691 NULL, getKeybind, setKeyGrab, NULL, NULL},
692 {"WindowShortcut3Key", "None", (void *)WKBD_WINDOW3,
693 NULL, getKeybind, setKeyGrab, NULL, NULL},
694 {"WindowShortcut4Key", "None", (void *)WKBD_WINDOW4,
695 NULL, getKeybind, setKeyGrab, NULL, NULL},
696 {"WindowShortcut5Key", "None", (void *)WKBD_WINDOW5,
697 NULL, getKeybind, setKeyGrab, NULL, NULL},
698 {"WindowShortcut6Key", "None", (void *)WKBD_WINDOW6,
699 NULL, getKeybind, setKeyGrab, NULL, NULL},
700 {"WindowShortcut7Key", "None", (void *)WKBD_WINDOW7,
701 NULL, getKeybind, setKeyGrab, NULL, NULL},
702 {"WindowShortcut8Key", "None", (void *)WKBD_WINDOW8,
703 NULL, getKeybind, setKeyGrab, NULL, NULL},
704 {"WindowShortcut9Key", "None", (void *)WKBD_WINDOW9,
705 NULL, getKeybind, setKeyGrab, NULL, NULL},
706 {"WindowShortcut10Key", "None", (void *)WKBD_WINDOW10,
707 NULL, getKeybind, setKeyGrab, NULL, NULL},
708 {"WindowRelaunchKey", "None", (void *)WKBD_RELAUNCH,
709 NULL, getKeybind, setKeyGrab, NULL, NULL},
710 {"ScreenSwitchKey", "None", (void *)WKBD_SWITCH_SCREEN,
711 NULL, getKeybind, setKeyGrab, NULL, NULL},
713 #ifdef KEEP_XKB_LOCK_STATUS
714 {"ToggleKbdModeKey", "None", (void *)WKBD_TOGGLE,
715 NULL, getKeybind, setKeyGrab, NULL, NULL},
716 {"KbdModeLock", "NO", NULL,
717 &wPreferences.modelock, getBool, NULL, NULL, NULL},
718 #endif /* KEEP_XKB_LOCK_STATUS */
720 {"NormalCursor", "(builtin, left_ptr)", (void *)WCUR_ROOT,
721 NULL, getCursor, setCursor, NULL, NULL},
722 {"ArrowCursor", "(builtin, top_left_arrow)", (void *)WCUR_ARROW,
723 NULL, getCursor, setCursor, NULL, NULL},
724 {"MoveCursor", "(builtin, fleur)", (void *)WCUR_MOVE,
725 NULL, getCursor, setCursor, NULL, NULL},
726 {"ResizeCursor", "(builtin, sizing)", (void *)WCUR_RESIZE,
727 NULL, getCursor, setCursor, NULL, NULL},
728 {"TopLeftResizeCursor", "(builtin, top_left_corner)", (void *)WCUR_TOPLEFTRESIZE,
729 NULL, getCursor, setCursor, NULL, NULL},
730 {"TopRightResizeCursor", "(builtin, top_right_corner)", (void *)WCUR_TOPRIGHTRESIZE,
731 NULL, getCursor, setCursor, NULL, NULL},
732 {"BottomLeftResizeCursor", "(builtin, bottom_left_corner)", (void *)WCUR_BOTTOMLEFTRESIZE,
733 NULL, getCursor, setCursor, NULL, NULL},
734 {"BottomRightResizeCursor", "(builtin, bottom_right_corner)", (void *)WCUR_BOTTOMRIGHTRESIZE,
735 NULL, getCursor, setCursor, NULL, NULL},
736 {"VerticalResizeCursor", "(builtin, sb_v_double_arrow)", (void *)WCUR_VERTICALRESIZE,
737 NULL, getCursor, setCursor, NULL, NULL},
738 {"HorizontalResizeCursor", "(builtin, sb_h_double_arrow)", (void *)WCUR_HORIZONRESIZE,
739 NULL, getCursor, setCursor, NULL, NULL},
740 {"WaitCursor", "(builtin, watch)", (void *)WCUR_WAIT,
741 NULL, getCursor, setCursor, NULL, NULL},
742 {"QuestionCursor", "(builtin, question_arrow)", (void *)WCUR_QUESTION,
743 NULL, getCursor, setCursor, NULL, NULL},
744 {"TextCursor", "(builtin, xterm)", (void *)WCUR_TEXT,
745 NULL, getCursor, setCursor, NULL, NULL},
746 {"SelectCursor", "(builtin, cross)", (void *)WCUR_SELECT,
747 NULL, getCursor, setCursor, NULL, NULL},
748 {"DialogHistoryLines", "500", NULL,
749 &wPreferences.history_lines, getInt, NULL, NULL, NULL},
750 {"CycleActiveHeadOnly", "NO", NULL,
751 &wPreferences.cycle_active_head_only, getBool, NULL, NULL, NULL},
752 {"CycleIgnoreMinimized", "NO", NULL,
753 &wPreferences.cycle_ignore_minimized, getBool, NULL, NULL, NULL}
756 static void initDefaults(void)
758 unsigned int i;
759 WDefaultEntry *entry;
761 WMPLSetCaseSensitive(False);
763 for (i = 0; i < sizeof(optionList) / sizeof(optionList[0]); i++) {
764 entry = &optionList[i];
766 entry->plkey = WMCreatePLString(entry->key);
767 if (entry->default_value)
768 entry->plvalue = WMCreatePropListFromDescription(entry->default_value);
769 else
770 entry->plvalue = NULL;
773 for (i = 0; i < sizeof(staticOptionList) / sizeof(staticOptionList[0]); i++) {
774 entry = &staticOptionList[i];
776 entry->plkey = WMCreatePLString(entry->key);
777 if (entry->default_value)
778 entry->plvalue = WMCreatePropListFromDescription(entry->default_value);
779 else
780 entry->plvalue = NULL;
784 static WMPropList *readGlobalDomain(char *domainName, Bool requireDictionary)
786 WMPropList *globalDict = NULL;
787 char path[PATH_MAX];
788 struct stat stbuf;
790 snprintf(path, sizeof(path), "%s/%s/%s", SYSCONFDIR, GLOBAL_DEFAULTS_SUBDIR, domainName);
791 if (stat(path, &stbuf) >= 0) {
792 globalDict = WMReadPropListFromFile(path);
793 if (globalDict && requireDictionary && !WMIsPLDictionary(globalDict)) {
794 wwarning(_("Domain %s (%s) of global defaults database is corrupted!"), domainName, path);
795 WMReleasePropList(globalDict);
796 globalDict = NULL;
797 } else if (!globalDict) {
798 wwarning(_("could not load domain %s from global defaults database"), domainName);
802 return globalDict;
805 #if defined(GLOBAL_PREAMBLE_MENU_FILE) || defined(GLOBAL_EPILOGUE_MENU_FILE)
806 static void prependMenu(WMPropList * destarr, WMPropList * array)
808 WMPropList *item;
809 int i;
811 for (i = 0; i < WMGetPropListItemCount(array); i++) {
812 item = WMGetFromPLArray(array, i);
813 if (item)
814 WMInsertInPLArray(destarr, i + 1, item);
818 static void appendMenu(WMPropList * destarr, WMPropList * array)
820 WMPropList *item;
821 int i;
823 for (i = 0; i < WMGetPropListItemCount(array); i++) {
824 item = WMGetFromPLArray(array, i);
825 if (item)
826 WMAddToPLArray(destarr, item);
829 #endif
831 void wDefaultsMergeGlobalMenus(WDDomain * menuDomain)
833 WMPropList *menu = menuDomain->dictionary;
834 WMPropList *submenu;
836 if (!menu || !WMIsPLArray(menu))
837 return;
839 #ifdef GLOBAL_PREAMBLE_MENU_FILE
840 submenu = WMReadPropListFromFile(SYSCONFDIR "/" GLOBAL_DEFAULTS_SUBDIR "/" GLOBAL_PREAMBLE_MENU_FILE);
842 if (submenu && !WMIsPLArray(submenu)) {
843 wwarning(_("invalid global menu file %s"), GLOBAL_PREAMBLE_MENU_FILE);
844 WMReleasePropList(submenu);
845 submenu = NULL;
847 if (submenu) {
848 prependMenu(menu, submenu);
849 WMReleasePropList(submenu);
851 #endif
853 #ifdef GLOBAL_EPILOGUE_MENU_FILE
854 submenu = WMReadPropListFromFile(SYSCONFDIR "/" GLOBAL_DEFAULTS_SUBDIR "/" GLOBAL_EPILOGUE_MENU_FILE);
856 if (submenu && !WMIsPLArray(submenu)) {
857 wwarning(_("invalid global menu file %s"), GLOBAL_EPILOGUE_MENU_FILE);
858 WMReleasePropList(submenu);
859 submenu = NULL;
861 if (submenu) {
862 appendMenu(menu, submenu);
863 WMReleasePropList(submenu);
865 #endif
867 menuDomain->dictionary = menu;
870 WDDomain *wDefaultsInitDomain(char *domain, Bool requireDictionary)
872 WDDomain *db;
873 struct stat stbuf;
874 static int inited = 0;
875 char *the_path;
876 WMPropList *shared_dict = NULL;
878 if (!inited) {
879 inited = 1;
880 initDefaults();
883 db = wmalloc(sizeof(WDDomain));
884 db->domain_name = domain;
885 db->path = wdefaultspathfordomain(domain);
886 the_path = db->path;
888 if (the_path && stat(the_path, &stbuf) >= 0) {
889 db->dictionary = WMReadPropListFromFile(the_path);
890 if (db->dictionary) {
891 if (requireDictionary && !WMIsPLDictionary(db->dictionary)) {
892 WMReleasePropList(db->dictionary);
893 db->dictionary = NULL;
894 wwarning(_("Domain %s (%s) of defaults database is corrupted!"), domain, the_path);
896 db->timestamp = stbuf.st_mtime;
897 } else {
898 wwarning(_("could not load domain %s from user defaults database"), domain);
902 /* global system dictionary */
903 shared_dict = readGlobalDomain(domain, requireDictionary);
905 if (shared_dict && db->dictionary && WMIsPLDictionary(shared_dict) &&
906 WMIsPLDictionary(db->dictionary)) {
907 WMMergePLDictionaries(shared_dict, db->dictionary, True);
908 WMReleasePropList(db->dictionary);
909 db->dictionary = shared_dict;
910 if (stbuf.st_mtime > db->timestamp)
911 db->timestamp = stbuf.st_mtime;
912 } else if (!db->dictionary) {
913 db->dictionary = shared_dict;
914 if (stbuf.st_mtime > db->timestamp)
915 db->timestamp = stbuf.st_mtime;
918 return db;
921 void wReadStaticDefaults(WMPropList * dict)
923 WMPropList *plvalue;
924 WDefaultEntry *entry;
925 unsigned int i;
926 void *tdata;
928 for (i = 0; i < sizeof(staticOptionList) / sizeof(staticOptionList[0]); i++) {
929 entry = &staticOptionList[i];
931 if (dict)
932 plvalue = WMGetFromPLDictionary(dict, entry->plkey);
933 else
934 plvalue = NULL;
936 /* no default in the DB. Use builtin default */
937 if (!plvalue)
938 plvalue = entry->plvalue;
940 if (plvalue) {
941 /* convert data */
942 (*entry->convert) (NULL, entry, plvalue, entry->addr, &tdata);
943 if (entry->update)
944 (*entry->update) (NULL, entry, tdata, entry->extra_data);
949 void wDefaultsCheckDomains(void* arg)
951 WScreen *scr;
952 struct stat stbuf;
953 WMPropList *shared_dict = NULL;
954 WMPropList *dict;
955 int i;
957 if (stat(WDWindowMaker->path, &stbuf) >= 0 && WDWindowMaker->timestamp < stbuf.st_mtime) {
958 WDWindowMaker->timestamp = stbuf.st_mtime;
960 /* Global dictionary */
961 shared_dict = readGlobalDomain("WindowMaker", True);
963 /* User dictionary */
964 dict = WMReadPropListFromFile(WDWindowMaker->path);
966 if (dict) {
967 if (!WMIsPLDictionary(dict)) {
968 WMReleasePropList(dict);
969 dict = NULL;
970 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
971 "WindowMaker", WDWindowMaker->path);
972 } else {
973 if (shared_dict) {
974 WMMergePLDictionaries(shared_dict, dict, True);
975 WMReleasePropList(dict);
976 dict = shared_dict;
977 shared_dict = NULL;
980 for (i = 0; i < wScreenCount; i++) {
981 scr = wScreenWithNumber(i);
982 if (scr)
983 wReadDefaults(scr, dict);
986 if (WDWindowMaker->dictionary)
987 WMReleasePropList(WDWindowMaker->dictionary);
989 WDWindowMaker->dictionary = dict;
991 } else {
992 wwarning(_("could not load domain %s from user defaults database"), "WindowMaker");
995 if (shared_dict)
996 WMReleasePropList(shared_dict);
1000 if (stat(WDWindowAttributes->path, &stbuf) >= 0 && WDWindowAttributes->timestamp < stbuf.st_mtime) {
1001 /* global dictionary */
1002 shared_dict = readGlobalDomain("WMWindowAttributes", True);
1003 /* user dictionary */
1004 dict = WMReadPropListFromFile(WDWindowAttributes->path);
1005 if (dict) {
1006 if (!WMIsPLDictionary(dict)) {
1007 WMReleasePropList(dict);
1008 dict = NULL;
1009 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
1010 "WMWindowAttributes", WDWindowAttributes->path);
1011 } else {
1012 if (shared_dict) {
1013 WMMergePLDictionaries(shared_dict, dict, True);
1014 WMReleasePropList(dict);
1015 dict = shared_dict;
1016 shared_dict = NULL;
1019 if (WDWindowAttributes->dictionary)
1020 WMReleasePropList(WDWindowAttributes->dictionary);
1022 WDWindowAttributes->dictionary = dict;
1023 for (i = 0; i < wScreenCount; i++) {
1024 scr = wScreenWithNumber(i);
1025 if (scr) {
1026 wDefaultUpdateIcons(scr);
1028 /* Update the panel image if changed */
1029 /* Don't worry. If the image is the same these
1030 * functions will have no performance impact. */
1031 create_logo_image(scr);
1035 } else {
1036 wwarning(_("could not load domain %s from user defaults database"), "WMWindowAttributes");
1039 WDWindowAttributes->timestamp = stbuf.st_mtime;
1040 if (shared_dict)
1041 WMReleasePropList(shared_dict);
1044 if (stat(WDRootMenu->path, &stbuf) >= 0 && WDRootMenu->timestamp < stbuf.st_mtime) {
1045 dict = WMReadPropListFromFile(WDRootMenu->path);
1046 if (dict) {
1047 if (!WMIsPLArray(dict) && !WMIsPLString(dict)) {
1048 WMReleasePropList(dict);
1049 dict = NULL;
1050 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
1051 "WMRootMenu", WDRootMenu->path);
1052 } else {
1053 if (WDRootMenu->dictionary)
1054 WMReleasePropList(WDRootMenu->dictionary);
1056 WDRootMenu->dictionary = dict;
1057 wDefaultsMergeGlobalMenus(WDRootMenu);
1059 } else {
1060 wwarning(_("could not load domain %s from user defaults database"), "WMRootMenu");
1062 WDRootMenu->timestamp = stbuf.st_mtime;
1064 #ifndef HAVE_INOTIFY
1065 if (!arg)
1066 WMAddTimerHandler(DEFAULTS_CHECK_INTERVAL, wDefaultsCheckDomains, arg);
1067 #endif
1070 void wReadDefaults(WScreen * scr, WMPropList * new_dict)
1072 WMPropList *plvalue, *old_value;
1073 WDefaultEntry *entry;
1074 unsigned int i;
1075 int update_workspace_back = 0; /* kluge :/ */
1076 unsigned int needs_refresh;
1077 void *tdata;
1078 WMPropList *old_dict = (WDWindowMaker->dictionary != new_dict ? WDWindowMaker->dictionary : NULL);
1080 needs_refresh = 0;
1082 for (i = 0; i < sizeof(optionList) / sizeof(optionList[0]); i++) {
1083 entry = &optionList[i];
1085 if (new_dict)
1086 plvalue = WMGetFromPLDictionary(new_dict, entry->plkey);
1087 else
1088 plvalue = NULL;
1090 if (!old_dict)
1091 old_value = NULL;
1092 else
1093 old_value = WMGetFromPLDictionary(old_dict, entry->plkey);
1095 if (!plvalue && !old_value) {
1096 /* no default in the DB. Use builtin default */
1097 plvalue = entry->plvalue;
1098 if (plvalue && new_dict)
1099 WMPutInPLDictionary(new_dict, entry->plkey, plvalue);
1101 } else if (!plvalue) {
1102 /* value was deleted from DB. Keep current value */
1103 continue;
1104 } else if (!old_value) {
1105 /* set value for the 1st time */
1106 } else if (!WMIsPropListEqualTo(plvalue, old_value)) {
1107 /* value has changed */
1108 } else {
1109 if (strcmp(entry->key, "WorkspaceBack") == 0
1110 && update_workspace_back && scr->flags.backimage_helper_launched) {
1111 } else {
1112 /* value was not changed since last time */
1113 continue;
1117 if (plvalue) {
1118 /* convert data */
1119 if ((*entry->convert) (scr, entry, plvalue, entry->addr, &tdata)) {
1121 * If the WorkspaceSpecificBack data has been changed
1122 * so that the helper will be launched now, we must be
1123 * sure to send the default background texture config
1124 * to the helper.
1126 if (strcmp(entry->key, "WorkspaceSpecificBack") == 0 &&
1127 !scr->flags.backimage_helper_launched)
1128 update_workspace_back = 1;
1130 if (entry->update)
1131 needs_refresh |= (*entry->update) (scr, entry, tdata, entry->extra_data);
1137 if (needs_refresh != 0 && !scr->flags.startup) {
1138 int foo;
1140 foo = 0;
1141 if (needs_refresh & REFRESH_MENU_TITLE_TEXTURE)
1142 foo |= WTextureSettings;
1143 if (needs_refresh & REFRESH_MENU_TITLE_FONT)
1144 foo |= WFontSettings;
1145 if (needs_refresh & REFRESH_MENU_TITLE_COLOR)
1146 foo |= WColorSettings;
1147 if (foo)
1148 WMPostNotificationName(WNMenuTitleAppearanceSettingsChanged, NULL,
1149 (void *)(uintptr_t) foo);
1151 foo = 0;
1152 if (needs_refresh & REFRESH_MENU_TEXTURE)
1153 foo |= WTextureSettings;
1154 if (needs_refresh & REFRESH_MENU_FONT)
1155 foo |= WFontSettings;
1156 if (needs_refresh & REFRESH_MENU_COLOR)
1157 foo |= WColorSettings;
1158 if (foo)
1159 WMPostNotificationName(WNMenuAppearanceSettingsChanged, NULL, (void *)(uintptr_t) foo);
1161 foo = 0;
1162 if (needs_refresh & REFRESH_WINDOW_FONT)
1163 foo |= WFontSettings;
1164 if (needs_refresh & REFRESH_WINDOW_TEXTURES)
1165 foo |= WTextureSettings;
1166 if (needs_refresh & REFRESH_WINDOW_TITLE_COLOR)
1167 foo |= WColorSettings;
1168 if (foo)
1169 WMPostNotificationName(WNWindowAppearanceSettingsChanged, NULL, (void *)(uintptr_t) foo);
1171 if (!(needs_refresh & REFRESH_ICON_TILE)) {
1172 foo = 0;
1173 if (needs_refresh & REFRESH_ICON_FONT)
1174 foo |= WFontSettings;
1175 if (needs_refresh & REFRESH_ICON_TITLE_COLOR)
1176 foo |= WTextureSettings;
1177 if (needs_refresh & REFRESH_ICON_TITLE_BACK)
1178 foo |= WTextureSettings;
1179 if (foo)
1180 WMPostNotificationName(WNIconAppearanceSettingsChanged, NULL,
1181 (void *)(uintptr_t) foo);
1183 if (needs_refresh & REFRESH_ICON_TILE)
1184 WMPostNotificationName(WNIconTileSettingsChanged, NULL, NULL);
1186 if (needs_refresh & REFRESH_WORKSPACE_MENU) {
1187 if (scr->workspace_menu)
1188 wWorkspaceMenuUpdate(scr, scr->workspace_menu);
1189 if (scr->clip_ws_menu)
1190 wWorkspaceMenuUpdate(scr, scr->clip_ws_menu);
1191 if (scr->workspace_submenu)
1192 scr->workspace_submenu->flags.realized = 0;
1193 if (scr->clip_submenu)
1194 scr->clip_submenu->flags.realized = 0;
1199 void wDefaultUpdateIcons(WScreen *scr)
1201 WAppIcon *aicon = scr->app_icon_list;
1202 WDrawerChain *dc;
1203 WWindow *wwin = scr->focused_window;
1205 while (aicon) {
1206 /* Get the application icon, default included */
1207 wIconChangeImageFile(aicon->icon, NULL);
1208 wAppIconPaint(aicon);
1209 aicon = aicon->next;
1212 if (!wPreferences.flags.noclip || wPreferences.flags.clip_merged_in_dock)
1213 wClipIconPaint(scr->clip_icon);
1215 for (dc = scr->drawers; dc != NULL; dc = dc->next)
1216 wDrawerIconPaint(dc->adrawer->icon_array[0]);
1218 while (wwin) {
1219 if (wwin->icon && wwin->flags.miniaturized)
1220 wIconChangeImageFile(wwin->icon, NULL);
1221 wwin = wwin->prev;
1225 /* --------------------------- Local ----------------------- */
1227 #define GET_STRING_OR_DEFAULT(x, var) if (!WMIsPLString(value)) { \
1228 wwarning(_("Wrong option format for key \"%s\". Should be %s."), \
1229 entry->key, x); \
1230 wwarning(_("using default \"%s\" instead"), entry->default_value); \
1231 var = entry->default_value;\
1232 } else var = WMGetFromPLString(value)\
1235 static int string2index(WMPropList * key, WMPropList * val, char *def, WOptionEnumeration * values)
1237 char *str;
1238 WOptionEnumeration *v;
1239 char buffer[TOTAL_VALUES_LENGTH];
1241 if (WMIsPLString(val) && (str = WMGetFromPLString(val))) {
1242 for (v = values; v->string != NULL; v++) {
1243 if (strcasecmp(v->string, str) == 0)
1244 return v->value;
1248 buffer[0] = 0;
1249 for (v = values; v->string != NULL; v++) {
1250 if (!v->is_alias) {
1251 if (buffer[0] != 0)
1252 strcat(buffer, ", ");
1253 snprintf(buffer+strlen(buffer),
1254 sizeof(buffer)-strlen(buffer)-1, "\"%s\"", v->string);
1257 wwarning(_("wrong option value for key \"%s\"; got \"%s\", should be one of %s."),
1258 WMGetFromPLString(key),
1259 WMIsPLString(val) ? WMGetFromPLString(val) : "(unknown)",
1260 buffer);
1262 if (def) {
1263 return string2index(key, val, NULL, values);
1266 return -1;
1270 * value - is the value in the defaults DB
1271 * addr - is the address to store the data
1272 * ret - is the address to store a pointer to a temporary buffer. ret
1273 * must not be freed and is used by the set functions
1275 static int getBool(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1277 static char data;
1278 char *val;
1279 int second_pass = 0;
1281 GET_STRING_OR_DEFAULT("Boolean", val);
1283 again:
1284 if ((val[1] == '\0' && (val[0] == 'y' || val[0] == 'Y'))
1285 || strcasecmp(val, "YES") == 0) {
1287 data = 1;
1288 } else if ((val[1] == '\0' && (val[0] == 'n' || val[0] == 'N'))
1289 || strcasecmp(val, "NO") == 0) {
1290 data = 0;
1291 } else {
1292 int i;
1293 if (sscanf(val, "%i", &i) == 1) {
1294 if (i != 0)
1295 data = 1;
1296 else
1297 data = 0;
1298 } else {
1299 wwarning(_("can't convert \"%s\" to boolean for key \"%s\""), val, entry->key);
1300 if (second_pass == 0) {
1301 val = WMGetFromPLString(entry->plvalue);
1302 second_pass = 1;
1303 wwarning(_("using default \"%s\" instead"), val);
1304 goto again;
1306 return False;
1310 if (ret)
1311 *ret = &data;
1312 if (addr)
1313 *(char *)addr = data;
1315 return True;
1318 static int getInt(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1320 static int data;
1321 char *val;
1323 GET_STRING_OR_DEFAULT("Integer", val);
1325 if (sscanf(val, "%i", &data) != 1) {
1326 wwarning(_("can't convert \"%s\" to integer for key \"%s\""), val, entry->key);
1327 val = WMGetFromPLString(entry->plvalue);
1328 wwarning(_("using default \"%s\" instead"), val);
1329 if (sscanf(val, "%i", &data) != 1) {
1330 return False;
1334 if (ret)
1335 *ret = &data;
1336 if (addr)
1337 *(int *)addr = data;
1339 return True;
1342 static int getCoord(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1344 static WCoord data;
1345 char *val_x, *val_y;
1346 int nelem, changed = 0;
1347 WMPropList *elem_x, *elem_y;
1349 again:
1350 if (!WMIsPLArray(value)) {
1351 wwarning(_("Wrong option format for key \"%s\". Should be %s."), entry->key, "Coordinate");
1352 if (changed == 0) {
1353 value = entry->plvalue;
1354 changed = 1;
1355 wwarning(_("using default \"%s\" instead"), entry->default_value);
1356 goto again;
1358 return False;
1361 nelem = WMGetPropListItemCount(value);
1362 if (nelem != 2) {
1363 wwarning(_("Incorrect number of elements in array for key \"%s\"."), entry->key);
1364 if (changed == 0) {
1365 value = entry->plvalue;
1366 changed = 1;
1367 wwarning(_("using default \"%s\" instead"), entry->default_value);
1368 goto again;
1370 return False;
1373 elem_x = WMGetFromPLArray(value, 0);
1374 elem_y = WMGetFromPLArray(value, 1);
1376 if (!elem_x || !elem_y || !WMIsPLString(elem_x) || !WMIsPLString(elem_y)) {
1377 wwarning(_("Wrong value for key \"%s\". Should be Coordinate."), entry->key);
1378 if (changed == 0) {
1379 value = entry->plvalue;
1380 changed = 1;
1381 wwarning(_("using default \"%s\" instead"), entry->default_value);
1382 goto again;
1384 return False;
1387 val_x = WMGetFromPLString(elem_x);
1388 val_y = WMGetFromPLString(elem_y);
1390 if (sscanf(val_x, "%i", &data.x) != 1 || sscanf(val_y, "%i", &data.y) != 1) {
1391 wwarning(_("can't convert array to integers for \"%s\"."), entry->key);
1392 if (changed == 0) {
1393 value = entry->plvalue;
1394 changed = 1;
1395 wwarning(_("using default \"%s\" instead"), entry->default_value);
1396 goto again;
1398 return False;
1401 if (data.x < 0)
1402 data.x = 0;
1403 else if (data.x > scr->scr_width / 3)
1404 data.x = scr->scr_width / 3;
1405 if (data.y < 0)
1406 data.y = 0;
1407 else if (data.y > scr->scr_height / 3)
1408 data.y = scr->scr_height / 3;
1410 if (ret)
1411 *ret = &data;
1412 if (addr)
1413 *(WCoord *) addr = data;
1415 return True;
1418 static int getPropList(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1420 WMRetainPropList(value);
1422 *ret = value;
1424 return True;
1427 static int getPathList(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1429 static char *data;
1430 int i, count, len;
1431 char *ptr;
1432 WMPropList *d;
1433 int changed = 0;
1435 again:
1436 if (!WMIsPLArray(value)) {
1437 wwarning(_("Wrong option format for key \"%s\". Should be %s."), entry->key, "an array of paths");
1438 if (changed == 0) {
1439 value = entry->plvalue;
1440 changed = 1;
1441 wwarning(_("using default \"%s\" instead"), entry->default_value);
1442 goto again;
1444 return False;
1447 i = 0;
1448 count = WMGetPropListItemCount(value);
1449 if (count < 1) {
1450 if (changed == 0) {
1451 value = entry->plvalue;
1452 changed = 1;
1453 wwarning(_("using default \"%s\" instead"), entry->default_value);
1454 goto again;
1456 return False;
1459 len = 0;
1460 for (i = 0; i < count; i++) {
1461 d = WMGetFromPLArray(value, i);
1462 if (!d || !WMIsPLString(d)) {
1463 count = i;
1464 break;
1466 len += strlen(WMGetFromPLString(d)) + 1;
1469 ptr = data = wmalloc(len + 1);
1471 for (i = 0; i < count; i++) {
1472 d = WMGetFromPLArray(value, i);
1473 if (!d || !WMIsPLString(d)) {
1474 break;
1476 strcpy(ptr, WMGetFromPLString(d));
1477 ptr += strlen(WMGetFromPLString(d));
1478 *ptr = ':';
1479 ptr++;
1481 ptr--;
1482 *(ptr--) = 0;
1484 if (*(char **)addr != NULL) {
1485 wfree(*(char **)addr);
1487 *(char **)addr = data;
1489 return True;
1492 static int getEnum(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1494 static signed char data;
1496 data = string2index(entry->plkey, value, entry->default_value, (WOptionEnumeration *) entry->extra_data);
1497 if (data < 0)
1498 return False;
1500 if (ret)
1501 *ret = &data;
1502 if (addr)
1503 *(signed char *)addr = data;
1505 return True;
1509 * (solid <color>)
1510 * (hgradient <color> <color>)
1511 * (vgradient <color> <color>)
1512 * (dgradient <color> <color>)
1513 * (mhgradient <color> <color> ...)
1514 * (mvgradient <color> <color> ...)
1515 * (mdgradient <color> <color> ...)
1516 * (igradient <color1> <color1> <thickness1> <color2> <color2> <thickness2>)
1517 * (tpixmap <file> <color>)
1518 * (spixmap <file> <color>)
1519 * (cpixmap <file> <color>)
1520 * (thgradient <file> <opaqueness> <color> <color>)
1521 * (tvgradient <file> <opaqueness> <color> <color>)
1522 * (tdgradient <file> <opaqueness> <color> <color>)
1523 * (function <lib> <function> ...)
1526 static WTexture *parse_texture(WScreen * scr, WMPropList * pl)
1528 WMPropList *elem;
1529 char *val;
1530 int nelem;
1531 WTexture *texture = NULL;
1533 nelem = WMGetPropListItemCount(pl);
1534 if (nelem < 1)
1535 return NULL;
1537 elem = WMGetFromPLArray(pl, 0);
1538 if (!elem || !WMIsPLString(elem))
1539 return NULL;
1540 val = WMGetFromPLString(elem);
1542 if (strcasecmp(val, "solid") == 0) {
1543 XColor color;
1545 if (nelem != 2)
1546 return NULL;
1548 /* get color */
1550 elem = WMGetFromPLArray(pl, 1);
1551 if (!elem || !WMIsPLString(elem))
1552 return NULL;
1553 val = WMGetFromPLString(elem);
1555 if (!XParseColor(dpy, scr->w_colormap, val, &color)) {
1556 wwarning(_("\"%s\" is not a valid color name"), val);
1557 return NULL;
1560 texture = (WTexture *) wTextureMakeSolid(scr, &color);
1561 } else if (strcasecmp(val, "dgradient") == 0
1562 || strcasecmp(val, "vgradient") == 0 || strcasecmp(val, "hgradient") == 0) {
1563 RColor color1, color2;
1564 XColor xcolor;
1565 int type;
1567 if (nelem != 3) {
1568 wwarning(_("bad number of arguments in gradient specification"));
1569 return NULL;
1572 if (val[0] == 'd' || val[0] == 'D')
1573 type = WTEX_DGRADIENT;
1574 else if (val[0] == 'h' || val[0] == 'H')
1575 type = WTEX_HGRADIENT;
1576 else
1577 type = WTEX_VGRADIENT;
1579 /* get from color */
1580 elem = WMGetFromPLArray(pl, 1);
1581 if (!elem || !WMIsPLString(elem))
1582 return NULL;
1583 val = WMGetFromPLString(elem);
1585 if (!XParseColor(dpy, scr->w_colormap, val, &xcolor)) {
1586 wwarning(_("\"%s\" is not a valid color name"), val);
1587 return NULL;
1589 color1.alpha = 255;
1590 color1.red = xcolor.red >> 8;
1591 color1.green = xcolor.green >> 8;
1592 color1.blue = xcolor.blue >> 8;
1594 /* get to color */
1595 elem = WMGetFromPLArray(pl, 2);
1596 if (!elem || !WMIsPLString(elem)) {
1597 return NULL;
1599 val = WMGetFromPLString(elem);
1601 if (!XParseColor(dpy, scr->w_colormap, val, &xcolor)) {
1602 wwarning(_("\"%s\" is not a valid color name"), val);
1603 return NULL;
1605 color2.alpha = 255;
1606 color2.red = xcolor.red >> 8;
1607 color2.green = xcolor.green >> 8;
1608 color2.blue = xcolor.blue >> 8;
1610 texture = (WTexture *) wTextureMakeGradient(scr, type, &color1, &color2);
1612 } else if (strcasecmp(val, "igradient") == 0) {
1613 RColor colors1[2], colors2[2];
1614 int th1, th2;
1615 XColor xcolor;
1616 int i;
1618 if (nelem != 7) {
1619 wwarning(_("bad number of arguments in gradient specification"));
1620 return NULL;
1623 /* get from color */
1624 for (i = 0; i < 2; i++) {
1625 elem = WMGetFromPLArray(pl, 1 + i);
1626 if (!elem || !WMIsPLString(elem))
1627 return NULL;
1628 val = WMGetFromPLString(elem);
1630 if (!XParseColor(dpy, scr->w_colormap, val, &xcolor)) {
1631 wwarning(_("\"%s\" is not a valid color name"), val);
1632 return NULL;
1634 colors1[i].alpha = 255;
1635 colors1[i].red = xcolor.red >> 8;
1636 colors1[i].green = xcolor.green >> 8;
1637 colors1[i].blue = xcolor.blue >> 8;
1639 elem = WMGetFromPLArray(pl, 3);
1640 if (!elem || !WMIsPLString(elem))
1641 return NULL;
1642 val = WMGetFromPLString(elem);
1643 th1 = atoi(val);
1645 /* get from color */
1646 for (i = 0; i < 2; i++) {
1647 elem = WMGetFromPLArray(pl, 4 + i);
1648 if (!elem || !WMIsPLString(elem))
1649 return NULL;
1650 val = WMGetFromPLString(elem);
1652 if (!XParseColor(dpy, scr->w_colormap, val, &xcolor)) {
1653 wwarning(_("\"%s\" is not a valid color name"), val);
1654 return NULL;
1656 colors2[i].alpha = 255;
1657 colors2[i].red = xcolor.red >> 8;
1658 colors2[i].green = xcolor.green >> 8;
1659 colors2[i].blue = xcolor.blue >> 8;
1661 elem = WMGetFromPLArray(pl, 6);
1662 if (!elem || !WMIsPLString(elem))
1663 return NULL;
1664 val = WMGetFromPLString(elem);
1665 th2 = atoi(val);
1667 texture = (WTexture *) wTextureMakeIGradient(scr, th1, colors1, th2, colors2);
1669 } else if (strcasecmp(val, "mhgradient") == 0
1670 || strcasecmp(val, "mvgradient") == 0 || strcasecmp(val, "mdgradient") == 0) {
1671 XColor color;
1672 RColor **colors;
1673 int i, count;
1674 int type;
1676 if (nelem < 3) {
1677 wwarning(_("too few arguments in multicolor gradient specification"));
1678 return NULL;
1681 if (val[1] == 'h' || val[1] == 'H')
1682 type = WTEX_MHGRADIENT;
1683 else if (val[1] == 'v' || val[1] == 'V')
1684 type = WTEX_MVGRADIENT;
1685 else
1686 type = WTEX_MDGRADIENT;
1688 count = nelem - 1;
1690 colors = wmalloc(sizeof(RColor *) * (count + 1));
1692 for (i = 0; i < count; i++) {
1693 elem = WMGetFromPLArray(pl, i + 1);
1694 if (!elem || !WMIsPLString(elem)) {
1695 for (--i; i >= 0; --i) {
1696 wfree(colors[i]);
1698 wfree(colors);
1699 return NULL;
1701 val = WMGetFromPLString(elem);
1703 if (!XParseColor(dpy, scr->w_colormap, val, &color)) {
1704 wwarning(_("\"%s\" is not a valid color name"), val);
1705 for (--i; i >= 0; --i) {
1706 wfree(colors[i]);
1708 wfree(colors);
1709 return NULL;
1710 } else {
1711 colors[i] = wmalloc(sizeof(RColor));
1712 colors[i]->red = color.red >> 8;
1713 colors[i]->green = color.green >> 8;
1714 colors[i]->blue = color.blue >> 8;
1717 colors[i] = NULL;
1719 texture = (WTexture *) wTextureMakeMGradient(scr, type, colors);
1720 } else if (strcasecmp(val, "spixmap") == 0 ||
1721 strcasecmp(val, "cpixmap") == 0 || strcasecmp(val, "tpixmap") == 0) {
1722 XColor color;
1723 int type;
1725 if (nelem != 3)
1726 return NULL;
1728 if (val[0] == 's' || val[0] == 'S')
1729 type = WTP_SCALE;
1730 else if (val[0] == 'c' || val[0] == 'C')
1731 type = WTP_CENTER;
1732 else
1733 type = WTP_TILE;
1735 /* get color */
1736 elem = WMGetFromPLArray(pl, 2);
1737 if (!elem || !WMIsPLString(elem)) {
1738 return NULL;
1740 val = WMGetFromPLString(elem);
1742 if (!XParseColor(dpy, scr->w_colormap, val, &color)) {
1743 wwarning(_("\"%s\" is not a valid color name"), val);
1744 return NULL;
1747 /* file name */
1748 elem = WMGetFromPLArray(pl, 1);
1749 if (!elem || !WMIsPLString(elem))
1750 return NULL;
1751 val = WMGetFromPLString(elem);
1753 texture = (WTexture *) wTextureMakePixmap(scr, type, val, &color);
1754 } else if (strcasecmp(val, "thgradient") == 0
1755 || strcasecmp(val, "tvgradient") == 0 || strcasecmp(val, "tdgradient") == 0) {
1756 RColor color1, color2;
1757 XColor xcolor;
1758 int opacity;
1759 int style;
1761 if (val[1] == 'h' || val[1] == 'H')
1762 style = WTEX_THGRADIENT;
1763 else if (val[1] == 'v' || val[1] == 'V')
1764 style = WTEX_TVGRADIENT;
1765 else
1766 style = WTEX_TDGRADIENT;
1768 if (nelem != 5) {
1769 wwarning(_("bad number of arguments in textured gradient specification"));
1770 return NULL;
1773 /* get from color */
1774 elem = WMGetFromPLArray(pl, 3);
1775 if (!elem || !WMIsPLString(elem))
1776 return NULL;
1777 val = WMGetFromPLString(elem);
1779 if (!XParseColor(dpy, scr->w_colormap, val, &xcolor)) {
1780 wwarning(_("\"%s\" is not a valid color name"), val);
1781 return NULL;
1783 color1.alpha = 255;
1784 color1.red = xcolor.red >> 8;
1785 color1.green = xcolor.green >> 8;
1786 color1.blue = xcolor.blue >> 8;
1788 /* get to color */
1789 elem = WMGetFromPLArray(pl, 4);
1790 if (!elem || !WMIsPLString(elem)) {
1791 return NULL;
1793 val = WMGetFromPLString(elem);
1795 if (!XParseColor(dpy, scr->w_colormap, val, &xcolor)) {
1796 wwarning(_("\"%s\" is not a valid color name"), val);
1797 return NULL;
1799 color2.alpha = 255;
1800 color2.red = xcolor.red >> 8;
1801 color2.green = xcolor.green >> 8;
1802 color2.blue = xcolor.blue >> 8;
1804 /* get opacity */
1805 elem = WMGetFromPLArray(pl, 2);
1806 if (!elem || !WMIsPLString(elem))
1807 opacity = 128;
1808 else
1809 val = WMGetFromPLString(elem);
1811 if (!val || (opacity = atoi(val)) < 0 || opacity > 255) {
1812 wwarning(_("bad opacity value for tgradient texture \"%s\". Should be [0..255]"), val);
1813 opacity = 128;
1816 /* get file name */
1817 elem = WMGetFromPLArray(pl, 1);
1818 if (!elem || !WMIsPLString(elem))
1819 return NULL;
1820 val = WMGetFromPLString(elem);
1822 texture = (WTexture *) wTextureMakeTGradient(scr, style, &color1, &color2, val, opacity);
1823 } else if (strcasecmp(val, "function") == 0) {
1824 /* Leave this in to handle the unlikely case of
1825 * someone actually having function textures configured */
1826 wwarning("function texture support has been removed");
1827 return NULL;
1828 } else {
1829 wwarning(_("invalid texture type %s"), val);
1830 return NULL;
1832 return texture;
1835 static int getTexture(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1837 static WTexture *texture;
1838 int changed = 0;
1840 again:
1841 if (!WMIsPLArray(value)) {
1842 wwarning(_("Wrong option format for key \"%s\". Should be %s."), entry->key, "Texture");
1843 if (changed == 0) {
1844 value = entry->plvalue;
1845 changed = 1;
1846 wwarning(_("using default \"%s\" instead"), entry->default_value);
1847 goto again;
1849 return False;
1852 if (strcmp(entry->key, "WidgetColor") == 0 && !changed) {
1853 WMPropList *pl;
1855 pl = WMGetFromPLArray(value, 0);
1856 if (!pl || !WMIsPLString(pl) || !WMGetFromPLString(pl)
1857 || strcasecmp(WMGetFromPLString(pl), "solid") != 0) {
1858 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1859 entry->key, "Solid Texture");
1861 value = entry->plvalue;
1862 changed = 1;
1863 wwarning(_("using default \"%s\" instead"), entry->default_value);
1864 goto again;
1868 texture = parse_texture(scr, value);
1870 if (!texture) {
1871 wwarning(_("Error in texture specification for key \"%s\""), entry->key);
1872 if (changed == 0) {
1873 value = entry->plvalue;
1874 changed = 1;
1875 wwarning(_("using default \"%s\" instead"), entry->default_value);
1876 goto again;
1878 return False;
1881 if (ret)
1882 *ret = &texture;
1884 if (addr)
1885 *(WTexture **) addr = texture;
1887 return True;
1890 static int getWSBackground(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1892 WMPropList *elem;
1893 int changed = 0;
1894 char *val;
1895 int nelem;
1897 again:
1898 if (!WMIsPLArray(value)) {
1899 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1900 "WorkspaceBack", "Texture or None");
1901 if (changed == 0) {
1902 value = entry->plvalue;
1903 changed = 1;
1904 wwarning(_("using default \"%s\" instead"), entry->default_value);
1905 goto again;
1907 return False;
1910 /* only do basic error checking and verify for None texture */
1912 nelem = WMGetPropListItemCount(value);
1913 if (nelem > 0) {
1914 elem = WMGetFromPLArray(value, 0);
1915 if (!elem || !WMIsPLString(elem)) {
1916 wwarning(_("Wrong type for workspace background. Should be a texture type."));
1917 if (changed == 0) {
1918 value = entry->plvalue;
1919 changed = 1;
1920 wwarning(_("using default \"%s\" instead"), entry->default_value);
1921 goto again;
1923 return False;
1925 val = WMGetFromPLString(elem);
1927 if (strcasecmp(val, "None") == 0)
1928 return True;
1930 *ret = WMRetainPropList(value);
1932 return True;
1935 static int
1936 getWSSpecificBackground(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1938 WMPropList *elem;
1939 int nelem;
1940 int changed = 0;
1942 again:
1943 if (!WMIsPLArray(value)) {
1944 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1945 "WorkspaceSpecificBack", "an array of textures");
1946 if (changed == 0) {
1947 value = entry->plvalue;
1948 changed = 1;
1949 wwarning(_("using default \"%s\" instead"), entry->default_value);
1950 goto again;
1952 return False;
1955 /* only do basic error checking and verify for None texture */
1957 nelem = WMGetPropListItemCount(value);
1958 if (nelem > 0) {
1959 while (nelem--) {
1960 elem = WMGetFromPLArray(value, nelem);
1961 if (!elem || !WMIsPLArray(elem)) {
1962 wwarning(_("Wrong type for background of workspace %i. Should be a texture."),
1963 nelem);
1968 *ret = WMRetainPropList(value);
1970 #ifdef notworking
1972 * Kluge to force wmsetbg helper to set the default background.
1973 * If the WorkspaceSpecificBack is changed once wmaker has started,
1974 * the WorkspaceBack won't be sent to the helper, unless the user
1975 * changes it's value too. So, we must force this by removing the
1976 * value from the defaults DB.
1978 if (!scr->flags.backimage_helper_launched && !scr->flags.startup) {
1979 WMPropList *key = WMCreatePLString("WorkspaceBack");
1981 WMRemoveFromPLDictionary(WDWindowMaker->dictionary, key);
1983 WMReleasePropList(key);
1985 #endif
1986 return True;
1989 static int getFont(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1991 static WMFont *font;
1992 char *val;
1994 GET_STRING_OR_DEFAULT("Font", val);
1996 font = WMCreateFont(scr->wmscreen, val);
1997 if (!font)
1998 font = WMCreateFont(scr->wmscreen, "fixed");
2000 if (!font) {
2001 wfatal(_("could not load any usable font!!!"));
2002 exit(1);
2005 if (ret)
2006 *ret = font;
2008 /* can't assign font value outside update function */
2009 wassertrv(addr == NULL, True);
2011 return True;
2014 static int getColor(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
2016 static XColor color;
2017 char *val;
2018 int second_pass = 0;
2020 GET_STRING_OR_DEFAULT("Color", val);
2022 again:
2023 if (!wGetColor(scr, val, &color)) {
2024 wwarning(_("could not get color for key \"%s\""), entry->key);
2025 if (second_pass == 0) {
2026 val = WMGetFromPLString(entry->plvalue);
2027 second_pass = 1;
2028 wwarning(_("using default \"%s\" instead"), val);
2029 goto again;
2031 return False;
2034 if (ret)
2035 *ret = &color;
2037 assert(addr == NULL);
2039 if (addr)
2040 *(unsigned long*)addr = pixel;
2043 return True;
2046 static int getKeybind(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
2048 static WShortKey shortcut;
2049 KeySym ksym;
2050 char *val;
2051 char *k;
2052 char buf[MAX_SHORTCUT_LENGTH], *b;
2054 GET_STRING_OR_DEFAULT("Key spec", val);
2056 if (!val || strcasecmp(val, "NONE") == 0) {
2057 shortcut.keycode = 0;
2058 shortcut.modifier = 0;
2059 if (ret)
2060 *ret = &shortcut;
2061 return True;
2064 wstrlcpy(buf, val, MAX_SHORTCUT_LENGTH);
2066 b = (char *)buf;
2068 /* get modifiers */
2069 shortcut.modifier = 0;
2070 while ((k = strchr(b, '+')) != NULL) {
2071 int mod;
2073 *k = 0;
2074 mod = wXModifierFromKey(b);
2075 if (mod < 0) {
2076 wwarning(_("%s: invalid key modifier \"%s\""), entry->key, b);
2077 return False;
2079 shortcut.modifier |= mod;
2081 b = k + 1;
2084 /* get key */
2085 ksym = XStringToKeysym(b);
2087 if (ksym == NoSymbol) {
2088 wwarning(_("%s:invalid kbd shortcut specification \"%s\""), entry->key, val);
2089 return False;
2092 shortcut.keycode = XKeysymToKeycode(dpy, ksym);
2093 if (shortcut.keycode == 0) {
2094 wwarning(_("%s:invalid key in shortcut \"%s\""), entry->key, val);
2095 return False;
2098 if (ret)
2099 *ret = &shortcut;
2101 return True;
2104 static int getModMask(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
2106 static int mask;
2107 char *str;
2109 GET_STRING_OR_DEFAULT("Modifier Key", str);
2111 if (!str)
2112 return False;
2114 mask = wXModifierFromKey(str);
2115 if (mask < 0) {
2116 wwarning(_("%s: modifier key %s is not valid"), entry->key, str);
2117 mask = 0;
2118 return False;
2121 if (addr)
2122 *(int *)addr = mask;
2124 if (ret)
2125 *ret = &mask;
2127 return True;
2130 # include <X11/cursorfont.h>
2131 typedef struct {
2132 char *name;
2133 int id;
2134 } WCursorLookup;
2136 #define CURSOR_ID_NONE (XC_num_glyphs)
2138 static WCursorLookup cursor_table[] = {
2139 {"X_cursor", XC_X_cursor},
2140 {"arrow", XC_arrow},
2141 {"based_arrow_down", XC_based_arrow_down},
2142 {"based_arrow_up", XC_based_arrow_up},
2143 {"boat", XC_boat},
2144 {"bogosity", XC_bogosity},
2145 {"bottom_left_corner", XC_bottom_left_corner},
2146 {"bottom_right_corner", XC_bottom_right_corner},
2147 {"bottom_side", XC_bottom_side},
2148 {"bottom_tee", XC_bottom_tee},
2149 {"box_spiral", XC_box_spiral},
2150 {"center_ptr", XC_center_ptr},
2151 {"circle", XC_circle},
2152 {"clock", XC_clock},
2153 {"coffee_mug", XC_coffee_mug},
2154 {"cross", XC_cross},
2155 {"cross_reverse", XC_cross_reverse},
2156 {"crosshair", XC_crosshair},
2157 {"diamond_cross", XC_diamond_cross},
2158 {"dot", XC_dot},
2159 {"dotbox", XC_dotbox},
2160 {"double_arrow", XC_double_arrow},
2161 {"draft_large", XC_draft_large},
2162 {"draft_small", XC_draft_small},
2163 {"draped_box", XC_draped_box},
2164 {"exchange", XC_exchange},
2165 {"fleur", XC_fleur},
2166 {"gobbler", XC_gobbler},
2167 {"gumby", XC_gumby},
2168 {"hand1", XC_hand1},
2169 {"hand2", XC_hand2},
2170 {"heart", XC_heart},
2171 {"icon", XC_icon},
2172 {"iron_cross", XC_iron_cross},
2173 {"left_ptr", XC_left_ptr},
2174 {"left_side", XC_left_side},
2175 {"left_tee", XC_left_tee},
2176 {"leftbutton", XC_leftbutton},
2177 {"ll_angle", XC_ll_angle},
2178 {"lr_angle", XC_lr_angle},
2179 {"man", XC_man},
2180 {"middlebutton", XC_middlebutton},
2181 {"mouse", XC_mouse},
2182 {"pencil", XC_pencil},
2183 {"pirate", XC_pirate},
2184 {"plus", XC_plus},
2185 {"question_arrow", XC_question_arrow},
2186 {"right_ptr", XC_right_ptr},
2187 {"right_side", XC_right_side},
2188 {"right_tee", XC_right_tee},
2189 {"rightbutton", XC_rightbutton},
2190 {"rtl_logo", XC_rtl_logo},
2191 {"sailboat", XC_sailboat},
2192 {"sb_down_arrow", XC_sb_down_arrow},
2193 {"sb_h_double_arrow", XC_sb_h_double_arrow},
2194 {"sb_left_arrow", XC_sb_left_arrow},
2195 {"sb_right_arrow", XC_sb_right_arrow},
2196 {"sb_up_arrow", XC_sb_up_arrow},
2197 {"sb_v_double_arrow", XC_sb_v_double_arrow},
2198 {"shuttle", XC_shuttle},
2199 {"sizing", XC_sizing},
2200 {"spider", XC_spider},
2201 {"spraycan", XC_spraycan},
2202 {"star", XC_star},
2203 {"target", XC_target},
2204 {"tcross", XC_tcross},
2205 {"top_left_arrow", XC_top_left_arrow},
2206 {"top_left_corner", XC_top_left_corner},
2207 {"top_right_corner", XC_top_right_corner},
2208 {"top_side", XC_top_side},
2209 {"top_tee", XC_top_tee},
2210 {"trek", XC_trek},
2211 {"ul_angle", XC_ul_angle},
2212 {"umbrella", XC_umbrella},
2213 {"ur_angle", XC_ur_angle},
2214 {"watch", XC_watch},
2215 {"xterm", XC_xterm},
2216 {NULL, CURSOR_ID_NONE}
2219 static void check_bitmap_status(int status, char *filename, Pixmap bitmap)
2221 switch (status) {
2222 case BitmapOpenFailed:
2223 wwarning(_("failed to open bitmap file \"%s\""), filename);
2224 break;
2225 case BitmapFileInvalid:
2226 wwarning(_("\"%s\" is not a valid bitmap file"), filename);
2227 break;
2228 case BitmapNoMemory:
2229 wwarning(_("out of memory reading bitmap file \"%s\""), filename);
2230 break;
2231 case BitmapSuccess:
2232 XFreePixmap(dpy, bitmap);
2233 break;
2238 * (none)
2239 * (builtin, <cursor_name>)
2240 * (bitmap, <cursor_bitmap>, <cursor_mask>)
2242 static int parse_cursor(WScreen * scr, WMPropList * pl, Cursor * cursor)
2244 WMPropList *elem;
2245 char *val;
2246 int nelem;
2247 int status = 0;
2249 nelem = WMGetPropListItemCount(pl);
2250 if (nelem < 1) {
2251 return (status);
2253 elem = WMGetFromPLArray(pl, 0);
2254 if (!elem || !WMIsPLString(elem)) {
2255 return (status);
2257 val = WMGetFromPLString(elem);
2259 if (strcasecmp(val, "none") == 0) {
2260 status = 1;
2261 *cursor = None;
2262 } else if (strcasecmp(val, "builtin") == 0) {
2263 int i;
2264 int cursor_id = CURSOR_ID_NONE;
2266 if (nelem != 2) {
2267 wwarning(_("bad number of arguments in cursor specification"));
2268 return (status);
2270 elem = WMGetFromPLArray(pl, 1);
2271 if (!elem || !WMIsPLString(elem)) {
2272 return (status);
2274 val = WMGetFromPLString(elem);
2276 for (i = 0; cursor_table[i].name != NULL; i++) {
2277 if (strcasecmp(val, cursor_table[i].name) == 0) {
2278 cursor_id = cursor_table[i].id;
2279 break;
2282 if (CURSOR_ID_NONE == cursor_id) {
2283 wwarning(_("unknown builtin cursor name \"%s\""), val);
2284 } else {
2285 *cursor = XCreateFontCursor(dpy, cursor_id);
2286 status = 1;
2288 } else if (strcasecmp(val, "bitmap") == 0) {
2289 char *bitmap_name;
2290 char *mask_name;
2291 int bitmap_status;
2292 int mask_status;
2293 Pixmap bitmap;
2294 Pixmap mask;
2295 unsigned int w, h;
2296 int x, y;
2297 XColor fg, bg;
2299 if (nelem != 3) {
2300 wwarning(_("bad number of arguments in cursor specification"));
2301 return (status);
2303 elem = WMGetFromPLArray(pl, 1);
2304 if (!elem || !WMIsPLString(elem)) {
2305 return (status);
2307 val = WMGetFromPLString(elem);
2308 bitmap_name = FindImage(wPreferences.pixmap_path, val);
2309 if (!bitmap_name) {
2310 wwarning(_("could not find cursor bitmap file \"%s\""), val);
2311 return (status);
2313 elem = WMGetFromPLArray(pl, 2);
2314 if (!elem || !WMIsPLString(elem)) {
2315 wfree(bitmap_name);
2316 return (status);
2318 val = WMGetFromPLString(elem);
2319 mask_name = FindImage(wPreferences.pixmap_path, val);
2320 if (!mask_name) {
2321 wfree(bitmap_name);
2322 wwarning(_("could not find cursor bitmap file \"%s\""), val);
2323 return (status);
2325 mask_status = XReadBitmapFile(dpy, scr->w_win, mask_name, &w, &h, &mask, &x, &y);
2326 bitmap_status = XReadBitmapFile(dpy, scr->w_win, bitmap_name, &w, &h, &bitmap, &x, &y);
2327 if ((BitmapSuccess == bitmap_status) && (BitmapSuccess == mask_status)) {
2328 fg.pixel = scr->black_pixel;
2329 bg.pixel = scr->white_pixel;
2330 XQueryColor(dpy, scr->w_colormap, &fg);
2331 XQueryColor(dpy, scr->w_colormap, &bg);
2332 *cursor = XCreatePixmapCursor(dpy, bitmap, mask, &fg, &bg, x, y);
2333 status = 1;
2335 check_bitmap_status(bitmap_status, bitmap_name, bitmap);
2336 check_bitmap_status(mask_status, mask_name, mask);
2337 wfree(bitmap_name);
2338 wfree(mask_name);
2340 return (status);
2343 static int getCursor(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
2345 static Cursor cursor;
2346 int status;
2347 int changed = 0;
2349 again:
2350 if (!WMIsPLArray(value)) {
2351 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
2352 entry->key, "cursor specification");
2353 if (!changed) {
2354 value = entry->plvalue;
2355 changed = 1;
2356 wwarning(_("using default \"%s\" instead"), entry->default_value);
2357 goto again;
2359 return (False);
2361 status = parse_cursor(scr, value, &cursor);
2362 if (!status) {
2363 wwarning(_("Error in cursor specification for key \"%s\""), entry->key);
2364 if (!changed) {
2365 value = entry->plvalue;
2366 changed = 1;
2367 wwarning(_("using default \"%s\" instead"), entry->default_value);
2368 goto again;
2370 return (False);
2372 if (ret) {
2373 *ret = &cursor;
2375 if (addr) {
2376 *(Cursor *) addr = cursor;
2378 return (True);
2381 #undef CURSOR_ID_NONE
2383 /* ---------------- value setting functions --------------- */
2384 static int setJustify(WScreen * scr, WDefaultEntry * entry, WTexture ** texture, void *foo)
2386 return REFRESH_WINDOW_TITLE_COLOR;
2389 static int setClearance(WScreen * scr, WDefaultEntry * entry, void *bar, void *foo)
2391 return REFRESH_WINDOW_FONT | REFRESH_BUTTON_IMAGES | REFRESH_MENU_TITLE_FONT | REFRESH_MENU_FONT;
2394 static int setIfDockPresent(WScreen * scr, WDefaultEntry * entry, char *flag, long which)
2396 switch (which) {
2397 case WM_DOCK:
2398 wPreferences.flags.nodock = wPreferences.flags.nodock || *flag;
2399 // Drawers require the dock
2400 wPreferences.flags.nodrawer = wPreferences.flags.nodrawer || wPreferences.flags.nodock;
2401 break;
2402 case WM_CLIP:
2403 wPreferences.flags.noclip = wPreferences.flags.noclip || *flag;
2404 break;
2405 case WM_DRAWER:
2406 wPreferences.flags.nodrawer = wPreferences.flags.nodrawer || *flag;
2407 break;
2408 default:
2409 break;
2411 return 0;
2414 static int setClipMergedInDock(WScreen *scr, WDefaultEntry *entry, char *flag, void *foo)
2416 wPreferences.flags.clip_merged_in_dock = *flag;
2417 wPreferences.flags.noclip = wPreferences.flags.noclip || *flag;
2418 return 0;
2421 static int setWrapAppiconsInDock(WScreen *scr, WDefaultEntry *entry, char *flag, void *foo)
2423 wPreferences.flags.wrap_appicons_in_dock = *flag;
2424 return 0;
2427 static int setStickyIcons(WScreen * scr, WDefaultEntry * entry, void *bar, void *foo)
2429 if (scr->workspaces) {
2430 wWorkspaceForceChange(scr, scr->current_workspace);
2431 wArrangeIcons(scr, False);
2433 return 0;
2436 static int setIconTile(WScreen * scr, WDefaultEntry * entry, WTexture ** texture, void *foo)
2438 Pixmap pixmap;
2439 RImage *img;
2440 int reset = 0;
2442 img = wTextureRenderImage(*texture, wPreferences.icon_size,
2443 wPreferences.icon_size, ((*texture)->any.type & WREL_BORDER_MASK)
2444 ? WREL_ICON : WREL_FLAT);
2445 if (!img) {
2446 wwarning(_("could not render texture for icon background"));
2447 if (!entry->addr)
2448 wTextureDestroy(scr, *texture);
2449 return 0;
2451 RConvertImage(scr->rcontext, img, &pixmap);
2453 if (scr->icon_tile) {
2454 reset = 1;
2455 RReleaseImage(scr->icon_tile);
2456 XFreePixmap(dpy, scr->icon_tile_pixmap);
2459 scr->icon_tile = img;
2461 /* put the icon in the noticeboard hint */
2462 PropSetIconTileHint(scr, img);
2464 if (!wPreferences.flags.noclip || wPreferences.flags.clip_merged_in_dock) {
2465 if (scr->clip_tile) {
2466 RReleaseImage(scr->clip_tile);
2468 scr->clip_tile = wClipMakeTile(scr, img);
2471 if (!wPreferences.flags.nodrawer) {
2472 if (scr->drawer_tile) {
2473 RReleaseImage(scr->drawer_tile);
2475 scr->drawer_tile = wDrawerMakeTile(scr, img);
2478 scr->icon_tile_pixmap = pixmap;
2480 if (scr->def_icon_rimage) {
2481 RReleaseImage(scr->def_icon_rimage);
2482 scr->def_icon_rimage = NULL;
2485 if (scr->icon_back_texture)
2486 wTextureDestroy(scr, (WTexture *) scr->icon_back_texture);
2488 scr->icon_back_texture = wTextureMakeSolid(scr, &((*texture)->any.color));
2490 /* Free the texture as nobody else will use it, nor refer to it. */
2491 if (!entry->addr)
2492 wTextureDestroy(scr, *texture);
2494 return (reset ? REFRESH_ICON_TILE : 0);
2497 static int setWinTitleFont(WScreen * scr, WDefaultEntry * entry, WMFont * font, void *foo)
2499 if (scr->title_font) {
2500 WMReleaseFont(scr->title_font);
2502 scr->title_font = font;
2504 return REFRESH_WINDOW_FONT | REFRESH_BUTTON_IMAGES;
2507 static int setMenuTitleFont(WScreen * scr, WDefaultEntry * entry, WMFont * font, void *foo)
2509 if (scr->menu_title_font) {
2510 WMReleaseFont(scr->menu_title_font);
2513 scr->menu_title_font = font;
2515 return REFRESH_MENU_TITLE_FONT;
2518 static int setMenuTextFont(WScreen * scr, WDefaultEntry * entry, WMFont * font, void *foo)
2520 if (scr->menu_entry_font) {
2521 WMReleaseFont(scr->menu_entry_font);
2523 scr->menu_entry_font = font;
2525 return REFRESH_MENU_FONT;
2528 static int setIconTitleFont(WScreen * scr, WDefaultEntry * entry, WMFont * font, void *foo)
2530 if (scr->icon_title_font) {
2531 WMReleaseFont(scr->icon_title_font);
2534 scr->icon_title_font = font;
2536 return REFRESH_ICON_FONT;
2539 static int setClipTitleFont(WScreen * scr, WDefaultEntry * entry, WMFont * font, void *foo)
2541 if (scr->clip_title_font) {
2542 WMReleaseFont(scr->clip_title_font);
2545 scr->clip_title_font = font;
2547 return REFRESH_ICON_FONT;
2550 static int setLargeDisplayFont(WScreen * scr, WDefaultEntry * entry, WMFont * font, void *foo)
2552 if (scr->workspace_name_font) {
2553 WMReleaseFont(scr->workspace_name_font);
2556 scr->workspace_name_font = font;
2558 return 0;
2561 static int setHightlight(WScreen * scr, WDefaultEntry * entry, XColor * color, void *foo)
2563 if (scr->select_color)
2564 WMReleaseColor(scr->select_color);
2566 scr->select_color = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2568 wFreeColor(scr, color->pixel);
2570 return REFRESH_MENU_COLOR;
2573 static int setHightlightText(WScreen * scr, WDefaultEntry * entry, XColor * color, void *foo)
2575 if (scr->select_text_color)
2576 WMReleaseColor(scr->select_text_color);
2578 scr->select_text_color = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2580 wFreeColor(scr, color->pixel);
2582 return REFRESH_MENU_COLOR;
2585 static int setClipTitleColor(WScreen * scr, WDefaultEntry * entry, XColor * color, long widx)
2587 if (scr->clip_title_color[widx])
2588 WMReleaseColor(scr->clip_title_color[widx]);
2590 scr->clip_title_color[widx] = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2591 wFreeColor(scr, color->pixel);
2593 return REFRESH_ICON_TITLE_COLOR;
2596 static int setWTitleColor(WScreen * scr, WDefaultEntry * entry, XColor * color, long widx)
2598 if (scr->window_title_color[widx])
2599 WMReleaseColor(scr->window_title_color[widx]);
2601 scr->window_title_color[widx] =
2602 WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2604 wFreeColor(scr, color->pixel);
2606 return REFRESH_WINDOW_TITLE_COLOR;
2609 static int setMenuTitleColor(WScreen * scr, WDefaultEntry * entry, XColor * color, long widx)
2611 if (scr->menu_title_color[0])
2612 WMReleaseColor(scr->menu_title_color[0]);
2614 scr->menu_title_color[0] = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2616 wFreeColor(scr, color->pixel);
2618 return REFRESH_MENU_TITLE_COLOR;
2621 static int setMenuTextColor(WScreen * scr, WDefaultEntry * entry, XColor * color, void *foo)
2623 if (scr->mtext_color)
2624 WMReleaseColor(scr->mtext_color);
2626 scr->mtext_color = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2628 if (WMColorPixel(scr->dtext_color) == WMColorPixel(scr->mtext_color)) {
2629 WMSetColorAlpha(scr->dtext_color, 0x7fff);
2630 } else {
2631 WMSetColorAlpha(scr->dtext_color, 0xffff);
2634 wFreeColor(scr, color->pixel);
2636 return REFRESH_MENU_COLOR;
2639 static int setMenuDisabledColor(WScreen * scr, WDefaultEntry * entry, XColor * color, void *foo)
2641 if (scr->dtext_color)
2642 WMReleaseColor(scr->dtext_color);
2644 scr->dtext_color = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2646 if (WMColorPixel(scr->dtext_color) == WMColorPixel(scr->mtext_color)) {
2647 WMSetColorAlpha(scr->dtext_color, 0x7fff);
2648 } else {
2649 WMSetColorAlpha(scr->dtext_color, 0xffff);
2652 wFreeColor(scr, color->pixel);
2654 return REFRESH_MENU_COLOR;
2657 static int setIconTitleColor(WScreen * scr, WDefaultEntry * entry, XColor * color, void *foo)
2659 if (scr->icon_title_color)
2660 WMReleaseColor(scr->icon_title_color);
2661 scr->icon_title_color = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2663 wFreeColor(scr, color->pixel);
2665 return REFRESH_ICON_TITLE_COLOR;
2668 static int setIconTitleBack(WScreen * scr, WDefaultEntry * entry, XColor * color, void *foo)
2670 if (scr->icon_title_texture) {
2671 wTextureDestroy(scr, (WTexture *) scr->icon_title_texture);
2673 scr->icon_title_texture = wTextureMakeSolid(scr, color);
2675 return REFRESH_ICON_TITLE_BACK;
2678 static int setFrameBorderWidth(WScreen * scr, WDefaultEntry * entry, int * value, void *foo)
2680 scr->frame_border_width = *value;
2682 return REFRESH_FRAME_BORDER;
2685 static int setFrameBorderColor(WScreen * scr, WDefaultEntry * entry, XColor * color, void *foo)
2687 if (scr->frame_border_color)
2688 WMReleaseColor(scr->frame_border_color);
2689 scr->frame_border_color = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2691 wFreeColor(scr, color->pixel);
2693 return REFRESH_FRAME_BORDER;
2696 static int setFrameSelectedBorderColor(WScreen * scr, WDefaultEntry * entry, XColor * color, void *foo)
2698 if (scr->frame_selected_border_color)
2699 WMReleaseColor(scr->frame_selected_border_color);
2700 scr->frame_selected_border_color = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2702 wFreeColor(scr, color->pixel);
2704 return REFRESH_FRAME_BORDER;
2707 static void trackDeadProcess(pid_t pid, unsigned char status, WScreen * scr)
2709 close(scr->helper_fd);
2710 scr->helper_fd = 0;
2711 scr->helper_pid = 0;
2712 scr->flags.backimage_helper_launched = 0;
2715 static int setWorkspaceSpecificBack(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *bar)
2717 WMPropList *val;
2718 char *str;
2719 int i;
2721 if (scr->flags.backimage_helper_launched) {
2722 if (WMGetPropListItemCount(value) == 0) {
2723 SendHelperMessage(scr, 'C', 0, NULL);
2724 SendHelperMessage(scr, 'K', 0, NULL);
2726 WMReleasePropList(value);
2727 return 0;
2729 } else {
2730 pid_t pid;
2731 int filedes[2];
2733 if (WMGetPropListItemCount(value) == 0)
2734 return 0;
2736 if (pipe(filedes) < 0) {
2737 werror("pipe() failed:can't set workspace specific background image");
2739 WMReleasePropList(value);
2740 return 0;
2743 pid = fork();
2744 if (pid < 0) {
2745 werror("fork() failed:can't set workspace specific background image");
2746 if (close(filedes[0]) < 0)
2747 werror("could not close pipe");
2748 if (close(filedes[1]) < 0)
2749 werror("could not close pipe");
2751 } else if (pid == 0) {
2752 char *dither;
2754 SetupEnvironment(scr);
2756 if (close(0) < 0)
2757 werror("could not close pipe");
2758 if (dup(filedes[0]) < 0) {
2759 werror("dup() failed:can't set workspace specific background image");
2761 dither = wPreferences.no_dithering ? "-m" : "-d";
2762 if (wPreferences.smooth_workspace_back)
2763 execlp("wmsetbg", "wmsetbg", "-helper", "-S", dither, NULL);
2764 else
2765 execlp("wmsetbg", "wmsetbg", "-helper", dither, NULL);
2766 werror("could not execute wmsetbg");
2767 exit(1);
2768 } else {
2770 if (fcntl(filedes[0], F_SETFD, FD_CLOEXEC) < 0) {
2771 werror("error setting close-on-exec flag");
2773 if (fcntl(filedes[1], F_SETFD, FD_CLOEXEC) < 0) {
2774 werror("error setting close-on-exec flag");
2777 scr->helper_fd = filedes[1];
2778 scr->helper_pid = pid;
2779 scr->flags.backimage_helper_launched = 1;
2781 wAddDeathHandler(pid, (WDeathHandler *) trackDeadProcess, scr);
2783 SendHelperMessage(scr, 'P', -1, wPreferences.pixmap_path);
2788 for (i = 0; i < WMGetPropListItemCount(value); i++) {
2789 val = WMGetFromPLArray(value, i);
2790 if (val && WMIsPLArray(val) && WMGetPropListItemCount(val) > 0) {
2791 str = WMGetPropListDescription(val, False);
2793 SendHelperMessage(scr, 'S', i + 1, str);
2795 wfree(str);
2796 } else {
2797 SendHelperMessage(scr, 'U', i + 1, NULL);
2800 sleep(1);
2802 WMReleasePropList(value);
2803 return 0;
2806 static int setWorkspaceBack(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *bar)
2808 if (scr->flags.backimage_helper_launched) {
2809 char *str;
2811 if (WMGetPropListItemCount(value) == 0) {
2812 SendHelperMessage(scr, 'U', 0, NULL);
2813 } else {
2814 /* set the default workspace background to this one */
2815 str = WMGetPropListDescription(value, False);
2816 if (str) {
2817 SendHelperMessage(scr, 'S', 0, str);
2818 wfree(str);
2819 SendHelperMessage(scr, 'C', scr->current_workspace + 1, NULL);
2820 } else {
2821 SendHelperMessage(scr, 'U', 0, NULL);
2824 } else if (WMGetPropListItemCount(value) > 0) {
2825 char *command;
2826 char *text;
2827 char *dither;
2828 int len;
2830 text = WMGetPropListDescription(value, False);
2831 len = strlen(text) + 40;
2832 command = wmalloc(len);
2833 dither = wPreferences.no_dithering ? "-m" : "-d";
2834 if (wPreferences.smooth_workspace_back)
2835 snprintf(command, len, "wmsetbg %s -S -p '%s' &", dither, text);
2836 else
2837 snprintf(command, len, "wmsetbg %s -p '%s' &", dither, text);
2838 wfree(text);
2839 ExecuteShellCommand(scr, command);
2840 wfree(command);
2842 WMReleasePropList(value);
2844 return 0;
2847 static int setWidgetColor(WScreen * scr, WDefaultEntry * entry, WTexture ** texture, void *foo)
2849 if (scr->widget_texture) {
2850 wTextureDestroy(scr, (WTexture *) scr->widget_texture);
2852 scr->widget_texture = *(WTexSolid **) texture;
2854 return 0;
2857 static int setFTitleBack(WScreen * scr, WDefaultEntry * entry, WTexture ** texture, void *foo)
2859 if (scr->window_title_texture[WS_FOCUSED]) {
2860 wTextureDestroy(scr, scr->window_title_texture[WS_FOCUSED]);
2862 scr->window_title_texture[WS_FOCUSED] = *texture;
2864 return REFRESH_WINDOW_TEXTURES;
2867 static int setPTitleBack(WScreen * scr, WDefaultEntry * entry, WTexture ** texture, void *foo)
2869 if (scr->window_title_texture[WS_PFOCUSED]) {
2870 wTextureDestroy(scr, scr->window_title_texture[WS_PFOCUSED]);
2872 scr->window_title_texture[WS_PFOCUSED] = *texture;
2874 return REFRESH_WINDOW_TEXTURES;
2877 static int setUTitleBack(WScreen * scr, WDefaultEntry * entry, WTexture ** texture, void *foo)
2879 if (scr->window_title_texture[WS_UNFOCUSED]) {
2880 wTextureDestroy(scr, scr->window_title_texture[WS_UNFOCUSED]);
2882 scr->window_title_texture[WS_UNFOCUSED] = *texture;
2884 return REFRESH_WINDOW_TEXTURES;
2887 static int setResizebarBack(WScreen * scr, WDefaultEntry * entry, WTexture ** texture, void *foo)
2889 if (scr->resizebar_texture[0]) {
2890 wTextureDestroy(scr, scr->resizebar_texture[0]);
2892 scr->resizebar_texture[0] = *texture;
2894 return REFRESH_WINDOW_TEXTURES;
2897 static int setMenuTitleBack(WScreen * scr, WDefaultEntry * entry, WTexture ** texture, void *foo)
2899 if (scr->menu_title_texture[0]) {
2900 wTextureDestroy(scr, scr->menu_title_texture[0]);
2902 scr->menu_title_texture[0] = *texture;
2904 return REFRESH_MENU_TITLE_TEXTURE;
2907 static int setMenuTextBack(WScreen * scr, WDefaultEntry * entry, WTexture ** texture, void *foo)
2909 if (scr->menu_item_texture) {
2910 wTextureDestroy(scr, scr->menu_item_texture);
2911 wTextureDestroy(scr, (WTexture *) scr->menu_item_auxtexture);
2913 scr->menu_item_texture = *texture;
2915 scr->menu_item_auxtexture = wTextureMakeSolid(scr, &scr->menu_item_texture->any.color);
2917 return REFRESH_MENU_TEXTURE;
2920 static int setKeyGrab(WScreen * scr, WDefaultEntry * entry, WShortKey * shortcut, long widx)
2922 WWindow *wwin;
2923 wKeyBindings[widx] = *shortcut;
2925 wwin = scr->focused_window;
2927 while (wwin != NULL) {
2928 XUngrabKey(dpy, AnyKey, AnyModifier, wwin->frame->core->window);
2930 if (!WFLAGP(wwin, no_bind_keys)) {
2931 wWindowSetKeyGrabs(wwin);
2933 wwin = wwin->prev;
2936 /* do we need to update window menus? */
2937 if (widx >= WKBD_WORKSPACE1 && widx <= WKBD_WORKSPACE10)
2938 return REFRESH_WORKSPACE_MENU;
2939 if (widx == WKBD_LASTWORKSPACE)
2940 return REFRESH_WORKSPACE_MENU;
2941 if (widx >= WKBD_MOVE_WORKSPACE1 && widx <= WKBD_MOVE_WORKSPACE10)
2942 return REFRESH_WORKSPACE_MENU;
2944 return 0;
2947 static int setIconPosition(WScreen * scr, WDefaultEntry * entry, void *bar, void *foo)
2949 wScreenUpdateUsableArea(scr);
2950 wArrangeIcons(scr, True);
2952 return 0;
2955 static int updateUsableArea(WScreen * scr, WDefaultEntry * entry, void *bar, void *foo)
2957 wScreenUpdateUsableArea(scr);
2959 return 0;
2962 static int setMenuStyle(WScreen * scr, WDefaultEntry * entry, int *value, void *foo)
2964 return REFRESH_MENU_TEXTURE;
2967 static RImage *chopOffImage(RImage * image, int x, int y, int w, int h)
2969 RImage *img = RCreateImage(w, h, image->format == RRGBAFormat);
2971 RCopyArea(img, image, x, y, w, h, 0, 0);
2973 return img;
2976 static int setSwPOptions(WScreen * scr, WDefaultEntry * entry, WMPropList * array, void *foo)
2978 char *path;
2979 RImage *bgimage;
2980 int cwidth, cheight;
2981 WPreferences *prefs = (WPreferences *) foo;
2983 if (!WMIsPLArray(array) || WMGetPropListItemCount(array) == 0) {
2984 if (prefs->swtileImage)
2985 RReleaseImage(prefs->swtileImage);
2986 prefs->swtileImage = NULL;
2988 WMReleasePropList(array);
2989 return 0;
2992 switch (WMGetPropListItemCount(array)) {
2993 case 4:
2994 if (!WMIsPLString(WMGetFromPLArray(array, 1))) {
2995 wwarning(_("Invalid arguments for option \"%s\""), entry->key);
2996 break;
2997 } else
2998 path = FindImage(wPreferences.pixmap_path, WMGetFromPLString(WMGetFromPLArray(array, 1)));
3000 if (!path) {
3001 wwarning(_("Could not find image \"%s\" for option \"%s\""),
3002 WMGetFromPLString(WMGetFromPLArray(array, 1)), entry->key);
3003 } else {
3004 bgimage = RLoadImage(scr->rcontext, path, 0);
3005 if (!bgimage) {
3006 wwarning(_("Could not load image \"%s\" for option \"%s\""), path, entry->key);
3007 wfree(path);
3008 } else {
3009 wfree(path);
3011 cwidth = atoi(WMGetFromPLString(WMGetFromPLArray(array, 2)));
3012 cheight = atoi(WMGetFromPLString(WMGetFromPLArray(array, 3)));
3014 if (cwidth <= 0 || cheight <= 0 ||
3015 cwidth >= bgimage->width - 2 || cheight >= bgimage->height - 2)
3016 wwarning(_("Invalid split sizes for SwitchPanel back image."));
3017 else {
3018 int i;
3019 int swidth, theight;
3020 for (i = 0; i < 9; i++) {
3021 if (prefs->swbackImage[i])
3022 RReleaseImage(prefs->swbackImage[i]);
3023 prefs->swbackImage[i] = NULL;
3025 swidth = (bgimage->width - cwidth) / 2;
3026 theight = (bgimage->height - cheight) / 2;
3028 prefs->swbackImage[0] = chopOffImage(bgimage, 0, 0, swidth, theight);
3029 prefs->swbackImage[1] = chopOffImage(bgimage, swidth, 0, cwidth, theight);
3030 prefs->swbackImage[2] = chopOffImage(bgimage, swidth + cwidth, 0,
3031 swidth, theight);
3033 prefs->swbackImage[3] = chopOffImage(bgimage, 0, theight, swidth, cheight);
3034 prefs->swbackImage[4] = chopOffImage(bgimage, swidth, theight,
3035 cwidth, cheight);
3036 prefs->swbackImage[5] = chopOffImage(bgimage, swidth + cwidth, theight,
3037 swidth, cheight);
3039 prefs->swbackImage[6] = chopOffImage(bgimage, 0, theight + cheight,
3040 swidth, theight);
3041 prefs->swbackImage[7] = chopOffImage(bgimage, swidth, theight + cheight,
3042 cwidth, theight);
3043 prefs->swbackImage[8] =
3044 chopOffImage(bgimage, swidth + cwidth, theight + cheight, swidth,
3045 theight);
3047 // check if anything failed
3048 for (i = 0; i < 9; i++) {
3049 if (!prefs->swbackImage[i]) {
3050 for (; i >= 0; --i) {
3051 RReleaseImage(prefs->swbackImage[i]);
3052 prefs->swbackImage[i] = NULL;
3054 break;
3058 RReleaseImage(bgimage);
3062 case 1:
3063 if (!WMIsPLString(WMGetFromPLArray(array, 0))) {
3064 wwarning(_("Invalid arguments for option \"%s\""), entry->key);
3065 break;
3066 } else
3067 path = FindImage(wPreferences.pixmap_path, WMGetFromPLString(WMGetFromPLArray(array, 0)));
3069 if (!path) {
3070 wwarning(_("Could not find image \"%s\" for option \"%s\""),
3071 WMGetFromPLString(WMGetFromPLArray(array, 0)), entry->key);
3072 } else {
3073 if (prefs->swtileImage)
3074 RReleaseImage(prefs->swtileImage);
3076 prefs->swtileImage = RLoadImage(scr->rcontext, path, 0);
3077 if (!prefs->swtileImage) {
3078 wwarning(_("Could not load image \"%s\" for option \"%s\""), path, entry->key);
3080 wfree(path);
3082 break;
3084 default:
3085 wwarning(_("Invalid number of arguments for option \"%s\""), entry->key);
3086 break;
3089 WMReleasePropList(array);
3091 return 0;
3094 static int setModifierKeyLabels(WScreen * scr, WDefaultEntry * entry, WMPropList * array, void *foo)
3096 int i;
3097 WPreferences *prefs = (WPreferences *) foo;
3099 if (!WMIsPLArray(array) || WMGetPropListItemCount(array) != 7) {
3100 wwarning(_("Value for option \"%s\" must be an array of 7 strings"), entry->key);
3101 WMReleasePropList(array);
3102 return 0;
3105 DestroyWindowMenu(scr);
3107 for (i = 0; i < 7; i++) {
3108 if (prefs->modifier_labels[i])
3109 wfree(prefs->modifier_labels[i]);
3111 if (WMIsPLString(WMGetFromPLArray(array, i))) {
3112 prefs->modifier_labels[i] = wstrdup(WMGetFromPLString(WMGetFromPLArray(array, i)));
3113 } else {
3114 wwarning(_("Invalid argument for option \"%s\" item %d"), entry->key, i);
3115 prefs->modifier_labels[i] = NULL;
3119 WMReleasePropList(array);
3121 return 0;
3124 static int setDoubleClick(WScreen *scr, WDefaultEntry *entry, int *value, void *foo)
3126 if (*value <= 0)
3127 *(int *)foo = 1;
3129 W_setconf_doubleClickDelay(*value);
3131 return 0;
3134 static int setCursor(WScreen * scr, WDefaultEntry * entry, Cursor * cursor, long widx)
3136 if (wCursor[widx] != None) {
3137 XFreeCursor(dpy, wCursor[widx]);
3140 wCursor[widx] = *cursor;
3142 if (widx == WCUR_ROOT && *cursor != None) {
3143 XDefineCursor(dpy, scr->root_win, *cursor);
3146 return 0;