Merge branch 'wmdrawer' into next
[wmaker-crm.git] / src / defaults.c
blob5300a23f01e838ab8cc141bf6ecc62df29ca5c40
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"
65 #define MAX_SHORTCUT_LENGTH 32
67 #ifndef GLOBAL_DEFAULTS_SUBDIR
68 #define GLOBAL_DEFAULTS_SUBDIR "WindowMaker"
69 #endif
71 /***** Global *****/
72 extern WDDomain *WDWindowMaker;
73 extern WDDomain *WDWindowAttributes;
74 extern WDDomain *WDRootMenu;
75 extern int wScreenCount;
76 extern WPreferences wPreferences;
77 extern WShortKey wKeyBindings[WKBD_LAST];
79 typedef struct {
80 char *key;
81 char *default_value;
82 void *extra_data;
83 void *addr;
84 int (*convert) ();
85 int (*update) ();
86 WMPropList *plkey;
87 WMPropList *plvalue; /* default value */
88 } WDefaultEntry;
90 /* used to map strings to integers */
91 typedef struct {
92 char *string;
93 short value;
94 char is_alias;
95 } WOptionEnumeration;
97 /* type converters */
98 static int getBool();
99 static int getInt();
100 static int getCoord();
101 static int getPathList();
102 static int getEnum();
103 static int getTexture();
104 static int getWSBackground();
105 static int getWSSpecificBackground();
106 static int getFont();
107 static int getColor();
108 static int getKeybind();
109 static int getModMask();
110 static int getPropList();
112 /* value setting functions */
113 static int setJustify();
114 static int setClearance();
115 static int setIfDockPresent();
116 static int setClipMergedInDock();
117 static int setWrapAppiconsInDock();
118 static int setStickyIcons();
119 static int setWidgetColor();
120 static int setIconTile();
121 static int setWinTitleFont();
122 static int setMenuTitleFont();
123 static int setMenuTextFont();
124 static int setIconTitleFont();
125 static int setIconTitleColor();
126 static int setIconTitleBack();
127 static int setFrameBorderWidth();
128 static int setFrameBorderColor();
129 static int setFrameSelectedBorderColor();
130 static int setLargeDisplayFont();
131 static int setWTitleColor();
132 static int setFTitleBack();
133 static int setPTitleBack();
134 static int setUTitleBack();
135 static int setResizebarBack();
136 static int setWorkspaceBack();
137 static int setWorkspaceSpecificBack();
138 static int setMenuTitleColor();
139 static int setMenuTextColor();
140 static int setMenuDisabledColor();
141 static int setMenuTitleBack();
142 static int setMenuTextBack();
143 static int setHightlight();
144 static int setHightlightText();
145 static int setKeyGrab();
146 static int setDoubleClick();
147 static int setIconPosition();
149 static int setClipTitleFont();
150 static int setClipTitleColor();
152 static int setMenuStyle();
153 static int setSwPOptions();
154 static int updateUsableArea();
156 static int setModifierKeyLabels();
158 extern Cursor wCursor[WCUR_LAST];
159 static int getCursor();
160 static int setCursor();
163 * Tables to convert strings to enumeration values.
164 * Values stored are char
167 /* WARNING: sum of length of all value strings must not exceed
168 * this value */
169 #define TOTAL_VALUES_LENGTH 80
171 #define REFRESH_WINDOW_TEXTURES (1<<0)
172 #define REFRESH_MENU_TEXTURE (1<<1)
173 #define REFRESH_MENU_FONT (1<<2)
174 #define REFRESH_MENU_COLOR (1<<3)
175 #define REFRESH_MENU_TITLE_TEXTURE (1<<4)
176 #define REFRESH_MENU_TITLE_FONT (1<<5)
177 #define REFRESH_MENU_TITLE_COLOR (1<<6)
178 #define REFRESH_WINDOW_TITLE_COLOR (1<<7)
179 #define REFRESH_WINDOW_FONT (1<<8)
180 #define REFRESH_ICON_TILE (1<<9)
181 #define REFRESH_ICON_FONT (1<<10)
182 #define REFRESH_WORKSPACE_BACK (1<<11)
184 #define REFRESH_BUTTON_IMAGES (1<<12)
186 #define REFRESH_ICON_TITLE_COLOR (1<<13)
187 #define REFRESH_ICON_TITLE_BACK (1<<14)
189 #define REFRESH_WORKSPACE_MENU (1<<15)
191 #define REFRESH_FRAME_BORDER REFRESH_MENU_FONT|REFRESH_WINDOW_FONT
193 static WOptionEnumeration seFocusModes[] = {
194 {"Manual", WKF_CLICK, 0}, {"ClickToFocus", WKF_CLICK, 1},
195 {"Sloppy", WKF_SLOPPY, 0}, {"SemiAuto", WKF_SLOPPY, 1}, {"Auto", WKF_SLOPPY, 1},
196 {NULL, 0, 0}
199 static WOptionEnumeration seTitlebarModes[] = {
200 {"new", TS_NEW, 0}, {"old", TS_OLD, 0},
201 {"next", TS_NEXT, 0}, {NULL, 0, 0}
204 static WOptionEnumeration seColormapModes[] = {
205 {"Manual", WCM_CLICK, 0}, {"ClickToFocus", WCM_CLICK, 1},
206 {"Auto", WCM_POINTER, 0}, {"FocusFollowMouse", WCM_POINTER, 1},
207 {NULL, 0, 0}
210 static WOptionEnumeration sePlacements[] = {
211 {"Auto", WPM_AUTO, 0},
212 {"Smart", WPM_SMART, 0},
213 {"Cascade", WPM_CASCADE, 0},
214 {"Random", WPM_RANDOM, 0},
215 {"Manual", WPM_MANUAL, 0},
216 {"Center", WPM_CENTER, 0},
217 {NULL, 0, 0}
220 static WOptionEnumeration seGeomDisplays[] = {
221 {"None", WDIS_NONE, 0},
222 {"Center", WDIS_CENTER, 0},
223 {"Corner", WDIS_TOPLEFT, 0},
224 {"Floating", WDIS_FRAME_CENTER, 0},
225 {"Line", WDIS_NEW, 0},
226 {NULL, 0, 0}
229 static WOptionEnumeration seSpeeds[] = {
230 {"UltraFast", SPEED_ULTRAFAST, 0},
231 {"Fast", SPEED_FAST, 0},
232 {"Medium", SPEED_MEDIUM, 0},
233 {"Slow", SPEED_SLOW, 0},
234 {"UltraSlow", SPEED_ULTRASLOW, 0},
235 {NULL, 0, 0}
238 static WOptionEnumeration seMouseButtonActions[] = {
239 {"None", WA_NONE, 0},
240 {"SelectWindows", WA_SELECT_WINDOWS, 0},
241 {"OpenApplicationsMenu", WA_OPEN_APPMENU, 0},
242 {"OpenWindowListMenu", WA_OPEN_WINLISTMENU, 0},
243 {NULL, 0, 0}
246 static WOptionEnumeration seMouseWheelActions[] = {
247 {"None", WA_NONE, 0},
248 {"SwitchWorkspaces", WA_SWITCH_WORKSPACES, 0},
249 {NULL, 0, 0}
252 static WOptionEnumeration seIconificationStyles[] = {
253 {"Zoom", WIS_ZOOM, 0},
254 {"Twist", WIS_TWIST, 0},
255 {"Flip", WIS_FLIP, 0},
256 {"None", WIS_NONE, 0},
257 {"random", WIS_RANDOM, 0},
258 {NULL, 0, 0}
261 static WOptionEnumeration seJustifications[] = {
262 {"Left", WTJ_LEFT, 0},
263 {"Center", WTJ_CENTER, 0},
264 {"Right", WTJ_RIGHT, 0},
265 {NULL, 0, 0}
268 static WOptionEnumeration seIconPositions[] = {
269 {"blv", IY_BOTTOM | IY_LEFT | IY_VERT, 0},
270 {"blh", IY_BOTTOM | IY_LEFT | IY_HORIZ, 0},
271 {"brv", IY_BOTTOM | IY_RIGHT | IY_VERT, 0},
272 {"brh", IY_BOTTOM | IY_RIGHT | IY_HORIZ, 0},
273 {"tlv", IY_TOP | IY_LEFT | IY_VERT, 0},
274 {"tlh", IY_TOP | IY_LEFT | IY_HORIZ, 0},
275 {"trv", IY_TOP | IY_RIGHT | IY_VERT, 0},
276 {"trh", IY_TOP | IY_RIGHT | IY_HORIZ, 0},
277 {NULL, 0, 0}
280 static WOptionEnumeration seMenuStyles[] = {
281 {"normal", MS_NORMAL, 0},
282 {"singletexture", MS_SINGLE_TEXTURE, 0},
283 {"flat", MS_FLAT, 0},
284 {NULL, 0, 0}
287 static WOptionEnumeration seDisplayPositions[] = {
288 {"none", WD_NONE, 0},
289 {"center", WD_CENTER, 0},
290 {"top", WD_TOP, 0},
291 {"bottom", WD_BOTTOM, 0},
292 {"topleft", WD_TOPLEFT, 0},
293 {"topright", WD_TOPRIGHT, 0},
294 {"bottomleft", WD_BOTTOMLEFT, 0},
295 {"bottomright", WD_BOTTOMRIGHT, 0},
296 {NULL, 0, 0}
299 static WOptionEnumeration seWorkspaceBorder[] = {
300 {"None", WB_NONE, 0},
301 {"LeftRight", WB_LEFTRIGHT, 0},
302 {"TopBottom", WB_TOPBOTTOM, 0},
303 {"AllDirections", WB_ALLDIRS, 0},
304 {NULL, 0, 0}
308 * ALL entries in the tables bellow, NEED to have a default value
309 * defined, and this value needs to be correct.
312 /* these options will only affect the window manager on startup
314 * static defaults can't access the screen data, because it is
315 * created after these defaults are read
317 WDefaultEntry staticOptionList[] = {
319 {"ColormapSize", "4", NULL,
320 &wPreferences.cmap_size, getInt, NULL, NULL, NULL},
321 {"DisableDithering", "NO", NULL,
322 &wPreferences.no_dithering, getBool, NULL, NULL, NULL},
323 {"IconSize", "64", NULL,
324 &wPreferences.icon_size, getInt, NULL, NULL, NULL},
325 {"ModifierKey", "Mod1", NULL,
326 &wPreferences.modifier_mask, getModMask, NULL, NULL, NULL},
327 {"DisableWSMouseActions", "NO", NULL,
328 &wPreferences.disable_root_mouse, getBool, NULL, NULL, NULL},
329 {"FocusMode", "manual", seFocusModes, /* have a problem when switching from */
330 &wPreferences.focus_mode, getEnum, NULL, NULL, NULL}, /* manual to sloppy without restart */
331 {"NewStyle", "new", seTitlebarModes,
332 &wPreferences.new_style, getEnum, NULL, NULL, NULL},
333 {"DisableDock", "NO", (void *)WM_DOCK,
334 NULL, getBool, setIfDockPresent, NULL, NULL},
335 {"DisableClip", "NO", (void *)WM_CLIP,
336 NULL, getBool, setIfDockPresent, NULL, NULL},
337 {"DisableDrawers", "NO", (void *)WM_DRAWER,
338 NULL, getBool, setIfDockPresent, NULL, NULL},
339 {"ClipMergedInDock", "NO", NULL,
340 NULL, getBool, setClipMergedInDock, NULL, NULL},
341 {"DisableMiniwindows", "NO", NULL,
342 &wPreferences.disable_miniwindows, getBool, NULL, NULL, NULL}
345 #define NUM2STRING_(x) #x
346 #define NUM2STRING(x) NUM2STRING_(x)
348 WDefaultEntry optionList[] = {
350 /* dynamic options */
352 {"IconPosition", "blh", seIconPositions,
353 &wPreferences.icon_yard, getEnum, setIconPosition, NULL, NULL},
354 {"IconificationStyle", "Zoom", seIconificationStyles,
355 &wPreferences.iconification_style, getEnum, NULL, NULL, NULL},
356 {"MouseLeftButtonAction", "SelectWindows", seMouseButtonActions,
357 &wPreferences.mouse_button1, getEnum, NULL, NULL, NULL},
358 {"MouseMiddleButtonAction", "OpenWindowListMenu", seMouseButtonActions,
359 &wPreferences.mouse_button2, getEnum, NULL, NULL, NULL},
360 {"MouseRightButtonAction", "OpenApplicationsMenu", seMouseButtonActions,
361 &wPreferences.mouse_button3, getEnum, NULL, NULL, NULL},
362 {"MouseWheelAction", "None", seMouseWheelActions,
363 &wPreferences.mouse_wheel, getEnum, NULL, NULL, NULL},
364 {"PixmapPath", DEF_PIXMAP_PATHS, NULL,
365 &wPreferences.pixmap_path, getPathList, NULL, NULL, NULL},
366 {"IconPath", DEF_ICON_PATHS, NULL,
367 &wPreferences.icon_path, getPathList, NULL, NULL, NULL},
368 {"ColormapMode", "auto", seColormapModes,
369 &wPreferences.colormap_mode, getEnum, NULL, NULL, NULL},
370 {"AutoFocus", "NO", NULL,
371 &wPreferences.auto_focus, getBool, NULL, NULL, NULL},
372 {"RaiseDelay", "0", NULL,
373 &wPreferences.raise_delay, getInt, NULL, NULL, NULL},
374 {"CirculateRaise", "NO", NULL,
375 &wPreferences.circ_raise, getBool, NULL, NULL, NULL},
376 {"Superfluous", "NO", NULL,
377 &wPreferences.superfluous, getBool, NULL, NULL, NULL},
378 {"AdvanceToNewWorkspace", "NO", NULL,
379 &wPreferences.ws_advance, getBool, NULL, NULL, NULL},
380 {"CycleWorkspaces", "NO", NULL,
381 &wPreferences.ws_cycle, getBool, NULL, NULL, NULL},
382 {"WorkspaceNameDisplayPosition", "center", seDisplayPositions,
383 &wPreferences.workspace_name_display_position, getEnum, NULL, NULL, NULL},
384 {"WorkspaceBorder", "None", seWorkspaceBorder,
385 &wPreferences.workspace_border_position, getEnum, updateUsableArea, NULL, NULL},
386 {"WorkspaceBorderSize", "0", NULL,
387 &wPreferences.workspace_border_size, getInt, updateUsableArea, NULL, NULL},
388 {"StickyIcons", "NO", NULL,
389 &wPreferences.sticky_icons, getBool, setStickyIcons, NULL, NULL},
390 {"SaveSessionOnExit", "NO", NULL,
391 &wPreferences.save_session_on_exit, getBool, NULL, NULL, NULL},
392 {"WrapMenus", "NO", NULL,
393 &wPreferences.wrap_menus, getBool, NULL, NULL, NULL},
394 {"ScrollableMenus", "NO", NULL,
395 &wPreferences.scrollable_menus, getBool, NULL, NULL, NULL},
396 {"MenuScrollSpeed", "medium", seSpeeds,
397 &wPreferences.menu_scroll_speed, getEnum, NULL, NULL, NULL},
398 {"IconSlideSpeed", "medium", seSpeeds,
399 &wPreferences.icon_slide_speed, getEnum, NULL, NULL, NULL},
400 {"ShadeSpeed", "medium", seSpeeds,
401 &wPreferences.shade_speed, getEnum, NULL, NULL, NULL},
402 {"BounceAppIconsWhenUrgent", "YES", NULL,
403 &wPreferences.bounce_appicons_when_urgent, getBool, NULL, NULL, NULL},
404 {"RaiseAppIconsWhenBouncing", "NO", NULL,
405 &wPreferences.raise_appicons_when_bouncing, getBool, NULL, NULL, NULL},
406 {"DoNotMakeAppIconsBounce", "NO", NULL,
407 &wPreferences.do_not_make_appicons_bounce, getBool, NULL, NULL, NULL},
408 {"DoubleClickTime", "250", (void *)&wPreferences.dblclick_time,
409 &wPreferences.dblclick_time, getInt, setDoubleClick, NULL, NULL},
410 {"ClipAutoraiseDelay", "600", NULL,
411 &wPreferences.clip_auto_raise_delay, getInt, NULL, NULL, NULL},
412 {"ClipAutolowerDelay", "1000", NULL,
413 &wPreferences.clip_auto_lower_delay, getInt, NULL, NULL, NULL},
414 {"ClipAutoexpandDelay", "600", NULL,
415 &wPreferences.clip_auto_expand_delay, getInt, NULL, NULL, NULL},
416 {"ClipAutocollapseDelay", "1000", NULL,
417 &wPreferences.clip_auto_collapse_delay, getInt, NULL, NULL, NULL},
418 {"WrapAppiconsInDock", "YES", NULL,
419 NULL, getBool, setWrapAppiconsInDock, NULL, NULL},
420 {"AlignSubmenus", "NO", NULL,
421 &wPreferences.align_menus, getBool, NULL, NULL, NULL},
422 {"ViKeyMenus", "NO", NULL,
423 &wPreferences.vi_key_menus, getBool, NULL, NULL, NULL},
424 {"OpenTransientOnOwnerWorkspace", "NO", NULL,
425 &wPreferences.open_transients_with_parent, getBool, NULL, NULL, NULL},
426 {"WindowPlacement", "auto", sePlacements,
427 &wPreferences.window_placement, getEnum, NULL, NULL, NULL},
428 {"IgnoreFocusClick", "NO", NULL,
429 &wPreferences.ignore_focus_click, getBool, NULL, NULL, NULL},
430 {"UseSaveUnders", "NO", NULL,
431 &wPreferences.use_saveunders, getBool, NULL, NULL, NULL},
432 {"OpaqueMove", "NO", NULL,
433 &wPreferences.opaque_move, getBool, NULL, NULL, NULL},
434 {"OpaqueResize", "NO", NULL,
435 &wPreferences.opaque_resize, getBool, NULL, NULL, NULL},
436 {"OpaqueMoveResizeKeyboard", "NO", NULL,
437 &wPreferences.opaque_move_resize_keyboard, getBool, NULL, NULL, NULL},
438 {"DisableAnimations", "NO", NULL,
439 &wPreferences.no_animations, getBool, NULL, NULL, NULL},
440 {"DontLinkWorkspaces", "NO", NULL,
441 &wPreferences.no_autowrap, getBool, NULL, NULL, NULL},
442 {"HighlightActiveApp", "YES", NULL,
443 &wPreferences.highlight_active_app, getBool, NULL, NULL, NULL},
444 {"AutoArrangeIcons", "NO", NULL,
445 &wPreferences.auto_arrange_icons, getBool, NULL, NULL, NULL},
446 {"NoWindowOverDock", "NO", NULL,
447 &wPreferences.no_window_over_dock, getBool, updateUsableArea, NULL, NULL},
448 {"NoWindowOverIcons", "NO", NULL,
449 &wPreferences.no_window_over_icons, getBool, updateUsableArea, NULL, NULL},
450 {"WindowPlaceOrigin", "(0, 0)", NULL,
451 &wPreferences.window_place_origin, getCoord, NULL, NULL, NULL},
452 {"ResizeDisplay", "corner", seGeomDisplays,
453 &wPreferences.size_display, getEnum, NULL, NULL, NULL},
454 {"MoveDisplay", "corner", seGeomDisplays,
455 &wPreferences.move_display, getEnum, NULL, NULL, NULL},
456 {"DontConfirmKill", "NO", NULL,
457 &wPreferences.dont_confirm_kill, getBool, NULL, NULL, NULL},
458 {"WindowTitleBalloons", "NO", NULL,
459 &wPreferences.window_balloon, getBool, NULL, NULL, NULL},
460 {"MiniwindowTitleBalloons", "NO", NULL,
461 &wPreferences.miniwin_balloon, getBool, NULL, NULL, NULL},
462 {"AppIconBalloons", "NO", NULL,
463 &wPreferences.appicon_balloon, getBool, NULL, NULL, NULL},
464 {"HelpBalloons", "NO", NULL,
465 &wPreferences.help_balloon, getBool, NULL, NULL, NULL},
466 {"EdgeResistance", "30", NULL,
467 &wPreferences.edge_resistance, getInt, NULL, NULL, NULL},
468 {"ResizeIncrement", "0", NULL,
469 &wPreferences.resize_increment, getInt, NULL, NULL, NULL},
470 {"Attraction", "NO", NULL,
471 &wPreferences.attract, getBool, NULL, NULL, NULL},
472 {"DisableBlinking", "NO", NULL,
473 &wPreferences.dont_blink, getBool, NULL, NULL, NULL},
474 {"SingleClickLaunch", "NO", NULL,
475 &wPreferences.single_click, getBool, NULL, NULL, NULL},
477 /* style options */
479 {"MenuStyle", "normal", seMenuStyles,
480 &wPreferences.menu_style, getEnum, setMenuStyle, NULL, NULL},
481 {"WidgetColor", "(solid, gray)", NULL,
482 NULL, getTexture, setWidgetColor, NULL, NULL},
483 {"WorkspaceSpecificBack", "()", NULL,
484 NULL, getWSSpecificBackground, setWorkspaceSpecificBack, NULL, NULL},
485 /* WorkspaceBack must come after WorkspaceSpecificBack or
486 * WorkspaceBack wont know WorkspaceSpecificBack was also
487 * specified and 2 copies of wmsetbg will be launched */
488 {"WorkspaceBack", "(solid, black)", NULL,
489 NULL, getWSBackground, setWorkspaceBack, NULL, NULL},
490 {"SmoothWorkspaceBack", "NO", NULL,
491 NULL, getBool, NULL, NULL, NULL},
492 {"IconBack", "(solid, gray)", NULL,
493 NULL, getTexture, setIconTile, NULL, NULL},
494 {"TitleJustify", "center", seJustifications,
495 &wPreferences.title_justification, getEnum, setJustify, NULL, NULL},
496 {"WindowTitleFont", DEF_TITLE_FONT, NULL,
497 NULL, getFont, setWinTitleFont, NULL, NULL},
498 {"WindowTitleExtendSpace", DEF_WINDOW_TITLE_EXTEND_SPACE, NULL,
499 &wPreferences.window_title_clearance, getInt, setClearance, NULL, NULL},
500 {"WindowTitleMinHeight", "0", NULL,
501 &wPreferences.window_title_min_height, getInt, setClearance, NULL, NULL},
502 {"WindowTitleMaxHeight", NUM2STRING(INT_MAX), NULL,
503 &wPreferences.window_title_max_height, getInt, setClearance, NULL, NULL},
504 {"MenuTitleExtendSpace", DEF_MENU_TITLE_EXTEND_SPACE, NULL,
505 &wPreferences.menu_title_clearance, getInt, setClearance, NULL, NULL},
506 {"MenuTitleMinHeight", "0", NULL,
507 &wPreferences.menu_title_min_height, getInt, setClearance, NULL, NULL},
508 {"MenuTitleMaxHeight", NUM2STRING(INT_MAX), NULL,
509 &wPreferences.menu_title_max_height, getInt, setClearance, NULL, NULL},
510 {"MenuTextExtendSpace", DEF_MENU_TEXT_EXTEND_SPACE, NULL,
511 &wPreferences.menu_text_clearance, getInt, setClearance, NULL, NULL},
512 {"MenuTitleFont", DEF_MENU_TITLE_FONT, NULL,
513 NULL, getFont, setMenuTitleFont, NULL, NULL},
514 {"MenuTextFont", DEF_MENU_ENTRY_FONT, NULL,
515 NULL, getFont, setMenuTextFont, NULL, NULL},
516 {"IconTitleFont", DEF_ICON_TITLE_FONT, NULL,
517 NULL, getFont, setIconTitleFont, NULL, NULL},
518 {"ClipTitleFont", DEF_CLIP_TITLE_FONT, NULL,
519 NULL, getFont, setClipTitleFont, NULL, NULL},
520 {"ShowClipTitle", "YES", NULL,
521 &wPreferences.show_clip_title, getBool, NULL, NULL, NULL},
522 {"LargeDisplayFont", DEF_WORKSPACE_NAME_FONT, NULL,
523 NULL, getFont, setLargeDisplayFont, NULL, NULL},
524 {"HighlightColor", "white", NULL,
525 NULL, getColor, setHightlight, NULL, NULL},
526 {"HighlightTextColor", "black", NULL,
527 NULL, getColor, setHightlightText, NULL, NULL},
528 {"ClipTitleColor", "black", (void *)CLIP_NORMAL,
529 NULL, getColor, setClipTitleColor, NULL, NULL},
530 {"CClipTitleColor", "\"#454045\"", (void *)CLIP_COLLAPSED,
531 NULL, getColor, setClipTitleColor, NULL, NULL},
532 {"FTitleColor", "white", (void *)WS_FOCUSED,
533 NULL, getColor, setWTitleColor, NULL, NULL},
534 {"PTitleColor", "white", (void *)WS_PFOCUSED,
535 NULL, getColor, setWTitleColor, NULL, NULL},
536 {"UTitleColor", "black", (void *)WS_UNFOCUSED,
537 NULL, getColor, setWTitleColor, NULL, NULL},
538 {"FTitleBack", "(solid, black)", NULL,
539 NULL, getTexture, setFTitleBack, NULL, NULL},
540 {"PTitleBack", "(solid, \"#616161\")", NULL,
541 NULL, getTexture, setPTitleBack, NULL, NULL},
542 {"UTitleBack", "(solid, gray)", NULL,
543 NULL, getTexture, setUTitleBack, NULL, NULL},
544 {"ResizebarBack", "(solid, gray)", NULL,
545 NULL, getTexture, setResizebarBack, NULL, NULL},
546 {"MenuTitleColor", "white", NULL,
547 NULL, getColor, setMenuTitleColor, NULL, NULL},
548 {"MenuTextColor", "black", NULL,
549 NULL, getColor, setMenuTextColor, NULL, NULL},
550 {"MenuDisabledColor", "\"#616161\"", NULL,
551 NULL, getColor, setMenuDisabledColor, NULL, NULL},
552 {"MenuTitleBack", "(solid, black)", NULL,
553 NULL, getTexture, setMenuTitleBack, NULL, NULL},
554 {"MenuTextBack", "(solid, gray)", NULL,
555 NULL, getTexture, setMenuTextBack, NULL, NULL},
556 {"IconTitleColor", "white", NULL,
557 NULL, getColor, setIconTitleColor, NULL, NULL},
558 {"IconTitleBack", "black", NULL,
559 NULL, getColor, setIconTitleBack, NULL, NULL},
560 {"SwitchPanelImages", "(swtile.png, swback.png, 30, 40)", &wPreferences,
561 NULL, getPropList, setSwPOptions, NULL, NULL},
562 {"ModifierKeyLabels", "(\"Shift+\", \"Ctrl+\", \"Mod1+\", \"Mod2+\", \"Mod3+\", \"Mod4+\", \"Mod5+\")", &wPreferences,
563 NULL, getPropList, setModifierKeyLabels, NULL, NULL},
564 {"FrameBorderWidth", "1", NULL,
565 NULL, getInt, setFrameBorderWidth, NULL, NULL},
566 {"FrameBorderColor", "black", NULL,
567 NULL, getColor, setFrameBorderColor, NULL, NULL},
568 {"FrameSelectedBorderColor", "white", NULL,
569 NULL, getColor, setFrameSelectedBorderColor, NULL, NULL},
571 /* keybindings */
573 {"RootMenuKey", "None", (void *)WKBD_ROOTMENU,
574 NULL, getKeybind, setKeyGrab, NULL, NULL},
575 {"WindowListKey", "None", (void *)WKBD_WINDOWLIST,
576 NULL, getKeybind, setKeyGrab, NULL, NULL},
577 {"WindowMenuKey", "None", (void *)WKBD_WINDOWMENU,
578 NULL, getKeybind, setKeyGrab, NULL, NULL},
579 {"DockRaiseLowerKey", "None", (void*)WKBD_DOCKRAISELOWER,
580 NULL, getKeybind, setKeyGrab, NULL, NULL},
581 {"ClipRaiseLowerKey", "None", (void *)WKBD_CLIPRAISELOWER,
582 NULL, getKeybind, setKeyGrab, NULL, NULL},
583 {"MiniaturizeKey", "None", (void *)WKBD_MINIATURIZE,
584 NULL, getKeybind, setKeyGrab, NULL, NULL},
585 {"MinimizeAllKey", "None", (void *)WKBD_MINIMIZEALL,
586 NULL, getKeybind, setKeyGrab, NULL, NULL },
587 {"HideKey", "None", (void *)WKBD_HIDE,
588 NULL, getKeybind, setKeyGrab, NULL, NULL},
589 {"HideOthersKey", "None", (void *)WKBD_HIDE_OTHERS,
590 NULL, getKeybind, setKeyGrab, NULL, NULL},
591 {"MoveResizeKey", "None", (void *)WKBD_MOVERESIZE,
592 NULL, getKeybind, setKeyGrab, NULL, NULL},
593 {"CloseKey", "None", (void *)WKBD_CLOSE,
594 NULL, getKeybind, setKeyGrab, NULL, NULL},
595 {"MaximizeKey", "None", (void *)WKBD_MAXIMIZE,
596 NULL, getKeybind, setKeyGrab, NULL, NULL},
597 {"VMaximizeKey", "None", (void *)WKBD_VMAXIMIZE,
598 NULL, getKeybind, setKeyGrab, NULL, NULL},
599 {"HMaximizeKey", "None", (void *)WKBD_HMAXIMIZE,
600 NULL, getKeybind, setKeyGrab, NULL, NULL},
601 {"LHMaximizeKey", "None", (void*)WKBD_LHMAXIMIZE,
602 NULL, getKeybind, setKeyGrab, NULL, NULL},
603 {"RHMaximizeKey", "None", (void*)WKBD_RHMAXIMIZE,
604 NULL, getKeybind, setKeyGrab, NULL, NULL},
605 {"MaximusKey", "None", (void*)WKBD_MAXIMUS,
606 NULL, getKeybind, setKeyGrab, NULL, NULL},
607 {"RaiseKey", "\"Meta+Up\"", (void *)WKBD_RAISE,
608 NULL, getKeybind, setKeyGrab, NULL, NULL},
609 {"LowerKey", "\"Meta+Down\"", (void *)WKBD_LOWER,
610 NULL, getKeybind, setKeyGrab, NULL, NULL},
611 {"RaiseLowerKey", "None", (void *)WKBD_RAISELOWER,
612 NULL, getKeybind, setKeyGrab, NULL, NULL},
613 {"ShadeKey", "None", (void *)WKBD_SHADE,
614 NULL, getKeybind, setKeyGrab, NULL, NULL},
615 {"SelectKey", "None", (void *)WKBD_SELECT,
616 NULL, getKeybind, setKeyGrab, NULL, NULL},
617 {"FocusNextKey", "None", (void *)WKBD_FOCUSNEXT,
618 NULL, getKeybind, setKeyGrab, NULL, NULL},
619 {"FocusPrevKey", "None", (void *)WKBD_FOCUSPREV,
620 NULL, getKeybind, setKeyGrab, NULL, NULL},
621 {"GroupNextKey", "None", (void *)WKBD_GROUPNEXT,
622 NULL, getKeybind, setKeyGrab, NULL, NULL},
623 {"GroupPrevKey", "None", (void *)WKBD_GROUPPREV,
624 NULL, getKeybind, setKeyGrab, NULL, NULL},
625 {"NextWorkspaceKey", "None", (void *)WKBD_NEXTWORKSPACE,
626 NULL, getKeybind, setKeyGrab, NULL, NULL},
627 {"PrevWorkspaceKey", "None", (void *)WKBD_PREVWORKSPACE,
628 NULL, getKeybind, setKeyGrab, NULL, NULL},
629 {"LastWorkspaceKey", "None", (void *)WKBD_LASTWORKSPACE,
630 NULL, getKeybind, setKeyGrab, NULL, NULL},
631 {"NextWorkspaceLayerKey", "None", (void *)WKBD_NEXTWSLAYER,
632 NULL, getKeybind, setKeyGrab, NULL, NULL},
633 {"PrevWorkspaceLayerKey", "None", (void *)WKBD_PREVWSLAYER,
634 NULL, getKeybind, setKeyGrab, NULL, NULL},
635 {"Workspace1Key", "None", (void *)WKBD_WORKSPACE1,
636 NULL, getKeybind, setKeyGrab, NULL, NULL},
637 {"Workspace2Key", "None", (void *)WKBD_WORKSPACE2,
638 NULL, getKeybind, setKeyGrab, NULL, NULL},
639 {"Workspace3Key", "None", (void *)WKBD_WORKSPACE3,
640 NULL, getKeybind, setKeyGrab, NULL, NULL},
641 {"Workspace4Key", "None", (void *)WKBD_WORKSPACE4,
642 NULL, getKeybind, setKeyGrab, NULL, NULL},
643 {"Workspace5Key", "None", (void *)WKBD_WORKSPACE5,
644 NULL, getKeybind, setKeyGrab, NULL, NULL},
645 {"Workspace6Key", "None", (void *)WKBD_WORKSPACE6,
646 NULL, getKeybind, setKeyGrab, NULL, NULL},
647 {"Workspace7Key", "None", (void *)WKBD_WORKSPACE7,
648 NULL, getKeybind, setKeyGrab, NULL, NULL},
649 {"Workspace8Key", "None", (void *)WKBD_WORKSPACE8,
650 NULL, getKeybind, setKeyGrab, NULL, NULL},
651 {"Workspace9Key", "None", (void *)WKBD_WORKSPACE9,
652 NULL, getKeybind, setKeyGrab, NULL, NULL},
653 {"Workspace10Key", "None", (void *)WKBD_WORKSPACE10,
654 NULL, getKeybind, setKeyGrab, NULL, NULL},
655 {"MoveToWorkspace1Key", "None", (void *)WKBD_MOVE_WORKSPACE1,
656 NULL, getKeybind, setKeyGrab, NULL, NULL},
657 {"MoveToWorkspace2Key", "None", (void *)WKBD_MOVE_WORKSPACE2,
658 NULL, getKeybind, setKeyGrab, NULL, NULL},
659 {"MoveToWorkspace3Key", "None", (void *)WKBD_MOVE_WORKSPACE3,
660 NULL, getKeybind, setKeyGrab, NULL, NULL},
661 {"MoveToWorkspace4Key", "None", (void *)WKBD_MOVE_WORKSPACE4,
662 NULL, getKeybind, setKeyGrab, NULL, NULL},
663 {"MoveToWorkspace5Key", "None", (void *)WKBD_MOVE_WORKSPACE5,
664 NULL, getKeybind, setKeyGrab, NULL, NULL},
665 {"MoveToWorkspace6Key", "None", (void *)WKBD_MOVE_WORKSPACE6,
666 NULL, getKeybind, setKeyGrab, NULL, NULL},
667 {"MoveToWorkspace7Key", "None", (void *)WKBD_MOVE_WORKSPACE7,
668 NULL, getKeybind, setKeyGrab, NULL, NULL},
669 {"MoveToWorkspace8Key", "None", (void *)WKBD_MOVE_WORKSPACE8,
670 NULL, getKeybind, setKeyGrab, NULL, NULL},
671 {"MoveToWorkspace9Key", "None", (void *)WKBD_MOVE_WORKSPACE9,
672 NULL, getKeybind, setKeyGrab, NULL, NULL},
673 {"MoveToWorkspace10Key", "None", (void *)WKBD_MOVE_WORKSPACE10,
674 NULL, getKeybind, setKeyGrab, NULL, NULL},
675 {"MoveToNextWorkspaceKey", "None", (void *)WKBD_MOVE_NEXTWORKSPACE,
676 NULL, getKeybind, setKeyGrab, NULL, NULL},
677 {"MoveToPrevWorkspaceKey", "None", (void *)WKBD_MOVE_PREVWORKSPACE,
678 NULL, getKeybind, setKeyGrab, NULL, NULL},
679 {"MoveToLastWorkspaceKey", "None", (void *)WKBD_MOVE_LASTWORKSPACE,
680 NULL, getKeybind, setKeyGrab, NULL, NULL},
681 {"MoveToNextWorkspaceLayerKey", "None", (void *)WKBD_MOVE_NEXTWSLAYER,
682 NULL, getKeybind, setKeyGrab, NULL, NULL},
683 {"MoveToPrevWorkspaceLayerKey", "None", (void *)WKBD_MOVE_PREVWSLAYER,
684 NULL, getKeybind, setKeyGrab, NULL, NULL},
685 {"WindowShortcut1Key", "None", (void *)WKBD_WINDOW1,
686 NULL, getKeybind, setKeyGrab, NULL, NULL},
687 {"WindowShortcut2Key", "None", (void *)WKBD_WINDOW2,
688 NULL, getKeybind, setKeyGrab, NULL, NULL},
689 {"WindowShortcut3Key", "None", (void *)WKBD_WINDOW3,
690 NULL, getKeybind, setKeyGrab, NULL, NULL},
691 {"WindowShortcut4Key", "None", (void *)WKBD_WINDOW4,
692 NULL, getKeybind, setKeyGrab, NULL, NULL},
693 {"WindowShortcut5Key", "None", (void *)WKBD_WINDOW5,
694 NULL, getKeybind, setKeyGrab, NULL, NULL},
695 {"WindowShortcut6Key", "None", (void *)WKBD_WINDOW6,
696 NULL, getKeybind, setKeyGrab, NULL, NULL},
697 {"WindowShortcut7Key", "None", (void *)WKBD_WINDOW7,
698 NULL, getKeybind, setKeyGrab, NULL, NULL},
699 {"WindowShortcut8Key", "None", (void *)WKBD_WINDOW8,
700 NULL, getKeybind, setKeyGrab, NULL, NULL},
701 {"WindowShortcut9Key", "None", (void *)WKBD_WINDOW9,
702 NULL, getKeybind, setKeyGrab, NULL, NULL},
703 {"WindowShortcut10Key", "None", (void *)WKBD_WINDOW10,
704 NULL, getKeybind, setKeyGrab, NULL, NULL},
705 {"WindowRelaunchKey", "None", (void *)WKBD_RELAUNCH,
706 NULL, getKeybind, setKeyGrab, NULL, NULL},
707 {"ScreenSwitchKey", "None", (void *)WKBD_SWITCH_SCREEN,
708 NULL, getKeybind, setKeyGrab, NULL, NULL},
710 #ifdef KEEP_XKB_LOCK_STATUS
711 {"ToggleKbdModeKey", "None", (void *)WKBD_TOGGLE,
712 NULL, getKeybind, setKeyGrab, NULL, NULL},
713 {"KbdModeLock", "NO", NULL,
714 &wPreferences.modelock, getBool, NULL, NULL, NULL},
715 #endif /* KEEP_XKB_LOCK_STATUS */
717 {"NormalCursor", "(builtin, left_ptr)", (void *)WCUR_ROOT,
718 NULL, getCursor, setCursor, NULL, NULL},
719 {"ArrowCursor", "(builtin, top_left_arrow)", (void *)WCUR_ARROW,
720 NULL, getCursor, setCursor, NULL, NULL},
721 {"MoveCursor", "(builtin, fleur)", (void *)WCUR_MOVE,
722 NULL, getCursor, setCursor, NULL, NULL},
723 {"ResizeCursor", "(builtin, sizing)", (void *)WCUR_RESIZE,
724 NULL, getCursor, setCursor, NULL, NULL},
725 {"TopLeftResizeCursor", "(builtin, top_left_corner)", (void *)WCUR_TOPLEFTRESIZE,
726 NULL, getCursor, setCursor, NULL, NULL},
727 {"TopRightResizeCursor", "(builtin, top_right_corner)", (void *)WCUR_TOPRIGHTRESIZE,
728 NULL, getCursor, setCursor, NULL, NULL},
729 {"BottomLeftResizeCursor", "(builtin, bottom_left_corner)", (void *)WCUR_BOTTOMLEFTRESIZE,
730 NULL, getCursor, setCursor, NULL, NULL},
731 {"BottomRightResizeCursor", "(builtin, bottom_right_corner)", (void *)WCUR_BOTTOMRIGHTRESIZE,
732 NULL, getCursor, setCursor, NULL, NULL},
733 {"VerticalResizeCursor", "(builtin, sb_v_double_arrow)", (void *)WCUR_VERTICALRESIZE,
734 NULL, getCursor, setCursor, NULL, NULL},
735 {"HorizontalResizeCursor", "(builtin, sb_h_double_arrow)", (void *)WCUR_HORIZONRESIZE,
736 NULL, getCursor, setCursor, NULL, NULL},
737 {"WaitCursor", "(builtin, watch)", (void *)WCUR_WAIT,
738 NULL, getCursor, setCursor, NULL, NULL},
739 {"QuestionCursor", "(builtin, question_arrow)", (void *)WCUR_QUESTION,
740 NULL, getCursor, setCursor, NULL, NULL},
741 {"TextCursor", "(builtin, xterm)", (void *)WCUR_TEXT,
742 NULL, getCursor, setCursor, NULL, NULL},
743 {"SelectCursor", "(builtin, cross)", (void *)WCUR_SELECT,
744 NULL, getCursor, setCursor, NULL, NULL},
745 {"DialogHistoryLines", "500", NULL,
746 &wPreferences.history_lines, getInt, NULL, NULL, NULL},
747 {"CycleActiveHeadOnly", "NO", NULL,
748 &wPreferences.cycle_active_head_only, getBool, NULL, NULL, NULL},
749 {"CycleIgnoreMinimized", "NO", NULL,
750 &wPreferences.cycle_ignore_minimized, getBool, NULL, NULL, NULL}
753 static void initDefaults()
755 unsigned int i;
756 WDefaultEntry *entry;
758 WMPLSetCaseSensitive(False);
760 for (i = 0; i < sizeof(optionList) / sizeof(WDefaultEntry); i++) {
761 entry = &optionList[i];
763 entry->plkey = WMCreatePLString(entry->key);
764 if (entry->default_value)
765 entry->plvalue = WMCreatePropListFromDescription(entry->default_value);
766 else
767 entry->plvalue = NULL;
770 for (i = 0; i < sizeof(staticOptionList) / sizeof(WDefaultEntry); i++) {
771 entry = &staticOptionList[i];
773 entry->plkey = WMCreatePLString(entry->key);
774 if (entry->default_value)
775 entry->plvalue = WMCreatePropListFromDescription(entry->default_value);
776 else
777 entry->plvalue = NULL;
781 static WMPropList *readGlobalDomain(char *domainName, Bool requireDictionary)
783 WMPropList *globalDict = NULL;
784 char path[PATH_MAX];
785 struct stat stbuf;
787 snprintf(path, sizeof(path), "%s/%s/%s", SYSCONFDIR, GLOBAL_DEFAULTS_SUBDIR, domainName);
788 if (stat(path, &stbuf) >= 0) {
789 globalDict = WMReadPropListFromFile(path);
790 if (globalDict && requireDictionary && !WMIsPLDictionary(globalDict)) {
791 wwarning(_("Domain %s (%s) of global defaults database is corrupted!"), domainName, path);
792 WMReleasePropList(globalDict);
793 globalDict = NULL;
794 } else if (!globalDict) {
795 wwarning(_("could not load domain %s from global defaults database"), domainName);
799 return globalDict;
802 #if defined(GLOBAL_PREAMBLE_MENU_FILE) || defined(GLOBAL_EPILOGUE_MENU_FILE)
803 static void prependMenu(WMPropList * destarr, WMPropList * array)
805 WMPropList *item;
806 int i;
808 for (i = 0; i < WMGetPropListItemCount(array); i++) {
809 item = WMGetFromPLArray(array, i);
810 if (item)
811 WMInsertInPLArray(destarr, i + 1, item);
815 static void appendMenu(WMPropList * destarr, WMPropList * array)
817 WMPropList *item;
818 int i;
820 for (i = 0; i < WMGetPropListItemCount(array); i++) {
821 item = WMGetFromPLArray(array, i);
822 if (item)
823 WMAddToPLArray(destarr, item);
826 #endif
828 void wDefaultsMergeGlobalMenus(WDDomain * menuDomain)
830 WMPropList *menu = menuDomain->dictionary;
831 WMPropList *submenu;
833 if (!menu || !WMIsPLArray(menu))
834 return;
836 #ifdef GLOBAL_PREAMBLE_MENU_FILE
837 submenu = WMReadPropListFromFile(SYSCONFDIR "/" GLOBAL_DEFAULTS_SUBDIR "/" GLOBAL_PREAMBLE_MENU_FILE);
839 if (submenu && !WMIsPLArray(submenu)) {
840 wwarning(_("invalid global menu file %s"), GLOBAL_PREAMBLE_MENU_FILE);
841 WMReleasePropList(submenu);
842 submenu = NULL;
844 if (submenu) {
845 prependMenu(menu, submenu);
846 WMReleasePropList(submenu);
848 #endif
850 #ifdef GLOBAL_EPILOGUE_MENU_FILE
851 submenu = WMReadPropListFromFile(SYSCONFDIR "/" GLOBAL_DEFAULTS_SUBDIR "/" GLOBAL_EPILOGUE_MENU_FILE);
853 if (submenu && !WMIsPLArray(submenu)) {
854 wwarning(_("invalid global menu file %s"), GLOBAL_EPILOGUE_MENU_FILE);
855 WMReleasePropList(submenu);
856 submenu = NULL;
858 if (submenu) {
859 appendMenu(menu, submenu);
860 WMReleasePropList(submenu);
862 #endif
864 menuDomain->dictionary = menu;
867 WDDomain *wDefaultsInitDomain(char *domain, Bool requireDictionary)
869 WDDomain *db;
870 struct stat stbuf;
871 static int inited = 0;
872 char *the_path;
873 WMPropList *shared_dict = NULL;
875 if (!inited) {
876 inited = 1;
877 initDefaults();
880 db = wmalloc(sizeof(WDDomain));
881 db->domain_name = domain;
882 db->path = wdefaultspathfordomain(domain);
883 the_path = db->path;
885 if (the_path && stat(the_path, &stbuf) >= 0) {
886 db->dictionary = WMReadPropListFromFile(the_path);
887 if (db->dictionary) {
888 if (requireDictionary && !WMIsPLDictionary(db->dictionary)) {
889 WMReleasePropList(db->dictionary);
890 db->dictionary = NULL;
891 wwarning(_("Domain %s (%s) of defaults database is corrupted!"), domain, the_path);
893 db->timestamp = stbuf.st_mtime;
894 } else {
895 wwarning(_("could not load domain %s from user defaults database"), domain);
899 /* global system dictionary */
900 shared_dict = readGlobalDomain(domain, requireDictionary);
902 if (shared_dict && db->dictionary && WMIsPLDictionary(shared_dict) &&
903 WMIsPLDictionary(db->dictionary)) {
904 WMMergePLDictionaries(shared_dict, db->dictionary, True);
905 WMReleasePropList(db->dictionary);
906 db->dictionary = shared_dict;
907 if (stbuf.st_mtime > db->timestamp)
908 db->timestamp = stbuf.st_mtime;
909 } else if (!db->dictionary) {
910 db->dictionary = shared_dict;
911 if (stbuf.st_mtime > db->timestamp)
912 db->timestamp = stbuf.st_mtime;
915 return db;
918 void wReadStaticDefaults(WMPropList * dict)
920 WMPropList *plvalue;
921 WDefaultEntry *entry;
922 unsigned int i;
923 void *tdata;
925 for (i = 0; i < sizeof(staticOptionList) / sizeof(WDefaultEntry); i++) {
926 entry = &staticOptionList[i];
928 if (dict)
929 plvalue = WMGetFromPLDictionary(dict, entry->plkey);
930 else
931 plvalue = NULL;
933 /* no default in the DB. Use builtin default */
934 if (!plvalue)
935 plvalue = entry->plvalue;
937 if (plvalue) {
938 /* convert data */
939 (*entry->convert) (NULL, entry, plvalue, entry->addr, &tdata);
940 if (entry->update)
941 (*entry->update) (NULL, entry, tdata, entry->extra_data);
946 void wDefaultsCheckDomains(void* arg)
948 WScreen *scr;
949 struct stat stbuf;
950 WMPropList *shared_dict = NULL;
951 WMPropList *dict;
952 int i;
954 if (stat(WDWindowMaker->path, &stbuf) >= 0 && WDWindowMaker->timestamp < stbuf.st_mtime) {
955 WDWindowMaker->timestamp = stbuf.st_mtime;
957 /* Global dictionary */
958 shared_dict = readGlobalDomain("WindowMaker", True);
960 /* User dictionary */
961 dict = WMReadPropListFromFile(WDWindowMaker->path);
963 if (dict) {
964 if (!WMIsPLDictionary(dict)) {
965 WMReleasePropList(dict);
966 dict = NULL;
967 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
968 "WindowMaker", WDWindowMaker->path);
969 } else {
970 if (shared_dict) {
971 WMMergePLDictionaries(shared_dict, dict, True);
972 WMReleasePropList(dict);
973 dict = shared_dict;
974 shared_dict = NULL;
977 for (i = 0; i < wScreenCount; i++) {
978 scr = wScreenWithNumber(i);
979 if (scr)
980 wReadDefaults(scr, dict);
983 if (WDWindowMaker->dictionary)
984 WMReleasePropList(WDWindowMaker->dictionary);
986 WDWindowMaker->dictionary = dict;
988 } else {
989 wwarning(_("could not load domain %s from user defaults database"), "WindowMaker");
992 if (shared_dict)
993 WMReleasePropList(shared_dict);
997 if (stat(WDWindowAttributes->path, &stbuf) >= 0 && WDWindowAttributes->timestamp < stbuf.st_mtime) {
998 /* global dictionary */
999 shared_dict = readGlobalDomain("WMWindowAttributes", True);
1000 /* user dictionary */
1001 dict = WMReadPropListFromFile(WDWindowAttributes->path);
1002 if (dict) {
1003 if (!WMIsPLDictionary(dict)) {
1004 WMReleasePropList(dict);
1005 dict = NULL;
1006 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
1007 "WMWindowAttributes", WDWindowAttributes->path);
1008 } else {
1009 if (shared_dict) {
1010 WMMergePLDictionaries(shared_dict, dict, True);
1011 WMReleasePropList(dict);
1012 dict = shared_dict;
1013 shared_dict = NULL;
1016 if (WDWindowAttributes->dictionary)
1017 WMReleasePropList(WDWindowAttributes->dictionary);
1019 WDWindowAttributes->dictionary = dict;
1020 for (i = 0; i < wScreenCount; i++) {
1021 scr = wScreenWithNumber(i);
1022 if (scr) {
1023 wDefaultUpdateIcons(scr);
1025 /* Update the panel image if changed */
1026 /* Don't worry. If the image is the same these
1027 * functions will have no performance impact. */
1028 create_logo_image(scr);
1032 } else {
1033 wwarning(_("could not load domain %s from user defaults database"), "WMWindowAttributes");
1036 WDWindowAttributes->timestamp = stbuf.st_mtime;
1037 if (shared_dict)
1038 WMReleasePropList(shared_dict);
1041 if (stat(WDRootMenu->path, &stbuf) >= 0 && WDRootMenu->timestamp < stbuf.st_mtime) {
1042 dict = WMReadPropListFromFile(WDRootMenu->path);
1043 if (dict) {
1044 if (!WMIsPLArray(dict) && !WMIsPLString(dict)) {
1045 WMReleasePropList(dict);
1046 dict = NULL;
1047 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
1048 "WMRootMenu", WDRootMenu->path);
1049 } else {
1050 if (WDRootMenu->dictionary)
1051 WMReleasePropList(WDRootMenu->dictionary);
1053 WDRootMenu->dictionary = dict;
1054 wDefaultsMergeGlobalMenus(WDRootMenu);
1056 } else {
1057 wwarning(_("could not load domain %s from user defaults database"), "WMRootMenu");
1059 WDRootMenu->timestamp = stbuf.st_mtime;
1061 #ifndef HAVE_INOTIFY
1062 if (!arg)
1063 WMAddTimerHandler(DEFAULTS_CHECK_INTERVAL, wDefaultsCheckDomains, arg);
1064 #endif
1067 void wReadDefaults(WScreen * scr, WMPropList * new_dict)
1069 WMPropList *plvalue, *old_value;
1070 WDefaultEntry *entry;
1071 unsigned int i;
1072 int update_workspace_back = 0; /* kluge :/ */
1073 unsigned int needs_refresh;
1074 void *tdata;
1075 WMPropList *old_dict = (WDWindowMaker->dictionary != new_dict ? WDWindowMaker->dictionary : NULL);
1077 needs_refresh = 0;
1079 for (i = 0; i < sizeof(optionList) / sizeof(WDefaultEntry); i++) {
1080 entry = &optionList[i];
1082 if (new_dict)
1083 plvalue = WMGetFromPLDictionary(new_dict, entry->plkey);
1084 else
1085 plvalue = NULL;
1087 if (!old_dict)
1088 old_value = NULL;
1089 else
1090 old_value = WMGetFromPLDictionary(old_dict, entry->plkey);
1092 if (!plvalue && !old_value) {
1093 /* no default in the DB. Use builtin default */
1094 plvalue = entry->plvalue;
1095 if (plvalue && new_dict)
1096 WMPutInPLDictionary(new_dict, entry->plkey, plvalue);
1098 } else if (!plvalue) {
1099 /* value was deleted from DB. Keep current value */
1100 continue;
1101 } else if (!old_value) {
1102 /* set value for the 1st time */
1103 } else if (!WMIsPropListEqualTo(plvalue, old_value)) {
1104 /* value has changed */
1105 } else {
1106 if (strcmp(entry->key, "WorkspaceBack") == 0
1107 && update_workspace_back && scr->flags.backimage_helper_launched) {
1108 } else {
1109 /* value was not changed since last time */
1110 continue;
1114 if (plvalue) {
1115 /* convert data */
1116 if ((*entry->convert) (scr, entry, plvalue, entry->addr, &tdata)) {
1118 * If the WorkspaceSpecificBack data has been changed
1119 * so that the helper will be launched now, we must be
1120 * sure to send the default background texture config
1121 * to the helper.
1123 if (strcmp(entry->key, "WorkspaceSpecificBack") == 0 &&
1124 !scr->flags.backimage_helper_launched)
1125 update_workspace_back = 1;
1127 if (entry->update)
1128 needs_refresh |= (*entry->update) (scr, entry, tdata, entry->extra_data);
1134 if (needs_refresh != 0 && !scr->flags.startup) {
1135 int foo;
1137 foo = 0;
1138 if (needs_refresh & REFRESH_MENU_TITLE_TEXTURE)
1139 foo |= WTextureSettings;
1140 if (needs_refresh & REFRESH_MENU_TITLE_FONT)
1141 foo |= WFontSettings;
1142 if (needs_refresh & REFRESH_MENU_TITLE_COLOR)
1143 foo |= WColorSettings;
1144 if (foo)
1145 WMPostNotificationName(WNMenuTitleAppearanceSettingsChanged, NULL,
1146 (void *)(uintptr_t) foo);
1148 foo = 0;
1149 if (needs_refresh & REFRESH_MENU_TEXTURE)
1150 foo |= WTextureSettings;
1151 if (needs_refresh & REFRESH_MENU_FONT)
1152 foo |= WFontSettings;
1153 if (needs_refresh & REFRESH_MENU_COLOR)
1154 foo |= WColorSettings;
1155 if (foo)
1156 WMPostNotificationName(WNMenuAppearanceSettingsChanged, NULL, (void *)(uintptr_t) foo);
1158 foo = 0;
1159 if (needs_refresh & REFRESH_WINDOW_FONT)
1160 foo |= WFontSettings;
1161 if (needs_refresh & REFRESH_WINDOW_TEXTURES)
1162 foo |= WTextureSettings;
1163 if (needs_refresh & REFRESH_WINDOW_TITLE_COLOR)
1164 foo |= WColorSettings;
1165 if (foo)
1166 WMPostNotificationName(WNWindowAppearanceSettingsChanged, NULL, (void *)(uintptr_t) foo);
1168 if (!(needs_refresh & REFRESH_ICON_TILE)) {
1169 foo = 0;
1170 if (needs_refresh & REFRESH_ICON_FONT)
1171 foo |= WFontSettings;
1172 if (needs_refresh & REFRESH_ICON_TITLE_COLOR)
1173 foo |= WTextureSettings;
1174 if (needs_refresh & REFRESH_ICON_TITLE_BACK)
1175 foo |= WTextureSettings;
1176 if (foo)
1177 WMPostNotificationName(WNIconAppearanceSettingsChanged, NULL,
1178 (void *)(uintptr_t) foo);
1180 if (needs_refresh & REFRESH_ICON_TILE)
1181 WMPostNotificationName(WNIconTileSettingsChanged, NULL, NULL);
1183 if (needs_refresh & REFRESH_WORKSPACE_MENU) {
1184 if (scr->workspace_menu)
1185 wWorkspaceMenuUpdate(scr, scr->workspace_menu);
1186 if (scr->clip_ws_menu)
1187 wWorkspaceMenuUpdate(scr, scr->clip_ws_menu);
1188 if (scr->workspace_submenu)
1189 scr->workspace_submenu->flags.realized = 0;
1190 if (scr->clip_submenu)
1191 scr->clip_submenu->flags.realized = 0;
1196 void wDefaultUpdateIcons(WScreen *scr)
1198 WAppIcon *aicon = scr->app_icon_list;
1199 WDrawerChain *dc;
1200 WWindow *wwin = scr->focused_window;
1202 while (aicon) {
1203 /* Get the application icon, default included */
1204 wIconChangeImageFile(aicon->icon, NULL);
1205 wAppIconPaint(aicon);
1206 aicon = aicon->next;
1209 if (!wPreferences.flags.noclip || wPreferences.flags.clip_merged_in_dock)
1210 wClipIconPaint(scr->clip_icon);
1212 for (dc = scr->drawers; dc != NULL; dc = dc->next)
1213 wDrawerIconPaint(dc->adrawer->icon_array[0]);
1215 while (wwin) {
1216 if (wwin->icon && wwin->flags.miniaturized)
1217 wIconChangeImageFile(wwin->icon, NULL);
1218 wwin = wwin->prev;
1222 /* --------------------------- Local ----------------------- */
1224 #define GET_STRING_OR_DEFAULT(x, var) if (!WMIsPLString(value)) { \
1225 wwarning(_("Wrong option format for key \"%s\". Should be %s."), \
1226 entry->key, x); \
1227 wwarning(_("using default \"%s\" instead"), entry->default_value); \
1228 var = entry->default_value;\
1229 } else var = WMGetFromPLString(value)\
1232 static int string2index(WMPropList * key, WMPropList * val, char *def, WOptionEnumeration * values)
1234 char *str;
1235 WOptionEnumeration *v;
1236 char buffer[TOTAL_VALUES_LENGTH];
1238 if (WMIsPLString(val) && (str = WMGetFromPLString(val))) {
1239 for (v = values; v->string != NULL; v++) {
1240 if (strcasecmp(v->string, str) == 0)
1241 return v->value;
1245 buffer[0] = 0;
1246 for (v = values; v->string != NULL; v++) {
1247 if (!v->is_alias) {
1248 if (buffer[0] != 0)
1249 strcat(buffer, ", ");
1250 snprintf(buffer+strlen(buffer),
1251 sizeof(buffer)-strlen(buffer)-1, "\"%s\"", v->string);
1254 wwarning(_("wrong option value for key \"%s\"; got \"%s\", should be one of %s."),
1255 WMGetFromPLString(key),
1256 WMIsPLString(val) ? WMGetFromPLString(val) : "(unknown)",
1257 buffer);
1259 if (def) {
1260 return string2index(key, val, NULL, values);
1263 return -1;
1267 * value - is the value in the defaults DB
1268 * addr - is the address to store the data
1269 * ret - is the address to store a pointer to a temporary buffer. ret
1270 * must not be freed and is used by the set functions
1272 static int getBool(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1274 static char data;
1275 char *val;
1276 int second_pass = 0;
1278 GET_STRING_OR_DEFAULT("Boolean", val);
1280 again:
1281 if ((val[1] == '\0' && (val[0] == 'y' || val[0] == 'Y'))
1282 || strcasecmp(val, "YES") == 0) {
1284 data = 1;
1285 } else if ((val[1] == '\0' && (val[0] == 'n' || val[0] == 'N'))
1286 || strcasecmp(val, "NO") == 0) {
1287 data = 0;
1288 } else {
1289 int i;
1290 if (sscanf(val, "%i", &i) == 1) {
1291 if (i != 0)
1292 data = 1;
1293 else
1294 data = 0;
1295 } else {
1296 wwarning(_("can't convert \"%s\" to boolean for key \"%s\""), val, entry->key);
1297 if (second_pass == 0) {
1298 val = WMGetFromPLString(entry->plvalue);
1299 second_pass = 1;
1300 wwarning(_("using default \"%s\" instead"), val);
1301 goto again;
1303 return False;
1307 if (ret)
1308 *ret = &data;
1309 if (addr)
1310 *(char *)addr = data;
1312 return True;
1315 static int getInt(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1317 static int data;
1318 char *val;
1320 GET_STRING_OR_DEFAULT("Integer", val);
1322 if (sscanf(val, "%i", &data) != 1) {
1323 wwarning(_("can't convert \"%s\" to integer for key \"%s\""), val, entry->key);
1324 val = WMGetFromPLString(entry->plvalue);
1325 wwarning(_("using default \"%s\" instead"), val);
1326 if (sscanf(val, "%i", &data) != 1) {
1327 return False;
1331 if (ret)
1332 *ret = &data;
1333 if (addr)
1334 *(int *)addr = data;
1336 return True;
1339 static int getCoord(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1341 static WCoord data;
1342 char *val_x, *val_y;
1343 int nelem, changed = 0;
1344 WMPropList *elem_x, *elem_y;
1346 again:
1347 if (!WMIsPLArray(value)) {
1348 wwarning(_("Wrong option format for key \"%s\". Should be %s."), entry->key, "Coordinate");
1349 if (changed == 0) {
1350 value = entry->plvalue;
1351 changed = 1;
1352 wwarning(_("using default \"%s\" instead"), entry->default_value);
1353 goto again;
1355 return False;
1358 nelem = WMGetPropListItemCount(value);
1359 if (nelem != 2) {
1360 wwarning(_("Incorrect number of elements in array for key \"%s\"."), entry->key);
1361 if (changed == 0) {
1362 value = entry->plvalue;
1363 changed = 1;
1364 wwarning(_("using default \"%s\" instead"), entry->default_value);
1365 goto again;
1367 return False;
1370 elem_x = WMGetFromPLArray(value, 0);
1371 elem_y = WMGetFromPLArray(value, 1);
1373 if (!elem_x || !elem_y || !WMIsPLString(elem_x) || !WMIsPLString(elem_y)) {
1374 wwarning(_("Wrong value for key \"%s\". Should be Coordinate."), entry->key);
1375 if (changed == 0) {
1376 value = entry->plvalue;
1377 changed = 1;
1378 wwarning(_("using default \"%s\" instead"), entry->default_value);
1379 goto again;
1381 return False;
1384 val_x = WMGetFromPLString(elem_x);
1385 val_y = WMGetFromPLString(elem_y);
1387 if (sscanf(val_x, "%i", &data.x) != 1 || sscanf(val_y, "%i", &data.y) != 1) {
1388 wwarning(_("can't convert array to integers for \"%s\"."), entry->key);
1389 if (changed == 0) {
1390 value = entry->plvalue;
1391 changed = 1;
1392 wwarning(_("using default \"%s\" instead"), entry->default_value);
1393 goto again;
1395 return False;
1398 if (data.x < 0)
1399 data.x = 0;
1400 else if (data.x > scr->scr_width / 3)
1401 data.x = scr->scr_width / 3;
1402 if (data.y < 0)
1403 data.y = 0;
1404 else if (data.y > scr->scr_height / 3)
1405 data.y = scr->scr_height / 3;
1407 if (ret)
1408 *ret = &data;
1409 if (addr)
1410 *(WCoord *) addr = data;
1412 return True;
1415 static int getPropList(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1417 WMRetainPropList(value);
1419 *ret = value;
1421 return True;
1424 static int getPathList(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1426 static char *data;
1427 int i, count, len;
1428 char *ptr;
1429 WMPropList *d;
1430 int changed = 0;
1432 again:
1433 if (!WMIsPLArray(value)) {
1434 wwarning(_("Wrong option format for key \"%s\". Should be %s."), entry->key, "an array of paths");
1435 if (changed == 0) {
1436 value = entry->plvalue;
1437 changed = 1;
1438 wwarning(_("using default \"%s\" instead"), entry->default_value);
1439 goto again;
1441 return False;
1444 i = 0;
1445 count = WMGetPropListItemCount(value);
1446 if (count < 1) {
1447 if (changed == 0) {
1448 value = entry->plvalue;
1449 changed = 1;
1450 wwarning(_("using default \"%s\" instead"), entry->default_value);
1451 goto again;
1453 return False;
1456 len = 0;
1457 for (i = 0; i < count; i++) {
1458 d = WMGetFromPLArray(value, i);
1459 if (!d || !WMIsPLString(d)) {
1460 count = i;
1461 break;
1463 len += strlen(WMGetFromPLString(d)) + 1;
1466 ptr = data = wmalloc(len + 1);
1468 for (i = 0; i < count; i++) {
1469 d = WMGetFromPLArray(value, i);
1470 if (!d || !WMIsPLString(d)) {
1471 break;
1473 strcpy(ptr, WMGetFromPLString(d));
1474 ptr += strlen(WMGetFromPLString(d));
1475 *ptr = ':';
1476 ptr++;
1478 ptr--;
1479 *(ptr--) = 0;
1481 if (*(char **)addr != NULL) {
1482 wfree(*(char **)addr);
1484 *(char **)addr = data;
1486 return True;
1489 static int getEnum(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1491 static signed char data;
1493 data = string2index(entry->plkey, value, entry->default_value, (WOptionEnumeration *) entry->extra_data);
1494 if (data < 0)
1495 return False;
1497 if (ret)
1498 *ret = &data;
1499 if (addr)
1500 *(signed char *)addr = data;
1502 return True;
1506 * (solid <color>)
1507 * (hgradient <color> <color>)
1508 * (vgradient <color> <color>)
1509 * (dgradient <color> <color>)
1510 * (mhgradient <color> <color> ...)
1511 * (mvgradient <color> <color> ...)
1512 * (mdgradient <color> <color> ...)
1513 * (igradient <color1> <color1> <thickness1> <color2> <color2> <thickness2>)
1514 * (tpixmap <file> <color>)
1515 * (spixmap <file> <color>)
1516 * (cpixmap <file> <color>)
1517 * (thgradient <file> <opaqueness> <color> <color>)
1518 * (tvgradient <file> <opaqueness> <color> <color>)
1519 * (tdgradient <file> <opaqueness> <color> <color>)
1520 * (function <lib> <function> ...)
1523 static WTexture *parse_texture(WScreen * scr, WMPropList * pl)
1525 WMPropList *elem;
1526 char *val;
1527 int nelem;
1528 WTexture *texture = NULL;
1530 nelem = WMGetPropListItemCount(pl);
1531 if (nelem < 1)
1532 return NULL;
1534 elem = WMGetFromPLArray(pl, 0);
1535 if (!elem || !WMIsPLString(elem))
1536 return NULL;
1537 val = WMGetFromPLString(elem);
1539 if (strcasecmp(val, "solid") == 0) {
1540 XColor color;
1542 if (nelem != 2)
1543 return NULL;
1545 /* get color */
1547 elem = WMGetFromPLArray(pl, 1);
1548 if (!elem || !WMIsPLString(elem))
1549 return NULL;
1550 val = WMGetFromPLString(elem);
1552 if (!XParseColor(dpy, scr->w_colormap, val, &color)) {
1553 wwarning(_("\"%s\" is not a valid color name"), val);
1554 return NULL;
1557 texture = (WTexture *) wTextureMakeSolid(scr, &color);
1558 } else if (strcasecmp(val, "dgradient") == 0
1559 || strcasecmp(val, "vgradient") == 0 || strcasecmp(val, "hgradient") == 0) {
1560 RColor color1, color2;
1561 XColor xcolor;
1562 int type;
1564 if (nelem != 3) {
1565 wwarning(_("bad number of arguments in gradient specification"));
1566 return NULL;
1569 if (val[0] == 'd' || val[0] == 'D')
1570 type = WTEX_DGRADIENT;
1571 else if (val[0] == 'h' || val[0] == 'H')
1572 type = WTEX_HGRADIENT;
1573 else
1574 type = WTEX_VGRADIENT;
1576 /* get from color */
1577 elem = WMGetFromPLArray(pl, 1);
1578 if (!elem || !WMIsPLString(elem))
1579 return NULL;
1580 val = WMGetFromPLString(elem);
1582 if (!XParseColor(dpy, scr->w_colormap, val, &xcolor)) {
1583 wwarning(_("\"%s\" is not a valid color name"), val);
1584 return NULL;
1586 color1.alpha = 255;
1587 color1.red = xcolor.red >> 8;
1588 color1.green = xcolor.green >> 8;
1589 color1.blue = xcolor.blue >> 8;
1591 /* get to color */
1592 elem = WMGetFromPLArray(pl, 2);
1593 if (!elem || !WMIsPLString(elem)) {
1594 return NULL;
1596 val = WMGetFromPLString(elem);
1598 if (!XParseColor(dpy, scr->w_colormap, val, &xcolor)) {
1599 wwarning(_("\"%s\" is not a valid color name"), val);
1600 return NULL;
1602 color2.alpha = 255;
1603 color2.red = xcolor.red >> 8;
1604 color2.green = xcolor.green >> 8;
1605 color2.blue = xcolor.blue >> 8;
1607 texture = (WTexture *) wTextureMakeGradient(scr, type, &color1, &color2);
1609 } else if (strcasecmp(val, "igradient") == 0) {
1610 RColor colors1[2], colors2[2];
1611 int th1, th2;
1612 XColor xcolor;
1613 int i;
1615 if (nelem != 7) {
1616 wwarning(_("bad number of arguments in gradient specification"));
1617 return NULL;
1620 /* get from color */
1621 for (i = 0; i < 2; i++) {
1622 elem = WMGetFromPLArray(pl, 1 + i);
1623 if (!elem || !WMIsPLString(elem))
1624 return NULL;
1625 val = WMGetFromPLString(elem);
1627 if (!XParseColor(dpy, scr->w_colormap, val, &xcolor)) {
1628 wwarning(_("\"%s\" is not a valid color name"), val);
1629 return NULL;
1631 colors1[i].alpha = 255;
1632 colors1[i].red = xcolor.red >> 8;
1633 colors1[i].green = xcolor.green >> 8;
1634 colors1[i].blue = xcolor.blue >> 8;
1636 elem = WMGetFromPLArray(pl, 3);
1637 if (!elem || !WMIsPLString(elem))
1638 return NULL;
1639 val = WMGetFromPLString(elem);
1640 th1 = atoi(val);
1642 /* get from color */
1643 for (i = 0; i < 2; i++) {
1644 elem = WMGetFromPLArray(pl, 4 + i);
1645 if (!elem || !WMIsPLString(elem))
1646 return NULL;
1647 val = WMGetFromPLString(elem);
1649 if (!XParseColor(dpy, scr->w_colormap, val, &xcolor)) {
1650 wwarning(_("\"%s\" is not a valid color name"), val);
1651 return NULL;
1653 colors2[i].alpha = 255;
1654 colors2[i].red = xcolor.red >> 8;
1655 colors2[i].green = xcolor.green >> 8;
1656 colors2[i].blue = xcolor.blue >> 8;
1658 elem = WMGetFromPLArray(pl, 6);
1659 if (!elem || !WMIsPLString(elem))
1660 return NULL;
1661 val = WMGetFromPLString(elem);
1662 th2 = atoi(val);
1664 texture = (WTexture *) wTextureMakeIGradient(scr, th1, colors1, th2, colors2);
1666 } else if (strcasecmp(val, "mhgradient") == 0
1667 || strcasecmp(val, "mvgradient") == 0 || strcasecmp(val, "mdgradient") == 0) {
1668 XColor color;
1669 RColor **colors;
1670 int i, count;
1671 int type;
1673 if (nelem < 3) {
1674 wwarning(_("too few arguments in multicolor gradient specification"));
1675 return NULL;
1678 if (val[1] == 'h' || val[1] == 'H')
1679 type = WTEX_MHGRADIENT;
1680 else if (val[1] == 'v' || val[1] == 'V')
1681 type = WTEX_MVGRADIENT;
1682 else
1683 type = WTEX_MDGRADIENT;
1685 count = nelem - 1;
1687 colors = wmalloc(sizeof(RColor *) * (count + 1));
1689 for (i = 0; i < count; i++) {
1690 elem = WMGetFromPLArray(pl, i + 1);
1691 if (!elem || !WMIsPLString(elem)) {
1692 for (--i; i >= 0; --i) {
1693 wfree(colors[i]);
1695 wfree(colors);
1696 return NULL;
1698 val = WMGetFromPLString(elem);
1700 if (!XParseColor(dpy, scr->w_colormap, val, &color)) {
1701 wwarning(_("\"%s\" is not a valid color name"), val);
1702 for (--i; i >= 0; --i) {
1703 wfree(colors[i]);
1705 wfree(colors);
1706 return NULL;
1707 } else {
1708 colors[i] = wmalloc(sizeof(RColor));
1709 colors[i]->red = color.red >> 8;
1710 colors[i]->green = color.green >> 8;
1711 colors[i]->blue = color.blue >> 8;
1714 colors[i] = NULL;
1716 texture = (WTexture *) wTextureMakeMGradient(scr, type, colors);
1717 } else if (strcasecmp(val, "spixmap") == 0 ||
1718 strcasecmp(val, "cpixmap") == 0 || strcasecmp(val, "tpixmap") == 0) {
1719 XColor color;
1720 int type;
1722 if (nelem != 3)
1723 return NULL;
1725 if (val[0] == 's' || val[0] == 'S')
1726 type = WTP_SCALE;
1727 else if (val[0] == 'c' || val[0] == 'C')
1728 type = WTP_CENTER;
1729 else
1730 type = WTP_TILE;
1732 /* get color */
1733 elem = WMGetFromPLArray(pl, 2);
1734 if (!elem || !WMIsPLString(elem)) {
1735 return NULL;
1737 val = WMGetFromPLString(elem);
1739 if (!XParseColor(dpy, scr->w_colormap, val, &color)) {
1740 wwarning(_("\"%s\" is not a valid color name"), val);
1741 return NULL;
1744 /* file name */
1745 elem = WMGetFromPLArray(pl, 1);
1746 if (!elem || !WMIsPLString(elem))
1747 return NULL;
1748 val = WMGetFromPLString(elem);
1750 texture = (WTexture *) wTextureMakePixmap(scr, type, val, &color);
1751 } else if (strcasecmp(val, "thgradient") == 0
1752 || strcasecmp(val, "tvgradient") == 0 || strcasecmp(val, "tdgradient") == 0) {
1753 RColor color1, color2;
1754 XColor xcolor;
1755 int opacity;
1756 int style;
1758 if (val[1] == 'h' || val[1] == 'H')
1759 style = WTEX_THGRADIENT;
1760 else if (val[1] == 'v' || val[1] == 'V')
1761 style = WTEX_TVGRADIENT;
1762 else
1763 style = WTEX_TDGRADIENT;
1765 if (nelem != 5) {
1766 wwarning(_("bad number of arguments in textured gradient specification"));
1767 return NULL;
1770 /* get from color */
1771 elem = WMGetFromPLArray(pl, 3);
1772 if (!elem || !WMIsPLString(elem))
1773 return NULL;
1774 val = WMGetFromPLString(elem);
1776 if (!XParseColor(dpy, scr->w_colormap, val, &xcolor)) {
1777 wwarning(_("\"%s\" is not a valid color name"), val);
1778 return NULL;
1780 color1.alpha = 255;
1781 color1.red = xcolor.red >> 8;
1782 color1.green = xcolor.green >> 8;
1783 color1.blue = xcolor.blue >> 8;
1785 /* get to color */
1786 elem = WMGetFromPLArray(pl, 4);
1787 if (!elem || !WMIsPLString(elem)) {
1788 return NULL;
1790 val = WMGetFromPLString(elem);
1792 if (!XParseColor(dpy, scr->w_colormap, val, &xcolor)) {
1793 wwarning(_("\"%s\" is not a valid color name"), val);
1794 return NULL;
1796 color2.alpha = 255;
1797 color2.red = xcolor.red >> 8;
1798 color2.green = xcolor.green >> 8;
1799 color2.blue = xcolor.blue >> 8;
1801 /* get opacity */
1802 elem = WMGetFromPLArray(pl, 2);
1803 if (!elem || !WMIsPLString(elem))
1804 opacity = 128;
1805 else
1806 val = WMGetFromPLString(elem);
1808 if (!val || (opacity = atoi(val)) < 0 || opacity > 255) {
1809 wwarning(_("bad opacity value for tgradient texture \"%s\". Should be [0..255]"), val);
1810 opacity = 128;
1813 /* get file name */
1814 elem = WMGetFromPLArray(pl, 1);
1815 if (!elem || !WMIsPLString(elem))
1816 return NULL;
1817 val = WMGetFromPLString(elem);
1819 texture = (WTexture *) wTextureMakeTGradient(scr, style, &color1, &color2, val, opacity);
1820 } else if (strcasecmp(val, "function") == 0) {
1821 /* Leave this in to handle the unlikely case of
1822 * someone actually having function textures configured */
1823 wwarning("function texture support has been removed");
1824 return NULL;
1825 } else {
1826 wwarning(_("invalid texture type %s"), val);
1827 return NULL;
1829 return texture;
1832 static int getTexture(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1834 static WTexture *texture;
1835 int changed = 0;
1837 again:
1838 if (!WMIsPLArray(value)) {
1839 wwarning(_("Wrong option format for key \"%s\". Should be %s."), entry->key, "Texture");
1840 if (changed == 0) {
1841 value = entry->plvalue;
1842 changed = 1;
1843 wwarning(_("using default \"%s\" instead"), entry->default_value);
1844 goto again;
1846 return False;
1849 if (strcmp(entry->key, "WidgetColor") == 0 && !changed) {
1850 WMPropList *pl;
1852 pl = WMGetFromPLArray(value, 0);
1853 if (!pl || !WMIsPLString(pl) || !WMGetFromPLString(pl)
1854 || strcasecmp(WMGetFromPLString(pl), "solid") != 0) {
1855 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1856 entry->key, "Solid Texture");
1858 value = entry->plvalue;
1859 changed = 1;
1860 wwarning(_("using default \"%s\" instead"), entry->default_value);
1861 goto again;
1865 texture = parse_texture(scr, value);
1867 if (!texture) {
1868 wwarning(_("Error in texture specification for key \"%s\""), entry->key);
1869 if (changed == 0) {
1870 value = entry->plvalue;
1871 changed = 1;
1872 wwarning(_("using default \"%s\" instead"), entry->default_value);
1873 goto again;
1875 return False;
1878 if (ret)
1879 *ret = &texture;
1881 if (addr)
1882 *(WTexture **) addr = texture;
1884 return True;
1887 static int getWSBackground(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1889 WMPropList *elem;
1890 int changed = 0;
1891 char *val;
1892 int nelem;
1894 again:
1895 if (!WMIsPLArray(value)) {
1896 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1897 "WorkspaceBack", "Texture or None");
1898 if (changed == 0) {
1899 value = entry->plvalue;
1900 changed = 1;
1901 wwarning(_("using default \"%s\" instead"), entry->default_value);
1902 goto again;
1904 return False;
1907 /* only do basic error checking and verify for None texture */
1909 nelem = WMGetPropListItemCount(value);
1910 if (nelem > 0) {
1911 elem = WMGetFromPLArray(value, 0);
1912 if (!elem || !WMIsPLString(elem)) {
1913 wwarning(_("Wrong type for workspace background. Should be a texture type."));
1914 if (changed == 0) {
1915 value = entry->plvalue;
1916 changed = 1;
1917 wwarning(_("using default \"%s\" instead"), entry->default_value);
1918 goto again;
1920 return False;
1922 val = WMGetFromPLString(elem);
1924 if (strcasecmp(val, "None") == 0)
1925 return True;
1927 *ret = WMRetainPropList(value);
1929 return True;
1932 static int
1933 getWSSpecificBackground(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1935 WMPropList *elem;
1936 int nelem;
1937 int changed = 0;
1939 again:
1940 if (!WMIsPLArray(value)) {
1941 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1942 "WorkspaceSpecificBack", "an array of textures");
1943 if (changed == 0) {
1944 value = entry->plvalue;
1945 changed = 1;
1946 wwarning(_("using default \"%s\" instead"), entry->default_value);
1947 goto again;
1949 return False;
1952 /* only do basic error checking and verify for None texture */
1954 nelem = WMGetPropListItemCount(value);
1955 if (nelem > 0) {
1956 while (nelem--) {
1957 elem = WMGetFromPLArray(value, nelem);
1958 if (!elem || !WMIsPLArray(elem)) {
1959 wwarning(_("Wrong type for background of workspace %i. Should be a texture."),
1960 nelem);
1965 *ret = WMRetainPropList(value);
1967 #ifdef notworking
1969 * Kluge to force wmsetbg helper to set the default background.
1970 * If the WorkspaceSpecificBack is changed once wmaker has started,
1971 * the WorkspaceBack won't be sent to the helper, unless the user
1972 * changes it's value too. So, we must force this by removing the
1973 * value from the defaults DB.
1975 if (!scr->flags.backimage_helper_launched && !scr->flags.startup) {
1976 WMPropList *key = WMCreatePLString("WorkspaceBack");
1978 WMRemoveFromPLDictionary(WDWindowMaker->dictionary, key);
1980 WMReleasePropList(key);
1982 #endif
1983 return True;
1986 static int getFont(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1988 static WMFont *font;
1989 char *val;
1991 GET_STRING_OR_DEFAULT("Font", val);
1993 font = WMCreateFont(scr->wmscreen, val);
1994 if (!font)
1995 font = WMCreateFont(scr->wmscreen, "fixed");
1997 if (!font) {
1998 wfatal(_("could not load any usable font!!!"));
1999 exit(1);
2002 if (ret)
2003 *ret = font;
2005 /* can't assign font value outside update function */
2006 wassertrv(addr == NULL, True);
2008 return True;
2011 static int getColor(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
2013 static XColor color;
2014 char *val;
2015 int second_pass = 0;
2017 GET_STRING_OR_DEFAULT("Color", val);
2019 again:
2020 if (!wGetColor(scr, val, &color)) {
2021 wwarning(_("could not get color for key \"%s\""), entry->key);
2022 if (second_pass == 0) {
2023 val = WMGetFromPLString(entry->plvalue);
2024 second_pass = 1;
2025 wwarning(_("using default \"%s\" instead"), val);
2026 goto again;
2028 return False;
2031 if (ret)
2032 *ret = &color;
2034 assert(addr == NULL);
2036 if (addr)
2037 *(unsigned long*)addr = pixel;
2040 return True;
2043 static int getKeybind(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
2045 static WShortKey shortcut;
2046 KeySym ksym;
2047 char *val;
2048 char *k;
2049 char buf[MAX_SHORTCUT_LENGTH], *b;
2051 GET_STRING_OR_DEFAULT("Key spec", val);
2053 if (!val || strcasecmp(val, "NONE") == 0) {
2054 shortcut.keycode = 0;
2055 shortcut.modifier = 0;
2056 if (ret)
2057 *ret = &shortcut;
2058 return True;
2061 wstrlcpy(buf, val, MAX_SHORTCUT_LENGTH);
2063 b = (char *)buf;
2065 /* get modifiers */
2066 shortcut.modifier = 0;
2067 while ((k = strchr(b, '+')) != NULL) {
2068 int mod;
2070 *k = 0;
2071 mod = wXModifierFromKey(b);
2072 if (mod < 0) {
2073 wwarning(_("%s: invalid key modifier \"%s\""), entry->key, b);
2074 return False;
2076 shortcut.modifier |= mod;
2078 b = k + 1;
2081 /* get key */
2082 ksym = XStringToKeysym(b);
2084 if (ksym == NoSymbol) {
2085 wwarning(_("%s:invalid kbd shortcut specification \"%s\""), entry->key, val);
2086 return False;
2089 shortcut.keycode = XKeysymToKeycode(dpy, ksym);
2090 if (shortcut.keycode == 0) {
2091 wwarning(_("%s:invalid key in shortcut \"%s\""), entry->key, val);
2092 return False;
2095 if (ret)
2096 *ret = &shortcut;
2098 return True;
2101 static int getModMask(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
2103 static int mask;
2104 char *str;
2106 GET_STRING_OR_DEFAULT("Modifier Key", str);
2108 if (!str)
2109 return False;
2111 mask = wXModifierFromKey(str);
2112 if (mask < 0) {
2113 wwarning(_("%s: modifier key %s is not valid"), entry->key, str);
2114 mask = 0;
2115 return False;
2118 if (addr)
2119 *(int *)addr = mask;
2121 if (ret)
2122 *ret = &mask;
2124 return True;
2127 # include <X11/cursorfont.h>
2128 typedef struct {
2129 char *name;
2130 int id;
2131 } WCursorLookup;
2133 #define CURSOR_ID_NONE (XC_num_glyphs)
2135 static WCursorLookup cursor_table[] = {
2136 {"X_cursor", XC_X_cursor},
2137 {"arrow", XC_arrow},
2138 {"based_arrow_down", XC_based_arrow_down},
2139 {"based_arrow_up", XC_based_arrow_up},
2140 {"boat", XC_boat},
2141 {"bogosity", XC_bogosity},
2142 {"bottom_left_corner", XC_bottom_left_corner},
2143 {"bottom_right_corner", XC_bottom_right_corner},
2144 {"bottom_side", XC_bottom_side},
2145 {"bottom_tee", XC_bottom_tee},
2146 {"box_spiral", XC_box_spiral},
2147 {"center_ptr", XC_center_ptr},
2148 {"circle", XC_circle},
2149 {"clock", XC_clock},
2150 {"coffee_mug", XC_coffee_mug},
2151 {"cross", XC_cross},
2152 {"cross_reverse", XC_cross_reverse},
2153 {"crosshair", XC_crosshair},
2154 {"diamond_cross", XC_diamond_cross},
2155 {"dot", XC_dot},
2156 {"dotbox", XC_dotbox},
2157 {"double_arrow", XC_double_arrow},
2158 {"draft_large", XC_draft_large},
2159 {"draft_small", XC_draft_small},
2160 {"draped_box", XC_draped_box},
2161 {"exchange", XC_exchange},
2162 {"fleur", XC_fleur},
2163 {"gobbler", XC_gobbler},
2164 {"gumby", XC_gumby},
2165 {"hand1", XC_hand1},
2166 {"hand2", XC_hand2},
2167 {"heart", XC_heart},
2168 {"icon", XC_icon},
2169 {"iron_cross", XC_iron_cross},
2170 {"left_ptr", XC_left_ptr},
2171 {"left_side", XC_left_side},
2172 {"left_tee", XC_left_tee},
2173 {"leftbutton", XC_leftbutton},
2174 {"ll_angle", XC_ll_angle},
2175 {"lr_angle", XC_lr_angle},
2176 {"man", XC_man},
2177 {"middlebutton", XC_middlebutton},
2178 {"mouse", XC_mouse},
2179 {"pencil", XC_pencil},
2180 {"pirate", XC_pirate},
2181 {"plus", XC_plus},
2182 {"question_arrow", XC_question_arrow},
2183 {"right_ptr", XC_right_ptr},
2184 {"right_side", XC_right_side},
2185 {"right_tee", XC_right_tee},
2186 {"rightbutton", XC_rightbutton},
2187 {"rtl_logo", XC_rtl_logo},
2188 {"sailboat", XC_sailboat},
2189 {"sb_down_arrow", XC_sb_down_arrow},
2190 {"sb_h_double_arrow", XC_sb_h_double_arrow},
2191 {"sb_left_arrow", XC_sb_left_arrow},
2192 {"sb_right_arrow", XC_sb_right_arrow},
2193 {"sb_up_arrow", XC_sb_up_arrow},
2194 {"sb_v_double_arrow", XC_sb_v_double_arrow},
2195 {"shuttle", XC_shuttle},
2196 {"sizing", XC_sizing},
2197 {"spider", XC_spider},
2198 {"spraycan", XC_spraycan},
2199 {"star", XC_star},
2200 {"target", XC_target},
2201 {"tcross", XC_tcross},
2202 {"top_left_arrow", XC_top_left_arrow},
2203 {"top_left_corner", XC_top_left_corner},
2204 {"top_right_corner", XC_top_right_corner},
2205 {"top_side", XC_top_side},
2206 {"top_tee", XC_top_tee},
2207 {"trek", XC_trek},
2208 {"ul_angle", XC_ul_angle},
2209 {"umbrella", XC_umbrella},
2210 {"ur_angle", XC_ur_angle},
2211 {"watch", XC_watch},
2212 {"xterm", XC_xterm},
2213 {NULL, CURSOR_ID_NONE}
2216 static void check_bitmap_status(int status, char *filename, Pixmap bitmap)
2218 switch (status) {
2219 case BitmapOpenFailed:
2220 wwarning(_("failed to open bitmap file \"%s\""), filename);
2221 break;
2222 case BitmapFileInvalid:
2223 wwarning(_("\"%s\" is not a valid bitmap file"), filename);
2224 break;
2225 case BitmapNoMemory:
2226 wwarning(_("out of memory reading bitmap file \"%s\""), filename);
2227 break;
2228 case BitmapSuccess:
2229 XFreePixmap(dpy, bitmap);
2230 break;
2235 * (none)
2236 * (builtin, <cursor_name>)
2237 * (bitmap, <cursor_bitmap>, <cursor_mask>)
2239 static int parse_cursor(WScreen * scr, WMPropList * pl, Cursor * cursor)
2241 WMPropList *elem;
2242 char *val;
2243 int nelem;
2244 int status = 0;
2246 nelem = WMGetPropListItemCount(pl);
2247 if (nelem < 1) {
2248 return (status);
2250 elem = WMGetFromPLArray(pl, 0);
2251 if (!elem || !WMIsPLString(elem)) {
2252 return (status);
2254 val = WMGetFromPLString(elem);
2256 if (strcasecmp(val, "none") == 0) {
2257 status = 1;
2258 *cursor = None;
2259 } else if (strcasecmp(val, "builtin") == 0) {
2260 int i;
2261 int cursor_id = CURSOR_ID_NONE;
2263 if (nelem != 2) {
2264 wwarning(_("bad number of arguments in cursor specification"));
2265 return (status);
2267 elem = WMGetFromPLArray(pl, 1);
2268 if (!elem || !WMIsPLString(elem)) {
2269 return (status);
2271 val = WMGetFromPLString(elem);
2273 for (i = 0; cursor_table[i].name != NULL; i++) {
2274 if (strcasecmp(val, cursor_table[i].name) == 0) {
2275 cursor_id = cursor_table[i].id;
2276 break;
2279 if (CURSOR_ID_NONE == cursor_id) {
2280 wwarning(_("unknown builtin cursor name \"%s\""), val);
2281 } else {
2282 *cursor = XCreateFontCursor(dpy, cursor_id);
2283 status = 1;
2285 } else if (strcasecmp(val, "bitmap") == 0) {
2286 char *bitmap_name;
2287 char *mask_name;
2288 int bitmap_status;
2289 int mask_status;
2290 Pixmap bitmap;
2291 Pixmap mask;
2292 unsigned int w, h;
2293 int x, y;
2294 XColor fg, bg;
2296 if (nelem != 3) {
2297 wwarning(_("bad number of arguments in cursor specification"));
2298 return (status);
2300 elem = WMGetFromPLArray(pl, 1);
2301 if (!elem || !WMIsPLString(elem)) {
2302 return (status);
2304 val = WMGetFromPLString(elem);
2305 bitmap_name = FindImage(wPreferences.pixmap_path, val);
2306 if (!bitmap_name) {
2307 wwarning(_("could not find cursor bitmap file \"%s\""), val);
2308 return (status);
2310 elem = WMGetFromPLArray(pl, 2);
2311 if (!elem || !WMIsPLString(elem)) {
2312 wfree(bitmap_name);
2313 return (status);
2315 val = WMGetFromPLString(elem);
2316 mask_name = FindImage(wPreferences.pixmap_path, val);
2317 if (!mask_name) {
2318 wfree(bitmap_name);
2319 wwarning(_("could not find cursor bitmap file \"%s\""), val);
2320 return (status);
2322 mask_status = XReadBitmapFile(dpy, scr->w_win, mask_name, &w, &h, &mask, &x, &y);
2323 bitmap_status = XReadBitmapFile(dpy, scr->w_win, bitmap_name, &w, &h, &bitmap, &x, &y);
2324 if ((BitmapSuccess == bitmap_status) && (BitmapSuccess == mask_status)) {
2325 fg.pixel = scr->black_pixel;
2326 bg.pixel = scr->white_pixel;
2327 XQueryColor(dpy, scr->w_colormap, &fg);
2328 XQueryColor(dpy, scr->w_colormap, &bg);
2329 *cursor = XCreatePixmapCursor(dpy, bitmap, mask, &fg, &bg, x, y);
2330 status = 1;
2332 check_bitmap_status(bitmap_status, bitmap_name, bitmap);
2333 check_bitmap_status(mask_status, mask_name, mask);
2334 wfree(bitmap_name);
2335 wfree(mask_name);
2337 return (status);
2340 static int getCursor(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
2342 static Cursor cursor;
2343 int status;
2344 int changed = 0;
2346 again:
2347 if (!WMIsPLArray(value)) {
2348 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
2349 entry->key, "cursor specification");
2350 if (!changed) {
2351 value = entry->plvalue;
2352 changed = 1;
2353 wwarning(_("using default \"%s\" instead"), entry->default_value);
2354 goto again;
2356 return (False);
2358 status = parse_cursor(scr, value, &cursor);
2359 if (!status) {
2360 wwarning(_("Error in cursor specification for key \"%s\""), entry->key);
2361 if (!changed) {
2362 value = entry->plvalue;
2363 changed = 1;
2364 wwarning(_("using default \"%s\" instead"), entry->default_value);
2365 goto again;
2367 return (False);
2369 if (ret) {
2370 *ret = &cursor;
2372 if (addr) {
2373 *(Cursor *) addr = cursor;
2375 return (True);
2378 #undef CURSOR_ID_NONE
2380 /* ---------------- value setting functions --------------- */
2381 static int setJustify(WScreen * scr, WDefaultEntry * entry, WTexture ** texture, void *foo)
2383 return REFRESH_WINDOW_TITLE_COLOR;
2386 static int setClearance(WScreen * scr, WDefaultEntry * entry, void *bar, void *foo)
2388 return REFRESH_WINDOW_FONT | REFRESH_BUTTON_IMAGES | REFRESH_MENU_TITLE_FONT | REFRESH_MENU_FONT;
2391 static int setIfDockPresent(WScreen * scr, WDefaultEntry * entry, char *flag, long which)
2393 switch (which) {
2394 case WM_DOCK:
2395 wPreferences.flags.nodock = wPreferences.flags.nodock || *flag;
2396 // Drawers require the dock
2397 wPreferences.flags.nodrawer = wPreferences.flags.nodrawer || wPreferences.flags.nodock;
2398 break;
2399 case WM_CLIP:
2400 wPreferences.flags.noclip = wPreferences.flags.noclip || *flag;
2401 break;
2402 case WM_DRAWER:
2403 wPreferences.flags.nodrawer = wPreferences.flags.nodrawer || *flag;
2404 break;
2405 default:
2406 break;
2408 return 0;
2411 static int setClipMergedInDock(WScreen *scr, WDefaultEntry *entry, char *flag, void *foo)
2413 wPreferences.flags.clip_merged_in_dock = *flag;
2414 wPreferences.flags.noclip = wPreferences.flags.noclip || *flag;
2415 return 0;
2418 static int setWrapAppiconsInDock(WScreen *scr, WDefaultEntry *entry, char *flag, void *foo)
2420 wPreferences.flags.wrap_appicons_in_dock = *flag;
2421 return 0;
2424 static int setStickyIcons(WScreen * scr, WDefaultEntry * entry, void *bar, void *foo)
2426 if (scr->workspaces) {
2427 wWorkspaceForceChange(scr, scr->current_workspace);
2428 wArrangeIcons(scr, False);
2430 return 0;
2433 static int setIconTile(WScreen * scr, WDefaultEntry * entry, WTexture ** texture, void *foo)
2435 Pixmap pixmap;
2436 RImage *img;
2437 int reset = 0;
2439 img = wTextureRenderImage(*texture, wPreferences.icon_size,
2440 wPreferences.icon_size, ((*texture)->any.type & WREL_BORDER_MASK)
2441 ? WREL_ICON : WREL_FLAT);
2442 if (!img) {
2443 wwarning(_("could not render texture for icon background"));
2444 if (!entry->addr)
2445 wTextureDestroy(scr, *texture);
2446 return 0;
2448 RConvertImage(scr->rcontext, img, &pixmap);
2450 if (scr->icon_tile) {
2451 reset = 1;
2452 RReleaseImage(scr->icon_tile);
2453 XFreePixmap(dpy, scr->icon_tile_pixmap);
2456 scr->icon_tile = img;
2458 /* put the icon in the noticeboard hint */
2459 PropSetIconTileHint(scr, img);
2461 if (!wPreferences.flags.noclip || wPreferences.flags.clip_merged_in_dock) {
2462 if (scr->clip_tile) {
2463 RReleaseImage(scr->clip_tile);
2465 scr->clip_tile = wClipMakeTile(scr, img);
2468 if (!wPreferences.flags.nodrawer) {
2469 if (scr->drawer_tile) {
2470 RReleaseImage(scr->drawer_tile);
2472 scr->drawer_tile = wDrawerMakeTile(scr, img);
2475 scr->icon_tile_pixmap = pixmap;
2477 if (scr->def_icon_rimage) {
2478 RReleaseImage(scr->def_icon_rimage);
2479 scr->def_icon_rimage = NULL;
2482 if (scr->icon_back_texture)
2483 wTextureDestroy(scr, (WTexture *) scr->icon_back_texture);
2485 scr->icon_back_texture = wTextureMakeSolid(scr, &((*texture)->any.color));
2487 /* Free the texture as nobody else will use it, nor refer to it. */
2488 if (!entry->addr)
2489 wTextureDestroy(scr, *texture);
2491 return (reset ? REFRESH_ICON_TILE : 0);
2494 static int setWinTitleFont(WScreen * scr, WDefaultEntry * entry, WMFont * font, void *foo)
2496 if (scr->title_font) {
2497 WMReleaseFont(scr->title_font);
2499 scr->title_font = font;
2501 return REFRESH_WINDOW_FONT | REFRESH_BUTTON_IMAGES;
2504 static int setMenuTitleFont(WScreen * scr, WDefaultEntry * entry, WMFont * font, void *foo)
2506 if (scr->menu_title_font) {
2507 WMReleaseFont(scr->menu_title_font);
2510 scr->menu_title_font = font;
2512 return REFRESH_MENU_TITLE_FONT;
2515 static int setMenuTextFont(WScreen * scr, WDefaultEntry * entry, WMFont * font, void *foo)
2517 if (scr->menu_entry_font) {
2518 WMReleaseFont(scr->menu_entry_font);
2520 scr->menu_entry_font = font;
2522 return REFRESH_MENU_FONT;
2525 static int setIconTitleFont(WScreen * scr, WDefaultEntry * entry, WMFont * font, void *foo)
2527 if (scr->icon_title_font) {
2528 WMReleaseFont(scr->icon_title_font);
2531 scr->icon_title_font = font;
2533 return REFRESH_ICON_FONT;
2536 static int setClipTitleFont(WScreen * scr, WDefaultEntry * entry, WMFont * font, void *foo)
2538 if (scr->clip_title_font) {
2539 WMReleaseFont(scr->clip_title_font);
2542 scr->clip_title_font = font;
2544 return REFRESH_ICON_FONT;
2547 static int setLargeDisplayFont(WScreen * scr, WDefaultEntry * entry, WMFont * font, void *foo)
2549 if (scr->workspace_name_font) {
2550 WMReleaseFont(scr->workspace_name_font);
2553 scr->workspace_name_font = font;
2555 return 0;
2558 static int setHightlight(WScreen * scr, WDefaultEntry * entry, XColor * color, void *foo)
2560 if (scr->select_color)
2561 WMReleaseColor(scr->select_color);
2563 scr->select_color = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2565 wFreeColor(scr, color->pixel);
2567 return REFRESH_MENU_COLOR;
2570 static int setHightlightText(WScreen * scr, WDefaultEntry * entry, XColor * color, void *foo)
2572 if (scr->select_text_color)
2573 WMReleaseColor(scr->select_text_color);
2575 scr->select_text_color = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2577 wFreeColor(scr, color->pixel);
2579 return REFRESH_MENU_COLOR;
2582 static int setClipTitleColor(WScreen * scr, WDefaultEntry * entry, XColor * color, long widx)
2584 if (scr->clip_title_color[widx])
2585 WMReleaseColor(scr->clip_title_color[widx]);
2587 scr->clip_title_color[widx] = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2588 wFreeColor(scr, color->pixel);
2590 return REFRESH_ICON_TITLE_COLOR;
2593 static int setWTitleColor(WScreen * scr, WDefaultEntry * entry, XColor * color, long widx)
2595 if (scr->window_title_color[widx])
2596 WMReleaseColor(scr->window_title_color[widx]);
2598 scr->window_title_color[widx] =
2599 WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2601 wFreeColor(scr, color->pixel);
2603 return REFRESH_WINDOW_TITLE_COLOR;
2606 static int setMenuTitleColor(WScreen * scr, WDefaultEntry * entry, XColor * color, long widx)
2608 if (scr->menu_title_color[0])
2609 WMReleaseColor(scr->menu_title_color[0]);
2611 scr->menu_title_color[0] = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2613 wFreeColor(scr, color->pixel);
2615 return REFRESH_MENU_TITLE_COLOR;
2618 static int setMenuTextColor(WScreen * scr, WDefaultEntry * entry, XColor * color, void *foo)
2620 if (scr->mtext_color)
2621 WMReleaseColor(scr->mtext_color);
2623 scr->mtext_color = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2625 if (WMColorPixel(scr->dtext_color) == WMColorPixel(scr->mtext_color)) {
2626 WMSetColorAlpha(scr->dtext_color, 0x7fff);
2627 } else {
2628 WMSetColorAlpha(scr->dtext_color, 0xffff);
2631 wFreeColor(scr, color->pixel);
2633 return REFRESH_MENU_COLOR;
2636 static int setMenuDisabledColor(WScreen * scr, WDefaultEntry * entry, XColor * color, void *foo)
2638 if (scr->dtext_color)
2639 WMReleaseColor(scr->dtext_color);
2641 scr->dtext_color = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2643 if (WMColorPixel(scr->dtext_color) == WMColorPixel(scr->mtext_color)) {
2644 WMSetColorAlpha(scr->dtext_color, 0x7fff);
2645 } else {
2646 WMSetColorAlpha(scr->dtext_color, 0xffff);
2649 wFreeColor(scr, color->pixel);
2651 return REFRESH_MENU_COLOR;
2654 static int setIconTitleColor(WScreen * scr, WDefaultEntry * entry, XColor * color, void *foo)
2656 if (scr->icon_title_color)
2657 WMReleaseColor(scr->icon_title_color);
2658 scr->icon_title_color = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2660 wFreeColor(scr, color->pixel);
2662 return REFRESH_ICON_TITLE_COLOR;
2665 static int setIconTitleBack(WScreen * scr, WDefaultEntry * entry, XColor * color, void *foo)
2667 if (scr->icon_title_texture) {
2668 wTextureDestroy(scr, (WTexture *) scr->icon_title_texture);
2670 scr->icon_title_texture = wTextureMakeSolid(scr, color);
2672 return REFRESH_ICON_TITLE_BACK;
2675 static int setFrameBorderWidth(WScreen * scr, WDefaultEntry * entry, int * value, void *foo)
2677 scr->frame_border_width = *value;
2679 return REFRESH_FRAME_BORDER;
2682 static int setFrameBorderColor(WScreen * scr, WDefaultEntry * entry, XColor * color, void *foo)
2684 if (scr->frame_border_color)
2685 WMReleaseColor(scr->frame_border_color);
2686 scr->frame_border_color = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2688 wFreeColor(scr, color->pixel);
2690 return REFRESH_FRAME_BORDER;
2693 static int setFrameSelectedBorderColor(WScreen * scr, WDefaultEntry * entry, XColor * color, void *foo)
2695 if (scr->frame_selected_border_color)
2696 WMReleaseColor(scr->frame_selected_border_color);
2697 scr->frame_selected_border_color = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2699 wFreeColor(scr, color->pixel);
2701 return REFRESH_FRAME_BORDER;
2704 static void trackDeadProcess(pid_t pid, unsigned char status, WScreen * scr)
2706 close(scr->helper_fd);
2707 scr->helper_fd = 0;
2708 scr->helper_pid = 0;
2709 scr->flags.backimage_helper_launched = 0;
2712 static int setWorkspaceSpecificBack(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *bar)
2714 WMPropList *val;
2715 char *str;
2716 int i;
2718 if (scr->flags.backimage_helper_launched) {
2719 if (WMGetPropListItemCount(value) == 0) {
2720 SendHelperMessage(scr, 'C', 0, NULL);
2721 SendHelperMessage(scr, 'K', 0, NULL);
2723 WMReleasePropList(value);
2724 return 0;
2726 } else {
2727 pid_t pid;
2728 int filedes[2];
2730 if (WMGetPropListItemCount(value) == 0)
2731 return 0;
2733 if (pipe(filedes) < 0) {
2734 werror("pipe() failed:can't set workspace specific background image");
2736 WMReleasePropList(value);
2737 return 0;
2740 pid = fork();
2741 if (pid < 0) {
2742 werror("fork() failed:can't set workspace specific background image");
2743 if (close(filedes[0]) < 0)
2744 werror("could not close pipe");
2745 if (close(filedes[1]) < 0)
2746 werror("could not close pipe");
2748 } else if (pid == 0) {
2749 char *dither;
2751 SetupEnvironment(scr);
2753 if (close(0) < 0)
2754 werror("could not close pipe");
2755 if (dup(filedes[0]) < 0) {
2756 werror("dup() failed:can't set workspace specific background image");
2758 dither = wPreferences.no_dithering ? "-m" : "-d";
2759 if (wPreferences.smooth_workspace_back)
2760 execlp("wmsetbg", "wmsetbg", "-helper", "-S", dither, NULL);
2761 else
2762 execlp("wmsetbg", "wmsetbg", "-helper", dither, NULL);
2763 werror("could not execute wmsetbg");
2764 exit(1);
2765 } else {
2767 if (fcntl(filedes[0], F_SETFD, FD_CLOEXEC) < 0) {
2768 werror("error setting close-on-exec flag");
2770 if (fcntl(filedes[1], F_SETFD, FD_CLOEXEC) < 0) {
2771 werror("error setting close-on-exec flag");
2774 scr->helper_fd = filedes[1];
2775 scr->helper_pid = pid;
2776 scr->flags.backimage_helper_launched = 1;
2778 wAddDeathHandler(pid, (WDeathHandler *) trackDeadProcess, scr);
2780 SendHelperMessage(scr, 'P', -1, wPreferences.pixmap_path);
2785 for (i = 0; i < WMGetPropListItemCount(value); i++) {
2786 val = WMGetFromPLArray(value, i);
2787 if (val && WMIsPLArray(val) && WMGetPropListItemCount(val) > 0) {
2788 str = WMGetPropListDescription(val, False);
2790 SendHelperMessage(scr, 'S', i + 1, str);
2792 wfree(str);
2793 } else {
2794 SendHelperMessage(scr, 'U', i + 1, NULL);
2797 sleep(1);
2799 WMReleasePropList(value);
2800 return 0;
2803 static int setWorkspaceBack(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *bar)
2805 if (scr->flags.backimage_helper_launched) {
2806 char *str;
2808 if (WMGetPropListItemCount(value) == 0) {
2809 SendHelperMessage(scr, 'U', 0, NULL);
2810 } else {
2811 /* set the default workspace background to this one */
2812 str = WMGetPropListDescription(value, False);
2813 if (str) {
2814 SendHelperMessage(scr, 'S', 0, str);
2815 wfree(str);
2816 SendHelperMessage(scr, 'C', scr->current_workspace + 1, NULL);
2817 } else {
2818 SendHelperMessage(scr, 'U', 0, NULL);
2821 } else if (WMGetPropListItemCount(value) > 0) {
2822 char *command;
2823 char *text;
2824 char *dither;
2825 int len;
2827 text = WMGetPropListDescription(value, False);
2828 len = strlen(text) + 40;
2829 command = wmalloc(len);
2830 dither = wPreferences.no_dithering ? "-m" : "-d";
2831 if (wPreferences.smooth_workspace_back)
2832 snprintf(command, len, "wmsetbg %s -S -p '%s' &", dither, text);
2833 else
2834 snprintf(command, len, "wmsetbg %s -p '%s' &", dither, text);
2835 wfree(text);
2836 ExecuteShellCommand(scr, command);
2837 wfree(command);
2839 WMReleasePropList(value);
2841 return 0;
2844 static int setWidgetColor(WScreen * scr, WDefaultEntry * entry, WTexture ** texture, void *foo)
2846 if (scr->widget_texture) {
2847 wTextureDestroy(scr, (WTexture *) scr->widget_texture);
2849 scr->widget_texture = *(WTexSolid **) texture;
2851 return 0;
2854 static int setFTitleBack(WScreen * scr, WDefaultEntry * entry, WTexture ** texture, void *foo)
2856 if (scr->window_title_texture[WS_FOCUSED]) {
2857 wTextureDestroy(scr, scr->window_title_texture[WS_FOCUSED]);
2859 scr->window_title_texture[WS_FOCUSED] = *texture;
2861 return REFRESH_WINDOW_TEXTURES;
2864 static int setPTitleBack(WScreen * scr, WDefaultEntry * entry, WTexture ** texture, void *foo)
2866 if (scr->window_title_texture[WS_PFOCUSED]) {
2867 wTextureDestroy(scr, scr->window_title_texture[WS_PFOCUSED]);
2869 scr->window_title_texture[WS_PFOCUSED] = *texture;
2871 return REFRESH_WINDOW_TEXTURES;
2874 static int setUTitleBack(WScreen * scr, WDefaultEntry * entry, WTexture ** texture, void *foo)
2876 if (scr->window_title_texture[WS_UNFOCUSED]) {
2877 wTextureDestroy(scr, scr->window_title_texture[WS_UNFOCUSED]);
2879 scr->window_title_texture[WS_UNFOCUSED] = *texture;
2881 return REFRESH_WINDOW_TEXTURES;
2884 static int setResizebarBack(WScreen * scr, WDefaultEntry * entry, WTexture ** texture, void *foo)
2886 if (scr->resizebar_texture[0]) {
2887 wTextureDestroy(scr, scr->resizebar_texture[0]);
2889 scr->resizebar_texture[0] = *texture;
2891 return REFRESH_WINDOW_TEXTURES;
2894 static int setMenuTitleBack(WScreen * scr, WDefaultEntry * entry, WTexture ** texture, void *foo)
2896 if (scr->menu_title_texture[0]) {
2897 wTextureDestroy(scr, scr->menu_title_texture[0]);
2899 scr->menu_title_texture[0] = *texture;
2901 return REFRESH_MENU_TITLE_TEXTURE;
2904 static int setMenuTextBack(WScreen * scr, WDefaultEntry * entry, WTexture ** texture, void *foo)
2906 if (scr->menu_item_texture) {
2907 wTextureDestroy(scr, scr->menu_item_texture);
2908 wTextureDestroy(scr, (WTexture *) scr->menu_item_auxtexture);
2910 scr->menu_item_texture = *texture;
2912 scr->menu_item_auxtexture = wTextureMakeSolid(scr, &scr->menu_item_texture->any.color);
2914 return REFRESH_MENU_TEXTURE;
2917 static int setKeyGrab(WScreen * scr, WDefaultEntry * entry, WShortKey * shortcut, long widx)
2919 WWindow *wwin;
2920 wKeyBindings[widx] = *shortcut;
2922 wwin = scr->focused_window;
2924 while (wwin != NULL) {
2925 XUngrabKey(dpy, AnyKey, AnyModifier, wwin->frame->core->window);
2927 if (!WFLAGP(wwin, no_bind_keys)) {
2928 wWindowSetKeyGrabs(wwin);
2930 wwin = wwin->prev;
2933 /* do we need to update window menus? */
2934 if (widx >= WKBD_WORKSPACE1 && widx <= WKBD_WORKSPACE10)
2935 return REFRESH_WORKSPACE_MENU;
2936 if (widx == WKBD_LASTWORKSPACE)
2937 return REFRESH_WORKSPACE_MENU;
2938 if (widx >= WKBD_MOVE_WORKSPACE1 && widx <= WKBD_MOVE_WORKSPACE10)
2939 return REFRESH_WORKSPACE_MENU;
2941 return 0;
2944 static int setIconPosition(WScreen * scr, WDefaultEntry * entry, void *bar, void *foo)
2946 wScreenUpdateUsableArea(scr);
2947 wArrangeIcons(scr, True);
2949 return 0;
2952 static int updateUsableArea(WScreen * scr, WDefaultEntry * entry, void *bar, void *foo)
2954 wScreenUpdateUsableArea(scr);
2956 return 0;
2959 static int setMenuStyle(WScreen * scr, WDefaultEntry * entry, int *value, void *foo)
2961 return REFRESH_MENU_TEXTURE;
2964 static RImage *chopOffImage(RImage * image, int x, int y, int w, int h)
2966 RImage *img = RCreateImage(w, h, image->format == RRGBAFormat);
2968 RCopyArea(img, image, x, y, w, h, 0, 0);
2970 return img;
2973 static int setSwPOptions(WScreen * scr, WDefaultEntry * entry, WMPropList * array, void *foo)
2975 char *path;
2976 RImage *bgimage;
2977 int cwidth, cheight;
2978 WPreferences *prefs = (WPreferences *) foo;
2980 if (!WMIsPLArray(array) || WMGetPropListItemCount(array) == 0) {
2981 if (prefs->swtileImage)
2982 RReleaseImage(prefs->swtileImage);
2983 prefs->swtileImage = NULL;
2985 WMReleasePropList(array);
2986 return 0;
2989 switch (WMGetPropListItemCount(array)) {
2990 case 4:
2991 if (!WMIsPLString(WMGetFromPLArray(array, 1))) {
2992 wwarning(_("Invalid arguments for option \"%s\""), entry->key);
2993 break;
2994 } else
2995 path = FindImage(wPreferences.pixmap_path, WMGetFromPLString(WMGetFromPLArray(array, 1)));
2997 if (!path) {
2998 wwarning(_("Could not find image \"%s\" for option \"%s\""),
2999 WMGetFromPLString(WMGetFromPLArray(array, 1)), entry->key);
3000 } else {
3001 bgimage = RLoadImage(scr->rcontext, path, 0);
3002 if (!bgimage) {
3003 wwarning(_("Could not load image \"%s\" for option \"%s\""), path, entry->key);
3004 wfree(path);
3005 } else {
3006 wfree(path);
3008 cwidth = atoi(WMGetFromPLString(WMGetFromPLArray(array, 2)));
3009 cheight = atoi(WMGetFromPLString(WMGetFromPLArray(array, 3)));
3011 if (cwidth <= 0 || cheight <= 0 ||
3012 cwidth >= bgimage->width - 2 || cheight >= bgimage->height - 2)
3013 wwarning(_("Invalid split sizes for SwitchPanel back image."));
3014 else {
3015 int i;
3016 int swidth, theight;
3017 for (i = 0; i < 9; i++) {
3018 if (prefs->swbackImage[i])
3019 RReleaseImage(prefs->swbackImage[i]);
3020 prefs->swbackImage[i] = NULL;
3022 swidth = (bgimage->width - cwidth) / 2;
3023 theight = (bgimage->height - cheight) / 2;
3025 prefs->swbackImage[0] = chopOffImage(bgimage, 0, 0, swidth, theight);
3026 prefs->swbackImage[1] = chopOffImage(bgimage, swidth, 0, cwidth, theight);
3027 prefs->swbackImage[2] = chopOffImage(bgimage, swidth + cwidth, 0,
3028 swidth, theight);
3030 prefs->swbackImage[3] = chopOffImage(bgimage, 0, theight, swidth, cheight);
3031 prefs->swbackImage[4] = chopOffImage(bgimage, swidth, theight,
3032 cwidth, cheight);
3033 prefs->swbackImage[5] = chopOffImage(bgimage, swidth + cwidth, theight,
3034 swidth, cheight);
3036 prefs->swbackImage[6] = chopOffImage(bgimage, 0, theight + cheight,
3037 swidth, theight);
3038 prefs->swbackImage[7] = chopOffImage(bgimage, swidth, theight + cheight,
3039 cwidth, theight);
3040 prefs->swbackImage[8] =
3041 chopOffImage(bgimage, swidth + cwidth, theight + cheight, swidth,
3042 theight);
3044 // check if anything failed
3045 for (i = 0; i < 9; i++) {
3046 if (!prefs->swbackImage[i]) {
3047 for (; i >= 0; --i) {
3048 RReleaseImage(prefs->swbackImage[i]);
3049 prefs->swbackImage[i] = NULL;
3051 break;
3055 RReleaseImage(bgimage);
3059 case 1:
3060 if (!WMIsPLString(WMGetFromPLArray(array, 0))) {
3061 wwarning(_("Invalid arguments for option \"%s\""), entry->key);
3062 break;
3063 } else
3064 path = FindImage(wPreferences.pixmap_path, WMGetFromPLString(WMGetFromPLArray(array, 0)));
3066 if (!path) {
3067 wwarning(_("Could not find image \"%s\" for option \"%s\""),
3068 WMGetFromPLString(WMGetFromPLArray(array, 0)), entry->key);
3069 } else {
3070 if (prefs->swtileImage)
3071 RReleaseImage(prefs->swtileImage);
3073 prefs->swtileImage = RLoadImage(scr->rcontext, path, 0);
3074 if (!prefs->swtileImage) {
3075 wwarning(_("Could not load image \"%s\" for option \"%s\""), path, entry->key);
3077 wfree(path);
3079 break;
3081 default:
3082 wwarning(_("Invalid number of arguments for option \"%s\""), entry->key);
3083 break;
3086 WMReleasePropList(array);
3088 return 0;
3091 static int setModifierKeyLabels(WScreen * scr, WDefaultEntry * entry, WMPropList * array, void *foo)
3093 int i;
3094 WPreferences *prefs = (WPreferences *) foo;
3096 if (!WMIsPLArray(array) || WMGetPropListItemCount(array) != 7) {
3097 wwarning(_("Value for option \"%s\" must be an array of 7 strings"), entry->key);
3098 WMReleasePropList(array);
3099 return 0;
3102 DestroyWindowMenu(scr);
3104 for (i = 0; i < 7; i++) {
3105 if (prefs->modifier_labels[i])
3106 wfree(prefs->modifier_labels[i]);
3108 if (WMIsPLString(WMGetFromPLArray(array, i))) {
3109 prefs->modifier_labels[i] = wstrdup(WMGetFromPLString(WMGetFromPLArray(array, i)));
3110 } else {
3111 wwarning(_("Invalid argument for option \"%s\" item %d"), entry->key, i);
3112 prefs->modifier_labels[i] = NULL;
3116 WMReleasePropList(array);
3118 return 0;
3121 static int setDoubleClick(WScreen *scr, WDefaultEntry *entry, int *value, void *foo)
3123 if (*value <= 0)
3124 *(int *)foo = 1;
3126 W_setconf_doubleClickDelay(*value);
3128 return 0;
3131 static int setCursor(WScreen * scr, WDefaultEntry * entry, Cursor * cursor, long widx)
3133 if (wCursor[widx] != None) {
3134 XFreeCursor(dpy, wCursor[widx]);
3137 wCursor[widx] = *cursor;
3139 if (widx == WCUR_ROOT && *cursor != None) {
3140 XDefineCursor(dpy, scr->root_win, *cursor);
3143 return 0;