wrlib: Fix typo in macro containing ImageMagick version
[wmaker-crm.git] / src / defaults.c
blob3caa5047375079f0684d729cf56b0fdbae4b56dd
1 /* defaults.c - manage configuration through defaults db
3 * Window Maker window manager
5 * Copyright (c) 1997-2003 Alfredo K. Kojima
6 * Copyright (c) 1998-2003 Dan Pascu
7 * Copyright (c) 2014 Window Maker Team
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License along
21 * with this program; if not, write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 #include "wconfig.h"
27 #include <stdio.h>
28 #include <stdint.h>
29 #include <stdlib.h>
30 #include <unistd.h>
31 #include <string.h>
32 #include <strings.h>
33 #include <ctype.h>
34 #include <time.h>
35 #include <sys/types.h>
36 #include <sys/stat.h>
37 #include <limits.h>
38 #include <signal.h>
40 #ifndef PATH_MAX
41 #define PATH_MAX DEFAULT_PATH_MAX
42 #endif
44 #include <X11/Xlib.h>
45 #include <X11/Xutil.h>
46 #include <X11/keysym.h>
48 #include <wraster.h>
50 #include "WindowMaker.h"
51 #include "framewin.h"
52 #include "window.h"
53 #include "texture.h"
54 #include "screen.h"
55 #include "resources.h"
56 #include "defaults.h"
57 #include "keybind.h"
58 #include "xmodifier.h"
59 #include "icon.h"
60 #include "main.h"
61 #include "actions.h"
62 #include "dock.h"
63 #include "workspace.h"
64 #include "properties.h"
65 #include "misc.h"
66 #include "winmenu.h"
68 #define MAX_SHORTCUT_LENGTH 32
70 typedef struct _WDefaultEntry WDefaultEntry;
71 typedef int (WDECallbackConvert) (WScreen *scr, WDefaultEntry *entry, WMPropList *plvalue, void *addr, void **tdata);
72 typedef int (WDECallbackUpdate) (WScreen *scr, WDefaultEntry *entry, void *tdata, void *extra_data);
74 struct _WDefaultEntry {
75 const char *key;
76 const char *default_value;
77 void *extra_data;
78 void *addr;
79 WDECallbackConvert *convert;
80 WDECallbackUpdate *update;
81 WMPropList *plkey;
82 WMPropList *plvalue; /* default value */
85 /* used to map strings to integers */
86 typedef struct {
87 const char *string;
88 short value;
89 char is_alias;
90 } WOptionEnumeration;
92 /* type converters */
93 static WDECallbackConvert getBool;
94 static WDECallbackConvert getInt;
95 static WDECallbackConvert getCoord;
96 static WDECallbackConvert getPathList;
97 static WDECallbackConvert getEnum;
98 static WDECallbackConvert getTexture;
99 static WDECallbackConvert getWSBackground;
100 static WDECallbackConvert getWSSpecificBackground;
101 static WDECallbackConvert getFont;
102 static WDECallbackConvert getColor;
103 static WDECallbackConvert getKeybind;
104 static WDECallbackConvert getModMask;
105 static WDECallbackConvert getPropList;
107 /* value setting functions */
108 static WDECallbackUpdate setJustify;
109 static WDECallbackUpdate setClearance;
110 static WDECallbackUpdate setIfDockPresent;
111 static WDECallbackUpdate setClipMergedInDock;
112 static WDECallbackUpdate setWrapAppiconsInDock;
113 static WDECallbackUpdate setStickyIcons;
114 static WDECallbackUpdate setWidgetColor;
115 static WDECallbackUpdate setIconTile;
116 static WDECallbackUpdate setWinTitleFont;
117 static WDECallbackUpdate setMenuTitleFont;
118 static WDECallbackUpdate setMenuTextFont;
119 static WDECallbackUpdate setIconTitleFont;
120 static WDECallbackUpdate setIconTitleColor;
121 static WDECallbackUpdate setIconTitleBack;
122 static WDECallbackUpdate setFrameBorderWidth;
123 static WDECallbackUpdate setFrameBorderColor;
124 static WDECallbackUpdate setFrameFocusedBorderColor;
125 static WDECallbackUpdate setFrameSelectedBorderColor;
126 static WDECallbackUpdate setLargeDisplayFont;
127 static WDECallbackUpdate setWTitleColor;
128 static WDECallbackUpdate setFTitleBack;
129 static WDECallbackUpdate setPTitleBack;
130 static WDECallbackUpdate setUTitleBack;
131 static WDECallbackUpdate setResizebarBack;
132 static WDECallbackUpdate setWorkspaceBack;
133 static WDECallbackUpdate setWorkspaceSpecificBack;
134 static WDECallbackUpdate setMenuTitleColor;
135 static WDECallbackUpdate setMenuTextColor;
136 static WDECallbackUpdate setMenuDisabledColor;
137 static WDECallbackUpdate setMenuTitleBack;
138 static WDECallbackUpdate setMenuTextBack;
139 static WDECallbackUpdate setHightlight;
140 static WDECallbackUpdate setHightlightText;
141 static WDECallbackUpdate setKeyGrab;
142 static WDECallbackUpdate setDoubleClick;
143 static WDECallbackUpdate setIconPosition;
144 static WDECallbackUpdate setWorkspaceMapBackground;
146 static WDECallbackUpdate setClipTitleFont;
147 static WDECallbackUpdate setClipTitleColor;
149 static WDECallbackUpdate setMenuStyle;
150 static WDECallbackUpdate setSwPOptions;
151 static WDECallbackUpdate updateUsableArea;
153 static WDECallbackUpdate setModifierKeyLabels;
155 static WDECallbackConvert getCursor;
156 static WDECallbackUpdate setCursor;
159 * Tables to convert strings to enumeration values.
160 * Values stored are char
163 /* WARNING: sum of length of all value strings must not exceed
164 * this value */
165 #define TOTAL_VALUES_LENGTH 80
167 #define REFRESH_WINDOW_TEXTURES (1<<0)
168 #define REFRESH_MENU_TEXTURE (1<<1)
169 #define REFRESH_MENU_FONT (1<<2)
170 #define REFRESH_MENU_COLOR (1<<3)
171 #define REFRESH_MENU_TITLE_TEXTURE (1<<4)
172 #define REFRESH_MENU_TITLE_FONT (1<<5)
173 #define REFRESH_MENU_TITLE_COLOR (1<<6)
174 #define REFRESH_WINDOW_TITLE_COLOR (1<<7)
175 #define REFRESH_WINDOW_FONT (1<<8)
176 #define REFRESH_ICON_TILE (1<<9)
177 #define REFRESH_ICON_FONT (1<<10)
179 #define REFRESH_BUTTON_IMAGES (1<<11)
181 #define REFRESH_ICON_TITLE_COLOR (1<<12)
182 #define REFRESH_ICON_TITLE_BACK (1<<13)
184 #define REFRESH_WORKSPACE_MENU (1<<14)
186 #define REFRESH_FRAME_BORDER REFRESH_MENU_FONT|REFRESH_WINDOW_FONT
188 static WOptionEnumeration seFocusModes[] = {
189 {"Manual", WKF_CLICK, 0}, {"ClickToFocus", WKF_CLICK, 1},
190 {"Sloppy", WKF_SLOPPY, 0}, {"SemiAuto", WKF_SLOPPY, 1}, {"Auto", WKF_SLOPPY, 1},
191 {NULL, 0, 0}
194 static WOptionEnumeration seTitlebarModes[] = {
195 {"new", TS_NEW, 0}, {"old", TS_OLD, 0},
196 {"next", TS_NEXT, 0}, {NULL, 0, 0}
199 static WOptionEnumeration seColormapModes[] = {
200 {"Manual", WCM_CLICK, 0}, {"ClickToFocus", WCM_CLICK, 1},
201 {"Auto", WCM_POINTER, 0}, {"FocusFollowMouse", WCM_POINTER, 1},
202 {NULL, 0, 0}
205 static WOptionEnumeration sePlacements[] = {
206 {"Auto", WPM_AUTO, 0},
207 {"Smart", WPM_SMART, 0},
208 {"Cascade", WPM_CASCADE, 0},
209 {"Random", WPM_RANDOM, 0},
210 {"Manual", WPM_MANUAL, 0},
211 {"Center", WPM_CENTER, 0},
212 {NULL, 0, 0}
215 static WOptionEnumeration seGeomDisplays[] = {
216 {"None", WDIS_NONE, 0},
217 {"Center", WDIS_CENTER, 0},
218 {"Corner", WDIS_TOPLEFT, 0},
219 {"Floating", WDIS_FRAME_CENTER, 0},
220 {"Line", WDIS_NEW, 0},
221 {NULL, 0, 0}
224 static WOptionEnumeration seSpeeds[] = {
225 {"UltraFast", SPEED_ULTRAFAST, 0},
226 {"Fast", SPEED_FAST, 0},
227 {"Medium", SPEED_MEDIUM, 0},
228 {"Slow", SPEED_SLOW, 0},
229 {"UltraSlow", SPEED_ULTRASLOW, 0},
230 {NULL, 0, 0}
233 static WOptionEnumeration seMouseButtonActions[] = {
234 {"None", WA_NONE, 0},
235 {"SelectWindows", WA_SELECT_WINDOWS, 0},
236 {"OpenApplicationsMenu", WA_OPEN_APPMENU, 0},
237 {"OpenWindowListMenu", WA_OPEN_WINLISTMENU, 0},
238 {"MoveToPrevWorkspace", WA_MOVE_PREVWORKSPACE, 0},
239 {"MoveToNextWorkspace", WA_MOVE_NEXTWORKSPACE, 0},
240 {"MoveToPrevWindow", WA_MOVE_PREVWINDOW, 0},
241 {"MoveToNextWindow", WA_MOVE_NEXTWINDOW, 0},
242 {NULL, 0, 0}
245 static WOptionEnumeration seMouseWheelActions[] = {
246 {"None", WA_NONE, 0},
247 {"SwitchWorkspaces", WA_SWITCH_WORKSPACES, 0},
248 {"SwitchWindows", WA_SWITCH_WINDOWS, 0},
249 {NULL, 0, 0}
252 static WOptionEnumeration seIconificationStyles[] = {
253 {"Zoom", WIS_ZOOM, 0},
254 {"Twist", WIS_TWIST, 0},
255 {"Flip", WIS_FLIP, 0},
256 {"None", WIS_NONE, 0},
257 {"random", WIS_RANDOM, 0},
258 {NULL, 0, 0}
261 static WOptionEnumeration seJustifications[] = {
262 {"Left", WTJ_LEFT, 0},
263 {"Center", WTJ_CENTER, 0},
264 {"Right", WTJ_RIGHT, 0},
265 {NULL, 0, 0}
268 static WOptionEnumeration seIconPositions[] = {
269 {"blv", IY_BOTTOM | IY_LEFT | IY_VERT, 0},
270 {"blh", IY_BOTTOM | IY_LEFT | IY_HORIZ, 0},
271 {"brv", IY_BOTTOM | IY_RIGHT | IY_VERT, 0},
272 {"brh", IY_BOTTOM | IY_RIGHT | IY_HORIZ, 0},
273 {"tlv", IY_TOP | IY_LEFT | IY_VERT, 0},
274 {"tlh", IY_TOP | IY_LEFT | IY_HORIZ, 0},
275 {"trv", IY_TOP | IY_RIGHT | IY_VERT, 0},
276 {"trh", IY_TOP | IY_RIGHT | IY_HORIZ, 0},
277 {NULL, 0, 0}
280 static WOptionEnumeration seMenuStyles[] = {
281 {"normal", MS_NORMAL, 0},
282 {"singletexture", MS_SINGLE_TEXTURE, 0},
283 {"flat", MS_FLAT, 0},
284 {NULL, 0, 0}
287 static WOptionEnumeration seDisplayPositions[] = {
288 {"none", WD_NONE, 0},
289 {"center", WD_CENTER, 0},
290 {"top", WD_TOP, 0},
291 {"bottom", WD_BOTTOM, 0},
292 {"topleft", WD_TOPLEFT, 0},
293 {"topright", WD_TOPRIGHT, 0},
294 {"bottomleft", WD_BOTTOMLEFT, 0},
295 {"bottomright", WD_BOTTOMRIGHT, 0},
296 {NULL, 0, 0}
299 static WOptionEnumeration seWorkspaceBorder[] = {
300 {"None", WB_NONE, 0},
301 {"LeftRight", WB_LEFTRIGHT, 0},
302 {"TopBottom", WB_TOPBOTTOM, 0},
303 {"AllDirections", WB_ALLDIRS, 0},
304 {NULL, 0, 0}
307 static WOptionEnumeration seDragMaximizedWindow[] = {
308 {"Move", DRAGMAX_MOVE, 0},
309 {"RestoreGeometry", DRAGMAX_RESTORE, 0},
310 {"Unmaximize", DRAGMAX_UNMAXIMIZE, 0},
311 {"NoMove", DRAGMAX_NOMOVE, 0},
312 {NULL, 0, 0}
316 * ALL entries in the tables below NEED to have a default value
317 * defined, and this value needs to be correct.
319 * Also add the default key/value pair to WindowMaker/Defaults/WindowMaker.in
322 /* these options will only affect the window manager on startup
324 * static defaults can't access the screen data, because it is
325 * created after these defaults are read
327 WDefaultEntry staticOptionList[] = {
329 {"ColormapSize", "4", NULL,
330 &wPreferences.cmap_size, getInt, NULL, NULL, NULL},
331 {"DisableDithering", "NO", NULL,
332 &wPreferences.no_dithering, getBool, NULL, NULL, NULL},
333 {"IconSize", "64", NULL,
334 &wPreferences.icon_size, getInt, NULL, NULL, NULL},
335 {"ModifierKey", "Mod1", NULL,
336 &wPreferences.modifier_mask, getModMask, NULL, NULL, NULL},
337 {"FocusMode", "manual", seFocusModes, /* have a problem when switching from */
338 &wPreferences.focus_mode, getEnum, NULL, NULL, NULL}, /* manual to sloppy without restart */
339 {"NewStyle", "new", seTitlebarModes,
340 &wPreferences.new_style, getEnum, NULL, NULL, NULL},
341 {"DisableDock", "NO", (void *)WM_DOCK,
342 NULL, getBool, setIfDockPresent, NULL, NULL},
343 {"DisableClip", "NO", (void *)WM_CLIP,
344 NULL, getBool, setIfDockPresent, NULL, NULL},
345 {"DisableDrawers", "NO", (void *)WM_DRAWER,
346 NULL, getBool, setIfDockPresent, NULL, NULL},
347 {"ClipMergedInDock", "NO", NULL,
348 NULL, getBool, setClipMergedInDock, NULL, NULL},
349 {"DisableMiniwindows", "NO", NULL,
350 &wPreferences.disable_miniwindows, getBool, NULL, NULL, NULL},
351 {"EnableWorkspacePager", "NO", NULL,
352 &wPreferences.enable_workspace_pager, getBool, NULL, NULL, NULL},
353 {"SwitchPanelIconSize", "64", NULL,
354 &wPreferences.switch_panel_icon_size, getInt, NULL, NULL, NULL},
357 #define NUM2STRING_(x) #x
358 #define NUM2STRING(x) NUM2STRING_(x)
360 WDefaultEntry optionList[] = {
362 /* dynamic options */
364 {"IconPosition", "blh", seIconPositions,
365 &wPreferences.icon_yard, getEnum, setIconPosition, NULL, NULL},
366 {"IconificationStyle", "Zoom", seIconificationStyles,
367 &wPreferences.iconification_style, getEnum, NULL, NULL, NULL},
368 {"EnforceIconMargin", "NO", NULL,
369 &wPreferences.enforce_icon_margin, getBool, NULL, NULL, NULL},
370 {"DisableWSMouseActions", "NO", NULL,
371 &wPreferences.disable_root_mouse, getBool, NULL, NULL, NULL},
372 {"MouseLeftButtonAction", "SelectWindows", seMouseButtonActions,
373 &wPreferences.mouse_button1, getEnum, NULL, NULL, NULL},
374 {"MouseMiddleButtonAction", "OpenWindowListMenu", seMouseButtonActions,
375 &wPreferences.mouse_button2, getEnum, NULL, NULL, NULL},
376 {"MouseRightButtonAction", "OpenApplicationsMenu", seMouseButtonActions,
377 &wPreferences.mouse_button3, getEnum, NULL, NULL, NULL},
378 {"MouseBackwardButtonAction", "None", seMouseButtonActions,
379 &wPreferences.mouse_button8, getEnum, NULL, NULL, NULL},
380 {"MouseForwardButtonAction", "None", seMouseButtonActions,
381 &wPreferences.mouse_button9, getEnum, NULL, NULL, NULL},
382 {"MouseWheelAction", "None", seMouseWheelActions,
383 &wPreferences.mouse_wheel_scroll, getEnum, NULL, NULL, NULL},
384 {"MouseWheelTiltAction", "None", seMouseWheelActions,
385 &wPreferences.mouse_wheel_tilt, getEnum, NULL, NULL, NULL},
386 {"PixmapPath", DEF_PIXMAP_PATHS, NULL,
387 &wPreferences.pixmap_path, getPathList, NULL, NULL, NULL},
388 {"IconPath", DEF_ICON_PATHS, NULL,
389 &wPreferences.icon_path, getPathList, NULL, NULL, NULL},
390 {"ColormapMode", "auto", seColormapModes,
391 &wPreferences.colormap_mode, getEnum, NULL, NULL, NULL},
392 {"AutoFocus", "YES", NULL,
393 &wPreferences.auto_focus, getBool, NULL, NULL, NULL},
394 {"RaiseDelay", "0", NULL,
395 &wPreferences.raise_delay, getInt, NULL, NULL, NULL},
396 {"CirculateRaise", "NO", NULL,
397 &wPreferences.circ_raise, getBool, NULL, NULL, NULL},
398 {"Superfluous", "YES", NULL,
399 &wPreferences.superfluous, getBool, NULL, NULL, NULL},
400 {"AdvanceToNewWorkspace", "NO", NULL,
401 &wPreferences.ws_advance, getBool, NULL, NULL, NULL},
402 {"CycleWorkspaces", "NO", NULL,
403 &wPreferences.ws_cycle, getBool, NULL, NULL, NULL},
404 {"WorkspaceNameDisplayPosition", "center", seDisplayPositions,
405 &wPreferences.workspace_name_display_position, getEnum, NULL, NULL, NULL},
406 {"WorkspaceBorder", "None", seWorkspaceBorder,
407 &wPreferences.workspace_border_position, getEnum, updateUsableArea, NULL, NULL},
408 {"WorkspaceBorderSize", "0", NULL,
409 &wPreferences.workspace_border_size, getInt, updateUsableArea, NULL, NULL},
410 {"StickyIcons", "NO", NULL,
411 &wPreferences.sticky_icons, getBool, setStickyIcons, NULL, NULL},
412 {"SaveSessionOnExit", "NO", NULL,
413 &wPreferences.save_session_on_exit, getBool, NULL, NULL, NULL},
414 {"WrapMenus", "NO", NULL,
415 &wPreferences.wrap_menus, getBool, NULL, NULL, NULL},
416 {"ScrollableMenus", "YES", NULL,
417 &wPreferences.scrollable_menus, getBool, NULL, NULL, NULL},
418 {"MenuScrollSpeed", "fast", seSpeeds,
419 &wPreferences.menu_scroll_speed, getEnum, NULL, NULL, NULL},
420 {"IconSlideSpeed", "fast", seSpeeds,
421 &wPreferences.icon_slide_speed, getEnum, NULL, NULL, NULL},
422 {"ShadeSpeed", "fast", seSpeeds,
423 &wPreferences.shade_speed, getEnum, NULL, NULL, NULL},
424 {"BounceAppIconsWhenUrgent", "YES", NULL,
425 &wPreferences.bounce_appicons_when_urgent, getBool, NULL, NULL, NULL},
426 {"RaiseAppIconsWhenBouncing", "NO", NULL,
427 &wPreferences.raise_appicons_when_bouncing, getBool, NULL, NULL, NULL},
428 {"DoNotMakeAppIconsBounce", "NO", NULL,
429 &wPreferences.do_not_make_appicons_bounce, getBool, NULL, NULL, NULL},
430 {"DoubleClickTime", "250", (void *)&wPreferences.dblclick_time,
431 &wPreferences.dblclick_time, getInt, setDoubleClick, NULL, NULL},
432 {"ClipAutoraiseDelay", "600", NULL,
433 &wPreferences.clip_auto_raise_delay, getInt, NULL, NULL, NULL},
434 {"ClipAutolowerDelay", "1000", NULL,
435 &wPreferences.clip_auto_lower_delay, getInt, NULL, NULL, NULL},
436 {"ClipAutoexpandDelay", "600", NULL,
437 &wPreferences.clip_auto_expand_delay, getInt, NULL, NULL, NULL},
438 {"ClipAutocollapseDelay", "1000", NULL,
439 &wPreferences.clip_auto_collapse_delay, getInt, NULL, NULL, NULL},
440 {"WrapAppiconsInDock", "YES", NULL,
441 NULL, getBool, setWrapAppiconsInDock, NULL, NULL},
442 {"AlignSubmenus", "NO", NULL,
443 &wPreferences.align_menus, getBool, NULL, NULL, NULL},
444 {"ViKeyMenus", "NO", NULL,
445 &wPreferences.vi_key_menus, getBool, NULL, NULL, NULL},
446 {"OpenTransientOnOwnerWorkspace", "NO", NULL,
447 &wPreferences.open_transients_with_parent, getBool, NULL, NULL, NULL},
448 {"WindowPlacement", "auto", sePlacements,
449 &wPreferences.window_placement, getEnum, NULL, NULL, NULL},
450 {"IgnoreFocusClick", "NO", NULL,
451 &wPreferences.ignore_focus_click, getBool, NULL, NULL, NULL},
452 {"UseSaveUnders", "NO", NULL,
453 &wPreferences.use_saveunders, getBool, NULL, NULL, NULL},
454 {"OpaqueMove", "YES", NULL,
455 &wPreferences.opaque_move, getBool, NULL, NULL, NULL},
456 {"OpaqueResize", "NO", NULL,
457 &wPreferences.opaque_resize, getBool, NULL, NULL, NULL},
458 {"OpaqueMoveResizeKeyboard", "NO", NULL,
459 &wPreferences.opaque_move_resize_keyboard, getBool, NULL, NULL, NULL},
460 {"DisableAnimations", "NO", NULL,
461 &wPreferences.no_animations, getBool, NULL, NULL, NULL},
462 {"DontLinkWorkspaces", "YES", NULL,
463 &wPreferences.no_autowrap, getBool, NULL, NULL, NULL},
464 {"WindowSnapping", "NO", NULL,
465 &wPreferences.window_snapping, getBool, NULL, NULL, NULL},
466 {"SnapEdgeDetect", "1", NULL,
467 &wPreferences.snap_edge_detect, getInt, NULL, NULL, NULL},
468 {"SnapCornerDetect", "10", NULL,
469 &wPreferences.snap_corner_detect, getInt, NULL, NULL, NULL},
470 {"SnapToTopMaximizesFullscreen", "NO", NULL,
471 &wPreferences.snap_to_top_maximizes_fullscreen, getBool, NULL, NULL, NULL},
472 {"DragMaximizedWindow", "Move", seDragMaximizedWindow,
473 &wPreferences.drag_maximized_window, getEnum, NULL, NULL, NULL},
474 {"MoveHalfMaximizedWindowsBetweenScreens", "NO", NULL,
475 &wPreferences.move_half_max_between_heads, getBool, NULL, NULL, NULL},
476 {"AlternativeHalfMaximized", "NO", NULL,
477 &wPreferences.alt_half_maximize, getBool, NULL, NULL, NULL},
478 {"PointerWithHalfMaxWindows", "NO", NULL,
479 &wPreferences.pointer_with_half_max_windows, getBool, NULL, NULL, NULL},
480 {"HighlightActiveApp", "YES", NULL,
481 &wPreferences.highlight_active_app, getBool, NULL, NULL, NULL},
482 {"AutoArrangeIcons", "NO", NULL,
483 &wPreferences.auto_arrange_icons, getBool, NULL, NULL, NULL},
484 {"NoWindowOverDock", "NO", NULL,
485 &wPreferences.no_window_over_dock, getBool, updateUsableArea, NULL, NULL},
486 {"NoWindowOverIcons", "NO", NULL,
487 &wPreferences.no_window_over_icons, getBool, updateUsableArea, NULL, NULL},
488 {"WindowPlaceOrigin", "(64, 0)", NULL,
489 &wPreferences.window_place_origin, getCoord, NULL, NULL, NULL},
490 {"ResizeDisplay", "center", seGeomDisplays,
491 &wPreferences.size_display, getEnum, NULL, NULL, NULL},
492 {"MoveDisplay", "floating", seGeomDisplays,
493 &wPreferences.move_display, getEnum, NULL, NULL, NULL},
494 {"DontConfirmKill", "NO", NULL,
495 &wPreferences.dont_confirm_kill, getBool, NULL, NULL, NULL},
496 {"WindowTitleBalloons", "YES", NULL,
497 &wPreferences.window_balloon, getBool, NULL, NULL, NULL},
498 {"MiniwindowTitleBalloons", "NO", NULL,
499 &wPreferences.miniwin_title_balloon, getBool, NULL, NULL, NULL},
500 {"MiniwindowPreviewBalloons", "NO", NULL,
501 &wPreferences.miniwin_preview_balloon, getBool, NULL, NULL, NULL},
502 {"AppIconBalloons", "NO", NULL,
503 &wPreferences.appicon_balloon, getBool, NULL, NULL, NULL},
504 {"HelpBalloons", "NO", NULL,
505 &wPreferences.help_balloon, getBool, NULL, NULL, NULL},
506 {"EdgeResistance", "30", NULL,
507 &wPreferences.edge_resistance, getInt, NULL, NULL, NULL},
508 {"ResizeIncrement", "0", NULL,
509 &wPreferences.resize_increment, getInt, NULL, NULL, NULL},
510 {"Attraction", "NO", NULL,
511 &wPreferences.attract, getBool, NULL, NULL, NULL},
512 {"DisableBlinking", "NO", NULL,
513 &wPreferences.dont_blink, getBool, NULL, NULL, NULL},
514 {"SingleClickLaunch", "NO", NULL,
515 &wPreferences.single_click, getBool, NULL, NULL, NULL},
516 {"StrictWindozeCycle", "YES", NULL,
517 &wPreferences.strict_windoze_cycle, getBool, NULL, NULL, NULL},
518 {"SwitchPanelOnlyOpen", "NO", NULL,
519 &wPreferences.panel_only_open, getBool, NULL, NULL, NULL},
520 {"MiniPreviewSize", "128", NULL,
521 &wPreferences.minipreview_size, getInt, NULL, NULL, NULL},
522 {"IgnoreGtkHints", "NO", NULL,
523 &wPreferences.ignore_gtk_decoration_hints, getBool, NULL, NULL, NULL},
525 /* style options */
527 {"MenuStyle", "normal", seMenuStyles,
528 &wPreferences.menu_style, getEnum, setMenuStyle, NULL, NULL},
529 {"WidgetColor", "(solid, gray)", NULL,
530 NULL, getTexture, setWidgetColor, NULL, NULL},
531 {"WorkspaceSpecificBack", "()", NULL,
532 NULL, getWSSpecificBackground, setWorkspaceSpecificBack, NULL, NULL},
533 /* WorkspaceBack must come after WorkspaceSpecificBack or
534 * WorkspaceBack won't know WorkspaceSpecificBack was also
535 * specified and 2 copies of wmsetbg will be launched */
536 {"WorkspaceBack", "(solid, \"rgb:50/50/75\")", NULL,
537 NULL, getWSBackground, setWorkspaceBack, NULL, NULL},
538 {"SmoothWorkspaceBack", "NO", NULL,
539 NULL, getBool, NULL, NULL, NULL},
540 {"IconBack", "(dgradient, \"rgb:a6/a6/b6\", \"rgb:51/55/61\")", NULL,
541 NULL, getTexture, setIconTile, NULL, NULL},
542 {"TitleJustify", "center", seJustifications,
543 &wPreferences.title_justification, getEnum, setJustify, NULL, NULL},
544 {"WindowTitleFont", DEF_TITLE_FONT, NULL,
545 NULL, getFont, setWinTitleFont, NULL, NULL},
546 {"WindowTitleExtendSpace", DEF_WINDOW_TITLE_EXTEND_SPACE, NULL,
547 &wPreferences.window_title_clearance, getInt, setClearance, NULL, NULL},
548 {"WindowTitleMinHeight", "0", NULL,
549 &wPreferences.window_title_min_height, getInt, setClearance, NULL, NULL},
550 {"WindowTitleMaxHeight", NUM2STRING(INT_MAX), NULL,
551 &wPreferences.window_title_max_height, getInt, setClearance, NULL, NULL},
552 {"MenuTitleExtendSpace", DEF_MENU_TITLE_EXTEND_SPACE, NULL,
553 &wPreferences.menu_title_clearance, getInt, setClearance, NULL, NULL},
554 {"MenuTitleMinHeight", "0", NULL,
555 &wPreferences.menu_title_min_height, getInt, setClearance, NULL, NULL},
556 {"MenuTitleMaxHeight", NUM2STRING(INT_MAX), NULL,
557 &wPreferences.menu_title_max_height, getInt, setClearance, NULL, NULL},
558 {"MenuTextExtendSpace", DEF_MENU_TEXT_EXTEND_SPACE, NULL,
559 &wPreferences.menu_text_clearance, getInt, setClearance, NULL, NULL},
560 {"MenuTitleFont", DEF_MENU_TITLE_FONT, NULL,
561 NULL, getFont, setMenuTitleFont, NULL, NULL},
562 {"MenuTextFont", DEF_MENU_ENTRY_FONT, NULL,
563 NULL, getFont, setMenuTextFont, NULL, NULL},
564 {"IconTitleFont", DEF_ICON_TITLE_FONT, NULL,
565 NULL, getFont, setIconTitleFont, NULL, NULL},
566 {"ClipTitleFont", DEF_CLIP_TITLE_FONT, NULL,
567 NULL, getFont, setClipTitleFont, NULL, NULL},
568 {"ShowClipTitle", "YES", NULL,
569 &wPreferences.show_clip_title, getBool, NULL, NULL, NULL},
570 {"LargeDisplayFont", DEF_WORKSPACE_NAME_FONT, NULL,
571 NULL, getFont, setLargeDisplayFont, NULL, NULL},
572 {"HighlightColor", "white", NULL,
573 NULL, getColor, setHightlight, NULL, NULL},
574 {"HighlightTextColor", "black", NULL,
575 NULL, getColor, setHightlightText, NULL, NULL},
576 {"ClipTitleColor", "black", (void *)CLIP_NORMAL,
577 NULL, getColor, setClipTitleColor, NULL, NULL},
578 {"CClipTitleColor", "\"rgb:61/61/61\"", (void *)CLIP_COLLAPSED,
579 NULL, getColor, setClipTitleColor, NULL, NULL},
580 {"FTitleColor", "white", (void *)WS_FOCUSED,
581 NULL, getColor, setWTitleColor, NULL, NULL},
582 {"PTitleColor", "white", (void *)WS_PFOCUSED,
583 NULL, getColor, setWTitleColor, NULL, NULL},
584 {"UTitleColor", "black", (void *)WS_UNFOCUSED,
585 NULL, getColor, setWTitleColor, NULL, NULL},
586 {"FTitleBack", "(solid, black)", NULL,
587 NULL, getTexture, setFTitleBack, NULL, NULL},
588 {"PTitleBack", "(solid, gray40)", NULL,
589 NULL, getTexture, setPTitleBack, NULL, NULL},
590 {"UTitleBack", "(solid, \"rgb:aa/aa/aa\")", NULL,
591 NULL, getTexture, setUTitleBack, NULL, NULL},
592 {"ResizebarBack", "(solid, \"rgb:aa/aa/aa\")", NULL,
593 NULL, getTexture, setResizebarBack, NULL, NULL},
594 {"MenuTitleColor", "white", NULL,
595 NULL, getColor, setMenuTitleColor, NULL, NULL},
596 {"MenuTextColor", "black", NULL,
597 NULL, getColor, setMenuTextColor, NULL, NULL},
598 {"MenuDisabledColor", "gray50", NULL,
599 NULL, getColor, setMenuDisabledColor, NULL, NULL},
600 {"MenuTitleBack", "(solid, black)", NULL,
601 NULL, getTexture, setMenuTitleBack, NULL, NULL},
602 {"MenuTextBack", "(solid, \"rgb:aa/aa/aa\")", NULL,
603 NULL, getTexture, setMenuTextBack, NULL, NULL},
604 {"IconTitleColor", "white", NULL,
605 NULL, getColor, setIconTitleColor, NULL, NULL},
606 {"IconTitleBack", "black", NULL,
607 NULL, getColor, setIconTitleBack, NULL, NULL},
608 {"SwitchPanelImages", "(swtile.png, swback.png, 30, 40)", &wPreferences,
609 NULL, getPropList, setSwPOptions, NULL, NULL},
610 {"ModifierKeyLabels", "(\"Shift+\", \"Control+\", \"Mod1+\", \"Mod2+\", \"Mod3+\", \"Mod4+\", \"Mod5+\")", &wPreferences,
611 NULL, getPropList, setModifierKeyLabels, NULL, NULL},
612 {"FrameBorderWidth", "1", NULL,
613 NULL, getInt, setFrameBorderWidth, NULL, NULL},
614 {"FrameBorderColor", "black", NULL,
615 NULL, getColor, setFrameBorderColor, NULL, NULL},
616 {"FrameFocusedBorderColor", "black", NULL,
617 NULL, getColor, setFrameFocusedBorderColor, NULL, NULL},
618 {"FrameSelectedBorderColor", "white", NULL,
619 NULL, getColor, setFrameSelectedBorderColor, NULL, NULL},
620 {"WorkspaceMapBack", "(solid, black)", NULL,
621 NULL, getTexture, setWorkspaceMapBackground, NULL, NULL},
623 /* keybindings */
625 {"RootMenuKey", "F12", (void *)WKBD_ROOTMENU,
626 NULL, getKeybind, setKeyGrab, NULL, NULL},
627 {"WindowListKey", "F11", (void *)WKBD_WINDOWLIST,
628 NULL, getKeybind, setKeyGrab, NULL, NULL},
629 {"WindowMenuKey", "Control+Escape", (void *)WKBD_WINDOWMENU,
630 NULL, getKeybind, setKeyGrab, NULL, NULL},
631 {"DockRaiseLowerKey", "None", (void*)WKBD_DOCKRAISELOWER,
632 NULL, getKeybind, setKeyGrab, NULL, NULL},
633 {"ClipRaiseLowerKey", "None", (void *)WKBD_CLIPRAISELOWER,
634 NULL, getKeybind, setKeyGrab, NULL, NULL},
635 {"MiniaturizeKey", "Mod1+M", (void *)WKBD_MINIATURIZE,
636 NULL, getKeybind, setKeyGrab, NULL, NULL},
637 {"MinimizeAllKey", "None", (void *)WKBD_MINIMIZEALL,
638 NULL, getKeybind, setKeyGrab, NULL, NULL },
639 {"HideKey", "Mod1+H", (void *)WKBD_HIDE,
640 NULL, getKeybind, setKeyGrab, NULL, NULL},
641 {"HideOthersKey", "None", (void *)WKBD_HIDE_OTHERS,
642 NULL, getKeybind, setKeyGrab, NULL, NULL},
643 {"MoveResizeKey", "None", (void *)WKBD_MOVERESIZE,
644 NULL, getKeybind, setKeyGrab, NULL, NULL},
645 {"CloseKey", "None", (void *)WKBD_CLOSE,
646 NULL, getKeybind, setKeyGrab, NULL, NULL},
647 {"MaximizeKey", "None", (void *)WKBD_MAXIMIZE,
648 NULL, getKeybind, setKeyGrab, NULL, NULL},
649 {"VMaximizeKey", "None", (void *)WKBD_VMAXIMIZE,
650 NULL, getKeybind, setKeyGrab, NULL, NULL},
651 {"HMaximizeKey", "None", (void *)WKBD_HMAXIMIZE,
652 NULL, getKeybind, setKeyGrab, NULL, NULL},
653 {"LHMaximizeKey", "None", (void*)WKBD_LHMAXIMIZE,
654 NULL, getKeybind, setKeyGrab, NULL, NULL},
655 {"RHMaximizeKey", "None", (void*)WKBD_RHMAXIMIZE,
656 NULL, getKeybind, setKeyGrab, NULL, NULL},
657 {"THMaximizeKey", "None", (void*)WKBD_THMAXIMIZE,
658 NULL, getKeybind, setKeyGrab, NULL, NULL},
659 {"BHMaximizeKey", "None", (void*)WKBD_BHMAXIMIZE,
660 NULL, getKeybind, setKeyGrab, NULL, NULL},
661 {"LTCMaximizeKey", "None", (void*)WKBD_LTCMAXIMIZE,
662 NULL, getKeybind, setKeyGrab, NULL, NULL},
663 {"RTCMaximizeKey", "None", (void*)WKBD_RTCMAXIMIZE,
664 NULL, getKeybind, setKeyGrab, NULL, NULL},
665 {"LBCMaximizeKey", "None", (void*)WKBD_LBCMAXIMIZE,
666 NULL, getKeybind, setKeyGrab, NULL, NULL},
667 {"RBCMaximizeKey", "None", (void*)WKBD_RBCMAXIMIZE,
668 NULL, getKeybind, setKeyGrab, NULL, NULL},
669 {"MaximusKey", "None", (void*)WKBD_MAXIMUS,
670 NULL, getKeybind, setKeyGrab, NULL, NULL},
671 {"KeepOnTopKey", "None", (void *)WKBD_KEEP_ON_TOP,
672 NULL, getKeybind, setKeyGrab, NULL, NULL},
673 {"KeepAtBottomKey", "None", (void *)WKBD_KEEP_AT_BOTTOM,
674 NULL, getKeybind, setKeyGrab, NULL, NULL},
675 {"OmnipresentKey", "None", (void *)WKBD_OMNIPRESENT,
676 NULL, getKeybind, setKeyGrab, NULL, NULL},
677 {"RaiseKey", "Mod1+Up", (void *)WKBD_RAISE,
678 NULL, getKeybind, setKeyGrab, NULL, NULL},
679 {"LowerKey", "Mod1+Down", (void *)WKBD_LOWER,
680 NULL, getKeybind, setKeyGrab, NULL, NULL},
681 {"RaiseLowerKey", "None", (void *)WKBD_RAISELOWER,
682 NULL, getKeybind, setKeyGrab, NULL, NULL},
683 {"ShadeKey", "None", (void *)WKBD_SHADE,
684 NULL, getKeybind, setKeyGrab, NULL, NULL},
685 {"SelectKey", "None", (void *)WKBD_SELECT,
686 NULL, getKeybind, setKeyGrab, NULL, NULL},
687 {"WorkspaceMapKey", "None", (void *)WKBD_WORKSPACEMAP,
688 NULL, getKeybind, setKeyGrab, NULL, NULL},
689 {"FocusNextKey", "Mod1+Tab", (void *)WKBD_FOCUSNEXT,
690 NULL, getKeybind, setKeyGrab, NULL, NULL},
691 {"FocusPrevKey", "Mod1+Shift+Tab", (void *)WKBD_FOCUSPREV,
692 NULL, getKeybind, setKeyGrab, NULL, NULL},
693 {"GroupNextKey", "None", (void *)WKBD_GROUPNEXT,
694 NULL, getKeybind, setKeyGrab, NULL, NULL},
695 {"GroupPrevKey", "None", (void *)WKBD_GROUPPREV,
696 NULL, getKeybind, setKeyGrab, NULL, NULL},
697 {"NextWorkspaceKey", "Mod1+Control+Right", (void *)WKBD_NEXTWORKSPACE,
698 NULL, getKeybind, setKeyGrab, NULL, NULL},
699 {"PrevWorkspaceKey", "Mod1+Control+Left", (void *)WKBD_PREVWORKSPACE,
700 NULL, getKeybind, setKeyGrab, NULL, NULL},
701 {"LastWorkspaceKey", "None", (void *)WKBD_LASTWORKSPACE,
702 NULL, getKeybind, setKeyGrab, NULL, NULL},
703 {"NextWorkspaceLayerKey", "None", (void *)WKBD_NEXTWSLAYER,
704 NULL, getKeybind, setKeyGrab, NULL, NULL},
705 {"PrevWorkspaceLayerKey", "None", (void *)WKBD_PREVWSLAYER,
706 NULL, getKeybind, setKeyGrab, NULL, NULL},
707 {"Workspace1Key", "Mod1+1", (void *)WKBD_WORKSPACE1,
708 NULL, getKeybind, setKeyGrab, NULL, NULL},
709 {"Workspace2Key", "Mod1+2", (void *)WKBD_WORKSPACE2,
710 NULL, getKeybind, setKeyGrab, NULL, NULL},
711 {"Workspace3Key", "Mod1+3", (void *)WKBD_WORKSPACE3,
712 NULL, getKeybind, setKeyGrab, NULL, NULL},
713 {"Workspace4Key", "Mod1+4", (void *)WKBD_WORKSPACE4,
714 NULL, getKeybind, setKeyGrab, NULL, NULL},
715 {"Workspace5Key", "Mod1+5", (void *)WKBD_WORKSPACE5,
716 NULL, getKeybind, setKeyGrab, NULL, NULL},
717 {"Workspace6Key", "Mod1+6", (void *)WKBD_WORKSPACE6,
718 NULL, getKeybind, setKeyGrab, NULL, NULL},
719 {"Workspace7Key", "Mod1+7", (void *)WKBD_WORKSPACE7,
720 NULL, getKeybind, setKeyGrab, NULL, NULL},
721 {"Workspace8Key", "Mod1+8", (void *)WKBD_WORKSPACE8,
722 NULL, getKeybind, setKeyGrab, NULL, NULL},
723 {"Workspace9Key", "Mod1+9", (void *)WKBD_WORKSPACE9,
724 NULL, getKeybind, setKeyGrab, NULL, NULL},
725 {"Workspace10Key", "Mod1+0", (void *)WKBD_WORKSPACE10,
726 NULL, getKeybind, setKeyGrab, NULL, NULL},
727 {"MoveToWorkspace1Key", "None", (void *)WKBD_MOVE_WORKSPACE1,
728 NULL, getKeybind, setKeyGrab, NULL, NULL},
729 {"MoveToWorkspace2Key", "None", (void *)WKBD_MOVE_WORKSPACE2,
730 NULL, getKeybind, setKeyGrab, NULL, NULL},
731 {"MoveToWorkspace3Key", "None", (void *)WKBD_MOVE_WORKSPACE3,
732 NULL, getKeybind, setKeyGrab, NULL, NULL},
733 {"MoveToWorkspace4Key", "None", (void *)WKBD_MOVE_WORKSPACE4,
734 NULL, getKeybind, setKeyGrab, NULL, NULL},
735 {"MoveToWorkspace5Key", "None", (void *)WKBD_MOVE_WORKSPACE5,
736 NULL, getKeybind, setKeyGrab, NULL, NULL},
737 {"MoveToWorkspace6Key", "None", (void *)WKBD_MOVE_WORKSPACE6,
738 NULL, getKeybind, setKeyGrab, NULL, NULL},
739 {"MoveToWorkspace7Key", "None", (void *)WKBD_MOVE_WORKSPACE7,
740 NULL, getKeybind, setKeyGrab, NULL, NULL},
741 {"MoveToWorkspace8Key", "None", (void *)WKBD_MOVE_WORKSPACE8,
742 NULL, getKeybind, setKeyGrab, NULL, NULL},
743 {"MoveToWorkspace9Key", "None", (void *)WKBD_MOVE_WORKSPACE9,
744 NULL, getKeybind, setKeyGrab, NULL, NULL},
745 {"MoveToWorkspace10Key", "None", (void *)WKBD_MOVE_WORKSPACE10,
746 NULL, getKeybind, setKeyGrab, NULL, NULL},
747 {"MoveToNextWorkspaceKey", "None", (void *)WKBD_MOVE_NEXTWORKSPACE,
748 NULL, getKeybind, setKeyGrab, NULL, NULL},
749 {"MoveToPrevWorkspaceKey", "None", (void *)WKBD_MOVE_PREVWORKSPACE,
750 NULL, getKeybind, setKeyGrab, NULL, NULL},
751 {"MoveToLastWorkspaceKey", "None", (void *)WKBD_MOVE_LASTWORKSPACE,
752 NULL, getKeybind, setKeyGrab, NULL, NULL},
753 {"MoveToNextWorkspaceLayerKey", "None", (void *)WKBD_MOVE_NEXTWSLAYER,
754 NULL, getKeybind, setKeyGrab, NULL, NULL},
755 {"MoveToPrevWorkspaceLayerKey", "None", (void *)WKBD_MOVE_PREVWSLAYER,
756 NULL, getKeybind, setKeyGrab, NULL, NULL},
757 {"WindowShortcut1Key", "None", (void *)WKBD_WINDOW1,
758 NULL, getKeybind, setKeyGrab, NULL, NULL},
759 {"WindowShortcut2Key", "None", (void *)WKBD_WINDOW2,
760 NULL, getKeybind, setKeyGrab, NULL, NULL},
761 {"WindowShortcut3Key", "None", (void *)WKBD_WINDOW3,
762 NULL, getKeybind, setKeyGrab, NULL, NULL},
763 {"WindowShortcut4Key", "None", (void *)WKBD_WINDOW4,
764 NULL, getKeybind, setKeyGrab, NULL, NULL},
765 {"WindowShortcut5Key", "None", (void *)WKBD_WINDOW5,
766 NULL, getKeybind, setKeyGrab, NULL, NULL},
767 {"WindowShortcut6Key", "None", (void *)WKBD_WINDOW6,
768 NULL, getKeybind, setKeyGrab, NULL, NULL},
769 {"WindowShortcut7Key", "None", (void *)WKBD_WINDOW7,
770 NULL, getKeybind, setKeyGrab, NULL, NULL},
771 {"WindowShortcut8Key", "None", (void *)WKBD_WINDOW8,
772 NULL, getKeybind, setKeyGrab, NULL, NULL},
773 {"WindowShortcut9Key", "None", (void *)WKBD_WINDOW9,
774 NULL, getKeybind, setKeyGrab, NULL, NULL},
775 {"WindowShortcut10Key", "None", (void *)WKBD_WINDOW10,
776 NULL, getKeybind, setKeyGrab, NULL, NULL},
777 {"MoveTo12to6Head", "None", (void *)WKBD_MOVE_12_TO_6_HEAD,
778 NULL, getKeybind, setKeyGrab, NULL, NULL},
779 {"MoveTo6to12Head", "None", (void *)WKBD_MOVE_6_TO_12_HEAD,
780 NULL, getKeybind, setKeyGrab, NULL, NULL},
781 {"WindowRelaunchKey", "None", (void *)WKBD_RELAUNCH,
782 NULL, getKeybind, setKeyGrab, NULL, NULL},
783 {"ScreenSwitchKey", "None", (void *)WKBD_SWITCH_SCREEN,
784 NULL, getKeybind, setKeyGrab, NULL, NULL},
785 {"RunKey", "None", (void *)WKBD_RUN,
786 NULL, getKeybind, setKeyGrab, NULL, NULL},
788 #ifdef KEEP_XKB_LOCK_STATUS
789 {"ToggleKbdModeKey", "None", (void *)WKBD_TOGGLE,
790 NULL, getKeybind, setKeyGrab, NULL, NULL},
791 {"KbdModeLock", "NO", NULL,
792 &wPreferences.modelock, getBool, NULL, NULL, NULL},
793 #endif /* KEEP_XKB_LOCK_STATUS */
795 {"NormalCursor", "(builtin, left_ptr)", (void *)WCUR_ROOT,
796 NULL, getCursor, setCursor, NULL, NULL},
797 {"ArrowCursor", "(builtin, top_left_arrow)", (void *)WCUR_ARROW,
798 NULL, getCursor, setCursor, NULL, NULL},
799 {"MoveCursor", "(builtin, fleur)", (void *)WCUR_MOVE,
800 NULL, getCursor, setCursor, NULL, NULL},
801 {"ResizeCursor", "(builtin, sizing)", (void *)WCUR_RESIZE,
802 NULL, getCursor, setCursor, NULL, NULL},
803 {"TopLeftResizeCursor", "(builtin, top_left_corner)", (void *)WCUR_TOPLEFTRESIZE,
804 NULL, getCursor, setCursor, NULL, NULL},
805 {"TopRightResizeCursor", "(builtin, top_right_corner)", (void *)WCUR_TOPRIGHTRESIZE,
806 NULL, getCursor, setCursor, NULL, NULL},
807 {"BottomLeftResizeCursor", "(builtin, bottom_left_corner)", (void *)WCUR_BOTTOMLEFTRESIZE,
808 NULL, getCursor, setCursor, NULL, NULL},
809 {"BottomRightResizeCursor", "(builtin, bottom_right_corner)", (void *)WCUR_BOTTOMRIGHTRESIZE,
810 NULL, getCursor, setCursor, NULL, NULL},
811 {"VerticalResizeCursor", "(builtin, sb_v_double_arrow)", (void *)WCUR_VERTICALRESIZE,
812 NULL, getCursor, setCursor, NULL, NULL},
813 {"HorizontalResizeCursor", "(builtin, sb_h_double_arrow)", (void *)WCUR_HORIZONRESIZE,
814 NULL, getCursor, setCursor, NULL, NULL},
815 {"WaitCursor", "(builtin, watch)", (void *)WCUR_WAIT,
816 NULL, getCursor, setCursor, NULL, NULL},
817 {"QuestionCursor", "(builtin, question_arrow)", (void *)WCUR_QUESTION,
818 NULL, getCursor, setCursor, NULL, NULL},
819 {"TextCursor", "(builtin, xterm)", (void *)WCUR_TEXT,
820 NULL, getCursor, setCursor, NULL, NULL},
821 {"SelectCursor", "(builtin, cross)", (void *)WCUR_SELECT,
822 NULL, getCursor, setCursor, NULL, NULL},
823 {"DialogHistoryLines", "500", NULL,
824 &wPreferences.history_lines, getInt, NULL, NULL, NULL},
825 {"CycleActiveHeadOnly", "NO", NULL,
826 &wPreferences.cycle_active_head_only, getBool, NULL, NULL, NULL},
827 {"CycleIgnoreMinimized", "NO", NULL,
828 &wPreferences.cycle_ignore_minimized, getBool, NULL, NULL, NULL}
831 static void initDefaults(void)
833 unsigned int i;
834 WDefaultEntry *entry;
836 WMPLSetCaseSensitive(False);
838 for (i = 0; i < wlengthof(optionList); i++) {
839 entry = &optionList[i];
841 entry->plkey = WMCreatePLString(entry->key);
842 if (entry->default_value)
843 entry->plvalue = WMCreatePropListFromDescription(entry->default_value);
844 else
845 entry->plvalue = NULL;
848 for (i = 0; i < wlengthof(staticOptionList); i++) {
849 entry = &staticOptionList[i];
851 entry->plkey = WMCreatePLString(entry->key);
852 if (entry->default_value)
853 entry->plvalue = WMCreatePropListFromDescription(entry->default_value);
854 else
855 entry->plvalue = NULL;
859 static WMPropList *readGlobalDomain(const char *domainName, Bool requireDictionary)
861 WMPropList *globalDict = NULL;
862 char path[PATH_MAX];
863 struct stat stbuf;
865 snprintf(path, sizeof(path), "%s/%s", DEFSDATADIR, domainName);
866 if (stat(path, &stbuf) >= 0) {
867 globalDict = WMReadPropListFromFile(path);
868 if (globalDict && requireDictionary && !WMIsPLDictionary(globalDict)) {
869 wwarning(_("Domain %s (%s) of global defaults database is corrupted!"), domainName, path);
870 WMReleasePropList(globalDict);
871 globalDict = NULL;
872 } else if (!globalDict) {
873 wwarning(_("could not load domain %s from global defaults database"), domainName);
877 return globalDict;
880 #if defined(GLOBAL_PREAMBLE_MENU_FILE) || defined(GLOBAL_EPILOGUE_MENU_FILE)
881 static void prependMenu(WMPropList * destarr, WMPropList * array)
883 WMPropList *item;
884 int i;
886 for (i = 0; i < WMGetPropListItemCount(array); i++) {
887 item = WMGetFromPLArray(array, i);
888 if (item)
889 WMInsertInPLArray(destarr, i + 1, item);
893 static void appendMenu(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 WMAddToPLArray(destarr, item);
904 #endif
906 void wDefaultsMergeGlobalMenus(WDDomain * menuDomain)
908 WMPropList *menu = menuDomain->dictionary;
909 WMPropList *submenu;
911 if (!menu || !WMIsPLArray(menu))
912 return;
914 #ifdef GLOBAL_PREAMBLE_MENU_FILE
915 submenu = WMReadPropListFromFile(DEFSDATADIR "/" GLOBAL_PREAMBLE_MENU_FILE);
917 if (submenu && !WMIsPLArray(submenu)) {
918 wwarning(_("invalid global menu file %s"), GLOBAL_PREAMBLE_MENU_FILE);
919 WMReleasePropList(submenu);
920 submenu = NULL;
922 if (submenu) {
923 prependMenu(menu, submenu);
924 WMReleasePropList(submenu);
926 #endif
928 #ifdef GLOBAL_EPILOGUE_MENU_FILE
929 submenu = WMReadPropListFromFile(DEFSDATADIR "/" GLOBAL_EPILOGUE_MENU_FILE);
931 if (submenu && !WMIsPLArray(submenu)) {
932 wwarning(_("invalid global menu file %s"), GLOBAL_EPILOGUE_MENU_FILE);
933 WMReleasePropList(submenu);
934 submenu = NULL;
936 if (submenu) {
937 appendMenu(menu, submenu);
938 WMReleasePropList(submenu);
940 #endif
942 menuDomain->dictionary = menu;
945 WDDomain *wDefaultsInitDomain(const char *domain, Bool requireDictionary)
947 WDDomain *db;
948 struct stat stbuf;
949 static int inited = 0;
950 WMPropList *shared_dict = NULL;
952 if (!inited) {
953 inited = 1;
954 initDefaults();
957 db = wmalloc(sizeof(WDDomain));
958 db->domain_name = domain;
959 db->path = wdefaultspathfordomain(domain);
961 if (stat(db->path, &stbuf) >= 0) {
962 db->dictionary = WMReadPropListFromFile(db->path);
963 if (db->dictionary) {
964 if (requireDictionary && !WMIsPLDictionary(db->dictionary)) {
965 WMReleasePropList(db->dictionary);
966 db->dictionary = NULL;
967 wwarning(_("Domain %s (%s) of defaults database is corrupted!"), domain, db->path);
969 db->timestamp = stbuf.st_mtime;
970 } else {
971 wwarning(_("could not load domain %s from user defaults database"), domain);
975 /* global system dictionary */
976 shared_dict = readGlobalDomain(domain, requireDictionary);
978 if (shared_dict && db->dictionary && WMIsPLDictionary(shared_dict) &&
979 WMIsPLDictionary(db->dictionary)) {
980 WMMergePLDictionaries(shared_dict, db->dictionary, True);
981 WMReleasePropList(db->dictionary);
982 db->dictionary = shared_dict;
983 if (stbuf.st_mtime > db->timestamp)
984 db->timestamp = stbuf.st_mtime;
985 } else if (!db->dictionary) {
986 db->dictionary = shared_dict;
987 if (stbuf.st_mtime > db->timestamp)
988 db->timestamp = stbuf.st_mtime;
991 return db;
994 void wReadStaticDefaults(WMPropList * dict)
996 WMPropList *plvalue;
997 WDefaultEntry *entry;
998 unsigned int i;
999 void *tdata;
1001 for (i = 0; i < wlengthof(staticOptionList); i++) {
1002 entry = &staticOptionList[i];
1004 if (dict)
1005 plvalue = WMGetFromPLDictionary(dict, entry->plkey);
1006 else
1007 plvalue = NULL;
1009 /* no default in the DB. Use builtin default */
1010 if (!plvalue)
1011 plvalue = entry->plvalue;
1013 if (plvalue) {
1014 /* convert data */
1015 (*entry->convert) (NULL, entry, plvalue, entry->addr, &tdata);
1016 if (entry->update)
1017 (*entry->update) (NULL, entry, tdata, entry->extra_data);
1022 void wDefaultsCheckDomains(void* arg)
1024 WScreen *scr;
1025 struct stat stbuf;
1026 WMPropList *shared_dict = NULL;
1027 WMPropList *dict;
1028 int i;
1030 /* Parameter not used, but tell the compiler that it is ok */
1031 (void) arg;
1033 if (stat(w_global.domain.wmaker->path, &stbuf) >= 0 && w_global.domain.wmaker->timestamp < stbuf.st_mtime) {
1034 w_global.domain.wmaker->timestamp = stbuf.st_mtime;
1036 /* Global dictionary */
1037 shared_dict = readGlobalDomain("WindowMaker", True);
1039 /* User dictionary */
1040 dict = WMReadPropListFromFile(w_global.domain.wmaker->path);
1042 if (dict) {
1043 if (!WMIsPLDictionary(dict)) {
1044 WMReleasePropList(dict);
1045 dict = NULL;
1046 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
1047 "WindowMaker", w_global.domain.wmaker->path);
1048 } else {
1049 if (shared_dict) {
1050 WMMergePLDictionaries(shared_dict, dict, True);
1051 WMReleasePropList(dict);
1052 dict = shared_dict;
1053 shared_dict = NULL;
1056 for (i = 0; i < w_global.screen_count; i++) {
1057 scr = wScreenWithNumber(i);
1058 if (scr)
1059 wReadDefaults(scr, dict);
1062 if (w_global.domain.wmaker->dictionary)
1063 WMReleasePropList(w_global.domain.wmaker->dictionary);
1065 w_global.domain.wmaker->dictionary = dict;
1067 } else {
1068 wwarning(_("could not load domain %s from user defaults database"), "WindowMaker");
1071 if (shared_dict)
1072 WMReleasePropList(shared_dict);
1076 if (stat(w_global.domain.window_attr->path, &stbuf) >= 0 && w_global.domain.window_attr->timestamp < stbuf.st_mtime) {
1077 /* global dictionary */
1078 shared_dict = readGlobalDomain("WMWindowAttributes", True);
1079 /* user dictionary */
1080 dict = WMReadPropListFromFile(w_global.domain.window_attr->path);
1081 if (dict) {
1082 if (!WMIsPLDictionary(dict)) {
1083 WMReleasePropList(dict);
1084 dict = NULL;
1085 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
1086 "WMWindowAttributes", w_global.domain.window_attr->path);
1087 } else {
1088 if (shared_dict) {
1089 WMMergePLDictionaries(shared_dict, dict, True);
1090 WMReleasePropList(dict);
1091 dict = shared_dict;
1092 shared_dict = NULL;
1095 if (w_global.domain.window_attr->dictionary)
1096 WMReleasePropList(w_global.domain.window_attr->dictionary);
1098 w_global.domain.window_attr->dictionary = dict;
1099 for (i = 0; i < w_global.screen_count; i++) {
1100 scr = wScreenWithNumber(i);
1101 if (scr) {
1102 wDefaultUpdateIcons(scr);
1104 /* Update the panel image if changed */
1105 /* Don't worry. If the image is the same these
1106 * functions will have no performance impact. */
1107 create_logo_image(scr);
1111 } else {
1112 wwarning(_("could not load domain %s from user defaults database"), "WMWindowAttributes");
1115 w_global.domain.window_attr->timestamp = stbuf.st_mtime;
1116 if (shared_dict)
1117 WMReleasePropList(shared_dict);
1120 if (stat(w_global.domain.root_menu->path, &stbuf) >= 0 && w_global.domain.root_menu->timestamp < stbuf.st_mtime) {
1121 dict = WMReadPropListFromFile(w_global.domain.root_menu->path);
1122 if (dict) {
1123 if (!WMIsPLArray(dict) && !WMIsPLString(dict)) {
1124 WMReleasePropList(dict);
1125 dict = NULL;
1126 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
1127 "WMRootMenu", w_global.domain.root_menu->path);
1128 } else {
1129 if (w_global.domain.root_menu->dictionary)
1130 WMReleasePropList(w_global.domain.root_menu->dictionary);
1132 w_global.domain.root_menu->dictionary = dict;
1133 wDefaultsMergeGlobalMenus(w_global.domain.root_menu);
1135 } else {
1136 wwarning(_("could not load domain %s from user defaults database"), "WMRootMenu");
1138 w_global.domain.root_menu->timestamp = stbuf.st_mtime;
1140 #ifndef HAVE_INOTIFY
1141 if (!arg)
1142 WMAddTimerHandler(DEFAULTS_CHECK_INTERVAL, wDefaultsCheckDomains, arg);
1143 #endif
1146 void wReadDefaults(WScreen * scr, WMPropList * new_dict)
1148 WMPropList *plvalue, *old_value;
1149 WDefaultEntry *entry;
1150 unsigned int i;
1151 int update_workspace_back = 0; /* kluge :/ */
1152 unsigned int needs_refresh;
1153 void *tdata;
1154 WMPropList *old_dict = (w_global.domain.wmaker->dictionary != new_dict ? w_global.domain.wmaker->dictionary : NULL);
1156 needs_refresh = 0;
1158 for (i = 0; i < wlengthof(optionList); i++) {
1159 entry = &optionList[i];
1161 if (new_dict)
1162 plvalue = WMGetFromPLDictionary(new_dict, entry->plkey);
1163 else
1164 plvalue = NULL;
1166 if (!old_dict)
1167 old_value = NULL;
1168 else
1169 old_value = WMGetFromPLDictionary(old_dict, entry->plkey);
1171 if (!plvalue && !old_value) {
1172 /* no default in the DB. Use builtin default */
1173 plvalue = entry->plvalue;
1174 if (plvalue && new_dict)
1175 WMPutInPLDictionary(new_dict, entry->plkey, plvalue);
1177 } else if (!plvalue) {
1178 /* value was deleted from DB. Keep current value */
1179 continue;
1180 } else if (!old_value) {
1181 /* set value for the 1st time */
1182 } else if (!WMIsPropListEqualTo(plvalue, old_value)) {
1183 /* value has changed */
1184 } else {
1185 if (strcmp(entry->key, "WorkspaceBack") == 0
1186 && update_workspace_back && scr->flags.backimage_helper_launched) {
1187 } else {
1188 /* value was not changed since last time */
1189 continue;
1193 if (plvalue) {
1194 /* convert data */
1195 if ((*entry->convert) (scr, entry, plvalue, entry->addr, &tdata)) {
1197 * If the WorkspaceSpecificBack data has been changed
1198 * so that the helper will be launched now, we must be
1199 * sure to send the default background texture config
1200 * to the helper.
1202 if (strcmp(entry->key, "WorkspaceSpecificBack") == 0 &&
1203 !scr->flags.backimage_helper_launched)
1204 update_workspace_back = 1;
1206 if (entry->update)
1207 needs_refresh |= (*entry->update) (scr, entry, tdata, entry->extra_data);
1213 if (needs_refresh != 0 && !scr->flags.startup) {
1214 int foo;
1216 foo = 0;
1217 if (needs_refresh & REFRESH_MENU_TITLE_TEXTURE)
1218 foo |= WTextureSettings;
1219 if (needs_refresh & REFRESH_MENU_TITLE_FONT)
1220 foo |= WFontSettings;
1221 if (needs_refresh & REFRESH_MENU_TITLE_COLOR)
1222 foo |= WColorSettings;
1223 if (foo)
1224 WMPostNotificationName(WNMenuTitleAppearanceSettingsChanged, NULL,
1225 (void *)(uintptr_t) foo);
1227 foo = 0;
1228 if (needs_refresh & REFRESH_MENU_TEXTURE)
1229 foo |= WTextureSettings;
1230 if (needs_refresh & REFRESH_MENU_FONT)
1231 foo |= WFontSettings;
1232 if (needs_refresh & REFRESH_MENU_COLOR)
1233 foo |= WColorSettings;
1234 if (foo)
1235 WMPostNotificationName(WNMenuAppearanceSettingsChanged, NULL, (void *)(uintptr_t) foo);
1237 foo = 0;
1238 if (needs_refresh & REFRESH_WINDOW_FONT)
1239 foo |= WFontSettings;
1240 if (needs_refresh & REFRESH_WINDOW_TEXTURES)
1241 foo |= WTextureSettings;
1242 if (needs_refresh & REFRESH_WINDOW_TITLE_COLOR)
1243 foo |= WColorSettings;
1244 if (foo)
1245 WMPostNotificationName(WNWindowAppearanceSettingsChanged, NULL, (void *)(uintptr_t) foo);
1247 if (!(needs_refresh & REFRESH_ICON_TILE)) {
1248 foo = 0;
1249 if (needs_refresh & REFRESH_ICON_FONT)
1250 foo |= WFontSettings;
1251 if (needs_refresh & REFRESH_ICON_TITLE_COLOR)
1252 foo |= WTextureSettings;
1253 if (needs_refresh & REFRESH_ICON_TITLE_BACK)
1254 foo |= WTextureSettings;
1255 if (foo)
1256 WMPostNotificationName(WNIconAppearanceSettingsChanged, NULL,
1257 (void *)(uintptr_t) foo);
1259 if (needs_refresh & REFRESH_ICON_TILE)
1260 WMPostNotificationName(WNIconTileSettingsChanged, NULL, NULL);
1262 if (needs_refresh & REFRESH_WORKSPACE_MENU) {
1263 if (scr->workspace_menu)
1264 wWorkspaceMenuUpdate(scr, scr->workspace_menu);
1265 if (scr->clip_ws_menu)
1266 wWorkspaceMenuUpdate(scr, scr->clip_ws_menu);
1267 if (scr->workspace_submenu)
1268 scr->workspace_submenu->flags.realized = 0;
1269 if (scr->clip_submenu)
1270 scr->clip_submenu->flags.realized = 0;
1275 void wDefaultUpdateIcons(WScreen *scr)
1277 WAppIcon *aicon = scr->app_icon_list;
1278 WDrawerChain *dc;
1279 WWindow *wwin = scr->focused_window;
1281 while (aicon) {
1282 /* Get the application icon, default included */
1283 wIconChangeImageFile(aicon->icon, NULL);
1284 wAppIconPaint(aicon);
1285 aicon = aicon->next;
1288 if (!wPreferences.flags.noclip || wPreferences.flags.clip_merged_in_dock)
1289 wClipIconPaint(scr->clip_icon);
1291 for (dc = scr->drawers; dc != NULL; dc = dc->next)
1292 wDrawerIconPaint(dc->adrawer->icon_array[0]);
1294 while (wwin) {
1295 if (wwin->icon && wwin->flags.miniaturized)
1296 wIconChangeImageFile(wwin->icon, NULL);
1297 wwin = wwin->prev;
1301 /* --------------------------- Local ----------------------- */
1303 #define GET_STRING_OR_DEFAULT(x, var) if (!WMIsPLString(value)) { \
1304 wwarning(_("Wrong option format for key \"%s\". Should be %s."), \
1305 entry->key, x); \
1306 wwarning(_("using default \"%s\" instead"), entry->default_value); \
1307 var = entry->default_value;\
1308 } else var = WMGetFromPLString(value)\
1311 static int string2index(WMPropList *key, WMPropList *val, const char *def, WOptionEnumeration * values)
1313 char *str;
1314 WOptionEnumeration *v;
1315 char buffer[TOTAL_VALUES_LENGTH];
1317 if (WMIsPLString(val) && (str = WMGetFromPLString(val))) {
1318 for (v = values; v->string != NULL; v++) {
1319 if (strcasecmp(v->string, str) == 0)
1320 return v->value;
1324 buffer[0] = 0;
1325 for (v = values; v->string != NULL; v++) {
1326 if (!v->is_alias) {
1327 if (buffer[0] != 0)
1328 strcat(buffer, ", ");
1329 snprintf(buffer+strlen(buffer),
1330 sizeof(buffer)-strlen(buffer)-1, "\"%s\"", v->string);
1333 wwarning(_("wrong option value for key \"%s\"; got \"%s\", should be one of %s."),
1334 WMGetFromPLString(key),
1335 WMIsPLString(val) ? WMGetFromPLString(val) : "(unknown)",
1336 buffer);
1338 if (def) {
1339 return string2index(key, val, NULL, values);
1342 return -1;
1346 * value - is the value in the defaults DB
1347 * addr - is the address to store the data
1348 * ret - is the address to store a pointer to a temporary buffer. ret
1349 * must not be freed and is used by the set functions
1351 static int getBool(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1353 static char data;
1354 const char *val;
1355 int second_pass = 0;
1357 /* Parameter not used, but tell the compiler that it is ok */
1358 (void) scr;
1360 GET_STRING_OR_DEFAULT("Boolean", val);
1362 again:
1363 if ((val[1] == '\0' && (val[0] == 'y' || val[0] == 'Y'))
1364 || strcasecmp(val, "YES") == 0) {
1366 data = 1;
1367 } else if ((val[1] == '\0' && (val[0] == 'n' || val[0] == 'N'))
1368 || strcasecmp(val, "NO") == 0) {
1369 data = 0;
1370 } else {
1371 int i;
1372 if (sscanf(val, "%i", &i) == 1) {
1373 if (i != 0)
1374 data = 1;
1375 else
1376 data = 0;
1377 } else {
1378 wwarning(_("can't convert \"%s\" to boolean for key \"%s\""), val, entry->key);
1379 if (second_pass == 0) {
1380 val = WMGetFromPLString(entry->plvalue);
1381 second_pass = 1;
1382 wwarning(_("using default \"%s\" instead"), val);
1383 goto again;
1385 return False;
1389 if (ret)
1390 *ret = &data;
1391 if (addr)
1392 *(char *)addr = data;
1394 return True;
1397 static int getInt(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1399 static int data;
1400 const char *val;
1402 /* Parameter not used, but tell the compiler that it is ok */
1403 (void) scr;
1405 GET_STRING_OR_DEFAULT("Integer", val);
1407 if (sscanf(val, "%i", &data) != 1) {
1408 wwarning(_("can't convert \"%s\" to integer for key \"%s\""), val, entry->key);
1409 val = WMGetFromPLString(entry->plvalue);
1410 wwarning(_("using default \"%s\" instead"), val);
1411 if (sscanf(val, "%i", &data) != 1) {
1412 return False;
1416 if (ret)
1417 *ret = &data;
1418 if (addr)
1419 *(int *)addr = data;
1421 return True;
1424 static int getCoord(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1426 static WCoord data;
1427 char *val_x, *val_y;
1428 int nelem, changed = 0;
1429 WMPropList *elem_x, *elem_y;
1431 again:
1432 if (!WMIsPLArray(value)) {
1433 wwarning(_("Wrong option format for key \"%s\". Should be %s."), entry->key, "Coordinate");
1434 if (changed == 0) {
1435 value = entry->plvalue;
1436 changed = 1;
1437 wwarning(_("using default \"%s\" instead"), entry->default_value);
1438 goto again;
1440 return False;
1443 nelem = WMGetPropListItemCount(value);
1444 if (nelem != 2) {
1445 wwarning(_("Incorrect number of elements in array for key \"%s\"."), entry->key);
1446 if (changed == 0) {
1447 value = entry->plvalue;
1448 changed = 1;
1449 wwarning(_("using default \"%s\" instead"), entry->default_value);
1450 goto again;
1452 return False;
1455 elem_x = WMGetFromPLArray(value, 0);
1456 elem_y = WMGetFromPLArray(value, 1);
1458 if (!elem_x || !elem_y || !WMIsPLString(elem_x) || !WMIsPLString(elem_y)) {
1459 wwarning(_("Wrong value for key \"%s\". Should be Coordinate."), entry->key);
1460 if (changed == 0) {
1461 value = entry->plvalue;
1462 changed = 1;
1463 wwarning(_("using default \"%s\" instead"), entry->default_value);
1464 goto again;
1466 return False;
1469 val_x = WMGetFromPLString(elem_x);
1470 val_y = WMGetFromPLString(elem_y);
1472 if (sscanf(val_x, "%i", &data.x) != 1 || sscanf(val_y, "%i", &data.y) != 1) {
1473 wwarning(_("can't convert array to integers for \"%s\"."), entry->key);
1474 if (changed == 0) {
1475 value = entry->plvalue;
1476 changed = 1;
1477 wwarning(_("using default \"%s\" instead"), entry->default_value);
1478 goto again;
1480 return False;
1483 if (data.x < 0)
1484 data.x = 0;
1485 else if (data.x > scr->scr_width / 3)
1486 data.x = scr->scr_width / 3;
1487 if (data.y < 0)
1488 data.y = 0;
1489 else if (data.y > scr->scr_height / 3)
1490 data.y = scr->scr_height / 3;
1492 if (ret)
1493 *ret = &data;
1494 if (addr)
1495 *(WCoord *) addr = data;
1497 return True;
1500 static int getPropList(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1502 /* Parameter not used, but tell the compiler that it is ok */
1503 (void) scr;
1504 (void) entry;
1505 (void) addr;
1507 WMRetainPropList(value);
1509 *ret = value;
1511 return True;
1514 static int getPathList(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1516 static char *data;
1517 int i, count, len;
1518 char *ptr;
1519 WMPropList *d;
1520 int changed = 0;
1522 /* Parameter not used, but tell the compiler that it is ok */
1523 (void) scr;
1524 (void) ret;
1526 again:
1527 if (!WMIsPLArray(value)) {
1528 wwarning(_("Wrong option format for key \"%s\". Should be %s."), entry->key, "an array of paths");
1529 if (changed == 0) {
1530 value = entry->plvalue;
1531 changed = 1;
1532 wwarning(_("using default \"%s\" instead"), entry->default_value);
1533 goto again;
1535 return False;
1538 i = 0;
1539 count = WMGetPropListItemCount(value);
1540 if (count < 1) {
1541 if (changed == 0) {
1542 value = entry->plvalue;
1543 changed = 1;
1544 wwarning(_("using default \"%s\" instead"), entry->default_value);
1545 goto again;
1547 return False;
1550 len = 0;
1551 for (i = 0; i < count; i++) {
1552 d = WMGetFromPLArray(value, i);
1553 if (!d || !WMIsPLString(d)) {
1554 count = i;
1555 break;
1557 len += strlen(WMGetFromPLString(d)) + 1;
1560 ptr = data = wmalloc(len + 1);
1562 for (i = 0; i < count; i++) {
1563 d = WMGetFromPLArray(value, i);
1564 if (!d || !WMIsPLString(d)) {
1565 break;
1567 strcpy(ptr, WMGetFromPLString(d));
1568 ptr += strlen(WMGetFromPLString(d));
1569 *ptr = ':';
1570 ptr++;
1572 ptr--;
1573 *(ptr--) = 0;
1575 if (*(char **)addr != NULL) {
1576 wfree(*(char **)addr);
1578 *(char **)addr = data;
1580 return True;
1583 static int getEnum(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1585 static signed char data;
1587 /* Parameter not used, but tell the compiler that it is ok */
1588 (void) scr;
1590 data = string2index(entry->plkey, value, entry->default_value, (WOptionEnumeration *) entry->extra_data);
1591 if (data < 0)
1592 return False;
1594 if (ret)
1595 *ret = &data;
1596 if (addr)
1597 *(signed char *)addr = data;
1599 return True;
1603 * (solid <color>)
1604 * (hgradient <color> <color>)
1605 * (vgradient <color> <color>)
1606 * (dgradient <color> <color>)
1607 * (mhgradient <color> <color> ...)
1608 * (mvgradient <color> <color> ...)
1609 * (mdgradient <color> <color> ...)
1610 * (igradient <color1> <color1> <thickness1> <color2> <color2> <thickness2>)
1611 * (tpixmap <file> <color>)
1612 * (spixmap <file> <color>)
1613 * (cpixmap <file> <color>)
1614 * (thgradient <file> <opaqueness> <color> <color>)
1615 * (tvgradient <file> <opaqueness> <color> <color>)
1616 * (tdgradient <file> <opaqueness> <color> <color>)
1617 * (function <lib> <function> ...)
1620 static WTexture *parse_texture(WScreen * scr, WMPropList * pl)
1622 WMPropList *elem;
1623 char *val;
1624 int nelem;
1625 WTexture *texture = NULL;
1627 nelem = WMGetPropListItemCount(pl);
1628 if (nelem < 1)
1629 return NULL;
1631 elem = WMGetFromPLArray(pl, 0);
1632 if (!elem || !WMIsPLString(elem))
1633 return NULL;
1634 val = WMGetFromPLString(elem);
1636 if (strcasecmp(val, "solid") == 0) {
1637 XColor color;
1639 if (nelem != 2)
1640 return NULL;
1642 /* get color */
1644 elem = WMGetFromPLArray(pl, 1);
1645 if (!elem || !WMIsPLString(elem))
1646 return NULL;
1647 val = WMGetFromPLString(elem);
1649 if (!XParseColor(dpy, scr->w_colormap, val, &color)) {
1650 wwarning(_("\"%s\" is not a valid color name"), val);
1651 return NULL;
1654 texture = (WTexture *) wTextureMakeSolid(scr, &color);
1655 } else if (strcasecmp(val, "dgradient") == 0
1656 || strcasecmp(val, "vgradient") == 0 || strcasecmp(val, "hgradient") == 0) {
1657 RColor color1, color2;
1658 XColor xcolor;
1659 int type;
1661 if (nelem != 3) {
1662 wwarning(_("bad number of arguments in gradient specification"));
1663 return NULL;
1666 if (val[0] == 'd' || val[0] == 'D')
1667 type = WTEX_DGRADIENT;
1668 else if (val[0] == 'h' || val[0] == 'H')
1669 type = WTEX_HGRADIENT;
1670 else
1671 type = WTEX_VGRADIENT;
1673 /* get from color */
1674 elem = WMGetFromPLArray(pl, 1);
1675 if (!elem || !WMIsPLString(elem))
1676 return NULL;
1677 val = WMGetFromPLString(elem);
1679 if (!XParseColor(dpy, scr->w_colormap, val, &xcolor)) {
1680 wwarning(_("\"%s\" is not a valid color name"), val);
1681 return NULL;
1683 color1.alpha = 255;
1684 color1.red = xcolor.red >> 8;
1685 color1.green = xcolor.green >> 8;
1686 color1.blue = xcolor.blue >> 8;
1688 /* get to color */
1689 elem = WMGetFromPLArray(pl, 2);
1690 if (!elem || !WMIsPLString(elem)) {
1691 return NULL;
1693 val = WMGetFromPLString(elem);
1695 if (!XParseColor(dpy, scr->w_colormap, val, &xcolor)) {
1696 wwarning(_("\"%s\" is not a valid color name"), val);
1697 return NULL;
1699 color2.alpha = 255;
1700 color2.red = xcolor.red >> 8;
1701 color2.green = xcolor.green >> 8;
1702 color2.blue = xcolor.blue >> 8;
1704 texture = (WTexture *) wTextureMakeGradient(scr, type, &color1, &color2);
1706 } else if (strcasecmp(val, "igradient") == 0) {
1707 RColor colors1[2], colors2[2];
1708 int th1, th2;
1709 XColor xcolor;
1710 int i;
1712 if (nelem != 7) {
1713 wwarning(_("bad number of arguments in gradient specification"));
1714 return NULL;
1717 /* get from color */
1718 for (i = 0; i < 2; i++) {
1719 elem = WMGetFromPLArray(pl, 1 + i);
1720 if (!elem || !WMIsPLString(elem))
1721 return NULL;
1722 val = WMGetFromPLString(elem);
1724 if (!XParseColor(dpy, scr->w_colormap, val, &xcolor)) {
1725 wwarning(_("\"%s\" is not a valid color name"), val);
1726 return NULL;
1728 colors1[i].alpha = 255;
1729 colors1[i].red = xcolor.red >> 8;
1730 colors1[i].green = xcolor.green >> 8;
1731 colors1[i].blue = xcolor.blue >> 8;
1733 elem = WMGetFromPLArray(pl, 3);
1734 if (!elem || !WMIsPLString(elem))
1735 return NULL;
1736 val = WMGetFromPLString(elem);
1737 th1 = atoi(val);
1739 /* get from color */
1740 for (i = 0; i < 2; i++) {
1741 elem = WMGetFromPLArray(pl, 4 + i);
1742 if (!elem || !WMIsPLString(elem))
1743 return NULL;
1744 val = WMGetFromPLString(elem);
1746 if (!XParseColor(dpy, scr->w_colormap, val, &xcolor)) {
1747 wwarning(_("\"%s\" is not a valid color name"), val);
1748 return NULL;
1750 colors2[i].alpha = 255;
1751 colors2[i].red = xcolor.red >> 8;
1752 colors2[i].green = xcolor.green >> 8;
1753 colors2[i].blue = xcolor.blue >> 8;
1755 elem = WMGetFromPLArray(pl, 6);
1756 if (!elem || !WMIsPLString(elem))
1757 return NULL;
1758 val = WMGetFromPLString(elem);
1759 th2 = atoi(val);
1761 texture = (WTexture *) wTextureMakeIGradient(scr, th1, colors1, th2, colors2);
1763 } else if (strcasecmp(val, "mhgradient") == 0
1764 || strcasecmp(val, "mvgradient") == 0 || strcasecmp(val, "mdgradient") == 0) {
1765 XColor color;
1766 RColor **colors;
1767 int i, count;
1768 int type;
1770 if (nelem < 3) {
1771 wwarning(_("too few arguments in multicolor gradient specification"));
1772 return NULL;
1775 if (val[1] == 'h' || val[1] == 'H')
1776 type = WTEX_MHGRADIENT;
1777 else if (val[1] == 'v' || val[1] == 'V')
1778 type = WTEX_MVGRADIENT;
1779 else
1780 type = WTEX_MDGRADIENT;
1782 count = nelem - 1;
1784 colors = wmalloc(sizeof(RColor *) * (count + 1));
1786 for (i = 0; i < count; i++) {
1787 elem = WMGetFromPLArray(pl, i + 1);
1788 if (!elem || !WMIsPLString(elem)) {
1789 for (--i; i >= 0; --i) {
1790 wfree(colors[i]);
1792 wfree(colors);
1793 return NULL;
1795 val = WMGetFromPLString(elem);
1797 if (!XParseColor(dpy, scr->w_colormap, val, &color)) {
1798 wwarning(_("\"%s\" is not a valid color name"), val);
1799 for (--i; i >= 0; --i) {
1800 wfree(colors[i]);
1802 wfree(colors);
1803 return NULL;
1804 } else {
1805 colors[i] = wmalloc(sizeof(RColor));
1806 colors[i]->red = color.red >> 8;
1807 colors[i]->green = color.green >> 8;
1808 colors[i]->blue = color.blue >> 8;
1811 colors[i] = NULL;
1813 texture = (WTexture *) wTextureMakeMGradient(scr, type, colors);
1814 } else if (strcasecmp(val, "spixmap") == 0 ||
1815 strcasecmp(val, "cpixmap") == 0 || strcasecmp(val, "tpixmap") == 0) {
1816 XColor color;
1817 int type;
1819 if (nelem != 3)
1820 return NULL;
1822 if (val[0] == 's' || val[0] == 'S')
1823 type = WTP_SCALE;
1824 else if (val[0] == 'c' || val[0] == 'C')
1825 type = WTP_CENTER;
1826 else
1827 type = WTP_TILE;
1829 /* get color */
1830 elem = WMGetFromPLArray(pl, 2);
1831 if (!elem || !WMIsPLString(elem)) {
1832 return NULL;
1834 val = WMGetFromPLString(elem);
1836 if (!XParseColor(dpy, scr->w_colormap, val, &color)) {
1837 wwarning(_("\"%s\" is not a valid color name"), val);
1838 return NULL;
1841 /* file name */
1842 elem = WMGetFromPLArray(pl, 1);
1843 if (!elem || !WMIsPLString(elem))
1844 return NULL;
1845 val = WMGetFromPLString(elem);
1847 texture = (WTexture *) wTextureMakePixmap(scr, type, val, &color);
1848 } else if (strcasecmp(val, "thgradient") == 0
1849 || strcasecmp(val, "tvgradient") == 0 || strcasecmp(val, "tdgradient") == 0) {
1850 RColor color1, color2;
1851 XColor xcolor;
1852 int opacity;
1853 int style;
1855 if (val[1] == 'h' || val[1] == 'H')
1856 style = WTEX_THGRADIENT;
1857 else if (val[1] == 'v' || val[1] == 'V')
1858 style = WTEX_TVGRADIENT;
1859 else
1860 style = WTEX_TDGRADIENT;
1862 if (nelem != 5) {
1863 wwarning(_("bad number of arguments in textured gradient specification"));
1864 return NULL;
1867 /* get from color */
1868 elem = WMGetFromPLArray(pl, 3);
1869 if (!elem || !WMIsPLString(elem))
1870 return NULL;
1871 val = WMGetFromPLString(elem);
1873 if (!XParseColor(dpy, scr->w_colormap, val, &xcolor)) {
1874 wwarning(_("\"%s\" is not a valid color name"), val);
1875 return NULL;
1877 color1.alpha = 255;
1878 color1.red = xcolor.red >> 8;
1879 color1.green = xcolor.green >> 8;
1880 color1.blue = xcolor.blue >> 8;
1882 /* get to color */
1883 elem = WMGetFromPLArray(pl, 4);
1884 if (!elem || !WMIsPLString(elem)) {
1885 return NULL;
1887 val = WMGetFromPLString(elem);
1889 if (!XParseColor(dpy, scr->w_colormap, val, &xcolor)) {
1890 wwarning(_("\"%s\" is not a valid color name"), val);
1891 return NULL;
1893 color2.alpha = 255;
1894 color2.red = xcolor.red >> 8;
1895 color2.green = xcolor.green >> 8;
1896 color2.blue = xcolor.blue >> 8;
1898 /* get opacity */
1899 elem = WMGetFromPLArray(pl, 2);
1900 if (!elem || !WMIsPLString(elem))
1901 opacity = 128;
1902 else
1903 val = WMGetFromPLString(elem);
1905 if (!val || (opacity = atoi(val)) < 0 || opacity > 255) {
1906 wwarning(_("bad opacity value for tgradient texture \"%s\". Should be [0..255]"), val);
1907 opacity = 128;
1910 /* get file name */
1911 elem = WMGetFromPLArray(pl, 1);
1912 if (!elem || !WMIsPLString(elem))
1913 return NULL;
1914 val = WMGetFromPLString(elem);
1916 texture = (WTexture *) wTextureMakeTGradient(scr, style, &color1, &color2, val, opacity);
1917 } else if (strcasecmp(val, "function") == 0) {
1918 /* Leave this in to handle the unlikely case of
1919 * someone actually having function textures configured */
1920 wwarning("function texture support has been removed");
1921 return NULL;
1922 } else {
1923 wwarning(_("invalid texture type %s"), val);
1924 return NULL;
1926 return texture;
1929 static int getTexture(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1931 static WTexture *texture;
1932 int changed = 0;
1934 again:
1935 if (!WMIsPLArray(value)) {
1936 wwarning(_("Wrong option format for key \"%s\". Should be %s."), entry->key, "Texture");
1937 if (changed == 0) {
1938 value = entry->plvalue;
1939 changed = 1;
1940 wwarning(_("using default \"%s\" instead"), entry->default_value);
1941 goto again;
1943 return False;
1946 if (strcmp(entry->key, "WidgetColor") == 0 && !changed) {
1947 WMPropList *pl;
1949 pl = WMGetFromPLArray(value, 0);
1950 if (!pl || !WMIsPLString(pl) || !WMGetFromPLString(pl)
1951 || strcasecmp(WMGetFromPLString(pl), "solid") != 0) {
1952 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1953 entry->key, "Solid Texture");
1955 value = entry->plvalue;
1956 changed = 1;
1957 wwarning(_("using default \"%s\" instead"), entry->default_value);
1958 goto again;
1962 texture = parse_texture(scr, value);
1964 if (!texture) {
1965 wwarning(_("Error in texture specification for key \"%s\""), entry->key);
1966 if (changed == 0) {
1967 value = entry->plvalue;
1968 changed = 1;
1969 wwarning(_("using default \"%s\" instead"), entry->default_value);
1970 goto again;
1972 return False;
1975 if (ret)
1976 *ret = &texture;
1978 if (addr)
1979 *(WTexture **) addr = texture;
1981 return True;
1984 static int getWSBackground(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1986 WMPropList *elem;
1987 int changed = 0;
1988 char *val;
1989 int nelem;
1991 /* Parameter not used, but tell the compiler that it is ok */
1992 (void) scr;
1993 (void) addr;
1995 again:
1996 if (!WMIsPLArray(value)) {
1997 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1998 "WorkspaceBack", "Texture or None");
1999 if (changed == 0) {
2000 value = entry->plvalue;
2001 changed = 1;
2002 wwarning(_("using default \"%s\" instead"), entry->default_value);
2003 goto again;
2005 return False;
2008 /* only do basic error checking and verify for None texture */
2010 nelem = WMGetPropListItemCount(value);
2011 if (nelem > 0) {
2012 elem = WMGetFromPLArray(value, 0);
2013 if (!elem || !WMIsPLString(elem)) {
2014 wwarning(_("Wrong type for workspace background. Should be a texture type."));
2015 if (changed == 0) {
2016 value = entry->plvalue;
2017 changed = 1;
2018 wwarning(_("using default \"%s\" instead"), entry->default_value);
2019 goto again;
2021 return False;
2023 val = WMGetFromPLString(elem);
2025 if (strcasecmp(val, "None") == 0)
2026 return True;
2028 *ret = WMRetainPropList(value);
2030 return True;
2033 static int
2034 getWSSpecificBackground(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
2036 WMPropList *elem;
2037 int nelem;
2038 int changed = 0;
2040 /* Parameter not used, but tell the compiler that it is ok */
2041 (void) scr;
2042 (void) addr;
2044 again:
2045 if (!WMIsPLArray(value)) {
2046 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
2047 "WorkspaceSpecificBack", "an array of textures");
2048 if (changed == 0) {
2049 value = entry->plvalue;
2050 changed = 1;
2051 wwarning(_("using default \"%s\" instead"), entry->default_value);
2052 goto again;
2054 return False;
2057 /* only do basic error checking and verify for None texture */
2059 nelem = WMGetPropListItemCount(value);
2060 if (nelem > 0) {
2061 while (nelem--) {
2062 elem = WMGetFromPLArray(value, nelem);
2063 if (!elem || !WMIsPLArray(elem)) {
2064 wwarning(_("Wrong type for background of workspace %i. Should be a texture."),
2065 nelem);
2070 *ret = WMRetainPropList(value);
2072 #ifdef notworking
2074 * Kluge to force wmsetbg helper to set the default background.
2075 * If the WorkspaceSpecificBack is changed once wmaker has started,
2076 * the WorkspaceBack won't be sent to the helper, unless the user
2077 * changes its value too. So, we must force this by removing the
2078 * value from the defaults DB.
2080 if (!scr->flags.backimage_helper_launched && !scr->flags.startup) {
2081 WMPropList *key = WMCreatePLString("WorkspaceBack");
2083 WMRemoveFromPLDictionary(w_global.domain.wmaker->dictionary, key);
2085 WMReleasePropList(key);
2087 #endif
2088 return True;
2091 static int getFont(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
2093 static WMFont *font;
2094 const char *val;
2096 (void) addr;
2098 GET_STRING_OR_DEFAULT("Font", val);
2100 font = WMCreateFont(scr->wmscreen, val);
2101 if (!font)
2102 font = WMCreateFont(scr->wmscreen, "fixed");
2104 if (!font) {
2105 wfatal(_("could not load any usable font!!!"));
2106 exit(1);
2109 if (ret)
2110 *ret = font;
2112 /* can't assign font value outside update function */
2113 wassertrv(addr == NULL, True);
2115 return True;
2118 static int getColor(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
2120 static XColor color;
2121 const char *val;
2122 int second_pass = 0;
2124 (void) addr;
2126 GET_STRING_OR_DEFAULT("Color", val);
2128 again:
2129 if (!wGetColor(scr, val, &color)) {
2130 wwarning(_("could not get color for key \"%s\""), entry->key);
2131 if (second_pass == 0) {
2132 val = WMGetFromPLString(entry->plvalue);
2133 second_pass = 1;
2134 wwarning(_("using default \"%s\" instead"), val);
2135 goto again;
2137 return False;
2140 if (ret)
2141 *ret = &color;
2143 assert(addr == NULL);
2145 if (addr)
2146 *(unsigned long*)addr = pixel;
2149 return True;
2152 static int getKeybind(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
2154 static WShortKey shortcut;
2155 KeySym ksym;
2156 const char *val;
2157 char *k;
2158 char buf[MAX_SHORTCUT_LENGTH], *b;
2160 /* Parameter not used, but tell the compiler that it is ok */
2161 (void) scr;
2162 (void) addr;
2164 GET_STRING_OR_DEFAULT("Key spec", val);
2166 if (!val || strcasecmp(val, "NONE") == 0) {
2167 shortcut.keycode = 0;
2168 shortcut.modifier = 0;
2169 if (ret)
2170 *ret = &shortcut;
2171 return True;
2174 wstrlcpy(buf, val, MAX_SHORTCUT_LENGTH);
2176 b = (char *)buf;
2178 /* get modifiers */
2179 shortcut.modifier = 0;
2180 while ((k = strchr(b, '+')) != NULL) {
2181 int mod;
2183 *k = 0;
2184 mod = wXModifierFromKey(b);
2185 if (mod < 0) {
2186 wwarning(_("%s: invalid key modifier \"%s\""), entry->key, b);
2187 return False;
2189 shortcut.modifier |= mod;
2191 b = k + 1;
2194 /* get key */
2195 ksym = XStringToKeysym(b);
2197 if (ksym == NoSymbol) {
2198 wwarning(_("%s:invalid kbd shortcut specification \"%s\""), entry->key, val);
2199 return False;
2202 shortcut.keycode = XKeysymToKeycode(dpy, ksym);
2203 if (shortcut.keycode == 0) {
2204 wwarning(_("%s:invalid key in shortcut \"%s\""), entry->key, val);
2205 return False;
2208 if (ret)
2209 *ret = &shortcut;
2211 return True;
2214 static int getModMask(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
2216 static int mask;
2217 const char *str;
2219 /* Parameter not used, but tell the compiler that it is ok */
2220 (void) scr;
2222 GET_STRING_OR_DEFAULT("Modifier Key", str);
2224 if (!str)
2225 return False;
2227 mask = wXModifierFromKey(str);
2228 if (mask < 0) {
2229 wwarning(_("%s: modifier key %s is not valid"), entry->key, str);
2230 mask = 0;
2231 return False;
2234 if (addr)
2235 *(int *)addr = mask;
2237 if (ret)
2238 *ret = &mask;
2240 return True;
2243 # include <X11/cursorfont.h>
2244 typedef struct {
2245 const char *name;
2246 int id;
2247 } WCursorLookup;
2249 #define CURSOR_ID_NONE (XC_num_glyphs)
2251 static const WCursorLookup cursor_table[] = {
2252 {"X_cursor", XC_X_cursor},
2253 {"arrow", XC_arrow},
2254 {"based_arrow_down", XC_based_arrow_down},
2255 {"based_arrow_up", XC_based_arrow_up},
2256 {"boat", XC_boat},
2257 {"bogosity", XC_bogosity},
2258 {"bottom_left_corner", XC_bottom_left_corner},
2259 {"bottom_right_corner", XC_bottom_right_corner},
2260 {"bottom_side", XC_bottom_side},
2261 {"bottom_tee", XC_bottom_tee},
2262 {"box_spiral", XC_box_spiral},
2263 {"center_ptr", XC_center_ptr},
2264 {"circle", XC_circle},
2265 {"clock", XC_clock},
2266 {"coffee_mug", XC_coffee_mug},
2267 {"cross", XC_cross},
2268 {"cross_reverse", XC_cross_reverse},
2269 {"crosshair", XC_crosshair},
2270 {"diamond_cross", XC_diamond_cross},
2271 {"dot", XC_dot},
2272 {"dotbox", XC_dotbox},
2273 {"double_arrow", XC_double_arrow},
2274 {"draft_large", XC_draft_large},
2275 {"draft_small", XC_draft_small},
2276 {"draped_box", XC_draped_box},
2277 {"exchange", XC_exchange},
2278 {"fleur", XC_fleur},
2279 {"gobbler", XC_gobbler},
2280 {"gumby", XC_gumby},
2281 {"hand1", XC_hand1},
2282 {"hand2", XC_hand2},
2283 {"heart", XC_heart},
2284 {"icon", XC_icon},
2285 {"iron_cross", XC_iron_cross},
2286 {"left_ptr", XC_left_ptr},
2287 {"left_side", XC_left_side},
2288 {"left_tee", XC_left_tee},
2289 {"leftbutton", XC_leftbutton},
2290 {"ll_angle", XC_ll_angle},
2291 {"lr_angle", XC_lr_angle},
2292 {"man", XC_man},
2293 {"middlebutton", XC_middlebutton},
2294 {"mouse", XC_mouse},
2295 {"pencil", XC_pencil},
2296 {"pirate", XC_pirate},
2297 {"plus", XC_plus},
2298 {"question_arrow", XC_question_arrow},
2299 {"right_ptr", XC_right_ptr},
2300 {"right_side", XC_right_side},
2301 {"right_tee", XC_right_tee},
2302 {"rightbutton", XC_rightbutton},
2303 {"rtl_logo", XC_rtl_logo},
2304 {"sailboat", XC_sailboat},
2305 {"sb_down_arrow", XC_sb_down_arrow},
2306 {"sb_h_double_arrow", XC_sb_h_double_arrow},
2307 {"sb_left_arrow", XC_sb_left_arrow},
2308 {"sb_right_arrow", XC_sb_right_arrow},
2309 {"sb_up_arrow", XC_sb_up_arrow},
2310 {"sb_v_double_arrow", XC_sb_v_double_arrow},
2311 {"shuttle", XC_shuttle},
2312 {"sizing", XC_sizing},
2313 {"spider", XC_spider},
2314 {"spraycan", XC_spraycan},
2315 {"star", XC_star},
2316 {"target", XC_target},
2317 {"tcross", XC_tcross},
2318 {"top_left_arrow", XC_top_left_arrow},
2319 {"top_left_corner", XC_top_left_corner},
2320 {"top_right_corner", XC_top_right_corner},
2321 {"top_side", XC_top_side},
2322 {"top_tee", XC_top_tee},
2323 {"trek", XC_trek},
2324 {"ul_angle", XC_ul_angle},
2325 {"umbrella", XC_umbrella},
2326 {"ur_angle", XC_ur_angle},
2327 {"watch", XC_watch},
2328 {"xterm", XC_xterm},
2329 {NULL, CURSOR_ID_NONE}
2332 static void check_bitmap_status(int status, const char *filename, Pixmap bitmap)
2334 switch (status) {
2335 case BitmapOpenFailed:
2336 wwarning(_("failed to open bitmap file \"%s\""), filename);
2337 break;
2338 case BitmapFileInvalid:
2339 wwarning(_("\"%s\" is not a valid bitmap file"), filename);
2340 break;
2341 case BitmapNoMemory:
2342 wwarning(_("out of memory reading bitmap file \"%s\""), filename);
2343 break;
2344 case BitmapSuccess:
2345 XFreePixmap(dpy, bitmap);
2346 break;
2351 * (none)
2352 * (builtin, <cursor_name>)
2353 * (bitmap, <cursor_bitmap>, <cursor_mask>)
2355 static int parse_cursor(WScreen * scr, WMPropList * pl, Cursor * cursor)
2357 WMPropList *elem;
2358 char *val;
2359 int nelem;
2360 int status = 0;
2362 nelem = WMGetPropListItemCount(pl);
2363 if (nelem < 1) {
2364 return (status);
2366 elem = WMGetFromPLArray(pl, 0);
2367 if (!elem || !WMIsPLString(elem)) {
2368 return (status);
2370 val = WMGetFromPLString(elem);
2372 if (strcasecmp(val, "none") == 0) {
2373 status = 1;
2374 *cursor = None;
2375 } else if (strcasecmp(val, "builtin") == 0) {
2376 int i;
2377 int cursor_id = CURSOR_ID_NONE;
2379 if (nelem != 2) {
2380 wwarning(_("bad number of arguments in cursor specification"));
2381 return (status);
2383 elem = WMGetFromPLArray(pl, 1);
2384 if (!elem || !WMIsPLString(elem)) {
2385 return (status);
2387 val = WMGetFromPLString(elem);
2389 for (i = 0; cursor_table[i].name != NULL; i++) {
2390 if (strcasecmp(val, cursor_table[i].name) == 0) {
2391 cursor_id = cursor_table[i].id;
2392 break;
2395 if (CURSOR_ID_NONE == cursor_id) {
2396 wwarning(_("unknown builtin cursor name \"%s\""), val);
2397 } else {
2398 *cursor = XCreateFontCursor(dpy, cursor_id);
2399 status = 1;
2401 } else if (strcasecmp(val, "bitmap") == 0) {
2402 char *bitmap_name;
2403 char *mask_name;
2404 int bitmap_status;
2405 int mask_status;
2406 Pixmap bitmap;
2407 Pixmap mask;
2408 unsigned int w, h;
2409 int x, y;
2410 XColor fg, bg;
2412 if (nelem != 3) {
2413 wwarning(_("bad number of arguments in cursor specification"));
2414 return (status);
2416 elem = WMGetFromPLArray(pl, 1);
2417 if (!elem || !WMIsPLString(elem)) {
2418 return (status);
2420 val = WMGetFromPLString(elem);
2421 bitmap_name = FindImage(wPreferences.pixmap_path, val);
2422 if (!bitmap_name) {
2423 wwarning(_("could not find cursor bitmap file \"%s\""), val);
2424 return (status);
2426 elem = WMGetFromPLArray(pl, 2);
2427 if (!elem || !WMIsPLString(elem)) {
2428 wfree(bitmap_name);
2429 return (status);
2431 val = WMGetFromPLString(elem);
2432 mask_name = FindImage(wPreferences.pixmap_path, val);
2433 if (!mask_name) {
2434 wfree(bitmap_name);
2435 wwarning(_("could not find cursor bitmap file \"%s\""), val);
2436 return (status);
2438 mask_status = XReadBitmapFile(dpy, scr->w_win, mask_name, &w, &h, &mask, &x, &y);
2439 bitmap_status = XReadBitmapFile(dpy, scr->w_win, bitmap_name, &w, &h, &bitmap, &x, &y);
2440 if ((BitmapSuccess == bitmap_status) && (BitmapSuccess == mask_status)) {
2441 fg.pixel = scr->black_pixel;
2442 bg.pixel = scr->white_pixel;
2443 XQueryColor(dpy, scr->w_colormap, &fg);
2444 XQueryColor(dpy, scr->w_colormap, &bg);
2445 *cursor = XCreatePixmapCursor(dpy, bitmap, mask, &fg, &bg, x, y);
2446 status = 1;
2448 check_bitmap_status(bitmap_status, bitmap_name, bitmap);
2449 check_bitmap_status(mask_status, mask_name, mask);
2450 wfree(bitmap_name);
2451 wfree(mask_name);
2453 return (status);
2456 static int getCursor(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
2458 static Cursor cursor;
2459 int status;
2460 int changed = 0;
2462 again:
2463 if (!WMIsPLArray(value)) {
2464 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
2465 entry->key, "cursor specification");
2466 if (!changed) {
2467 value = entry->plvalue;
2468 changed = 1;
2469 wwarning(_("using default \"%s\" instead"), entry->default_value);
2470 goto again;
2472 return (False);
2474 status = parse_cursor(scr, value, &cursor);
2475 if (!status) {
2476 wwarning(_("Error in cursor specification for key \"%s\""), entry->key);
2477 if (!changed) {
2478 value = entry->plvalue;
2479 changed = 1;
2480 wwarning(_("using default \"%s\" instead"), entry->default_value);
2481 goto again;
2483 return (False);
2485 if (ret) {
2486 *ret = &cursor;
2488 if (addr) {
2489 *(Cursor *) addr = cursor;
2491 return (True);
2494 #undef CURSOR_ID_NONE
2496 /* ---------------- value setting functions --------------- */
2497 static int setJustify(WScreen * scr, WDefaultEntry * entry, void *tdata, void *extra_data)
2499 /* Parameter not used, but tell the compiler that it is ok */
2500 (void) scr;
2501 (void) entry;
2502 (void) tdata;
2503 (void) extra_data;
2505 return REFRESH_WINDOW_TITLE_COLOR;
2508 static int setClearance(WScreen * scr, WDefaultEntry * entry, void *bar, void *foo)
2510 /* Parameter not used, but tell the compiler that it is ok */
2511 (void) scr;
2512 (void) entry;
2513 (void) bar;
2514 (void) foo;
2516 return REFRESH_WINDOW_FONT | REFRESH_BUTTON_IMAGES | REFRESH_MENU_TITLE_FONT | REFRESH_MENU_FONT;
2519 static int setIfDockPresent(WScreen * scr, WDefaultEntry * entry, void *tdata, void *extra_data)
2521 char *flag = tdata;
2522 long which = (long) extra_data;
2524 /* Parameter not used, but tell the compiler that it is ok */
2525 (void) scr;
2526 (void) entry;
2528 switch (which) {
2529 case WM_DOCK:
2530 wPreferences.flags.nodock = wPreferences.flags.nodock || *flag;
2531 // Drawers require the dock
2532 wPreferences.flags.nodrawer = wPreferences.flags.nodrawer || wPreferences.flags.nodock;
2533 break;
2534 case WM_CLIP:
2535 wPreferences.flags.noclip = wPreferences.flags.noclip || *flag;
2536 break;
2537 case WM_DRAWER:
2538 wPreferences.flags.nodrawer = wPreferences.flags.nodrawer || *flag;
2539 break;
2540 default:
2541 break;
2543 return 0;
2546 static int setClipMergedInDock(WScreen *scr, WDefaultEntry *entry, void *tdata, void *foo)
2548 char *flag = tdata;
2550 /* Parameter not used, but tell the compiler that it is ok */
2551 (void) scr;
2552 (void) entry;
2553 (void) foo;
2555 wPreferences.flags.clip_merged_in_dock = *flag;
2556 wPreferences.flags.noclip = wPreferences.flags.noclip || *flag;
2557 return 0;
2560 static int setWrapAppiconsInDock(WScreen *scr, WDefaultEntry *entry, void *tdata, void *foo)
2562 char *flag = tdata;
2564 /* Parameter not used, but tell the compiler that it is ok */
2565 (void) scr;
2566 (void) entry;
2567 (void) foo;
2569 wPreferences.flags.wrap_appicons_in_dock = *flag;
2570 return 0;
2573 static int setStickyIcons(WScreen * scr, WDefaultEntry * entry, void *bar, void *foo)
2575 /* Parameter not used, but tell the compiler that it is ok */
2576 (void) entry;
2577 (void) bar;
2578 (void) foo;
2580 if (scr->workspaces) {
2581 wWorkspaceForceChange(scr, scr->current_workspace);
2582 wArrangeIcons(scr, False);
2584 return 0;
2587 static int setIconTile(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2589 Pixmap pixmap;
2590 RImage *img;
2591 WTexture ** texture = tdata;
2592 int reset = 0;
2594 /* Parameter not used, but tell the compiler that it is ok */
2595 (void) foo;
2597 img = wTextureRenderImage(*texture, wPreferences.icon_size,
2598 wPreferences.icon_size, ((*texture)->any.type & WREL_BORDER_MASK)
2599 ? WREL_ICON : WREL_FLAT);
2600 if (!img) {
2601 wwarning(_("could not render texture for icon background"));
2602 if (!entry->addr)
2603 wTextureDestroy(scr, *texture);
2604 return 0;
2606 RConvertImage(scr->rcontext, img, &pixmap);
2608 if (scr->icon_tile) {
2609 reset = 1;
2610 RReleaseImage(scr->icon_tile);
2611 XFreePixmap(dpy, scr->icon_tile_pixmap);
2614 scr->icon_tile = img;
2616 /* put the icon in the noticeboard hint */
2617 PropSetIconTileHint(scr, img);
2619 if (!wPreferences.flags.noclip || wPreferences.flags.clip_merged_in_dock) {
2620 if (scr->clip_tile) {
2621 RReleaseImage(scr->clip_tile);
2623 scr->clip_tile = wClipMakeTile(img);
2626 if (!wPreferences.flags.nodrawer) {
2627 if (scr->drawer_tile) {
2628 RReleaseImage(scr->drawer_tile);
2630 scr->drawer_tile = wDrawerMakeTile(scr, img);
2633 scr->icon_tile_pixmap = pixmap;
2635 if (scr->def_icon_rimage) {
2636 RReleaseImage(scr->def_icon_rimage);
2637 scr->def_icon_rimage = NULL;
2640 if (scr->icon_back_texture)
2641 wTextureDestroy(scr, (WTexture *) scr->icon_back_texture);
2643 scr->icon_back_texture = wTextureMakeSolid(scr, &((*texture)->any.color));
2645 /* Free the texture as nobody else will use it, nor refer to it. */
2646 if (!entry->addr)
2647 wTextureDestroy(scr, *texture);
2649 return (reset ? REFRESH_ICON_TILE : 0);
2652 static int setWinTitleFont(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2654 WMFont *font = tdata;
2656 /* Parameter not used, but tell the compiler that it is ok */
2657 (void) entry;
2658 (void) foo;
2660 if (scr->title_font) {
2661 WMReleaseFont(scr->title_font);
2663 scr->title_font = font;
2665 return REFRESH_WINDOW_FONT | REFRESH_BUTTON_IMAGES;
2668 static int setMenuTitleFont(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2670 WMFont *font = tdata;
2672 /* Parameter not used, but tell the compiler that it is ok */
2673 (void) entry;
2674 (void) foo;
2676 if (scr->menu_title_font) {
2677 WMReleaseFont(scr->menu_title_font);
2680 scr->menu_title_font = font;
2682 return REFRESH_MENU_TITLE_FONT;
2685 static int setMenuTextFont(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2687 WMFont *font = tdata;
2689 /* Parameter not used, but tell the compiler that it is ok */
2690 (void) entry;
2691 (void) foo;
2693 if (scr->menu_entry_font) {
2694 WMReleaseFont(scr->menu_entry_font);
2696 scr->menu_entry_font = font;
2698 return REFRESH_MENU_FONT;
2701 static int setIconTitleFont(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2703 WMFont *font = tdata;
2705 /* Parameter not used, but tell the compiler that it is ok */
2706 (void) entry;
2707 (void) foo;
2709 if (scr->icon_title_font) {
2710 WMReleaseFont(scr->icon_title_font);
2713 scr->icon_title_font = font;
2715 return REFRESH_ICON_FONT;
2718 static int setClipTitleFont(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2720 WMFont *font = tdata;
2722 /* Parameter not used, but tell the compiler that it is ok */
2723 (void) entry;
2724 (void) foo;
2726 if (scr->clip_title_font) {
2727 WMReleaseFont(scr->clip_title_font);
2730 scr->clip_title_font = font;
2732 return REFRESH_ICON_FONT;
2735 static int setLargeDisplayFont(WScreen *scr, WDefaultEntry *entry, void *tdata, void *foo)
2737 WMFont *font = tdata;
2739 /* Parameter not used, but tell the compiler that it is ok */
2740 (void) scr;
2741 (void) entry;
2742 (void) foo;
2744 if (scr->workspace_name_font)
2745 WMReleaseFont(scr->workspace_name_font);
2747 scr->workspace_name_font = font;
2749 return 0;
2752 static int setHightlight(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2754 XColor *color = tdata;
2756 /* Parameter not used, but tell the compiler that it is ok */
2757 (void) entry;
2758 (void) foo;
2760 if (scr->select_color)
2761 WMReleaseColor(scr->select_color);
2763 scr->select_color = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2765 wFreeColor(scr, color->pixel);
2767 return REFRESH_MENU_COLOR;
2770 static int setHightlightText(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2772 XColor *color = tdata;
2774 /* Parameter not used, but tell the compiler that it is ok */
2775 (void) entry;
2776 (void) foo;
2778 if (scr->select_text_color)
2779 WMReleaseColor(scr->select_text_color);
2781 scr->select_text_color = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2783 wFreeColor(scr, color->pixel);
2785 return REFRESH_MENU_COLOR;
2788 static int setClipTitleColor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *extra_data)
2790 XColor *color = tdata;
2791 long widx = (long) extra_data;
2793 /* Parameter not used, but tell the compiler that it is ok */
2794 (void) entry;
2796 if (scr->clip_title_color[widx])
2797 WMReleaseColor(scr->clip_title_color[widx]);
2799 scr->clip_title_color[widx] = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2800 wFreeColor(scr, color->pixel);
2802 return REFRESH_ICON_TITLE_COLOR;
2805 static int setWTitleColor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *extra_data)
2807 XColor *color = tdata;
2808 long widx = (long) extra_data;
2810 /* Parameter not used, but tell the compiler that it is ok */
2811 (void) entry;
2813 if (scr->window_title_color[widx])
2814 WMReleaseColor(scr->window_title_color[widx]);
2816 scr->window_title_color[widx] =
2817 WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2819 wFreeColor(scr, color->pixel);
2821 return REFRESH_WINDOW_TITLE_COLOR;
2824 static int setMenuTitleColor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *extra_data)
2826 XColor *color = tdata;
2828 /* Parameter not used, but tell the compiler that it is ok */
2829 (void) entry;
2830 (void) extra_data;
2832 if (scr->menu_title_color[0])
2833 WMReleaseColor(scr->menu_title_color[0]);
2835 scr->menu_title_color[0] = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2837 wFreeColor(scr, color->pixel);
2839 return REFRESH_MENU_TITLE_COLOR;
2842 static int setMenuTextColor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2844 XColor *color = tdata;
2846 /* Parameter not used, but tell the compiler that it is ok */
2847 (void) entry;
2848 (void) foo;
2850 if (scr->mtext_color)
2851 WMReleaseColor(scr->mtext_color);
2853 scr->mtext_color = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2855 if (WMColorPixel(scr->dtext_color) == WMColorPixel(scr->mtext_color)) {
2856 WMSetColorAlpha(scr->dtext_color, 0x7fff);
2857 } else {
2858 WMSetColorAlpha(scr->dtext_color, 0xffff);
2861 wFreeColor(scr, color->pixel);
2863 return REFRESH_MENU_COLOR;
2866 static int setMenuDisabledColor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2868 XColor *color = tdata;
2870 /* Parameter not used, but tell the compiler that it is ok */
2871 (void) entry;
2872 (void) foo;
2874 if (scr->dtext_color)
2875 WMReleaseColor(scr->dtext_color);
2877 scr->dtext_color = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2879 if (WMColorPixel(scr->dtext_color) == WMColorPixel(scr->mtext_color)) {
2880 WMSetColorAlpha(scr->dtext_color, 0x7fff);
2881 } else {
2882 WMSetColorAlpha(scr->dtext_color, 0xffff);
2885 wFreeColor(scr, color->pixel);
2887 return REFRESH_MENU_COLOR;
2890 static int setIconTitleColor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2892 XColor *color = tdata;
2894 /* Parameter not used, but tell the compiler that it is ok */
2895 (void) entry;
2896 (void) foo;
2898 if (scr->icon_title_color)
2899 WMReleaseColor(scr->icon_title_color);
2900 scr->icon_title_color = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2902 wFreeColor(scr, color->pixel);
2904 return REFRESH_ICON_TITLE_COLOR;
2907 static int setIconTitleBack(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2909 XColor *color = tdata;
2911 /* Parameter not used, but tell the compiler that it is ok */
2912 (void) entry;
2913 (void) foo;
2915 if (scr->icon_title_texture) {
2916 wTextureDestroy(scr, (WTexture *) scr->icon_title_texture);
2918 scr->icon_title_texture = wTextureMakeSolid(scr, color);
2920 return REFRESH_ICON_TITLE_BACK;
2923 static int setFrameBorderWidth(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2925 int *value = tdata;
2927 /* Parameter not used, but tell the compiler that it is ok */
2928 (void) entry;
2929 (void) foo;
2931 scr->frame_border_width = *value;
2933 return REFRESH_FRAME_BORDER;
2936 static int setFrameBorderColor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2938 XColor *color = tdata;
2940 /* Parameter not used, but tell the compiler that it is ok */
2941 (void) entry;
2942 (void) foo;
2944 if (scr->frame_border_color)
2945 WMReleaseColor(scr->frame_border_color);
2946 scr->frame_border_color = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2948 wFreeColor(scr, color->pixel);
2950 return REFRESH_FRAME_BORDER;
2953 static int setFrameFocusedBorderColor(WScreen *scr, WDefaultEntry *entry, void *tdata, void *foo)
2955 XColor *color = tdata;
2957 /* Parameter not used, but tell the compiler that it is ok */
2958 (void) entry;
2959 (void) foo;
2961 if (scr->frame_focused_border_color)
2962 WMReleaseColor(scr->frame_focused_border_color);
2963 scr->frame_focused_border_color = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2965 wFreeColor(scr, color->pixel);
2967 return REFRESH_FRAME_BORDER;
2970 static int setFrameSelectedBorderColor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2972 XColor *color = tdata;
2974 /* Parameter not used, but tell the compiler that it is ok */
2975 (void) entry;
2976 (void) foo;
2978 if (scr->frame_selected_border_color)
2979 WMReleaseColor(scr->frame_selected_border_color);
2980 scr->frame_selected_border_color = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2982 wFreeColor(scr, color->pixel);
2984 return REFRESH_FRAME_BORDER;
2987 static int setWorkspaceSpecificBack(WScreen * scr, WDefaultEntry * entry, void *tdata, void *bar)
2989 WMPropList *value = tdata;
2990 WMPropList *val;
2991 char *str;
2992 int i;
2994 /* Parameter not used, but tell the compiler that it is ok */
2995 (void) entry;
2996 (void) bar;
2998 if (scr->flags.backimage_helper_launched) {
2999 if (WMGetPropListItemCount(value) == 0) {
3000 SendHelperMessage(scr, 'C', 0, NULL);
3001 SendHelperMessage(scr, 'K', 0, NULL);
3003 WMReleasePropList(value);
3004 return 0;
3006 } else {
3007 if (WMGetPropListItemCount(value) == 0)
3008 return 0;
3010 if (!start_bg_helper(scr)) {
3011 WMReleasePropList(value);
3012 return 0;
3015 SendHelperMessage(scr, 'P', -1, wPreferences.pixmap_path);
3018 for (i = 0; i < WMGetPropListItemCount(value); i++) {
3019 val = WMGetFromPLArray(value, i);
3020 if (val && WMIsPLArray(val) && WMGetPropListItemCount(val) > 0) {
3021 str = WMGetPropListDescription(val, False);
3023 SendHelperMessage(scr, 'S', i + 1, str);
3025 wfree(str);
3026 } else {
3027 SendHelperMessage(scr, 'U', i + 1, NULL);
3030 sleep(1);
3032 WMReleasePropList(value);
3033 return 0;
3036 static int setWorkspaceBack(WScreen * scr, WDefaultEntry * entry, void *tdata, void *bar)
3038 WMPropList *value = tdata;
3040 /* Parameter not used, but tell the compiler that it is ok */
3041 (void) entry;
3042 (void) bar;
3044 if (scr->flags.backimage_helper_launched) {
3045 char *str;
3047 if (WMGetPropListItemCount(value) == 0) {
3048 SendHelperMessage(scr, 'U', 0, NULL);
3049 } else {
3050 /* set the default workspace background to this one */
3051 str = WMGetPropListDescription(value, False);
3052 if (str) {
3053 SendHelperMessage(scr, 'S', 0, str);
3054 wfree(str);
3055 SendHelperMessage(scr, 'C', scr->current_workspace + 1, NULL);
3056 } else {
3057 SendHelperMessage(scr, 'U', 0, NULL);
3060 } else if (WMGetPropListItemCount(value) > 0) {
3061 char *text;
3062 char *dither;
3063 int len;
3065 text = WMGetPropListDescription(value, False);
3066 len = strlen(text) + 40;
3067 dither = wPreferences.no_dithering ? "-m" : "-d";
3068 if (!strchr(text, '\'') && !strchr(text, '\\')) {
3069 char command[len];
3071 if (wPreferences.smooth_workspace_back)
3072 snprintf(command, len, "wmsetbg %s -S -p '%s' &", dither, text);
3073 else
3074 snprintf(command, len, "wmsetbg %s -p '%s' &", dither, text);
3075 ExecuteShellCommand(scr, command);
3076 } else
3077 wwarning(_("Invalid arguments for background \"%s\""), text);
3078 wfree(text);
3080 WMReleasePropList(value);
3082 return 0;
3085 static int setWidgetColor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
3087 WTexture **texture = tdata;
3089 /* Parameter not used, but tell the compiler that it is ok */
3090 (void) entry;
3091 (void) foo;
3093 if (scr->widget_texture) {
3094 wTextureDestroy(scr, (WTexture *) scr->widget_texture);
3096 scr->widget_texture = *(WTexSolid **) texture;
3098 return 0;
3101 static int setFTitleBack(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
3103 WTexture **texture = tdata;
3105 /* Parameter not used, but tell the compiler that it is ok */
3106 (void) entry;
3107 (void) foo;
3109 if (scr->window_title_texture[WS_FOCUSED]) {
3110 wTextureDestroy(scr, scr->window_title_texture[WS_FOCUSED]);
3112 scr->window_title_texture[WS_FOCUSED] = *texture;
3114 return REFRESH_WINDOW_TEXTURES;
3117 static int setPTitleBack(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
3119 WTexture **texture = tdata;
3121 /* Parameter not used, but tell the compiler that it is ok */
3122 (void) entry;
3123 (void) foo;
3125 if (scr->window_title_texture[WS_PFOCUSED]) {
3126 wTextureDestroy(scr, scr->window_title_texture[WS_PFOCUSED]);
3128 scr->window_title_texture[WS_PFOCUSED] = *texture;
3130 return REFRESH_WINDOW_TEXTURES;
3133 static int setUTitleBack(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
3135 WTexture **texture = tdata;
3137 /* Parameter not used, but tell the compiler that it is ok */
3138 (void) entry;
3139 (void) foo;
3141 if (scr->window_title_texture[WS_UNFOCUSED]) {
3142 wTextureDestroy(scr, scr->window_title_texture[WS_UNFOCUSED]);
3144 scr->window_title_texture[WS_UNFOCUSED] = *texture;
3146 return REFRESH_WINDOW_TEXTURES;
3149 static int setResizebarBack(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
3151 WTexture **texture = tdata;
3153 /* Parameter not used, but tell the compiler that it is ok */
3154 (void) entry;
3155 (void) foo;
3157 if (scr->resizebar_texture[0]) {
3158 wTextureDestroy(scr, scr->resizebar_texture[0]);
3160 scr->resizebar_texture[0] = *texture;
3162 return REFRESH_WINDOW_TEXTURES;
3165 static int setMenuTitleBack(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
3167 WTexture **texture = tdata;
3169 /* Parameter not used, but tell the compiler that it is ok */
3170 (void) entry;
3171 (void) foo;
3173 if (scr->menu_title_texture[0]) {
3174 wTextureDestroy(scr, scr->menu_title_texture[0]);
3176 scr->menu_title_texture[0] = *texture;
3178 return REFRESH_MENU_TITLE_TEXTURE;
3181 static int setMenuTextBack(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
3183 WTexture **texture = tdata;
3185 /* Parameter not used, but tell the compiler that it is ok */
3186 (void) entry;
3187 (void) foo;
3189 if (scr->menu_item_texture) {
3190 wTextureDestroy(scr, scr->menu_item_texture);
3191 wTextureDestroy(scr, (WTexture *) scr->menu_item_auxtexture);
3193 scr->menu_item_texture = *texture;
3195 scr->menu_item_auxtexture = wTextureMakeSolid(scr, &scr->menu_item_texture->any.color);
3197 return REFRESH_MENU_TEXTURE;
3200 static int setKeyGrab(WScreen * scr, WDefaultEntry * entry, void *tdata, void *extra_data)
3202 WShortKey *shortcut = tdata;
3203 WWindow *wwin;
3204 long widx = (long) extra_data;
3206 /* Parameter not used, but tell the compiler that it is ok */
3207 (void) entry;
3209 wKeyBindings[widx] = *shortcut;
3211 wwin = scr->focused_window;
3213 while (wwin != NULL) {
3214 XUngrabKey(dpy, AnyKey, AnyModifier, wwin->frame->core->window);
3216 if (!WFLAGP(wwin, no_bind_keys)) {
3217 wWindowSetKeyGrabs(wwin);
3219 wwin = wwin->prev;
3222 /* do we need to update window menus? */
3223 if (widx >= WKBD_WORKSPACE1 && widx <= WKBD_WORKSPACE10)
3224 return REFRESH_WORKSPACE_MENU;
3225 if (widx == WKBD_LASTWORKSPACE)
3226 return REFRESH_WORKSPACE_MENU;
3227 if (widx >= WKBD_MOVE_WORKSPACE1 && widx <= WKBD_MOVE_WORKSPACE10)
3228 return REFRESH_WORKSPACE_MENU;
3230 return 0;
3233 static int setIconPosition(WScreen * scr, WDefaultEntry * entry, void *bar, void *foo)
3235 /* Parameter not used, but tell the compiler that it is ok */
3236 (void) entry;
3237 (void) bar;
3238 (void) foo;
3240 wScreenUpdateUsableArea(scr);
3241 wArrangeIcons(scr, True);
3243 return 0;
3246 static int updateUsableArea(WScreen * scr, WDefaultEntry * entry, void *bar, void *foo)
3248 /* Parameter not used, but tell the compiler that it is ok */
3249 (void) entry;
3250 (void) bar;
3251 (void) foo;
3253 wScreenUpdateUsableArea(scr);
3255 return 0;
3258 static int setWorkspaceMapBackground(WScreen *scr, WDefaultEntry *entry, void *tdata, void *foo)
3260 WTexture **texture = tdata;
3262 /* Parameter not used, but tell the compiler that it is ok */
3263 (void) entry;
3264 (void) foo;
3266 if (wPreferences.wsmbackTexture)
3267 wTextureDestroy(scr, wPreferences.wsmbackTexture);
3269 wPreferences.wsmbackTexture = *texture;
3271 return REFRESH_WINDOW_TEXTURES;
3274 static int setMenuStyle(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
3276 /* Parameter not used, but tell the compiler that it is ok */
3277 (void) scr;
3278 (void) entry;
3279 (void) tdata;
3280 (void) foo;
3282 return REFRESH_MENU_TEXTURE;
3285 static RImage *chopOffImage(RImage * image, int x, int y, int w, int h)
3287 RImage *img = RCreateImage(w, h, image->format == RRGBAFormat);
3289 RCopyArea(img, image, x, y, w, h, 0, 0);
3291 return img;
3294 static int setSwPOptions(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
3296 WMPropList *array = tdata;
3297 char *path;
3298 RImage *bgimage;
3299 int cwidth, cheight;
3300 struct WPreferences *prefs = foo;
3302 if (!WMIsPLArray(array) || WMGetPropListItemCount(array) == 0) {
3303 if (prefs->swtileImage)
3304 RReleaseImage(prefs->swtileImage);
3305 prefs->swtileImage = NULL;
3307 WMReleasePropList(array);
3308 return 0;
3311 switch (WMGetPropListItemCount(array)) {
3312 case 4:
3313 if (!WMIsPLString(WMGetFromPLArray(array, 1))) {
3314 wwarning(_("Invalid arguments for option \"%s\""), entry->key);
3315 break;
3316 } else
3317 path = FindImage(wPreferences.pixmap_path, WMGetFromPLString(WMGetFromPLArray(array, 1)));
3319 if (!path) {
3320 wwarning(_("Could not find image \"%s\" for option \"%s\""),
3321 WMGetFromPLString(WMGetFromPLArray(array, 1)), entry->key);
3322 } else {
3323 bgimage = RLoadImage(scr->rcontext, path, 0);
3324 if (!bgimage) {
3325 wwarning(_("Could not load image \"%s\" for option \"%s\""), path, entry->key);
3326 wfree(path);
3327 } else {
3328 wfree(path);
3330 cwidth = atoi(WMGetFromPLString(WMGetFromPLArray(array, 2)));
3331 cheight = atoi(WMGetFromPLString(WMGetFromPLArray(array, 3)));
3333 if (cwidth <= 0 || cheight <= 0 ||
3334 cwidth >= bgimage->width - 2 || cheight >= bgimage->height - 2)
3335 wwarning(_("Invalid split sizes for switch panel back image."));
3336 else {
3337 int i;
3338 int swidth, theight;
3339 for (i = 0; i < 9; i++) {
3340 if (prefs->swbackImage[i])
3341 RReleaseImage(prefs->swbackImage[i]);
3342 prefs->swbackImage[i] = NULL;
3344 swidth = (bgimage->width - cwidth) / 2;
3345 theight = (bgimage->height - cheight) / 2;
3347 prefs->swbackImage[0] = chopOffImage(bgimage, 0, 0, swidth, theight);
3348 prefs->swbackImage[1] = chopOffImage(bgimage, swidth, 0, cwidth, theight);
3349 prefs->swbackImage[2] = chopOffImage(bgimage, swidth + cwidth, 0,
3350 swidth, theight);
3352 prefs->swbackImage[3] = chopOffImage(bgimage, 0, theight, swidth, cheight);
3353 prefs->swbackImage[4] = chopOffImage(bgimage, swidth, theight,
3354 cwidth, cheight);
3355 prefs->swbackImage[5] = chopOffImage(bgimage, swidth + cwidth, theight,
3356 swidth, cheight);
3358 prefs->swbackImage[6] = chopOffImage(bgimage, 0, theight + cheight,
3359 swidth, theight);
3360 prefs->swbackImage[7] = chopOffImage(bgimage, swidth, theight + cheight,
3361 cwidth, theight);
3362 prefs->swbackImage[8] =
3363 chopOffImage(bgimage, swidth + cwidth, theight + cheight, swidth,
3364 theight);
3366 // check if anything failed
3367 for (i = 0; i < 9; i++) {
3368 if (!prefs->swbackImage[i]) {
3369 for (; i >= 0; --i) {
3370 RReleaseImage(prefs->swbackImage[i]);
3371 prefs->swbackImage[i] = NULL;
3373 break;
3377 RReleaseImage(bgimage);
3381 /* Fall through. */
3383 case 1:
3384 if (!WMIsPLString(WMGetFromPLArray(array, 0))) {
3385 wwarning(_("Invalid arguments for option \"%s\""), entry->key);
3386 break;
3387 } else
3388 path = FindImage(wPreferences.pixmap_path, WMGetFromPLString(WMGetFromPLArray(array, 0)));
3390 if (!path) {
3391 wwarning(_("Could not find image \"%s\" for option \"%s\""),
3392 WMGetFromPLString(WMGetFromPLArray(array, 0)), entry->key);
3393 } else {
3394 if (prefs->swtileImage)
3395 RReleaseImage(prefs->swtileImage);
3397 prefs->swtileImage = RLoadImage(scr->rcontext, path, 0);
3398 if (!prefs->swtileImage) {
3399 wwarning(_("Could not load image \"%s\" for option \"%s\""), path, entry->key);
3401 wfree(path);
3403 break;
3405 default:
3406 wwarning(_("Invalid number of arguments for option \"%s\""), entry->key);
3407 break;
3410 WMReleasePropList(array);
3412 return 0;
3415 static int setModifierKeyLabels(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
3417 WMPropList *array = tdata;
3418 int i;
3419 struct WPreferences *prefs = foo;
3421 if (!WMIsPLArray(array) || WMGetPropListItemCount(array) != 7) {
3422 wwarning(_("Value for option \"%s\" must be an array of 7 strings"), entry->key);
3423 WMReleasePropList(array);
3424 return 0;
3427 DestroyWindowMenu(scr);
3429 for (i = 0; i < 7; i++) {
3430 if (prefs->modifier_labels[i])
3431 wfree(prefs->modifier_labels[i]);
3433 if (WMIsPLString(WMGetFromPLArray(array, i))) {
3434 prefs->modifier_labels[i] = wstrdup(WMGetFromPLString(WMGetFromPLArray(array, i)));
3435 } else {
3436 wwarning(_("Invalid argument for option \"%s\" item %d"), entry->key, i);
3437 prefs->modifier_labels[i] = NULL;
3441 WMReleasePropList(array);
3443 return 0;
3446 static int setDoubleClick(WScreen *scr, WDefaultEntry *entry, void *tdata, void *foo)
3448 int *value = tdata;
3450 /* Parameter not used, but tell the compiler that it is ok */
3451 (void) entry;
3452 (void) scr;
3454 if (*value <= 0)
3455 *(int *)foo = 1;
3457 W_setconf_doubleClickDelay(*value);
3459 return 0;
3462 static int setCursor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *extra_data)
3464 Cursor *cursor = tdata;
3465 long widx = (long) extra_data;
3467 /* Parameter not used, but tell the compiler that it is ok */
3468 (void) entry;
3470 if (wPreferences.cursor[widx] != None) {
3471 XFreeCursor(dpy, wPreferences.cursor[widx]);
3474 wPreferences.cursor[widx] = *cursor;
3476 if (widx == WCUR_ROOT && *cursor != None) {
3477 XDefineCursor(dpy, scr->root_win, *cursor);
3480 return 0;