NEWS: Hot corners feature description
[wmaker-crm.git] / src / defaults.c
blob3b848b15c4e68d0ce7d09ddc86dfe6e6c7223b5d
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-2023 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;
154 static WDECallbackUpdate setHotCornerActions;
156 static WDECallbackConvert getCursor;
157 static WDECallbackUpdate setCursor;
158 static WDECallbackUpdate updateDock;
161 * Tables to convert strings to enumeration values.
162 * Values stored are char
165 /* WARNING: sum of length of all value strings must not exceed
166 * this value */
167 #define TOTAL_VALUES_LENGTH 80
169 #define REFRESH_WINDOW_TEXTURES (1<<0)
170 #define REFRESH_MENU_TEXTURE (1<<1)
171 #define REFRESH_MENU_FONT (1<<2)
172 #define REFRESH_MENU_COLOR (1<<3)
173 #define REFRESH_MENU_TITLE_TEXTURE (1<<4)
174 #define REFRESH_MENU_TITLE_FONT (1<<5)
175 #define REFRESH_MENU_TITLE_COLOR (1<<6)
176 #define REFRESH_WINDOW_TITLE_COLOR (1<<7)
177 #define REFRESH_WINDOW_FONT (1<<8)
178 #define REFRESH_ICON_TILE (1<<9)
179 #define REFRESH_ICON_FONT (1<<10)
181 #define REFRESH_BUTTON_IMAGES (1<<11)
183 #define REFRESH_ICON_TITLE_COLOR (1<<12)
184 #define REFRESH_ICON_TITLE_BACK (1<<13)
186 #define REFRESH_WORKSPACE_MENU (1<<14)
188 #define REFRESH_FRAME_BORDER REFRESH_MENU_FONT|REFRESH_WINDOW_FONT
190 static WOptionEnumeration seFocusModes[] = {
191 {"Manual", WKF_CLICK, 0}, {"ClickToFocus", WKF_CLICK, 1},
192 {"Sloppy", WKF_SLOPPY, 0}, {"SemiAuto", WKF_SLOPPY, 1}, {"Auto", WKF_SLOPPY, 1},
193 {NULL, 0, 0}
196 static WOptionEnumeration seTitlebarModes[] = {
197 {"new", TS_NEW, 0}, {"old", TS_OLD, 0},
198 {"next", TS_NEXT, 0}, {NULL, 0, 0}
201 static WOptionEnumeration seColormapModes[] = {
202 {"Manual", WCM_CLICK, 0}, {"ClickToFocus", WCM_CLICK, 1},
203 {"Auto", WCM_POINTER, 0}, {"FocusFollowMouse", WCM_POINTER, 1},
204 {NULL, 0, 0}
207 static WOptionEnumeration sePlacements[] = {
208 {"Auto", WPM_AUTO, 0},
209 {"Smart", WPM_SMART, 0},
210 {"Cascade", WPM_CASCADE, 0},
211 {"Random", WPM_RANDOM, 0},
212 {"Manual", WPM_MANUAL, 0},
213 {"Center", WPM_CENTER, 0},
214 {NULL, 0, 0}
217 static WOptionEnumeration seGeomDisplays[] = {
218 {"None", WDIS_NONE, 0},
219 {"Center", WDIS_CENTER, 0},
220 {"Corner", WDIS_TOPLEFT, 0},
221 {"Floating", WDIS_FRAME_CENTER, 0},
222 {"Line", WDIS_NEW, 0},
223 {NULL, 0, 0}
226 static WOptionEnumeration seSpeeds[] = {
227 {"UltraFast", SPEED_ULTRAFAST, 0},
228 {"Fast", SPEED_FAST, 0},
229 {"Medium", SPEED_MEDIUM, 0},
230 {"Slow", SPEED_SLOW, 0},
231 {"UltraSlow", SPEED_ULTRASLOW, 0},
232 {NULL, 0, 0}
235 static WOptionEnumeration seMouseButtonActions[] = {
236 {"None", WA_NONE, 0},
237 {"SelectWindows", WA_SELECT_WINDOWS, 0},
238 {"OpenApplicationsMenu", WA_OPEN_APPMENU, 0},
239 {"OpenWindowListMenu", WA_OPEN_WINLISTMENU, 0},
240 {"MoveToPrevWorkspace", WA_MOVE_PREVWORKSPACE, 0},
241 {"MoveToNextWorkspace", WA_MOVE_NEXTWORKSPACE, 0},
242 {"MoveToPrevWindow", WA_MOVE_PREVWINDOW, 0},
243 {"MoveToNextWindow", WA_MOVE_NEXTWINDOW, 0},
244 {NULL, 0, 0}
247 static WOptionEnumeration seMouseWheelActions[] = {
248 {"None", WA_NONE, 0},
249 {"SwitchWorkspaces", WA_SWITCH_WORKSPACES, 0},
250 {"SwitchWindows", WA_SWITCH_WINDOWS, 0},
251 {NULL, 0, 0}
254 static WOptionEnumeration seIconificationStyles[] = {
255 {"Zoom", WIS_ZOOM, 0},
256 {"Twist", WIS_TWIST, 0},
257 {"Flip", WIS_FLIP, 0},
258 {"None", WIS_NONE, 0},
259 {"random", WIS_RANDOM, 0},
260 {NULL, 0, 0}
263 static WOptionEnumeration seJustifications[] = {
264 {"Left", WTJ_LEFT, 0},
265 {"Center", WTJ_CENTER, 0},
266 {"Right", WTJ_RIGHT, 0},
267 {NULL, 0, 0}
270 static WOptionEnumeration seIconPositions[] = {
271 {"blv", IY_BOTTOM | IY_LEFT | IY_VERT, 0},
272 {"blh", IY_BOTTOM | IY_LEFT | IY_HORIZ, 0},
273 {"brv", IY_BOTTOM | IY_RIGHT | IY_VERT, 0},
274 {"brh", IY_BOTTOM | IY_RIGHT | IY_HORIZ, 0},
275 {"tlv", IY_TOP | IY_LEFT | IY_VERT, 0},
276 {"tlh", IY_TOP | IY_LEFT | IY_HORIZ, 0},
277 {"trv", IY_TOP | IY_RIGHT | IY_VERT, 0},
278 {"trh", IY_TOP | IY_RIGHT | IY_HORIZ, 0},
279 {NULL, 0, 0}
282 static WOptionEnumeration seMenuStyles[] = {
283 {"normal", MS_NORMAL, 0},
284 {"singletexture", MS_SINGLE_TEXTURE, 0},
285 {"flat", MS_FLAT, 0},
286 {NULL, 0, 0}
289 static WOptionEnumeration seDisplayPositions[] = {
290 {"none", WD_NONE, 0},
291 {"center", WD_CENTER, 0},
292 {"top", WD_TOP, 0},
293 {"bottom", WD_BOTTOM, 0},
294 {"topleft", WD_TOPLEFT, 0},
295 {"topright", WD_TOPRIGHT, 0},
296 {"bottomleft", WD_BOTTOMLEFT, 0},
297 {"bottomright", WD_BOTTOMRIGHT, 0},
298 {NULL, 0, 0}
301 static WOptionEnumeration seWorkspaceBorder[] = {
302 {"None", WB_NONE, 0},
303 {"LeftRight", WB_LEFTRIGHT, 0},
304 {"TopBottom", WB_TOPBOTTOM, 0},
305 {"AllDirections", WB_ALLDIRS, 0},
306 {NULL, 0, 0}
309 static WOptionEnumeration seDragMaximizedWindow[] = {
310 {"Move", DRAGMAX_MOVE, 0},
311 {"RestoreGeometry", DRAGMAX_RESTORE, 0},
312 {"Unmaximize", DRAGMAX_UNMAXIMIZE, 0},
313 {"NoMove", DRAGMAX_NOMOVE, 0},
314 {NULL, 0, 0}
318 * ALL entries in the tables below NEED to have a default value
319 * defined, and this value needs to be correct.
321 * Also add the default key/value pair to WindowMaker/Defaults/WindowMaker.in
324 /* these options will only affect the window manager on startup
326 * static defaults can't access the screen data, because it is
327 * created after these defaults are read
329 WDefaultEntry staticOptionList[] = {
331 {"ColormapSize", "4", NULL,
332 &wPreferences.cmap_size, getInt, NULL, NULL, NULL},
333 {"DisableDithering", "NO", NULL,
334 &wPreferences.no_dithering, getBool, NULL, NULL, NULL},
335 {"IconSize", "64", NULL,
336 &wPreferences.icon_size, getInt, NULL, NULL, NULL},
337 {"ModifierKey", "Mod1", NULL,
338 &wPreferences.modifier_mask, getModMask, NULL, NULL, NULL},
339 {"FocusMode", "manual", seFocusModes, /* have a problem when switching from */
340 &wPreferences.focus_mode, getEnum, NULL, NULL, NULL}, /* manual to sloppy without restart */
341 {"NewStyle", "new", seTitlebarModes,
342 &wPreferences.new_style, getEnum, NULL, NULL, NULL},
343 {"DisableDock", "NO", (void *)WM_DOCK,
344 NULL, getBool, setIfDockPresent, NULL, NULL},
345 {"DisableClip", "NO", (void *)WM_CLIP,
346 NULL, getBool, setIfDockPresent, NULL, NULL},
347 {"DisableDrawers", "NO", (void *)WM_DRAWER,
348 NULL, getBool, setIfDockPresent, NULL, NULL},
349 {"ClipMergedInDock", "NO", NULL,
350 NULL, getBool, setClipMergedInDock, NULL, NULL},
351 {"DisableMiniwindows", "NO", NULL,
352 &wPreferences.disable_miniwindows, getBool, NULL, NULL, NULL},
353 {"EnableWorkspacePager", "NO", NULL,
354 &wPreferences.enable_workspace_pager, getBool, NULL, NULL, NULL},
355 {"SwitchPanelIconSize", "64", NULL,
356 &wPreferences.switch_panel_icon_size, getInt, NULL, NULL, NULL},
359 #define NUM2STRING_(x) #x
360 #define NUM2STRING(x) NUM2STRING_(x)
362 WDefaultEntry optionList[] = {
364 /* dynamic options */
366 {"IconPosition", "blh", seIconPositions,
367 &wPreferences.icon_yard, getEnum, setIconPosition, NULL, NULL},
368 {"IconificationStyle", "Zoom", seIconificationStyles,
369 &wPreferences.iconification_style, getEnum, NULL, NULL, NULL},
370 {"EnforceIconMargin", "NO", NULL,
371 &wPreferences.enforce_icon_margin, getBool, NULL, NULL, NULL},
372 {"DisableWSMouseActions", "NO", NULL,
373 &wPreferences.disable_root_mouse, getBool, NULL, NULL, NULL},
374 {"MouseLeftButtonAction", "SelectWindows", seMouseButtonActions,
375 &wPreferences.mouse_button1, getEnum, NULL, NULL, NULL},
376 {"MouseMiddleButtonAction", "OpenWindowListMenu", seMouseButtonActions,
377 &wPreferences.mouse_button2, getEnum, NULL, NULL, NULL},
378 {"MouseRightButtonAction", "OpenApplicationsMenu", seMouseButtonActions,
379 &wPreferences.mouse_button3, getEnum, NULL, NULL, NULL},
380 {"MouseBackwardButtonAction", "None", seMouseButtonActions,
381 &wPreferences.mouse_button8, getEnum, NULL, NULL, NULL},
382 {"MouseForwardButtonAction", "None", seMouseButtonActions,
383 &wPreferences.mouse_button9, getEnum, NULL, NULL, NULL},
384 {"MouseWheelAction", "None", seMouseWheelActions,
385 &wPreferences.mouse_wheel_scroll, getEnum, NULL, NULL, NULL},
386 {"MouseWheelTiltAction", "None", seMouseWheelActions,
387 &wPreferences.mouse_wheel_tilt, getEnum, NULL, NULL, NULL},
388 {"PixmapPath", DEF_PIXMAP_PATHS, NULL,
389 &wPreferences.pixmap_path, getPathList, NULL, NULL, NULL},
390 {"IconPath", DEF_ICON_PATHS, NULL,
391 &wPreferences.icon_path, getPathList, NULL, NULL, NULL},
392 {"ColormapMode", "auto", seColormapModes,
393 &wPreferences.colormap_mode, getEnum, NULL, NULL, NULL},
394 {"AutoFocus", "YES", NULL,
395 &wPreferences.auto_focus, getBool, NULL, NULL, NULL},
396 {"RaiseDelay", "0", NULL,
397 &wPreferences.raise_delay, getInt, NULL, NULL, NULL},
398 {"CirculateRaise", "NO", NULL,
399 &wPreferences.circ_raise, getBool, NULL, NULL, NULL},
400 {"Superfluous", "YES", NULL,
401 &wPreferences.superfluous, getBool, NULL, NULL, NULL},
402 {"AdvanceToNewWorkspace", "NO", NULL,
403 &wPreferences.ws_advance, getBool, NULL, NULL, NULL},
404 {"CycleWorkspaces", "NO", NULL,
405 &wPreferences.ws_cycle, getBool, NULL, NULL, NULL},
406 {"WorkspaceNameDisplayPosition", "center", seDisplayPositions,
407 &wPreferences.workspace_name_display_position, getEnum, NULL, NULL, NULL},
408 {"WorkspaceBorder", "None", seWorkspaceBorder,
409 &wPreferences.workspace_border_position, getEnum, updateUsableArea, NULL, NULL},
410 {"WorkspaceBorderSize", "0", NULL,
411 &wPreferences.workspace_border_size, getInt, updateUsableArea, NULL, NULL},
412 {"StickyIcons", "NO", NULL,
413 &wPreferences.sticky_icons, getBool, setStickyIcons, NULL, NULL},
414 {"SaveSessionOnExit", "NO", NULL,
415 &wPreferences.save_session_on_exit, getBool, NULL, NULL, NULL},
416 {"WrapMenus", "NO", NULL,
417 &wPreferences.wrap_menus, getBool, NULL, NULL, NULL},
418 {"ScrollableMenus", "YES", NULL,
419 &wPreferences.scrollable_menus, getBool, NULL, NULL, NULL},
420 {"MenuScrollSpeed", "fast", seSpeeds,
421 &wPreferences.menu_scroll_speed, getEnum, NULL, NULL, NULL},
422 {"IconSlideSpeed", "fast", seSpeeds,
423 &wPreferences.icon_slide_speed, getEnum, NULL, NULL, NULL},
424 {"ShadeSpeed", "fast", seSpeeds,
425 &wPreferences.shade_speed, getEnum, NULL, NULL, NULL},
426 {"BounceAppIconsWhenUrgent", "YES", NULL,
427 &wPreferences.bounce_appicons_when_urgent, getBool, NULL, NULL, NULL},
428 {"RaiseAppIconsWhenBouncing", "NO", NULL,
429 &wPreferences.raise_appicons_when_bouncing, getBool, NULL, NULL, NULL},
430 {"DoNotMakeAppIconsBounce", "NO", NULL,
431 &wPreferences.do_not_make_appicons_bounce, getBool, NULL, NULL, NULL},
432 {"DoubleClickTime", "250", (void *)&wPreferences.dblclick_time,
433 &wPreferences.dblclick_time, getInt, setDoubleClick, NULL, NULL},
434 {"ClipAutoraiseDelay", "600", NULL,
435 &wPreferences.clip_auto_raise_delay, getInt, NULL, NULL, NULL},
436 {"ClipAutolowerDelay", "1000", NULL,
437 &wPreferences.clip_auto_lower_delay, getInt, NULL, NULL, NULL},
438 {"ClipAutoexpandDelay", "600", NULL,
439 &wPreferences.clip_auto_expand_delay, getInt, NULL, NULL, NULL},
440 {"ClipAutocollapseDelay", "1000", NULL,
441 &wPreferences.clip_auto_collapse_delay, getInt, NULL, NULL, NULL},
442 {"WrapAppiconsInDock", "YES", NULL,
443 NULL, getBool, setWrapAppiconsInDock, NULL, NULL},
444 {"AlignSubmenus", "NO", NULL,
445 &wPreferences.align_menus, getBool, NULL, NULL, NULL},
446 {"ViKeyMenus", "NO", NULL,
447 &wPreferences.vi_key_menus, getBool, NULL, NULL, NULL},
448 {"OpenTransientOnOwnerWorkspace", "NO", NULL,
449 &wPreferences.open_transients_with_parent, getBool, NULL, NULL, NULL},
450 {"WindowPlacement", "auto", sePlacements,
451 &wPreferences.window_placement, getEnum, NULL, NULL, NULL},
452 {"IgnoreFocusClick", "NO", NULL,
453 &wPreferences.ignore_focus_click, getBool, NULL, NULL, NULL},
454 {"UseSaveUnders", "NO", NULL,
455 &wPreferences.use_saveunders, getBool, NULL, NULL, NULL},
456 {"OpaqueMove", "YES", NULL,
457 &wPreferences.opaque_move, getBool, NULL, NULL, NULL},
458 {"OpaqueResize", "NO", NULL,
459 &wPreferences.opaque_resize, getBool, NULL, NULL, NULL},
460 {"OpaqueMoveResizeKeyboard", "NO", NULL,
461 &wPreferences.opaque_move_resize_keyboard, getBool, NULL, NULL, NULL},
462 {"DisableAnimations", "NO", NULL,
463 &wPreferences.no_animations, getBool, NULL, NULL, NULL},
464 {"DontLinkWorkspaces", "YES", NULL,
465 &wPreferences.no_autowrap, getBool, NULL, NULL, NULL},
466 {"WindowSnapping", "NO", NULL,
467 &wPreferences.window_snapping, getBool, NULL, NULL, NULL},
468 {"SnapEdgeDetect", "1", NULL,
469 &wPreferences.snap_edge_detect, getInt, NULL, NULL, NULL},
470 {"SnapCornerDetect", "10", NULL,
471 &wPreferences.snap_corner_detect, getInt, NULL, NULL, NULL},
472 {"SnapToTopMaximizesFullscreen", "NO", NULL,
473 &wPreferences.snap_to_top_maximizes_fullscreen, getBool, NULL, NULL, NULL},
474 {"DragMaximizedWindow", "Move", seDragMaximizedWindow,
475 &wPreferences.drag_maximized_window, getEnum, NULL, NULL, NULL},
476 {"MoveHalfMaximizedWindowsBetweenScreens", "NO", NULL,
477 &wPreferences.move_half_max_between_heads, getBool, NULL, NULL, NULL},
478 {"AlternativeHalfMaximized", "NO", NULL,
479 &wPreferences.alt_half_maximize, getBool, NULL, NULL, NULL},
480 {"PointerWithHalfMaxWindows", "NO", NULL,
481 &wPreferences.pointer_with_half_max_windows, getBool, NULL, NULL, NULL},
482 {"HighlightActiveApp", "YES", NULL,
483 &wPreferences.highlight_active_app, getBool, NULL, NULL, NULL},
484 {"AutoArrangeIcons", "NO", NULL,
485 &wPreferences.auto_arrange_icons, getBool, NULL, NULL, NULL},
486 {"NoWindowOverDock", "NO", NULL,
487 &wPreferences.no_window_over_dock, getBool, updateUsableArea, NULL, NULL},
488 {"NoWindowOverIcons", "NO", NULL,
489 &wPreferences.no_window_over_icons, getBool, updateUsableArea, NULL, NULL},
490 {"WindowPlaceOrigin", "(64, 0)", NULL,
491 &wPreferences.window_place_origin, getCoord, NULL, NULL, NULL},
492 {"ResizeDisplay", "center", seGeomDisplays,
493 &wPreferences.size_display, getEnum, NULL, NULL, NULL},
494 {"MoveDisplay", "floating", seGeomDisplays,
495 &wPreferences.move_display, getEnum, NULL, NULL, NULL},
496 {"DontConfirmKill", "NO", NULL,
497 &wPreferences.dont_confirm_kill, getBool, NULL, NULL, NULL},
498 {"WindowTitleBalloons", "YES", NULL,
499 &wPreferences.window_balloon, getBool, NULL, NULL, NULL},
500 {"MiniwindowTitleBalloons", "NO", NULL,
501 &wPreferences.miniwin_title_balloon, getBool, NULL, NULL, NULL},
502 {"MiniwindowPreviewBalloons", "NO", NULL,
503 &wPreferences.miniwin_preview_balloon, getBool, NULL, NULL, NULL},
504 {"AppIconBalloons", "NO", NULL,
505 &wPreferences.appicon_balloon, getBool, NULL, NULL, NULL},
506 {"HelpBalloons", "NO", NULL,
507 &wPreferences.help_balloon, getBool, NULL, NULL, NULL},
508 {"EdgeResistance", "30", NULL,
509 &wPreferences.edge_resistance, getInt, NULL, NULL, NULL},
510 {"ResizeIncrement", "0", NULL,
511 &wPreferences.resize_increment, getInt, NULL, NULL, NULL},
512 {"Attraction", "NO", NULL,
513 &wPreferences.attract, getBool, NULL, NULL, NULL},
514 {"DisableBlinking", "NO", NULL,
515 &wPreferences.dont_blink, getBool, NULL, NULL, NULL},
516 {"SingleClickLaunch", "NO", NULL,
517 &wPreferences.single_click, getBool, NULL, NULL, NULL},
518 {"StrictWindozeCycle", "YES", NULL,
519 &wPreferences.strict_windoze_cycle, getBool, NULL, NULL, NULL},
520 {"SwitchPanelOnlyOpen", "NO", NULL,
521 &wPreferences.panel_only_open, getBool, NULL, NULL, NULL},
522 {"MiniPreviewSize", "128", NULL,
523 &wPreferences.minipreview_size, getInt, NULL, NULL, NULL},
524 {"IgnoreGtkHints", "NO", NULL,
525 &wPreferences.ignore_gtk_decoration_hints, getBool, NULL, NULL, NULL},
526 {"KeepDockOnPrimaryHead", "NO", NULL,
527 &wPreferences.keep_dock_on_primary_head, getBool, updateDock,
528 NULL, NULL},
529 {"HotCorners", "NO", NULL,
530 &wPreferences.hot_corners, getBool, NULL, NULL, NULL},
531 {"HotCornerDelay", "250", (void *)&wPreferences.hot_corner_delay,
532 &wPreferences.hot_corner_delay, getInt, NULL, NULL, NULL},
533 {"HotCornerEdge", "2", (void *)&wPreferences.hot_corner_edge,
534 &wPreferences.hot_corner_edge, getInt, NULL, NULL, NULL},
535 {"HotCornerActions", "(\"None\", \"None\", \"None\", \"None\")", &wPreferences,
536 NULL, getPropList, setHotCornerActions, NULL, NULL},
538 /* style options */
540 {"MenuStyle", "normal", seMenuStyles,
541 &wPreferences.menu_style, getEnum, setMenuStyle, NULL, NULL},
542 {"WidgetColor", "(solid, gray)", NULL,
543 NULL, getTexture, setWidgetColor, NULL, NULL},
544 {"WorkspaceSpecificBack", "()", NULL,
545 NULL, getWSSpecificBackground, setWorkspaceSpecificBack, NULL, NULL},
546 /* WorkspaceBack must come after WorkspaceSpecificBack or
547 * WorkspaceBack won't know WorkspaceSpecificBack was also
548 * specified and 2 copies of wmsetbg will be launched */
549 {"WorkspaceBack", "(solid, \"rgb:50/50/75\")", NULL,
550 NULL, getWSBackground, setWorkspaceBack, NULL, NULL},
551 {"SmoothWorkspaceBack", "NO", NULL,
552 NULL, getBool, NULL, NULL, NULL},
553 {"IconBack", "(dgradient, \"rgb:a6/a6/b6\", \"rgb:51/55/61\")", NULL,
554 NULL, getTexture, setIconTile, NULL, NULL},
555 {"TitleJustify", "center", seJustifications,
556 &wPreferences.title_justification, getEnum, setJustify, NULL, NULL},
557 {"WindowTitleFont", DEF_TITLE_FONT, NULL,
558 NULL, getFont, setWinTitleFont, NULL, NULL},
559 {"WindowTitleExtendSpace", DEF_WINDOW_TITLE_EXTEND_SPACE, NULL,
560 &wPreferences.window_title_clearance, getInt, setClearance, NULL, NULL},
561 {"WindowTitleMinHeight", "0", NULL,
562 &wPreferences.window_title_min_height, getInt, setClearance, NULL, NULL},
563 {"WindowTitleMaxHeight", NUM2STRING(INT_MAX), NULL,
564 &wPreferences.window_title_max_height, getInt, setClearance, NULL, NULL},
565 {"MenuTitleExtendSpace", DEF_MENU_TITLE_EXTEND_SPACE, NULL,
566 &wPreferences.menu_title_clearance, getInt, setClearance, NULL, NULL},
567 {"MenuTitleMinHeight", "0", NULL,
568 &wPreferences.menu_title_min_height, getInt, setClearance, NULL, NULL},
569 {"MenuTitleMaxHeight", NUM2STRING(INT_MAX), NULL,
570 &wPreferences.menu_title_max_height, getInt, setClearance, NULL, NULL},
571 {"MenuTextExtendSpace", DEF_MENU_TEXT_EXTEND_SPACE, NULL,
572 &wPreferences.menu_text_clearance, getInt, setClearance, NULL, NULL},
573 {"MenuTitleFont", DEF_MENU_TITLE_FONT, NULL,
574 NULL, getFont, setMenuTitleFont, NULL, NULL},
575 {"MenuTextFont", DEF_MENU_ENTRY_FONT, NULL,
576 NULL, getFont, setMenuTextFont, NULL, NULL},
577 {"IconTitleFont", DEF_ICON_TITLE_FONT, NULL,
578 NULL, getFont, setIconTitleFont, NULL, NULL},
579 {"ClipTitleFont", DEF_CLIP_TITLE_FONT, NULL,
580 NULL, getFont, setClipTitleFont, NULL, NULL},
581 {"ShowClipTitle", "YES", NULL,
582 &wPreferences.show_clip_title, getBool, NULL, NULL, NULL},
583 {"LargeDisplayFont", DEF_WORKSPACE_NAME_FONT, NULL,
584 NULL, getFont, setLargeDisplayFont, NULL, NULL},
585 {"HighlightColor", "white", NULL,
586 NULL, getColor, setHightlight, NULL, NULL},
587 {"HighlightTextColor", "black", NULL,
588 NULL, getColor, setHightlightText, NULL, NULL},
589 {"ClipTitleColor", "black", (void *)CLIP_NORMAL,
590 NULL, getColor, setClipTitleColor, NULL, NULL},
591 {"CClipTitleColor", "\"rgb:61/61/61\"", (void *)CLIP_COLLAPSED,
592 NULL, getColor, setClipTitleColor, NULL, NULL},
593 {"FTitleColor", "white", (void *)WS_FOCUSED,
594 NULL, getColor, setWTitleColor, NULL, NULL},
595 {"PTitleColor", "white", (void *)WS_PFOCUSED,
596 NULL, getColor, setWTitleColor, NULL, NULL},
597 {"UTitleColor", "black", (void *)WS_UNFOCUSED,
598 NULL, getColor, setWTitleColor, NULL, NULL},
599 {"FTitleBack", "(solid, black)", NULL,
600 NULL, getTexture, setFTitleBack, NULL, NULL},
601 {"PTitleBack", "(solid, gray40)", NULL,
602 NULL, getTexture, setPTitleBack, NULL, NULL},
603 {"UTitleBack", "(solid, \"rgb:aa/aa/aa\")", NULL,
604 NULL, getTexture, setUTitleBack, NULL, NULL},
605 {"ResizebarBack", "(solid, \"rgb:aa/aa/aa\")", NULL,
606 NULL, getTexture, setResizebarBack, NULL, NULL},
607 {"MenuTitleColor", "white", NULL,
608 NULL, getColor, setMenuTitleColor, NULL, NULL},
609 {"MenuTextColor", "black", NULL,
610 NULL, getColor, setMenuTextColor, NULL, NULL},
611 {"MenuDisabledColor", "gray50", NULL,
612 NULL, getColor, setMenuDisabledColor, NULL, NULL},
613 {"MenuTitleBack", "(solid, black)", NULL,
614 NULL, getTexture, setMenuTitleBack, NULL, NULL},
615 {"MenuTextBack", "(solid, \"rgb:aa/aa/aa\")", NULL,
616 NULL, getTexture, setMenuTextBack, NULL, NULL},
617 {"IconTitleColor", "white", NULL,
618 NULL, getColor, setIconTitleColor, NULL, NULL},
619 {"IconTitleBack", "black", NULL,
620 NULL, getColor, setIconTitleBack, NULL, NULL},
621 {"SwitchPanelImages", "(swtile.png, swback.png, 30, 40)", &wPreferences,
622 NULL, getPropList, setSwPOptions, NULL, NULL},
623 {"ModifierKeyLabels", "(\"Shift+\", \"Control+\", \"Mod1+\", \"Mod2+\", \"Mod3+\", \"Mod4+\", \"Mod5+\")", &wPreferences,
624 NULL, getPropList, setModifierKeyLabels, NULL, NULL},
625 {"FrameBorderWidth", "1", NULL,
626 NULL, getInt, setFrameBorderWidth, NULL, NULL},
627 {"FrameBorderColor", "black", NULL,
628 NULL, getColor, setFrameBorderColor, NULL, NULL},
629 {"FrameFocusedBorderColor", "black", NULL,
630 NULL, getColor, setFrameFocusedBorderColor, NULL, NULL},
631 {"FrameSelectedBorderColor", "white", NULL,
632 NULL, getColor, setFrameSelectedBorderColor, NULL, NULL},
633 {"WorkspaceMapBack", "(solid, black)", NULL,
634 NULL, getTexture, setWorkspaceMapBackground, NULL, NULL},
636 /* keybindings */
638 {"RootMenuKey", "F12", (void *)WKBD_ROOTMENU,
639 NULL, getKeybind, setKeyGrab, NULL, NULL},
640 {"WindowListKey", "F11", (void *)WKBD_WINDOWLIST,
641 NULL, getKeybind, setKeyGrab, NULL, NULL},
642 {"WindowMenuKey", "Control+Escape", (void *)WKBD_WINDOWMENU,
643 NULL, getKeybind, setKeyGrab, NULL, NULL},
644 {"DockRaiseLowerKey", "None", (void*)WKBD_DOCKRAISELOWER,
645 NULL, getKeybind, setKeyGrab, NULL, NULL},
646 {"ClipRaiseLowerKey", "None", (void *)WKBD_CLIPRAISELOWER,
647 NULL, getKeybind, setKeyGrab, NULL, NULL},
648 {"MiniaturizeKey", "Mod1+M", (void *)WKBD_MINIATURIZE,
649 NULL, getKeybind, setKeyGrab, NULL, NULL},
650 {"MinimizeAllKey", "None", (void *)WKBD_MINIMIZEALL,
651 NULL, getKeybind, setKeyGrab, NULL, NULL },
652 {"HideKey", "Mod1+H", (void *)WKBD_HIDE,
653 NULL, getKeybind, setKeyGrab, NULL, NULL},
654 {"HideOthersKey", "None", (void *)WKBD_HIDE_OTHERS,
655 NULL, getKeybind, setKeyGrab, NULL, NULL},
656 {"MoveResizeKey", "None", (void *)WKBD_MOVERESIZE,
657 NULL, getKeybind, setKeyGrab, NULL, NULL},
658 {"CloseKey", "None", (void *)WKBD_CLOSE,
659 NULL, getKeybind, setKeyGrab, NULL, NULL},
660 {"MaximizeKey", "None", (void *)WKBD_MAXIMIZE,
661 NULL, getKeybind, setKeyGrab, NULL, NULL},
662 {"VMaximizeKey", "None", (void *)WKBD_VMAXIMIZE,
663 NULL, getKeybind, setKeyGrab, NULL, NULL},
664 {"HMaximizeKey", "None", (void *)WKBD_HMAXIMIZE,
665 NULL, getKeybind, setKeyGrab, NULL, NULL},
666 {"LHMaximizeKey", "None", (void*)WKBD_LHMAXIMIZE,
667 NULL, getKeybind, setKeyGrab, NULL, NULL},
668 {"RHMaximizeKey", "None", (void*)WKBD_RHMAXIMIZE,
669 NULL, getKeybind, setKeyGrab, NULL, NULL},
670 {"THMaximizeKey", "None", (void*)WKBD_THMAXIMIZE,
671 NULL, getKeybind, setKeyGrab, NULL, NULL},
672 {"BHMaximizeKey", "None", (void*)WKBD_BHMAXIMIZE,
673 NULL, getKeybind, setKeyGrab, NULL, NULL},
674 {"TLCMaximizeKey", "None", (void*)WKBD_LTCMAXIMIZE,
675 NULL, getKeybind, setKeyGrab, NULL, NULL},
676 {"TRCMaximizeKey", "None", (void*)WKBD_RTCMAXIMIZE,
677 NULL, getKeybind, setKeyGrab, NULL, NULL},
678 {"BLCMaximizeKey", "None", (void*)WKBD_LBCMAXIMIZE,
679 NULL, getKeybind, setKeyGrab, NULL, NULL},
680 {"BRCMaximizeKey", "None", (void*)WKBD_RBCMAXIMIZE,
681 NULL, getKeybind, setKeyGrab, NULL, NULL},
682 {"MaximusKey", "None", (void*)WKBD_MAXIMUS,
683 NULL, getKeybind, setKeyGrab, NULL, NULL},
684 {"KeepOnTopKey", "None", (void *)WKBD_KEEP_ON_TOP,
685 NULL, getKeybind, setKeyGrab, NULL, NULL},
686 {"KeepAtBottomKey", "None", (void *)WKBD_KEEP_AT_BOTTOM,
687 NULL, getKeybind, setKeyGrab, NULL, NULL},
688 {"OmnipresentKey", "None", (void *)WKBD_OMNIPRESENT,
689 NULL, getKeybind, setKeyGrab, NULL, NULL},
690 {"RaiseKey", "Mod1+Up", (void *)WKBD_RAISE,
691 NULL, getKeybind, setKeyGrab, NULL, NULL},
692 {"LowerKey", "Mod1+Down", (void *)WKBD_LOWER,
693 NULL, getKeybind, setKeyGrab, NULL, NULL},
694 {"RaiseLowerKey", "None", (void *)WKBD_RAISELOWER,
695 NULL, getKeybind, setKeyGrab, NULL, NULL},
696 {"ShadeKey", "None", (void *)WKBD_SHADE,
697 NULL, getKeybind, setKeyGrab, NULL, NULL},
698 {"SelectKey", "None", (void *)WKBD_SELECT,
699 NULL, getKeybind, setKeyGrab, NULL, NULL},
700 {"WorkspaceMapKey", "None", (void *)WKBD_WORKSPACEMAP,
701 NULL, getKeybind, setKeyGrab, NULL, NULL},
702 {"FocusNextKey", "Mod1+Tab", (void *)WKBD_FOCUSNEXT,
703 NULL, getKeybind, setKeyGrab, NULL, NULL},
704 {"FocusPrevKey", "Mod1+Shift+Tab", (void *)WKBD_FOCUSPREV,
705 NULL, getKeybind, setKeyGrab, NULL, NULL},
706 {"GroupNextKey", "None", (void *)WKBD_GROUPNEXT,
707 NULL, getKeybind, setKeyGrab, NULL, NULL},
708 {"GroupPrevKey", "None", (void *)WKBD_GROUPPREV,
709 NULL, getKeybind, setKeyGrab, NULL, NULL},
710 {"NextWorkspaceKey", "Mod1+Control+Right", (void *)WKBD_NEXTWORKSPACE,
711 NULL, getKeybind, setKeyGrab, NULL, NULL},
712 {"PrevWorkspaceKey", "Mod1+Control+Left", (void *)WKBD_PREVWORKSPACE,
713 NULL, getKeybind, setKeyGrab, NULL, NULL},
714 {"LastWorkspaceKey", "None", (void *)WKBD_LASTWORKSPACE,
715 NULL, getKeybind, setKeyGrab, NULL, NULL},
716 {"NextWorkspaceLayerKey", "None", (void *)WKBD_NEXTWSLAYER,
717 NULL, getKeybind, setKeyGrab, NULL, NULL},
718 {"PrevWorkspaceLayerKey", "None", (void *)WKBD_PREVWSLAYER,
719 NULL, getKeybind, setKeyGrab, NULL, NULL},
720 {"Workspace1Key", "Mod1+1", (void *)WKBD_WORKSPACE1,
721 NULL, getKeybind, setKeyGrab, NULL, NULL},
722 {"Workspace2Key", "Mod1+2", (void *)WKBD_WORKSPACE2,
723 NULL, getKeybind, setKeyGrab, NULL, NULL},
724 {"Workspace3Key", "Mod1+3", (void *)WKBD_WORKSPACE3,
725 NULL, getKeybind, setKeyGrab, NULL, NULL},
726 {"Workspace4Key", "Mod1+4", (void *)WKBD_WORKSPACE4,
727 NULL, getKeybind, setKeyGrab, NULL, NULL},
728 {"Workspace5Key", "Mod1+5", (void *)WKBD_WORKSPACE5,
729 NULL, getKeybind, setKeyGrab, NULL, NULL},
730 {"Workspace6Key", "Mod1+6", (void *)WKBD_WORKSPACE6,
731 NULL, getKeybind, setKeyGrab, NULL, NULL},
732 {"Workspace7Key", "Mod1+7", (void *)WKBD_WORKSPACE7,
733 NULL, getKeybind, setKeyGrab, NULL, NULL},
734 {"Workspace8Key", "Mod1+8", (void *)WKBD_WORKSPACE8,
735 NULL, getKeybind, setKeyGrab, NULL, NULL},
736 {"Workspace9Key", "Mod1+9", (void *)WKBD_WORKSPACE9,
737 NULL, getKeybind, setKeyGrab, NULL, NULL},
738 {"Workspace10Key", "Mod1+0", (void *)WKBD_WORKSPACE10,
739 NULL, getKeybind, setKeyGrab, NULL, NULL},
740 {"MoveToWorkspace1Key", "None", (void *)WKBD_MOVE_WORKSPACE1,
741 NULL, getKeybind, setKeyGrab, NULL, NULL},
742 {"MoveToWorkspace2Key", "None", (void *)WKBD_MOVE_WORKSPACE2,
743 NULL, getKeybind, setKeyGrab, NULL, NULL},
744 {"MoveToWorkspace3Key", "None", (void *)WKBD_MOVE_WORKSPACE3,
745 NULL, getKeybind, setKeyGrab, NULL, NULL},
746 {"MoveToWorkspace4Key", "None", (void *)WKBD_MOVE_WORKSPACE4,
747 NULL, getKeybind, setKeyGrab, NULL, NULL},
748 {"MoveToWorkspace5Key", "None", (void *)WKBD_MOVE_WORKSPACE5,
749 NULL, getKeybind, setKeyGrab, NULL, NULL},
750 {"MoveToWorkspace6Key", "None", (void *)WKBD_MOVE_WORKSPACE6,
751 NULL, getKeybind, setKeyGrab, NULL, NULL},
752 {"MoveToWorkspace7Key", "None", (void *)WKBD_MOVE_WORKSPACE7,
753 NULL, getKeybind, setKeyGrab, NULL, NULL},
754 {"MoveToWorkspace8Key", "None", (void *)WKBD_MOVE_WORKSPACE8,
755 NULL, getKeybind, setKeyGrab, NULL, NULL},
756 {"MoveToWorkspace9Key", "None", (void *)WKBD_MOVE_WORKSPACE9,
757 NULL, getKeybind, setKeyGrab, NULL, NULL},
758 {"MoveToWorkspace10Key", "None", (void *)WKBD_MOVE_WORKSPACE10,
759 NULL, getKeybind, setKeyGrab, NULL, NULL},
760 {"MoveToNextWorkspaceKey", "None", (void *)WKBD_MOVE_NEXTWORKSPACE,
761 NULL, getKeybind, setKeyGrab, NULL, NULL},
762 {"MoveToPrevWorkspaceKey", "None", (void *)WKBD_MOVE_PREVWORKSPACE,
763 NULL, getKeybind, setKeyGrab, NULL, NULL},
764 {"MoveToLastWorkspaceKey", "None", (void *)WKBD_MOVE_LASTWORKSPACE,
765 NULL, getKeybind, setKeyGrab, NULL, NULL},
766 {"MoveToNextWorkspaceLayerKey", "None", (void *)WKBD_MOVE_NEXTWSLAYER,
767 NULL, getKeybind, setKeyGrab, NULL, NULL},
768 {"MoveToPrevWorkspaceLayerKey", "None", (void *)WKBD_MOVE_PREVWSLAYER,
769 NULL, getKeybind, setKeyGrab, NULL, NULL},
770 {"WindowShortcut1Key", "None", (void *)WKBD_WINDOW1,
771 NULL, getKeybind, setKeyGrab, NULL, NULL},
772 {"WindowShortcut2Key", "None", (void *)WKBD_WINDOW2,
773 NULL, getKeybind, setKeyGrab, NULL, NULL},
774 {"WindowShortcut3Key", "None", (void *)WKBD_WINDOW3,
775 NULL, getKeybind, setKeyGrab, NULL, NULL},
776 {"WindowShortcut4Key", "None", (void *)WKBD_WINDOW4,
777 NULL, getKeybind, setKeyGrab, NULL, NULL},
778 {"WindowShortcut5Key", "None", (void *)WKBD_WINDOW5,
779 NULL, getKeybind, setKeyGrab, NULL, NULL},
780 {"WindowShortcut6Key", "None", (void *)WKBD_WINDOW6,
781 NULL, getKeybind, setKeyGrab, NULL, NULL},
782 {"WindowShortcut7Key", "None", (void *)WKBD_WINDOW7,
783 NULL, getKeybind, setKeyGrab, NULL, NULL},
784 {"WindowShortcut8Key", "None", (void *)WKBD_WINDOW8,
785 NULL, getKeybind, setKeyGrab, NULL, NULL},
786 {"WindowShortcut9Key", "None", (void *)WKBD_WINDOW9,
787 NULL, getKeybind, setKeyGrab, NULL, NULL},
788 {"WindowShortcut10Key", "None", (void *)WKBD_WINDOW10,
789 NULL, getKeybind, setKeyGrab, NULL, NULL},
790 {"MoveTo12to6Head", "None", (void *)WKBD_MOVE_12_TO_6_HEAD,
791 NULL, getKeybind, setKeyGrab, NULL, NULL},
792 {"MoveTo6to12Head", "None", (void *)WKBD_MOVE_6_TO_12_HEAD,
793 NULL, getKeybind, setKeyGrab, NULL, NULL},
794 {"WindowRelaunchKey", "None", (void *)WKBD_RELAUNCH,
795 NULL, getKeybind, setKeyGrab, NULL, NULL},
796 {"ScreenSwitchKey", "None", (void *)WKBD_SWITCH_SCREEN,
797 NULL, getKeybind, setKeyGrab, NULL, NULL},
798 {"RunKey", "None", (void *)WKBD_RUN,
799 NULL, getKeybind, setKeyGrab, NULL, NULL},
800 {"ExitKey", "None", (void *)WKBD_EXIT,
801 NULL, getKeybind, setKeyGrab, NULL, NULL},
802 {"ScreenCaptureKey", "None", (void *)WKBD_PRINTS,
803 NULL, getKeybind, setKeyGrab, NULL, NULL},
804 {"WindowCaptureKey", "None", (void *)WKBD_PRINTW,
805 NULL, getKeybind, setKeyGrab, NULL, NULL},
806 {"PartialCaptureKey", "None", (void *)WKBD_PRINTP,
807 NULL, getKeybind, setKeyGrab, NULL, NULL},
809 #ifdef KEEP_XKB_LOCK_STATUS
810 {"ToggleKbdModeKey", "None", (void *)WKBD_TOGGLE,
811 NULL, getKeybind, setKeyGrab, NULL, NULL},
812 {"KbdModeLock", "NO", NULL,
813 &wPreferences.modelock, getBool, NULL, NULL, NULL},
814 #endif /* KEEP_XKB_LOCK_STATUS */
816 {"NormalCursor", "(builtin, left_ptr)", (void *)WCUR_ROOT,
817 NULL, getCursor, setCursor, NULL, NULL},
818 {"ArrowCursor", "(builtin, top_left_arrow)", (void *)WCUR_ARROW,
819 NULL, getCursor, setCursor, NULL, NULL},
820 {"MoveCursor", "(builtin, fleur)", (void *)WCUR_MOVE,
821 NULL, getCursor, setCursor, NULL, NULL},
822 {"ResizeCursor", "(builtin, sizing)", (void *)WCUR_RESIZE,
823 NULL, getCursor, setCursor, NULL, NULL},
824 {"TopLeftResizeCursor", "(builtin, top_left_corner)", (void *)WCUR_TOPLEFTRESIZE,
825 NULL, getCursor, setCursor, NULL, NULL},
826 {"TopRightResizeCursor", "(builtin, top_right_corner)", (void *)WCUR_TOPRIGHTRESIZE,
827 NULL, getCursor, setCursor, NULL, NULL},
828 {"BottomLeftResizeCursor", "(builtin, bottom_left_corner)", (void *)WCUR_BOTTOMLEFTRESIZE,
829 NULL, getCursor, setCursor, NULL, NULL},
830 {"BottomRightResizeCursor", "(builtin, bottom_right_corner)", (void *)WCUR_BOTTOMRIGHTRESIZE,
831 NULL, getCursor, setCursor, NULL, NULL},
832 {"VerticalResizeCursor", "(builtin, sb_v_double_arrow)", (void *)WCUR_VERTICALRESIZE,
833 NULL, getCursor, setCursor, NULL, NULL},
834 {"HorizontalResizeCursor", "(builtin, sb_h_double_arrow)", (void *)WCUR_HORIZONRESIZE,
835 NULL, getCursor, setCursor, NULL, NULL},
836 {"WaitCursor", "(builtin, watch)", (void *)WCUR_WAIT,
837 NULL, getCursor, setCursor, NULL, NULL},
838 {"QuestionCursor", "(builtin, question_arrow)", (void *)WCUR_QUESTION,
839 NULL, getCursor, setCursor, NULL, NULL},
840 {"TextCursor", "(builtin, xterm)", (void *)WCUR_TEXT,
841 NULL, getCursor, setCursor, NULL, NULL},
842 {"SelectCursor", "(builtin, cross)", (void *)WCUR_SELECT,
843 NULL, getCursor, setCursor, NULL, NULL},
844 {"CaptureCursor", "(builtin, crosshair)", (void *)WCUR_CAPTURE,
845 NULL, getCursor, setCursor, NULL, NULL},
846 {"DialogHistoryLines", "500", NULL,
847 &wPreferences.history_lines, getInt, NULL, NULL, NULL},
848 {"CycleActiveHeadOnly", "NO", NULL,
849 &wPreferences.cycle_active_head_only, getBool, NULL, NULL, NULL},
850 {"CycleIgnoreMinimized", "NO", NULL,
851 &wPreferences.cycle_ignore_minimized, getBool, NULL, NULL, NULL},
852 {"DbClickFullScreen", "NO", NULL,
853 &wPreferences.double_click_fullscreen, getBool, NULL, NULL, NULL},
854 {"CloseRootMenuByLeftOrRightMouseClick", "NO", NULL,
855 &wPreferences.close_rootmenu_left_right_click, getBool, NULL, NULL, NULL}
858 static void initDefaults(void)
860 unsigned int i;
861 WDefaultEntry *entry;
863 WMPLSetCaseSensitive(False);
865 for (i = 0; i < wlengthof(optionList); i++) {
866 entry = &optionList[i];
868 entry->plkey = WMCreatePLString(entry->key);
869 if (entry->default_value)
870 entry->plvalue = WMCreatePropListFromDescription(entry->default_value);
871 else
872 entry->plvalue = NULL;
875 for (i = 0; i < wlengthof(staticOptionList); i++) {
876 entry = &staticOptionList[i];
878 entry->plkey = WMCreatePLString(entry->key);
879 if (entry->default_value)
880 entry->plvalue = WMCreatePropListFromDescription(entry->default_value);
881 else
882 entry->plvalue = NULL;
886 static WMPropList *readGlobalDomain(const char *domainName, Bool requireDictionary)
888 WMPropList *globalDict = NULL;
889 char path[PATH_MAX];
890 struct stat stbuf;
892 snprintf(path, sizeof(path), "%s/%s", PKGCONFDIR, domainName);
893 if (stat(path, &stbuf) >= 0) {
894 globalDict = WMReadPropListFromFile(path);
895 if (globalDict && requireDictionary && !WMIsPLDictionary(globalDict)) {
896 wwarning(_("Domain %s (%s) of global defaults database is corrupted!"), domainName, path);
897 WMReleasePropList(globalDict);
898 globalDict = NULL;
899 } else if (!globalDict) {
900 wwarning(_("could not load domain %s from global defaults database"), domainName);
904 return globalDict;
907 #if defined(GLOBAL_PREAMBLE_MENU_FILE) || defined(GLOBAL_EPILOGUE_MENU_FILE)
908 static void prependMenu(WMPropList * destarr, WMPropList * array)
910 WMPropList *item;
911 int i;
913 for (i = 0; i < WMGetPropListItemCount(array); i++) {
914 item = WMGetFromPLArray(array, i);
915 if (item)
916 WMInsertInPLArray(destarr, i + 1, item);
920 static void appendMenu(WMPropList * destarr, WMPropList * array)
922 WMPropList *item;
923 int i;
925 for (i = 0; i < WMGetPropListItemCount(array); i++) {
926 item = WMGetFromPLArray(array, i);
927 if (item)
928 WMAddToPLArray(destarr, item);
931 #endif
933 void wDefaultsMergeGlobalMenus(WDDomain * menuDomain)
935 WMPropList *menu = menuDomain->dictionary;
936 WMPropList *submenu;
938 if (!menu || !WMIsPLArray(menu))
939 return;
941 #ifdef GLOBAL_PREAMBLE_MENU_FILE
942 submenu = WMReadPropListFromFile(PKGCONFDIR "/" GLOBAL_PREAMBLE_MENU_FILE);
944 if (submenu && !WMIsPLArray(submenu)) {
945 wwarning(_("invalid global menu file %s"), GLOBAL_PREAMBLE_MENU_FILE);
946 WMReleasePropList(submenu);
947 submenu = NULL;
949 if (submenu) {
950 prependMenu(menu, submenu);
951 WMReleasePropList(submenu);
953 #endif
955 #ifdef GLOBAL_EPILOGUE_MENU_FILE
956 submenu = WMReadPropListFromFile(PKGCONFDIR "/" GLOBAL_EPILOGUE_MENU_FILE);
958 if (submenu && !WMIsPLArray(submenu)) {
959 wwarning(_("invalid global menu file %s"), GLOBAL_EPILOGUE_MENU_FILE);
960 WMReleasePropList(submenu);
961 submenu = NULL;
963 if (submenu) {
964 appendMenu(menu, submenu);
965 WMReleasePropList(submenu);
967 #endif
969 menuDomain->dictionary = menu;
972 WDDomain *wDefaultsInitDomain(const char *domain, Bool requireDictionary)
974 WDDomain *db;
975 struct stat stbuf;
976 static int inited = 0;
977 WMPropList *shared_dict = NULL;
979 if (!inited) {
980 inited = 1;
981 initDefaults();
984 db = wmalloc(sizeof(WDDomain));
985 db->domain_name = domain;
986 db->path = wdefaultspathfordomain(domain);
988 if (stat(db->path, &stbuf) >= 0) {
989 db->dictionary = WMReadPropListFromFile(db->path);
990 if (db->dictionary) {
991 if (requireDictionary && !WMIsPLDictionary(db->dictionary)) {
992 WMReleasePropList(db->dictionary);
993 db->dictionary = NULL;
994 wwarning(_("Domain %s (%s) of defaults database is corrupted!"), domain, db->path);
996 db->timestamp = stbuf.st_mtime;
997 } else {
998 wwarning(_("could not load domain %s from user defaults database"), domain);
1002 /* global system dictionary */
1003 shared_dict = readGlobalDomain(domain, requireDictionary);
1005 if (shared_dict && db->dictionary && WMIsPLDictionary(shared_dict) &&
1006 WMIsPLDictionary(db->dictionary)) {
1007 WMMergePLDictionaries(shared_dict, db->dictionary, True);
1008 WMReleasePropList(db->dictionary);
1009 db->dictionary = shared_dict;
1010 if (stbuf.st_mtime > db->timestamp)
1011 db->timestamp = stbuf.st_mtime;
1012 } else if (!db->dictionary) {
1013 db->dictionary = shared_dict;
1014 if (stbuf.st_mtime > db->timestamp)
1015 db->timestamp = stbuf.st_mtime;
1018 return db;
1021 void wReadStaticDefaults(WMPropList * dict)
1023 WMPropList *plvalue;
1024 WDefaultEntry *entry;
1025 unsigned int i;
1026 void *tdata;
1028 for (i = 0; i < wlengthof(staticOptionList); i++) {
1029 entry = &staticOptionList[i];
1031 if (dict)
1032 plvalue = WMGetFromPLDictionary(dict, entry->plkey);
1033 else
1034 plvalue = NULL;
1036 /* no default in the DB. Use builtin default */
1037 if (!plvalue)
1038 plvalue = entry->plvalue;
1040 if (plvalue) {
1041 /* convert data */
1042 (*entry->convert) (NULL, entry, plvalue, entry->addr, &tdata);
1043 if (entry->update)
1044 (*entry->update) (NULL, entry, tdata, entry->extra_data);
1049 void wDefaultsCheckDomains(void* arg)
1051 WScreen *scr;
1052 struct stat stbuf;
1053 WMPropList *shared_dict = NULL;
1054 WMPropList *dict;
1055 int i;
1057 /* Parameter not used, but tell the compiler that it is ok */
1058 (void) arg;
1060 if (stat(w_global.domain.wmaker->path, &stbuf) >= 0 && w_global.domain.wmaker->timestamp < stbuf.st_mtime) {
1061 w_global.domain.wmaker->timestamp = stbuf.st_mtime;
1063 /* Global dictionary */
1064 shared_dict = readGlobalDomain("WindowMaker", True);
1066 /* User dictionary */
1067 dict = WMReadPropListFromFile(w_global.domain.wmaker->path);
1069 if (dict) {
1070 if (!WMIsPLDictionary(dict)) {
1071 WMReleasePropList(dict);
1072 dict = NULL;
1073 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
1074 "WindowMaker", w_global.domain.wmaker->path);
1075 } else {
1076 if (shared_dict) {
1077 WMMergePLDictionaries(shared_dict, dict, True);
1078 WMReleasePropList(dict);
1079 dict = shared_dict;
1080 shared_dict = NULL;
1083 for (i = 0; i < w_global.screen_count; i++) {
1084 scr = wScreenWithNumber(i);
1085 if (scr)
1086 wReadDefaults(scr, dict);
1089 if (w_global.domain.wmaker->dictionary)
1090 WMReleasePropList(w_global.domain.wmaker->dictionary);
1092 w_global.domain.wmaker->dictionary = dict;
1094 } else {
1095 wwarning(_("could not load domain %s from user defaults database"), "WindowMaker");
1098 if (shared_dict)
1099 WMReleasePropList(shared_dict);
1103 if (stat(w_global.domain.window_attr->path, &stbuf) >= 0 && w_global.domain.window_attr->timestamp < stbuf.st_mtime) {
1104 /* global dictionary */
1105 shared_dict = readGlobalDomain("WMWindowAttributes", True);
1106 /* user dictionary */
1107 dict = WMReadPropListFromFile(w_global.domain.window_attr->path);
1108 if (dict) {
1109 if (!WMIsPLDictionary(dict)) {
1110 WMReleasePropList(dict);
1111 dict = NULL;
1112 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
1113 "WMWindowAttributes", w_global.domain.window_attr->path);
1114 } else {
1115 if (shared_dict) {
1116 WMMergePLDictionaries(shared_dict, dict, True);
1117 WMReleasePropList(dict);
1118 dict = shared_dict;
1119 shared_dict = NULL;
1122 if (w_global.domain.window_attr->dictionary)
1123 WMReleasePropList(w_global.domain.window_attr->dictionary);
1125 w_global.domain.window_attr->dictionary = dict;
1126 for (i = 0; i < w_global.screen_count; i++) {
1127 scr = wScreenWithNumber(i);
1128 if (scr) {
1129 wDefaultUpdateIcons(scr);
1131 /* Update the panel image if changed */
1132 /* Don't worry. If the image is the same these
1133 * functions will have no performance impact. */
1134 create_logo_image(scr);
1138 } else {
1139 wwarning(_("could not load domain %s from user defaults database"), "WMWindowAttributes");
1142 w_global.domain.window_attr->timestamp = stbuf.st_mtime;
1143 if (shared_dict)
1144 WMReleasePropList(shared_dict);
1147 if (stat(w_global.domain.root_menu->path, &stbuf) >= 0 && w_global.domain.root_menu->timestamp < stbuf.st_mtime) {
1148 dict = WMReadPropListFromFile(w_global.domain.root_menu->path);
1149 if (dict) {
1150 if (!WMIsPLArray(dict) && !WMIsPLString(dict)) {
1151 WMReleasePropList(dict);
1152 dict = NULL;
1153 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
1154 "WMRootMenu", w_global.domain.root_menu->path);
1155 } else {
1156 if (w_global.domain.root_menu->dictionary)
1157 WMReleasePropList(w_global.domain.root_menu->dictionary);
1159 w_global.domain.root_menu->dictionary = dict;
1160 wDefaultsMergeGlobalMenus(w_global.domain.root_menu);
1162 } else {
1163 wwarning(_("could not load domain %s from user defaults database"), "WMRootMenu");
1165 w_global.domain.root_menu->timestamp = stbuf.st_mtime;
1167 #ifndef HAVE_INOTIFY
1168 if (!arg)
1169 WMAddTimerHandler(DEFAULTS_CHECK_INTERVAL, wDefaultsCheckDomains, arg);
1170 #endif
1173 void wReadDefaults(WScreen * scr, WMPropList * new_dict)
1175 WMPropList *plvalue, *old_value;
1176 WDefaultEntry *entry;
1177 unsigned int i;
1178 int update_workspace_back = 0; /* kluge :/ */
1179 unsigned int needs_refresh;
1180 void *tdata;
1181 WMPropList *old_dict = (w_global.domain.wmaker->dictionary != new_dict ? w_global.domain.wmaker->dictionary : NULL);
1183 needs_refresh = 0;
1185 for (i = 0; i < wlengthof(optionList); i++) {
1186 entry = &optionList[i];
1188 if (new_dict)
1189 plvalue = WMGetFromPLDictionary(new_dict, entry->plkey);
1190 else
1191 plvalue = NULL;
1193 if (!old_dict)
1194 old_value = NULL;
1195 else
1196 old_value = WMGetFromPLDictionary(old_dict, entry->plkey);
1198 if (!plvalue && !old_value) {
1199 /* no default in the DB. Use builtin default */
1200 plvalue = entry->plvalue;
1201 if (plvalue && new_dict)
1202 WMPutInPLDictionary(new_dict, entry->plkey, plvalue);
1204 } else if (!plvalue) {
1205 /* value was deleted from DB. Keep current value */
1206 continue;
1207 } else if (!old_value) {
1208 /* set value for the 1st time */
1209 } else if (!WMIsPropListEqualTo(plvalue, old_value)) {
1210 /* value has changed */
1211 } else {
1212 if (strcmp(entry->key, "WorkspaceBack") == 0
1213 && update_workspace_back && scr->flags.backimage_helper_launched) {
1214 } else {
1215 /* value was not changed since last time */
1216 continue;
1220 if (plvalue) {
1221 /* convert data */
1222 if ((*entry->convert) (scr, entry, plvalue, entry->addr, &tdata)) {
1224 * If the WorkspaceSpecificBack data has been changed
1225 * so that the helper will be launched now, we must be
1226 * sure to send the default background texture config
1227 * to the helper.
1229 if (strcmp(entry->key, "WorkspaceSpecificBack") == 0 &&
1230 !scr->flags.backimage_helper_launched)
1231 update_workspace_back = 1;
1233 if (entry->update)
1234 needs_refresh |= (*entry->update) (scr, entry, tdata, entry->extra_data);
1240 if (needs_refresh != 0 && !scr->flags.startup) {
1241 int foo;
1243 foo = 0;
1244 if (needs_refresh & REFRESH_MENU_TITLE_TEXTURE)
1245 foo |= WTextureSettings;
1246 if (needs_refresh & REFRESH_MENU_TITLE_FONT)
1247 foo |= WFontSettings;
1248 if (needs_refresh & REFRESH_MENU_TITLE_COLOR)
1249 foo |= WColorSettings;
1250 if (foo)
1251 WMPostNotificationName(WNMenuTitleAppearanceSettingsChanged, NULL,
1252 (void *)(uintptr_t) foo);
1254 foo = 0;
1255 if (needs_refresh & REFRESH_MENU_TEXTURE)
1256 foo |= WTextureSettings;
1257 if (needs_refresh & REFRESH_MENU_FONT)
1258 foo |= WFontSettings;
1259 if (needs_refresh & REFRESH_MENU_COLOR)
1260 foo |= WColorSettings;
1261 if (foo)
1262 WMPostNotificationName(WNMenuAppearanceSettingsChanged, NULL, (void *)(uintptr_t) foo);
1264 foo = 0;
1265 if (needs_refresh & REFRESH_WINDOW_FONT)
1266 foo |= WFontSettings;
1267 if (needs_refresh & REFRESH_WINDOW_TEXTURES)
1268 foo |= WTextureSettings;
1269 if (needs_refresh & REFRESH_WINDOW_TITLE_COLOR)
1270 foo |= WColorSettings;
1271 if (foo)
1272 WMPostNotificationName(WNWindowAppearanceSettingsChanged, NULL, (void *)(uintptr_t) foo);
1274 if (!(needs_refresh & REFRESH_ICON_TILE)) {
1275 foo = 0;
1276 if (needs_refresh & REFRESH_ICON_FONT)
1277 foo |= WFontSettings;
1278 if (needs_refresh & REFRESH_ICON_TITLE_COLOR)
1279 foo |= WTextureSettings;
1280 if (needs_refresh & REFRESH_ICON_TITLE_BACK)
1281 foo |= WTextureSettings;
1282 if (foo)
1283 WMPostNotificationName(WNIconAppearanceSettingsChanged, NULL,
1284 (void *)(uintptr_t) foo);
1286 if (needs_refresh & REFRESH_ICON_TILE)
1287 WMPostNotificationName(WNIconTileSettingsChanged, NULL, NULL);
1289 if (needs_refresh & REFRESH_WORKSPACE_MENU) {
1290 if (scr->workspace_menu)
1291 wWorkspaceMenuUpdate(scr, scr->workspace_menu);
1292 if (scr->clip_ws_menu)
1293 wWorkspaceMenuUpdate(scr, scr->clip_ws_menu);
1294 if (scr->workspace_submenu)
1295 scr->workspace_submenu->flags.realized = 0;
1296 if (scr->clip_submenu)
1297 scr->clip_submenu->flags.realized = 0;
1302 void wDefaultUpdateIcons(WScreen *scr)
1304 WAppIcon *aicon = scr->app_icon_list;
1305 WDrawerChain *dc;
1306 WWindow *wwin = scr->focused_window;
1308 while (aicon) {
1309 /* Get the application icon, default included */
1310 wIconChangeImageFile(aicon->icon, NULL);
1311 wAppIconPaint(aicon);
1312 aicon = aicon->next;
1315 if (!wPreferences.flags.noclip || wPreferences.flags.clip_merged_in_dock)
1316 wClipIconPaint(scr->clip_icon);
1318 for (dc = scr->drawers; dc != NULL; dc = dc->next)
1319 wDrawerIconPaint(dc->adrawer->icon_array[0]);
1321 while (wwin) {
1322 if (wwin->icon && wwin->flags.miniaturized)
1323 wIconChangeImageFile(wwin->icon, NULL);
1324 wwin = wwin->prev;
1328 /* --------------------------- Local ----------------------- */
1330 #define GET_STRING_OR_DEFAULT(x, var) if (!WMIsPLString(value)) { \
1331 wwarning(_("Wrong option format for key \"%s\". Should be %s."), \
1332 entry->key, x); \
1333 wwarning(_("using default \"%s\" instead"), entry->default_value); \
1334 var = entry->default_value;\
1335 } else var = WMGetFromPLString(value)\
1338 static int string2index(WMPropList *key, WMPropList *val, const char *def, WOptionEnumeration * values)
1340 char *str;
1341 WOptionEnumeration *v;
1342 char buffer[TOTAL_VALUES_LENGTH];
1344 if (WMIsPLString(val) && (str = WMGetFromPLString(val))) {
1345 for (v = values; v->string != NULL; v++) {
1346 if (strcasecmp(v->string, str) == 0)
1347 return v->value;
1351 buffer[0] = 0;
1352 for (v = values; v->string != NULL; v++) {
1353 if (!v->is_alias) {
1354 if (buffer[0] != 0)
1355 strcat(buffer, ", ");
1356 snprintf(buffer+strlen(buffer),
1357 sizeof(buffer)-strlen(buffer)-1, "\"%s\"", v->string);
1360 wwarning(_("wrong option value for key \"%s\"; got \"%s\", should be one of %s."),
1361 WMGetFromPLString(key),
1362 WMIsPLString(val) ? WMGetFromPLString(val) : "(unknown)",
1363 buffer);
1365 if (def) {
1366 return string2index(key, val, NULL, values);
1369 return -1;
1373 * value - is the value in the defaults DB
1374 * addr - is the address to store the data
1375 * ret - is the address to store a pointer to a temporary buffer. ret
1376 * must not be freed and is used by the set functions
1378 static int getBool(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1380 static char data;
1381 const char *val;
1382 int second_pass = 0;
1384 /* Parameter not used, but tell the compiler that it is ok */
1385 (void) scr;
1387 GET_STRING_OR_DEFAULT("Boolean", val);
1389 again:
1390 if ((val[1] == '\0' && (val[0] == 'y' || val[0] == 'Y'))
1391 || strcasecmp(val, "YES") == 0) {
1393 data = 1;
1394 } else if ((val[1] == '\0' && (val[0] == 'n' || val[0] == 'N'))
1395 || strcasecmp(val, "NO") == 0) {
1396 data = 0;
1397 } else {
1398 int i;
1399 if (sscanf(val, "%i", &i) == 1) {
1400 if (i != 0)
1401 data = 1;
1402 else
1403 data = 0;
1404 } else {
1405 wwarning(_("can't convert \"%s\" to boolean for key \"%s\""), val, entry->key);
1406 if (second_pass == 0) {
1407 val = WMGetFromPLString(entry->plvalue);
1408 second_pass = 1;
1409 wwarning(_("using default \"%s\" instead"), val);
1410 goto again;
1412 return False;
1416 if (ret)
1417 *ret = &data;
1418 if (addr)
1419 *(char *)addr = data;
1421 return True;
1424 static int getInt(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1426 static int data;
1427 const char *val;
1429 /* Parameter not used, but tell the compiler that it is ok */
1430 (void) scr;
1432 GET_STRING_OR_DEFAULT("Integer", val);
1434 if (sscanf(val, "%i", &data) != 1) {
1435 wwarning(_("can't convert \"%s\" to integer for key \"%s\""), val, entry->key);
1436 val = WMGetFromPLString(entry->plvalue);
1437 wwarning(_("using default \"%s\" instead"), val);
1438 if (sscanf(val, "%i", &data) != 1) {
1439 return False;
1443 if (ret)
1444 *ret = &data;
1445 if (addr)
1446 *(int *)addr = data;
1448 return True;
1451 static int getCoord(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1453 static WCoord data;
1454 char *val_x, *val_y;
1455 int nelem, changed = 0;
1456 WMPropList *elem_x, *elem_y;
1458 again:
1459 if (!WMIsPLArray(value)) {
1460 wwarning(_("Wrong option format for key \"%s\". Should be %s."), entry->key, "Coordinate");
1461 if (changed == 0) {
1462 value = entry->plvalue;
1463 changed = 1;
1464 wwarning(_("using default \"%s\" instead"), entry->default_value);
1465 goto again;
1467 return False;
1470 nelem = WMGetPropListItemCount(value);
1471 if (nelem != 2) {
1472 wwarning(_("Incorrect number of elements in array for key \"%s\"."), entry->key);
1473 if (changed == 0) {
1474 value = entry->plvalue;
1475 changed = 1;
1476 wwarning(_("using default \"%s\" instead"), entry->default_value);
1477 goto again;
1479 return False;
1482 elem_x = WMGetFromPLArray(value, 0);
1483 elem_y = WMGetFromPLArray(value, 1);
1485 if (!elem_x || !elem_y || !WMIsPLString(elem_x) || !WMIsPLString(elem_y)) {
1486 wwarning(_("Wrong value for key \"%s\". Should be Coordinate."), entry->key);
1487 if (changed == 0) {
1488 value = entry->plvalue;
1489 changed = 1;
1490 wwarning(_("using default \"%s\" instead"), entry->default_value);
1491 goto again;
1493 return False;
1496 val_x = WMGetFromPLString(elem_x);
1497 val_y = WMGetFromPLString(elem_y);
1499 if (sscanf(val_x, "%i", &data.x) != 1 || sscanf(val_y, "%i", &data.y) != 1) {
1500 wwarning(_("can't convert array to integers for \"%s\"."), entry->key);
1501 if (changed == 0) {
1502 value = entry->plvalue;
1503 changed = 1;
1504 wwarning(_("using default \"%s\" instead"), entry->default_value);
1505 goto again;
1507 return False;
1510 if (data.x < 0)
1511 data.x = 0;
1512 else if (data.x > scr->scr_width / 3)
1513 data.x = scr->scr_width / 3;
1514 if (data.y < 0)
1515 data.y = 0;
1516 else if (data.y > scr->scr_height / 3)
1517 data.y = scr->scr_height / 3;
1519 if (ret)
1520 *ret = &data;
1521 if (addr)
1522 *(WCoord *) addr = data;
1524 return True;
1527 static int getPropList(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1529 /* Parameter not used, but tell the compiler that it is ok */
1530 (void) scr;
1531 (void) entry;
1532 (void) addr;
1534 WMRetainPropList(value);
1536 *ret = value;
1538 return True;
1541 static int getPathList(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1543 static char *data;
1544 int i, count, len;
1545 char *ptr;
1546 WMPropList *d;
1547 int changed = 0;
1549 /* Parameter not used, but tell the compiler that it is ok */
1550 (void) scr;
1551 (void) ret;
1553 again:
1554 if (!WMIsPLArray(value)) {
1555 wwarning(_("Wrong option format for key \"%s\". Should be %s."), entry->key, "an array of paths");
1556 if (changed == 0) {
1557 value = entry->plvalue;
1558 changed = 1;
1559 wwarning(_("using default \"%s\" instead"), entry->default_value);
1560 goto again;
1562 return False;
1565 i = 0;
1566 count = WMGetPropListItemCount(value);
1567 if (count < 1) {
1568 if (changed == 0) {
1569 value = entry->plvalue;
1570 changed = 1;
1571 wwarning(_("using default \"%s\" instead"), entry->default_value);
1572 goto again;
1574 return False;
1577 len = 0;
1578 for (i = 0; i < count; i++) {
1579 d = WMGetFromPLArray(value, i);
1580 if (!d || !WMIsPLString(d)) {
1581 count = i;
1582 break;
1584 len += strlen(WMGetFromPLString(d)) + 1;
1587 ptr = data = wmalloc(len + 1);
1589 for (i = 0; i < count; i++) {
1590 d = WMGetFromPLArray(value, i);
1591 if (!d || !WMIsPLString(d)) {
1592 break;
1594 strcpy(ptr, WMGetFromPLString(d));
1595 ptr += strlen(WMGetFromPLString(d));
1596 *ptr = ':';
1597 ptr++;
1599 ptr--;
1600 *(ptr--) = 0;
1602 if (*(char **)addr != NULL) {
1603 wfree(*(char **)addr);
1605 *(char **)addr = data;
1607 return True;
1610 static int getEnum(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1612 static signed char data;
1614 /* Parameter not used, but tell the compiler that it is ok */
1615 (void) scr;
1617 data = string2index(entry->plkey, value, entry->default_value, (WOptionEnumeration *) entry->extra_data);
1618 if (data < 0)
1619 return False;
1621 if (ret)
1622 *ret = &data;
1623 if (addr)
1624 *(signed char *)addr = data;
1626 return True;
1630 * (solid <color>)
1631 * (hgradient <color> <color>)
1632 * (vgradient <color> <color>)
1633 * (dgradient <color> <color>)
1634 * (mhgradient <color> <color> ...)
1635 * (mvgradient <color> <color> ...)
1636 * (mdgradient <color> <color> ...)
1637 * (igradient <color1> <color1> <thickness1> <color2> <color2> <thickness2>)
1638 * (tpixmap <file> <color>)
1639 * (spixmap <file> <color>)
1640 * (cpixmap <file> <color>)
1641 * (thgradient <file> <opaqueness> <color> <color>)
1642 * (tvgradient <file> <opaqueness> <color> <color>)
1643 * (tdgradient <file> <opaqueness> <color> <color>)
1644 * (function <lib> <function> ...)
1647 static WTexture *parse_texture(WScreen * scr, WMPropList * pl)
1649 WMPropList *elem;
1650 char *val;
1651 int nelem;
1652 WTexture *texture = NULL;
1654 nelem = WMGetPropListItemCount(pl);
1655 if (nelem < 1)
1656 return NULL;
1658 elem = WMGetFromPLArray(pl, 0);
1659 if (!elem || !WMIsPLString(elem))
1660 return NULL;
1661 val = WMGetFromPLString(elem);
1663 if (strcasecmp(val, "solid") == 0) {
1664 XColor color;
1666 if (nelem != 2)
1667 return NULL;
1669 /* get color */
1671 elem = WMGetFromPLArray(pl, 1);
1672 if (!elem || !WMIsPLString(elem))
1673 return NULL;
1674 val = WMGetFromPLString(elem);
1676 if (!XParseColor(dpy, scr->w_colormap, val, &color)) {
1677 wwarning(_("\"%s\" is not a valid color name"), val);
1678 return NULL;
1681 texture = (WTexture *) wTextureMakeSolid(scr, &color);
1682 } else if (strcasecmp(val, "dgradient") == 0
1683 || strcasecmp(val, "vgradient") == 0 || strcasecmp(val, "hgradient") == 0) {
1684 RColor color1, color2;
1685 XColor xcolor;
1686 int type;
1688 if (nelem != 3) {
1689 wwarning(_("bad number of arguments in gradient specification"));
1690 return NULL;
1693 if (val[0] == 'd' || val[0] == 'D')
1694 type = WTEX_DGRADIENT;
1695 else if (val[0] == 'h' || val[0] == 'H')
1696 type = WTEX_HGRADIENT;
1697 else
1698 type = WTEX_VGRADIENT;
1700 /* get from color */
1701 elem = WMGetFromPLArray(pl, 1);
1702 if (!elem || !WMIsPLString(elem))
1703 return NULL;
1704 val = WMGetFromPLString(elem);
1706 if (!XParseColor(dpy, scr->w_colormap, val, &xcolor)) {
1707 wwarning(_("\"%s\" is not a valid color name"), val);
1708 return NULL;
1710 color1.alpha = 255;
1711 color1.red = xcolor.red >> 8;
1712 color1.green = xcolor.green >> 8;
1713 color1.blue = xcolor.blue >> 8;
1715 /* get to color */
1716 elem = WMGetFromPLArray(pl, 2);
1717 if (!elem || !WMIsPLString(elem)) {
1718 return NULL;
1720 val = WMGetFromPLString(elem);
1722 if (!XParseColor(dpy, scr->w_colormap, val, &xcolor)) {
1723 wwarning(_("\"%s\" is not a valid color name"), val);
1724 return NULL;
1726 color2.alpha = 255;
1727 color2.red = xcolor.red >> 8;
1728 color2.green = xcolor.green >> 8;
1729 color2.blue = xcolor.blue >> 8;
1731 texture = (WTexture *) wTextureMakeGradient(scr, type, &color1, &color2);
1733 } else if (strcasecmp(val, "igradient") == 0) {
1734 RColor colors1[2], colors2[2];
1735 int th1, th2;
1736 XColor xcolor;
1737 int i;
1739 if (nelem != 7) {
1740 wwarning(_("bad number of arguments in gradient specification"));
1741 return NULL;
1744 /* get from color */
1745 for (i = 0; i < 2; i++) {
1746 elem = WMGetFromPLArray(pl, 1 + i);
1747 if (!elem || !WMIsPLString(elem))
1748 return NULL;
1749 val = WMGetFromPLString(elem);
1751 if (!XParseColor(dpy, scr->w_colormap, val, &xcolor)) {
1752 wwarning(_("\"%s\" is not a valid color name"), val);
1753 return NULL;
1755 colors1[i].alpha = 255;
1756 colors1[i].red = xcolor.red >> 8;
1757 colors1[i].green = xcolor.green >> 8;
1758 colors1[i].blue = xcolor.blue >> 8;
1760 elem = WMGetFromPLArray(pl, 3);
1761 if (!elem || !WMIsPLString(elem))
1762 return NULL;
1763 val = WMGetFromPLString(elem);
1764 th1 = atoi(val);
1766 /* get from color */
1767 for (i = 0; i < 2; i++) {
1768 elem = WMGetFromPLArray(pl, 4 + i);
1769 if (!elem || !WMIsPLString(elem))
1770 return NULL;
1771 val = WMGetFromPLString(elem);
1773 if (!XParseColor(dpy, scr->w_colormap, val, &xcolor)) {
1774 wwarning(_("\"%s\" is not a valid color name"), val);
1775 return NULL;
1777 colors2[i].alpha = 255;
1778 colors2[i].red = xcolor.red >> 8;
1779 colors2[i].green = xcolor.green >> 8;
1780 colors2[i].blue = xcolor.blue >> 8;
1782 elem = WMGetFromPLArray(pl, 6);
1783 if (!elem || !WMIsPLString(elem))
1784 return NULL;
1785 val = WMGetFromPLString(elem);
1786 th2 = atoi(val);
1788 texture = (WTexture *) wTextureMakeIGradient(scr, th1, colors1, th2, colors2);
1790 } else if (strcasecmp(val, "mhgradient") == 0
1791 || strcasecmp(val, "mvgradient") == 0 || strcasecmp(val, "mdgradient") == 0) {
1792 XColor color;
1793 RColor **colors;
1794 int i, count;
1795 int type;
1797 if (nelem < 3) {
1798 wwarning(_("too few arguments in multicolor gradient specification"));
1799 return NULL;
1802 if (val[1] == 'h' || val[1] == 'H')
1803 type = WTEX_MHGRADIENT;
1804 else if (val[1] == 'v' || val[1] == 'V')
1805 type = WTEX_MVGRADIENT;
1806 else
1807 type = WTEX_MDGRADIENT;
1809 count = nelem - 1;
1811 colors = wmalloc(sizeof(RColor *) * (count + 1));
1813 for (i = 0; i < count; i++) {
1814 elem = WMGetFromPLArray(pl, i + 1);
1815 if (!elem || !WMIsPLString(elem)) {
1816 for (--i; i >= 0; --i) {
1817 wfree(colors[i]);
1819 wfree(colors);
1820 return NULL;
1822 val = WMGetFromPLString(elem);
1824 if (!XParseColor(dpy, scr->w_colormap, val, &color)) {
1825 wwarning(_("\"%s\" is not a valid color name"), val);
1826 for (--i; i >= 0; --i) {
1827 wfree(colors[i]);
1829 wfree(colors);
1830 return NULL;
1831 } else {
1832 colors[i] = wmalloc(sizeof(RColor));
1833 colors[i]->red = color.red >> 8;
1834 colors[i]->green = color.green >> 8;
1835 colors[i]->blue = color.blue >> 8;
1838 colors[i] = NULL;
1840 texture = (WTexture *) wTextureMakeMGradient(scr, type, colors);
1841 } else if (strcasecmp(val, "spixmap") == 0 ||
1842 strcasecmp(val, "cpixmap") == 0 || strcasecmp(val, "tpixmap") == 0) {
1843 XColor color;
1844 int type;
1846 if (nelem != 3)
1847 return NULL;
1849 if (val[0] == 's' || val[0] == 'S')
1850 type = WTP_SCALE;
1851 else if (val[0] == 'c' || val[0] == 'C')
1852 type = WTP_CENTER;
1853 else
1854 type = WTP_TILE;
1856 /* get color */
1857 elem = WMGetFromPLArray(pl, 2);
1858 if (!elem || !WMIsPLString(elem)) {
1859 return NULL;
1861 val = WMGetFromPLString(elem);
1863 if (!XParseColor(dpy, scr->w_colormap, val, &color)) {
1864 wwarning(_("\"%s\" is not a valid color name"), val);
1865 return NULL;
1868 /* file name */
1869 elem = WMGetFromPLArray(pl, 1);
1870 if (!elem || !WMIsPLString(elem))
1871 return NULL;
1872 val = WMGetFromPLString(elem);
1874 texture = (WTexture *) wTextureMakePixmap(scr, type, val, &color);
1875 } else if (strcasecmp(val, "thgradient") == 0
1876 || strcasecmp(val, "tvgradient") == 0 || strcasecmp(val, "tdgradient") == 0) {
1877 RColor color1, color2;
1878 XColor xcolor;
1879 int opacity;
1880 int style;
1882 if (val[1] == 'h' || val[1] == 'H')
1883 style = WTEX_THGRADIENT;
1884 else if (val[1] == 'v' || val[1] == 'V')
1885 style = WTEX_TVGRADIENT;
1886 else
1887 style = WTEX_TDGRADIENT;
1889 if (nelem != 5) {
1890 wwarning(_("bad number of arguments in textured gradient specification"));
1891 return NULL;
1894 /* get from color */
1895 elem = WMGetFromPLArray(pl, 3);
1896 if (!elem || !WMIsPLString(elem))
1897 return NULL;
1898 val = WMGetFromPLString(elem);
1900 if (!XParseColor(dpy, scr->w_colormap, val, &xcolor)) {
1901 wwarning(_("\"%s\" is not a valid color name"), val);
1902 return NULL;
1904 color1.alpha = 255;
1905 color1.red = xcolor.red >> 8;
1906 color1.green = xcolor.green >> 8;
1907 color1.blue = xcolor.blue >> 8;
1909 /* get to color */
1910 elem = WMGetFromPLArray(pl, 4);
1911 if (!elem || !WMIsPLString(elem)) {
1912 return NULL;
1914 val = WMGetFromPLString(elem);
1916 if (!XParseColor(dpy, scr->w_colormap, val, &xcolor)) {
1917 wwarning(_("\"%s\" is not a valid color name"), val);
1918 return NULL;
1920 color2.alpha = 255;
1921 color2.red = xcolor.red >> 8;
1922 color2.green = xcolor.green >> 8;
1923 color2.blue = xcolor.blue >> 8;
1925 /* get opacity */
1926 elem = WMGetFromPLArray(pl, 2);
1927 if (!elem || !WMIsPLString(elem))
1928 opacity = 128;
1929 else
1930 val = WMGetFromPLString(elem);
1932 if (!val || (opacity = atoi(val)) < 0 || opacity > 255) {
1933 wwarning(_("bad opacity value for tgradient texture \"%s\". Should be [0..255]"), val);
1934 opacity = 128;
1937 /* get file name */
1938 elem = WMGetFromPLArray(pl, 1);
1939 if (!elem || !WMIsPLString(elem))
1940 return NULL;
1941 val = WMGetFromPLString(elem);
1943 texture = (WTexture *) wTextureMakeTGradient(scr, style, &color1, &color2, val, opacity);
1944 } else if (strcasecmp(val, "function") == 0) {
1945 /* Leave this in to handle the unlikely case of
1946 * someone actually having function textures configured */
1947 wwarning("function texture support has been removed");
1948 return NULL;
1949 } else {
1950 wwarning(_("invalid texture type %s"), val);
1951 return NULL;
1953 return texture;
1956 static int getTexture(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1958 static WTexture *texture;
1959 int changed = 0;
1961 again:
1962 if (!WMIsPLArray(value)) {
1963 wwarning(_("Wrong option format for key \"%s\". Should be %s."), entry->key, "Texture");
1964 if (changed == 0) {
1965 value = entry->plvalue;
1966 changed = 1;
1967 wwarning(_("using default \"%s\" instead"), entry->default_value);
1968 goto again;
1970 return False;
1973 if (strcmp(entry->key, "WidgetColor") == 0 && !changed) {
1974 WMPropList *pl;
1976 pl = WMGetFromPLArray(value, 0);
1977 if (!pl || !WMIsPLString(pl) || !WMGetFromPLString(pl)
1978 || strcasecmp(WMGetFromPLString(pl), "solid") != 0) {
1979 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1980 entry->key, "Solid Texture");
1982 value = entry->plvalue;
1983 changed = 1;
1984 wwarning(_("using default \"%s\" instead"), entry->default_value);
1985 goto again;
1989 texture = parse_texture(scr, value);
1991 if (!texture) {
1992 wwarning(_("Error in texture specification for key \"%s\""), entry->key);
1993 if (changed == 0) {
1994 value = entry->plvalue;
1995 changed = 1;
1996 wwarning(_("using default \"%s\" instead"), entry->default_value);
1997 goto again;
1999 return False;
2002 if (ret)
2003 *ret = &texture;
2005 if (addr)
2006 *(WTexture **) addr = texture;
2008 return True;
2011 static int getWSBackground(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
2013 WMPropList *elem;
2014 int changed = 0;
2015 char *val;
2016 int nelem;
2018 /* Parameter not used, but tell the compiler that it is ok */
2019 (void) scr;
2020 (void) addr;
2022 again:
2023 if (!WMIsPLArray(value)) {
2024 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
2025 "WorkspaceBack", "Texture or None");
2026 if (changed == 0) {
2027 value = entry->plvalue;
2028 changed = 1;
2029 wwarning(_("using default \"%s\" instead"), entry->default_value);
2030 goto again;
2032 return False;
2035 /* only do basic error checking and verify for None texture */
2037 nelem = WMGetPropListItemCount(value);
2038 if (nelem > 0) {
2039 elem = WMGetFromPLArray(value, 0);
2040 if (!elem || !WMIsPLString(elem)) {
2041 wwarning(_("Wrong type for workspace background. Should be a texture type."));
2042 if (changed == 0) {
2043 value = entry->plvalue;
2044 changed = 1;
2045 wwarning(_("using default \"%s\" instead"), entry->default_value);
2046 goto again;
2048 return False;
2050 val = WMGetFromPLString(elem);
2052 if (strcasecmp(val, "None") == 0)
2053 return True;
2055 *ret = WMRetainPropList(value);
2057 return True;
2060 static int
2061 getWSSpecificBackground(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
2063 WMPropList *elem;
2064 int nelem;
2065 int changed = 0;
2067 /* Parameter not used, but tell the compiler that it is ok */
2068 (void) scr;
2069 (void) addr;
2071 again:
2072 if (!WMIsPLArray(value)) {
2073 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
2074 "WorkspaceSpecificBack", "an array of textures");
2075 if (changed == 0) {
2076 value = entry->plvalue;
2077 changed = 1;
2078 wwarning(_("using default \"%s\" instead"), entry->default_value);
2079 goto again;
2081 return False;
2084 /* only do basic error checking and verify for None texture */
2086 nelem = WMGetPropListItemCount(value);
2087 if (nelem > 0) {
2088 while (nelem--) {
2089 elem = WMGetFromPLArray(value, nelem);
2090 if (!elem || !WMIsPLArray(elem)) {
2091 wwarning(_("Wrong type for background of workspace %i. Should be a texture."),
2092 nelem);
2097 *ret = WMRetainPropList(value);
2099 #ifdef notworking
2101 * Kluge to force wmsetbg helper to set the default background.
2102 * If the WorkspaceSpecificBack is changed once wmaker has started,
2103 * the WorkspaceBack won't be sent to the helper, unless the user
2104 * changes its value too. So, we must force this by removing the
2105 * value from the defaults DB.
2107 if (!scr->flags.backimage_helper_launched && !scr->flags.startup) {
2108 WMPropList *key = WMCreatePLString("WorkspaceBack");
2110 WMRemoveFromPLDictionary(w_global.domain.wmaker->dictionary, key);
2112 WMReleasePropList(key);
2114 #endif
2115 return True;
2118 static int getFont(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
2120 static WMFont *font;
2121 const char *val;
2123 (void) addr;
2125 GET_STRING_OR_DEFAULT("Font", val);
2127 font = WMCreateFont(scr->wmscreen, val);
2128 if (!font)
2129 font = WMCreateFont(scr->wmscreen, "fixed");
2131 if (!font) {
2132 wfatal(_("could not load any usable font!!!"));
2133 exit(1);
2136 if (ret)
2137 *ret = font;
2139 /* can't assign font value outside update function */
2140 wassertrv(addr == NULL, True);
2142 return True;
2145 static int getColor(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
2147 static XColor color;
2148 const char *val;
2149 int second_pass = 0;
2151 (void) addr;
2153 GET_STRING_OR_DEFAULT("Color", val);
2155 again:
2156 if (!wGetColor(scr, val, &color)) {
2157 wwarning(_("could not get color for key \"%s\""), entry->key);
2158 if (second_pass == 0) {
2159 val = WMGetFromPLString(entry->plvalue);
2160 second_pass = 1;
2161 wwarning(_("using default \"%s\" instead"), val);
2162 goto again;
2164 return False;
2167 if (ret)
2168 *ret = &color;
2170 assert(addr == NULL);
2172 if (addr)
2173 *(unsigned long*)addr = pixel;
2176 return True;
2179 static int getKeybind(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
2181 static WShortKey shortcut;
2182 KeySym ksym;
2183 const char *val;
2184 char *k;
2185 char buf[MAX_SHORTCUT_LENGTH], *b;
2187 /* Parameter not used, but tell the compiler that it is ok */
2188 (void) scr;
2189 (void) addr;
2191 GET_STRING_OR_DEFAULT("Key spec", val);
2193 if (!val || strcasecmp(val, "NONE") == 0) {
2194 shortcut.keycode = 0;
2195 shortcut.modifier = 0;
2196 if (ret)
2197 *ret = &shortcut;
2198 return True;
2201 wstrlcpy(buf, val, MAX_SHORTCUT_LENGTH);
2203 b = (char *)buf;
2205 /* get modifiers */
2206 shortcut.modifier = 0;
2207 while ((k = strchr(b, '+')) != NULL) {
2208 int mod;
2210 *k = 0;
2211 mod = wXModifierFromKey(b);
2212 if (mod < 0) {
2213 wwarning(_("%s: invalid key modifier \"%s\""), entry->key, b);
2214 return False;
2216 shortcut.modifier |= mod;
2218 b = k + 1;
2221 /* get key */
2222 ksym = XStringToKeysym(b);
2224 if (ksym == NoSymbol) {
2225 wwarning(_("%s:invalid kbd shortcut specification \"%s\""), entry->key, val);
2226 return False;
2229 shortcut.keycode = XKeysymToKeycode(dpy, ksym);
2230 if (shortcut.keycode == 0) {
2231 wwarning(_("%s:invalid key in shortcut \"%s\""), entry->key, val);
2232 return False;
2235 if (ret)
2236 *ret = &shortcut;
2238 return True;
2241 static int getModMask(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
2243 static int mask;
2244 const char *str;
2246 /* Parameter not used, but tell the compiler that it is ok */
2247 (void) scr;
2249 GET_STRING_OR_DEFAULT("Modifier Key", str);
2251 if (!str)
2252 return False;
2254 mask = wXModifierFromKey(str);
2255 if (mask < 0) {
2256 wwarning(_("%s: modifier key %s is not valid"), entry->key, str);
2257 mask = 0;
2258 return False;
2261 if (addr)
2262 *(int *)addr = mask;
2264 if (ret)
2265 *ret = &mask;
2267 return True;
2270 # include <X11/cursorfont.h>
2271 typedef struct {
2272 const char *name;
2273 int id;
2274 } WCursorLookup;
2276 #define CURSOR_ID_NONE (XC_num_glyphs)
2278 static const WCursorLookup cursor_table[] = {
2279 {"X_cursor", XC_X_cursor},
2280 {"arrow", XC_arrow},
2281 {"based_arrow_down", XC_based_arrow_down},
2282 {"based_arrow_up", XC_based_arrow_up},
2283 {"boat", XC_boat},
2284 {"bogosity", XC_bogosity},
2285 {"bottom_left_corner", XC_bottom_left_corner},
2286 {"bottom_right_corner", XC_bottom_right_corner},
2287 {"bottom_side", XC_bottom_side},
2288 {"bottom_tee", XC_bottom_tee},
2289 {"box_spiral", XC_box_spiral},
2290 {"center_ptr", XC_center_ptr},
2291 {"circle", XC_circle},
2292 {"clock", XC_clock},
2293 {"coffee_mug", XC_coffee_mug},
2294 {"cross", XC_cross},
2295 {"cross_reverse", XC_cross_reverse},
2296 {"crosshair", XC_crosshair},
2297 {"diamond_cross", XC_diamond_cross},
2298 {"dot", XC_dot},
2299 {"dotbox", XC_dotbox},
2300 {"double_arrow", XC_double_arrow},
2301 {"draft_large", XC_draft_large},
2302 {"draft_small", XC_draft_small},
2303 {"draped_box", XC_draped_box},
2304 {"exchange", XC_exchange},
2305 {"fleur", XC_fleur},
2306 {"gobbler", XC_gobbler},
2307 {"gumby", XC_gumby},
2308 {"hand1", XC_hand1},
2309 {"hand2", XC_hand2},
2310 {"heart", XC_heart},
2311 {"icon", XC_icon},
2312 {"iron_cross", XC_iron_cross},
2313 {"left_ptr", XC_left_ptr},
2314 {"left_side", XC_left_side},
2315 {"left_tee", XC_left_tee},
2316 {"leftbutton", XC_leftbutton},
2317 {"ll_angle", XC_ll_angle},
2318 {"lr_angle", XC_lr_angle},
2319 {"man", XC_man},
2320 {"middlebutton", XC_middlebutton},
2321 {"mouse", XC_mouse},
2322 {"pencil", XC_pencil},
2323 {"pirate", XC_pirate},
2324 {"plus", XC_plus},
2325 {"question_arrow", XC_question_arrow},
2326 {"right_ptr", XC_right_ptr},
2327 {"right_side", XC_right_side},
2328 {"right_tee", XC_right_tee},
2329 {"rightbutton", XC_rightbutton},
2330 {"rtl_logo", XC_rtl_logo},
2331 {"sailboat", XC_sailboat},
2332 {"sb_down_arrow", XC_sb_down_arrow},
2333 {"sb_h_double_arrow", XC_sb_h_double_arrow},
2334 {"sb_left_arrow", XC_sb_left_arrow},
2335 {"sb_right_arrow", XC_sb_right_arrow},
2336 {"sb_up_arrow", XC_sb_up_arrow},
2337 {"sb_v_double_arrow", XC_sb_v_double_arrow},
2338 {"shuttle", XC_shuttle},
2339 {"sizing", XC_sizing},
2340 {"spider", XC_spider},
2341 {"spraycan", XC_spraycan},
2342 {"star", XC_star},
2343 {"target", XC_target},
2344 {"tcross", XC_tcross},
2345 {"top_left_arrow", XC_top_left_arrow},
2346 {"top_left_corner", XC_top_left_corner},
2347 {"top_right_corner", XC_top_right_corner},
2348 {"top_side", XC_top_side},
2349 {"top_tee", XC_top_tee},
2350 {"trek", XC_trek},
2351 {"ul_angle", XC_ul_angle},
2352 {"umbrella", XC_umbrella},
2353 {"ur_angle", XC_ur_angle},
2354 {"watch", XC_watch},
2355 {"xterm", XC_xterm},
2356 {NULL, CURSOR_ID_NONE}
2359 static void check_bitmap_status(int status, const char *filename, Pixmap bitmap)
2361 switch (status) {
2362 case BitmapOpenFailed:
2363 wwarning(_("failed to open bitmap file \"%s\""), filename);
2364 break;
2365 case BitmapFileInvalid:
2366 wwarning(_("\"%s\" is not a valid bitmap file"), filename);
2367 break;
2368 case BitmapNoMemory:
2369 wwarning(_("out of memory reading bitmap file \"%s\""), filename);
2370 break;
2371 case BitmapSuccess:
2372 XFreePixmap(dpy, bitmap);
2373 break;
2378 * (none)
2379 * (builtin, <cursor_name>)
2380 * (bitmap, <cursor_bitmap>, <cursor_mask>)
2382 static int parse_cursor(WScreen * scr, WMPropList * pl, Cursor * cursor)
2384 WMPropList *elem;
2385 char *val;
2386 int nelem;
2387 int status = 0;
2389 nelem = WMGetPropListItemCount(pl);
2390 if (nelem < 1) {
2391 return (status);
2393 elem = WMGetFromPLArray(pl, 0);
2394 if (!elem || !WMIsPLString(elem)) {
2395 return (status);
2397 val = WMGetFromPLString(elem);
2399 if (strcasecmp(val, "none") == 0) {
2400 status = 1;
2401 *cursor = None;
2402 } else if (strcasecmp(val, "builtin") == 0) {
2403 int i;
2404 int cursor_id = CURSOR_ID_NONE;
2406 if (nelem != 2) {
2407 wwarning(_("bad number of arguments in cursor specification"));
2408 return (status);
2410 elem = WMGetFromPLArray(pl, 1);
2411 if (!elem || !WMIsPLString(elem)) {
2412 return (status);
2414 val = WMGetFromPLString(elem);
2416 for (i = 0; cursor_table[i].name != NULL; i++) {
2417 if (strcasecmp(val, cursor_table[i].name) == 0) {
2418 cursor_id = cursor_table[i].id;
2419 break;
2422 if (CURSOR_ID_NONE == cursor_id) {
2423 wwarning(_("unknown builtin cursor name \"%s\""), val);
2424 } else {
2425 *cursor = XCreateFontCursor(dpy, cursor_id);
2426 status = 1;
2428 } else if (strcasecmp(val, "bitmap") == 0) {
2429 char *bitmap_name;
2430 char *mask_name;
2431 int bitmap_status;
2432 int mask_status;
2433 Pixmap bitmap;
2434 Pixmap mask;
2435 unsigned int w, h;
2436 int x, y;
2437 XColor fg, bg;
2439 if (nelem != 3) {
2440 wwarning(_("bad number of arguments in cursor specification"));
2441 return (status);
2443 elem = WMGetFromPLArray(pl, 1);
2444 if (!elem || !WMIsPLString(elem)) {
2445 return (status);
2447 val = WMGetFromPLString(elem);
2448 bitmap_name = FindImage(wPreferences.pixmap_path, val);
2449 if (!bitmap_name) {
2450 wwarning(_("could not find cursor bitmap file \"%s\""), val);
2451 return (status);
2453 elem = WMGetFromPLArray(pl, 2);
2454 if (!elem || !WMIsPLString(elem)) {
2455 wfree(bitmap_name);
2456 return (status);
2458 val = WMGetFromPLString(elem);
2459 mask_name = FindImage(wPreferences.pixmap_path, val);
2460 if (!mask_name) {
2461 wfree(bitmap_name);
2462 wwarning(_("could not find cursor bitmap file \"%s\""), val);
2463 return (status);
2465 mask_status = XReadBitmapFile(dpy, scr->w_win, mask_name, &w, &h, &mask, &x, &y);
2466 bitmap_status = XReadBitmapFile(dpy, scr->w_win, bitmap_name, &w, &h, &bitmap, &x, &y);
2467 if ((BitmapSuccess == bitmap_status) && (BitmapSuccess == mask_status)) {
2468 fg.pixel = scr->black_pixel;
2469 bg.pixel = scr->white_pixel;
2470 XQueryColor(dpy, scr->w_colormap, &fg);
2471 XQueryColor(dpy, scr->w_colormap, &bg);
2472 *cursor = XCreatePixmapCursor(dpy, bitmap, mask, &fg, &bg, x, y);
2473 status = 1;
2475 check_bitmap_status(bitmap_status, bitmap_name, bitmap);
2476 check_bitmap_status(mask_status, mask_name, mask);
2477 wfree(bitmap_name);
2478 wfree(mask_name);
2480 return (status);
2483 static int getCursor(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
2485 static Cursor cursor;
2486 int status;
2487 int changed = 0;
2489 again:
2490 if (!WMIsPLArray(value)) {
2491 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
2492 entry->key, "cursor specification");
2493 if (!changed) {
2494 value = entry->plvalue;
2495 changed = 1;
2496 wwarning(_("using default \"%s\" instead"), entry->default_value);
2497 goto again;
2499 return (False);
2501 status = parse_cursor(scr, value, &cursor);
2502 if (!status) {
2503 wwarning(_("Error in cursor specification for key \"%s\""), entry->key);
2504 if (!changed) {
2505 value = entry->plvalue;
2506 changed = 1;
2507 wwarning(_("using default \"%s\" instead"), entry->default_value);
2508 goto again;
2510 return (False);
2512 if (ret) {
2513 *ret = &cursor;
2515 if (addr) {
2516 *(Cursor *) addr = cursor;
2518 return (True);
2521 #undef CURSOR_ID_NONE
2523 /* ---------------- value setting functions --------------- */
2524 static int setJustify(WScreen * scr, WDefaultEntry * entry, void *tdata, void *extra_data)
2526 /* Parameter not used, but tell the compiler that it is ok */
2527 (void) scr;
2528 (void) entry;
2529 (void) tdata;
2530 (void) extra_data;
2532 return REFRESH_WINDOW_TITLE_COLOR;
2535 static int setClearance(WScreen * scr, WDefaultEntry * entry, void *bar, void *foo)
2537 /* Parameter not used, but tell the compiler that it is ok */
2538 (void) scr;
2539 (void) entry;
2540 (void) bar;
2541 (void) foo;
2543 return REFRESH_WINDOW_FONT | REFRESH_BUTTON_IMAGES | REFRESH_MENU_TITLE_FONT | REFRESH_MENU_FONT;
2546 static int setIfDockPresent(WScreen * scr, WDefaultEntry * entry, void *tdata, void *extra_data)
2548 char *flag = tdata;
2549 long which = (long) extra_data;
2551 /* Parameter not used, but tell the compiler that it is ok */
2552 (void) scr;
2553 (void) entry;
2555 switch (which) {
2556 case WM_DOCK:
2557 wPreferences.flags.nodock = wPreferences.flags.nodock || *flag;
2558 // Drawers require the dock
2559 wPreferences.flags.nodrawer = wPreferences.flags.nodrawer || wPreferences.flags.nodock;
2560 break;
2561 case WM_CLIP:
2562 wPreferences.flags.noclip = wPreferences.flags.noclip || *flag;
2563 break;
2564 case WM_DRAWER:
2565 wPreferences.flags.nodrawer = wPreferences.flags.nodrawer || *flag;
2566 break;
2567 default:
2568 break;
2570 return 0;
2573 static int setClipMergedInDock(WScreen *scr, WDefaultEntry *entry, void *tdata, void *foo)
2575 char *flag = tdata;
2577 /* Parameter not used, but tell the compiler that it is ok */
2578 (void) scr;
2579 (void) entry;
2580 (void) foo;
2582 wPreferences.flags.clip_merged_in_dock = *flag;
2583 wPreferences.flags.noclip = wPreferences.flags.noclip || *flag;
2584 return 0;
2587 static int setWrapAppiconsInDock(WScreen *scr, WDefaultEntry *entry, void *tdata, void *foo)
2589 char *flag = tdata;
2591 /* Parameter not used, but tell the compiler that it is ok */
2592 (void) scr;
2593 (void) entry;
2594 (void) foo;
2596 wPreferences.flags.wrap_appicons_in_dock = *flag;
2597 return 0;
2600 static int setStickyIcons(WScreen * scr, WDefaultEntry * entry, void *bar, void *foo)
2602 /* Parameter not used, but tell the compiler that it is ok */
2603 (void) entry;
2604 (void) bar;
2605 (void) foo;
2607 if (scr->workspaces) {
2608 wWorkspaceForceChange(scr, scr->current_workspace);
2609 wArrangeIcons(scr, False);
2611 return 0;
2614 static int setIconTile(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2616 Pixmap pixmap;
2617 RImage *img;
2618 WTexture ** texture = tdata;
2619 int reset = 0;
2621 /* Parameter not used, but tell the compiler that it is ok */
2622 (void) foo;
2624 img = wTextureRenderImage(*texture, wPreferences.icon_size,
2625 wPreferences.icon_size, ((*texture)->any.type & WREL_BORDER_MASK)
2626 ? WREL_ICON : WREL_FLAT);
2627 if (!img) {
2628 wwarning(_("could not render texture for icon background"));
2629 if (!entry->addr)
2630 wTextureDestroy(scr, *texture);
2631 return 0;
2633 RConvertImage(scr->rcontext, img, &pixmap);
2635 if (scr->icon_tile) {
2636 reset = 1;
2637 RReleaseImage(scr->icon_tile);
2638 XFreePixmap(dpy, scr->icon_tile_pixmap);
2641 scr->icon_tile = img;
2643 /* put the icon in the noticeboard hint */
2644 PropSetIconTileHint(scr, img);
2646 if (!wPreferences.flags.noclip || wPreferences.flags.clip_merged_in_dock) {
2647 if (scr->clip_tile) {
2648 RReleaseImage(scr->clip_tile);
2650 scr->clip_tile = wClipMakeTile(img);
2653 if (!wPreferences.flags.nodrawer) {
2654 if (scr->drawer_tile) {
2655 RReleaseImage(scr->drawer_tile);
2657 scr->drawer_tile = wDrawerMakeTile(scr, img);
2660 scr->icon_tile_pixmap = pixmap;
2662 if (scr->def_icon_rimage) {
2663 RReleaseImage(scr->def_icon_rimage);
2664 scr->def_icon_rimage = NULL;
2667 if (scr->icon_back_texture)
2668 wTextureDestroy(scr, (WTexture *) scr->icon_back_texture);
2670 scr->icon_back_texture = wTextureMakeSolid(scr, &((*texture)->any.color));
2672 /* Free the texture as nobody else will use it, nor refer to it. */
2673 if (!entry->addr)
2674 wTextureDestroy(scr, *texture);
2676 return (reset ? REFRESH_ICON_TILE : 0);
2679 static int setWinTitleFont(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2681 WMFont *font = tdata;
2683 /* Parameter not used, but tell the compiler that it is ok */
2684 (void) entry;
2685 (void) foo;
2687 if (scr->title_font) {
2688 WMReleaseFont(scr->title_font);
2690 scr->title_font = font;
2692 return REFRESH_WINDOW_FONT | REFRESH_BUTTON_IMAGES;
2695 static int setMenuTitleFont(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2697 WMFont *font = tdata;
2699 /* Parameter not used, but tell the compiler that it is ok */
2700 (void) entry;
2701 (void) foo;
2703 if (scr->menu_title_font) {
2704 WMReleaseFont(scr->menu_title_font);
2707 scr->menu_title_font = font;
2709 return REFRESH_MENU_TITLE_FONT;
2712 static int setMenuTextFont(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2714 WMFont *font = tdata;
2716 /* Parameter not used, but tell the compiler that it is ok */
2717 (void) entry;
2718 (void) foo;
2720 if (scr->menu_entry_font) {
2721 WMReleaseFont(scr->menu_entry_font);
2723 scr->menu_entry_font = font;
2725 return REFRESH_MENU_FONT;
2728 static int setIconTitleFont(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2730 WMFont *font = tdata;
2732 /* Parameter not used, but tell the compiler that it is ok */
2733 (void) entry;
2734 (void) foo;
2736 if (scr->icon_title_font) {
2737 WMReleaseFont(scr->icon_title_font);
2740 scr->icon_title_font = font;
2742 return REFRESH_ICON_FONT;
2745 static int setClipTitleFont(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2747 WMFont *font = tdata;
2749 /* Parameter not used, but tell the compiler that it is ok */
2750 (void) entry;
2751 (void) foo;
2753 if (scr->clip_title_font) {
2754 WMReleaseFont(scr->clip_title_font);
2757 scr->clip_title_font = font;
2759 return REFRESH_ICON_FONT;
2762 static int setLargeDisplayFont(WScreen *scr, WDefaultEntry *entry, void *tdata, void *foo)
2764 WMFont *font = tdata;
2766 /* Parameter not used, but tell the compiler that it is ok */
2767 (void) scr;
2768 (void) entry;
2769 (void) foo;
2771 if (scr->workspace_name_font)
2772 WMReleaseFont(scr->workspace_name_font);
2774 scr->workspace_name_font = font;
2776 return 0;
2779 static int setHightlight(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2781 XColor *color = tdata;
2783 /* Parameter not used, but tell the compiler that it is ok */
2784 (void) entry;
2785 (void) foo;
2787 if (scr->select_color)
2788 WMReleaseColor(scr->select_color);
2790 scr->select_color = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2792 wFreeColor(scr, color->pixel);
2794 return REFRESH_MENU_COLOR;
2797 static int setHightlightText(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2799 XColor *color = tdata;
2801 /* Parameter not used, but tell the compiler that it is ok */
2802 (void) entry;
2803 (void) foo;
2805 if (scr->select_text_color)
2806 WMReleaseColor(scr->select_text_color);
2808 scr->select_text_color = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2810 wFreeColor(scr, color->pixel);
2812 return REFRESH_MENU_COLOR;
2815 static int setClipTitleColor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *extra_data)
2817 XColor *color = tdata;
2818 long widx = (long) extra_data;
2820 /* Parameter not used, but tell the compiler that it is ok */
2821 (void) entry;
2823 if (scr->clip_title_color[widx])
2824 WMReleaseColor(scr->clip_title_color[widx]);
2826 scr->clip_title_color[widx] = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2827 wFreeColor(scr, color->pixel);
2829 return REFRESH_ICON_TITLE_COLOR;
2832 static int setWTitleColor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *extra_data)
2834 XColor *color = tdata;
2835 long widx = (long) extra_data;
2837 /* Parameter not used, but tell the compiler that it is ok */
2838 (void) entry;
2840 if (scr->window_title_color[widx])
2841 WMReleaseColor(scr->window_title_color[widx]);
2843 scr->window_title_color[widx] =
2844 WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2846 wFreeColor(scr, color->pixel);
2848 return REFRESH_WINDOW_TITLE_COLOR;
2851 static int setMenuTitleColor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *extra_data)
2853 XColor *color = tdata;
2855 /* Parameter not used, but tell the compiler that it is ok */
2856 (void) entry;
2857 (void) extra_data;
2859 if (scr->menu_title_color[0])
2860 WMReleaseColor(scr->menu_title_color[0]);
2862 scr->menu_title_color[0] = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2864 wFreeColor(scr, color->pixel);
2866 return REFRESH_MENU_TITLE_COLOR;
2869 static int setMenuTextColor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2871 XColor *color = tdata;
2873 /* Parameter not used, but tell the compiler that it is ok */
2874 (void) entry;
2875 (void) foo;
2877 if (scr->mtext_color)
2878 WMReleaseColor(scr->mtext_color);
2880 scr->mtext_color = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2882 if (WMColorPixel(scr->dtext_color) == WMColorPixel(scr->mtext_color)) {
2883 WMSetColorAlpha(scr->dtext_color, 0x7fff);
2884 } else {
2885 WMSetColorAlpha(scr->dtext_color, 0xffff);
2888 wFreeColor(scr, color->pixel);
2890 return REFRESH_MENU_COLOR;
2893 static int setMenuDisabledColor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2895 XColor *color = tdata;
2897 /* Parameter not used, but tell the compiler that it is ok */
2898 (void) entry;
2899 (void) foo;
2901 if (scr->dtext_color)
2902 WMReleaseColor(scr->dtext_color);
2904 scr->dtext_color = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2906 if (WMColorPixel(scr->dtext_color) == WMColorPixel(scr->mtext_color)) {
2907 WMSetColorAlpha(scr->dtext_color, 0x7fff);
2908 } else {
2909 WMSetColorAlpha(scr->dtext_color, 0xffff);
2912 wFreeColor(scr, color->pixel);
2914 return REFRESH_MENU_COLOR;
2917 static int setIconTitleColor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2919 XColor *color = tdata;
2921 /* Parameter not used, but tell the compiler that it is ok */
2922 (void) entry;
2923 (void) foo;
2925 if (scr->icon_title_color)
2926 WMReleaseColor(scr->icon_title_color);
2927 scr->icon_title_color = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2929 wFreeColor(scr, color->pixel);
2931 return REFRESH_ICON_TITLE_COLOR;
2934 static int setIconTitleBack(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2936 XColor *color = tdata;
2938 /* Parameter not used, but tell the compiler that it is ok */
2939 (void) entry;
2940 (void) foo;
2942 if (scr->icon_title_texture) {
2943 wTextureDestroy(scr, (WTexture *) scr->icon_title_texture);
2945 scr->icon_title_texture = wTextureMakeSolid(scr, color);
2947 return REFRESH_ICON_TITLE_BACK;
2950 static int setFrameBorderWidth(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2952 int *value = tdata;
2954 /* Parameter not used, but tell the compiler that it is ok */
2955 (void) entry;
2956 (void) foo;
2958 scr->frame_border_width = *value;
2960 return REFRESH_FRAME_BORDER;
2963 static int setFrameBorderColor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2965 XColor *color = tdata;
2967 /* Parameter not used, but tell the compiler that it is ok */
2968 (void) entry;
2969 (void) foo;
2971 if (scr->frame_border_color)
2972 WMReleaseColor(scr->frame_border_color);
2973 scr->frame_border_color = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2975 wFreeColor(scr, color->pixel);
2977 return REFRESH_FRAME_BORDER;
2980 static int setFrameFocusedBorderColor(WScreen *scr, WDefaultEntry *entry, void *tdata, void *foo)
2982 XColor *color = tdata;
2984 /* Parameter not used, but tell the compiler that it is ok */
2985 (void) entry;
2986 (void) foo;
2988 if (scr->frame_focused_border_color)
2989 WMReleaseColor(scr->frame_focused_border_color);
2990 scr->frame_focused_border_color = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2992 wFreeColor(scr, color->pixel);
2994 return REFRESH_FRAME_BORDER;
2997 static int setFrameSelectedBorderColor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2999 XColor *color = tdata;
3001 /* Parameter not used, but tell the compiler that it is ok */
3002 (void) entry;
3003 (void) foo;
3005 if (scr->frame_selected_border_color)
3006 WMReleaseColor(scr->frame_selected_border_color);
3007 scr->frame_selected_border_color = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
3009 wFreeColor(scr, color->pixel);
3011 return REFRESH_FRAME_BORDER;
3014 static int setWorkspaceSpecificBack(WScreen * scr, WDefaultEntry * entry, void *tdata, void *bar)
3016 WMPropList *value = tdata;
3017 WMPropList *val;
3018 char *str;
3019 int i;
3021 /* Parameter not used, but tell the compiler that it is ok */
3022 (void) entry;
3023 (void) bar;
3025 if (scr->flags.backimage_helper_launched) {
3026 if (WMGetPropListItemCount(value) == 0) {
3027 SendHelperMessage(scr, 'C', 0, NULL);
3028 SendHelperMessage(scr, 'K', 0, NULL);
3030 WMReleasePropList(value);
3031 return 0;
3033 } else {
3034 if (WMGetPropListItemCount(value) == 0)
3035 return 0;
3037 if (!start_bg_helper(scr)) {
3038 WMReleasePropList(value);
3039 return 0;
3042 SendHelperMessage(scr, 'P', -1, wPreferences.pixmap_path);
3045 for (i = 0; i < WMGetPropListItemCount(value); i++) {
3046 val = WMGetFromPLArray(value, i);
3047 if (val && WMIsPLArray(val) && WMGetPropListItemCount(val) > 0) {
3048 str = WMGetPropListDescription(val, False);
3050 SendHelperMessage(scr, 'S', i + 1, str);
3052 wfree(str);
3053 } else {
3054 SendHelperMessage(scr, 'U', i + 1, NULL);
3057 sleep(1);
3059 WMReleasePropList(value);
3060 return 0;
3063 static int setWorkspaceBack(WScreen * scr, WDefaultEntry * entry, void *tdata, void *bar)
3065 WMPropList *value = tdata;
3067 /* Parameter not used, but tell the compiler that it is ok */
3068 (void) entry;
3069 (void) bar;
3071 if (scr->flags.backimage_helper_launched) {
3072 char *str;
3074 if (WMGetPropListItemCount(value) == 0) {
3075 SendHelperMessage(scr, 'U', 0, NULL);
3076 } else {
3077 /* set the default workspace background to this one */
3078 str = WMGetPropListDescription(value, False);
3079 if (str) {
3080 SendHelperMessage(scr, 'S', 0, str);
3081 wfree(str);
3082 SendHelperMessage(scr, 'C', scr->current_workspace + 1, NULL);
3083 } else {
3084 SendHelperMessage(scr, 'U', 0, NULL);
3087 } else if (WMGetPropListItemCount(value) > 0) {
3088 char *text;
3089 char *dither;
3090 int len;
3092 text = WMGetPropListDescription(value, False);
3093 len = strlen(text) + 40;
3094 dither = wPreferences.no_dithering ? "-m" : "-d";
3095 if (!strchr(text, '\'') && !strchr(text, '\\')) {
3096 char command[len];
3098 if (wPreferences.smooth_workspace_back)
3099 snprintf(command, len, "wmsetbg %s -S -p '%s' &", dither, text);
3100 else
3101 snprintf(command, len, "wmsetbg %s -p '%s' &", dither, text);
3102 ExecuteShellCommand(scr, command);
3103 } else
3104 wwarning(_("Invalid arguments for background \"%s\""), text);
3105 wfree(text);
3107 WMReleasePropList(value);
3109 return 0;
3112 static int setWidgetColor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
3114 WTexture **texture = tdata;
3116 /* Parameter not used, but tell the compiler that it is ok */
3117 (void) entry;
3118 (void) foo;
3120 if (scr->widget_texture) {
3121 wTextureDestroy(scr, (WTexture *) scr->widget_texture);
3123 scr->widget_texture = *(WTexSolid **) texture;
3125 return 0;
3128 static int setFTitleBack(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
3130 WTexture **texture = tdata;
3132 /* Parameter not used, but tell the compiler that it is ok */
3133 (void) entry;
3134 (void) foo;
3136 if (scr->window_title_texture[WS_FOCUSED]) {
3137 wTextureDestroy(scr, scr->window_title_texture[WS_FOCUSED]);
3139 scr->window_title_texture[WS_FOCUSED] = *texture;
3141 return REFRESH_WINDOW_TEXTURES;
3144 static int setPTitleBack(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
3146 WTexture **texture = tdata;
3148 /* Parameter not used, but tell the compiler that it is ok */
3149 (void) entry;
3150 (void) foo;
3152 if (scr->window_title_texture[WS_PFOCUSED]) {
3153 wTextureDestroy(scr, scr->window_title_texture[WS_PFOCUSED]);
3155 scr->window_title_texture[WS_PFOCUSED] = *texture;
3157 return REFRESH_WINDOW_TEXTURES;
3160 static int setUTitleBack(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
3162 WTexture **texture = tdata;
3164 /* Parameter not used, but tell the compiler that it is ok */
3165 (void) entry;
3166 (void) foo;
3168 if (scr->window_title_texture[WS_UNFOCUSED]) {
3169 wTextureDestroy(scr, scr->window_title_texture[WS_UNFOCUSED]);
3171 scr->window_title_texture[WS_UNFOCUSED] = *texture;
3173 return REFRESH_WINDOW_TEXTURES;
3176 static int setResizebarBack(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
3178 WTexture **texture = tdata;
3180 /* Parameter not used, but tell the compiler that it is ok */
3181 (void) entry;
3182 (void) foo;
3184 if (scr->resizebar_texture[0]) {
3185 wTextureDestroy(scr, scr->resizebar_texture[0]);
3187 scr->resizebar_texture[0] = *texture;
3189 return REFRESH_WINDOW_TEXTURES;
3192 static int setMenuTitleBack(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
3194 WTexture **texture = tdata;
3196 /* Parameter not used, but tell the compiler that it is ok */
3197 (void) entry;
3198 (void) foo;
3200 if (scr->menu_title_texture[0]) {
3201 wTextureDestroy(scr, scr->menu_title_texture[0]);
3203 scr->menu_title_texture[0] = *texture;
3205 return REFRESH_MENU_TITLE_TEXTURE;
3208 static int setMenuTextBack(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
3210 WTexture **texture = tdata;
3212 /* Parameter not used, but tell the compiler that it is ok */
3213 (void) entry;
3214 (void) foo;
3216 if (scr->menu_item_texture) {
3217 wTextureDestroy(scr, scr->menu_item_texture);
3218 wTextureDestroy(scr, (WTexture *) scr->menu_item_auxtexture);
3220 scr->menu_item_texture = *texture;
3222 scr->menu_item_auxtexture = wTextureMakeSolid(scr, &scr->menu_item_texture->any.color);
3224 return REFRESH_MENU_TEXTURE;
3227 static int setKeyGrab(WScreen * scr, WDefaultEntry * entry, void *tdata, void *extra_data)
3229 WShortKey *shortcut = tdata;
3230 WWindow *wwin;
3231 long widx = (long) extra_data;
3233 /* Parameter not used, but tell the compiler that it is ok */
3234 (void) entry;
3236 wKeyBindings[widx] = *shortcut;
3238 wwin = scr->focused_window;
3240 while (wwin != NULL) {
3241 XUngrabKey(dpy, AnyKey, AnyModifier, wwin->frame->core->window);
3243 if (!WFLAGP(wwin, no_bind_keys)) {
3244 wWindowSetKeyGrabs(wwin);
3246 wwin = wwin->prev;
3249 /* do we need to update window menus? */
3250 if (widx >= WKBD_WORKSPACE1 && widx <= WKBD_WORKSPACE10)
3251 return REFRESH_WORKSPACE_MENU;
3252 if (widx == WKBD_LASTWORKSPACE)
3253 return REFRESH_WORKSPACE_MENU;
3254 if (widx >= WKBD_MOVE_WORKSPACE1 && widx <= WKBD_MOVE_WORKSPACE10)
3255 return REFRESH_WORKSPACE_MENU;
3257 return 0;
3260 static int setIconPosition(WScreen * scr, WDefaultEntry * entry, void *bar, void *foo)
3262 /* Parameter not used, but tell the compiler that it is ok */
3263 (void) entry;
3264 (void) bar;
3265 (void) foo;
3267 wScreenUpdateUsableArea(scr);
3268 wArrangeIcons(scr, True);
3270 return 0;
3273 static int updateUsableArea(WScreen * scr, WDefaultEntry * entry, void *bar, void *foo)
3275 /* Parameter not used, but tell the compiler that it is ok */
3276 (void) entry;
3277 (void) bar;
3278 (void) foo;
3280 wScreenUpdateUsableArea(scr);
3282 return 0;
3285 static int setWorkspaceMapBackground(WScreen *scr, WDefaultEntry *entry, void *tdata, void *foo)
3287 WTexture **texture = tdata;
3289 /* Parameter not used, but tell the compiler that it is ok */
3290 (void) entry;
3291 (void) foo;
3293 if (wPreferences.wsmbackTexture)
3294 wTextureDestroy(scr, wPreferences.wsmbackTexture);
3296 wPreferences.wsmbackTexture = *texture;
3298 return REFRESH_WINDOW_TEXTURES;
3301 static int setMenuStyle(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
3303 /* Parameter not used, but tell the compiler that it is ok */
3304 (void) scr;
3305 (void) entry;
3306 (void) tdata;
3307 (void) foo;
3309 return REFRESH_MENU_TEXTURE;
3312 static RImage *chopOffImage(RImage * image, int x, int y, int w, int h)
3314 RImage *img = RCreateImage(w, h, image->format == RRGBAFormat);
3316 RCopyArea(img, image, x, y, w, h, 0, 0);
3318 return img;
3321 static int setSwPOptions(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
3323 WMPropList *array = tdata;
3324 char *path;
3325 RImage *bgimage;
3326 int cwidth, cheight;
3327 struct WPreferences *prefs = foo;
3329 if (!WMIsPLArray(array) || WMGetPropListItemCount(array) == 0) {
3330 if (prefs->swtileImage)
3331 RReleaseImage(prefs->swtileImage);
3332 prefs->swtileImage = NULL;
3334 WMReleasePropList(array);
3335 return 0;
3338 switch (WMGetPropListItemCount(array)) {
3339 case 4:
3340 if (!WMIsPLString(WMGetFromPLArray(array, 1))) {
3341 wwarning(_("Invalid arguments for option \"%s\""), entry->key);
3342 break;
3343 } else
3344 path = FindImage(wPreferences.pixmap_path, WMGetFromPLString(WMGetFromPLArray(array, 1)));
3346 if (!path) {
3347 wwarning(_("Could not find image \"%s\" for option \"%s\""),
3348 WMGetFromPLString(WMGetFromPLArray(array, 1)), entry->key);
3349 } else {
3350 bgimage = RLoadImage(scr->rcontext, path, 0);
3351 if (!bgimage) {
3352 wwarning(_("Could not load image \"%s\" for option \"%s\""), path, entry->key);
3353 wfree(path);
3354 } else {
3355 wfree(path);
3357 cwidth = atoi(WMGetFromPLString(WMGetFromPLArray(array, 2)));
3358 cheight = atoi(WMGetFromPLString(WMGetFromPLArray(array, 3)));
3360 if (cwidth <= 0 || cheight <= 0 ||
3361 cwidth >= bgimage->width - 2 || cheight >= bgimage->height - 2)
3362 wwarning(_("Invalid split sizes for switch panel back image."));
3363 else {
3364 int i;
3365 int swidth, theight;
3366 for (i = 0; i < 9; i++) {
3367 if (prefs->swbackImage[i])
3368 RReleaseImage(prefs->swbackImage[i]);
3369 prefs->swbackImage[i] = NULL;
3371 swidth = (bgimage->width - cwidth) / 2;
3372 theight = (bgimage->height - cheight) / 2;
3374 prefs->swbackImage[0] = chopOffImage(bgimage, 0, 0, swidth, theight);
3375 prefs->swbackImage[1] = chopOffImage(bgimage, swidth, 0, cwidth, theight);
3376 prefs->swbackImage[2] = chopOffImage(bgimage, swidth + cwidth, 0,
3377 swidth, theight);
3379 prefs->swbackImage[3] = chopOffImage(bgimage, 0, theight, swidth, cheight);
3380 prefs->swbackImage[4] = chopOffImage(bgimage, swidth, theight,
3381 cwidth, cheight);
3382 prefs->swbackImage[5] = chopOffImage(bgimage, swidth + cwidth, theight,
3383 swidth, cheight);
3385 prefs->swbackImage[6] = chopOffImage(bgimage, 0, theight + cheight,
3386 swidth, theight);
3387 prefs->swbackImage[7] = chopOffImage(bgimage, swidth, theight + cheight,
3388 cwidth, theight);
3389 prefs->swbackImage[8] =
3390 chopOffImage(bgimage, swidth + cwidth, theight + cheight, swidth,
3391 theight);
3393 // check if anything failed
3394 for (i = 0; i < 9; i++) {
3395 if (!prefs->swbackImage[i]) {
3396 for (; i >= 0; --i) {
3397 RReleaseImage(prefs->swbackImage[i]);
3398 prefs->swbackImage[i] = NULL;
3400 break;
3404 RReleaseImage(bgimage);
3408 /* Fall through. */
3410 case 1:
3411 if (!WMIsPLString(WMGetFromPLArray(array, 0))) {
3412 wwarning(_("Invalid arguments for option \"%s\""), entry->key);
3413 break;
3414 } else
3415 path = FindImage(wPreferences.pixmap_path, WMGetFromPLString(WMGetFromPLArray(array, 0)));
3417 if (!path) {
3418 wwarning(_("Could not find image \"%s\" for option \"%s\""),
3419 WMGetFromPLString(WMGetFromPLArray(array, 0)), entry->key);
3420 } else {
3421 if (prefs->swtileImage)
3422 RReleaseImage(prefs->swtileImage);
3424 prefs->swtileImage = RLoadImage(scr->rcontext, path, 0);
3425 if (!prefs->swtileImage) {
3426 wwarning(_("Could not load image \"%s\" for option \"%s\""), path, entry->key);
3428 wfree(path);
3430 break;
3432 default:
3433 wwarning(_("Invalid number of arguments for option \"%s\""), entry->key);
3434 break;
3437 WMReleasePropList(array);
3439 return 0;
3442 static int setModifierKeyLabels(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
3444 WMPropList *array = tdata;
3445 int i;
3446 struct WPreferences *prefs = foo;
3448 if (!WMIsPLArray(array) || WMGetPropListItemCount(array) != 7) {
3449 wwarning(_("Value for option \"%s\" must be an array of 7 strings"), entry->key);
3450 WMReleasePropList(array);
3451 return 0;
3454 DestroyWindowMenu(scr);
3456 for (i = 0; i < 7; i++) {
3457 if (prefs->modifier_labels[i])
3458 wfree(prefs->modifier_labels[i]);
3460 if (WMIsPLString(WMGetFromPLArray(array, i))) {
3461 prefs->modifier_labels[i] = wstrdup(WMGetFromPLString(WMGetFromPLArray(array, i)));
3462 } else {
3463 wwarning(_("Invalid argument for option \"%s\" item %d"), entry->key, i);
3464 prefs->modifier_labels[i] = NULL;
3468 WMReleasePropList(array);
3470 return 0;
3473 static int setHotCornerActions(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
3475 WMPropList *array = tdata;
3476 int i;
3477 struct WPreferences *prefs = foo;
3479 if (!WMIsPLArray(array) || WMGetPropListItemCount(array) != 4) {
3480 wwarning(_("Value for option \"%s\" must be an array of 4 strings"), entry->key);
3481 WMReleasePropList(array);
3482 return 0;
3485 DestroyWindowMenu(scr);
3487 for (i = 0; i < 4; i++) {
3488 if (prefs->hot_corner_actions[i])
3489 wfree(prefs->hot_corner_actions[i]);
3491 if (WMIsPLString(WMGetFromPLArray(array, i))) {
3492 const char *val;
3493 val = WMGetFromPLString(WMGetFromPLArray(array, i));
3494 if (strcasecmp(val, "NONE") != 0)
3495 prefs->hot_corner_actions[i] = wstrdup(val);
3496 else
3497 prefs->hot_corner_actions[i] = NULL;
3498 } else {
3499 wwarning(_("Invalid argument for option \"%s\" item %d"), entry->key, i);
3500 prefs->hot_corner_actions[i] = NULL;
3504 WMReleasePropList(array);
3506 return 0;
3510 static int setDoubleClick(WScreen *scr, WDefaultEntry *entry, void *tdata, void *foo)
3512 int *value = tdata;
3514 /* Parameter not used, but tell the compiler that it is ok */
3515 (void) entry;
3516 (void) scr;
3518 if (*value <= 0)
3519 *(int *)foo = 1;
3521 W_setconf_doubleClickDelay(*value);
3523 return 0;
3526 static int setCursor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *extra_data)
3528 Cursor *cursor = tdata;
3529 long widx = (long) extra_data;
3531 /* Parameter not used, but tell the compiler that it is ok */
3532 (void) entry;
3534 if (wPreferences.cursor[widx] != None) {
3535 XFreeCursor(dpy, wPreferences.cursor[widx]);
3538 wPreferences.cursor[widx] = *cursor;
3540 if (widx == WCUR_ROOT && *cursor != None) {
3541 XDefineCursor(dpy, scr->root_win, *cursor);
3544 return 0;
3547 static int updateDock(WScreen * scr, WDefaultEntry * entry,
3548 void *tdata, void *extra_data) {
3549 (void) entry;
3550 (void) tdata;
3551 (void) extra_data;
3553 if (scr->dock)
3554 wDockSwap(scr->dock);
3556 return 0;