wmaker/WPrefs: Remove legacy support for deprecated apercus.
[wmaker-crm.git] / src / defaults.c
blob19d230cbad3df1115134177cb80d1b5eb1e1b2a2
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 typedef struct _WDefaultEntry WDefaultEntry;
71 typedef int (WDECallbackConvert) (WScreen *scr, WDefaultEntry *entry, WMPropList *plvalue, void *addr, void **tdata);
72 typedef int (WDECallbackUpdate) (WScreen *scr, WDefaultEntry *entry, void *tdata, void *extra_data);
74 struct _WDefaultEntry {
75 const char *key;
76 const char *default_value;
77 void *extra_data;
78 void *addr;
79 WDECallbackConvert *convert;
80 WDECallbackUpdate *update;
81 WMPropList *plkey;
82 WMPropList *plvalue; /* default value */
85 /* used to map strings to integers */
86 typedef struct {
87 const char *string;
88 short value;
89 char is_alias;
90 } WOptionEnumeration;
92 /* type converters */
93 static WDECallbackConvert getBool;
94 static WDECallbackConvert getInt;
95 static WDECallbackConvert getCoord;
96 static WDECallbackConvert getPathList;
97 static WDECallbackConvert getEnum;
98 static WDECallbackConvert getTexture;
99 static WDECallbackConvert getWSBackground;
100 static WDECallbackConvert getWSSpecificBackground;
101 static WDECallbackConvert getFont;
102 static WDECallbackConvert getColor;
103 static WDECallbackConvert getKeybind;
104 static WDECallbackConvert getModMask;
105 static WDECallbackConvert getPropList;
107 /* value setting functions */
108 static WDECallbackUpdate setJustify;
109 static WDECallbackUpdate setClearance;
110 static WDECallbackUpdate setIfDockPresent;
111 static WDECallbackUpdate setClipMergedInDock;
112 static WDECallbackUpdate setWrapAppiconsInDock;
113 static WDECallbackUpdate setStickyIcons;
114 static WDECallbackUpdate setWidgetColor;
115 static WDECallbackUpdate setIconTile;
116 static WDECallbackUpdate setWinTitleFont;
117 static WDECallbackUpdate setMenuTitleFont;
118 static WDECallbackUpdate setMenuTextFont;
119 static WDECallbackUpdate setIconTitleFont;
120 static WDECallbackUpdate setIconTitleColor;
121 static WDECallbackUpdate setIconTitleBack;
122 static WDECallbackUpdate setFrameBorderWidth;
123 static WDECallbackUpdate setFrameBorderColor;
124 static WDECallbackUpdate setFrameFocusedBorderColor;
125 static WDECallbackUpdate setFrameSelectedBorderColor;
126 static WDECallbackUpdate setLargeDisplayFont;
127 static WDECallbackUpdate setWTitleColor;
128 static WDECallbackUpdate setFTitleBack;
129 static WDECallbackUpdate setPTitleBack;
130 static WDECallbackUpdate setUTitleBack;
131 static WDECallbackUpdate setResizebarBack;
132 static WDECallbackUpdate setWorkspaceBack;
133 static WDECallbackUpdate setWorkspaceSpecificBack;
134 static WDECallbackUpdate setMenuTitleColor;
135 static WDECallbackUpdate setMenuTextColor;
136 static WDECallbackUpdate setMenuDisabledColor;
137 static WDECallbackUpdate setMenuTitleBack;
138 static WDECallbackUpdate setMenuTextBack;
139 static WDECallbackUpdate setHightlight;
140 static WDECallbackUpdate setHightlightText;
141 static WDECallbackUpdate setKeyGrab;
142 static WDECallbackUpdate setDoubleClick;
143 static WDECallbackUpdate setIconPosition;
144 static WDECallbackUpdate setWorkspaceMapBackground;
146 static WDECallbackUpdate setClipTitleFont;
147 static WDECallbackUpdate setClipTitleColor;
149 static WDECallbackUpdate setMenuStyle;
150 static WDECallbackUpdate setSwPOptions;
151 static WDECallbackUpdate updateUsableArea;
153 static WDECallbackUpdate setModifierKeyLabels;
155 static WDECallbackConvert getCursor;
156 static WDECallbackUpdate setCursor;
159 * Tables to convert strings to enumeration values.
160 * Values stored are char
163 /* WARNING: sum of length of all value strings must not exceed
164 * this value */
165 #define TOTAL_VALUES_LENGTH 80
167 #define REFRESH_WINDOW_TEXTURES (1<<0)
168 #define REFRESH_MENU_TEXTURE (1<<1)
169 #define REFRESH_MENU_FONT (1<<2)
170 #define REFRESH_MENU_COLOR (1<<3)
171 #define REFRESH_MENU_TITLE_TEXTURE (1<<4)
172 #define REFRESH_MENU_TITLE_FONT (1<<5)
173 #define REFRESH_MENU_TITLE_COLOR (1<<6)
174 #define REFRESH_WINDOW_TITLE_COLOR (1<<7)
175 #define REFRESH_WINDOW_FONT (1<<8)
176 #define REFRESH_ICON_TILE (1<<9)
177 #define REFRESH_ICON_FONT (1<<10)
179 #define REFRESH_BUTTON_IMAGES (1<<11)
181 #define REFRESH_ICON_TITLE_COLOR (1<<12)
182 #define REFRESH_ICON_TITLE_BACK (1<<13)
184 #define REFRESH_WORKSPACE_MENU (1<<14)
186 #define REFRESH_FRAME_BORDER REFRESH_MENU_FONT|REFRESH_WINDOW_FONT
188 static WOptionEnumeration seFocusModes[] = {
189 {"Manual", WKF_CLICK, 0}, {"ClickToFocus", WKF_CLICK, 1},
190 {"Sloppy", WKF_SLOPPY, 0}, {"SemiAuto", WKF_SLOPPY, 1}, {"Auto", WKF_SLOPPY, 1},
191 {NULL, 0, 0}
194 static WOptionEnumeration seTitlebarModes[] = {
195 {"new", TS_NEW, 0}, {"old", TS_OLD, 0},
196 {"next", TS_NEXT, 0}, {NULL, 0, 0}
199 static WOptionEnumeration seColormapModes[] = {
200 {"Manual", WCM_CLICK, 0}, {"ClickToFocus", WCM_CLICK, 1},
201 {"Auto", WCM_POINTER, 0}, {"FocusFollowMouse", WCM_POINTER, 1},
202 {NULL, 0, 0}
205 static WOptionEnumeration sePlacements[] = {
206 {"Auto", WPM_AUTO, 0},
207 {"Smart", WPM_SMART, 0},
208 {"Cascade", WPM_CASCADE, 0},
209 {"Random", WPM_RANDOM, 0},
210 {"Manual", WPM_MANUAL, 0},
211 {"Center", WPM_CENTER, 0},
212 {NULL, 0, 0}
215 static WOptionEnumeration seGeomDisplays[] = {
216 {"None", WDIS_NONE, 0},
217 {"Center", WDIS_CENTER, 0},
218 {"Corner", WDIS_TOPLEFT, 0},
219 {"Floating", WDIS_FRAME_CENTER, 0},
220 {"Line", WDIS_NEW, 0},
221 {NULL, 0, 0}
224 static WOptionEnumeration seSpeeds[] = {
225 {"UltraFast", SPEED_ULTRAFAST, 0},
226 {"Fast", SPEED_FAST, 0},
227 {"Medium", SPEED_MEDIUM, 0},
228 {"Slow", SPEED_SLOW, 0},
229 {"UltraSlow", SPEED_ULTRASLOW, 0},
230 {NULL, 0, 0}
233 static WOptionEnumeration seMouseButtonActions[] = {
234 {"None", WA_NONE, 0},
235 {"SelectWindows", WA_SELECT_WINDOWS, 0},
236 {"OpenApplicationsMenu", WA_OPEN_APPMENU, 0},
237 {"OpenWindowListMenu", WA_OPEN_WINLISTMENU, 0},
238 {"MoveToPrevWorkspace", WA_MOVE_PREVWORKSPACE, 0},
239 {"MoveToNextWorkspace", WA_MOVE_NEXTWORKSPACE, 0},
240 {"MoveToPrevWindow", WA_MOVE_PREVWINDOW, 0},
241 {"MoveToNextWindow", WA_MOVE_NEXTWINDOW, 0},
242 {NULL, 0, 0}
245 static WOptionEnumeration seMouseWheelActions[] = {
246 {"None", WA_NONE, 0},
247 {"SwitchWorkspaces", WA_SWITCH_WORKSPACES, 0},
248 {"SwitchWindows", WA_SWITCH_WINDOWS, 0},
249 {NULL, 0, 0}
252 static WOptionEnumeration seIconificationStyles[] = {
253 {"Zoom", WIS_ZOOM, 0},
254 {"Twist", WIS_TWIST, 0},
255 {"Flip", WIS_FLIP, 0},
256 {"None", WIS_NONE, 0},
257 {"random", WIS_RANDOM, 0},
258 {NULL, 0, 0}
261 static WOptionEnumeration seJustifications[] = {
262 {"Left", WTJ_LEFT, 0},
263 {"Center", WTJ_CENTER, 0},
264 {"Right", WTJ_RIGHT, 0},
265 {NULL, 0, 0}
268 static WOptionEnumeration seIconPositions[] = {
269 {"blv", IY_BOTTOM | IY_LEFT | IY_VERT, 0},
270 {"blh", IY_BOTTOM | IY_LEFT | IY_HORIZ, 0},
271 {"brv", IY_BOTTOM | IY_RIGHT | IY_VERT, 0},
272 {"brh", IY_BOTTOM | IY_RIGHT | IY_HORIZ, 0},
273 {"tlv", IY_TOP | IY_LEFT | IY_VERT, 0},
274 {"tlh", IY_TOP | IY_LEFT | IY_HORIZ, 0},
275 {"trv", IY_TOP | IY_RIGHT | IY_VERT, 0},
276 {"trh", IY_TOP | IY_RIGHT | IY_HORIZ, 0},
277 {NULL, 0, 0}
280 static WOptionEnumeration seMenuStyles[] = {
281 {"normal", MS_NORMAL, 0},
282 {"singletexture", MS_SINGLE_TEXTURE, 0},
283 {"flat", MS_FLAT, 0},
284 {NULL, 0, 0}
287 static WOptionEnumeration seDisplayPositions[] = {
288 {"none", WD_NONE, 0},
289 {"center", WD_CENTER, 0},
290 {"top", WD_TOP, 0},
291 {"bottom", WD_BOTTOM, 0},
292 {"topleft", WD_TOPLEFT, 0},
293 {"topright", WD_TOPRIGHT, 0},
294 {"bottomleft", WD_BOTTOMLEFT, 0},
295 {"bottomright", WD_BOTTOMRIGHT, 0},
296 {NULL, 0, 0}
299 static WOptionEnumeration seWorkspaceBorder[] = {
300 {"None", WB_NONE, 0},
301 {"LeftRight", WB_LEFTRIGHT, 0},
302 {"TopBottom", WB_TOPBOTTOM, 0},
303 {"AllDirections", WB_ALLDIRS, 0},
304 {NULL, 0, 0}
307 static WOptionEnumeration seDragMaximizedWindow[] = {
308 {"Move", DRAGMAX_MOVE, 0},
309 {"RestoreGeometry", DRAGMAX_RESTORE, 0},
310 {"Unmaximize", DRAGMAX_UNMAXIMIZE, 0},
311 {"NoMove", DRAGMAX_NOMOVE, 0},
312 {NULL, 0, 0}
316 * ALL entries in the tables bellow, NEED to have a default value
317 * defined, and this value needs to be correct.
320 /* these options will only affect the window manager on startup
322 * static defaults can't access the screen data, because it is
323 * created after these defaults are read
325 WDefaultEntry staticOptionList[] = {
327 {"ColormapSize", "4", NULL,
328 &wPreferences.cmap_size, getInt, NULL, NULL, NULL},
329 {"DisableDithering", "NO", NULL,
330 &wPreferences.no_dithering, getBool, NULL, NULL, NULL},
331 {"IconSize", "64", NULL,
332 &wPreferences.icon_size, getInt, NULL, NULL, NULL},
333 {"ModifierKey", "Mod1", NULL,
334 &wPreferences.modifier_mask, getModMask, NULL, NULL, NULL},
335 {"FocusMode", "manual", seFocusModes, /* have a problem when switching from */
336 &wPreferences.focus_mode, getEnum, NULL, NULL, NULL}, /* manual to sloppy without restart */
337 {"NewStyle", "new", seTitlebarModes,
338 &wPreferences.new_style, getEnum, NULL, NULL, NULL},
339 {"DisableDock", "NO", (void *)WM_DOCK,
340 NULL, getBool, setIfDockPresent, NULL, NULL},
341 {"DisableClip", "NO", (void *)WM_CLIP,
342 NULL, getBool, setIfDockPresent, NULL, NULL},
343 {"DisableDrawers", "NO", (void *)WM_DRAWER,
344 NULL, getBool, setIfDockPresent, NULL, NULL},
345 {"ClipMergedInDock", "NO", NULL,
346 NULL, getBool, setClipMergedInDock, NULL, NULL},
347 {"DisableMiniwindows", "NO", NULL,
348 &wPreferences.disable_miniwindows, getBool, NULL, NULL, NULL},
349 {"EnableWorkspacePager", "NO", NULL,
350 &wPreferences.enable_workspace_pager, getBool, NULL, NULL, NULL}
353 #define NUM2STRING_(x) #x
354 #define NUM2STRING(x) NUM2STRING_(x)
356 WDefaultEntry optionList[] = {
358 /* dynamic options */
360 {"IconPosition", "blh", seIconPositions,
361 &wPreferences.icon_yard, getEnum, setIconPosition, NULL, NULL},
362 {"IconificationStyle", "Zoom", seIconificationStyles,
363 &wPreferences.iconification_style, getEnum, NULL, NULL, NULL},
364 {"DisableWSMouseActions", "NO", NULL,
365 &wPreferences.disable_root_mouse, getBool, NULL, NULL, NULL},
366 {"MouseLeftButtonAction", "SelectWindows", seMouseButtonActions,
367 &wPreferences.mouse_button1, getEnum, NULL, NULL, NULL},
368 {"MouseMiddleButtonAction", "OpenWindowListMenu", seMouseButtonActions,
369 &wPreferences.mouse_button2, getEnum, NULL, NULL, NULL},
370 {"MouseRightButtonAction", "OpenApplicationsMenu", seMouseButtonActions,
371 &wPreferences.mouse_button3, getEnum, NULL, NULL, NULL},
372 {"MouseBackwardButtonAction", "None", seMouseButtonActions,
373 &wPreferences.mouse_button8, getEnum, NULL, NULL, NULL},
374 {"MouseForwardButtonAction", "None", seMouseButtonActions,
375 &wPreferences.mouse_button9, getEnum, NULL, NULL, NULL},
376 {"MouseWheelAction", "None", seMouseWheelActions,
377 &wPreferences.mouse_wheel_scroll, getEnum, NULL, NULL, NULL},
378 {"MouseWheelTiltAction", "None", seMouseWheelActions,
379 &wPreferences.mouse_wheel_tilt, getEnum, NULL, NULL, NULL},
380 {"PixmapPath", DEF_PIXMAP_PATHS, NULL,
381 &wPreferences.pixmap_path, getPathList, NULL, NULL, NULL},
382 {"IconPath", DEF_ICON_PATHS, NULL,
383 &wPreferences.icon_path, getPathList, NULL, NULL, NULL},
384 {"ColormapMode", "auto", seColormapModes,
385 &wPreferences.colormap_mode, getEnum, NULL, NULL, NULL},
386 {"AutoFocus", "NO", NULL,
387 &wPreferences.auto_focus, getBool, NULL, NULL, NULL},
388 {"RaiseDelay", "0", NULL,
389 &wPreferences.raise_delay, getInt, NULL, NULL, NULL},
390 {"CirculateRaise", "NO", NULL,
391 &wPreferences.circ_raise, getBool, NULL, NULL, NULL},
392 {"Superfluous", "NO", NULL,
393 &wPreferences.superfluous, getBool, NULL, NULL, NULL},
394 {"AdvanceToNewWorkspace", "NO", NULL,
395 &wPreferences.ws_advance, getBool, NULL, NULL, NULL},
396 {"CycleWorkspaces", "NO", NULL,
397 &wPreferences.ws_cycle, getBool, NULL, NULL, NULL},
398 {"WorkspaceNameDisplayPosition", "center", seDisplayPositions,
399 &wPreferences.workspace_name_display_position, getEnum, NULL, NULL, NULL},
400 {"WorkspaceBorder", "None", seWorkspaceBorder,
401 &wPreferences.workspace_border_position, getEnum, updateUsableArea, NULL, NULL},
402 {"WorkspaceBorderSize", "0", NULL,
403 &wPreferences.workspace_border_size, getInt, updateUsableArea, NULL, NULL},
404 {"StickyIcons", "NO", NULL,
405 &wPreferences.sticky_icons, getBool, setStickyIcons, NULL, NULL},
406 {"SaveSessionOnExit", "NO", NULL,
407 &wPreferences.save_session_on_exit, getBool, NULL, NULL, NULL},
408 {"WrapMenus", "NO", NULL,
409 &wPreferences.wrap_menus, getBool, NULL, NULL, NULL},
410 {"ScrollableMenus", "NO", NULL,
411 &wPreferences.scrollable_menus, getBool, NULL, NULL, NULL},
412 {"MenuScrollSpeed", "medium", seSpeeds,
413 &wPreferences.menu_scroll_speed, getEnum, NULL, NULL, NULL},
414 {"IconSlideSpeed", "medium", seSpeeds,
415 &wPreferences.icon_slide_speed, getEnum, NULL, NULL, NULL},
416 {"ShadeSpeed", "medium", seSpeeds,
417 &wPreferences.shade_speed, getEnum, NULL, NULL, NULL},
418 {"BounceAppIconsWhenUrgent", "YES", NULL,
419 &wPreferences.bounce_appicons_when_urgent, getBool, NULL, NULL, NULL},
420 {"RaiseAppIconsWhenBouncing", "NO", NULL,
421 &wPreferences.raise_appicons_when_bouncing, getBool, NULL, NULL, NULL},
422 {"DoNotMakeAppIconsBounce", "NO", NULL,
423 &wPreferences.do_not_make_appicons_bounce, getBool, NULL, NULL, NULL},
424 {"DoubleClickTime", "250", (void *)&wPreferences.dblclick_time,
425 &wPreferences.dblclick_time, getInt, setDoubleClick, NULL, NULL},
426 {"ClipAutoraiseDelay", "600", NULL,
427 &wPreferences.clip_auto_raise_delay, getInt, NULL, NULL, NULL},
428 {"ClipAutolowerDelay", "1000", NULL,
429 &wPreferences.clip_auto_lower_delay, getInt, NULL, NULL, NULL},
430 {"ClipAutoexpandDelay", "600", NULL,
431 &wPreferences.clip_auto_expand_delay, getInt, NULL, NULL, NULL},
432 {"ClipAutocollapseDelay", "1000", NULL,
433 &wPreferences.clip_auto_collapse_delay, getInt, NULL, NULL, NULL},
434 {"WrapAppiconsInDock", "YES", NULL,
435 NULL, getBool, setWrapAppiconsInDock, NULL, NULL},
436 {"AlignSubmenus", "NO", NULL,
437 &wPreferences.align_menus, getBool, NULL, NULL, NULL},
438 {"ViKeyMenus", "NO", NULL,
439 &wPreferences.vi_key_menus, getBool, NULL, NULL, NULL},
440 {"OpenTransientOnOwnerWorkspace", "NO", NULL,
441 &wPreferences.open_transients_with_parent, getBool, NULL, NULL, NULL},
442 {"WindowPlacement", "auto", sePlacements,
443 &wPreferences.window_placement, getEnum, NULL, NULL, NULL},
444 {"IgnoreFocusClick", "NO", NULL,
445 &wPreferences.ignore_focus_click, getBool, NULL, NULL, NULL},
446 {"UseSaveUnders", "NO", NULL,
447 &wPreferences.use_saveunders, getBool, NULL, NULL, NULL},
448 {"OpaqueMove", "NO", NULL,
449 &wPreferences.opaque_move, getBool, NULL, NULL, NULL},
450 {"OpaqueResize", "NO", NULL,
451 &wPreferences.opaque_resize, getBool, NULL, NULL, NULL},
452 {"OpaqueMoveResizeKeyboard", "NO", NULL,
453 &wPreferences.opaque_move_resize_keyboard, getBool, NULL, NULL, NULL},
454 {"DisableAnimations", "NO", NULL,
455 &wPreferences.no_animations, getBool, NULL, NULL, NULL},
456 {"DontLinkWorkspaces", "NO", NULL,
457 &wPreferences.no_autowrap, getBool, NULL, NULL, NULL},
458 {"WindowSnapping", "NO", NULL,
459 &wPreferences.window_snapping, getBool, NULL, NULL, NULL},
460 {"SnapEdgeDetect", "1", NULL,
461 &wPreferences.snap_edge_detect, getInt, NULL, NULL, NULL},
462 {"SnapCornerDetect", "10", NULL,
463 &wPreferences.snap_corner_detect, getInt, NULL, NULL, NULL},
464 {"SnapToTopMaximizesFullscreen", "NO", NULL,
465 &wPreferences.snap_to_top_maximizes_fullscreen, getBool, NULL, NULL, NULL},
466 {"DragMaximizedWindow", "Move", seDragMaximizedWindow,
467 &wPreferences.drag_maximized_window, getEnum, NULL, NULL, NULL},
468 {"MoveHalfMaximizedWindowsBetweenScreens", "NO", NULL,
469 &wPreferences.move_half_max_between_heads, getBool, NULL, NULL, NULL},
470 {"AlternativeHalfMaximized", "NO", NULL,
471 &wPreferences.alt_half_maximize, getBool, NULL, NULL, NULL},
472 {"PointerWithHalfMaxWindows", "NO", NULL,
473 &wPreferences.pointer_with_half_max_windows, getBool, NULL, NULL, NULL},
474 {"HighlightActiveApp", "YES", NULL,
475 &wPreferences.highlight_active_app, getBool, NULL, NULL, NULL},
476 {"AutoArrangeIcons", "NO", NULL,
477 &wPreferences.auto_arrange_icons, getBool, NULL, NULL, NULL},
478 {"NoWindowOverDock", "NO", NULL,
479 &wPreferences.no_window_over_dock, getBool, updateUsableArea, NULL, NULL},
480 {"NoWindowOverIcons", "NO", NULL,
481 &wPreferences.no_window_over_icons, getBool, updateUsableArea, NULL, NULL},
482 {"WindowPlaceOrigin", "(0, 0)", NULL,
483 &wPreferences.window_place_origin, getCoord, NULL, NULL, NULL},
484 {"ResizeDisplay", "corner", seGeomDisplays,
485 &wPreferences.size_display, getEnum, NULL, NULL, NULL},
486 {"MoveDisplay", "corner", seGeomDisplays,
487 &wPreferences.move_display, getEnum, NULL, NULL, NULL},
488 {"DontConfirmKill", "NO", NULL,
489 &wPreferences.dont_confirm_kill, getBool, NULL, NULL, NULL},
490 {"WindowTitleBalloons", "NO", NULL,
491 &wPreferences.window_balloon, getBool, NULL, NULL, NULL},
492 {"MiniwindowTitleBalloons", "NO", NULL,
493 &wPreferences.miniwin_title_balloon, getBool, NULL, NULL, NULL},
494 {"MiniwindowPreviewBalloons", "NO", NULL,
495 &wPreferences.miniwin_preview_balloon, getBool, NULL, NULL, NULL},
496 {"AppIconBalloons", "NO", NULL,
497 &wPreferences.appicon_balloon, getBool, NULL, NULL, NULL},
498 {"HelpBalloons", "NO", NULL,
499 &wPreferences.help_balloon, getBool, NULL, NULL, NULL},
500 {"EdgeResistance", "30", NULL,
501 &wPreferences.edge_resistance, getInt, NULL, NULL, NULL},
502 {"ResizeIncrement", "0", NULL,
503 &wPreferences.resize_increment, getInt, NULL, NULL, NULL},
504 {"Attraction", "NO", NULL,
505 &wPreferences.attract, getBool, NULL, NULL, NULL},
506 {"DisableBlinking", "NO", NULL,
507 &wPreferences.dont_blink, getBool, NULL, NULL, NULL},
508 {"SingleClickLaunch", "NO", NULL,
509 &wPreferences.single_click, getBool, NULL, NULL, NULL},
510 {"StrictWindozeCycle", "YES", NULL,
511 &wPreferences.strict_windoze_cycle, getBool, NULL, NULL, NULL},
512 {"SwitchPanelOnlyOpen", "NO", NULL,
513 &wPreferences.panel_only_open, getBool, NULL, NULL, NULL},
514 {"MiniPreviewSize", "128", NULL,
515 &wPreferences.minipreview_size, getInt, NULL, NULL, NULL},
516 {"IgnoreGtkHints", "NO", NULL,
517 &wPreferences.ignore_gtk_decoration_hints, getBool, NULL, NULL, NULL},
519 /* style options */
521 {"MenuStyle", "normal", seMenuStyles,
522 &wPreferences.menu_style, getEnum, setMenuStyle, NULL, NULL},
523 {"WidgetColor", "(solid, gray)", NULL,
524 NULL, getTexture, setWidgetColor, NULL, NULL},
525 {"WorkspaceSpecificBack", "()", NULL,
526 NULL, getWSSpecificBackground, setWorkspaceSpecificBack, NULL, NULL},
527 /* WorkspaceBack must come after WorkspaceSpecificBack or
528 * WorkspaceBack won't know WorkspaceSpecificBack was also
529 * specified and 2 copies of wmsetbg will be launched */
530 {"WorkspaceBack", "(solid, black)", NULL,
531 NULL, getWSBackground, setWorkspaceBack, NULL, NULL},
532 {"SmoothWorkspaceBack", "NO", NULL,
533 NULL, getBool, NULL, NULL, NULL},
534 {"IconBack", "(solid, gray)", NULL,
535 NULL, getTexture, setIconTile, NULL, NULL},
536 {"TitleJustify", "center", seJustifications,
537 &wPreferences.title_justification, getEnum, setJustify, NULL, NULL},
538 {"WindowTitleFont", DEF_TITLE_FONT, NULL,
539 NULL, getFont, setWinTitleFont, NULL, NULL},
540 {"WindowTitleExtendSpace", DEF_WINDOW_TITLE_EXTEND_SPACE, NULL,
541 &wPreferences.window_title_clearance, getInt, setClearance, NULL, NULL},
542 {"WindowTitleMinHeight", "0", NULL,
543 &wPreferences.window_title_min_height, getInt, setClearance, NULL, NULL},
544 {"WindowTitleMaxHeight", NUM2STRING(INT_MAX), NULL,
545 &wPreferences.window_title_max_height, getInt, setClearance, NULL, NULL},
546 {"MenuTitleExtendSpace", DEF_MENU_TITLE_EXTEND_SPACE, NULL,
547 &wPreferences.menu_title_clearance, getInt, setClearance, NULL, NULL},
548 {"MenuTitleMinHeight", "0", NULL,
549 &wPreferences.menu_title_min_height, getInt, setClearance, NULL, NULL},
550 {"MenuTitleMaxHeight", NUM2STRING(INT_MAX), NULL,
551 &wPreferences.menu_title_max_height, getInt, setClearance, NULL, NULL},
552 {"MenuTextExtendSpace", DEF_MENU_TEXT_EXTEND_SPACE, NULL,
553 &wPreferences.menu_text_clearance, getInt, setClearance, NULL, NULL},
554 {"MenuTitleFont", DEF_MENU_TITLE_FONT, NULL,
555 NULL, getFont, setMenuTitleFont, NULL, NULL},
556 {"MenuTextFont", DEF_MENU_ENTRY_FONT, NULL,
557 NULL, getFont, setMenuTextFont, NULL, NULL},
558 {"IconTitleFont", DEF_ICON_TITLE_FONT, NULL,
559 NULL, getFont, setIconTitleFont, NULL, NULL},
560 {"ClipTitleFont", DEF_CLIP_TITLE_FONT, NULL,
561 NULL, getFont, setClipTitleFont, NULL, NULL},
562 {"ShowClipTitle", "YES", NULL,
563 &wPreferences.show_clip_title, getBool, NULL, NULL, NULL},
564 {"LargeDisplayFont", DEF_WORKSPACE_NAME_FONT, NULL,
565 NULL, getFont, setLargeDisplayFont, NULL, NULL},
566 {"HighlightColor", "white", NULL,
567 NULL, getColor, setHightlight, NULL, NULL},
568 {"HighlightTextColor", "black", NULL,
569 NULL, getColor, setHightlightText, NULL, NULL},
570 {"ClipTitleColor", "black", (void *)CLIP_NORMAL,
571 NULL, getColor, setClipTitleColor, NULL, NULL},
572 {"CClipTitleColor", "\"#454045\"", (void *)CLIP_COLLAPSED,
573 NULL, getColor, setClipTitleColor, NULL, NULL},
574 {"FTitleColor", "white", (void *)WS_FOCUSED,
575 NULL, getColor, setWTitleColor, NULL, NULL},
576 {"PTitleColor", "white", (void *)WS_PFOCUSED,
577 NULL, getColor, setWTitleColor, NULL, NULL},
578 {"UTitleColor", "black", (void *)WS_UNFOCUSED,
579 NULL, getColor, setWTitleColor, NULL, NULL},
580 {"FTitleBack", "(solid, black)", NULL,
581 NULL, getTexture, setFTitleBack, NULL, NULL},
582 {"PTitleBack", "(solid, \"#616161\")", NULL,
583 NULL, getTexture, setPTitleBack, NULL, NULL},
584 {"UTitleBack", "(solid, gray)", NULL,
585 NULL, getTexture, setUTitleBack, NULL, NULL},
586 {"ResizebarBack", "(solid, gray)", NULL,
587 NULL, getTexture, setResizebarBack, NULL, NULL},
588 {"MenuTitleColor", "white", NULL,
589 NULL, getColor, setMenuTitleColor, NULL, NULL},
590 {"MenuTextColor", "black", NULL,
591 NULL, getColor, setMenuTextColor, NULL, NULL},
592 {"MenuDisabledColor", "\"#616161\"", NULL,
593 NULL, getColor, setMenuDisabledColor, NULL, NULL},
594 {"MenuTitleBack", "(solid, black)", NULL,
595 NULL, getTexture, setMenuTitleBack, NULL, NULL},
596 {"MenuTextBack", "(solid, gray)", NULL,
597 NULL, getTexture, setMenuTextBack, NULL, NULL},
598 {"IconTitleColor", "white", NULL,
599 NULL, getColor, setIconTitleColor, NULL, NULL},
600 {"IconTitleBack", "black", NULL,
601 NULL, getColor, setIconTitleBack, NULL, NULL},
602 {"SwitchPanelImages", "(swtile.png, swback.png, 30, 40)", &wPreferences,
603 NULL, getPropList, setSwPOptions, NULL, NULL},
604 {"ModifierKeyLabels", "(\"Shift+\", \"Control+\", \"Mod1+\", \"Mod2+\", \"Mod3+\", \"Mod4+\", \"Mod5+\")", &wPreferences,
605 NULL, getPropList, setModifierKeyLabels, NULL, NULL},
606 {"FrameBorderWidth", "1", NULL,
607 NULL, getInt, setFrameBorderWidth, NULL, NULL},
608 {"FrameBorderColor", "black", NULL,
609 NULL, getColor, setFrameBorderColor, NULL, NULL},
610 {"FrameFocusedBorderColor", "black", NULL,
611 NULL, getColor, setFrameFocusedBorderColor, NULL, NULL},
612 {"FrameSelectedBorderColor", "white", NULL,
613 NULL, getColor, setFrameSelectedBorderColor, NULL, NULL},
614 {"WorkspaceMapBack", "(solid, black)", NULL,
615 NULL, getTexture, setWorkspaceMapBackground, NULL, NULL},
617 /* keybindings */
619 {"RootMenuKey", "None", (void *)WKBD_ROOTMENU,
620 NULL, getKeybind, setKeyGrab, NULL, NULL},
621 {"WindowListKey", "None", (void *)WKBD_WINDOWLIST,
622 NULL, getKeybind, setKeyGrab, NULL, NULL},
623 {"WindowMenuKey", "None", (void *)WKBD_WINDOWMENU,
624 NULL, getKeybind, setKeyGrab, NULL, NULL},
625 {"DockRaiseLowerKey", "None", (void*)WKBD_DOCKRAISELOWER,
626 NULL, getKeybind, setKeyGrab, NULL, NULL},
627 {"ClipRaiseLowerKey", "None", (void *)WKBD_CLIPRAISELOWER,
628 NULL, getKeybind, setKeyGrab, NULL, NULL},
629 {"MiniaturizeKey", "None", (void *)WKBD_MINIATURIZE,
630 NULL, getKeybind, setKeyGrab, NULL, NULL},
631 {"MinimizeAllKey", "None", (void *)WKBD_MINIMIZEALL,
632 NULL, getKeybind, setKeyGrab, NULL, NULL },
633 {"HideKey", "None", (void *)WKBD_HIDE,
634 NULL, getKeybind, setKeyGrab, NULL, NULL},
635 {"HideOthersKey", "None", (void *)WKBD_HIDE_OTHERS,
636 NULL, getKeybind, setKeyGrab, NULL, NULL},
637 {"MoveResizeKey", "None", (void *)WKBD_MOVERESIZE,
638 NULL, getKeybind, setKeyGrab, NULL, NULL},
639 {"CloseKey", "None", (void *)WKBD_CLOSE,
640 NULL, getKeybind, setKeyGrab, NULL, NULL},
641 {"MaximizeKey", "None", (void *)WKBD_MAXIMIZE,
642 NULL, getKeybind, setKeyGrab, NULL, NULL},
643 {"VMaximizeKey", "None", (void *)WKBD_VMAXIMIZE,
644 NULL, getKeybind, setKeyGrab, NULL, NULL},
645 {"HMaximizeKey", "None", (void *)WKBD_HMAXIMIZE,
646 NULL, getKeybind, setKeyGrab, NULL, NULL},
647 {"LHMaximizeKey", "None", (void*)WKBD_LHMAXIMIZE,
648 NULL, getKeybind, setKeyGrab, NULL, NULL},
649 {"RHMaximizeKey", "None", (void*)WKBD_RHMAXIMIZE,
650 NULL, getKeybind, setKeyGrab, NULL, NULL},
651 {"THMaximizeKey", "None", (void*)WKBD_THMAXIMIZE,
652 NULL, getKeybind, setKeyGrab, NULL, NULL},
653 {"BHMaximizeKey", "None", (void*)WKBD_BHMAXIMIZE,
654 NULL, getKeybind, setKeyGrab, NULL, NULL},
655 {"LTCMaximizeKey", "None", (void*)WKBD_LTCMAXIMIZE,
656 NULL, getKeybind, setKeyGrab, NULL, NULL},
657 {"RTCMaximizeKey", "None", (void*)WKBD_RTCMAXIMIZE,
658 NULL, getKeybind, setKeyGrab, NULL, NULL},
659 {"LBCMaximizeKey", "None", (void*)WKBD_LBCMAXIMIZE,
660 NULL, getKeybind, setKeyGrab, NULL, NULL},
661 {"RBCMaximizeKey", "None", (void*)WKBD_RBCMAXIMIZE,
662 NULL, getKeybind, setKeyGrab, NULL, NULL},
663 {"MaximusKey", "None", (void*)WKBD_MAXIMUS,
664 NULL, getKeybind, setKeyGrab, NULL, NULL},
665 {"KeepOnTopKey", "None", (void *)WKBD_KEEP_ON_TOP,
666 NULL, getKeybind, setKeyGrab, NULL, NULL},
667 {"KeepAtBottomKey", "None", (void *)WKBD_KEEP_AT_BOTTOM,
668 NULL, getKeybind, setKeyGrab, NULL, NULL},
669 {"OmnipresentKey", "None", (void *)WKBD_OMNIPRESENT,
670 NULL, getKeybind, setKeyGrab, NULL, NULL},
671 {"RaiseKey", "\"Meta+Up\"", (void *)WKBD_RAISE,
672 NULL, getKeybind, setKeyGrab, NULL, NULL},
673 {"LowerKey", "\"Meta+Down\"", (void *)WKBD_LOWER,
674 NULL, getKeybind, setKeyGrab, NULL, NULL},
675 {"RaiseLowerKey", "None", (void *)WKBD_RAISELOWER,
676 NULL, getKeybind, setKeyGrab, NULL, NULL},
677 {"ShadeKey", "None", (void *)WKBD_SHADE,
678 NULL, getKeybind, setKeyGrab, NULL, NULL},
679 {"SelectKey", "None", (void *)WKBD_SELECT,
680 NULL, getKeybind, setKeyGrab, NULL, NULL},
681 {"WorkspaceMapKey", "None", (void *)WKBD_WORKSPACEMAP,
682 NULL, getKeybind, setKeyGrab, NULL, NULL},
683 {"FocusNextKey", "None", (void *)WKBD_FOCUSNEXT,
684 NULL, getKeybind, setKeyGrab, NULL, NULL},
685 {"FocusPrevKey", "None", (void *)WKBD_FOCUSPREV,
686 NULL, getKeybind, setKeyGrab, NULL, NULL},
687 {"GroupNextKey", "None", (void *)WKBD_GROUPNEXT,
688 NULL, getKeybind, setKeyGrab, NULL, NULL},
689 {"GroupPrevKey", "None", (void *)WKBD_GROUPPREV,
690 NULL, getKeybind, setKeyGrab, NULL, NULL},
691 {"NextWorkspaceKey", "None", (void *)WKBD_NEXTWORKSPACE,
692 NULL, getKeybind, setKeyGrab, NULL, NULL},
693 {"PrevWorkspaceKey", "None", (void *)WKBD_PREVWORKSPACE,
694 NULL, getKeybind, setKeyGrab, NULL, NULL},
695 {"LastWorkspaceKey", "None", (void *)WKBD_LASTWORKSPACE,
696 NULL, getKeybind, setKeyGrab, NULL, NULL},
697 {"NextWorkspaceLayerKey", "None", (void *)WKBD_NEXTWSLAYER,
698 NULL, getKeybind, setKeyGrab, NULL, NULL},
699 {"PrevWorkspaceLayerKey", "None", (void *)WKBD_PREVWSLAYER,
700 NULL, getKeybind, setKeyGrab, NULL, NULL},
701 {"Workspace1Key", "None", (void *)WKBD_WORKSPACE1,
702 NULL, getKeybind, setKeyGrab, NULL, NULL},
703 {"Workspace2Key", "None", (void *)WKBD_WORKSPACE2,
704 NULL, getKeybind, setKeyGrab, NULL, NULL},
705 {"Workspace3Key", "None", (void *)WKBD_WORKSPACE3,
706 NULL, getKeybind, setKeyGrab, NULL, NULL},
707 {"Workspace4Key", "None", (void *)WKBD_WORKSPACE4,
708 NULL, getKeybind, setKeyGrab, NULL, NULL},
709 {"Workspace5Key", "None", (void *)WKBD_WORKSPACE5,
710 NULL, getKeybind, setKeyGrab, NULL, NULL},
711 {"Workspace6Key", "None", (void *)WKBD_WORKSPACE6,
712 NULL, getKeybind, setKeyGrab, NULL, NULL},
713 {"Workspace7Key", "None", (void *)WKBD_WORKSPACE7,
714 NULL, getKeybind, setKeyGrab, NULL, NULL},
715 {"Workspace8Key", "None", (void *)WKBD_WORKSPACE8,
716 NULL, getKeybind, setKeyGrab, NULL, NULL},
717 {"Workspace9Key", "None", (void *)WKBD_WORKSPACE9,
718 NULL, getKeybind, setKeyGrab, NULL, NULL},
719 {"Workspace10Key", "None", (void *)WKBD_WORKSPACE10,
720 NULL, getKeybind, setKeyGrab, NULL, NULL},
721 {"MoveToWorkspace1Key", "None", (void *)WKBD_MOVE_WORKSPACE1,
722 NULL, getKeybind, setKeyGrab, NULL, NULL},
723 {"MoveToWorkspace2Key", "None", (void *)WKBD_MOVE_WORKSPACE2,
724 NULL, getKeybind, setKeyGrab, NULL, NULL},
725 {"MoveToWorkspace3Key", "None", (void *)WKBD_MOVE_WORKSPACE3,
726 NULL, getKeybind, setKeyGrab, NULL, NULL},
727 {"MoveToWorkspace4Key", "None", (void *)WKBD_MOVE_WORKSPACE4,
728 NULL, getKeybind, setKeyGrab, NULL, NULL},
729 {"MoveToWorkspace5Key", "None", (void *)WKBD_MOVE_WORKSPACE5,
730 NULL, getKeybind, setKeyGrab, NULL, NULL},
731 {"MoveToWorkspace6Key", "None", (void *)WKBD_MOVE_WORKSPACE6,
732 NULL, getKeybind, setKeyGrab, NULL, NULL},
733 {"MoveToWorkspace7Key", "None", (void *)WKBD_MOVE_WORKSPACE7,
734 NULL, getKeybind, setKeyGrab, NULL, NULL},
735 {"MoveToWorkspace8Key", "None", (void *)WKBD_MOVE_WORKSPACE8,
736 NULL, getKeybind, setKeyGrab, NULL, NULL},
737 {"MoveToWorkspace9Key", "None", (void *)WKBD_MOVE_WORKSPACE9,
738 NULL, getKeybind, setKeyGrab, NULL, NULL},
739 {"MoveToWorkspace10Key", "None", (void *)WKBD_MOVE_WORKSPACE10,
740 NULL, getKeybind, setKeyGrab, NULL, NULL},
741 {"MoveToNextWorkspaceKey", "None", (void *)WKBD_MOVE_NEXTWORKSPACE,
742 NULL, getKeybind, setKeyGrab, NULL, NULL},
743 {"MoveToPrevWorkspaceKey", "None", (void *)WKBD_MOVE_PREVWORKSPACE,
744 NULL, getKeybind, setKeyGrab, NULL, NULL},
745 {"MoveToLastWorkspaceKey", "None", (void *)WKBD_MOVE_LASTWORKSPACE,
746 NULL, getKeybind, setKeyGrab, NULL, NULL},
747 {"MoveToNextWorkspaceLayerKey", "None", (void *)WKBD_MOVE_NEXTWSLAYER,
748 NULL, getKeybind, setKeyGrab, NULL, NULL},
749 {"MoveToPrevWorkspaceLayerKey", "None", (void *)WKBD_MOVE_PREVWSLAYER,
750 NULL, getKeybind, setKeyGrab, NULL, NULL},
751 {"WindowShortcut1Key", "None", (void *)WKBD_WINDOW1,
752 NULL, getKeybind, setKeyGrab, NULL, NULL},
753 {"WindowShortcut2Key", "None", (void *)WKBD_WINDOW2,
754 NULL, getKeybind, setKeyGrab, NULL, NULL},
755 {"WindowShortcut3Key", "None", (void *)WKBD_WINDOW3,
756 NULL, getKeybind, setKeyGrab, NULL, NULL},
757 {"WindowShortcut4Key", "None", (void *)WKBD_WINDOW4,
758 NULL, getKeybind, setKeyGrab, NULL, NULL},
759 {"WindowShortcut5Key", "None", (void *)WKBD_WINDOW5,
760 NULL, getKeybind, setKeyGrab, NULL, NULL},
761 {"WindowShortcut6Key", "None", (void *)WKBD_WINDOW6,
762 NULL, getKeybind, setKeyGrab, NULL, NULL},
763 {"WindowShortcut7Key", "None", (void *)WKBD_WINDOW7,
764 NULL, getKeybind, setKeyGrab, NULL, NULL},
765 {"WindowShortcut8Key", "None", (void *)WKBD_WINDOW8,
766 NULL, getKeybind, setKeyGrab, NULL, NULL},
767 {"WindowShortcut9Key", "None", (void *)WKBD_WINDOW9,
768 NULL, getKeybind, setKeyGrab, NULL, NULL},
769 {"WindowShortcut10Key", "None", (void *)WKBD_WINDOW10,
770 NULL, getKeybind, setKeyGrab, NULL, NULL},
771 {"WindowRelaunchKey", "None", (void *)WKBD_RELAUNCH,
772 NULL, getKeybind, setKeyGrab, NULL, NULL},
773 {"ScreenSwitchKey", "None", (void *)WKBD_SWITCH_SCREEN,
774 NULL, getKeybind, setKeyGrab, NULL, NULL},
775 {"RunKey", "None", (void *)WKBD_RUN,
776 NULL, getKeybind, setKeyGrab, NULL, NULL},
778 #ifdef KEEP_XKB_LOCK_STATUS
779 {"ToggleKbdModeKey", "None", (void *)WKBD_TOGGLE,
780 NULL, getKeybind, setKeyGrab, NULL, NULL},
781 {"KbdModeLock", "NO", NULL,
782 &wPreferences.modelock, getBool, NULL, NULL, NULL},
783 #endif /* KEEP_XKB_LOCK_STATUS */
785 {"NormalCursor", "(builtin, left_ptr)", (void *)WCUR_ROOT,
786 NULL, getCursor, setCursor, NULL, NULL},
787 {"ArrowCursor", "(builtin, top_left_arrow)", (void *)WCUR_ARROW,
788 NULL, getCursor, setCursor, NULL, NULL},
789 {"MoveCursor", "(builtin, fleur)", (void *)WCUR_MOVE,
790 NULL, getCursor, setCursor, NULL, NULL},
791 {"ResizeCursor", "(builtin, sizing)", (void *)WCUR_RESIZE,
792 NULL, getCursor, setCursor, NULL, NULL},
793 {"TopLeftResizeCursor", "(builtin, top_left_corner)", (void *)WCUR_TOPLEFTRESIZE,
794 NULL, getCursor, setCursor, NULL, NULL},
795 {"TopRightResizeCursor", "(builtin, top_right_corner)", (void *)WCUR_TOPRIGHTRESIZE,
796 NULL, getCursor, setCursor, NULL, NULL},
797 {"BottomLeftResizeCursor", "(builtin, bottom_left_corner)", (void *)WCUR_BOTTOMLEFTRESIZE,
798 NULL, getCursor, setCursor, NULL, NULL},
799 {"BottomRightResizeCursor", "(builtin, bottom_right_corner)", (void *)WCUR_BOTTOMRIGHTRESIZE,
800 NULL, getCursor, setCursor, NULL, NULL},
801 {"VerticalResizeCursor", "(builtin, sb_v_double_arrow)", (void *)WCUR_VERTICALRESIZE,
802 NULL, getCursor, setCursor, NULL, NULL},
803 {"HorizontalResizeCursor", "(builtin, sb_h_double_arrow)", (void *)WCUR_HORIZONRESIZE,
804 NULL, getCursor, setCursor, NULL, NULL},
805 {"WaitCursor", "(builtin, watch)", (void *)WCUR_WAIT,
806 NULL, getCursor, setCursor, NULL, NULL},
807 {"QuestionCursor", "(builtin, question_arrow)", (void *)WCUR_QUESTION,
808 NULL, getCursor, setCursor, NULL, NULL},
809 {"TextCursor", "(builtin, xterm)", (void *)WCUR_TEXT,
810 NULL, getCursor, setCursor, NULL, NULL},
811 {"SelectCursor", "(builtin, cross)", (void *)WCUR_SELECT,
812 NULL, getCursor, setCursor, NULL, NULL},
813 {"DialogHistoryLines", "500", NULL,
814 &wPreferences.history_lines, getInt, NULL, NULL, NULL},
815 {"CycleActiveHeadOnly", "NO", NULL,
816 &wPreferences.cycle_active_head_only, getBool, NULL, NULL, NULL},
817 {"CycleIgnoreMinimized", "NO", NULL,
818 &wPreferences.cycle_ignore_minimized, getBool, NULL, NULL, NULL}
821 static void initDefaults(void)
823 unsigned int i;
824 WDefaultEntry *entry;
826 WMPLSetCaseSensitive(False);
828 for (i = 0; i < wlengthof(optionList); i++) {
829 entry = &optionList[i];
831 entry->plkey = WMCreatePLString(entry->key);
832 if (entry->default_value)
833 entry->plvalue = WMCreatePropListFromDescription(entry->default_value);
834 else
835 entry->plvalue = NULL;
838 for (i = 0; i < wlengthof(staticOptionList); i++) {
839 entry = &staticOptionList[i];
841 entry->plkey = WMCreatePLString(entry->key);
842 if (entry->default_value)
843 entry->plvalue = WMCreatePropListFromDescription(entry->default_value);
844 else
845 entry->plvalue = NULL;
849 static WMPropList *readGlobalDomain(const char *domainName, Bool requireDictionary)
851 WMPropList *globalDict = NULL;
852 char path[PATH_MAX];
853 struct stat stbuf;
855 snprintf(path, sizeof(path), "%s/%s", DEFSDATADIR, domainName);
856 if (stat(path, &stbuf) >= 0) {
857 globalDict = WMReadPropListFromFile(path);
858 if (globalDict && requireDictionary && !WMIsPLDictionary(globalDict)) {
859 wwarning(_("Domain %s (%s) of global defaults database is corrupted!"), domainName, path);
860 WMReleasePropList(globalDict);
861 globalDict = NULL;
862 } else if (!globalDict) {
863 wwarning(_("could not load domain %s from global defaults database"), domainName);
867 return globalDict;
870 #if defined(GLOBAL_PREAMBLE_MENU_FILE) || defined(GLOBAL_EPILOGUE_MENU_FILE)
871 static void prependMenu(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 WMInsertInPLArray(destarr, i + 1, item);
883 static void appendMenu(WMPropList * destarr, WMPropList * array)
885 WMPropList *item;
886 int i;
888 for (i = 0; i < WMGetPropListItemCount(array); i++) {
889 item = WMGetFromPLArray(array, i);
890 if (item)
891 WMAddToPLArray(destarr, item);
894 #endif
896 void wDefaultsMergeGlobalMenus(WDDomain * menuDomain)
898 WMPropList *menu = menuDomain->dictionary;
899 WMPropList *submenu;
901 if (!menu || !WMIsPLArray(menu))
902 return;
904 #ifdef GLOBAL_PREAMBLE_MENU_FILE
905 submenu = WMReadPropListFromFile(DEFSDATADIR "/" GLOBAL_PREAMBLE_MENU_FILE);
907 if (submenu && !WMIsPLArray(submenu)) {
908 wwarning(_("invalid global menu file %s"), GLOBAL_PREAMBLE_MENU_FILE);
909 WMReleasePropList(submenu);
910 submenu = NULL;
912 if (submenu) {
913 prependMenu(menu, submenu);
914 WMReleasePropList(submenu);
916 #endif
918 #ifdef GLOBAL_EPILOGUE_MENU_FILE
919 submenu = WMReadPropListFromFile(DEFSDATADIR "/" GLOBAL_EPILOGUE_MENU_FILE);
921 if (submenu && !WMIsPLArray(submenu)) {
922 wwarning(_("invalid global menu file %s"), GLOBAL_EPILOGUE_MENU_FILE);
923 WMReleasePropList(submenu);
924 submenu = NULL;
926 if (submenu) {
927 appendMenu(menu, submenu);
928 WMReleasePropList(submenu);
930 #endif
932 menuDomain->dictionary = menu;
935 WDDomain *wDefaultsInitDomain(const char *domain, Bool requireDictionary)
937 WDDomain *db;
938 struct stat stbuf;
939 static int inited = 0;
940 WMPropList *shared_dict = NULL;
942 if (!inited) {
943 inited = 1;
944 initDefaults();
947 db = wmalloc(sizeof(WDDomain));
948 db->domain_name = domain;
949 db->path = wdefaultspathfordomain(domain);
951 if (stat(db->path, &stbuf) >= 0) {
952 db->dictionary = WMReadPropListFromFile(db->path);
953 if (db->dictionary) {
954 if (requireDictionary && !WMIsPLDictionary(db->dictionary)) {
955 WMReleasePropList(db->dictionary);
956 db->dictionary = NULL;
957 wwarning(_("Domain %s (%s) of defaults database is corrupted!"), domain, db->path);
959 db->timestamp = stbuf.st_mtime;
960 } else {
961 wwarning(_("could not load domain %s from user defaults database"), domain);
965 /* global system dictionary */
966 shared_dict = readGlobalDomain(domain, requireDictionary);
968 if (shared_dict && db->dictionary && WMIsPLDictionary(shared_dict) &&
969 WMIsPLDictionary(db->dictionary)) {
970 WMMergePLDictionaries(shared_dict, db->dictionary, True);
971 WMReleasePropList(db->dictionary);
972 db->dictionary = shared_dict;
973 if (stbuf.st_mtime > db->timestamp)
974 db->timestamp = stbuf.st_mtime;
975 } else if (!db->dictionary) {
976 db->dictionary = shared_dict;
977 if (stbuf.st_mtime > db->timestamp)
978 db->timestamp = stbuf.st_mtime;
981 return db;
984 void wReadStaticDefaults(WMPropList * dict)
986 WMPropList *plvalue;
987 WDefaultEntry *entry;
988 unsigned int i;
989 void *tdata;
991 for (i = 0; i < wlengthof(staticOptionList); i++) {
992 entry = &staticOptionList[i];
994 if (dict)
995 plvalue = WMGetFromPLDictionary(dict, entry->plkey);
996 else
997 plvalue = NULL;
999 /* no default in the DB. Use builtin default */
1000 if (!plvalue)
1001 plvalue = entry->plvalue;
1003 if (plvalue) {
1004 /* convert data */
1005 (*entry->convert) (NULL, entry, plvalue, entry->addr, &tdata);
1006 if (entry->update)
1007 (*entry->update) (NULL, entry, tdata, entry->extra_data);
1012 void wDefaultsCheckDomains(void* arg)
1014 WScreen *scr;
1015 struct stat stbuf;
1016 WMPropList *shared_dict = NULL;
1017 WMPropList *dict;
1018 int i;
1020 /* Parameter not used, but tell the compiler that it is ok */
1021 (void) arg;
1023 if (stat(w_global.domain.wmaker->path, &stbuf) >= 0 && w_global.domain.wmaker->timestamp < stbuf.st_mtime) {
1024 w_global.domain.wmaker->timestamp = stbuf.st_mtime;
1026 /* Global dictionary */
1027 shared_dict = readGlobalDomain("WindowMaker", True);
1029 /* User dictionary */
1030 dict = WMReadPropListFromFile(w_global.domain.wmaker->path);
1032 if (dict) {
1033 if (!WMIsPLDictionary(dict)) {
1034 WMReleasePropList(dict);
1035 dict = NULL;
1036 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
1037 "WindowMaker", w_global.domain.wmaker->path);
1038 } else {
1039 if (shared_dict) {
1040 WMMergePLDictionaries(shared_dict, dict, True);
1041 WMReleasePropList(dict);
1042 dict = shared_dict;
1043 shared_dict = NULL;
1046 for (i = 0; i < w_global.screen_count; i++) {
1047 scr = wScreenWithNumber(i);
1048 if (scr)
1049 wReadDefaults(scr, dict);
1052 if (w_global.domain.wmaker->dictionary)
1053 WMReleasePropList(w_global.domain.wmaker->dictionary);
1055 w_global.domain.wmaker->dictionary = dict;
1057 } else {
1058 wwarning(_("could not load domain %s from user defaults database"), "WindowMaker");
1061 if (shared_dict)
1062 WMReleasePropList(shared_dict);
1066 if (stat(w_global.domain.window_attr->path, &stbuf) >= 0 && w_global.domain.window_attr->timestamp < stbuf.st_mtime) {
1067 /* global dictionary */
1068 shared_dict = readGlobalDomain("WMWindowAttributes", True);
1069 /* user dictionary */
1070 dict = WMReadPropListFromFile(w_global.domain.window_attr->path);
1071 if (dict) {
1072 if (!WMIsPLDictionary(dict)) {
1073 WMReleasePropList(dict);
1074 dict = NULL;
1075 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
1076 "WMWindowAttributes", w_global.domain.window_attr->path);
1077 } else {
1078 if (shared_dict) {
1079 WMMergePLDictionaries(shared_dict, dict, True);
1080 WMReleasePropList(dict);
1081 dict = shared_dict;
1082 shared_dict = NULL;
1085 if (w_global.domain.window_attr->dictionary)
1086 WMReleasePropList(w_global.domain.window_attr->dictionary);
1088 w_global.domain.window_attr->dictionary = dict;
1089 for (i = 0; i < w_global.screen_count; i++) {
1090 scr = wScreenWithNumber(i);
1091 if (scr) {
1092 wDefaultUpdateIcons(scr);
1094 /* Update the panel image if changed */
1095 /* Don't worry. If the image is the same these
1096 * functions will have no performance impact. */
1097 create_logo_image(scr);
1101 } else {
1102 wwarning(_("could not load domain %s from user defaults database"), "WMWindowAttributes");
1105 w_global.domain.window_attr->timestamp = stbuf.st_mtime;
1106 if (shared_dict)
1107 WMReleasePropList(shared_dict);
1110 if (stat(w_global.domain.root_menu->path, &stbuf) >= 0 && w_global.domain.root_menu->timestamp < stbuf.st_mtime) {
1111 dict = WMReadPropListFromFile(w_global.domain.root_menu->path);
1112 if (dict) {
1113 if (!WMIsPLArray(dict) && !WMIsPLString(dict)) {
1114 WMReleasePropList(dict);
1115 dict = NULL;
1116 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
1117 "WMRootMenu", w_global.domain.root_menu->path);
1118 } else {
1119 if (w_global.domain.root_menu->dictionary)
1120 WMReleasePropList(w_global.domain.root_menu->dictionary);
1122 w_global.domain.root_menu->dictionary = dict;
1123 wDefaultsMergeGlobalMenus(w_global.domain.root_menu);
1125 } else {
1126 wwarning(_("could not load domain %s from user defaults database"), "WMRootMenu");
1128 w_global.domain.root_menu->timestamp = stbuf.st_mtime;
1130 #ifndef HAVE_INOTIFY
1131 if (!arg)
1132 WMAddTimerHandler(DEFAULTS_CHECK_INTERVAL, wDefaultsCheckDomains, arg);
1133 #endif
1136 void wReadDefaults(WScreen * scr, WMPropList * new_dict)
1138 WMPropList *plvalue, *old_value;
1139 WDefaultEntry *entry;
1140 unsigned int i;
1141 int update_workspace_back = 0; /* kluge :/ */
1142 unsigned int needs_refresh;
1143 void *tdata;
1144 WMPropList *old_dict = (w_global.domain.wmaker->dictionary != new_dict ? w_global.domain.wmaker->dictionary : NULL);
1146 needs_refresh = 0;
1148 for (i = 0; i < wlengthof(optionList); i++) {
1149 entry = &optionList[i];
1151 if (new_dict)
1152 plvalue = WMGetFromPLDictionary(new_dict, entry->plkey);
1153 else
1154 plvalue = NULL;
1156 if (!old_dict)
1157 old_value = NULL;
1158 else
1159 old_value = WMGetFromPLDictionary(old_dict, entry->plkey);
1161 if (!plvalue && !old_value) {
1162 /* no default in the DB. Use builtin default */
1163 plvalue = entry->plvalue;
1164 if (plvalue && new_dict)
1165 WMPutInPLDictionary(new_dict, entry->plkey, plvalue);
1167 } else if (!plvalue) {
1168 /* value was deleted from DB. Keep current value */
1169 continue;
1170 } else if (!old_value) {
1171 /* set value for the 1st time */
1172 } else if (!WMIsPropListEqualTo(plvalue, old_value)) {
1173 /* value has changed */
1174 } else {
1175 if (strcmp(entry->key, "WorkspaceBack") == 0
1176 && update_workspace_back && scr->flags.backimage_helper_launched) {
1177 } else {
1178 /* value was not changed since last time */
1179 continue;
1183 if (plvalue) {
1184 /* convert data */
1185 if ((*entry->convert) (scr, entry, plvalue, entry->addr, &tdata)) {
1187 * If the WorkspaceSpecificBack data has been changed
1188 * so that the helper will be launched now, we must be
1189 * sure to send the default background texture config
1190 * to the helper.
1192 if (strcmp(entry->key, "WorkspaceSpecificBack") == 0 &&
1193 !scr->flags.backimage_helper_launched)
1194 update_workspace_back = 1;
1196 if (entry->update)
1197 needs_refresh |= (*entry->update) (scr, entry, tdata, entry->extra_data);
1203 if (needs_refresh != 0 && !scr->flags.startup) {
1204 int foo;
1206 foo = 0;
1207 if (needs_refresh & REFRESH_MENU_TITLE_TEXTURE)
1208 foo |= WTextureSettings;
1209 if (needs_refresh & REFRESH_MENU_TITLE_FONT)
1210 foo |= WFontSettings;
1211 if (needs_refresh & REFRESH_MENU_TITLE_COLOR)
1212 foo |= WColorSettings;
1213 if (foo)
1214 WMPostNotificationName(WNMenuTitleAppearanceSettingsChanged, NULL,
1215 (void *)(uintptr_t) foo);
1217 foo = 0;
1218 if (needs_refresh & REFRESH_MENU_TEXTURE)
1219 foo |= WTextureSettings;
1220 if (needs_refresh & REFRESH_MENU_FONT)
1221 foo |= WFontSettings;
1222 if (needs_refresh & REFRESH_MENU_COLOR)
1223 foo |= WColorSettings;
1224 if (foo)
1225 WMPostNotificationName(WNMenuAppearanceSettingsChanged, NULL, (void *)(uintptr_t) foo);
1227 foo = 0;
1228 if (needs_refresh & REFRESH_WINDOW_FONT)
1229 foo |= WFontSettings;
1230 if (needs_refresh & REFRESH_WINDOW_TEXTURES)
1231 foo |= WTextureSettings;
1232 if (needs_refresh & REFRESH_WINDOW_TITLE_COLOR)
1233 foo |= WColorSettings;
1234 if (foo)
1235 WMPostNotificationName(WNWindowAppearanceSettingsChanged, NULL, (void *)(uintptr_t) foo);
1237 if (!(needs_refresh & REFRESH_ICON_TILE)) {
1238 foo = 0;
1239 if (needs_refresh & REFRESH_ICON_FONT)
1240 foo |= WFontSettings;
1241 if (needs_refresh & REFRESH_ICON_TITLE_COLOR)
1242 foo |= WTextureSettings;
1243 if (needs_refresh & REFRESH_ICON_TITLE_BACK)
1244 foo |= WTextureSettings;
1245 if (foo)
1246 WMPostNotificationName(WNIconAppearanceSettingsChanged, NULL,
1247 (void *)(uintptr_t) foo);
1249 if (needs_refresh & REFRESH_ICON_TILE)
1250 WMPostNotificationName(WNIconTileSettingsChanged, NULL, NULL);
1252 if (needs_refresh & REFRESH_WORKSPACE_MENU) {
1253 if (scr->workspace_menu)
1254 wWorkspaceMenuUpdate(scr, scr->workspace_menu);
1255 if (scr->clip_ws_menu)
1256 wWorkspaceMenuUpdate(scr, scr->clip_ws_menu);
1257 if (scr->workspace_submenu)
1258 scr->workspace_submenu->flags.realized = 0;
1259 if (scr->clip_submenu)
1260 scr->clip_submenu->flags.realized = 0;
1265 void wDefaultUpdateIcons(WScreen *scr)
1267 WAppIcon *aicon = scr->app_icon_list;
1268 WDrawerChain *dc;
1269 WWindow *wwin = scr->focused_window;
1271 while (aicon) {
1272 /* Get the application icon, default included */
1273 wIconChangeImageFile(aicon->icon, NULL);
1274 wAppIconPaint(aicon);
1275 aicon = aicon->next;
1278 if (!wPreferences.flags.noclip || wPreferences.flags.clip_merged_in_dock)
1279 wClipIconPaint(scr->clip_icon);
1281 for (dc = scr->drawers; dc != NULL; dc = dc->next)
1282 wDrawerIconPaint(dc->adrawer->icon_array[0]);
1284 while (wwin) {
1285 if (wwin->icon && wwin->flags.miniaturized)
1286 wIconChangeImageFile(wwin->icon, NULL);
1287 wwin = wwin->prev;
1291 /* --------------------------- Local ----------------------- */
1293 #define GET_STRING_OR_DEFAULT(x, var) if (!WMIsPLString(value)) { \
1294 wwarning(_("Wrong option format for key \"%s\". Should be %s."), \
1295 entry->key, x); \
1296 wwarning(_("using default \"%s\" instead"), entry->default_value); \
1297 var = entry->default_value;\
1298 } else var = WMGetFromPLString(value)\
1301 static int string2index(WMPropList *key, WMPropList *val, const char *def, WOptionEnumeration * values)
1303 char *str;
1304 WOptionEnumeration *v;
1305 char buffer[TOTAL_VALUES_LENGTH];
1307 if (WMIsPLString(val) && (str = WMGetFromPLString(val))) {
1308 for (v = values; v->string != NULL; v++) {
1309 if (strcasecmp(v->string, str) == 0)
1310 return v->value;
1314 buffer[0] = 0;
1315 for (v = values; v->string != NULL; v++) {
1316 if (!v->is_alias) {
1317 if (buffer[0] != 0)
1318 strcat(buffer, ", ");
1319 snprintf(buffer+strlen(buffer),
1320 sizeof(buffer)-strlen(buffer)-1, "\"%s\"", v->string);
1323 wwarning(_("wrong option value for key \"%s\"; got \"%s\", should be one of %s."),
1324 WMGetFromPLString(key),
1325 WMIsPLString(val) ? WMGetFromPLString(val) : "(unknown)",
1326 buffer);
1328 if (def) {
1329 return string2index(key, val, NULL, values);
1332 return -1;
1336 * value - is the value in the defaults DB
1337 * addr - is the address to store the data
1338 * ret - is the address to store a pointer to a temporary buffer. ret
1339 * must not be freed and is used by the set functions
1341 static int getBool(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1343 static char data;
1344 const char *val;
1345 int second_pass = 0;
1347 /* Parameter not used, but tell the compiler that it is ok */
1348 (void) scr;
1350 GET_STRING_OR_DEFAULT("Boolean", val);
1352 again:
1353 if ((val[1] == '\0' && (val[0] == 'y' || val[0] == 'Y'))
1354 || strcasecmp(val, "YES") == 0) {
1356 data = 1;
1357 } else if ((val[1] == '\0' && (val[0] == 'n' || val[0] == 'N'))
1358 || strcasecmp(val, "NO") == 0) {
1359 data = 0;
1360 } else {
1361 int i;
1362 if (sscanf(val, "%i", &i) == 1) {
1363 if (i != 0)
1364 data = 1;
1365 else
1366 data = 0;
1367 } else {
1368 wwarning(_("can't convert \"%s\" to boolean for key \"%s\""), val, entry->key);
1369 if (second_pass == 0) {
1370 val = WMGetFromPLString(entry->plvalue);
1371 second_pass = 1;
1372 wwarning(_("using default \"%s\" instead"), val);
1373 goto again;
1375 return False;
1379 if (ret)
1380 *ret = &data;
1381 if (addr)
1382 *(char *)addr = data;
1384 return True;
1387 static int getInt(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1389 static int data;
1390 const char *val;
1392 /* Parameter not used, but tell the compiler that it is ok */
1393 (void) scr;
1395 GET_STRING_OR_DEFAULT("Integer", val);
1397 if (sscanf(val, "%i", &data) != 1) {
1398 wwarning(_("can't convert \"%s\" to integer for key \"%s\""), val, entry->key);
1399 val = WMGetFromPLString(entry->plvalue);
1400 wwarning(_("using default \"%s\" instead"), val);
1401 if (sscanf(val, "%i", &data) != 1) {
1402 return False;
1406 if (ret)
1407 *ret = &data;
1408 if (addr)
1409 *(int *)addr = data;
1411 return True;
1414 static int getCoord(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1416 static WCoord data;
1417 char *val_x, *val_y;
1418 int nelem, changed = 0;
1419 WMPropList *elem_x, *elem_y;
1421 again:
1422 if (!WMIsPLArray(value)) {
1423 wwarning(_("Wrong option format for key \"%s\". Should be %s."), entry->key, "Coordinate");
1424 if (changed == 0) {
1425 value = entry->plvalue;
1426 changed = 1;
1427 wwarning(_("using default \"%s\" instead"), entry->default_value);
1428 goto again;
1430 return False;
1433 nelem = WMGetPropListItemCount(value);
1434 if (nelem != 2) {
1435 wwarning(_("Incorrect number of elements in array for key \"%s\"."), entry->key);
1436 if (changed == 0) {
1437 value = entry->plvalue;
1438 changed = 1;
1439 wwarning(_("using default \"%s\" instead"), entry->default_value);
1440 goto again;
1442 return False;
1445 elem_x = WMGetFromPLArray(value, 0);
1446 elem_y = WMGetFromPLArray(value, 1);
1448 if (!elem_x || !elem_y || !WMIsPLString(elem_x) || !WMIsPLString(elem_y)) {
1449 wwarning(_("Wrong value for key \"%s\". Should be Coordinate."), entry->key);
1450 if (changed == 0) {
1451 value = entry->plvalue;
1452 changed = 1;
1453 wwarning(_("using default \"%s\" instead"), entry->default_value);
1454 goto again;
1456 return False;
1459 val_x = WMGetFromPLString(elem_x);
1460 val_y = WMGetFromPLString(elem_y);
1462 if (sscanf(val_x, "%i", &data.x) != 1 || sscanf(val_y, "%i", &data.y) != 1) {
1463 wwarning(_("can't convert array to integers for \"%s\"."), entry->key);
1464 if (changed == 0) {
1465 value = entry->plvalue;
1466 changed = 1;
1467 wwarning(_("using default \"%s\" instead"), entry->default_value);
1468 goto again;
1470 return False;
1473 if (data.x < 0)
1474 data.x = 0;
1475 else if (data.x > scr->scr_width / 3)
1476 data.x = scr->scr_width / 3;
1477 if (data.y < 0)
1478 data.y = 0;
1479 else if (data.y > scr->scr_height / 3)
1480 data.y = scr->scr_height / 3;
1482 if (ret)
1483 *ret = &data;
1484 if (addr)
1485 *(WCoord *) addr = data;
1487 return True;
1490 static int getPropList(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1492 /* Parameter not used, but tell the compiler that it is ok */
1493 (void) scr;
1494 (void) entry;
1495 (void) addr;
1497 WMRetainPropList(value);
1499 *ret = value;
1501 return True;
1504 static int getPathList(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1506 static char *data;
1507 int i, count, len;
1508 char *ptr;
1509 WMPropList *d;
1510 int changed = 0;
1512 /* Parameter not used, but tell the compiler that it is ok */
1513 (void) scr;
1514 (void) ret;
1516 again:
1517 if (!WMIsPLArray(value)) {
1518 wwarning(_("Wrong option format for key \"%s\". Should be %s."), entry->key, "an array of paths");
1519 if (changed == 0) {
1520 value = entry->plvalue;
1521 changed = 1;
1522 wwarning(_("using default \"%s\" instead"), entry->default_value);
1523 goto again;
1525 return False;
1528 i = 0;
1529 count = WMGetPropListItemCount(value);
1530 if (count < 1) {
1531 if (changed == 0) {
1532 value = entry->plvalue;
1533 changed = 1;
1534 wwarning(_("using default \"%s\" instead"), entry->default_value);
1535 goto again;
1537 return False;
1540 len = 0;
1541 for (i = 0; i < count; i++) {
1542 d = WMGetFromPLArray(value, i);
1543 if (!d || !WMIsPLString(d)) {
1544 count = i;
1545 break;
1547 len += strlen(WMGetFromPLString(d)) + 1;
1550 ptr = data = wmalloc(len + 1);
1552 for (i = 0; i < count; i++) {
1553 d = WMGetFromPLArray(value, i);
1554 if (!d || !WMIsPLString(d)) {
1555 break;
1557 strcpy(ptr, WMGetFromPLString(d));
1558 ptr += strlen(WMGetFromPLString(d));
1559 *ptr = ':';
1560 ptr++;
1562 ptr--;
1563 *(ptr--) = 0;
1565 if (*(char **)addr != NULL) {
1566 wfree(*(char **)addr);
1568 *(char **)addr = data;
1570 return True;
1573 static int getEnum(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1575 static signed char data;
1577 /* Parameter not used, but tell the compiler that it is ok */
1578 (void) scr;
1580 data = string2index(entry->plkey, value, entry->default_value, (WOptionEnumeration *) entry->extra_data);
1581 if (data < 0)
1582 return False;
1584 if (ret)
1585 *ret = &data;
1586 if (addr)
1587 *(signed char *)addr = data;
1589 return True;
1593 * (solid <color>)
1594 * (hgradient <color> <color>)
1595 * (vgradient <color> <color>)
1596 * (dgradient <color> <color>)
1597 * (mhgradient <color> <color> ...)
1598 * (mvgradient <color> <color> ...)
1599 * (mdgradient <color> <color> ...)
1600 * (igradient <color1> <color1> <thickness1> <color2> <color2> <thickness2>)
1601 * (tpixmap <file> <color>)
1602 * (spixmap <file> <color>)
1603 * (cpixmap <file> <color>)
1604 * (thgradient <file> <opaqueness> <color> <color>)
1605 * (tvgradient <file> <opaqueness> <color> <color>)
1606 * (tdgradient <file> <opaqueness> <color> <color>)
1607 * (function <lib> <function> ...)
1610 static WTexture *parse_texture(WScreen * scr, WMPropList * pl)
1612 WMPropList *elem;
1613 char *val;
1614 int nelem;
1615 WTexture *texture = NULL;
1617 nelem = WMGetPropListItemCount(pl);
1618 if (nelem < 1)
1619 return NULL;
1621 elem = WMGetFromPLArray(pl, 0);
1622 if (!elem || !WMIsPLString(elem))
1623 return NULL;
1624 val = WMGetFromPLString(elem);
1626 if (strcasecmp(val, "solid") == 0) {
1627 XColor color;
1629 if (nelem != 2)
1630 return NULL;
1632 /* get color */
1634 elem = WMGetFromPLArray(pl, 1);
1635 if (!elem || !WMIsPLString(elem))
1636 return NULL;
1637 val = WMGetFromPLString(elem);
1639 if (!XParseColor(dpy, scr->w_colormap, val, &color)) {
1640 wwarning(_("\"%s\" is not a valid color name"), val);
1641 return NULL;
1644 texture = (WTexture *) wTextureMakeSolid(scr, &color);
1645 } else if (strcasecmp(val, "dgradient") == 0
1646 || strcasecmp(val, "vgradient") == 0 || strcasecmp(val, "hgradient") == 0) {
1647 RColor color1, color2;
1648 XColor xcolor;
1649 int type;
1651 if (nelem != 3) {
1652 wwarning(_("bad number of arguments in gradient specification"));
1653 return NULL;
1656 if (val[0] == 'd' || val[0] == 'D')
1657 type = WTEX_DGRADIENT;
1658 else if (val[0] == 'h' || val[0] == 'H')
1659 type = WTEX_HGRADIENT;
1660 else
1661 type = WTEX_VGRADIENT;
1663 /* get from color */
1664 elem = WMGetFromPLArray(pl, 1);
1665 if (!elem || !WMIsPLString(elem))
1666 return NULL;
1667 val = WMGetFromPLString(elem);
1669 if (!XParseColor(dpy, scr->w_colormap, val, &xcolor)) {
1670 wwarning(_("\"%s\" is not a valid color name"), val);
1671 return NULL;
1673 color1.alpha = 255;
1674 color1.red = xcolor.red >> 8;
1675 color1.green = xcolor.green >> 8;
1676 color1.blue = xcolor.blue >> 8;
1678 /* get to color */
1679 elem = WMGetFromPLArray(pl, 2);
1680 if (!elem || !WMIsPLString(elem)) {
1681 return NULL;
1683 val = WMGetFromPLString(elem);
1685 if (!XParseColor(dpy, scr->w_colormap, val, &xcolor)) {
1686 wwarning(_("\"%s\" is not a valid color name"), val);
1687 return NULL;
1689 color2.alpha = 255;
1690 color2.red = xcolor.red >> 8;
1691 color2.green = xcolor.green >> 8;
1692 color2.blue = xcolor.blue >> 8;
1694 texture = (WTexture *) wTextureMakeGradient(scr, type, &color1, &color2);
1696 } else if (strcasecmp(val, "igradient") == 0) {
1697 RColor colors1[2], colors2[2];
1698 int th1, th2;
1699 XColor xcolor;
1700 int i;
1702 if (nelem != 7) {
1703 wwarning(_("bad number of arguments in gradient specification"));
1704 return NULL;
1707 /* get from color */
1708 for (i = 0; i < 2; i++) {
1709 elem = WMGetFromPLArray(pl, 1 + i);
1710 if (!elem || !WMIsPLString(elem))
1711 return NULL;
1712 val = WMGetFromPLString(elem);
1714 if (!XParseColor(dpy, scr->w_colormap, val, &xcolor)) {
1715 wwarning(_("\"%s\" is not a valid color name"), val);
1716 return NULL;
1718 colors1[i].alpha = 255;
1719 colors1[i].red = xcolor.red >> 8;
1720 colors1[i].green = xcolor.green >> 8;
1721 colors1[i].blue = xcolor.blue >> 8;
1723 elem = WMGetFromPLArray(pl, 3);
1724 if (!elem || !WMIsPLString(elem))
1725 return NULL;
1726 val = WMGetFromPLString(elem);
1727 th1 = atoi(val);
1729 /* get from color */
1730 for (i = 0; i < 2; i++) {
1731 elem = WMGetFromPLArray(pl, 4 + i);
1732 if (!elem || !WMIsPLString(elem))
1733 return NULL;
1734 val = WMGetFromPLString(elem);
1736 if (!XParseColor(dpy, scr->w_colormap, val, &xcolor)) {
1737 wwarning(_("\"%s\" is not a valid color name"), val);
1738 return NULL;
1740 colors2[i].alpha = 255;
1741 colors2[i].red = xcolor.red >> 8;
1742 colors2[i].green = xcolor.green >> 8;
1743 colors2[i].blue = xcolor.blue >> 8;
1745 elem = WMGetFromPLArray(pl, 6);
1746 if (!elem || !WMIsPLString(elem))
1747 return NULL;
1748 val = WMGetFromPLString(elem);
1749 th2 = atoi(val);
1751 texture = (WTexture *) wTextureMakeIGradient(scr, th1, colors1, th2, colors2);
1753 } else if (strcasecmp(val, "mhgradient") == 0
1754 || strcasecmp(val, "mvgradient") == 0 || strcasecmp(val, "mdgradient") == 0) {
1755 XColor color;
1756 RColor **colors;
1757 int i, count;
1758 int type;
1760 if (nelem < 3) {
1761 wwarning(_("too few arguments in multicolor gradient specification"));
1762 return NULL;
1765 if (val[1] == 'h' || val[1] == 'H')
1766 type = WTEX_MHGRADIENT;
1767 else if (val[1] == 'v' || val[1] == 'V')
1768 type = WTEX_MVGRADIENT;
1769 else
1770 type = WTEX_MDGRADIENT;
1772 count = nelem - 1;
1774 colors = wmalloc(sizeof(RColor *) * (count + 1));
1776 for (i = 0; i < count; i++) {
1777 elem = WMGetFromPLArray(pl, i + 1);
1778 if (!elem || !WMIsPLString(elem)) {
1779 for (--i; i >= 0; --i) {
1780 wfree(colors[i]);
1782 wfree(colors);
1783 return NULL;
1785 val = WMGetFromPLString(elem);
1787 if (!XParseColor(dpy, scr->w_colormap, val, &color)) {
1788 wwarning(_("\"%s\" is not a valid color name"), val);
1789 for (--i; i >= 0; --i) {
1790 wfree(colors[i]);
1792 wfree(colors);
1793 return NULL;
1794 } else {
1795 colors[i] = wmalloc(sizeof(RColor));
1796 colors[i]->red = color.red >> 8;
1797 colors[i]->green = color.green >> 8;
1798 colors[i]->blue = color.blue >> 8;
1801 colors[i] = NULL;
1803 texture = (WTexture *) wTextureMakeMGradient(scr, type, colors);
1804 } else if (strcasecmp(val, "spixmap") == 0 ||
1805 strcasecmp(val, "cpixmap") == 0 || strcasecmp(val, "tpixmap") == 0) {
1806 XColor color;
1807 int type;
1809 if (nelem != 3)
1810 return NULL;
1812 if (val[0] == 's' || val[0] == 'S')
1813 type = WTP_SCALE;
1814 else if (val[0] == 'c' || val[0] == 'C')
1815 type = WTP_CENTER;
1816 else
1817 type = WTP_TILE;
1819 /* get color */
1820 elem = WMGetFromPLArray(pl, 2);
1821 if (!elem || !WMIsPLString(elem)) {
1822 return NULL;
1824 val = WMGetFromPLString(elem);
1826 if (!XParseColor(dpy, scr->w_colormap, val, &color)) {
1827 wwarning(_("\"%s\" is not a valid color name"), val);
1828 return NULL;
1831 /* file name */
1832 elem = WMGetFromPLArray(pl, 1);
1833 if (!elem || !WMIsPLString(elem))
1834 return NULL;
1835 val = WMGetFromPLString(elem);
1837 texture = (WTexture *) wTextureMakePixmap(scr, type, val, &color);
1838 } else if (strcasecmp(val, "thgradient") == 0
1839 || strcasecmp(val, "tvgradient") == 0 || strcasecmp(val, "tdgradient") == 0) {
1840 RColor color1, color2;
1841 XColor xcolor;
1842 int opacity;
1843 int style;
1845 if (val[1] == 'h' || val[1] == 'H')
1846 style = WTEX_THGRADIENT;
1847 else if (val[1] == 'v' || val[1] == 'V')
1848 style = WTEX_TVGRADIENT;
1849 else
1850 style = WTEX_TDGRADIENT;
1852 if (nelem != 5) {
1853 wwarning(_("bad number of arguments in textured gradient specification"));
1854 return NULL;
1857 /* get from color */
1858 elem = WMGetFromPLArray(pl, 3);
1859 if (!elem || !WMIsPLString(elem))
1860 return NULL;
1861 val = WMGetFromPLString(elem);
1863 if (!XParseColor(dpy, scr->w_colormap, val, &xcolor)) {
1864 wwarning(_("\"%s\" is not a valid color name"), val);
1865 return NULL;
1867 color1.alpha = 255;
1868 color1.red = xcolor.red >> 8;
1869 color1.green = xcolor.green >> 8;
1870 color1.blue = xcolor.blue >> 8;
1872 /* get to color */
1873 elem = WMGetFromPLArray(pl, 4);
1874 if (!elem || !WMIsPLString(elem)) {
1875 return NULL;
1877 val = WMGetFromPLString(elem);
1879 if (!XParseColor(dpy, scr->w_colormap, val, &xcolor)) {
1880 wwarning(_("\"%s\" is not a valid color name"), val);
1881 return NULL;
1883 color2.alpha = 255;
1884 color2.red = xcolor.red >> 8;
1885 color2.green = xcolor.green >> 8;
1886 color2.blue = xcolor.blue >> 8;
1888 /* get opacity */
1889 elem = WMGetFromPLArray(pl, 2);
1890 if (!elem || !WMIsPLString(elem))
1891 opacity = 128;
1892 else
1893 val = WMGetFromPLString(elem);
1895 if (!val || (opacity = atoi(val)) < 0 || opacity > 255) {
1896 wwarning(_("bad opacity value for tgradient texture \"%s\". Should be [0..255]"), val);
1897 opacity = 128;
1900 /* get file name */
1901 elem = WMGetFromPLArray(pl, 1);
1902 if (!elem || !WMIsPLString(elem))
1903 return NULL;
1904 val = WMGetFromPLString(elem);
1906 texture = (WTexture *) wTextureMakeTGradient(scr, style, &color1, &color2, val, opacity);
1907 } else if (strcasecmp(val, "function") == 0) {
1908 /* Leave this in to handle the unlikely case of
1909 * someone actually having function textures configured */
1910 wwarning("function texture support has been removed");
1911 return NULL;
1912 } else {
1913 wwarning(_("invalid texture type %s"), val);
1914 return NULL;
1916 return texture;
1919 static int getTexture(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1921 static WTexture *texture;
1922 int changed = 0;
1924 again:
1925 if (!WMIsPLArray(value)) {
1926 wwarning(_("Wrong option format for key \"%s\". Should be %s."), entry->key, "Texture");
1927 if (changed == 0) {
1928 value = entry->plvalue;
1929 changed = 1;
1930 wwarning(_("using default \"%s\" instead"), entry->default_value);
1931 goto again;
1933 return False;
1936 if (strcmp(entry->key, "WidgetColor") == 0 && !changed) {
1937 WMPropList *pl;
1939 pl = WMGetFromPLArray(value, 0);
1940 if (!pl || !WMIsPLString(pl) || !WMGetFromPLString(pl)
1941 || strcasecmp(WMGetFromPLString(pl), "solid") != 0) {
1942 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1943 entry->key, "Solid Texture");
1945 value = entry->plvalue;
1946 changed = 1;
1947 wwarning(_("using default \"%s\" instead"), entry->default_value);
1948 goto again;
1952 texture = parse_texture(scr, value);
1954 if (!texture) {
1955 wwarning(_("Error in texture specification for key \"%s\""), entry->key);
1956 if (changed == 0) {
1957 value = entry->plvalue;
1958 changed = 1;
1959 wwarning(_("using default \"%s\" instead"), entry->default_value);
1960 goto again;
1962 return False;
1965 if (ret)
1966 *ret = &texture;
1968 if (addr)
1969 *(WTexture **) addr = texture;
1971 return True;
1974 static int getWSBackground(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1976 WMPropList *elem;
1977 int changed = 0;
1978 char *val;
1979 int nelem;
1981 /* Parameter not used, but tell the compiler that it is ok */
1982 (void) scr;
1983 (void) addr;
1985 again:
1986 if (!WMIsPLArray(value)) {
1987 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1988 "WorkspaceBack", "Texture or None");
1989 if (changed == 0) {
1990 value = entry->plvalue;
1991 changed = 1;
1992 wwarning(_("using default \"%s\" instead"), entry->default_value);
1993 goto again;
1995 return False;
1998 /* only do basic error checking and verify for None texture */
2000 nelem = WMGetPropListItemCount(value);
2001 if (nelem > 0) {
2002 elem = WMGetFromPLArray(value, 0);
2003 if (!elem || !WMIsPLString(elem)) {
2004 wwarning(_("Wrong type for workspace background. Should be a texture type."));
2005 if (changed == 0) {
2006 value = entry->plvalue;
2007 changed = 1;
2008 wwarning(_("using default \"%s\" instead"), entry->default_value);
2009 goto again;
2011 return False;
2013 val = WMGetFromPLString(elem);
2015 if (strcasecmp(val, "None") == 0)
2016 return True;
2018 *ret = WMRetainPropList(value);
2020 return True;
2023 static int
2024 getWSSpecificBackground(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
2026 WMPropList *elem;
2027 int nelem;
2028 int changed = 0;
2030 /* Parameter not used, but tell the compiler that it is ok */
2031 (void) scr;
2032 (void) addr;
2034 again:
2035 if (!WMIsPLArray(value)) {
2036 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
2037 "WorkspaceSpecificBack", "an array of textures");
2038 if (changed == 0) {
2039 value = entry->plvalue;
2040 changed = 1;
2041 wwarning(_("using default \"%s\" instead"), entry->default_value);
2042 goto again;
2044 return False;
2047 /* only do basic error checking and verify for None texture */
2049 nelem = WMGetPropListItemCount(value);
2050 if (nelem > 0) {
2051 while (nelem--) {
2052 elem = WMGetFromPLArray(value, nelem);
2053 if (!elem || !WMIsPLArray(elem)) {
2054 wwarning(_("Wrong type for background of workspace %i. Should be a texture."),
2055 nelem);
2060 *ret = WMRetainPropList(value);
2062 #ifdef notworking
2064 * Kluge to force wmsetbg helper to set the default background.
2065 * If the WorkspaceSpecificBack is changed once wmaker has started,
2066 * the WorkspaceBack won't be sent to the helper, unless the user
2067 * changes it's value too. So, we must force this by removing the
2068 * value from the defaults DB.
2070 if (!scr->flags.backimage_helper_launched && !scr->flags.startup) {
2071 WMPropList *key = WMCreatePLString("WorkspaceBack");
2073 WMRemoveFromPLDictionary(w_global.domain.wmaker->dictionary, key);
2075 WMReleasePropList(key);
2077 #endif
2078 return True;
2081 static int getFont(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
2083 static WMFont *font;
2084 const char *val;
2086 (void) addr;
2088 GET_STRING_OR_DEFAULT("Font", val);
2090 font = WMCreateFont(scr->wmscreen, val);
2091 if (!font)
2092 font = WMCreateFont(scr->wmscreen, "fixed");
2094 if (!font) {
2095 wfatal(_("could not load any usable font!!!"));
2096 exit(1);
2099 if (ret)
2100 *ret = font;
2102 /* can't assign font value outside update function */
2103 wassertrv(addr == NULL, True);
2105 return True;
2108 static int getColor(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
2110 static XColor color;
2111 const char *val;
2112 int second_pass = 0;
2114 (void) addr;
2116 GET_STRING_OR_DEFAULT("Color", val);
2118 again:
2119 if (!wGetColor(scr, val, &color)) {
2120 wwarning(_("could not get color for key \"%s\""), entry->key);
2121 if (second_pass == 0) {
2122 val = WMGetFromPLString(entry->plvalue);
2123 second_pass = 1;
2124 wwarning(_("using default \"%s\" instead"), val);
2125 goto again;
2127 return False;
2130 if (ret)
2131 *ret = &color;
2133 assert(addr == NULL);
2135 if (addr)
2136 *(unsigned long*)addr = pixel;
2139 return True;
2142 static int getKeybind(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
2144 static WShortKey shortcut;
2145 KeySym ksym;
2146 const char *val;
2147 char *k;
2148 char buf[MAX_SHORTCUT_LENGTH], *b;
2150 /* Parameter not used, but tell the compiler that it is ok */
2151 (void) scr;
2152 (void) addr;
2154 GET_STRING_OR_DEFAULT("Key spec", val);
2156 if (!val || strcasecmp(val, "NONE") == 0) {
2157 shortcut.keycode = 0;
2158 shortcut.modifier = 0;
2159 if (ret)
2160 *ret = &shortcut;
2161 return True;
2164 wstrlcpy(buf, val, MAX_SHORTCUT_LENGTH);
2166 b = (char *)buf;
2168 /* get modifiers */
2169 shortcut.modifier = 0;
2170 while ((k = strchr(b, '+')) != NULL) {
2171 int mod;
2173 *k = 0;
2174 mod = wXModifierFromKey(b);
2175 if (mod < 0) {
2176 wwarning(_("%s: invalid key modifier \"%s\""), entry->key, b);
2177 return False;
2179 shortcut.modifier |= mod;
2181 b = k + 1;
2184 /* get key */
2185 ksym = XStringToKeysym(b);
2187 if (ksym == NoSymbol) {
2188 wwarning(_("%s:invalid kbd shortcut specification \"%s\""), entry->key, val);
2189 return False;
2192 shortcut.keycode = XKeysymToKeycode(dpy, ksym);
2193 if (shortcut.keycode == 0) {
2194 wwarning(_("%s:invalid key in shortcut \"%s\""), entry->key, val);
2195 return False;
2198 if (ret)
2199 *ret = &shortcut;
2201 return True;
2204 static int getModMask(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
2206 static int mask;
2207 const char *str;
2209 /* Parameter not used, but tell the compiler that it is ok */
2210 (void) scr;
2212 GET_STRING_OR_DEFAULT("Modifier Key", str);
2214 if (!str)
2215 return False;
2217 mask = wXModifierFromKey(str);
2218 if (mask < 0) {
2219 wwarning(_("%s: modifier key %s is not valid"), entry->key, str);
2220 mask = 0;
2221 return False;
2224 if (addr)
2225 *(int *)addr = mask;
2227 if (ret)
2228 *ret = &mask;
2230 return True;
2233 # include <X11/cursorfont.h>
2234 typedef struct {
2235 const char *name;
2236 int id;
2237 } WCursorLookup;
2239 #define CURSOR_ID_NONE (XC_num_glyphs)
2241 static const WCursorLookup cursor_table[] = {
2242 {"X_cursor", XC_X_cursor},
2243 {"arrow", XC_arrow},
2244 {"based_arrow_down", XC_based_arrow_down},
2245 {"based_arrow_up", XC_based_arrow_up},
2246 {"boat", XC_boat},
2247 {"bogosity", XC_bogosity},
2248 {"bottom_left_corner", XC_bottom_left_corner},
2249 {"bottom_right_corner", XC_bottom_right_corner},
2250 {"bottom_side", XC_bottom_side},
2251 {"bottom_tee", XC_bottom_tee},
2252 {"box_spiral", XC_box_spiral},
2253 {"center_ptr", XC_center_ptr},
2254 {"circle", XC_circle},
2255 {"clock", XC_clock},
2256 {"coffee_mug", XC_coffee_mug},
2257 {"cross", XC_cross},
2258 {"cross_reverse", XC_cross_reverse},
2259 {"crosshair", XC_crosshair},
2260 {"diamond_cross", XC_diamond_cross},
2261 {"dot", XC_dot},
2262 {"dotbox", XC_dotbox},
2263 {"double_arrow", XC_double_arrow},
2264 {"draft_large", XC_draft_large},
2265 {"draft_small", XC_draft_small},
2266 {"draped_box", XC_draped_box},
2267 {"exchange", XC_exchange},
2268 {"fleur", XC_fleur},
2269 {"gobbler", XC_gobbler},
2270 {"gumby", XC_gumby},
2271 {"hand1", XC_hand1},
2272 {"hand2", XC_hand2},
2273 {"heart", XC_heart},
2274 {"icon", XC_icon},
2275 {"iron_cross", XC_iron_cross},
2276 {"left_ptr", XC_left_ptr},
2277 {"left_side", XC_left_side},
2278 {"left_tee", XC_left_tee},
2279 {"leftbutton", XC_leftbutton},
2280 {"ll_angle", XC_ll_angle},
2281 {"lr_angle", XC_lr_angle},
2282 {"man", XC_man},
2283 {"middlebutton", XC_middlebutton},
2284 {"mouse", XC_mouse},
2285 {"pencil", XC_pencil},
2286 {"pirate", XC_pirate},
2287 {"plus", XC_plus},
2288 {"question_arrow", XC_question_arrow},
2289 {"right_ptr", XC_right_ptr},
2290 {"right_side", XC_right_side},
2291 {"right_tee", XC_right_tee},
2292 {"rightbutton", XC_rightbutton},
2293 {"rtl_logo", XC_rtl_logo},
2294 {"sailboat", XC_sailboat},
2295 {"sb_down_arrow", XC_sb_down_arrow},
2296 {"sb_h_double_arrow", XC_sb_h_double_arrow},
2297 {"sb_left_arrow", XC_sb_left_arrow},
2298 {"sb_right_arrow", XC_sb_right_arrow},
2299 {"sb_up_arrow", XC_sb_up_arrow},
2300 {"sb_v_double_arrow", XC_sb_v_double_arrow},
2301 {"shuttle", XC_shuttle},
2302 {"sizing", XC_sizing},
2303 {"spider", XC_spider},
2304 {"spraycan", XC_spraycan},
2305 {"star", XC_star},
2306 {"target", XC_target},
2307 {"tcross", XC_tcross},
2308 {"top_left_arrow", XC_top_left_arrow},
2309 {"top_left_corner", XC_top_left_corner},
2310 {"top_right_corner", XC_top_right_corner},
2311 {"top_side", XC_top_side},
2312 {"top_tee", XC_top_tee},
2313 {"trek", XC_trek},
2314 {"ul_angle", XC_ul_angle},
2315 {"umbrella", XC_umbrella},
2316 {"ur_angle", XC_ur_angle},
2317 {"watch", XC_watch},
2318 {"xterm", XC_xterm},
2319 {NULL, CURSOR_ID_NONE}
2322 static void check_bitmap_status(int status, const char *filename, Pixmap bitmap)
2324 switch (status) {
2325 case BitmapOpenFailed:
2326 wwarning(_("failed to open bitmap file \"%s\""), filename);
2327 break;
2328 case BitmapFileInvalid:
2329 wwarning(_("\"%s\" is not a valid bitmap file"), filename);
2330 break;
2331 case BitmapNoMemory:
2332 wwarning(_("out of memory reading bitmap file \"%s\""), filename);
2333 break;
2334 case BitmapSuccess:
2335 XFreePixmap(dpy, bitmap);
2336 break;
2341 * (none)
2342 * (builtin, <cursor_name>)
2343 * (bitmap, <cursor_bitmap>, <cursor_mask>)
2345 static int parse_cursor(WScreen * scr, WMPropList * pl, Cursor * cursor)
2347 WMPropList *elem;
2348 char *val;
2349 int nelem;
2350 int status = 0;
2352 nelem = WMGetPropListItemCount(pl);
2353 if (nelem < 1) {
2354 return (status);
2356 elem = WMGetFromPLArray(pl, 0);
2357 if (!elem || !WMIsPLString(elem)) {
2358 return (status);
2360 val = WMGetFromPLString(elem);
2362 if (strcasecmp(val, "none") == 0) {
2363 status = 1;
2364 *cursor = None;
2365 } else if (strcasecmp(val, "builtin") == 0) {
2366 int i;
2367 int cursor_id = CURSOR_ID_NONE;
2369 if (nelem != 2) {
2370 wwarning(_("bad number of arguments in cursor specification"));
2371 return (status);
2373 elem = WMGetFromPLArray(pl, 1);
2374 if (!elem || !WMIsPLString(elem)) {
2375 return (status);
2377 val = WMGetFromPLString(elem);
2379 for (i = 0; cursor_table[i].name != NULL; i++) {
2380 if (strcasecmp(val, cursor_table[i].name) == 0) {
2381 cursor_id = cursor_table[i].id;
2382 break;
2385 if (CURSOR_ID_NONE == cursor_id) {
2386 wwarning(_("unknown builtin cursor name \"%s\""), val);
2387 } else {
2388 *cursor = XCreateFontCursor(dpy, cursor_id);
2389 status = 1;
2391 } else if (strcasecmp(val, "bitmap") == 0) {
2392 char *bitmap_name;
2393 char *mask_name;
2394 int bitmap_status;
2395 int mask_status;
2396 Pixmap bitmap;
2397 Pixmap mask;
2398 unsigned int w, h;
2399 int x, y;
2400 XColor fg, bg;
2402 if (nelem != 3) {
2403 wwarning(_("bad number of arguments in cursor specification"));
2404 return (status);
2406 elem = WMGetFromPLArray(pl, 1);
2407 if (!elem || !WMIsPLString(elem)) {
2408 return (status);
2410 val = WMGetFromPLString(elem);
2411 bitmap_name = FindImage(wPreferences.pixmap_path, val);
2412 if (!bitmap_name) {
2413 wwarning(_("could not find cursor bitmap file \"%s\""), val);
2414 return (status);
2416 elem = WMGetFromPLArray(pl, 2);
2417 if (!elem || !WMIsPLString(elem)) {
2418 wfree(bitmap_name);
2419 return (status);
2421 val = WMGetFromPLString(elem);
2422 mask_name = FindImage(wPreferences.pixmap_path, val);
2423 if (!mask_name) {
2424 wfree(bitmap_name);
2425 wwarning(_("could not find cursor bitmap file \"%s\""), val);
2426 return (status);
2428 mask_status = XReadBitmapFile(dpy, scr->w_win, mask_name, &w, &h, &mask, &x, &y);
2429 bitmap_status = XReadBitmapFile(dpy, scr->w_win, bitmap_name, &w, &h, &bitmap, &x, &y);
2430 if ((BitmapSuccess == bitmap_status) && (BitmapSuccess == mask_status)) {
2431 fg.pixel = scr->black_pixel;
2432 bg.pixel = scr->white_pixel;
2433 XQueryColor(dpy, scr->w_colormap, &fg);
2434 XQueryColor(dpy, scr->w_colormap, &bg);
2435 *cursor = XCreatePixmapCursor(dpy, bitmap, mask, &fg, &bg, x, y);
2436 status = 1;
2438 check_bitmap_status(bitmap_status, bitmap_name, bitmap);
2439 check_bitmap_status(mask_status, mask_name, mask);
2440 wfree(bitmap_name);
2441 wfree(mask_name);
2443 return (status);
2446 static int getCursor(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
2448 static Cursor cursor;
2449 int status;
2450 int changed = 0;
2452 again:
2453 if (!WMIsPLArray(value)) {
2454 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
2455 entry->key, "cursor specification");
2456 if (!changed) {
2457 value = entry->plvalue;
2458 changed = 1;
2459 wwarning(_("using default \"%s\" instead"), entry->default_value);
2460 goto again;
2462 return (False);
2464 status = parse_cursor(scr, value, &cursor);
2465 if (!status) {
2466 wwarning(_("Error in cursor specification for key \"%s\""), entry->key);
2467 if (!changed) {
2468 value = entry->plvalue;
2469 changed = 1;
2470 wwarning(_("using default \"%s\" instead"), entry->default_value);
2471 goto again;
2473 return (False);
2475 if (ret) {
2476 *ret = &cursor;
2478 if (addr) {
2479 *(Cursor *) addr = cursor;
2481 return (True);
2484 #undef CURSOR_ID_NONE
2486 /* ---------------- value setting functions --------------- */
2487 static int setJustify(WScreen * scr, WDefaultEntry * entry, void *tdata, void *extra_data)
2489 /* Parameter not used, but tell the compiler that it is ok */
2490 (void) scr;
2491 (void) entry;
2492 (void) tdata;
2493 (void) extra_data;
2495 return REFRESH_WINDOW_TITLE_COLOR;
2498 static int setClearance(WScreen * scr, WDefaultEntry * entry, void *bar, void *foo)
2500 /* Parameter not used, but tell the compiler that it is ok */
2501 (void) scr;
2502 (void) entry;
2503 (void) bar;
2504 (void) foo;
2506 return REFRESH_WINDOW_FONT | REFRESH_BUTTON_IMAGES | REFRESH_MENU_TITLE_FONT | REFRESH_MENU_FONT;
2509 static int setIfDockPresent(WScreen * scr, WDefaultEntry * entry, void *tdata, void *extra_data)
2511 char *flag = tdata;
2512 long which = (long) extra_data;
2514 /* Parameter not used, but tell the compiler that it is ok */
2515 (void) scr;
2516 (void) entry;
2518 switch (which) {
2519 case WM_DOCK:
2520 wPreferences.flags.nodock = wPreferences.flags.nodock || *flag;
2521 // Drawers require the dock
2522 wPreferences.flags.nodrawer = wPreferences.flags.nodrawer || wPreferences.flags.nodock;
2523 break;
2524 case WM_CLIP:
2525 wPreferences.flags.noclip = wPreferences.flags.noclip || *flag;
2526 break;
2527 case WM_DRAWER:
2528 wPreferences.flags.nodrawer = wPreferences.flags.nodrawer || *flag;
2529 break;
2530 default:
2531 break;
2533 return 0;
2536 static int setClipMergedInDock(WScreen *scr, WDefaultEntry *entry, void *tdata, void *foo)
2538 char *flag = tdata;
2540 /* Parameter not used, but tell the compiler that it is ok */
2541 (void) scr;
2542 (void) entry;
2543 (void) foo;
2545 wPreferences.flags.clip_merged_in_dock = *flag;
2546 wPreferences.flags.noclip = wPreferences.flags.noclip || *flag;
2547 return 0;
2550 static int setWrapAppiconsInDock(WScreen *scr, WDefaultEntry *entry, void *tdata, void *foo)
2552 char *flag = tdata;
2554 /* Parameter not used, but tell the compiler that it is ok */
2555 (void) scr;
2556 (void) entry;
2557 (void) foo;
2559 wPreferences.flags.wrap_appicons_in_dock = *flag;
2560 return 0;
2563 static int setStickyIcons(WScreen * scr, WDefaultEntry * entry, void *bar, void *foo)
2565 /* Parameter not used, but tell the compiler that it is ok */
2566 (void) entry;
2567 (void) bar;
2568 (void) foo;
2570 if (scr->workspaces) {
2571 wWorkspaceForceChange(scr, scr->current_workspace);
2572 wArrangeIcons(scr, False);
2574 return 0;
2577 static int setIconTile(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2579 Pixmap pixmap;
2580 RImage *img;
2581 WTexture ** texture = tdata;
2582 int reset = 0;
2584 /* Parameter not used, but tell the compiler that it is ok */
2585 (void) foo;
2587 img = wTextureRenderImage(*texture, wPreferences.icon_size,
2588 wPreferences.icon_size, ((*texture)->any.type & WREL_BORDER_MASK)
2589 ? WREL_ICON : WREL_FLAT);
2590 if (!img) {
2591 wwarning(_("could not render texture for icon background"));
2592 if (!entry->addr)
2593 wTextureDestroy(scr, *texture);
2594 return 0;
2596 RConvertImage(scr->rcontext, img, &pixmap);
2598 if (scr->icon_tile) {
2599 reset = 1;
2600 RReleaseImage(scr->icon_tile);
2601 XFreePixmap(dpy, scr->icon_tile_pixmap);
2604 scr->icon_tile = img;
2606 /* put the icon in the noticeboard hint */
2607 PropSetIconTileHint(scr, img);
2609 if (!wPreferences.flags.noclip || wPreferences.flags.clip_merged_in_dock) {
2610 if (scr->clip_tile) {
2611 RReleaseImage(scr->clip_tile);
2613 scr->clip_tile = wClipMakeTile(img);
2616 if (!wPreferences.flags.nodrawer) {
2617 if (scr->drawer_tile) {
2618 RReleaseImage(scr->drawer_tile);
2620 scr->drawer_tile = wDrawerMakeTile(scr, img);
2623 scr->icon_tile_pixmap = pixmap;
2625 if (scr->def_icon_rimage) {
2626 RReleaseImage(scr->def_icon_rimage);
2627 scr->def_icon_rimage = NULL;
2630 if (scr->icon_back_texture)
2631 wTextureDestroy(scr, (WTexture *) scr->icon_back_texture);
2633 scr->icon_back_texture = wTextureMakeSolid(scr, &((*texture)->any.color));
2635 /* Free the texture as nobody else will use it, nor refer to it. */
2636 if (!entry->addr)
2637 wTextureDestroy(scr, *texture);
2639 return (reset ? REFRESH_ICON_TILE : 0);
2642 static int setWinTitleFont(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2644 WMFont *font = tdata;
2646 /* Parameter not used, but tell the compiler that it is ok */
2647 (void) entry;
2648 (void) foo;
2650 if (scr->title_font) {
2651 WMReleaseFont(scr->title_font);
2653 scr->title_font = font;
2655 return REFRESH_WINDOW_FONT | REFRESH_BUTTON_IMAGES;
2658 static int setMenuTitleFont(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2660 WMFont *font = tdata;
2662 /* Parameter not used, but tell the compiler that it is ok */
2663 (void) entry;
2664 (void) foo;
2666 if (scr->menu_title_font) {
2667 WMReleaseFont(scr->menu_title_font);
2670 scr->menu_title_font = font;
2672 return REFRESH_MENU_TITLE_FONT;
2675 static int setMenuTextFont(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2677 WMFont *font = tdata;
2679 /* Parameter not used, but tell the compiler that it is ok */
2680 (void) entry;
2681 (void) foo;
2683 if (scr->menu_entry_font) {
2684 WMReleaseFont(scr->menu_entry_font);
2686 scr->menu_entry_font = font;
2688 return REFRESH_MENU_FONT;
2691 static int setIconTitleFont(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2693 WMFont *font = tdata;
2695 /* Parameter not used, but tell the compiler that it is ok */
2696 (void) entry;
2697 (void) foo;
2699 if (scr->icon_title_font) {
2700 WMReleaseFont(scr->icon_title_font);
2703 scr->icon_title_font = font;
2705 return REFRESH_ICON_FONT;
2708 static int setClipTitleFont(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2710 WMFont *font = tdata;
2712 /* Parameter not used, but tell the compiler that it is ok */
2713 (void) entry;
2714 (void) foo;
2716 if (scr->clip_title_font) {
2717 WMReleaseFont(scr->clip_title_font);
2720 scr->clip_title_font = font;
2722 return REFRESH_ICON_FONT;
2725 static int setLargeDisplayFont(WScreen *scr, WDefaultEntry *entry, void *tdata, void *foo)
2727 WMFont *font = tdata;
2729 /* Parameter not used, but tell the compiler that it is ok */
2730 (void) scr;
2731 (void) entry;
2732 (void) foo;
2734 if (scr->workspace_name_font)
2735 WMReleaseFont(scr->workspace_name_font);
2737 scr->workspace_name_font = font;
2739 return 0;
2742 static int setHightlight(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2744 XColor *color = tdata;
2746 /* Parameter not used, but tell the compiler that it is ok */
2747 (void) entry;
2748 (void) foo;
2750 if (scr->select_color)
2751 WMReleaseColor(scr->select_color);
2753 scr->select_color = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2755 wFreeColor(scr, color->pixel);
2757 return REFRESH_MENU_COLOR;
2760 static int setHightlightText(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2762 XColor *color = tdata;
2764 /* Parameter not used, but tell the compiler that it is ok */
2765 (void) entry;
2766 (void) foo;
2768 if (scr->select_text_color)
2769 WMReleaseColor(scr->select_text_color);
2771 scr->select_text_color = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2773 wFreeColor(scr, color->pixel);
2775 return REFRESH_MENU_COLOR;
2778 static int setClipTitleColor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *extra_data)
2780 XColor *color = tdata;
2781 long widx = (long) extra_data;
2783 /* Parameter not used, but tell the compiler that it is ok */
2784 (void) entry;
2786 if (scr->clip_title_color[widx])
2787 WMReleaseColor(scr->clip_title_color[widx]);
2789 scr->clip_title_color[widx] = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2790 wFreeColor(scr, color->pixel);
2792 return REFRESH_ICON_TITLE_COLOR;
2795 static int setWTitleColor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *extra_data)
2797 XColor *color = tdata;
2798 long widx = (long) extra_data;
2800 /* Parameter not used, but tell the compiler that it is ok */
2801 (void) entry;
2803 if (scr->window_title_color[widx])
2804 WMReleaseColor(scr->window_title_color[widx]);
2806 scr->window_title_color[widx] =
2807 WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2809 wFreeColor(scr, color->pixel);
2811 return REFRESH_WINDOW_TITLE_COLOR;
2814 static int setMenuTitleColor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *extra_data)
2816 XColor *color = tdata;
2818 /* Parameter not used, but tell the compiler that it is ok */
2819 (void) entry;
2820 (void) extra_data;
2822 if (scr->menu_title_color[0])
2823 WMReleaseColor(scr->menu_title_color[0]);
2825 scr->menu_title_color[0] = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2827 wFreeColor(scr, color->pixel);
2829 return REFRESH_MENU_TITLE_COLOR;
2832 static int setMenuTextColor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2834 XColor *color = tdata;
2836 /* Parameter not used, but tell the compiler that it is ok */
2837 (void) entry;
2838 (void) foo;
2840 if (scr->mtext_color)
2841 WMReleaseColor(scr->mtext_color);
2843 scr->mtext_color = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2845 if (WMColorPixel(scr->dtext_color) == WMColorPixel(scr->mtext_color)) {
2846 WMSetColorAlpha(scr->dtext_color, 0x7fff);
2847 } else {
2848 WMSetColorAlpha(scr->dtext_color, 0xffff);
2851 wFreeColor(scr, color->pixel);
2853 return REFRESH_MENU_COLOR;
2856 static int setMenuDisabledColor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2858 XColor *color = tdata;
2860 /* Parameter not used, but tell the compiler that it is ok */
2861 (void) entry;
2862 (void) foo;
2864 if (scr->dtext_color)
2865 WMReleaseColor(scr->dtext_color);
2867 scr->dtext_color = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2869 if (WMColorPixel(scr->dtext_color) == WMColorPixel(scr->mtext_color)) {
2870 WMSetColorAlpha(scr->dtext_color, 0x7fff);
2871 } else {
2872 WMSetColorAlpha(scr->dtext_color, 0xffff);
2875 wFreeColor(scr, color->pixel);
2877 return REFRESH_MENU_COLOR;
2880 static int setIconTitleColor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2882 XColor *color = tdata;
2884 /* Parameter not used, but tell the compiler that it is ok */
2885 (void) entry;
2886 (void) foo;
2888 if (scr->icon_title_color)
2889 WMReleaseColor(scr->icon_title_color);
2890 scr->icon_title_color = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2892 wFreeColor(scr, color->pixel);
2894 return REFRESH_ICON_TITLE_COLOR;
2897 static int setIconTitleBack(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2899 XColor *color = tdata;
2901 /* Parameter not used, but tell the compiler that it is ok */
2902 (void) entry;
2903 (void) foo;
2905 if (scr->icon_title_texture) {
2906 wTextureDestroy(scr, (WTexture *) scr->icon_title_texture);
2908 scr->icon_title_texture = wTextureMakeSolid(scr, color);
2910 return REFRESH_ICON_TITLE_BACK;
2913 static int setFrameBorderWidth(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2915 int *value = tdata;
2917 /* Parameter not used, but tell the compiler that it is ok */
2918 (void) entry;
2919 (void) foo;
2921 scr->frame_border_width = *value;
2923 return REFRESH_FRAME_BORDER;
2926 static int setFrameBorderColor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2928 XColor *color = tdata;
2930 /* Parameter not used, but tell the compiler that it is ok */
2931 (void) entry;
2932 (void) foo;
2934 if (scr->frame_border_color)
2935 WMReleaseColor(scr->frame_border_color);
2936 scr->frame_border_color = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2938 wFreeColor(scr, color->pixel);
2940 return REFRESH_FRAME_BORDER;
2943 static int setFrameFocusedBorderColor(WScreen *scr, WDefaultEntry *entry, void *tdata, void *foo)
2945 XColor *color = tdata;
2947 /* Parameter not used, but tell the compiler that it is ok */
2948 (void) entry;
2949 (void) foo;
2951 if (scr->frame_focused_border_color)
2952 WMReleaseColor(scr->frame_focused_border_color);
2953 scr->frame_focused_border_color = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2955 wFreeColor(scr, color->pixel);
2957 return REFRESH_FRAME_BORDER;
2960 static int setFrameSelectedBorderColor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2962 XColor *color = tdata;
2964 /* Parameter not used, but tell the compiler that it is ok */
2965 (void) entry;
2966 (void) foo;
2968 if (scr->frame_selected_border_color)
2969 WMReleaseColor(scr->frame_selected_border_color);
2970 scr->frame_selected_border_color = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2972 wFreeColor(scr, color->pixel);
2974 return REFRESH_FRAME_BORDER;
2977 static int setWorkspaceSpecificBack(WScreen * scr, WDefaultEntry * entry, void *tdata, void *bar)
2979 WMPropList *value = tdata;
2980 WMPropList *val;
2981 char *str;
2982 int i;
2984 /* Parameter not used, but tell the compiler that it is ok */
2985 (void) entry;
2986 (void) bar;
2988 if (scr->flags.backimage_helper_launched) {
2989 if (WMGetPropListItemCount(value) == 0) {
2990 SendHelperMessage(scr, 'C', 0, NULL);
2991 SendHelperMessage(scr, 'K', 0, NULL);
2993 WMReleasePropList(value);
2994 return 0;
2996 } else {
2997 if (WMGetPropListItemCount(value) == 0)
2998 return 0;
3000 if (!start_bg_helper(scr)) {
3001 WMReleasePropList(value);
3002 return 0;
3005 SendHelperMessage(scr, 'P', -1, wPreferences.pixmap_path);
3008 for (i = 0; i < WMGetPropListItemCount(value); i++) {
3009 val = WMGetFromPLArray(value, i);
3010 if (val && WMIsPLArray(val) && WMGetPropListItemCount(val) > 0) {
3011 str = WMGetPropListDescription(val, False);
3013 SendHelperMessage(scr, 'S', i + 1, str);
3015 wfree(str);
3016 } else {
3017 SendHelperMessage(scr, 'U', i + 1, NULL);
3020 sleep(1);
3022 WMReleasePropList(value);
3023 return 0;
3026 static int setWorkspaceBack(WScreen * scr, WDefaultEntry * entry, void *tdata, void *bar)
3028 WMPropList *value = tdata;
3030 /* Parameter not used, but tell the compiler that it is ok */
3031 (void) entry;
3032 (void) bar;
3034 if (scr->flags.backimage_helper_launched) {
3035 char *str;
3037 if (WMGetPropListItemCount(value) == 0) {
3038 SendHelperMessage(scr, 'U', 0, NULL);
3039 } else {
3040 /* set the default workspace background to this one */
3041 str = WMGetPropListDescription(value, False);
3042 if (str) {
3043 SendHelperMessage(scr, 'S', 0, str);
3044 wfree(str);
3045 SendHelperMessage(scr, 'C', scr->current_workspace + 1, NULL);
3046 } else {
3047 SendHelperMessage(scr, 'U', 0, NULL);
3050 } else if (WMGetPropListItemCount(value) > 0) {
3051 char *text;
3052 char *dither;
3053 int len;
3055 text = WMGetPropListDescription(value, False);
3056 len = strlen(text) + 40;
3057 dither = wPreferences.no_dithering ? "-m" : "-d";
3058 if (!strchr(text, '\'') && !strchr(text, '\\')) {
3059 char command[len];
3061 if (wPreferences.smooth_workspace_back)
3062 snprintf(command, len, "wmsetbg %s -S -p '%s' &", dither, text);
3063 else
3064 snprintf(command, len, "wmsetbg %s -p '%s' &", dither, text);
3065 ExecuteShellCommand(scr, command);
3066 } else
3067 wwarning(_("Invalid arguments for background \"%s\""), text);
3068 wfree(text);
3070 WMReleasePropList(value);
3072 return 0;
3075 static int setWidgetColor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
3077 WTexture **texture = tdata;
3079 /* Parameter not used, but tell the compiler that it is ok */
3080 (void) entry;
3081 (void) foo;
3083 if (scr->widget_texture) {
3084 wTextureDestroy(scr, (WTexture *) scr->widget_texture);
3086 scr->widget_texture = *(WTexSolid **) texture;
3088 return 0;
3091 static int setFTitleBack(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
3093 WTexture **texture = tdata;
3095 /* Parameter not used, but tell the compiler that it is ok */
3096 (void) entry;
3097 (void) foo;
3099 if (scr->window_title_texture[WS_FOCUSED]) {
3100 wTextureDestroy(scr, scr->window_title_texture[WS_FOCUSED]);
3102 scr->window_title_texture[WS_FOCUSED] = *texture;
3104 return REFRESH_WINDOW_TEXTURES;
3107 static int setPTitleBack(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
3109 WTexture **texture = tdata;
3111 /* Parameter not used, but tell the compiler that it is ok */
3112 (void) entry;
3113 (void) foo;
3115 if (scr->window_title_texture[WS_PFOCUSED]) {
3116 wTextureDestroy(scr, scr->window_title_texture[WS_PFOCUSED]);
3118 scr->window_title_texture[WS_PFOCUSED] = *texture;
3120 return REFRESH_WINDOW_TEXTURES;
3123 static int setUTitleBack(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
3125 WTexture **texture = tdata;
3127 /* Parameter not used, but tell the compiler that it is ok */
3128 (void) entry;
3129 (void) foo;
3131 if (scr->window_title_texture[WS_UNFOCUSED]) {
3132 wTextureDestroy(scr, scr->window_title_texture[WS_UNFOCUSED]);
3134 scr->window_title_texture[WS_UNFOCUSED] = *texture;
3136 return REFRESH_WINDOW_TEXTURES;
3139 static int setResizebarBack(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
3141 WTexture **texture = tdata;
3143 /* Parameter not used, but tell the compiler that it is ok */
3144 (void) entry;
3145 (void) foo;
3147 if (scr->resizebar_texture[0]) {
3148 wTextureDestroy(scr, scr->resizebar_texture[0]);
3150 scr->resizebar_texture[0] = *texture;
3152 return REFRESH_WINDOW_TEXTURES;
3155 static int setMenuTitleBack(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
3157 WTexture **texture = tdata;
3159 /* Parameter not used, but tell the compiler that it is ok */
3160 (void) entry;
3161 (void) foo;
3163 if (scr->menu_title_texture[0]) {
3164 wTextureDestroy(scr, scr->menu_title_texture[0]);
3166 scr->menu_title_texture[0] = *texture;
3168 return REFRESH_MENU_TITLE_TEXTURE;
3171 static int setMenuTextBack(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
3173 WTexture **texture = tdata;
3175 /* Parameter not used, but tell the compiler that it is ok */
3176 (void) entry;
3177 (void) foo;
3179 if (scr->menu_item_texture) {
3180 wTextureDestroy(scr, scr->menu_item_texture);
3181 wTextureDestroy(scr, (WTexture *) scr->menu_item_auxtexture);
3183 scr->menu_item_texture = *texture;
3185 scr->menu_item_auxtexture = wTextureMakeSolid(scr, &scr->menu_item_texture->any.color);
3187 return REFRESH_MENU_TEXTURE;
3190 static int setKeyGrab(WScreen * scr, WDefaultEntry * entry, void *tdata, void *extra_data)
3192 WShortKey *shortcut = tdata;
3193 WWindow *wwin;
3194 long widx = (long) extra_data;
3196 /* Parameter not used, but tell the compiler that it is ok */
3197 (void) entry;
3199 wKeyBindings[widx] = *shortcut;
3201 wwin = scr->focused_window;
3203 while (wwin != NULL) {
3204 XUngrabKey(dpy, AnyKey, AnyModifier, wwin->frame->core->window);
3206 if (!WFLAGP(wwin, no_bind_keys)) {
3207 wWindowSetKeyGrabs(wwin);
3209 wwin = wwin->prev;
3212 /* do we need to update window menus? */
3213 if (widx >= WKBD_WORKSPACE1 && widx <= WKBD_WORKSPACE10)
3214 return REFRESH_WORKSPACE_MENU;
3215 if (widx == WKBD_LASTWORKSPACE)
3216 return REFRESH_WORKSPACE_MENU;
3217 if (widx >= WKBD_MOVE_WORKSPACE1 && widx <= WKBD_MOVE_WORKSPACE10)
3218 return REFRESH_WORKSPACE_MENU;
3220 return 0;
3223 static int setIconPosition(WScreen * scr, WDefaultEntry * entry, void *bar, void *foo)
3225 /* Parameter not used, but tell the compiler that it is ok */
3226 (void) entry;
3227 (void) bar;
3228 (void) foo;
3230 wScreenUpdateUsableArea(scr);
3231 wArrangeIcons(scr, True);
3233 return 0;
3236 static int updateUsableArea(WScreen * scr, WDefaultEntry * entry, void *bar, void *foo)
3238 /* Parameter not used, but tell the compiler that it is ok */
3239 (void) entry;
3240 (void) bar;
3241 (void) foo;
3243 wScreenUpdateUsableArea(scr);
3245 return 0;
3248 static int setWorkspaceMapBackground(WScreen *scr, WDefaultEntry *entry, void *tdata, void *foo)
3250 WTexture **texture = tdata;
3252 /* Parameter not used, but tell the compiler that it is ok */
3253 (void) entry;
3254 (void) foo;
3256 if (wPreferences.wsmbackTexture)
3257 wTextureDestroy(scr, wPreferences.wsmbackTexture);
3259 wPreferences.wsmbackTexture = *texture;
3261 return REFRESH_WINDOW_TEXTURES;
3264 static int setMenuStyle(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
3266 /* Parameter not used, but tell the compiler that it is ok */
3267 (void) scr;
3268 (void) entry;
3269 (void) tdata;
3270 (void) foo;
3272 return REFRESH_MENU_TEXTURE;
3275 static RImage *chopOffImage(RImage * image, int x, int y, int w, int h)
3277 RImage *img = RCreateImage(w, h, image->format == RRGBAFormat);
3279 RCopyArea(img, image, x, y, w, h, 0, 0);
3281 return img;
3284 static int setSwPOptions(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
3286 WMPropList *array = tdata;
3287 char *path;
3288 RImage *bgimage;
3289 int cwidth, cheight;
3290 struct WPreferences *prefs = foo;
3292 if (!WMIsPLArray(array) || WMGetPropListItemCount(array) == 0) {
3293 if (prefs->swtileImage)
3294 RReleaseImage(prefs->swtileImage);
3295 prefs->swtileImage = NULL;
3297 WMReleasePropList(array);
3298 return 0;
3301 switch (WMGetPropListItemCount(array)) {
3302 case 4:
3303 if (!WMIsPLString(WMGetFromPLArray(array, 1))) {
3304 wwarning(_("Invalid arguments for option \"%s\""), entry->key);
3305 break;
3306 } else
3307 path = FindImage(wPreferences.pixmap_path, WMGetFromPLString(WMGetFromPLArray(array, 1)));
3309 if (!path) {
3310 wwarning(_("Could not find image \"%s\" for option \"%s\""),
3311 WMGetFromPLString(WMGetFromPLArray(array, 1)), entry->key);
3312 } else {
3313 bgimage = RLoadImage(scr->rcontext, path, 0);
3314 if (!bgimage) {
3315 wwarning(_("Could not load image \"%s\" for option \"%s\""), path, entry->key);
3316 wfree(path);
3317 } else {
3318 wfree(path);
3320 cwidth = atoi(WMGetFromPLString(WMGetFromPLArray(array, 2)));
3321 cheight = atoi(WMGetFromPLString(WMGetFromPLArray(array, 3)));
3323 if (cwidth <= 0 || cheight <= 0 ||
3324 cwidth >= bgimage->width - 2 || cheight >= bgimage->height - 2)
3325 wwarning(_("Invalid split sizes for switch panel back image."));
3326 else {
3327 int i;
3328 int swidth, theight;
3329 for (i = 0; i < 9; i++) {
3330 if (prefs->swbackImage[i])
3331 RReleaseImage(prefs->swbackImage[i]);
3332 prefs->swbackImage[i] = NULL;
3334 swidth = (bgimage->width - cwidth) / 2;
3335 theight = (bgimage->height - cheight) / 2;
3337 prefs->swbackImage[0] = chopOffImage(bgimage, 0, 0, swidth, theight);
3338 prefs->swbackImage[1] = chopOffImage(bgimage, swidth, 0, cwidth, theight);
3339 prefs->swbackImage[2] = chopOffImage(bgimage, swidth + cwidth, 0,
3340 swidth, theight);
3342 prefs->swbackImage[3] = chopOffImage(bgimage, 0, theight, swidth, cheight);
3343 prefs->swbackImage[4] = chopOffImage(bgimage, swidth, theight,
3344 cwidth, cheight);
3345 prefs->swbackImage[5] = chopOffImage(bgimage, swidth + cwidth, theight,
3346 swidth, cheight);
3348 prefs->swbackImage[6] = chopOffImage(bgimage, 0, theight + cheight,
3349 swidth, theight);
3350 prefs->swbackImage[7] = chopOffImage(bgimage, swidth, theight + cheight,
3351 cwidth, theight);
3352 prefs->swbackImage[8] =
3353 chopOffImage(bgimage, swidth + cwidth, theight + cheight, swidth,
3354 theight);
3356 // check if anything failed
3357 for (i = 0; i < 9; i++) {
3358 if (!prefs->swbackImage[i]) {
3359 for (; i >= 0; --i) {
3360 RReleaseImage(prefs->swbackImage[i]);
3361 prefs->swbackImage[i] = NULL;
3363 break;
3367 RReleaseImage(bgimage);
3371 case 1:
3372 if (!WMIsPLString(WMGetFromPLArray(array, 0))) {
3373 wwarning(_("Invalid arguments for option \"%s\""), entry->key);
3374 break;
3375 } else
3376 path = FindImage(wPreferences.pixmap_path, WMGetFromPLString(WMGetFromPLArray(array, 0)));
3378 if (!path) {
3379 wwarning(_("Could not find image \"%s\" for option \"%s\""),
3380 WMGetFromPLString(WMGetFromPLArray(array, 0)), entry->key);
3381 } else {
3382 if (prefs->swtileImage)
3383 RReleaseImage(prefs->swtileImage);
3385 prefs->swtileImage = RLoadImage(scr->rcontext, path, 0);
3386 if (!prefs->swtileImage) {
3387 wwarning(_("Could not load image \"%s\" for option \"%s\""), path, entry->key);
3389 wfree(path);
3391 break;
3393 default:
3394 wwarning(_("Invalid number of arguments for option \"%s\""), entry->key);
3395 break;
3398 WMReleasePropList(array);
3400 return 0;
3403 static int setModifierKeyLabels(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
3405 WMPropList *array = tdata;
3406 int i;
3407 struct WPreferences *prefs = foo;
3409 if (!WMIsPLArray(array) || WMGetPropListItemCount(array) != 7) {
3410 wwarning(_("Value for option \"%s\" must be an array of 7 strings"), entry->key);
3411 WMReleasePropList(array);
3412 return 0;
3415 DestroyWindowMenu(scr);
3417 for (i = 0; i < 7; i++) {
3418 if (prefs->modifier_labels[i])
3419 wfree(prefs->modifier_labels[i]);
3421 if (WMIsPLString(WMGetFromPLArray(array, i))) {
3422 prefs->modifier_labels[i] = wstrdup(WMGetFromPLString(WMGetFromPLArray(array, i)));
3423 } else {
3424 wwarning(_("Invalid argument for option \"%s\" item %d"), entry->key, i);
3425 prefs->modifier_labels[i] = NULL;
3429 WMReleasePropList(array);
3431 return 0;
3434 static int setDoubleClick(WScreen *scr, WDefaultEntry *entry, void *tdata, void *foo)
3436 int *value = tdata;
3438 /* Parameter not used, but tell the compiler that it is ok */
3439 (void) entry;
3440 (void) scr;
3442 if (*value <= 0)
3443 *(int *)foo = 1;
3445 W_setconf_doubleClickDelay(*value);
3447 return 0;
3450 static int setCursor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *extra_data)
3452 Cursor *cursor = tdata;
3453 long widx = (long) extra_data;
3455 /* Parameter not used, but tell the compiler that it is ok */
3456 (void) entry;
3458 if (wPreferences.cursor[widx] != None) {
3459 XFreeCursor(dpy, wPreferences.cursor[widx]);
3462 wPreferences.cursor[widx] = *cursor;
3464 if (widx == WCUR_ROOT && *cursor != None) {
3465 XDefineCursor(dpy, scr->root_win, *cursor);
3468 return 0;