wmaker: fix detection of legacy Apercu configuration keywords
[wmaker-crm.git] / src / defaults.c
blobc5a94c6940cfa58536dc2612e3ad5dc51f317e41
1 /* defaults.c - manage configuration through defaults db
3 * Window Maker window manager
5 * Copyright (c) 1997-2003 Alfredo K. Kojima
6 * Copyright (c) 1998-2003 Dan Pascu
7 * Copyright (c) 2014 Window Maker Team
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License along
21 * with this program; if not, write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 #include "wconfig.h"
27 #include <stdio.h>
28 #include <stdint.h>
29 #include <stdlib.h>
30 #include <unistd.h>
31 #include <string.h>
32 #include <strings.h>
33 #include <ctype.h>
34 #include <time.h>
35 #include <sys/types.h>
36 #include <sys/stat.h>
37 #include <limits.h>
38 #include <signal.h>
40 #ifndef PATH_MAX
41 #define PATH_MAX DEFAULT_PATH_MAX
42 #endif
44 #include <X11/Xlib.h>
45 #include <X11/Xutil.h>
46 #include <X11/keysym.h>
48 #include <wraster.h>
50 #include "WindowMaker.h"
51 #include "framewin.h"
52 #include "window.h"
53 #include "texture.h"
54 #include "screen.h"
55 #include "resources.h"
56 #include "defaults.h"
57 #include "keybind.h"
58 #include "xmodifier.h"
59 #include "icon.h"
60 #include "main.h"
61 #include "actions.h"
62 #include "dock.h"
63 #include "workspace.h"
64 #include "properties.h"
65 #include "misc.h"
66 #include "winmenu.h"
68 #define MAX_SHORTCUT_LENGTH 32
70 #ifndef GLOBAL_DEFAULTS_SUBDIR
71 #define GLOBAL_DEFAULTS_SUBDIR "WindowMaker"
72 #endif
75 typedef struct _WDefaultEntry WDefaultEntry;
76 typedef int (WDECallbackConvert) (WScreen *scr, WDefaultEntry *entry, WMPropList *plvalue, void *addr, void **tdata);
77 typedef int (WDECallbackUpdate) (WScreen *scr, WDefaultEntry *entry, void *tdata, void *extra_data);
79 struct _WDefaultEntry {
80 const char *key;
81 const char *default_value;
82 void *extra_data;
83 void *addr;
84 WDECallbackConvert *convert;
85 WDECallbackUpdate *update;
86 WMPropList *plkey;
87 WMPropList *plvalue; /* default value */
90 /* used to map strings to integers */
91 typedef struct {
92 const char *string;
93 short value;
94 char is_alias;
95 } WOptionEnumeration;
97 /* type converters */
98 static WDECallbackConvert getBool;
99 static WDECallbackConvert getInt;
100 static WDECallbackConvert getCoord;
101 static WDECallbackConvert getPathList;
102 static WDECallbackConvert getEnum;
103 static WDECallbackConvert getTexture;
104 static WDECallbackConvert getWSBackground;
105 static WDECallbackConvert getWSSpecificBackground;
106 static WDECallbackConvert getFont;
107 static WDECallbackConvert getColor;
108 static WDECallbackConvert getKeybind;
109 static WDECallbackConvert getModMask;
110 static WDECallbackConvert getPropList;
112 /* value setting functions */
113 static WDECallbackUpdate setJustify;
114 static WDECallbackUpdate setClearance;
115 static WDECallbackUpdate setIfDockPresent;
116 static WDECallbackUpdate setClipMergedInDock;
117 static WDECallbackUpdate setWrapAppiconsInDock;
118 static WDECallbackUpdate setStickyIcons;
119 static WDECallbackUpdate setWidgetColor;
120 static WDECallbackUpdate setIconTile;
121 static WDECallbackUpdate setWinTitleFont;
122 static WDECallbackUpdate setMenuTitleFont;
123 static WDECallbackUpdate setMenuTextFont;
124 static WDECallbackUpdate setIconTitleFont;
125 static WDECallbackUpdate setIconTitleColor;
126 static WDECallbackUpdate setIconTitleBack;
127 static WDECallbackUpdate setFrameBorderWidth;
128 static WDECallbackUpdate setFrameBorderColor;
129 static WDECallbackUpdate setFrameFocusedBorderColor;
130 static WDECallbackUpdate setFrameSelectedBorderColor;
131 static WDECallbackUpdate setLargeDisplayFont;
132 static WDECallbackUpdate setWTitleColor;
133 static WDECallbackUpdate setFTitleBack;
134 static WDECallbackUpdate setPTitleBack;
135 static WDECallbackUpdate setUTitleBack;
136 static WDECallbackUpdate setResizebarBack;
137 static WDECallbackUpdate setWorkspaceBack;
138 static WDECallbackUpdate setWorkspaceSpecificBack;
139 static WDECallbackUpdate setMenuTitleColor;
140 static WDECallbackUpdate setMenuTextColor;
141 static WDECallbackUpdate setMenuDisabledColor;
142 static WDECallbackUpdate setMenuTitleBack;
143 static WDECallbackUpdate setMenuTextBack;
144 static WDECallbackUpdate setHightlight;
145 static WDECallbackUpdate setHightlightText;
146 static WDECallbackUpdate setKeyGrab;
147 static WDECallbackUpdate setDoubleClick;
148 static WDECallbackUpdate setIconPosition;
149 static WDECallbackUpdate setWorkspaceMapBackground;
151 static WDECallbackUpdate setClipTitleFont;
152 static WDECallbackUpdate setClipTitleColor;
154 static WDECallbackUpdate setMenuStyle;
155 static WDECallbackUpdate setSwPOptions;
156 static WDECallbackUpdate updateUsableArea;
158 static WDECallbackUpdate setModifierKeyLabels;
160 static WDECallbackConvert getCursor;
161 static WDECallbackUpdate setCursor;
164 * Tables to convert strings to enumeration values.
165 * Values stored are char
168 /* WARNING: sum of length of all value strings must not exceed
169 * this value */
170 #define TOTAL_VALUES_LENGTH 80
172 #define REFRESH_WINDOW_TEXTURES (1<<0)
173 #define REFRESH_MENU_TEXTURE (1<<1)
174 #define REFRESH_MENU_FONT (1<<2)
175 #define REFRESH_MENU_COLOR (1<<3)
176 #define REFRESH_MENU_TITLE_TEXTURE (1<<4)
177 #define REFRESH_MENU_TITLE_FONT (1<<5)
178 #define REFRESH_MENU_TITLE_COLOR (1<<6)
179 #define REFRESH_WINDOW_TITLE_COLOR (1<<7)
180 #define REFRESH_WINDOW_FONT (1<<8)
181 #define REFRESH_ICON_TILE (1<<9)
182 #define REFRESH_ICON_FONT (1<<10)
183 #define REFRESH_WORKSPACE_BACK (1<<11)
185 #define REFRESH_BUTTON_IMAGES (1<<12)
187 #define REFRESH_ICON_TITLE_COLOR (1<<13)
188 #define REFRESH_ICON_TITLE_BACK (1<<14)
190 #define REFRESH_WORKSPACE_MENU (1<<15)
192 #define REFRESH_FRAME_BORDER REFRESH_MENU_FONT|REFRESH_WINDOW_FONT
194 static WOptionEnumeration seFocusModes[] = {
195 {"Manual", WKF_CLICK, 0}, {"ClickToFocus", WKF_CLICK, 1},
196 {"Sloppy", WKF_SLOPPY, 0}, {"SemiAuto", WKF_SLOPPY, 1}, {"Auto", WKF_SLOPPY, 1},
197 {NULL, 0, 0}
200 static WOptionEnumeration seTitlebarModes[] = {
201 {"new", TS_NEW, 0}, {"old", TS_OLD, 0},
202 {"next", TS_NEXT, 0}, {NULL, 0, 0}
205 static WOptionEnumeration seColormapModes[] = {
206 {"Manual", WCM_CLICK, 0}, {"ClickToFocus", WCM_CLICK, 1},
207 {"Auto", WCM_POINTER, 0}, {"FocusFollowMouse", WCM_POINTER, 1},
208 {NULL, 0, 0}
211 static WOptionEnumeration sePlacements[] = {
212 {"Auto", WPM_AUTO, 0},
213 {"Smart", WPM_SMART, 0},
214 {"Cascade", WPM_CASCADE, 0},
215 {"Random", WPM_RANDOM, 0},
216 {"Manual", WPM_MANUAL, 0},
217 {"Center", WPM_CENTER, 0},
218 {NULL, 0, 0}
221 static WOptionEnumeration seGeomDisplays[] = {
222 {"None", WDIS_NONE, 0},
223 {"Center", WDIS_CENTER, 0},
224 {"Corner", WDIS_TOPLEFT, 0},
225 {"Floating", WDIS_FRAME_CENTER, 0},
226 {"Line", WDIS_NEW, 0},
227 {NULL, 0, 0}
230 static WOptionEnumeration seSpeeds[] = {
231 {"UltraFast", SPEED_ULTRAFAST, 0},
232 {"Fast", SPEED_FAST, 0},
233 {"Medium", SPEED_MEDIUM, 0},
234 {"Slow", SPEED_SLOW, 0},
235 {"UltraSlow", SPEED_ULTRASLOW, 0},
236 {NULL, 0, 0}
239 static WOptionEnumeration seMouseButtonActions[] = {
240 {"None", WA_NONE, 0},
241 {"SelectWindows", WA_SELECT_WINDOWS, 0},
242 {"OpenApplicationsMenu", WA_OPEN_APPMENU, 0},
243 {"OpenWindowListMenu", WA_OPEN_WINLISTMENU, 0},
244 {"MoveToPrevWorkspace", WA_MOVE_PREVWORKSPACE, 0},
245 {"MoveToNextWorkspace", WA_MOVE_NEXTWORKSPACE, 0},
246 {"MoveToPrevWindow", WA_MOVE_PREVWINDOW, 0},
247 {"MoveToNextWindow", WA_MOVE_NEXTWINDOW, 0},
248 {NULL, 0, 0}
251 static WOptionEnumeration seMouseWheelActions[] = {
252 {"None", WA_NONE, 0},
253 {"SwitchWorkspaces", WA_SWITCH_WORKSPACES, 0},
254 {"SwitchWindows", WA_SWITCH_WINDOWS, 0},
255 {NULL, 0, 0}
258 static WOptionEnumeration seIconificationStyles[] = {
259 {"Zoom", WIS_ZOOM, 0},
260 {"Twist", WIS_TWIST, 0},
261 {"Flip", WIS_FLIP, 0},
262 {"None", WIS_NONE, 0},
263 {"random", WIS_RANDOM, 0},
264 {NULL, 0, 0}
267 static WOptionEnumeration seJustifications[] = {
268 {"Left", WTJ_LEFT, 0},
269 {"Center", WTJ_CENTER, 0},
270 {"Right", WTJ_RIGHT, 0},
271 {NULL, 0, 0}
274 static WOptionEnumeration seIconPositions[] = {
275 {"blv", IY_BOTTOM | IY_LEFT | IY_VERT, 0},
276 {"blh", IY_BOTTOM | IY_LEFT | IY_HORIZ, 0},
277 {"brv", IY_BOTTOM | IY_RIGHT | IY_VERT, 0},
278 {"brh", IY_BOTTOM | IY_RIGHT | IY_HORIZ, 0},
279 {"tlv", IY_TOP | IY_LEFT | IY_VERT, 0},
280 {"tlh", IY_TOP | IY_LEFT | IY_HORIZ, 0},
281 {"trv", IY_TOP | IY_RIGHT | IY_VERT, 0},
282 {"trh", IY_TOP | IY_RIGHT | IY_HORIZ, 0},
283 {NULL, 0, 0}
286 static WOptionEnumeration seMenuStyles[] = {
287 {"normal", MS_NORMAL, 0},
288 {"singletexture", MS_SINGLE_TEXTURE, 0},
289 {"flat", MS_FLAT, 0},
290 {NULL, 0, 0}
293 static WOptionEnumeration seDisplayPositions[] = {
294 {"none", WD_NONE, 0},
295 {"center", WD_CENTER, 0},
296 {"top", WD_TOP, 0},
297 {"bottom", WD_BOTTOM, 0},
298 {"topleft", WD_TOPLEFT, 0},
299 {"topright", WD_TOPRIGHT, 0},
300 {"bottomleft", WD_BOTTOMLEFT, 0},
301 {"bottomright", WD_BOTTOMRIGHT, 0},
302 {NULL, 0, 0}
305 static WOptionEnumeration seWorkspaceBorder[] = {
306 {"None", WB_NONE, 0},
307 {"LeftRight", WB_LEFTRIGHT, 0},
308 {"TopBottom", WB_TOPBOTTOM, 0},
309 {"AllDirections", WB_ALLDIRS, 0},
310 {NULL, 0, 0}
313 static WOptionEnumeration seDragMaximizedWindow[] = {
314 {"Move", DRAGMAX_MOVE, 0},
315 {"RestoreGeometry", DRAGMAX_RESTORE, 0},
316 {"Unmaximize", DRAGMAX_UNMAXIMIZE, 0},
317 {"NoMove", DRAGMAX_NOMOVE, 0},
318 {NULL, 0, 0}
322 * Backward Compatibility:
323 * The Mini-Previews were introduced in 0.95.6 under the name "Apercu".
324 * For compatibility, we still support the old names in configuration files,
325 * which are loaded in this structure, so this should stay for at least
326 * 2 years (that means until 2017) */
327 static struct {
328 char enable;
329 int size;
330 } legacy_minipreview_config;
333 * ALL entries in the tables bellow, NEED to have a default value
334 * defined, and this value needs to be correct.
337 /* these options will only affect the window manager on startup
339 * static defaults can't access the screen data, because it is
340 * created after these defaults are read
342 WDefaultEntry staticOptionList[] = {
344 {"ColormapSize", "4", NULL,
345 &wPreferences.cmap_size, getInt, NULL, NULL, NULL},
346 {"DisableDithering", "NO", NULL,
347 &wPreferences.no_dithering, getBool, NULL, NULL, NULL},
348 {"IconSize", "64", NULL,
349 &wPreferences.icon_size, getInt, NULL, NULL, NULL},
350 {"ModifierKey", "Mod1", NULL,
351 &wPreferences.modifier_mask, getModMask, NULL, NULL, NULL},
352 {"FocusMode", "manual", seFocusModes, /* have a problem when switching from */
353 &wPreferences.focus_mode, getEnum, NULL, NULL, NULL}, /* manual to sloppy without restart */
354 {"NewStyle", "new", seTitlebarModes,
355 &wPreferences.new_style, getEnum, NULL, NULL, NULL},
356 {"DisableDock", "NO", (void *)WM_DOCK,
357 NULL, getBool, setIfDockPresent, NULL, NULL},
358 {"DisableClip", "NO", (void *)WM_CLIP,
359 NULL, getBool, setIfDockPresent, NULL, NULL},
360 {"DisableDrawers", "NO", (void *)WM_DRAWER,
361 NULL, getBool, setIfDockPresent, NULL, NULL},
362 {"ClipMergedInDock", "NO", NULL,
363 NULL, getBool, setClipMergedInDock, NULL, NULL},
364 {"DisableMiniwindows", "NO", NULL,
365 &wPreferences.disable_miniwindows, getBool, NULL, NULL, NULL},
366 {"DisableWorkspacePager", "NO", NULL,
367 &wPreferences.disable_workspace_pager, getBool, NULL, NULL, NULL}
370 #define NUM2STRING_(x) #x
371 #define NUM2STRING(x) NUM2STRING_(x)
373 WDefaultEntry optionList[] = {
375 /* dynamic options */
377 {"IconPosition", "blh", seIconPositions,
378 &wPreferences.icon_yard, getEnum, setIconPosition, NULL, NULL},
379 {"IconificationStyle", "Zoom", seIconificationStyles,
380 &wPreferences.iconification_style, getEnum, NULL, NULL, NULL},
381 {"DisableWSMouseActions", "NO", NULL,
382 &wPreferences.disable_root_mouse, getBool, NULL, NULL, NULL},
383 {"MouseLeftButtonAction", "SelectWindows", seMouseButtonActions,
384 &wPreferences.mouse_button1, getEnum, NULL, NULL, NULL},
385 {"MouseMiddleButtonAction", "OpenWindowListMenu", seMouseButtonActions,
386 &wPreferences.mouse_button2, getEnum, NULL, NULL, NULL},
387 {"MouseRightButtonAction", "OpenApplicationsMenu", seMouseButtonActions,
388 &wPreferences.mouse_button3, getEnum, NULL, NULL, NULL},
389 {"MouseBackwardButtonAction", "None", seMouseButtonActions,
390 &wPreferences.mouse_button8, getEnum, NULL, NULL, NULL},
391 {"MouseForwardButtonAction", "None", seMouseButtonActions,
392 &wPreferences.mouse_button9, getEnum, NULL, NULL, NULL},
393 {"MouseWheelAction", "None", seMouseWheelActions,
394 &wPreferences.mouse_wheel_scroll, getEnum, NULL, NULL, NULL},
395 {"MouseWheelTiltAction", "None", seMouseWheelActions,
396 &wPreferences.mouse_wheel_tilt, getEnum, NULL, NULL, NULL},
397 {"PixmapPath", DEF_PIXMAP_PATHS, NULL,
398 &wPreferences.pixmap_path, getPathList, NULL, NULL, NULL},
399 {"IconPath", DEF_ICON_PATHS, NULL,
400 &wPreferences.icon_path, getPathList, NULL, NULL, NULL},
401 {"ColormapMode", "auto", seColormapModes,
402 &wPreferences.colormap_mode, getEnum, NULL, NULL, NULL},
403 {"AutoFocus", "NO", NULL,
404 &wPreferences.auto_focus, getBool, NULL, NULL, NULL},
405 {"RaiseDelay", "0", NULL,
406 &wPreferences.raise_delay, getInt, NULL, NULL, NULL},
407 {"CirculateRaise", "NO", NULL,
408 &wPreferences.circ_raise, getBool, NULL, NULL, NULL},
409 {"Superfluous", "NO", NULL,
410 &wPreferences.superfluous, getBool, NULL, NULL, NULL},
411 {"AdvanceToNewWorkspace", "NO", NULL,
412 &wPreferences.ws_advance, getBool, NULL, NULL, NULL},
413 {"CycleWorkspaces", "NO", NULL,
414 &wPreferences.ws_cycle, getBool, NULL, NULL, NULL},
415 {"WorkspaceNameDisplayPosition", "center", seDisplayPositions,
416 &wPreferences.workspace_name_display_position, getEnum, NULL, NULL, NULL},
417 {"WorkspaceBorder", "None", seWorkspaceBorder,
418 &wPreferences.workspace_border_position, getEnum, updateUsableArea, NULL, NULL},
419 {"WorkspaceBorderSize", "0", NULL,
420 &wPreferences.workspace_border_size, getInt, updateUsableArea, NULL, NULL},
421 {"StickyIcons", "NO", NULL,
422 &wPreferences.sticky_icons, getBool, setStickyIcons, NULL, NULL},
423 {"SaveSessionOnExit", "NO", NULL,
424 &wPreferences.save_session_on_exit, getBool, NULL, NULL, NULL},
425 {"WrapMenus", "NO", NULL,
426 &wPreferences.wrap_menus, getBool, NULL, NULL, NULL},
427 {"ScrollableMenus", "NO", NULL,
428 &wPreferences.scrollable_menus, getBool, NULL, NULL, NULL},
429 {"MenuScrollSpeed", "medium", seSpeeds,
430 &wPreferences.menu_scroll_speed, getEnum, NULL, NULL, NULL},
431 {"IconSlideSpeed", "medium", seSpeeds,
432 &wPreferences.icon_slide_speed, getEnum, NULL, NULL, NULL},
433 {"ShadeSpeed", "medium", seSpeeds,
434 &wPreferences.shade_speed, getEnum, NULL, NULL, NULL},
435 {"BounceAppIconsWhenUrgent", "YES", NULL,
436 &wPreferences.bounce_appicons_when_urgent, getBool, NULL, NULL, NULL},
437 {"RaiseAppIconsWhenBouncing", "NO", NULL,
438 &wPreferences.raise_appicons_when_bouncing, getBool, NULL, NULL, NULL},
439 {"DoNotMakeAppIconsBounce", "NO", NULL,
440 &wPreferences.do_not_make_appicons_bounce, getBool, NULL, NULL, NULL},
441 {"DoubleClickTime", "250", (void *)&wPreferences.dblclick_time,
442 &wPreferences.dblclick_time, getInt, setDoubleClick, NULL, NULL},
443 {"ClipAutoraiseDelay", "600", NULL,
444 &wPreferences.clip_auto_raise_delay, getInt, NULL, NULL, NULL},
445 {"ClipAutolowerDelay", "1000", NULL,
446 &wPreferences.clip_auto_lower_delay, getInt, NULL, NULL, NULL},
447 {"ClipAutoexpandDelay", "600", NULL,
448 &wPreferences.clip_auto_expand_delay, getInt, NULL, NULL, NULL},
449 {"ClipAutocollapseDelay", "1000", NULL,
450 &wPreferences.clip_auto_collapse_delay, getInt, NULL, NULL, NULL},
451 {"WrapAppiconsInDock", "YES", NULL,
452 NULL, getBool, setWrapAppiconsInDock, NULL, NULL},
453 {"AlignSubmenus", "NO", NULL,
454 &wPreferences.align_menus, getBool, NULL, NULL, NULL},
455 {"ViKeyMenus", "NO", NULL,
456 &wPreferences.vi_key_menus, getBool, NULL, NULL, NULL},
457 {"OpenTransientOnOwnerWorkspace", "NO", NULL,
458 &wPreferences.open_transients_with_parent, getBool, NULL, NULL, NULL},
459 {"WindowPlacement", "auto", sePlacements,
460 &wPreferences.window_placement, getEnum, NULL, NULL, NULL},
461 {"IgnoreFocusClick", "NO", NULL,
462 &wPreferences.ignore_focus_click, getBool, NULL, NULL, NULL},
463 {"UseSaveUnders", "NO", NULL,
464 &wPreferences.use_saveunders, getBool, NULL, NULL, NULL},
465 {"OpaqueMove", "NO", NULL,
466 &wPreferences.opaque_move, getBool, NULL, NULL, NULL},
467 {"OpaqueResize", "NO", NULL,
468 &wPreferences.opaque_resize, getBool, NULL, NULL, NULL},
469 {"OpaqueMoveResizeKeyboard", "NO", NULL,
470 &wPreferences.opaque_move_resize_keyboard, getBool, NULL, NULL, NULL},
471 {"DisableAnimations", "NO", NULL,
472 &wPreferences.no_animations, getBool, NULL, NULL, NULL},
473 {"DontLinkWorkspaces", "NO", NULL,
474 &wPreferences.no_autowrap, getBool, NULL, NULL, NULL},
475 {"WindowSnapping", "NO", NULL,
476 &wPreferences.window_snapping, getBool, NULL, NULL, NULL},
477 {"DragMaximizedWindow", "Move", seDragMaximizedWindow,
478 &wPreferences.drag_maximized_window, getEnum, NULL, NULL, NULL},
479 {"HighlightActiveApp", "YES", NULL,
480 &wPreferences.highlight_active_app, getBool, NULL, NULL, NULL},
481 {"AutoArrangeIcons", "NO", NULL,
482 &wPreferences.auto_arrange_icons, getBool, NULL, NULL, NULL},
483 {"NoWindowOverDock", "NO", NULL,
484 &wPreferences.no_window_over_dock, getBool, updateUsableArea, NULL, NULL},
485 {"NoWindowOverIcons", "NO", NULL,
486 &wPreferences.no_window_over_icons, getBool, updateUsableArea, NULL, NULL},
487 {"WindowPlaceOrigin", "(0, 0)", NULL,
488 &wPreferences.window_place_origin, getCoord, NULL, NULL, NULL},
489 {"ResizeDisplay", "corner", seGeomDisplays,
490 &wPreferences.size_display, getEnum, NULL, NULL, NULL},
491 {"MoveDisplay", "corner", seGeomDisplays,
492 &wPreferences.move_display, getEnum, NULL, NULL, NULL},
493 {"DontConfirmKill", "NO", NULL,
494 &wPreferences.dont_confirm_kill, getBool, NULL, NULL, NULL},
495 {"WindowTitleBalloons", "NO", NULL,
496 &wPreferences.window_balloon, getBool, NULL, NULL, NULL},
497 {"MiniwindowTitleBalloons", "NO", NULL,
498 &wPreferences.miniwin_title_balloon, getBool, NULL, NULL, NULL},
499 {"MiniwindowPreviewBalloons", "NO", NULL,
500 &wPreferences.miniwin_preview_balloon, getBool, NULL, NULL, NULL},
501 {"AppIconBalloons", "NO", NULL,
502 &wPreferences.appicon_balloon, getBool, NULL, NULL, NULL},
503 {"HelpBalloons", "NO", NULL,
504 &wPreferences.help_balloon, getBool, NULL, NULL, NULL},
505 {"EdgeResistance", "30", NULL,
506 &wPreferences.edge_resistance, getInt, NULL, NULL, NULL},
507 {"ResizeIncrement", "0", NULL,
508 &wPreferences.resize_increment, getInt, NULL, NULL, NULL},
509 {"Attraction", "NO", NULL,
510 &wPreferences.attract, getBool, NULL, NULL, NULL},
511 {"DisableBlinking", "NO", NULL,
512 &wPreferences.dont_blink, getBool, NULL, NULL, NULL},
513 {"SingleClickLaunch", "NO", NULL,
514 &wPreferences.single_click, getBool, NULL, NULL, NULL},
515 {"StrictWindozeCycle", "YES", NULL,
516 &wPreferences.strict_windoze_cycle, getBool, NULL, NULL, NULL},
517 {"SwitchPanelOnlyOpen", "NO", NULL,
518 &wPreferences.panel_only_open, getBool, NULL, NULL, NULL},
519 {"MiniPreviewSize", "128", NULL,
520 &wPreferences.minipreview_size, getInt, NULL, NULL, NULL},
521 {"IgnoreGtkHints", "NO", NULL,
522 &wPreferences.ignore_gtk_decoration_hints, getBool, NULL, NULL, NULL},
525 * Backward Compatibility:
526 * The Mini-Previews were introduced in 0.95.6 under the name "Apercu".
527 * For compatibility, we still support the old names in configuration files,
528 * so this should stay for at least 2 years (that means until 2017)
530 {"MiniwindowApercuBalloons", "NO", NULL,
531 &legacy_minipreview_config.enable, getBool, NULL, NULL, NULL},
532 {"ApercuSize", "0", NULL,
533 &legacy_minipreview_config.size, getInt, NULL, NULL, NULL},
535 /* style options */
537 {"MenuStyle", "normal", seMenuStyles,
538 &wPreferences.menu_style, getEnum, setMenuStyle, NULL, NULL},
539 {"WidgetColor", "(solid, gray)", NULL,
540 NULL, getTexture, setWidgetColor, NULL, NULL},
541 {"WorkspaceSpecificBack", "()", NULL,
542 NULL, getWSSpecificBackground, setWorkspaceSpecificBack, NULL, NULL},
543 /* WorkspaceBack must come after WorkspaceSpecificBack or
544 * WorkspaceBack wont know WorkspaceSpecificBack was also
545 * specified and 2 copies of wmsetbg will be launched */
546 {"WorkspaceBack", "(solid, black)", NULL,
547 NULL, getWSBackground, setWorkspaceBack, NULL, NULL},
548 {"SmoothWorkspaceBack", "NO", NULL,
549 NULL, getBool, NULL, NULL, NULL},
550 {"IconBack", "(solid, gray)", NULL,
551 NULL, getTexture, setIconTile, NULL, NULL},
552 {"TitleJustify", "center", seJustifications,
553 &wPreferences.title_justification, getEnum, setJustify, NULL, NULL},
554 {"WindowTitleFont", DEF_TITLE_FONT, NULL,
555 NULL, getFont, setWinTitleFont, NULL, NULL},
556 {"WindowTitleExtendSpace", DEF_WINDOW_TITLE_EXTEND_SPACE, NULL,
557 &wPreferences.window_title_clearance, getInt, setClearance, NULL, NULL},
558 {"WindowTitleMinHeight", "0", NULL,
559 &wPreferences.window_title_min_height, getInt, setClearance, NULL, NULL},
560 {"WindowTitleMaxHeight", NUM2STRING(INT_MAX), NULL,
561 &wPreferences.window_title_max_height, getInt, setClearance, NULL, NULL},
562 {"MenuTitleExtendSpace", DEF_MENU_TITLE_EXTEND_SPACE, NULL,
563 &wPreferences.menu_title_clearance, getInt, setClearance, NULL, NULL},
564 {"MenuTitleMinHeight", "0", NULL,
565 &wPreferences.menu_title_min_height, getInt, setClearance, NULL, NULL},
566 {"MenuTitleMaxHeight", NUM2STRING(INT_MAX), NULL,
567 &wPreferences.menu_title_max_height, getInt, setClearance, NULL, NULL},
568 {"MenuTextExtendSpace", DEF_MENU_TEXT_EXTEND_SPACE, NULL,
569 &wPreferences.menu_text_clearance, getInt, setClearance, NULL, NULL},
570 {"MenuTitleFont", DEF_MENU_TITLE_FONT, NULL,
571 NULL, getFont, setMenuTitleFont, NULL, NULL},
572 {"MenuTextFont", DEF_MENU_ENTRY_FONT, NULL,
573 NULL, getFont, setMenuTextFont, NULL, NULL},
574 {"IconTitleFont", DEF_ICON_TITLE_FONT, NULL,
575 NULL, getFont, setIconTitleFont, NULL, NULL},
576 {"ClipTitleFont", DEF_CLIP_TITLE_FONT, NULL,
577 NULL, getFont, setClipTitleFont, NULL, NULL},
578 {"ShowClipTitle", "YES", NULL,
579 &wPreferences.show_clip_title, getBool, NULL, NULL, NULL},
580 {"LargeDisplayFont", DEF_WORKSPACE_NAME_FONT, NULL,
581 NULL, getFont, setLargeDisplayFont, NULL, NULL},
582 {"HighlightColor", "white", NULL,
583 NULL, getColor, setHightlight, NULL, NULL},
584 {"HighlightTextColor", "black", NULL,
585 NULL, getColor, setHightlightText, NULL, NULL},
586 {"ClipTitleColor", "black", (void *)CLIP_NORMAL,
587 NULL, getColor, setClipTitleColor, NULL, NULL},
588 {"CClipTitleColor", "\"#454045\"", (void *)CLIP_COLLAPSED,
589 NULL, getColor, setClipTitleColor, NULL, NULL},
590 {"FTitleColor", "white", (void *)WS_FOCUSED,
591 NULL, getColor, setWTitleColor, NULL, NULL},
592 {"PTitleColor", "white", (void *)WS_PFOCUSED,
593 NULL, getColor, setWTitleColor, NULL, NULL},
594 {"UTitleColor", "black", (void *)WS_UNFOCUSED,
595 NULL, getColor, setWTitleColor, NULL, NULL},
596 {"FTitleBack", "(solid, black)", NULL,
597 NULL, getTexture, setFTitleBack, NULL, NULL},
598 {"PTitleBack", "(solid, \"#616161\")", NULL,
599 NULL, getTexture, setPTitleBack, NULL, NULL},
600 {"UTitleBack", "(solid, gray)", NULL,
601 NULL, getTexture, setUTitleBack, NULL, NULL},
602 {"ResizebarBack", "(solid, gray)", NULL,
603 NULL, getTexture, setResizebarBack, NULL, NULL},
604 {"MenuTitleColor", "white", NULL,
605 NULL, getColor, setMenuTitleColor, NULL, NULL},
606 {"MenuTextColor", "black", NULL,
607 NULL, getColor, setMenuTextColor, NULL, NULL},
608 {"MenuDisabledColor", "\"#616161\"", NULL,
609 NULL, getColor, setMenuDisabledColor, NULL, NULL},
610 {"MenuTitleBack", "(solid, black)", NULL,
611 NULL, getTexture, setMenuTitleBack, NULL, NULL},
612 {"MenuTextBack", "(solid, gray)", NULL,
613 NULL, getTexture, setMenuTextBack, NULL, NULL},
614 {"IconTitleColor", "white", NULL,
615 NULL, getColor, setIconTitleColor, NULL, NULL},
616 {"IconTitleBack", "black", NULL,
617 NULL, getColor, setIconTitleBack, NULL, NULL},
618 {"SwitchPanelImages", "(swtile.png, swback.png, 30, 40)", &wPreferences,
619 NULL, getPropList, setSwPOptions, NULL, NULL},
620 {"ModifierKeyLabels", "(\"Shift+\", \"Control+\", \"Mod1+\", \"Mod2+\", \"Mod3+\", \"Mod4+\", \"Mod5+\")", &wPreferences,
621 NULL, getPropList, setModifierKeyLabels, NULL, NULL},
622 {"FrameBorderWidth", "1", NULL,
623 NULL, getInt, setFrameBorderWidth, NULL, NULL},
624 {"FrameBorderColor", "black", NULL,
625 NULL, getColor, setFrameBorderColor, NULL, NULL},
626 {"FrameFocusedBorderColor", "black", NULL,
627 NULL, getColor, setFrameFocusedBorderColor, NULL, NULL},
628 {"FrameSelectedBorderColor", "white", NULL,
629 NULL, getColor, setFrameSelectedBorderColor, NULL, NULL},
630 {"WorkspaceMapBack", "(solid, black)", NULL,
631 NULL, getTexture, setWorkspaceMapBackground, NULL, NULL},
633 /* keybindings */
635 {"RootMenuKey", "None", (void *)WKBD_ROOTMENU,
636 NULL, getKeybind, setKeyGrab, NULL, NULL},
637 {"WindowListKey", "None", (void *)WKBD_WINDOWLIST,
638 NULL, getKeybind, setKeyGrab, NULL, NULL},
639 {"WindowMenuKey", "None", (void *)WKBD_WINDOWMENU,
640 NULL, getKeybind, setKeyGrab, NULL, NULL},
641 {"DockRaiseLowerKey", "None", (void*)WKBD_DOCKRAISELOWER,
642 NULL, getKeybind, setKeyGrab, NULL, NULL},
643 {"ClipRaiseLowerKey", "None", (void *)WKBD_CLIPRAISELOWER,
644 NULL, getKeybind, setKeyGrab, NULL, NULL},
645 {"MiniaturizeKey", "None", (void *)WKBD_MINIATURIZE,
646 NULL, getKeybind, setKeyGrab, NULL, NULL},
647 {"MinimizeAllKey", "None", (void *)WKBD_MINIMIZEALL,
648 NULL, getKeybind, setKeyGrab, NULL, NULL },
649 {"HideKey", "None", (void *)WKBD_HIDE,
650 NULL, getKeybind, setKeyGrab, NULL, NULL},
651 {"HideOthersKey", "None", (void *)WKBD_HIDE_OTHERS,
652 NULL, getKeybind, setKeyGrab, NULL, NULL},
653 {"MoveResizeKey", "None", (void *)WKBD_MOVERESIZE,
654 NULL, getKeybind, setKeyGrab, NULL, NULL},
655 {"CloseKey", "None", (void *)WKBD_CLOSE,
656 NULL, getKeybind, setKeyGrab, NULL, NULL},
657 {"MaximizeKey", "None", (void *)WKBD_MAXIMIZE,
658 NULL, getKeybind, setKeyGrab, NULL, NULL},
659 {"VMaximizeKey", "None", (void *)WKBD_VMAXIMIZE,
660 NULL, getKeybind, setKeyGrab, NULL, NULL},
661 {"HMaximizeKey", "None", (void *)WKBD_HMAXIMIZE,
662 NULL, getKeybind, setKeyGrab, NULL, NULL},
663 {"LHMaximizeKey", "None", (void*)WKBD_LHMAXIMIZE,
664 NULL, getKeybind, setKeyGrab, NULL, NULL},
665 {"RHMaximizeKey", "None", (void*)WKBD_RHMAXIMIZE,
666 NULL, getKeybind, setKeyGrab, NULL, NULL},
667 {"THMaximizeKey", "None", (void*)WKBD_THMAXIMIZE,
668 NULL, getKeybind, setKeyGrab, NULL, NULL},
669 {"BHMaximizeKey", "None", (void*)WKBD_BHMAXIMIZE,
670 NULL, getKeybind, setKeyGrab, NULL, NULL},
671 {"LTCMaximizeKey", "None", (void*)WKBD_LTCMAXIMIZE,
672 NULL, getKeybind, setKeyGrab, NULL, NULL},
673 {"RTCMaximizeKey", "None", (void*)WKBD_RTCMAXIMIZE,
674 NULL, getKeybind, setKeyGrab, NULL, NULL},
675 {"LBCMaximizeKey", "None", (void*)WKBD_LBCMAXIMIZE,
676 NULL, getKeybind, setKeyGrab, NULL, NULL},
677 {"RBCMaximizeKey", "None", (void*)WKBD_RBCMAXIMIZE,
678 NULL, getKeybind, setKeyGrab, NULL, NULL},
679 {"MaximusKey", "None", (void*)WKBD_MAXIMUS,
680 NULL, getKeybind, setKeyGrab, NULL, NULL},
681 {"OmnipresentKey", "None", (void *)WKBD_OMNIPRESENT,
682 NULL, getKeybind, setKeyGrab, NULL, NULL},
683 {"RaiseKey", "\"Meta+Up\"", (void *)WKBD_RAISE,
684 NULL, getKeybind, setKeyGrab, NULL, NULL},
685 {"LowerKey", "\"Meta+Down\"", (void *)WKBD_LOWER,
686 NULL, getKeybind, setKeyGrab, NULL, NULL},
687 {"RaiseLowerKey", "None", (void *)WKBD_RAISELOWER,
688 NULL, getKeybind, setKeyGrab, NULL, NULL},
689 {"ShadeKey", "None", (void *)WKBD_SHADE,
690 NULL, getKeybind, setKeyGrab, NULL, NULL},
691 {"SelectKey", "None", (void *)WKBD_SELECT,
692 NULL, getKeybind, setKeyGrab, NULL, NULL},
693 {"WorkspaceMapKey", "None", (void *)WKBD_WORKSPACEMAP,
694 NULL, getKeybind, setKeyGrab, NULL, NULL},
695 {"FocusNextKey", "None", (void *)WKBD_FOCUSNEXT,
696 NULL, getKeybind, setKeyGrab, NULL, NULL},
697 {"FocusPrevKey", "None", (void *)WKBD_FOCUSPREV,
698 NULL, getKeybind, setKeyGrab, NULL, NULL},
699 {"GroupNextKey", "None", (void *)WKBD_GROUPNEXT,
700 NULL, getKeybind, setKeyGrab, NULL, NULL},
701 {"GroupPrevKey", "None", (void *)WKBD_GROUPPREV,
702 NULL, getKeybind, setKeyGrab, NULL, NULL},
703 {"NextWorkspaceKey", "None", (void *)WKBD_NEXTWORKSPACE,
704 NULL, getKeybind, setKeyGrab, NULL, NULL},
705 {"PrevWorkspaceKey", "None", (void *)WKBD_PREVWORKSPACE,
706 NULL, getKeybind, setKeyGrab, NULL, NULL},
707 {"LastWorkspaceKey", "None", (void *)WKBD_LASTWORKSPACE,
708 NULL, getKeybind, setKeyGrab, NULL, NULL},
709 {"NextWorkspaceLayerKey", "None", (void *)WKBD_NEXTWSLAYER,
710 NULL, getKeybind, setKeyGrab, NULL, NULL},
711 {"PrevWorkspaceLayerKey", "None", (void *)WKBD_PREVWSLAYER,
712 NULL, getKeybind, setKeyGrab, NULL, NULL},
713 {"Workspace1Key", "None", (void *)WKBD_WORKSPACE1,
714 NULL, getKeybind, setKeyGrab, NULL, NULL},
715 {"Workspace2Key", "None", (void *)WKBD_WORKSPACE2,
716 NULL, getKeybind, setKeyGrab, NULL, NULL},
717 {"Workspace3Key", "None", (void *)WKBD_WORKSPACE3,
718 NULL, getKeybind, setKeyGrab, NULL, NULL},
719 {"Workspace4Key", "None", (void *)WKBD_WORKSPACE4,
720 NULL, getKeybind, setKeyGrab, NULL, NULL},
721 {"Workspace5Key", "None", (void *)WKBD_WORKSPACE5,
722 NULL, getKeybind, setKeyGrab, NULL, NULL},
723 {"Workspace6Key", "None", (void *)WKBD_WORKSPACE6,
724 NULL, getKeybind, setKeyGrab, NULL, NULL},
725 {"Workspace7Key", "None", (void *)WKBD_WORKSPACE7,
726 NULL, getKeybind, setKeyGrab, NULL, NULL},
727 {"Workspace8Key", "None", (void *)WKBD_WORKSPACE8,
728 NULL, getKeybind, setKeyGrab, NULL, NULL},
729 {"Workspace9Key", "None", (void *)WKBD_WORKSPACE9,
730 NULL, getKeybind, setKeyGrab, NULL, NULL},
731 {"Workspace10Key", "None", (void *)WKBD_WORKSPACE10,
732 NULL, getKeybind, setKeyGrab, NULL, NULL},
733 {"MoveToWorkspace1Key", "None", (void *)WKBD_MOVE_WORKSPACE1,
734 NULL, getKeybind, setKeyGrab, NULL, NULL},
735 {"MoveToWorkspace2Key", "None", (void *)WKBD_MOVE_WORKSPACE2,
736 NULL, getKeybind, setKeyGrab, NULL, NULL},
737 {"MoveToWorkspace3Key", "None", (void *)WKBD_MOVE_WORKSPACE3,
738 NULL, getKeybind, setKeyGrab, NULL, NULL},
739 {"MoveToWorkspace4Key", "None", (void *)WKBD_MOVE_WORKSPACE4,
740 NULL, getKeybind, setKeyGrab, NULL, NULL},
741 {"MoveToWorkspace5Key", "None", (void *)WKBD_MOVE_WORKSPACE5,
742 NULL, getKeybind, setKeyGrab, NULL, NULL},
743 {"MoveToWorkspace6Key", "None", (void *)WKBD_MOVE_WORKSPACE6,
744 NULL, getKeybind, setKeyGrab, NULL, NULL},
745 {"MoveToWorkspace7Key", "None", (void *)WKBD_MOVE_WORKSPACE7,
746 NULL, getKeybind, setKeyGrab, NULL, NULL},
747 {"MoveToWorkspace8Key", "None", (void *)WKBD_MOVE_WORKSPACE8,
748 NULL, getKeybind, setKeyGrab, NULL, NULL},
749 {"MoveToWorkspace9Key", "None", (void *)WKBD_MOVE_WORKSPACE9,
750 NULL, getKeybind, setKeyGrab, NULL, NULL},
751 {"MoveToWorkspace10Key", "None", (void *)WKBD_MOVE_WORKSPACE10,
752 NULL, getKeybind, setKeyGrab, NULL, NULL},
753 {"MoveToNextWorkspaceKey", "None", (void *)WKBD_MOVE_NEXTWORKSPACE,
754 NULL, getKeybind, setKeyGrab, NULL, NULL},
755 {"MoveToPrevWorkspaceKey", "None", (void *)WKBD_MOVE_PREVWORKSPACE,
756 NULL, getKeybind, setKeyGrab, NULL, NULL},
757 {"MoveToLastWorkspaceKey", "None", (void *)WKBD_MOVE_LASTWORKSPACE,
758 NULL, getKeybind, setKeyGrab, NULL, NULL},
759 {"MoveToNextWorkspaceLayerKey", "None", (void *)WKBD_MOVE_NEXTWSLAYER,
760 NULL, getKeybind, setKeyGrab, NULL, NULL},
761 {"MoveToPrevWorkspaceLayerKey", "None", (void *)WKBD_MOVE_PREVWSLAYER,
762 NULL, getKeybind, setKeyGrab, NULL, NULL},
763 {"WindowShortcut1Key", "None", (void *)WKBD_WINDOW1,
764 NULL, getKeybind, setKeyGrab, NULL, NULL},
765 {"WindowShortcut2Key", "None", (void *)WKBD_WINDOW2,
766 NULL, getKeybind, setKeyGrab, NULL, NULL},
767 {"WindowShortcut3Key", "None", (void *)WKBD_WINDOW3,
768 NULL, getKeybind, setKeyGrab, NULL, NULL},
769 {"WindowShortcut4Key", "None", (void *)WKBD_WINDOW4,
770 NULL, getKeybind, setKeyGrab, NULL, NULL},
771 {"WindowShortcut5Key", "None", (void *)WKBD_WINDOW5,
772 NULL, getKeybind, setKeyGrab, NULL, NULL},
773 {"WindowShortcut6Key", "None", (void *)WKBD_WINDOW6,
774 NULL, getKeybind, setKeyGrab, NULL, NULL},
775 {"WindowShortcut7Key", "None", (void *)WKBD_WINDOW7,
776 NULL, getKeybind, setKeyGrab, NULL, NULL},
777 {"WindowShortcut8Key", "None", (void *)WKBD_WINDOW8,
778 NULL, getKeybind, setKeyGrab, NULL, NULL},
779 {"WindowShortcut9Key", "None", (void *)WKBD_WINDOW9,
780 NULL, getKeybind, setKeyGrab, NULL, NULL},
781 {"WindowShortcut10Key", "None", (void *)WKBD_WINDOW10,
782 NULL, getKeybind, setKeyGrab, NULL, NULL},
783 {"WindowRelaunchKey", "None", (void *)WKBD_RELAUNCH,
784 NULL, getKeybind, setKeyGrab, NULL, NULL},
785 {"ScreenSwitchKey", "None", (void *)WKBD_SWITCH_SCREEN,
786 NULL, getKeybind, setKeyGrab, NULL, NULL},
787 {"RunKey", "None", (void *)WKBD_RUN,
788 NULL, getKeybind, setKeyGrab, NULL, NULL},
790 #ifdef KEEP_XKB_LOCK_STATUS
791 {"ToggleKbdModeKey", "None", (void *)WKBD_TOGGLE,
792 NULL, getKeybind, setKeyGrab, NULL, NULL},
793 {"KbdModeLock", "NO", NULL,
794 &wPreferences.modelock, getBool, NULL, NULL, NULL},
795 #endif /* KEEP_XKB_LOCK_STATUS */
797 {"NormalCursor", "(builtin, left_ptr)", (void *)WCUR_ROOT,
798 NULL, getCursor, setCursor, NULL, NULL},
799 {"ArrowCursor", "(builtin, top_left_arrow)", (void *)WCUR_ARROW,
800 NULL, getCursor, setCursor, NULL, NULL},
801 {"MoveCursor", "(builtin, fleur)", (void *)WCUR_MOVE,
802 NULL, getCursor, setCursor, NULL, NULL},
803 {"ResizeCursor", "(builtin, sizing)", (void *)WCUR_RESIZE,
804 NULL, getCursor, setCursor, NULL, NULL},
805 {"TopLeftResizeCursor", "(builtin, top_left_corner)", (void *)WCUR_TOPLEFTRESIZE,
806 NULL, getCursor, setCursor, NULL, NULL},
807 {"TopRightResizeCursor", "(builtin, top_right_corner)", (void *)WCUR_TOPRIGHTRESIZE,
808 NULL, getCursor, setCursor, NULL, NULL},
809 {"BottomLeftResizeCursor", "(builtin, bottom_left_corner)", (void *)WCUR_BOTTOMLEFTRESIZE,
810 NULL, getCursor, setCursor, NULL, NULL},
811 {"BottomRightResizeCursor", "(builtin, bottom_right_corner)", (void *)WCUR_BOTTOMRIGHTRESIZE,
812 NULL, getCursor, setCursor, NULL, NULL},
813 {"VerticalResizeCursor", "(builtin, sb_v_double_arrow)", (void *)WCUR_VERTICALRESIZE,
814 NULL, getCursor, setCursor, NULL, NULL},
815 {"HorizontalResizeCursor", "(builtin, sb_h_double_arrow)", (void *)WCUR_HORIZONRESIZE,
816 NULL, getCursor, setCursor, NULL, NULL},
817 {"WaitCursor", "(builtin, watch)", (void *)WCUR_WAIT,
818 NULL, getCursor, setCursor, NULL, NULL},
819 {"QuestionCursor", "(builtin, question_arrow)", (void *)WCUR_QUESTION,
820 NULL, getCursor, setCursor, NULL, NULL},
821 {"TextCursor", "(builtin, xterm)", (void *)WCUR_TEXT,
822 NULL, getCursor, setCursor, NULL, NULL},
823 {"SelectCursor", "(builtin, cross)", (void *)WCUR_SELECT,
824 NULL, getCursor, setCursor, NULL, NULL},
825 {"DialogHistoryLines", "500", NULL,
826 &wPreferences.history_lines, getInt, NULL, NULL, NULL},
827 {"CycleActiveHeadOnly", "NO", NULL,
828 &wPreferences.cycle_active_head_only, getBool, NULL, NULL, NULL},
829 {"CycleIgnoreMinimized", "NO", NULL,
830 &wPreferences.cycle_ignore_minimized, getBool, NULL, NULL, NULL}
833 static void initDefaults(void)
835 unsigned int i;
836 WDefaultEntry *entry;
838 WMPLSetCaseSensitive(False);
840 for (i = 0; i < wlengthof(optionList); i++) {
841 entry = &optionList[i];
843 entry->plkey = WMCreatePLString(entry->key);
844 if (entry->default_value)
845 entry->plvalue = WMCreatePropListFromDescription(entry->default_value);
846 else
847 entry->plvalue = NULL;
850 for (i = 0; i < wlengthof(staticOptionList); i++) {
851 entry = &staticOptionList[i];
853 entry->plkey = WMCreatePLString(entry->key);
854 if (entry->default_value)
855 entry->plvalue = WMCreatePropListFromDescription(entry->default_value);
856 else
857 entry->plvalue = NULL;
861 static WMPropList *readGlobalDomain(const char *domainName, Bool requireDictionary)
863 WMPropList *globalDict = NULL;
864 char path[PATH_MAX];
865 struct stat stbuf;
867 snprintf(path, sizeof(path), "%s/%s/%s", SYSCONFDIR, GLOBAL_DEFAULTS_SUBDIR, domainName);
868 if (stat(path, &stbuf) >= 0) {
869 globalDict = WMReadPropListFromFile(path);
870 if (globalDict && requireDictionary && !WMIsPLDictionary(globalDict)) {
871 wwarning(_("Domain %s (%s) of global defaults database is corrupted!"), domainName, path);
872 WMReleasePropList(globalDict);
873 globalDict = NULL;
874 } else if (!globalDict) {
875 wwarning(_("could not load domain %s from global defaults database"), domainName);
879 return globalDict;
882 #if defined(GLOBAL_PREAMBLE_MENU_FILE) || defined(GLOBAL_EPILOGUE_MENU_FILE)
883 static void prependMenu(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 WMInsertInPLArray(destarr, i + 1, item);
895 static void appendMenu(WMPropList * destarr, WMPropList * array)
897 WMPropList *item;
898 int i;
900 for (i = 0; i < WMGetPropListItemCount(array); i++) {
901 item = WMGetFromPLArray(array, i);
902 if (item)
903 WMAddToPLArray(destarr, item);
906 #endif
908 void wDefaultsMergeGlobalMenus(WDDomain * menuDomain)
910 WMPropList *menu = menuDomain->dictionary;
911 WMPropList *submenu;
913 if (!menu || !WMIsPLArray(menu))
914 return;
916 #ifdef GLOBAL_PREAMBLE_MENU_FILE
917 submenu = WMReadPropListFromFile(SYSCONFDIR "/" GLOBAL_DEFAULTS_SUBDIR "/" GLOBAL_PREAMBLE_MENU_FILE);
919 if (submenu && !WMIsPLArray(submenu)) {
920 wwarning(_("invalid global menu file %s"), GLOBAL_PREAMBLE_MENU_FILE);
921 WMReleasePropList(submenu);
922 submenu = NULL;
924 if (submenu) {
925 prependMenu(menu, submenu);
926 WMReleasePropList(submenu);
928 #endif
930 #ifdef GLOBAL_EPILOGUE_MENU_FILE
931 submenu = WMReadPropListFromFile(SYSCONFDIR "/" GLOBAL_DEFAULTS_SUBDIR "/" GLOBAL_EPILOGUE_MENU_FILE);
933 if (submenu && !WMIsPLArray(submenu)) {
934 wwarning(_("invalid global menu file %s"), GLOBAL_EPILOGUE_MENU_FILE);
935 WMReleasePropList(submenu);
936 submenu = NULL;
938 if (submenu) {
939 appendMenu(menu, submenu);
940 WMReleasePropList(submenu);
942 #endif
944 menuDomain->dictionary = menu;
947 WDDomain *wDefaultsInitDomain(const char *domain, Bool requireDictionary)
949 WDDomain *db;
950 struct stat stbuf;
951 static int inited = 0;
952 WMPropList *shared_dict = NULL;
954 if (!inited) {
955 inited = 1;
956 initDefaults();
959 db = wmalloc(sizeof(WDDomain));
960 db->domain_name = domain;
961 db->path = wdefaultspathfordomain(domain);
963 if (stat(db->path, &stbuf) >= 0) {
964 db->dictionary = WMReadPropListFromFile(db->path);
965 if (db->dictionary) {
966 if (requireDictionary && !WMIsPLDictionary(db->dictionary)) {
967 WMReleasePropList(db->dictionary);
968 db->dictionary = NULL;
969 wwarning(_("Domain %s (%s) of defaults database is corrupted!"), domain, db->path);
971 db->timestamp = stbuf.st_mtime;
972 } else {
973 wwarning(_("could not load domain %s from user defaults database"), domain);
977 /* global system dictionary */
978 shared_dict = readGlobalDomain(domain, requireDictionary);
980 if (shared_dict && db->dictionary && WMIsPLDictionary(shared_dict) &&
981 WMIsPLDictionary(db->dictionary)) {
982 WMMergePLDictionaries(shared_dict, db->dictionary, True);
983 WMReleasePropList(db->dictionary);
984 db->dictionary = shared_dict;
985 if (stbuf.st_mtime > db->timestamp)
986 db->timestamp = stbuf.st_mtime;
987 } else if (!db->dictionary) {
988 db->dictionary = shared_dict;
989 if (stbuf.st_mtime > db->timestamp)
990 db->timestamp = stbuf.st_mtime;
993 return db;
996 void wReadStaticDefaults(WMPropList * dict)
998 WMPropList *plvalue;
999 WDefaultEntry *entry;
1000 unsigned int i;
1001 void *tdata;
1003 for (i = 0; i < wlengthof(staticOptionList); i++) {
1004 entry = &staticOptionList[i];
1006 if (dict)
1007 plvalue = WMGetFromPLDictionary(dict, entry->plkey);
1008 else
1009 plvalue = NULL;
1011 /* no default in the DB. Use builtin default */
1012 if (!plvalue)
1013 plvalue = entry->plvalue;
1015 if (plvalue) {
1016 /* convert data */
1017 (*entry->convert) (NULL, entry, plvalue, entry->addr, &tdata);
1018 if (entry->update)
1019 (*entry->update) (NULL, entry, tdata, entry->extra_data);
1024 void wDefaultsCheckDomains(void* arg)
1026 WScreen *scr;
1027 struct stat stbuf;
1028 WMPropList *shared_dict = NULL;
1029 WMPropList *dict;
1030 int i;
1032 /* Parameter not used, but tell the compiler that it is ok */
1033 (void) arg;
1035 if (stat(w_global.domain.wmaker->path, &stbuf) >= 0 && w_global.domain.wmaker->timestamp < stbuf.st_mtime) {
1036 w_global.domain.wmaker->timestamp = stbuf.st_mtime;
1038 /* Global dictionary */
1039 shared_dict = readGlobalDomain("WindowMaker", True);
1041 /* User dictionary */
1042 dict = WMReadPropListFromFile(w_global.domain.wmaker->path);
1044 if (dict) {
1045 if (!WMIsPLDictionary(dict)) {
1046 WMReleasePropList(dict);
1047 dict = NULL;
1048 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
1049 "WindowMaker", w_global.domain.wmaker->path);
1050 } else {
1051 if (shared_dict) {
1052 WMMergePLDictionaries(shared_dict, dict, True);
1053 WMReleasePropList(dict);
1054 dict = shared_dict;
1055 shared_dict = NULL;
1058 for (i = 0; i < w_global.screen_count; i++) {
1059 scr = wScreenWithNumber(i);
1060 if (scr)
1061 wReadDefaults(scr, dict);
1064 if (w_global.domain.wmaker->dictionary)
1065 WMReleasePropList(w_global.domain.wmaker->dictionary);
1067 w_global.domain.wmaker->dictionary = dict;
1069 } else {
1070 wwarning(_("could not load domain %s from user defaults database"), "WindowMaker");
1073 if (shared_dict)
1074 WMReleasePropList(shared_dict);
1078 if (stat(w_global.domain.window_attr->path, &stbuf) >= 0 && w_global.domain.window_attr->timestamp < stbuf.st_mtime) {
1079 /* global dictionary */
1080 shared_dict = readGlobalDomain("WMWindowAttributes", True);
1081 /* user dictionary */
1082 dict = WMReadPropListFromFile(w_global.domain.window_attr->path);
1083 if (dict) {
1084 if (!WMIsPLDictionary(dict)) {
1085 WMReleasePropList(dict);
1086 dict = NULL;
1087 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
1088 "WMWindowAttributes", w_global.domain.window_attr->path);
1089 } else {
1090 if (shared_dict) {
1091 WMMergePLDictionaries(shared_dict, dict, True);
1092 WMReleasePropList(dict);
1093 dict = shared_dict;
1094 shared_dict = NULL;
1097 if (w_global.domain.window_attr->dictionary)
1098 WMReleasePropList(w_global.domain.window_attr->dictionary);
1100 w_global.domain.window_attr->dictionary = dict;
1101 for (i = 0; i < w_global.screen_count; i++) {
1102 scr = wScreenWithNumber(i);
1103 if (scr) {
1104 wDefaultUpdateIcons(scr);
1106 /* Update the panel image if changed */
1107 /* Don't worry. If the image is the same these
1108 * functions will have no performance impact. */
1109 create_logo_image(scr);
1113 } else {
1114 wwarning(_("could not load domain %s from user defaults database"), "WMWindowAttributes");
1117 w_global.domain.window_attr->timestamp = stbuf.st_mtime;
1118 if (shared_dict)
1119 WMReleasePropList(shared_dict);
1122 if (stat(w_global.domain.root_menu->path, &stbuf) >= 0 && w_global.domain.root_menu->timestamp < stbuf.st_mtime) {
1123 dict = WMReadPropListFromFile(w_global.domain.root_menu->path);
1124 if (dict) {
1125 if (!WMIsPLArray(dict) && !WMIsPLString(dict)) {
1126 WMReleasePropList(dict);
1127 dict = NULL;
1128 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
1129 "WMRootMenu", w_global.domain.root_menu->path);
1130 } else {
1131 if (w_global.domain.root_menu->dictionary)
1132 WMReleasePropList(w_global.domain.root_menu->dictionary);
1134 w_global.domain.root_menu->dictionary = dict;
1135 wDefaultsMergeGlobalMenus(w_global.domain.root_menu);
1137 } else {
1138 wwarning(_("could not load domain %s from user defaults database"), "WMRootMenu");
1140 w_global.domain.root_menu->timestamp = stbuf.st_mtime;
1142 #ifndef HAVE_INOTIFY
1143 if (!arg)
1144 WMAddTimerHandler(DEFAULTS_CHECK_INTERVAL, wDefaultsCheckDomains, arg);
1145 #endif
1148 void wReadDefaults(WScreen * scr, WMPropList * new_dict)
1150 WMPropList *plvalue, *old_value;
1151 WDefaultEntry *entry;
1152 unsigned int i;
1153 int update_workspace_back = 0; /* kluge :/ */
1154 unsigned int needs_refresh;
1155 void *tdata;
1156 WMPropList *old_dict = (w_global.domain.wmaker->dictionary != new_dict ? w_global.domain.wmaker->dictionary : NULL);
1158 needs_refresh = 0;
1160 for (i = 0; i < wlengthof(optionList); i++) {
1161 entry = &optionList[i];
1163 if (new_dict)
1164 plvalue = WMGetFromPLDictionary(new_dict, entry->plkey);
1165 else
1166 plvalue = NULL;
1168 if (!old_dict)
1169 old_value = NULL;
1170 else
1171 old_value = WMGetFromPLDictionary(old_dict, entry->plkey);
1173 if (!plvalue && !old_value) {
1174 /* no default in the DB. Use builtin default */
1175 plvalue = entry->plvalue;
1176 if (plvalue && new_dict)
1177 WMPutInPLDictionary(new_dict, entry->plkey, plvalue);
1179 } else if (!plvalue) {
1180 /* value was deleted from DB. Keep current value */
1181 continue;
1182 } else if (!old_value) {
1183 /* set value for the 1st time */
1184 } else if (!WMIsPropListEqualTo(plvalue, old_value)) {
1185 /* value has changed */
1186 } else {
1187 if (strcmp(entry->key, "WorkspaceBack") == 0
1188 && update_workspace_back && scr->flags.backimage_helper_launched) {
1189 } else {
1190 /* value was not changed since last time */
1191 continue;
1195 if (plvalue) {
1196 /* convert data */
1197 if ((*entry->convert) (scr, entry, plvalue, entry->addr, &tdata)) {
1199 * If the WorkspaceSpecificBack data has been changed
1200 * so that the helper will be launched now, we must be
1201 * sure to send the default background texture config
1202 * to the helper.
1204 if (strcmp(entry->key, "WorkspaceSpecificBack") == 0 &&
1205 !scr->flags.backimage_helper_launched)
1206 update_workspace_back = 1;
1208 if (entry->update)
1209 needs_refresh |= (*entry->update) (scr, entry, tdata, entry->extra_data);
1216 * Backward Compatibility:
1217 * Support the old setting names for Apercu, now called Mini-Preview
1219 * This code should probably stay for at least 2 years, you should not consider removing
1220 * it before year 2017
1222 if (legacy_minipreview_config.enable) {
1223 wwarning(_("your configuration is using old syntax for Mini-Preview settings; consider running WPrefs.app to update"));
1224 wPreferences.miniwin_preview_balloon = legacy_minipreview_config.enable;
1226 if (legacy_minipreview_config.size > 0) {
1228 * the option 'ApercuSize' used to be coded as a multiple of the icon size in v0.95.6
1229 * it is now expressed directly in pixels, but to avoid breaking user's setting we check
1230 * for old coding and convert it now.
1232 if (legacy_minipreview_config.size < 24) {
1233 /* 24 is the minimum icon size proposed in WPref's settings */
1234 wPreferences.minipreview_size = legacy_minipreview_config.size * wPreferences.icon_size;
1235 } else {
1236 wPreferences.minipreview_size = legacy_minipreview_config.size;
1241 if (needs_refresh != 0 && !scr->flags.startup) {
1242 int foo;
1244 foo = 0;
1245 if (needs_refresh & REFRESH_MENU_TITLE_TEXTURE)
1246 foo |= WTextureSettings;
1247 if (needs_refresh & REFRESH_MENU_TITLE_FONT)
1248 foo |= WFontSettings;
1249 if (needs_refresh & REFRESH_MENU_TITLE_COLOR)
1250 foo |= WColorSettings;
1251 if (foo)
1252 WMPostNotificationName(WNMenuTitleAppearanceSettingsChanged, NULL,
1253 (void *)(uintptr_t) foo);
1255 foo = 0;
1256 if (needs_refresh & REFRESH_MENU_TEXTURE)
1257 foo |= WTextureSettings;
1258 if (needs_refresh & REFRESH_MENU_FONT)
1259 foo |= WFontSettings;
1260 if (needs_refresh & REFRESH_MENU_COLOR)
1261 foo |= WColorSettings;
1262 if (foo)
1263 WMPostNotificationName(WNMenuAppearanceSettingsChanged, NULL, (void *)(uintptr_t) foo);
1265 foo = 0;
1266 if (needs_refresh & REFRESH_WINDOW_FONT)
1267 foo |= WFontSettings;
1268 if (needs_refresh & REFRESH_WINDOW_TEXTURES)
1269 foo |= WTextureSettings;
1270 if (needs_refresh & REFRESH_WINDOW_TITLE_COLOR)
1271 foo |= WColorSettings;
1272 if (foo)
1273 WMPostNotificationName(WNWindowAppearanceSettingsChanged, NULL, (void *)(uintptr_t) foo);
1275 if (!(needs_refresh & REFRESH_ICON_TILE)) {
1276 foo = 0;
1277 if (needs_refresh & REFRESH_ICON_FONT)
1278 foo |= WFontSettings;
1279 if (needs_refresh & REFRESH_ICON_TITLE_COLOR)
1280 foo |= WTextureSettings;
1281 if (needs_refresh & REFRESH_ICON_TITLE_BACK)
1282 foo |= WTextureSettings;
1283 if (foo)
1284 WMPostNotificationName(WNIconAppearanceSettingsChanged, NULL,
1285 (void *)(uintptr_t) foo);
1287 if (needs_refresh & REFRESH_ICON_TILE)
1288 WMPostNotificationName(WNIconTileSettingsChanged, NULL, NULL);
1290 if (needs_refresh & REFRESH_WORKSPACE_MENU) {
1291 if (scr->workspace_menu)
1292 wWorkspaceMenuUpdate(scr, scr->workspace_menu);
1293 if (scr->clip_ws_menu)
1294 wWorkspaceMenuUpdate(scr, scr->clip_ws_menu);
1295 if (scr->workspace_submenu)
1296 scr->workspace_submenu->flags.realized = 0;
1297 if (scr->clip_submenu)
1298 scr->clip_submenu->flags.realized = 0;
1303 void wDefaultUpdateIcons(WScreen *scr)
1305 WAppIcon *aicon = scr->app_icon_list;
1306 WDrawerChain *dc;
1307 WWindow *wwin = scr->focused_window;
1309 while (aicon) {
1310 /* Get the application icon, default included */
1311 wIconChangeImageFile(aicon->icon, NULL);
1312 wAppIconPaint(aicon);
1313 aicon = aicon->next;
1316 if (!wPreferences.flags.noclip || wPreferences.flags.clip_merged_in_dock)
1317 wClipIconPaint(scr->clip_icon);
1319 for (dc = scr->drawers; dc != NULL; dc = dc->next)
1320 wDrawerIconPaint(dc->adrawer->icon_array[0]);
1322 while (wwin) {
1323 if (wwin->icon && wwin->flags.miniaturized)
1324 wIconChangeImageFile(wwin->icon, NULL);
1325 wwin = wwin->prev;
1329 /* --------------------------- Local ----------------------- */
1331 #define GET_STRING_OR_DEFAULT(x, var) if (!WMIsPLString(value)) { \
1332 wwarning(_("Wrong option format for key \"%s\". Should be %s."), \
1333 entry->key, x); \
1334 wwarning(_("using default \"%s\" instead"), entry->default_value); \
1335 var = entry->default_value;\
1336 } else var = WMGetFromPLString(value)\
1339 static int string2index(WMPropList *key, WMPropList *val, const char *def, WOptionEnumeration * values)
1341 char *str;
1342 WOptionEnumeration *v;
1343 char buffer[TOTAL_VALUES_LENGTH];
1345 if (WMIsPLString(val) && (str = WMGetFromPLString(val))) {
1346 for (v = values; v->string != NULL; v++) {
1347 if (strcasecmp(v->string, str) == 0)
1348 return v->value;
1352 buffer[0] = 0;
1353 for (v = values; v->string != NULL; v++) {
1354 if (!v->is_alias) {
1355 if (buffer[0] != 0)
1356 strcat(buffer, ", ");
1357 snprintf(buffer+strlen(buffer),
1358 sizeof(buffer)-strlen(buffer)-1, "\"%s\"", v->string);
1361 wwarning(_("wrong option value for key \"%s\"; got \"%s\", should be one of %s."),
1362 WMGetFromPLString(key),
1363 WMIsPLString(val) ? WMGetFromPLString(val) : "(unknown)",
1364 buffer);
1366 if (def) {
1367 return string2index(key, val, NULL, values);
1370 return -1;
1374 * value - is the value in the defaults DB
1375 * addr - is the address to store the data
1376 * ret - is the address to store a pointer to a temporary buffer. ret
1377 * must not be freed and is used by the set functions
1379 static int getBool(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1381 static char data;
1382 const char *val;
1383 int second_pass = 0;
1385 /* Parameter not used, but tell the compiler that it is ok */
1386 (void) scr;
1388 GET_STRING_OR_DEFAULT("Boolean", val);
1390 again:
1391 if ((val[1] == '\0' && (val[0] == 'y' || val[0] == 'Y'))
1392 || strcasecmp(val, "YES") == 0) {
1394 data = 1;
1395 } else if ((val[1] == '\0' && (val[0] == 'n' || val[0] == 'N'))
1396 || strcasecmp(val, "NO") == 0) {
1397 data = 0;
1398 } else {
1399 int i;
1400 if (sscanf(val, "%i", &i) == 1) {
1401 if (i != 0)
1402 data = 1;
1403 else
1404 data = 0;
1405 } else {
1406 wwarning(_("can't convert \"%s\" to boolean for key \"%s\""), val, entry->key);
1407 if (second_pass == 0) {
1408 val = WMGetFromPLString(entry->plvalue);
1409 second_pass = 1;
1410 wwarning(_("using default \"%s\" instead"), val);
1411 goto again;
1413 return False;
1417 if (ret)
1418 *ret = &data;
1419 if (addr)
1420 *(char *)addr = data;
1422 return True;
1425 static int getInt(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1427 static int data;
1428 const char *val;
1430 /* Parameter not used, but tell the compiler that it is ok */
1431 (void) scr;
1433 GET_STRING_OR_DEFAULT("Integer", val);
1435 if (sscanf(val, "%i", &data) != 1) {
1436 wwarning(_("can't convert \"%s\" to integer for key \"%s\""), val, entry->key);
1437 val = WMGetFromPLString(entry->plvalue);
1438 wwarning(_("using default \"%s\" instead"), val);
1439 if (sscanf(val, "%i", &data) != 1) {
1440 return False;
1444 if (ret)
1445 *ret = &data;
1446 if (addr)
1447 *(int *)addr = data;
1449 return True;
1452 static int getCoord(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1454 static WCoord data;
1455 char *val_x, *val_y;
1456 int nelem, changed = 0;
1457 WMPropList *elem_x, *elem_y;
1459 again:
1460 if (!WMIsPLArray(value)) {
1461 wwarning(_("Wrong option format for key \"%s\". Should be %s."), entry->key, "Coordinate");
1462 if (changed == 0) {
1463 value = entry->plvalue;
1464 changed = 1;
1465 wwarning(_("using default \"%s\" instead"), entry->default_value);
1466 goto again;
1468 return False;
1471 nelem = WMGetPropListItemCount(value);
1472 if (nelem != 2) {
1473 wwarning(_("Incorrect number of elements in array for key \"%s\"."), entry->key);
1474 if (changed == 0) {
1475 value = entry->plvalue;
1476 changed = 1;
1477 wwarning(_("using default \"%s\" instead"), entry->default_value);
1478 goto again;
1480 return False;
1483 elem_x = WMGetFromPLArray(value, 0);
1484 elem_y = WMGetFromPLArray(value, 1);
1486 if (!elem_x || !elem_y || !WMIsPLString(elem_x) || !WMIsPLString(elem_y)) {
1487 wwarning(_("Wrong value for key \"%s\". Should be Coordinate."), entry->key);
1488 if (changed == 0) {
1489 value = entry->plvalue;
1490 changed = 1;
1491 wwarning(_("using default \"%s\" instead"), entry->default_value);
1492 goto again;
1494 return False;
1497 val_x = WMGetFromPLString(elem_x);
1498 val_y = WMGetFromPLString(elem_y);
1500 if (sscanf(val_x, "%i", &data.x) != 1 || sscanf(val_y, "%i", &data.y) != 1) {
1501 wwarning(_("can't convert array to integers for \"%s\"."), entry->key);
1502 if (changed == 0) {
1503 value = entry->plvalue;
1504 changed = 1;
1505 wwarning(_("using default \"%s\" instead"), entry->default_value);
1506 goto again;
1508 return False;
1511 if (data.x < 0)
1512 data.x = 0;
1513 else if (data.x > scr->scr_width / 3)
1514 data.x = scr->scr_width / 3;
1515 if (data.y < 0)
1516 data.y = 0;
1517 else if (data.y > scr->scr_height / 3)
1518 data.y = scr->scr_height / 3;
1520 if (ret)
1521 *ret = &data;
1522 if (addr)
1523 *(WCoord *) addr = data;
1525 return True;
1528 static int getPropList(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1530 /* Parameter not used, but tell the compiler that it is ok */
1531 (void) scr;
1532 (void) entry;
1533 (void) addr;
1535 WMRetainPropList(value);
1537 *ret = value;
1539 return True;
1542 static int getPathList(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1544 static char *data;
1545 int i, count, len;
1546 char *ptr;
1547 WMPropList *d;
1548 int changed = 0;
1550 /* Parameter not used, but tell the compiler that it is ok */
1551 (void) scr;
1552 (void) ret;
1554 again:
1555 if (!WMIsPLArray(value)) {
1556 wwarning(_("Wrong option format for key \"%s\". Should be %s."), entry->key, "an array of paths");
1557 if (changed == 0) {
1558 value = entry->plvalue;
1559 changed = 1;
1560 wwarning(_("using default \"%s\" instead"), entry->default_value);
1561 goto again;
1563 return False;
1566 i = 0;
1567 count = WMGetPropListItemCount(value);
1568 if (count < 1) {
1569 if (changed == 0) {
1570 value = entry->plvalue;
1571 changed = 1;
1572 wwarning(_("using default \"%s\" instead"), entry->default_value);
1573 goto again;
1575 return False;
1578 len = 0;
1579 for (i = 0; i < count; i++) {
1580 d = WMGetFromPLArray(value, i);
1581 if (!d || !WMIsPLString(d)) {
1582 count = i;
1583 break;
1585 len += strlen(WMGetFromPLString(d)) + 1;
1588 ptr = data = wmalloc(len + 1);
1590 for (i = 0; i < count; i++) {
1591 d = WMGetFromPLArray(value, i);
1592 if (!d || !WMIsPLString(d)) {
1593 break;
1595 strcpy(ptr, WMGetFromPLString(d));
1596 ptr += strlen(WMGetFromPLString(d));
1597 *ptr = ':';
1598 ptr++;
1600 ptr--;
1601 *(ptr--) = 0;
1603 if (*(char **)addr != NULL) {
1604 wfree(*(char **)addr);
1606 *(char **)addr = data;
1608 return True;
1611 static int getEnum(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1613 static signed char data;
1615 /* Parameter not used, but tell the compiler that it is ok */
1616 (void) scr;
1618 data = string2index(entry->plkey, value, entry->default_value, (WOptionEnumeration *) entry->extra_data);
1619 if (data < 0)
1620 return False;
1622 if (ret)
1623 *ret = &data;
1624 if (addr)
1625 *(signed char *)addr = data;
1627 return True;
1631 * (solid <color>)
1632 * (hgradient <color> <color>)
1633 * (vgradient <color> <color>)
1634 * (dgradient <color> <color>)
1635 * (mhgradient <color> <color> ...)
1636 * (mvgradient <color> <color> ...)
1637 * (mdgradient <color> <color> ...)
1638 * (igradient <color1> <color1> <thickness1> <color2> <color2> <thickness2>)
1639 * (tpixmap <file> <color>)
1640 * (spixmap <file> <color>)
1641 * (cpixmap <file> <color>)
1642 * (thgradient <file> <opaqueness> <color> <color>)
1643 * (tvgradient <file> <opaqueness> <color> <color>)
1644 * (tdgradient <file> <opaqueness> <color> <color>)
1645 * (function <lib> <function> ...)
1648 static WTexture *parse_texture(WScreen * scr, WMPropList * pl)
1650 WMPropList *elem;
1651 char *val;
1652 int nelem;
1653 WTexture *texture = NULL;
1655 nelem = WMGetPropListItemCount(pl);
1656 if (nelem < 1)
1657 return NULL;
1659 elem = WMGetFromPLArray(pl, 0);
1660 if (!elem || !WMIsPLString(elem))
1661 return NULL;
1662 val = WMGetFromPLString(elem);
1664 if (strcasecmp(val, "solid") == 0) {
1665 XColor color;
1667 if (nelem != 2)
1668 return NULL;
1670 /* get color */
1672 elem = WMGetFromPLArray(pl, 1);
1673 if (!elem || !WMIsPLString(elem))
1674 return NULL;
1675 val = WMGetFromPLString(elem);
1677 if (!XParseColor(dpy, scr->w_colormap, val, &color)) {
1678 wwarning(_("\"%s\" is not a valid color name"), val);
1679 return NULL;
1682 texture = (WTexture *) wTextureMakeSolid(scr, &color);
1683 } else if (strcasecmp(val, "dgradient") == 0
1684 || strcasecmp(val, "vgradient") == 0 || strcasecmp(val, "hgradient") == 0) {
1685 RColor color1, color2;
1686 XColor xcolor;
1687 int type;
1689 if (nelem != 3) {
1690 wwarning(_("bad number of arguments in gradient specification"));
1691 return NULL;
1694 if (val[0] == 'd' || val[0] == 'D')
1695 type = WTEX_DGRADIENT;
1696 else if (val[0] == 'h' || val[0] == 'H')
1697 type = WTEX_HGRADIENT;
1698 else
1699 type = WTEX_VGRADIENT;
1701 /* get from color */
1702 elem = WMGetFromPLArray(pl, 1);
1703 if (!elem || !WMIsPLString(elem))
1704 return NULL;
1705 val = WMGetFromPLString(elem);
1707 if (!XParseColor(dpy, scr->w_colormap, val, &xcolor)) {
1708 wwarning(_("\"%s\" is not a valid color name"), val);
1709 return NULL;
1711 color1.alpha = 255;
1712 color1.red = xcolor.red >> 8;
1713 color1.green = xcolor.green >> 8;
1714 color1.blue = xcolor.blue >> 8;
1716 /* get to color */
1717 elem = WMGetFromPLArray(pl, 2);
1718 if (!elem || !WMIsPLString(elem)) {
1719 return NULL;
1721 val = WMGetFromPLString(elem);
1723 if (!XParseColor(dpy, scr->w_colormap, val, &xcolor)) {
1724 wwarning(_("\"%s\" is not a valid color name"), val);
1725 return NULL;
1727 color2.alpha = 255;
1728 color2.red = xcolor.red >> 8;
1729 color2.green = xcolor.green >> 8;
1730 color2.blue = xcolor.blue >> 8;
1732 texture = (WTexture *) wTextureMakeGradient(scr, type, &color1, &color2);
1734 } else if (strcasecmp(val, "igradient") == 0) {
1735 RColor colors1[2], colors2[2];
1736 int th1, th2;
1737 XColor xcolor;
1738 int i;
1740 if (nelem != 7) {
1741 wwarning(_("bad number of arguments in gradient specification"));
1742 return NULL;
1745 /* get from color */
1746 for (i = 0; i < 2; i++) {
1747 elem = WMGetFromPLArray(pl, 1 + i);
1748 if (!elem || !WMIsPLString(elem))
1749 return NULL;
1750 val = WMGetFromPLString(elem);
1752 if (!XParseColor(dpy, scr->w_colormap, val, &xcolor)) {
1753 wwarning(_("\"%s\" is not a valid color name"), val);
1754 return NULL;
1756 colors1[i].alpha = 255;
1757 colors1[i].red = xcolor.red >> 8;
1758 colors1[i].green = xcolor.green >> 8;
1759 colors1[i].blue = xcolor.blue >> 8;
1761 elem = WMGetFromPLArray(pl, 3);
1762 if (!elem || !WMIsPLString(elem))
1763 return NULL;
1764 val = WMGetFromPLString(elem);
1765 th1 = atoi(val);
1767 /* get from color */
1768 for (i = 0; i < 2; i++) {
1769 elem = WMGetFromPLArray(pl, 4 + i);
1770 if (!elem || !WMIsPLString(elem))
1771 return NULL;
1772 val = WMGetFromPLString(elem);
1774 if (!XParseColor(dpy, scr->w_colormap, val, &xcolor)) {
1775 wwarning(_("\"%s\" is not a valid color name"), val);
1776 return NULL;
1778 colors2[i].alpha = 255;
1779 colors2[i].red = xcolor.red >> 8;
1780 colors2[i].green = xcolor.green >> 8;
1781 colors2[i].blue = xcolor.blue >> 8;
1783 elem = WMGetFromPLArray(pl, 6);
1784 if (!elem || !WMIsPLString(elem))
1785 return NULL;
1786 val = WMGetFromPLString(elem);
1787 th2 = atoi(val);
1789 texture = (WTexture *) wTextureMakeIGradient(scr, th1, colors1, th2, colors2);
1791 } else if (strcasecmp(val, "mhgradient") == 0
1792 || strcasecmp(val, "mvgradient") == 0 || strcasecmp(val, "mdgradient") == 0) {
1793 XColor color;
1794 RColor **colors;
1795 int i, count;
1796 int type;
1798 if (nelem < 3) {
1799 wwarning(_("too few arguments in multicolor gradient specification"));
1800 return NULL;
1803 if (val[1] == 'h' || val[1] == 'H')
1804 type = WTEX_MHGRADIENT;
1805 else if (val[1] == 'v' || val[1] == 'V')
1806 type = WTEX_MVGRADIENT;
1807 else
1808 type = WTEX_MDGRADIENT;
1810 count = nelem - 1;
1812 colors = wmalloc(sizeof(RColor *) * (count + 1));
1814 for (i = 0; i < count; i++) {
1815 elem = WMGetFromPLArray(pl, i + 1);
1816 if (!elem || !WMIsPLString(elem)) {
1817 for (--i; i >= 0; --i) {
1818 wfree(colors[i]);
1820 wfree(colors);
1821 return NULL;
1823 val = WMGetFromPLString(elem);
1825 if (!XParseColor(dpy, scr->w_colormap, val, &color)) {
1826 wwarning(_("\"%s\" is not a valid color name"), val);
1827 for (--i; i >= 0; --i) {
1828 wfree(colors[i]);
1830 wfree(colors);
1831 return NULL;
1832 } else {
1833 colors[i] = wmalloc(sizeof(RColor));
1834 colors[i]->red = color.red >> 8;
1835 colors[i]->green = color.green >> 8;
1836 colors[i]->blue = color.blue >> 8;
1839 colors[i] = NULL;
1841 texture = (WTexture *) wTextureMakeMGradient(scr, type, colors);
1842 } else if (strcasecmp(val, "spixmap") == 0 ||
1843 strcasecmp(val, "cpixmap") == 0 || strcasecmp(val, "tpixmap") == 0) {
1844 XColor color;
1845 int type;
1847 if (nelem != 3)
1848 return NULL;
1850 if (val[0] == 's' || val[0] == 'S')
1851 type = WTP_SCALE;
1852 else if (val[0] == 'c' || val[0] == 'C')
1853 type = WTP_CENTER;
1854 else
1855 type = WTP_TILE;
1857 /* get color */
1858 elem = WMGetFromPLArray(pl, 2);
1859 if (!elem || !WMIsPLString(elem)) {
1860 return NULL;
1862 val = WMGetFromPLString(elem);
1864 if (!XParseColor(dpy, scr->w_colormap, val, &color)) {
1865 wwarning(_("\"%s\" is not a valid color name"), val);
1866 return NULL;
1869 /* file name */
1870 elem = WMGetFromPLArray(pl, 1);
1871 if (!elem || !WMIsPLString(elem))
1872 return NULL;
1873 val = WMGetFromPLString(elem);
1875 texture = (WTexture *) wTextureMakePixmap(scr, type, val, &color);
1876 } else if (strcasecmp(val, "thgradient") == 0
1877 || strcasecmp(val, "tvgradient") == 0 || strcasecmp(val, "tdgradient") == 0) {
1878 RColor color1, color2;
1879 XColor xcolor;
1880 int opacity;
1881 int style;
1883 if (val[1] == 'h' || val[1] == 'H')
1884 style = WTEX_THGRADIENT;
1885 else if (val[1] == 'v' || val[1] == 'V')
1886 style = WTEX_TVGRADIENT;
1887 else
1888 style = WTEX_TDGRADIENT;
1890 if (nelem != 5) {
1891 wwarning(_("bad number of arguments in textured gradient specification"));
1892 return NULL;
1895 /* get from color */
1896 elem = WMGetFromPLArray(pl, 3);
1897 if (!elem || !WMIsPLString(elem))
1898 return NULL;
1899 val = WMGetFromPLString(elem);
1901 if (!XParseColor(dpy, scr->w_colormap, val, &xcolor)) {
1902 wwarning(_("\"%s\" is not a valid color name"), val);
1903 return NULL;
1905 color1.alpha = 255;
1906 color1.red = xcolor.red >> 8;
1907 color1.green = xcolor.green >> 8;
1908 color1.blue = xcolor.blue >> 8;
1910 /* get to color */
1911 elem = WMGetFromPLArray(pl, 4);
1912 if (!elem || !WMIsPLString(elem)) {
1913 return NULL;
1915 val = WMGetFromPLString(elem);
1917 if (!XParseColor(dpy, scr->w_colormap, val, &xcolor)) {
1918 wwarning(_("\"%s\" is not a valid color name"), val);
1919 return NULL;
1921 color2.alpha = 255;
1922 color2.red = xcolor.red >> 8;
1923 color2.green = xcolor.green >> 8;
1924 color2.blue = xcolor.blue >> 8;
1926 /* get opacity */
1927 elem = WMGetFromPLArray(pl, 2);
1928 if (!elem || !WMIsPLString(elem))
1929 opacity = 128;
1930 else
1931 val = WMGetFromPLString(elem);
1933 if (!val || (opacity = atoi(val)) < 0 || opacity > 255) {
1934 wwarning(_("bad opacity value for tgradient texture \"%s\". Should be [0..255]"), val);
1935 opacity = 128;
1938 /* get file name */
1939 elem = WMGetFromPLArray(pl, 1);
1940 if (!elem || !WMIsPLString(elem))
1941 return NULL;
1942 val = WMGetFromPLString(elem);
1944 texture = (WTexture *) wTextureMakeTGradient(scr, style, &color1, &color2, val, opacity);
1945 } else if (strcasecmp(val, "function") == 0) {
1946 /* Leave this in to handle the unlikely case of
1947 * someone actually having function textures configured */
1948 wwarning("function texture support has been removed");
1949 return NULL;
1950 } else {
1951 wwarning(_("invalid texture type %s"), val);
1952 return NULL;
1954 return texture;
1957 static int getTexture(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1959 static WTexture *texture;
1960 int changed = 0;
1962 again:
1963 if (!WMIsPLArray(value)) {
1964 wwarning(_("Wrong option format for key \"%s\". Should be %s."), entry->key, "Texture");
1965 if (changed == 0) {
1966 value = entry->plvalue;
1967 changed = 1;
1968 wwarning(_("using default \"%s\" instead"), entry->default_value);
1969 goto again;
1971 return False;
1974 if (strcmp(entry->key, "WidgetColor") == 0 && !changed) {
1975 WMPropList *pl;
1977 pl = WMGetFromPLArray(value, 0);
1978 if (!pl || !WMIsPLString(pl) || !WMGetFromPLString(pl)
1979 || strcasecmp(WMGetFromPLString(pl), "solid") != 0) {
1980 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1981 entry->key, "Solid Texture");
1983 value = entry->plvalue;
1984 changed = 1;
1985 wwarning(_("using default \"%s\" instead"), entry->default_value);
1986 goto again;
1990 texture = parse_texture(scr, value);
1992 if (!texture) {
1993 wwarning(_("Error in texture specification for key \"%s\""), entry->key);
1994 if (changed == 0) {
1995 value = entry->plvalue;
1996 changed = 1;
1997 wwarning(_("using default \"%s\" instead"), entry->default_value);
1998 goto again;
2000 return False;
2003 if (ret)
2004 *ret = &texture;
2006 if (addr)
2007 *(WTexture **) addr = texture;
2009 return True;
2012 static int getWSBackground(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
2014 WMPropList *elem;
2015 int changed = 0;
2016 char *val;
2017 int nelem;
2019 /* Parameter not used, but tell the compiler that it is ok */
2020 (void) scr;
2021 (void) addr;
2023 again:
2024 if (!WMIsPLArray(value)) {
2025 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
2026 "WorkspaceBack", "Texture or None");
2027 if (changed == 0) {
2028 value = entry->plvalue;
2029 changed = 1;
2030 wwarning(_("using default \"%s\" instead"), entry->default_value);
2031 goto again;
2033 return False;
2036 /* only do basic error checking and verify for None texture */
2038 nelem = WMGetPropListItemCount(value);
2039 if (nelem > 0) {
2040 elem = WMGetFromPLArray(value, 0);
2041 if (!elem || !WMIsPLString(elem)) {
2042 wwarning(_("Wrong type for workspace background. Should be a texture type."));
2043 if (changed == 0) {
2044 value = entry->plvalue;
2045 changed = 1;
2046 wwarning(_("using default \"%s\" instead"), entry->default_value);
2047 goto again;
2049 return False;
2051 val = WMGetFromPLString(elem);
2053 if (strcasecmp(val, "None") == 0)
2054 return True;
2056 *ret = WMRetainPropList(value);
2058 return True;
2061 static int
2062 getWSSpecificBackground(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
2064 WMPropList *elem;
2065 int nelem;
2066 int changed = 0;
2068 /* Parameter not used, but tell the compiler that it is ok */
2069 (void) scr;
2070 (void) addr;
2072 again:
2073 if (!WMIsPLArray(value)) {
2074 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
2075 "WorkspaceSpecificBack", "an array of textures");
2076 if (changed == 0) {
2077 value = entry->plvalue;
2078 changed = 1;
2079 wwarning(_("using default \"%s\" instead"), entry->default_value);
2080 goto again;
2082 return False;
2085 /* only do basic error checking and verify for None texture */
2087 nelem = WMGetPropListItemCount(value);
2088 if (nelem > 0) {
2089 while (nelem--) {
2090 elem = WMGetFromPLArray(value, nelem);
2091 if (!elem || !WMIsPLArray(elem)) {
2092 wwarning(_("Wrong type for background of workspace %i. Should be a texture."),
2093 nelem);
2098 *ret = WMRetainPropList(value);
2100 #ifdef notworking
2102 * Kluge to force wmsetbg helper to set the default background.
2103 * If the WorkspaceSpecificBack is changed once wmaker has started,
2104 * the WorkspaceBack won't be sent to the helper, unless the user
2105 * changes it's value too. So, we must force this by removing the
2106 * value from the defaults DB.
2108 if (!scr->flags.backimage_helper_launched && !scr->flags.startup) {
2109 WMPropList *key = WMCreatePLString("WorkspaceBack");
2111 WMRemoveFromPLDictionary(w_global.domain.wmaker->dictionary, key);
2113 WMReleasePropList(key);
2115 #endif
2116 return True;
2119 static int getFont(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
2121 static WMFont *font;
2122 const char *val;
2124 (void) addr;
2126 GET_STRING_OR_DEFAULT("Font", val);
2128 font = WMCreateFont(scr->wmscreen, val);
2129 if (!font)
2130 font = WMCreateFont(scr->wmscreen, "fixed");
2132 if (!font) {
2133 wfatal(_("could not load any usable font!!!"));
2134 exit(1);
2137 if (ret)
2138 *ret = font;
2140 /* can't assign font value outside update function */
2141 wassertrv(addr == NULL, True);
2143 return True;
2146 static int getColor(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
2148 static XColor color;
2149 const char *val;
2150 int second_pass = 0;
2152 (void) addr;
2154 GET_STRING_OR_DEFAULT("Color", val);
2156 again:
2157 if (!wGetColor(scr, val, &color)) {
2158 wwarning(_("could not get color for key \"%s\""), entry->key);
2159 if (second_pass == 0) {
2160 val = WMGetFromPLString(entry->plvalue);
2161 second_pass = 1;
2162 wwarning(_("using default \"%s\" instead"), val);
2163 goto again;
2165 return False;
2168 if (ret)
2169 *ret = &color;
2171 assert(addr == NULL);
2173 if (addr)
2174 *(unsigned long*)addr = pixel;
2177 return True;
2180 static int getKeybind(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
2182 static WShortKey shortcut;
2183 KeySym ksym;
2184 const char *val;
2185 char *k;
2186 char buf[MAX_SHORTCUT_LENGTH], *b;
2188 /* Parameter not used, but tell the compiler that it is ok */
2189 (void) scr;
2190 (void) addr;
2192 GET_STRING_OR_DEFAULT("Key spec", val);
2194 if (!val || strcasecmp(val, "NONE") == 0) {
2195 shortcut.keycode = 0;
2196 shortcut.modifier = 0;
2197 if (ret)
2198 *ret = &shortcut;
2199 return True;
2202 wstrlcpy(buf, val, MAX_SHORTCUT_LENGTH);
2204 b = (char *)buf;
2206 /* get modifiers */
2207 shortcut.modifier = 0;
2208 while ((k = strchr(b, '+')) != NULL) {
2209 int mod;
2211 *k = 0;
2212 mod = wXModifierFromKey(b);
2213 if (mod < 0) {
2214 wwarning(_("%s: invalid key modifier \"%s\""), entry->key, b);
2215 return False;
2217 shortcut.modifier |= mod;
2219 b = k + 1;
2222 /* get key */
2223 ksym = XStringToKeysym(b);
2225 if (ksym == NoSymbol) {
2226 wwarning(_("%s:invalid kbd shortcut specification \"%s\""), entry->key, val);
2227 return False;
2230 shortcut.keycode = XKeysymToKeycode(dpy, ksym);
2231 if (shortcut.keycode == 0) {
2232 wwarning(_("%s:invalid key in shortcut \"%s\""), entry->key, val);
2233 return False;
2236 if (ret)
2237 *ret = &shortcut;
2239 return True;
2242 static int getModMask(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
2244 static int mask;
2245 const char *str;
2247 /* Parameter not used, but tell the compiler that it is ok */
2248 (void) scr;
2250 GET_STRING_OR_DEFAULT("Modifier Key", str);
2252 if (!str)
2253 return False;
2255 mask = wXModifierFromKey(str);
2256 if (mask < 0) {
2257 wwarning(_("%s: modifier key %s is not valid"), entry->key, str);
2258 mask = 0;
2259 return False;
2262 if (addr)
2263 *(int *)addr = mask;
2265 if (ret)
2266 *ret = &mask;
2268 return True;
2271 # include <X11/cursorfont.h>
2272 typedef struct {
2273 const char *name;
2274 int id;
2275 } WCursorLookup;
2277 #define CURSOR_ID_NONE (XC_num_glyphs)
2279 static const WCursorLookup cursor_table[] = {
2280 {"X_cursor", XC_X_cursor},
2281 {"arrow", XC_arrow},
2282 {"based_arrow_down", XC_based_arrow_down},
2283 {"based_arrow_up", XC_based_arrow_up},
2284 {"boat", XC_boat},
2285 {"bogosity", XC_bogosity},
2286 {"bottom_left_corner", XC_bottom_left_corner},
2287 {"bottom_right_corner", XC_bottom_right_corner},
2288 {"bottom_side", XC_bottom_side},
2289 {"bottom_tee", XC_bottom_tee},
2290 {"box_spiral", XC_box_spiral},
2291 {"center_ptr", XC_center_ptr},
2292 {"circle", XC_circle},
2293 {"clock", XC_clock},
2294 {"coffee_mug", XC_coffee_mug},
2295 {"cross", XC_cross},
2296 {"cross_reverse", XC_cross_reverse},
2297 {"crosshair", XC_crosshair},
2298 {"diamond_cross", XC_diamond_cross},
2299 {"dot", XC_dot},
2300 {"dotbox", XC_dotbox},
2301 {"double_arrow", XC_double_arrow},
2302 {"draft_large", XC_draft_large},
2303 {"draft_small", XC_draft_small},
2304 {"draped_box", XC_draped_box},
2305 {"exchange", XC_exchange},
2306 {"fleur", XC_fleur},
2307 {"gobbler", XC_gobbler},
2308 {"gumby", XC_gumby},
2309 {"hand1", XC_hand1},
2310 {"hand2", XC_hand2},
2311 {"heart", XC_heart},
2312 {"icon", XC_icon},
2313 {"iron_cross", XC_iron_cross},
2314 {"left_ptr", XC_left_ptr},
2315 {"left_side", XC_left_side},
2316 {"left_tee", XC_left_tee},
2317 {"leftbutton", XC_leftbutton},
2318 {"ll_angle", XC_ll_angle},
2319 {"lr_angle", XC_lr_angle},
2320 {"man", XC_man},
2321 {"middlebutton", XC_middlebutton},
2322 {"mouse", XC_mouse},
2323 {"pencil", XC_pencil},
2324 {"pirate", XC_pirate},
2325 {"plus", XC_plus},
2326 {"question_arrow", XC_question_arrow},
2327 {"right_ptr", XC_right_ptr},
2328 {"right_side", XC_right_side},
2329 {"right_tee", XC_right_tee},
2330 {"rightbutton", XC_rightbutton},
2331 {"rtl_logo", XC_rtl_logo},
2332 {"sailboat", XC_sailboat},
2333 {"sb_down_arrow", XC_sb_down_arrow},
2334 {"sb_h_double_arrow", XC_sb_h_double_arrow},
2335 {"sb_left_arrow", XC_sb_left_arrow},
2336 {"sb_right_arrow", XC_sb_right_arrow},
2337 {"sb_up_arrow", XC_sb_up_arrow},
2338 {"sb_v_double_arrow", XC_sb_v_double_arrow},
2339 {"shuttle", XC_shuttle},
2340 {"sizing", XC_sizing},
2341 {"spider", XC_spider},
2342 {"spraycan", XC_spraycan},
2343 {"star", XC_star},
2344 {"target", XC_target},
2345 {"tcross", XC_tcross},
2346 {"top_left_arrow", XC_top_left_arrow},
2347 {"top_left_corner", XC_top_left_corner},
2348 {"top_right_corner", XC_top_right_corner},
2349 {"top_side", XC_top_side},
2350 {"top_tee", XC_top_tee},
2351 {"trek", XC_trek},
2352 {"ul_angle", XC_ul_angle},
2353 {"umbrella", XC_umbrella},
2354 {"ur_angle", XC_ur_angle},
2355 {"watch", XC_watch},
2356 {"xterm", XC_xterm},
2357 {NULL, CURSOR_ID_NONE}
2360 static void check_bitmap_status(int status, const char *filename, Pixmap bitmap)
2362 switch (status) {
2363 case BitmapOpenFailed:
2364 wwarning(_("failed to open bitmap file \"%s\""), filename);
2365 break;
2366 case BitmapFileInvalid:
2367 wwarning(_("\"%s\" is not a valid bitmap file"), filename);
2368 break;
2369 case BitmapNoMemory:
2370 wwarning(_("out of memory reading bitmap file \"%s\""), filename);
2371 break;
2372 case BitmapSuccess:
2373 XFreePixmap(dpy, bitmap);
2374 break;
2379 * (none)
2380 * (builtin, <cursor_name>)
2381 * (bitmap, <cursor_bitmap>, <cursor_mask>)
2383 static int parse_cursor(WScreen * scr, WMPropList * pl, Cursor * cursor)
2385 WMPropList *elem;
2386 char *val;
2387 int nelem;
2388 int status = 0;
2390 nelem = WMGetPropListItemCount(pl);
2391 if (nelem < 1) {
2392 return (status);
2394 elem = WMGetFromPLArray(pl, 0);
2395 if (!elem || !WMIsPLString(elem)) {
2396 return (status);
2398 val = WMGetFromPLString(elem);
2400 if (strcasecmp(val, "none") == 0) {
2401 status = 1;
2402 *cursor = None;
2403 } else if (strcasecmp(val, "builtin") == 0) {
2404 int i;
2405 int cursor_id = CURSOR_ID_NONE;
2407 if (nelem != 2) {
2408 wwarning(_("bad number of arguments in cursor specification"));
2409 return (status);
2411 elem = WMGetFromPLArray(pl, 1);
2412 if (!elem || !WMIsPLString(elem)) {
2413 return (status);
2415 val = WMGetFromPLString(elem);
2417 for (i = 0; cursor_table[i].name != NULL; i++) {
2418 if (strcasecmp(val, cursor_table[i].name) == 0) {
2419 cursor_id = cursor_table[i].id;
2420 break;
2423 if (CURSOR_ID_NONE == cursor_id) {
2424 wwarning(_("unknown builtin cursor name \"%s\""), val);
2425 } else {
2426 *cursor = XCreateFontCursor(dpy, cursor_id);
2427 status = 1;
2429 } else if (strcasecmp(val, "bitmap") == 0) {
2430 char *bitmap_name;
2431 char *mask_name;
2432 int bitmap_status;
2433 int mask_status;
2434 Pixmap bitmap;
2435 Pixmap mask;
2436 unsigned int w, h;
2437 int x, y;
2438 XColor fg, bg;
2440 if (nelem != 3) {
2441 wwarning(_("bad number of arguments in cursor specification"));
2442 return (status);
2444 elem = WMGetFromPLArray(pl, 1);
2445 if (!elem || !WMIsPLString(elem)) {
2446 return (status);
2448 val = WMGetFromPLString(elem);
2449 bitmap_name = FindImage(wPreferences.pixmap_path, val);
2450 if (!bitmap_name) {
2451 wwarning(_("could not find cursor bitmap file \"%s\""), val);
2452 return (status);
2454 elem = WMGetFromPLArray(pl, 2);
2455 if (!elem || !WMIsPLString(elem)) {
2456 wfree(bitmap_name);
2457 return (status);
2459 val = WMGetFromPLString(elem);
2460 mask_name = FindImage(wPreferences.pixmap_path, val);
2461 if (!mask_name) {
2462 wfree(bitmap_name);
2463 wwarning(_("could not find cursor bitmap file \"%s\""), val);
2464 return (status);
2466 mask_status = XReadBitmapFile(dpy, scr->w_win, mask_name, &w, &h, &mask, &x, &y);
2467 bitmap_status = XReadBitmapFile(dpy, scr->w_win, bitmap_name, &w, &h, &bitmap, &x, &y);
2468 if ((BitmapSuccess == bitmap_status) && (BitmapSuccess == mask_status)) {
2469 fg.pixel = scr->black_pixel;
2470 bg.pixel = scr->white_pixel;
2471 XQueryColor(dpy, scr->w_colormap, &fg);
2472 XQueryColor(dpy, scr->w_colormap, &bg);
2473 *cursor = XCreatePixmapCursor(dpy, bitmap, mask, &fg, &bg, x, y);
2474 status = 1;
2476 check_bitmap_status(bitmap_status, bitmap_name, bitmap);
2477 check_bitmap_status(mask_status, mask_name, mask);
2478 wfree(bitmap_name);
2479 wfree(mask_name);
2481 return (status);
2484 static int getCursor(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
2486 static Cursor cursor;
2487 int status;
2488 int changed = 0;
2490 again:
2491 if (!WMIsPLArray(value)) {
2492 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
2493 entry->key, "cursor specification");
2494 if (!changed) {
2495 value = entry->plvalue;
2496 changed = 1;
2497 wwarning(_("using default \"%s\" instead"), entry->default_value);
2498 goto again;
2500 return (False);
2502 status = parse_cursor(scr, value, &cursor);
2503 if (!status) {
2504 wwarning(_("Error in cursor specification for key \"%s\""), entry->key);
2505 if (!changed) {
2506 value = entry->plvalue;
2507 changed = 1;
2508 wwarning(_("using default \"%s\" instead"), entry->default_value);
2509 goto again;
2511 return (False);
2513 if (ret) {
2514 *ret = &cursor;
2516 if (addr) {
2517 *(Cursor *) addr = cursor;
2519 return (True);
2522 #undef CURSOR_ID_NONE
2524 /* ---------------- value setting functions --------------- */
2525 static int setJustify(WScreen * scr, WDefaultEntry * entry, void *tdata, void *extra_data)
2527 /* Parameter not used, but tell the compiler that it is ok */
2528 (void) scr;
2529 (void) entry;
2530 (void) tdata;
2531 (void) extra_data;
2533 return REFRESH_WINDOW_TITLE_COLOR;
2536 static int setClearance(WScreen * scr, WDefaultEntry * entry, void *bar, void *foo)
2538 /* Parameter not used, but tell the compiler that it is ok */
2539 (void) scr;
2540 (void) entry;
2541 (void) bar;
2542 (void) foo;
2544 return REFRESH_WINDOW_FONT | REFRESH_BUTTON_IMAGES | REFRESH_MENU_TITLE_FONT | REFRESH_MENU_FONT;
2547 static int setIfDockPresent(WScreen * scr, WDefaultEntry * entry, void *tdata, void *extra_data)
2549 char *flag = tdata;
2550 long which = (long) extra_data;
2552 /* Parameter not used, but tell the compiler that it is ok */
2553 (void) scr;
2554 (void) entry;
2556 switch (which) {
2557 case WM_DOCK:
2558 wPreferences.flags.nodock = wPreferences.flags.nodock || *flag;
2559 // Drawers require the dock
2560 wPreferences.flags.nodrawer = wPreferences.flags.nodrawer || wPreferences.flags.nodock;
2561 break;
2562 case WM_CLIP:
2563 wPreferences.flags.noclip = wPreferences.flags.noclip || *flag;
2564 break;
2565 case WM_DRAWER:
2566 wPreferences.flags.nodrawer = wPreferences.flags.nodrawer || *flag;
2567 break;
2568 default:
2569 break;
2571 return 0;
2574 static int setClipMergedInDock(WScreen *scr, WDefaultEntry *entry, void *tdata, void *foo)
2576 char *flag = tdata;
2578 /* Parameter not used, but tell the compiler that it is ok */
2579 (void) scr;
2580 (void) entry;
2581 (void) foo;
2583 wPreferences.flags.clip_merged_in_dock = *flag;
2584 wPreferences.flags.noclip = wPreferences.flags.noclip || *flag;
2585 return 0;
2588 static int setWrapAppiconsInDock(WScreen *scr, WDefaultEntry *entry, void *tdata, void *foo)
2590 char *flag = tdata;
2592 /* Parameter not used, but tell the compiler that it is ok */
2593 (void) scr;
2594 (void) entry;
2595 (void) foo;
2597 wPreferences.flags.wrap_appicons_in_dock = *flag;
2598 return 0;
2601 static int setStickyIcons(WScreen * scr, WDefaultEntry * entry, void *bar, void *foo)
2603 /* Parameter not used, but tell the compiler that it is ok */
2604 (void) entry;
2605 (void) bar;
2606 (void) foo;
2608 if (scr->workspaces) {
2609 wWorkspaceForceChange(scr, scr->current_workspace);
2610 wArrangeIcons(scr, False);
2612 return 0;
2615 static int setIconTile(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2617 Pixmap pixmap;
2618 RImage *img;
2619 WTexture ** texture = tdata;
2620 int reset = 0;
2622 /* Parameter not used, but tell the compiler that it is ok */
2623 (void) foo;
2625 img = wTextureRenderImage(*texture, wPreferences.icon_size,
2626 wPreferences.icon_size, ((*texture)->any.type & WREL_BORDER_MASK)
2627 ? WREL_ICON : WREL_FLAT);
2628 if (!img) {
2629 wwarning(_("could not render texture for icon background"));
2630 if (!entry->addr)
2631 wTextureDestroy(scr, *texture);
2632 return 0;
2634 RConvertImage(scr->rcontext, img, &pixmap);
2636 if (scr->icon_tile) {
2637 reset = 1;
2638 RReleaseImage(scr->icon_tile);
2639 XFreePixmap(dpy, scr->icon_tile_pixmap);
2642 scr->icon_tile = img;
2644 /* put the icon in the noticeboard hint */
2645 PropSetIconTileHint(scr, img);
2647 if (!wPreferences.flags.noclip || wPreferences.flags.clip_merged_in_dock) {
2648 if (scr->clip_tile) {
2649 RReleaseImage(scr->clip_tile);
2651 scr->clip_tile = wClipMakeTile(img);
2654 if (!wPreferences.flags.nodrawer) {
2655 if (scr->drawer_tile) {
2656 RReleaseImage(scr->drawer_tile);
2658 scr->drawer_tile = wDrawerMakeTile(scr, img);
2661 scr->icon_tile_pixmap = pixmap;
2663 if (scr->def_icon_rimage) {
2664 RReleaseImage(scr->def_icon_rimage);
2665 scr->def_icon_rimage = NULL;
2668 if (scr->icon_back_texture)
2669 wTextureDestroy(scr, (WTexture *) scr->icon_back_texture);
2671 scr->icon_back_texture = wTextureMakeSolid(scr, &((*texture)->any.color));
2673 /* Free the texture as nobody else will use it, nor refer to it. */
2674 if (!entry->addr)
2675 wTextureDestroy(scr, *texture);
2677 return (reset ? REFRESH_ICON_TILE : 0);
2680 static int setWinTitleFont(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2682 WMFont *font = tdata;
2684 /* Parameter not used, but tell the compiler that it is ok */
2685 (void) entry;
2686 (void) foo;
2688 if (scr->title_font) {
2689 WMReleaseFont(scr->title_font);
2691 scr->title_font = font;
2693 return REFRESH_WINDOW_FONT | REFRESH_BUTTON_IMAGES;
2696 static int setMenuTitleFont(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2698 WMFont *font = tdata;
2700 /* Parameter not used, but tell the compiler that it is ok */
2701 (void) entry;
2702 (void) foo;
2704 if (scr->menu_title_font) {
2705 WMReleaseFont(scr->menu_title_font);
2708 scr->menu_title_font = font;
2710 return REFRESH_MENU_TITLE_FONT;
2713 static int setMenuTextFont(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2715 WMFont *font = tdata;
2717 /* Parameter not used, but tell the compiler that it is ok */
2718 (void) entry;
2719 (void) foo;
2721 if (scr->menu_entry_font) {
2722 WMReleaseFont(scr->menu_entry_font);
2724 scr->menu_entry_font = font;
2726 return REFRESH_MENU_FONT;
2729 static int setIconTitleFont(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2731 WMFont *font = tdata;
2733 /* Parameter not used, but tell the compiler that it is ok */
2734 (void) entry;
2735 (void) foo;
2737 if (scr->icon_title_font) {
2738 WMReleaseFont(scr->icon_title_font);
2741 scr->icon_title_font = font;
2743 return REFRESH_ICON_FONT;
2746 static int setClipTitleFont(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2748 WMFont *font = tdata;
2750 /* Parameter not used, but tell the compiler that it is ok */
2751 (void) entry;
2752 (void) foo;
2754 if (scr->clip_title_font) {
2755 WMReleaseFont(scr->clip_title_font);
2758 scr->clip_title_font = font;
2760 return REFRESH_ICON_FONT;
2763 static int setLargeDisplayFont(WScreen *scr, WDefaultEntry *entry, void *tdata, void *foo)
2765 WMFont *font = tdata;
2767 /* Parameter not used, but tell the compiler that it is ok */
2768 (void) scr;
2769 (void) entry;
2770 (void) foo;
2772 if (scr->workspace_name_font)
2773 WMReleaseFont(scr->workspace_name_font);
2775 scr->workspace_name_font = font;
2777 return 0;
2780 static int setHightlight(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2782 XColor *color = tdata;
2784 /* Parameter not used, but tell the compiler that it is ok */
2785 (void) entry;
2786 (void) foo;
2788 if (scr->select_color)
2789 WMReleaseColor(scr->select_color);
2791 scr->select_color = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2793 wFreeColor(scr, color->pixel);
2795 return REFRESH_MENU_COLOR;
2798 static int setHightlightText(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2800 XColor *color = tdata;
2802 /* Parameter not used, but tell the compiler that it is ok */
2803 (void) entry;
2804 (void) foo;
2806 if (scr->select_text_color)
2807 WMReleaseColor(scr->select_text_color);
2809 scr->select_text_color = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2811 wFreeColor(scr, color->pixel);
2813 return REFRESH_MENU_COLOR;
2816 static int setClipTitleColor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *extra_data)
2818 XColor *color = tdata;
2819 long widx = (long) extra_data;
2821 /* Parameter not used, but tell the compiler that it is ok */
2822 (void) entry;
2824 if (scr->clip_title_color[widx])
2825 WMReleaseColor(scr->clip_title_color[widx]);
2827 scr->clip_title_color[widx] = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2828 wFreeColor(scr, color->pixel);
2830 return REFRESH_ICON_TITLE_COLOR;
2833 static int setWTitleColor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *extra_data)
2835 XColor *color = tdata;
2836 long widx = (long) extra_data;
2838 /* Parameter not used, but tell the compiler that it is ok */
2839 (void) entry;
2841 if (scr->window_title_color[widx])
2842 WMReleaseColor(scr->window_title_color[widx]);
2844 scr->window_title_color[widx] =
2845 WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2847 wFreeColor(scr, color->pixel);
2849 return REFRESH_WINDOW_TITLE_COLOR;
2852 static int setMenuTitleColor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *extra_data)
2854 XColor *color = tdata;
2856 /* Parameter not used, but tell the compiler that it is ok */
2857 (void) entry;
2858 (void) extra_data;
2860 if (scr->menu_title_color[0])
2861 WMReleaseColor(scr->menu_title_color[0]);
2863 scr->menu_title_color[0] = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2865 wFreeColor(scr, color->pixel);
2867 return REFRESH_MENU_TITLE_COLOR;
2870 static int setMenuTextColor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2872 XColor *color = tdata;
2874 /* Parameter not used, but tell the compiler that it is ok */
2875 (void) entry;
2876 (void) foo;
2878 if (scr->mtext_color)
2879 WMReleaseColor(scr->mtext_color);
2881 scr->mtext_color = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2883 if (WMColorPixel(scr->dtext_color) == WMColorPixel(scr->mtext_color)) {
2884 WMSetColorAlpha(scr->dtext_color, 0x7fff);
2885 } else {
2886 WMSetColorAlpha(scr->dtext_color, 0xffff);
2889 wFreeColor(scr, color->pixel);
2891 return REFRESH_MENU_COLOR;
2894 static int setMenuDisabledColor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2896 XColor *color = tdata;
2898 /* Parameter not used, but tell the compiler that it is ok */
2899 (void) entry;
2900 (void) foo;
2902 if (scr->dtext_color)
2903 WMReleaseColor(scr->dtext_color);
2905 scr->dtext_color = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2907 if (WMColorPixel(scr->dtext_color) == WMColorPixel(scr->mtext_color)) {
2908 WMSetColorAlpha(scr->dtext_color, 0x7fff);
2909 } else {
2910 WMSetColorAlpha(scr->dtext_color, 0xffff);
2913 wFreeColor(scr, color->pixel);
2915 return REFRESH_MENU_COLOR;
2918 static int setIconTitleColor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2920 XColor *color = tdata;
2922 /* Parameter not used, but tell the compiler that it is ok */
2923 (void) entry;
2924 (void) foo;
2926 if (scr->icon_title_color)
2927 WMReleaseColor(scr->icon_title_color);
2928 scr->icon_title_color = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2930 wFreeColor(scr, color->pixel);
2932 return REFRESH_ICON_TITLE_COLOR;
2935 static int setIconTitleBack(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2937 XColor *color = tdata;
2939 /* Parameter not used, but tell the compiler that it is ok */
2940 (void) entry;
2941 (void) foo;
2943 if (scr->icon_title_texture) {
2944 wTextureDestroy(scr, (WTexture *) scr->icon_title_texture);
2946 scr->icon_title_texture = wTextureMakeSolid(scr, color);
2948 return REFRESH_ICON_TITLE_BACK;
2951 static int setFrameBorderWidth(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2953 int *value = tdata;
2955 /* Parameter not used, but tell the compiler that it is ok */
2956 (void) entry;
2957 (void) foo;
2959 scr->frame_border_width = *value;
2961 return REFRESH_FRAME_BORDER;
2964 static int setFrameBorderColor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2966 XColor *color = tdata;
2968 /* Parameter not used, but tell the compiler that it is ok */
2969 (void) entry;
2970 (void) foo;
2972 if (scr->frame_border_color)
2973 WMReleaseColor(scr->frame_border_color);
2974 scr->frame_border_color = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2976 wFreeColor(scr, color->pixel);
2978 return REFRESH_FRAME_BORDER;
2981 static int setFrameFocusedBorderColor(WScreen *scr, WDefaultEntry *entry, void *tdata, void *foo)
2983 XColor *color = tdata;
2985 /* Parameter not used, but tell the compiler that it is ok */
2986 (void) entry;
2987 (void) foo;
2989 if (scr->frame_focused_border_color)
2990 WMReleaseColor(scr->frame_focused_border_color);
2991 scr->frame_focused_border_color = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2993 wFreeColor(scr, color->pixel);
2995 return REFRESH_FRAME_BORDER;
2998 static int setFrameSelectedBorderColor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
3000 XColor *color = tdata;
3002 /* Parameter not used, but tell the compiler that it is ok */
3003 (void) entry;
3004 (void) foo;
3006 if (scr->frame_selected_border_color)
3007 WMReleaseColor(scr->frame_selected_border_color);
3008 scr->frame_selected_border_color = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
3010 wFreeColor(scr, color->pixel);
3012 return REFRESH_FRAME_BORDER;
3015 static int setWorkspaceSpecificBack(WScreen * scr, WDefaultEntry * entry, void *tdata, void *bar)
3017 WMPropList *value = tdata;
3018 WMPropList *val;
3019 char *str;
3020 int i;
3022 /* Parameter not used, but tell the compiler that it is ok */
3023 (void) entry;
3024 (void) bar;
3026 if (scr->flags.backimage_helper_launched) {
3027 if (WMGetPropListItemCount(value) == 0) {
3028 SendHelperMessage(scr, 'C', 0, NULL);
3029 SendHelperMessage(scr, 'K', 0, NULL);
3031 WMReleasePropList(value);
3032 return 0;
3034 } else {
3035 if (WMGetPropListItemCount(value) == 0)
3036 return 0;
3038 if (!start_bg_helper(scr)) {
3039 WMReleasePropList(value);
3040 return 0;
3043 SendHelperMessage(scr, 'P', -1, wPreferences.pixmap_path);
3046 for (i = 0; i < WMGetPropListItemCount(value); i++) {
3047 val = WMGetFromPLArray(value, i);
3048 if (val && WMIsPLArray(val) && WMGetPropListItemCount(val) > 0) {
3049 str = WMGetPropListDescription(val, False);
3051 SendHelperMessage(scr, 'S', i + 1, str);
3053 wfree(str);
3054 } else {
3055 SendHelperMessage(scr, 'U', i + 1, NULL);
3058 sleep(1);
3060 WMReleasePropList(value);
3061 return 0;
3064 static int setWorkspaceBack(WScreen * scr, WDefaultEntry * entry, void *tdata, void *bar)
3066 WMPropList *value = tdata;
3068 /* Parameter not used, but tell the compiler that it is ok */
3069 (void) entry;
3070 (void) bar;
3072 if (scr->flags.backimage_helper_launched) {
3073 char *str;
3075 if (WMGetPropListItemCount(value) == 0) {
3076 SendHelperMessage(scr, 'U', 0, NULL);
3077 } else {
3078 /* set the default workspace background to this one */
3079 str = WMGetPropListDescription(value, False);
3080 if (str) {
3081 SendHelperMessage(scr, 'S', 0, str);
3082 wfree(str);
3083 SendHelperMessage(scr, 'C', scr->current_workspace + 1, NULL);
3084 } else {
3085 SendHelperMessage(scr, 'U', 0, NULL);
3088 } else if (WMGetPropListItemCount(value) > 0) {
3089 char *text;
3090 char *dither;
3091 int len;
3093 text = WMGetPropListDescription(value, False);
3094 len = strlen(text) + 40;
3095 dither = wPreferences.no_dithering ? "-m" : "-d";
3096 if (!strchr(text, '\'') && !strchr(text, '\\')) {
3097 char command[len];
3099 if (wPreferences.smooth_workspace_back)
3100 snprintf(command, len, "wmsetbg %s -S -p '%s' &", dither, text);
3101 else
3102 snprintf(command, len, "wmsetbg %s -p '%s' &", dither, text);
3103 ExecuteShellCommand(scr, command);
3104 } else
3105 wwarning(_("Invalid arguments for background \"%s\""), text);
3106 wfree(text);
3108 WMReleasePropList(value);
3110 return 0;
3113 static int setWidgetColor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
3115 WTexture **texture = tdata;
3117 /* Parameter not used, but tell the compiler that it is ok */
3118 (void) entry;
3119 (void) foo;
3121 if (scr->widget_texture) {
3122 wTextureDestroy(scr, (WTexture *) scr->widget_texture);
3124 scr->widget_texture = *(WTexSolid **) texture;
3126 return 0;
3129 static int setFTitleBack(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
3131 WTexture **texture = tdata;
3133 /* Parameter not used, but tell the compiler that it is ok */
3134 (void) entry;
3135 (void) foo;
3137 if (scr->window_title_texture[WS_FOCUSED]) {
3138 wTextureDestroy(scr, scr->window_title_texture[WS_FOCUSED]);
3140 scr->window_title_texture[WS_FOCUSED] = *texture;
3142 return REFRESH_WINDOW_TEXTURES;
3145 static int setPTitleBack(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
3147 WTexture **texture = tdata;
3149 /* Parameter not used, but tell the compiler that it is ok */
3150 (void) entry;
3151 (void) foo;
3153 if (scr->window_title_texture[WS_PFOCUSED]) {
3154 wTextureDestroy(scr, scr->window_title_texture[WS_PFOCUSED]);
3156 scr->window_title_texture[WS_PFOCUSED] = *texture;
3158 return REFRESH_WINDOW_TEXTURES;
3161 static int setUTitleBack(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
3163 WTexture **texture = tdata;
3165 /* Parameter not used, but tell the compiler that it is ok */
3166 (void) entry;
3167 (void) foo;
3169 if (scr->window_title_texture[WS_UNFOCUSED]) {
3170 wTextureDestroy(scr, scr->window_title_texture[WS_UNFOCUSED]);
3172 scr->window_title_texture[WS_UNFOCUSED] = *texture;
3174 return REFRESH_WINDOW_TEXTURES;
3177 static int setResizebarBack(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
3179 WTexture **texture = tdata;
3181 /* Parameter not used, but tell the compiler that it is ok */
3182 (void) entry;
3183 (void) foo;
3185 if (scr->resizebar_texture[0]) {
3186 wTextureDestroy(scr, scr->resizebar_texture[0]);
3188 scr->resizebar_texture[0] = *texture;
3190 return REFRESH_WINDOW_TEXTURES;
3193 static int setMenuTitleBack(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
3195 WTexture **texture = tdata;
3197 /* Parameter not used, but tell the compiler that it is ok */
3198 (void) entry;
3199 (void) foo;
3201 if (scr->menu_title_texture[0]) {
3202 wTextureDestroy(scr, scr->menu_title_texture[0]);
3204 scr->menu_title_texture[0] = *texture;
3206 return REFRESH_MENU_TITLE_TEXTURE;
3209 static int setMenuTextBack(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
3211 WTexture **texture = tdata;
3213 /* Parameter not used, but tell the compiler that it is ok */
3214 (void) entry;
3215 (void) foo;
3217 if (scr->menu_item_texture) {
3218 wTextureDestroy(scr, scr->menu_item_texture);
3219 wTextureDestroy(scr, (WTexture *) scr->menu_item_auxtexture);
3221 scr->menu_item_texture = *texture;
3223 scr->menu_item_auxtexture = wTextureMakeSolid(scr, &scr->menu_item_texture->any.color);
3225 return REFRESH_MENU_TEXTURE;
3228 static int setKeyGrab(WScreen * scr, WDefaultEntry * entry, void *tdata, void *extra_data)
3230 WShortKey *shortcut = tdata;
3231 WWindow *wwin;
3232 long widx = (long) extra_data;
3234 /* Parameter not used, but tell the compiler that it is ok */
3235 (void) entry;
3237 wKeyBindings[widx] = *shortcut;
3239 wwin = scr->focused_window;
3241 while (wwin != NULL) {
3242 XUngrabKey(dpy, AnyKey, AnyModifier, wwin->frame->core->window);
3244 if (!WFLAGP(wwin, no_bind_keys)) {
3245 wWindowSetKeyGrabs(wwin);
3247 wwin = wwin->prev;
3250 /* do we need to update window menus? */
3251 if (widx >= WKBD_WORKSPACE1 && widx <= WKBD_WORKSPACE10)
3252 return REFRESH_WORKSPACE_MENU;
3253 if (widx == WKBD_LASTWORKSPACE)
3254 return REFRESH_WORKSPACE_MENU;
3255 if (widx >= WKBD_MOVE_WORKSPACE1 && widx <= WKBD_MOVE_WORKSPACE10)
3256 return REFRESH_WORKSPACE_MENU;
3258 return 0;
3261 static int setIconPosition(WScreen * scr, WDefaultEntry * entry, void *bar, void *foo)
3263 /* Parameter not used, but tell the compiler that it is ok */
3264 (void) entry;
3265 (void) bar;
3266 (void) foo;
3268 wScreenUpdateUsableArea(scr);
3269 wArrangeIcons(scr, True);
3271 return 0;
3274 static int updateUsableArea(WScreen * scr, WDefaultEntry * entry, void *bar, void *foo)
3276 /* Parameter not used, but tell the compiler that it is ok */
3277 (void) entry;
3278 (void) bar;
3279 (void) foo;
3281 wScreenUpdateUsableArea(scr);
3283 return 0;
3286 static int setWorkspaceMapBackground(WScreen *scr, WDefaultEntry *entry, void *tdata, void *foo)
3288 WTexture **texture = tdata;
3290 /* Parameter not used, but tell the compiler that it is ok */
3291 (void) entry;
3292 (void) foo;
3294 if (wPreferences.wsmbackTexture)
3295 wTextureDestroy(scr, wPreferences.wsmbackTexture);
3297 wPreferences.wsmbackTexture = *texture;
3299 return REFRESH_WINDOW_TEXTURES;
3302 static int setMenuStyle(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
3304 /* Parameter not used, but tell the compiler that it is ok */
3305 (void) scr;
3306 (void) entry;
3307 (void) tdata;
3308 (void) foo;
3310 return REFRESH_MENU_TEXTURE;
3313 static RImage *chopOffImage(RImage * image, int x, int y, int w, int h)
3315 RImage *img = RCreateImage(w, h, image->format == RRGBAFormat);
3317 RCopyArea(img, image, x, y, w, h, 0, 0);
3319 return img;
3322 static int setSwPOptions(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
3324 WMPropList *array = tdata;
3325 char *path;
3326 RImage *bgimage;
3327 int cwidth, cheight;
3328 struct WPreferences *prefs = foo;
3330 if (!WMIsPLArray(array) || WMGetPropListItemCount(array) == 0) {
3331 if (prefs->swtileImage)
3332 RReleaseImage(prefs->swtileImage);
3333 prefs->swtileImage = NULL;
3335 WMReleasePropList(array);
3336 return 0;
3339 switch (WMGetPropListItemCount(array)) {
3340 case 4:
3341 if (!WMIsPLString(WMGetFromPLArray(array, 1))) {
3342 wwarning(_("Invalid arguments for option \"%s\""), entry->key);
3343 break;
3344 } else
3345 path = FindImage(wPreferences.pixmap_path, WMGetFromPLString(WMGetFromPLArray(array, 1)));
3347 if (!path) {
3348 wwarning(_("Could not find image \"%s\" for option \"%s\""),
3349 WMGetFromPLString(WMGetFromPLArray(array, 1)), entry->key);
3350 } else {
3351 bgimage = RLoadImage(scr->rcontext, path, 0);
3352 if (!bgimage) {
3353 wwarning(_("Could not load image \"%s\" for option \"%s\""), path, entry->key);
3354 wfree(path);
3355 } else {
3356 wfree(path);
3358 cwidth = atoi(WMGetFromPLString(WMGetFromPLArray(array, 2)));
3359 cheight = atoi(WMGetFromPLString(WMGetFromPLArray(array, 3)));
3361 if (cwidth <= 0 || cheight <= 0 ||
3362 cwidth >= bgimage->width - 2 || cheight >= bgimage->height - 2)
3363 wwarning(_("Invalid split sizes for switch panel back image."));
3364 else {
3365 int i;
3366 int swidth, theight;
3367 for (i = 0; i < 9; i++) {
3368 if (prefs->swbackImage[i])
3369 RReleaseImage(prefs->swbackImage[i]);
3370 prefs->swbackImage[i] = NULL;
3372 swidth = (bgimage->width - cwidth) / 2;
3373 theight = (bgimage->height - cheight) / 2;
3375 prefs->swbackImage[0] = chopOffImage(bgimage, 0, 0, swidth, theight);
3376 prefs->swbackImage[1] = chopOffImage(bgimage, swidth, 0, cwidth, theight);
3377 prefs->swbackImage[2] = chopOffImage(bgimage, swidth + cwidth, 0,
3378 swidth, theight);
3380 prefs->swbackImage[3] = chopOffImage(bgimage, 0, theight, swidth, cheight);
3381 prefs->swbackImage[4] = chopOffImage(bgimage, swidth, theight,
3382 cwidth, cheight);
3383 prefs->swbackImage[5] = chopOffImage(bgimage, swidth + cwidth, theight,
3384 swidth, cheight);
3386 prefs->swbackImage[6] = chopOffImage(bgimage, 0, theight + cheight,
3387 swidth, theight);
3388 prefs->swbackImage[7] = chopOffImage(bgimage, swidth, theight + cheight,
3389 cwidth, theight);
3390 prefs->swbackImage[8] =
3391 chopOffImage(bgimage, swidth + cwidth, theight + cheight, swidth,
3392 theight);
3394 // check if anything failed
3395 for (i = 0; i < 9; i++) {
3396 if (!prefs->swbackImage[i]) {
3397 for (; i >= 0; --i) {
3398 RReleaseImage(prefs->swbackImage[i]);
3399 prefs->swbackImage[i] = NULL;
3401 break;
3405 RReleaseImage(bgimage);
3409 case 1:
3410 if (!WMIsPLString(WMGetFromPLArray(array, 0))) {
3411 wwarning(_("Invalid arguments for option \"%s\""), entry->key);
3412 break;
3413 } else
3414 path = FindImage(wPreferences.pixmap_path, WMGetFromPLString(WMGetFromPLArray(array, 0)));
3416 if (!path) {
3417 wwarning(_("Could not find image \"%s\" for option \"%s\""),
3418 WMGetFromPLString(WMGetFromPLArray(array, 0)), entry->key);
3419 } else {
3420 if (prefs->swtileImage)
3421 RReleaseImage(prefs->swtileImage);
3423 prefs->swtileImage = RLoadImage(scr->rcontext, path, 0);
3424 if (!prefs->swtileImage) {
3425 wwarning(_("Could not load image \"%s\" for option \"%s\""), path, entry->key);
3427 wfree(path);
3429 break;
3431 default:
3432 wwarning(_("Invalid number of arguments for option \"%s\""), entry->key);
3433 break;
3436 WMReleasePropList(array);
3438 return 0;
3441 static int setModifierKeyLabels(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
3443 WMPropList *array = tdata;
3444 int i;
3445 struct WPreferences *prefs = foo;
3447 if (!WMIsPLArray(array) || WMGetPropListItemCount(array) != 7) {
3448 wwarning(_("Value for option \"%s\" must be an array of 7 strings"), entry->key);
3449 WMReleasePropList(array);
3450 return 0;
3453 DestroyWindowMenu(scr);
3455 for (i = 0; i < 7; i++) {
3456 if (prefs->modifier_labels[i])
3457 wfree(prefs->modifier_labels[i]);
3459 if (WMIsPLString(WMGetFromPLArray(array, i))) {
3460 prefs->modifier_labels[i] = wstrdup(WMGetFromPLString(WMGetFromPLArray(array, i)));
3461 } else {
3462 wwarning(_("Invalid argument for option \"%s\" item %d"), entry->key, i);
3463 prefs->modifier_labels[i] = NULL;
3467 WMReleasePropList(array);
3469 return 0;
3472 static int setDoubleClick(WScreen *scr, WDefaultEntry *entry, void *tdata, void *foo)
3474 int *value = tdata;
3476 /* Parameter not used, but tell the compiler that it is ok */
3477 (void) entry;
3478 (void) scr;
3480 if (*value <= 0)
3481 *(int *)foo = 1;
3483 W_setconf_doubleClickDelay(*value);
3485 return 0;
3488 static int setCursor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *extra_data)
3490 Cursor *cursor = tdata;
3491 long widx = (long) extra_data;
3493 /* Parameter not used, but tell the compiler that it is ok */
3494 (void) entry;
3496 if (wPreferences.cursor[widx] != None) {
3497 XFreeCursor(dpy, wPreferences.cursor[widx]);
3500 wPreferences.cursor[widx] = *cursor;
3502 if (widx == WCUR_ROOT && *cursor != None) {
3503 XDefineCursor(dpy, scr->root_win, *cursor);
3506 return 0;