Disable pager by default
[wmaker-crm.git] / src / defaults.c
blobcaa428e1df77657b1c88ea7d4d83a30cdeae2083
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 {"EnableWorkspacePager", "NO", NULL,
367 &wPreferences.enable_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 {"SnapEdgeDetect", "1", NULL,
478 &wPreferences.snap_edge_detect, getInt, NULL, NULL, NULL},
479 {"SnapCornerDetect", "10", NULL,
480 &wPreferences.snap_corner_detect, getInt, NULL, NULL, NULL},
481 {"DragMaximizedWindow", "Move", seDragMaximizedWindow,
482 &wPreferences.drag_maximized_window, getEnum, NULL, NULL, NULL},
483 {"HighlightActiveApp", "YES", NULL,
484 &wPreferences.highlight_active_app, getBool, NULL, NULL, NULL},
485 {"AutoArrangeIcons", "NO", NULL,
486 &wPreferences.auto_arrange_icons, getBool, NULL, NULL, NULL},
487 {"NoWindowOverDock", "NO", NULL,
488 &wPreferences.no_window_over_dock, getBool, updateUsableArea, NULL, NULL},
489 {"NoWindowOverIcons", "NO", NULL,
490 &wPreferences.no_window_over_icons, getBool, updateUsableArea, NULL, NULL},
491 {"WindowPlaceOrigin", "(0, 0)", NULL,
492 &wPreferences.window_place_origin, getCoord, NULL, NULL, NULL},
493 {"ResizeDisplay", "corner", seGeomDisplays,
494 &wPreferences.size_display, getEnum, NULL, NULL, NULL},
495 {"MoveDisplay", "corner", seGeomDisplays,
496 &wPreferences.move_display, getEnum, NULL, NULL, NULL},
497 {"DontConfirmKill", "NO", NULL,
498 &wPreferences.dont_confirm_kill, getBool, NULL, NULL, NULL},
499 {"WindowTitleBalloons", "NO", NULL,
500 &wPreferences.window_balloon, getBool, NULL, NULL, NULL},
501 {"MiniwindowTitleBalloons", "NO", NULL,
502 &wPreferences.miniwin_title_balloon, getBool, NULL, NULL, NULL},
503 {"MiniwindowPreviewBalloons", "NO", NULL,
504 &wPreferences.miniwin_preview_balloon, getBool, NULL, NULL, NULL},
505 {"AppIconBalloons", "NO", NULL,
506 &wPreferences.appicon_balloon, getBool, NULL, NULL, NULL},
507 {"HelpBalloons", "NO", NULL,
508 &wPreferences.help_balloon, getBool, NULL, NULL, NULL},
509 {"EdgeResistance", "30", NULL,
510 &wPreferences.edge_resistance, getInt, NULL, NULL, NULL},
511 {"ResizeIncrement", "0", NULL,
512 &wPreferences.resize_increment, getInt, NULL, NULL, NULL},
513 {"Attraction", "NO", NULL,
514 &wPreferences.attract, getBool, NULL, NULL, NULL},
515 {"DisableBlinking", "NO", NULL,
516 &wPreferences.dont_blink, getBool, NULL, NULL, NULL},
517 {"SingleClickLaunch", "NO", NULL,
518 &wPreferences.single_click, getBool, NULL, NULL, NULL},
519 {"StrictWindozeCycle", "YES", NULL,
520 &wPreferences.strict_windoze_cycle, getBool, NULL, NULL, NULL},
521 {"SwitchPanelOnlyOpen", "NO", NULL,
522 &wPreferences.panel_only_open, getBool, NULL, NULL, NULL},
523 {"MiniPreviewSize", "128", NULL,
524 &wPreferences.minipreview_size, getInt, NULL, NULL, NULL},
525 {"IgnoreGtkHints", "NO", NULL,
526 &wPreferences.ignore_gtk_decoration_hints, getBool, NULL, NULL, NULL},
529 * Backward Compatibility:
530 * The Mini-Previews were introduced in 0.95.6 under the name "Apercu".
531 * For compatibility, we still support the old names in configuration files,
532 * so this should stay for at least 2 years (that means until 2017)
534 {"MiniwindowApercuBalloons", "NO", NULL,
535 &legacy_minipreview_config.enable, getBool, NULL, NULL, NULL},
536 {"ApercuSize", "0", NULL,
537 &legacy_minipreview_config.size, getInt, NULL, NULL, NULL},
539 /* style options */
541 {"MenuStyle", "normal", seMenuStyles,
542 &wPreferences.menu_style, getEnum, setMenuStyle, NULL, NULL},
543 {"WidgetColor", "(solid, gray)", NULL,
544 NULL, getTexture, setWidgetColor, NULL, NULL},
545 {"WorkspaceSpecificBack", "()", NULL,
546 NULL, getWSSpecificBackground, setWorkspaceSpecificBack, NULL, NULL},
547 /* WorkspaceBack must come after WorkspaceSpecificBack or
548 * WorkspaceBack wont know WorkspaceSpecificBack was also
549 * specified and 2 copies of wmsetbg will be launched */
550 {"WorkspaceBack", "(solid, black)", NULL,
551 NULL, getWSBackground, setWorkspaceBack, NULL, NULL},
552 {"SmoothWorkspaceBack", "NO", NULL,
553 NULL, getBool, NULL, NULL, NULL},
554 {"IconBack", "(solid, gray)", NULL,
555 NULL, getTexture, setIconTile, NULL, NULL},
556 {"TitleJustify", "center", seJustifications,
557 &wPreferences.title_justification, getEnum, setJustify, NULL, NULL},
558 {"WindowTitleFont", DEF_TITLE_FONT, NULL,
559 NULL, getFont, setWinTitleFont, NULL, NULL},
560 {"WindowTitleExtendSpace", DEF_WINDOW_TITLE_EXTEND_SPACE, NULL,
561 &wPreferences.window_title_clearance, getInt, setClearance, NULL, NULL},
562 {"WindowTitleMinHeight", "0", NULL,
563 &wPreferences.window_title_min_height, getInt, setClearance, NULL, NULL},
564 {"WindowTitleMaxHeight", NUM2STRING(INT_MAX), NULL,
565 &wPreferences.window_title_max_height, getInt, setClearance, NULL, NULL},
566 {"MenuTitleExtendSpace", DEF_MENU_TITLE_EXTEND_SPACE, NULL,
567 &wPreferences.menu_title_clearance, getInt, setClearance, NULL, NULL},
568 {"MenuTitleMinHeight", "0", NULL,
569 &wPreferences.menu_title_min_height, getInt, setClearance, NULL, NULL},
570 {"MenuTitleMaxHeight", NUM2STRING(INT_MAX), NULL,
571 &wPreferences.menu_title_max_height, getInt, setClearance, NULL, NULL},
572 {"MenuTextExtendSpace", DEF_MENU_TEXT_EXTEND_SPACE, NULL,
573 &wPreferences.menu_text_clearance, getInt, setClearance, NULL, NULL},
574 {"MenuTitleFont", DEF_MENU_TITLE_FONT, NULL,
575 NULL, getFont, setMenuTitleFont, NULL, NULL},
576 {"MenuTextFont", DEF_MENU_ENTRY_FONT, NULL,
577 NULL, getFont, setMenuTextFont, NULL, NULL},
578 {"IconTitleFont", DEF_ICON_TITLE_FONT, NULL,
579 NULL, getFont, setIconTitleFont, NULL, NULL},
580 {"ClipTitleFont", DEF_CLIP_TITLE_FONT, NULL,
581 NULL, getFont, setClipTitleFont, NULL, NULL},
582 {"ShowClipTitle", "YES", NULL,
583 &wPreferences.show_clip_title, getBool, NULL, NULL, NULL},
584 {"LargeDisplayFont", DEF_WORKSPACE_NAME_FONT, NULL,
585 NULL, getFont, setLargeDisplayFont, NULL, NULL},
586 {"HighlightColor", "white", NULL,
587 NULL, getColor, setHightlight, NULL, NULL},
588 {"HighlightTextColor", "black", NULL,
589 NULL, getColor, setHightlightText, NULL, NULL},
590 {"ClipTitleColor", "black", (void *)CLIP_NORMAL,
591 NULL, getColor, setClipTitleColor, NULL, NULL},
592 {"CClipTitleColor", "\"#454045\"", (void *)CLIP_COLLAPSED,
593 NULL, getColor, setClipTitleColor, NULL, NULL},
594 {"FTitleColor", "white", (void *)WS_FOCUSED,
595 NULL, getColor, setWTitleColor, NULL, NULL},
596 {"PTitleColor", "white", (void *)WS_PFOCUSED,
597 NULL, getColor, setWTitleColor, NULL, NULL},
598 {"UTitleColor", "black", (void *)WS_UNFOCUSED,
599 NULL, getColor, setWTitleColor, NULL, NULL},
600 {"FTitleBack", "(solid, black)", NULL,
601 NULL, getTexture, setFTitleBack, NULL, NULL},
602 {"PTitleBack", "(solid, \"#616161\")", NULL,
603 NULL, getTexture, setPTitleBack, NULL, NULL},
604 {"UTitleBack", "(solid, gray)", NULL,
605 NULL, getTexture, setUTitleBack, NULL, NULL},
606 {"ResizebarBack", "(solid, gray)", NULL,
607 NULL, getTexture, setResizebarBack, NULL, NULL},
608 {"MenuTitleColor", "white", NULL,
609 NULL, getColor, setMenuTitleColor, NULL, NULL},
610 {"MenuTextColor", "black", NULL,
611 NULL, getColor, setMenuTextColor, NULL, NULL},
612 {"MenuDisabledColor", "\"#616161\"", NULL,
613 NULL, getColor, setMenuDisabledColor, NULL, NULL},
614 {"MenuTitleBack", "(solid, black)", NULL,
615 NULL, getTexture, setMenuTitleBack, NULL, NULL},
616 {"MenuTextBack", "(solid, gray)", NULL,
617 NULL, getTexture, setMenuTextBack, NULL, NULL},
618 {"IconTitleColor", "white", NULL,
619 NULL, getColor, setIconTitleColor, NULL, NULL},
620 {"IconTitleBack", "black", NULL,
621 NULL, getColor, setIconTitleBack, NULL, NULL},
622 {"SwitchPanelImages", "(swtile.png, swback.png, 30, 40)", &wPreferences,
623 NULL, getPropList, setSwPOptions, NULL, NULL},
624 {"ModifierKeyLabels", "(\"Shift+\", \"Control+\", \"Mod1+\", \"Mod2+\", \"Mod3+\", \"Mod4+\", \"Mod5+\")", &wPreferences,
625 NULL, getPropList, setModifierKeyLabels, NULL, NULL},
626 {"FrameBorderWidth", "1", NULL,
627 NULL, getInt, setFrameBorderWidth, NULL, NULL},
628 {"FrameBorderColor", "black", NULL,
629 NULL, getColor, setFrameBorderColor, NULL, NULL},
630 {"FrameFocusedBorderColor", "black", NULL,
631 NULL, getColor, setFrameFocusedBorderColor, NULL, NULL},
632 {"FrameSelectedBorderColor", "white", NULL,
633 NULL, getColor, setFrameSelectedBorderColor, NULL, NULL},
634 {"WorkspaceMapBack", "(solid, black)", NULL,
635 NULL, getTexture, setWorkspaceMapBackground, NULL, NULL},
637 /* keybindings */
639 {"RootMenuKey", "None", (void *)WKBD_ROOTMENU,
640 NULL, getKeybind, setKeyGrab, NULL, NULL},
641 {"WindowListKey", "None", (void *)WKBD_WINDOWLIST,
642 NULL, getKeybind, setKeyGrab, NULL, NULL},
643 {"WindowMenuKey", "None", (void *)WKBD_WINDOWMENU,
644 NULL, getKeybind, setKeyGrab, NULL, NULL},
645 {"DockRaiseLowerKey", "None", (void*)WKBD_DOCKRAISELOWER,
646 NULL, getKeybind, setKeyGrab, NULL, NULL},
647 {"ClipRaiseLowerKey", "None", (void *)WKBD_CLIPRAISELOWER,
648 NULL, getKeybind, setKeyGrab, NULL, NULL},
649 {"MiniaturizeKey", "None", (void *)WKBD_MINIATURIZE,
650 NULL, getKeybind, setKeyGrab, NULL, NULL},
651 {"MinimizeAllKey", "None", (void *)WKBD_MINIMIZEALL,
652 NULL, getKeybind, setKeyGrab, NULL, NULL },
653 {"HideKey", "None", (void *)WKBD_HIDE,
654 NULL, getKeybind, setKeyGrab, NULL, NULL},
655 {"HideOthersKey", "None", (void *)WKBD_HIDE_OTHERS,
656 NULL, getKeybind, setKeyGrab, NULL, NULL},
657 {"MoveResizeKey", "None", (void *)WKBD_MOVERESIZE,
658 NULL, getKeybind, setKeyGrab, NULL, NULL},
659 {"CloseKey", "None", (void *)WKBD_CLOSE,
660 NULL, getKeybind, setKeyGrab, NULL, NULL},
661 {"MaximizeKey", "None", (void *)WKBD_MAXIMIZE,
662 NULL, getKeybind, setKeyGrab, NULL, NULL},
663 {"VMaximizeKey", "None", (void *)WKBD_VMAXIMIZE,
664 NULL, getKeybind, setKeyGrab, NULL, NULL},
665 {"HMaximizeKey", "None", (void *)WKBD_HMAXIMIZE,
666 NULL, getKeybind, setKeyGrab, NULL, NULL},
667 {"LHMaximizeKey", "None", (void*)WKBD_LHMAXIMIZE,
668 NULL, getKeybind, setKeyGrab, NULL, NULL},
669 {"RHMaximizeKey", "None", (void*)WKBD_RHMAXIMIZE,
670 NULL, getKeybind, setKeyGrab, NULL, NULL},
671 {"THMaximizeKey", "None", (void*)WKBD_THMAXIMIZE,
672 NULL, getKeybind, setKeyGrab, NULL, NULL},
673 {"BHMaximizeKey", "None", (void*)WKBD_BHMAXIMIZE,
674 NULL, getKeybind, setKeyGrab, NULL, NULL},
675 {"LTCMaximizeKey", "None", (void*)WKBD_LTCMAXIMIZE,
676 NULL, getKeybind, setKeyGrab, NULL, NULL},
677 {"RTCMaximizeKey", "None", (void*)WKBD_RTCMAXIMIZE,
678 NULL, getKeybind, setKeyGrab, NULL, NULL},
679 {"LBCMaximizeKey", "None", (void*)WKBD_LBCMAXIMIZE,
680 NULL, getKeybind, setKeyGrab, NULL, NULL},
681 {"RBCMaximizeKey", "None", (void*)WKBD_RBCMAXIMIZE,
682 NULL, getKeybind, setKeyGrab, NULL, NULL},
683 {"MaximusKey", "None", (void*)WKBD_MAXIMUS,
684 NULL, getKeybind, setKeyGrab, NULL, NULL},
685 {"OmnipresentKey", "None", (void *)WKBD_OMNIPRESENT,
686 NULL, getKeybind, setKeyGrab, NULL, NULL},
687 {"RaiseKey", "\"Meta+Up\"", (void *)WKBD_RAISE,
688 NULL, getKeybind, setKeyGrab, NULL, NULL},
689 {"LowerKey", "\"Meta+Down\"", (void *)WKBD_LOWER,
690 NULL, getKeybind, setKeyGrab, NULL, NULL},
691 {"RaiseLowerKey", "None", (void *)WKBD_RAISELOWER,
692 NULL, getKeybind, setKeyGrab, NULL, NULL},
693 {"ShadeKey", "None", (void *)WKBD_SHADE,
694 NULL, getKeybind, setKeyGrab, NULL, NULL},
695 {"SelectKey", "None", (void *)WKBD_SELECT,
696 NULL, getKeybind, setKeyGrab, NULL, NULL},
697 {"WorkspaceMapKey", "None", (void *)WKBD_WORKSPACEMAP,
698 NULL, getKeybind, setKeyGrab, NULL, NULL},
699 {"FocusNextKey", "None", (void *)WKBD_FOCUSNEXT,
700 NULL, getKeybind, setKeyGrab, NULL, NULL},
701 {"FocusPrevKey", "None", (void *)WKBD_FOCUSPREV,
702 NULL, getKeybind, setKeyGrab, NULL, NULL},
703 {"GroupNextKey", "None", (void *)WKBD_GROUPNEXT,
704 NULL, getKeybind, setKeyGrab, NULL, NULL},
705 {"GroupPrevKey", "None", (void *)WKBD_GROUPPREV,
706 NULL, getKeybind, setKeyGrab, NULL, NULL},
707 {"NextWorkspaceKey", "None", (void *)WKBD_NEXTWORKSPACE,
708 NULL, getKeybind, setKeyGrab, NULL, NULL},
709 {"PrevWorkspaceKey", "None", (void *)WKBD_PREVWORKSPACE,
710 NULL, getKeybind, setKeyGrab, NULL, NULL},
711 {"LastWorkspaceKey", "None", (void *)WKBD_LASTWORKSPACE,
712 NULL, getKeybind, setKeyGrab, NULL, NULL},
713 {"NextWorkspaceLayerKey", "None", (void *)WKBD_NEXTWSLAYER,
714 NULL, getKeybind, setKeyGrab, NULL, NULL},
715 {"PrevWorkspaceLayerKey", "None", (void *)WKBD_PREVWSLAYER,
716 NULL, getKeybind, setKeyGrab, NULL, NULL},
717 {"Workspace1Key", "None", (void *)WKBD_WORKSPACE1,
718 NULL, getKeybind, setKeyGrab, NULL, NULL},
719 {"Workspace2Key", "None", (void *)WKBD_WORKSPACE2,
720 NULL, getKeybind, setKeyGrab, NULL, NULL},
721 {"Workspace3Key", "None", (void *)WKBD_WORKSPACE3,
722 NULL, getKeybind, setKeyGrab, NULL, NULL},
723 {"Workspace4Key", "None", (void *)WKBD_WORKSPACE4,
724 NULL, getKeybind, setKeyGrab, NULL, NULL},
725 {"Workspace5Key", "None", (void *)WKBD_WORKSPACE5,
726 NULL, getKeybind, setKeyGrab, NULL, NULL},
727 {"Workspace6Key", "None", (void *)WKBD_WORKSPACE6,
728 NULL, getKeybind, setKeyGrab, NULL, NULL},
729 {"Workspace7Key", "None", (void *)WKBD_WORKSPACE7,
730 NULL, getKeybind, setKeyGrab, NULL, NULL},
731 {"Workspace8Key", "None", (void *)WKBD_WORKSPACE8,
732 NULL, getKeybind, setKeyGrab, NULL, NULL},
733 {"Workspace9Key", "None", (void *)WKBD_WORKSPACE9,
734 NULL, getKeybind, setKeyGrab, NULL, NULL},
735 {"Workspace10Key", "None", (void *)WKBD_WORKSPACE10,
736 NULL, getKeybind, setKeyGrab, NULL, NULL},
737 {"MoveToWorkspace1Key", "None", (void *)WKBD_MOVE_WORKSPACE1,
738 NULL, getKeybind, setKeyGrab, NULL, NULL},
739 {"MoveToWorkspace2Key", "None", (void *)WKBD_MOVE_WORKSPACE2,
740 NULL, getKeybind, setKeyGrab, NULL, NULL},
741 {"MoveToWorkspace3Key", "None", (void *)WKBD_MOVE_WORKSPACE3,
742 NULL, getKeybind, setKeyGrab, NULL, NULL},
743 {"MoveToWorkspace4Key", "None", (void *)WKBD_MOVE_WORKSPACE4,
744 NULL, getKeybind, setKeyGrab, NULL, NULL},
745 {"MoveToWorkspace5Key", "None", (void *)WKBD_MOVE_WORKSPACE5,
746 NULL, getKeybind, setKeyGrab, NULL, NULL},
747 {"MoveToWorkspace6Key", "None", (void *)WKBD_MOVE_WORKSPACE6,
748 NULL, getKeybind, setKeyGrab, NULL, NULL},
749 {"MoveToWorkspace7Key", "None", (void *)WKBD_MOVE_WORKSPACE7,
750 NULL, getKeybind, setKeyGrab, NULL, NULL},
751 {"MoveToWorkspace8Key", "None", (void *)WKBD_MOVE_WORKSPACE8,
752 NULL, getKeybind, setKeyGrab, NULL, NULL},
753 {"MoveToWorkspace9Key", "None", (void *)WKBD_MOVE_WORKSPACE9,
754 NULL, getKeybind, setKeyGrab, NULL, NULL},
755 {"MoveToWorkspace10Key", "None", (void *)WKBD_MOVE_WORKSPACE10,
756 NULL, getKeybind, setKeyGrab, NULL, NULL},
757 {"MoveToNextWorkspaceKey", "None", (void *)WKBD_MOVE_NEXTWORKSPACE,
758 NULL, getKeybind, setKeyGrab, NULL, NULL},
759 {"MoveToPrevWorkspaceKey", "None", (void *)WKBD_MOVE_PREVWORKSPACE,
760 NULL, getKeybind, setKeyGrab, NULL, NULL},
761 {"MoveToLastWorkspaceKey", "None", (void *)WKBD_MOVE_LASTWORKSPACE,
762 NULL, getKeybind, setKeyGrab, NULL, NULL},
763 {"MoveToNextWorkspaceLayerKey", "None", (void *)WKBD_MOVE_NEXTWSLAYER,
764 NULL, getKeybind, setKeyGrab, NULL, NULL},
765 {"MoveToPrevWorkspaceLayerKey", "None", (void *)WKBD_MOVE_PREVWSLAYER,
766 NULL, getKeybind, setKeyGrab, NULL, NULL},
767 {"WindowShortcut1Key", "None", (void *)WKBD_WINDOW1,
768 NULL, getKeybind, setKeyGrab, NULL, NULL},
769 {"WindowShortcut2Key", "None", (void *)WKBD_WINDOW2,
770 NULL, getKeybind, setKeyGrab, NULL, NULL},
771 {"WindowShortcut3Key", "None", (void *)WKBD_WINDOW3,
772 NULL, getKeybind, setKeyGrab, NULL, NULL},
773 {"WindowShortcut4Key", "None", (void *)WKBD_WINDOW4,
774 NULL, getKeybind, setKeyGrab, NULL, NULL},
775 {"WindowShortcut5Key", "None", (void *)WKBD_WINDOW5,
776 NULL, getKeybind, setKeyGrab, NULL, NULL},
777 {"WindowShortcut6Key", "None", (void *)WKBD_WINDOW6,
778 NULL, getKeybind, setKeyGrab, NULL, NULL},
779 {"WindowShortcut7Key", "None", (void *)WKBD_WINDOW7,
780 NULL, getKeybind, setKeyGrab, NULL, NULL},
781 {"WindowShortcut8Key", "None", (void *)WKBD_WINDOW8,
782 NULL, getKeybind, setKeyGrab, NULL, NULL},
783 {"WindowShortcut9Key", "None", (void *)WKBD_WINDOW9,
784 NULL, getKeybind, setKeyGrab, NULL, NULL},
785 {"WindowShortcut10Key", "None", (void *)WKBD_WINDOW10,
786 NULL, getKeybind, setKeyGrab, NULL, NULL},
787 {"WindowRelaunchKey", "None", (void *)WKBD_RELAUNCH,
788 NULL, getKeybind, setKeyGrab, NULL, NULL},
789 {"ScreenSwitchKey", "None", (void *)WKBD_SWITCH_SCREEN,
790 NULL, getKeybind, setKeyGrab, NULL, NULL},
791 {"RunKey", "None", (void *)WKBD_RUN,
792 NULL, getKeybind, setKeyGrab, NULL, NULL},
794 #ifdef KEEP_XKB_LOCK_STATUS
795 {"ToggleKbdModeKey", "None", (void *)WKBD_TOGGLE,
796 NULL, getKeybind, setKeyGrab, NULL, NULL},
797 {"KbdModeLock", "NO", NULL,
798 &wPreferences.modelock, getBool, NULL, NULL, NULL},
799 #endif /* KEEP_XKB_LOCK_STATUS */
801 {"NormalCursor", "(builtin, left_ptr)", (void *)WCUR_ROOT,
802 NULL, getCursor, setCursor, NULL, NULL},
803 {"ArrowCursor", "(builtin, top_left_arrow)", (void *)WCUR_ARROW,
804 NULL, getCursor, setCursor, NULL, NULL},
805 {"MoveCursor", "(builtin, fleur)", (void *)WCUR_MOVE,
806 NULL, getCursor, setCursor, NULL, NULL},
807 {"ResizeCursor", "(builtin, sizing)", (void *)WCUR_RESIZE,
808 NULL, getCursor, setCursor, NULL, NULL},
809 {"TopLeftResizeCursor", "(builtin, top_left_corner)", (void *)WCUR_TOPLEFTRESIZE,
810 NULL, getCursor, setCursor, NULL, NULL},
811 {"TopRightResizeCursor", "(builtin, top_right_corner)", (void *)WCUR_TOPRIGHTRESIZE,
812 NULL, getCursor, setCursor, NULL, NULL},
813 {"BottomLeftResizeCursor", "(builtin, bottom_left_corner)", (void *)WCUR_BOTTOMLEFTRESIZE,
814 NULL, getCursor, setCursor, NULL, NULL},
815 {"BottomRightResizeCursor", "(builtin, bottom_right_corner)", (void *)WCUR_BOTTOMRIGHTRESIZE,
816 NULL, getCursor, setCursor, NULL, NULL},
817 {"VerticalResizeCursor", "(builtin, sb_v_double_arrow)", (void *)WCUR_VERTICALRESIZE,
818 NULL, getCursor, setCursor, NULL, NULL},
819 {"HorizontalResizeCursor", "(builtin, sb_h_double_arrow)", (void *)WCUR_HORIZONRESIZE,
820 NULL, getCursor, setCursor, NULL, NULL},
821 {"WaitCursor", "(builtin, watch)", (void *)WCUR_WAIT,
822 NULL, getCursor, setCursor, NULL, NULL},
823 {"QuestionCursor", "(builtin, question_arrow)", (void *)WCUR_QUESTION,
824 NULL, getCursor, setCursor, NULL, NULL},
825 {"TextCursor", "(builtin, xterm)", (void *)WCUR_TEXT,
826 NULL, getCursor, setCursor, NULL, NULL},
827 {"SelectCursor", "(builtin, cross)", (void *)WCUR_SELECT,
828 NULL, getCursor, setCursor, NULL, NULL},
829 {"DialogHistoryLines", "500", NULL,
830 &wPreferences.history_lines, getInt, NULL, NULL, NULL},
831 {"CycleActiveHeadOnly", "NO", NULL,
832 &wPreferences.cycle_active_head_only, getBool, NULL, NULL, NULL},
833 {"CycleIgnoreMinimized", "NO", NULL,
834 &wPreferences.cycle_ignore_minimized, getBool, NULL, NULL, NULL}
837 static void initDefaults(void)
839 unsigned int i;
840 WDefaultEntry *entry;
842 WMPLSetCaseSensitive(False);
844 for (i = 0; i < wlengthof(optionList); i++) {
845 entry = &optionList[i];
847 entry->plkey = WMCreatePLString(entry->key);
848 if (entry->default_value)
849 entry->plvalue = WMCreatePropListFromDescription(entry->default_value);
850 else
851 entry->plvalue = NULL;
854 for (i = 0; i < wlengthof(staticOptionList); i++) {
855 entry = &staticOptionList[i];
857 entry->plkey = WMCreatePLString(entry->key);
858 if (entry->default_value)
859 entry->plvalue = WMCreatePropListFromDescription(entry->default_value);
860 else
861 entry->plvalue = NULL;
865 static WMPropList *readGlobalDomain(const char *domainName, Bool requireDictionary)
867 WMPropList *globalDict = NULL;
868 char path[PATH_MAX];
869 struct stat stbuf;
871 snprintf(path, sizeof(path), "%s/%s/%s", SYSCONFDIR, GLOBAL_DEFAULTS_SUBDIR, domainName);
872 if (stat(path, &stbuf) >= 0) {
873 globalDict = WMReadPropListFromFile(path);
874 if (globalDict && requireDictionary && !WMIsPLDictionary(globalDict)) {
875 wwarning(_("Domain %s (%s) of global defaults database is corrupted!"), domainName, path);
876 WMReleasePropList(globalDict);
877 globalDict = NULL;
878 } else if (!globalDict) {
879 wwarning(_("could not load domain %s from global defaults database"), domainName);
883 return globalDict;
886 #if defined(GLOBAL_PREAMBLE_MENU_FILE) || defined(GLOBAL_EPILOGUE_MENU_FILE)
887 static void prependMenu(WMPropList * destarr, WMPropList * array)
889 WMPropList *item;
890 int i;
892 for (i = 0; i < WMGetPropListItemCount(array); i++) {
893 item = WMGetFromPLArray(array, i);
894 if (item)
895 WMInsertInPLArray(destarr, i + 1, item);
899 static void appendMenu(WMPropList * destarr, WMPropList * array)
901 WMPropList *item;
902 int i;
904 for (i = 0; i < WMGetPropListItemCount(array); i++) {
905 item = WMGetFromPLArray(array, i);
906 if (item)
907 WMAddToPLArray(destarr, item);
910 #endif
912 void wDefaultsMergeGlobalMenus(WDDomain * menuDomain)
914 WMPropList *menu = menuDomain->dictionary;
915 WMPropList *submenu;
917 if (!menu || !WMIsPLArray(menu))
918 return;
920 #ifdef GLOBAL_PREAMBLE_MENU_FILE
921 submenu = WMReadPropListFromFile(SYSCONFDIR "/" GLOBAL_DEFAULTS_SUBDIR "/" GLOBAL_PREAMBLE_MENU_FILE);
923 if (submenu && !WMIsPLArray(submenu)) {
924 wwarning(_("invalid global menu file %s"), GLOBAL_PREAMBLE_MENU_FILE);
925 WMReleasePropList(submenu);
926 submenu = NULL;
928 if (submenu) {
929 prependMenu(menu, submenu);
930 WMReleasePropList(submenu);
932 #endif
934 #ifdef GLOBAL_EPILOGUE_MENU_FILE
935 submenu = WMReadPropListFromFile(SYSCONFDIR "/" GLOBAL_DEFAULTS_SUBDIR "/" GLOBAL_EPILOGUE_MENU_FILE);
937 if (submenu && !WMIsPLArray(submenu)) {
938 wwarning(_("invalid global menu file %s"), GLOBAL_EPILOGUE_MENU_FILE);
939 WMReleasePropList(submenu);
940 submenu = NULL;
942 if (submenu) {
943 appendMenu(menu, submenu);
944 WMReleasePropList(submenu);
946 #endif
948 menuDomain->dictionary = menu;
951 WDDomain *wDefaultsInitDomain(const char *domain, Bool requireDictionary)
953 WDDomain *db;
954 struct stat stbuf;
955 static int inited = 0;
956 WMPropList *shared_dict = NULL;
958 if (!inited) {
959 inited = 1;
960 initDefaults();
963 db = wmalloc(sizeof(WDDomain));
964 db->domain_name = domain;
965 db->path = wdefaultspathfordomain(domain);
967 if (stat(db->path, &stbuf) >= 0) {
968 db->dictionary = WMReadPropListFromFile(db->path);
969 if (db->dictionary) {
970 if (requireDictionary && !WMIsPLDictionary(db->dictionary)) {
971 WMReleasePropList(db->dictionary);
972 db->dictionary = NULL;
973 wwarning(_("Domain %s (%s) of defaults database is corrupted!"), domain, db->path);
975 db->timestamp = stbuf.st_mtime;
976 } else {
977 wwarning(_("could not load domain %s from user defaults database"), domain);
981 /* global system dictionary */
982 shared_dict = readGlobalDomain(domain, requireDictionary);
984 if (shared_dict && db->dictionary && WMIsPLDictionary(shared_dict) &&
985 WMIsPLDictionary(db->dictionary)) {
986 WMMergePLDictionaries(shared_dict, db->dictionary, True);
987 WMReleasePropList(db->dictionary);
988 db->dictionary = shared_dict;
989 if (stbuf.st_mtime > db->timestamp)
990 db->timestamp = stbuf.st_mtime;
991 } else if (!db->dictionary) {
992 db->dictionary = shared_dict;
993 if (stbuf.st_mtime > db->timestamp)
994 db->timestamp = stbuf.st_mtime;
997 return db;
1000 void wReadStaticDefaults(WMPropList * dict)
1002 WMPropList *plvalue;
1003 WDefaultEntry *entry;
1004 unsigned int i;
1005 void *tdata;
1007 for (i = 0; i < wlengthof(staticOptionList); i++) {
1008 entry = &staticOptionList[i];
1010 if (dict)
1011 plvalue = WMGetFromPLDictionary(dict, entry->plkey);
1012 else
1013 plvalue = NULL;
1015 /* no default in the DB. Use builtin default */
1016 if (!plvalue)
1017 plvalue = entry->plvalue;
1019 if (plvalue) {
1020 /* convert data */
1021 (*entry->convert) (NULL, entry, plvalue, entry->addr, &tdata);
1022 if (entry->update)
1023 (*entry->update) (NULL, entry, tdata, entry->extra_data);
1028 void wDefaultsCheckDomains(void* arg)
1030 WScreen *scr;
1031 struct stat stbuf;
1032 WMPropList *shared_dict = NULL;
1033 WMPropList *dict;
1034 int i;
1036 /* Parameter not used, but tell the compiler that it is ok */
1037 (void) arg;
1039 if (stat(w_global.domain.wmaker->path, &stbuf) >= 0 && w_global.domain.wmaker->timestamp < stbuf.st_mtime) {
1040 w_global.domain.wmaker->timestamp = stbuf.st_mtime;
1042 /* Global dictionary */
1043 shared_dict = readGlobalDomain("WindowMaker", True);
1045 /* User dictionary */
1046 dict = WMReadPropListFromFile(w_global.domain.wmaker->path);
1048 if (dict) {
1049 if (!WMIsPLDictionary(dict)) {
1050 WMReleasePropList(dict);
1051 dict = NULL;
1052 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
1053 "WindowMaker", w_global.domain.wmaker->path);
1054 } else {
1055 if (shared_dict) {
1056 WMMergePLDictionaries(shared_dict, dict, True);
1057 WMReleasePropList(dict);
1058 dict = shared_dict;
1059 shared_dict = NULL;
1062 for (i = 0; i < w_global.screen_count; i++) {
1063 scr = wScreenWithNumber(i);
1064 if (scr)
1065 wReadDefaults(scr, dict);
1068 if (w_global.domain.wmaker->dictionary)
1069 WMReleasePropList(w_global.domain.wmaker->dictionary);
1071 w_global.domain.wmaker->dictionary = dict;
1073 } else {
1074 wwarning(_("could not load domain %s from user defaults database"), "WindowMaker");
1077 if (shared_dict)
1078 WMReleasePropList(shared_dict);
1082 if (stat(w_global.domain.window_attr->path, &stbuf) >= 0 && w_global.domain.window_attr->timestamp < stbuf.st_mtime) {
1083 /* global dictionary */
1084 shared_dict = readGlobalDomain("WMWindowAttributes", True);
1085 /* user dictionary */
1086 dict = WMReadPropListFromFile(w_global.domain.window_attr->path);
1087 if (dict) {
1088 if (!WMIsPLDictionary(dict)) {
1089 WMReleasePropList(dict);
1090 dict = NULL;
1091 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
1092 "WMWindowAttributes", w_global.domain.window_attr->path);
1093 } else {
1094 if (shared_dict) {
1095 WMMergePLDictionaries(shared_dict, dict, True);
1096 WMReleasePropList(dict);
1097 dict = shared_dict;
1098 shared_dict = NULL;
1101 if (w_global.domain.window_attr->dictionary)
1102 WMReleasePropList(w_global.domain.window_attr->dictionary);
1104 w_global.domain.window_attr->dictionary = dict;
1105 for (i = 0; i < w_global.screen_count; i++) {
1106 scr = wScreenWithNumber(i);
1107 if (scr) {
1108 wDefaultUpdateIcons(scr);
1110 /* Update the panel image if changed */
1111 /* Don't worry. If the image is the same these
1112 * functions will have no performance impact. */
1113 create_logo_image(scr);
1117 } else {
1118 wwarning(_("could not load domain %s from user defaults database"), "WMWindowAttributes");
1121 w_global.domain.window_attr->timestamp = stbuf.st_mtime;
1122 if (shared_dict)
1123 WMReleasePropList(shared_dict);
1126 if (stat(w_global.domain.root_menu->path, &stbuf) >= 0 && w_global.domain.root_menu->timestamp < stbuf.st_mtime) {
1127 dict = WMReadPropListFromFile(w_global.domain.root_menu->path);
1128 if (dict) {
1129 if (!WMIsPLArray(dict) && !WMIsPLString(dict)) {
1130 WMReleasePropList(dict);
1131 dict = NULL;
1132 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
1133 "WMRootMenu", w_global.domain.root_menu->path);
1134 } else {
1135 if (w_global.domain.root_menu->dictionary)
1136 WMReleasePropList(w_global.domain.root_menu->dictionary);
1138 w_global.domain.root_menu->dictionary = dict;
1139 wDefaultsMergeGlobalMenus(w_global.domain.root_menu);
1141 } else {
1142 wwarning(_("could not load domain %s from user defaults database"), "WMRootMenu");
1144 w_global.domain.root_menu->timestamp = stbuf.st_mtime;
1146 #ifndef HAVE_INOTIFY
1147 if (!arg)
1148 WMAddTimerHandler(DEFAULTS_CHECK_INTERVAL, wDefaultsCheckDomains, arg);
1149 #endif
1152 void wReadDefaults(WScreen * scr, WMPropList * new_dict)
1154 WMPropList *plvalue, *old_value;
1155 WDefaultEntry *entry;
1156 unsigned int i;
1157 int update_workspace_back = 0; /* kluge :/ */
1158 unsigned int needs_refresh;
1159 void *tdata;
1160 WMPropList *old_dict = (w_global.domain.wmaker->dictionary != new_dict ? w_global.domain.wmaker->dictionary : NULL);
1162 needs_refresh = 0;
1164 for (i = 0; i < wlengthof(optionList); i++) {
1165 entry = &optionList[i];
1167 if (new_dict)
1168 plvalue = WMGetFromPLDictionary(new_dict, entry->plkey);
1169 else
1170 plvalue = NULL;
1172 if (!old_dict)
1173 old_value = NULL;
1174 else
1175 old_value = WMGetFromPLDictionary(old_dict, entry->plkey);
1177 if (!plvalue && !old_value) {
1178 /* no default in the DB. Use builtin default */
1179 plvalue = entry->plvalue;
1180 if (plvalue && new_dict)
1181 WMPutInPLDictionary(new_dict, entry->plkey, plvalue);
1183 } else if (!plvalue) {
1184 /* value was deleted from DB. Keep current value */
1185 continue;
1186 } else if (!old_value) {
1187 /* set value for the 1st time */
1188 } else if (!WMIsPropListEqualTo(plvalue, old_value)) {
1189 /* value has changed */
1190 } else {
1191 if (strcmp(entry->key, "WorkspaceBack") == 0
1192 && update_workspace_back && scr->flags.backimage_helper_launched) {
1193 } else {
1194 /* value was not changed since last time */
1195 continue;
1199 if (plvalue) {
1200 /* convert data */
1201 if ((*entry->convert) (scr, entry, plvalue, entry->addr, &tdata)) {
1203 * If the WorkspaceSpecificBack data has been changed
1204 * so that the helper will be launched now, we must be
1205 * sure to send the default background texture config
1206 * to the helper.
1208 if (strcmp(entry->key, "WorkspaceSpecificBack") == 0 &&
1209 !scr->flags.backimage_helper_launched)
1210 update_workspace_back = 1;
1212 if (entry->update)
1213 needs_refresh |= (*entry->update) (scr, entry, tdata, entry->extra_data);
1220 * Backward Compatibility:
1221 * Support the old setting names for Apercu, now called Mini-Preview
1223 * This code should probably stay for at least 2 years, you should not consider removing
1224 * it before year 2017
1226 if (legacy_minipreview_config.enable) {
1227 wwarning(_("your configuration is using old syntax for Mini-Preview settings; consider running WPrefs.app to update"));
1228 wPreferences.miniwin_preview_balloon = legacy_minipreview_config.enable;
1230 if (legacy_minipreview_config.size > 0) {
1232 * the option 'ApercuSize' used to be coded as a multiple of the icon size in v0.95.6
1233 * it is now expressed directly in pixels, but to avoid breaking user's setting we check
1234 * for old coding and convert it now.
1236 if (legacy_minipreview_config.size < 24) {
1237 /* 24 is the minimum icon size proposed in WPref's settings */
1238 wPreferences.minipreview_size = legacy_minipreview_config.size * wPreferences.icon_size;
1239 } else {
1240 wPreferences.minipreview_size = legacy_minipreview_config.size;
1245 if (needs_refresh != 0 && !scr->flags.startup) {
1246 int foo;
1248 foo = 0;
1249 if (needs_refresh & REFRESH_MENU_TITLE_TEXTURE)
1250 foo |= WTextureSettings;
1251 if (needs_refresh & REFRESH_MENU_TITLE_FONT)
1252 foo |= WFontSettings;
1253 if (needs_refresh & REFRESH_MENU_TITLE_COLOR)
1254 foo |= WColorSettings;
1255 if (foo)
1256 WMPostNotificationName(WNMenuTitleAppearanceSettingsChanged, NULL,
1257 (void *)(uintptr_t) foo);
1259 foo = 0;
1260 if (needs_refresh & REFRESH_MENU_TEXTURE)
1261 foo |= WTextureSettings;
1262 if (needs_refresh & REFRESH_MENU_FONT)
1263 foo |= WFontSettings;
1264 if (needs_refresh & REFRESH_MENU_COLOR)
1265 foo |= WColorSettings;
1266 if (foo)
1267 WMPostNotificationName(WNMenuAppearanceSettingsChanged, NULL, (void *)(uintptr_t) foo);
1269 foo = 0;
1270 if (needs_refresh & REFRESH_WINDOW_FONT)
1271 foo |= WFontSettings;
1272 if (needs_refresh & REFRESH_WINDOW_TEXTURES)
1273 foo |= WTextureSettings;
1274 if (needs_refresh & REFRESH_WINDOW_TITLE_COLOR)
1275 foo |= WColorSettings;
1276 if (foo)
1277 WMPostNotificationName(WNWindowAppearanceSettingsChanged, NULL, (void *)(uintptr_t) foo);
1279 if (!(needs_refresh & REFRESH_ICON_TILE)) {
1280 foo = 0;
1281 if (needs_refresh & REFRESH_ICON_FONT)
1282 foo |= WFontSettings;
1283 if (needs_refresh & REFRESH_ICON_TITLE_COLOR)
1284 foo |= WTextureSettings;
1285 if (needs_refresh & REFRESH_ICON_TITLE_BACK)
1286 foo |= WTextureSettings;
1287 if (foo)
1288 WMPostNotificationName(WNIconAppearanceSettingsChanged, NULL,
1289 (void *)(uintptr_t) foo);
1291 if (needs_refresh & REFRESH_ICON_TILE)
1292 WMPostNotificationName(WNIconTileSettingsChanged, NULL, NULL);
1294 if (needs_refresh & REFRESH_WORKSPACE_MENU) {
1295 if (scr->workspace_menu)
1296 wWorkspaceMenuUpdate(scr, scr->workspace_menu);
1297 if (scr->clip_ws_menu)
1298 wWorkspaceMenuUpdate(scr, scr->clip_ws_menu);
1299 if (scr->workspace_submenu)
1300 scr->workspace_submenu->flags.realized = 0;
1301 if (scr->clip_submenu)
1302 scr->clip_submenu->flags.realized = 0;
1307 void wDefaultUpdateIcons(WScreen *scr)
1309 WAppIcon *aicon = scr->app_icon_list;
1310 WDrawerChain *dc;
1311 WWindow *wwin = scr->focused_window;
1313 while (aicon) {
1314 /* Get the application icon, default included */
1315 wIconChangeImageFile(aicon->icon, NULL);
1316 wAppIconPaint(aicon);
1317 aicon = aicon->next;
1320 if (!wPreferences.flags.noclip || wPreferences.flags.clip_merged_in_dock)
1321 wClipIconPaint(scr->clip_icon);
1323 for (dc = scr->drawers; dc != NULL; dc = dc->next)
1324 wDrawerIconPaint(dc->adrawer->icon_array[0]);
1326 while (wwin) {
1327 if (wwin->icon && wwin->flags.miniaturized)
1328 wIconChangeImageFile(wwin->icon, NULL);
1329 wwin = wwin->prev;
1333 /* --------------------------- Local ----------------------- */
1335 #define GET_STRING_OR_DEFAULT(x, var) if (!WMIsPLString(value)) { \
1336 wwarning(_("Wrong option format for key \"%s\". Should be %s."), \
1337 entry->key, x); \
1338 wwarning(_("using default \"%s\" instead"), entry->default_value); \
1339 var = entry->default_value;\
1340 } else var = WMGetFromPLString(value)\
1343 static int string2index(WMPropList *key, WMPropList *val, const char *def, WOptionEnumeration * values)
1345 char *str;
1346 WOptionEnumeration *v;
1347 char buffer[TOTAL_VALUES_LENGTH];
1349 if (WMIsPLString(val) && (str = WMGetFromPLString(val))) {
1350 for (v = values; v->string != NULL; v++) {
1351 if (strcasecmp(v->string, str) == 0)
1352 return v->value;
1356 buffer[0] = 0;
1357 for (v = values; v->string != NULL; v++) {
1358 if (!v->is_alias) {
1359 if (buffer[0] != 0)
1360 strcat(buffer, ", ");
1361 snprintf(buffer+strlen(buffer),
1362 sizeof(buffer)-strlen(buffer)-1, "\"%s\"", v->string);
1365 wwarning(_("wrong option value for key \"%s\"; got \"%s\", should be one of %s."),
1366 WMGetFromPLString(key),
1367 WMIsPLString(val) ? WMGetFromPLString(val) : "(unknown)",
1368 buffer);
1370 if (def) {
1371 return string2index(key, val, NULL, values);
1374 return -1;
1378 * value - is the value in the defaults DB
1379 * addr - is the address to store the data
1380 * ret - is the address to store a pointer to a temporary buffer. ret
1381 * must not be freed and is used by the set functions
1383 static int getBool(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1385 static char data;
1386 const char *val;
1387 int second_pass = 0;
1389 /* Parameter not used, but tell the compiler that it is ok */
1390 (void) scr;
1392 GET_STRING_OR_DEFAULT("Boolean", val);
1394 again:
1395 if ((val[1] == '\0' && (val[0] == 'y' || val[0] == 'Y'))
1396 || strcasecmp(val, "YES") == 0) {
1398 data = 1;
1399 } else if ((val[1] == '\0' && (val[0] == 'n' || val[0] == 'N'))
1400 || strcasecmp(val, "NO") == 0) {
1401 data = 0;
1402 } else {
1403 int i;
1404 if (sscanf(val, "%i", &i) == 1) {
1405 if (i != 0)
1406 data = 1;
1407 else
1408 data = 0;
1409 } else {
1410 wwarning(_("can't convert \"%s\" to boolean for key \"%s\""), val, entry->key);
1411 if (second_pass == 0) {
1412 val = WMGetFromPLString(entry->plvalue);
1413 second_pass = 1;
1414 wwarning(_("using default \"%s\" instead"), val);
1415 goto again;
1417 return False;
1421 if (ret)
1422 *ret = &data;
1423 if (addr)
1424 *(char *)addr = data;
1426 return True;
1429 static int getInt(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1431 static int data;
1432 const char *val;
1434 /* Parameter not used, but tell the compiler that it is ok */
1435 (void) scr;
1437 GET_STRING_OR_DEFAULT("Integer", val);
1439 if (sscanf(val, "%i", &data) != 1) {
1440 wwarning(_("can't convert \"%s\" to integer for key \"%s\""), val, entry->key);
1441 val = WMGetFromPLString(entry->plvalue);
1442 wwarning(_("using default \"%s\" instead"), val);
1443 if (sscanf(val, "%i", &data) != 1) {
1444 return False;
1448 if (ret)
1449 *ret = &data;
1450 if (addr)
1451 *(int *)addr = data;
1453 return True;
1456 static int getCoord(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1458 static WCoord data;
1459 char *val_x, *val_y;
1460 int nelem, changed = 0;
1461 WMPropList *elem_x, *elem_y;
1463 again:
1464 if (!WMIsPLArray(value)) {
1465 wwarning(_("Wrong option format for key \"%s\". Should be %s."), entry->key, "Coordinate");
1466 if (changed == 0) {
1467 value = entry->plvalue;
1468 changed = 1;
1469 wwarning(_("using default \"%s\" instead"), entry->default_value);
1470 goto again;
1472 return False;
1475 nelem = WMGetPropListItemCount(value);
1476 if (nelem != 2) {
1477 wwarning(_("Incorrect number of elements in array for key \"%s\"."), entry->key);
1478 if (changed == 0) {
1479 value = entry->plvalue;
1480 changed = 1;
1481 wwarning(_("using default \"%s\" instead"), entry->default_value);
1482 goto again;
1484 return False;
1487 elem_x = WMGetFromPLArray(value, 0);
1488 elem_y = WMGetFromPLArray(value, 1);
1490 if (!elem_x || !elem_y || !WMIsPLString(elem_x) || !WMIsPLString(elem_y)) {
1491 wwarning(_("Wrong value for key \"%s\". Should be Coordinate."), entry->key);
1492 if (changed == 0) {
1493 value = entry->plvalue;
1494 changed = 1;
1495 wwarning(_("using default \"%s\" instead"), entry->default_value);
1496 goto again;
1498 return False;
1501 val_x = WMGetFromPLString(elem_x);
1502 val_y = WMGetFromPLString(elem_y);
1504 if (sscanf(val_x, "%i", &data.x) != 1 || sscanf(val_y, "%i", &data.y) != 1) {
1505 wwarning(_("can't convert array to integers for \"%s\"."), entry->key);
1506 if (changed == 0) {
1507 value = entry->plvalue;
1508 changed = 1;
1509 wwarning(_("using default \"%s\" instead"), entry->default_value);
1510 goto again;
1512 return False;
1515 if (data.x < 0)
1516 data.x = 0;
1517 else if (data.x > scr->scr_width / 3)
1518 data.x = scr->scr_width / 3;
1519 if (data.y < 0)
1520 data.y = 0;
1521 else if (data.y > scr->scr_height / 3)
1522 data.y = scr->scr_height / 3;
1524 if (ret)
1525 *ret = &data;
1526 if (addr)
1527 *(WCoord *) addr = data;
1529 return True;
1532 static int getPropList(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1534 /* Parameter not used, but tell the compiler that it is ok */
1535 (void) scr;
1536 (void) entry;
1537 (void) addr;
1539 WMRetainPropList(value);
1541 *ret = value;
1543 return True;
1546 static int getPathList(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1548 static char *data;
1549 int i, count, len;
1550 char *ptr;
1551 WMPropList *d;
1552 int changed = 0;
1554 /* Parameter not used, but tell the compiler that it is ok */
1555 (void) scr;
1556 (void) ret;
1558 again:
1559 if (!WMIsPLArray(value)) {
1560 wwarning(_("Wrong option format for key \"%s\". Should be %s."), entry->key, "an array of paths");
1561 if (changed == 0) {
1562 value = entry->plvalue;
1563 changed = 1;
1564 wwarning(_("using default \"%s\" instead"), entry->default_value);
1565 goto again;
1567 return False;
1570 i = 0;
1571 count = WMGetPropListItemCount(value);
1572 if (count < 1) {
1573 if (changed == 0) {
1574 value = entry->plvalue;
1575 changed = 1;
1576 wwarning(_("using default \"%s\" instead"), entry->default_value);
1577 goto again;
1579 return False;
1582 len = 0;
1583 for (i = 0; i < count; i++) {
1584 d = WMGetFromPLArray(value, i);
1585 if (!d || !WMIsPLString(d)) {
1586 count = i;
1587 break;
1589 len += strlen(WMGetFromPLString(d)) + 1;
1592 ptr = data = wmalloc(len + 1);
1594 for (i = 0; i < count; i++) {
1595 d = WMGetFromPLArray(value, i);
1596 if (!d || !WMIsPLString(d)) {
1597 break;
1599 strcpy(ptr, WMGetFromPLString(d));
1600 ptr += strlen(WMGetFromPLString(d));
1601 *ptr = ':';
1602 ptr++;
1604 ptr--;
1605 *(ptr--) = 0;
1607 if (*(char **)addr != NULL) {
1608 wfree(*(char **)addr);
1610 *(char **)addr = data;
1612 return True;
1615 static int getEnum(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1617 static signed char data;
1619 /* Parameter not used, but tell the compiler that it is ok */
1620 (void) scr;
1622 data = string2index(entry->plkey, value, entry->default_value, (WOptionEnumeration *) entry->extra_data);
1623 if (data < 0)
1624 return False;
1626 if (ret)
1627 *ret = &data;
1628 if (addr)
1629 *(signed char *)addr = data;
1631 return True;
1635 * (solid <color>)
1636 * (hgradient <color> <color>)
1637 * (vgradient <color> <color>)
1638 * (dgradient <color> <color>)
1639 * (mhgradient <color> <color> ...)
1640 * (mvgradient <color> <color> ...)
1641 * (mdgradient <color> <color> ...)
1642 * (igradient <color1> <color1> <thickness1> <color2> <color2> <thickness2>)
1643 * (tpixmap <file> <color>)
1644 * (spixmap <file> <color>)
1645 * (cpixmap <file> <color>)
1646 * (thgradient <file> <opaqueness> <color> <color>)
1647 * (tvgradient <file> <opaqueness> <color> <color>)
1648 * (tdgradient <file> <opaqueness> <color> <color>)
1649 * (function <lib> <function> ...)
1652 static WTexture *parse_texture(WScreen * scr, WMPropList * pl)
1654 WMPropList *elem;
1655 char *val;
1656 int nelem;
1657 WTexture *texture = NULL;
1659 nelem = WMGetPropListItemCount(pl);
1660 if (nelem < 1)
1661 return NULL;
1663 elem = WMGetFromPLArray(pl, 0);
1664 if (!elem || !WMIsPLString(elem))
1665 return NULL;
1666 val = WMGetFromPLString(elem);
1668 if (strcasecmp(val, "solid") == 0) {
1669 XColor color;
1671 if (nelem != 2)
1672 return NULL;
1674 /* get color */
1676 elem = WMGetFromPLArray(pl, 1);
1677 if (!elem || !WMIsPLString(elem))
1678 return NULL;
1679 val = WMGetFromPLString(elem);
1681 if (!XParseColor(dpy, scr->w_colormap, val, &color)) {
1682 wwarning(_("\"%s\" is not a valid color name"), val);
1683 return NULL;
1686 texture = (WTexture *) wTextureMakeSolid(scr, &color);
1687 } else if (strcasecmp(val, "dgradient") == 0
1688 || strcasecmp(val, "vgradient") == 0 || strcasecmp(val, "hgradient") == 0) {
1689 RColor color1, color2;
1690 XColor xcolor;
1691 int type;
1693 if (nelem != 3) {
1694 wwarning(_("bad number of arguments in gradient specification"));
1695 return NULL;
1698 if (val[0] == 'd' || val[0] == 'D')
1699 type = WTEX_DGRADIENT;
1700 else if (val[0] == 'h' || val[0] == 'H')
1701 type = WTEX_HGRADIENT;
1702 else
1703 type = WTEX_VGRADIENT;
1705 /* get from color */
1706 elem = WMGetFromPLArray(pl, 1);
1707 if (!elem || !WMIsPLString(elem))
1708 return NULL;
1709 val = WMGetFromPLString(elem);
1711 if (!XParseColor(dpy, scr->w_colormap, val, &xcolor)) {
1712 wwarning(_("\"%s\" is not a valid color name"), val);
1713 return NULL;
1715 color1.alpha = 255;
1716 color1.red = xcolor.red >> 8;
1717 color1.green = xcolor.green >> 8;
1718 color1.blue = xcolor.blue >> 8;
1720 /* get to color */
1721 elem = WMGetFromPLArray(pl, 2);
1722 if (!elem || !WMIsPLString(elem)) {
1723 return NULL;
1725 val = WMGetFromPLString(elem);
1727 if (!XParseColor(dpy, scr->w_colormap, val, &xcolor)) {
1728 wwarning(_("\"%s\" is not a valid color name"), val);
1729 return NULL;
1731 color2.alpha = 255;
1732 color2.red = xcolor.red >> 8;
1733 color2.green = xcolor.green >> 8;
1734 color2.blue = xcolor.blue >> 8;
1736 texture = (WTexture *) wTextureMakeGradient(scr, type, &color1, &color2);
1738 } else if (strcasecmp(val, "igradient") == 0) {
1739 RColor colors1[2], colors2[2];
1740 int th1, th2;
1741 XColor xcolor;
1742 int i;
1744 if (nelem != 7) {
1745 wwarning(_("bad number of arguments in gradient specification"));
1746 return NULL;
1749 /* get from color */
1750 for (i = 0; i < 2; i++) {
1751 elem = WMGetFromPLArray(pl, 1 + i);
1752 if (!elem || !WMIsPLString(elem))
1753 return NULL;
1754 val = WMGetFromPLString(elem);
1756 if (!XParseColor(dpy, scr->w_colormap, val, &xcolor)) {
1757 wwarning(_("\"%s\" is not a valid color name"), val);
1758 return NULL;
1760 colors1[i].alpha = 255;
1761 colors1[i].red = xcolor.red >> 8;
1762 colors1[i].green = xcolor.green >> 8;
1763 colors1[i].blue = xcolor.blue >> 8;
1765 elem = WMGetFromPLArray(pl, 3);
1766 if (!elem || !WMIsPLString(elem))
1767 return NULL;
1768 val = WMGetFromPLString(elem);
1769 th1 = atoi(val);
1771 /* get from color */
1772 for (i = 0; i < 2; i++) {
1773 elem = WMGetFromPLArray(pl, 4 + i);
1774 if (!elem || !WMIsPLString(elem))
1775 return NULL;
1776 val = WMGetFromPLString(elem);
1778 if (!XParseColor(dpy, scr->w_colormap, val, &xcolor)) {
1779 wwarning(_("\"%s\" is not a valid color name"), val);
1780 return NULL;
1782 colors2[i].alpha = 255;
1783 colors2[i].red = xcolor.red >> 8;
1784 colors2[i].green = xcolor.green >> 8;
1785 colors2[i].blue = xcolor.blue >> 8;
1787 elem = WMGetFromPLArray(pl, 6);
1788 if (!elem || !WMIsPLString(elem))
1789 return NULL;
1790 val = WMGetFromPLString(elem);
1791 th2 = atoi(val);
1793 texture = (WTexture *) wTextureMakeIGradient(scr, th1, colors1, th2, colors2);
1795 } else if (strcasecmp(val, "mhgradient") == 0
1796 || strcasecmp(val, "mvgradient") == 0 || strcasecmp(val, "mdgradient") == 0) {
1797 XColor color;
1798 RColor **colors;
1799 int i, count;
1800 int type;
1802 if (nelem < 3) {
1803 wwarning(_("too few arguments in multicolor gradient specification"));
1804 return NULL;
1807 if (val[1] == 'h' || val[1] == 'H')
1808 type = WTEX_MHGRADIENT;
1809 else if (val[1] == 'v' || val[1] == 'V')
1810 type = WTEX_MVGRADIENT;
1811 else
1812 type = WTEX_MDGRADIENT;
1814 count = nelem - 1;
1816 colors = wmalloc(sizeof(RColor *) * (count + 1));
1818 for (i = 0; i < count; i++) {
1819 elem = WMGetFromPLArray(pl, i + 1);
1820 if (!elem || !WMIsPLString(elem)) {
1821 for (--i; i >= 0; --i) {
1822 wfree(colors[i]);
1824 wfree(colors);
1825 return NULL;
1827 val = WMGetFromPLString(elem);
1829 if (!XParseColor(dpy, scr->w_colormap, val, &color)) {
1830 wwarning(_("\"%s\" is not a valid color name"), val);
1831 for (--i; i >= 0; --i) {
1832 wfree(colors[i]);
1834 wfree(colors);
1835 return NULL;
1836 } else {
1837 colors[i] = wmalloc(sizeof(RColor));
1838 colors[i]->red = color.red >> 8;
1839 colors[i]->green = color.green >> 8;
1840 colors[i]->blue = color.blue >> 8;
1843 colors[i] = NULL;
1845 texture = (WTexture *) wTextureMakeMGradient(scr, type, colors);
1846 } else if (strcasecmp(val, "spixmap") == 0 ||
1847 strcasecmp(val, "cpixmap") == 0 || strcasecmp(val, "tpixmap") == 0) {
1848 XColor color;
1849 int type;
1851 if (nelem != 3)
1852 return NULL;
1854 if (val[0] == 's' || val[0] == 'S')
1855 type = WTP_SCALE;
1856 else if (val[0] == 'c' || val[0] == 'C')
1857 type = WTP_CENTER;
1858 else
1859 type = WTP_TILE;
1861 /* get color */
1862 elem = WMGetFromPLArray(pl, 2);
1863 if (!elem || !WMIsPLString(elem)) {
1864 return NULL;
1866 val = WMGetFromPLString(elem);
1868 if (!XParseColor(dpy, scr->w_colormap, val, &color)) {
1869 wwarning(_("\"%s\" is not a valid color name"), val);
1870 return NULL;
1873 /* file name */
1874 elem = WMGetFromPLArray(pl, 1);
1875 if (!elem || !WMIsPLString(elem))
1876 return NULL;
1877 val = WMGetFromPLString(elem);
1879 texture = (WTexture *) wTextureMakePixmap(scr, type, val, &color);
1880 } else if (strcasecmp(val, "thgradient") == 0
1881 || strcasecmp(val, "tvgradient") == 0 || strcasecmp(val, "tdgradient") == 0) {
1882 RColor color1, color2;
1883 XColor xcolor;
1884 int opacity;
1885 int style;
1887 if (val[1] == 'h' || val[1] == 'H')
1888 style = WTEX_THGRADIENT;
1889 else if (val[1] == 'v' || val[1] == 'V')
1890 style = WTEX_TVGRADIENT;
1891 else
1892 style = WTEX_TDGRADIENT;
1894 if (nelem != 5) {
1895 wwarning(_("bad number of arguments in textured gradient specification"));
1896 return NULL;
1899 /* get from color */
1900 elem = WMGetFromPLArray(pl, 3);
1901 if (!elem || !WMIsPLString(elem))
1902 return NULL;
1903 val = WMGetFromPLString(elem);
1905 if (!XParseColor(dpy, scr->w_colormap, val, &xcolor)) {
1906 wwarning(_("\"%s\" is not a valid color name"), val);
1907 return NULL;
1909 color1.alpha = 255;
1910 color1.red = xcolor.red >> 8;
1911 color1.green = xcolor.green >> 8;
1912 color1.blue = xcolor.blue >> 8;
1914 /* get to color */
1915 elem = WMGetFromPLArray(pl, 4);
1916 if (!elem || !WMIsPLString(elem)) {
1917 return NULL;
1919 val = WMGetFromPLString(elem);
1921 if (!XParseColor(dpy, scr->w_colormap, val, &xcolor)) {
1922 wwarning(_("\"%s\" is not a valid color name"), val);
1923 return NULL;
1925 color2.alpha = 255;
1926 color2.red = xcolor.red >> 8;
1927 color2.green = xcolor.green >> 8;
1928 color2.blue = xcolor.blue >> 8;
1930 /* get opacity */
1931 elem = WMGetFromPLArray(pl, 2);
1932 if (!elem || !WMIsPLString(elem))
1933 opacity = 128;
1934 else
1935 val = WMGetFromPLString(elem);
1937 if (!val || (opacity = atoi(val)) < 0 || opacity > 255) {
1938 wwarning(_("bad opacity value for tgradient texture \"%s\". Should be [0..255]"), val);
1939 opacity = 128;
1942 /* get file name */
1943 elem = WMGetFromPLArray(pl, 1);
1944 if (!elem || !WMIsPLString(elem))
1945 return NULL;
1946 val = WMGetFromPLString(elem);
1948 texture = (WTexture *) wTextureMakeTGradient(scr, style, &color1, &color2, val, opacity);
1949 } else if (strcasecmp(val, "function") == 0) {
1950 /* Leave this in to handle the unlikely case of
1951 * someone actually having function textures configured */
1952 wwarning("function texture support has been removed");
1953 return NULL;
1954 } else {
1955 wwarning(_("invalid texture type %s"), val);
1956 return NULL;
1958 return texture;
1961 static int getTexture(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1963 static WTexture *texture;
1964 int changed = 0;
1966 again:
1967 if (!WMIsPLArray(value)) {
1968 wwarning(_("Wrong option format for key \"%s\". Should be %s."), entry->key, "Texture");
1969 if (changed == 0) {
1970 value = entry->plvalue;
1971 changed = 1;
1972 wwarning(_("using default \"%s\" instead"), entry->default_value);
1973 goto again;
1975 return False;
1978 if (strcmp(entry->key, "WidgetColor") == 0 && !changed) {
1979 WMPropList *pl;
1981 pl = WMGetFromPLArray(value, 0);
1982 if (!pl || !WMIsPLString(pl) || !WMGetFromPLString(pl)
1983 || strcasecmp(WMGetFromPLString(pl), "solid") != 0) {
1984 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1985 entry->key, "Solid Texture");
1987 value = entry->plvalue;
1988 changed = 1;
1989 wwarning(_("using default \"%s\" instead"), entry->default_value);
1990 goto again;
1994 texture = parse_texture(scr, value);
1996 if (!texture) {
1997 wwarning(_("Error in texture specification for key \"%s\""), entry->key);
1998 if (changed == 0) {
1999 value = entry->plvalue;
2000 changed = 1;
2001 wwarning(_("using default \"%s\" instead"), entry->default_value);
2002 goto again;
2004 return False;
2007 if (ret)
2008 *ret = &texture;
2010 if (addr)
2011 *(WTexture **) addr = texture;
2013 return True;
2016 static int getWSBackground(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
2018 WMPropList *elem;
2019 int changed = 0;
2020 char *val;
2021 int nelem;
2023 /* Parameter not used, but tell the compiler that it is ok */
2024 (void) scr;
2025 (void) addr;
2027 again:
2028 if (!WMIsPLArray(value)) {
2029 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
2030 "WorkspaceBack", "Texture or None");
2031 if (changed == 0) {
2032 value = entry->plvalue;
2033 changed = 1;
2034 wwarning(_("using default \"%s\" instead"), entry->default_value);
2035 goto again;
2037 return False;
2040 /* only do basic error checking and verify for None texture */
2042 nelem = WMGetPropListItemCount(value);
2043 if (nelem > 0) {
2044 elem = WMGetFromPLArray(value, 0);
2045 if (!elem || !WMIsPLString(elem)) {
2046 wwarning(_("Wrong type for workspace background. Should be a texture type."));
2047 if (changed == 0) {
2048 value = entry->plvalue;
2049 changed = 1;
2050 wwarning(_("using default \"%s\" instead"), entry->default_value);
2051 goto again;
2053 return False;
2055 val = WMGetFromPLString(elem);
2057 if (strcasecmp(val, "None") == 0)
2058 return True;
2060 *ret = WMRetainPropList(value);
2062 return True;
2065 static int
2066 getWSSpecificBackground(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
2068 WMPropList *elem;
2069 int nelem;
2070 int changed = 0;
2072 /* Parameter not used, but tell the compiler that it is ok */
2073 (void) scr;
2074 (void) addr;
2076 again:
2077 if (!WMIsPLArray(value)) {
2078 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
2079 "WorkspaceSpecificBack", "an array of textures");
2080 if (changed == 0) {
2081 value = entry->plvalue;
2082 changed = 1;
2083 wwarning(_("using default \"%s\" instead"), entry->default_value);
2084 goto again;
2086 return False;
2089 /* only do basic error checking and verify for None texture */
2091 nelem = WMGetPropListItemCount(value);
2092 if (nelem > 0) {
2093 while (nelem--) {
2094 elem = WMGetFromPLArray(value, nelem);
2095 if (!elem || !WMIsPLArray(elem)) {
2096 wwarning(_("Wrong type for background of workspace %i. Should be a texture."),
2097 nelem);
2102 *ret = WMRetainPropList(value);
2104 #ifdef notworking
2106 * Kluge to force wmsetbg helper to set the default background.
2107 * If the WorkspaceSpecificBack is changed once wmaker has started,
2108 * the WorkspaceBack won't be sent to the helper, unless the user
2109 * changes it's value too. So, we must force this by removing the
2110 * value from the defaults DB.
2112 if (!scr->flags.backimage_helper_launched && !scr->flags.startup) {
2113 WMPropList *key = WMCreatePLString("WorkspaceBack");
2115 WMRemoveFromPLDictionary(w_global.domain.wmaker->dictionary, key);
2117 WMReleasePropList(key);
2119 #endif
2120 return True;
2123 static int getFont(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
2125 static WMFont *font;
2126 const char *val;
2128 (void) addr;
2130 GET_STRING_OR_DEFAULT("Font", val);
2132 font = WMCreateFont(scr->wmscreen, val);
2133 if (!font)
2134 font = WMCreateFont(scr->wmscreen, "fixed");
2136 if (!font) {
2137 wfatal(_("could not load any usable font!!!"));
2138 exit(1);
2141 if (ret)
2142 *ret = font;
2144 /* can't assign font value outside update function */
2145 wassertrv(addr == NULL, True);
2147 return True;
2150 static int getColor(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
2152 static XColor color;
2153 const char *val;
2154 int second_pass = 0;
2156 (void) addr;
2158 GET_STRING_OR_DEFAULT("Color", val);
2160 again:
2161 if (!wGetColor(scr, val, &color)) {
2162 wwarning(_("could not get color for key \"%s\""), entry->key);
2163 if (second_pass == 0) {
2164 val = WMGetFromPLString(entry->plvalue);
2165 second_pass = 1;
2166 wwarning(_("using default \"%s\" instead"), val);
2167 goto again;
2169 return False;
2172 if (ret)
2173 *ret = &color;
2175 assert(addr == NULL);
2177 if (addr)
2178 *(unsigned long*)addr = pixel;
2181 return True;
2184 static int getKeybind(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
2186 static WShortKey shortcut;
2187 KeySym ksym;
2188 const char *val;
2189 char *k;
2190 char buf[MAX_SHORTCUT_LENGTH], *b;
2192 /* Parameter not used, but tell the compiler that it is ok */
2193 (void) scr;
2194 (void) addr;
2196 GET_STRING_OR_DEFAULT("Key spec", val);
2198 if (!val || strcasecmp(val, "NONE") == 0) {
2199 shortcut.keycode = 0;
2200 shortcut.modifier = 0;
2201 if (ret)
2202 *ret = &shortcut;
2203 return True;
2206 wstrlcpy(buf, val, MAX_SHORTCUT_LENGTH);
2208 b = (char *)buf;
2210 /* get modifiers */
2211 shortcut.modifier = 0;
2212 while ((k = strchr(b, '+')) != NULL) {
2213 int mod;
2215 *k = 0;
2216 mod = wXModifierFromKey(b);
2217 if (mod < 0) {
2218 wwarning(_("%s: invalid key modifier \"%s\""), entry->key, b);
2219 return False;
2221 shortcut.modifier |= mod;
2223 b = k + 1;
2226 /* get key */
2227 ksym = XStringToKeysym(b);
2229 if (ksym == NoSymbol) {
2230 wwarning(_("%s:invalid kbd shortcut specification \"%s\""), entry->key, val);
2231 return False;
2234 shortcut.keycode = XKeysymToKeycode(dpy, ksym);
2235 if (shortcut.keycode == 0) {
2236 wwarning(_("%s:invalid key in shortcut \"%s\""), entry->key, val);
2237 return False;
2240 if (ret)
2241 *ret = &shortcut;
2243 return True;
2246 static int getModMask(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
2248 static int mask;
2249 const char *str;
2251 /* Parameter not used, but tell the compiler that it is ok */
2252 (void) scr;
2254 GET_STRING_OR_DEFAULT("Modifier Key", str);
2256 if (!str)
2257 return False;
2259 mask = wXModifierFromKey(str);
2260 if (mask < 0) {
2261 wwarning(_("%s: modifier key %s is not valid"), entry->key, str);
2262 mask = 0;
2263 return False;
2266 if (addr)
2267 *(int *)addr = mask;
2269 if (ret)
2270 *ret = &mask;
2272 return True;
2275 # include <X11/cursorfont.h>
2276 typedef struct {
2277 const char *name;
2278 int id;
2279 } WCursorLookup;
2281 #define CURSOR_ID_NONE (XC_num_glyphs)
2283 static const WCursorLookup cursor_table[] = {
2284 {"X_cursor", XC_X_cursor},
2285 {"arrow", XC_arrow},
2286 {"based_arrow_down", XC_based_arrow_down},
2287 {"based_arrow_up", XC_based_arrow_up},
2288 {"boat", XC_boat},
2289 {"bogosity", XC_bogosity},
2290 {"bottom_left_corner", XC_bottom_left_corner},
2291 {"bottom_right_corner", XC_bottom_right_corner},
2292 {"bottom_side", XC_bottom_side},
2293 {"bottom_tee", XC_bottom_tee},
2294 {"box_spiral", XC_box_spiral},
2295 {"center_ptr", XC_center_ptr},
2296 {"circle", XC_circle},
2297 {"clock", XC_clock},
2298 {"coffee_mug", XC_coffee_mug},
2299 {"cross", XC_cross},
2300 {"cross_reverse", XC_cross_reverse},
2301 {"crosshair", XC_crosshair},
2302 {"diamond_cross", XC_diamond_cross},
2303 {"dot", XC_dot},
2304 {"dotbox", XC_dotbox},
2305 {"double_arrow", XC_double_arrow},
2306 {"draft_large", XC_draft_large},
2307 {"draft_small", XC_draft_small},
2308 {"draped_box", XC_draped_box},
2309 {"exchange", XC_exchange},
2310 {"fleur", XC_fleur},
2311 {"gobbler", XC_gobbler},
2312 {"gumby", XC_gumby},
2313 {"hand1", XC_hand1},
2314 {"hand2", XC_hand2},
2315 {"heart", XC_heart},
2316 {"icon", XC_icon},
2317 {"iron_cross", XC_iron_cross},
2318 {"left_ptr", XC_left_ptr},
2319 {"left_side", XC_left_side},
2320 {"left_tee", XC_left_tee},
2321 {"leftbutton", XC_leftbutton},
2322 {"ll_angle", XC_ll_angle},
2323 {"lr_angle", XC_lr_angle},
2324 {"man", XC_man},
2325 {"middlebutton", XC_middlebutton},
2326 {"mouse", XC_mouse},
2327 {"pencil", XC_pencil},
2328 {"pirate", XC_pirate},
2329 {"plus", XC_plus},
2330 {"question_arrow", XC_question_arrow},
2331 {"right_ptr", XC_right_ptr},
2332 {"right_side", XC_right_side},
2333 {"right_tee", XC_right_tee},
2334 {"rightbutton", XC_rightbutton},
2335 {"rtl_logo", XC_rtl_logo},
2336 {"sailboat", XC_sailboat},
2337 {"sb_down_arrow", XC_sb_down_arrow},
2338 {"sb_h_double_arrow", XC_sb_h_double_arrow},
2339 {"sb_left_arrow", XC_sb_left_arrow},
2340 {"sb_right_arrow", XC_sb_right_arrow},
2341 {"sb_up_arrow", XC_sb_up_arrow},
2342 {"sb_v_double_arrow", XC_sb_v_double_arrow},
2343 {"shuttle", XC_shuttle},
2344 {"sizing", XC_sizing},
2345 {"spider", XC_spider},
2346 {"spraycan", XC_spraycan},
2347 {"star", XC_star},
2348 {"target", XC_target},
2349 {"tcross", XC_tcross},
2350 {"top_left_arrow", XC_top_left_arrow},
2351 {"top_left_corner", XC_top_left_corner},
2352 {"top_right_corner", XC_top_right_corner},
2353 {"top_side", XC_top_side},
2354 {"top_tee", XC_top_tee},
2355 {"trek", XC_trek},
2356 {"ul_angle", XC_ul_angle},
2357 {"umbrella", XC_umbrella},
2358 {"ur_angle", XC_ur_angle},
2359 {"watch", XC_watch},
2360 {"xterm", XC_xterm},
2361 {NULL, CURSOR_ID_NONE}
2364 static void check_bitmap_status(int status, const char *filename, Pixmap bitmap)
2366 switch (status) {
2367 case BitmapOpenFailed:
2368 wwarning(_("failed to open bitmap file \"%s\""), filename);
2369 break;
2370 case BitmapFileInvalid:
2371 wwarning(_("\"%s\" is not a valid bitmap file"), filename);
2372 break;
2373 case BitmapNoMemory:
2374 wwarning(_("out of memory reading bitmap file \"%s\""), filename);
2375 break;
2376 case BitmapSuccess:
2377 XFreePixmap(dpy, bitmap);
2378 break;
2383 * (none)
2384 * (builtin, <cursor_name>)
2385 * (bitmap, <cursor_bitmap>, <cursor_mask>)
2387 static int parse_cursor(WScreen * scr, WMPropList * pl, Cursor * cursor)
2389 WMPropList *elem;
2390 char *val;
2391 int nelem;
2392 int status = 0;
2394 nelem = WMGetPropListItemCount(pl);
2395 if (nelem < 1) {
2396 return (status);
2398 elem = WMGetFromPLArray(pl, 0);
2399 if (!elem || !WMIsPLString(elem)) {
2400 return (status);
2402 val = WMGetFromPLString(elem);
2404 if (strcasecmp(val, "none") == 0) {
2405 status = 1;
2406 *cursor = None;
2407 } else if (strcasecmp(val, "builtin") == 0) {
2408 int i;
2409 int cursor_id = CURSOR_ID_NONE;
2411 if (nelem != 2) {
2412 wwarning(_("bad number of arguments in cursor specification"));
2413 return (status);
2415 elem = WMGetFromPLArray(pl, 1);
2416 if (!elem || !WMIsPLString(elem)) {
2417 return (status);
2419 val = WMGetFromPLString(elem);
2421 for (i = 0; cursor_table[i].name != NULL; i++) {
2422 if (strcasecmp(val, cursor_table[i].name) == 0) {
2423 cursor_id = cursor_table[i].id;
2424 break;
2427 if (CURSOR_ID_NONE == cursor_id) {
2428 wwarning(_("unknown builtin cursor name \"%s\""), val);
2429 } else {
2430 *cursor = XCreateFontCursor(dpy, cursor_id);
2431 status = 1;
2433 } else if (strcasecmp(val, "bitmap") == 0) {
2434 char *bitmap_name;
2435 char *mask_name;
2436 int bitmap_status;
2437 int mask_status;
2438 Pixmap bitmap;
2439 Pixmap mask;
2440 unsigned int w, h;
2441 int x, y;
2442 XColor fg, bg;
2444 if (nelem != 3) {
2445 wwarning(_("bad number of arguments in cursor specification"));
2446 return (status);
2448 elem = WMGetFromPLArray(pl, 1);
2449 if (!elem || !WMIsPLString(elem)) {
2450 return (status);
2452 val = WMGetFromPLString(elem);
2453 bitmap_name = FindImage(wPreferences.pixmap_path, val);
2454 if (!bitmap_name) {
2455 wwarning(_("could not find cursor bitmap file \"%s\""), val);
2456 return (status);
2458 elem = WMGetFromPLArray(pl, 2);
2459 if (!elem || !WMIsPLString(elem)) {
2460 wfree(bitmap_name);
2461 return (status);
2463 val = WMGetFromPLString(elem);
2464 mask_name = FindImage(wPreferences.pixmap_path, val);
2465 if (!mask_name) {
2466 wfree(bitmap_name);
2467 wwarning(_("could not find cursor bitmap file \"%s\""), val);
2468 return (status);
2470 mask_status = XReadBitmapFile(dpy, scr->w_win, mask_name, &w, &h, &mask, &x, &y);
2471 bitmap_status = XReadBitmapFile(dpy, scr->w_win, bitmap_name, &w, &h, &bitmap, &x, &y);
2472 if ((BitmapSuccess == bitmap_status) && (BitmapSuccess == mask_status)) {
2473 fg.pixel = scr->black_pixel;
2474 bg.pixel = scr->white_pixel;
2475 XQueryColor(dpy, scr->w_colormap, &fg);
2476 XQueryColor(dpy, scr->w_colormap, &bg);
2477 *cursor = XCreatePixmapCursor(dpy, bitmap, mask, &fg, &bg, x, y);
2478 status = 1;
2480 check_bitmap_status(bitmap_status, bitmap_name, bitmap);
2481 check_bitmap_status(mask_status, mask_name, mask);
2482 wfree(bitmap_name);
2483 wfree(mask_name);
2485 return (status);
2488 static int getCursor(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
2490 static Cursor cursor;
2491 int status;
2492 int changed = 0;
2494 again:
2495 if (!WMIsPLArray(value)) {
2496 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
2497 entry->key, "cursor specification");
2498 if (!changed) {
2499 value = entry->plvalue;
2500 changed = 1;
2501 wwarning(_("using default \"%s\" instead"), entry->default_value);
2502 goto again;
2504 return (False);
2506 status = parse_cursor(scr, value, &cursor);
2507 if (!status) {
2508 wwarning(_("Error in cursor specification for key \"%s\""), entry->key);
2509 if (!changed) {
2510 value = entry->plvalue;
2511 changed = 1;
2512 wwarning(_("using default \"%s\" instead"), entry->default_value);
2513 goto again;
2515 return (False);
2517 if (ret) {
2518 *ret = &cursor;
2520 if (addr) {
2521 *(Cursor *) addr = cursor;
2523 return (True);
2526 #undef CURSOR_ID_NONE
2528 /* ---------------- value setting functions --------------- */
2529 static int setJustify(WScreen * scr, WDefaultEntry * entry, void *tdata, void *extra_data)
2531 /* Parameter not used, but tell the compiler that it is ok */
2532 (void) scr;
2533 (void) entry;
2534 (void) tdata;
2535 (void) extra_data;
2537 return REFRESH_WINDOW_TITLE_COLOR;
2540 static int setClearance(WScreen * scr, WDefaultEntry * entry, void *bar, void *foo)
2542 /* Parameter not used, but tell the compiler that it is ok */
2543 (void) scr;
2544 (void) entry;
2545 (void) bar;
2546 (void) foo;
2548 return REFRESH_WINDOW_FONT | REFRESH_BUTTON_IMAGES | REFRESH_MENU_TITLE_FONT | REFRESH_MENU_FONT;
2551 static int setIfDockPresent(WScreen * scr, WDefaultEntry * entry, void *tdata, void *extra_data)
2553 char *flag = tdata;
2554 long which = (long) extra_data;
2556 /* Parameter not used, but tell the compiler that it is ok */
2557 (void) scr;
2558 (void) entry;
2560 switch (which) {
2561 case WM_DOCK:
2562 wPreferences.flags.nodock = wPreferences.flags.nodock || *flag;
2563 // Drawers require the dock
2564 wPreferences.flags.nodrawer = wPreferences.flags.nodrawer || wPreferences.flags.nodock;
2565 break;
2566 case WM_CLIP:
2567 wPreferences.flags.noclip = wPreferences.flags.noclip || *flag;
2568 break;
2569 case WM_DRAWER:
2570 wPreferences.flags.nodrawer = wPreferences.flags.nodrawer || *flag;
2571 break;
2572 default:
2573 break;
2575 return 0;
2578 static int setClipMergedInDock(WScreen *scr, WDefaultEntry *entry, void *tdata, void *foo)
2580 char *flag = tdata;
2582 /* Parameter not used, but tell the compiler that it is ok */
2583 (void) scr;
2584 (void) entry;
2585 (void) foo;
2587 wPreferences.flags.clip_merged_in_dock = *flag;
2588 wPreferences.flags.noclip = wPreferences.flags.noclip || *flag;
2589 return 0;
2592 static int setWrapAppiconsInDock(WScreen *scr, WDefaultEntry *entry, void *tdata, void *foo)
2594 char *flag = tdata;
2596 /* Parameter not used, but tell the compiler that it is ok */
2597 (void) scr;
2598 (void) entry;
2599 (void) foo;
2601 wPreferences.flags.wrap_appicons_in_dock = *flag;
2602 return 0;
2605 static int setStickyIcons(WScreen * scr, WDefaultEntry * entry, void *bar, void *foo)
2607 /* Parameter not used, but tell the compiler that it is ok */
2608 (void) entry;
2609 (void) bar;
2610 (void) foo;
2612 if (scr->workspaces) {
2613 wWorkspaceForceChange(scr, scr->current_workspace);
2614 wArrangeIcons(scr, False);
2616 return 0;
2619 static int setIconTile(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2621 Pixmap pixmap;
2622 RImage *img;
2623 WTexture ** texture = tdata;
2624 int reset = 0;
2626 /* Parameter not used, but tell the compiler that it is ok */
2627 (void) foo;
2629 img = wTextureRenderImage(*texture, wPreferences.icon_size,
2630 wPreferences.icon_size, ((*texture)->any.type & WREL_BORDER_MASK)
2631 ? WREL_ICON : WREL_FLAT);
2632 if (!img) {
2633 wwarning(_("could not render texture for icon background"));
2634 if (!entry->addr)
2635 wTextureDestroy(scr, *texture);
2636 return 0;
2638 RConvertImage(scr->rcontext, img, &pixmap);
2640 if (scr->icon_tile) {
2641 reset = 1;
2642 RReleaseImage(scr->icon_tile);
2643 XFreePixmap(dpy, scr->icon_tile_pixmap);
2646 scr->icon_tile = img;
2648 /* put the icon in the noticeboard hint */
2649 PropSetIconTileHint(scr, img);
2651 if (!wPreferences.flags.noclip || wPreferences.flags.clip_merged_in_dock) {
2652 if (scr->clip_tile) {
2653 RReleaseImage(scr->clip_tile);
2655 scr->clip_tile = wClipMakeTile(img);
2658 if (!wPreferences.flags.nodrawer) {
2659 if (scr->drawer_tile) {
2660 RReleaseImage(scr->drawer_tile);
2662 scr->drawer_tile = wDrawerMakeTile(scr, img);
2665 scr->icon_tile_pixmap = pixmap;
2667 if (scr->def_icon_rimage) {
2668 RReleaseImage(scr->def_icon_rimage);
2669 scr->def_icon_rimage = NULL;
2672 if (scr->icon_back_texture)
2673 wTextureDestroy(scr, (WTexture *) scr->icon_back_texture);
2675 scr->icon_back_texture = wTextureMakeSolid(scr, &((*texture)->any.color));
2677 /* Free the texture as nobody else will use it, nor refer to it. */
2678 if (!entry->addr)
2679 wTextureDestroy(scr, *texture);
2681 return (reset ? REFRESH_ICON_TILE : 0);
2684 static int setWinTitleFont(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2686 WMFont *font = tdata;
2688 /* Parameter not used, but tell the compiler that it is ok */
2689 (void) entry;
2690 (void) foo;
2692 if (scr->title_font) {
2693 WMReleaseFont(scr->title_font);
2695 scr->title_font = font;
2697 return REFRESH_WINDOW_FONT | REFRESH_BUTTON_IMAGES;
2700 static int setMenuTitleFont(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2702 WMFont *font = tdata;
2704 /* Parameter not used, but tell the compiler that it is ok */
2705 (void) entry;
2706 (void) foo;
2708 if (scr->menu_title_font) {
2709 WMReleaseFont(scr->menu_title_font);
2712 scr->menu_title_font = font;
2714 return REFRESH_MENU_TITLE_FONT;
2717 static int setMenuTextFont(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2719 WMFont *font = tdata;
2721 /* Parameter not used, but tell the compiler that it is ok */
2722 (void) entry;
2723 (void) foo;
2725 if (scr->menu_entry_font) {
2726 WMReleaseFont(scr->menu_entry_font);
2728 scr->menu_entry_font = font;
2730 return REFRESH_MENU_FONT;
2733 static int setIconTitleFont(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2735 WMFont *font = tdata;
2737 /* Parameter not used, but tell the compiler that it is ok */
2738 (void) entry;
2739 (void) foo;
2741 if (scr->icon_title_font) {
2742 WMReleaseFont(scr->icon_title_font);
2745 scr->icon_title_font = font;
2747 return REFRESH_ICON_FONT;
2750 static int setClipTitleFont(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2752 WMFont *font = tdata;
2754 /* Parameter not used, but tell the compiler that it is ok */
2755 (void) entry;
2756 (void) foo;
2758 if (scr->clip_title_font) {
2759 WMReleaseFont(scr->clip_title_font);
2762 scr->clip_title_font = font;
2764 return REFRESH_ICON_FONT;
2767 static int setLargeDisplayFont(WScreen *scr, WDefaultEntry *entry, void *tdata, void *foo)
2769 WMFont *font = tdata;
2771 /* Parameter not used, but tell the compiler that it is ok */
2772 (void) scr;
2773 (void) entry;
2774 (void) foo;
2776 if (scr->workspace_name_font)
2777 WMReleaseFont(scr->workspace_name_font);
2779 scr->workspace_name_font = font;
2781 return 0;
2784 static int setHightlight(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2786 XColor *color = tdata;
2788 /* Parameter not used, but tell the compiler that it is ok */
2789 (void) entry;
2790 (void) foo;
2792 if (scr->select_color)
2793 WMReleaseColor(scr->select_color);
2795 scr->select_color = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2797 wFreeColor(scr, color->pixel);
2799 return REFRESH_MENU_COLOR;
2802 static int setHightlightText(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2804 XColor *color = tdata;
2806 /* Parameter not used, but tell the compiler that it is ok */
2807 (void) entry;
2808 (void) foo;
2810 if (scr->select_text_color)
2811 WMReleaseColor(scr->select_text_color);
2813 scr->select_text_color = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2815 wFreeColor(scr, color->pixel);
2817 return REFRESH_MENU_COLOR;
2820 static int setClipTitleColor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *extra_data)
2822 XColor *color = tdata;
2823 long widx = (long) extra_data;
2825 /* Parameter not used, but tell the compiler that it is ok */
2826 (void) entry;
2828 if (scr->clip_title_color[widx])
2829 WMReleaseColor(scr->clip_title_color[widx]);
2831 scr->clip_title_color[widx] = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2832 wFreeColor(scr, color->pixel);
2834 return REFRESH_ICON_TITLE_COLOR;
2837 static int setWTitleColor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *extra_data)
2839 XColor *color = tdata;
2840 long widx = (long) extra_data;
2842 /* Parameter not used, but tell the compiler that it is ok */
2843 (void) entry;
2845 if (scr->window_title_color[widx])
2846 WMReleaseColor(scr->window_title_color[widx]);
2848 scr->window_title_color[widx] =
2849 WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2851 wFreeColor(scr, color->pixel);
2853 return REFRESH_WINDOW_TITLE_COLOR;
2856 static int setMenuTitleColor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *extra_data)
2858 XColor *color = tdata;
2860 /* Parameter not used, but tell the compiler that it is ok */
2861 (void) entry;
2862 (void) extra_data;
2864 if (scr->menu_title_color[0])
2865 WMReleaseColor(scr->menu_title_color[0]);
2867 scr->menu_title_color[0] = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2869 wFreeColor(scr, color->pixel);
2871 return REFRESH_MENU_TITLE_COLOR;
2874 static int setMenuTextColor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2876 XColor *color = tdata;
2878 /* Parameter not used, but tell the compiler that it is ok */
2879 (void) entry;
2880 (void) foo;
2882 if (scr->mtext_color)
2883 WMReleaseColor(scr->mtext_color);
2885 scr->mtext_color = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2887 if (WMColorPixel(scr->dtext_color) == WMColorPixel(scr->mtext_color)) {
2888 WMSetColorAlpha(scr->dtext_color, 0x7fff);
2889 } else {
2890 WMSetColorAlpha(scr->dtext_color, 0xffff);
2893 wFreeColor(scr, color->pixel);
2895 return REFRESH_MENU_COLOR;
2898 static int setMenuDisabledColor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2900 XColor *color = tdata;
2902 /* Parameter not used, but tell the compiler that it is ok */
2903 (void) entry;
2904 (void) foo;
2906 if (scr->dtext_color)
2907 WMReleaseColor(scr->dtext_color);
2909 scr->dtext_color = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2911 if (WMColorPixel(scr->dtext_color) == WMColorPixel(scr->mtext_color)) {
2912 WMSetColorAlpha(scr->dtext_color, 0x7fff);
2913 } else {
2914 WMSetColorAlpha(scr->dtext_color, 0xffff);
2917 wFreeColor(scr, color->pixel);
2919 return REFRESH_MENU_COLOR;
2922 static int setIconTitleColor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2924 XColor *color = tdata;
2926 /* Parameter not used, but tell the compiler that it is ok */
2927 (void) entry;
2928 (void) foo;
2930 if (scr->icon_title_color)
2931 WMReleaseColor(scr->icon_title_color);
2932 scr->icon_title_color = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2934 wFreeColor(scr, color->pixel);
2936 return REFRESH_ICON_TITLE_COLOR;
2939 static int setIconTitleBack(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2941 XColor *color = tdata;
2943 /* Parameter not used, but tell the compiler that it is ok */
2944 (void) entry;
2945 (void) foo;
2947 if (scr->icon_title_texture) {
2948 wTextureDestroy(scr, (WTexture *) scr->icon_title_texture);
2950 scr->icon_title_texture = wTextureMakeSolid(scr, color);
2952 return REFRESH_ICON_TITLE_BACK;
2955 static int setFrameBorderWidth(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2957 int *value = tdata;
2959 /* Parameter not used, but tell the compiler that it is ok */
2960 (void) entry;
2961 (void) foo;
2963 scr->frame_border_width = *value;
2965 return REFRESH_FRAME_BORDER;
2968 static int setFrameBorderColor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2970 XColor *color = tdata;
2972 /* Parameter not used, but tell the compiler that it is ok */
2973 (void) entry;
2974 (void) foo;
2976 if (scr->frame_border_color)
2977 WMReleaseColor(scr->frame_border_color);
2978 scr->frame_border_color = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2980 wFreeColor(scr, color->pixel);
2982 return REFRESH_FRAME_BORDER;
2985 static int setFrameFocusedBorderColor(WScreen *scr, WDefaultEntry *entry, void *tdata, void *foo)
2987 XColor *color = tdata;
2989 /* Parameter not used, but tell the compiler that it is ok */
2990 (void) entry;
2991 (void) foo;
2993 if (scr->frame_focused_border_color)
2994 WMReleaseColor(scr->frame_focused_border_color);
2995 scr->frame_focused_border_color = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2997 wFreeColor(scr, color->pixel);
2999 return REFRESH_FRAME_BORDER;
3002 static int setFrameSelectedBorderColor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
3004 XColor *color = tdata;
3006 /* Parameter not used, but tell the compiler that it is ok */
3007 (void) entry;
3008 (void) foo;
3010 if (scr->frame_selected_border_color)
3011 WMReleaseColor(scr->frame_selected_border_color);
3012 scr->frame_selected_border_color = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
3014 wFreeColor(scr, color->pixel);
3016 return REFRESH_FRAME_BORDER;
3019 static int setWorkspaceSpecificBack(WScreen * scr, WDefaultEntry * entry, void *tdata, void *bar)
3021 WMPropList *value = tdata;
3022 WMPropList *val;
3023 char *str;
3024 int i;
3026 /* Parameter not used, but tell the compiler that it is ok */
3027 (void) entry;
3028 (void) bar;
3030 if (scr->flags.backimage_helper_launched) {
3031 if (WMGetPropListItemCount(value) == 0) {
3032 SendHelperMessage(scr, 'C', 0, NULL);
3033 SendHelperMessage(scr, 'K', 0, NULL);
3035 WMReleasePropList(value);
3036 return 0;
3038 } else {
3039 if (WMGetPropListItemCount(value) == 0)
3040 return 0;
3042 if (!start_bg_helper(scr)) {
3043 WMReleasePropList(value);
3044 return 0;
3047 SendHelperMessage(scr, 'P', -1, wPreferences.pixmap_path);
3050 for (i = 0; i < WMGetPropListItemCount(value); i++) {
3051 val = WMGetFromPLArray(value, i);
3052 if (val && WMIsPLArray(val) && WMGetPropListItemCount(val) > 0) {
3053 str = WMGetPropListDescription(val, False);
3055 SendHelperMessage(scr, 'S', i + 1, str);
3057 wfree(str);
3058 } else {
3059 SendHelperMessage(scr, 'U', i + 1, NULL);
3062 sleep(1);
3064 WMReleasePropList(value);
3065 return 0;
3068 static int setWorkspaceBack(WScreen * scr, WDefaultEntry * entry, void *tdata, void *bar)
3070 WMPropList *value = tdata;
3072 /* Parameter not used, but tell the compiler that it is ok */
3073 (void) entry;
3074 (void) bar;
3076 if (scr->flags.backimage_helper_launched) {
3077 char *str;
3079 if (WMGetPropListItemCount(value) == 0) {
3080 SendHelperMessage(scr, 'U', 0, NULL);
3081 } else {
3082 /* set the default workspace background to this one */
3083 str = WMGetPropListDescription(value, False);
3084 if (str) {
3085 SendHelperMessage(scr, 'S', 0, str);
3086 wfree(str);
3087 SendHelperMessage(scr, 'C', scr->current_workspace + 1, NULL);
3088 } else {
3089 SendHelperMessage(scr, 'U', 0, NULL);
3092 } else if (WMGetPropListItemCount(value) > 0) {
3093 char *text;
3094 char *dither;
3095 int len;
3097 text = WMGetPropListDescription(value, False);
3098 len = strlen(text) + 40;
3099 dither = wPreferences.no_dithering ? "-m" : "-d";
3100 if (!strchr(text, '\'') && !strchr(text, '\\')) {
3101 char command[len];
3103 if (wPreferences.smooth_workspace_back)
3104 snprintf(command, len, "wmsetbg %s -S -p '%s' &", dither, text);
3105 else
3106 snprintf(command, len, "wmsetbg %s -p '%s' &", dither, text);
3107 ExecuteShellCommand(scr, command);
3108 } else
3109 wwarning(_("Invalid arguments for background \"%s\""), text);
3110 wfree(text);
3112 WMReleasePropList(value);
3114 return 0;
3117 static int setWidgetColor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
3119 WTexture **texture = tdata;
3121 /* Parameter not used, but tell the compiler that it is ok */
3122 (void) entry;
3123 (void) foo;
3125 if (scr->widget_texture) {
3126 wTextureDestroy(scr, (WTexture *) scr->widget_texture);
3128 scr->widget_texture = *(WTexSolid **) texture;
3130 return 0;
3133 static int setFTitleBack(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
3135 WTexture **texture = tdata;
3137 /* Parameter not used, but tell the compiler that it is ok */
3138 (void) entry;
3139 (void) foo;
3141 if (scr->window_title_texture[WS_FOCUSED]) {
3142 wTextureDestroy(scr, scr->window_title_texture[WS_FOCUSED]);
3144 scr->window_title_texture[WS_FOCUSED] = *texture;
3146 return REFRESH_WINDOW_TEXTURES;
3149 static int setPTitleBack(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
3151 WTexture **texture = tdata;
3153 /* Parameter not used, but tell the compiler that it is ok */
3154 (void) entry;
3155 (void) foo;
3157 if (scr->window_title_texture[WS_PFOCUSED]) {
3158 wTextureDestroy(scr, scr->window_title_texture[WS_PFOCUSED]);
3160 scr->window_title_texture[WS_PFOCUSED] = *texture;
3162 return REFRESH_WINDOW_TEXTURES;
3165 static int setUTitleBack(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
3167 WTexture **texture = tdata;
3169 /* Parameter not used, but tell the compiler that it is ok */
3170 (void) entry;
3171 (void) foo;
3173 if (scr->window_title_texture[WS_UNFOCUSED]) {
3174 wTextureDestroy(scr, scr->window_title_texture[WS_UNFOCUSED]);
3176 scr->window_title_texture[WS_UNFOCUSED] = *texture;
3178 return REFRESH_WINDOW_TEXTURES;
3181 static int setResizebarBack(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
3183 WTexture **texture = tdata;
3185 /* Parameter not used, but tell the compiler that it is ok */
3186 (void) entry;
3187 (void) foo;
3189 if (scr->resizebar_texture[0]) {
3190 wTextureDestroy(scr, scr->resizebar_texture[0]);
3192 scr->resizebar_texture[0] = *texture;
3194 return REFRESH_WINDOW_TEXTURES;
3197 static int setMenuTitleBack(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
3199 WTexture **texture = tdata;
3201 /* Parameter not used, but tell the compiler that it is ok */
3202 (void) entry;
3203 (void) foo;
3205 if (scr->menu_title_texture[0]) {
3206 wTextureDestroy(scr, scr->menu_title_texture[0]);
3208 scr->menu_title_texture[0] = *texture;
3210 return REFRESH_MENU_TITLE_TEXTURE;
3213 static int setMenuTextBack(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
3215 WTexture **texture = tdata;
3217 /* Parameter not used, but tell the compiler that it is ok */
3218 (void) entry;
3219 (void) foo;
3221 if (scr->menu_item_texture) {
3222 wTextureDestroy(scr, scr->menu_item_texture);
3223 wTextureDestroy(scr, (WTexture *) scr->menu_item_auxtexture);
3225 scr->menu_item_texture = *texture;
3227 scr->menu_item_auxtexture = wTextureMakeSolid(scr, &scr->menu_item_texture->any.color);
3229 return REFRESH_MENU_TEXTURE;
3232 static int setKeyGrab(WScreen * scr, WDefaultEntry * entry, void *tdata, void *extra_data)
3234 WShortKey *shortcut = tdata;
3235 WWindow *wwin;
3236 long widx = (long) extra_data;
3238 /* Parameter not used, but tell the compiler that it is ok */
3239 (void) entry;
3241 wKeyBindings[widx] = *shortcut;
3243 wwin = scr->focused_window;
3245 while (wwin != NULL) {
3246 XUngrabKey(dpy, AnyKey, AnyModifier, wwin->frame->core->window);
3248 if (!WFLAGP(wwin, no_bind_keys)) {
3249 wWindowSetKeyGrabs(wwin);
3251 wwin = wwin->prev;
3254 /* do we need to update window menus? */
3255 if (widx >= WKBD_WORKSPACE1 && widx <= WKBD_WORKSPACE10)
3256 return REFRESH_WORKSPACE_MENU;
3257 if (widx == WKBD_LASTWORKSPACE)
3258 return REFRESH_WORKSPACE_MENU;
3259 if (widx >= WKBD_MOVE_WORKSPACE1 && widx <= WKBD_MOVE_WORKSPACE10)
3260 return REFRESH_WORKSPACE_MENU;
3262 return 0;
3265 static int setIconPosition(WScreen * scr, WDefaultEntry * entry, void *bar, void *foo)
3267 /* Parameter not used, but tell the compiler that it is ok */
3268 (void) entry;
3269 (void) bar;
3270 (void) foo;
3272 wScreenUpdateUsableArea(scr);
3273 wArrangeIcons(scr, True);
3275 return 0;
3278 static int updateUsableArea(WScreen * scr, WDefaultEntry * entry, void *bar, void *foo)
3280 /* Parameter not used, but tell the compiler that it is ok */
3281 (void) entry;
3282 (void) bar;
3283 (void) foo;
3285 wScreenUpdateUsableArea(scr);
3287 return 0;
3290 static int setWorkspaceMapBackground(WScreen *scr, WDefaultEntry *entry, void *tdata, void *foo)
3292 WTexture **texture = tdata;
3294 /* Parameter not used, but tell the compiler that it is ok */
3295 (void) entry;
3296 (void) foo;
3298 if (wPreferences.wsmbackTexture)
3299 wTextureDestroy(scr, wPreferences.wsmbackTexture);
3301 wPreferences.wsmbackTexture = *texture;
3303 return REFRESH_WINDOW_TEXTURES;
3306 static int setMenuStyle(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
3308 /* Parameter not used, but tell the compiler that it is ok */
3309 (void) scr;
3310 (void) entry;
3311 (void) tdata;
3312 (void) foo;
3314 return REFRESH_MENU_TEXTURE;
3317 static RImage *chopOffImage(RImage * image, int x, int y, int w, int h)
3319 RImage *img = RCreateImage(w, h, image->format == RRGBAFormat);
3321 RCopyArea(img, image, x, y, w, h, 0, 0);
3323 return img;
3326 static int setSwPOptions(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
3328 WMPropList *array = tdata;
3329 char *path;
3330 RImage *bgimage;
3331 int cwidth, cheight;
3332 struct WPreferences *prefs = foo;
3334 if (!WMIsPLArray(array) || WMGetPropListItemCount(array) == 0) {
3335 if (prefs->swtileImage)
3336 RReleaseImage(prefs->swtileImage);
3337 prefs->swtileImage = NULL;
3339 WMReleasePropList(array);
3340 return 0;
3343 switch (WMGetPropListItemCount(array)) {
3344 case 4:
3345 if (!WMIsPLString(WMGetFromPLArray(array, 1))) {
3346 wwarning(_("Invalid arguments for option \"%s\""), entry->key);
3347 break;
3348 } else
3349 path = FindImage(wPreferences.pixmap_path, WMGetFromPLString(WMGetFromPLArray(array, 1)));
3351 if (!path) {
3352 wwarning(_("Could not find image \"%s\" for option \"%s\""),
3353 WMGetFromPLString(WMGetFromPLArray(array, 1)), entry->key);
3354 } else {
3355 bgimage = RLoadImage(scr->rcontext, path, 0);
3356 if (!bgimage) {
3357 wwarning(_("Could not load image \"%s\" for option \"%s\""), path, entry->key);
3358 wfree(path);
3359 } else {
3360 wfree(path);
3362 cwidth = atoi(WMGetFromPLString(WMGetFromPLArray(array, 2)));
3363 cheight = atoi(WMGetFromPLString(WMGetFromPLArray(array, 3)));
3365 if (cwidth <= 0 || cheight <= 0 ||
3366 cwidth >= bgimage->width - 2 || cheight >= bgimage->height - 2)
3367 wwarning(_("Invalid split sizes for switch panel back image."));
3368 else {
3369 int i;
3370 int swidth, theight;
3371 for (i = 0; i < 9; i++) {
3372 if (prefs->swbackImage[i])
3373 RReleaseImage(prefs->swbackImage[i]);
3374 prefs->swbackImage[i] = NULL;
3376 swidth = (bgimage->width - cwidth) / 2;
3377 theight = (bgimage->height - cheight) / 2;
3379 prefs->swbackImage[0] = chopOffImage(bgimage, 0, 0, swidth, theight);
3380 prefs->swbackImage[1] = chopOffImage(bgimage, swidth, 0, cwidth, theight);
3381 prefs->swbackImage[2] = chopOffImage(bgimage, swidth + cwidth, 0,
3382 swidth, theight);
3384 prefs->swbackImage[3] = chopOffImage(bgimage, 0, theight, swidth, cheight);
3385 prefs->swbackImage[4] = chopOffImage(bgimage, swidth, theight,
3386 cwidth, cheight);
3387 prefs->swbackImage[5] = chopOffImage(bgimage, swidth + cwidth, theight,
3388 swidth, cheight);
3390 prefs->swbackImage[6] = chopOffImage(bgimage, 0, theight + cheight,
3391 swidth, theight);
3392 prefs->swbackImage[7] = chopOffImage(bgimage, swidth, theight + cheight,
3393 cwidth, theight);
3394 prefs->swbackImage[8] =
3395 chopOffImage(bgimage, swidth + cwidth, theight + cheight, swidth,
3396 theight);
3398 // check if anything failed
3399 for (i = 0; i < 9; i++) {
3400 if (!prefs->swbackImage[i]) {
3401 for (; i >= 0; --i) {
3402 RReleaseImage(prefs->swbackImage[i]);
3403 prefs->swbackImage[i] = NULL;
3405 break;
3409 RReleaseImage(bgimage);
3413 case 1:
3414 if (!WMIsPLString(WMGetFromPLArray(array, 0))) {
3415 wwarning(_("Invalid arguments for option \"%s\""), entry->key);
3416 break;
3417 } else
3418 path = FindImage(wPreferences.pixmap_path, WMGetFromPLString(WMGetFromPLArray(array, 0)));
3420 if (!path) {
3421 wwarning(_("Could not find image \"%s\" for option \"%s\""),
3422 WMGetFromPLString(WMGetFromPLArray(array, 0)), entry->key);
3423 } else {
3424 if (prefs->swtileImage)
3425 RReleaseImage(prefs->swtileImage);
3427 prefs->swtileImage = RLoadImage(scr->rcontext, path, 0);
3428 if (!prefs->swtileImage) {
3429 wwarning(_("Could not load image \"%s\" for option \"%s\""), path, entry->key);
3431 wfree(path);
3433 break;
3435 default:
3436 wwarning(_("Invalid number of arguments for option \"%s\""), entry->key);
3437 break;
3440 WMReleasePropList(array);
3442 return 0;
3445 static int setModifierKeyLabels(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
3447 WMPropList *array = tdata;
3448 int i;
3449 struct WPreferences *prefs = foo;
3451 if (!WMIsPLArray(array) || WMGetPropListItemCount(array) != 7) {
3452 wwarning(_("Value for option \"%s\" must be an array of 7 strings"), entry->key);
3453 WMReleasePropList(array);
3454 return 0;
3457 DestroyWindowMenu(scr);
3459 for (i = 0; i < 7; i++) {
3460 if (prefs->modifier_labels[i])
3461 wfree(prefs->modifier_labels[i]);
3463 if (WMIsPLString(WMGetFromPLArray(array, i))) {
3464 prefs->modifier_labels[i] = wstrdup(WMGetFromPLString(WMGetFromPLArray(array, i)));
3465 } else {
3466 wwarning(_("Invalid argument for option \"%s\" item %d"), entry->key, i);
3467 prefs->modifier_labels[i] = NULL;
3471 WMReleasePropList(array);
3473 return 0;
3476 static int setDoubleClick(WScreen *scr, WDefaultEntry *entry, void *tdata, void *foo)
3478 int *value = tdata;
3480 /* Parameter not used, but tell the compiler that it is ok */
3481 (void) entry;
3482 (void) scr;
3484 if (*value <= 0)
3485 *(int *)foo = 1;
3487 W_setconf_doubleClickDelay(*value);
3489 return 0;
3492 static int setCursor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *extra_data)
3494 Cursor *cursor = tdata;
3495 long widx = (long) extra_data;
3497 /* Parameter not used, but tell the compiler that it is ok */
3498 (void) entry;
3500 if (wPreferences.cursor[widx] != None) {
3501 XFreeCursor(dpy, wPreferences.cursor[widx]);
3504 wPreferences.cursor[widx] = *cursor;
3506 if (widx == WCUR_ROOT && *cursor != None) {
3507 XDefineCursor(dpy, scr->root_win, *cursor);
3510 return 0;