82202df7482fea30133979dba4d1e095c77f6a88
[wmaker-crm.git] / src / defaults.c
blob82202df7482fea30133979dba4d1e095c77f6a88
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 {"THMaximizeKey", "None", (void*)WKBD_THMAXIMIZE,
609 NULL, getKeybind, setKeyGrab, NULL, NULL},
610 {"BHMaximizeKey", "None", (void*)WKBD_BHMAXIMIZE,
611 NULL, getKeybind, setKeyGrab, NULL, NULL},
612 {"MaximusKey", "None", (void*)WKBD_MAXIMUS,
613 NULL, getKeybind, setKeyGrab, NULL, NULL},
614 {"RaiseKey", "\"Meta+Up\"", (void *)WKBD_RAISE,
615 NULL, getKeybind, setKeyGrab, NULL, NULL},
616 {"LowerKey", "\"Meta+Down\"", (void *)WKBD_LOWER,
617 NULL, getKeybind, setKeyGrab, NULL, NULL},
618 {"RaiseLowerKey", "None", (void *)WKBD_RAISELOWER,
619 NULL, getKeybind, setKeyGrab, NULL, NULL},
620 {"ShadeKey", "None", (void *)WKBD_SHADE,
621 NULL, getKeybind, setKeyGrab, NULL, NULL},
622 {"SelectKey", "None", (void *)WKBD_SELECT,
623 NULL, getKeybind, setKeyGrab, NULL, NULL},
624 {"FocusNextKey", "None", (void *)WKBD_FOCUSNEXT,
625 NULL, getKeybind, setKeyGrab, NULL, NULL},
626 {"FocusPrevKey", "None", (void *)WKBD_FOCUSPREV,
627 NULL, getKeybind, setKeyGrab, NULL, NULL},
628 {"GroupNextKey", "None", (void *)WKBD_GROUPNEXT,
629 NULL, getKeybind, setKeyGrab, NULL, NULL},
630 {"GroupPrevKey", "None", (void *)WKBD_GROUPPREV,
631 NULL, getKeybind, setKeyGrab, NULL, NULL},
632 {"NextWorkspaceKey", "None", (void *)WKBD_NEXTWORKSPACE,
633 NULL, getKeybind, setKeyGrab, NULL, NULL},
634 {"PrevWorkspaceKey", "None", (void *)WKBD_PREVWORKSPACE,
635 NULL, getKeybind, setKeyGrab, NULL, NULL},
636 {"LastWorkspaceKey", "None", (void *)WKBD_LASTWORKSPACE,
637 NULL, getKeybind, setKeyGrab, NULL, NULL},
638 {"NextWorkspaceLayerKey", "None", (void *)WKBD_NEXTWSLAYER,
639 NULL, getKeybind, setKeyGrab, NULL, NULL},
640 {"PrevWorkspaceLayerKey", "None", (void *)WKBD_PREVWSLAYER,
641 NULL, getKeybind, setKeyGrab, NULL, NULL},
642 {"Workspace1Key", "None", (void *)WKBD_WORKSPACE1,
643 NULL, getKeybind, setKeyGrab, NULL, NULL},
644 {"Workspace2Key", "None", (void *)WKBD_WORKSPACE2,
645 NULL, getKeybind, setKeyGrab, NULL, NULL},
646 {"Workspace3Key", "None", (void *)WKBD_WORKSPACE3,
647 NULL, getKeybind, setKeyGrab, NULL, NULL},
648 {"Workspace4Key", "None", (void *)WKBD_WORKSPACE4,
649 NULL, getKeybind, setKeyGrab, NULL, NULL},
650 {"Workspace5Key", "None", (void *)WKBD_WORKSPACE5,
651 NULL, getKeybind, setKeyGrab, NULL, NULL},
652 {"Workspace6Key", "None", (void *)WKBD_WORKSPACE6,
653 NULL, getKeybind, setKeyGrab, NULL, NULL},
654 {"Workspace7Key", "None", (void *)WKBD_WORKSPACE7,
655 NULL, getKeybind, setKeyGrab, NULL, NULL},
656 {"Workspace8Key", "None", (void *)WKBD_WORKSPACE8,
657 NULL, getKeybind, setKeyGrab, NULL, NULL},
658 {"Workspace9Key", "None", (void *)WKBD_WORKSPACE9,
659 NULL, getKeybind, setKeyGrab, NULL, NULL},
660 {"Workspace10Key", "None", (void *)WKBD_WORKSPACE10,
661 NULL, getKeybind, setKeyGrab, NULL, NULL},
662 {"MoveToWorkspace1Key", "None", (void *)WKBD_MOVE_WORKSPACE1,
663 NULL, getKeybind, setKeyGrab, NULL, NULL},
664 {"MoveToWorkspace2Key", "None", (void *)WKBD_MOVE_WORKSPACE2,
665 NULL, getKeybind, setKeyGrab, NULL, NULL},
666 {"MoveToWorkspace3Key", "None", (void *)WKBD_MOVE_WORKSPACE3,
667 NULL, getKeybind, setKeyGrab, NULL, NULL},
668 {"MoveToWorkspace4Key", "None", (void *)WKBD_MOVE_WORKSPACE4,
669 NULL, getKeybind, setKeyGrab, NULL, NULL},
670 {"MoveToWorkspace5Key", "None", (void *)WKBD_MOVE_WORKSPACE5,
671 NULL, getKeybind, setKeyGrab, NULL, NULL},
672 {"MoveToWorkspace6Key", "None", (void *)WKBD_MOVE_WORKSPACE6,
673 NULL, getKeybind, setKeyGrab, NULL, NULL},
674 {"MoveToWorkspace7Key", "None", (void *)WKBD_MOVE_WORKSPACE7,
675 NULL, getKeybind, setKeyGrab, NULL, NULL},
676 {"MoveToWorkspace8Key", "None", (void *)WKBD_MOVE_WORKSPACE8,
677 NULL, getKeybind, setKeyGrab, NULL, NULL},
678 {"MoveToWorkspace9Key", "None", (void *)WKBD_MOVE_WORKSPACE9,
679 NULL, getKeybind, setKeyGrab, NULL, NULL},
680 {"MoveToWorkspace10Key", "None", (void *)WKBD_MOVE_WORKSPACE10,
681 NULL, getKeybind, setKeyGrab, NULL, NULL},
682 {"MoveToNextWorkspaceKey", "None", (void *)WKBD_MOVE_NEXTWORKSPACE,
683 NULL, getKeybind, setKeyGrab, NULL, NULL},
684 {"MoveToPrevWorkspaceKey", "None", (void *)WKBD_MOVE_PREVWORKSPACE,
685 NULL, getKeybind, setKeyGrab, NULL, NULL},
686 {"MoveToLastWorkspaceKey", "None", (void *)WKBD_MOVE_LASTWORKSPACE,
687 NULL, getKeybind, setKeyGrab, NULL, NULL},
688 {"MoveToNextWorkspaceLayerKey", "None", (void *)WKBD_MOVE_NEXTWSLAYER,
689 NULL, getKeybind, setKeyGrab, NULL, NULL},
690 {"MoveToPrevWorkspaceLayerKey", "None", (void *)WKBD_MOVE_PREVWSLAYER,
691 NULL, getKeybind, setKeyGrab, NULL, NULL},
692 {"WindowShortcut1Key", "None", (void *)WKBD_WINDOW1,
693 NULL, getKeybind, setKeyGrab, NULL, NULL},
694 {"WindowShortcut2Key", "None", (void *)WKBD_WINDOW2,
695 NULL, getKeybind, setKeyGrab, NULL, NULL},
696 {"WindowShortcut3Key", "None", (void *)WKBD_WINDOW3,
697 NULL, getKeybind, setKeyGrab, NULL, NULL},
698 {"WindowShortcut4Key", "None", (void *)WKBD_WINDOW4,
699 NULL, getKeybind, setKeyGrab, NULL, NULL},
700 {"WindowShortcut5Key", "None", (void *)WKBD_WINDOW5,
701 NULL, getKeybind, setKeyGrab, NULL, NULL},
702 {"WindowShortcut6Key", "None", (void *)WKBD_WINDOW6,
703 NULL, getKeybind, setKeyGrab, NULL, NULL},
704 {"WindowShortcut7Key", "None", (void *)WKBD_WINDOW7,
705 NULL, getKeybind, setKeyGrab, NULL, NULL},
706 {"WindowShortcut8Key", "None", (void *)WKBD_WINDOW8,
707 NULL, getKeybind, setKeyGrab, NULL, NULL},
708 {"WindowShortcut9Key", "None", (void *)WKBD_WINDOW9,
709 NULL, getKeybind, setKeyGrab, NULL, NULL},
710 {"WindowShortcut10Key", "None", (void *)WKBD_WINDOW10,
711 NULL, getKeybind, setKeyGrab, NULL, NULL},
712 {"WindowRelaunchKey", "None", (void *)WKBD_RELAUNCH,
713 NULL, getKeybind, setKeyGrab, NULL, NULL},
714 {"ScreenSwitchKey", "None", (void *)WKBD_SWITCH_SCREEN,
715 NULL, getKeybind, setKeyGrab, NULL, NULL},
717 #ifdef KEEP_XKB_LOCK_STATUS
718 {"ToggleKbdModeKey", "None", (void *)WKBD_TOGGLE,
719 NULL, getKeybind, setKeyGrab, NULL, NULL},
720 {"KbdModeLock", "NO", NULL,
721 &wPreferences.modelock, getBool, NULL, NULL, NULL},
722 #endif /* KEEP_XKB_LOCK_STATUS */
724 {"NormalCursor", "(builtin, left_ptr)", (void *)WCUR_ROOT,
725 NULL, getCursor, setCursor, NULL, NULL},
726 {"ArrowCursor", "(builtin, top_left_arrow)", (void *)WCUR_ARROW,
727 NULL, getCursor, setCursor, NULL, NULL},
728 {"MoveCursor", "(builtin, fleur)", (void *)WCUR_MOVE,
729 NULL, getCursor, setCursor, NULL, NULL},
730 {"ResizeCursor", "(builtin, sizing)", (void *)WCUR_RESIZE,
731 NULL, getCursor, setCursor, NULL, NULL},
732 {"TopLeftResizeCursor", "(builtin, top_left_corner)", (void *)WCUR_TOPLEFTRESIZE,
733 NULL, getCursor, setCursor, NULL, NULL},
734 {"TopRightResizeCursor", "(builtin, top_right_corner)", (void *)WCUR_TOPRIGHTRESIZE,
735 NULL, getCursor, setCursor, NULL, NULL},
736 {"BottomLeftResizeCursor", "(builtin, bottom_left_corner)", (void *)WCUR_BOTTOMLEFTRESIZE,
737 NULL, getCursor, setCursor, NULL, NULL},
738 {"BottomRightResizeCursor", "(builtin, bottom_right_corner)", (void *)WCUR_BOTTOMRIGHTRESIZE,
739 NULL, getCursor, setCursor, NULL, NULL},
740 {"VerticalResizeCursor", "(builtin, sb_v_double_arrow)", (void *)WCUR_VERTICALRESIZE,
741 NULL, getCursor, setCursor, NULL, NULL},
742 {"HorizontalResizeCursor", "(builtin, sb_h_double_arrow)", (void *)WCUR_HORIZONRESIZE,
743 NULL, getCursor, setCursor, NULL, NULL},
744 {"WaitCursor", "(builtin, watch)", (void *)WCUR_WAIT,
745 NULL, getCursor, setCursor, NULL, NULL},
746 {"QuestionCursor", "(builtin, question_arrow)", (void *)WCUR_QUESTION,
747 NULL, getCursor, setCursor, NULL, NULL},
748 {"TextCursor", "(builtin, xterm)", (void *)WCUR_TEXT,
749 NULL, getCursor, setCursor, NULL, NULL},
750 {"SelectCursor", "(builtin, cross)", (void *)WCUR_SELECT,
751 NULL, getCursor, setCursor, NULL, NULL},
752 {"DialogHistoryLines", "500", NULL,
753 &wPreferences.history_lines, getInt, NULL, NULL, NULL},
754 {"CycleActiveHeadOnly", "NO", NULL,
755 &wPreferences.cycle_active_head_only, getBool, NULL, NULL, NULL},
756 {"CycleIgnoreMinimized", "NO", NULL,
757 &wPreferences.cycle_ignore_minimized, getBool, NULL, NULL, NULL}
760 static void initDefaults(void)
762 unsigned int i;
763 WDefaultEntry *entry;
765 WMPLSetCaseSensitive(False);
767 for (i = 0; i < sizeof(optionList) / sizeof(optionList[0]); i++) {
768 entry = &optionList[i];
770 entry->plkey = WMCreatePLString(entry->key);
771 if (entry->default_value)
772 entry->plvalue = WMCreatePropListFromDescription(entry->default_value);
773 else
774 entry->plvalue = NULL;
777 for (i = 0; i < sizeof(staticOptionList) / sizeof(staticOptionList[0]); i++) {
778 entry = &staticOptionList[i];
780 entry->plkey = WMCreatePLString(entry->key);
781 if (entry->default_value)
782 entry->plvalue = WMCreatePropListFromDescription(entry->default_value);
783 else
784 entry->plvalue = NULL;
788 static WMPropList *readGlobalDomain(char *domainName, Bool requireDictionary)
790 WMPropList *globalDict = NULL;
791 char path[PATH_MAX];
792 struct stat stbuf;
794 snprintf(path, sizeof(path), "%s/%s/%s", SYSCONFDIR, GLOBAL_DEFAULTS_SUBDIR, domainName);
795 if (stat(path, &stbuf) >= 0) {
796 globalDict = WMReadPropListFromFile(path);
797 if (globalDict && requireDictionary && !WMIsPLDictionary(globalDict)) {
798 wwarning(_("Domain %s (%s) of global defaults database is corrupted!"), domainName, path);
799 WMReleasePropList(globalDict);
800 globalDict = NULL;
801 } else if (!globalDict) {
802 wwarning(_("could not load domain %s from global defaults database"), domainName);
806 return globalDict;
809 #if defined(GLOBAL_PREAMBLE_MENU_FILE) || defined(GLOBAL_EPILOGUE_MENU_FILE)
810 static void prependMenu(WMPropList * destarr, WMPropList * array)
812 WMPropList *item;
813 int i;
815 for (i = 0; i < WMGetPropListItemCount(array); i++) {
816 item = WMGetFromPLArray(array, i);
817 if (item)
818 WMInsertInPLArray(destarr, i + 1, item);
822 static void appendMenu(WMPropList * destarr, WMPropList * array)
824 WMPropList *item;
825 int i;
827 for (i = 0; i < WMGetPropListItemCount(array); i++) {
828 item = WMGetFromPLArray(array, i);
829 if (item)
830 WMAddToPLArray(destarr, item);
833 #endif
835 void wDefaultsMergeGlobalMenus(WDDomain * menuDomain)
837 WMPropList *menu = menuDomain->dictionary;
838 WMPropList *submenu;
840 if (!menu || !WMIsPLArray(menu))
841 return;
843 #ifdef GLOBAL_PREAMBLE_MENU_FILE
844 submenu = WMReadPropListFromFile(SYSCONFDIR "/" GLOBAL_DEFAULTS_SUBDIR "/" GLOBAL_PREAMBLE_MENU_FILE);
846 if (submenu && !WMIsPLArray(submenu)) {
847 wwarning(_("invalid global menu file %s"), GLOBAL_PREAMBLE_MENU_FILE);
848 WMReleasePropList(submenu);
849 submenu = NULL;
851 if (submenu) {
852 prependMenu(menu, submenu);
853 WMReleasePropList(submenu);
855 #endif
857 #ifdef GLOBAL_EPILOGUE_MENU_FILE
858 submenu = WMReadPropListFromFile(SYSCONFDIR "/" GLOBAL_DEFAULTS_SUBDIR "/" GLOBAL_EPILOGUE_MENU_FILE);
860 if (submenu && !WMIsPLArray(submenu)) {
861 wwarning(_("invalid global menu file %s"), GLOBAL_EPILOGUE_MENU_FILE);
862 WMReleasePropList(submenu);
863 submenu = NULL;
865 if (submenu) {
866 appendMenu(menu, submenu);
867 WMReleasePropList(submenu);
869 #endif
871 menuDomain->dictionary = menu;
874 WDDomain *wDefaultsInitDomain(char *domain, Bool requireDictionary)
876 WDDomain *db;
877 struct stat stbuf;
878 static int inited = 0;
879 char *the_path;
880 WMPropList *shared_dict = NULL;
882 if (!inited) {
883 inited = 1;
884 initDefaults();
887 db = wmalloc(sizeof(WDDomain));
888 db->domain_name = domain;
889 db->path = wdefaultspathfordomain(domain);
890 the_path = db->path;
892 if (the_path && stat(the_path, &stbuf) >= 0) {
893 db->dictionary = WMReadPropListFromFile(the_path);
894 if (db->dictionary) {
895 if (requireDictionary && !WMIsPLDictionary(db->dictionary)) {
896 WMReleasePropList(db->dictionary);
897 db->dictionary = NULL;
898 wwarning(_("Domain %s (%s) of defaults database is corrupted!"), domain, the_path);
900 db->timestamp = stbuf.st_mtime;
901 } else {
902 wwarning(_("could not load domain %s from user defaults database"), domain);
906 /* global system dictionary */
907 shared_dict = readGlobalDomain(domain, requireDictionary);
909 if (shared_dict && db->dictionary && WMIsPLDictionary(shared_dict) &&
910 WMIsPLDictionary(db->dictionary)) {
911 WMMergePLDictionaries(shared_dict, db->dictionary, True);
912 WMReleasePropList(db->dictionary);
913 db->dictionary = shared_dict;
914 if (stbuf.st_mtime > db->timestamp)
915 db->timestamp = stbuf.st_mtime;
916 } else if (!db->dictionary) {
917 db->dictionary = shared_dict;
918 if (stbuf.st_mtime > db->timestamp)
919 db->timestamp = stbuf.st_mtime;
922 return db;
925 void wReadStaticDefaults(WMPropList * dict)
927 WMPropList *plvalue;
928 WDefaultEntry *entry;
929 unsigned int i;
930 void *tdata;
932 for (i = 0; i < sizeof(staticOptionList) / sizeof(staticOptionList[0]); i++) {
933 entry = &staticOptionList[i];
935 if (dict)
936 plvalue = WMGetFromPLDictionary(dict, entry->plkey);
937 else
938 plvalue = NULL;
940 /* no default in the DB. Use builtin default */
941 if (!plvalue)
942 plvalue = entry->plvalue;
944 if (plvalue) {
945 /* convert data */
946 (*entry->convert) (NULL, entry, plvalue, entry->addr, &tdata);
947 if (entry->update)
948 (*entry->update) (NULL, entry, tdata, entry->extra_data);
953 void wDefaultsCheckDomains(void* arg)
955 WScreen *scr;
956 struct stat stbuf;
957 WMPropList *shared_dict = NULL;
958 WMPropList *dict;
959 int i;
961 if (stat(WDWindowMaker->path, &stbuf) >= 0 && WDWindowMaker->timestamp < stbuf.st_mtime) {
962 WDWindowMaker->timestamp = stbuf.st_mtime;
964 /* Global dictionary */
965 shared_dict = readGlobalDomain("WindowMaker", True);
967 /* User dictionary */
968 dict = WMReadPropListFromFile(WDWindowMaker->path);
970 if (dict) {
971 if (!WMIsPLDictionary(dict)) {
972 WMReleasePropList(dict);
973 dict = NULL;
974 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
975 "WindowMaker", WDWindowMaker->path);
976 } else {
977 if (shared_dict) {
978 WMMergePLDictionaries(shared_dict, dict, True);
979 WMReleasePropList(dict);
980 dict = shared_dict;
981 shared_dict = NULL;
984 for (i = 0; i < wScreenCount; i++) {
985 scr = wScreenWithNumber(i);
986 if (scr)
987 wReadDefaults(scr, dict);
990 if (WDWindowMaker->dictionary)
991 WMReleasePropList(WDWindowMaker->dictionary);
993 WDWindowMaker->dictionary = dict;
995 } else {
996 wwarning(_("could not load domain %s from user defaults database"), "WindowMaker");
999 if (shared_dict)
1000 WMReleasePropList(shared_dict);
1004 if (stat(WDWindowAttributes->path, &stbuf) >= 0 && WDWindowAttributes->timestamp < stbuf.st_mtime) {
1005 /* global dictionary */
1006 shared_dict = readGlobalDomain("WMWindowAttributes", True);
1007 /* user dictionary */
1008 dict = WMReadPropListFromFile(WDWindowAttributes->path);
1009 if (dict) {
1010 if (!WMIsPLDictionary(dict)) {
1011 WMReleasePropList(dict);
1012 dict = NULL;
1013 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
1014 "WMWindowAttributes", WDWindowAttributes->path);
1015 } else {
1016 if (shared_dict) {
1017 WMMergePLDictionaries(shared_dict, dict, True);
1018 WMReleasePropList(dict);
1019 dict = shared_dict;
1020 shared_dict = NULL;
1023 if (WDWindowAttributes->dictionary)
1024 WMReleasePropList(WDWindowAttributes->dictionary);
1026 WDWindowAttributes->dictionary = dict;
1027 for (i = 0; i < wScreenCount; i++) {
1028 scr = wScreenWithNumber(i);
1029 if (scr) {
1030 wDefaultUpdateIcons(scr);
1032 /* Update the panel image if changed */
1033 /* Don't worry. If the image is the same these
1034 * functions will have no performance impact. */
1035 create_logo_image(scr);
1039 } else {
1040 wwarning(_("could not load domain %s from user defaults database"), "WMWindowAttributes");
1043 WDWindowAttributes->timestamp = stbuf.st_mtime;
1044 if (shared_dict)
1045 WMReleasePropList(shared_dict);
1048 if (stat(WDRootMenu->path, &stbuf) >= 0 && WDRootMenu->timestamp < stbuf.st_mtime) {
1049 dict = WMReadPropListFromFile(WDRootMenu->path);
1050 if (dict) {
1051 if (!WMIsPLArray(dict) && !WMIsPLString(dict)) {
1052 WMReleasePropList(dict);
1053 dict = NULL;
1054 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
1055 "WMRootMenu", WDRootMenu->path);
1056 } else {
1057 if (WDRootMenu->dictionary)
1058 WMReleasePropList(WDRootMenu->dictionary);
1060 WDRootMenu->dictionary = dict;
1061 wDefaultsMergeGlobalMenus(WDRootMenu);
1063 } else {
1064 wwarning(_("could not load domain %s from user defaults database"), "WMRootMenu");
1066 WDRootMenu->timestamp = stbuf.st_mtime;
1068 #ifndef HAVE_INOTIFY
1069 if (!arg)
1070 WMAddTimerHandler(DEFAULTS_CHECK_INTERVAL, wDefaultsCheckDomains, arg);
1071 #endif
1074 void wReadDefaults(WScreen * scr, WMPropList * new_dict)
1076 WMPropList *plvalue, *old_value;
1077 WDefaultEntry *entry;
1078 unsigned int i;
1079 int update_workspace_back = 0; /* kluge :/ */
1080 unsigned int needs_refresh;
1081 void *tdata;
1082 WMPropList *old_dict = (WDWindowMaker->dictionary != new_dict ? WDWindowMaker->dictionary : NULL);
1084 needs_refresh = 0;
1086 for (i = 0; i < sizeof(optionList) / sizeof(optionList[0]); i++) {
1087 entry = &optionList[i];
1089 if (new_dict)
1090 plvalue = WMGetFromPLDictionary(new_dict, entry->plkey);
1091 else
1092 plvalue = NULL;
1094 if (!old_dict)
1095 old_value = NULL;
1096 else
1097 old_value = WMGetFromPLDictionary(old_dict, entry->plkey);
1099 if (!plvalue && !old_value) {
1100 /* no default in the DB. Use builtin default */
1101 plvalue = entry->plvalue;
1102 if (plvalue && new_dict)
1103 WMPutInPLDictionary(new_dict, entry->plkey, plvalue);
1105 } else if (!plvalue) {
1106 /* value was deleted from DB. Keep current value */
1107 continue;
1108 } else if (!old_value) {
1109 /* set value for the 1st time */
1110 } else if (!WMIsPropListEqualTo(plvalue, old_value)) {
1111 /* value has changed */
1112 } else {
1113 if (strcmp(entry->key, "WorkspaceBack") == 0
1114 && update_workspace_back && scr->flags.backimage_helper_launched) {
1115 } else {
1116 /* value was not changed since last time */
1117 continue;
1121 if (plvalue) {
1122 /* convert data */
1123 if ((*entry->convert) (scr, entry, plvalue, entry->addr, &tdata)) {
1125 * If the WorkspaceSpecificBack data has been changed
1126 * so that the helper will be launched now, we must be
1127 * sure to send the default background texture config
1128 * to the helper.
1130 if (strcmp(entry->key, "WorkspaceSpecificBack") == 0 &&
1131 !scr->flags.backimage_helper_launched)
1132 update_workspace_back = 1;
1134 if (entry->update)
1135 needs_refresh |= (*entry->update) (scr, entry, tdata, entry->extra_data);
1141 if (needs_refresh != 0 && !scr->flags.startup) {
1142 int foo;
1144 foo = 0;
1145 if (needs_refresh & REFRESH_MENU_TITLE_TEXTURE)
1146 foo |= WTextureSettings;
1147 if (needs_refresh & REFRESH_MENU_TITLE_FONT)
1148 foo |= WFontSettings;
1149 if (needs_refresh & REFRESH_MENU_TITLE_COLOR)
1150 foo |= WColorSettings;
1151 if (foo)
1152 WMPostNotificationName(WNMenuTitleAppearanceSettingsChanged, NULL,
1153 (void *)(uintptr_t) foo);
1155 foo = 0;
1156 if (needs_refresh & REFRESH_MENU_TEXTURE)
1157 foo |= WTextureSettings;
1158 if (needs_refresh & REFRESH_MENU_FONT)
1159 foo |= WFontSettings;
1160 if (needs_refresh & REFRESH_MENU_COLOR)
1161 foo |= WColorSettings;
1162 if (foo)
1163 WMPostNotificationName(WNMenuAppearanceSettingsChanged, NULL, (void *)(uintptr_t) foo);
1165 foo = 0;
1166 if (needs_refresh & REFRESH_WINDOW_FONT)
1167 foo |= WFontSettings;
1168 if (needs_refresh & REFRESH_WINDOW_TEXTURES)
1169 foo |= WTextureSettings;
1170 if (needs_refresh & REFRESH_WINDOW_TITLE_COLOR)
1171 foo |= WColorSettings;
1172 if (foo)
1173 WMPostNotificationName(WNWindowAppearanceSettingsChanged, NULL, (void *)(uintptr_t) foo);
1175 if (!(needs_refresh & REFRESH_ICON_TILE)) {
1176 foo = 0;
1177 if (needs_refresh & REFRESH_ICON_FONT)
1178 foo |= WFontSettings;
1179 if (needs_refresh & REFRESH_ICON_TITLE_COLOR)
1180 foo |= WTextureSettings;
1181 if (needs_refresh & REFRESH_ICON_TITLE_BACK)
1182 foo |= WTextureSettings;
1183 if (foo)
1184 WMPostNotificationName(WNIconAppearanceSettingsChanged, NULL,
1185 (void *)(uintptr_t) foo);
1187 if (needs_refresh & REFRESH_ICON_TILE)
1188 WMPostNotificationName(WNIconTileSettingsChanged, NULL, NULL);
1190 if (needs_refresh & REFRESH_WORKSPACE_MENU) {
1191 if (scr->workspace_menu)
1192 wWorkspaceMenuUpdate(scr, scr->workspace_menu);
1193 if (scr->clip_ws_menu)
1194 wWorkspaceMenuUpdate(scr, scr->clip_ws_menu);
1195 if (scr->workspace_submenu)
1196 scr->workspace_submenu->flags.realized = 0;
1197 if (scr->clip_submenu)
1198 scr->clip_submenu->flags.realized = 0;
1203 void wDefaultUpdateIcons(WScreen *scr)
1205 WAppIcon *aicon = scr->app_icon_list;
1206 WDrawerChain *dc;
1207 WWindow *wwin = scr->focused_window;
1209 while (aicon) {
1210 /* Get the application icon, default included */
1211 wIconChangeImageFile(aicon->icon, NULL);
1212 wAppIconPaint(aicon);
1213 aicon = aicon->next;
1216 if (!wPreferences.flags.noclip || wPreferences.flags.clip_merged_in_dock)
1217 wClipIconPaint(scr->clip_icon);
1219 for (dc = scr->drawers; dc != NULL; dc = dc->next)
1220 wDrawerIconPaint(dc->adrawer->icon_array[0]);
1222 while (wwin) {
1223 if (wwin->icon && wwin->flags.miniaturized)
1224 wIconChangeImageFile(wwin->icon, NULL);
1225 wwin = wwin->prev;
1229 /* --------------------------- Local ----------------------- */
1231 #define GET_STRING_OR_DEFAULT(x, var) if (!WMIsPLString(value)) { \
1232 wwarning(_("Wrong option format for key \"%s\". Should be %s."), \
1233 entry->key, x); \
1234 wwarning(_("using default \"%s\" instead"), entry->default_value); \
1235 var = entry->default_value;\
1236 } else var = WMGetFromPLString(value)\
1239 static int string2index(WMPropList * key, WMPropList * val, char *def, WOptionEnumeration * values)
1241 char *str;
1242 WOptionEnumeration *v;
1243 char buffer[TOTAL_VALUES_LENGTH];
1245 if (WMIsPLString(val) && (str = WMGetFromPLString(val))) {
1246 for (v = values; v->string != NULL; v++) {
1247 if (strcasecmp(v->string, str) == 0)
1248 return v->value;
1252 buffer[0] = 0;
1253 for (v = values; v->string != NULL; v++) {
1254 if (!v->is_alias) {
1255 if (buffer[0] != 0)
1256 strcat(buffer, ", ");
1257 snprintf(buffer+strlen(buffer),
1258 sizeof(buffer)-strlen(buffer)-1, "\"%s\"", v->string);
1261 wwarning(_("wrong option value for key \"%s\"; got \"%s\", should be one of %s."),
1262 WMGetFromPLString(key),
1263 WMIsPLString(val) ? WMGetFromPLString(val) : "(unknown)",
1264 buffer);
1266 if (def) {
1267 return string2index(key, val, NULL, values);
1270 return -1;
1274 * value - is the value in the defaults DB
1275 * addr - is the address to store the data
1276 * ret - is the address to store a pointer to a temporary buffer. ret
1277 * must not be freed and is used by the set functions
1279 static int getBool(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1281 static char data;
1282 char *val;
1283 int second_pass = 0;
1285 GET_STRING_OR_DEFAULT("Boolean", val);
1287 again:
1288 if ((val[1] == '\0' && (val[0] == 'y' || val[0] == 'Y'))
1289 || strcasecmp(val, "YES") == 0) {
1291 data = 1;
1292 } else if ((val[1] == '\0' && (val[0] == 'n' || val[0] == 'N'))
1293 || strcasecmp(val, "NO") == 0) {
1294 data = 0;
1295 } else {
1296 int i;
1297 if (sscanf(val, "%i", &i) == 1) {
1298 if (i != 0)
1299 data = 1;
1300 else
1301 data = 0;
1302 } else {
1303 wwarning(_("can't convert \"%s\" to boolean for key \"%s\""), val, entry->key);
1304 if (second_pass == 0) {
1305 val = WMGetFromPLString(entry->plvalue);
1306 second_pass = 1;
1307 wwarning(_("using default \"%s\" instead"), val);
1308 goto again;
1310 return False;
1314 if (ret)
1315 *ret = &data;
1316 if (addr)
1317 *(char *)addr = data;
1319 return True;
1322 static int getInt(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1324 static int data;
1325 char *val;
1327 GET_STRING_OR_DEFAULT("Integer", val);
1329 if (sscanf(val, "%i", &data) != 1) {
1330 wwarning(_("can't convert \"%s\" to integer for key \"%s\""), val, entry->key);
1331 val = WMGetFromPLString(entry->plvalue);
1332 wwarning(_("using default \"%s\" instead"), val);
1333 if (sscanf(val, "%i", &data) != 1) {
1334 return False;
1338 if (ret)
1339 *ret = &data;
1340 if (addr)
1341 *(int *)addr = data;
1343 return True;
1346 static int getCoord(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1348 static WCoord data;
1349 char *val_x, *val_y;
1350 int nelem, changed = 0;
1351 WMPropList *elem_x, *elem_y;
1353 again:
1354 if (!WMIsPLArray(value)) {
1355 wwarning(_("Wrong option format for key \"%s\". Should be %s."), entry->key, "Coordinate");
1356 if (changed == 0) {
1357 value = entry->plvalue;
1358 changed = 1;
1359 wwarning(_("using default \"%s\" instead"), entry->default_value);
1360 goto again;
1362 return False;
1365 nelem = WMGetPropListItemCount(value);
1366 if (nelem != 2) {
1367 wwarning(_("Incorrect number of elements in array for key \"%s\"."), entry->key);
1368 if (changed == 0) {
1369 value = entry->plvalue;
1370 changed = 1;
1371 wwarning(_("using default \"%s\" instead"), entry->default_value);
1372 goto again;
1374 return False;
1377 elem_x = WMGetFromPLArray(value, 0);
1378 elem_y = WMGetFromPLArray(value, 1);
1380 if (!elem_x || !elem_y || !WMIsPLString(elem_x) || !WMIsPLString(elem_y)) {
1381 wwarning(_("Wrong value for key \"%s\". Should be Coordinate."), entry->key);
1382 if (changed == 0) {
1383 value = entry->plvalue;
1384 changed = 1;
1385 wwarning(_("using default \"%s\" instead"), entry->default_value);
1386 goto again;
1388 return False;
1391 val_x = WMGetFromPLString(elem_x);
1392 val_y = WMGetFromPLString(elem_y);
1394 if (sscanf(val_x, "%i", &data.x) != 1 || sscanf(val_y, "%i", &data.y) != 1) {
1395 wwarning(_("can't convert array to integers for \"%s\"."), entry->key);
1396 if (changed == 0) {
1397 value = entry->plvalue;
1398 changed = 1;
1399 wwarning(_("using default \"%s\" instead"), entry->default_value);
1400 goto again;
1402 return False;
1405 if (data.x < 0)
1406 data.x = 0;
1407 else if (data.x > scr->scr_width / 3)
1408 data.x = scr->scr_width / 3;
1409 if (data.y < 0)
1410 data.y = 0;
1411 else if (data.y > scr->scr_height / 3)
1412 data.y = scr->scr_height / 3;
1414 if (ret)
1415 *ret = &data;
1416 if (addr)
1417 *(WCoord *) addr = data;
1419 return True;
1422 static int getPropList(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1424 WMRetainPropList(value);
1426 *ret = value;
1428 return True;
1431 static int getPathList(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1433 static char *data;
1434 int i, count, len;
1435 char *ptr;
1436 WMPropList *d;
1437 int changed = 0;
1439 again:
1440 if (!WMIsPLArray(value)) {
1441 wwarning(_("Wrong option format for key \"%s\". Should be %s."), entry->key, "an array of paths");
1442 if (changed == 0) {
1443 value = entry->plvalue;
1444 changed = 1;
1445 wwarning(_("using default \"%s\" instead"), entry->default_value);
1446 goto again;
1448 return False;
1451 i = 0;
1452 count = WMGetPropListItemCount(value);
1453 if (count < 1) {
1454 if (changed == 0) {
1455 value = entry->plvalue;
1456 changed = 1;
1457 wwarning(_("using default \"%s\" instead"), entry->default_value);
1458 goto again;
1460 return False;
1463 len = 0;
1464 for (i = 0; i < count; i++) {
1465 d = WMGetFromPLArray(value, i);
1466 if (!d || !WMIsPLString(d)) {
1467 count = i;
1468 break;
1470 len += strlen(WMGetFromPLString(d)) + 1;
1473 ptr = data = wmalloc(len + 1);
1475 for (i = 0; i < count; i++) {
1476 d = WMGetFromPLArray(value, i);
1477 if (!d || !WMIsPLString(d)) {
1478 break;
1480 strcpy(ptr, WMGetFromPLString(d));
1481 ptr += strlen(WMGetFromPLString(d));
1482 *ptr = ':';
1483 ptr++;
1485 ptr--;
1486 *(ptr--) = 0;
1488 if (*(char **)addr != NULL) {
1489 wfree(*(char **)addr);
1491 *(char **)addr = data;
1493 return True;
1496 static int getEnum(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1498 static signed char data;
1500 data = string2index(entry->plkey, value, entry->default_value, (WOptionEnumeration *) entry->extra_data);
1501 if (data < 0)
1502 return False;
1504 if (ret)
1505 *ret = &data;
1506 if (addr)
1507 *(signed char *)addr = data;
1509 return True;
1513 * (solid <color>)
1514 * (hgradient <color> <color>)
1515 * (vgradient <color> <color>)
1516 * (dgradient <color> <color>)
1517 * (mhgradient <color> <color> ...)
1518 * (mvgradient <color> <color> ...)
1519 * (mdgradient <color> <color> ...)
1520 * (igradient <color1> <color1> <thickness1> <color2> <color2> <thickness2>)
1521 * (tpixmap <file> <color>)
1522 * (spixmap <file> <color>)
1523 * (cpixmap <file> <color>)
1524 * (thgradient <file> <opaqueness> <color> <color>)
1525 * (tvgradient <file> <opaqueness> <color> <color>)
1526 * (tdgradient <file> <opaqueness> <color> <color>)
1527 * (function <lib> <function> ...)
1530 static WTexture *parse_texture(WScreen * scr, WMPropList * pl)
1532 WMPropList *elem;
1533 char *val;
1534 int nelem;
1535 WTexture *texture = NULL;
1537 nelem = WMGetPropListItemCount(pl);
1538 if (nelem < 1)
1539 return NULL;
1541 elem = WMGetFromPLArray(pl, 0);
1542 if (!elem || !WMIsPLString(elem))
1543 return NULL;
1544 val = WMGetFromPLString(elem);
1546 if (strcasecmp(val, "solid") == 0) {
1547 XColor color;
1549 if (nelem != 2)
1550 return NULL;
1552 /* get color */
1554 elem = WMGetFromPLArray(pl, 1);
1555 if (!elem || !WMIsPLString(elem))
1556 return NULL;
1557 val = WMGetFromPLString(elem);
1559 if (!XParseColor(dpy, scr->w_colormap, val, &color)) {
1560 wwarning(_("\"%s\" is not a valid color name"), val);
1561 return NULL;
1564 texture = (WTexture *) wTextureMakeSolid(scr, &color);
1565 } else if (strcasecmp(val, "dgradient") == 0
1566 || strcasecmp(val, "vgradient") == 0 || strcasecmp(val, "hgradient") == 0) {
1567 RColor color1, color2;
1568 XColor xcolor;
1569 int type;
1571 if (nelem != 3) {
1572 wwarning(_("bad number of arguments in gradient specification"));
1573 return NULL;
1576 if (val[0] == 'd' || val[0] == 'D')
1577 type = WTEX_DGRADIENT;
1578 else if (val[0] == 'h' || val[0] == 'H')
1579 type = WTEX_HGRADIENT;
1580 else
1581 type = WTEX_VGRADIENT;
1583 /* get from color */
1584 elem = WMGetFromPLArray(pl, 1);
1585 if (!elem || !WMIsPLString(elem))
1586 return NULL;
1587 val = WMGetFromPLString(elem);
1589 if (!XParseColor(dpy, scr->w_colormap, val, &xcolor)) {
1590 wwarning(_("\"%s\" is not a valid color name"), val);
1591 return NULL;
1593 color1.alpha = 255;
1594 color1.red = xcolor.red >> 8;
1595 color1.green = xcolor.green >> 8;
1596 color1.blue = xcolor.blue >> 8;
1598 /* get to color */
1599 elem = WMGetFromPLArray(pl, 2);
1600 if (!elem || !WMIsPLString(elem)) {
1601 return NULL;
1603 val = WMGetFromPLString(elem);
1605 if (!XParseColor(dpy, scr->w_colormap, val, &xcolor)) {
1606 wwarning(_("\"%s\" is not a valid color name"), val);
1607 return NULL;
1609 color2.alpha = 255;
1610 color2.red = xcolor.red >> 8;
1611 color2.green = xcolor.green >> 8;
1612 color2.blue = xcolor.blue >> 8;
1614 texture = (WTexture *) wTextureMakeGradient(scr, type, &color1, &color2);
1616 } else if (strcasecmp(val, "igradient") == 0) {
1617 RColor colors1[2], colors2[2];
1618 int th1, th2;
1619 XColor xcolor;
1620 int i;
1622 if (nelem != 7) {
1623 wwarning(_("bad number of arguments in gradient specification"));
1624 return NULL;
1627 /* get from color */
1628 for (i = 0; i < 2; i++) {
1629 elem = WMGetFromPLArray(pl, 1 + i);
1630 if (!elem || !WMIsPLString(elem))
1631 return NULL;
1632 val = WMGetFromPLString(elem);
1634 if (!XParseColor(dpy, scr->w_colormap, val, &xcolor)) {
1635 wwarning(_("\"%s\" is not a valid color name"), val);
1636 return NULL;
1638 colors1[i].alpha = 255;
1639 colors1[i].red = xcolor.red >> 8;
1640 colors1[i].green = xcolor.green >> 8;
1641 colors1[i].blue = xcolor.blue >> 8;
1643 elem = WMGetFromPLArray(pl, 3);
1644 if (!elem || !WMIsPLString(elem))
1645 return NULL;
1646 val = WMGetFromPLString(elem);
1647 th1 = atoi(val);
1649 /* get from color */
1650 for (i = 0; i < 2; i++) {
1651 elem = WMGetFromPLArray(pl, 4 + i);
1652 if (!elem || !WMIsPLString(elem))
1653 return NULL;
1654 val = WMGetFromPLString(elem);
1656 if (!XParseColor(dpy, scr->w_colormap, val, &xcolor)) {
1657 wwarning(_("\"%s\" is not a valid color name"), val);
1658 return NULL;
1660 colors2[i].alpha = 255;
1661 colors2[i].red = xcolor.red >> 8;
1662 colors2[i].green = xcolor.green >> 8;
1663 colors2[i].blue = xcolor.blue >> 8;
1665 elem = WMGetFromPLArray(pl, 6);
1666 if (!elem || !WMIsPLString(elem))
1667 return NULL;
1668 val = WMGetFromPLString(elem);
1669 th2 = atoi(val);
1671 texture = (WTexture *) wTextureMakeIGradient(scr, th1, colors1, th2, colors2);
1673 } else if (strcasecmp(val, "mhgradient") == 0
1674 || strcasecmp(val, "mvgradient") == 0 || strcasecmp(val, "mdgradient") == 0) {
1675 XColor color;
1676 RColor **colors;
1677 int i, count;
1678 int type;
1680 if (nelem < 3) {
1681 wwarning(_("too few arguments in multicolor gradient specification"));
1682 return NULL;
1685 if (val[1] == 'h' || val[1] == 'H')
1686 type = WTEX_MHGRADIENT;
1687 else if (val[1] == 'v' || val[1] == 'V')
1688 type = WTEX_MVGRADIENT;
1689 else
1690 type = WTEX_MDGRADIENT;
1692 count = nelem - 1;
1694 colors = wmalloc(sizeof(RColor *) * (count + 1));
1696 for (i = 0; i < count; i++) {
1697 elem = WMGetFromPLArray(pl, i + 1);
1698 if (!elem || !WMIsPLString(elem)) {
1699 for (--i; i >= 0; --i) {
1700 wfree(colors[i]);
1702 wfree(colors);
1703 return NULL;
1705 val = WMGetFromPLString(elem);
1707 if (!XParseColor(dpy, scr->w_colormap, val, &color)) {
1708 wwarning(_("\"%s\" is not a valid color name"), val);
1709 for (--i; i >= 0; --i) {
1710 wfree(colors[i]);
1712 wfree(colors);
1713 return NULL;
1714 } else {
1715 colors[i] = wmalloc(sizeof(RColor));
1716 colors[i]->red = color.red >> 8;
1717 colors[i]->green = color.green >> 8;
1718 colors[i]->blue = color.blue >> 8;
1721 colors[i] = NULL;
1723 texture = (WTexture *) wTextureMakeMGradient(scr, type, colors);
1724 } else if (strcasecmp(val, "spixmap") == 0 ||
1725 strcasecmp(val, "cpixmap") == 0 || strcasecmp(val, "tpixmap") == 0) {
1726 XColor color;
1727 int type;
1729 if (nelem != 3)
1730 return NULL;
1732 if (val[0] == 's' || val[0] == 'S')
1733 type = WTP_SCALE;
1734 else if (val[0] == 'c' || val[0] == 'C')
1735 type = WTP_CENTER;
1736 else
1737 type = WTP_TILE;
1739 /* get color */
1740 elem = WMGetFromPLArray(pl, 2);
1741 if (!elem || !WMIsPLString(elem)) {
1742 return NULL;
1744 val = WMGetFromPLString(elem);
1746 if (!XParseColor(dpy, scr->w_colormap, val, &color)) {
1747 wwarning(_("\"%s\" is not a valid color name"), val);
1748 return NULL;
1751 /* file name */
1752 elem = WMGetFromPLArray(pl, 1);
1753 if (!elem || !WMIsPLString(elem))
1754 return NULL;
1755 val = WMGetFromPLString(elem);
1757 texture = (WTexture *) wTextureMakePixmap(scr, type, val, &color);
1758 } else if (strcasecmp(val, "thgradient") == 0
1759 || strcasecmp(val, "tvgradient") == 0 || strcasecmp(val, "tdgradient") == 0) {
1760 RColor color1, color2;
1761 XColor xcolor;
1762 int opacity;
1763 int style;
1765 if (val[1] == 'h' || val[1] == 'H')
1766 style = WTEX_THGRADIENT;
1767 else if (val[1] == 'v' || val[1] == 'V')
1768 style = WTEX_TVGRADIENT;
1769 else
1770 style = WTEX_TDGRADIENT;
1772 if (nelem != 5) {
1773 wwarning(_("bad number of arguments in textured gradient specification"));
1774 return NULL;
1777 /* get from color */
1778 elem = WMGetFromPLArray(pl, 3);
1779 if (!elem || !WMIsPLString(elem))
1780 return NULL;
1781 val = WMGetFromPLString(elem);
1783 if (!XParseColor(dpy, scr->w_colormap, val, &xcolor)) {
1784 wwarning(_("\"%s\" is not a valid color name"), val);
1785 return NULL;
1787 color1.alpha = 255;
1788 color1.red = xcolor.red >> 8;
1789 color1.green = xcolor.green >> 8;
1790 color1.blue = xcolor.blue >> 8;
1792 /* get to color */
1793 elem = WMGetFromPLArray(pl, 4);
1794 if (!elem || !WMIsPLString(elem)) {
1795 return NULL;
1797 val = WMGetFromPLString(elem);
1799 if (!XParseColor(dpy, scr->w_colormap, val, &xcolor)) {
1800 wwarning(_("\"%s\" is not a valid color name"), val);
1801 return NULL;
1803 color2.alpha = 255;
1804 color2.red = xcolor.red >> 8;
1805 color2.green = xcolor.green >> 8;
1806 color2.blue = xcolor.blue >> 8;
1808 /* get opacity */
1809 elem = WMGetFromPLArray(pl, 2);
1810 if (!elem || !WMIsPLString(elem))
1811 opacity = 128;
1812 else
1813 val = WMGetFromPLString(elem);
1815 if (!val || (opacity = atoi(val)) < 0 || opacity > 255) {
1816 wwarning(_("bad opacity value for tgradient texture \"%s\". Should be [0..255]"), val);
1817 opacity = 128;
1820 /* get file name */
1821 elem = WMGetFromPLArray(pl, 1);
1822 if (!elem || !WMIsPLString(elem))
1823 return NULL;
1824 val = WMGetFromPLString(elem);
1826 texture = (WTexture *) wTextureMakeTGradient(scr, style, &color1, &color2, val, opacity);
1827 } else if (strcasecmp(val, "function") == 0) {
1828 /* Leave this in to handle the unlikely case of
1829 * someone actually having function textures configured */
1830 wwarning("function texture support has been removed");
1831 return NULL;
1832 } else {
1833 wwarning(_("invalid texture type %s"), val);
1834 return NULL;
1836 return texture;
1839 static int getTexture(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1841 static WTexture *texture;
1842 int changed = 0;
1844 again:
1845 if (!WMIsPLArray(value)) {
1846 wwarning(_("Wrong option format for key \"%s\". Should be %s."), entry->key, "Texture");
1847 if (changed == 0) {
1848 value = entry->plvalue;
1849 changed = 1;
1850 wwarning(_("using default \"%s\" instead"), entry->default_value);
1851 goto again;
1853 return False;
1856 if (strcmp(entry->key, "WidgetColor") == 0 && !changed) {
1857 WMPropList *pl;
1859 pl = WMGetFromPLArray(value, 0);
1860 if (!pl || !WMIsPLString(pl) || !WMGetFromPLString(pl)
1861 || strcasecmp(WMGetFromPLString(pl), "solid") != 0) {
1862 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1863 entry->key, "Solid Texture");
1865 value = entry->plvalue;
1866 changed = 1;
1867 wwarning(_("using default \"%s\" instead"), entry->default_value);
1868 goto again;
1872 texture = parse_texture(scr, value);
1874 if (!texture) {
1875 wwarning(_("Error in texture specification for key \"%s\""), entry->key);
1876 if (changed == 0) {
1877 value = entry->plvalue;
1878 changed = 1;
1879 wwarning(_("using default \"%s\" instead"), entry->default_value);
1880 goto again;
1882 return False;
1885 if (ret)
1886 *ret = &texture;
1888 if (addr)
1889 *(WTexture **) addr = texture;
1891 return True;
1894 static int getWSBackground(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1896 WMPropList *elem;
1897 int changed = 0;
1898 char *val;
1899 int nelem;
1901 again:
1902 if (!WMIsPLArray(value)) {
1903 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1904 "WorkspaceBack", "Texture or None");
1905 if (changed == 0) {
1906 value = entry->plvalue;
1907 changed = 1;
1908 wwarning(_("using default \"%s\" instead"), entry->default_value);
1909 goto again;
1911 return False;
1914 /* only do basic error checking and verify for None texture */
1916 nelem = WMGetPropListItemCount(value);
1917 if (nelem > 0) {
1918 elem = WMGetFromPLArray(value, 0);
1919 if (!elem || !WMIsPLString(elem)) {
1920 wwarning(_("Wrong type for workspace background. Should be a texture type."));
1921 if (changed == 0) {
1922 value = entry->plvalue;
1923 changed = 1;
1924 wwarning(_("using default \"%s\" instead"), entry->default_value);
1925 goto again;
1927 return False;
1929 val = WMGetFromPLString(elem);
1931 if (strcasecmp(val, "None") == 0)
1932 return True;
1934 *ret = WMRetainPropList(value);
1936 return True;
1939 static int
1940 getWSSpecificBackground(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1942 WMPropList *elem;
1943 int nelem;
1944 int changed = 0;
1946 again:
1947 if (!WMIsPLArray(value)) {
1948 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1949 "WorkspaceSpecificBack", "an array of textures");
1950 if (changed == 0) {
1951 value = entry->plvalue;
1952 changed = 1;
1953 wwarning(_("using default \"%s\" instead"), entry->default_value);
1954 goto again;
1956 return False;
1959 /* only do basic error checking and verify for None texture */
1961 nelem = WMGetPropListItemCount(value);
1962 if (nelem > 0) {
1963 while (nelem--) {
1964 elem = WMGetFromPLArray(value, nelem);
1965 if (!elem || !WMIsPLArray(elem)) {
1966 wwarning(_("Wrong type for background of workspace %i. Should be a texture."),
1967 nelem);
1972 *ret = WMRetainPropList(value);
1974 #ifdef notworking
1976 * Kluge to force wmsetbg helper to set the default background.
1977 * If the WorkspaceSpecificBack is changed once wmaker has started,
1978 * the WorkspaceBack won't be sent to the helper, unless the user
1979 * changes it's value too. So, we must force this by removing the
1980 * value from the defaults DB.
1982 if (!scr->flags.backimage_helper_launched && !scr->flags.startup) {
1983 WMPropList *key = WMCreatePLString("WorkspaceBack");
1985 WMRemoveFromPLDictionary(WDWindowMaker->dictionary, key);
1987 WMReleasePropList(key);
1989 #endif
1990 return True;
1993 static int getFont(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1995 static WMFont *font;
1996 char *val;
1998 GET_STRING_OR_DEFAULT("Font", val);
2000 font = WMCreateFont(scr->wmscreen, val);
2001 if (!font)
2002 font = WMCreateFont(scr->wmscreen, "fixed");
2004 if (!font) {
2005 wfatal(_("could not load any usable font!!!"));
2006 exit(1);
2009 if (ret)
2010 *ret = font;
2012 /* can't assign font value outside update function */
2013 wassertrv(addr == NULL, True);
2015 return True;
2018 static int getColor(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
2020 static XColor color;
2021 char *val;
2022 int second_pass = 0;
2024 GET_STRING_OR_DEFAULT("Color", val);
2026 again:
2027 if (!wGetColor(scr, val, &color)) {
2028 wwarning(_("could not get color for key \"%s\""), entry->key);
2029 if (second_pass == 0) {
2030 val = WMGetFromPLString(entry->plvalue);
2031 second_pass = 1;
2032 wwarning(_("using default \"%s\" instead"), val);
2033 goto again;
2035 return False;
2038 if (ret)
2039 *ret = &color;
2041 assert(addr == NULL);
2043 if (addr)
2044 *(unsigned long*)addr = pixel;
2047 return True;
2050 static int getKeybind(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
2052 static WShortKey shortcut;
2053 KeySym ksym;
2054 char *val;
2055 char *k;
2056 char buf[MAX_SHORTCUT_LENGTH], *b;
2058 GET_STRING_OR_DEFAULT("Key spec", val);
2060 if (!val || strcasecmp(val, "NONE") == 0) {
2061 shortcut.keycode = 0;
2062 shortcut.modifier = 0;
2063 if (ret)
2064 *ret = &shortcut;
2065 return True;
2068 wstrlcpy(buf, val, MAX_SHORTCUT_LENGTH);
2070 b = (char *)buf;
2072 /* get modifiers */
2073 shortcut.modifier = 0;
2074 while ((k = strchr(b, '+')) != NULL) {
2075 int mod;
2077 *k = 0;
2078 mod = wXModifierFromKey(b);
2079 if (mod < 0) {
2080 wwarning(_("%s: invalid key modifier \"%s\""), entry->key, b);
2081 return False;
2083 shortcut.modifier |= mod;
2085 b = k + 1;
2088 /* get key */
2089 ksym = XStringToKeysym(b);
2091 if (ksym == NoSymbol) {
2092 wwarning(_("%s:invalid kbd shortcut specification \"%s\""), entry->key, val);
2093 return False;
2096 shortcut.keycode = XKeysymToKeycode(dpy, ksym);
2097 if (shortcut.keycode == 0) {
2098 wwarning(_("%s:invalid key in shortcut \"%s\""), entry->key, val);
2099 return False;
2102 if (ret)
2103 *ret = &shortcut;
2105 return True;
2108 static int getModMask(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
2110 static int mask;
2111 char *str;
2113 GET_STRING_OR_DEFAULT("Modifier Key", str);
2115 if (!str)
2116 return False;
2118 mask = wXModifierFromKey(str);
2119 if (mask < 0) {
2120 wwarning(_("%s: modifier key %s is not valid"), entry->key, str);
2121 mask = 0;
2122 return False;
2125 if (addr)
2126 *(int *)addr = mask;
2128 if (ret)
2129 *ret = &mask;
2131 return True;
2134 # include <X11/cursorfont.h>
2135 typedef struct {
2136 char *name;
2137 int id;
2138 } WCursorLookup;
2140 #define CURSOR_ID_NONE (XC_num_glyphs)
2142 static WCursorLookup cursor_table[] = {
2143 {"X_cursor", XC_X_cursor},
2144 {"arrow", XC_arrow},
2145 {"based_arrow_down", XC_based_arrow_down},
2146 {"based_arrow_up", XC_based_arrow_up},
2147 {"boat", XC_boat},
2148 {"bogosity", XC_bogosity},
2149 {"bottom_left_corner", XC_bottom_left_corner},
2150 {"bottom_right_corner", XC_bottom_right_corner},
2151 {"bottom_side", XC_bottom_side},
2152 {"bottom_tee", XC_bottom_tee},
2153 {"box_spiral", XC_box_spiral},
2154 {"center_ptr", XC_center_ptr},
2155 {"circle", XC_circle},
2156 {"clock", XC_clock},
2157 {"coffee_mug", XC_coffee_mug},
2158 {"cross", XC_cross},
2159 {"cross_reverse", XC_cross_reverse},
2160 {"crosshair", XC_crosshair},
2161 {"diamond_cross", XC_diamond_cross},
2162 {"dot", XC_dot},
2163 {"dotbox", XC_dotbox},
2164 {"double_arrow", XC_double_arrow},
2165 {"draft_large", XC_draft_large},
2166 {"draft_small", XC_draft_small},
2167 {"draped_box", XC_draped_box},
2168 {"exchange", XC_exchange},
2169 {"fleur", XC_fleur},
2170 {"gobbler", XC_gobbler},
2171 {"gumby", XC_gumby},
2172 {"hand1", XC_hand1},
2173 {"hand2", XC_hand2},
2174 {"heart", XC_heart},
2175 {"icon", XC_icon},
2176 {"iron_cross", XC_iron_cross},
2177 {"left_ptr", XC_left_ptr},
2178 {"left_side", XC_left_side},
2179 {"left_tee", XC_left_tee},
2180 {"leftbutton", XC_leftbutton},
2181 {"ll_angle", XC_ll_angle},
2182 {"lr_angle", XC_lr_angle},
2183 {"man", XC_man},
2184 {"middlebutton", XC_middlebutton},
2185 {"mouse", XC_mouse},
2186 {"pencil", XC_pencil},
2187 {"pirate", XC_pirate},
2188 {"plus", XC_plus},
2189 {"question_arrow", XC_question_arrow},
2190 {"right_ptr", XC_right_ptr},
2191 {"right_side", XC_right_side},
2192 {"right_tee", XC_right_tee},
2193 {"rightbutton", XC_rightbutton},
2194 {"rtl_logo", XC_rtl_logo},
2195 {"sailboat", XC_sailboat},
2196 {"sb_down_arrow", XC_sb_down_arrow},
2197 {"sb_h_double_arrow", XC_sb_h_double_arrow},
2198 {"sb_left_arrow", XC_sb_left_arrow},
2199 {"sb_right_arrow", XC_sb_right_arrow},
2200 {"sb_up_arrow", XC_sb_up_arrow},
2201 {"sb_v_double_arrow", XC_sb_v_double_arrow},
2202 {"shuttle", XC_shuttle},
2203 {"sizing", XC_sizing},
2204 {"spider", XC_spider},
2205 {"spraycan", XC_spraycan},
2206 {"star", XC_star},
2207 {"target", XC_target},
2208 {"tcross", XC_tcross},
2209 {"top_left_arrow", XC_top_left_arrow},
2210 {"top_left_corner", XC_top_left_corner},
2211 {"top_right_corner", XC_top_right_corner},
2212 {"top_side", XC_top_side},
2213 {"top_tee", XC_top_tee},
2214 {"trek", XC_trek},
2215 {"ul_angle", XC_ul_angle},
2216 {"umbrella", XC_umbrella},
2217 {"ur_angle", XC_ur_angle},
2218 {"watch", XC_watch},
2219 {"xterm", XC_xterm},
2220 {NULL, CURSOR_ID_NONE}
2223 static void check_bitmap_status(int status, char *filename, Pixmap bitmap)
2225 switch (status) {
2226 case BitmapOpenFailed:
2227 wwarning(_("failed to open bitmap file \"%s\""), filename);
2228 break;
2229 case BitmapFileInvalid:
2230 wwarning(_("\"%s\" is not a valid bitmap file"), filename);
2231 break;
2232 case BitmapNoMemory:
2233 wwarning(_("out of memory reading bitmap file \"%s\""), filename);
2234 break;
2235 case BitmapSuccess:
2236 XFreePixmap(dpy, bitmap);
2237 break;
2242 * (none)
2243 * (builtin, <cursor_name>)
2244 * (bitmap, <cursor_bitmap>, <cursor_mask>)
2246 static int parse_cursor(WScreen * scr, WMPropList * pl, Cursor * cursor)
2248 WMPropList *elem;
2249 char *val;
2250 int nelem;
2251 int status = 0;
2253 nelem = WMGetPropListItemCount(pl);
2254 if (nelem < 1) {
2255 return (status);
2257 elem = WMGetFromPLArray(pl, 0);
2258 if (!elem || !WMIsPLString(elem)) {
2259 return (status);
2261 val = WMGetFromPLString(elem);
2263 if (strcasecmp(val, "none") == 0) {
2264 status = 1;
2265 *cursor = None;
2266 } else if (strcasecmp(val, "builtin") == 0) {
2267 int i;
2268 int cursor_id = CURSOR_ID_NONE;
2270 if (nelem != 2) {
2271 wwarning(_("bad number of arguments in cursor specification"));
2272 return (status);
2274 elem = WMGetFromPLArray(pl, 1);
2275 if (!elem || !WMIsPLString(elem)) {
2276 return (status);
2278 val = WMGetFromPLString(elem);
2280 for (i = 0; cursor_table[i].name != NULL; i++) {
2281 if (strcasecmp(val, cursor_table[i].name) == 0) {
2282 cursor_id = cursor_table[i].id;
2283 break;
2286 if (CURSOR_ID_NONE == cursor_id) {
2287 wwarning(_("unknown builtin cursor name \"%s\""), val);
2288 } else {
2289 *cursor = XCreateFontCursor(dpy, cursor_id);
2290 status = 1;
2292 } else if (strcasecmp(val, "bitmap") == 0) {
2293 char *bitmap_name;
2294 char *mask_name;
2295 int bitmap_status;
2296 int mask_status;
2297 Pixmap bitmap;
2298 Pixmap mask;
2299 unsigned int w, h;
2300 int x, y;
2301 XColor fg, bg;
2303 if (nelem != 3) {
2304 wwarning(_("bad number of arguments in cursor specification"));
2305 return (status);
2307 elem = WMGetFromPLArray(pl, 1);
2308 if (!elem || !WMIsPLString(elem)) {
2309 return (status);
2311 val = WMGetFromPLString(elem);
2312 bitmap_name = FindImage(wPreferences.pixmap_path, val);
2313 if (!bitmap_name) {
2314 wwarning(_("could not find cursor bitmap file \"%s\""), val);
2315 return (status);
2317 elem = WMGetFromPLArray(pl, 2);
2318 if (!elem || !WMIsPLString(elem)) {
2319 wfree(bitmap_name);
2320 return (status);
2322 val = WMGetFromPLString(elem);
2323 mask_name = FindImage(wPreferences.pixmap_path, val);
2324 if (!mask_name) {
2325 wfree(bitmap_name);
2326 wwarning(_("could not find cursor bitmap file \"%s\""), val);
2327 return (status);
2329 mask_status = XReadBitmapFile(dpy, scr->w_win, mask_name, &w, &h, &mask, &x, &y);
2330 bitmap_status = XReadBitmapFile(dpy, scr->w_win, bitmap_name, &w, &h, &bitmap, &x, &y);
2331 if ((BitmapSuccess == bitmap_status) && (BitmapSuccess == mask_status)) {
2332 fg.pixel = scr->black_pixel;
2333 bg.pixel = scr->white_pixel;
2334 XQueryColor(dpy, scr->w_colormap, &fg);
2335 XQueryColor(dpy, scr->w_colormap, &bg);
2336 *cursor = XCreatePixmapCursor(dpy, bitmap, mask, &fg, &bg, x, y);
2337 status = 1;
2339 check_bitmap_status(bitmap_status, bitmap_name, bitmap);
2340 check_bitmap_status(mask_status, mask_name, mask);
2341 wfree(bitmap_name);
2342 wfree(mask_name);
2344 return (status);
2347 static int getCursor(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
2349 static Cursor cursor;
2350 int status;
2351 int changed = 0;
2353 again:
2354 if (!WMIsPLArray(value)) {
2355 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
2356 entry->key, "cursor specification");
2357 if (!changed) {
2358 value = entry->plvalue;
2359 changed = 1;
2360 wwarning(_("using default \"%s\" instead"), entry->default_value);
2361 goto again;
2363 return (False);
2365 status = parse_cursor(scr, value, &cursor);
2366 if (!status) {
2367 wwarning(_("Error in cursor specification for key \"%s\""), entry->key);
2368 if (!changed) {
2369 value = entry->plvalue;
2370 changed = 1;
2371 wwarning(_("using default \"%s\" instead"), entry->default_value);
2372 goto again;
2374 return (False);
2376 if (ret) {
2377 *ret = &cursor;
2379 if (addr) {
2380 *(Cursor *) addr = cursor;
2382 return (True);
2385 #undef CURSOR_ID_NONE
2387 /* ---------------- value setting functions --------------- */
2388 static int setJustify(WScreen * scr, WDefaultEntry * entry, WTexture ** texture, void *foo)
2390 return REFRESH_WINDOW_TITLE_COLOR;
2393 static int setClearance(WScreen * scr, WDefaultEntry * entry, void *bar, void *foo)
2395 return REFRESH_WINDOW_FONT | REFRESH_BUTTON_IMAGES | REFRESH_MENU_TITLE_FONT | REFRESH_MENU_FONT;
2398 static int setIfDockPresent(WScreen * scr, WDefaultEntry * entry, char *flag, long which)
2400 switch (which) {
2401 case WM_DOCK:
2402 wPreferences.flags.nodock = wPreferences.flags.nodock || *flag;
2403 // Drawers require the dock
2404 wPreferences.flags.nodrawer = wPreferences.flags.nodrawer || wPreferences.flags.nodock;
2405 break;
2406 case WM_CLIP:
2407 wPreferences.flags.noclip = wPreferences.flags.noclip || *flag;
2408 break;
2409 case WM_DRAWER:
2410 wPreferences.flags.nodrawer = wPreferences.flags.nodrawer || *flag;
2411 break;
2412 default:
2413 break;
2415 return 0;
2418 static int setClipMergedInDock(WScreen *scr, WDefaultEntry *entry, char *flag, void *foo)
2420 wPreferences.flags.clip_merged_in_dock = *flag;
2421 wPreferences.flags.noclip = wPreferences.flags.noclip || *flag;
2422 return 0;
2425 static int setWrapAppiconsInDock(WScreen *scr, WDefaultEntry *entry, char *flag, void *foo)
2427 wPreferences.flags.wrap_appicons_in_dock = *flag;
2428 return 0;
2431 static int setStickyIcons(WScreen * scr, WDefaultEntry * entry, void *bar, void *foo)
2433 if (scr->workspaces) {
2434 wWorkspaceForceChange(scr, scr->current_workspace);
2435 wArrangeIcons(scr, False);
2437 return 0;
2440 static int setIconTile(WScreen * scr, WDefaultEntry * entry, WTexture ** texture, void *foo)
2442 Pixmap pixmap;
2443 RImage *img;
2444 int reset = 0;
2446 img = wTextureRenderImage(*texture, wPreferences.icon_size,
2447 wPreferences.icon_size, ((*texture)->any.type & WREL_BORDER_MASK)
2448 ? WREL_ICON : WREL_FLAT);
2449 if (!img) {
2450 wwarning(_("could not render texture for icon background"));
2451 if (!entry->addr)
2452 wTextureDestroy(scr, *texture);
2453 return 0;
2455 RConvertImage(scr->rcontext, img, &pixmap);
2457 if (scr->icon_tile) {
2458 reset = 1;
2459 RReleaseImage(scr->icon_tile);
2460 XFreePixmap(dpy, scr->icon_tile_pixmap);
2463 scr->icon_tile = img;
2465 /* put the icon in the noticeboard hint */
2466 PropSetIconTileHint(scr, img);
2468 if (!wPreferences.flags.noclip || wPreferences.flags.clip_merged_in_dock) {
2469 if (scr->clip_tile) {
2470 RReleaseImage(scr->clip_tile);
2472 scr->clip_tile = wClipMakeTile(scr, img);
2475 if (!wPreferences.flags.nodrawer) {
2476 if (scr->drawer_tile) {
2477 RReleaseImage(scr->drawer_tile);
2479 scr->drawer_tile = wDrawerMakeTile(scr, img);
2482 scr->icon_tile_pixmap = pixmap;
2484 if (scr->def_icon_rimage) {
2485 RReleaseImage(scr->def_icon_rimage);
2486 scr->def_icon_rimage = NULL;
2489 if (scr->icon_back_texture)
2490 wTextureDestroy(scr, (WTexture *) scr->icon_back_texture);
2492 scr->icon_back_texture = wTextureMakeSolid(scr, &((*texture)->any.color));
2494 /* Free the texture as nobody else will use it, nor refer to it. */
2495 if (!entry->addr)
2496 wTextureDestroy(scr, *texture);
2498 return (reset ? REFRESH_ICON_TILE : 0);
2501 static int setWinTitleFont(WScreen * scr, WDefaultEntry * entry, WMFont * font, void *foo)
2503 if (scr->title_font) {
2504 WMReleaseFont(scr->title_font);
2506 scr->title_font = font;
2508 return REFRESH_WINDOW_FONT | REFRESH_BUTTON_IMAGES;
2511 static int setMenuTitleFont(WScreen * scr, WDefaultEntry * entry, WMFont * font, void *foo)
2513 if (scr->menu_title_font) {
2514 WMReleaseFont(scr->menu_title_font);
2517 scr->menu_title_font = font;
2519 return REFRESH_MENU_TITLE_FONT;
2522 static int setMenuTextFont(WScreen * scr, WDefaultEntry * entry, WMFont * font, void *foo)
2524 if (scr->menu_entry_font) {
2525 WMReleaseFont(scr->menu_entry_font);
2527 scr->menu_entry_font = font;
2529 return REFRESH_MENU_FONT;
2532 static int setIconTitleFont(WScreen * scr, WDefaultEntry * entry, WMFont * font, void *foo)
2534 if (scr->icon_title_font) {
2535 WMReleaseFont(scr->icon_title_font);
2538 scr->icon_title_font = font;
2540 return REFRESH_ICON_FONT;
2543 static int setClipTitleFont(WScreen * scr, WDefaultEntry * entry, WMFont * font, void *foo)
2545 if (scr->clip_title_font) {
2546 WMReleaseFont(scr->clip_title_font);
2549 scr->clip_title_font = font;
2551 return REFRESH_ICON_FONT;
2554 static int setLargeDisplayFont(WScreen * scr, WDefaultEntry * entry, WMFont * font, void *foo)
2556 if (scr->workspace_name_font) {
2557 WMReleaseFont(scr->workspace_name_font);
2560 scr->workspace_name_font = font;
2562 return 0;
2565 static int setHightlight(WScreen * scr, WDefaultEntry * entry, XColor * color, void *foo)
2567 if (scr->select_color)
2568 WMReleaseColor(scr->select_color);
2570 scr->select_color = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2572 wFreeColor(scr, color->pixel);
2574 return REFRESH_MENU_COLOR;
2577 static int setHightlightText(WScreen * scr, WDefaultEntry * entry, XColor * color, void *foo)
2579 if (scr->select_text_color)
2580 WMReleaseColor(scr->select_text_color);
2582 scr->select_text_color = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2584 wFreeColor(scr, color->pixel);
2586 return REFRESH_MENU_COLOR;
2589 static int setClipTitleColor(WScreen * scr, WDefaultEntry * entry, XColor * color, long widx)
2591 if (scr->clip_title_color[widx])
2592 WMReleaseColor(scr->clip_title_color[widx]);
2594 scr->clip_title_color[widx] = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2595 wFreeColor(scr, color->pixel);
2597 return REFRESH_ICON_TITLE_COLOR;
2600 static int setWTitleColor(WScreen * scr, WDefaultEntry * entry, XColor * color, long widx)
2602 if (scr->window_title_color[widx])
2603 WMReleaseColor(scr->window_title_color[widx]);
2605 scr->window_title_color[widx] =
2606 WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2608 wFreeColor(scr, color->pixel);
2610 return REFRESH_WINDOW_TITLE_COLOR;
2613 static int setMenuTitleColor(WScreen * scr, WDefaultEntry * entry, XColor * color, long widx)
2615 if (scr->menu_title_color[0])
2616 WMReleaseColor(scr->menu_title_color[0]);
2618 scr->menu_title_color[0] = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2620 wFreeColor(scr, color->pixel);
2622 return REFRESH_MENU_TITLE_COLOR;
2625 static int setMenuTextColor(WScreen * scr, WDefaultEntry * entry, XColor * color, void *foo)
2627 if (scr->mtext_color)
2628 WMReleaseColor(scr->mtext_color);
2630 scr->mtext_color = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2632 if (WMColorPixel(scr->dtext_color) == WMColorPixel(scr->mtext_color)) {
2633 WMSetColorAlpha(scr->dtext_color, 0x7fff);
2634 } else {
2635 WMSetColorAlpha(scr->dtext_color, 0xffff);
2638 wFreeColor(scr, color->pixel);
2640 return REFRESH_MENU_COLOR;
2643 static int setMenuDisabledColor(WScreen * scr, WDefaultEntry * entry, XColor * color, void *foo)
2645 if (scr->dtext_color)
2646 WMReleaseColor(scr->dtext_color);
2648 scr->dtext_color = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2650 if (WMColorPixel(scr->dtext_color) == WMColorPixel(scr->mtext_color)) {
2651 WMSetColorAlpha(scr->dtext_color, 0x7fff);
2652 } else {
2653 WMSetColorAlpha(scr->dtext_color, 0xffff);
2656 wFreeColor(scr, color->pixel);
2658 return REFRESH_MENU_COLOR;
2661 static int setIconTitleColor(WScreen * scr, WDefaultEntry * entry, XColor * color, void *foo)
2663 if (scr->icon_title_color)
2664 WMReleaseColor(scr->icon_title_color);
2665 scr->icon_title_color = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2667 wFreeColor(scr, color->pixel);
2669 return REFRESH_ICON_TITLE_COLOR;
2672 static int setIconTitleBack(WScreen * scr, WDefaultEntry * entry, XColor * color, void *foo)
2674 if (scr->icon_title_texture) {
2675 wTextureDestroy(scr, (WTexture *) scr->icon_title_texture);
2677 scr->icon_title_texture = wTextureMakeSolid(scr, color);
2679 return REFRESH_ICON_TITLE_BACK;
2682 static int setFrameBorderWidth(WScreen * scr, WDefaultEntry * entry, int * value, void *foo)
2684 scr->frame_border_width = *value;
2686 return REFRESH_FRAME_BORDER;
2689 static int setFrameBorderColor(WScreen * scr, WDefaultEntry * entry, XColor * color, void *foo)
2691 if (scr->frame_border_color)
2692 WMReleaseColor(scr->frame_border_color);
2693 scr->frame_border_color = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2695 wFreeColor(scr, color->pixel);
2697 return REFRESH_FRAME_BORDER;
2700 static int setFrameSelectedBorderColor(WScreen * scr, WDefaultEntry * entry, XColor * color, void *foo)
2702 if (scr->frame_selected_border_color)
2703 WMReleaseColor(scr->frame_selected_border_color);
2704 scr->frame_selected_border_color = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2706 wFreeColor(scr, color->pixel);
2708 return REFRESH_FRAME_BORDER;
2711 static void trackDeadProcess(pid_t pid, unsigned char status, WScreen * scr)
2713 close(scr->helper_fd);
2714 scr->helper_fd = 0;
2715 scr->helper_pid = 0;
2716 scr->flags.backimage_helper_launched = 0;
2719 static int setWorkspaceSpecificBack(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *bar)
2721 WMPropList *val;
2722 char *str;
2723 int i;
2725 if (scr->flags.backimage_helper_launched) {
2726 if (WMGetPropListItemCount(value) == 0) {
2727 SendHelperMessage(scr, 'C', 0, NULL);
2728 SendHelperMessage(scr, 'K', 0, NULL);
2730 WMReleasePropList(value);
2731 return 0;
2733 } else {
2734 pid_t pid;
2735 int filedes[2];
2737 if (WMGetPropListItemCount(value) == 0)
2738 return 0;
2740 if (pipe(filedes) < 0) {
2741 werror("pipe() failed:can't set workspace specific background image");
2743 WMReleasePropList(value);
2744 return 0;
2747 pid = fork();
2748 if (pid < 0) {
2749 werror("fork() failed:can't set workspace specific background image");
2750 if (close(filedes[0]) < 0)
2751 werror("could not close pipe");
2752 if (close(filedes[1]) < 0)
2753 werror("could not close pipe");
2755 } else if (pid == 0) {
2756 char *dither;
2758 SetupEnvironment(scr);
2760 if (close(0) < 0)
2761 werror("could not close pipe");
2762 if (dup(filedes[0]) < 0) {
2763 werror("dup() failed:can't set workspace specific background image");
2765 dither = wPreferences.no_dithering ? "-m" : "-d";
2766 if (wPreferences.smooth_workspace_back)
2767 execlp("wmsetbg", "wmsetbg", "-helper", "-S", dither, NULL);
2768 else
2769 execlp("wmsetbg", "wmsetbg", "-helper", dither, NULL);
2770 werror("could not execute wmsetbg");
2771 exit(1);
2772 } else {
2774 if (fcntl(filedes[0], F_SETFD, FD_CLOEXEC) < 0) {
2775 werror("error setting close-on-exec flag");
2777 if (fcntl(filedes[1], F_SETFD, FD_CLOEXEC) < 0) {
2778 werror("error setting close-on-exec flag");
2781 scr->helper_fd = filedes[1];
2782 scr->helper_pid = pid;
2783 scr->flags.backimage_helper_launched = 1;
2785 wAddDeathHandler(pid, (WDeathHandler *) trackDeadProcess, scr);
2787 SendHelperMessage(scr, 'P', -1, wPreferences.pixmap_path);
2792 for (i = 0; i < WMGetPropListItemCount(value); i++) {
2793 val = WMGetFromPLArray(value, i);
2794 if (val && WMIsPLArray(val) && WMGetPropListItemCount(val) > 0) {
2795 str = WMGetPropListDescription(val, False);
2797 SendHelperMessage(scr, 'S', i + 1, str);
2799 wfree(str);
2800 } else {
2801 SendHelperMessage(scr, 'U', i + 1, NULL);
2804 sleep(1);
2806 WMReleasePropList(value);
2807 return 0;
2810 static int setWorkspaceBack(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *bar)
2812 if (scr->flags.backimage_helper_launched) {
2813 char *str;
2815 if (WMGetPropListItemCount(value) == 0) {
2816 SendHelperMessage(scr, 'U', 0, NULL);
2817 } else {
2818 /* set the default workspace background to this one */
2819 str = WMGetPropListDescription(value, False);
2820 if (str) {
2821 SendHelperMessage(scr, 'S', 0, str);
2822 wfree(str);
2823 SendHelperMessage(scr, 'C', scr->current_workspace + 1, NULL);
2824 } else {
2825 SendHelperMessage(scr, 'U', 0, NULL);
2828 } else if (WMGetPropListItemCount(value) > 0) {
2829 char *command;
2830 char *text;
2831 char *dither;
2832 int len;
2834 text = WMGetPropListDescription(value, False);
2835 len = strlen(text) + 40;
2836 command = wmalloc(len);
2837 dither = wPreferences.no_dithering ? "-m" : "-d";
2838 if (wPreferences.smooth_workspace_back)
2839 snprintf(command, len, "wmsetbg %s -S -p '%s' &", dither, text);
2840 else
2841 snprintf(command, len, "wmsetbg %s -p '%s' &", dither, text);
2842 wfree(text);
2843 ExecuteShellCommand(scr, command);
2844 wfree(command);
2846 WMReleasePropList(value);
2848 return 0;
2851 static int setWidgetColor(WScreen * scr, WDefaultEntry * entry, WTexture ** texture, void *foo)
2853 if (scr->widget_texture) {
2854 wTextureDestroy(scr, (WTexture *) scr->widget_texture);
2856 scr->widget_texture = *(WTexSolid **) texture;
2858 return 0;
2861 static int setFTitleBack(WScreen * scr, WDefaultEntry * entry, WTexture ** texture, void *foo)
2863 if (scr->window_title_texture[WS_FOCUSED]) {
2864 wTextureDestroy(scr, scr->window_title_texture[WS_FOCUSED]);
2866 scr->window_title_texture[WS_FOCUSED] = *texture;
2868 return REFRESH_WINDOW_TEXTURES;
2871 static int setPTitleBack(WScreen * scr, WDefaultEntry * entry, WTexture ** texture, void *foo)
2873 if (scr->window_title_texture[WS_PFOCUSED]) {
2874 wTextureDestroy(scr, scr->window_title_texture[WS_PFOCUSED]);
2876 scr->window_title_texture[WS_PFOCUSED] = *texture;
2878 return REFRESH_WINDOW_TEXTURES;
2881 static int setUTitleBack(WScreen * scr, WDefaultEntry * entry, WTexture ** texture, void *foo)
2883 if (scr->window_title_texture[WS_UNFOCUSED]) {
2884 wTextureDestroy(scr, scr->window_title_texture[WS_UNFOCUSED]);
2886 scr->window_title_texture[WS_UNFOCUSED] = *texture;
2888 return REFRESH_WINDOW_TEXTURES;
2891 static int setResizebarBack(WScreen * scr, WDefaultEntry * entry, WTexture ** texture, void *foo)
2893 if (scr->resizebar_texture[0]) {
2894 wTextureDestroy(scr, scr->resizebar_texture[0]);
2896 scr->resizebar_texture[0] = *texture;
2898 return REFRESH_WINDOW_TEXTURES;
2901 static int setMenuTitleBack(WScreen * scr, WDefaultEntry * entry, WTexture ** texture, void *foo)
2903 if (scr->menu_title_texture[0]) {
2904 wTextureDestroy(scr, scr->menu_title_texture[0]);
2906 scr->menu_title_texture[0] = *texture;
2908 return REFRESH_MENU_TITLE_TEXTURE;
2911 static int setMenuTextBack(WScreen * scr, WDefaultEntry * entry, WTexture ** texture, void *foo)
2913 if (scr->menu_item_texture) {
2914 wTextureDestroy(scr, scr->menu_item_texture);
2915 wTextureDestroy(scr, (WTexture *) scr->menu_item_auxtexture);
2917 scr->menu_item_texture = *texture;
2919 scr->menu_item_auxtexture = wTextureMakeSolid(scr, &scr->menu_item_texture->any.color);
2921 return REFRESH_MENU_TEXTURE;
2924 static int setKeyGrab(WScreen * scr, WDefaultEntry * entry, WShortKey * shortcut, long widx)
2926 WWindow *wwin;
2927 wKeyBindings[widx] = *shortcut;
2929 wwin = scr->focused_window;
2931 while (wwin != NULL) {
2932 XUngrabKey(dpy, AnyKey, AnyModifier, wwin->frame->core->window);
2934 if (!WFLAGP(wwin, no_bind_keys)) {
2935 wWindowSetKeyGrabs(wwin);
2937 wwin = wwin->prev;
2940 /* do we need to update window menus? */
2941 if (widx >= WKBD_WORKSPACE1 && widx <= WKBD_WORKSPACE10)
2942 return REFRESH_WORKSPACE_MENU;
2943 if (widx == WKBD_LASTWORKSPACE)
2944 return REFRESH_WORKSPACE_MENU;
2945 if (widx >= WKBD_MOVE_WORKSPACE1 && widx <= WKBD_MOVE_WORKSPACE10)
2946 return REFRESH_WORKSPACE_MENU;
2948 return 0;
2951 static int setIconPosition(WScreen * scr, WDefaultEntry * entry, void *bar, void *foo)
2953 wScreenUpdateUsableArea(scr);
2954 wArrangeIcons(scr, True);
2956 return 0;
2959 static int updateUsableArea(WScreen * scr, WDefaultEntry * entry, void *bar, void *foo)
2961 wScreenUpdateUsableArea(scr);
2963 return 0;
2966 static int setMenuStyle(WScreen * scr, WDefaultEntry * entry, int *value, void *foo)
2968 return REFRESH_MENU_TEXTURE;
2971 static RImage *chopOffImage(RImage * image, int x, int y, int w, int h)
2973 RImage *img = RCreateImage(w, h, image->format == RRGBAFormat);
2975 RCopyArea(img, image, x, y, w, h, 0, 0);
2977 return img;
2980 static int setSwPOptions(WScreen * scr, WDefaultEntry * entry, WMPropList * array, void *foo)
2982 char *path;
2983 RImage *bgimage;
2984 int cwidth, cheight;
2985 WPreferences *prefs = (WPreferences *) foo;
2987 if (!WMIsPLArray(array) || WMGetPropListItemCount(array) == 0) {
2988 if (prefs->swtileImage)
2989 RReleaseImage(prefs->swtileImage);
2990 prefs->swtileImage = NULL;
2992 WMReleasePropList(array);
2993 return 0;
2996 switch (WMGetPropListItemCount(array)) {
2997 case 4:
2998 if (!WMIsPLString(WMGetFromPLArray(array, 1))) {
2999 wwarning(_("Invalid arguments for option \"%s\""), entry->key);
3000 break;
3001 } else
3002 path = FindImage(wPreferences.pixmap_path, WMGetFromPLString(WMGetFromPLArray(array, 1)));
3004 if (!path) {
3005 wwarning(_("Could not find image \"%s\" for option \"%s\""),
3006 WMGetFromPLString(WMGetFromPLArray(array, 1)), entry->key);
3007 } else {
3008 bgimage = RLoadImage(scr->rcontext, path, 0);
3009 if (!bgimage) {
3010 wwarning(_("Could not load image \"%s\" for option \"%s\""), path, entry->key);
3011 wfree(path);
3012 } else {
3013 wfree(path);
3015 cwidth = atoi(WMGetFromPLString(WMGetFromPLArray(array, 2)));
3016 cheight = atoi(WMGetFromPLString(WMGetFromPLArray(array, 3)));
3018 if (cwidth <= 0 || cheight <= 0 ||
3019 cwidth >= bgimage->width - 2 || cheight >= bgimage->height - 2)
3020 wwarning(_("Invalid split sizes for SwitchPanel back image."));
3021 else {
3022 int i;
3023 int swidth, theight;
3024 for (i = 0; i < 9; i++) {
3025 if (prefs->swbackImage[i])
3026 RReleaseImage(prefs->swbackImage[i]);
3027 prefs->swbackImage[i] = NULL;
3029 swidth = (bgimage->width - cwidth) / 2;
3030 theight = (bgimage->height - cheight) / 2;
3032 prefs->swbackImage[0] = chopOffImage(bgimage, 0, 0, swidth, theight);
3033 prefs->swbackImage[1] = chopOffImage(bgimage, swidth, 0, cwidth, theight);
3034 prefs->swbackImage[2] = chopOffImage(bgimage, swidth + cwidth, 0,
3035 swidth, theight);
3037 prefs->swbackImage[3] = chopOffImage(bgimage, 0, theight, swidth, cheight);
3038 prefs->swbackImage[4] = chopOffImage(bgimage, swidth, theight,
3039 cwidth, cheight);
3040 prefs->swbackImage[5] = chopOffImage(bgimage, swidth + cwidth, theight,
3041 swidth, cheight);
3043 prefs->swbackImage[6] = chopOffImage(bgimage, 0, theight + cheight,
3044 swidth, theight);
3045 prefs->swbackImage[7] = chopOffImage(bgimage, swidth, theight + cheight,
3046 cwidth, theight);
3047 prefs->swbackImage[8] =
3048 chopOffImage(bgimage, swidth + cwidth, theight + cheight, swidth,
3049 theight);
3051 // check if anything failed
3052 for (i = 0; i < 9; i++) {
3053 if (!prefs->swbackImage[i]) {
3054 for (; i >= 0; --i) {
3055 RReleaseImage(prefs->swbackImage[i]);
3056 prefs->swbackImage[i] = NULL;
3058 break;
3062 RReleaseImage(bgimage);
3066 case 1:
3067 if (!WMIsPLString(WMGetFromPLArray(array, 0))) {
3068 wwarning(_("Invalid arguments for option \"%s\""), entry->key);
3069 break;
3070 } else
3071 path = FindImage(wPreferences.pixmap_path, WMGetFromPLString(WMGetFromPLArray(array, 0)));
3073 if (!path) {
3074 wwarning(_("Could not find image \"%s\" for option \"%s\""),
3075 WMGetFromPLString(WMGetFromPLArray(array, 0)), entry->key);
3076 } else {
3077 if (prefs->swtileImage)
3078 RReleaseImage(prefs->swtileImage);
3080 prefs->swtileImage = RLoadImage(scr->rcontext, path, 0);
3081 if (!prefs->swtileImage) {
3082 wwarning(_("Could not load image \"%s\" for option \"%s\""), path, entry->key);
3084 wfree(path);
3086 break;
3088 default:
3089 wwarning(_("Invalid number of arguments for option \"%s\""), entry->key);
3090 break;
3093 WMReleasePropList(array);
3095 return 0;
3098 static int setModifierKeyLabels(WScreen * scr, WDefaultEntry * entry, WMPropList * array, void *foo)
3100 int i;
3101 WPreferences *prefs = (WPreferences *) foo;
3103 if (!WMIsPLArray(array) || WMGetPropListItemCount(array) != 7) {
3104 wwarning(_("Value for option \"%s\" must be an array of 7 strings"), entry->key);
3105 WMReleasePropList(array);
3106 return 0;
3109 DestroyWindowMenu(scr);
3111 for (i = 0; i < 7; i++) {
3112 if (prefs->modifier_labels[i])
3113 wfree(prefs->modifier_labels[i]);
3115 if (WMIsPLString(WMGetFromPLArray(array, i))) {
3116 prefs->modifier_labels[i] = wstrdup(WMGetFromPLString(WMGetFromPLArray(array, i)));
3117 } else {
3118 wwarning(_("Invalid argument for option \"%s\" item %d"), entry->key, i);
3119 prefs->modifier_labels[i] = NULL;
3123 WMReleasePropList(array);
3125 return 0;
3128 static int setDoubleClick(WScreen *scr, WDefaultEntry *entry, int *value, void *foo)
3130 if (*value <= 0)
3131 *(int *)foo = 1;
3133 W_setconf_doubleClickDelay(*value);
3135 return 0;
3138 static int setCursor(WScreen * scr, WDefaultEntry * entry, Cursor * cursor, long widx)
3140 if (wCursor[widx] != None) {
3141 XFreeCursor(dpy, wCursor[widx]);
3144 wCursor[widx] = *cursor;
3146 if (widx == WCUR_ROOT && *cursor != None) {
3147 XDefineCursor(dpy, scr->root_win, *cursor);
3150 return 0;