wmaker: replaced macro by an inline function, in X Modifier initialisation
[wmaker-crm.git] / src / defaults.c
blobb1b5050a81567e0451693eccd0d4cdde990a7343
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
7 * Copyright (c) 2014 Window Maker Team
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License along
21 * with this program; if not, write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 #include "wconfig.h"
27 #include <stdio.h>
28 #include <stdint.h>
29 #include <stdlib.h>
30 #include <unistd.h>
31 #include <string.h>
32 #include <strings.h>
33 #include <ctype.h>
34 #include <time.h>
35 #include <sys/types.h>
36 #include <sys/stat.h>
37 #include <limits.h>
38 #include <signal.h>
40 #ifndef PATH_MAX
41 #define PATH_MAX DEFAULT_PATH_MAX
42 #endif
44 #include <X11/Xlib.h>
45 #include <X11/Xutil.h>
46 #include <X11/keysym.h>
48 #include <wraster.h>
50 #include "WindowMaker.h"
51 #include "framewin.h"
52 #include "window.h"
53 #include "texture.h"
54 #include "screen.h"
55 #include "resources.h"
56 #include "defaults.h"
57 #include "keybind.h"
58 #include "xmodifier.h"
59 #include "icon.h"
60 #include "main.h"
61 #include "actions.h"
62 #include "dock.h"
63 #include "workspace.h"
64 #include "properties.h"
65 #include "misc.h"
66 #include "winmenu.h"
68 #define MAX_SHORTCUT_LENGTH 32
70 #ifndef GLOBAL_DEFAULTS_SUBDIR
71 #define GLOBAL_DEFAULTS_SUBDIR "WindowMaker"
72 #endif
75 typedef struct _WDefaultEntry WDefaultEntry;
76 typedef int (WDECallbackConvert) (WScreen *scr, WDefaultEntry *entry, WMPropList *plvalue, void *addr, void **tdata);
77 typedef int (WDECallbackUpdate) (WScreen *scr, WDefaultEntry *entry, void *tdata, void *extra_data);
79 struct _WDefaultEntry {
80 const char *key;
81 const char *default_value;
82 void *extra_data;
83 void *addr;
84 WDECallbackConvert *convert;
85 WDECallbackUpdate *update;
86 WMPropList *plkey;
87 WMPropList *plvalue; /* default value */
90 /* used to map strings to integers */
91 typedef struct {
92 const char *string;
93 short value;
94 char is_alias;
95 } WOptionEnumeration;
97 /* type converters */
98 static WDECallbackConvert getBool;
99 static WDECallbackConvert getInt;
100 static WDECallbackConvert getCoord;
101 static WDECallbackConvert getPathList;
102 static WDECallbackConvert getEnum;
103 static WDECallbackConvert getTexture;
104 static WDECallbackConvert getWSBackground;
105 static WDECallbackConvert getWSSpecificBackground;
106 static WDECallbackConvert getFont;
107 static WDECallbackConvert getColor;
108 static WDECallbackConvert getKeybind;
109 static WDECallbackConvert getModMask;
110 static WDECallbackConvert getPropList;
112 /* value setting functions */
113 static WDECallbackUpdate setJustify;
114 static WDECallbackUpdate setClearance;
115 static WDECallbackUpdate setIfDockPresent;
116 static WDECallbackUpdate setClipMergedInDock;
117 static WDECallbackUpdate setWrapAppiconsInDock;
118 static WDECallbackUpdate setStickyIcons;
119 static WDECallbackUpdate setWidgetColor;
120 static WDECallbackUpdate setIconTile;
121 static WDECallbackUpdate setWinTitleFont;
122 static WDECallbackUpdate setMenuTitleFont;
123 static WDECallbackUpdate setMenuTextFont;
124 static WDECallbackUpdate setIconTitleFont;
125 static WDECallbackUpdate setIconTitleColor;
126 static WDECallbackUpdate setIconTitleBack;
127 static WDECallbackUpdate setFrameBorderWidth;
128 static WDECallbackUpdate setFrameBorderColor;
129 static WDECallbackUpdate setFrameFocusedBorderColor;
130 static WDECallbackUpdate setFrameSelectedBorderColor;
131 static WDECallbackUpdate setLargeDisplayFont;
132 static WDECallbackUpdate setWTitleColor;
133 static WDECallbackUpdate setFTitleBack;
134 static WDECallbackUpdate setPTitleBack;
135 static WDECallbackUpdate setUTitleBack;
136 static WDECallbackUpdate setResizebarBack;
137 static WDECallbackUpdate setWorkspaceBack;
138 static WDECallbackUpdate setWorkspaceSpecificBack;
139 static WDECallbackUpdate setMenuTitleColor;
140 static WDECallbackUpdate setMenuTextColor;
141 static WDECallbackUpdate setMenuDisabledColor;
142 static WDECallbackUpdate setMenuTitleBack;
143 static WDECallbackUpdate setMenuTextBack;
144 static WDECallbackUpdate setHightlight;
145 static WDECallbackUpdate setHightlightText;
146 static WDECallbackUpdate setKeyGrab;
147 static WDECallbackUpdate setDoubleClick;
148 static WDECallbackUpdate setIconPosition;
149 static WDECallbackUpdate setWorkspaceMapBackground;
151 static WDECallbackUpdate setClipTitleFont;
152 static WDECallbackUpdate setClipTitleColor;
154 static WDECallbackUpdate setMenuStyle;
155 static WDECallbackUpdate setSwPOptions;
156 static WDECallbackUpdate updateUsableArea;
158 static WDECallbackUpdate setModifierKeyLabels;
160 static WDECallbackConvert getCursor;
161 static WDECallbackUpdate setCursor;
164 * Tables to convert strings to enumeration values.
165 * Values stored are char
168 /* WARNING: sum of length of all value strings must not exceed
169 * this value */
170 #define TOTAL_VALUES_LENGTH 80
172 #define REFRESH_WINDOW_TEXTURES (1<<0)
173 #define REFRESH_MENU_TEXTURE (1<<1)
174 #define REFRESH_MENU_FONT (1<<2)
175 #define REFRESH_MENU_COLOR (1<<3)
176 #define REFRESH_MENU_TITLE_TEXTURE (1<<4)
177 #define REFRESH_MENU_TITLE_FONT (1<<5)
178 #define REFRESH_MENU_TITLE_COLOR (1<<6)
179 #define REFRESH_WINDOW_TITLE_COLOR (1<<7)
180 #define REFRESH_WINDOW_FONT (1<<8)
181 #define REFRESH_ICON_TILE (1<<9)
182 #define REFRESH_ICON_FONT (1<<10)
183 #define REFRESH_WORKSPACE_BACK (1<<11)
185 #define REFRESH_BUTTON_IMAGES (1<<12)
187 #define REFRESH_ICON_TITLE_COLOR (1<<13)
188 #define REFRESH_ICON_TITLE_BACK (1<<14)
190 #define REFRESH_WORKSPACE_MENU (1<<15)
192 #define REFRESH_FRAME_BORDER REFRESH_MENU_FONT|REFRESH_WINDOW_FONT
194 static WOptionEnumeration seFocusModes[] = {
195 {"Manual", WKF_CLICK, 0}, {"ClickToFocus", WKF_CLICK, 1},
196 {"Sloppy", WKF_SLOPPY, 0}, {"SemiAuto", WKF_SLOPPY, 1}, {"Auto", WKF_SLOPPY, 1},
197 {NULL, 0, 0}
200 static WOptionEnumeration seTitlebarModes[] = {
201 {"new", TS_NEW, 0}, {"old", TS_OLD, 0},
202 {"next", TS_NEXT, 0}, {NULL, 0, 0}
205 static WOptionEnumeration seColormapModes[] = {
206 {"Manual", WCM_CLICK, 0}, {"ClickToFocus", WCM_CLICK, 1},
207 {"Auto", WCM_POINTER, 0}, {"FocusFollowMouse", WCM_POINTER, 1},
208 {NULL, 0, 0}
211 static WOptionEnumeration sePlacements[] = {
212 {"Auto", WPM_AUTO, 0},
213 {"Smart", WPM_SMART, 0},
214 {"Cascade", WPM_CASCADE, 0},
215 {"Random", WPM_RANDOM, 0},
216 {"Manual", WPM_MANUAL, 0},
217 {"Center", WPM_CENTER, 0},
218 {NULL, 0, 0}
221 static WOptionEnumeration seGeomDisplays[] = {
222 {"None", WDIS_NONE, 0},
223 {"Center", WDIS_CENTER, 0},
224 {"Corner", WDIS_TOPLEFT, 0},
225 {"Floating", WDIS_FRAME_CENTER, 0},
226 {"Line", WDIS_NEW, 0},
227 {NULL, 0, 0}
230 static WOptionEnumeration seSpeeds[] = {
231 {"UltraFast", SPEED_ULTRAFAST, 0},
232 {"Fast", SPEED_FAST, 0},
233 {"Medium", SPEED_MEDIUM, 0},
234 {"Slow", SPEED_SLOW, 0},
235 {"UltraSlow", SPEED_ULTRASLOW, 0},
236 {NULL, 0, 0}
239 static WOptionEnumeration seMouseButtonActions[] = {
240 {"None", WA_NONE, 0},
241 {"SelectWindows", WA_SELECT_WINDOWS, 0},
242 {"OpenApplicationsMenu", WA_OPEN_APPMENU, 0},
243 {"OpenWindowListMenu", WA_OPEN_WINLISTMENU, 0},
244 {"MoveToPrevWorkspace", WA_MOVE_PREVWORKSPACE, 0},
245 {"MoveToNextWorkspace", WA_MOVE_NEXTWORKSPACE, 0},
246 {"MoveToPrevWindow", WA_MOVE_PREVWINDOW, 0},
247 {"MoveToNextWindow", WA_MOVE_NEXTWINDOW, 0},
248 {NULL, 0, 0}
251 static WOptionEnumeration seMouseWheelActions[] = {
252 {"None", WA_NONE, 0},
253 {"SwitchWorkspaces", WA_SWITCH_WORKSPACES, 0},
254 {"SwitchWindows", WA_SWITCH_WINDOWS, 0},
255 {NULL, 0, 0}
258 static WOptionEnumeration seIconificationStyles[] = {
259 {"Zoom", WIS_ZOOM, 0},
260 {"Twist", WIS_TWIST, 0},
261 {"Flip", WIS_FLIP, 0},
262 {"None", WIS_NONE, 0},
263 {"random", WIS_RANDOM, 0},
264 {NULL, 0, 0}
267 static WOptionEnumeration seJustifications[] = {
268 {"Left", WTJ_LEFT, 0},
269 {"Center", WTJ_CENTER, 0},
270 {"Right", WTJ_RIGHT, 0},
271 {NULL, 0, 0}
274 static WOptionEnumeration seIconPositions[] = {
275 {"blv", IY_BOTTOM | IY_LEFT | IY_VERT, 0},
276 {"blh", IY_BOTTOM | IY_LEFT | IY_HORIZ, 0},
277 {"brv", IY_BOTTOM | IY_RIGHT | IY_VERT, 0},
278 {"brh", IY_BOTTOM | IY_RIGHT | IY_HORIZ, 0},
279 {"tlv", IY_TOP | IY_LEFT | IY_VERT, 0},
280 {"tlh", IY_TOP | IY_LEFT | IY_HORIZ, 0},
281 {"trv", IY_TOP | IY_RIGHT | IY_VERT, 0},
282 {"trh", IY_TOP | IY_RIGHT | IY_HORIZ, 0},
283 {NULL, 0, 0}
286 static WOptionEnumeration seMenuStyles[] = {
287 {"normal", MS_NORMAL, 0},
288 {"singletexture", MS_SINGLE_TEXTURE, 0},
289 {"flat", MS_FLAT, 0},
290 {NULL, 0, 0}
293 static WOptionEnumeration seDisplayPositions[] = {
294 {"none", WD_NONE, 0},
295 {"center", WD_CENTER, 0},
296 {"top", WD_TOP, 0},
297 {"bottom", WD_BOTTOM, 0},
298 {"topleft", WD_TOPLEFT, 0},
299 {"topright", WD_TOPRIGHT, 0},
300 {"bottomleft", WD_BOTTOMLEFT, 0},
301 {"bottomright", WD_BOTTOMRIGHT, 0},
302 {NULL, 0, 0}
305 static WOptionEnumeration seWorkspaceBorder[] = {
306 {"None", WB_NONE, 0},
307 {"LeftRight", WB_LEFTRIGHT, 0},
308 {"TopBottom", WB_TOPBOTTOM, 0},
309 {"AllDirections", WB_ALLDIRS, 0},
310 {NULL, 0, 0}
313 static WOptionEnumeration seDragMaximizedWindow[] = {
314 {"Move", DRAGMAX_MOVE, 0},
315 {"RestoreGeometry", DRAGMAX_RESTORE, 0},
316 {"Unmaximize", DRAGMAX_UNMAXIMIZE, 0},
317 {"NoMove", DRAGMAX_NOMOVE, 0},
318 {NULL, 0, 0}
322 * ALL entries in the tables bellow, NEED to have a default value
323 * defined, and this value needs to be correct.
326 /* these options will only affect the window manager on startup
328 * static defaults can't access the screen data, because it is
329 * created after these defaults are read
331 WDefaultEntry staticOptionList[] = {
333 {"ColormapSize", "4", NULL,
334 &wPreferences.cmap_size, getInt, NULL, NULL, NULL},
335 {"DisableDithering", "NO", NULL,
336 &wPreferences.no_dithering, getBool, NULL, NULL, NULL},
337 {"IconSize", "64", NULL,
338 &wPreferences.icon_size, getInt, NULL, NULL, NULL},
339 {"ModifierKey", "Mod1", NULL,
340 &wPreferences.modifier_mask, getModMask, NULL, NULL, NULL},
341 {"FocusMode", "manual", seFocusModes, /* have a problem when switching from */
342 &wPreferences.focus_mode, getEnum, NULL, NULL, NULL}, /* manual to sloppy without restart */
343 {"NewStyle", "new", seTitlebarModes,
344 &wPreferences.new_style, getEnum, NULL, NULL, NULL},
345 {"DisableDock", "NO", (void *)WM_DOCK,
346 NULL, getBool, setIfDockPresent, NULL, NULL},
347 {"DisableClip", "NO", (void *)WM_CLIP,
348 NULL, getBool, setIfDockPresent, NULL, NULL},
349 {"DisableDrawers", "NO", (void *)WM_DRAWER,
350 NULL, getBool, setIfDockPresent, NULL, NULL},
351 {"ClipMergedInDock", "NO", NULL,
352 NULL, getBool, setClipMergedInDock, NULL, NULL},
353 {"DisableMiniwindows", "NO", NULL,
354 &wPreferences.disable_miniwindows, getBool, NULL, NULL, NULL},
355 {"DisableWorkspacePager", "NO", NULL,
356 &wPreferences.disable_workspace_pager, getBool, NULL, NULL, NULL}
359 #define NUM2STRING_(x) #x
360 #define NUM2STRING(x) NUM2STRING_(x)
362 WDefaultEntry optionList[] = {
364 /* dynamic options */
366 {"IconPosition", "blh", seIconPositions,
367 &wPreferences.icon_yard, getEnum, setIconPosition, NULL, NULL},
368 {"IconificationStyle", "Zoom", seIconificationStyles,
369 &wPreferences.iconification_style, getEnum, NULL, NULL, NULL},
370 {"DisableWSMouseActions", "NO", NULL,
371 &wPreferences.disable_root_mouse, getBool, NULL, NULL, NULL},
372 {"MouseLeftButtonAction", "SelectWindows", seMouseButtonActions,
373 &wPreferences.mouse_button1, getEnum, NULL, NULL, NULL},
374 {"MouseMiddleButtonAction", "OpenWindowListMenu", seMouseButtonActions,
375 &wPreferences.mouse_button2, getEnum, NULL, NULL, NULL},
376 {"MouseRightButtonAction", "OpenApplicationsMenu", seMouseButtonActions,
377 &wPreferences.mouse_button3, getEnum, NULL, NULL, NULL},
378 {"MouseBackwardButtonAction", "None", seMouseButtonActions,
379 &wPreferences.mouse_button8, getEnum, NULL, NULL, NULL},
380 {"MouseForwardButtonAction", "None", seMouseButtonActions,
381 &wPreferences.mouse_button9, getEnum, NULL, NULL, NULL},
382 {"MouseWheelAction", "None", seMouseWheelActions,
383 &wPreferences.mouse_wheel_scroll, getEnum, NULL, NULL, NULL},
384 {"MouseWheelTiltAction", "None", seMouseWheelActions,
385 &wPreferences.mouse_wheel_tilt, getEnum, NULL, NULL, NULL},
386 {"PixmapPath", DEF_PIXMAP_PATHS, NULL,
387 &wPreferences.pixmap_path, getPathList, NULL, NULL, NULL},
388 {"IconPath", DEF_ICON_PATHS, NULL,
389 &wPreferences.icon_path, getPathList, NULL, NULL, NULL},
390 {"ColormapMode", "auto", seColormapModes,
391 &wPreferences.colormap_mode, getEnum, NULL, NULL, NULL},
392 {"AutoFocus", "NO", NULL,
393 &wPreferences.auto_focus, getBool, NULL, NULL, NULL},
394 {"RaiseDelay", "0", NULL,
395 &wPreferences.raise_delay, getInt, NULL, NULL, NULL},
396 {"CirculateRaise", "NO", NULL,
397 &wPreferences.circ_raise, getBool, NULL, NULL, NULL},
398 {"Superfluous", "NO", NULL,
399 &wPreferences.superfluous, getBool, NULL, NULL, NULL},
400 {"AdvanceToNewWorkspace", "NO", NULL,
401 &wPreferences.ws_advance, getBool, NULL, NULL, NULL},
402 {"CycleWorkspaces", "NO", NULL,
403 &wPreferences.ws_cycle, getBool, NULL, NULL, NULL},
404 {"WorkspaceNameDisplayPosition", "center", seDisplayPositions,
405 &wPreferences.workspace_name_display_position, getEnum, NULL, NULL, NULL},
406 {"WorkspaceBorder", "None", seWorkspaceBorder,
407 &wPreferences.workspace_border_position, getEnum, updateUsableArea, NULL, NULL},
408 {"WorkspaceBorderSize", "0", NULL,
409 &wPreferences.workspace_border_size, getInt, updateUsableArea, NULL, NULL},
410 {"StickyIcons", "NO", NULL,
411 &wPreferences.sticky_icons, getBool, setStickyIcons, NULL, NULL},
412 {"SaveSessionOnExit", "NO", NULL,
413 &wPreferences.save_session_on_exit, getBool, NULL, NULL, NULL},
414 {"WrapMenus", "NO", NULL,
415 &wPreferences.wrap_menus, getBool, NULL, NULL, NULL},
416 {"ScrollableMenus", "NO", NULL,
417 &wPreferences.scrollable_menus, getBool, NULL, NULL, NULL},
418 {"MenuScrollSpeed", "medium", seSpeeds,
419 &wPreferences.menu_scroll_speed, getEnum, NULL, NULL, NULL},
420 {"IconSlideSpeed", "medium", seSpeeds,
421 &wPreferences.icon_slide_speed, getEnum, NULL, NULL, NULL},
422 {"ShadeSpeed", "medium", seSpeeds,
423 &wPreferences.shade_speed, getEnum, NULL, NULL, NULL},
424 {"BounceAppIconsWhenUrgent", "YES", NULL,
425 &wPreferences.bounce_appicons_when_urgent, getBool, NULL, NULL, NULL},
426 {"RaiseAppIconsWhenBouncing", "NO", NULL,
427 &wPreferences.raise_appicons_when_bouncing, getBool, NULL, NULL, NULL},
428 {"DoNotMakeAppIconsBounce", "NO", NULL,
429 &wPreferences.do_not_make_appicons_bounce, getBool, NULL, NULL, NULL},
430 {"DoubleClickTime", "250", (void *)&wPreferences.dblclick_time,
431 &wPreferences.dblclick_time, getInt, setDoubleClick, NULL, NULL},
432 {"ClipAutoraiseDelay", "600", NULL,
433 &wPreferences.clip_auto_raise_delay, getInt, NULL, NULL, NULL},
434 {"ClipAutolowerDelay", "1000", NULL,
435 &wPreferences.clip_auto_lower_delay, getInt, NULL, NULL, NULL},
436 {"ClipAutoexpandDelay", "600", NULL,
437 &wPreferences.clip_auto_expand_delay, getInt, NULL, NULL, NULL},
438 {"ClipAutocollapseDelay", "1000", NULL,
439 &wPreferences.clip_auto_collapse_delay, getInt, NULL, NULL, NULL},
440 {"WrapAppiconsInDock", "YES", NULL,
441 NULL, getBool, setWrapAppiconsInDock, NULL, NULL},
442 {"AlignSubmenus", "NO", NULL,
443 &wPreferences.align_menus, getBool, NULL, NULL, NULL},
444 {"ViKeyMenus", "NO", NULL,
445 &wPreferences.vi_key_menus, getBool, NULL, NULL, NULL},
446 {"OpenTransientOnOwnerWorkspace", "NO", NULL,
447 &wPreferences.open_transients_with_parent, getBool, NULL, NULL, NULL},
448 {"WindowPlacement", "auto", sePlacements,
449 &wPreferences.window_placement, getEnum, NULL, NULL, NULL},
450 {"IgnoreFocusClick", "NO", NULL,
451 &wPreferences.ignore_focus_click, getBool, NULL, NULL, NULL},
452 {"UseSaveUnders", "NO", NULL,
453 &wPreferences.use_saveunders, getBool, NULL, NULL, NULL},
454 {"OpaqueMove", "NO", NULL,
455 &wPreferences.opaque_move, getBool, NULL, NULL, NULL},
456 {"OpaqueResize", "NO", NULL,
457 &wPreferences.opaque_resize, getBool, NULL, NULL, NULL},
458 {"OpaqueMoveResizeKeyboard", "NO", NULL,
459 &wPreferences.opaque_move_resize_keyboard, getBool, NULL, NULL, NULL},
460 {"DisableAnimations", "NO", NULL,
461 &wPreferences.no_animations, getBool, NULL, NULL, NULL},
462 {"DontLinkWorkspaces", "NO", NULL,
463 &wPreferences.no_autowrap, getBool, NULL, NULL, NULL},
464 {"WindowSnapping", "NO", NULL,
465 &wPreferences.window_snapping, getBool, NULL, NULL, NULL},
466 {"DragMaximizedWindow", "Move", seDragMaximizedWindow,
467 &wPreferences.drag_maximized_window, getEnum, NULL, NULL, NULL},
468 {"HighlightActiveApp", "YES", NULL,
469 &wPreferences.highlight_active_app, getBool, NULL, NULL, NULL},
470 {"AutoArrangeIcons", "NO", NULL,
471 &wPreferences.auto_arrange_icons, getBool, NULL, NULL, NULL},
472 {"NoWindowOverDock", "NO", NULL,
473 &wPreferences.no_window_over_dock, getBool, updateUsableArea, NULL, NULL},
474 {"NoWindowOverIcons", "NO", NULL,
475 &wPreferences.no_window_over_icons, getBool, updateUsableArea, NULL, NULL},
476 {"WindowPlaceOrigin", "(0, 0)", NULL,
477 &wPreferences.window_place_origin, getCoord, NULL, NULL, NULL},
478 {"ResizeDisplay", "corner", seGeomDisplays,
479 &wPreferences.size_display, getEnum, NULL, NULL, NULL},
480 {"MoveDisplay", "corner", seGeomDisplays,
481 &wPreferences.move_display, getEnum, NULL, NULL, NULL},
482 {"DontConfirmKill", "NO", NULL,
483 &wPreferences.dont_confirm_kill, getBool, NULL, NULL, NULL},
484 {"WindowTitleBalloons", "NO", NULL,
485 &wPreferences.window_balloon, getBool, NULL, NULL, NULL},
486 {"MiniwindowTitleBalloons", "NO", NULL,
487 &wPreferences.miniwin_title_balloon, getBool, NULL, NULL, NULL},
488 {"MiniwindowApercuBalloons", "NO", NULL,
489 &wPreferences.miniwin_apercu_balloon, getBool, NULL, NULL, NULL},
490 {"AppIconBalloons", "NO", NULL,
491 &wPreferences.appicon_balloon, getBool, NULL, NULL, NULL},
492 {"HelpBalloons", "NO", NULL,
493 &wPreferences.help_balloon, getBool, NULL, NULL, NULL},
494 {"EdgeResistance", "30", NULL,
495 &wPreferences.edge_resistance, getInt, NULL, NULL, NULL},
496 {"ResizeIncrement", "0", NULL,
497 &wPreferences.resize_increment, getInt, NULL, NULL, NULL},
498 {"Attraction", "NO", NULL,
499 &wPreferences.attract, getBool, NULL, NULL, NULL},
500 {"DisableBlinking", "NO", NULL,
501 &wPreferences.dont_blink, getBool, NULL, NULL, NULL},
502 {"SingleClickLaunch", "NO", NULL,
503 &wPreferences.single_click, getBool, NULL, NULL, NULL},
504 {"StrictWindozeCycle", "YES", NULL,
505 &wPreferences.strict_windoze_cycle, getBool, NULL, NULL, NULL},
506 {"SwitchPanelOnlyOpen", "NO", NULL,
507 &wPreferences.panel_only_open, getBool, NULL, NULL, NULL},
508 {"ApercuSize", "128", NULL,
509 &wPreferences.apercu_size, getInt, NULL, NULL, NULL},
511 /* style options */
513 {"MenuStyle", "normal", seMenuStyles,
514 &wPreferences.menu_style, getEnum, setMenuStyle, NULL, NULL},
515 {"WidgetColor", "(solid, gray)", NULL,
516 NULL, getTexture, setWidgetColor, NULL, NULL},
517 {"WorkspaceSpecificBack", "()", NULL,
518 NULL, getWSSpecificBackground, setWorkspaceSpecificBack, NULL, NULL},
519 /* WorkspaceBack must come after WorkspaceSpecificBack or
520 * WorkspaceBack wont know WorkspaceSpecificBack was also
521 * specified and 2 copies of wmsetbg will be launched */
522 {"WorkspaceBack", "(solid, black)", NULL,
523 NULL, getWSBackground, setWorkspaceBack, NULL, NULL},
524 {"SmoothWorkspaceBack", "NO", NULL,
525 NULL, getBool, NULL, NULL, NULL},
526 {"IconBack", "(solid, gray)", NULL,
527 NULL, getTexture, setIconTile, NULL, NULL},
528 {"TitleJustify", "center", seJustifications,
529 &wPreferences.title_justification, getEnum, setJustify, NULL, NULL},
530 {"WindowTitleFont", DEF_TITLE_FONT, NULL,
531 NULL, getFont, setWinTitleFont, NULL, NULL},
532 {"WindowTitleExtendSpace", DEF_WINDOW_TITLE_EXTEND_SPACE, NULL,
533 &wPreferences.window_title_clearance, getInt, setClearance, NULL, NULL},
534 {"WindowTitleMinHeight", "0", NULL,
535 &wPreferences.window_title_min_height, getInt, setClearance, NULL, NULL},
536 {"WindowTitleMaxHeight", NUM2STRING(INT_MAX), NULL,
537 &wPreferences.window_title_max_height, getInt, setClearance, NULL, NULL},
538 {"MenuTitleExtendSpace", DEF_MENU_TITLE_EXTEND_SPACE, NULL,
539 &wPreferences.menu_title_clearance, getInt, setClearance, NULL, NULL},
540 {"MenuTitleMinHeight", "0", NULL,
541 &wPreferences.menu_title_min_height, getInt, setClearance, NULL, NULL},
542 {"MenuTitleMaxHeight", NUM2STRING(INT_MAX), NULL,
543 &wPreferences.menu_title_max_height, getInt, setClearance, NULL, NULL},
544 {"MenuTextExtendSpace", DEF_MENU_TEXT_EXTEND_SPACE, NULL,
545 &wPreferences.menu_text_clearance, getInt, setClearance, NULL, NULL},
546 {"MenuTitleFont", DEF_MENU_TITLE_FONT, NULL,
547 NULL, getFont, setMenuTitleFont, NULL, NULL},
548 {"MenuTextFont", DEF_MENU_ENTRY_FONT, NULL,
549 NULL, getFont, setMenuTextFont, NULL, NULL},
550 {"IconTitleFont", DEF_ICON_TITLE_FONT, NULL,
551 NULL, getFont, setIconTitleFont, NULL, NULL},
552 {"ClipTitleFont", DEF_CLIP_TITLE_FONT, NULL,
553 NULL, getFont, setClipTitleFont, NULL, NULL},
554 {"ShowClipTitle", "YES", NULL,
555 &wPreferences.show_clip_title, getBool, NULL, NULL, NULL},
556 {"LargeDisplayFont", DEF_WORKSPACE_NAME_FONT, NULL,
557 NULL, getFont, setLargeDisplayFont, NULL, NULL},
558 {"HighlightColor", "white", NULL,
559 NULL, getColor, setHightlight, NULL, NULL},
560 {"HighlightTextColor", "black", NULL,
561 NULL, getColor, setHightlightText, NULL, NULL},
562 {"ClipTitleColor", "black", (void *)CLIP_NORMAL,
563 NULL, getColor, setClipTitleColor, NULL, NULL},
564 {"CClipTitleColor", "\"#454045\"", (void *)CLIP_COLLAPSED,
565 NULL, getColor, setClipTitleColor, NULL, NULL},
566 {"FTitleColor", "white", (void *)WS_FOCUSED,
567 NULL, getColor, setWTitleColor, NULL, NULL},
568 {"PTitleColor", "white", (void *)WS_PFOCUSED,
569 NULL, getColor, setWTitleColor, NULL, NULL},
570 {"UTitleColor", "black", (void *)WS_UNFOCUSED,
571 NULL, getColor, setWTitleColor, NULL, NULL},
572 {"FTitleBack", "(solid, black)", NULL,
573 NULL, getTexture, setFTitleBack, NULL, NULL},
574 {"PTitleBack", "(solid, \"#616161\")", NULL,
575 NULL, getTexture, setPTitleBack, NULL, NULL},
576 {"UTitleBack", "(solid, gray)", NULL,
577 NULL, getTexture, setUTitleBack, NULL, NULL},
578 {"ResizebarBack", "(solid, gray)", NULL,
579 NULL, getTexture, setResizebarBack, NULL, NULL},
580 {"MenuTitleColor", "white", NULL,
581 NULL, getColor, setMenuTitleColor, NULL, NULL},
582 {"MenuTextColor", "black", NULL,
583 NULL, getColor, setMenuTextColor, NULL, NULL},
584 {"MenuDisabledColor", "\"#616161\"", NULL,
585 NULL, getColor, setMenuDisabledColor, NULL, NULL},
586 {"MenuTitleBack", "(solid, black)", NULL,
587 NULL, getTexture, setMenuTitleBack, NULL, NULL},
588 {"MenuTextBack", "(solid, gray)", NULL,
589 NULL, getTexture, setMenuTextBack, NULL, NULL},
590 {"IconTitleColor", "white", NULL,
591 NULL, getColor, setIconTitleColor, NULL, NULL},
592 {"IconTitleBack", "black", NULL,
593 NULL, getColor, setIconTitleBack, NULL, NULL},
594 {"SwitchPanelImages", "(swtile.png, swback.png, 30, 40)", &wPreferences,
595 NULL, getPropList, setSwPOptions, NULL, NULL},
596 {"ModifierKeyLabels", "(\"Shift+\", \"Control+\", \"Mod1+\", \"Mod2+\", \"Mod3+\", \"Mod4+\", \"Mod5+\")", &wPreferences,
597 NULL, getPropList, setModifierKeyLabels, NULL, NULL},
598 {"FrameBorderWidth", "1", NULL,
599 NULL, getInt, setFrameBorderWidth, NULL, NULL},
600 {"FrameBorderColor", "black", NULL,
601 NULL, getColor, setFrameBorderColor, NULL, NULL},
602 {"FrameFocusedBorderColor", "black", NULL,
603 NULL, getColor, setFrameFocusedBorderColor, NULL, NULL},
604 {"FrameSelectedBorderColor", "white", NULL,
605 NULL, getColor, setFrameSelectedBorderColor, NULL, NULL},
606 {"WorkspaceMapBack", "(solid, black)", NULL,
607 NULL, getTexture, setWorkspaceMapBackground, NULL, NULL},
609 /* keybindings */
611 {"RootMenuKey", "None", (void *)WKBD_ROOTMENU,
612 NULL, getKeybind, setKeyGrab, NULL, NULL},
613 {"WindowListKey", "None", (void *)WKBD_WINDOWLIST,
614 NULL, getKeybind, setKeyGrab, NULL, NULL},
615 {"WindowMenuKey", "None", (void *)WKBD_WINDOWMENU,
616 NULL, getKeybind, setKeyGrab, NULL, NULL},
617 {"DockRaiseLowerKey", "None", (void*)WKBD_DOCKRAISELOWER,
618 NULL, getKeybind, setKeyGrab, NULL, NULL},
619 {"ClipRaiseLowerKey", "None", (void *)WKBD_CLIPRAISELOWER,
620 NULL, getKeybind, setKeyGrab, NULL, NULL},
621 {"MiniaturizeKey", "None", (void *)WKBD_MINIATURIZE,
622 NULL, getKeybind, setKeyGrab, NULL, NULL},
623 {"MinimizeAllKey", "None", (void *)WKBD_MINIMIZEALL,
624 NULL, getKeybind, setKeyGrab, NULL, NULL },
625 {"HideKey", "None", (void *)WKBD_HIDE,
626 NULL, getKeybind, setKeyGrab, NULL, NULL},
627 {"HideOthersKey", "None", (void *)WKBD_HIDE_OTHERS,
628 NULL, getKeybind, setKeyGrab, NULL, NULL},
629 {"MoveResizeKey", "None", (void *)WKBD_MOVERESIZE,
630 NULL, getKeybind, setKeyGrab, NULL, NULL},
631 {"CloseKey", "None", (void *)WKBD_CLOSE,
632 NULL, getKeybind, setKeyGrab, NULL, NULL},
633 {"MaximizeKey", "None", (void *)WKBD_MAXIMIZE,
634 NULL, getKeybind, setKeyGrab, NULL, NULL},
635 {"VMaximizeKey", "None", (void *)WKBD_VMAXIMIZE,
636 NULL, getKeybind, setKeyGrab, NULL, NULL},
637 {"HMaximizeKey", "None", (void *)WKBD_HMAXIMIZE,
638 NULL, getKeybind, setKeyGrab, NULL, NULL},
639 {"LHMaximizeKey", "None", (void*)WKBD_LHMAXIMIZE,
640 NULL, getKeybind, setKeyGrab, NULL, NULL},
641 {"RHMaximizeKey", "None", (void*)WKBD_RHMAXIMIZE,
642 NULL, getKeybind, setKeyGrab, NULL, NULL},
643 {"THMaximizeKey", "None", (void*)WKBD_THMAXIMIZE,
644 NULL, getKeybind, setKeyGrab, NULL, NULL},
645 {"BHMaximizeKey", "None", (void*)WKBD_BHMAXIMIZE,
646 NULL, getKeybind, setKeyGrab, NULL, NULL},
647 {"LTCMaximizeKey", "None", (void*)WKBD_LTCMAXIMIZE,
648 NULL, getKeybind, setKeyGrab, NULL, NULL},
649 {"RTCMaximizeKey", "None", (void*)WKBD_RTCMAXIMIZE,
650 NULL, getKeybind, setKeyGrab, NULL, NULL},
651 {"LBCMaximizeKey", "None", (void*)WKBD_LBCMAXIMIZE,
652 NULL, getKeybind, setKeyGrab, NULL, NULL},
653 {"RBCMaximizeKey", "None", (void*)WKBD_RBCMAXIMIZE,
654 NULL, getKeybind, setKeyGrab, NULL, NULL},
655 {"MaximusKey", "None", (void*)WKBD_MAXIMUS,
656 NULL, getKeybind, setKeyGrab, NULL, NULL},
657 {"OmnipresentKey", "None", (void *)WKBD_OMNIPRESENT,
658 NULL, getKeybind, setKeyGrab, NULL, NULL},
659 {"RaiseKey", "\"Meta+Up\"", (void *)WKBD_RAISE,
660 NULL, getKeybind, setKeyGrab, NULL, NULL},
661 {"LowerKey", "\"Meta+Down\"", (void *)WKBD_LOWER,
662 NULL, getKeybind, setKeyGrab, NULL, NULL},
663 {"RaiseLowerKey", "None", (void *)WKBD_RAISELOWER,
664 NULL, getKeybind, setKeyGrab, NULL, NULL},
665 {"ShadeKey", "None", (void *)WKBD_SHADE,
666 NULL, getKeybind, setKeyGrab, NULL, NULL},
667 {"SelectKey", "None", (void *)WKBD_SELECT,
668 NULL, getKeybind, setKeyGrab, NULL, NULL},
669 {"WorkspaceMapKey", "None", (void *)WKBD_WORKSPACEMAP,
670 NULL, getKeybind, setKeyGrab, NULL, NULL},
671 {"FocusNextKey", "None", (void *)WKBD_FOCUSNEXT,
672 NULL, getKeybind, setKeyGrab, NULL, NULL},
673 {"FocusPrevKey", "None", (void *)WKBD_FOCUSPREV,
674 NULL, getKeybind, setKeyGrab, NULL, NULL},
675 {"GroupNextKey", "None", (void *)WKBD_GROUPNEXT,
676 NULL, getKeybind, setKeyGrab, NULL, NULL},
677 {"GroupPrevKey", "None", (void *)WKBD_GROUPPREV,
678 NULL, getKeybind, setKeyGrab, NULL, NULL},
679 {"NextWorkspaceKey", "None", (void *)WKBD_NEXTWORKSPACE,
680 NULL, getKeybind, setKeyGrab, NULL, NULL},
681 {"PrevWorkspaceKey", "None", (void *)WKBD_PREVWORKSPACE,
682 NULL, getKeybind, setKeyGrab, NULL, NULL},
683 {"LastWorkspaceKey", "None", (void *)WKBD_LASTWORKSPACE,
684 NULL, getKeybind, setKeyGrab, NULL, NULL},
685 {"NextWorkspaceLayerKey", "None", (void *)WKBD_NEXTWSLAYER,
686 NULL, getKeybind, setKeyGrab, NULL, NULL},
687 {"PrevWorkspaceLayerKey", "None", (void *)WKBD_PREVWSLAYER,
688 NULL, getKeybind, setKeyGrab, NULL, NULL},
689 {"Workspace1Key", "None", (void *)WKBD_WORKSPACE1,
690 NULL, getKeybind, setKeyGrab, NULL, NULL},
691 {"Workspace2Key", "None", (void *)WKBD_WORKSPACE2,
692 NULL, getKeybind, setKeyGrab, NULL, NULL},
693 {"Workspace3Key", "None", (void *)WKBD_WORKSPACE3,
694 NULL, getKeybind, setKeyGrab, NULL, NULL},
695 {"Workspace4Key", "None", (void *)WKBD_WORKSPACE4,
696 NULL, getKeybind, setKeyGrab, NULL, NULL},
697 {"Workspace5Key", "None", (void *)WKBD_WORKSPACE5,
698 NULL, getKeybind, setKeyGrab, NULL, NULL},
699 {"Workspace6Key", "None", (void *)WKBD_WORKSPACE6,
700 NULL, getKeybind, setKeyGrab, NULL, NULL},
701 {"Workspace7Key", "None", (void *)WKBD_WORKSPACE7,
702 NULL, getKeybind, setKeyGrab, NULL, NULL},
703 {"Workspace8Key", "None", (void *)WKBD_WORKSPACE8,
704 NULL, getKeybind, setKeyGrab, NULL, NULL},
705 {"Workspace9Key", "None", (void *)WKBD_WORKSPACE9,
706 NULL, getKeybind, setKeyGrab, NULL, NULL},
707 {"Workspace10Key", "None", (void *)WKBD_WORKSPACE10,
708 NULL, getKeybind, setKeyGrab, NULL, NULL},
709 {"MoveToWorkspace1Key", "None", (void *)WKBD_MOVE_WORKSPACE1,
710 NULL, getKeybind, setKeyGrab, NULL, NULL},
711 {"MoveToWorkspace2Key", "None", (void *)WKBD_MOVE_WORKSPACE2,
712 NULL, getKeybind, setKeyGrab, NULL, NULL},
713 {"MoveToWorkspace3Key", "None", (void *)WKBD_MOVE_WORKSPACE3,
714 NULL, getKeybind, setKeyGrab, NULL, NULL},
715 {"MoveToWorkspace4Key", "None", (void *)WKBD_MOVE_WORKSPACE4,
716 NULL, getKeybind, setKeyGrab, NULL, NULL},
717 {"MoveToWorkspace5Key", "None", (void *)WKBD_MOVE_WORKSPACE5,
718 NULL, getKeybind, setKeyGrab, NULL, NULL},
719 {"MoveToWorkspace6Key", "None", (void *)WKBD_MOVE_WORKSPACE6,
720 NULL, getKeybind, setKeyGrab, NULL, NULL},
721 {"MoveToWorkspace7Key", "None", (void *)WKBD_MOVE_WORKSPACE7,
722 NULL, getKeybind, setKeyGrab, NULL, NULL},
723 {"MoveToWorkspace8Key", "None", (void *)WKBD_MOVE_WORKSPACE8,
724 NULL, getKeybind, setKeyGrab, NULL, NULL},
725 {"MoveToWorkspace9Key", "None", (void *)WKBD_MOVE_WORKSPACE9,
726 NULL, getKeybind, setKeyGrab, NULL, NULL},
727 {"MoveToWorkspace10Key", "None", (void *)WKBD_MOVE_WORKSPACE10,
728 NULL, getKeybind, setKeyGrab, NULL, NULL},
729 {"MoveToNextWorkspaceKey", "None", (void *)WKBD_MOVE_NEXTWORKSPACE,
730 NULL, getKeybind, setKeyGrab, NULL, NULL},
731 {"MoveToPrevWorkspaceKey", "None", (void *)WKBD_MOVE_PREVWORKSPACE,
732 NULL, getKeybind, setKeyGrab, NULL, NULL},
733 {"MoveToLastWorkspaceKey", "None", (void *)WKBD_MOVE_LASTWORKSPACE,
734 NULL, getKeybind, setKeyGrab, NULL, NULL},
735 {"MoveToNextWorkspaceLayerKey", "None", (void *)WKBD_MOVE_NEXTWSLAYER,
736 NULL, getKeybind, setKeyGrab, NULL, NULL},
737 {"MoveToPrevWorkspaceLayerKey", "None", (void *)WKBD_MOVE_PREVWSLAYER,
738 NULL, getKeybind, setKeyGrab, NULL, NULL},
739 {"WindowShortcut1Key", "None", (void *)WKBD_WINDOW1,
740 NULL, getKeybind, setKeyGrab, NULL, NULL},
741 {"WindowShortcut2Key", "None", (void *)WKBD_WINDOW2,
742 NULL, getKeybind, setKeyGrab, NULL, NULL},
743 {"WindowShortcut3Key", "None", (void *)WKBD_WINDOW3,
744 NULL, getKeybind, setKeyGrab, NULL, NULL},
745 {"WindowShortcut4Key", "None", (void *)WKBD_WINDOW4,
746 NULL, getKeybind, setKeyGrab, NULL, NULL},
747 {"WindowShortcut5Key", "None", (void *)WKBD_WINDOW5,
748 NULL, getKeybind, setKeyGrab, NULL, NULL},
749 {"WindowShortcut6Key", "None", (void *)WKBD_WINDOW6,
750 NULL, getKeybind, setKeyGrab, NULL, NULL},
751 {"WindowShortcut7Key", "None", (void *)WKBD_WINDOW7,
752 NULL, getKeybind, setKeyGrab, NULL, NULL},
753 {"WindowShortcut8Key", "None", (void *)WKBD_WINDOW8,
754 NULL, getKeybind, setKeyGrab, NULL, NULL},
755 {"WindowShortcut9Key", "None", (void *)WKBD_WINDOW9,
756 NULL, getKeybind, setKeyGrab, NULL, NULL},
757 {"WindowShortcut10Key", "None", (void *)WKBD_WINDOW10,
758 NULL, getKeybind, setKeyGrab, NULL, NULL},
759 {"WindowRelaunchKey", "None", (void *)WKBD_RELAUNCH,
760 NULL, getKeybind, setKeyGrab, NULL, NULL},
761 {"ScreenSwitchKey", "None", (void *)WKBD_SWITCH_SCREEN,
762 NULL, getKeybind, setKeyGrab, NULL, NULL},
763 {"RunKey", "None", (void *)WKBD_RUN,
764 NULL, getKeybind, setKeyGrab, NULL, NULL},
766 #ifdef KEEP_XKB_LOCK_STATUS
767 {"ToggleKbdModeKey", "None", (void *)WKBD_TOGGLE,
768 NULL, getKeybind, setKeyGrab, NULL, NULL},
769 {"KbdModeLock", "NO", NULL,
770 &wPreferences.modelock, getBool, NULL, NULL, NULL},
771 #endif /* KEEP_XKB_LOCK_STATUS */
773 {"NormalCursor", "(builtin, left_ptr)", (void *)WCUR_ROOT,
774 NULL, getCursor, setCursor, NULL, NULL},
775 {"ArrowCursor", "(builtin, top_left_arrow)", (void *)WCUR_ARROW,
776 NULL, getCursor, setCursor, NULL, NULL},
777 {"MoveCursor", "(builtin, fleur)", (void *)WCUR_MOVE,
778 NULL, getCursor, setCursor, NULL, NULL},
779 {"ResizeCursor", "(builtin, sizing)", (void *)WCUR_RESIZE,
780 NULL, getCursor, setCursor, NULL, NULL},
781 {"TopLeftResizeCursor", "(builtin, top_left_corner)", (void *)WCUR_TOPLEFTRESIZE,
782 NULL, getCursor, setCursor, NULL, NULL},
783 {"TopRightResizeCursor", "(builtin, top_right_corner)", (void *)WCUR_TOPRIGHTRESIZE,
784 NULL, getCursor, setCursor, NULL, NULL},
785 {"BottomLeftResizeCursor", "(builtin, bottom_left_corner)", (void *)WCUR_BOTTOMLEFTRESIZE,
786 NULL, getCursor, setCursor, NULL, NULL},
787 {"BottomRightResizeCursor", "(builtin, bottom_right_corner)", (void *)WCUR_BOTTOMRIGHTRESIZE,
788 NULL, getCursor, setCursor, NULL, NULL},
789 {"VerticalResizeCursor", "(builtin, sb_v_double_arrow)", (void *)WCUR_VERTICALRESIZE,
790 NULL, getCursor, setCursor, NULL, NULL},
791 {"HorizontalResizeCursor", "(builtin, sb_h_double_arrow)", (void *)WCUR_HORIZONRESIZE,
792 NULL, getCursor, setCursor, NULL, NULL},
793 {"WaitCursor", "(builtin, watch)", (void *)WCUR_WAIT,
794 NULL, getCursor, setCursor, NULL, NULL},
795 {"QuestionCursor", "(builtin, question_arrow)", (void *)WCUR_QUESTION,
796 NULL, getCursor, setCursor, NULL, NULL},
797 {"TextCursor", "(builtin, xterm)", (void *)WCUR_TEXT,
798 NULL, getCursor, setCursor, NULL, NULL},
799 {"SelectCursor", "(builtin, cross)", (void *)WCUR_SELECT,
800 NULL, getCursor, setCursor, NULL, NULL},
801 {"DialogHistoryLines", "500", NULL,
802 &wPreferences.history_lines, getInt, NULL, NULL, NULL},
803 {"CycleActiveHeadOnly", "NO", NULL,
804 &wPreferences.cycle_active_head_only, getBool, NULL, NULL, NULL},
805 {"CycleIgnoreMinimized", "NO", NULL,
806 &wPreferences.cycle_ignore_minimized, getBool, NULL, NULL, NULL}
809 static void initDefaults(void)
811 unsigned int i;
812 WDefaultEntry *entry;
814 WMPLSetCaseSensitive(False);
816 for (i = 0; i < wlengthof(optionList); i++) {
817 entry = &optionList[i];
819 entry->plkey = WMCreatePLString(entry->key);
820 if (entry->default_value)
821 entry->plvalue = WMCreatePropListFromDescription(entry->default_value);
822 else
823 entry->plvalue = NULL;
826 for (i = 0; i < wlengthof(staticOptionList); i++) {
827 entry = &staticOptionList[i];
829 entry->plkey = WMCreatePLString(entry->key);
830 if (entry->default_value)
831 entry->plvalue = WMCreatePropListFromDescription(entry->default_value);
832 else
833 entry->plvalue = NULL;
837 static WMPropList *readGlobalDomain(const char *domainName, Bool requireDictionary)
839 WMPropList *globalDict = NULL;
840 char path[PATH_MAX];
841 struct stat stbuf;
843 snprintf(path, sizeof(path), "%s/%s/%s", SYSCONFDIR, GLOBAL_DEFAULTS_SUBDIR, domainName);
844 if (stat(path, &stbuf) >= 0) {
845 globalDict = WMReadPropListFromFile(path);
846 if (globalDict && requireDictionary && !WMIsPLDictionary(globalDict)) {
847 wwarning(_("Domain %s (%s) of global defaults database is corrupted!"), domainName, path);
848 WMReleasePropList(globalDict);
849 globalDict = NULL;
850 } else if (!globalDict) {
851 wwarning(_("could not load domain %s from global defaults database"), domainName);
855 return globalDict;
858 #if defined(GLOBAL_PREAMBLE_MENU_FILE) || defined(GLOBAL_EPILOGUE_MENU_FILE)
859 static void prependMenu(WMPropList * destarr, WMPropList * array)
861 WMPropList *item;
862 int i;
864 for (i = 0; i < WMGetPropListItemCount(array); i++) {
865 item = WMGetFromPLArray(array, i);
866 if (item)
867 WMInsertInPLArray(destarr, i + 1, item);
871 static void appendMenu(WMPropList * destarr, WMPropList * array)
873 WMPropList *item;
874 int i;
876 for (i = 0; i < WMGetPropListItemCount(array); i++) {
877 item = WMGetFromPLArray(array, i);
878 if (item)
879 WMAddToPLArray(destarr, item);
882 #endif
884 void wDefaultsMergeGlobalMenus(WDDomain * menuDomain)
886 WMPropList *menu = menuDomain->dictionary;
887 WMPropList *submenu;
889 if (!menu || !WMIsPLArray(menu))
890 return;
892 #ifdef GLOBAL_PREAMBLE_MENU_FILE
893 submenu = WMReadPropListFromFile(SYSCONFDIR "/" GLOBAL_DEFAULTS_SUBDIR "/" GLOBAL_PREAMBLE_MENU_FILE);
895 if (submenu && !WMIsPLArray(submenu)) {
896 wwarning(_("invalid global menu file %s"), GLOBAL_PREAMBLE_MENU_FILE);
897 WMReleasePropList(submenu);
898 submenu = NULL;
900 if (submenu) {
901 prependMenu(menu, submenu);
902 WMReleasePropList(submenu);
904 #endif
906 #ifdef GLOBAL_EPILOGUE_MENU_FILE
907 submenu = WMReadPropListFromFile(SYSCONFDIR "/" GLOBAL_DEFAULTS_SUBDIR "/" GLOBAL_EPILOGUE_MENU_FILE);
909 if (submenu && !WMIsPLArray(submenu)) {
910 wwarning(_("invalid global menu file %s"), GLOBAL_EPILOGUE_MENU_FILE);
911 WMReleasePropList(submenu);
912 submenu = NULL;
914 if (submenu) {
915 appendMenu(menu, submenu);
916 WMReleasePropList(submenu);
918 #endif
920 menuDomain->dictionary = menu;
923 WDDomain *wDefaultsInitDomain(const char *domain, Bool requireDictionary)
925 WDDomain *db;
926 struct stat stbuf;
927 static int inited = 0;
928 WMPropList *shared_dict = NULL;
930 if (!inited) {
931 inited = 1;
932 initDefaults();
935 db = wmalloc(sizeof(WDDomain));
936 db->domain_name = domain;
937 db->path = wdefaultspathfordomain(domain);
939 if (stat(db->path, &stbuf) >= 0) {
940 db->dictionary = WMReadPropListFromFile(db->path);
941 if (db->dictionary) {
942 if (requireDictionary && !WMIsPLDictionary(db->dictionary)) {
943 WMReleasePropList(db->dictionary);
944 db->dictionary = NULL;
945 wwarning(_("Domain %s (%s) of defaults database is corrupted!"), domain, db->path);
947 db->timestamp = stbuf.st_mtime;
948 } else {
949 wwarning(_("could not load domain %s from user defaults database"), domain);
953 /* global system dictionary */
954 shared_dict = readGlobalDomain(domain, requireDictionary);
956 if (shared_dict && db->dictionary && WMIsPLDictionary(shared_dict) &&
957 WMIsPLDictionary(db->dictionary)) {
958 WMMergePLDictionaries(shared_dict, db->dictionary, True);
959 WMReleasePropList(db->dictionary);
960 db->dictionary = shared_dict;
961 if (stbuf.st_mtime > db->timestamp)
962 db->timestamp = stbuf.st_mtime;
963 } else if (!db->dictionary) {
964 db->dictionary = shared_dict;
965 if (stbuf.st_mtime > db->timestamp)
966 db->timestamp = stbuf.st_mtime;
969 return db;
972 void wReadStaticDefaults(WMPropList * dict)
974 WMPropList *plvalue;
975 WDefaultEntry *entry;
976 unsigned int i;
977 void *tdata;
979 for (i = 0; i < wlengthof(staticOptionList); i++) {
980 entry = &staticOptionList[i];
982 if (dict)
983 plvalue = WMGetFromPLDictionary(dict, entry->plkey);
984 else
985 plvalue = NULL;
987 /* no default in the DB. Use builtin default */
988 if (!plvalue)
989 plvalue = entry->plvalue;
991 if (plvalue) {
992 /* convert data */
993 (*entry->convert) (NULL, entry, plvalue, entry->addr, &tdata);
994 if (entry->update)
995 (*entry->update) (NULL, entry, tdata, entry->extra_data);
1000 void wDefaultsCheckDomains(void* arg)
1002 WScreen *scr;
1003 struct stat stbuf;
1004 WMPropList *shared_dict = NULL;
1005 WMPropList *dict;
1006 int i;
1008 /* Parameter not used, but tell the compiler that it is ok */
1009 (void) arg;
1011 if (stat(w_global.domain.wmaker->path, &stbuf) >= 0 && w_global.domain.wmaker->timestamp < stbuf.st_mtime) {
1012 w_global.domain.wmaker->timestamp = stbuf.st_mtime;
1014 /* Global dictionary */
1015 shared_dict = readGlobalDomain("WindowMaker", True);
1017 /* User dictionary */
1018 dict = WMReadPropListFromFile(w_global.domain.wmaker->path);
1020 if (dict) {
1021 if (!WMIsPLDictionary(dict)) {
1022 WMReleasePropList(dict);
1023 dict = NULL;
1024 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
1025 "WindowMaker", w_global.domain.wmaker->path);
1026 } else {
1027 if (shared_dict) {
1028 WMMergePLDictionaries(shared_dict, dict, True);
1029 WMReleasePropList(dict);
1030 dict = shared_dict;
1031 shared_dict = NULL;
1034 for (i = 0; i < w_global.screen_count; i++) {
1035 scr = wScreenWithNumber(i);
1036 if (scr)
1037 wReadDefaults(scr, dict);
1040 if (w_global.domain.wmaker->dictionary)
1041 WMReleasePropList(w_global.domain.wmaker->dictionary);
1043 w_global.domain.wmaker->dictionary = dict;
1045 } else {
1046 wwarning(_("could not load domain %s from user defaults database"), "WindowMaker");
1049 if (shared_dict)
1050 WMReleasePropList(shared_dict);
1054 if (stat(w_global.domain.window_attr->path, &stbuf) >= 0 && w_global.domain.window_attr->timestamp < stbuf.st_mtime) {
1055 /* global dictionary */
1056 shared_dict = readGlobalDomain("WMWindowAttributes", True);
1057 /* user dictionary */
1058 dict = WMReadPropListFromFile(w_global.domain.window_attr->path);
1059 if (dict) {
1060 if (!WMIsPLDictionary(dict)) {
1061 WMReleasePropList(dict);
1062 dict = NULL;
1063 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
1064 "WMWindowAttributes", w_global.domain.window_attr->path);
1065 } else {
1066 if (shared_dict) {
1067 WMMergePLDictionaries(shared_dict, dict, True);
1068 WMReleasePropList(dict);
1069 dict = shared_dict;
1070 shared_dict = NULL;
1073 if (w_global.domain.window_attr->dictionary)
1074 WMReleasePropList(w_global.domain.window_attr->dictionary);
1076 w_global.domain.window_attr->dictionary = dict;
1077 for (i = 0; i < w_global.screen_count; i++) {
1078 scr = wScreenWithNumber(i);
1079 if (scr) {
1080 wDefaultUpdateIcons(scr);
1082 /* Update the panel image if changed */
1083 /* Don't worry. If the image is the same these
1084 * functions will have no performance impact. */
1085 create_logo_image(scr);
1089 } else {
1090 wwarning(_("could not load domain %s from user defaults database"), "WMWindowAttributes");
1093 w_global.domain.window_attr->timestamp = stbuf.st_mtime;
1094 if (shared_dict)
1095 WMReleasePropList(shared_dict);
1098 if (stat(w_global.domain.root_menu->path, &stbuf) >= 0 && w_global.domain.root_menu->timestamp < stbuf.st_mtime) {
1099 dict = WMReadPropListFromFile(w_global.domain.root_menu->path);
1100 if (dict) {
1101 if (!WMIsPLArray(dict) && !WMIsPLString(dict)) {
1102 WMReleasePropList(dict);
1103 dict = NULL;
1104 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
1105 "WMRootMenu", w_global.domain.root_menu->path);
1106 } else {
1107 if (w_global.domain.root_menu->dictionary)
1108 WMReleasePropList(w_global.domain.root_menu->dictionary);
1110 w_global.domain.root_menu->dictionary = dict;
1111 wDefaultsMergeGlobalMenus(w_global.domain.root_menu);
1113 } else {
1114 wwarning(_("could not load domain %s from user defaults database"), "WMRootMenu");
1116 w_global.domain.root_menu->timestamp = stbuf.st_mtime;
1118 #ifndef HAVE_INOTIFY
1119 if (!arg)
1120 WMAddTimerHandler(DEFAULTS_CHECK_INTERVAL, wDefaultsCheckDomains, arg);
1121 #endif
1124 void wReadDefaults(WScreen * scr, WMPropList * new_dict)
1126 WMPropList *plvalue, *old_value;
1127 WDefaultEntry *entry;
1128 unsigned int i;
1129 int update_workspace_back = 0; /* kluge :/ */
1130 unsigned int needs_refresh;
1131 void *tdata;
1132 WMPropList *old_dict = (w_global.domain.wmaker->dictionary != new_dict ? w_global.domain.wmaker->dictionary : NULL);
1134 needs_refresh = 0;
1136 for (i = 0; i < wlengthof(optionList); i++) {
1137 entry = &optionList[i];
1139 if (new_dict)
1140 plvalue = WMGetFromPLDictionary(new_dict, entry->plkey);
1141 else
1142 plvalue = NULL;
1144 if (!old_dict)
1145 old_value = NULL;
1146 else
1147 old_value = WMGetFromPLDictionary(old_dict, entry->plkey);
1149 if (!plvalue && !old_value) {
1150 /* no default in the DB. Use builtin default */
1151 plvalue = entry->plvalue;
1152 if (plvalue && new_dict)
1153 WMPutInPLDictionary(new_dict, entry->plkey, plvalue);
1155 } else if (!plvalue) {
1156 /* value was deleted from DB. Keep current value */
1157 continue;
1158 } else if (!old_value) {
1159 /* set value for the 1st time */
1160 } else if (!WMIsPropListEqualTo(plvalue, old_value)) {
1161 /* value has changed */
1162 } else {
1163 if (strcmp(entry->key, "WorkspaceBack") == 0
1164 && update_workspace_back && scr->flags.backimage_helper_launched) {
1165 } else {
1166 /* value was not changed since last time */
1167 continue;
1171 if (plvalue) {
1172 /* convert data */
1173 if ((*entry->convert) (scr, entry, plvalue, entry->addr, &tdata)) {
1175 * If the WorkspaceSpecificBack data has been changed
1176 * so that the helper will be launched now, we must be
1177 * sure to send the default background texture config
1178 * to the helper.
1180 if (strcmp(entry->key, "WorkspaceSpecificBack") == 0 &&
1181 !scr->flags.backimage_helper_launched)
1182 update_workspace_back = 1;
1184 if (entry->update)
1185 needs_refresh |= (*entry->update) (scr, entry, tdata, entry->extra_data);
1192 * Backward Compatibility:
1193 * the option 'apercu_size' used to be coded as a multiple of the icon size in v0.95.6
1194 * it is now expressed directly in pixels, but to avoid breaking user's setting we check
1195 * for old coding and convert it now.
1196 * This code should probably stay for at least 2 years, you should not consider removing
1197 * it before year 2017
1199 if (wPreferences.apercu_size < 24) {
1200 /* 24 is the minimum icon size proposed in WPref's settings */
1201 wPreferences.apercu_size *= wPreferences.icon_size;
1202 if (wPreferences.miniwin_apercu_balloon)
1203 wwarning(_("your ApercuSize setting is using old syntax, it is converted to %d pixels; consider running WPrefs.app to update your settings"),
1204 wPreferences.apercu_size);
1207 if (needs_refresh != 0 && !scr->flags.startup) {
1208 int foo;
1210 foo = 0;
1211 if (needs_refresh & REFRESH_MENU_TITLE_TEXTURE)
1212 foo |= WTextureSettings;
1213 if (needs_refresh & REFRESH_MENU_TITLE_FONT)
1214 foo |= WFontSettings;
1215 if (needs_refresh & REFRESH_MENU_TITLE_COLOR)
1216 foo |= WColorSettings;
1217 if (foo)
1218 WMPostNotificationName(WNMenuTitleAppearanceSettingsChanged, NULL,
1219 (void *)(uintptr_t) foo);
1221 foo = 0;
1222 if (needs_refresh & REFRESH_MENU_TEXTURE)
1223 foo |= WTextureSettings;
1224 if (needs_refresh & REFRESH_MENU_FONT)
1225 foo |= WFontSettings;
1226 if (needs_refresh & REFRESH_MENU_COLOR)
1227 foo |= WColorSettings;
1228 if (foo)
1229 WMPostNotificationName(WNMenuAppearanceSettingsChanged, NULL, (void *)(uintptr_t) foo);
1231 foo = 0;
1232 if (needs_refresh & REFRESH_WINDOW_FONT)
1233 foo |= WFontSettings;
1234 if (needs_refresh & REFRESH_WINDOW_TEXTURES)
1235 foo |= WTextureSettings;
1236 if (needs_refresh & REFRESH_WINDOW_TITLE_COLOR)
1237 foo |= WColorSettings;
1238 if (foo)
1239 WMPostNotificationName(WNWindowAppearanceSettingsChanged, NULL, (void *)(uintptr_t) foo);
1241 if (!(needs_refresh & REFRESH_ICON_TILE)) {
1242 foo = 0;
1243 if (needs_refresh & REFRESH_ICON_FONT)
1244 foo |= WFontSettings;
1245 if (needs_refresh & REFRESH_ICON_TITLE_COLOR)
1246 foo |= WTextureSettings;
1247 if (needs_refresh & REFRESH_ICON_TITLE_BACK)
1248 foo |= WTextureSettings;
1249 if (foo)
1250 WMPostNotificationName(WNIconAppearanceSettingsChanged, NULL,
1251 (void *)(uintptr_t) foo);
1253 if (needs_refresh & REFRESH_ICON_TILE)
1254 WMPostNotificationName(WNIconTileSettingsChanged, NULL, NULL);
1256 if (needs_refresh & REFRESH_WORKSPACE_MENU) {
1257 if (scr->workspace_menu)
1258 wWorkspaceMenuUpdate(scr, scr->workspace_menu);
1259 if (scr->clip_ws_menu)
1260 wWorkspaceMenuUpdate(scr, scr->clip_ws_menu);
1261 if (scr->workspace_submenu)
1262 scr->workspace_submenu->flags.realized = 0;
1263 if (scr->clip_submenu)
1264 scr->clip_submenu->flags.realized = 0;
1269 void wDefaultUpdateIcons(WScreen *scr)
1271 WAppIcon *aicon = scr->app_icon_list;
1272 WDrawerChain *dc;
1273 WWindow *wwin = scr->focused_window;
1275 while (aicon) {
1276 /* Get the application icon, default included */
1277 wIconChangeImageFile(aicon->icon, NULL);
1278 wAppIconPaint(aicon);
1279 aicon = aicon->next;
1282 if (!wPreferences.flags.noclip || wPreferences.flags.clip_merged_in_dock)
1283 wClipIconPaint(scr->clip_icon);
1285 for (dc = scr->drawers; dc != NULL; dc = dc->next)
1286 wDrawerIconPaint(dc->adrawer->icon_array[0]);
1288 while (wwin) {
1289 if (wwin->icon && wwin->flags.miniaturized)
1290 wIconChangeImageFile(wwin->icon, NULL);
1291 wwin = wwin->prev;
1295 /* --------------------------- Local ----------------------- */
1297 #define GET_STRING_OR_DEFAULT(x, var) if (!WMIsPLString(value)) { \
1298 wwarning(_("Wrong option format for key \"%s\". Should be %s."), \
1299 entry->key, x); \
1300 wwarning(_("using default \"%s\" instead"), entry->default_value); \
1301 var = entry->default_value;\
1302 } else var = WMGetFromPLString(value)\
1305 static int string2index(WMPropList *key, WMPropList *val, const char *def, WOptionEnumeration * values)
1307 char *str;
1308 WOptionEnumeration *v;
1309 char buffer[TOTAL_VALUES_LENGTH];
1311 if (WMIsPLString(val) && (str = WMGetFromPLString(val))) {
1312 for (v = values; v->string != NULL; v++) {
1313 if (strcasecmp(v->string, str) == 0)
1314 return v->value;
1318 buffer[0] = 0;
1319 for (v = values; v->string != NULL; v++) {
1320 if (!v->is_alias) {
1321 if (buffer[0] != 0)
1322 strcat(buffer, ", ");
1323 snprintf(buffer+strlen(buffer),
1324 sizeof(buffer)-strlen(buffer)-1, "\"%s\"", v->string);
1327 wwarning(_("wrong option value for key \"%s\"; got \"%s\", should be one of %s."),
1328 WMGetFromPLString(key),
1329 WMIsPLString(val) ? WMGetFromPLString(val) : "(unknown)",
1330 buffer);
1332 if (def) {
1333 return string2index(key, val, NULL, values);
1336 return -1;
1340 * value - is the value in the defaults DB
1341 * addr - is the address to store the data
1342 * ret - is the address to store a pointer to a temporary buffer. ret
1343 * must not be freed and is used by the set functions
1345 static int getBool(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1347 static char data;
1348 const char *val;
1349 int second_pass = 0;
1351 /* Parameter not used, but tell the compiler that it is ok */
1352 (void) scr;
1354 GET_STRING_OR_DEFAULT("Boolean", val);
1356 again:
1357 if ((val[1] == '\0' && (val[0] == 'y' || val[0] == 'Y'))
1358 || strcasecmp(val, "YES") == 0) {
1360 data = 1;
1361 } else if ((val[1] == '\0' && (val[0] == 'n' || val[0] == 'N'))
1362 || strcasecmp(val, "NO") == 0) {
1363 data = 0;
1364 } else {
1365 int i;
1366 if (sscanf(val, "%i", &i) == 1) {
1367 if (i != 0)
1368 data = 1;
1369 else
1370 data = 0;
1371 } else {
1372 wwarning(_("can't convert \"%s\" to boolean for key \"%s\""), val, entry->key);
1373 if (second_pass == 0) {
1374 val = WMGetFromPLString(entry->plvalue);
1375 second_pass = 1;
1376 wwarning(_("using default \"%s\" instead"), val);
1377 goto again;
1379 return False;
1383 if (ret)
1384 *ret = &data;
1385 if (addr)
1386 *(char *)addr = data;
1388 return True;
1391 static int getInt(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1393 static int data;
1394 const char *val;
1396 /* Parameter not used, but tell the compiler that it is ok */
1397 (void) scr;
1399 GET_STRING_OR_DEFAULT("Integer", val);
1401 if (sscanf(val, "%i", &data) != 1) {
1402 wwarning(_("can't convert \"%s\" to integer for key \"%s\""), val, entry->key);
1403 val = WMGetFromPLString(entry->plvalue);
1404 wwarning(_("using default \"%s\" instead"), val);
1405 if (sscanf(val, "%i", &data) != 1) {
1406 return False;
1410 if (ret)
1411 *ret = &data;
1412 if (addr)
1413 *(int *)addr = data;
1415 return True;
1418 static int getCoord(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1420 static WCoord data;
1421 char *val_x, *val_y;
1422 int nelem, changed = 0;
1423 WMPropList *elem_x, *elem_y;
1425 again:
1426 if (!WMIsPLArray(value)) {
1427 wwarning(_("Wrong option format for key \"%s\". Should be %s."), entry->key, "Coordinate");
1428 if (changed == 0) {
1429 value = entry->plvalue;
1430 changed = 1;
1431 wwarning(_("using default \"%s\" instead"), entry->default_value);
1432 goto again;
1434 return False;
1437 nelem = WMGetPropListItemCount(value);
1438 if (nelem != 2) {
1439 wwarning(_("Incorrect number of elements in array for key \"%s\"."), entry->key);
1440 if (changed == 0) {
1441 value = entry->plvalue;
1442 changed = 1;
1443 wwarning(_("using default \"%s\" instead"), entry->default_value);
1444 goto again;
1446 return False;
1449 elem_x = WMGetFromPLArray(value, 0);
1450 elem_y = WMGetFromPLArray(value, 1);
1452 if (!elem_x || !elem_y || !WMIsPLString(elem_x) || !WMIsPLString(elem_y)) {
1453 wwarning(_("Wrong value for key \"%s\". Should be Coordinate."), entry->key);
1454 if (changed == 0) {
1455 value = entry->plvalue;
1456 changed = 1;
1457 wwarning(_("using default \"%s\" instead"), entry->default_value);
1458 goto again;
1460 return False;
1463 val_x = WMGetFromPLString(elem_x);
1464 val_y = WMGetFromPLString(elem_y);
1466 if (sscanf(val_x, "%i", &data.x) != 1 || sscanf(val_y, "%i", &data.y) != 1) {
1467 wwarning(_("can't convert array to integers for \"%s\"."), entry->key);
1468 if (changed == 0) {
1469 value = entry->plvalue;
1470 changed = 1;
1471 wwarning(_("using default \"%s\" instead"), entry->default_value);
1472 goto again;
1474 return False;
1477 if (data.x < 0)
1478 data.x = 0;
1479 else if (data.x > scr->scr_width / 3)
1480 data.x = scr->scr_width / 3;
1481 if (data.y < 0)
1482 data.y = 0;
1483 else if (data.y > scr->scr_height / 3)
1484 data.y = scr->scr_height / 3;
1486 if (ret)
1487 *ret = &data;
1488 if (addr)
1489 *(WCoord *) addr = data;
1491 return True;
1494 static int getPropList(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1496 /* Parameter not used, but tell the compiler that it is ok */
1497 (void) scr;
1498 (void) entry;
1499 (void) addr;
1501 WMRetainPropList(value);
1503 *ret = value;
1505 return True;
1508 static int getPathList(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1510 static char *data;
1511 int i, count, len;
1512 char *ptr;
1513 WMPropList *d;
1514 int changed = 0;
1516 /* Parameter not used, but tell the compiler that it is ok */
1517 (void) scr;
1518 (void) ret;
1520 again:
1521 if (!WMIsPLArray(value)) {
1522 wwarning(_("Wrong option format for key \"%s\". Should be %s."), entry->key, "an array of paths");
1523 if (changed == 0) {
1524 value = entry->plvalue;
1525 changed = 1;
1526 wwarning(_("using default \"%s\" instead"), entry->default_value);
1527 goto again;
1529 return False;
1532 i = 0;
1533 count = WMGetPropListItemCount(value);
1534 if (count < 1) {
1535 if (changed == 0) {
1536 value = entry->plvalue;
1537 changed = 1;
1538 wwarning(_("using default \"%s\" instead"), entry->default_value);
1539 goto again;
1541 return False;
1544 len = 0;
1545 for (i = 0; i < count; i++) {
1546 d = WMGetFromPLArray(value, i);
1547 if (!d || !WMIsPLString(d)) {
1548 count = i;
1549 break;
1551 len += strlen(WMGetFromPLString(d)) + 1;
1554 ptr = data = wmalloc(len + 1);
1556 for (i = 0; i < count; i++) {
1557 d = WMGetFromPLArray(value, i);
1558 if (!d || !WMIsPLString(d)) {
1559 break;
1561 strcpy(ptr, WMGetFromPLString(d));
1562 ptr += strlen(WMGetFromPLString(d));
1563 *ptr = ':';
1564 ptr++;
1566 ptr--;
1567 *(ptr--) = 0;
1569 if (*(char **)addr != NULL) {
1570 wfree(*(char **)addr);
1572 *(char **)addr = data;
1574 return True;
1577 static int getEnum(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1579 static signed char data;
1581 /* Parameter not used, but tell the compiler that it is ok */
1582 (void) scr;
1584 data = string2index(entry->plkey, value, entry->default_value, (WOptionEnumeration *) entry->extra_data);
1585 if (data < 0)
1586 return False;
1588 if (ret)
1589 *ret = &data;
1590 if (addr)
1591 *(signed char *)addr = data;
1593 return True;
1597 * (solid <color>)
1598 * (hgradient <color> <color>)
1599 * (vgradient <color> <color>)
1600 * (dgradient <color> <color>)
1601 * (mhgradient <color> <color> ...)
1602 * (mvgradient <color> <color> ...)
1603 * (mdgradient <color> <color> ...)
1604 * (igradient <color1> <color1> <thickness1> <color2> <color2> <thickness2>)
1605 * (tpixmap <file> <color>)
1606 * (spixmap <file> <color>)
1607 * (cpixmap <file> <color>)
1608 * (thgradient <file> <opaqueness> <color> <color>)
1609 * (tvgradient <file> <opaqueness> <color> <color>)
1610 * (tdgradient <file> <opaqueness> <color> <color>)
1611 * (function <lib> <function> ...)
1614 static WTexture *parse_texture(WScreen * scr, WMPropList * pl)
1616 WMPropList *elem;
1617 char *val;
1618 int nelem;
1619 WTexture *texture = NULL;
1621 nelem = WMGetPropListItemCount(pl);
1622 if (nelem < 1)
1623 return NULL;
1625 elem = WMGetFromPLArray(pl, 0);
1626 if (!elem || !WMIsPLString(elem))
1627 return NULL;
1628 val = WMGetFromPLString(elem);
1630 if (strcasecmp(val, "solid") == 0) {
1631 XColor color;
1633 if (nelem != 2)
1634 return NULL;
1636 /* get color */
1638 elem = WMGetFromPLArray(pl, 1);
1639 if (!elem || !WMIsPLString(elem))
1640 return NULL;
1641 val = WMGetFromPLString(elem);
1643 if (!XParseColor(dpy, scr->w_colormap, val, &color)) {
1644 wwarning(_("\"%s\" is not a valid color name"), val);
1645 return NULL;
1648 texture = (WTexture *) wTextureMakeSolid(scr, &color);
1649 } else if (strcasecmp(val, "dgradient") == 0
1650 || strcasecmp(val, "vgradient") == 0 || strcasecmp(val, "hgradient") == 0) {
1651 RColor color1, color2;
1652 XColor xcolor;
1653 int type;
1655 if (nelem != 3) {
1656 wwarning(_("bad number of arguments in gradient specification"));
1657 return NULL;
1660 if (val[0] == 'd' || val[0] == 'D')
1661 type = WTEX_DGRADIENT;
1662 else if (val[0] == 'h' || val[0] == 'H')
1663 type = WTEX_HGRADIENT;
1664 else
1665 type = WTEX_VGRADIENT;
1667 /* get from color */
1668 elem = WMGetFromPLArray(pl, 1);
1669 if (!elem || !WMIsPLString(elem))
1670 return NULL;
1671 val = WMGetFromPLString(elem);
1673 if (!XParseColor(dpy, scr->w_colormap, val, &xcolor)) {
1674 wwarning(_("\"%s\" is not a valid color name"), val);
1675 return NULL;
1677 color1.alpha = 255;
1678 color1.red = xcolor.red >> 8;
1679 color1.green = xcolor.green >> 8;
1680 color1.blue = xcolor.blue >> 8;
1682 /* get to color */
1683 elem = WMGetFromPLArray(pl, 2);
1684 if (!elem || !WMIsPLString(elem)) {
1685 return NULL;
1687 val = WMGetFromPLString(elem);
1689 if (!XParseColor(dpy, scr->w_colormap, val, &xcolor)) {
1690 wwarning(_("\"%s\" is not a valid color name"), val);
1691 return NULL;
1693 color2.alpha = 255;
1694 color2.red = xcolor.red >> 8;
1695 color2.green = xcolor.green >> 8;
1696 color2.blue = xcolor.blue >> 8;
1698 texture = (WTexture *) wTextureMakeGradient(scr, type, &color1, &color2);
1700 } else if (strcasecmp(val, "igradient") == 0) {
1701 RColor colors1[2], colors2[2];
1702 int th1, th2;
1703 XColor xcolor;
1704 int i;
1706 if (nelem != 7) {
1707 wwarning(_("bad number of arguments in gradient specification"));
1708 return NULL;
1711 /* get from color */
1712 for (i = 0; i < 2; i++) {
1713 elem = WMGetFromPLArray(pl, 1 + i);
1714 if (!elem || !WMIsPLString(elem))
1715 return NULL;
1716 val = WMGetFromPLString(elem);
1718 if (!XParseColor(dpy, scr->w_colormap, val, &xcolor)) {
1719 wwarning(_("\"%s\" is not a valid color name"), val);
1720 return NULL;
1722 colors1[i].alpha = 255;
1723 colors1[i].red = xcolor.red >> 8;
1724 colors1[i].green = xcolor.green >> 8;
1725 colors1[i].blue = xcolor.blue >> 8;
1727 elem = WMGetFromPLArray(pl, 3);
1728 if (!elem || !WMIsPLString(elem))
1729 return NULL;
1730 val = WMGetFromPLString(elem);
1731 th1 = atoi(val);
1733 /* get from color */
1734 for (i = 0; i < 2; i++) {
1735 elem = WMGetFromPLArray(pl, 4 + i);
1736 if (!elem || !WMIsPLString(elem))
1737 return NULL;
1738 val = WMGetFromPLString(elem);
1740 if (!XParseColor(dpy, scr->w_colormap, val, &xcolor)) {
1741 wwarning(_("\"%s\" is not a valid color name"), val);
1742 return NULL;
1744 colors2[i].alpha = 255;
1745 colors2[i].red = xcolor.red >> 8;
1746 colors2[i].green = xcolor.green >> 8;
1747 colors2[i].blue = xcolor.blue >> 8;
1749 elem = WMGetFromPLArray(pl, 6);
1750 if (!elem || !WMIsPLString(elem))
1751 return NULL;
1752 val = WMGetFromPLString(elem);
1753 th2 = atoi(val);
1755 texture = (WTexture *) wTextureMakeIGradient(scr, th1, colors1, th2, colors2);
1757 } else if (strcasecmp(val, "mhgradient") == 0
1758 || strcasecmp(val, "mvgradient") == 0 || strcasecmp(val, "mdgradient") == 0) {
1759 XColor color;
1760 RColor **colors;
1761 int i, count;
1762 int type;
1764 if (nelem < 3) {
1765 wwarning(_("too few arguments in multicolor gradient specification"));
1766 return NULL;
1769 if (val[1] == 'h' || val[1] == 'H')
1770 type = WTEX_MHGRADIENT;
1771 else if (val[1] == 'v' || val[1] == 'V')
1772 type = WTEX_MVGRADIENT;
1773 else
1774 type = WTEX_MDGRADIENT;
1776 count = nelem - 1;
1778 colors = wmalloc(sizeof(RColor *) * (count + 1));
1780 for (i = 0; i < count; i++) {
1781 elem = WMGetFromPLArray(pl, i + 1);
1782 if (!elem || !WMIsPLString(elem)) {
1783 for (--i; i >= 0; --i) {
1784 wfree(colors[i]);
1786 wfree(colors);
1787 return NULL;
1789 val = WMGetFromPLString(elem);
1791 if (!XParseColor(dpy, scr->w_colormap, val, &color)) {
1792 wwarning(_("\"%s\" is not a valid color name"), val);
1793 for (--i; i >= 0; --i) {
1794 wfree(colors[i]);
1796 wfree(colors);
1797 return NULL;
1798 } else {
1799 colors[i] = wmalloc(sizeof(RColor));
1800 colors[i]->red = color.red >> 8;
1801 colors[i]->green = color.green >> 8;
1802 colors[i]->blue = color.blue >> 8;
1805 colors[i] = NULL;
1807 texture = (WTexture *) wTextureMakeMGradient(scr, type, colors);
1808 } else if (strcasecmp(val, "spixmap") == 0 ||
1809 strcasecmp(val, "cpixmap") == 0 || strcasecmp(val, "tpixmap") == 0) {
1810 XColor color;
1811 int type;
1813 if (nelem != 3)
1814 return NULL;
1816 if (val[0] == 's' || val[0] == 'S')
1817 type = WTP_SCALE;
1818 else if (val[0] == 'c' || val[0] == 'C')
1819 type = WTP_CENTER;
1820 else
1821 type = WTP_TILE;
1823 /* get color */
1824 elem = WMGetFromPLArray(pl, 2);
1825 if (!elem || !WMIsPLString(elem)) {
1826 return NULL;
1828 val = WMGetFromPLString(elem);
1830 if (!XParseColor(dpy, scr->w_colormap, val, &color)) {
1831 wwarning(_("\"%s\" is not a valid color name"), val);
1832 return NULL;
1835 /* file name */
1836 elem = WMGetFromPLArray(pl, 1);
1837 if (!elem || !WMIsPLString(elem))
1838 return NULL;
1839 val = WMGetFromPLString(elem);
1841 texture = (WTexture *) wTextureMakePixmap(scr, type, val, &color);
1842 } else if (strcasecmp(val, "thgradient") == 0
1843 || strcasecmp(val, "tvgradient") == 0 || strcasecmp(val, "tdgradient") == 0) {
1844 RColor color1, color2;
1845 XColor xcolor;
1846 int opacity;
1847 int style;
1849 if (val[1] == 'h' || val[1] == 'H')
1850 style = WTEX_THGRADIENT;
1851 else if (val[1] == 'v' || val[1] == 'V')
1852 style = WTEX_TVGRADIENT;
1853 else
1854 style = WTEX_TDGRADIENT;
1856 if (nelem != 5) {
1857 wwarning(_("bad number of arguments in textured gradient specification"));
1858 return NULL;
1861 /* get from color */
1862 elem = WMGetFromPLArray(pl, 3);
1863 if (!elem || !WMIsPLString(elem))
1864 return NULL;
1865 val = WMGetFromPLString(elem);
1867 if (!XParseColor(dpy, scr->w_colormap, val, &xcolor)) {
1868 wwarning(_("\"%s\" is not a valid color name"), val);
1869 return NULL;
1871 color1.alpha = 255;
1872 color1.red = xcolor.red >> 8;
1873 color1.green = xcolor.green >> 8;
1874 color1.blue = xcolor.blue >> 8;
1876 /* get to color */
1877 elem = WMGetFromPLArray(pl, 4);
1878 if (!elem || !WMIsPLString(elem)) {
1879 return NULL;
1881 val = WMGetFromPLString(elem);
1883 if (!XParseColor(dpy, scr->w_colormap, val, &xcolor)) {
1884 wwarning(_("\"%s\" is not a valid color name"), val);
1885 return NULL;
1887 color2.alpha = 255;
1888 color2.red = xcolor.red >> 8;
1889 color2.green = xcolor.green >> 8;
1890 color2.blue = xcolor.blue >> 8;
1892 /* get opacity */
1893 elem = WMGetFromPLArray(pl, 2);
1894 if (!elem || !WMIsPLString(elem))
1895 opacity = 128;
1896 else
1897 val = WMGetFromPLString(elem);
1899 if (!val || (opacity = atoi(val)) < 0 || opacity > 255) {
1900 wwarning(_("bad opacity value for tgradient texture \"%s\". Should be [0..255]"), val);
1901 opacity = 128;
1904 /* get file name */
1905 elem = WMGetFromPLArray(pl, 1);
1906 if (!elem || !WMIsPLString(elem))
1907 return NULL;
1908 val = WMGetFromPLString(elem);
1910 texture = (WTexture *) wTextureMakeTGradient(scr, style, &color1, &color2, val, opacity);
1911 } else if (strcasecmp(val, "function") == 0) {
1912 /* Leave this in to handle the unlikely case of
1913 * someone actually having function textures configured */
1914 wwarning("function texture support has been removed");
1915 return NULL;
1916 } else {
1917 wwarning(_("invalid texture type %s"), val);
1918 return NULL;
1920 return texture;
1923 static int getTexture(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1925 static WTexture *texture;
1926 int changed = 0;
1928 again:
1929 if (!WMIsPLArray(value)) {
1930 wwarning(_("Wrong option format for key \"%s\". Should be %s."), entry->key, "Texture");
1931 if (changed == 0) {
1932 value = entry->plvalue;
1933 changed = 1;
1934 wwarning(_("using default \"%s\" instead"), entry->default_value);
1935 goto again;
1937 return False;
1940 if (strcmp(entry->key, "WidgetColor") == 0 && !changed) {
1941 WMPropList *pl;
1943 pl = WMGetFromPLArray(value, 0);
1944 if (!pl || !WMIsPLString(pl) || !WMGetFromPLString(pl)
1945 || strcasecmp(WMGetFromPLString(pl), "solid") != 0) {
1946 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1947 entry->key, "Solid Texture");
1949 value = entry->plvalue;
1950 changed = 1;
1951 wwarning(_("using default \"%s\" instead"), entry->default_value);
1952 goto again;
1956 texture = parse_texture(scr, value);
1958 if (!texture) {
1959 wwarning(_("Error in texture specification for key \"%s\""), entry->key);
1960 if (changed == 0) {
1961 value = entry->plvalue;
1962 changed = 1;
1963 wwarning(_("using default \"%s\" instead"), entry->default_value);
1964 goto again;
1966 return False;
1969 if (ret)
1970 *ret = &texture;
1972 if (addr)
1973 *(WTexture **) addr = texture;
1975 return True;
1978 static int getWSBackground(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1980 WMPropList *elem;
1981 int changed = 0;
1982 char *val;
1983 int nelem;
1985 /* Parameter not used, but tell the compiler that it is ok */
1986 (void) scr;
1987 (void) addr;
1989 again:
1990 if (!WMIsPLArray(value)) {
1991 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1992 "WorkspaceBack", "Texture or None");
1993 if (changed == 0) {
1994 value = entry->plvalue;
1995 changed = 1;
1996 wwarning(_("using default \"%s\" instead"), entry->default_value);
1997 goto again;
1999 return False;
2002 /* only do basic error checking and verify for None texture */
2004 nelem = WMGetPropListItemCount(value);
2005 if (nelem > 0) {
2006 elem = WMGetFromPLArray(value, 0);
2007 if (!elem || !WMIsPLString(elem)) {
2008 wwarning(_("Wrong type for workspace background. Should be a texture type."));
2009 if (changed == 0) {
2010 value = entry->plvalue;
2011 changed = 1;
2012 wwarning(_("using default \"%s\" instead"), entry->default_value);
2013 goto again;
2015 return False;
2017 val = WMGetFromPLString(elem);
2019 if (strcasecmp(val, "None") == 0)
2020 return True;
2022 *ret = WMRetainPropList(value);
2024 return True;
2027 static int
2028 getWSSpecificBackground(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
2030 WMPropList *elem;
2031 int nelem;
2032 int changed = 0;
2034 /* Parameter not used, but tell the compiler that it is ok */
2035 (void) scr;
2036 (void) addr;
2038 again:
2039 if (!WMIsPLArray(value)) {
2040 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
2041 "WorkspaceSpecificBack", "an array of textures");
2042 if (changed == 0) {
2043 value = entry->plvalue;
2044 changed = 1;
2045 wwarning(_("using default \"%s\" instead"), entry->default_value);
2046 goto again;
2048 return False;
2051 /* only do basic error checking and verify for None texture */
2053 nelem = WMGetPropListItemCount(value);
2054 if (nelem > 0) {
2055 while (nelem--) {
2056 elem = WMGetFromPLArray(value, nelem);
2057 if (!elem || !WMIsPLArray(elem)) {
2058 wwarning(_("Wrong type for background of workspace %i. Should be a texture."),
2059 nelem);
2064 *ret = WMRetainPropList(value);
2066 #ifdef notworking
2068 * Kluge to force wmsetbg helper to set the default background.
2069 * If the WorkspaceSpecificBack is changed once wmaker has started,
2070 * the WorkspaceBack won't be sent to the helper, unless the user
2071 * changes it's value too. So, we must force this by removing the
2072 * value from the defaults DB.
2074 if (!scr->flags.backimage_helper_launched && !scr->flags.startup) {
2075 WMPropList *key = WMCreatePLString("WorkspaceBack");
2077 WMRemoveFromPLDictionary(w_global.domain.wmaker->dictionary, key);
2079 WMReleasePropList(key);
2081 #endif
2082 return True;
2085 static int getFont(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
2087 static WMFont *font;
2088 const char *val;
2090 (void) addr;
2092 GET_STRING_OR_DEFAULT("Font", val);
2094 font = WMCreateFont(scr->wmscreen, val);
2095 if (!font)
2096 font = WMCreateFont(scr->wmscreen, "fixed");
2098 if (!font) {
2099 wfatal(_("could not load any usable font!!!"));
2100 exit(1);
2103 if (ret)
2104 *ret = font;
2106 /* can't assign font value outside update function */
2107 wassertrv(addr == NULL, True);
2109 return True;
2112 static int getColor(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
2114 static XColor color;
2115 const char *val;
2116 int second_pass = 0;
2118 (void) addr;
2120 GET_STRING_OR_DEFAULT("Color", val);
2122 again:
2123 if (!wGetColor(scr, val, &color)) {
2124 wwarning(_("could not get color for key \"%s\""), entry->key);
2125 if (second_pass == 0) {
2126 val = WMGetFromPLString(entry->plvalue);
2127 second_pass = 1;
2128 wwarning(_("using default \"%s\" instead"), val);
2129 goto again;
2131 return False;
2134 if (ret)
2135 *ret = &color;
2137 assert(addr == NULL);
2139 if (addr)
2140 *(unsigned long*)addr = pixel;
2143 return True;
2146 static int getKeybind(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
2148 static WShortKey shortcut;
2149 KeySym ksym;
2150 const char *val;
2151 char *k;
2152 char buf[MAX_SHORTCUT_LENGTH], *b;
2154 /* Parameter not used, but tell the compiler that it is ok */
2155 (void) scr;
2156 (void) addr;
2158 GET_STRING_OR_DEFAULT("Key spec", val);
2160 if (!val || strcasecmp(val, "NONE") == 0) {
2161 shortcut.keycode = 0;
2162 shortcut.modifier = 0;
2163 if (ret)
2164 *ret = &shortcut;
2165 return True;
2168 wstrlcpy(buf, val, MAX_SHORTCUT_LENGTH);
2170 b = (char *)buf;
2172 /* get modifiers */
2173 shortcut.modifier = 0;
2174 while ((k = strchr(b, '+')) != NULL) {
2175 int mod;
2177 *k = 0;
2178 mod = wXModifierFromKey(b);
2179 if (mod < 0) {
2180 wwarning(_("%s: invalid key modifier \"%s\""), entry->key, b);
2181 return False;
2183 shortcut.modifier |= mod;
2185 b = k + 1;
2188 /* get key */
2189 ksym = XStringToKeysym(b);
2191 if (ksym == NoSymbol) {
2192 wwarning(_("%s:invalid kbd shortcut specification \"%s\""), entry->key, val);
2193 return False;
2196 shortcut.keycode = XKeysymToKeycode(dpy, ksym);
2197 if (shortcut.keycode == 0) {
2198 wwarning(_("%s:invalid key in shortcut \"%s\""), entry->key, val);
2199 return False;
2202 if (ret)
2203 *ret = &shortcut;
2205 return True;
2208 static int getModMask(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
2210 static int mask;
2211 const char *str;
2213 /* Parameter not used, but tell the compiler that it is ok */
2214 (void) scr;
2216 GET_STRING_OR_DEFAULT("Modifier Key", str);
2218 if (!str)
2219 return False;
2221 mask = wXModifierFromKey(str);
2222 if (mask < 0) {
2223 wwarning(_("%s: modifier key %s is not valid"), entry->key, str);
2224 mask = 0;
2225 return False;
2228 if (addr)
2229 *(int *)addr = mask;
2231 if (ret)
2232 *ret = &mask;
2234 return True;
2237 # include <X11/cursorfont.h>
2238 typedef struct {
2239 const char *name;
2240 int id;
2241 } WCursorLookup;
2243 #define CURSOR_ID_NONE (XC_num_glyphs)
2245 static const WCursorLookup cursor_table[] = {
2246 {"X_cursor", XC_X_cursor},
2247 {"arrow", XC_arrow},
2248 {"based_arrow_down", XC_based_arrow_down},
2249 {"based_arrow_up", XC_based_arrow_up},
2250 {"boat", XC_boat},
2251 {"bogosity", XC_bogosity},
2252 {"bottom_left_corner", XC_bottom_left_corner},
2253 {"bottom_right_corner", XC_bottom_right_corner},
2254 {"bottom_side", XC_bottom_side},
2255 {"bottom_tee", XC_bottom_tee},
2256 {"box_spiral", XC_box_spiral},
2257 {"center_ptr", XC_center_ptr},
2258 {"circle", XC_circle},
2259 {"clock", XC_clock},
2260 {"coffee_mug", XC_coffee_mug},
2261 {"cross", XC_cross},
2262 {"cross_reverse", XC_cross_reverse},
2263 {"crosshair", XC_crosshair},
2264 {"diamond_cross", XC_diamond_cross},
2265 {"dot", XC_dot},
2266 {"dotbox", XC_dotbox},
2267 {"double_arrow", XC_double_arrow},
2268 {"draft_large", XC_draft_large},
2269 {"draft_small", XC_draft_small},
2270 {"draped_box", XC_draped_box},
2271 {"exchange", XC_exchange},
2272 {"fleur", XC_fleur},
2273 {"gobbler", XC_gobbler},
2274 {"gumby", XC_gumby},
2275 {"hand1", XC_hand1},
2276 {"hand2", XC_hand2},
2277 {"heart", XC_heart},
2278 {"icon", XC_icon},
2279 {"iron_cross", XC_iron_cross},
2280 {"left_ptr", XC_left_ptr},
2281 {"left_side", XC_left_side},
2282 {"left_tee", XC_left_tee},
2283 {"leftbutton", XC_leftbutton},
2284 {"ll_angle", XC_ll_angle},
2285 {"lr_angle", XC_lr_angle},
2286 {"man", XC_man},
2287 {"middlebutton", XC_middlebutton},
2288 {"mouse", XC_mouse},
2289 {"pencil", XC_pencil},
2290 {"pirate", XC_pirate},
2291 {"plus", XC_plus},
2292 {"question_arrow", XC_question_arrow},
2293 {"right_ptr", XC_right_ptr},
2294 {"right_side", XC_right_side},
2295 {"right_tee", XC_right_tee},
2296 {"rightbutton", XC_rightbutton},
2297 {"rtl_logo", XC_rtl_logo},
2298 {"sailboat", XC_sailboat},
2299 {"sb_down_arrow", XC_sb_down_arrow},
2300 {"sb_h_double_arrow", XC_sb_h_double_arrow},
2301 {"sb_left_arrow", XC_sb_left_arrow},
2302 {"sb_right_arrow", XC_sb_right_arrow},
2303 {"sb_up_arrow", XC_sb_up_arrow},
2304 {"sb_v_double_arrow", XC_sb_v_double_arrow},
2305 {"shuttle", XC_shuttle},
2306 {"sizing", XC_sizing},
2307 {"spider", XC_spider},
2308 {"spraycan", XC_spraycan},
2309 {"star", XC_star},
2310 {"target", XC_target},
2311 {"tcross", XC_tcross},
2312 {"top_left_arrow", XC_top_left_arrow},
2313 {"top_left_corner", XC_top_left_corner},
2314 {"top_right_corner", XC_top_right_corner},
2315 {"top_side", XC_top_side},
2316 {"top_tee", XC_top_tee},
2317 {"trek", XC_trek},
2318 {"ul_angle", XC_ul_angle},
2319 {"umbrella", XC_umbrella},
2320 {"ur_angle", XC_ur_angle},
2321 {"watch", XC_watch},
2322 {"xterm", XC_xterm},
2323 {NULL, CURSOR_ID_NONE}
2326 static void check_bitmap_status(int status, const char *filename, Pixmap bitmap)
2328 switch (status) {
2329 case BitmapOpenFailed:
2330 wwarning(_("failed to open bitmap file \"%s\""), filename);
2331 break;
2332 case BitmapFileInvalid:
2333 wwarning(_("\"%s\" is not a valid bitmap file"), filename);
2334 break;
2335 case BitmapNoMemory:
2336 wwarning(_("out of memory reading bitmap file \"%s\""), filename);
2337 break;
2338 case BitmapSuccess:
2339 XFreePixmap(dpy, bitmap);
2340 break;
2345 * (none)
2346 * (builtin, <cursor_name>)
2347 * (bitmap, <cursor_bitmap>, <cursor_mask>)
2349 static int parse_cursor(WScreen * scr, WMPropList * pl, Cursor * cursor)
2351 WMPropList *elem;
2352 char *val;
2353 int nelem;
2354 int status = 0;
2356 nelem = WMGetPropListItemCount(pl);
2357 if (nelem < 1) {
2358 return (status);
2360 elem = WMGetFromPLArray(pl, 0);
2361 if (!elem || !WMIsPLString(elem)) {
2362 return (status);
2364 val = WMGetFromPLString(elem);
2366 if (strcasecmp(val, "none") == 0) {
2367 status = 1;
2368 *cursor = None;
2369 } else if (strcasecmp(val, "builtin") == 0) {
2370 int i;
2371 int cursor_id = CURSOR_ID_NONE;
2373 if (nelem != 2) {
2374 wwarning(_("bad number of arguments in cursor specification"));
2375 return (status);
2377 elem = WMGetFromPLArray(pl, 1);
2378 if (!elem || !WMIsPLString(elem)) {
2379 return (status);
2381 val = WMGetFromPLString(elem);
2383 for (i = 0; cursor_table[i].name != NULL; i++) {
2384 if (strcasecmp(val, cursor_table[i].name) == 0) {
2385 cursor_id = cursor_table[i].id;
2386 break;
2389 if (CURSOR_ID_NONE == cursor_id) {
2390 wwarning(_("unknown builtin cursor name \"%s\""), val);
2391 } else {
2392 *cursor = XCreateFontCursor(dpy, cursor_id);
2393 status = 1;
2395 } else if (strcasecmp(val, "bitmap") == 0) {
2396 char *bitmap_name;
2397 char *mask_name;
2398 int bitmap_status;
2399 int mask_status;
2400 Pixmap bitmap;
2401 Pixmap mask;
2402 unsigned int w, h;
2403 int x, y;
2404 XColor fg, bg;
2406 if (nelem != 3) {
2407 wwarning(_("bad number of arguments in cursor specification"));
2408 return (status);
2410 elem = WMGetFromPLArray(pl, 1);
2411 if (!elem || !WMIsPLString(elem)) {
2412 return (status);
2414 val = WMGetFromPLString(elem);
2415 bitmap_name = FindImage(wPreferences.pixmap_path, val);
2416 if (!bitmap_name) {
2417 wwarning(_("could not find cursor bitmap file \"%s\""), val);
2418 return (status);
2420 elem = WMGetFromPLArray(pl, 2);
2421 if (!elem || !WMIsPLString(elem)) {
2422 wfree(bitmap_name);
2423 return (status);
2425 val = WMGetFromPLString(elem);
2426 mask_name = FindImage(wPreferences.pixmap_path, val);
2427 if (!mask_name) {
2428 wfree(bitmap_name);
2429 wwarning(_("could not find cursor bitmap file \"%s\""), val);
2430 return (status);
2432 mask_status = XReadBitmapFile(dpy, scr->w_win, mask_name, &w, &h, &mask, &x, &y);
2433 bitmap_status = XReadBitmapFile(dpy, scr->w_win, bitmap_name, &w, &h, &bitmap, &x, &y);
2434 if ((BitmapSuccess == bitmap_status) && (BitmapSuccess == mask_status)) {
2435 fg.pixel = scr->black_pixel;
2436 bg.pixel = scr->white_pixel;
2437 XQueryColor(dpy, scr->w_colormap, &fg);
2438 XQueryColor(dpy, scr->w_colormap, &bg);
2439 *cursor = XCreatePixmapCursor(dpy, bitmap, mask, &fg, &bg, x, y);
2440 status = 1;
2442 check_bitmap_status(bitmap_status, bitmap_name, bitmap);
2443 check_bitmap_status(mask_status, mask_name, mask);
2444 wfree(bitmap_name);
2445 wfree(mask_name);
2447 return (status);
2450 static int getCursor(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
2452 static Cursor cursor;
2453 int status;
2454 int changed = 0;
2456 again:
2457 if (!WMIsPLArray(value)) {
2458 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
2459 entry->key, "cursor specification");
2460 if (!changed) {
2461 value = entry->plvalue;
2462 changed = 1;
2463 wwarning(_("using default \"%s\" instead"), entry->default_value);
2464 goto again;
2466 return (False);
2468 status = parse_cursor(scr, value, &cursor);
2469 if (!status) {
2470 wwarning(_("Error in cursor specification for key \"%s\""), entry->key);
2471 if (!changed) {
2472 value = entry->plvalue;
2473 changed = 1;
2474 wwarning(_("using default \"%s\" instead"), entry->default_value);
2475 goto again;
2477 return (False);
2479 if (ret) {
2480 *ret = &cursor;
2482 if (addr) {
2483 *(Cursor *) addr = cursor;
2485 return (True);
2488 #undef CURSOR_ID_NONE
2490 /* ---------------- value setting functions --------------- */
2491 static int setJustify(WScreen * scr, WDefaultEntry * entry, void *tdata, void *extra_data)
2493 /* Parameter not used, but tell the compiler that it is ok */
2494 (void) scr;
2495 (void) entry;
2496 (void) tdata;
2497 (void) extra_data;
2499 return REFRESH_WINDOW_TITLE_COLOR;
2502 static int setClearance(WScreen * scr, WDefaultEntry * entry, void *bar, void *foo)
2504 /* Parameter not used, but tell the compiler that it is ok */
2505 (void) scr;
2506 (void) entry;
2507 (void) bar;
2508 (void) foo;
2510 return REFRESH_WINDOW_FONT | REFRESH_BUTTON_IMAGES | REFRESH_MENU_TITLE_FONT | REFRESH_MENU_FONT;
2513 static int setIfDockPresent(WScreen * scr, WDefaultEntry * entry, void *tdata, void *extra_data)
2515 char *flag = tdata;
2516 long which = (long) extra_data;
2518 /* Parameter not used, but tell the compiler that it is ok */
2519 (void) scr;
2520 (void) entry;
2522 switch (which) {
2523 case WM_DOCK:
2524 wPreferences.flags.nodock = wPreferences.flags.nodock || *flag;
2525 // Drawers require the dock
2526 wPreferences.flags.nodrawer = wPreferences.flags.nodrawer || wPreferences.flags.nodock;
2527 break;
2528 case WM_CLIP:
2529 wPreferences.flags.noclip = wPreferences.flags.noclip || *flag;
2530 break;
2531 case WM_DRAWER:
2532 wPreferences.flags.nodrawer = wPreferences.flags.nodrawer || *flag;
2533 break;
2534 default:
2535 break;
2537 return 0;
2540 static int setClipMergedInDock(WScreen *scr, WDefaultEntry *entry, void *tdata, void *foo)
2542 char *flag = tdata;
2544 /* Parameter not used, but tell the compiler that it is ok */
2545 (void) scr;
2546 (void) entry;
2547 (void) foo;
2549 wPreferences.flags.clip_merged_in_dock = *flag;
2550 wPreferences.flags.noclip = wPreferences.flags.noclip || *flag;
2551 return 0;
2554 static int setWrapAppiconsInDock(WScreen *scr, WDefaultEntry *entry, void *tdata, void *foo)
2556 char *flag = tdata;
2558 /* Parameter not used, but tell the compiler that it is ok */
2559 (void) scr;
2560 (void) entry;
2561 (void) foo;
2563 wPreferences.flags.wrap_appicons_in_dock = *flag;
2564 return 0;
2567 static int setStickyIcons(WScreen * scr, WDefaultEntry * entry, void *bar, void *foo)
2569 /* Parameter not used, but tell the compiler that it is ok */
2570 (void) entry;
2571 (void) bar;
2572 (void) foo;
2574 if (scr->workspaces) {
2575 wWorkspaceForceChange(scr, scr->current_workspace);
2576 wArrangeIcons(scr, False);
2578 return 0;
2581 static int setIconTile(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2583 Pixmap pixmap;
2584 RImage *img;
2585 WTexture ** texture = tdata;
2586 int reset = 0;
2588 /* Parameter not used, but tell the compiler that it is ok */
2589 (void) foo;
2591 img = wTextureRenderImage(*texture, wPreferences.icon_size,
2592 wPreferences.icon_size, ((*texture)->any.type & WREL_BORDER_MASK)
2593 ? WREL_ICON : WREL_FLAT);
2594 if (!img) {
2595 wwarning(_("could not render texture for icon background"));
2596 if (!entry->addr)
2597 wTextureDestroy(scr, *texture);
2598 return 0;
2600 RConvertImage(scr->rcontext, img, &pixmap);
2602 if (scr->icon_tile) {
2603 reset = 1;
2604 RReleaseImage(scr->icon_tile);
2605 XFreePixmap(dpy, scr->icon_tile_pixmap);
2608 scr->icon_tile = img;
2610 /* put the icon in the noticeboard hint */
2611 PropSetIconTileHint(scr, img);
2613 if (!wPreferences.flags.noclip || wPreferences.flags.clip_merged_in_dock) {
2614 if (scr->clip_tile) {
2615 RReleaseImage(scr->clip_tile);
2617 scr->clip_tile = wClipMakeTile(img);
2620 if (!wPreferences.flags.nodrawer) {
2621 if (scr->drawer_tile) {
2622 RReleaseImage(scr->drawer_tile);
2624 scr->drawer_tile = wDrawerMakeTile(scr, img);
2627 scr->icon_tile_pixmap = pixmap;
2629 if (scr->def_icon_rimage) {
2630 RReleaseImage(scr->def_icon_rimage);
2631 scr->def_icon_rimage = NULL;
2634 if (scr->icon_back_texture)
2635 wTextureDestroy(scr, (WTexture *) scr->icon_back_texture);
2637 scr->icon_back_texture = wTextureMakeSolid(scr, &((*texture)->any.color));
2639 /* Free the texture as nobody else will use it, nor refer to it. */
2640 if (!entry->addr)
2641 wTextureDestroy(scr, *texture);
2643 return (reset ? REFRESH_ICON_TILE : 0);
2646 static int setWinTitleFont(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2648 WMFont *font = tdata;
2650 /* Parameter not used, but tell the compiler that it is ok */
2651 (void) entry;
2652 (void) foo;
2654 if (scr->title_font) {
2655 WMReleaseFont(scr->title_font);
2657 scr->title_font = font;
2659 return REFRESH_WINDOW_FONT | REFRESH_BUTTON_IMAGES;
2662 static int setMenuTitleFont(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2664 WMFont *font = tdata;
2666 /* Parameter not used, but tell the compiler that it is ok */
2667 (void) entry;
2668 (void) foo;
2670 if (scr->menu_title_font) {
2671 WMReleaseFont(scr->menu_title_font);
2674 scr->menu_title_font = font;
2676 return REFRESH_MENU_TITLE_FONT;
2679 static int setMenuTextFont(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2681 WMFont *font = tdata;
2683 /* Parameter not used, but tell the compiler that it is ok */
2684 (void) entry;
2685 (void) foo;
2687 if (scr->menu_entry_font) {
2688 WMReleaseFont(scr->menu_entry_font);
2690 scr->menu_entry_font = font;
2692 return REFRESH_MENU_FONT;
2695 static int setIconTitleFont(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2697 WMFont *font = tdata;
2699 /* Parameter not used, but tell the compiler that it is ok */
2700 (void) entry;
2701 (void) foo;
2703 if (scr->icon_title_font) {
2704 WMReleaseFont(scr->icon_title_font);
2707 scr->icon_title_font = font;
2709 return REFRESH_ICON_FONT;
2712 static int setClipTitleFont(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2714 WMFont *font = tdata;
2716 /* Parameter not used, but tell the compiler that it is ok */
2717 (void) entry;
2718 (void) foo;
2720 if (scr->clip_title_font) {
2721 WMReleaseFont(scr->clip_title_font);
2724 scr->clip_title_font = font;
2726 return REFRESH_ICON_FONT;
2729 static int setLargeDisplayFont(WScreen *scr, WDefaultEntry *entry, void *tdata, void *foo)
2731 WMFont *font = tdata;
2733 /* Parameter not used, but tell the compiler that it is ok */
2734 (void) scr;
2735 (void) entry;
2736 (void) foo;
2738 if (scr->workspace_name_font)
2739 WMReleaseFont(scr->workspace_name_font);
2741 scr->workspace_name_font = font;
2743 return 0;
2746 static int setHightlight(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2748 XColor *color = tdata;
2750 /* Parameter not used, but tell the compiler that it is ok */
2751 (void) entry;
2752 (void) foo;
2754 if (scr->select_color)
2755 WMReleaseColor(scr->select_color);
2757 scr->select_color = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2759 wFreeColor(scr, color->pixel);
2761 return REFRESH_MENU_COLOR;
2764 static int setHightlightText(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2766 XColor *color = tdata;
2768 /* Parameter not used, but tell the compiler that it is ok */
2769 (void) entry;
2770 (void) foo;
2772 if (scr->select_text_color)
2773 WMReleaseColor(scr->select_text_color);
2775 scr->select_text_color = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2777 wFreeColor(scr, color->pixel);
2779 return REFRESH_MENU_COLOR;
2782 static int setClipTitleColor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *extra_data)
2784 XColor *color = tdata;
2785 long widx = (long) extra_data;
2787 /* Parameter not used, but tell the compiler that it is ok */
2788 (void) entry;
2790 if (scr->clip_title_color[widx])
2791 WMReleaseColor(scr->clip_title_color[widx]);
2793 scr->clip_title_color[widx] = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2794 wFreeColor(scr, color->pixel);
2796 return REFRESH_ICON_TITLE_COLOR;
2799 static int setWTitleColor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *extra_data)
2801 XColor *color = tdata;
2802 long widx = (long) extra_data;
2804 /* Parameter not used, but tell the compiler that it is ok */
2805 (void) entry;
2807 if (scr->window_title_color[widx])
2808 WMReleaseColor(scr->window_title_color[widx]);
2810 scr->window_title_color[widx] =
2811 WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2813 wFreeColor(scr, color->pixel);
2815 return REFRESH_WINDOW_TITLE_COLOR;
2818 static int setMenuTitleColor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *extra_data)
2820 XColor *color = tdata;
2822 /* Parameter not used, but tell the compiler that it is ok */
2823 (void) entry;
2824 (void) extra_data;
2826 if (scr->menu_title_color[0])
2827 WMReleaseColor(scr->menu_title_color[0]);
2829 scr->menu_title_color[0] = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2831 wFreeColor(scr, color->pixel);
2833 return REFRESH_MENU_TITLE_COLOR;
2836 static int setMenuTextColor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2838 XColor *color = tdata;
2840 /* Parameter not used, but tell the compiler that it is ok */
2841 (void) entry;
2842 (void) foo;
2844 if (scr->mtext_color)
2845 WMReleaseColor(scr->mtext_color);
2847 scr->mtext_color = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2849 if (WMColorPixel(scr->dtext_color) == WMColorPixel(scr->mtext_color)) {
2850 WMSetColorAlpha(scr->dtext_color, 0x7fff);
2851 } else {
2852 WMSetColorAlpha(scr->dtext_color, 0xffff);
2855 wFreeColor(scr, color->pixel);
2857 return REFRESH_MENU_COLOR;
2860 static int setMenuDisabledColor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2862 XColor *color = tdata;
2864 /* Parameter not used, but tell the compiler that it is ok */
2865 (void) entry;
2866 (void) foo;
2868 if (scr->dtext_color)
2869 WMReleaseColor(scr->dtext_color);
2871 scr->dtext_color = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2873 if (WMColorPixel(scr->dtext_color) == WMColorPixel(scr->mtext_color)) {
2874 WMSetColorAlpha(scr->dtext_color, 0x7fff);
2875 } else {
2876 WMSetColorAlpha(scr->dtext_color, 0xffff);
2879 wFreeColor(scr, color->pixel);
2881 return REFRESH_MENU_COLOR;
2884 static int setIconTitleColor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2886 XColor *color = tdata;
2888 /* Parameter not used, but tell the compiler that it is ok */
2889 (void) entry;
2890 (void) foo;
2892 if (scr->icon_title_color)
2893 WMReleaseColor(scr->icon_title_color);
2894 scr->icon_title_color = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2896 wFreeColor(scr, color->pixel);
2898 return REFRESH_ICON_TITLE_COLOR;
2901 static int setIconTitleBack(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2903 XColor *color = tdata;
2905 /* Parameter not used, but tell the compiler that it is ok */
2906 (void) entry;
2907 (void) foo;
2909 if (scr->icon_title_texture) {
2910 wTextureDestroy(scr, (WTexture *) scr->icon_title_texture);
2912 scr->icon_title_texture = wTextureMakeSolid(scr, color);
2914 return REFRESH_ICON_TITLE_BACK;
2917 static int setFrameBorderWidth(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2919 int *value = tdata;
2921 /* Parameter not used, but tell the compiler that it is ok */
2922 (void) entry;
2923 (void) foo;
2925 scr->frame_border_width = *value;
2927 return REFRESH_FRAME_BORDER;
2930 static int setFrameBorderColor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2932 XColor *color = tdata;
2934 /* Parameter not used, but tell the compiler that it is ok */
2935 (void) entry;
2936 (void) foo;
2938 if (scr->frame_border_color)
2939 WMReleaseColor(scr->frame_border_color);
2940 scr->frame_border_color = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2942 wFreeColor(scr, color->pixel);
2944 return REFRESH_FRAME_BORDER;
2947 static int setFrameFocusedBorderColor(WScreen *scr, WDefaultEntry *entry, void *tdata, void *foo)
2949 XColor *color = tdata;
2951 /* Parameter not used, but tell the compiler that it is ok */
2952 (void) entry;
2953 (void) foo;
2955 if (scr->frame_focused_border_color)
2956 WMReleaseColor(scr->frame_focused_border_color);
2957 scr->frame_focused_border_color = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2959 wFreeColor(scr, color->pixel);
2961 return REFRESH_FRAME_BORDER;
2964 static int setFrameSelectedBorderColor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2966 XColor *color = tdata;
2968 /* Parameter not used, but tell the compiler that it is ok */
2969 (void) entry;
2970 (void) foo;
2972 if (scr->frame_selected_border_color)
2973 WMReleaseColor(scr->frame_selected_border_color);
2974 scr->frame_selected_border_color = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2976 wFreeColor(scr, color->pixel);
2978 return REFRESH_FRAME_BORDER;
2981 static int setWorkspaceSpecificBack(WScreen * scr, WDefaultEntry * entry, void *tdata, void *bar)
2983 WMPropList *value = tdata;
2984 WMPropList *val;
2985 char *str;
2986 int i;
2988 /* Parameter not used, but tell the compiler that it is ok */
2989 (void) entry;
2990 (void) bar;
2992 if (scr->flags.backimage_helper_launched) {
2993 if (WMGetPropListItemCount(value) == 0) {
2994 SendHelperMessage(scr, 'C', 0, NULL);
2995 SendHelperMessage(scr, 'K', 0, NULL);
2997 WMReleasePropList(value);
2998 return 0;
3000 } else {
3001 if (WMGetPropListItemCount(value) == 0)
3002 return 0;
3004 if (!start_bg_helper(scr)) {
3005 WMReleasePropList(value);
3006 return 0;
3009 SendHelperMessage(scr, 'P', -1, wPreferences.pixmap_path);
3012 for (i = 0; i < WMGetPropListItemCount(value); i++) {
3013 val = WMGetFromPLArray(value, i);
3014 if (val && WMIsPLArray(val) && WMGetPropListItemCount(val) > 0) {
3015 str = WMGetPropListDescription(val, False);
3017 SendHelperMessage(scr, 'S', i + 1, str);
3019 wfree(str);
3020 } else {
3021 SendHelperMessage(scr, 'U', i + 1, NULL);
3024 sleep(1);
3026 WMReleasePropList(value);
3027 return 0;
3030 static int setWorkspaceBack(WScreen * scr, WDefaultEntry * entry, void *tdata, void *bar)
3032 WMPropList *value = tdata;
3034 /* Parameter not used, but tell the compiler that it is ok */
3035 (void) entry;
3036 (void) bar;
3038 if (scr->flags.backimage_helper_launched) {
3039 char *str;
3041 if (WMGetPropListItemCount(value) == 0) {
3042 SendHelperMessage(scr, 'U', 0, NULL);
3043 } else {
3044 /* set the default workspace background to this one */
3045 str = WMGetPropListDescription(value, False);
3046 if (str) {
3047 SendHelperMessage(scr, 'S', 0, str);
3048 wfree(str);
3049 SendHelperMessage(scr, 'C', scr->current_workspace + 1, NULL);
3050 } else {
3051 SendHelperMessage(scr, 'U', 0, NULL);
3054 } else if (WMGetPropListItemCount(value) > 0) {
3055 char *command;
3056 char *text;
3057 char *dither;
3058 int len;
3060 text = WMGetPropListDescription(value, False);
3061 len = strlen(text) + 40;
3062 command = wmalloc(len);
3063 dither = wPreferences.no_dithering ? "-m" : "-d";
3064 if (!strchr(text, '\'') && !strchr(text, '\\')) {
3065 command = wmalloc(len);
3066 if (wPreferences.smooth_workspace_back)
3067 snprintf(command, len, "wmsetbg %s -S -p '%s' &", dither, text);
3068 else
3069 snprintf(command, len, "wmsetbg %s -p '%s' &", dither, text);
3070 ExecuteShellCommand(scr, command);
3071 wfree(command);
3072 } else
3073 wwarning(_("Invalid arguments for background \"%s\""), text);
3074 wfree(text);
3076 WMReleasePropList(value);
3078 return 0;
3081 static int setWidgetColor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
3083 WTexture **texture = tdata;
3085 /* Parameter not used, but tell the compiler that it is ok */
3086 (void) entry;
3087 (void) foo;
3089 if (scr->widget_texture) {
3090 wTextureDestroy(scr, (WTexture *) scr->widget_texture);
3092 scr->widget_texture = *(WTexSolid **) texture;
3094 return 0;
3097 static int setFTitleBack(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
3099 WTexture **texture = tdata;
3101 /* Parameter not used, but tell the compiler that it is ok */
3102 (void) entry;
3103 (void) foo;
3105 if (scr->window_title_texture[WS_FOCUSED]) {
3106 wTextureDestroy(scr, scr->window_title_texture[WS_FOCUSED]);
3108 scr->window_title_texture[WS_FOCUSED] = *texture;
3110 return REFRESH_WINDOW_TEXTURES;
3113 static int setPTitleBack(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
3115 WTexture **texture = tdata;
3117 /* Parameter not used, but tell the compiler that it is ok */
3118 (void) entry;
3119 (void) foo;
3121 if (scr->window_title_texture[WS_PFOCUSED]) {
3122 wTextureDestroy(scr, scr->window_title_texture[WS_PFOCUSED]);
3124 scr->window_title_texture[WS_PFOCUSED] = *texture;
3126 return REFRESH_WINDOW_TEXTURES;
3129 static int setUTitleBack(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
3131 WTexture **texture = tdata;
3133 /* Parameter not used, but tell the compiler that it is ok */
3134 (void) entry;
3135 (void) foo;
3137 if (scr->window_title_texture[WS_UNFOCUSED]) {
3138 wTextureDestroy(scr, scr->window_title_texture[WS_UNFOCUSED]);
3140 scr->window_title_texture[WS_UNFOCUSED] = *texture;
3142 return REFRESH_WINDOW_TEXTURES;
3145 static int setResizebarBack(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
3147 WTexture **texture = tdata;
3149 /* Parameter not used, but tell the compiler that it is ok */
3150 (void) entry;
3151 (void) foo;
3153 if (scr->resizebar_texture[0]) {
3154 wTextureDestroy(scr, scr->resizebar_texture[0]);
3156 scr->resizebar_texture[0] = *texture;
3158 return REFRESH_WINDOW_TEXTURES;
3161 static int setMenuTitleBack(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
3163 WTexture **texture = tdata;
3165 /* Parameter not used, but tell the compiler that it is ok */
3166 (void) entry;
3167 (void) foo;
3169 if (scr->menu_title_texture[0]) {
3170 wTextureDestroy(scr, scr->menu_title_texture[0]);
3172 scr->menu_title_texture[0] = *texture;
3174 return REFRESH_MENU_TITLE_TEXTURE;
3177 static int setMenuTextBack(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
3179 WTexture **texture = tdata;
3181 /* Parameter not used, but tell the compiler that it is ok */
3182 (void) entry;
3183 (void) foo;
3185 if (scr->menu_item_texture) {
3186 wTextureDestroy(scr, scr->menu_item_texture);
3187 wTextureDestroy(scr, (WTexture *) scr->menu_item_auxtexture);
3189 scr->menu_item_texture = *texture;
3191 scr->menu_item_auxtexture = wTextureMakeSolid(scr, &scr->menu_item_texture->any.color);
3193 return REFRESH_MENU_TEXTURE;
3196 static int setKeyGrab(WScreen * scr, WDefaultEntry * entry, void *tdata, void *extra_data)
3198 WShortKey *shortcut = tdata;
3199 WWindow *wwin;
3200 long widx = (long) extra_data;
3202 /* Parameter not used, but tell the compiler that it is ok */
3203 (void) entry;
3205 wKeyBindings[widx] = *shortcut;
3207 wwin = scr->focused_window;
3209 while (wwin != NULL) {
3210 XUngrabKey(dpy, AnyKey, AnyModifier, wwin->frame->core->window);
3212 if (!WFLAGP(wwin, no_bind_keys)) {
3213 wWindowSetKeyGrabs(wwin);
3215 wwin = wwin->prev;
3218 /* do we need to update window menus? */
3219 if (widx >= WKBD_WORKSPACE1 && widx <= WKBD_WORKSPACE10)
3220 return REFRESH_WORKSPACE_MENU;
3221 if (widx == WKBD_LASTWORKSPACE)
3222 return REFRESH_WORKSPACE_MENU;
3223 if (widx >= WKBD_MOVE_WORKSPACE1 && widx <= WKBD_MOVE_WORKSPACE10)
3224 return REFRESH_WORKSPACE_MENU;
3226 return 0;
3229 static int setIconPosition(WScreen * scr, WDefaultEntry * entry, void *bar, void *foo)
3231 /* Parameter not used, but tell the compiler that it is ok */
3232 (void) entry;
3233 (void) bar;
3234 (void) foo;
3236 wScreenUpdateUsableArea(scr);
3237 wArrangeIcons(scr, True);
3239 return 0;
3242 static int updateUsableArea(WScreen * scr, WDefaultEntry * entry, void *bar, void *foo)
3244 /* Parameter not used, but tell the compiler that it is ok */
3245 (void) entry;
3246 (void) bar;
3247 (void) foo;
3249 wScreenUpdateUsableArea(scr);
3251 return 0;
3254 static int setWorkspaceMapBackground(WScreen *scr, WDefaultEntry *entry, void *tdata, void *foo)
3256 WTexture **texture = tdata;
3258 /* Parameter not used, but tell the compiler that it is ok */
3259 (void) entry;
3260 (void) foo;
3262 if (wPreferences.wsmbackTexture)
3263 wTextureDestroy(scr, wPreferences.wsmbackTexture);
3265 wPreferences.wsmbackTexture = *texture;
3267 return REFRESH_WINDOW_TEXTURES;
3270 static int setMenuStyle(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
3272 /* Parameter not used, but tell the compiler that it is ok */
3273 (void) scr;
3274 (void) entry;
3275 (void) tdata;
3276 (void) foo;
3278 return REFRESH_MENU_TEXTURE;
3281 static RImage *chopOffImage(RImage * image, int x, int y, int w, int h)
3283 RImage *img = RCreateImage(w, h, image->format == RRGBAFormat);
3285 RCopyArea(img, image, x, y, w, h, 0, 0);
3287 return img;
3290 static int setSwPOptions(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
3292 WMPropList *array = tdata;
3293 char *path;
3294 RImage *bgimage;
3295 int cwidth, cheight;
3296 struct WPreferences *prefs = foo;
3298 if (!WMIsPLArray(array) || WMGetPropListItemCount(array) == 0) {
3299 if (prefs->swtileImage)
3300 RReleaseImage(prefs->swtileImage);
3301 prefs->swtileImage = NULL;
3303 WMReleasePropList(array);
3304 return 0;
3307 switch (WMGetPropListItemCount(array)) {
3308 case 4:
3309 if (!WMIsPLString(WMGetFromPLArray(array, 1))) {
3310 wwarning(_("Invalid arguments for option \"%s\""), entry->key);
3311 break;
3312 } else
3313 path = FindImage(wPreferences.pixmap_path, WMGetFromPLString(WMGetFromPLArray(array, 1)));
3315 if (!path) {
3316 wwarning(_("Could not find image \"%s\" for option \"%s\""),
3317 WMGetFromPLString(WMGetFromPLArray(array, 1)), entry->key);
3318 } else {
3319 bgimage = RLoadImage(scr->rcontext, path, 0);
3320 if (!bgimage) {
3321 wwarning(_("Could not load image \"%s\" for option \"%s\""), path, entry->key);
3322 wfree(path);
3323 } else {
3324 wfree(path);
3326 cwidth = atoi(WMGetFromPLString(WMGetFromPLArray(array, 2)));
3327 cheight = atoi(WMGetFromPLString(WMGetFromPLArray(array, 3)));
3329 if (cwidth <= 0 || cheight <= 0 ||
3330 cwidth >= bgimage->width - 2 || cheight >= bgimage->height - 2)
3331 wwarning(_("Invalid split sizes for switch panel back image."));
3332 else {
3333 int i;
3334 int swidth, theight;
3335 for (i = 0; i < 9; i++) {
3336 if (prefs->swbackImage[i])
3337 RReleaseImage(prefs->swbackImage[i]);
3338 prefs->swbackImage[i] = NULL;
3340 swidth = (bgimage->width - cwidth) / 2;
3341 theight = (bgimage->height - cheight) / 2;
3343 prefs->swbackImage[0] = chopOffImage(bgimage, 0, 0, swidth, theight);
3344 prefs->swbackImage[1] = chopOffImage(bgimage, swidth, 0, cwidth, theight);
3345 prefs->swbackImage[2] = chopOffImage(bgimage, swidth + cwidth, 0,
3346 swidth, theight);
3348 prefs->swbackImage[3] = chopOffImage(bgimage, 0, theight, swidth, cheight);
3349 prefs->swbackImage[4] = chopOffImage(bgimage, swidth, theight,
3350 cwidth, cheight);
3351 prefs->swbackImage[5] = chopOffImage(bgimage, swidth + cwidth, theight,
3352 swidth, cheight);
3354 prefs->swbackImage[6] = chopOffImage(bgimage, 0, theight + cheight,
3355 swidth, theight);
3356 prefs->swbackImage[7] = chopOffImage(bgimage, swidth, theight + cheight,
3357 cwidth, theight);
3358 prefs->swbackImage[8] =
3359 chopOffImage(bgimage, swidth + cwidth, theight + cheight, swidth,
3360 theight);
3362 // check if anything failed
3363 for (i = 0; i < 9; i++) {
3364 if (!prefs->swbackImage[i]) {
3365 for (; i >= 0; --i) {
3366 RReleaseImage(prefs->swbackImage[i]);
3367 prefs->swbackImage[i] = NULL;
3369 break;
3373 RReleaseImage(bgimage);
3377 case 1:
3378 if (!WMIsPLString(WMGetFromPLArray(array, 0))) {
3379 wwarning(_("Invalid arguments for option \"%s\""), entry->key);
3380 break;
3381 } else
3382 path = FindImage(wPreferences.pixmap_path, WMGetFromPLString(WMGetFromPLArray(array, 0)));
3384 if (!path) {
3385 wwarning(_("Could not find image \"%s\" for option \"%s\""),
3386 WMGetFromPLString(WMGetFromPLArray(array, 0)), entry->key);
3387 } else {
3388 if (prefs->swtileImage)
3389 RReleaseImage(prefs->swtileImage);
3391 prefs->swtileImage = RLoadImage(scr->rcontext, path, 0);
3392 if (!prefs->swtileImage) {
3393 wwarning(_("Could not load image \"%s\" for option \"%s\""), path, entry->key);
3395 wfree(path);
3397 break;
3399 default:
3400 wwarning(_("Invalid number of arguments for option \"%s\""), entry->key);
3401 break;
3404 WMReleasePropList(array);
3406 return 0;
3409 static int setModifierKeyLabels(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
3411 WMPropList *array = tdata;
3412 int i;
3413 struct WPreferences *prefs = foo;
3415 if (!WMIsPLArray(array) || WMGetPropListItemCount(array) != 7) {
3416 wwarning(_("Value for option \"%s\" must be an array of 7 strings"), entry->key);
3417 WMReleasePropList(array);
3418 return 0;
3421 DestroyWindowMenu(scr);
3423 for (i = 0; i < 7; i++) {
3424 if (prefs->modifier_labels[i])
3425 wfree(prefs->modifier_labels[i]);
3427 if (WMIsPLString(WMGetFromPLArray(array, i))) {
3428 prefs->modifier_labels[i] = wstrdup(WMGetFromPLString(WMGetFromPLArray(array, i)));
3429 } else {
3430 wwarning(_("Invalid argument for option \"%s\" item %d"), entry->key, i);
3431 prefs->modifier_labels[i] = NULL;
3435 WMReleasePropList(array);
3437 return 0;
3440 static int setDoubleClick(WScreen *scr, WDefaultEntry *entry, void *tdata, void *foo)
3442 int *value = tdata;
3444 /* Parameter not used, but tell the compiler that it is ok */
3445 (void) entry;
3446 (void) scr;
3448 if (*value <= 0)
3449 *(int *)foo = 1;
3451 W_setconf_doubleClickDelay(*value);
3453 return 0;
3456 static int setCursor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *extra_data)
3458 Cursor *cursor = tdata;
3459 long widx = (long) extra_data;
3461 /* Parameter not used, but tell the compiler that it is ok */
3462 (void) entry;
3464 if (wPreferences.cursor[widx] != None) {
3465 XFreeCursor(dpy, wPreferences.cursor[widx]);
3468 wPreferences.cursor[widx] = *cursor;
3470 if (widx == WCUR_ROOT && *cursor != None) {
3471 XDefineCursor(dpy, scr->root_win, *cursor);
3474 return 0;