configure: Add option to specify global defaults directory.
[wmaker-crm.git] / src / defaults.c
blobf83f6a5da92fd43f0ed92d0196365c1d5c3875d8
1 /* defaults.c - manage configuration through defaults db
3 * Window Maker window manager
5 * Copyright (c) 1997-2003 Alfredo K. Kojima
6 * Copyright (c) 1998-2003 Dan Pascu
7 * Copyright (c) 2014 Window Maker Team
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License along
21 * with this program; if not, write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 #include "wconfig.h"
27 #include <stdio.h>
28 #include <stdint.h>
29 #include <stdlib.h>
30 #include <unistd.h>
31 #include <string.h>
32 #include <strings.h>
33 #include <ctype.h>
34 #include <time.h>
35 #include <sys/types.h>
36 #include <sys/stat.h>
37 #include <limits.h>
38 #include <signal.h>
40 #ifndef PATH_MAX
41 #define PATH_MAX DEFAULT_PATH_MAX
42 #endif
44 #include <X11/Xlib.h>
45 #include <X11/Xutil.h>
46 #include <X11/keysym.h>
48 #include <wraster.h>
50 #include "WindowMaker.h"
51 #include "framewin.h"
52 #include "window.h"
53 #include "texture.h"
54 #include "screen.h"
55 #include "resources.h"
56 #include "defaults.h"
57 #include "keybind.h"
58 #include "xmodifier.h"
59 #include "icon.h"
60 #include "main.h"
61 #include "actions.h"
62 #include "dock.h"
63 #include "workspace.h"
64 #include "properties.h"
65 #include "misc.h"
66 #include "winmenu.h"
68 #define MAX_SHORTCUT_LENGTH 32
70 typedef struct _WDefaultEntry WDefaultEntry;
71 typedef int (WDECallbackConvert) (WScreen *scr, WDefaultEntry *entry, WMPropList *plvalue, void *addr, void **tdata);
72 typedef int (WDECallbackUpdate) (WScreen *scr, WDefaultEntry *entry, void *tdata, void *extra_data);
74 struct _WDefaultEntry {
75 const char *key;
76 const char *default_value;
77 void *extra_data;
78 void *addr;
79 WDECallbackConvert *convert;
80 WDECallbackUpdate *update;
81 WMPropList *plkey;
82 WMPropList *plvalue; /* default value */
85 /* used to map strings to integers */
86 typedef struct {
87 const char *string;
88 short value;
89 char is_alias;
90 } WOptionEnumeration;
92 /* type converters */
93 static WDECallbackConvert getBool;
94 static WDECallbackConvert getInt;
95 static WDECallbackConvert getCoord;
96 static WDECallbackConvert getPathList;
97 static WDECallbackConvert getEnum;
98 static WDECallbackConvert getTexture;
99 static WDECallbackConvert getWSBackground;
100 static WDECallbackConvert getWSSpecificBackground;
101 static WDECallbackConvert getFont;
102 static WDECallbackConvert getColor;
103 static WDECallbackConvert getKeybind;
104 static WDECallbackConvert getModMask;
105 static WDECallbackConvert getPropList;
107 /* value setting functions */
108 static WDECallbackUpdate setJustify;
109 static WDECallbackUpdate setClearance;
110 static WDECallbackUpdate setIfDockPresent;
111 static WDECallbackUpdate setClipMergedInDock;
112 static WDECallbackUpdate setWrapAppiconsInDock;
113 static WDECallbackUpdate setStickyIcons;
114 static WDECallbackUpdate setWidgetColor;
115 static WDECallbackUpdate setIconTile;
116 static WDECallbackUpdate setWinTitleFont;
117 static WDECallbackUpdate setMenuTitleFont;
118 static WDECallbackUpdate setMenuTextFont;
119 static WDECallbackUpdate setIconTitleFont;
120 static WDECallbackUpdate setIconTitleColor;
121 static WDECallbackUpdate setIconTitleBack;
122 static WDECallbackUpdate setFrameBorderWidth;
123 static WDECallbackUpdate setFrameBorderColor;
124 static WDECallbackUpdate setFrameFocusedBorderColor;
125 static WDECallbackUpdate setFrameSelectedBorderColor;
126 static WDECallbackUpdate setLargeDisplayFont;
127 static WDECallbackUpdate setWTitleColor;
128 static WDECallbackUpdate setFTitleBack;
129 static WDECallbackUpdate setPTitleBack;
130 static WDECallbackUpdate setUTitleBack;
131 static WDECallbackUpdate setResizebarBack;
132 static WDECallbackUpdate setWorkspaceBack;
133 static WDECallbackUpdate setWorkspaceSpecificBack;
134 static WDECallbackUpdate setMenuTitleColor;
135 static WDECallbackUpdate setMenuTextColor;
136 static WDECallbackUpdate setMenuDisabledColor;
137 static WDECallbackUpdate setMenuTitleBack;
138 static WDECallbackUpdate setMenuTextBack;
139 static WDECallbackUpdate setHightlight;
140 static WDECallbackUpdate setHightlightText;
141 static WDECallbackUpdate setKeyGrab;
142 static WDECallbackUpdate setDoubleClick;
143 static WDECallbackUpdate setIconPosition;
144 static WDECallbackUpdate setWorkspaceMapBackground;
146 static WDECallbackUpdate setClipTitleFont;
147 static WDECallbackUpdate setClipTitleColor;
149 static WDECallbackUpdate setMenuStyle;
150 static WDECallbackUpdate setSwPOptions;
151 static WDECallbackUpdate updateUsableArea;
153 static WDECallbackUpdate setModifierKeyLabels;
155 static WDECallbackConvert getCursor;
156 static WDECallbackUpdate setCursor;
159 * Tables to convert strings to enumeration values.
160 * Values stored are char
163 /* WARNING: sum of length of all value strings must not exceed
164 * this value */
165 #define TOTAL_VALUES_LENGTH 80
167 #define REFRESH_WINDOW_TEXTURES (1<<0)
168 #define REFRESH_MENU_TEXTURE (1<<1)
169 #define REFRESH_MENU_FONT (1<<2)
170 #define REFRESH_MENU_COLOR (1<<3)
171 #define REFRESH_MENU_TITLE_TEXTURE (1<<4)
172 #define REFRESH_MENU_TITLE_FONT (1<<5)
173 #define REFRESH_MENU_TITLE_COLOR (1<<6)
174 #define REFRESH_WINDOW_TITLE_COLOR (1<<7)
175 #define REFRESH_WINDOW_FONT (1<<8)
176 #define REFRESH_ICON_TILE (1<<9)
177 #define REFRESH_ICON_FONT (1<<10)
179 #define REFRESH_BUTTON_IMAGES (1<<11)
181 #define REFRESH_ICON_TITLE_COLOR (1<<12)
182 #define REFRESH_ICON_TITLE_BACK (1<<13)
184 #define REFRESH_WORKSPACE_MENU (1<<14)
186 #define REFRESH_FRAME_BORDER REFRESH_MENU_FONT|REFRESH_WINDOW_FONT
188 static WOptionEnumeration seFocusModes[] = {
189 {"Manual", WKF_CLICK, 0}, {"ClickToFocus", WKF_CLICK, 1},
190 {"Sloppy", WKF_SLOPPY, 0}, {"SemiAuto", WKF_SLOPPY, 1}, {"Auto", WKF_SLOPPY, 1},
191 {NULL, 0, 0}
194 static WOptionEnumeration seTitlebarModes[] = {
195 {"new", TS_NEW, 0}, {"old", TS_OLD, 0},
196 {"next", TS_NEXT, 0}, {NULL, 0, 0}
199 static WOptionEnumeration seColormapModes[] = {
200 {"Manual", WCM_CLICK, 0}, {"ClickToFocus", WCM_CLICK, 1},
201 {"Auto", WCM_POINTER, 0}, {"FocusFollowMouse", WCM_POINTER, 1},
202 {NULL, 0, 0}
205 static WOptionEnumeration sePlacements[] = {
206 {"Auto", WPM_AUTO, 0},
207 {"Smart", WPM_SMART, 0},
208 {"Cascade", WPM_CASCADE, 0},
209 {"Random", WPM_RANDOM, 0},
210 {"Manual", WPM_MANUAL, 0},
211 {"Center", WPM_CENTER, 0},
212 {NULL, 0, 0}
215 static WOptionEnumeration seGeomDisplays[] = {
216 {"None", WDIS_NONE, 0},
217 {"Center", WDIS_CENTER, 0},
218 {"Corner", WDIS_TOPLEFT, 0},
219 {"Floating", WDIS_FRAME_CENTER, 0},
220 {"Line", WDIS_NEW, 0},
221 {NULL, 0, 0}
224 static WOptionEnumeration seSpeeds[] = {
225 {"UltraFast", SPEED_ULTRAFAST, 0},
226 {"Fast", SPEED_FAST, 0},
227 {"Medium", SPEED_MEDIUM, 0},
228 {"Slow", SPEED_SLOW, 0},
229 {"UltraSlow", SPEED_ULTRASLOW, 0},
230 {NULL, 0, 0}
233 static WOptionEnumeration seMouseButtonActions[] = {
234 {"None", WA_NONE, 0},
235 {"SelectWindows", WA_SELECT_WINDOWS, 0},
236 {"OpenApplicationsMenu", WA_OPEN_APPMENU, 0},
237 {"OpenWindowListMenu", WA_OPEN_WINLISTMENU, 0},
238 {"MoveToPrevWorkspace", WA_MOVE_PREVWORKSPACE, 0},
239 {"MoveToNextWorkspace", WA_MOVE_NEXTWORKSPACE, 0},
240 {"MoveToPrevWindow", WA_MOVE_PREVWINDOW, 0},
241 {"MoveToNextWindow", WA_MOVE_NEXTWINDOW, 0},
242 {NULL, 0, 0}
245 static WOptionEnumeration seMouseWheelActions[] = {
246 {"None", WA_NONE, 0},
247 {"SwitchWorkspaces", WA_SWITCH_WORKSPACES, 0},
248 {"SwitchWindows", WA_SWITCH_WINDOWS, 0},
249 {NULL, 0, 0}
252 static WOptionEnumeration seIconificationStyles[] = {
253 {"Zoom", WIS_ZOOM, 0},
254 {"Twist", WIS_TWIST, 0},
255 {"Flip", WIS_FLIP, 0},
256 {"None", WIS_NONE, 0},
257 {"random", WIS_RANDOM, 0},
258 {NULL, 0, 0}
261 static WOptionEnumeration seJustifications[] = {
262 {"Left", WTJ_LEFT, 0},
263 {"Center", WTJ_CENTER, 0},
264 {"Right", WTJ_RIGHT, 0},
265 {NULL, 0, 0}
268 static WOptionEnumeration seIconPositions[] = {
269 {"blv", IY_BOTTOM | IY_LEFT | IY_VERT, 0},
270 {"blh", IY_BOTTOM | IY_LEFT | IY_HORIZ, 0},
271 {"brv", IY_BOTTOM | IY_RIGHT | IY_VERT, 0},
272 {"brh", IY_BOTTOM | IY_RIGHT | IY_HORIZ, 0},
273 {"tlv", IY_TOP | IY_LEFT | IY_VERT, 0},
274 {"tlh", IY_TOP | IY_LEFT | IY_HORIZ, 0},
275 {"trv", IY_TOP | IY_RIGHT | IY_VERT, 0},
276 {"trh", IY_TOP | IY_RIGHT | IY_HORIZ, 0},
277 {NULL, 0, 0}
280 static WOptionEnumeration seMenuStyles[] = {
281 {"normal", MS_NORMAL, 0},
282 {"singletexture", MS_SINGLE_TEXTURE, 0},
283 {"flat", MS_FLAT, 0},
284 {NULL, 0, 0}
287 static WOptionEnumeration seDisplayPositions[] = {
288 {"none", WD_NONE, 0},
289 {"center", WD_CENTER, 0},
290 {"top", WD_TOP, 0},
291 {"bottom", WD_BOTTOM, 0},
292 {"topleft", WD_TOPLEFT, 0},
293 {"topright", WD_TOPRIGHT, 0},
294 {"bottomleft", WD_BOTTOMLEFT, 0},
295 {"bottomright", WD_BOTTOMRIGHT, 0},
296 {NULL, 0, 0}
299 static WOptionEnumeration seWorkspaceBorder[] = {
300 {"None", WB_NONE, 0},
301 {"LeftRight", WB_LEFTRIGHT, 0},
302 {"TopBottom", WB_TOPBOTTOM, 0},
303 {"AllDirections", WB_ALLDIRS, 0},
304 {NULL, 0, 0}
307 static WOptionEnumeration seDragMaximizedWindow[] = {
308 {"Move", DRAGMAX_MOVE, 0},
309 {"RestoreGeometry", DRAGMAX_RESTORE, 0},
310 {"Unmaximize", DRAGMAX_UNMAXIMIZE, 0},
311 {"NoMove", DRAGMAX_NOMOVE, 0},
312 {NULL, 0, 0}
316 * Backward Compatibility:
317 * The Mini-Previews were introduced in 0.95.6 under the name "Apercu".
318 * For compatibility, we still support the old names in configuration files,
319 * which are loaded in this structure, so this should stay for at least
320 * 2 years (that means until 2017) */
321 static struct {
322 char enable;
323 int size;
324 } legacy_minipreview_config;
327 * ALL entries in the tables bellow, NEED to have a default value
328 * defined, and this value needs to be correct.
331 /* these options will only affect the window manager on startup
333 * static defaults can't access the screen data, because it is
334 * created after these defaults are read
336 WDefaultEntry staticOptionList[] = {
338 {"ColormapSize", "4", NULL,
339 &wPreferences.cmap_size, getInt, NULL, NULL, NULL},
340 {"DisableDithering", "NO", NULL,
341 &wPreferences.no_dithering, getBool, NULL, NULL, NULL},
342 {"IconSize", "64", NULL,
343 &wPreferences.icon_size, getInt, NULL, NULL, NULL},
344 {"ModifierKey", "Mod1", NULL,
345 &wPreferences.modifier_mask, getModMask, NULL, NULL, NULL},
346 {"FocusMode", "manual", seFocusModes, /* have a problem when switching from */
347 &wPreferences.focus_mode, getEnum, NULL, NULL, NULL}, /* manual to sloppy without restart */
348 {"NewStyle", "new", seTitlebarModes,
349 &wPreferences.new_style, getEnum, NULL, NULL, NULL},
350 {"DisableDock", "NO", (void *)WM_DOCK,
351 NULL, getBool, setIfDockPresent, NULL, NULL},
352 {"DisableClip", "NO", (void *)WM_CLIP,
353 NULL, getBool, setIfDockPresent, NULL, NULL},
354 {"DisableDrawers", "NO", (void *)WM_DRAWER,
355 NULL, getBool, setIfDockPresent, NULL, NULL},
356 {"ClipMergedInDock", "NO", NULL,
357 NULL, getBool, setClipMergedInDock, NULL, NULL},
358 {"DisableMiniwindows", "NO", NULL,
359 &wPreferences.disable_miniwindows, getBool, NULL, NULL, NULL},
360 {"EnableWorkspacePager", "NO", NULL,
361 &wPreferences.enable_workspace_pager, getBool, NULL, NULL, NULL}
364 #define NUM2STRING_(x) #x
365 #define NUM2STRING(x) NUM2STRING_(x)
367 WDefaultEntry optionList[] = {
369 /* dynamic options */
371 {"IconPosition", "blh", seIconPositions,
372 &wPreferences.icon_yard, getEnum, setIconPosition, NULL, NULL},
373 {"IconificationStyle", "Zoom", seIconificationStyles,
374 &wPreferences.iconification_style, getEnum, NULL, NULL, NULL},
375 {"DisableWSMouseActions", "NO", NULL,
376 &wPreferences.disable_root_mouse, getBool, NULL, NULL, NULL},
377 {"MouseLeftButtonAction", "SelectWindows", seMouseButtonActions,
378 &wPreferences.mouse_button1, getEnum, NULL, NULL, NULL},
379 {"MouseMiddleButtonAction", "OpenWindowListMenu", seMouseButtonActions,
380 &wPreferences.mouse_button2, getEnum, NULL, NULL, NULL},
381 {"MouseRightButtonAction", "OpenApplicationsMenu", seMouseButtonActions,
382 &wPreferences.mouse_button3, getEnum, NULL, NULL, NULL},
383 {"MouseBackwardButtonAction", "None", seMouseButtonActions,
384 &wPreferences.mouse_button8, getEnum, NULL, NULL, NULL},
385 {"MouseForwardButtonAction", "None", seMouseButtonActions,
386 &wPreferences.mouse_button9, getEnum, NULL, NULL, NULL},
387 {"MouseWheelAction", "None", seMouseWheelActions,
388 &wPreferences.mouse_wheel_scroll, getEnum, NULL, NULL, NULL},
389 {"MouseWheelTiltAction", "None", seMouseWheelActions,
390 &wPreferences.mouse_wheel_tilt, getEnum, NULL, NULL, NULL},
391 {"PixmapPath", DEF_PIXMAP_PATHS, NULL,
392 &wPreferences.pixmap_path, getPathList, NULL, NULL, NULL},
393 {"IconPath", DEF_ICON_PATHS, NULL,
394 &wPreferences.icon_path, getPathList, NULL, NULL, NULL},
395 {"ColormapMode", "auto", seColormapModes,
396 &wPreferences.colormap_mode, getEnum, NULL, NULL, NULL},
397 {"AutoFocus", "NO", NULL,
398 &wPreferences.auto_focus, getBool, NULL, NULL, NULL},
399 {"RaiseDelay", "0", NULL,
400 &wPreferences.raise_delay, getInt, NULL, NULL, NULL},
401 {"CirculateRaise", "NO", NULL,
402 &wPreferences.circ_raise, getBool, NULL, NULL, NULL},
403 {"Superfluous", "NO", NULL,
404 &wPreferences.superfluous, getBool, NULL, NULL, NULL},
405 {"AdvanceToNewWorkspace", "NO", NULL,
406 &wPreferences.ws_advance, getBool, NULL, NULL, NULL},
407 {"CycleWorkspaces", "NO", NULL,
408 &wPreferences.ws_cycle, getBool, NULL, NULL, NULL},
409 {"WorkspaceNameDisplayPosition", "center", seDisplayPositions,
410 &wPreferences.workspace_name_display_position, getEnum, NULL, NULL, NULL},
411 {"WorkspaceBorder", "None", seWorkspaceBorder,
412 &wPreferences.workspace_border_position, getEnum, updateUsableArea, NULL, NULL},
413 {"WorkspaceBorderSize", "0", NULL,
414 &wPreferences.workspace_border_size, getInt, updateUsableArea, NULL, NULL},
415 {"StickyIcons", "NO", NULL,
416 &wPreferences.sticky_icons, getBool, setStickyIcons, NULL, NULL},
417 {"SaveSessionOnExit", "NO", NULL,
418 &wPreferences.save_session_on_exit, getBool, NULL, NULL, NULL},
419 {"WrapMenus", "NO", NULL,
420 &wPreferences.wrap_menus, getBool, NULL, NULL, NULL},
421 {"ScrollableMenus", "NO", NULL,
422 &wPreferences.scrollable_menus, getBool, NULL, NULL, NULL},
423 {"MenuScrollSpeed", "medium", seSpeeds,
424 &wPreferences.menu_scroll_speed, getEnum, NULL, NULL, NULL},
425 {"IconSlideSpeed", "medium", seSpeeds,
426 &wPreferences.icon_slide_speed, getEnum, NULL, NULL, NULL},
427 {"ShadeSpeed", "medium", seSpeeds,
428 &wPreferences.shade_speed, getEnum, NULL, NULL, NULL},
429 {"BounceAppIconsWhenUrgent", "YES", NULL,
430 &wPreferences.bounce_appicons_when_urgent, getBool, NULL, NULL, NULL},
431 {"RaiseAppIconsWhenBouncing", "NO", NULL,
432 &wPreferences.raise_appicons_when_bouncing, getBool, NULL, NULL, NULL},
433 {"DoNotMakeAppIconsBounce", "NO", NULL,
434 &wPreferences.do_not_make_appicons_bounce, getBool, NULL, NULL, NULL},
435 {"DoubleClickTime", "250", (void *)&wPreferences.dblclick_time,
436 &wPreferences.dblclick_time, getInt, setDoubleClick, NULL, NULL},
437 {"ClipAutoraiseDelay", "600", NULL,
438 &wPreferences.clip_auto_raise_delay, getInt, NULL, NULL, NULL},
439 {"ClipAutolowerDelay", "1000", NULL,
440 &wPreferences.clip_auto_lower_delay, getInt, NULL, NULL, NULL},
441 {"ClipAutoexpandDelay", "600", NULL,
442 &wPreferences.clip_auto_expand_delay, getInt, NULL, NULL, NULL},
443 {"ClipAutocollapseDelay", "1000", NULL,
444 &wPreferences.clip_auto_collapse_delay, getInt, NULL, NULL, NULL},
445 {"WrapAppiconsInDock", "YES", NULL,
446 NULL, getBool, setWrapAppiconsInDock, NULL, NULL},
447 {"AlignSubmenus", "NO", NULL,
448 &wPreferences.align_menus, getBool, NULL, NULL, NULL},
449 {"ViKeyMenus", "NO", NULL,
450 &wPreferences.vi_key_menus, getBool, NULL, NULL, NULL},
451 {"OpenTransientOnOwnerWorkspace", "NO", NULL,
452 &wPreferences.open_transients_with_parent, getBool, NULL, NULL, NULL},
453 {"WindowPlacement", "auto", sePlacements,
454 &wPreferences.window_placement, getEnum, NULL, NULL, NULL},
455 {"IgnoreFocusClick", "NO", NULL,
456 &wPreferences.ignore_focus_click, getBool, NULL, NULL, NULL},
457 {"UseSaveUnders", "NO", NULL,
458 &wPreferences.use_saveunders, getBool, NULL, NULL, NULL},
459 {"OpaqueMove", "NO", NULL,
460 &wPreferences.opaque_move, getBool, NULL, NULL, NULL},
461 {"OpaqueResize", "NO", NULL,
462 &wPreferences.opaque_resize, getBool, NULL, NULL, NULL},
463 {"OpaqueMoveResizeKeyboard", "NO", NULL,
464 &wPreferences.opaque_move_resize_keyboard, getBool, NULL, NULL, NULL},
465 {"DisableAnimations", "NO", NULL,
466 &wPreferences.no_animations, getBool, NULL, NULL, NULL},
467 {"DontLinkWorkspaces", "NO", NULL,
468 &wPreferences.no_autowrap, getBool, NULL, NULL, NULL},
469 {"WindowSnapping", "NO", NULL,
470 &wPreferences.window_snapping, getBool, NULL, NULL, NULL},
471 {"SnapEdgeDetect", "1", NULL,
472 &wPreferences.snap_edge_detect, getInt, NULL, NULL, NULL},
473 {"SnapCornerDetect", "10", NULL,
474 &wPreferences.snap_corner_detect, getInt, NULL, NULL, NULL},
475 {"SnapToTopMaximizesFullscreen", "NO", NULL,
476 &wPreferences.snap_to_top_maximizes_fullscreen, getBool, NULL, NULL, NULL},
477 {"DragMaximizedWindow", "Move", seDragMaximizedWindow,
478 &wPreferences.drag_maximized_window, getEnum, NULL, NULL, NULL},
479 {"MoveHalfMaximizedWindowsBetweenScreens", "NO", NULL,
480 &wPreferences.move_half_max_between_heads, getBool, NULL, NULL, NULL},
481 {"AlternativeHalfMaximized", "NO", NULL,
482 &wPreferences.alt_half_maximize, getBool, NULL, NULL, NULL},
483 {"PointerWithHalfMaxWindows", "NO", NULL,
484 &wPreferences.pointer_with_half_max_windows, getBool, NULL, NULL, NULL},
485 {"HighlightActiveApp", "YES", NULL,
486 &wPreferences.highlight_active_app, getBool, NULL, NULL, NULL},
487 {"AutoArrangeIcons", "NO", NULL,
488 &wPreferences.auto_arrange_icons, getBool, NULL, NULL, NULL},
489 {"NoWindowOverDock", "NO", NULL,
490 &wPreferences.no_window_over_dock, getBool, updateUsableArea, NULL, NULL},
491 {"NoWindowOverIcons", "NO", NULL,
492 &wPreferences.no_window_over_icons, getBool, updateUsableArea, NULL, NULL},
493 {"WindowPlaceOrigin", "(0, 0)", NULL,
494 &wPreferences.window_place_origin, getCoord, NULL, NULL, NULL},
495 {"ResizeDisplay", "corner", seGeomDisplays,
496 &wPreferences.size_display, getEnum, NULL, NULL, NULL},
497 {"MoveDisplay", "corner", seGeomDisplays,
498 &wPreferences.move_display, getEnum, NULL, NULL, NULL},
499 {"DontConfirmKill", "NO", NULL,
500 &wPreferences.dont_confirm_kill, getBool, NULL, NULL, NULL},
501 {"WindowTitleBalloons", "NO", NULL,
502 &wPreferences.window_balloon, getBool, NULL, NULL, NULL},
503 {"MiniwindowTitleBalloons", "NO", NULL,
504 &wPreferences.miniwin_title_balloon, getBool, NULL, NULL, NULL},
505 {"MiniwindowPreviewBalloons", "NO", NULL,
506 &wPreferences.miniwin_preview_balloon, getBool, NULL, NULL, NULL},
507 {"AppIconBalloons", "NO", NULL,
508 &wPreferences.appicon_balloon, getBool, NULL, NULL, NULL},
509 {"HelpBalloons", "NO", NULL,
510 &wPreferences.help_balloon, getBool, NULL, NULL, NULL},
511 {"EdgeResistance", "30", NULL,
512 &wPreferences.edge_resistance, getInt, NULL, NULL, NULL},
513 {"ResizeIncrement", "0", NULL,
514 &wPreferences.resize_increment, getInt, NULL, NULL, NULL},
515 {"Attraction", "NO", NULL,
516 &wPreferences.attract, getBool, NULL, NULL, NULL},
517 {"DisableBlinking", "NO", NULL,
518 &wPreferences.dont_blink, getBool, NULL, NULL, NULL},
519 {"SingleClickLaunch", "NO", NULL,
520 &wPreferences.single_click, getBool, NULL, NULL, NULL},
521 {"StrictWindozeCycle", "YES", NULL,
522 &wPreferences.strict_windoze_cycle, getBool, NULL, NULL, NULL},
523 {"SwitchPanelOnlyOpen", "NO", NULL,
524 &wPreferences.panel_only_open, getBool, NULL, NULL, NULL},
525 {"MiniPreviewSize", "128", NULL,
526 &wPreferences.minipreview_size, getInt, NULL, NULL, NULL},
527 {"IgnoreGtkHints", "NO", NULL,
528 &wPreferences.ignore_gtk_decoration_hints, getBool, NULL, NULL, NULL},
531 * Backward Compatibility:
532 * The Mini-Previews were introduced in 0.95.6 under the name "Apercu".
533 * For compatibility, we still support the old names in configuration files,
534 * so this should stay for at least 2 years (that means until 2017)
536 {"MiniwindowApercuBalloons", "NO", NULL,
537 &legacy_minipreview_config.enable, getBool, NULL, NULL, NULL},
538 {"ApercuSize", "0", NULL,
539 &legacy_minipreview_config.size, getInt, NULL, NULL, NULL},
541 /* style options */
543 {"MenuStyle", "normal", seMenuStyles,
544 &wPreferences.menu_style, getEnum, setMenuStyle, NULL, NULL},
545 {"WidgetColor", "(solid, gray)", NULL,
546 NULL, getTexture, setWidgetColor, NULL, NULL},
547 {"WorkspaceSpecificBack", "()", NULL,
548 NULL, getWSSpecificBackground, setWorkspaceSpecificBack, NULL, NULL},
549 /* WorkspaceBack must come after WorkspaceSpecificBack or
550 * WorkspaceBack won't know WorkspaceSpecificBack was also
551 * specified and 2 copies of wmsetbg will be launched */
552 {"WorkspaceBack", "(solid, black)", NULL,
553 NULL, getWSBackground, setWorkspaceBack, NULL, NULL},
554 {"SmoothWorkspaceBack", "NO", NULL,
555 NULL, getBool, NULL, NULL, NULL},
556 {"IconBack", "(solid, gray)", NULL,
557 NULL, getTexture, setIconTile, NULL, NULL},
558 {"TitleJustify", "center", seJustifications,
559 &wPreferences.title_justification, getEnum, setJustify, NULL, NULL},
560 {"WindowTitleFont", DEF_TITLE_FONT, NULL,
561 NULL, getFont, setWinTitleFont, NULL, NULL},
562 {"WindowTitleExtendSpace", DEF_WINDOW_TITLE_EXTEND_SPACE, NULL,
563 &wPreferences.window_title_clearance, getInt, setClearance, NULL, NULL},
564 {"WindowTitleMinHeight", "0", NULL,
565 &wPreferences.window_title_min_height, getInt, setClearance, NULL, NULL},
566 {"WindowTitleMaxHeight", NUM2STRING(INT_MAX), NULL,
567 &wPreferences.window_title_max_height, getInt, setClearance, NULL, NULL},
568 {"MenuTitleExtendSpace", DEF_MENU_TITLE_EXTEND_SPACE, NULL,
569 &wPreferences.menu_title_clearance, getInt, setClearance, NULL, NULL},
570 {"MenuTitleMinHeight", "0", NULL,
571 &wPreferences.menu_title_min_height, getInt, setClearance, NULL, NULL},
572 {"MenuTitleMaxHeight", NUM2STRING(INT_MAX), NULL,
573 &wPreferences.menu_title_max_height, getInt, setClearance, NULL, NULL},
574 {"MenuTextExtendSpace", DEF_MENU_TEXT_EXTEND_SPACE, NULL,
575 &wPreferences.menu_text_clearance, getInt, setClearance, NULL, NULL},
576 {"MenuTitleFont", DEF_MENU_TITLE_FONT, NULL,
577 NULL, getFont, setMenuTitleFont, NULL, NULL},
578 {"MenuTextFont", DEF_MENU_ENTRY_FONT, NULL,
579 NULL, getFont, setMenuTextFont, NULL, NULL},
580 {"IconTitleFont", DEF_ICON_TITLE_FONT, NULL,
581 NULL, getFont, setIconTitleFont, NULL, NULL},
582 {"ClipTitleFont", DEF_CLIP_TITLE_FONT, NULL,
583 NULL, getFont, setClipTitleFont, NULL, NULL},
584 {"ShowClipTitle", "YES", NULL,
585 &wPreferences.show_clip_title, getBool, NULL, NULL, NULL},
586 {"LargeDisplayFont", DEF_WORKSPACE_NAME_FONT, NULL,
587 NULL, getFont, setLargeDisplayFont, NULL, NULL},
588 {"HighlightColor", "white", NULL,
589 NULL, getColor, setHightlight, NULL, NULL},
590 {"HighlightTextColor", "black", NULL,
591 NULL, getColor, setHightlightText, NULL, NULL},
592 {"ClipTitleColor", "black", (void *)CLIP_NORMAL,
593 NULL, getColor, setClipTitleColor, NULL, NULL},
594 {"CClipTitleColor", "\"#454045\"", (void *)CLIP_COLLAPSED,
595 NULL, getColor, setClipTitleColor, NULL, NULL},
596 {"FTitleColor", "white", (void *)WS_FOCUSED,
597 NULL, getColor, setWTitleColor, NULL, NULL},
598 {"PTitleColor", "white", (void *)WS_PFOCUSED,
599 NULL, getColor, setWTitleColor, NULL, NULL},
600 {"UTitleColor", "black", (void *)WS_UNFOCUSED,
601 NULL, getColor, setWTitleColor, NULL, NULL},
602 {"FTitleBack", "(solid, black)", NULL,
603 NULL, getTexture, setFTitleBack, NULL, NULL},
604 {"PTitleBack", "(solid, \"#616161\")", NULL,
605 NULL, getTexture, setPTitleBack, NULL, NULL},
606 {"UTitleBack", "(solid, gray)", NULL,
607 NULL, getTexture, setUTitleBack, NULL, NULL},
608 {"ResizebarBack", "(solid, gray)", NULL,
609 NULL, getTexture, setResizebarBack, NULL, NULL},
610 {"MenuTitleColor", "white", NULL,
611 NULL, getColor, setMenuTitleColor, NULL, NULL},
612 {"MenuTextColor", "black", NULL,
613 NULL, getColor, setMenuTextColor, NULL, NULL},
614 {"MenuDisabledColor", "\"#616161\"", NULL,
615 NULL, getColor, setMenuDisabledColor, NULL, NULL},
616 {"MenuTitleBack", "(solid, black)", NULL,
617 NULL, getTexture, setMenuTitleBack, NULL, NULL},
618 {"MenuTextBack", "(solid, gray)", NULL,
619 NULL, getTexture, setMenuTextBack, NULL, NULL},
620 {"IconTitleColor", "white", NULL,
621 NULL, getColor, setIconTitleColor, NULL, NULL},
622 {"IconTitleBack", "black", NULL,
623 NULL, getColor, setIconTitleBack, NULL, NULL},
624 {"SwitchPanelImages", "(swtile.png, swback.png, 30, 40)", &wPreferences,
625 NULL, getPropList, setSwPOptions, NULL, NULL},
626 {"ModifierKeyLabels", "(\"Shift+\", \"Control+\", \"Mod1+\", \"Mod2+\", \"Mod3+\", \"Mod4+\", \"Mod5+\")", &wPreferences,
627 NULL, getPropList, setModifierKeyLabels, NULL, NULL},
628 {"FrameBorderWidth", "1", NULL,
629 NULL, getInt, setFrameBorderWidth, NULL, NULL},
630 {"FrameBorderColor", "black", NULL,
631 NULL, getColor, setFrameBorderColor, NULL, NULL},
632 {"FrameFocusedBorderColor", "black", NULL,
633 NULL, getColor, setFrameFocusedBorderColor, NULL, NULL},
634 {"FrameSelectedBorderColor", "white", NULL,
635 NULL, getColor, setFrameSelectedBorderColor, NULL, NULL},
636 {"WorkspaceMapBack", "(solid, black)", NULL,
637 NULL, getTexture, setWorkspaceMapBackground, NULL, NULL},
639 /* keybindings */
641 {"RootMenuKey", "None", (void *)WKBD_ROOTMENU,
642 NULL, getKeybind, setKeyGrab, NULL, NULL},
643 {"WindowListKey", "None", (void *)WKBD_WINDOWLIST,
644 NULL, getKeybind, setKeyGrab, NULL, NULL},
645 {"WindowMenuKey", "None", (void *)WKBD_WINDOWMENU,
646 NULL, getKeybind, setKeyGrab, NULL, NULL},
647 {"DockRaiseLowerKey", "None", (void*)WKBD_DOCKRAISELOWER,
648 NULL, getKeybind, setKeyGrab, NULL, NULL},
649 {"ClipRaiseLowerKey", "None", (void *)WKBD_CLIPRAISELOWER,
650 NULL, getKeybind, setKeyGrab, NULL, NULL},
651 {"MiniaturizeKey", "None", (void *)WKBD_MINIATURIZE,
652 NULL, getKeybind, setKeyGrab, NULL, NULL},
653 {"MinimizeAllKey", "None", (void *)WKBD_MINIMIZEALL,
654 NULL, getKeybind, setKeyGrab, NULL, NULL },
655 {"HideKey", "None", (void *)WKBD_HIDE,
656 NULL, getKeybind, setKeyGrab, NULL, NULL},
657 {"HideOthersKey", "None", (void *)WKBD_HIDE_OTHERS,
658 NULL, getKeybind, setKeyGrab, NULL, NULL},
659 {"MoveResizeKey", "None", (void *)WKBD_MOVERESIZE,
660 NULL, getKeybind, setKeyGrab, NULL, NULL},
661 {"CloseKey", "None", (void *)WKBD_CLOSE,
662 NULL, getKeybind, setKeyGrab, NULL, NULL},
663 {"MaximizeKey", "None", (void *)WKBD_MAXIMIZE,
664 NULL, getKeybind, setKeyGrab, NULL, NULL},
665 {"VMaximizeKey", "None", (void *)WKBD_VMAXIMIZE,
666 NULL, getKeybind, setKeyGrab, NULL, NULL},
667 {"HMaximizeKey", "None", (void *)WKBD_HMAXIMIZE,
668 NULL, getKeybind, setKeyGrab, NULL, NULL},
669 {"LHMaximizeKey", "None", (void*)WKBD_LHMAXIMIZE,
670 NULL, getKeybind, setKeyGrab, NULL, NULL},
671 {"RHMaximizeKey", "None", (void*)WKBD_RHMAXIMIZE,
672 NULL, getKeybind, setKeyGrab, NULL, NULL},
673 {"THMaximizeKey", "None", (void*)WKBD_THMAXIMIZE,
674 NULL, getKeybind, setKeyGrab, NULL, NULL},
675 {"BHMaximizeKey", "None", (void*)WKBD_BHMAXIMIZE,
676 NULL, getKeybind, setKeyGrab, NULL, NULL},
677 {"LTCMaximizeKey", "None", (void*)WKBD_LTCMAXIMIZE,
678 NULL, getKeybind, setKeyGrab, NULL, NULL},
679 {"RTCMaximizeKey", "None", (void*)WKBD_RTCMAXIMIZE,
680 NULL, getKeybind, setKeyGrab, NULL, NULL},
681 {"LBCMaximizeKey", "None", (void*)WKBD_LBCMAXIMIZE,
682 NULL, getKeybind, setKeyGrab, NULL, NULL},
683 {"RBCMaximizeKey", "None", (void*)WKBD_RBCMAXIMIZE,
684 NULL, getKeybind, setKeyGrab, NULL, NULL},
685 {"MaximusKey", "None", (void*)WKBD_MAXIMUS,
686 NULL, getKeybind, setKeyGrab, NULL, NULL},
687 {"KeepOnTopKey", "None", (void *)WKBD_KEEP_ON_TOP,
688 NULL, getKeybind, setKeyGrab, NULL, NULL},
689 {"KeepAtBottomKey", "None", (void *)WKBD_KEEP_AT_BOTTOM,
690 NULL, getKeybind, setKeyGrab, NULL, NULL},
691 {"OmnipresentKey", "None", (void *)WKBD_OMNIPRESENT,
692 NULL, getKeybind, setKeyGrab, NULL, NULL},
693 {"RaiseKey", "\"Meta+Up\"", (void *)WKBD_RAISE,
694 NULL, getKeybind, setKeyGrab, NULL, NULL},
695 {"LowerKey", "\"Meta+Down\"", (void *)WKBD_LOWER,
696 NULL, getKeybind, setKeyGrab, NULL, NULL},
697 {"RaiseLowerKey", "None", (void *)WKBD_RAISELOWER,
698 NULL, getKeybind, setKeyGrab, NULL, NULL},
699 {"ShadeKey", "None", (void *)WKBD_SHADE,
700 NULL, getKeybind, setKeyGrab, NULL, NULL},
701 {"SelectKey", "None", (void *)WKBD_SELECT,
702 NULL, getKeybind, setKeyGrab, NULL, NULL},
703 {"WorkspaceMapKey", "None", (void *)WKBD_WORKSPACEMAP,
704 NULL, getKeybind, setKeyGrab, NULL, NULL},
705 {"FocusNextKey", "None", (void *)WKBD_FOCUSNEXT,
706 NULL, getKeybind, setKeyGrab, NULL, NULL},
707 {"FocusPrevKey", "None", (void *)WKBD_FOCUSPREV,
708 NULL, getKeybind, setKeyGrab, NULL, NULL},
709 {"GroupNextKey", "None", (void *)WKBD_GROUPNEXT,
710 NULL, getKeybind, setKeyGrab, NULL, NULL},
711 {"GroupPrevKey", "None", (void *)WKBD_GROUPPREV,
712 NULL, getKeybind, setKeyGrab, NULL, NULL},
713 {"NextWorkspaceKey", "None", (void *)WKBD_NEXTWORKSPACE,
714 NULL, getKeybind, setKeyGrab, NULL, NULL},
715 {"PrevWorkspaceKey", "None", (void *)WKBD_PREVWORKSPACE,
716 NULL, getKeybind, setKeyGrab, NULL, NULL},
717 {"LastWorkspaceKey", "None", (void *)WKBD_LASTWORKSPACE,
718 NULL, getKeybind, setKeyGrab, NULL, NULL},
719 {"NextWorkspaceLayerKey", "None", (void *)WKBD_NEXTWSLAYER,
720 NULL, getKeybind, setKeyGrab, NULL, NULL},
721 {"PrevWorkspaceLayerKey", "None", (void *)WKBD_PREVWSLAYER,
722 NULL, getKeybind, setKeyGrab, NULL, NULL},
723 {"Workspace1Key", "None", (void *)WKBD_WORKSPACE1,
724 NULL, getKeybind, setKeyGrab, NULL, NULL},
725 {"Workspace2Key", "None", (void *)WKBD_WORKSPACE2,
726 NULL, getKeybind, setKeyGrab, NULL, NULL},
727 {"Workspace3Key", "None", (void *)WKBD_WORKSPACE3,
728 NULL, getKeybind, setKeyGrab, NULL, NULL},
729 {"Workspace4Key", "None", (void *)WKBD_WORKSPACE4,
730 NULL, getKeybind, setKeyGrab, NULL, NULL},
731 {"Workspace5Key", "None", (void *)WKBD_WORKSPACE5,
732 NULL, getKeybind, setKeyGrab, NULL, NULL},
733 {"Workspace6Key", "None", (void *)WKBD_WORKSPACE6,
734 NULL, getKeybind, setKeyGrab, NULL, NULL},
735 {"Workspace7Key", "None", (void *)WKBD_WORKSPACE7,
736 NULL, getKeybind, setKeyGrab, NULL, NULL},
737 {"Workspace8Key", "None", (void *)WKBD_WORKSPACE8,
738 NULL, getKeybind, setKeyGrab, NULL, NULL},
739 {"Workspace9Key", "None", (void *)WKBD_WORKSPACE9,
740 NULL, getKeybind, setKeyGrab, NULL, NULL},
741 {"Workspace10Key", "None", (void *)WKBD_WORKSPACE10,
742 NULL, getKeybind, setKeyGrab, NULL, NULL},
743 {"MoveToWorkspace1Key", "None", (void *)WKBD_MOVE_WORKSPACE1,
744 NULL, getKeybind, setKeyGrab, NULL, NULL},
745 {"MoveToWorkspace2Key", "None", (void *)WKBD_MOVE_WORKSPACE2,
746 NULL, getKeybind, setKeyGrab, NULL, NULL},
747 {"MoveToWorkspace3Key", "None", (void *)WKBD_MOVE_WORKSPACE3,
748 NULL, getKeybind, setKeyGrab, NULL, NULL},
749 {"MoveToWorkspace4Key", "None", (void *)WKBD_MOVE_WORKSPACE4,
750 NULL, getKeybind, setKeyGrab, NULL, NULL},
751 {"MoveToWorkspace5Key", "None", (void *)WKBD_MOVE_WORKSPACE5,
752 NULL, getKeybind, setKeyGrab, NULL, NULL},
753 {"MoveToWorkspace6Key", "None", (void *)WKBD_MOVE_WORKSPACE6,
754 NULL, getKeybind, setKeyGrab, NULL, NULL},
755 {"MoveToWorkspace7Key", "None", (void *)WKBD_MOVE_WORKSPACE7,
756 NULL, getKeybind, setKeyGrab, NULL, NULL},
757 {"MoveToWorkspace8Key", "None", (void *)WKBD_MOVE_WORKSPACE8,
758 NULL, getKeybind, setKeyGrab, NULL, NULL},
759 {"MoveToWorkspace9Key", "None", (void *)WKBD_MOVE_WORKSPACE9,
760 NULL, getKeybind, setKeyGrab, NULL, NULL},
761 {"MoveToWorkspace10Key", "None", (void *)WKBD_MOVE_WORKSPACE10,
762 NULL, getKeybind, setKeyGrab, NULL, NULL},
763 {"MoveToNextWorkspaceKey", "None", (void *)WKBD_MOVE_NEXTWORKSPACE,
764 NULL, getKeybind, setKeyGrab, NULL, NULL},
765 {"MoveToPrevWorkspaceKey", "None", (void *)WKBD_MOVE_PREVWORKSPACE,
766 NULL, getKeybind, setKeyGrab, NULL, NULL},
767 {"MoveToLastWorkspaceKey", "None", (void *)WKBD_MOVE_LASTWORKSPACE,
768 NULL, getKeybind, setKeyGrab, NULL, NULL},
769 {"MoveToNextWorkspaceLayerKey", "None", (void *)WKBD_MOVE_NEXTWSLAYER,
770 NULL, getKeybind, setKeyGrab, NULL, NULL},
771 {"MoveToPrevWorkspaceLayerKey", "None", (void *)WKBD_MOVE_PREVWSLAYER,
772 NULL, getKeybind, setKeyGrab, NULL, NULL},
773 {"WindowShortcut1Key", "None", (void *)WKBD_WINDOW1,
774 NULL, getKeybind, setKeyGrab, NULL, NULL},
775 {"WindowShortcut2Key", "None", (void *)WKBD_WINDOW2,
776 NULL, getKeybind, setKeyGrab, NULL, NULL},
777 {"WindowShortcut3Key", "None", (void *)WKBD_WINDOW3,
778 NULL, getKeybind, setKeyGrab, NULL, NULL},
779 {"WindowShortcut4Key", "None", (void *)WKBD_WINDOW4,
780 NULL, getKeybind, setKeyGrab, NULL, NULL},
781 {"WindowShortcut5Key", "None", (void *)WKBD_WINDOW5,
782 NULL, getKeybind, setKeyGrab, NULL, NULL},
783 {"WindowShortcut6Key", "None", (void *)WKBD_WINDOW6,
784 NULL, getKeybind, setKeyGrab, NULL, NULL},
785 {"WindowShortcut7Key", "None", (void *)WKBD_WINDOW7,
786 NULL, getKeybind, setKeyGrab, NULL, NULL},
787 {"WindowShortcut8Key", "None", (void *)WKBD_WINDOW8,
788 NULL, getKeybind, setKeyGrab, NULL, NULL},
789 {"WindowShortcut9Key", "None", (void *)WKBD_WINDOW9,
790 NULL, getKeybind, setKeyGrab, NULL, NULL},
791 {"WindowShortcut10Key", "None", (void *)WKBD_WINDOW10,
792 NULL, getKeybind, setKeyGrab, NULL, NULL},
793 {"WindowRelaunchKey", "None", (void *)WKBD_RELAUNCH,
794 NULL, getKeybind, setKeyGrab, NULL, NULL},
795 {"ScreenSwitchKey", "None", (void *)WKBD_SWITCH_SCREEN,
796 NULL, getKeybind, setKeyGrab, NULL, NULL},
797 {"RunKey", "None", (void *)WKBD_RUN,
798 NULL, getKeybind, setKeyGrab, NULL, NULL},
800 #ifdef KEEP_XKB_LOCK_STATUS
801 {"ToggleKbdModeKey", "None", (void *)WKBD_TOGGLE,
802 NULL, getKeybind, setKeyGrab, NULL, NULL},
803 {"KbdModeLock", "NO", NULL,
804 &wPreferences.modelock, getBool, NULL, NULL, NULL},
805 #endif /* KEEP_XKB_LOCK_STATUS */
807 {"NormalCursor", "(builtin, left_ptr)", (void *)WCUR_ROOT,
808 NULL, getCursor, setCursor, NULL, NULL},
809 {"ArrowCursor", "(builtin, top_left_arrow)", (void *)WCUR_ARROW,
810 NULL, getCursor, setCursor, NULL, NULL},
811 {"MoveCursor", "(builtin, fleur)", (void *)WCUR_MOVE,
812 NULL, getCursor, setCursor, NULL, NULL},
813 {"ResizeCursor", "(builtin, sizing)", (void *)WCUR_RESIZE,
814 NULL, getCursor, setCursor, NULL, NULL},
815 {"TopLeftResizeCursor", "(builtin, top_left_corner)", (void *)WCUR_TOPLEFTRESIZE,
816 NULL, getCursor, setCursor, NULL, NULL},
817 {"TopRightResizeCursor", "(builtin, top_right_corner)", (void *)WCUR_TOPRIGHTRESIZE,
818 NULL, getCursor, setCursor, NULL, NULL},
819 {"BottomLeftResizeCursor", "(builtin, bottom_left_corner)", (void *)WCUR_BOTTOMLEFTRESIZE,
820 NULL, getCursor, setCursor, NULL, NULL},
821 {"BottomRightResizeCursor", "(builtin, bottom_right_corner)", (void *)WCUR_BOTTOMRIGHTRESIZE,
822 NULL, getCursor, setCursor, NULL, NULL},
823 {"VerticalResizeCursor", "(builtin, sb_v_double_arrow)", (void *)WCUR_VERTICALRESIZE,
824 NULL, getCursor, setCursor, NULL, NULL},
825 {"HorizontalResizeCursor", "(builtin, sb_h_double_arrow)", (void *)WCUR_HORIZONRESIZE,
826 NULL, getCursor, setCursor, NULL, NULL},
827 {"WaitCursor", "(builtin, watch)", (void *)WCUR_WAIT,
828 NULL, getCursor, setCursor, NULL, NULL},
829 {"QuestionCursor", "(builtin, question_arrow)", (void *)WCUR_QUESTION,
830 NULL, getCursor, setCursor, NULL, NULL},
831 {"TextCursor", "(builtin, xterm)", (void *)WCUR_TEXT,
832 NULL, getCursor, setCursor, NULL, NULL},
833 {"SelectCursor", "(builtin, cross)", (void *)WCUR_SELECT,
834 NULL, getCursor, setCursor, NULL, NULL},
835 {"DialogHistoryLines", "500", NULL,
836 &wPreferences.history_lines, getInt, NULL, NULL, NULL},
837 {"CycleActiveHeadOnly", "NO", NULL,
838 &wPreferences.cycle_active_head_only, getBool, NULL, NULL, NULL},
839 {"CycleIgnoreMinimized", "NO", NULL,
840 &wPreferences.cycle_ignore_minimized, getBool, NULL, NULL, NULL}
843 static void initDefaults(void)
845 unsigned int i;
846 WDefaultEntry *entry;
848 WMPLSetCaseSensitive(False);
850 for (i = 0; i < wlengthof(optionList); i++) {
851 entry = &optionList[i];
853 entry->plkey = WMCreatePLString(entry->key);
854 if (entry->default_value)
855 entry->plvalue = WMCreatePropListFromDescription(entry->default_value);
856 else
857 entry->plvalue = NULL;
860 for (i = 0; i < wlengthof(staticOptionList); i++) {
861 entry = &staticOptionList[i];
863 entry->plkey = WMCreatePLString(entry->key);
864 if (entry->default_value)
865 entry->plvalue = WMCreatePropListFromDescription(entry->default_value);
866 else
867 entry->plvalue = NULL;
871 static WMPropList *readGlobalDomain(const char *domainName, Bool requireDictionary)
873 WMPropList *globalDict = NULL;
874 char path[PATH_MAX];
875 struct stat stbuf;
877 snprintf(path, sizeof(path), "%s/%s", DEFSDATADIR, domainName);
878 if (stat(path, &stbuf) >= 0) {
879 globalDict = WMReadPropListFromFile(path);
880 if (globalDict && requireDictionary && !WMIsPLDictionary(globalDict)) {
881 wwarning(_("Domain %s (%s) of global defaults database is corrupted!"), domainName, path);
882 WMReleasePropList(globalDict);
883 globalDict = NULL;
884 } else if (!globalDict) {
885 wwarning(_("could not load domain %s from global defaults database"), domainName);
889 return globalDict;
892 #if defined(GLOBAL_PREAMBLE_MENU_FILE) || defined(GLOBAL_EPILOGUE_MENU_FILE)
893 static void prependMenu(WMPropList * destarr, WMPropList * array)
895 WMPropList *item;
896 int i;
898 for (i = 0; i < WMGetPropListItemCount(array); i++) {
899 item = WMGetFromPLArray(array, i);
900 if (item)
901 WMInsertInPLArray(destarr, i + 1, item);
905 static void appendMenu(WMPropList * destarr, WMPropList * array)
907 WMPropList *item;
908 int i;
910 for (i = 0; i < WMGetPropListItemCount(array); i++) {
911 item = WMGetFromPLArray(array, i);
912 if (item)
913 WMAddToPLArray(destarr, item);
916 #endif
918 void wDefaultsMergeGlobalMenus(WDDomain * menuDomain)
920 WMPropList *menu = menuDomain->dictionary;
921 WMPropList *submenu;
923 if (!menu || !WMIsPLArray(menu))
924 return;
926 #ifdef GLOBAL_PREAMBLE_MENU_FILE
927 submenu = WMReadPropListFromFile(DEFSDATADIR "/" GLOBAL_PREAMBLE_MENU_FILE);
929 if (submenu && !WMIsPLArray(submenu)) {
930 wwarning(_("invalid global menu file %s"), GLOBAL_PREAMBLE_MENU_FILE);
931 WMReleasePropList(submenu);
932 submenu = NULL;
934 if (submenu) {
935 prependMenu(menu, submenu);
936 WMReleasePropList(submenu);
938 #endif
940 #ifdef GLOBAL_EPILOGUE_MENU_FILE
941 submenu = WMReadPropListFromFile(DEFSDATADIR "/" GLOBAL_EPILOGUE_MENU_FILE);
943 if (submenu && !WMIsPLArray(submenu)) {
944 wwarning(_("invalid global menu file %s"), GLOBAL_EPILOGUE_MENU_FILE);
945 WMReleasePropList(submenu);
946 submenu = NULL;
948 if (submenu) {
949 appendMenu(menu, submenu);
950 WMReleasePropList(submenu);
952 #endif
954 menuDomain->dictionary = menu;
957 WDDomain *wDefaultsInitDomain(const char *domain, Bool requireDictionary)
959 WDDomain *db;
960 struct stat stbuf;
961 static int inited = 0;
962 WMPropList *shared_dict = NULL;
964 if (!inited) {
965 inited = 1;
966 initDefaults();
969 db = wmalloc(sizeof(WDDomain));
970 db->domain_name = domain;
971 db->path = wdefaultspathfordomain(domain);
973 if (stat(db->path, &stbuf) >= 0) {
974 db->dictionary = WMReadPropListFromFile(db->path);
975 if (db->dictionary) {
976 if (requireDictionary && !WMIsPLDictionary(db->dictionary)) {
977 WMReleasePropList(db->dictionary);
978 db->dictionary = NULL;
979 wwarning(_("Domain %s (%s) of defaults database is corrupted!"), domain, db->path);
981 db->timestamp = stbuf.st_mtime;
982 } else {
983 wwarning(_("could not load domain %s from user defaults database"), domain);
987 /* global system dictionary */
988 shared_dict = readGlobalDomain(domain, requireDictionary);
990 if (shared_dict && db->dictionary && WMIsPLDictionary(shared_dict) &&
991 WMIsPLDictionary(db->dictionary)) {
992 WMMergePLDictionaries(shared_dict, db->dictionary, True);
993 WMReleasePropList(db->dictionary);
994 db->dictionary = shared_dict;
995 if (stbuf.st_mtime > db->timestamp)
996 db->timestamp = stbuf.st_mtime;
997 } else if (!db->dictionary) {
998 db->dictionary = shared_dict;
999 if (stbuf.st_mtime > db->timestamp)
1000 db->timestamp = stbuf.st_mtime;
1003 return db;
1006 void wReadStaticDefaults(WMPropList * dict)
1008 WMPropList *plvalue;
1009 WDefaultEntry *entry;
1010 unsigned int i;
1011 void *tdata;
1013 for (i = 0; i < wlengthof(staticOptionList); i++) {
1014 entry = &staticOptionList[i];
1016 if (dict)
1017 plvalue = WMGetFromPLDictionary(dict, entry->plkey);
1018 else
1019 plvalue = NULL;
1021 /* no default in the DB. Use builtin default */
1022 if (!plvalue)
1023 plvalue = entry->plvalue;
1025 if (plvalue) {
1026 /* convert data */
1027 (*entry->convert) (NULL, entry, plvalue, entry->addr, &tdata);
1028 if (entry->update)
1029 (*entry->update) (NULL, entry, tdata, entry->extra_data);
1034 void wDefaultsCheckDomains(void* arg)
1036 WScreen *scr;
1037 struct stat stbuf;
1038 WMPropList *shared_dict = NULL;
1039 WMPropList *dict;
1040 int i;
1042 /* Parameter not used, but tell the compiler that it is ok */
1043 (void) arg;
1045 if (stat(w_global.domain.wmaker->path, &stbuf) >= 0 && w_global.domain.wmaker->timestamp < stbuf.st_mtime) {
1046 w_global.domain.wmaker->timestamp = stbuf.st_mtime;
1048 /* Global dictionary */
1049 shared_dict = readGlobalDomain("WindowMaker", True);
1051 /* User dictionary */
1052 dict = WMReadPropListFromFile(w_global.domain.wmaker->path);
1054 if (dict) {
1055 if (!WMIsPLDictionary(dict)) {
1056 WMReleasePropList(dict);
1057 dict = NULL;
1058 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
1059 "WindowMaker", w_global.domain.wmaker->path);
1060 } else {
1061 if (shared_dict) {
1062 WMMergePLDictionaries(shared_dict, dict, True);
1063 WMReleasePropList(dict);
1064 dict = shared_dict;
1065 shared_dict = NULL;
1068 for (i = 0; i < w_global.screen_count; i++) {
1069 scr = wScreenWithNumber(i);
1070 if (scr)
1071 wReadDefaults(scr, dict);
1074 if (w_global.domain.wmaker->dictionary)
1075 WMReleasePropList(w_global.domain.wmaker->dictionary);
1077 w_global.domain.wmaker->dictionary = dict;
1079 } else {
1080 wwarning(_("could not load domain %s from user defaults database"), "WindowMaker");
1083 if (shared_dict)
1084 WMReleasePropList(shared_dict);
1088 if (stat(w_global.domain.window_attr->path, &stbuf) >= 0 && w_global.domain.window_attr->timestamp < stbuf.st_mtime) {
1089 /* global dictionary */
1090 shared_dict = readGlobalDomain("WMWindowAttributes", True);
1091 /* user dictionary */
1092 dict = WMReadPropListFromFile(w_global.domain.window_attr->path);
1093 if (dict) {
1094 if (!WMIsPLDictionary(dict)) {
1095 WMReleasePropList(dict);
1096 dict = NULL;
1097 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
1098 "WMWindowAttributes", w_global.domain.window_attr->path);
1099 } else {
1100 if (shared_dict) {
1101 WMMergePLDictionaries(shared_dict, dict, True);
1102 WMReleasePropList(dict);
1103 dict = shared_dict;
1104 shared_dict = NULL;
1107 if (w_global.domain.window_attr->dictionary)
1108 WMReleasePropList(w_global.domain.window_attr->dictionary);
1110 w_global.domain.window_attr->dictionary = dict;
1111 for (i = 0; i < w_global.screen_count; i++) {
1112 scr = wScreenWithNumber(i);
1113 if (scr) {
1114 wDefaultUpdateIcons(scr);
1116 /* Update the panel image if changed */
1117 /* Don't worry. If the image is the same these
1118 * functions will have no performance impact. */
1119 create_logo_image(scr);
1123 } else {
1124 wwarning(_("could not load domain %s from user defaults database"), "WMWindowAttributes");
1127 w_global.domain.window_attr->timestamp = stbuf.st_mtime;
1128 if (shared_dict)
1129 WMReleasePropList(shared_dict);
1132 if (stat(w_global.domain.root_menu->path, &stbuf) >= 0 && w_global.domain.root_menu->timestamp < stbuf.st_mtime) {
1133 dict = WMReadPropListFromFile(w_global.domain.root_menu->path);
1134 if (dict) {
1135 if (!WMIsPLArray(dict) && !WMIsPLString(dict)) {
1136 WMReleasePropList(dict);
1137 dict = NULL;
1138 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
1139 "WMRootMenu", w_global.domain.root_menu->path);
1140 } else {
1141 if (w_global.domain.root_menu->dictionary)
1142 WMReleasePropList(w_global.domain.root_menu->dictionary);
1144 w_global.domain.root_menu->dictionary = dict;
1145 wDefaultsMergeGlobalMenus(w_global.domain.root_menu);
1147 } else {
1148 wwarning(_("could not load domain %s from user defaults database"), "WMRootMenu");
1150 w_global.domain.root_menu->timestamp = stbuf.st_mtime;
1152 #ifndef HAVE_INOTIFY
1153 if (!arg)
1154 WMAddTimerHandler(DEFAULTS_CHECK_INTERVAL, wDefaultsCheckDomains, arg);
1155 #endif
1158 void wReadDefaults(WScreen * scr, WMPropList * new_dict)
1160 WMPropList *plvalue, *old_value;
1161 WDefaultEntry *entry;
1162 unsigned int i;
1163 int update_workspace_back = 0; /* kluge :/ */
1164 unsigned int needs_refresh;
1165 void *tdata;
1166 WMPropList *old_dict = (w_global.domain.wmaker->dictionary != new_dict ? w_global.domain.wmaker->dictionary : NULL);
1168 needs_refresh = 0;
1170 for (i = 0; i < wlengthof(optionList); i++) {
1171 entry = &optionList[i];
1173 if (new_dict)
1174 plvalue = WMGetFromPLDictionary(new_dict, entry->plkey);
1175 else
1176 plvalue = NULL;
1178 if (!old_dict)
1179 old_value = NULL;
1180 else
1181 old_value = WMGetFromPLDictionary(old_dict, entry->plkey);
1183 if (!plvalue && !old_value) {
1184 /* no default in the DB. Use builtin default */
1185 plvalue = entry->plvalue;
1186 if (plvalue && new_dict)
1187 WMPutInPLDictionary(new_dict, entry->plkey, plvalue);
1189 } else if (!plvalue) {
1190 /* value was deleted from DB. Keep current value */
1191 continue;
1192 } else if (!old_value) {
1193 /* set value for the 1st time */
1194 } else if (!WMIsPropListEqualTo(plvalue, old_value)) {
1195 /* value has changed */
1196 } else {
1197 if (strcmp(entry->key, "WorkspaceBack") == 0
1198 && update_workspace_back && scr->flags.backimage_helper_launched) {
1199 } else {
1200 /* value was not changed since last time */
1201 continue;
1205 if (plvalue) {
1206 /* convert data */
1207 if ((*entry->convert) (scr, entry, plvalue, entry->addr, &tdata)) {
1209 * If the WorkspaceSpecificBack data has been changed
1210 * so that the helper will be launched now, we must be
1211 * sure to send the default background texture config
1212 * to the helper.
1214 if (strcmp(entry->key, "WorkspaceSpecificBack") == 0 &&
1215 !scr->flags.backimage_helper_launched)
1216 update_workspace_back = 1;
1218 if (entry->update)
1219 needs_refresh |= (*entry->update) (scr, entry, tdata, entry->extra_data);
1226 * Backward Compatibility:
1227 * Support the old setting names for Apercu, now called Mini-Preview
1229 * This code should probably stay for at least 2 years, you should not consider removing
1230 * it before year 2017
1232 if (legacy_minipreview_config.enable) {
1233 wwarning(_("your configuration is using old syntax for Mini-Preview settings; consider running WPrefs.app to update"));
1234 wPreferences.miniwin_preview_balloon = legacy_minipreview_config.enable;
1236 if (legacy_minipreview_config.size > 0) {
1238 * the option 'ApercuSize' used to be coded as a multiple of the icon size in v0.95.6
1239 * it is now expressed directly in pixels, but to avoid breaking user's setting we check
1240 * for old coding and convert it now.
1242 if (legacy_minipreview_config.size < 24) {
1243 /* 24 is the minimum icon size proposed in WPref's settings */
1244 wPreferences.minipreview_size = legacy_minipreview_config.size * wPreferences.icon_size;
1245 } else {
1246 wPreferences.minipreview_size = legacy_minipreview_config.size;
1251 if (needs_refresh != 0 && !scr->flags.startup) {
1252 int foo;
1254 foo = 0;
1255 if (needs_refresh & REFRESH_MENU_TITLE_TEXTURE)
1256 foo |= WTextureSettings;
1257 if (needs_refresh & REFRESH_MENU_TITLE_FONT)
1258 foo |= WFontSettings;
1259 if (needs_refresh & REFRESH_MENU_TITLE_COLOR)
1260 foo |= WColorSettings;
1261 if (foo)
1262 WMPostNotificationName(WNMenuTitleAppearanceSettingsChanged, NULL,
1263 (void *)(uintptr_t) foo);
1265 foo = 0;
1266 if (needs_refresh & REFRESH_MENU_TEXTURE)
1267 foo |= WTextureSettings;
1268 if (needs_refresh & REFRESH_MENU_FONT)
1269 foo |= WFontSettings;
1270 if (needs_refresh & REFRESH_MENU_COLOR)
1271 foo |= WColorSettings;
1272 if (foo)
1273 WMPostNotificationName(WNMenuAppearanceSettingsChanged, NULL, (void *)(uintptr_t) foo);
1275 foo = 0;
1276 if (needs_refresh & REFRESH_WINDOW_FONT)
1277 foo |= WFontSettings;
1278 if (needs_refresh & REFRESH_WINDOW_TEXTURES)
1279 foo |= WTextureSettings;
1280 if (needs_refresh & REFRESH_WINDOW_TITLE_COLOR)
1281 foo |= WColorSettings;
1282 if (foo)
1283 WMPostNotificationName(WNWindowAppearanceSettingsChanged, NULL, (void *)(uintptr_t) foo);
1285 if (!(needs_refresh & REFRESH_ICON_TILE)) {
1286 foo = 0;
1287 if (needs_refresh & REFRESH_ICON_FONT)
1288 foo |= WFontSettings;
1289 if (needs_refresh & REFRESH_ICON_TITLE_COLOR)
1290 foo |= WTextureSettings;
1291 if (needs_refresh & REFRESH_ICON_TITLE_BACK)
1292 foo |= WTextureSettings;
1293 if (foo)
1294 WMPostNotificationName(WNIconAppearanceSettingsChanged, NULL,
1295 (void *)(uintptr_t) foo);
1297 if (needs_refresh & REFRESH_ICON_TILE)
1298 WMPostNotificationName(WNIconTileSettingsChanged, NULL, NULL);
1300 if (needs_refresh & REFRESH_WORKSPACE_MENU) {
1301 if (scr->workspace_menu)
1302 wWorkspaceMenuUpdate(scr, scr->workspace_menu);
1303 if (scr->clip_ws_menu)
1304 wWorkspaceMenuUpdate(scr, scr->clip_ws_menu);
1305 if (scr->workspace_submenu)
1306 scr->workspace_submenu->flags.realized = 0;
1307 if (scr->clip_submenu)
1308 scr->clip_submenu->flags.realized = 0;
1313 void wDefaultUpdateIcons(WScreen *scr)
1315 WAppIcon *aicon = scr->app_icon_list;
1316 WDrawerChain *dc;
1317 WWindow *wwin = scr->focused_window;
1319 while (aicon) {
1320 /* Get the application icon, default included */
1321 wIconChangeImageFile(aicon->icon, NULL);
1322 wAppIconPaint(aicon);
1323 aicon = aicon->next;
1326 if (!wPreferences.flags.noclip || wPreferences.flags.clip_merged_in_dock)
1327 wClipIconPaint(scr->clip_icon);
1329 for (dc = scr->drawers; dc != NULL; dc = dc->next)
1330 wDrawerIconPaint(dc->adrawer->icon_array[0]);
1332 while (wwin) {
1333 if (wwin->icon && wwin->flags.miniaturized)
1334 wIconChangeImageFile(wwin->icon, NULL);
1335 wwin = wwin->prev;
1339 /* --------------------------- Local ----------------------- */
1341 #define GET_STRING_OR_DEFAULT(x, var) if (!WMIsPLString(value)) { \
1342 wwarning(_("Wrong option format for key \"%s\". Should be %s."), \
1343 entry->key, x); \
1344 wwarning(_("using default \"%s\" instead"), entry->default_value); \
1345 var = entry->default_value;\
1346 } else var = WMGetFromPLString(value)\
1349 static int string2index(WMPropList *key, WMPropList *val, const char *def, WOptionEnumeration * values)
1351 char *str;
1352 WOptionEnumeration *v;
1353 char buffer[TOTAL_VALUES_LENGTH];
1355 if (WMIsPLString(val) && (str = WMGetFromPLString(val))) {
1356 for (v = values; v->string != NULL; v++) {
1357 if (strcasecmp(v->string, str) == 0)
1358 return v->value;
1362 buffer[0] = 0;
1363 for (v = values; v->string != NULL; v++) {
1364 if (!v->is_alias) {
1365 if (buffer[0] != 0)
1366 strcat(buffer, ", ");
1367 snprintf(buffer+strlen(buffer),
1368 sizeof(buffer)-strlen(buffer)-1, "\"%s\"", v->string);
1371 wwarning(_("wrong option value for key \"%s\"; got \"%s\", should be one of %s."),
1372 WMGetFromPLString(key),
1373 WMIsPLString(val) ? WMGetFromPLString(val) : "(unknown)",
1374 buffer);
1376 if (def) {
1377 return string2index(key, val, NULL, values);
1380 return -1;
1384 * value - is the value in the defaults DB
1385 * addr - is the address to store the data
1386 * ret - is the address to store a pointer to a temporary buffer. ret
1387 * must not be freed and is used by the set functions
1389 static int getBool(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1391 static char data;
1392 const char *val;
1393 int second_pass = 0;
1395 /* Parameter not used, but tell the compiler that it is ok */
1396 (void) scr;
1398 GET_STRING_OR_DEFAULT("Boolean", val);
1400 again:
1401 if ((val[1] == '\0' && (val[0] == 'y' || val[0] == 'Y'))
1402 || strcasecmp(val, "YES") == 0) {
1404 data = 1;
1405 } else if ((val[1] == '\0' && (val[0] == 'n' || val[0] == 'N'))
1406 || strcasecmp(val, "NO") == 0) {
1407 data = 0;
1408 } else {
1409 int i;
1410 if (sscanf(val, "%i", &i) == 1) {
1411 if (i != 0)
1412 data = 1;
1413 else
1414 data = 0;
1415 } else {
1416 wwarning(_("can't convert \"%s\" to boolean for key \"%s\""), val, entry->key);
1417 if (second_pass == 0) {
1418 val = WMGetFromPLString(entry->plvalue);
1419 second_pass = 1;
1420 wwarning(_("using default \"%s\" instead"), val);
1421 goto again;
1423 return False;
1427 if (ret)
1428 *ret = &data;
1429 if (addr)
1430 *(char *)addr = data;
1432 return True;
1435 static int getInt(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1437 static int data;
1438 const char *val;
1440 /* Parameter not used, but tell the compiler that it is ok */
1441 (void) scr;
1443 GET_STRING_OR_DEFAULT("Integer", val);
1445 if (sscanf(val, "%i", &data) != 1) {
1446 wwarning(_("can't convert \"%s\" to integer for key \"%s\""), val, entry->key);
1447 val = WMGetFromPLString(entry->plvalue);
1448 wwarning(_("using default \"%s\" instead"), val);
1449 if (sscanf(val, "%i", &data) != 1) {
1450 return False;
1454 if (ret)
1455 *ret = &data;
1456 if (addr)
1457 *(int *)addr = data;
1459 return True;
1462 static int getCoord(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1464 static WCoord data;
1465 char *val_x, *val_y;
1466 int nelem, changed = 0;
1467 WMPropList *elem_x, *elem_y;
1469 again:
1470 if (!WMIsPLArray(value)) {
1471 wwarning(_("Wrong option format for key \"%s\". Should be %s."), entry->key, "Coordinate");
1472 if (changed == 0) {
1473 value = entry->plvalue;
1474 changed = 1;
1475 wwarning(_("using default \"%s\" instead"), entry->default_value);
1476 goto again;
1478 return False;
1481 nelem = WMGetPropListItemCount(value);
1482 if (nelem != 2) {
1483 wwarning(_("Incorrect number of elements in array for key \"%s\"."), entry->key);
1484 if (changed == 0) {
1485 value = entry->plvalue;
1486 changed = 1;
1487 wwarning(_("using default \"%s\" instead"), entry->default_value);
1488 goto again;
1490 return False;
1493 elem_x = WMGetFromPLArray(value, 0);
1494 elem_y = WMGetFromPLArray(value, 1);
1496 if (!elem_x || !elem_y || !WMIsPLString(elem_x) || !WMIsPLString(elem_y)) {
1497 wwarning(_("Wrong value for key \"%s\". Should be Coordinate."), entry->key);
1498 if (changed == 0) {
1499 value = entry->plvalue;
1500 changed = 1;
1501 wwarning(_("using default \"%s\" instead"), entry->default_value);
1502 goto again;
1504 return False;
1507 val_x = WMGetFromPLString(elem_x);
1508 val_y = WMGetFromPLString(elem_y);
1510 if (sscanf(val_x, "%i", &data.x) != 1 || sscanf(val_y, "%i", &data.y) != 1) {
1511 wwarning(_("can't convert array to integers for \"%s\"."), entry->key);
1512 if (changed == 0) {
1513 value = entry->plvalue;
1514 changed = 1;
1515 wwarning(_("using default \"%s\" instead"), entry->default_value);
1516 goto again;
1518 return False;
1521 if (data.x < 0)
1522 data.x = 0;
1523 else if (data.x > scr->scr_width / 3)
1524 data.x = scr->scr_width / 3;
1525 if (data.y < 0)
1526 data.y = 0;
1527 else if (data.y > scr->scr_height / 3)
1528 data.y = scr->scr_height / 3;
1530 if (ret)
1531 *ret = &data;
1532 if (addr)
1533 *(WCoord *) addr = data;
1535 return True;
1538 static int getPropList(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1540 /* Parameter not used, but tell the compiler that it is ok */
1541 (void) scr;
1542 (void) entry;
1543 (void) addr;
1545 WMRetainPropList(value);
1547 *ret = value;
1549 return True;
1552 static int getPathList(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1554 static char *data;
1555 int i, count, len;
1556 char *ptr;
1557 WMPropList *d;
1558 int changed = 0;
1560 /* Parameter not used, but tell the compiler that it is ok */
1561 (void) scr;
1562 (void) ret;
1564 again:
1565 if (!WMIsPLArray(value)) {
1566 wwarning(_("Wrong option format for key \"%s\". Should be %s."), entry->key, "an array of paths");
1567 if (changed == 0) {
1568 value = entry->plvalue;
1569 changed = 1;
1570 wwarning(_("using default \"%s\" instead"), entry->default_value);
1571 goto again;
1573 return False;
1576 i = 0;
1577 count = WMGetPropListItemCount(value);
1578 if (count < 1) {
1579 if (changed == 0) {
1580 value = entry->plvalue;
1581 changed = 1;
1582 wwarning(_("using default \"%s\" instead"), entry->default_value);
1583 goto again;
1585 return False;
1588 len = 0;
1589 for (i = 0; i < count; i++) {
1590 d = WMGetFromPLArray(value, i);
1591 if (!d || !WMIsPLString(d)) {
1592 count = i;
1593 break;
1595 len += strlen(WMGetFromPLString(d)) + 1;
1598 ptr = data = wmalloc(len + 1);
1600 for (i = 0; i < count; i++) {
1601 d = WMGetFromPLArray(value, i);
1602 if (!d || !WMIsPLString(d)) {
1603 break;
1605 strcpy(ptr, WMGetFromPLString(d));
1606 ptr += strlen(WMGetFromPLString(d));
1607 *ptr = ':';
1608 ptr++;
1610 ptr--;
1611 *(ptr--) = 0;
1613 if (*(char **)addr != NULL) {
1614 wfree(*(char **)addr);
1616 *(char **)addr = data;
1618 return True;
1621 static int getEnum(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1623 static signed char data;
1625 /* Parameter not used, but tell the compiler that it is ok */
1626 (void) scr;
1628 data = string2index(entry->plkey, value, entry->default_value, (WOptionEnumeration *) entry->extra_data);
1629 if (data < 0)
1630 return False;
1632 if (ret)
1633 *ret = &data;
1634 if (addr)
1635 *(signed char *)addr = data;
1637 return True;
1641 * (solid <color>)
1642 * (hgradient <color> <color>)
1643 * (vgradient <color> <color>)
1644 * (dgradient <color> <color>)
1645 * (mhgradient <color> <color> ...)
1646 * (mvgradient <color> <color> ...)
1647 * (mdgradient <color> <color> ...)
1648 * (igradient <color1> <color1> <thickness1> <color2> <color2> <thickness2>)
1649 * (tpixmap <file> <color>)
1650 * (spixmap <file> <color>)
1651 * (cpixmap <file> <color>)
1652 * (thgradient <file> <opaqueness> <color> <color>)
1653 * (tvgradient <file> <opaqueness> <color> <color>)
1654 * (tdgradient <file> <opaqueness> <color> <color>)
1655 * (function <lib> <function> ...)
1658 static WTexture *parse_texture(WScreen * scr, WMPropList * pl)
1660 WMPropList *elem;
1661 char *val;
1662 int nelem;
1663 WTexture *texture = NULL;
1665 nelem = WMGetPropListItemCount(pl);
1666 if (nelem < 1)
1667 return NULL;
1669 elem = WMGetFromPLArray(pl, 0);
1670 if (!elem || !WMIsPLString(elem))
1671 return NULL;
1672 val = WMGetFromPLString(elem);
1674 if (strcasecmp(val, "solid") == 0) {
1675 XColor color;
1677 if (nelem != 2)
1678 return NULL;
1680 /* get color */
1682 elem = WMGetFromPLArray(pl, 1);
1683 if (!elem || !WMIsPLString(elem))
1684 return NULL;
1685 val = WMGetFromPLString(elem);
1687 if (!XParseColor(dpy, scr->w_colormap, val, &color)) {
1688 wwarning(_("\"%s\" is not a valid color name"), val);
1689 return NULL;
1692 texture = (WTexture *) wTextureMakeSolid(scr, &color);
1693 } else if (strcasecmp(val, "dgradient") == 0
1694 || strcasecmp(val, "vgradient") == 0 || strcasecmp(val, "hgradient") == 0) {
1695 RColor color1, color2;
1696 XColor xcolor;
1697 int type;
1699 if (nelem != 3) {
1700 wwarning(_("bad number of arguments in gradient specification"));
1701 return NULL;
1704 if (val[0] == 'd' || val[0] == 'D')
1705 type = WTEX_DGRADIENT;
1706 else if (val[0] == 'h' || val[0] == 'H')
1707 type = WTEX_HGRADIENT;
1708 else
1709 type = WTEX_VGRADIENT;
1711 /* get from color */
1712 elem = WMGetFromPLArray(pl, 1);
1713 if (!elem || !WMIsPLString(elem))
1714 return NULL;
1715 val = WMGetFromPLString(elem);
1717 if (!XParseColor(dpy, scr->w_colormap, val, &xcolor)) {
1718 wwarning(_("\"%s\" is not a valid color name"), val);
1719 return NULL;
1721 color1.alpha = 255;
1722 color1.red = xcolor.red >> 8;
1723 color1.green = xcolor.green >> 8;
1724 color1.blue = xcolor.blue >> 8;
1726 /* get to color */
1727 elem = WMGetFromPLArray(pl, 2);
1728 if (!elem || !WMIsPLString(elem)) {
1729 return NULL;
1731 val = WMGetFromPLString(elem);
1733 if (!XParseColor(dpy, scr->w_colormap, val, &xcolor)) {
1734 wwarning(_("\"%s\" is not a valid color name"), val);
1735 return NULL;
1737 color2.alpha = 255;
1738 color2.red = xcolor.red >> 8;
1739 color2.green = xcolor.green >> 8;
1740 color2.blue = xcolor.blue >> 8;
1742 texture = (WTexture *) wTextureMakeGradient(scr, type, &color1, &color2);
1744 } else if (strcasecmp(val, "igradient") == 0) {
1745 RColor colors1[2], colors2[2];
1746 int th1, th2;
1747 XColor xcolor;
1748 int i;
1750 if (nelem != 7) {
1751 wwarning(_("bad number of arguments in gradient specification"));
1752 return NULL;
1755 /* get from color */
1756 for (i = 0; i < 2; i++) {
1757 elem = WMGetFromPLArray(pl, 1 + i);
1758 if (!elem || !WMIsPLString(elem))
1759 return NULL;
1760 val = WMGetFromPLString(elem);
1762 if (!XParseColor(dpy, scr->w_colormap, val, &xcolor)) {
1763 wwarning(_("\"%s\" is not a valid color name"), val);
1764 return NULL;
1766 colors1[i].alpha = 255;
1767 colors1[i].red = xcolor.red >> 8;
1768 colors1[i].green = xcolor.green >> 8;
1769 colors1[i].blue = xcolor.blue >> 8;
1771 elem = WMGetFromPLArray(pl, 3);
1772 if (!elem || !WMIsPLString(elem))
1773 return NULL;
1774 val = WMGetFromPLString(elem);
1775 th1 = atoi(val);
1777 /* get from color */
1778 for (i = 0; i < 2; i++) {
1779 elem = WMGetFromPLArray(pl, 4 + i);
1780 if (!elem || !WMIsPLString(elem))
1781 return NULL;
1782 val = WMGetFromPLString(elem);
1784 if (!XParseColor(dpy, scr->w_colormap, val, &xcolor)) {
1785 wwarning(_("\"%s\" is not a valid color name"), val);
1786 return NULL;
1788 colors2[i].alpha = 255;
1789 colors2[i].red = xcolor.red >> 8;
1790 colors2[i].green = xcolor.green >> 8;
1791 colors2[i].blue = xcolor.blue >> 8;
1793 elem = WMGetFromPLArray(pl, 6);
1794 if (!elem || !WMIsPLString(elem))
1795 return NULL;
1796 val = WMGetFromPLString(elem);
1797 th2 = atoi(val);
1799 texture = (WTexture *) wTextureMakeIGradient(scr, th1, colors1, th2, colors2);
1801 } else if (strcasecmp(val, "mhgradient") == 0
1802 || strcasecmp(val, "mvgradient") == 0 || strcasecmp(val, "mdgradient") == 0) {
1803 XColor color;
1804 RColor **colors;
1805 int i, count;
1806 int type;
1808 if (nelem < 3) {
1809 wwarning(_("too few arguments in multicolor gradient specification"));
1810 return NULL;
1813 if (val[1] == 'h' || val[1] == 'H')
1814 type = WTEX_MHGRADIENT;
1815 else if (val[1] == 'v' || val[1] == 'V')
1816 type = WTEX_MVGRADIENT;
1817 else
1818 type = WTEX_MDGRADIENT;
1820 count = nelem - 1;
1822 colors = wmalloc(sizeof(RColor *) * (count + 1));
1824 for (i = 0; i < count; i++) {
1825 elem = WMGetFromPLArray(pl, i + 1);
1826 if (!elem || !WMIsPLString(elem)) {
1827 for (--i; i >= 0; --i) {
1828 wfree(colors[i]);
1830 wfree(colors);
1831 return NULL;
1833 val = WMGetFromPLString(elem);
1835 if (!XParseColor(dpy, scr->w_colormap, val, &color)) {
1836 wwarning(_("\"%s\" is not a valid color name"), val);
1837 for (--i; i >= 0; --i) {
1838 wfree(colors[i]);
1840 wfree(colors);
1841 return NULL;
1842 } else {
1843 colors[i] = wmalloc(sizeof(RColor));
1844 colors[i]->red = color.red >> 8;
1845 colors[i]->green = color.green >> 8;
1846 colors[i]->blue = color.blue >> 8;
1849 colors[i] = NULL;
1851 texture = (WTexture *) wTextureMakeMGradient(scr, type, colors);
1852 } else if (strcasecmp(val, "spixmap") == 0 ||
1853 strcasecmp(val, "cpixmap") == 0 || strcasecmp(val, "tpixmap") == 0) {
1854 XColor color;
1855 int type;
1857 if (nelem != 3)
1858 return NULL;
1860 if (val[0] == 's' || val[0] == 'S')
1861 type = WTP_SCALE;
1862 else if (val[0] == 'c' || val[0] == 'C')
1863 type = WTP_CENTER;
1864 else
1865 type = WTP_TILE;
1867 /* get color */
1868 elem = WMGetFromPLArray(pl, 2);
1869 if (!elem || !WMIsPLString(elem)) {
1870 return NULL;
1872 val = WMGetFromPLString(elem);
1874 if (!XParseColor(dpy, scr->w_colormap, val, &color)) {
1875 wwarning(_("\"%s\" is not a valid color name"), val);
1876 return NULL;
1879 /* file name */
1880 elem = WMGetFromPLArray(pl, 1);
1881 if (!elem || !WMIsPLString(elem))
1882 return NULL;
1883 val = WMGetFromPLString(elem);
1885 texture = (WTexture *) wTextureMakePixmap(scr, type, val, &color);
1886 } else if (strcasecmp(val, "thgradient") == 0
1887 || strcasecmp(val, "tvgradient") == 0 || strcasecmp(val, "tdgradient") == 0) {
1888 RColor color1, color2;
1889 XColor xcolor;
1890 int opacity;
1891 int style;
1893 if (val[1] == 'h' || val[1] == 'H')
1894 style = WTEX_THGRADIENT;
1895 else if (val[1] == 'v' || val[1] == 'V')
1896 style = WTEX_TVGRADIENT;
1897 else
1898 style = WTEX_TDGRADIENT;
1900 if (nelem != 5) {
1901 wwarning(_("bad number of arguments in textured gradient specification"));
1902 return NULL;
1905 /* get from color */
1906 elem = WMGetFromPLArray(pl, 3);
1907 if (!elem || !WMIsPLString(elem))
1908 return NULL;
1909 val = WMGetFromPLString(elem);
1911 if (!XParseColor(dpy, scr->w_colormap, val, &xcolor)) {
1912 wwarning(_("\"%s\" is not a valid color name"), val);
1913 return NULL;
1915 color1.alpha = 255;
1916 color1.red = xcolor.red >> 8;
1917 color1.green = xcolor.green >> 8;
1918 color1.blue = xcolor.blue >> 8;
1920 /* get to color */
1921 elem = WMGetFromPLArray(pl, 4);
1922 if (!elem || !WMIsPLString(elem)) {
1923 return NULL;
1925 val = WMGetFromPLString(elem);
1927 if (!XParseColor(dpy, scr->w_colormap, val, &xcolor)) {
1928 wwarning(_("\"%s\" is not a valid color name"), val);
1929 return NULL;
1931 color2.alpha = 255;
1932 color2.red = xcolor.red >> 8;
1933 color2.green = xcolor.green >> 8;
1934 color2.blue = xcolor.blue >> 8;
1936 /* get opacity */
1937 elem = WMGetFromPLArray(pl, 2);
1938 if (!elem || !WMIsPLString(elem))
1939 opacity = 128;
1940 else
1941 val = WMGetFromPLString(elem);
1943 if (!val || (opacity = atoi(val)) < 0 || opacity > 255) {
1944 wwarning(_("bad opacity value for tgradient texture \"%s\". Should be [0..255]"), val);
1945 opacity = 128;
1948 /* get file name */
1949 elem = WMGetFromPLArray(pl, 1);
1950 if (!elem || !WMIsPLString(elem))
1951 return NULL;
1952 val = WMGetFromPLString(elem);
1954 texture = (WTexture *) wTextureMakeTGradient(scr, style, &color1, &color2, val, opacity);
1955 } else if (strcasecmp(val, "function") == 0) {
1956 /* Leave this in to handle the unlikely case of
1957 * someone actually having function textures configured */
1958 wwarning("function texture support has been removed");
1959 return NULL;
1960 } else {
1961 wwarning(_("invalid texture type %s"), val);
1962 return NULL;
1964 return texture;
1967 static int getTexture(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1969 static WTexture *texture;
1970 int changed = 0;
1972 again:
1973 if (!WMIsPLArray(value)) {
1974 wwarning(_("Wrong option format for key \"%s\". Should be %s."), entry->key, "Texture");
1975 if (changed == 0) {
1976 value = entry->plvalue;
1977 changed = 1;
1978 wwarning(_("using default \"%s\" instead"), entry->default_value);
1979 goto again;
1981 return False;
1984 if (strcmp(entry->key, "WidgetColor") == 0 && !changed) {
1985 WMPropList *pl;
1987 pl = WMGetFromPLArray(value, 0);
1988 if (!pl || !WMIsPLString(pl) || !WMGetFromPLString(pl)
1989 || strcasecmp(WMGetFromPLString(pl), "solid") != 0) {
1990 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1991 entry->key, "Solid Texture");
1993 value = entry->plvalue;
1994 changed = 1;
1995 wwarning(_("using default \"%s\" instead"), entry->default_value);
1996 goto again;
2000 texture = parse_texture(scr, value);
2002 if (!texture) {
2003 wwarning(_("Error in texture specification for key \"%s\""), entry->key);
2004 if (changed == 0) {
2005 value = entry->plvalue;
2006 changed = 1;
2007 wwarning(_("using default \"%s\" instead"), entry->default_value);
2008 goto again;
2010 return False;
2013 if (ret)
2014 *ret = &texture;
2016 if (addr)
2017 *(WTexture **) addr = texture;
2019 return True;
2022 static int getWSBackground(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
2024 WMPropList *elem;
2025 int changed = 0;
2026 char *val;
2027 int nelem;
2029 /* Parameter not used, but tell the compiler that it is ok */
2030 (void) scr;
2031 (void) addr;
2033 again:
2034 if (!WMIsPLArray(value)) {
2035 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
2036 "WorkspaceBack", "Texture or None");
2037 if (changed == 0) {
2038 value = entry->plvalue;
2039 changed = 1;
2040 wwarning(_("using default \"%s\" instead"), entry->default_value);
2041 goto again;
2043 return False;
2046 /* only do basic error checking and verify for None texture */
2048 nelem = WMGetPropListItemCount(value);
2049 if (nelem > 0) {
2050 elem = WMGetFromPLArray(value, 0);
2051 if (!elem || !WMIsPLString(elem)) {
2052 wwarning(_("Wrong type for workspace background. Should be a texture type."));
2053 if (changed == 0) {
2054 value = entry->plvalue;
2055 changed = 1;
2056 wwarning(_("using default \"%s\" instead"), entry->default_value);
2057 goto again;
2059 return False;
2061 val = WMGetFromPLString(elem);
2063 if (strcasecmp(val, "None") == 0)
2064 return True;
2066 *ret = WMRetainPropList(value);
2068 return True;
2071 static int
2072 getWSSpecificBackground(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
2074 WMPropList *elem;
2075 int nelem;
2076 int changed = 0;
2078 /* Parameter not used, but tell the compiler that it is ok */
2079 (void) scr;
2080 (void) addr;
2082 again:
2083 if (!WMIsPLArray(value)) {
2084 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
2085 "WorkspaceSpecificBack", "an array of textures");
2086 if (changed == 0) {
2087 value = entry->plvalue;
2088 changed = 1;
2089 wwarning(_("using default \"%s\" instead"), entry->default_value);
2090 goto again;
2092 return False;
2095 /* only do basic error checking and verify for None texture */
2097 nelem = WMGetPropListItemCount(value);
2098 if (nelem > 0) {
2099 while (nelem--) {
2100 elem = WMGetFromPLArray(value, nelem);
2101 if (!elem || !WMIsPLArray(elem)) {
2102 wwarning(_("Wrong type for background of workspace %i. Should be a texture."),
2103 nelem);
2108 *ret = WMRetainPropList(value);
2110 #ifdef notworking
2112 * Kluge to force wmsetbg helper to set the default background.
2113 * If the WorkspaceSpecificBack is changed once wmaker has started,
2114 * the WorkspaceBack won't be sent to the helper, unless the user
2115 * changes it's value too. So, we must force this by removing the
2116 * value from the defaults DB.
2118 if (!scr->flags.backimage_helper_launched && !scr->flags.startup) {
2119 WMPropList *key = WMCreatePLString("WorkspaceBack");
2121 WMRemoveFromPLDictionary(w_global.domain.wmaker->dictionary, key);
2123 WMReleasePropList(key);
2125 #endif
2126 return True;
2129 static int getFont(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
2131 static WMFont *font;
2132 const char *val;
2134 (void) addr;
2136 GET_STRING_OR_DEFAULT("Font", val);
2138 font = WMCreateFont(scr->wmscreen, val);
2139 if (!font)
2140 font = WMCreateFont(scr->wmscreen, "fixed");
2142 if (!font) {
2143 wfatal(_("could not load any usable font!!!"));
2144 exit(1);
2147 if (ret)
2148 *ret = font;
2150 /* can't assign font value outside update function */
2151 wassertrv(addr == NULL, True);
2153 return True;
2156 static int getColor(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
2158 static XColor color;
2159 const char *val;
2160 int second_pass = 0;
2162 (void) addr;
2164 GET_STRING_OR_DEFAULT("Color", val);
2166 again:
2167 if (!wGetColor(scr, val, &color)) {
2168 wwarning(_("could not get color for key \"%s\""), entry->key);
2169 if (second_pass == 0) {
2170 val = WMGetFromPLString(entry->plvalue);
2171 second_pass = 1;
2172 wwarning(_("using default \"%s\" instead"), val);
2173 goto again;
2175 return False;
2178 if (ret)
2179 *ret = &color;
2181 assert(addr == NULL);
2183 if (addr)
2184 *(unsigned long*)addr = pixel;
2187 return True;
2190 static int getKeybind(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
2192 static WShortKey shortcut;
2193 KeySym ksym;
2194 const char *val;
2195 char *k;
2196 char buf[MAX_SHORTCUT_LENGTH], *b;
2198 /* Parameter not used, but tell the compiler that it is ok */
2199 (void) scr;
2200 (void) addr;
2202 GET_STRING_OR_DEFAULT("Key spec", val);
2204 if (!val || strcasecmp(val, "NONE") == 0) {
2205 shortcut.keycode = 0;
2206 shortcut.modifier = 0;
2207 if (ret)
2208 *ret = &shortcut;
2209 return True;
2212 wstrlcpy(buf, val, MAX_SHORTCUT_LENGTH);
2214 b = (char *)buf;
2216 /* get modifiers */
2217 shortcut.modifier = 0;
2218 while ((k = strchr(b, '+')) != NULL) {
2219 int mod;
2221 *k = 0;
2222 mod = wXModifierFromKey(b);
2223 if (mod < 0) {
2224 wwarning(_("%s: invalid key modifier \"%s\""), entry->key, b);
2225 return False;
2227 shortcut.modifier |= mod;
2229 b = k + 1;
2232 /* get key */
2233 ksym = XStringToKeysym(b);
2235 if (ksym == NoSymbol) {
2236 wwarning(_("%s:invalid kbd shortcut specification \"%s\""), entry->key, val);
2237 return False;
2240 shortcut.keycode = XKeysymToKeycode(dpy, ksym);
2241 if (shortcut.keycode == 0) {
2242 wwarning(_("%s:invalid key in shortcut \"%s\""), entry->key, val);
2243 return False;
2246 if (ret)
2247 *ret = &shortcut;
2249 return True;
2252 static int getModMask(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
2254 static int mask;
2255 const char *str;
2257 /* Parameter not used, but tell the compiler that it is ok */
2258 (void) scr;
2260 GET_STRING_OR_DEFAULT("Modifier Key", str);
2262 if (!str)
2263 return False;
2265 mask = wXModifierFromKey(str);
2266 if (mask < 0) {
2267 wwarning(_("%s: modifier key %s is not valid"), entry->key, str);
2268 mask = 0;
2269 return False;
2272 if (addr)
2273 *(int *)addr = mask;
2275 if (ret)
2276 *ret = &mask;
2278 return True;
2281 # include <X11/cursorfont.h>
2282 typedef struct {
2283 const char *name;
2284 int id;
2285 } WCursorLookup;
2287 #define CURSOR_ID_NONE (XC_num_glyphs)
2289 static const WCursorLookup cursor_table[] = {
2290 {"X_cursor", XC_X_cursor},
2291 {"arrow", XC_arrow},
2292 {"based_arrow_down", XC_based_arrow_down},
2293 {"based_arrow_up", XC_based_arrow_up},
2294 {"boat", XC_boat},
2295 {"bogosity", XC_bogosity},
2296 {"bottom_left_corner", XC_bottom_left_corner},
2297 {"bottom_right_corner", XC_bottom_right_corner},
2298 {"bottom_side", XC_bottom_side},
2299 {"bottom_tee", XC_bottom_tee},
2300 {"box_spiral", XC_box_spiral},
2301 {"center_ptr", XC_center_ptr},
2302 {"circle", XC_circle},
2303 {"clock", XC_clock},
2304 {"coffee_mug", XC_coffee_mug},
2305 {"cross", XC_cross},
2306 {"cross_reverse", XC_cross_reverse},
2307 {"crosshair", XC_crosshair},
2308 {"diamond_cross", XC_diamond_cross},
2309 {"dot", XC_dot},
2310 {"dotbox", XC_dotbox},
2311 {"double_arrow", XC_double_arrow},
2312 {"draft_large", XC_draft_large},
2313 {"draft_small", XC_draft_small},
2314 {"draped_box", XC_draped_box},
2315 {"exchange", XC_exchange},
2316 {"fleur", XC_fleur},
2317 {"gobbler", XC_gobbler},
2318 {"gumby", XC_gumby},
2319 {"hand1", XC_hand1},
2320 {"hand2", XC_hand2},
2321 {"heart", XC_heart},
2322 {"icon", XC_icon},
2323 {"iron_cross", XC_iron_cross},
2324 {"left_ptr", XC_left_ptr},
2325 {"left_side", XC_left_side},
2326 {"left_tee", XC_left_tee},
2327 {"leftbutton", XC_leftbutton},
2328 {"ll_angle", XC_ll_angle},
2329 {"lr_angle", XC_lr_angle},
2330 {"man", XC_man},
2331 {"middlebutton", XC_middlebutton},
2332 {"mouse", XC_mouse},
2333 {"pencil", XC_pencil},
2334 {"pirate", XC_pirate},
2335 {"plus", XC_plus},
2336 {"question_arrow", XC_question_arrow},
2337 {"right_ptr", XC_right_ptr},
2338 {"right_side", XC_right_side},
2339 {"right_tee", XC_right_tee},
2340 {"rightbutton", XC_rightbutton},
2341 {"rtl_logo", XC_rtl_logo},
2342 {"sailboat", XC_sailboat},
2343 {"sb_down_arrow", XC_sb_down_arrow},
2344 {"sb_h_double_arrow", XC_sb_h_double_arrow},
2345 {"sb_left_arrow", XC_sb_left_arrow},
2346 {"sb_right_arrow", XC_sb_right_arrow},
2347 {"sb_up_arrow", XC_sb_up_arrow},
2348 {"sb_v_double_arrow", XC_sb_v_double_arrow},
2349 {"shuttle", XC_shuttle},
2350 {"sizing", XC_sizing},
2351 {"spider", XC_spider},
2352 {"spraycan", XC_spraycan},
2353 {"star", XC_star},
2354 {"target", XC_target},
2355 {"tcross", XC_tcross},
2356 {"top_left_arrow", XC_top_left_arrow},
2357 {"top_left_corner", XC_top_left_corner},
2358 {"top_right_corner", XC_top_right_corner},
2359 {"top_side", XC_top_side},
2360 {"top_tee", XC_top_tee},
2361 {"trek", XC_trek},
2362 {"ul_angle", XC_ul_angle},
2363 {"umbrella", XC_umbrella},
2364 {"ur_angle", XC_ur_angle},
2365 {"watch", XC_watch},
2366 {"xterm", XC_xterm},
2367 {NULL, CURSOR_ID_NONE}
2370 static void check_bitmap_status(int status, const char *filename, Pixmap bitmap)
2372 switch (status) {
2373 case BitmapOpenFailed:
2374 wwarning(_("failed to open bitmap file \"%s\""), filename);
2375 break;
2376 case BitmapFileInvalid:
2377 wwarning(_("\"%s\" is not a valid bitmap file"), filename);
2378 break;
2379 case BitmapNoMemory:
2380 wwarning(_("out of memory reading bitmap file \"%s\""), filename);
2381 break;
2382 case BitmapSuccess:
2383 XFreePixmap(dpy, bitmap);
2384 break;
2389 * (none)
2390 * (builtin, <cursor_name>)
2391 * (bitmap, <cursor_bitmap>, <cursor_mask>)
2393 static int parse_cursor(WScreen * scr, WMPropList * pl, Cursor * cursor)
2395 WMPropList *elem;
2396 char *val;
2397 int nelem;
2398 int status = 0;
2400 nelem = WMGetPropListItemCount(pl);
2401 if (nelem < 1) {
2402 return (status);
2404 elem = WMGetFromPLArray(pl, 0);
2405 if (!elem || !WMIsPLString(elem)) {
2406 return (status);
2408 val = WMGetFromPLString(elem);
2410 if (strcasecmp(val, "none") == 0) {
2411 status = 1;
2412 *cursor = None;
2413 } else if (strcasecmp(val, "builtin") == 0) {
2414 int i;
2415 int cursor_id = CURSOR_ID_NONE;
2417 if (nelem != 2) {
2418 wwarning(_("bad number of arguments in cursor specification"));
2419 return (status);
2421 elem = WMGetFromPLArray(pl, 1);
2422 if (!elem || !WMIsPLString(elem)) {
2423 return (status);
2425 val = WMGetFromPLString(elem);
2427 for (i = 0; cursor_table[i].name != NULL; i++) {
2428 if (strcasecmp(val, cursor_table[i].name) == 0) {
2429 cursor_id = cursor_table[i].id;
2430 break;
2433 if (CURSOR_ID_NONE == cursor_id) {
2434 wwarning(_("unknown builtin cursor name \"%s\""), val);
2435 } else {
2436 *cursor = XCreateFontCursor(dpy, cursor_id);
2437 status = 1;
2439 } else if (strcasecmp(val, "bitmap") == 0) {
2440 char *bitmap_name;
2441 char *mask_name;
2442 int bitmap_status;
2443 int mask_status;
2444 Pixmap bitmap;
2445 Pixmap mask;
2446 unsigned int w, h;
2447 int x, y;
2448 XColor fg, bg;
2450 if (nelem != 3) {
2451 wwarning(_("bad number of arguments in cursor specification"));
2452 return (status);
2454 elem = WMGetFromPLArray(pl, 1);
2455 if (!elem || !WMIsPLString(elem)) {
2456 return (status);
2458 val = WMGetFromPLString(elem);
2459 bitmap_name = FindImage(wPreferences.pixmap_path, val);
2460 if (!bitmap_name) {
2461 wwarning(_("could not find cursor bitmap file \"%s\""), val);
2462 return (status);
2464 elem = WMGetFromPLArray(pl, 2);
2465 if (!elem || !WMIsPLString(elem)) {
2466 wfree(bitmap_name);
2467 return (status);
2469 val = WMGetFromPLString(elem);
2470 mask_name = FindImage(wPreferences.pixmap_path, val);
2471 if (!mask_name) {
2472 wfree(bitmap_name);
2473 wwarning(_("could not find cursor bitmap file \"%s\""), val);
2474 return (status);
2476 mask_status = XReadBitmapFile(dpy, scr->w_win, mask_name, &w, &h, &mask, &x, &y);
2477 bitmap_status = XReadBitmapFile(dpy, scr->w_win, bitmap_name, &w, &h, &bitmap, &x, &y);
2478 if ((BitmapSuccess == bitmap_status) && (BitmapSuccess == mask_status)) {
2479 fg.pixel = scr->black_pixel;
2480 bg.pixel = scr->white_pixel;
2481 XQueryColor(dpy, scr->w_colormap, &fg);
2482 XQueryColor(dpy, scr->w_colormap, &bg);
2483 *cursor = XCreatePixmapCursor(dpy, bitmap, mask, &fg, &bg, x, y);
2484 status = 1;
2486 check_bitmap_status(bitmap_status, bitmap_name, bitmap);
2487 check_bitmap_status(mask_status, mask_name, mask);
2488 wfree(bitmap_name);
2489 wfree(mask_name);
2491 return (status);
2494 static int getCursor(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
2496 static Cursor cursor;
2497 int status;
2498 int changed = 0;
2500 again:
2501 if (!WMIsPLArray(value)) {
2502 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
2503 entry->key, "cursor specification");
2504 if (!changed) {
2505 value = entry->plvalue;
2506 changed = 1;
2507 wwarning(_("using default \"%s\" instead"), entry->default_value);
2508 goto again;
2510 return (False);
2512 status = parse_cursor(scr, value, &cursor);
2513 if (!status) {
2514 wwarning(_("Error in cursor specification for key \"%s\""), entry->key);
2515 if (!changed) {
2516 value = entry->plvalue;
2517 changed = 1;
2518 wwarning(_("using default \"%s\" instead"), entry->default_value);
2519 goto again;
2521 return (False);
2523 if (ret) {
2524 *ret = &cursor;
2526 if (addr) {
2527 *(Cursor *) addr = cursor;
2529 return (True);
2532 #undef CURSOR_ID_NONE
2534 /* ---------------- value setting functions --------------- */
2535 static int setJustify(WScreen * scr, WDefaultEntry * entry, void *tdata, void *extra_data)
2537 /* Parameter not used, but tell the compiler that it is ok */
2538 (void) scr;
2539 (void) entry;
2540 (void) tdata;
2541 (void) extra_data;
2543 return REFRESH_WINDOW_TITLE_COLOR;
2546 static int setClearance(WScreen * scr, WDefaultEntry * entry, void *bar, void *foo)
2548 /* Parameter not used, but tell the compiler that it is ok */
2549 (void) scr;
2550 (void) entry;
2551 (void) bar;
2552 (void) foo;
2554 return REFRESH_WINDOW_FONT | REFRESH_BUTTON_IMAGES | REFRESH_MENU_TITLE_FONT | REFRESH_MENU_FONT;
2557 static int setIfDockPresent(WScreen * scr, WDefaultEntry * entry, void *tdata, void *extra_data)
2559 char *flag = tdata;
2560 long which = (long) extra_data;
2562 /* Parameter not used, but tell the compiler that it is ok */
2563 (void) scr;
2564 (void) entry;
2566 switch (which) {
2567 case WM_DOCK:
2568 wPreferences.flags.nodock = wPreferences.flags.nodock || *flag;
2569 // Drawers require the dock
2570 wPreferences.flags.nodrawer = wPreferences.flags.nodrawer || wPreferences.flags.nodock;
2571 break;
2572 case WM_CLIP:
2573 wPreferences.flags.noclip = wPreferences.flags.noclip || *flag;
2574 break;
2575 case WM_DRAWER:
2576 wPreferences.flags.nodrawer = wPreferences.flags.nodrawer || *flag;
2577 break;
2578 default:
2579 break;
2581 return 0;
2584 static int setClipMergedInDock(WScreen *scr, WDefaultEntry *entry, void *tdata, void *foo)
2586 char *flag = tdata;
2588 /* Parameter not used, but tell the compiler that it is ok */
2589 (void) scr;
2590 (void) entry;
2591 (void) foo;
2593 wPreferences.flags.clip_merged_in_dock = *flag;
2594 wPreferences.flags.noclip = wPreferences.flags.noclip || *flag;
2595 return 0;
2598 static int setWrapAppiconsInDock(WScreen *scr, WDefaultEntry *entry, void *tdata, void *foo)
2600 char *flag = tdata;
2602 /* Parameter not used, but tell the compiler that it is ok */
2603 (void) scr;
2604 (void) entry;
2605 (void) foo;
2607 wPreferences.flags.wrap_appicons_in_dock = *flag;
2608 return 0;
2611 static int setStickyIcons(WScreen * scr, WDefaultEntry * entry, void *bar, void *foo)
2613 /* Parameter not used, but tell the compiler that it is ok */
2614 (void) entry;
2615 (void) bar;
2616 (void) foo;
2618 if (scr->workspaces) {
2619 wWorkspaceForceChange(scr, scr->current_workspace);
2620 wArrangeIcons(scr, False);
2622 return 0;
2625 static int setIconTile(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2627 Pixmap pixmap;
2628 RImage *img;
2629 WTexture ** texture = tdata;
2630 int reset = 0;
2632 /* Parameter not used, but tell the compiler that it is ok */
2633 (void) foo;
2635 img = wTextureRenderImage(*texture, wPreferences.icon_size,
2636 wPreferences.icon_size, ((*texture)->any.type & WREL_BORDER_MASK)
2637 ? WREL_ICON : WREL_FLAT);
2638 if (!img) {
2639 wwarning(_("could not render texture for icon background"));
2640 if (!entry->addr)
2641 wTextureDestroy(scr, *texture);
2642 return 0;
2644 RConvertImage(scr->rcontext, img, &pixmap);
2646 if (scr->icon_tile) {
2647 reset = 1;
2648 RReleaseImage(scr->icon_tile);
2649 XFreePixmap(dpy, scr->icon_tile_pixmap);
2652 scr->icon_tile = img;
2654 /* put the icon in the noticeboard hint */
2655 PropSetIconTileHint(scr, img);
2657 if (!wPreferences.flags.noclip || wPreferences.flags.clip_merged_in_dock) {
2658 if (scr->clip_tile) {
2659 RReleaseImage(scr->clip_tile);
2661 scr->clip_tile = wClipMakeTile(img);
2664 if (!wPreferences.flags.nodrawer) {
2665 if (scr->drawer_tile) {
2666 RReleaseImage(scr->drawer_tile);
2668 scr->drawer_tile = wDrawerMakeTile(scr, img);
2671 scr->icon_tile_pixmap = pixmap;
2673 if (scr->def_icon_rimage) {
2674 RReleaseImage(scr->def_icon_rimage);
2675 scr->def_icon_rimage = NULL;
2678 if (scr->icon_back_texture)
2679 wTextureDestroy(scr, (WTexture *) scr->icon_back_texture);
2681 scr->icon_back_texture = wTextureMakeSolid(scr, &((*texture)->any.color));
2683 /* Free the texture as nobody else will use it, nor refer to it. */
2684 if (!entry->addr)
2685 wTextureDestroy(scr, *texture);
2687 return (reset ? REFRESH_ICON_TILE : 0);
2690 static int setWinTitleFont(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2692 WMFont *font = tdata;
2694 /* Parameter not used, but tell the compiler that it is ok */
2695 (void) entry;
2696 (void) foo;
2698 if (scr->title_font) {
2699 WMReleaseFont(scr->title_font);
2701 scr->title_font = font;
2703 return REFRESH_WINDOW_FONT | REFRESH_BUTTON_IMAGES;
2706 static int setMenuTitleFont(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2708 WMFont *font = tdata;
2710 /* Parameter not used, but tell the compiler that it is ok */
2711 (void) entry;
2712 (void) foo;
2714 if (scr->menu_title_font) {
2715 WMReleaseFont(scr->menu_title_font);
2718 scr->menu_title_font = font;
2720 return REFRESH_MENU_TITLE_FONT;
2723 static int setMenuTextFont(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2725 WMFont *font = tdata;
2727 /* Parameter not used, but tell the compiler that it is ok */
2728 (void) entry;
2729 (void) foo;
2731 if (scr->menu_entry_font) {
2732 WMReleaseFont(scr->menu_entry_font);
2734 scr->menu_entry_font = font;
2736 return REFRESH_MENU_FONT;
2739 static int setIconTitleFont(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2741 WMFont *font = tdata;
2743 /* Parameter not used, but tell the compiler that it is ok */
2744 (void) entry;
2745 (void) foo;
2747 if (scr->icon_title_font) {
2748 WMReleaseFont(scr->icon_title_font);
2751 scr->icon_title_font = font;
2753 return REFRESH_ICON_FONT;
2756 static int setClipTitleFont(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2758 WMFont *font = tdata;
2760 /* Parameter not used, but tell the compiler that it is ok */
2761 (void) entry;
2762 (void) foo;
2764 if (scr->clip_title_font) {
2765 WMReleaseFont(scr->clip_title_font);
2768 scr->clip_title_font = font;
2770 return REFRESH_ICON_FONT;
2773 static int setLargeDisplayFont(WScreen *scr, WDefaultEntry *entry, void *tdata, void *foo)
2775 WMFont *font = tdata;
2777 /* Parameter not used, but tell the compiler that it is ok */
2778 (void) scr;
2779 (void) entry;
2780 (void) foo;
2782 if (scr->workspace_name_font)
2783 WMReleaseFont(scr->workspace_name_font);
2785 scr->workspace_name_font = font;
2787 return 0;
2790 static int setHightlight(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2792 XColor *color = tdata;
2794 /* Parameter not used, but tell the compiler that it is ok */
2795 (void) entry;
2796 (void) foo;
2798 if (scr->select_color)
2799 WMReleaseColor(scr->select_color);
2801 scr->select_color = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2803 wFreeColor(scr, color->pixel);
2805 return REFRESH_MENU_COLOR;
2808 static int setHightlightText(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2810 XColor *color = tdata;
2812 /* Parameter not used, but tell the compiler that it is ok */
2813 (void) entry;
2814 (void) foo;
2816 if (scr->select_text_color)
2817 WMReleaseColor(scr->select_text_color);
2819 scr->select_text_color = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2821 wFreeColor(scr, color->pixel);
2823 return REFRESH_MENU_COLOR;
2826 static int setClipTitleColor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *extra_data)
2828 XColor *color = tdata;
2829 long widx = (long) extra_data;
2831 /* Parameter not used, but tell the compiler that it is ok */
2832 (void) entry;
2834 if (scr->clip_title_color[widx])
2835 WMReleaseColor(scr->clip_title_color[widx]);
2837 scr->clip_title_color[widx] = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2838 wFreeColor(scr, color->pixel);
2840 return REFRESH_ICON_TITLE_COLOR;
2843 static int setWTitleColor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *extra_data)
2845 XColor *color = tdata;
2846 long widx = (long) extra_data;
2848 /* Parameter not used, but tell the compiler that it is ok */
2849 (void) entry;
2851 if (scr->window_title_color[widx])
2852 WMReleaseColor(scr->window_title_color[widx]);
2854 scr->window_title_color[widx] =
2855 WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2857 wFreeColor(scr, color->pixel);
2859 return REFRESH_WINDOW_TITLE_COLOR;
2862 static int setMenuTitleColor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *extra_data)
2864 XColor *color = tdata;
2866 /* Parameter not used, but tell the compiler that it is ok */
2867 (void) entry;
2868 (void) extra_data;
2870 if (scr->menu_title_color[0])
2871 WMReleaseColor(scr->menu_title_color[0]);
2873 scr->menu_title_color[0] = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2875 wFreeColor(scr, color->pixel);
2877 return REFRESH_MENU_TITLE_COLOR;
2880 static int setMenuTextColor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2882 XColor *color = tdata;
2884 /* Parameter not used, but tell the compiler that it is ok */
2885 (void) entry;
2886 (void) foo;
2888 if (scr->mtext_color)
2889 WMReleaseColor(scr->mtext_color);
2891 scr->mtext_color = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2893 if (WMColorPixel(scr->dtext_color) == WMColorPixel(scr->mtext_color)) {
2894 WMSetColorAlpha(scr->dtext_color, 0x7fff);
2895 } else {
2896 WMSetColorAlpha(scr->dtext_color, 0xffff);
2899 wFreeColor(scr, color->pixel);
2901 return REFRESH_MENU_COLOR;
2904 static int setMenuDisabledColor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2906 XColor *color = tdata;
2908 /* Parameter not used, but tell the compiler that it is ok */
2909 (void) entry;
2910 (void) foo;
2912 if (scr->dtext_color)
2913 WMReleaseColor(scr->dtext_color);
2915 scr->dtext_color = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2917 if (WMColorPixel(scr->dtext_color) == WMColorPixel(scr->mtext_color)) {
2918 WMSetColorAlpha(scr->dtext_color, 0x7fff);
2919 } else {
2920 WMSetColorAlpha(scr->dtext_color, 0xffff);
2923 wFreeColor(scr, color->pixel);
2925 return REFRESH_MENU_COLOR;
2928 static int setIconTitleColor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2930 XColor *color = tdata;
2932 /* Parameter not used, but tell the compiler that it is ok */
2933 (void) entry;
2934 (void) foo;
2936 if (scr->icon_title_color)
2937 WMReleaseColor(scr->icon_title_color);
2938 scr->icon_title_color = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2940 wFreeColor(scr, color->pixel);
2942 return REFRESH_ICON_TITLE_COLOR;
2945 static int setIconTitleBack(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2947 XColor *color = tdata;
2949 /* Parameter not used, but tell the compiler that it is ok */
2950 (void) entry;
2951 (void) foo;
2953 if (scr->icon_title_texture) {
2954 wTextureDestroy(scr, (WTexture *) scr->icon_title_texture);
2956 scr->icon_title_texture = wTextureMakeSolid(scr, color);
2958 return REFRESH_ICON_TITLE_BACK;
2961 static int setFrameBorderWidth(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2963 int *value = tdata;
2965 /* Parameter not used, but tell the compiler that it is ok */
2966 (void) entry;
2967 (void) foo;
2969 scr->frame_border_width = *value;
2971 return REFRESH_FRAME_BORDER;
2974 static int setFrameBorderColor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2976 XColor *color = tdata;
2978 /* Parameter not used, but tell the compiler that it is ok */
2979 (void) entry;
2980 (void) foo;
2982 if (scr->frame_border_color)
2983 WMReleaseColor(scr->frame_border_color);
2984 scr->frame_border_color = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2986 wFreeColor(scr, color->pixel);
2988 return REFRESH_FRAME_BORDER;
2991 static int setFrameFocusedBorderColor(WScreen *scr, WDefaultEntry *entry, void *tdata, void *foo)
2993 XColor *color = tdata;
2995 /* Parameter not used, but tell the compiler that it is ok */
2996 (void) entry;
2997 (void) foo;
2999 if (scr->frame_focused_border_color)
3000 WMReleaseColor(scr->frame_focused_border_color);
3001 scr->frame_focused_border_color = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
3003 wFreeColor(scr, color->pixel);
3005 return REFRESH_FRAME_BORDER;
3008 static int setFrameSelectedBorderColor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
3010 XColor *color = tdata;
3012 /* Parameter not used, but tell the compiler that it is ok */
3013 (void) entry;
3014 (void) foo;
3016 if (scr->frame_selected_border_color)
3017 WMReleaseColor(scr->frame_selected_border_color);
3018 scr->frame_selected_border_color = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
3020 wFreeColor(scr, color->pixel);
3022 return REFRESH_FRAME_BORDER;
3025 static int setWorkspaceSpecificBack(WScreen * scr, WDefaultEntry * entry, void *tdata, void *bar)
3027 WMPropList *value = tdata;
3028 WMPropList *val;
3029 char *str;
3030 int i;
3032 /* Parameter not used, but tell the compiler that it is ok */
3033 (void) entry;
3034 (void) bar;
3036 if (scr->flags.backimage_helper_launched) {
3037 if (WMGetPropListItemCount(value) == 0) {
3038 SendHelperMessage(scr, 'C', 0, NULL);
3039 SendHelperMessage(scr, 'K', 0, NULL);
3041 WMReleasePropList(value);
3042 return 0;
3044 } else {
3045 if (WMGetPropListItemCount(value) == 0)
3046 return 0;
3048 if (!start_bg_helper(scr)) {
3049 WMReleasePropList(value);
3050 return 0;
3053 SendHelperMessage(scr, 'P', -1, wPreferences.pixmap_path);
3056 for (i = 0; i < WMGetPropListItemCount(value); i++) {
3057 val = WMGetFromPLArray(value, i);
3058 if (val && WMIsPLArray(val) && WMGetPropListItemCount(val) > 0) {
3059 str = WMGetPropListDescription(val, False);
3061 SendHelperMessage(scr, 'S', i + 1, str);
3063 wfree(str);
3064 } else {
3065 SendHelperMessage(scr, 'U', i + 1, NULL);
3068 sleep(1);
3070 WMReleasePropList(value);
3071 return 0;
3074 static int setWorkspaceBack(WScreen * scr, WDefaultEntry * entry, void *tdata, void *bar)
3076 WMPropList *value = tdata;
3078 /* Parameter not used, but tell the compiler that it is ok */
3079 (void) entry;
3080 (void) bar;
3082 if (scr->flags.backimage_helper_launched) {
3083 char *str;
3085 if (WMGetPropListItemCount(value) == 0) {
3086 SendHelperMessage(scr, 'U', 0, NULL);
3087 } else {
3088 /* set the default workspace background to this one */
3089 str = WMGetPropListDescription(value, False);
3090 if (str) {
3091 SendHelperMessage(scr, 'S', 0, str);
3092 wfree(str);
3093 SendHelperMessage(scr, 'C', scr->current_workspace + 1, NULL);
3094 } else {
3095 SendHelperMessage(scr, 'U', 0, NULL);
3098 } else if (WMGetPropListItemCount(value) > 0) {
3099 char *text;
3100 char *dither;
3101 int len;
3103 text = WMGetPropListDescription(value, False);
3104 len = strlen(text) + 40;
3105 dither = wPreferences.no_dithering ? "-m" : "-d";
3106 if (!strchr(text, '\'') && !strchr(text, '\\')) {
3107 char command[len];
3109 if (wPreferences.smooth_workspace_back)
3110 snprintf(command, len, "wmsetbg %s -S -p '%s' &", dither, text);
3111 else
3112 snprintf(command, len, "wmsetbg %s -p '%s' &", dither, text);
3113 ExecuteShellCommand(scr, command);
3114 } else
3115 wwarning(_("Invalid arguments for background \"%s\""), text);
3116 wfree(text);
3118 WMReleasePropList(value);
3120 return 0;
3123 static int setWidgetColor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
3125 WTexture **texture = tdata;
3127 /* Parameter not used, but tell the compiler that it is ok */
3128 (void) entry;
3129 (void) foo;
3131 if (scr->widget_texture) {
3132 wTextureDestroy(scr, (WTexture *) scr->widget_texture);
3134 scr->widget_texture = *(WTexSolid **) texture;
3136 return 0;
3139 static int setFTitleBack(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
3141 WTexture **texture = tdata;
3143 /* Parameter not used, but tell the compiler that it is ok */
3144 (void) entry;
3145 (void) foo;
3147 if (scr->window_title_texture[WS_FOCUSED]) {
3148 wTextureDestroy(scr, scr->window_title_texture[WS_FOCUSED]);
3150 scr->window_title_texture[WS_FOCUSED] = *texture;
3152 return REFRESH_WINDOW_TEXTURES;
3155 static int setPTitleBack(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
3157 WTexture **texture = tdata;
3159 /* Parameter not used, but tell the compiler that it is ok */
3160 (void) entry;
3161 (void) foo;
3163 if (scr->window_title_texture[WS_PFOCUSED]) {
3164 wTextureDestroy(scr, scr->window_title_texture[WS_PFOCUSED]);
3166 scr->window_title_texture[WS_PFOCUSED] = *texture;
3168 return REFRESH_WINDOW_TEXTURES;
3171 static int setUTitleBack(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
3173 WTexture **texture = tdata;
3175 /* Parameter not used, but tell the compiler that it is ok */
3176 (void) entry;
3177 (void) foo;
3179 if (scr->window_title_texture[WS_UNFOCUSED]) {
3180 wTextureDestroy(scr, scr->window_title_texture[WS_UNFOCUSED]);
3182 scr->window_title_texture[WS_UNFOCUSED] = *texture;
3184 return REFRESH_WINDOW_TEXTURES;
3187 static int setResizebarBack(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
3189 WTexture **texture = tdata;
3191 /* Parameter not used, but tell the compiler that it is ok */
3192 (void) entry;
3193 (void) foo;
3195 if (scr->resizebar_texture[0]) {
3196 wTextureDestroy(scr, scr->resizebar_texture[0]);
3198 scr->resizebar_texture[0] = *texture;
3200 return REFRESH_WINDOW_TEXTURES;
3203 static int setMenuTitleBack(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
3205 WTexture **texture = tdata;
3207 /* Parameter not used, but tell the compiler that it is ok */
3208 (void) entry;
3209 (void) foo;
3211 if (scr->menu_title_texture[0]) {
3212 wTextureDestroy(scr, scr->menu_title_texture[0]);
3214 scr->menu_title_texture[0] = *texture;
3216 return REFRESH_MENU_TITLE_TEXTURE;
3219 static int setMenuTextBack(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
3221 WTexture **texture = tdata;
3223 /* Parameter not used, but tell the compiler that it is ok */
3224 (void) entry;
3225 (void) foo;
3227 if (scr->menu_item_texture) {
3228 wTextureDestroy(scr, scr->menu_item_texture);
3229 wTextureDestroy(scr, (WTexture *) scr->menu_item_auxtexture);
3231 scr->menu_item_texture = *texture;
3233 scr->menu_item_auxtexture = wTextureMakeSolid(scr, &scr->menu_item_texture->any.color);
3235 return REFRESH_MENU_TEXTURE;
3238 static int setKeyGrab(WScreen * scr, WDefaultEntry * entry, void *tdata, void *extra_data)
3240 WShortKey *shortcut = tdata;
3241 WWindow *wwin;
3242 long widx = (long) extra_data;
3244 /* Parameter not used, but tell the compiler that it is ok */
3245 (void) entry;
3247 wKeyBindings[widx] = *shortcut;
3249 wwin = scr->focused_window;
3251 while (wwin != NULL) {
3252 XUngrabKey(dpy, AnyKey, AnyModifier, wwin->frame->core->window);
3254 if (!WFLAGP(wwin, no_bind_keys)) {
3255 wWindowSetKeyGrabs(wwin);
3257 wwin = wwin->prev;
3260 /* do we need to update window menus? */
3261 if (widx >= WKBD_WORKSPACE1 && widx <= WKBD_WORKSPACE10)
3262 return REFRESH_WORKSPACE_MENU;
3263 if (widx == WKBD_LASTWORKSPACE)
3264 return REFRESH_WORKSPACE_MENU;
3265 if (widx >= WKBD_MOVE_WORKSPACE1 && widx <= WKBD_MOVE_WORKSPACE10)
3266 return REFRESH_WORKSPACE_MENU;
3268 return 0;
3271 static int setIconPosition(WScreen * scr, WDefaultEntry * entry, void *bar, void *foo)
3273 /* Parameter not used, but tell the compiler that it is ok */
3274 (void) entry;
3275 (void) bar;
3276 (void) foo;
3278 wScreenUpdateUsableArea(scr);
3279 wArrangeIcons(scr, True);
3281 return 0;
3284 static int updateUsableArea(WScreen * scr, WDefaultEntry * entry, void *bar, void *foo)
3286 /* Parameter not used, but tell the compiler that it is ok */
3287 (void) entry;
3288 (void) bar;
3289 (void) foo;
3291 wScreenUpdateUsableArea(scr);
3293 return 0;
3296 static int setWorkspaceMapBackground(WScreen *scr, WDefaultEntry *entry, void *tdata, void *foo)
3298 WTexture **texture = tdata;
3300 /* Parameter not used, but tell the compiler that it is ok */
3301 (void) entry;
3302 (void) foo;
3304 if (wPreferences.wsmbackTexture)
3305 wTextureDestroy(scr, wPreferences.wsmbackTexture);
3307 wPreferences.wsmbackTexture = *texture;
3309 return REFRESH_WINDOW_TEXTURES;
3312 static int setMenuStyle(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
3314 /* Parameter not used, but tell the compiler that it is ok */
3315 (void) scr;
3316 (void) entry;
3317 (void) tdata;
3318 (void) foo;
3320 return REFRESH_MENU_TEXTURE;
3323 static RImage *chopOffImage(RImage * image, int x, int y, int w, int h)
3325 RImage *img = RCreateImage(w, h, image->format == RRGBAFormat);
3327 RCopyArea(img, image, x, y, w, h, 0, 0);
3329 return img;
3332 static int setSwPOptions(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
3334 WMPropList *array = tdata;
3335 char *path;
3336 RImage *bgimage;
3337 int cwidth, cheight;
3338 struct WPreferences *prefs = foo;
3340 if (!WMIsPLArray(array) || WMGetPropListItemCount(array) == 0) {
3341 if (prefs->swtileImage)
3342 RReleaseImage(prefs->swtileImage);
3343 prefs->swtileImage = NULL;
3345 WMReleasePropList(array);
3346 return 0;
3349 switch (WMGetPropListItemCount(array)) {
3350 case 4:
3351 if (!WMIsPLString(WMGetFromPLArray(array, 1))) {
3352 wwarning(_("Invalid arguments for option \"%s\""), entry->key);
3353 break;
3354 } else
3355 path = FindImage(wPreferences.pixmap_path, WMGetFromPLString(WMGetFromPLArray(array, 1)));
3357 if (!path) {
3358 wwarning(_("Could not find image \"%s\" for option \"%s\""),
3359 WMGetFromPLString(WMGetFromPLArray(array, 1)), entry->key);
3360 } else {
3361 bgimage = RLoadImage(scr->rcontext, path, 0);
3362 if (!bgimage) {
3363 wwarning(_("Could not load image \"%s\" for option \"%s\""), path, entry->key);
3364 wfree(path);
3365 } else {
3366 wfree(path);
3368 cwidth = atoi(WMGetFromPLString(WMGetFromPLArray(array, 2)));
3369 cheight = atoi(WMGetFromPLString(WMGetFromPLArray(array, 3)));
3371 if (cwidth <= 0 || cheight <= 0 ||
3372 cwidth >= bgimage->width - 2 || cheight >= bgimage->height - 2)
3373 wwarning(_("Invalid split sizes for switch panel back image."));
3374 else {
3375 int i;
3376 int swidth, theight;
3377 for (i = 0; i < 9; i++) {
3378 if (prefs->swbackImage[i])
3379 RReleaseImage(prefs->swbackImage[i]);
3380 prefs->swbackImage[i] = NULL;
3382 swidth = (bgimage->width - cwidth) / 2;
3383 theight = (bgimage->height - cheight) / 2;
3385 prefs->swbackImage[0] = chopOffImage(bgimage, 0, 0, swidth, theight);
3386 prefs->swbackImage[1] = chopOffImage(bgimage, swidth, 0, cwidth, theight);
3387 prefs->swbackImage[2] = chopOffImage(bgimage, swidth + cwidth, 0,
3388 swidth, theight);
3390 prefs->swbackImage[3] = chopOffImage(bgimage, 0, theight, swidth, cheight);
3391 prefs->swbackImage[4] = chopOffImage(bgimage, swidth, theight,
3392 cwidth, cheight);
3393 prefs->swbackImage[5] = chopOffImage(bgimage, swidth + cwidth, theight,
3394 swidth, cheight);
3396 prefs->swbackImage[6] = chopOffImage(bgimage, 0, theight + cheight,
3397 swidth, theight);
3398 prefs->swbackImage[7] = chopOffImage(bgimage, swidth, theight + cheight,
3399 cwidth, theight);
3400 prefs->swbackImage[8] =
3401 chopOffImage(bgimage, swidth + cwidth, theight + cheight, swidth,
3402 theight);
3404 // check if anything failed
3405 for (i = 0; i < 9; i++) {
3406 if (!prefs->swbackImage[i]) {
3407 for (; i >= 0; --i) {
3408 RReleaseImage(prefs->swbackImage[i]);
3409 prefs->swbackImage[i] = NULL;
3411 break;
3415 RReleaseImage(bgimage);
3419 case 1:
3420 if (!WMIsPLString(WMGetFromPLArray(array, 0))) {
3421 wwarning(_("Invalid arguments for option \"%s\""), entry->key);
3422 break;
3423 } else
3424 path = FindImage(wPreferences.pixmap_path, WMGetFromPLString(WMGetFromPLArray(array, 0)));
3426 if (!path) {
3427 wwarning(_("Could not find image \"%s\" for option \"%s\""),
3428 WMGetFromPLString(WMGetFromPLArray(array, 0)), entry->key);
3429 } else {
3430 if (prefs->swtileImage)
3431 RReleaseImage(prefs->swtileImage);
3433 prefs->swtileImage = RLoadImage(scr->rcontext, path, 0);
3434 if (!prefs->swtileImage) {
3435 wwarning(_("Could not load image \"%s\" for option \"%s\""), path, entry->key);
3437 wfree(path);
3439 break;
3441 default:
3442 wwarning(_("Invalid number of arguments for option \"%s\""), entry->key);
3443 break;
3446 WMReleasePropList(array);
3448 return 0;
3451 static int setModifierKeyLabels(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
3453 WMPropList *array = tdata;
3454 int i;
3455 struct WPreferences *prefs = foo;
3457 if (!WMIsPLArray(array) || WMGetPropListItemCount(array) != 7) {
3458 wwarning(_("Value for option \"%s\" must be an array of 7 strings"), entry->key);
3459 WMReleasePropList(array);
3460 return 0;
3463 DestroyWindowMenu(scr);
3465 for (i = 0; i < 7; i++) {
3466 if (prefs->modifier_labels[i])
3467 wfree(prefs->modifier_labels[i]);
3469 if (WMIsPLString(WMGetFromPLArray(array, i))) {
3470 prefs->modifier_labels[i] = wstrdup(WMGetFromPLString(WMGetFromPLArray(array, i)));
3471 } else {
3472 wwarning(_("Invalid argument for option \"%s\" item %d"), entry->key, i);
3473 prefs->modifier_labels[i] = NULL;
3477 WMReleasePropList(array);
3479 return 0;
3482 static int setDoubleClick(WScreen *scr, WDefaultEntry *entry, void *tdata, void *foo)
3484 int *value = tdata;
3486 /* Parameter not used, but tell the compiler that it is ok */
3487 (void) entry;
3488 (void) scr;
3490 if (*value <= 0)
3491 *(int *)foo = 1;
3493 W_setconf_doubleClickDelay(*value);
3495 return 0;
3498 static int setCursor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *extra_data)
3500 Cursor *cursor = tdata;
3501 long widx = (long) extra_data;
3503 /* Parameter not used, but tell the compiler that it is ok */
3504 (void) entry;
3506 if (wPreferences.cursor[widx] != None) {
3507 XFreeCursor(dpy, wPreferences.cursor[widx]);
3510 wPreferences.cursor[widx] = *cursor;
3512 if (widx == WCUR_ROOT && *cursor != None) {
3513 XDefineCursor(dpy, scr->root_win, *cursor);
3516 return 0;