New header file event.h
[wmaker-crm.git] / src / defaults.c
blobd82105c4d79a25cb3d4563914cd5a400cca33dc2
1 /* defaults.c - manage configuration through defaults db
3 * Window Maker window manager
5 * Copyright (c) 1997-2003 Alfredo K. Kojima
6 * Copyright (c) 1998-2003 Dan Pascu
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 #include "wconfig.h"
25 #include <stdio.h>
26 #include <stdint.h>
27 #include <stdlib.h>
28 #include <unistd.h>
29 #include <string.h>
30 #include <strings.h>
31 #include <ctype.h>
32 #include <time.h>
33 #include <sys/types.h>
34 #include <sys/stat.h>
35 #include <fcntl.h>
36 #include <limits.h>
37 #include <signal.h>
39 #ifndef PATH_MAX
40 #define PATH_MAX DEFAULT_PATH_MAX
41 #endif
43 #include <X11/Xlib.h>
44 #include <X11/Xutil.h>
45 #include <X11/keysym.h>
47 #include <wraster.h>
49 #include "WindowMaker.h"
50 #include "framewin.h"
51 #include "window.h"
52 #include "texture.h"
53 #include "screen.h"
54 #include "resources.h"
55 #include "defaults.h"
56 #include "keybind.h"
57 #include "xmodifier.h"
58 #include "icon.h"
59 #include "main.h"
60 #include "actions.h"
61 #include "dock.h"
62 #include "workspace.h"
63 #include "properties.h"
64 #include "misc.h"
65 #include "event.h"
67 #define MAX_SHORTCUT_LENGTH 32
69 #ifndef GLOBAL_DEFAULTS_SUBDIR
70 #define GLOBAL_DEFAULTS_SUBDIR "WindowMaker"
71 #endif
73 /***** Global *****/
74 extern WDDomain *WDWindowMaker;
75 extern WDDomain *WDWindowAttributes;
76 extern WDDomain *WDRootMenu;
77 extern int wScreenCount;
78 extern WPreferences wPreferences;
79 extern WShortKey wKeyBindings[WKBD_LAST];
81 typedef struct {
82 char *key;
83 char *default_value;
84 void *extra_data;
85 void *addr;
86 int (*convert) ();
87 int (*update) ();
88 WMPropList *plkey;
89 WMPropList *plvalue; /* default value */
90 } WDefaultEntry;
92 /* used to map strings to integers */
93 typedef struct {
94 char *string;
95 short value;
96 char is_alias;
97 } WOptionEnumeration;
99 /* type converters */
100 static int getBool();
101 static int getInt();
102 static int getCoord();
103 static int getPathList();
104 static int getEnum();
105 static int getTexture();
106 static int getWSBackground();
107 static int getWSSpecificBackground();
108 static int getFont();
109 static int getColor();
110 static int getKeybind();
111 static int getModMask();
112 static int getPropList();
114 /* value setting functions */
115 static int setJustify();
116 static int setClearance();
117 static int setIfDockPresent();
118 static int setClipMergedInDock();
119 static int setWrapAppiconsInDock();
120 static int setStickyIcons();
121 static int setWidgetColor();
122 static int setIconTile();
123 static int setWinTitleFont();
124 static int setMenuTitleFont();
125 static int setMenuTextFont();
126 static int setIconTitleFont();
127 static int setIconTitleColor();
128 static int setIconTitleBack();
129 static int setFrameBorderWidth();
130 static int setFrameBorderColor();
131 static int setFrameSelectedBorderColor();
132 static int setLargeDisplayFont();
133 static int setWTitleColor();
134 static int setFTitleBack();
135 static int setPTitleBack();
136 static int setUTitleBack();
137 static int setResizebarBack();
138 static int setWorkspaceBack();
139 static int setWorkspaceSpecificBack();
140 static int setMenuTitleColor();
141 static int setMenuTextColor();
142 static int setMenuDisabledColor();
143 static int setMenuTitleBack();
144 static int setMenuTextBack();
145 static int setHightlight();
146 static int setHightlightText();
147 static int setKeyGrab();
148 static int setDoubleClick();
149 static int setIconPosition();
151 static int setClipTitleFont();
152 static int setClipTitleColor();
154 static int setMenuStyle();
155 static int setSwPOptions();
156 static int updateUsableArea();
158 static int setModifierKeyLabels();
160 extern Cursor wCursor[WCUR_LAST];
161 static int getCursor();
162 static int setCursor();
165 * Tables to convert strings to enumeration values.
166 * Values stored are char
169 /* WARNING: sum of length of all value strings must not exceed
170 * this value */
171 #define TOTAL_VALUES_LENGTH 80
173 #define REFRESH_WINDOW_TEXTURES (1<<0)
174 #define REFRESH_MENU_TEXTURE (1<<1)
175 #define REFRESH_MENU_FONT (1<<2)
176 #define REFRESH_MENU_COLOR (1<<3)
177 #define REFRESH_MENU_TITLE_TEXTURE (1<<4)
178 #define REFRESH_MENU_TITLE_FONT (1<<5)
179 #define REFRESH_MENU_TITLE_COLOR (1<<6)
180 #define REFRESH_WINDOW_TITLE_COLOR (1<<7)
181 #define REFRESH_WINDOW_FONT (1<<8)
182 #define REFRESH_ICON_TILE (1<<9)
183 #define REFRESH_ICON_FONT (1<<10)
184 #define REFRESH_WORKSPACE_BACK (1<<11)
186 #define REFRESH_BUTTON_IMAGES (1<<12)
188 #define REFRESH_ICON_TITLE_COLOR (1<<13)
189 #define REFRESH_ICON_TITLE_BACK (1<<14)
191 #define REFRESH_WORKSPACE_MENU (1<<15)
193 #define REFRESH_FRAME_BORDER REFRESH_MENU_FONT|REFRESH_WINDOW_FONT
195 static WOptionEnumeration seFocusModes[] = {
196 {"Manual", WKF_CLICK, 0}, {"ClickToFocus", WKF_CLICK, 1},
197 {"Sloppy", WKF_SLOPPY, 0}, {"SemiAuto", WKF_SLOPPY, 1}, {"Auto", WKF_SLOPPY, 1},
198 {NULL, 0, 0}
201 static WOptionEnumeration seTitlebarModes[] = {
202 {"new", TS_NEW, 0}, {"old", TS_OLD, 0},
203 {"next", TS_NEXT, 0}, {NULL, 0, 0}
206 static WOptionEnumeration seColormapModes[] = {
207 {"Manual", WCM_CLICK, 0}, {"ClickToFocus", WCM_CLICK, 1},
208 {"Auto", WCM_POINTER, 0}, {"FocusFollowMouse", WCM_POINTER, 1},
209 {NULL, 0, 0}
212 static WOptionEnumeration sePlacements[] = {
213 {"Auto", WPM_AUTO, 0},
214 {"Smart", WPM_SMART, 0},
215 {"Cascade", WPM_CASCADE, 0},
216 {"Random", WPM_RANDOM, 0},
217 {"Manual", WPM_MANUAL, 0},
218 {"Center", WPM_CENTER, 0},
219 {NULL, 0, 0}
222 static WOptionEnumeration seGeomDisplays[] = {
223 {"None", WDIS_NONE, 0},
224 {"Center", WDIS_CENTER, 0},
225 {"Corner", WDIS_TOPLEFT, 0},
226 {"Floating", WDIS_FRAME_CENTER, 0},
227 {"Line", WDIS_NEW, 0},
228 {NULL, 0, 0}
231 static WOptionEnumeration seSpeeds[] = {
232 {"UltraFast", SPEED_ULTRAFAST, 0},
233 {"Fast", SPEED_FAST, 0},
234 {"Medium", SPEED_MEDIUM, 0},
235 {"Slow", SPEED_SLOW, 0},
236 {"UltraSlow", SPEED_ULTRASLOW, 0},
237 {NULL, 0, 0}
240 static WOptionEnumeration seMouseButtonActions[] = {
241 {"None", WA_NONE, 0},
242 {"SelectWindows", WA_SELECT_WINDOWS, 0},
243 {"OpenApplicationsMenu", WA_OPEN_APPMENU, 0},
244 {"OpenWindowListMenu", WA_OPEN_WINLISTMENU, 0},
245 {NULL, 0, 0}
248 static WOptionEnumeration seMouseWheelActions[] = {
249 {"None", WA_NONE, 0},
250 {"SwitchWorkspaces", WA_SWITCH_WORKSPACES, 0},
251 {NULL, 0, 0}
254 static WOptionEnumeration seIconificationStyles[] = {
255 {"Zoom", WIS_ZOOM, 0},
256 {"Twist", WIS_TWIST, 0},
257 {"Flip", WIS_FLIP, 0},
258 {"None", WIS_NONE, 0},
259 {"random", WIS_RANDOM, 0},
260 {NULL, 0, 0}
263 static WOptionEnumeration seJustifications[] = {
264 {"Left", WTJ_LEFT, 0},
265 {"Center", WTJ_CENTER, 0},
266 {"Right", WTJ_RIGHT, 0},
267 {NULL, 0, 0}
270 static WOptionEnumeration seIconPositions[] = {
271 {"blv", IY_BOTTOM | IY_LEFT | IY_VERT, 0},
272 {"blh", IY_BOTTOM | IY_LEFT | IY_HORIZ, 0},
273 {"brv", IY_BOTTOM | IY_RIGHT | IY_VERT, 0},
274 {"brh", IY_BOTTOM | IY_RIGHT | IY_HORIZ, 0},
275 {"tlv", IY_TOP | IY_LEFT | IY_VERT, 0},
276 {"tlh", IY_TOP | IY_LEFT | IY_HORIZ, 0},
277 {"trv", IY_TOP | IY_RIGHT | IY_VERT, 0},
278 {"trh", IY_TOP | IY_RIGHT | IY_HORIZ, 0},
279 {NULL, 0, 0}
282 static WOptionEnumeration seMenuStyles[] = {
283 {"normal", MS_NORMAL, 0},
284 {"singletexture", MS_SINGLE_TEXTURE, 0},
285 {"flat", MS_FLAT, 0},
286 {NULL, 0, 0}
289 static WOptionEnumeration seDisplayPositions[] = {
290 {"none", WD_NONE, 0},
291 {"center", WD_CENTER, 0},
292 {"top", WD_TOP, 0},
293 {"bottom", WD_BOTTOM, 0},
294 {"topleft", WD_TOPLEFT, 0},
295 {"topright", WD_TOPRIGHT, 0},
296 {"bottomleft", WD_BOTTOMLEFT, 0},
297 {"bottomright", WD_BOTTOMRIGHT, 0},
298 {NULL, 0, 0}
301 static WOptionEnumeration seWorkspaceBorder[] = {
302 {"None", WB_NONE, 0},
303 {"LeftRight", WB_LEFTRIGHT, 0},
304 {"TopBottom", WB_TOPBOTTOM, 0},
305 {"AllDirections", WB_ALLDIRS, 0},
306 {NULL, 0, 0}
310 * ALL entries in the tables bellow, NEED to have a default value
311 * defined, and this value needs to be correct.
314 /* these options will only affect the window manager on startup
316 * static defaults can't access the screen data, because it is
317 * created after these defaults are read
319 WDefaultEntry staticOptionList[] = {
321 {"ColormapSize", "4", NULL,
322 &wPreferences.cmap_size, getInt, NULL, NULL, NULL},
323 {"DisableDithering", "NO", NULL,
324 &wPreferences.no_dithering, getBool, NULL, NULL, NULL},
325 {"IconSize", "64", NULL,
326 &wPreferences.icon_size, getInt, NULL, NULL, NULL},
327 {"ModifierKey", "Mod1", NULL,
328 &wPreferences.modifier_mask, getModMask, NULL, NULL, NULL},
329 {"DisableWSMouseActions", "NO", NULL,
330 &wPreferences.disable_root_mouse, getBool, NULL, NULL, NULL},
331 {"FocusMode", "manual", seFocusModes, /* have a problem when switching from */
332 &wPreferences.focus_mode, getEnum, NULL, NULL, NULL}, /* manual to sloppy without restart */
333 {"NewStyle", "new", seTitlebarModes,
334 &wPreferences.new_style, getEnum, NULL, NULL, NULL},
335 {"DisableDock", "NO", (void *)WM_DOCK,
336 NULL, getBool, setIfDockPresent, NULL, NULL},
337 {"DisableClip", "NO", (void *)WM_CLIP,
338 NULL, getBool, setIfDockPresent, NULL, NULL},
339 {"DisableDrawers", "NO", (void *)WM_DRAWER,
340 NULL, getBool, setIfDockPresent, NULL, NULL},
341 {"ClipMergedInDock", "NO", NULL,
342 NULL, getBool, setClipMergedInDock, NULL, NULL},
343 {"DisableMiniwindows", "NO", NULL,
344 &wPreferences.disable_miniwindows, getBool, NULL, NULL, NULL}
347 #define NUM2STRING_(x) #x
348 #define NUM2STRING(x) NUM2STRING_(x)
350 WDefaultEntry optionList[] = {
352 /* dynamic options */
354 {"IconPosition", "blh", seIconPositions,
355 &wPreferences.icon_yard, getEnum, setIconPosition, NULL, NULL},
356 {"IconificationStyle", "Zoom", seIconificationStyles,
357 &wPreferences.iconification_style, getEnum, NULL, NULL, NULL},
358 {"MouseLeftButtonAction", "SelectWindows", seMouseButtonActions,
359 &wPreferences.mouse_button1, getEnum, NULL, NULL, NULL},
360 {"MouseMiddleButtonAction", "OpenWindowListMenu", seMouseButtonActions,
361 &wPreferences.mouse_button2, getEnum, NULL, NULL, NULL},
362 {"MouseRightButtonAction", "OpenApplicationsMenu", seMouseButtonActions,
363 &wPreferences.mouse_button3, getEnum, NULL, NULL, NULL},
364 {"MouseWheelAction", "None", seMouseWheelActions,
365 &wPreferences.mouse_wheel, getEnum, NULL, NULL, NULL},
366 {"PixmapPath", DEF_PIXMAP_PATHS, NULL,
367 &wPreferences.pixmap_path, getPathList, NULL, NULL, NULL},
368 {"IconPath", DEF_ICON_PATHS, NULL,
369 &wPreferences.icon_path, getPathList, NULL, NULL, NULL},
370 {"ColormapMode", "auto", seColormapModes,
371 &wPreferences.colormap_mode, getEnum, NULL, NULL, NULL},
372 {"AutoFocus", "NO", NULL,
373 &wPreferences.auto_focus, getBool, NULL, NULL, NULL},
374 {"RaiseDelay", "0", NULL,
375 &wPreferences.raise_delay, getInt, NULL, NULL, NULL},
376 {"CirculateRaise", "NO", NULL,
377 &wPreferences.circ_raise, getBool, NULL, NULL, NULL},
378 {"Superfluous", "NO", NULL,
379 &wPreferences.superfluous, getBool, NULL, NULL, NULL},
380 {"AdvanceToNewWorkspace", "NO", NULL,
381 &wPreferences.ws_advance, getBool, NULL, NULL, NULL},
382 {"CycleWorkspaces", "NO", NULL,
383 &wPreferences.ws_cycle, getBool, NULL, NULL, NULL},
384 {"WorkspaceNameDisplayPosition", "center", seDisplayPositions,
385 &wPreferences.workspace_name_display_position, getEnum, NULL, NULL, NULL},
386 {"WorkspaceBorder", "None", seWorkspaceBorder,
387 &wPreferences.workspace_border_position, getEnum, updateUsableArea, NULL, NULL},
388 {"WorkspaceBorderSize", "0", NULL,
389 &wPreferences.workspace_border_size, getInt, updateUsableArea, NULL, NULL},
390 {"StickyIcons", "NO", NULL,
391 &wPreferences.sticky_icons, getBool, setStickyIcons, NULL, NULL},
392 {"SaveSessionOnExit", "NO", NULL,
393 &wPreferences.save_session_on_exit, getBool, NULL, NULL, NULL},
394 {"WrapMenus", "NO", NULL,
395 &wPreferences.wrap_menus, getBool, NULL, NULL, NULL},
396 {"ScrollableMenus", "NO", NULL,
397 &wPreferences.scrollable_menus, getBool, NULL, NULL, NULL},
398 {"MenuScrollSpeed", "medium", seSpeeds,
399 &wPreferences.menu_scroll_speed, getEnum, NULL, NULL, NULL},
400 {"IconSlideSpeed", "medium", seSpeeds,
401 &wPreferences.icon_slide_speed, getEnum, NULL, NULL, NULL},
402 {"ShadeSpeed", "medium", seSpeeds,
403 &wPreferences.shade_speed, getEnum, NULL, NULL, NULL},
404 {"BounceAppIconsWhenUrgent", "YES", NULL,
405 &wPreferences.bounce_appicons_when_urgent, getBool, NULL, NULL, NULL},
406 {"RaiseAppIconsWhenBouncing", "NO", NULL,
407 &wPreferences.raise_appicons_when_bouncing, getBool, NULL, NULL, NULL},
408 {"DoNotMakeAppIconsBounce", "NO", NULL,
409 &wPreferences.do_not_make_appicons_bounce, getBool, NULL, NULL, NULL},
410 {"DoubleClickTime", "250", (void *)&wPreferences.dblclick_time,
411 &wPreferences.dblclick_time, getInt, setDoubleClick, NULL, NULL},
412 {"ClipAutoraiseDelay", "600", NULL,
413 &wPreferences.clip_auto_raise_delay, getInt, NULL, NULL, NULL},
414 {"ClipAutolowerDelay", "1000", NULL,
415 &wPreferences.clip_auto_lower_delay, getInt, NULL, NULL, NULL},
416 {"ClipAutoexpandDelay", "600", NULL,
417 &wPreferences.clip_auto_expand_delay, getInt, NULL, NULL, NULL},
418 {"ClipAutocollapseDelay", "1000", NULL,
419 &wPreferences.clip_auto_collapse_delay, getInt, NULL, NULL, NULL},
420 {"WrapAppiconsInDock", "YES", NULL,
421 NULL, getBool, setWrapAppiconsInDock, NULL, NULL},
422 {"AlignSubmenus", "NO", NULL,
423 &wPreferences.align_menus, getBool, NULL, NULL, NULL},
424 {"ViKeyMenus", "NO", NULL,
425 &wPreferences.vi_key_menus, getBool, NULL, NULL, NULL},
426 {"OpenTransientOnOwnerWorkspace", "NO", NULL,
427 &wPreferences.open_transients_with_parent, getBool, NULL, NULL, NULL},
428 {"WindowPlacement", "auto", sePlacements,
429 &wPreferences.window_placement, getEnum, NULL, NULL, NULL},
430 {"IgnoreFocusClick", "NO", NULL,
431 &wPreferences.ignore_focus_click, getBool, NULL, NULL, NULL},
432 {"UseSaveUnders", "NO", NULL,
433 &wPreferences.use_saveunders, getBool, NULL, NULL, NULL},
434 {"OpaqueMove", "NO", NULL,
435 &wPreferences.opaque_move, getBool, NULL, NULL, NULL},
436 {"OpaqueResize", "NO", NULL,
437 &wPreferences.opaque_resize, getBool, NULL, NULL, NULL},
438 {"OpaqueMoveResizeKeyboard", "NO", NULL,
439 &wPreferences.opaque_move_resize_keyboard, getBool, NULL, NULL, NULL},
440 {"DisableAnimations", "NO", NULL,
441 &wPreferences.no_animations, getBool, NULL, NULL, NULL},
442 {"DontLinkWorkspaces", "NO", NULL,
443 &wPreferences.no_autowrap, getBool, NULL, NULL, NULL},
444 {"HighlightActiveApp", "YES", NULL,
445 &wPreferences.highlight_active_app, getBool, NULL, NULL, NULL},
446 {"AutoArrangeIcons", "NO", NULL,
447 &wPreferences.auto_arrange_icons, getBool, NULL, NULL, NULL},
448 {"NoWindowOverDock", "NO", NULL,
449 &wPreferences.no_window_over_dock, getBool, updateUsableArea, NULL, NULL},
450 {"NoWindowOverIcons", "NO", NULL,
451 &wPreferences.no_window_over_icons, getBool, updateUsableArea, NULL, NULL},
452 {"WindowPlaceOrigin", "(0, 0)", NULL,
453 &wPreferences.window_place_origin, getCoord, NULL, NULL, NULL},
454 {"ResizeDisplay", "corner", seGeomDisplays,
455 &wPreferences.size_display, getEnum, NULL, NULL, NULL},
456 {"MoveDisplay", "corner", seGeomDisplays,
457 &wPreferences.move_display, getEnum, NULL, NULL, NULL},
458 {"DontConfirmKill", "NO", NULL,
459 &wPreferences.dont_confirm_kill, getBool, NULL, NULL, NULL},
460 {"WindowTitleBalloons", "NO", NULL,
461 &wPreferences.window_balloon, getBool, NULL, NULL, NULL},
462 {"MiniwindowTitleBalloons", "NO", NULL,
463 &wPreferences.miniwin_balloon, getBool, NULL, NULL, NULL},
464 {"AppIconBalloons", "NO", NULL,
465 &wPreferences.appicon_balloon, getBool, NULL, NULL, NULL},
466 {"HelpBalloons", "NO", NULL,
467 &wPreferences.help_balloon, getBool, NULL, NULL, NULL},
468 {"EdgeResistance", "30", NULL,
469 &wPreferences.edge_resistance, getInt, NULL, NULL, NULL},
470 {"ResizeIncrement", "0", NULL,
471 &wPreferences.resize_increment, getInt, NULL, NULL, NULL},
472 {"Attraction", "NO", NULL,
473 &wPreferences.attract, getBool, NULL, NULL, NULL},
474 {"DisableBlinking", "NO", NULL,
475 &wPreferences.dont_blink, getBool, NULL, NULL, NULL},
476 {"SingleClickLaunch", "NO", NULL,
477 &wPreferences.single_click, getBool, NULL, NULL, NULL},
478 {"StrictWindozeCycle", "YES", NULL,
479 &wPreferences.strict_windoze_cycle, getBool, NULL, NULL, NULL},
481 /* style options */
483 {"MenuStyle", "normal", seMenuStyles,
484 &wPreferences.menu_style, getEnum, setMenuStyle, NULL, NULL},
485 {"WidgetColor", "(solid, gray)", NULL,
486 NULL, getTexture, setWidgetColor, NULL, NULL},
487 {"WorkspaceSpecificBack", "()", NULL,
488 NULL, getWSSpecificBackground, setWorkspaceSpecificBack, NULL, NULL},
489 /* WorkspaceBack must come after WorkspaceSpecificBack or
490 * WorkspaceBack wont know WorkspaceSpecificBack was also
491 * specified and 2 copies of wmsetbg will be launched */
492 {"WorkspaceBack", "(solid, black)", NULL,
493 NULL, getWSBackground, setWorkspaceBack, NULL, NULL},
494 {"SmoothWorkspaceBack", "NO", NULL,
495 NULL, getBool, NULL, NULL, NULL},
496 {"IconBack", "(solid, gray)", NULL,
497 NULL, getTexture, setIconTile, NULL, NULL},
498 {"TitleJustify", "center", seJustifications,
499 &wPreferences.title_justification, getEnum, setJustify, NULL, NULL},
500 {"WindowTitleFont", DEF_TITLE_FONT, NULL,
501 NULL, getFont, setWinTitleFont, NULL, NULL},
502 {"WindowTitleExtendSpace", DEF_WINDOW_TITLE_EXTEND_SPACE, NULL,
503 &wPreferences.window_title_clearance, getInt, setClearance, NULL, NULL},
504 {"WindowTitleMinHeight", "0", NULL,
505 &wPreferences.window_title_min_height, getInt, setClearance, NULL, NULL},
506 {"WindowTitleMaxHeight", NUM2STRING(INT_MAX), NULL,
507 &wPreferences.window_title_max_height, getInt, setClearance, NULL, NULL},
508 {"MenuTitleExtendSpace", DEF_MENU_TITLE_EXTEND_SPACE, NULL,
509 &wPreferences.menu_title_clearance, getInt, setClearance, NULL, NULL},
510 {"MenuTitleMinHeight", "0", NULL,
511 &wPreferences.menu_title_min_height, getInt, setClearance, NULL, NULL},
512 {"MenuTitleMaxHeight", NUM2STRING(INT_MAX), NULL,
513 &wPreferences.menu_title_max_height, getInt, setClearance, NULL, NULL},
514 {"MenuTextExtendSpace", DEF_MENU_TEXT_EXTEND_SPACE, NULL,
515 &wPreferences.menu_text_clearance, getInt, setClearance, NULL, NULL},
516 {"MenuTitleFont", DEF_MENU_TITLE_FONT, NULL,
517 NULL, getFont, setMenuTitleFont, NULL, NULL},
518 {"MenuTextFont", DEF_MENU_ENTRY_FONT, NULL,
519 NULL, getFont, setMenuTextFont, NULL, NULL},
520 {"IconTitleFont", DEF_ICON_TITLE_FONT, NULL,
521 NULL, getFont, setIconTitleFont, NULL, NULL},
522 {"ClipTitleFont", DEF_CLIP_TITLE_FONT, NULL,
523 NULL, getFont, setClipTitleFont, NULL, NULL},
524 {"ShowClipTitle", "YES", NULL,
525 &wPreferences.show_clip_title, getBool, NULL, NULL, NULL},
526 {"LargeDisplayFont", DEF_WORKSPACE_NAME_FONT, NULL,
527 NULL, getFont, setLargeDisplayFont, NULL, NULL},
528 {"HighlightColor", "white", NULL,
529 NULL, getColor, setHightlight, NULL, NULL},
530 {"HighlightTextColor", "black", NULL,
531 NULL, getColor, setHightlightText, NULL, NULL},
532 {"ClipTitleColor", "black", (void *)CLIP_NORMAL,
533 NULL, getColor, setClipTitleColor, NULL, NULL},
534 {"CClipTitleColor", "\"#454045\"", (void *)CLIP_COLLAPSED,
535 NULL, getColor, setClipTitleColor, NULL, NULL},
536 {"FTitleColor", "white", (void *)WS_FOCUSED,
537 NULL, getColor, setWTitleColor, NULL, NULL},
538 {"PTitleColor", "white", (void *)WS_PFOCUSED,
539 NULL, getColor, setWTitleColor, NULL, NULL},
540 {"UTitleColor", "black", (void *)WS_UNFOCUSED,
541 NULL, getColor, setWTitleColor, NULL, NULL},
542 {"FTitleBack", "(solid, black)", NULL,
543 NULL, getTexture, setFTitleBack, NULL, NULL},
544 {"PTitleBack", "(solid, \"#616161\")", NULL,
545 NULL, getTexture, setPTitleBack, NULL, NULL},
546 {"UTitleBack", "(solid, gray)", NULL,
547 NULL, getTexture, setUTitleBack, NULL, NULL},
548 {"ResizebarBack", "(solid, gray)", NULL,
549 NULL, getTexture, setResizebarBack, NULL, NULL},
550 {"MenuTitleColor", "white", NULL,
551 NULL, getColor, setMenuTitleColor, NULL, NULL},
552 {"MenuTextColor", "black", NULL,
553 NULL, getColor, setMenuTextColor, NULL, NULL},
554 {"MenuDisabledColor", "\"#616161\"", NULL,
555 NULL, getColor, setMenuDisabledColor, NULL, NULL},
556 {"MenuTitleBack", "(solid, black)", NULL,
557 NULL, getTexture, setMenuTitleBack, NULL, NULL},
558 {"MenuTextBack", "(solid, gray)", NULL,
559 NULL, getTexture, setMenuTextBack, NULL, NULL},
560 {"IconTitleColor", "white", NULL,
561 NULL, getColor, setIconTitleColor, NULL, NULL},
562 {"IconTitleBack", "black", NULL,
563 NULL, getColor, setIconTitleBack, NULL, NULL},
564 {"SwitchPanelImages", "(swtile.png, swback.png, 30, 40)", &wPreferences,
565 NULL, getPropList, setSwPOptions, NULL, NULL},
566 {"ModifierKeyLabels", "(\"Shift+\", \"Ctrl+\", \"Mod1+\", \"Mod2+\", \"Mod3+\", \"Mod4+\", \"Mod5+\")", &wPreferences,
567 NULL, getPropList, setModifierKeyLabels, NULL, NULL},
568 {"FrameBorderWidth", "1", NULL,
569 NULL, getInt, setFrameBorderWidth, NULL, NULL},
570 {"FrameBorderColor", "black", NULL,
571 NULL, getColor, setFrameBorderColor, NULL, NULL},
572 {"FrameSelectedBorderColor", "white", NULL,
573 NULL, getColor, setFrameSelectedBorderColor, NULL, NULL},
575 /* keybindings */
577 {"RootMenuKey", "None", (void *)WKBD_ROOTMENU,
578 NULL, getKeybind, setKeyGrab, NULL, NULL},
579 {"WindowListKey", "None", (void *)WKBD_WINDOWLIST,
580 NULL, getKeybind, setKeyGrab, NULL, NULL},
581 {"WindowMenuKey", "None", (void *)WKBD_WINDOWMENU,
582 NULL, getKeybind, setKeyGrab, NULL, NULL},
583 {"DockRaiseLowerKey", "None", (void*)WKBD_DOCKRAISELOWER,
584 NULL, getKeybind, setKeyGrab, NULL, NULL},
585 {"ClipRaiseLowerKey", "None", (void *)WKBD_CLIPRAISELOWER,
586 NULL, getKeybind, setKeyGrab, NULL, NULL},
587 {"MiniaturizeKey", "None", (void *)WKBD_MINIATURIZE,
588 NULL, getKeybind, setKeyGrab, NULL, NULL},
589 {"MinimizeAllKey", "None", (void *)WKBD_MINIMIZEALL,
590 NULL, getKeybind, setKeyGrab, NULL, NULL },
591 {"HideKey", "None", (void *)WKBD_HIDE,
592 NULL, getKeybind, setKeyGrab, NULL, NULL},
593 {"HideOthersKey", "None", (void *)WKBD_HIDE_OTHERS,
594 NULL, getKeybind, setKeyGrab, NULL, NULL},
595 {"MoveResizeKey", "None", (void *)WKBD_MOVERESIZE,
596 NULL, getKeybind, setKeyGrab, NULL, NULL},
597 {"CloseKey", "None", (void *)WKBD_CLOSE,
598 NULL, getKeybind, setKeyGrab, NULL, NULL},
599 {"MaximizeKey", "None", (void *)WKBD_MAXIMIZE,
600 NULL, getKeybind, setKeyGrab, NULL, NULL},
601 {"VMaximizeKey", "None", (void *)WKBD_VMAXIMIZE,
602 NULL, getKeybind, setKeyGrab, NULL, NULL},
603 {"HMaximizeKey", "None", (void *)WKBD_HMAXIMIZE,
604 NULL, getKeybind, setKeyGrab, NULL, NULL},
605 {"LHMaximizeKey", "None", (void*)WKBD_LHMAXIMIZE,
606 NULL, getKeybind, setKeyGrab, NULL, NULL},
607 {"RHMaximizeKey", "None", (void*)WKBD_RHMAXIMIZE,
608 NULL, getKeybind, setKeyGrab, NULL, NULL},
609 {"THMaximizeKey", "None", (void*)WKBD_THMAXIMIZE,
610 NULL, getKeybind, setKeyGrab, NULL, NULL},
611 {"BHMaximizeKey", "None", (void*)WKBD_BHMAXIMIZE,
612 NULL, getKeybind, setKeyGrab, NULL, NULL},
613 {"LTCMaximizeKey", "None", (void*)WKBD_LTCMAXIMIZE,
614 NULL, getKeybind, setKeyGrab, NULL, NULL},
615 {"RTCMaximizeKey", "None", (void*)WKBD_RTCMAXIMIZE,
616 NULL, getKeybind, setKeyGrab, NULL, NULL},
617 {"LBCMaximizeKey", "None", (void*)WKBD_LBCMAXIMIZE,
618 NULL, getKeybind, setKeyGrab, NULL, NULL},
619 {"RBCMaximizeKey", "None", (void*)WKBD_RBCMAXIMIZE,
620 NULL, getKeybind, setKeyGrab, NULL, NULL},
621 {"MaximusKey", "None", (void*)WKBD_MAXIMUS,
622 NULL, getKeybind, setKeyGrab, NULL, NULL},
623 {"RaiseKey", "\"Meta+Up\"", (void *)WKBD_RAISE,
624 NULL, getKeybind, setKeyGrab, NULL, NULL},
625 {"LowerKey", "\"Meta+Down\"", (void *)WKBD_LOWER,
626 NULL, getKeybind, setKeyGrab, NULL, NULL},
627 {"RaiseLowerKey", "None", (void *)WKBD_RAISELOWER,
628 NULL, getKeybind, setKeyGrab, NULL, NULL},
629 {"ShadeKey", "None", (void *)WKBD_SHADE,
630 NULL, getKeybind, setKeyGrab, NULL, NULL},
631 {"SelectKey", "None", (void *)WKBD_SELECT,
632 NULL, getKeybind, setKeyGrab, NULL, NULL},
633 {"FocusNextKey", "None", (void *)WKBD_FOCUSNEXT,
634 NULL, getKeybind, setKeyGrab, NULL, NULL},
635 {"FocusPrevKey", "None", (void *)WKBD_FOCUSPREV,
636 NULL, getKeybind, setKeyGrab, NULL, NULL},
637 {"GroupNextKey", "None", (void *)WKBD_GROUPNEXT,
638 NULL, getKeybind, setKeyGrab, NULL, NULL},
639 {"GroupPrevKey", "None", (void *)WKBD_GROUPPREV,
640 NULL, getKeybind, setKeyGrab, NULL, NULL},
641 {"NextWorkspaceKey", "None", (void *)WKBD_NEXTWORKSPACE,
642 NULL, getKeybind, setKeyGrab, NULL, NULL},
643 {"PrevWorkspaceKey", "None", (void *)WKBD_PREVWORKSPACE,
644 NULL, getKeybind, setKeyGrab, NULL, NULL},
645 {"LastWorkspaceKey", "None", (void *)WKBD_LASTWORKSPACE,
646 NULL, getKeybind, setKeyGrab, NULL, NULL},
647 {"NextWorkspaceLayerKey", "None", (void *)WKBD_NEXTWSLAYER,
648 NULL, getKeybind, setKeyGrab, NULL, NULL},
649 {"PrevWorkspaceLayerKey", "None", (void *)WKBD_PREVWSLAYER,
650 NULL, getKeybind, setKeyGrab, NULL, NULL},
651 {"Workspace1Key", "None", (void *)WKBD_WORKSPACE1,
652 NULL, getKeybind, setKeyGrab, NULL, NULL},
653 {"Workspace2Key", "None", (void *)WKBD_WORKSPACE2,
654 NULL, getKeybind, setKeyGrab, NULL, NULL},
655 {"Workspace3Key", "None", (void *)WKBD_WORKSPACE3,
656 NULL, getKeybind, setKeyGrab, NULL, NULL},
657 {"Workspace4Key", "None", (void *)WKBD_WORKSPACE4,
658 NULL, getKeybind, setKeyGrab, NULL, NULL},
659 {"Workspace5Key", "None", (void *)WKBD_WORKSPACE5,
660 NULL, getKeybind, setKeyGrab, NULL, NULL},
661 {"Workspace6Key", "None", (void *)WKBD_WORKSPACE6,
662 NULL, getKeybind, setKeyGrab, NULL, NULL},
663 {"Workspace7Key", "None", (void *)WKBD_WORKSPACE7,
664 NULL, getKeybind, setKeyGrab, NULL, NULL},
665 {"Workspace8Key", "None", (void *)WKBD_WORKSPACE8,
666 NULL, getKeybind, setKeyGrab, NULL, NULL},
667 {"Workspace9Key", "None", (void *)WKBD_WORKSPACE9,
668 NULL, getKeybind, setKeyGrab, NULL, NULL},
669 {"Workspace10Key", "None", (void *)WKBD_WORKSPACE10,
670 NULL, getKeybind, setKeyGrab, NULL, NULL},
671 {"MoveToWorkspace1Key", "None", (void *)WKBD_MOVE_WORKSPACE1,
672 NULL, getKeybind, setKeyGrab, NULL, NULL},
673 {"MoveToWorkspace2Key", "None", (void *)WKBD_MOVE_WORKSPACE2,
674 NULL, getKeybind, setKeyGrab, NULL, NULL},
675 {"MoveToWorkspace3Key", "None", (void *)WKBD_MOVE_WORKSPACE3,
676 NULL, getKeybind, setKeyGrab, NULL, NULL},
677 {"MoveToWorkspace4Key", "None", (void *)WKBD_MOVE_WORKSPACE4,
678 NULL, getKeybind, setKeyGrab, NULL, NULL},
679 {"MoveToWorkspace5Key", "None", (void *)WKBD_MOVE_WORKSPACE5,
680 NULL, getKeybind, setKeyGrab, NULL, NULL},
681 {"MoveToWorkspace6Key", "None", (void *)WKBD_MOVE_WORKSPACE6,
682 NULL, getKeybind, setKeyGrab, NULL, NULL},
683 {"MoveToWorkspace7Key", "None", (void *)WKBD_MOVE_WORKSPACE7,
684 NULL, getKeybind, setKeyGrab, NULL, NULL},
685 {"MoveToWorkspace8Key", "None", (void *)WKBD_MOVE_WORKSPACE8,
686 NULL, getKeybind, setKeyGrab, NULL, NULL},
687 {"MoveToWorkspace9Key", "None", (void *)WKBD_MOVE_WORKSPACE9,
688 NULL, getKeybind, setKeyGrab, NULL, NULL},
689 {"MoveToWorkspace10Key", "None", (void *)WKBD_MOVE_WORKSPACE10,
690 NULL, getKeybind, setKeyGrab, NULL, NULL},
691 {"MoveToNextWorkspaceKey", "None", (void *)WKBD_MOVE_NEXTWORKSPACE,
692 NULL, getKeybind, setKeyGrab, NULL, NULL},
693 {"MoveToPrevWorkspaceKey", "None", (void *)WKBD_MOVE_PREVWORKSPACE,
694 NULL, getKeybind, setKeyGrab, NULL, NULL},
695 {"MoveToLastWorkspaceKey", "None", (void *)WKBD_MOVE_LASTWORKSPACE,
696 NULL, getKeybind, setKeyGrab, NULL, NULL},
697 {"MoveToNextWorkspaceLayerKey", "None", (void *)WKBD_MOVE_NEXTWSLAYER,
698 NULL, getKeybind, setKeyGrab, NULL, NULL},
699 {"MoveToPrevWorkspaceLayerKey", "None", (void *)WKBD_MOVE_PREVWSLAYER,
700 NULL, getKeybind, setKeyGrab, NULL, NULL},
701 {"WindowShortcut1Key", "None", (void *)WKBD_WINDOW1,
702 NULL, getKeybind, setKeyGrab, NULL, NULL},
703 {"WindowShortcut2Key", "None", (void *)WKBD_WINDOW2,
704 NULL, getKeybind, setKeyGrab, NULL, NULL},
705 {"WindowShortcut3Key", "None", (void *)WKBD_WINDOW3,
706 NULL, getKeybind, setKeyGrab, NULL, NULL},
707 {"WindowShortcut4Key", "None", (void *)WKBD_WINDOW4,
708 NULL, getKeybind, setKeyGrab, NULL, NULL},
709 {"WindowShortcut5Key", "None", (void *)WKBD_WINDOW5,
710 NULL, getKeybind, setKeyGrab, NULL, NULL},
711 {"WindowShortcut6Key", "None", (void *)WKBD_WINDOW6,
712 NULL, getKeybind, setKeyGrab, NULL, NULL},
713 {"WindowShortcut7Key", "None", (void *)WKBD_WINDOW7,
714 NULL, getKeybind, setKeyGrab, NULL, NULL},
715 {"WindowShortcut8Key", "None", (void *)WKBD_WINDOW8,
716 NULL, getKeybind, setKeyGrab, NULL, NULL},
717 {"WindowShortcut9Key", "None", (void *)WKBD_WINDOW9,
718 NULL, getKeybind, setKeyGrab, NULL, NULL},
719 {"WindowShortcut10Key", "None", (void *)WKBD_WINDOW10,
720 NULL, getKeybind, setKeyGrab, NULL, NULL},
721 {"WindowRelaunchKey", "None", (void *)WKBD_RELAUNCH,
722 NULL, getKeybind, setKeyGrab, NULL, NULL},
723 {"ScreenSwitchKey", "None", (void *)WKBD_SWITCH_SCREEN,
724 NULL, getKeybind, setKeyGrab, NULL, NULL},
726 #ifdef KEEP_XKB_LOCK_STATUS
727 {"ToggleKbdModeKey", "None", (void *)WKBD_TOGGLE,
728 NULL, getKeybind, setKeyGrab, NULL, NULL},
729 {"KbdModeLock", "NO", NULL,
730 &wPreferences.modelock, getBool, NULL, NULL, NULL},
731 #endif /* KEEP_XKB_LOCK_STATUS */
733 {"NormalCursor", "(builtin, left_ptr)", (void *)WCUR_ROOT,
734 NULL, getCursor, setCursor, NULL, NULL},
735 {"ArrowCursor", "(builtin, top_left_arrow)", (void *)WCUR_ARROW,
736 NULL, getCursor, setCursor, NULL, NULL},
737 {"MoveCursor", "(builtin, fleur)", (void *)WCUR_MOVE,
738 NULL, getCursor, setCursor, NULL, NULL},
739 {"ResizeCursor", "(builtin, sizing)", (void *)WCUR_RESIZE,
740 NULL, getCursor, setCursor, NULL, NULL},
741 {"TopLeftResizeCursor", "(builtin, top_left_corner)", (void *)WCUR_TOPLEFTRESIZE,
742 NULL, getCursor, setCursor, NULL, NULL},
743 {"TopRightResizeCursor", "(builtin, top_right_corner)", (void *)WCUR_TOPRIGHTRESIZE,
744 NULL, getCursor, setCursor, NULL, NULL},
745 {"BottomLeftResizeCursor", "(builtin, bottom_left_corner)", (void *)WCUR_BOTTOMLEFTRESIZE,
746 NULL, getCursor, setCursor, NULL, NULL},
747 {"BottomRightResizeCursor", "(builtin, bottom_right_corner)", (void *)WCUR_BOTTOMRIGHTRESIZE,
748 NULL, getCursor, setCursor, NULL, NULL},
749 {"VerticalResizeCursor", "(builtin, sb_v_double_arrow)", (void *)WCUR_VERTICALRESIZE,
750 NULL, getCursor, setCursor, NULL, NULL},
751 {"HorizontalResizeCursor", "(builtin, sb_h_double_arrow)", (void *)WCUR_HORIZONRESIZE,
752 NULL, getCursor, setCursor, NULL, NULL},
753 {"WaitCursor", "(builtin, watch)", (void *)WCUR_WAIT,
754 NULL, getCursor, setCursor, NULL, NULL},
755 {"QuestionCursor", "(builtin, question_arrow)", (void *)WCUR_QUESTION,
756 NULL, getCursor, setCursor, NULL, NULL},
757 {"TextCursor", "(builtin, xterm)", (void *)WCUR_TEXT,
758 NULL, getCursor, setCursor, NULL, NULL},
759 {"SelectCursor", "(builtin, cross)", (void *)WCUR_SELECT,
760 NULL, getCursor, setCursor, NULL, NULL},
761 {"DialogHistoryLines", "500", NULL,
762 &wPreferences.history_lines, getInt, NULL, NULL, NULL},
763 {"CycleActiveHeadOnly", "NO", NULL,
764 &wPreferences.cycle_active_head_only, getBool, NULL, NULL, NULL},
765 {"CycleIgnoreMinimized", "NO", NULL,
766 &wPreferences.cycle_ignore_minimized, getBool, NULL, NULL, NULL}
769 static void initDefaults(void)
771 unsigned int i;
772 WDefaultEntry *entry;
774 WMPLSetCaseSensitive(False);
776 for (i = 0; i < sizeof(optionList) / sizeof(optionList[0]); i++) {
777 entry = &optionList[i];
779 entry->plkey = WMCreatePLString(entry->key);
780 if (entry->default_value)
781 entry->plvalue = WMCreatePropListFromDescription(entry->default_value);
782 else
783 entry->plvalue = NULL;
786 for (i = 0; i < sizeof(staticOptionList) / sizeof(staticOptionList[0]); i++) {
787 entry = &staticOptionList[i];
789 entry->plkey = WMCreatePLString(entry->key);
790 if (entry->default_value)
791 entry->plvalue = WMCreatePropListFromDescription(entry->default_value);
792 else
793 entry->plvalue = NULL;
797 static WMPropList *readGlobalDomain(char *domainName, Bool requireDictionary)
799 WMPropList *globalDict = NULL;
800 char path[PATH_MAX];
801 struct stat stbuf;
803 snprintf(path, sizeof(path), "%s/%s/%s", SYSCONFDIR, GLOBAL_DEFAULTS_SUBDIR, domainName);
804 if (stat(path, &stbuf) >= 0) {
805 globalDict = WMReadPropListFromFile(path);
806 if (globalDict && requireDictionary && !WMIsPLDictionary(globalDict)) {
807 wwarning(_("Domain %s (%s) of global defaults database is corrupted!"), domainName, path);
808 WMReleasePropList(globalDict);
809 globalDict = NULL;
810 } else if (!globalDict) {
811 wwarning(_("could not load domain %s from global defaults database"), domainName);
815 return globalDict;
818 #if defined(GLOBAL_PREAMBLE_MENU_FILE) || defined(GLOBAL_EPILOGUE_MENU_FILE)
819 static void prependMenu(WMPropList * destarr, WMPropList * array)
821 WMPropList *item;
822 int i;
824 for (i = 0; i < WMGetPropListItemCount(array); i++) {
825 item = WMGetFromPLArray(array, i);
826 if (item)
827 WMInsertInPLArray(destarr, i + 1, item);
831 static void appendMenu(WMPropList * destarr, WMPropList * array)
833 WMPropList *item;
834 int i;
836 for (i = 0; i < WMGetPropListItemCount(array); i++) {
837 item = WMGetFromPLArray(array, i);
838 if (item)
839 WMAddToPLArray(destarr, item);
842 #endif
844 void wDefaultsMergeGlobalMenus(WDDomain * menuDomain)
846 WMPropList *menu = menuDomain->dictionary;
847 WMPropList *submenu;
849 if (!menu || !WMIsPLArray(menu))
850 return;
852 #ifdef GLOBAL_PREAMBLE_MENU_FILE
853 submenu = WMReadPropListFromFile(SYSCONFDIR "/" GLOBAL_DEFAULTS_SUBDIR "/" GLOBAL_PREAMBLE_MENU_FILE);
855 if (submenu && !WMIsPLArray(submenu)) {
856 wwarning(_("invalid global menu file %s"), GLOBAL_PREAMBLE_MENU_FILE);
857 WMReleasePropList(submenu);
858 submenu = NULL;
860 if (submenu) {
861 prependMenu(menu, submenu);
862 WMReleasePropList(submenu);
864 #endif
866 #ifdef GLOBAL_EPILOGUE_MENU_FILE
867 submenu = WMReadPropListFromFile(SYSCONFDIR "/" GLOBAL_DEFAULTS_SUBDIR "/" GLOBAL_EPILOGUE_MENU_FILE);
869 if (submenu && !WMIsPLArray(submenu)) {
870 wwarning(_("invalid global menu file %s"), GLOBAL_EPILOGUE_MENU_FILE);
871 WMReleasePropList(submenu);
872 submenu = NULL;
874 if (submenu) {
875 appendMenu(menu, submenu);
876 WMReleasePropList(submenu);
878 #endif
880 menuDomain->dictionary = menu;
883 WDDomain *wDefaultsInitDomain(char *domain, Bool requireDictionary)
885 WDDomain *db;
886 struct stat stbuf;
887 static int inited = 0;
888 char *the_path;
889 WMPropList *shared_dict = NULL;
891 if (!inited) {
892 inited = 1;
893 initDefaults();
896 db = wmalloc(sizeof(WDDomain));
897 db->domain_name = domain;
898 db->path = wdefaultspathfordomain(domain);
899 the_path = db->path;
901 if (the_path && stat(the_path, &stbuf) >= 0) {
902 db->dictionary = WMReadPropListFromFile(the_path);
903 if (db->dictionary) {
904 if (requireDictionary && !WMIsPLDictionary(db->dictionary)) {
905 WMReleasePropList(db->dictionary);
906 db->dictionary = NULL;
907 wwarning(_("Domain %s (%s) of defaults database is corrupted!"), domain, the_path);
909 db->timestamp = stbuf.st_mtime;
910 } else {
911 wwarning(_("could not load domain %s from user defaults database"), domain);
915 /* global system dictionary */
916 shared_dict = readGlobalDomain(domain, requireDictionary);
918 if (shared_dict && db->dictionary && WMIsPLDictionary(shared_dict) &&
919 WMIsPLDictionary(db->dictionary)) {
920 WMMergePLDictionaries(shared_dict, db->dictionary, True);
921 WMReleasePropList(db->dictionary);
922 db->dictionary = shared_dict;
923 if (stbuf.st_mtime > db->timestamp)
924 db->timestamp = stbuf.st_mtime;
925 } else if (!db->dictionary) {
926 db->dictionary = shared_dict;
927 if (stbuf.st_mtime > db->timestamp)
928 db->timestamp = stbuf.st_mtime;
931 return db;
934 void wReadStaticDefaults(WMPropList * dict)
936 WMPropList *plvalue;
937 WDefaultEntry *entry;
938 unsigned int i;
939 void *tdata;
941 for (i = 0; i < sizeof(staticOptionList) / sizeof(staticOptionList[0]); i++) {
942 entry = &staticOptionList[i];
944 if (dict)
945 plvalue = WMGetFromPLDictionary(dict, entry->plkey);
946 else
947 plvalue = NULL;
949 /* no default in the DB. Use builtin default */
950 if (!plvalue)
951 plvalue = entry->plvalue;
953 if (plvalue) {
954 /* convert data */
955 (*entry->convert) (NULL, entry, plvalue, entry->addr, &tdata);
956 if (entry->update)
957 (*entry->update) (NULL, entry, tdata, entry->extra_data);
962 void wDefaultsCheckDomains(void* arg)
964 WScreen *scr;
965 struct stat stbuf;
966 WMPropList *shared_dict = NULL;
967 WMPropList *dict;
968 int i;
970 if (stat(WDWindowMaker->path, &stbuf) >= 0 && WDWindowMaker->timestamp < stbuf.st_mtime) {
971 WDWindowMaker->timestamp = stbuf.st_mtime;
973 /* Global dictionary */
974 shared_dict = readGlobalDomain("WindowMaker", True);
976 /* User dictionary */
977 dict = WMReadPropListFromFile(WDWindowMaker->path);
979 if (dict) {
980 if (!WMIsPLDictionary(dict)) {
981 WMReleasePropList(dict);
982 dict = NULL;
983 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
984 "WindowMaker", WDWindowMaker->path);
985 } else {
986 if (shared_dict) {
987 WMMergePLDictionaries(shared_dict, dict, True);
988 WMReleasePropList(dict);
989 dict = shared_dict;
990 shared_dict = NULL;
993 for (i = 0; i < wScreenCount; i++) {
994 scr = wScreenWithNumber(i);
995 if (scr)
996 wReadDefaults(scr, dict);
999 if (WDWindowMaker->dictionary)
1000 WMReleasePropList(WDWindowMaker->dictionary);
1002 WDWindowMaker->dictionary = dict;
1004 } else {
1005 wwarning(_("could not load domain %s from user defaults database"), "WindowMaker");
1008 if (shared_dict)
1009 WMReleasePropList(shared_dict);
1013 if (stat(WDWindowAttributes->path, &stbuf) >= 0 && WDWindowAttributes->timestamp < stbuf.st_mtime) {
1014 /* global dictionary */
1015 shared_dict = readGlobalDomain("WMWindowAttributes", True);
1016 /* user dictionary */
1017 dict = WMReadPropListFromFile(WDWindowAttributes->path);
1018 if (dict) {
1019 if (!WMIsPLDictionary(dict)) {
1020 WMReleasePropList(dict);
1021 dict = NULL;
1022 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
1023 "WMWindowAttributes", WDWindowAttributes->path);
1024 } else {
1025 if (shared_dict) {
1026 WMMergePLDictionaries(shared_dict, dict, True);
1027 WMReleasePropList(dict);
1028 dict = shared_dict;
1029 shared_dict = NULL;
1032 if (WDWindowAttributes->dictionary)
1033 WMReleasePropList(WDWindowAttributes->dictionary);
1035 WDWindowAttributes->dictionary = dict;
1036 for (i = 0; i < wScreenCount; i++) {
1037 scr = wScreenWithNumber(i);
1038 if (scr) {
1039 wDefaultUpdateIcons(scr);
1041 /* Update the panel image if changed */
1042 /* Don't worry. If the image is the same these
1043 * functions will have no performance impact. */
1044 create_logo_image(scr);
1048 } else {
1049 wwarning(_("could not load domain %s from user defaults database"), "WMWindowAttributes");
1052 WDWindowAttributes->timestamp = stbuf.st_mtime;
1053 if (shared_dict)
1054 WMReleasePropList(shared_dict);
1057 if (stat(WDRootMenu->path, &stbuf) >= 0 && WDRootMenu->timestamp < stbuf.st_mtime) {
1058 dict = WMReadPropListFromFile(WDRootMenu->path);
1059 if (dict) {
1060 if (!WMIsPLArray(dict) && !WMIsPLString(dict)) {
1061 WMReleasePropList(dict);
1062 dict = NULL;
1063 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
1064 "WMRootMenu", WDRootMenu->path);
1065 } else {
1066 if (WDRootMenu->dictionary)
1067 WMReleasePropList(WDRootMenu->dictionary);
1069 WDRootMenu->dictionary = dict;
1070 wDefaultsMergeGlobalMenus(WDRootMenu);
1072 } else {
1073 wwarning(_("could not load domain %s from user defaults database"), "WMRootMenu");
1075 WDRootMenu->timestamp = stbuf.st_mtime;
1077 #ifndef HAVE_INOTIFY
1078 if (!arg)
1079 WMAddTimerHandler(DEFAULTS_CHECK_INTERVAL, wDefaultsCheckDomains, arg);
1080 #endif
1083 void wReadDefaults(WScreen * scr, WMPropList * new_dict)
1085 WMPropList *plvalue, *old_value;
1086 WDefaultEntry *entry;
1087 unsigned int i;
1088 int update_workspace_back = 0; /* kluge :/ */
1089 unsigned int needs_refresh;
1090 void *tdata;
1091 WMPropList *old_dict = (WDWindowMaker->dictionary != new_dict ? WDWindowMaker->dictionary : NULL);
1093 needs_refresh = 0;
1095 for (i = 0; i < sizeof(optionList) / sizeof(optionList[0]); i++) {
1096 entry = &optionList[i];
1098 if (new_dict)
1099 plvalue = WMGetFromPLDictionary(new_dict, entry->plkey);
1100 else
1101 plvalue = NULL;
1103 if (!old_dict)
1104 old_value = NULL;
1105 else
1106 old_value = WMGetFromPLDictionary(old_dict, entry->plkey);
1108 if (!plvalue && !old_value) {
1109 /* no default in the DB. Use builtin default */
1110 plvalue = entry->plvalue;
1111 if (plvalue && new_dict)
1112 WMPutInPLDictionary(new_dict, entry->plkey, plvalue);
1114 } else if (!plvalue) {
1115 /* value was deleted from DB. Keep current value */
1116 continue;
1117 } else if (!old_value) {
1118 /* set value for the 1st time */
1119 } else if (!WMIsPropListEqualTo(plvalue, old_value)) {
1120 /* value has changed */
1121 } else {
1122 if (strcmp(entry->key, "WorkspaceBack") == 0
1123 && update_workspace_back && scr->flags.backimage_helper_launched) {
1124 } else {
1125 /* value was not changed since last time */
1126 continue;
1130 if (plvalue) {
1131 /* convert data */
1132 if ((*entry->convert) (scr, entry, plvalue, entry->addr, &tdata)) {
1134 * If the WorkspaceSpecificBack data has been changed
1135 * so that the helper will be launched now, we must be
1136 * sure to send the default background texture config
1137 * to the helper.
1139 if (strcmp(entry->key, "WorkspaceSpecificBack") == 0 &&
1140 !scr->flags.backimage_helper_launched)
1141 update_workspace_back = 1;
1143 if (entry->update)
1144 needs_refresh |= (*entry->update) (scr, entry, tdata, entry->extra_data);
1150 if (needs_refresh != 0 && !scr->flags.startup) {
1151 int foo;
1153 foo = 0;
1154 if (needs_refresh & REFRESH_MENU_TITLE_TEXTURE)
1155 foo |= WTextureSettings;
1156 if (needs_refresh & REFRESH_MENU_TITLE_FONT)
1157 foo |= WFontSettings;
1158 if (needs_refresh & REFRESH_MENU_TITLE_COLOR)
1159 foo |= WColorSettings;
1160 if (foo)
1161 WMPostNotificationName(WNMenuTitleAppearanceSettingsChanged, NULL,
1162 (void *)(uintptr_t) foo);
1164 foo = 0;
1165 if (needs_refresh & REFRESH_MENU_TEXTURE)
1166 foo |= WTextureSettings;
1167 if (needs_refresh & REFRESH_MENU_FONT)
1168 foo |= WFontSettings;
1169 if (needs_refresh & REFRESH_MENU_COLOR)
1170 foo |= WColorSettings;
1171 if (foo)
1172 WMPostNotificationName(WNMenuAppearanceSettingsChanged, NULL, (void *)(uintptr_t) foo);
1174 foo = 0;
1175 if (needs_refresh & REFRESH_WINDOW_FONT)
1176 foo |= WFontSettings;
1177 if (needs_refresh & REFRESH_WINDOW_TEXTURES)
1178 foo |= WTextureSettings;
1179 if (needs_refresh & REFRESH_WINDOW_TITLE_COLOR)
1180 foo |= WColorSettings;
1181 if (foo)
1182 WMPostNotificationName(WNWindowAppearanceSettingsChanged, NULL, (void *)(uintptr_t) foo);
1184 if (!(needs_refresh & REFRESH_ICON_TILE)) {
1185 foo = 0;
1186 if (needs_refresh & REFRESH_ICON_FONT)
1187 foo |= WFontSettings;
1188 if (needs_refresh & REFRESH_ICON_TITLE_COLOR)
1189 foo |= WTextureSettings;
1190 if (needs_refresh & REFRESH_ICON_TITLE_BACK)
1191 foo |= WTextureSettings;
1192 if (foo)
1193 WMPostNotificationName(WNIconAppearanceSettingsChanged, NULL,
1194 (void *)(uintptr_t) foo);
1196 if (needs_refresh & REFRESH_ICON_TILE)
1197 WMPostNotificationName(WNIconTileSettingsChanged, NULL, NULL);
1199 if (needs_refresh & REFRESH_WORKSPACE_MENU) {
1200 if (scr->workspace_menu)
1201 wWorkspaceMenuUpdate(scr, scr->workspace_menu);
1202 if (scr->clip_ws_menu)
1203 wWorkspaceMenuUpdate(scr, scr->clip_ws_menu);
1204 if (scr->workspace_submenu)
1205 scr->workspace_submenu->flags.realized = 0;
1206 if (scr->clip_submenu)
1207 scr->clip_submenu->flags.realized = 0;
1212 void wDefaultUpdateIcons(WScreen *scr)
1214 WAppIcon *aicon = scr->app_icon_list;
1215 WDrawerChain *dc;
1216 WWindow *wwin = scr->focused_window;
1218 while (aicon) {
1219 /* Get the application icon, default included */
1220 wIconChangeImageFile(aicon->icon, NULL);
1221 wAppIconPaint(aicon);
1222 aicon = aicon->next;
1225 if (!wPreferences.flags.noclip || wPreferences.flags.clip_merged_in_dock)
1226 wClipIconPaint(scr->clip_icon);
1228 for (dc = scr->drawers; dc != NULL; dc = dc->next)
1229 wDrawerIconPaint(dc->adrawer->icon_array[0]);
1231 while (wwin) {
1232 if (wwin->icon && wwin->flags.miniaturized)
1233 wIconChangeImageFile(wwin->icon, NULL);
1234 wwin = wwin->prev;
1238 /* --------------------------- Local ----------------------- */
1240 #define GET_STRING_OR_DEFAULT(x, var) if (!WMIsPLString(value)) { \
1241 wwarning(_("Wrong option format for key \"%s\". Should be %s."), \
1242 entry->key, x); \
1243 wwarning(_("using default \"%s\" instead"), entry->default_value); \
1244 var = entry->default_value;\
1245 } else var = WMGetFromPLString(value)\
1248 static int string2index(WMPropList * key, WMPropList * val, char *def, WOptionEnumeration * values)
1250 char *str;
1251 WOptionEnumeration *v;
1252 char buffer[TOTAL_VALUES_LENGTH];
1254 if (WMIsPLString(val) && (str = WMGetFromPLString(val))) {
1255 for (v = values; v->string != NULL; v++) {
1256 if (strcasecmp(v->string, str) == 0)
1257 return v->value;
1261 buffer[0] = 0;
1262 for (v = values; v->string != NULL; v++) {
1263 if (!v->is_alias) {
1264 if (buffer[0] != 0)
1265 strcat(buffer, ", ");
1266 snprintf(buffer+strlen(buffer),
1267 sizeof(buffer)-strlen(buffer)-1, "\"%s\"", v->string);
1270 wwarning(_("wrong option value for key \"%s\"; got \"%s\", should be one of %s."),
1271 WMGetFromPLString(key),
1272 WMIsPLString(val) ? WMGetFromPLString(val) : "(unknown)",
1273 buffer);
1275 if (def) {
1276 return string2index(key, val, NULL, values);
1279 return -1;
1283 * value - is the value in the defaults DB
1284 * addr - is the address to store the data
1285 * ret - is the address to store a pointer to a temporary buffer. ret
1286 * must not be freed and is used by the set functions
1288 static int getBool(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1290 static char data;
1291 char *val;
1292 int second_pass = 0;
1294 GET_STRING_OR_DEFAULT("Boolean", val);
1296 again:
1297 if ((val[1] == '\0' && (val[0] == 'y' || val[0] == 'Y'))
1298 || strcasecmp(val, "YES") == 0) {
1300 data = 1;
1301 } else if ((val[1] == '\0' && (val[0] == 'n' || val[0] == 'N'))
1302 || strcasecmp(val, "NO") == 0) {
1303 data = 0;
1304 } else {
1305 int i;
1306 if (sscanf(val, "%i", &i) == 1) {
1307 if (i != 0)
1308 data = 1;
1309 else
1310 data = 0;
1311 } else {
1312 wwarning(_("can't convert \"%s\" to boolean for key \"%s\""), val, entry->key);
1313 if (second_pass == 0) {
1314 val = WMGetFromPLString(entry->plvalue);
1315 second_pass = 1;
1316 wwarning(_("using default \"%s\" instead"), val);
1317 goto again;
1319 return False;
1323 if (ret)
1324 *ret = &data;
1325 if (addr)
1326 *(char *)addr = data;
1328 return True;
1331 static int getInt(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1333 static int data;
1334 char *val;
1336 GET_STRING_OR_DEFAULT("Integer", val);
1338 if (sscanf(val, "%i", &data) != 1) {
1339 wwarning(_("can't convert \"%s\" to integer for key \"%s\""), val, entry->key);
1340 val = WMGetFromPLString(entry->plvalue);
1341 wwarning(_("using default \"%s\" instead"), val);
1342 if (sscanf(val, "%i", &data) != 1) {
1343 return False;
1347 if (ret)
1348 *ret = &data;
1349 if (addr)
1350 *(int *)addr = data;
1352 return True;
1355 static int getCoord(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1357 static WCoord data;
1358 char *val_x, *val_y;
1359 int nelem, changed = 0;
1360 WMPropList *elem_x, *elem_y;
1362 again:
1363 if (!WMIsPLArray(value)) {
1364 wwarning(_("Wrong option format for key \"%s\". Should be %s."), entry->key, "Coordinate");
1365 if (changed == 0) {
1366 value = entry->plvalue;
1367 changed = 1;
1368 wwarning(_("using default \"%s\" instead"), entry->default_value);
1369 goto again;
1371 return False;
1374 nelem = WMGetPropListItemCount(value);
1375 if (nelem != 2) {
1376 wwarning(_("Incorrect number of elements in array for key \"%s\"."), entry->key);
1377 if (changed == 0) {
1378 value = entry->plvalue;
1379 changed = 1;
1380 wwarning(_("using default \"%s\" instead"), entry->default_value);
1381 goto again;
1383 return False;
1386 elem_x = WMGetFromPLArray(value, 0);
1387 elem_y = WMGetFromPLArray(value, 1);
1389 if (!elem_x || !elem_y || !WMIsPLString(elem_x) || !WMIsPLString(elem_y)) {
1390 wwarning(_("Wrong value for key \"%s\". Should be Coordinate."), entry->key);
1391 if (changed == 0) {
1392 value = entry->plvalue;
1393 changed = 1;
1394 wwarning(_("using default \"%s\" instead"), entry->default_value);
1395 goto again;
1397 return False;
1400 val_x = WMGetFromPLString(elem_x);
1401 val_y = WMGetFromPLString(elem_y);
1403 if (sscanf(val_x, "%i", &data.x) != 1 || sscanf(val_y, "%i", &data.y) != 1) {
1404 wwarning(_("can't convert array to integers for \"%s\"."), entry->key);
1405 if (changed == 0) {
1406 value = entry->plvalue;
1407 changed = 1;
1408 wwarning(_("using default \"%s\" instead"), entry->default_value);
1409 goto again;
1411 return False;
1414 if (data.x < 0)
1415 data.x = 0;
1416 else if (data.x > scr->scr_width / 3)
1417 data.x = scr->scr_width / 3;
1418 if (data.y < 0)
1419 data.y = 0;
1420 else if (data.y > scr->scr_height / 3)
1421 data.y = scr->scr_height / 3;
1423 if (ret)
1424 *ret = &data;
1425 if (addr)
1426 *(WCoord *) addr = data;
1428 return True;
1431 static int getPropList(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1433 WMRetainPropList(value);
1435 *ret = value;
1437 return True;
1440 static int getPathList(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1442 static char *data;
1443 int i, count, len;
1444 char *ptr;
1445 WMPropList *d;
1446 int changed = 0;
1448 again:
1449 if (!WMIsPLArray(value)) {
1450 wwarning(_("Wrong option format for key \"%s\". Should be %s."), entry->key, "an array of paths");
1451 if (changed == 0) {
1452 value = entry->plvalue;
1453 changed = 1;
1454 wwarning(_("using default \"%s\" instead"), entry->default_value);
1455 goto again;
1457 return False;
1460 i = 0;
1461 count = WMGetPropListItemCount(value);
1462 if (count < 1) {
1463 if (changed == 0) {
1464 value = entry->plvalue;
1465 changed = 1;
1466 wwarning(_("using default \"%s\" instead"), entry->default_value);
1467 goto again;
1469 return False;
1472 len = 0;
1473 for (i = 0; i < count; i++) {
1474 d = WMGetFromPLArray(value, i);
1475 if (!d || !WMIsPLString(d)) {
1476 count = i;
1477 break;
1479 len += strlen(WMGetFromPLString(d)) + 1;
1482 ptr = data = wmalloc(len + 1);
1484 for (i = 0; i < count; i++) {
1485 d = WMGetFromPLArray(value, i);
1486 if (!d || !WMIsPLString(d)) {
1487 break;
1489 strcpy(ptr, WMGetFromPLString(d));
1490 ptr += strlen(WMGetFromPLString(d));
1491 *ptr = ':';
1492 ptr++;
1494 ptr--;
1495 *(ptr--) = 0;
1497 if (*(char **)addr != NULL) {
1498 wfree(*(char **)addr);
1500 *(char **)addr = data;
1502 return True;
1505 static int getEnum(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1507 static signed char data;
1509 data = string2index(entry->plkey, value, entry->default_value, (WOptionEnumeration *) entry->extra_data);
1510 if (data < 0)
1511 return False;
1513 if (ret)
1514 *ret = &data;
1515 if (addr)
1516 *(signed char *)addr = data;
1518 return True;
1522 * (solid <color>)
1523 * (hgradient <color> <color>)
1524 * (vgradient <color> <color>)
1525 * (dgradient <color> <color>)
1526 * (mhgradient <color> <color> ...)
1527 * (mvgradient <color> <color> ...)
1528 * (mdgradient <color> <color> ...)
1529 * (igradient <color1> <color1> <thickness1> <color2> <color2> <thickness2>)
1530 * (tpixmap <file> <color>)
1531 * (spixmap <file> <color>)
1532 * (cpixmap <file> <color>)
1533 * (thgradient <file> <opaqueness> <color> <color>)
1534 * (tvgradient <file> <opaqueness> <color> <color>)
1535 * (tdgradient <file> <opaqueness> <color> <color>)
1536 * (function <lib> <function> ...)
1539 static WTexture *parse_texture(WScreen * scr, WMPropList * pl)
1541 WMPropList *elem;
1542 char *val;
1543 int nelem;
1544 WTexture *texture = NULL;
1546 nelem = WMGetPropListItemCount(pl);
1547 if (nelem < 1)
1548 return NULL;
1550 elem = WMGetFromPLArray(pl, 0);
1551 if (!elem || !WMIsPLString(elem))
1552 return NULL;
1553 val = WMGetFromPLString(elem);
1555 if (strcasecmp(val, "solid") == 0) {
1556 XColor color;
1558 if (nelem != 2)
1559 return NULL;
1561 /* get color */
1563 elem = WMGetFromPLArray(pl, 1);
1564 if (!elem || !WMIsPLString(elem))
1565 return NULL;
1566 val = WMGetFromPLString(elem);
1568 if (!XParseColor(dpy, scr->w_colormap, val, &color)) {
1569 wwarning(_("\"%s\" is not a valid color name"), val);
1570 return NULL;
1573 texture = (WTexture *) wTextureMakeSolid(scr, &color);
1574 } else if (strcasecmp(val, "dgradient") == 0
1575 || strcasecmp(val, "vgradient") == 0 || strcasecmp(val, "hgradient") == 0) {
1576 RColor color1, color2;
1577 XColor xcolor;
1578 int type;
1580 if (nelem != 3) {
1581 wwarning(_("bad number of arguments in gradient specification"));
1582 return NULL;
1585 if (val[0] == 'd' || val[0] == 'D')
1586 type = WTEX_DGRADIENT;
1587 else if (val[0] == 'h' || val[0] == 'H')
1588 type = WTEX_HGRADIENT;
1589 else
1590 type = WTEX_VGRADIENT;
1592 /* get from color */
1593 elem = WMGetFromPLArray(pl, 1);
1594 if (!elem || !WMIsPLString(elem))
1595 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 color1.alpha = 255;
1603 color1.red = xcolor.red >> 8;
1604 color1.green = xcolor.green >> 8;
1605 color1.blue = xcolor.blue >> 8;
1607 /* get to color */
1608 elem = WMGetFromPLArray(pl, 2);
1609 if (!elem || !WMIsPLString(elem)) {
1610 return NULL;
1612 val = WMGetFromPLString(elem);
1614 if (!XParseColor(dpy, scr->w_colormap, val, &xcolor)) {
1615 wwarning(_("\"%s\" is not a valid color name"), val);
1616 return NULL;
1618 color2.alpha = 255;
1619 color2.red = xcolor.red >> 8;
1620 color2.green = xcolor.green >> 8;
1621 color2.blue = xcolor.blue >> 8;
1623 texture = (WTexture *) wTextureMakeGradient(scr, type, &color1, &color2);
1625 } else if (strcasecmp(val, "igradient") == 0) {
1626 RColor colors1[2], colors2[2];
1627 int th1, th2;
1628 XColor xcolor;
1629 int i;
1631 if (nelem != 7) {
1632 wwarning(_("bad number of arguments in gradient specification"));
1633 return NULL;
1636 /* get from color */
1637 for (i = 0; i < 2; i++) {
1638 elem = WMGetFromPLArray(pl, 1 + i);
1639 if (!elem || !WMIsPLString(elem))
1640 return NULL;
1641 val = WMGetFromPLString(elem);
1643 if (!XParseColor(dpy, scr->w_colormap, val, &xcolor)) {
1644 wwarning(_("\"%s\" is not a valid color name"), val);
1645 return NULL;
1647 colors1[i].alpha = 255;
1648 colors1[i].red = xcolor.red >> 8;
1649 colors1[i].green = xcolor.green >> 8;
1650 colors1[i].blue = xcolor.blue >> 8;
1652 elem = WMGetFromPLArray(pl, 3);
1653 if (!elem || !WMIsPLString(elem))
1654 return NULL;
1655 val = WMGetFromPLString(elem);
1656 th1 = atoi(val);
1658 /* get from color */
1659 for (i = 0; i < 2; i++) {
1660 elem = WMGetFromPLArray(pl, 4 + i);
1661 if (!elem || !WMIsPLString(elem))
1662 return NULL;
1663 val = WMGetFromPLString(elem);
1665 if (!XParseColor(dpy, scr->w_colormap, val, &xcolor)) {
1666 wwarning(_("\"%s\" is not a valid color name"), val);
1667 return NULL;
1669 colors2[i].alpha = 255;
1670 colors2[i].red = xcolor.red >> 8;
1671 colors2[i].green = xcolor.green >> 8;
1672 colors2[i].blue = xcolor.blue >> 8;
1674 elem = WMGetFromPLArray(pl, 6);
1675 if (!elem || !WMIsPLString(elem))
1676 return NULL;
1677 val = WMGetFromPLString(elem);
1678 th2 = atoi(val);
1680 texture = (WTexture *) wTextureMakeIGradient(scr, th1, colors1, th2, colors2);
1682 } else if (strcasecmp(val, "mhgradient") == 0
1683 || strcasecmp(val, "mvgradient") == 0 || strcasecmp(val, "mdgradient") == 0) {
1684 XColor color;
1685 RColor **colors;
1686 int i, count;
1687 int type;
1689 if (nelem < 3) {
1690 wwarning(_("too few arguments in multicolor gradient specification"));
1691 return NULL;
1694 if (val[1] == 'h' || val[1] == 'H')
1695 type = WTEX_MHGRADIENT;
1696 else if (val[1] == 'v' || val[1] == 'V')
1697 type = WTEX_MVGRADIENT;
1698 else
1699 type = WTEX_MDGRADIENT;
1701 count = nelem - 1;
1703 colors = wmalloc(sizeof(RColor *) * (count + 1));
1705 for (i = 0; i < count; i++) {
1706 elem = WMGetFromPLArray(pl, i + 1);
1707 if (!elem || !WMIsPLString(elem)) {
1708 for (--i; i >= 0; --i) {
1709 wfree(colors[i]);
1711 wfree(colors);
1712 return NULL;
1714 val = WMGetFromPLString(elem);
1716 if (!XParseColor(dpy, scr->w_colormap, val, &color)) {
1717 wwarning(_("\"%s\" is not a valid color name"), val);
1718 for (--i; i >= 0; --i) {
1719 wfree(colors[i]);
1721 wfree(colors);
1722 return NULL;
1723 } else {
1724 colors[i] = wmalloc(sizeof(RColor));
1725 colors[i]->red = color.red >> 8;
1726 colors[i]->green = color.green >> 8;
1727 colors[i]->blue = color.blue >> 8;
1730 colors[i] = NULL;
1732 texture = (WTexture *) wTextureMakeMGradient(scr, type, colors);
1733 } else if (strcasecmp(val, "spixmap") == 0 ||
1734 strcasecmp(val, "cpixmap") == 0 || strcasecmp(val, "tpixmap") == 0) {
1735 XColor color;
1736 int type;
1738 if (nelem != 3)
1739 return NULL;
1741 if (val[0] == 's' || val[0] == 'S')
1742 type = WTP_SCALE;
1743 else if (val[0] == 'c' || val[0] == 'C')
1744 type = WTP_CENTER;
1745 else
1746 type = WTP_TILE;
1748 /* get color */
1749 elem = WMGetFromPLArray(pl, 2);
1750 if (!elem || !WMIsPLString(elem)) {
1751 return NULL;
1753 val = WMGetFromPLString(elem);
1755 if (!XParseColor(dpy, scr->w_colormap, val, &color)) {
1756 wwarning(_("\"%s\" is not a valid color name"), val);
1757 return NULL;
1760 /* file name */
1761 elem = WMGetFromPLArray(pl, 1);
1762 if (!elem || !WMIsPLString(elem))
1763 return NULL;
1764 val = WMGetFromPLString(elem);
1766 texture = (WTexture *) wTextureMakePixmap(scr, type, val, &color);
1767 } else if (strcasecmp(val, "thgradient") == 0
1768 || strcasecmp(val, "tvgradient") == 0 || strcasecmp(val, "tdgradient") == 0) {
1769 RColor color1, color2;
1770 XColor xcolor;
1771 int opacity;
1772 int style;
1774 if (val[1] == 'h' || val[1] == 'H')
1775 style = WTEX_THGRADIENT;
1776 else if (val[1] == 'v' || val[1] == 'V')
1777 style = WTEX_TVGRADIENT;
1778 else
1779 style = WTEX_TDGRADIENT;
1781 if (nelem != 5) {
1782 wwarning(_("bad number of arguments in textured gradient specification"));
1783 return NULL;
1786 /* get from color */
1787 elem = WMGetFromPLArray(pl, 3);
1788 if (!elem || !WMIsPLString(elem))
1789 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 color1.alpha = 255;
1797 color1.red = xcolor.red >> 8;
1798 color1.green = xcolor.green >> 8;
1799 color1.blue = xcolor.blue >> 8;
1801 /* get to color */
1802 elem = WMGetFromPLArray(pl, 4);
1803 if (!elem || !WMIsPLString(elem)) {
1804 return NULL;
1806 val = WMGetFromPLString(elem);
1808 if (!XParseColor(dpy, scr->w_colormap, val, &xcolor)) {
1809 wwarning(_("\"%s\" is not a valid color name"), val);
1810 return NULL;
1812 color2.alpha = 255;
1813 color2.red = xcolor.red >> 8;
1814 color2.green = xcolor.green >> 8;
1815 color2.blue = xcolor.blue >> 8;
1817 /* get opacity */
1818 elem = WMGetFromPLArray(pl, 2);
1819 if (!elem || !WMIsPLString(elem))
1820 opacity = 128;
1821 else
1822 val = WMGetFromPLString(elem);
1824 if (!val || (opacity = atoi(val)) < 0 || opacity > 255) {
1825 wwarning(_("bad opacity value for tgradient texture \"%s\". Should be [0..255]"), val);
1826 opacity = 128;
1829 /* get file name */
1830 elem = WMGetFromPLArray(pl, 1);
1831 if (!elem || !WMIsPLString(elem))
1832 return NULL;
1833 val = WMGetFromPLString(elem);
1835 texture = (WTexture *) wTextureMakeTGradient(scr, style, &color1, &color2, val, opacity);
1836 } else if (strcasecmp(val, "function") == 0) {
1837 /* Leave this in to handle the unlikely case of
1838 * someone actually having function textures configured */
1839 wwarning("function texture support has been removed");
1840 return NULL;
1841 } else {
1842 wwarning(_("invalid texture type %s"), val);
1843 return NULL;
1845 return texture;
1848 static int getTexture(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1850 static WTexture *texture;
1851 int changed = 0;
1853 again:
1854 if (!WMIsPLArray(value)) {
1855 wwarning(_("Wrong option format for key \"%s\". Should be %s."), entry->key, "Texture");
1856 if (changed == 0) {
1857 value = entry->plvalue;
1858 changed = 1;
1859 wwarning(_("using default \"%s\" instead"), entry->default_value);
1860 goto again;
1862 return False;
1865 if (strcmp(entry->key, "WidgetColor") == 0 && !changed) {
1866 WMPropList *pl;
1868 pl = WMGetFromPLArray(value, 0);
1869 if (!pl || !WMIsPLString(pl) || !WMGetFromPLString(pl)
1870 || strcasecmp(WMGetFromPLString(pl), "solid") != 0) {
1871 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1872 entry->key, "Solid Texture");
1874 value = entry->plvalue;
1875 changed = 1;
1876 wwarning(_("using default \"%s\" instead"), entry->default_value);
1877 goto again;
1881 texture = parse_texture(scr, value);
1883 if (!texture) {
1884 wwarning(_("Error in texture specification for key \"%s\""), entry->key);
1885 if (changed == 0) {
1886 value = entry->plvalue;
1887 changed = 1;
1888 wwarning(_("using default \"%s\" instead"), entry->default_value);
1889 goto again;
1891 return False;
1894 if (ret)
1895 *ret = &texture;
1897 if (addr)
1898 *(WTexture **) addr = texture;
1900 return True;
1903 static int getWSBackground(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1905 WMPropList *elem;
1906 int changed = 0;
1907 char *val;
1908 int nelem;
1910 again:
1911 if (!WMIsPLArray(value)) {
1912 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1913 "WorkspaceBack", "Texture or None");
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;
1923 /* only do basic error checking and verify for None texture */
1925 nelem = WMGetPropListItemCount(value);
1926 if (nelem > 0) {
1927 elem = WMGetFromPLArray(value, 0);
1928 if (!elem || !WMIsPLString(elem)) {
1929 wwarning(_("Wrong type for workspace background. Should be a texture type."));
1930 if (changed == 0) {
1931 value = entry->plvalue;
1932 changed = 1;
1933 wwarning(_("using default \"%s\" instead"), entry->default_value);
1934 goto again;
1936 return False;
1938 val = WMGetFromPLString(elem);
1940 if (strcasecmp(val, "None") == 0)
1941 return True;
1943 *ret = WMRetainPropList(value);
1945 return True;
1948 static int
1949 getWSSpecificBackground(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1951 WMPropList *elem;
1952 int nelem;
1953 int changed = 0;
1955 again:
1956 if (!WMIsPLArray(value)) {
1957 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1958 "WorkspaceSpecificBack", "an array of textures");
1959 if (changed == 0) {
1960 value = entry->plvalue;
1961 changed = 1;
1962 wwarning(_("using default \"%s\" instead"), entry->default_value);
1963 goto again;
1965 return False;
1968 /* only do basic error checking and verify for None texture */
1970 nelem = WMGetPropListItemCount(value);
1971 if (nelem > 0) {
1972 while (nelem--) {
1973 elem = WMGetFromPLArray(value, nelem);
1974 if (!elem || !WMIsPLArray(elem)) {
1975 wwarning(_("Wrong type for background of workspace %i. Should be a texture."),
1976 nelem);
1981 *ret = WMRetainPropList(value);
1983 #ifdef notworking
1985 * Kluge to force wmsetbg helper to set the default background.
1986 * If the WorkspaceSpecificBack is changed once wmaker has started,
1987 * the WorkspaceBack won't be sent to the helper, unless the user
1988 * changes it's value too. So, we must force this by removing the
1989 * value from the defaults DB.
1991 if (!scr->flags.backimage_helper_launched && !scr->flags.startup) {
1992 WMPropList *key = WMCreatePLString("WorkspaceBack");
1994 WMRemoveFromPLDictionary(WDWindowMaker->dictionary, key);
1996 WMReleasePropList(key);
1998 #endif
1999 return True;
2002 static int getFont(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
2004 static WMFont *font;
2005 char *val;
2007 GET_STRING_OR_DEFAULT("Font", val);
2009 font = WMCreateFont(scr->wmscreen, val);
2010 if (!font)
2011 font = WMCreateFont(scr->wmscreen, "fixed");
2013 if (!font) {
2014 wfatal(_("could not load any usable font!!!"));
2015 exit(1);
2018 if (ret)
2019 *ret = font;
2021 /* can't assign font value outside update function */
2022 wassertrv(addr == NULL, True);
2024 return True;
2027 static int getColor(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
2029 static XColor color;
2030 char *val;
2031 int second_pass = 0;
2033 GET_STRING_OR_DEFAULT("Color", val);
2035 again:
2036 if (!wGetColor(scr, val, &color)) {
2037 wwarning(_("could not get color for key \"%s\""), entry->key);
2038 if (second_pass == 0) {
2039 val = WMGetFromPLString(entry->plvalue);
2040 second_pass = 1;
2041 wwarning(_("using default \"%s\" instead"), val);
2042 goto again;
2044 return False;
2047 if (ret)
2048 *ret = &color;
2050 assert(addr == NULL);
2052 if (addr)
2053 *(unsigned long*)addr = pixel;
2056 return True;
2059 static int getKeybind(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
2061 static WShortKey shortcut;
2062 KeySym ksym;
2063 char *val;
2064 char *k;
2065 char buf[MAX_SHORTCUT_LENGTH], *b;
2067 GET_STRING_OR_DEFAULT("Key spec", val);
2069 if (!val || strcasecmp(val, "NONE") == 0) {
2070 shortcut.keycode = 0;
2071 shortcut.modifier = 0;
2072 if (ret)
2073 *ret = &shortcut;
2074 return True;
2077 wstrlcpy(buf, val, MAX_SHORTCUT_LENGTH);
2079 b = (char *)buf;
2081 /* get modifiers */
2082 shortcut.modifier = 0;
2083 while ((k = strchr(b, '+')) != NULL) {
2084 int mod;
2086 *k = 0;
2087 mod = wXModifierFromKey(b);
2088 if (mod < 0) {
2089 wwarning(_("%s: invalid key modifier \"%s\""), entry->key, b);
2090 return False;
2092 shortcut.modifier |= mod;
2094 b = k + 1;
2097 /* get key */
2098 ksym = XStringToKeysym(b);
2100 if (ksym == NoSymbol) {
2101 wwarning(_("%s:invalid kbd shortcut specification \"%s\""), entry->key, val);
2102 return False;
2105 shortcut.keycode = XKeysymToKeycode(dpy, ksym);
2106 if (shortcut.keycode == 0) {
2107 wwarning(_("%s:invalid key in shortcut \"%s\""), entry->key, val);
2108 return False;
2111 if (ret)
2112 *ret = &shortcut;
2114 return True;
2117 static int getModMask(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
2119 static int mask;
2120 char *str;
2122 GET_STRING_OR_DEFAULT("Modifier Key", str);
2124 if (!str)
2125 return False;
2127 mask = wXModifierFromKey(str);
2128 if (mask < 0) {
2129 wwarning(_("%s: modifier key %s is not valid"), entry->key, str);
2130 mask = 0;
2131 return False;
2134 if (addr)
2135 *(int *)addr = mask;
2137 if (ret)
2138 *ret = &mask;
2140 return True;
2143 # include <X11/cursorfont.h>
2144 typedef struct {
2145 char *name;
2146 int id;
2147 } WCursorLookup;
2149 #define CURSOR_ID_NONE (XC_num_glyphs)
2151 static WCursorLookup cursor_table[] = {
2152 {"X_cursor", XC_X_cursor},
2153 {"arrow", XC_arrow},
2154 {"based_arrow_down", XC_based_arrow_down},
2155 {"based_arrow_up", XC_based_arrow_up},
2156 {"boat", XC_boat},
2157 {"bogosity", XC_bogosity},
2158 {"bottom_left_corner", XC_bottom_left_corner},
2159 {"bottom_right_corner", XC_bottom_right_corner},
2160 {"bottom_side", XC_bottom_side},
2161 {"bottom_tee", XC_bottom_tee},
2162 {"box_spiral", XC_box_spiral},
2163 {"center_ptr", XC_center_ptr},
2164 {"circle", XC_circle},
2165 {"clock", XC_clock},
2166 {"coffee_mug", XC_coffee_mug},
2167 {"cross", XC_cross},
2168 {"cross_reverse", XC_cross_reverse},
2169 {"crosshair", XC_crosshair},
2170 {"diamond_cross", XC_diamond_cross},
2171 {"dot", XC_dot},
2172 {"dotbox", XC_dotbox},
2173 {"double_arrow", XC_double_arrow},
2174 {"draft_large", XC_draft_large},
2175 {"draft_small", XC_draft_small},
2176 {"draped_box", XC_draped_box},
2177 {"exchange", XC_exchange},
2178 {"fleur", XC_fleur},
2179 {"gobbler", XC_gobbler},
2180 {"gumby", XC_gumby},
2181 {"hand1", XC_hand1},
2182 {"hand2", XC_hand2},
2183 {"heart", XC_heart},
2184 {"icon", XC_icon},
2185 {"iron_cross", XC_iron_cross},
2186 {"left_ptr", XC_left_ptr},
2187 {"left_side", XC_left_side},
2188 {"left_tee", XC_left_tee},
2189 {"leftbutton", XC_leftbutton},
2190 {"ll_angle", XC_ll_angle},
2191 {"lr_angle", XC_lr_angle},
2192 {"man", XC_man},
2193 {"middlebutton", XC_middlebutton},
2194 {"mouse", XC_mouse},
2195 {"pencil", XC_pencil},
2196 {"pirate", XC_pirate},
2197 {"plus", XC_plus},
2198 {"question_arrow", XC_question_arrow},
2199 {"right_ptr", XC_right_ptr},
2200 {"right_side", XC_right_side},
2201 {"right_tee", XC_right_tee},
2202 {"rightbutton", XC_rightbutton},
2203 {"rtl_logo", XC_rtl_logo},
2204 {"sailboat", XC_sailboat},
2205 {"sb_down_arrow", XC_sb_down_arrow},
2206 {"sb_h_double_arrow", XC_sb_h_double_arrow},
2207 {"sb_left_arrow", XC_sb_left_arrow},
2208 {"sb_right_arrow", XC_sb_right_arrow},
2209 {"sb_up_arrow", XC_sb_up_arrow},
2210 {"sb_v_double_arrow", XC_sb_v_double_arrow},
2211 {"shuttle", XC_shuttle},
2212 {"sizing", XC_sizing},
2213 {"spider", XC_spider},
2214 {"spraycan", XC_spraycan},
2215 {"star", XC_star},
2216 {"target", XC_target},
2217 {"tcross", XC_tcross},
2218 {"top_left_arrow", XC_top_left_arrow},
2219 {"top_left_corner", XC_top_left_corner},
2220 {"top_right_corner", XC_top_right_corner},
2221 {"top_side", XC_top_side},
2222 {"top_tee", XC_top_tee},
2223 {"trek", XC_trek},
2224 {"ul_angle", XC_ul_angle},
2225 {"umbrella", XC_umbrella},
2226 {"ur_angle", XC_ur_angle},
2227 {"watch", XC_watch},
2228 {"xterm", XC_xterm},
2229 {NULL, CURSOR_ID_NONE}
2232 static void check_bitmap_status(int status, char *filename, Pixmap bitmap)
2234 switch (status) {
2235 case BitmapOpenFailed:
2236 wwarning(_("failed to open bitmap file \"%s\""), filename);
2237 break;
2238 case BitmapFileInvalid:
2239 wwarning(_("\"%s\" is not a valid bitmap file"), filename);
2240 break;
2241 case BitmapNoMemory:
2242 wwarning(_("out of memory reading bitmap file \"%s\""), filename);
2243 break;
2244 case BitmapSuccess:
2245 XFreePixmap(dpy, bitmap);
2246 break;
2251 * (none)
2252 * (builtin, <cursor_name>)
2253 * (bitmap, <cursor_bitmap>, <cursor_mask>)
2255 static int parse_cursor(WScreen * scr, WMPropList * pl, Cursor * cursor)
2257 WMPropList *elem;
2258 char *val;
2259 int nelem;
2260 int status = 0;
2262 nelem = WMGetPropListItemCount(pl);
2263 if (nelem < 1) {
2264 return (status);
2266 elem = WMGetFromPLArray(pl, 0);
2267 if (!elem || !WMIsPLString(elem)) {
2268 return (status);
2270 val = WMGetFromPLString(elem);
2272 if (strcasecmp(val, "none") == 0) {
2273 status = 1;
2274 *cursor = None;
2275 } else if (strcasecmp(val, "builtin") == 0) {
2276 int i;
2277 int cursor_id = CURSOR_ID_NONE;
2279 if (nelem != 2) {
2280 wwarning(_("bad number of arguments in cursor specification"));
2281 return (status);
2283 elem = WMGetFromPLArray(pl, 1);
2284 if (!elem || !WMIsPLString(elem)) {
2285 return (status);
2287 val = WMGetFromPLString(elem);
2289 for (i = 0; cursor_table[i].name != NULL; i++) {
2290 if (strcasecmp(val, cursor_table[i].name) == 0) {
2291 cursor_id = cursor_table[i].id;
2292 break;
2295 if (CURSOR_ID_NONE == cursor_id) {
2296 wwarning(_("unknown builtin cursor name \"%s\""), val);
2297 } else {
2298 *cursor = XCreateFontCursor(dpy, cursor_id);
2299 status = 1;
2301 } else if (strcasecmp(val, "bitmap") == 0) {
2302 char *bitmap_name;
2303 char *mask_name;
2304 int bitmap_status;
2305 int mask_status;
2306 Pixmap bitmap;
2307 Pixmap mask;
2308 unsigned int w, h;
2309 int x, y;
2310 XColor fg, bg;
2312 if (nelem != 3) {
2313 wwarning(_("bad number of arguments in cursor specification"));
2314 return (status);
2316 elem = WMGetFromPLArray(pl, 1);
2317 if (!elem || !WMIsPLString(elem)) {
2318 return (status);
2320 val = WMGetFromPLString(elem);
2321 bitmap_name = FindImage(wPreferences.pixmap_path, val);
2322 if (!bitmap_name) {
2323 wwarning(_("could not find cursor bitmap file \"%s\""), val);
2324 return (status);
2326 elem = WMGetFromPLArray(pl, 2);
2327 if (!elem || !WMIsPLString(elem)) {
2328 wfree(bitmap_name);
2329 return (status);
2331 val = WMGetFromPLString(elem);
2332 mask_name = FindImage(wPreferences.pixmap_path, val);
2333 if (!mask_name) {
2334 wfree(bitmap_name);
2335 wwarning(_("could not find cursor bitmap file \"%s\""), val);
2336 return (status);
2338 mask_status = XReadBitmapFile(dpy, scr->w_win, mask_name, &w, &h, &mask, &x, &y);
2339 bitmap_status = XReadBitmapFile(dpy, scr->w_win, bitmap_name, &w, &h, &bitmap, &x, &y);
2340 if ((BitmapSuccess == bitmap_status) && (BitmapSuccess == mask_status)) {
2341 fg.pixel = scr->black_pixel;
2342 bg.pixel = scr->white_pixel;
2343 XQueryColor(dpy, scr->w_colormap, &fg);
2344 XQueryColor(dpy, scr->w_colormap, &bg);
2345 *cursor = XCreatePixmapCursor(dpy, bitmap, mask, &fg, &bg, x, y);
2346 status = 1;
2348 check_bitmap_status(bitmap_status, bitmap_name, bitmap);
2349 check_bitmap_status(mask_status, mask_name, mask);
2350 wfree(bitmap_name);
2351 wfree(mask_name);
2353 return (status);
2356 static int getCursor(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
2358 static Cursor cursor;
2359 int status;
2360 int changed = 0;
2362 again:
2363 if (!WMIsPLArray(value)) {
2364 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
2365 entry->key, "cursor specification");
2366 if (!changed) {
2367 value = entry->plvalue;
2368 changed = 1;
2369 wwarning(_("using default \"%s\" instead"), entry->default_value);
2370 goto again;
2372 return (False);
2374 status = parse_cursor(scr, value, &cursor);
2375 if (!status) {
2376 wwarning(_("Error in cursor specification for key \"%s\""), entry->key);
2377 if (!changed) {
2378 value = entry->plvalue;
2379 changed = 1;
2380 wwarning(_("using default \"%s\" instead"), entry->default_value);
2381 goto again;
2383 return (False);
2385 if (ret) {
2386 *ret = &cursor;
2388 if (addr) {
2389 *(Cursor *) addr = cursor;
2391 return (True);
2394 #undef CURSOR_ID_NONE
2396 /* ---------------- value setting functions --------------- */
2397 static int setJustify(WScreen * scr, WDefaultEntry * entry, WTexture ** texture, void *foo)
2399 return REFRESH_WINDOW_TITLE_COLOR;
2402 static int setClearance(WScreen * scr, WDefaultEntry * entry, void *bar, void *foo)
2404 return REFRESH_WINDOW_FONT | REFRESH_BUTTON_IMAGES | REFRESH_MENU_TITLE_FONT | REFRESH_MENU_FONT;
2407 static int setIfDockPresent(WScreen * scr, WDefaultEntry * entry, char *flag, long which)
2409 switch (which) {
2410 case WM_DOCK:
2411 wPreferences.flags.nodock = wPreferences.flags.nodock || *flag;
2412 // Drawers require the dock
2413 wPreferences.flags.nodrawer = wPreferences.flags.nodrawer || wPreferences.flags.nodock;
2414 break;
2415 case WM_CLIP:
2416 wPreferences.flags.noclip = wPreferences.flags.noclip || *flag;
2417 break;
2418 case WM_DRAWER:
2419 wPreferences.flags.nodrawer = wPreferences.flags.nodrawer || *flag;
2420 break;
2421 default:
2422 break;
2424 return 0;
2427 static int setClipMergedInDock(WScreen *scr, WDefaultEntry *entry, char *flag, void *foo)
2429 wPreferences.flags.clip_merged_in_dock = *flag;
2430 wPreferences.flags.noclip = wPreferences.flags.noclip || *flag;
2431 return 0;
2434 static int setWrapAppiconsInDock(WScreen *scr, WDefaultEntry *entry, char *flag, void *foo)
2436 wPreferences.flags.wrap_appicons_in_dock = *flag;
2437 return 0;
2440 static int setStickyIcons(WScreen * scr, WDefaultEntry * entry, void *bar, void *foo)
2442 if (scr->workspaces) {
2443 wWorkspaceForceChange(scr, scr->current_workspace);
2444 wArrangeIcons(scr, False);
2446 return 0;
2449 static int setIconTile(WScreen * scr, WDefaultEntry * entry, WTexture ** texture, void *foo)
2451 Pixmap pixmap;
2452 RImage *img;
2453 int reset = 0;
2455 img = wTextureRenderImage(*texture, wPreferences.icon_size,
2456 wPreferences.icon_size, ((*texture)->any.type & WREL_BORDER_MASK)
2457 ? WREL_ICON : WREL_FLAT);
2458 if (!img) {
2459 wwarning(_("could not render texture for icon background"));
2460 if (!entry->addr)
2461 wTextureDestroy(scr, *texture);
2462 return 0;
2464 RConvertImage(scr->rcontext, img, &pixmap);
2466 if (scr->icon_tile) {
2467 reset = 1;
2468 RReleaseImage(scr->icon_tile);
2469 XFreePixmap(dpy, scr->icon_tile_pixmap);
2472 scr->icon_tile = img;
2474 /* put the icon in the noticeboard hint */
2475 PropSetIconTileHint(scr, img);
2477 if (!wPreferences.flags.noclip || wPreferences.flags.clip_merged_in_dock) {
2478 if (scr->clip_tile) {
2479 RReleaseImage(scr->clip_tile);
2481 scr->clip_tile = wClipMakeTile(scr, img);
2484 if (!wPreferences.flags.nodrawer) {
2485 if (scr->drawer_tile) {
2486 RReleaseImage(scr->drawer_tile);
2488 scr->drawer_tile = wDrawerMakeTile(scr, img);
2491 scr->icon_tile_pixmap = pixmap;
2493 if (scr->def_icon_rimage) {
2494 RReleaseImage(scr->def_icon_rimage);
2495 scr->def_icon_rimage = NULL;
2498 if (scr->icon_back_texture)
2499 wTextureDestroy(scr, (WTexture *) scr->icon_back_texture);
2501 scr->icon_back_texture = wTextureMakeSolid(scr, &((*texture)->any.color));
2503 /* Free the texture as nobody else will use it, nor refer to it. */
2504 if (!entry->addr)
2505 wTextureDestroy(scr, *texture);
2507 return (reset ? REFRESH_ICON_TILE : 0);
2510 static int setWinTitleFont(WScreen * scr, WDefaultEntry * entry, WMFont * font, void *foo)
2512 if (scr->title_font) {
2513 WMReleaseFont(scr->title_font);
2515 scr->title_font = font;
2517 return REFRESH_WINDOW_FONT | REFRESH_BUTTON_IMAGES;
2520 static int setMenuTitleFont(WScreen * scr, WDefaultEntry * entry, WMFont * font, void *foo)
2522 if (scr->menu_title_font) {
2523 WMReleaseFont(scr->menu_title_font);
2526 scr->menu_title_font = font;
2528 return REFRESH_MENU_TITLE_FONT;
2531 static int setMenuTextFont(WScreen * scr, WDefaultEntry * entry, WMFont * font, void *foo)
2533 if (scr->menu_entry_font) {
2534 WMReleaseFont(scr->menu_entry_font);
2536 scr->menu_entry_font = font;
2538 return REFRESH_MENU_FONT;
2541 static int setIconTitleFont(WScreen * scr, WDefaultEntry * entry, WMFont * font, void *foo)
2543 if (scr->icon_title_font) {
2544 WMReleaseFont(scr->icon_title_font);
2547 scr->icon_title_font = font;
2549 return REFRESH_ICON_FONT;
2552 static int setClipTitleFont(WScreen * scr, WDefaultEntry * entry, WMFont * font, void *foo)
2554 if (scr->clip_title_font) {
2555 WMReleaseFont(scr->clip_title_font);
2558 scr->clip_title_font = font;
2560 return REFRESH_ICON_FONT;
2563 static int setLargeDisplayFont(WScreen * scr, WDefaultEntry * entry, WMFont * font, void *foo)
2565 if (scr->workspace_name_font) {
2566 WMReleaseFont(scr->workspace_name_font);
2569 scr->workspace_name_font = font;
2571 return 0;
2574 static int setHightlight(WScreen * scr, WDefaultEntry * entry, XColor * color, void *foo)
2576 if (scr->select_color)
2577 WMReleaseColor(scr->select_color);
2579 scr->select_color = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2581 wFreeColor(scr, color->pixel);
2583 return REFRESH_MENU_COLOR;
2586 static int setHightlightText(WScreen * scr, WDefaultEntry * entry, XColor * color, void *foo)
2588 if (scr->select_text_color)
2589 WMReleaseColor(scr->select_text_color);
2591 scr->select_text_color = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2593 wFreeColor(scr, color->pixel);
2595 return REFRESH_MENU_COLOR;
2598 static int setClipTitleColor(WScreen * scr, WDefaultEntry * entry, XColor * color, long widx)
2600 if (scr->clip_title_color[widx])
2601 WMReleaseColor(scr->clip_title_color[widx]);
2603 scr->clip_title_color[widx] = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2604 wFreeColor(scr, color->pixel);
2606 return REFRESH_ICON_TITLE_COLOR;
2609 static int setWTitleColor(WScreen * scr, WDefaultEntry * entry, XColor * color, long widx)
2611 if (scr->window_title_color[widx])
2612 WMReleaseColor(scr->window_title_color[widx]);
2614 scr->window_title_color[widx] =
2615 WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2617 wFreeColor(scr, color->pixel);
2619 return REFRESH_WINDOW_TITLE_COLOR;
2622 static int setMenuTitleColor(WScreen * scr, WDefaultEntry * entry, XColor * color, long widx)
2624 if (scr->menu_title_color[0])
2625 WMReleaseColor(scr->menu_title_color[0]);
2627 scr->menu_title_color[0] = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2629 wFreeColor(scr, color->pixel);
2631 return REFRESH_MENU_TITLE_COLOR;
2634 static int setMenuTextColor(WScreen * scr, WDefaultEntry * entry, XColor * color, void *foo)
2636 if (scr->mtext_color)
2637 WMReleaseColor(scr->mtext_color);
2639 scr->mtext_color = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2641 if (WMColorPixel(scr->dtext_color) == WMColorPixel(scr->mtext_color)) {
2642 WMSetColorAlpha(scr->dtext_color, 0x7fff);
2643 } else {
2644 WMSetColorAlpha(scr->dtext_color, 0xffff);
2647 wFreeColor(scr, color->pixel);
2649 return REFRESH_MENU_COLOR;
2652 static int setMenuDisabledColor(WScreen * scr, WDefaultEntry * entry, XColor * color, void *foo)
2654 if (scr->dtext_color)
2655 WMReleaseColor(scr->dtext_color);
2657 scr->dtext_color = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2659 if (WMColorPixel(scr->dtext_color) == WMColorPixel(scr->mtext_color)) {
2660 WMSetColorAlpha(scr->dtext_color, 0x7fff);
2661 } else {
2662 WMSetColorAlpha(scr->dtext_color, 0xffff);
2665 wFreeColor(scr, color->pixel);
2667 return REFRESH_MENU_COLOR;
2670 static int setIconTitleColor(WScreen * scr, WDefaultEntry * entry, XColor * color, void *foo)
2672 if (scr->icon_title_color)
2673 WMReleaseColor(scr->icon_title_color);
2674 scr->icon_title_color = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2676 wFreeColor(scr, color->pixel);
2678 return REFRESH_ICON_TITLE_COLOR;
2681 static int setIconTitleBack(WScreen * scr, WDefaultEntry * entry, XColor * color, void *foo)
2683 if (scr->icon_title_texture) {
2684 wTextureDestroy(scr, (WTexture *) scr->icon_title_texture);
2686 scr->icon_title_texture = wTextureMakeSolid(scr, color);
2688 return REFRESH_ICON_TITLE_BACK;
2691 static int setFrameBorderWidth(WScreen * scr, WDefaultEntry * entry, int * value, void *foo)
2693 scr->frame_border_width = *value;
2695 return REFRESH_FRAME_BORDER;
2698 static int setFrameBorderColor(WScreen * scr, WDefaultEntry * entry, XColor * color, void *foo)
2700 if (scr->frame_border_color)
2701 WMReleaseColor(scr->frame_border_color);
2702 scr->frame_border_color = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2704 wFreeColor(scr, color->pixel);
2706 return REFRESH_FRAME_BORDER;
2709 static int setFrameSelectedBorderColor(WScreen * scr, WDefaultEntry * entry, XColor * color, void *foo)
2711 if (scr->frame_selected_border_color)
2712 WMReleaseColor(scr->frame_selected_border_color);
2713 scr->frame_selected_border_color = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2715 wFreeColor(scr, color->pixel);
2717 return REFRESH_FRAME_BORDER;
2720 static void trackDeadProcess(pid_t pid, unsigned char status, WScreen * scr)
2722 close(scr->helper_fd);
2723 scr->helper_fd = 0;
2724 scr->helper_pid = 0;
2725 scr->flags.backimage_helper_launched = 0;
2728 static int setWorkspaceSpecificBack(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *bar)
2730 WMPropList *val;
2731 char *str;
2732 int i;
2734 if (scr->flags.backimage_helper_launched) {
2735 if (WMGetPropListItemCount(value) == 0) {
2736 SendHelperMessage(scr, 'C', 0, NULL);
2737 SendHelperMessage(scr, 'K', 0, NULL);
2739 WMReleasePropList(value);
2740 return 0;
2742 } else {
2743 pid_t pid;
2744 int filedes[2];
2746 if (WMGetPropListItemCount(value) == 0)
2747 return 0;
2749 if (pipe(filedes) < 0) {
2750 werror("pipe() failed:can't set workspace specific background image");
2752 WMReleasePropList(value);
2753 return 0;
2756 pid = fork();
2757 if (pid < 0) {
2758 werror("fork() failed:can't set workspace specific background image");
2759 if (close(filedes[0]) < 0)
2760 werror("could not close pipe");
2761 if (close(filedes[1]) < 0)
2762 werror("could not close pipe");
2764 } else if (pid == 0) {
2765 char *dither;
2767 SetupEnvironment(scr);
2769 if (close(0) < 0)
2770 werror("could not close pipe");
2771 if (dup(filedes[0]) < 0) {
2772 werror("dup() failed:can't set workspace specific background image");
2774 dither = wPreferences.no_dithering ? "-m" : "-d";
2775 if (wPreferences.smooth_workspace_back)
2776 execlp("wmsetbg", "wmsetbg", "-helper", "-S", dither, NULL);
2777 else
2778 execlp("wmsetbg", "wmsetbg", "-helper", dither, NULL);
2779 werror("could not execute wmsetbg");
2780 exit(1);
2781 } else {
2783 if (fcntl(filedes[0], F_SETFD, FD_CLOEXEC) < 0) {
2784 werror("error setting close-on-exec flag");
2786 if (fcntl(filedes[1], F_SETFD, FD_CLOEXEC) < 0) {
2787 werror("error setting close-on-exec flag");
2790 scr->helper_fd = filedes[1];
2791 scr->helper_pid = pid;
2792 scr->flags.backimage_helper_launched = 1;
2794 wAddDeathHandler(pid, (WDeathHandler *) trackDeadProcess, scr);
2796 SendHelperMessage(scr, 'P', -1, wPreferences.pixmap_path);
2801 for (i = 0; i < WMGetPropListItemCount(value); i++) {
2802 val = WMGetFromPLArray(value, i);
2803 if (val && WMIsPLArray(val) && WMGetPropListItemCount(val) > 0) {
2804 str = WMGetPropListDescription(val, False);
2806 SendHelperMessage(scr, 'S', i + 1, str);
2808 wfree(str);
2809 } else {
2810 SendHelperMessage(scr, 'U', i + 1, NULL);
2813 sleep(1);
2815 WMReleasePropList(value);
2816 return 0;
2819 static int setWorkspaceBack(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *bar)
2821 if (scr->flags.backimage_helper_launched) {
2822 char *str;
2824 if (WMGetPropListItemCount(value) == 0) {
2825 SendHelperMessage(scr, 'U', 0, NULL);
2826 } else {
2827 /* set the default workspace background to this one */
2828 str = WMGetPropListDescription(value, False);
2829 if (str) {
2830 SendHelperMessage(scr, 'S', 0, str);
2831 wfree(str);
2832 SendHelperMessage(scr, 'C', scr->current_workspace + 1, NULL);
2833 } else {
2834 SendHelperMessage(scr, 'U', 0, NULL);
2837 } else if (WMGetPropListItemCount(value) > 0) {
2838 char *command;
2839 char *text;
2840 char *dither;
2841 int len;
2843 text = WMGetPropListDescription(value, False);
2844 len = strlen(text) + 40;
2845 command = wmalloc(len);
2846 dither = wPreferences.no_dithering ? "-m" : "-d";
2847 if (wPreferences.smooth_workspace_back)
2848 snprintf(command, len, "wmsetbg %s -S -p '%s' &", dither, text);
2849 else
2850 snprintf(command, len, "wmsetbg %s -p '%s' &", dither, text);
2851 wfree(text);
2852 ExecuteShellCommand(scr, command);
2853 wfree(command);
2855 WMReleasePropList(value);
2857 return 0;
2860 static int setWidgetColor(WScreen * scr, WDefaultEntry * entry, WTexture ** texture, void *foo)
2862 if (scr->widget_texture) {
2863 wTextureDestroy(scr, (WTexture *) scr->widget_texture);
2865 scr->widget_texture = *(WTexSolid **) texture;
2867 return 0;
2870 static int setFTitleBack(WScreen * scr, WDefaultEntry * entry, WTexture ** texture, void *foo)
2872 if (scr->window_title_texture[WS_FOCUSED]) {
2873 wTextureDestroy(scr, scr->window_title_texture[WS_FOCUSED]);
2875 scr->window_title_texture[WS_FOCUSED] = *texture;
2877 return REFRESH_WINDOW_TEXTURES;
2880 static int setPTitleBack(WScreen * scr, WDefaultEntry * entry, WTexture ** texture, void *foo)
2882 if (scr->window_title_texture[WS_PFOCUSED]) {
2883 wTextureDestroy(scr, scr->window_title_texture[WS_PFOCUSED]);
2885 scr->window_title_texture[WS_PFOCUSED] = *texture;
2887 return REFRESH_WINDOW_TEXTURES;
2890 static int setUTitleBack(WScreen * scr, WDefaultEntry * entry, WTexture ** texture, void *foo)
2892 if (scr->window_title_texture[WS_UNFOCUSED]) {
2893 wTextureDestroy(scr, scr->window_title_texture[WS_UNFOCUSED]);
2895 scr->window_title_texture[WS_UNFOCUSED] = *texture;
2897 return REFRESH_WINDOW_TEXTURES;
2900 static int setResizebarBack(WScreen * scr, WDefaultEntry * entry, WTexture ** texture, void *foo)
2902 if (scr->resizebar_texture[0]) {
2903 wTextureDestroy(scr, scr->resizebar_texture[0]);
2905 scr->resizebar_texture[0] = *texture;
2907 return REFRESH_WINDOW_TEXTURES;
2910 static int setMenuTitleBack(WScreen * scr, WDefaultEntry * entry, WTexture ** texture, void *foo)
2912 if (scr->menu_title_texture[0]) {
2913 wTextureDestroy(scr, scr->menu_title_texture[0]);
2915 scr->menu_title_texture[0] = *texture;
2917 return REFRESH_MENU_TITLE_TEXTURE;
2920 static int setMenuTextBack(WScreen * scr, WDefaultEntry * entry, WTexture ** texture, void *foo)
2922 if (scr->menu_item_texture) {
2923 wTextureDestroy(scr, scr->menu_item_texture);
2924 wTextureDestroy(scr, (WTexture *) scr->menu_item_auxtexture);
2926 scr->menu_item_texture = *texture;
2928 scr->menu_item_auxtexture = wTextureMakeSolid(scr, &scr->menu_item_texture->any.color);
2930 return REFRESH_MENU_TEXTURE;
2933 static int setKeyGrab(WScreen * scr, WDefaultEntry * entry, WShortKey * shortcut, long widx)
2935 WWindow *wwin;
2936 wKeyBindings[widx] = *shortcut;
2938 wwin = scr->focused_window;
2940 while (wwin != NULL) {
2941 XUngrabKey(dpy, AnyKey, AnyModifier, wwin->frame->core->window);
2943 if (!WFLAGP(wwin, no_bind_keys)) {
2944 wWindowSetKeyGrabs(wwin);
2946 wwin = wwin->prev;
2949 /* do we need to update window menus? */
2950 if (widx >= WKBD_WORKSPACE1 && widx <= WKBD_WORKSPACE10)
2951 return REFRESH_WORKSPACE_MENU;
2952 if (widx == WKBD_LASTWORKSPACE)
2953 return REFRESH_WORKSPACE_MENU;
2954 if (widx >= WKBD_MOVE_WORKSPACE1 && widx <= WKBD_MOVE_WORKSPACE10)
2955 return REFRESH_WORKSPACE_MENU;
2957 return 0;
2960 static int setIconPosition(WScreen * scr, WDefaultEntry * entry, void *bar, void *foo)
2962 wScreenUpdateUsableArea(scr);
2963 wArrangeIcons(scr, True);
2965 return 0;
2968 static int updateUsableArea(WScreen * scr, WDefaultEntry * entry, void *bar, void *foo)
2970 wScreenUpdateUsableArea(scr);
2972 return 0;
2975 static int setMenuStyle(WScreen * scr, WDefaultEntry * entry, int *value, void *foo)
2977 return REFRESH_MENU_TEXTURE;
2980 static RImage *chopOffImage(RImage * image, int x, int y, int w, int h)
2982 RImage *img = RCreateImage(w, h, image->format == RRGBAFormat);
2984 RCopyArea(img, image, x, y, w, h, 0, 0);
2986 return img;
2989 static int setSwPOptions(WScreen * scr, WDefaultEntry * entry, WMPropList * array, void *foo)
2991 char *path;
2992 RImage *bgimage;
2993 int cwidth, cheight;
2994 WPreferences *prefs = (WPreferences *) foo;
2996 if (!WMIsPLArray(array) || WMGetPropListItemCount(array) == 0) {
2997 if (prefs->swtileImage)
2998 RReleaseImage(prefs->swtileImage);
2999 prefs->swtileImage = NULL;
3001 WMReleasePropList(array);
3002 return 0;
3005 switch (WMGetPropListItemCount(array)) {
3006 case 4:
3007 if (!WMIsPLString(WMGetFromPLArray(array, 1))) {
3008 wwarning(_("Invalid arguments for option \"%s\""), entry->key);
3009 break;
3010 } else
3011 path = FindImage(wPreferences.pixmap_path, WMGetFromPLString(WMGetFromPLArray(array, 1)));
3013 if (!path) {
3014 wwarning(_("Could not find image \"%s\" for option \"%s\""),
3015 WMGetFromPLString(WMGetFromPLArray(array, 1)), entry->key);
3016 } else {
3017 bgimage = RLoadImage(scr->rcontext, path, 0);
3018 if (!bgimage) {
3019 wwarning(_("Could not load image \"%s\" for option \"%s\""), path, entry->key);
3020 wfree(path);
3021 } else {
3022 wfree(path);
3024 cwidth = atoi(WMGetFromPLString(WMGetFromPLArray(array, 2)));
3025 cheight = atoi(WMGetFromPLString(WMGetFromPLArray(array, 3)));
3027 if (cwidth <= 0 || cheight <= 0 ||
3028 cwidth >= bgimage->width - 2 || cheight >= bgimage->height - 2)
3029 wwarning(_("Invalid split sizes for SwitchPanel back image."));
3030 else {
3031 int i;
3032 int swidth, theight;
3033 for (i = 0; i < 9; i++) {
3034 if (prefs->swbackImage[i])
3035 RReleaseImage(prefs->swbackImage[i]);
3036 prefs->swbackImage[i] = NULL;
3038 swidth = (bgimage->width - cwidth) / 2;
3039 theight = (bgimage->height - cheight) / 2;
3041 prefs->swbackImage[0] = chopOffImage(bgimage, 0, 0, swidth, theight);
3042 prefs->swbackImage[1] = chopOffImage(bgimage, swidth, 0, cwidth, theight);
3043 prefs->swbackImage[2] = chopOffImage(bgimage, swidth + cwidth, 0,
3044 swidth, theight);
3046 prefs->swbackImage[3] = chopOffImage(bgimage, 0, theight, swidth, cheight);
3047 prefs->swbackImage[4] = chopOffImage(bgimage, swidth, theight,
3048 cwidth, cheight);
3049 prefs->swbackImage[5] = chopOffImage(bgimage, swidth + cwidth, theight,
3050 swidth, cheight);
3052 prefs->swbackImage[6] = chopOffImage(bgimage, 0, theight + cheight,
3053 swidth, theight);
3054 prefs->swbackImage[7] = chopOffImage(bgimage, swidth, theight + cheight,
3055 cwidth, theight);
3056 prefs->swbackImage[8] =
3057 chopOffImage(bgimage, swidth + cwidth, theight + cheight, swidth,
3058 theight);
3060 // check if anything failed
3061 for (i = 0; i < 9; i++) {
3062 if (!prefs->swbackImage[i]) {
3063 for (; i >= 0; --i) {
3064 RReleaseImage(prefs->swbackImage[i]);
3065 prefs->swbackImage[i] = NULL;
3067 break;
3071 RReleaseImage(bgimage);
3075 case 1:
3076 if (!WMIsPLString(WMGetFromPLArray(array, 0))) {
3077 wwarning(_("Invalid arguments for option \"%s\""), entry->key);
3078 break;
3079 } else
3080 path = FindImage(wPreferences.pixmap_path, WMGetFromPLString(WMGetFromPLArray(array, 0)));
3082 if (!path) {
3083 wwarning(_("Could not find image \"%s\" for option \"%s\""),
3084 WMGetFromPLString(WMGetFromPLArray(array, 0)), entry->key);
3085 } else {
3086 if (prefs->swtileImage)
3087 RReleaseImage(prefs->swtileImage);
3089 prefs->swtileImage = RLoadImage(scr->rcontext, path, 0);
3090 if (!prefs->swtileImage) {
3091 wwarning(_("Could not load image \"%s\" for option \"%s\""), path, entry->key);
3093 wfree(path);
3095 break;
3097 default:
3098 wwarning(_("Invalid number of arguments for option \"%s\""), entry->key);
3099 break;
3102 WMReleasePropList(array);
3104 return 0;
3107 static int setModifierKeyLabels(WScreen * scr, WDefaultEntry * entry, WMPropList * array, void *foo)
3109 int i;
3110 WPreferences *prefs = (WPreferences *) foo;
3112 if (!WMIsPLArray(array) || WMGetPropListItemCount(array) != 7) {
3113 wwarning(_("Value for option \"%s\" must be an array of 7 strings"), entry->key);
3114 WMReleasePropList(array);
3115 return 0;
3118 DestroyWindowMenu(scr);
3120 for (i = 0; i < 7; i++) {
3121 if (prefs->modifier_labels[i])
3122 wfree(prefs->modifier_labels[i]);
3124 if (WMIsPLString(WMGetFromPLArray(array, i))) {
3125 prefs->modifier_labels[i] = wstrdup(WMGetFromPLString(WMGetFromPLArray(array, i)));
3126 } else {
3127 wwarning(_("Invalid argument for option \"%s\" item %d"), entry->key, i);
3128 prefs->modifier_labels[i] = NULL;
3132 WMReleasePropList(array);
3134 return 0;
3137 static int setDoubleClick(WScreen *scr, WDefaultEntry *entry, int *value, void *foo)
3139 if (*value <= 0)
3140 *(int *)foo = 1;
3142 W_setconf_doubleClickDelay(*value);
3144 return 0;
3147 static int setCursor(WScreen * scr, WDefaultEntry * entry, Cursor * cursor, long widx)
3149 if (wCursor[widx] != None) {
3150 XFreeCursor(dpy, wCursor[widx]);
3153 wCursor[widx] = *cursor;
3155 if (widx == WCUR_ROOT && *cursor != None) {
3156 XDefineCursor(dpy, scr->root_win, *cursor);
3159 return 0;