Update Serbian translation from master branch
[wmaker-crm.git] / src / defaults.c
blobc10f27ff5a4c6cc00a7b0cde6aa06ad3c1e2aa46
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 {"CenterKey", "None", (void *)WKBD_CENTRAL,
685 NULL, getKeybind, setKeyGrab, NULL, NULL},
686 {"KeepOnTopKey", "None", (void *)WKBD_KEEP_ON_TOP,
687 NULL, getKeybind, setKeyGrab, NULL, NULL},
688 {"KeepAtBottomKey", "None", (void *)WKBD_KEEP_AT_BOTTOM,
689 NULL, getKeybind, setKeyGrab, NULL, NULL},
690 {"OmnipresentKey", "None", (void *)WKBD_OMNIPRESENT,
691 NULL, getKeybind, setKeyGrab, NULL, NULL},
692 {"RaiseKey", "Mod1+Up", (void *)WKBD_RAISE,
693 NULL, getKeybind, setKeyGrab, NULL, NULL},
694 {"LowerKey", "Mod1+Down", (void *)WKBD_LOWER,
695 NULL, getKeybind, setKeyGrab, NULL, NULL},
696 {"RaiseLowerKey", "None", (void *)WKBD_RAISELOWER,
697 NULL, getKeybind, setKeyGrab, NULL, NULL},
698 {"ShadeKey", "None", (void *)WKBD_SHADE,
699 NULL, getKeybind, setKeyGrab, NULL, NULL},
700 {"SelectKey", "None", (void *)WKBD_SELECT,
701 NULL, getKeybind, setKeyGrab, NULL, NULL},
702 {"WorkspaceMapKey", "None", (void *)WKBD_WORKSPACEMAP,
703 NULL, getKeybind, setKeyGrab, NULL, NULL},
704 {"FocusNextKey", "Mod1+Tab", (void *)WKBD_FOCUSNEXT,
705 NULL, getKeybind, setKeyGrab, NULL, NULL},
706 {"FocusPrevKey", "Mod1+Shift+Tab", (void *)WKBD_FOCUSPREV,
707 NULL, getKeybind, setKeyGrab, NULL, NULL},
708 {"GroupNextKey", "None", (void *)WKBD_GROUPNEXT,
709 NULL, getKeybind, setKeyGrab, NULL, NULL},
710 {"GroupPrevKey", "None", (void *)WKBD_GROUPPREV,
711 NULL, getKeybind, setKeyGrab, NULL, NULL},
712 {"NextWorkspaceKey", "Mod1+Control+Right", (void *)WKBD_NEXTWORKSPACE,
713 NULL, getKeybind, setKeyGrab, NULL, NULL},
714 {"PrevWorkspaceKey", "Mod1+Control+Left", (void *)WKBD_PREVWORKSPACE,
715 NULL, getKeybind, setKeyGrab, NULL, NULL},
716 {"LastWorkspaceKey", "None", (void *)WKBD_LASTWORKSPACE,
717 NULL, getKeybind, setKeyGrab, NULL, NULL},
718 {"NextWorkspaceLayerKey", "None", (void *)WKBD_NEXTWSLAYER,
719 NULL, getKeybind, setKeyGrab, NULL, NULL},
720 {"PrevWorkspaceLayerKey", "None", (void *)WKBD_PREVWSLAYER,
721 NULL, getKeybind, setKeyGrab, NULL, NULL},
722 {"Workspace1Key", "Mod1+1", (void *)WKBD_WORKSPACE1,
723 NULL, getKeybind, setKeyGrab, NULL, NULL},
724 {"Workspace2Key", "Mod1+2", (void *)WKBD_WORKSPACE2,
725 NULL, getKeybind, setKeyGrab, NULL, NULL},
726 {"Workspace3Key", "Mod1+3", (void *)WKBD_WORKSPACE3,
727 NULL, getKeybind, setKeyGrab, NULL, NULL},
728 {"Workspace4Key", "Mod1+4", (void *)WKBD_WORKSPACE4,
729 NULL, getKeybind, setKeyGrab, NULL, NULL},
730 {"Workspace5Key", "Mod1+5", (void *)WKBD_WORKSPACE5,
731 NULL, getKeybind, setKeyGrab, NULL, NULL},
732 {"Workspace6Key", "Mod1+6", (void *)WKBD_WORKSPACE6,
733 NULL, getKeybind, setKeyGrab, NULL, NULL},
734 {"Workspace7Key", "Mod1+7", (void *)WKBD_WORKSPACE7,
735 NULL, getKeybind, setKeyGrab, NULL, NULL},
736 {"Workspace8Key", "Mod1+8", (void *)WKBD_WORKSPACE8,
737 NULL, getKeybind, setKeyGrab, NULL, NULL},
738 {"Workspace9Key", "Mod1+9", (void *)WKBD_WORKSPACE9,
739 NULL, getKeybind, setKeyGrab, NULL, NULL},
740 {"Workspace10Key", "Mod1+0", (void *)WKBD_WORKSPACE10,
741 NULL, getKeybind, setKeyGrab, NULL, NULL},
742 {"MoveToWorkspace1Key", "None", (void *)WKBD_MOVE_WORKSPACE1,
743 NULL, getKeybind, setKeyGrab, NULL, NULL},
744 {"MoveToWorkspace2Key", "None", (void *)WKBD_MOVE_WORKSPACE2,
745 NULL, getKeybind, setKeyGrab, NULL, NULL},
746 {"MoveToWorkspace3Key", "None", (void *)WKBD_MOVE_WORKSPACE3,
747 NULL, getKeybind, setKeyGrab, NULL, NULL},
748 {"MoveToWorkspace4Key", "None", (void *)WKBD_MOVE_WORKSPACE4,
749 NULL, getKeybind, setKeyGrab, NULL, NULL},
750 {"MoveToWorkspace5Key", "None", (void *)WKBD_MOVE_WORKSPACE5,
751 NULL, getKeybind, setKeyGrab, NULL, NULL},
752 {"MoveToWorkspace6Key", "None", (void *)WKBD_MOVE_WORKSPACE6,
753 NULL, getKeybind, setKeyGrab, NULL, NULL},
754 {"MoveToWorkspace7Key", "None", (void *)WKBD_MOVE_WORKSPACE7,
755 NULL, getKeybind, setKeyGrab, NULL, NULL},
756 {"MoveToWorkspace8Key", "None", (void *)WKBD_MOVE_WORKSPACE8,
757 NULL, getKeybind, setKeyGrab, NULL, NULL},
758 {"MoveToWorkspace9Key", "None", (void *)WKBD_MOVE_WORKSPACE9,
759 NULL, getKeybind, setKeyGrab, NULL, NULL},
760 {"MoveToWorkspace10Key", "None", (void *)WKBD_MOVE_WORKSPACE10,
761 NULL, getKeybind, setKeyGrab, NULL, NULL},
762 {"MoveToNextWorkspaceKey", "None", (void *)WKBD_MOVE_NEXTWORKSPACE,
763 NULL, getKeybind, setKeyGrab, NULL, NULL},
764 {"MoveToPrevWorkspaceKey", "None", (void *)WKBD_MOVE_PREVWORKSPACE,
765 NULL, getKeybind, setKeyGrab, NULL, NULL},
766 {"MoveToLastWorkspaceKey", "None", (void *)WKBD_MOVE_LASTWORKSPACE,
767 NULL, getKeybind, setKeyGrab, NULL, NULL},
768 {"MoveToNextWorkspaceLayerKey", "None", (void *)WKBD_MOVE_NEXTWSLAYER,
769 NULL, getKeybind, setKeyGrab, NULL, NULL},
770 {"MoveToPrevWorkspaceLayerKey", "None", (void *)WKBD_MOVE_PREVWSLAYER,
771 NULL, getKeybind, setKeyGrab, NULL, NULL},
772 {"WindowShortcut1Key", "None", (void *)WKBD_WINDOW1,
773 NULL, getKeybind, setKeyGrab, NULL, NULL},
774 {"WindowShortcut2Key", "None", (void *)WKBD_WINDOW2,
775 NULL, getKeybind, setKeyGrab, NULL, NULL},
776 {"WindowShortcut3Key", "None", (void *)WKBD_WINDOW3,
777 NULL, getKeybind, setKeyGrab, NULL, NULL},
778 {"WindowShortcut4Key", "None", (void *)WKBD_WINDOW4,
779 NULL, getKeybind, setKeyGrab, NULL, NULL},
780 {"WindowShortcut5Key", "None", (void *)WKBD_WINDOW5,
781 NULL, getKeybind, setKeyGrab, NULL, NULL},
782 {"WindowShortcut6Key", "None", (void *)WKBD_WINDOW6,
783 NULL, getKeybind, setKeyGrab, NULL, NULL},
784 {"WindowShortcut7Key", "None", (void *)WKBD_WINDOW7,
785 NULL, getKeybind, setKeyGrab, NULL, NULL},
786 {"WindowShortcut8Key", "None", (void *)WKBD_WINDOW8,
787 NULL, getKeybind, setKeyGrab, NULL, NULL},
788 {"WindowShortcut9Key", "None", (void *)WKBD_WINDOW9,
789 NULL, getKeybind, setKeyGrab, NULL, NULL},
790 {"WindowShortcut10Key", "None", (void *)WKBD_WINDOW10,
791 NULL, getKeybind, setKeyGrab, NULL, NULL},
792 {"MoveTo12to6Head", "None", (void *)WKBD_MOVE_12_TO_6_HEAD,
793 NULL, getKeybind, setKeyGrab, NULL, NULL},
794 {"MoveTo6to12Head", "None", (void *)WKBD_MOVE_6_TO_12_HEAD,
795 NULL, getKeybind, setKeyGrab, NULL, NULL},
796 {"WindowRelaunchKey", "None", (void *)WKBD_RELAUNCH,
797 NULL, getKeybind, setKeyGrab, NULL, NULL},
798 {"ScreenSwitchKey", "None", (void *)WKBD_SWITCH_SCREEN,
799 NULL, getKeybind, setKeyGrab, NULL, NULL},
800 {"RunKey", "None", (void *)WKBD_RUN,
801 NULL, getKeybind, setKeyGrab, NULL, NULL},
802 {"ExitKey", "None", (void *)WKBD_EXIT,
803 NULL, getKeybind, setKeyGrab, NULL, NULL},
804 {"ScreenCaptureKey", "None", (void *)WKBD_PRINTS,
805 NULL, getKeybind, setKeyGrab, NULL, NULL},
806 {"WindowCaptureKey", "None", (void *)WKBD_PRINTW,
807 NULL, getKeybind, setKeyGrab, NULL, NULL},
808 {"PartialCaptureKey", "None", (void *)WKBD_PRINTP,
809 NULL, getKeybind, setKeyGrab, NULL, NULL},
811 #ifdef KEEP_XKB_LOCK_STATUS
812 {"ToggleKbdModeKey", "None", (void *)WKBD_TOGGLE,
813 NULL, getKeybind, setKeyGrab, NULL, NULL},
814 {"KbdModeLock", "NO", NULL,
815 &wPreferences.modelock, getBool, NULL, NULL, NULL},
816 #endif /* KEEP_XKB_LOCK_STATUS */
818 {"NormalCursor", "(builtin, left_ptr)", (void *)WCUR_ROOT,
819 NULL, getCursor, setCursor, NULL, NULL},
820 {"ArrowCursor", "(builtin, top_left_arrow)", (void *)WCUR_ARROW,
821 NULL, getCursor, setCursor, NULL, NULL},
822 {"MoveCursor", "(builtin, fleur)", (void *)WCUR_MOVE,
823 NULL, getCursor, setCursor, NULL, NULL},
824 {"ResizeCursor", "(builtin, sizing)", (void *)WCUR_RESIZE,
825 NULL, getCursor, setCursor, NULL, NULL},
826 {"TopLeftResizeCursor", "(builtin, top_left_corner)", (void *)WCUR_TOPLEFTRESIZE,
827 NULL, getCursor, setCursor, NULL, NULL},
828 {"TopRightResizeCursor", "(builtin, top_right_corner)", (void *)WCUR_TOPRIGHTRESIZE,
829 NULL, getCursor, setCursor, NULL, NULL},
830 {"BottomLeftResizeCursor", "(builtin, bottom_left_corner)", (void *)WCUR_BOTTOMLEFTRESIZE,
831 NULL, getCursor, setCursor, NULL, NULL},
832 {"BottomRightResizeCursor", "(builtin, bottom_right_corner)", (void *)WCUR_BOTTOMRIGHTRESIZE,
833 NULL, getCursor, setCursor, NULL, NULL},
834 {"VerticalResizeCursor", "(builtin, sb_v_double_arrow)", (void *)WCUR_VERTICALRESIZE,
835 NULL, getCursor, setCursor, NULL, NULL},
836 {"HorizontalResizeCursor", "(builtin, sb_h_double_arrow)", (void *)WCUR_HORIZONRESIZE,
837 NULL, getCursor, setCursor, NULL, NULL},
838 {"WaitCursor", "(builtin, watch)", (void *)WCUR_WAIT,
839 NULL, getCursor, setCursor, NULL, NULL},
840 {"QuestionCursor", "(builtin, question_arrow)", (void *)WCUR_QUESTION,
841 NULL, getCursor, setCursor, NULL, NULL},
842 {"TextCursor", "(builtin, xterm)", (void *)WCUR_TEXT,
843 NULL, getCursor, setCursor, NULL, NULL},
844 {"SelectCursor", "(builtin, cross)", (void *)WCUR_SELECT,
845 NULL, getCursor, setCursor, NULL, NULL},
846 {"CaptureCursor", "(builtin, crosshair)", (void *)WCUR_CAPTURE,
847 NULL, getCursor, setCursor, NULL, NULL},
848 {"DialogHistoryLines", "500", NULL,
849 &wPreferences.history_lines, getInt, NULL, NULL, NULL},
850 {"CycleActiveHeadOnly", "NO", NULL,
851 &wPreferences.cycle_active_head_only, getBool, NULL, NULL, NULL},
852 {"CycleIgnoreMinimized", "NO", NULL,
853 &wPreferences.cycle_ignore_minimized, getBool, NULL, NULL, NULL},
854 {"DbClickFullScreen", "NO", NULL,
855 &wPreferences.double_click_fullscreen, getBool, NULL, NULL, NULL},
856 {"CloseRootMenuByLeftOrRightMouseClick", "NO", NULL,
857 &wPreferences.close_rootmenu_left_right_click, getBool, NULL, NULL, NULL}
860 static void initDefaults(void)
862 unsigned int i;
863 WDefaultEntry *entry;
865 WMPLSetCaseSensitive(False);
867 for (i = 0; i < wlengthof(optionList); i++) {
868 entry = &optionList[i];
870 entry->plkey = WMCreatePLString(entry->key);
871 if (entry->default_value)
872 entry->plvalue = WMCreatePropListFromDescription(entry->default_value);
873 else
874 entry->plvalue = NULL;
877 for (i = 0; i < wlengthof(staticOptionList); i++) {
878 entry = &staticOptionList[i];
880 entry->plkey = WMCreatePLString(entry->key);
881 if (entry->default_value)
882 entry->plvalue = WMCreatePropListFromDescription(entry->default_value);
883 else
884 entry->plvalue = NULL;
888 static WMPropList *readGlobalDomain(const char *domainName, Bool requireDictionary)
890 WMPropList *globalDict = NULL;
891 char path[PATH_MAX];
892 struct stat stbuf;
894 snprintf(path, sizeof(path), "%s/%s", PKGCONFDIR, domainName);
895 if (stat(path, &stbuf) >= 0) {
896 globalDict = WMReadPropListFromFile(path);
897 if (globalDict && requireDictionary && !WMIsPLDictionary(globalDict)) {
898 wwarning(_("Domain %s (%s) of global defaults database is corrupted!"), domainName, path);
899 WMReleasePropList(globalDict);
900 globalDict = NULL;
901 } else if (!globalDict) {
902 wwarning(_("could not load domain %s from global defaults database"), domainName);
906 return globalDict;
909 #if defined(GLOBAL_PREAMBLE_MENU_FILE) || defined(GLOBAL_EPILOGUE_MENU_FILE)
910 static void prependMenu(WMPropList * destarr, WMPropList * array)
912 WMPropList *item;
913 int i;
915 for (i = 0; i < WMGetPropListItemCount(array); i++) {
916 item = WMGetFromPLArray(array, i);
917 if (item)
918 WMInsertInPLArray(destarr, i + 1, item);
922 static void appendMenu(WMPropList * destarr, WMPropList * array)
924 WMPropList *item;
925 int i;
927 for (i = 0; i < WMGetPropListItemCount(array); i++) {
928 item = WMGetFromPLArray(array, i);
929 if (item)
930 WMAddToPLArray(destarr, item);
933 #endif
935 void wDefaultsMergeGlobalMenus(WDDomain * menuDomain)
937 WMPropList *menu = menuDomain->dictionary;
938 WMPropList *submenu;
940 if (!menu || !WMIsPLArray(menu))
941 return;
943 #ifdef GLOBAL_PREAMBLE_MENU_FILE
944 submenu = WMReadPropListFromFile(PKGCONFDIR "/" GLOBAL_PREAMBLE_MENU_FILE);
946 if (submenu && !WMIsPLArray(submenu)) {
947 wwarning(_("invalid global menu file %s"), GLOBAL_PREAMBLE_MENU_FILE);
948 WMReleasePropList(submenu);
949 submenu = NULL;
951 if (submenu) {
952 prependMenu(menu, submenu);
953 WMReleasePropList(submenu);
955 #endif
957 #ifdef GLOBAL_EPILOGUE_MENU_FILE
958 submenu = WMReadPropListFromFile(PKGCONFDIR "/" GLOBAL_EPILOGUE_MENU_FILE);
960 if (submenu && !WMIsPLArray(submenu)) {
961 wwarning(_("invalid global menu file %s"), GLOBAL_EPILOGUE_MENU_FILE);
962 WMReleasePropList(submenu);
963 submenu = NULL;
965 if (submenu) {
966 appendMenu(menu, submenu);
967 WMReleasePropList(submenu);
969 #endif
971 menuDomain->dictionary = menu;
974 WDDomain *wDefaultsInitDomain(const char *domain, Bool requireDictionary)
976 WDDomain *db;
977 struct stat stbuf;
978 static int inited = 0;
979 WMPropList *shared_dict = NULL;
981 if (!inited) {
982 inited = 1;
983 initDefaults();
986 db = wmalloc(sizeof(WDDomain));
987 db->domain_name = domain;
988 db->path = wdefaultspathfordomain(domain);
990 if (stat(db->path, &stbuf) >= 0) {
991 db->dictionary = WMReadPropListFromFile(db->path);
992 if (db->dictionary) {
993 if (requireDictionary && !WMIsPLDictionary(db->dictionary)) {
994 WMReleasePropList(db->dictionary);
995 db->dictionary = NULL;
996 wwarning(_("Domain %s (%s) of defaults database is corrupted!"), domain, db->path);
998 db->timestamp = stbuf.st_mtime;
999 } else {
1000 wwarning(_("could not load domain %s from user defaults database"), domain);
1004 /* global system dictionary */
1005 shared_dict = readGlobalDomain(domain, requireDictionary);
1007 if (shared_dict && db->dictionary && WMIsPLDictionary(shared_dict) &&
1008 WMIsPLDictionary(db->dictionary)) {
1009 WMMergePLDictionaries(shared_dict, db->dictionary, True);
1010 WMReleasePropList(db->dictionary);
1011 db->dictionary = shared_dict;
1012 if (stbuf.st_mtime > db->timestamp)
1013 db->timestamp = stbuf.st_mtime;
1014 } else if (!db->dictionary) {
1015 db->dictionary = shared_dict;
1016 if (stbuf.st_mtime > db->timestamp)
1017 db->timestamp = stbuf.st_mtime;
1020 return db;
1023 void wReadStaticDefaults(WMPropList * dict)
1025 WMPropList *plvalue;
1026 WDefaultEntry *entry;
1027 unsigned int i;
1028 void *tdata;
1030 for (i = 0; i < wlengthof(staticOptionList); i++) {
1031 entry = &staticOptionList[i];
1033 if (dict)
1034 plvalue = WMGetFromPLDictionary(dict, entry->plkey);
1035 else
1036 plvalue = NULL;
1038 /* no default in the DB. Use builtin default */
1039 if (!plvalue)
1040 plvalue = entry->plvalue;
1042 if (plvalue) {
1043 /* convert data */
1044 (*entry->convert) (NULL, entry, plvalue, entry->addr, &tdata);
1045 if (entry->update)
1046 (*entry->update) (NULL, entry, tdata, entry->extra_data);
1051 void wDefaultsCheckDomains(void* arg)
1053 WScreen *scr;
1054 struct stat stbuf;
1055 WMPropList *shared_dict = NULL;
1056 WMPropList *dict;
1057 int i;
1059 /* Parameter not used, but tell the compiler that it is ok */
1060 (void) arg;
1062 if (stat(w_global.domain.wmaker->path, &stbuf) >= 0 && w_global.domain.wmaker->timestamp < stbuf.st_mtime) {
1063 w_global.domain.wmaker->timestamp = stbuf.st_mtime;
1065 /* Global dictionary */
1066 shared_dict = readGlobalDomain("WindowMaker", True);
1068 /* User dictionary */
1069 dict = WMReadPropListFromFile(w_global.domain.wmaker->path);
1071 if (dict) {
1072 if (!WMIsPLDictionary(dict)) {
1073 WMReleasePropList(dict);
1074 dict = NULL;
1075 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
1076 "WindowMaker", w_global.domain.wmaker->path);
1077 } else {
1078 if (shared_dict) {
1079 WMMergePLDictionaries(shared_dict, dict, True);
1080 WMReleasePropList(dict);
1081 dict = shared_dict;
1082 shared_dict = NULL;
1085 for (i = 0; i < w_global.screen_count; i++) {
1086 scr = wScreenWithNumber(i);
1087 if (scr)
1088 wReadDefaults(scr, dict);
1091 if (w_global.domain.wmaker->dictionary)
1092 WMReleasePropList(w_global.domain.wmaker->dictionary);
1094 w_global.domain.wmaker->dictionary = dict;
1096 } else {
1097 wwarning(_("could not load domain %s from user defaults database"), "WindowMaker");
1100 if (shared_dict)
1101 WMReleasePropList(shared_dict);
1105 if (stat(w_global.domain.window_attr->path, &stbuf) >= 0 && w_global.domain.window_attr->timestamp < stbuf.st_mtime) {
1106 /* global dictionary */
1107 shared_dict = readGlobalDomain("WMWindowAttributes", True);
1108 /* user dictionary */
1109 dict = WMReadPropListFromFile(w_global.domain.window_attr->path);
1110 if (dict) {
1111 if (!WMIsPLDictionary(dict)) {
1112 WMReleasePropList(dict);
1113 dict = NULL;
1114 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
1115 "WMWindowAttributes", w_global.domain.window_attr->path);
1116 } else {
1117 if (shared_dict) {
1118 WMMergePLDictionaries(shared_dict, dict, True);
1119 WMReleasePropList(dict);
1120 dict = shared_dict;
1121 shared_dict = NULL;
1124 if (w_global.domain.window_attr->dictionary)
1125 WMReleasePropList(w_global.domain.window_attr->dictionary);
1127 w_global.domain.window_attr->dictionary = dict;
1128 for (i = 0; i < w_global.screen_count; i++) {
1129 scr = wScreenWithNumber(i);
1130 if (scr) {
1131 wDefaultUpdateIcons(scr);
1133 /* Update the panel image if changed */
1134 /* Don't worry. If the image is the same these
1135 * functions will have no performance impact. */
1136 create_logo_image(scr);
1140 } else {
1141 wwarning(_("could not load domain %s from user defaults database"), "WMWindowAttributes");
1144 w_global.domain.window_attr->timestamp = stbuf.st_mtime;
1145 if (shared_dict)
1146 WMReleasePropList(shared_dict);
1149 if (stat(w_global.domain.root_menu->path, &stbuf) >= 0 && w_global.domain.root_menu->timestamp < stbuf.st_mtime) {
1150 dict = WMReadPropListFromFile(w_global.domain.root_menu->path);
1151 if (dict) {
1152 if (!WMIsPLArray(dict) && !WMIsPLString(dict)) {
1153 WMReleasePropList(dict);
1154 dict = NULL;
1155 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
1156 "WMRootMenu", w_global.domain.root_menu->path);
1157 } else {
1158 if (w_global.domain.root_menu->dictionary)
1159 WMReleasePropList(w_global.domain.root_menu->dictionary);
1161 w_global.domain.root_menu->dictionary = dict;
1162 wDefaultsMergeGlobalMenus(w_global.domain.root_menu);
1164 } else {
1165 wwarning(_("could not load domain %s from user defaults database"), "WMRootMenu");
1167 w_global.domain.root_menu->timestamp = stbuf.st_mtime;
1169 #ifndef HAVE_INOTIFY
1170 if (!arg)
1171 WMAddTimerHandler(DEFAULTS_CHECK_INTERVAL, wDefaultsCheckDomains, arg);
1172 #endif
1175 void wReadDefaults(WScreen * scr, WMPropList * new_dict)
1177 WMPropList *plvalue, *old_value;
1178 WDefaultEntry *entry;
1179 unsigned int i;
1180 int update_workspace_back = 0; /* kluge :/ */
1181 unsigned int needs_refresh;
1182 void *tdata;
1183 WMPropList *old_dict = (w_global.domain.wmaker->dictionary != new_dict ? w_global.domain.wmaker->dictionary : NULL);
1185 needs_refresh = 0;
1187 for (i = 0; i < wlengthof(optionList); i++) {
1188 entry = &optionList[i];
1190 if (new_dict)
1191 plvalue = WMGetFromPLDictionary(new_dict, entry->plkey);
1192 else
1193 plvalue = NULL;
1195 if (!old_dict)
1196 old_value = NULL;
1197 else
1198 old_value = WMGetFromPLDictionary(old_dict, entry->plkey);
1200 if (!plvalue && !old_value) {
1201 /* no default in the DB. Use builtin default */
1202 plvalue = entry->plvalue;
1203 if (plvalue && new_dict)
1204 WMPutInPLDictionary(new_dict, entry->plkey, plvalue);
1206 } else if (!plvalue) {
1207 /* value was deleted from DB. Keep current value */
1208 continue;
1209 } else if (!old_value) {
1210 /* set value for the 1st time */
1211 } else if (!WMIsPropListEqualTo(plvalue, old_value)) {
1212 /* value has changed */
1213 } else {
1214 if (strcmp(entry->key, "WorkspaceBack") == 0
1215 && update_workspace_back && scr->flags.backimage_helper_launched) {
1216 } else {
1217 /* value was not changed since last time */
1218 continue;
1222 if (plvalue) {
1223 /* convert data */
1224 if ((*entry->convert) (scr, entry, plvalue, entry->addr, &tdata)) {
1226 * If the WorkspaceSpecificBack data has been changed
1227 * so that the helper will be launched now, we must be
1228 * sure to send the default background texture config
1229 * to the helper.
1231 if (strcmp(entry->key, "WorkspaceSpecificBack") == 0 &&
1232 !scr->flags.backimage_helper_launched)
1233 update_workspace_back = 1;
1235 if (entry->update)
1236 needs_refresh |= (*entry->update) (scr, entry, tdata, entry->extra_data);
1242 if (needs_refresh != 0 && !scr->flags.startup) {
1243 int foo;
1245 foo = 0;
1246 if (needs_refresh & REFRESH_MENU_TITLE_TEXTURE)
1247 foo |= WTextureSettings;
1248 if (needs_refresh & REFRESH_MENU_TITLE_FONT)
1249 foo |= WFontSettings;
1250 if (needs_refresh & REFRESH_MENU_TITLE_COLOR)
1251 foo |= WColorSettings;
1252 if (foo)
1253 WMPostNotificationName(WNMenuTitleAppearanceSettingsChanged, NULL,
1254 (void *)(uintptr_t) foo);
1256 foo = 0;
1257 if (needs_refresh & REFRESH_MENU_TEXTURE)
1258 foo |= WTextureSettings;
1259 if (needs_refresh & REFRESH_MENU_FONT)
1260 foo |= WFontSettings;
1261 if (needs_refresh & REFRESH_MENU_COLOR)
1262 foo |= WColorSettings;
1263 if (foo)
1264 WMPostNotificationName(WNMenuAppearanceSettingsChanged, NULL, (void *)(uintptr_t) foo);
1266 foo = 0;
1267 if (needs_refresh & REFRESH_WINDOW_FONT)
1268 foo |= WFontSettings;
1269 if (needs_refresh & REFRESH_WINDOW_TEXTURES)
1270 foo |= WTextureSettings;
1271 if (needs_refresh & REFRESH_WINDOW_TITLE_COLOR)
1272 foo |= WColorSettings;
1273 if (foo)
1274 WMPostNotificationName(WNWindowAppearanceSettingsChanged, NULL, (void *)(uintptr_t) foo);
1276 if (!(needs_refresh & REFRESH_ICON_TILE)) {
1277 foo = 0;
1278 if (needs_refresh & REFRESH_ICON_FONT)
1279 foo |= WFontSettings;
1280 if (needs_refresh & REFRESH_ICON_TITLE_COLOR)
1281 foo |= WTextureSettings;
1282 if (needs_refresh & REFRESH_ICON_TITLE_BACK)
1283 foo |= WTextureSettings;
1284 if (foo)
1285 WMPostNotificationName(WNIconAppearanceSettingsChanged, NULL,
1286 (void *)(uintptr_t) foo);
1288 if (needs_refresh & REFRESH_ICON_TILE)
1289 WMPostNotificationName(WNIconTileSettingsChanged, NULL, NULL);
1291 if (needs_refresh & REFRESH_WORKSPACE_MENU) {
1292 if (scr->workspace_menu)
1293 wWorkspaceMenuUpdate(scr, scr->workspace_menu);
1294 if (scr->clip_ws_menu)
1295 wWorkspaceMenuUpdate(scr, scr->clip_ws_menu);
1296 if (scr->workspace_submenu)
1297 scr->workspace_submenu->flags.realized = 0;
1298 if (scr->clip_submenu)
1299 scr->clip_submenu->flags.realized = 0;
1304 void wDefaultUpdateIcons(WScreen *scr)
1306 WAppIcon *aicon = scr->app_icon_list;
1307 WDrawerChain *dc;
1308 WWindow *wwin = scr->focused_window;
1310 while (aicon) {
1311 /* Get the application icon, default included */
1312 wIconChangeImageFile(aicon->icon, NULL);
1313 wAppIconPaint(aicon);
1314 aicon = aicon->next;
1317 if (!wPreferences.flags.noclip || wPreferences.flags.clip_merged_in_dock)
1318 wClipIconPaint(scr->clip_icon);
1320 for (dc = scr->drawers; dc != NULL; dc = dc->next)
1321 wDrawerIconPaint(dc->adrawer->icon_array[0]);
1323 while (wwin) {
1324 if (wwin->icon && wwin->flags.miniaturized)
1325 wIconChangeImageFile(wwin->icon, NULL);
1326 wwin = wwin->prev;
1330 /* --------------------------- Local ----------------------- */
1332 #define GET_STRING_OR_DEFAULT(x, var) if (!WMIsPLString(value)) { \
1333 wwarning(_("Wrong option format for key \"%s\". Should be %s."), \
1334 entry->key, x); \
1335 wwarning(_("using default \"%s\" instead"), entry->default_value); \
1336 var = entry->default_value;\
1337 } else var = WMGetFromPLString(value)\
1340 static int string2index(WMPropList *key, WMPropList *val, const char *def, WOptionEnumeration * values)
1342 char *str;
1343 WOptionEnumeration *v;
1344 char buffer[TOTAL_VALUES_LENGTH];
1346 if (WMIsPLString(val) && (str = WMGetFromPLString(val))) {
1347 for (v = values; v->string != NULL; v++) {
1348 if (strcasecmp(v->string, str) == 0)
1349 return v->value;
1353 buffer[0] = 0;
1354 for (v = values; v->string != NULL; v++) {
1355 if (!v->is_alias) {
1356 if (buffer[0] != 0)
1357 strcat(buffer, ", ");
1358 snprintf(buffer+strlen(buffer),
1359 sizeof(buffer)-strlen(buffer)-1, "\"%s\"", v->string);
1362 wwarning(_("wrong option value for key \"%s\"; got \"%s\", should be one of %s."),
1363 WMGetFromPLString(key),
1364 WMIsPLString(val) ? WMGetFromPLString(val) : "(unknown)",
1365 buffer);
1367 if (def) {
1368 return string2index(key, val, NULL, values);
1371 return -1;
1375 * value - is the value in the defaults DB
1376 * addr - is the address to store the data
1377 * ret - is the address to store a pointer to a temporary buffer. ret
1378 * must not be freed and is used by the set functions
1380 static int getBool(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1382 static char data;
1383 const char *val;
1384 int second_pass = 0;
1386 /* Parameter not used, but tell the compiler that it is ok */
1387 (void) scr;
1389 GET_STRING_OR_DEFAULT("Boolean", val);
1391 again:
1392 if ((val[1] == '\0' && (val[0] == 'y' || val[0] == 'Y'))
1393 || strcasecmp(val, "YES") == 0) {
1395 data = 1;
1396 } else if ((val[1] == '\0' && (val[0] == 'n' || val[0] == 'N'))
1397 || strcasecmp(val, "NO") == 0) {
1398 data = 0;
1399 } else {
1400 int i;
1401 if (sscanf(val, "%i", &i) == 1) {
1402 if (i != 0)
1403 data = 1;
1404 else
1405 data = 0;
1406 } else {
1407 wwarning(_("can't convert \"%s\" to boolean for key \"%s\""), val, entry->key);
1408 if (second_pass == 0) {
1409 val = WMGetFromPLString(entry->plvalue);
1410 second_pass = 1;
1411 wwarning(_("using default \"%s\" instead"), val);
1412 goto again;
1414 return False;
1418 if (ret)
1419 *ret = &data;
1420 if (addr)
1421 *(char *)addr = data;
1423 return True;
1426 static int getInt(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1428 static int data;
1429 const char *val;
1431 /* Parameter not used, but tell the compiler that it is ok */
1432 (void) scr;
1434 GET_STRING_OR_DEFAULT("Integer", val);
1436 if (sscanf(val, "%i", &data) != 1) {
1437 wwarning(_("can't convert \"%s\" to integer for key \"%s\""), val, entry->key);
1438 val = WMGetFromPLString(entry->plvalue);
1439 wwarning(_("using default \"%s\" instead"), val);
1440 if (sscanf(val, "%i", &data) != 1) {
1441 return False;
1445 if (ret)
1446 *ret = &data;
1447 if (addr)
1448 *(int *)addr = data;
1450 return True;
1453 static int getCoord(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1455 static WCoord data;
1456 char *val_x, *val_y;
1457 int nelem, changed = 0;
1458 WMPropList *elem_x, *elem_y;
1460 again:
1461 if (!WMIsPLArray(value)) {
1462 wwarning(_("Wrong option format for key \"%s\". Should be %s."), entry->key, "Coordinate");
1463 if (changed == 0) {
1464 value = entry->plvalue;
1465 changed = 1;
1466 wwarning(_("using default \"%s\" instead"), entry->default_value);
1467 goto again;
1469 return False;
1472 nelem = WMGetPropListItemCount(value);
1473 if (nelem != 2) {
1474 wwarning(_("Incorrect number of elements in array for key \"%s\"."), entry->key);
1475 if (changed == 0) {
1476 value = entry->plvalue;
1477 changed = 1;
1478 wwarning(_("using default \"%s\" instead"), entry->default_value);
1479 goto again;
1481 return False;
1484 elem_x = WMGetFromPLArray(value, 0);
1485 elem_y = WMGetFromPLArray(value, 1);
1487 if (!elem_x || !elem_y || !WMIsPLString(elem_x) || !WMIsPLString(elem_y)) {
1488 wwarning(_("Wrong value for key \"%s\". Should be Coordinate."), entry->key);
1489 if (changed == 0) {
1490 value = entry->plvalue;
1491 changed = 1;
1492 wwarning(_("using default \"%s\" instead"), entry->default_value);
1493 goto again;
1495 return False;
1498 val_x = WMGetFromPLString(elem_x);
1499 val_y = WMGetFromPLString(elem_y);
1501 if (sscanf(val_x, "%i", &data.x) != 1 || sscanf(val_y, "%i", &data.y) != 1) {
1502 wwarning(_("can't convert array to integers for \"%s\"."), entry->key);
1503 if (changed == 0) {
1504 value = entry->plvalue;
1505 changed = 1;
1506 wwarning(_("using default \"%s\" instead"), entry->default_value);
1507 goto again;
1509 return False;
1512 if (data.x < 0)
1513 data.x = 0;
1514 else if (data.x > scr->scr_width / 3)
1515 data.x = scr->scr_width / 3;
1516 if (data.y < 0)
1517 data.y = 0;
1518 else if (data.y > scr->scr_height / 3)
1519 data.y = scr->scr_height / 3;
1521 if (ret)
1522 *ret = &data;
1523 if (addr)
1524 *(WCoord *) addr = data;
1526 return True;
1529 static int getPropList(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1531 /* Parameter not used, but tell the compiler that it is ok */
1532 (void) scr;
1533 (void) entry;
1534 (void) addr;
1536 WMRetainPropList(value);
1538 *ret = value;
1540 return True;
1543 static int getPathList(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1545 static char *data;
1546 int i, count, len;
1547 char *ptr;
1548 WMPropList *d;
1549 int changed = 0;
1551 /* Parameter not used, but tell the compiler that it is ok */
1552 (void) scr;
1553 (void) ret;
1555 again:
1556 if (!WMIsPLArray(value)) {
1557 wwarning(_("Wrong option format for key \"%s\". Should be %s."), entry->key, "an array of paths");
1558 if (changed == 0) {
1559 value = entry->plvalue;
1560 changed = 1;
1561 wwarning(_("using default \"%s\" instead"), entry->default_value);
1562 goto again;
1564 return False;
1567 i = 0;
1568 count = WMGetPropListItemCount(value);
1569 if (count < 1) {
1570 if (changed == 0) {
1571 value = entry->plvalue;
1572 changed = 1;
1573 wwarning(_("using default \"%s\" instead"), entry->default_value);
1574 goto again;
1576 return False;
1579 len = 0;
1580 for (i = 0; i < count; i++) {
1581 d = WMGetFromPLArray(value, i);
1582 if (!d || !WMIsPLString(d)) {
1583 count = i;
1584 break;
1586 len += strlen(WMGetFromPLString(d)) + 1;
1589 ptr = data = wmalloc(len + 1);
1591 for (i = 0; i < count; i++) {
1592 d = WMGetFromPLArray(value, i);
1593 if (!d || !WMIsPLString(d)) {
1594 break;
1596 strcpy(ptr, WMGetFromPLString(d));
1597 ptr += strlen(WMGetFromPLString(d));
1598 *ptr = ':';
1599 ptr++;
1601 ptr--;
1602 *(ptr--) = 0;
1604 if (*(char **)addr != NULL) {
1605 wfree(*(char **)addr);
1607 *(char **)addr = data;
1609 return True;
1612 static int getEnum(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1614 static signed char data;
1616 /* Parameter not used, but tell the compiler that it is ok */
1617 (void) scr;
1619 data = string2index(entry->plkey, value, entry->default_value, (WOptionEnumeration *) entry->extra_data);
1620 if (data < 0)
1621 return False;
1623 if (ret)
1624 *ret = &data;
1625 if (addr)
1626 *(signed char *)addr = data;
1628 return True;
1632 * (solid <color>)
1633 * (hgradient <color> <color>)
1634 * (vgradient <color> <color>)
1635 * (dgradient <color> <color>)
1636 * (mhgradient <color> <color> ...)
1637 * (mvgradient <color> <color> ...)
1638 * (mdgradient <color> <color> ...)
1639 * (igradient <color1> <color1> <thickness1> <color2> <color2> <thickness2>)
1640 * (tpixmap <file> <color>)
1641 * (spixmap <file> <color>)
1642 * (cpixmap <file> <color>)
1643 * (thgradient <file> <opaqueness> <color> <color>)
1644 * (tvgradient <file> <opaqueness> <color> <color>)
1645 * (tdgradient <file> <opaqueness> <color> <color>)
1646 * (function <lib> <function> ...)
1649 static WTexture *parse_texture(WScreen * scr, WMPropList * pl)
1651 WMPropList *elem;
1652 char *val;
1653 int nelem;
1654 WTexture *texture = NULL;
1656 nelem = WMGetPropListItemCount(pl);
1657 if (nelem < 1)
1658 return NULL;
1660 elem = WMGetFromPLArray(pl, 0);
1661 if (!elem || !WMIsPLString(elem))
1662 return NULL;
1663 val = WMGetFromPLString(elem);
1665 if (strcasecmp(val, "solid") == 0) {
1666 XColor color;
1668 if (nelem != 2)
1669 return NULL;
1671 /* get color */
1673 elem = WMGetFromPLArray(pl, 1);
1674 if (!elem || !WMIsPLString(elem))
1675 return NULL;
1676 val = WMGetFromPLString(elem);
1678 if (!XParseColor(dpy, scr->w_colormap, val, &color)) {
1679 wwarning(_("\"%s\" is not a valid color name"), val);
1680 return NULL;
1683 texture = (WTexture *) wTextureMakeSolid(scr, &color);
1684 } else if (strcasecmp(val, "dgradient") == 0
1685 || strcasecmp(val, "vgradient") == 0 || strcasecmp(val, "hgradient") == 0) {
1686 RColor color1, color2;
1687 XColor xcolor;
1688 int type;
1690 if (nelem != 3) {
1691 wwarning(_("bad number of arguments in gradient specification"));
1692 return NULL;
1695 if (val[0] == 'd' || val[0] == 'D')
1696 type = WTEX_DGRADIENT;
1697 else if (val[0] == 'h' || val[0] == 'H')
1698 type = WTEX_HGRADIENT;
1699 else
1700 type = WTEX_VGRADIENT;
1702 /* get from color */
1703 elem = WMGetFromPLArray(pl, 1);
1704 if (!elem || !WMIsPLString(elem))
1705 return NULL;
1706 val = WMGetFromPLString(elem);
1708 if (!XParseColor(dpy, scr->w_colormap, val, &xcolor)) {
1709 wwarning(_("\"%s\" is not a valid color name"), val);
1710 return NULL;
1712 color1.alpha = 255;
1713 color1.red = xcolor.red >> 8;
1714 color1.green = xcolor.green >> 8;
1715 color1.blue = xcolor.blue >> 8;
1717 /* get to color */
1718 elem = WMGetFromPLArray(pl, 2);
1719 if (!elem || !WMIsPLString(elem)) {
1720 return NULL;
1722 val = WMGetFromPLString(elem);
1724 if (!XParseColor(dpy, scr->w_colormap, val, &xcolor)) {
1725 wwarning(_("\"%s\" is not a valid color name"), val);
1726 return NULL;
1728 color2.alpha = 255;
1729 color2.red = xcolor.red >> 8;
1730 color2.green = xcolor.green >> 8;
1731 color2.blue = xcolor.blue >> 8;
1733 texture = (WTexture *) wTextureMakeGradient(scr, type, &color1, &color2);
1735 } else if (strcasecmp(val, "igradient") == 0) {
1736 RColor colors1[2], colors2[2];
1737 int th1, th2;
1738 XColor xcolor;
1739 int i;
1741 if (nelem != 7) {
1742 wwarning(_("bad number of arguments in gradient specification"));
1743 return NULL;
1746 /* get from color */
1747 for (i = 0; i < 2; i++) {
1748 elem = WMGetFromPLArray(pl, 1 + i);
1749 if (!elem || !WMIsPLString(elem))
1750 return NULL;
1751 val = WMGetFromPLString(elem);
1753 if (!XParseColor(dpy, scr->w_colormap, val, &xcolor)) {
1754 wwarning(_("\"%s\" is not a valid color name"), val);
1755 return NULL;
1757 colors1[i].alpha = 255;
1758 colors1[i].red = xcolor.red >> 8;
1759 colors1[i].green = xcolor.green >> 8;
1760 colors1[i].blue = xcolor.blue >> 8;
1762 elem = WMGetFromPLArray(pl, 3);
1763 if (!elem || !WMIsPLString(elem))
1764 return NULL;
1765 val = WMGetFromPLString(elem);
1766 th1 = atoi(val);
1768 /* get from color */
1769 for (i = 0; i < 2; i++) {
1770 elem = WMGetFromPLArray(pl, 4 + i);
1771 if (!elem || !WMIsPLString(elem))
1772 return NULL;
1773 val = WMGetFromPLString(elem);
1775 if (!XParseColor(dpy, scr->w_colormap, val, &xcolor)) {
1776 wwarning(_("\"%s\" is not a valid color name"), val);
1777 return NULL;
1779 colors2[i].alpha = 255;
1780 colors2[i].red = xcolor.red >> 8;
1781 colors2[i].green = xcolor.green >> 8;
1782 colors2[i].blue = xcolor.blue >> 8;
1784 elem = WMGetFromPLArray(pl, 6);
1785 if (!elem || !WMIsPLString(elem))
1786 return NULL;
1787 val = WMGetFromPLString(elem);
1788 th2 = atoi(val);
1790 texture = (WTexture *) wTextureMakeIGradient(scr, th1, colors1, th2, colors2);
1792 } else if (strcasecmp(val, "mhgradient") == 0
1793 || strcasecmp(val, "mvgradient") == 0 || strcasecmp(val, "mdgradient") == 0) {
1794 XColor color;
1795 RColor **colors;
1796 int i, count;
1797 int type;
1799 if (nelem < 3) {
1800 wwarning(_("too few arguments in multicolor gradient specification"));
1801 return NULL;
1804 if (val[1] == 'h' || val[1] == 'H')
1805 type = WTEX_MHGRADIENT;
1806 else if (val[1] == 'v' || val[1] == 'V')
1807 type = WTEX_MVGRADIENT;
1808 else
1809 type = WTEX_MDGRADIENT;
1811 count = nelem - 1;
1813 colors = wmalloc(sizeof(RColor *) * (count + 1));
1815 for (i = 0; i < count; i++) {
1816 elem = WMGetFromPLArray(pl, i + 1);
1817 if (!elem || !WMIsPLString(elem)) {
1818 for (--i; i >= 0; --i) {
1819 wfree(colors[i]);
1821 wfree(colors);
1822 return NULL;
1824 val = WMGetFromPLString(elem);
1826 if (!XParseColor(dpy, scr->w_colormap, val, &color)) {
1827 wwarning(_("\"%s\" is not a valid color name"), val);
1828 for (--i; i >= 0; --i) {
1829 wfree(colors[i]);
1831 wfree(colors);
1832 return NULL;
1833 } else {
1834 colors[i] = wmalloc(sizeof(RColor));
1835 colors[i]->red = color.red >> 8;
1836 colors[i]->green = color.green >> 8;
1837 colors[i]->blue = color.blue >> 8;
1840 colors[i] = NULL;
1842 texture = (WTexture *) wTextureMakeMGradient(scr, type, colors);
1843 } else if (strcasecmp(val, "spixmap") == 0 ||
1844 strcasecmp(val, "cpixmap") == 0 || strcasecmp(val, "tpixmap") == 0) {
1845 XColor color;
1846 int type;
1848 if (nelem != 3)
1849 return NULL;
1851 if (val[0] == 's' || val[0] == 'S')
1852 type = WTP_SCALE;
1853 else if (val[0] == 'c' || val[0] == 'C')
1854 type = WTP_CENTER;
1855 else
1856 type = WTP_TILE;
1858 /* get color */
1859 elem = WMGetFromPLArray(pl, 2);
1860 if (!elem || !WMIsPLString(elem)) {
1861 return NULL;
1863 val = WMGetFromPLString(elem);
1865 if (!XParseColor(dpy, scr->w_colormap, val, &color)) {
1866 wwarning(_("\"%s\" is not a valid color name"), val);
1867 return NULL;
1870 /* file name */
1871 elem = WMGetFromPLArray(pl, 1);
1872 if (!elem || !WMIsPLString(elem))
1873 return NULL;
1874 val = WMGetFromPLString(elem);
1876 texture = (WTexture *) wTextureMakePixmap(scr, type, val, &color);
1877 } else if (strcasecmp(val, "thgradient") == 0
1878 || strcasecmp(val, "tvgradient") == 0 || strcasecmp(val, "tdgradient") == 0) {
1879 RColor color1, color2;
1880 XColor xcolor;
1881 int opacity;
1882 int style;
1884 if (val[1] == 'h' || val[1] == 'H')
1885 style = WTEX_THGRADIENT;
1886 else if (val[1] == 'v' || val[1] == 'V')
1887 style = WTEX_TVGRADIENT;
1888 else
1889 style = WTEX_TDGRADIENT;
1891 if (nelem != 5) {
1892 wwarning(_("bad number of arguments in textured gradient specification"));
1893 return NULL;
1896 /* get from color */
1897 elem = WMGetFromPLArray(pl, 3);
1898 if (!elem || !WMIsPLString(elem))
1899 return NULL;
1900 val = WMGetFromPLString(elem);
1902 if (!XParseColor(dpy, scr->w_colormap, val, &xcolor)) {
1903 wwarning(_("\"%s\" is not a valid color name"), val);
1904 return NULL;
1906 color1.alpha = 255;
1907 color1.red = xcolor.red >> 8;
1908 color1.green = xcolor.green >> 8;
1909 color1.blue = xcolor.blue >> 8;
1911 /* get to color */
1912 elem = WMGetFromPLArray(pl, 4);
1913 if (!elem || !WMIsPLString(elem)) {
1914 return NULL;
1916 val = WMGetFromPLString(elem);
1918 if (!XParseColor(dpy, scr->w_colormap, val, &xcolor)) {
1919 wwarning(_("\"%s\" is not a valid color name"), val);
1920 return NULL;
1922 color2.alpha = 255;
1923 color2.red = xcolor.red >> 8;
1924 color2.green = xcolor.green >> 8;
1925 color2.blue = xcolor.blue >> 8;
1927 /* get opacity */
1928 elem = WMGetFromPLArray(pl, 2);
1929 if (!elem || !WMIsPLString(elem))
1930 opacity = 128;
1931 else
1932 val = WMGetFromPLString(elem);
1934 if (!val || (opacity = atoi(val)) < 0 || opacity > 255) {
1935 wwarning(_("bad opacity value for tgradient texture \"%s\". Should be [0..255]"), val);
1936 opacity = 128;
1939 /* get file name */
1940 elem = WMGetFromPLArray(pl, 1);
1941 if (!elem || !WMIsPLString(elem))
1942 return NULL;
1943 val = WMGetFromPLString(elem);
1945 texture = (WTexture *) wTextureMakeTGradient(scr, style, &color1, &color2, val, opacity);
1946 } else if (strcasecmp(val, "function") == 0) {
1947 /* Leave this in to handle the unlikely case of
1948 * someone actually having function textures configured */
1949 wwarning("function texture support has been removed");
1950 return NULL;
1951 } else {
1952 wwarning(_("invalid texture type %s"), val);
1953 return NULL;
1955 return texture;
1958 static int getTexture(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1960 static WTexture *texture;
1961 int changed = 0;
1963 again:
1964 if (!WMIsPLArray(value)) {
1965 wwarning(_("Wrong option format for key \"%s\". Should be %s."), entry->key, "Texture");
1966 if (changed == 0) {
1967 value = entry->plvalue;
1968 changed = 1;
1969 wwarning(_("using default \"%s\" instead"), entry->default_value);
1970 goto again;
1972 return False;
1975 if (strcmp(entry->key, "WidgetColor") == 0 && !changed) {
1976 WMPropList *pl;
1978 pl = WMGetFromPLArray(value, 0);
1979 if (!pl || !WMIsPLString(pl) || !WMGetFromPLString(pl)
1980 || strcasecmp(WMGetFromPLString(pl), "solid") != 0) {
1981 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1982 entry->key, "Solid Texture");
1984 value = entry->plvalue;
1985 changed = 1;
1986 wwarning(_("using default \"%s\" instead"), entry->default_value);
1987 goto again;
1991 texture = parse_texture(scr, value);
1993 if (!texture) {
1994 wwarning(_("Error in texture specification for key \"%s\""), entry->key);
1995 if (changed == 0) {
1996 value = entry->plvalue;
1997 changed = 1;
1998 wwarning(_("using default \"%s\" instead"), entry->default_value);
1999 goto again;
2001 return False;
2004 if (ret)
2005 *ret = &texture;
2007 if (addr)
2008 *(WTexture **) addr = texture;
2010 return True;
2013 static int getWSBackground(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
2015 WMPropList *elem;
2016 int changed = 0;
2017 char *val;
2018 int nelem;
2020 /* Parameter not used, but tell the compiler that it is ok */
2021 (void) scr;
2022 (void) addr;
2024 again:
2025 if (!WMIsPLArray(value)) {
2026 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
2027 "WorkspaceBack", "Texture or None");
2028 if (changed == 0) {
2029 value = entry->plvalue;
2030 changed = 1;
2031 wwarning(_("using default \"%s\" instead"), entry->default_value);
2032 goto again;
2034 return False;
2037 /* only do basic error checking and verify for None texture */
2039 nelem = WMGetPropListItemCount(value);
2040 if (nelem > 0) {
2041 elem = WMGetFromPLArray(value, 0);
2042 if (!elem || !WMIsPLString(elem)) {
2043 wwarning(_("Wrong type for workspace background. Should be a texture type."));
2044 if (changed == 0) {
2045 value = entry->plvalue;
2046 changed = 1;
2047 wwarning(_("using default \"%s\" instead"), entry->default_value);
2048 goto again;
2050 return False;
2052 val = WMGetFromPLString(elem);
2054 if (strcasecmp(val, "None") == 0)
2055 return True;
2057 *ret = WMRetainPropList(value);
2059 return True;
2062 static int
2063 getWSSpecificBackground(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
2065 WMPropList *elem;
2066 int nelem;
2067 int changed = 0;
2069 /* Parameter not used, but tell the compiler that it is ok */
2070 (void) scr;
2071 (void) addr;
2073 again:
2074 if (!WMIsPLArray(value)) {
2075 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
2076 "WorkspaceSpecificBack", "an array of textures");
2077 if (changed == 0) {
2078 value = entry->plvalue;
2079 changed = 1;
2080 wwarning(_("using default \"%s\" instead"), entry->default_value);
2081 goto again;
2083 return False;
2086 /* only do basic error checking and verify for None texture */
2088 nelem = WMGetPropListItemCount(value);
2089 if (nelem > 0) {
2090 while (nelem--) {
2091 elem = WMGetFromPLArray(value, nelem);
2092 if (!elem || !WMIsPLArray(elem)) {
2093 wwarning(_("Wrong type for background of workspace %i. Should be a texture."),
2094 nelem);
2099 *ret = WMRetainPropList(value);
2101 #ifdef notworking
2103 * Kluge to force wmsetbg helper to set the default background.
2104 * If the WorkspaceSpecificBack is changed once wmaker has started,
2105 * the WorkspaceBack won't be sent to the helper, unless the user
2106 * changes its value too. So, we must force this by removing the
2107 * value from the defaults DB.
2109 if (!scr->flags.backimage_helper_launched && !scr->flags.startup) {
2110 WMPropList *key = WMCreatePLString("WorkspaceBack");
2112 WMRemoveFromPLDictionary(w_global.domain.wmaker->dictionary, key);
2114 WMReleasePropList(key);
2116 #endif
2117 return True;
2120 static int getFont(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
2122 static WMFont *font;
2123 const char *val;
2125 (void) addr;
2127 GET_STRING_OR_DEFAULT("Font", val);
2129 font = WMCreateFont(scr->wmscreen, val);
2130 if (!font)
2131 font = WMCreateFont(scr->wmscreen, "fixed");
2133 if (!font) {
2134 wfatal(_("could not load any usable font!!!"));
2135 exit(1);
2138 if (ret)
2139 *ret = font;
2141 /* can't assign font value outside update function */
2142 wassertrv(addr == NULL, True);
2144 return True;
2147 static int getColor(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
2149 static XColor color;
2150 const char *val;
2151 int second_pass = 0;
2153 (void) addr;
2155 GET_STRING_OR_DEFAULT("Color", val);
2157 again:
2158 if (!wGetColor(scr, val, &color)) {
2159 wwarning(_("could not get color for key \"%s\""), entry->key);
2160 if (second_pass == 0) {
2161 val = WMGetFromPLString(entry->plvalue);
2162 second_pass = 1;
2163 wwarning(_("using default \"%s\" instead"), val);
2164 goto again;
2166 return False;
2169 if (ret)
2170 *ret = &color;
2172 assert(addr == NULL);
2174 if (addr)
2175 *(unsigned long*)addr = pixel;
2178 return True;
2181 static int getKeybind(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
2183 static WShortKey shortcut;
2184 KeySym ksym;
2185 const char *val;
2186 char *k;
2187 char buf[MAX_SHORTCUT_LENGTH], *b;
2189 /* Parameter not used, but tell the compiler that it is ok */
2190 (void) scr;
2191 (void) addr;
2193 GET_STRING_OR_DEFAULT("Key spec", val);
2195 if (!val || strcasecmp(val, "NONE") == 0) {
2196 shortcut.keycode = 0;
2197 shortcut.modifier = 0;
2198 if (ret)
2199 *ret = &shortcut;
2200 return True;
2203 wstrlcpy(buf, val, MAX_SHORTCUT_LENGTH);
2205 b = (char *)buf;
2207 /* get modifiers */
2208 shortcut.modifier = 0;
2209 while ((k = strchr(b, '+')) != NULL) {
2210 int mod;
2212 *k = 0;
2213 mod = wXModifierFromKey(b);
2214 if (mod < 0) {
2215 wwarning(_("%s: invalid key modifier \"%s\""), entry->key, b);
2216 return False;
2218 shortcut.modifier |= mod;
2220 b = k + 1;
2223 /* get key */
2224 ksym = XStringToKeysym(b);
2226 if (ksym == NoSymbol) {
2227 wwarning(_("%s:invalid kbd shortcut specification \"%s\""), entry->key, val);
2228 return False;
2231 shortcut.keycode = XKeysymToKeycode(dpy, ksym);
2232 if (shortcut.keycode == 0) {
2233 wwarning(_("%s:invalid key in shortcut \"%s\""), entry->key, val);
2234 return False;
2237 if (ret)
2238 *ret = &shortcut;
2240 return True;
2243 static int getModMask(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
2245 static int mask;
2246 const char *str;
2248 /* Parameter not used, but tell the compiler that it is ok */
2249 (void) scr;
2251 GET_STRING_OR_DEFAULT("Modifier Key", str);
2253 if (!str)
2254 return False;
2256 mask = wXModifierFromKey(str);
2257 if (mask < 0) {
2258 wwarning(_("%s: modifier key %s is not valid"), entry->key, str);
2259 mask = 0;
2260 return False;
2263 if (addr)
2264 *(int *)addr = mask;
2266 if (ret)
2267 *ret = &mask;
2269 return True;
2272 # include <X11/cursorfont.h>
2273 typedef struct {
2274 const char *name;
2275 int id;
2276 } WCursorLookup;
2278 #define CURSOR_ID_NONE (XC_num_glyphs)
2280 static const WCursorLookup cursor_table[] = {
2281 {"X_cursor", XC_X_cursor},
2282 {"arrow", XC_arrow},
2283 {"based_arrow_down", XC_based_arrow_down},
2284 {"based_arrow_up", XC_based_arrow_up},
2285 {"boat", XC_boat},
2286 {"bogosity", XC_bogosity},
2287 {"bottom_left_corner", XC_bottom_left_corner},
2288 {"bottom_right_corner", XC_bottom_right_corner},
2289 {"bottom_side", XC_bottom_side},
2290 {"bottom_tee", XC_bottom_tee},
2291 {"box_spiral", XC_box_spiral},
2292 {"center_ptr", XC_center_ptr},
2293 {"circle", XC_circle},
2294 {"clock", XC_clock},
2295 {"coffee_mug", XC_coffee_mug},
2296 {"cross", XC_cross},
2297 {"cross_reverse", XC_cross_reverse},
2298 {"crosshair", XC_crosshair},
2299 {"diamond_cross", XC_diamond_cross},
2300 {"dot", XC_dot},
2301 {"dotbox", XC_dotbox},
2302 {"double_arrow", XC_double_arrow},
2303 {"draft_large", XC_draft_large},
2304 {"draft_small", XC_draft_small},
2305 {"draped_box", XC_draped_box},
2306 {"exchange", XC_exchange},
2307 {"fleur", XC_fleur},
2308 {"gobbler", XC_gobbler},
2309 {"gumby", XC_gumby},
2310 {"hand1", XC_hand1},
2311 {"hand2", XC_hand2},
2312 {"heart", XC_heart},
2313 {"icon", XC_icon},
2314 {"iron_cross", XC_iron_cross},
2315 {"left_ptr", XC_left_ptr},
2316 {"left_side", XC_left_side},
2317 {"left_tee", XC_left_tee},
2318 {"leftbutton", XC_leftbutton},
2319 {"ll_angle", XC_ll_angle},
2320 {"lr_angle", XC_lr_angle},
2321 {"man", XC_man},
2322 {"middlebutton", XC_middlebutton},
2323 {"mouse", XC_mouse},
2324 {"pencil", XC_pencil},
2325 {"pirate", XC_pirate},
2326 {"plus", XC_plus},
2327 {"question_arrow", XC_question_arrow},
2328 {"right_ptr", XC_right_ptr},
2329 {"right_side", XC_right_side},
2330 {"right_tee", XC_right_tee},
2331 {"rightbutton", XC_rightbutton},
2332 {"rtl_logo", XC_rtl_logo},
2333 {"sailboat", XC_sailboat},
2334 {"sb_down_arrow", XC_sb_down_arrow},
2335 {"sb_h_double_arrow", XC_sb_h_double_arrow},
2336 {"sb_left_arrow", XC_sb_left_arrow},
2337 {"sb_right_arrow", XC_sb_right_arrow},
2338 {"sb_up_arrow", XC_sb_up_arrow},
2339 {"sb_v_double_arrow", XC_sb_v_double_arrow},
2340 {"shuttle", XC_shuttle},
2341 {"sizing", XC_sizing},
2342 {"spider", XC_spider},
2343 {"spraycan", XC_spraycan},
2344 {"star", XC_star},
2345 {"target", XC_target},
2346 {"tcross", XC_tcross},
2347 {"top_left_arrow", XC_top_left_arrow},
2348 {"top_left_corner", XC_top_left_corner},
2349 {"top_right_corner", XC_top_right_corner},
2350 {"top_side", XC_top_side},
2351 {"top_tee", XC_top_tee},
2352 {"trek", XC_trek},
2353 {"ul_angle", XC_ul_angle},
2354 {"umbrella", XC_umbrella},
2355 {"ur_angle", XC_ur_angle},
2356 {"watch", XC_watch},
2357 {"xterm", XC_xterm},
2358 {NULL, CURSOR_ID_NONE}
2361 static void check_bitmap_status(int status, const char *filename, Pixmap bitmap)
2363 switch (status) {
2364 case BitmapOpenFailed:
2365 wwarning(_("failed to open bitmap file \"%s\""), filename);
2366 break;
2367 case BitmapFileInvalid:
2368 wwarning(_("\"%s\" is not a valid bitmap file"), filename);
2369 break;
2370 case BitmapNoMemory:
2371 wwarning(_("out of memory reading bitmap file \"%s\""), filename);
2372 break;
2373 case BitmapSuccess:
2374 XFreePixmap(dpy, bitmap);
2375 break;
2380 * (none)
2381 * (builtin, <cursor_name>)
2382 * (bitmap, <cursor_bitmap>, <cursor_mask>)
2384 static int parse_cursor(WScreen * scr, WMPropList * pl, Cursor * cursor)
2386 WMPropList *elem;
2387 char *val;
2388 int nelem;
2389 int status = 0;
2391 nelem = WMGetPropListItemCount(pl);
2392 if (nelem < 1) {
2393 return (status);
2395 elem = WMGetFromPLArray(pl, 0);
2396 if (!elem || !WMIsPLString(elem)) {
2397 return (status);
2399 val = WMGetFromPLString(elem);
2401 if (strcasecmp(val, "none") == 0) {
2402 status = 1;
2403 *cursor = None;
2404 } else if (strcasecmp(val, "builtin") == 0) {
2405 int i;
2406 int cursor_id = CURSOR_ID_NONE;
2408 if (nelem != 2) {
2409 wwarning(_("bad number of arguments in cursor specification"));
2410 return (status);
2412 elem = WMGetFromPLArray(pl, 1);
2413 if (!elem || !WMIsPLString(elem)) {
2414 return (status);
2416 val = WMGetFromPLString(elem);
2418 for (i = 0; cursor_table[i].name != NULL; i++) {
2419 if (strcasecmp(val, cursor_table[i].name) == 0) {
2420 cursor_id = cursor_table[i].id;
2421 break;
2424 if (CURSOR_ID_NONE == cursor_id) {
2425 wwarning(_("unknown builtin cursor name \"%s\""), val);
2426 } else {
2427 *cursor = XCreateFontCursor(dpy, cursor_id);
2428 status = 1;
2430 } else if (strcasecmp(val, "bitmap") == 0) {
2431 char *bitmap_name;
2432 char *mask_name;
2433 int bitmap_status;
2434 int mask_status;
2435 Pixmap bitmap;
2436 Pixmap mask;
2437 unsigned int w, h;
2438 int x, y;
2439 XColor fg, bg;
2441 if (nelem != 3) {
2442 wwarning(_("bad number of arguments in cursor specification"));
2443 return (status);
2445 elem = WMGetFromPLArray(pl, 1);
2446 if (!elem || !WMIsPLString(elem)) {
2447 return (status);
2449 val = WMGetFromPLString(elem);
2450 bitmap_name = FindImage(wPreferences.pixmap_path, val);
2451 if (!bitmap_name) {
2452 wwarning(_("could not find cursor bitmap file \"%s\""), val);
2453 return (status);
2455 elem = WMGetFromPLArray(pl, 2);
2456 if (!elem || !WMIsPLString(elem)) {
2457 wfree(bitmap_name);
2458 return (status);
2460 val = WMGetFromPLString(elem);
2461 mask_name = FindImage(wPreferences.pixmap_path, val);
2462 if (!mask_name) {
2463 wfree(bitmap_name);
2464 wwarning(_("could not find cursor bitmap file \"%s\""), val);
2465 return (status);
2467 mask_status = XReadBitmapFile(dpy, scr->w_win, mask_name, &w, &h, &mask, &x, &y);
2468 bitmap_status = XReadBitmapFile(dpy, scr->w_win, bitmap_name, &w, &h, &bitmap, &x, &y);
2469 if ((BitmapSuccess == bitmap_status) && (BitmapSuccess == mask_status)) {
2470 fg.pixel = scr->black_pixel;
2471 bg.pixel = scr->white_pixel;
2472 XQueryColor(dpy, scr->w_colormap, &fg);
2473 XQueryColor(dpy, scr->w_colormap, &bg);
2474 *cursor = XCreatePixmapCursor(dpy, bitmap, mask, &fg, &bg, x, y);
2475 status = 1;
2477 check_bitmap_status(bitmap_status, bitmap_name, bitmap);
2478 check_bitmap_status(mask_status, mask_name, mask);
2479 wfree(bitmap_name);
2480 wfree(mask_name);
2482 return (status);
2485 static int getCursor(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
2487 static Cursor cursor;
2488 int status;
2489 int changed = 0;
2491 again:
2492 if (!WMIsPLArray(value)) {
2493 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
2494 entry->key, "cursor specification");
2495 if (!changed) {
2496 value = entry->plvalue;
2497 changed = 1;
2498 wwarning(_("using default \"%s\" instead"), entry->default_value);
2499 goto again;
2501 return (False);
2503 status = parse_cursor(scr, value, &cursor);
2504 if (!status) {
2505 wwarning(_("Error in cursor specification for key \"%s\""), entry->key);
2506 if (!changed) {
2507 value = entry->plvalue;
2508 changed = 1;
2509 wwarning(_("using default \"%s\" instead"), entry->default_value);
2510 goto again;
2512 return (False);
2514 if (ret) {
2515 *ret = &cursor;
2517 if (addr) {
2518 *(Cursor *) addr = cursor;
2520 return (True);
2523 #undef CURSOR_ID_NONE
2525 /* ---------------- value setting functions --------------- */
2526 static int setJustify(WScreen * scr, WDefaultEntry * entry, void *tdata, void *extra_data)
2528 /* Parameter not used, but tell the compiler that it is ok */
2529 (void) scr;
2530 (void) entry;
2531 (void) tdata;
2532 (void) extra_data;
2534 return REFRESH_WINDOW_TITLE_COLOR;
2537 static int setClearance(WScreen * scr, WDefaultEntry * entry, void *bar, void *foo)
2539 /* Parameter not used, but tell the compiler that it is ok */
2540 (void) scr;
2541 (void) entry;
2542 (void) bar;
2543 (void) foo;
2545 return REFRESH_WINDOW_FONT | REFRESH_BUTTON_IMAGES | REFRESH_MENU_TITLE_FONT | REFRESH_MENU_FONT;
2548 static int setIfDockPresent(WScreen * scr, WDefaultEntry * entry, void *tdata, void *extra_data)
2550 char *flag = tdata;
2551 long which = (long) extra_data;
2553 /* Parameter not used, but tell the compiler that it is ok */
2554 (void) scr;
2555 (void) entry;
2557 switch (which) {
2558 case WM_DOCK:
2559 wPreferences.flags.nodock = wPreferences.flags.nodock || *flag;
2560 // Drawers require the dock
2561 wPreferences.flags.nodrawer = wPreferences.flags.nodrawer || wPreferences.flags.nodock;
2562 break;
2563 case WM_CLIP:
2564 wPreferences.flags.noclip = wPreferences.flags.noclip || *flag;
2565 break;
2566 case WM_DRAWER:
2567 wPreferences.flags.nodrawer = wPreferences.flags.nodrawer || *flag;
2568 break;
2569 default:
2570 break;
2572 return 0;
2575 static int setClipMergedInDock(WScreen *scr, WDefaultEntry *entry, void *tdata, void *foo)
2577 char *flag = tdata;
2579 /* Parameter not used, but tell the compiler that it is ok */
2580 (void) scr;
2581 (void) entry;
2582 (void) foo;
2584 wPreferences.flags.clip_merged_in_dock = *flag;
2585 wPreferences.flags.noclip = wPreferences.flags.noclip || *flag;
2586 return 0;
2589 static int setWrapAppiconsInDock(WScreen *scr, WDefaultEntry *entry, void *tdata, void *foo)
2591 char *flag = tdata;
2593 /* Parameter not used, but tell the compiler that it is ok */
2594 (void) scr;
2595 (void) entry;
2596 (void) foo;
2598 wPreferences.flags.wrap_appicons_in_dock = *flag;
2599 return 0;
2602 static int setStickyIcons(WScreen * scr, WDefaultEntry * entry, void *bar, void *foo)
2604 /* Parameter not used, but tell the compiler that it is ok */
2605 (void) entry;
2606 (void) bar;
2607 (void) foo;
2609 if (scr->workspaces) {
2610 wWorkspaceForceChange(scr, scr->current_workspace);
2611 wArrangeIcons(scr, False);
2613 return 0;
2616 static int setIconTile(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2618 Pixmap pixmap;
2619 RImage *img;
2620 WTexture ** texture = tdata;
2621 int reset = 0;
2623 /* Parameter not used, but tell the compiler that it is ok */
2624 (void) foo;
2626 img = wTextureRenderImage(*texture, wPreferences.icon_size,
2627 wPreferences.icon_size, ((*texture)->any.type & WREL_BORDER_MASK)
2628 ? WREL_ICON : WREL_FLAT);
2629 if (!img) {
2630 wwarning(_("could not render texture for icon background"));
2631 if (!entry->addr)
2632 wTextureDestroy(scr, *texture);
2633 return 0;
2635 RConvertImage(scr->rcontext, img, &pixmap);
2637 if (scr->icon_tile) {
2638 reset = 1;
2639 RReleaseImage(scr->icon_tile);
2640 XFreePixmap(dpy, scr->icon_tile_pixmap);
2643 scr->icon_tile = img;
2645 /* put the icon in the noticeboard hint */
2646 PropSetIconTileHint(scr, img);
2648 if (!wPreferences.flags.noclip || wPreferences.flags.clip_merged_in_dock) {
2649 if (scr->clip_tile) {
2650 RReleaseImage(scr->clip_tile);
2652 scr->clip_tile = wClipMakeTile(img);
2655 if (!wPreferences.flags.nodrawer) {
2656 if (scr->drawer_tile) {
2657 RReleaseImage(scr->drawer_tile);
2659 scr->drawer_tile = wDrawerMakeTile(scr, img);
2662 scr->icon_tile_pixmap = pixmap;
2664 if (scr->def_icon_rimage) {
2665 RReleaseImage(scr->def_icon_rimage);
2666 scr->def_icon_rimage = NULL;
2669 if (scr->icon_back_texture)
2670 wTextureDestroy(scr, (WTexture *) scr->icon_back_texture);
2672 scr->icon_back_texture = wTextureMakeSolid(scr, &((*texture)->any.color));
2674 /* Free the texture as nobody else will use it, nor refer to it. */
2675 if (!entry->addr)
2676 wTextureDestroy(scr, *texture);
2678 return (reset ? REFRESH_ICON_TILE : 0);
2681 static int setWinTitleFont(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2683 WMFont *font = tdata;
2685 /* Parameter not used, but tell the compiler that it is ok */
2686 (void) entry;
2687 (void) foo;
2689 if (scr->title_font) {
2690 WMReleaseFont(scr->title_font);
2692 scr->title_font = font;
2694 return REFRESH_WINDOW_FONT | REFRESH_BUTTON_IMAGES;
2697 static int setMenuTitleFont(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2699 WMFont *font = tdata;
2701 /* Parameter not used, but tell the compiler that it is ok */
2702 (void) entry;
2703 (void) foo;
2705 if (scr->menu_title_font) {
2706 WMReleaseFont(scr->menu_title_font);
2709 scr->menu_title_font = font;
2711 return REFRESH_MENU_TITLE_FONT;
2714 static int setMenuTextFont(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2716 WMFont *font = tdata;
2718 /* Parameter not used, but tell the compiler that it is ok */
2719 (void) entry;
2720 (void) foo;
2722 if (scr->menu_entry_font) {
2723 WMReleaseFont(scr->menu_entry_font);
2725 scr->menu_entry_font = font;
2727 return REFRESH_MENU_FONT;
2730 static int setIconTitleFont(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2732 WMFont *font = tdata;
2734 /* Parameter not used, but tell the compiler that it is ok */
2735 (void) entry;
2736 (void) foo;
2738 if (scr->icon_title_font) {
2739 WMReleaseFont(scr->icon_title_font);
2742 scr->icon_title_font = font;
2744 return REFRESH_ICON_FONT;
2747 static int setClipTitleFont(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2749 WMFont *font = tdata;
2751 /* Parameter not used, but tell the compiler that it is ok */
2752 (void) entry;
2753 (void) foo;
2755 if (scr->clip_title_font) {
2756 WMReleaseFont(scr->clip_title_font);
2759 scr->clip_title_font = font;
2761 return REFRESH_ICON_FONT;
2764 static int setLargeDisplayFont(WScreen *scr, WDefaultEntry *entry, void *tdata, void *foo)
2766 WMFont *font = tdata;
2768 /* Parameter not used, but tell the compiler that it is ok */
2769 (void) scr;
2770 (void) entry;
2771 (void) foo;
2773 if (scr->workspace_name_font)
2774 WMReleaseFont(scr->workspace_name_font);
2776 scr->workspace_name_font = font;
2778 return 0;
2781 static int setHightlight(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2783 XColor *color = tdata;
2785 /* Parameter not used, but tell the compiler that it is ok */
2786 (void) entry;
2787 (void) foo;
2789 if (scr->select_color)
2790 WMReleaseColor(scr->select_color);
2792 scr->select_color = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2794 wFreeColor(scr, color->pixel);
2796 return REFRESH_MENU_COLOR;
2799 static int setHightlightText(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2801 XColor *color = tdata;
2803 /* Parameter not used, but tell the compiler that it is ok */
2804 (void) entry;
2805 (void) foo;
2807 if (scr->select_text_color)
2808 WMReleaseColor(scr->select_text_color);
2810 scr->select_text_color = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2812 wFreeColor(scr, color->pixel);
2814 return REFRESH_MENU_COLOR;
2817 static int setClipTitleColor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *extra_data)
2819 XColor *color = tdata;
2820 long widx = (long) extra_data;
2822 /* Parameter not used, but tell the compiler that it is ok */
2823 (void) entry;
2825 if (scr->clip_title_color[widx])
2826 WMReleaseColor(scr->clip_title_color[widx]);
2828 scr->clip_title_color[widx] = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2829 wFreeColor(scr, color->pixel);
2831 return REFRESH_ICON_TITLE_COLOR;
2834 static int setWTitleColor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *extra_data)
2836 XColor *color = tdata;
2837 long widx = (long) extra_data;
2839 /* Parameter not used, but tell the compiler that it is ok */
2840 (void) entry;
2842 if (scr->window_title_color[widx])
2843 WMReleaseColor(scr->window_title_color[widx]);
2845 scr->window_title_color[widx] =
2846 WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2848 wFreeColor(scr, color->pixel);
2850 return REFRESH_WINDOW_TITLE_COLOR;
2853 static int setMenuTitleColor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *extra_data)
2855 XColor *color = tdata;
2857 /* Parameter not used, but tell the compiler that it is ok */
2858 (void) entry;
2859 (void) extra_data;
2861 if (scr->menu_title_color[0])
2862 WMReleaseColor(scr->menu_title_color[0]);
2864 scr->menu_title_color[0] = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2866 wFreeColor(scr, color->pixel);
2868 return REFRESH_MENU_TITLE_COLOR;
2871 static int setMenuTextColor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2873 XColor *color = tdata;
2875 /* Parameter not used, but tell the compiler that it is ok */
2876 (void) entry;
2877 (void) foo;
2879 if (scr->mtext_color)
2880 WMReleaseColor(scr->mtext_color);
2882 scr->mtext_color = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2884 if (WMColorPixel(scr->dtext_color) == WMColorPixel(scr->mtext_color)) {
2885 WMSetColorAlpha(scr->dtext_color, 0x7fff);
2886 } else {
2887 WMSetColorAlpha(scr->dtext_color, 0xffff);
2890 wFreeColor(scr, color->pixel);
2892 return REFRESH_MENU_COLOR;
2895 static int setMenuDisabledColor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2897 XColor *color = tdata;
2899 /* Parameter not used, but tell the compiler that it is ok */
2900 (void) entry;
2901 (void) foo;
2903 if (scr->dtext_color)
2904 WMReleaseColor(scr->dtext_color);
2906 scr->dtext_color = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2908 if (WMColorPixel(scr->dtext_color) == WMColorPixel(scr->mtext_color)) {
2909 WMSetColorAlpha(scr->dtext_color, 0x7fff);
2910 } else {
2911 WMSetColorAlpha(scr->dtext_color, 0xffff);
2914 wFreeColor(scr, color->pixel);
2916 return REFRESH_MENU_COLOR;
2919 static int setIconTitleColor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2921 XColor *color = tdata;
2923 /* Parameter not used, but tell the compiler that it is ok */
2924 (void) entry;
2925 (void) foo;
2927 if (scr->icon_title_color)
2928 WMReleaseColor(scr->icon_title_color);
2929 scr->icon_title_color = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2931 wFreeColor(scr, color->pixel);
2933 return REFRESH_ICON_TITLE_COLOR;
2936 static int setIconTitleBack(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2938 XColor *color = tdata;
2940 /* Parameter not used, but tell the compiler that it is ok */
2941 (void) entry;
2942 (void) foo;
2944 if (scr->icon_title_texture) {
2945 wTextureDestroy(scr, (WTexture *) scr->icon_title_texture);
2947 scr->icon_title_texture = wTextureMakeSolid(scr, color);
2949 return REFRESH_ICON_TITLE_BACK;
2952 static int setFrameBorderWidth(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2954 int *value = tdata;
2956 /* Parameter not used, but tell the compiler that it is ok */
2957 (void) entry;
2958 (void) foo;
2960 scr->frame_border_width = *value;
2962 return REFRESH_FRAME_BORDER;
2965 static int setFrameBorderColor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2967 XColor *color = tdata;
2969 /* Parameter not used, but tell the compiler that it is ok */
2970 (void) entry;
2971 (void) foo;
2973 if (scr->frame_border_color)
2974 WMReleaseColor(scr->frame_border_color);
2975 scr->frame_border_color = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2977 wFreeColor(scr, color->pixel);
2979 return REFRESH_FRAME_BORDER;
2982 static int setFrameFocusedBorderColor(WScreen *scr, WDefaultEntry *entry, void *tdata, void *foo)
2984 XColor *color = tdata;
2986 /* Parameter not used, but tell the compiler that it is ok */
2987 (void) entry;
2988 (void) foo;
2990 if (scr->frame_focused_border_color)
2991 WMReleaseColor(scr->frame_focused_border_color);
2992 scr->frame_focused_border_color = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2994 wFreeColor(scr, color->pixel);
2996 return REFRESH_FRAME_BORDER;
2999 static int setFrameSelectedBorderColor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
3001 XColor *color = tdata;
3003 /* Parameter not used, but tell the compiler that it is ok */
3004 (void) entry;
3005 (void) foo;
3007 if (scr->frame_selected_border_color)
3008 WMReleaseColor(scr->frame_selected_border_color);
3009 scr->frame_selected_border_color = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
3011 wFreeColor(scr, color->pixel);
3013 return REFRESH_FRAME_BORDER;
3016 static int setWorkspaceSpecificBack(WScreen * scr, WDefaultEntry * entry, void *tdata, void *bar)
3018 WMPropList *value = tdata;
3019 WMPropList *val;
3020 char *str;
3021 int i;
3023 /* Parameter not used, but tell the compiler that it is ok */
3024 (void) entry;
3025 (void) bar;
3027 if (scr->flags.backimage_helper_launched) {
3028 if (WMGetPropListItemCount(value) == 0) {
3029 SendHelperMessage(scr, 'C', 0, NULL);
3030 SendHelperMessage(scr, 'K', 0, NULL);
3032 WMReleasePropList(value);
3033 return 0;
3035 } else {
3036 if (WMGetPropListItemCount(value) == 0)
3037 return 0;
3039 if (!start_bg_helper(scr)) {
3040 WMReleasePropList(value);
3041 return 0;
3044 SendHelperMessage(scr, 'P', -1, wPreferences.pixmap_path);
3047 for (i = 0; i < WMGetPropListItemCount(value); i++) {
3048 val = WMGetFromPLArray(value, i);
3049 if (val && WMIsPLArray(val) && WMGetPropListItemCount(val) > 0) {
3050 str = WMGetPropListDescription(val, False);
3052 SendHelperMessage(scr, 'S', i + 1, str);
3054 wfree(str);
3055 } else {
3056 SendHelperMessage(scr, 'U', i + 1, NULL);
3059 sleep(1);
3061 WMReleasePropList(value);
3062 return 0;
3065 static int setWorkspaceBack(WScreen * scr, WDefaultEntry * entry, void *tdata, void *bar)
3067 WMPropList *value = tdata;
3069 /* Parameter not used, but tell the compiler that it is ok */
3070 (void) entry;
3071 (void) bar;
3073 if (scr->flags.backimage_helper_launched) {
3074 char *str;
3076 if (WMGetPropListItemCount(value) == 0) {
3077 SendHelperMessage(scr, 'U', 0, NULL);
3078 } else {
3079 /* set the default workspace background to this one */
3080 str = WMGetPropListDescription(value, False);
3081 if (str) {
3082 SendHelperMessage(scr, 'S', 0, str);
3083 wfree(str);
3084 SendHelperMessage(scr, 'C', scr->current_workspace + 1, NULL);
3085 } else {
3086 SendHelperMessage(scr, 'U', 0, NULL);
3089 } else if (WMGetPropListItemCount(value) > 0) {
3090 char *text;
3091 char *dither;
3092 int len;
3094 text = WMGetPropListDescription(value, False);
3095 len = strlen(text) + 40;
3096 dither = wPreferences.no_dithering ? "-m" : "-d";
3097 if (!strchr(text, '\'') && !strchr(text, '\\')) {
3098 char command[len];
3100 if (wPreferences.smooth_workspace_back)
3101 snprintf(command, len, "wmsetbg %s -S -p '%s' &", dither, text);
3102 else
3103 snprintf(command, len, "wmsetbg %s -p '%s' &", dither, text);
3104 ExecuteShellCommand(scr, command);
3105 } else
3106 wwarning(_("Invalid arguments for background \"%s\""), text);
3107 wfree(text);
3109 WMReleasePropList(value);
3111 return 0;
3114 static int setWidgetColor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
3116 WTexture **texture = tdata;
3118 /* Parameter not used, but tell the compiler that it is ok */
3119 (void) entry;
3120 (void) foo;
3122 if (scr->widget_texture) {
3123 wTextureDestroy(scr, (WTexture *) scr->widget_texture);
3125 scr->widget_texture = *(WTexSolid **) texture;
3127 return 0;
3130 static int setFTitleBack(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
3132 WTexture **texture = tdata;
3134 /* Parameter not used, but tell the compiler that it is ok */
3135 (void) entry;
3136 (void) foo;
3138 if (scr->window_title_texture[WS_FOCUSED]) {
3139 wTextureDestroy(scr, scr->window_title_texture[WS_FOCUSED]);
3141 scr->window_title_texture[WS_FOCUSED] = *texture;
3143 return REFRESH_WINDOW_TEXTURES;
3146 static int setPTitleBack(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
3148 WTexture **texture = tdata;
3150 /* Parameter not used, but tell the compiler that it is ok */
3151 (void) entry;
3152 (void) foo;
3154 if (scr->window_title_texture[WS_PFOCUSED]) {
3155 wTextureDestroy(scr, scr->window_title_texture[WS_PFOCUSED]);
3157 scr->window_title_texture[WS_PFOCUSED] = *texture;
3159 return REFRESH_WINDOW_TEXTURES;
3162 static int setUTitleBack(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
3164 WTexture **texture = tdata;
3166 /* Parameter not used, but tell the compiler that it is ok */
3167 (void) entry;
3168 (void) foo;
3170 if (scr->window_title_texture[WS_UNFOCUSED]) {
3171 wTextureDestroy(scr, scr->window_title_texture[WS_UNFOCUSED]);
3173 scr->window_title_texture[WS_UNFOCUSED] = *texture;
3175 return REFRESH_WINDOW_TEXTURES;
3178 static int setResizebarBack(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
3180 WTexture **texture = tdata;
3182 /* Parameter not used, but tell the compiler that it is ok */
3183 (void) entry;
3184 (void) foo;
3186 if (scr->resizebar_texture[0]) {
3187 wTextureDestroy(scr, scr->resizebar_texture[0]);
3189 scr->resizebar_texture[0] = *texture;
3191 return REFRESH_WINDOW_TEXTURES;
3194 static int setMenuTitleBack(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
3196 WTexture **texture = tdata;
3198 /* Parameter not used, but tell the compiler that it is ok */
3199 (void) entry;
3200 (void) foo;
3202 if (scr->menu_title_texture[0]) {
3203 wTextureDestroy(scr, scr->menu_title_texture[0]);
3205 scr->menu_title_texture[0] = *texture;
3207 return REFRESH_MENU_TITLE_TEXTURE;
3210 static int setMenuTextBack(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
3212 WTexture **texture = tdata;
3214 /* Parameter not used, but tell the compiler that it is ok */
3215 (void) entry;
3216 (void) foo;
3218 if (scr->menu_item_texture) {
3219 wTextureDestroy(scr, scr->menu_item_texture);
3220 wTextureDestroy(scr, (WTexture *) scr->menu_item_auxtexture);
3222 scr->menu_item_texture = *texture;
3224 scr->menu_item_auxtexture = wTextureMakeSolid(scr, &scr->menu_item_texture->any.color);
3226 return REFRESH_MENU_TEXTURE;
3229 static int setKeyGrab(WScreen * scr, WDefaultEntry * entry, void *tdata, void *extra_data)
3231 WShortKey *shortcut = tdata;
3232 WWindow *wwin;
3233 long widx = (long) extra_data;
3235 /* Parameter not used, but tell the compiler that it is ok */
3236 (void) entry;
3238 wKeyBindings[widx] = *shortcut;
3240 wwin = scr->focused_window;
3242 while (wwin != NULL) {
3243 XUngrabKey(dpy, AnyKey, AnyModifier, wwin->frame->core->window);
3245 if (!WFLAGP(wwin, no_bind_keys)) {
3246 wWindowSetKeyGrabs(wwin);
3248 wwin = wwin->prev;
3251 /* do we need to update window menus? */
3252 if (widx >= WKBD_WORKSPACE1 && widx <= WKBD_WORKSPACE10)
3253 return REFRESH_WORKSPACE_MENU;
3254 if (widx == WKBD_LASTWORKSPACE)
3255 return REFRESH_WORKSPACE_MENU;
3256 if (widx >= WKBD_MOVE_WORKSPACE1 && widx <= WKBD_MOVE_WORKSPACE10)
3257 return REFRESH_WORKSPACE_MENU;
3259 return 0;
3262 static int setIconPosition(WScreen * scr, WDefaultEntry * entry, void *bar, void *foo)
3264 /* Parameter not used, but tell the compiler that it is ok */
3265 (void) entry;
3266 (void) bar;
3267 (void) foo;
3269 wScreenUpdateUsableArea(scr);
3270 wArrangeIcons(scr, True);
3272 return 0;
3275 static int updateUsableArea(WScreen * scr, WDefaultEntry * entry, void *bar, void *foo)
3277 /* Parameter not used, but tell the compiler that it is ok */
3278 (void) entry;
3279 (void) bar;
3280 (void) foo;
3282 wScreenUpdateUsableArea(scr);
3284 return 0;
3287 static int setWorkspaceMapBackground(WScreen *scr, WDefaultEntry *entry, void *tdata, void *foo)
3289 WTexture **texture = tdata;
3291 /* Parameter not used, but tell the compiler that it is ok */
3292 (void) entry;
3293 (void) foo;
3295 if (wPreferences.wsmbackTexture)
3296 wTextureDestroy(scr, wPreferences.wsmbackTexture);
3298 wPreferences.wsmbackTexture = *texture;
3300 return REFRESH_WINDOW_TEXTURES;
3303 static int setMenuStyle(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
3305 /* Parameter not used, but tell the compiler that it is ok */
3306 (void) scr;
3307 (void) entry;
3308 (void) tdata;
3309 (void) foo;
3311 return REFRESH_MENU_TEXTURE;
3314 static RImage *chopOffImage(RImage * image, int x, int y, int w, int h)
3316 RImage *img = RCreateImage(w, h, image->format == RRGBAFormat);
3318 RCopyArea(img, image, x, y, w, h, 0, 0);
3320 return img;
3323 static int setSwPOptions(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
3325 WMPropList *array = tdata;
3326 char *path;
3327 RImage *bgimage;
3328 int cwidth, cheight;
3329 struct WPreferences *prefs = foo;
3331 if (!WMIsPLArray(array) || WMGetPropListItemCount(array) == 0) {
3332 if (prefs->swtileImage)
3333 RReleaseImage(prefs->swtileImage);
3334 prefs->swtileImage = NULL;
3336 WMReleasePropList(array);
3337 return 0;
3340 switch (WMGetPropListItemCount(array)) {
3341 case 4:
3342 if (!WMIsPLString(WMGetFromPLArray(array, 1))) {
3343 wwarning(_("Invalid arguments for option \"%s\""), entry->key);
3344 break;
3345 } else
3346 path = FindImage(wPreferences.pixmap_path, WMGetFromPLString(WMGetFromPLArray(array, 1)));
3348 if (!path) {
3349 wwarning(_("Could not find image \"%s\" for option \"%s\""),
3350 WMGetFromPLString(WMGetFromPLArray(array, 1)), entry->key);
3351 } else {
3352 bgimage = RLoadImage(scr->rcontext, path, 0);
3353 if (!bgimage) {
3354 wwarning(_("Could not load image \"%s\" for option \"%s\""), path, entry->key);
3355 wfree(path);
3356 } else {
3357 wfree(path);
3359 cwidth = atoi(WMGetFromPLString(WMGetFromPLArray(array, 2)));
3360 cheight = atoi(WMGetFromPLString(WMGetFromPLArray(array, 3)));
3362 if (cwidth <= 0 || cheight <= 0 ||
3363 cwidth >= bgimage->width - 2 || cheight >= bgimage->height - 2)
3364 wwarning(_("Invalid split sizes for switch panel back image."));
3365 else {
3366 int i;
3367 int swidth, theight;
3368 for (i = 0; i < 9; i++) {
3369 if (prefs->swbackImage[i])
3370 RReleaseImage(prefs->swbackImage[i]);
3371 prefs->swbackImage[i] = NULL;
3373 swidth = (bgimage->width - cwidth) / 2;
3374 theight = (bgimage->height - cheight) / 2;
3376 prefs->swbackImage[0] = chopOffImage(bgimage, 0, 0, swidth, theight);
3377 prefs->swbackImage[1] = chopOffImage(bgimage, swidth, 0, cwidth, theight);
3378 prefs->swbackImage[2] = chopOffImage(bgimage, swidth + cwidth, 0,
3379 swidth, theight);
3381 prefs->swbackImage[3] = chopOffImage(bgimage, 0, theight, swidth, cheight);
3382 prefs->swbackImage[4] = chopOffImage(bgimage, swidth, theight,
3383 cwidth, cheight);
3384 prefs->swbackImage[5] = chopOffImage(bgimage, swidth + cwidth, theight,
3385 swidth, cheight);
3387 prefs->swbackImage[6] = chopOffImage(bgimage, 0, theight + cheight,
3388 swidth, theight);
3389 prefs->swbackImage[7] = chopOffImage(bgimage, swidth, theight + cheight,
3390 cwidth, theight);
3391 prefs->swbackImage[8] =
3392 chopOffImage(bgimage, swidth + cwidth, theight + cheight, swidth,
3393 theight);
3395 // check if anything failed
3396 for (i = 0; i < 9; i++) {
3397 if (!prefs->swbackImage[i]) {
3398 for (; i >= 0; --i) {
3399 RReleaseImage(prefs->swbackImage[i]);
3400 prefs->swbackImage[i] = NULL;
3402 break;
3406 RReleaseImage(bgimage);
3410 /* Fall through. */
3412 case 1:
3413 if (!WMIsPLString(WMGetFromPLArray(array, 0))) {
3414 wwarning(_("Invalid arguments for option \"%s\""), entry->key);
3415 break;
3416 } else
3417 path = FindImage(wPreferences.pixmap_path, WMGetFromPLString(WMGetFromPLArray(array, 0)));
3419 if (!path) {
3420 wwarning(_("Could not find image \"%s\" for option \"%s\""),
3421 WMGetFromPLString(WMGetFromPLArray(array, 0)), entry->key);
3422 } else {
3423 if (prefs->swtileImage)
3424 RReleaseImage(prefs->swtileImage);
3426 prefs->swtileImage = RLoadImage(scr->rcontext, path, 0);
3427 if (!prefs->swtileImage) {
3428 wwarning(_("Could not load image \"%s\" for option \"%s\""), path, entry->key);
3430 wfree(path);
3432 break;
3434 default:
3435 wwarning(_("Invalid number of arguments for option \"%s\""), entry->key);
3436 break;
3439 WMReleasePropList(array);
3441 return 0;
3444 static int setModifierKeyLabels(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
3446 WMPropList *array = tdata;
3447 int i;
3448 struct WPreferences *prefs = foo;
3450 if (!WMIsPLArray(array) || WMGetPropListItemCount(array) != 7) {
3451 wwarning(_("Value for option \"%s\" must be an array of 7 strings"), entry->key);
3452 WMReleasePropList(array);
3453 return 0;
3456 DestroyWindowMenu(scr);
3458 for (i = 0; i < 7; i++) {
3459 if (prefs->modifier_labels[i])
3460 wfree(prefs->modifier_labels[i]);
3462 if (WMIsPLString(WMGetFromPLArray(array, i))) {
3463 prefs->modifier_labels[i] = wstrdup(WMGetFromPLString(WMGetFromPLArray(array, i)));
3464 } else {
3465 wwarning(_("Invalid argument for option \"%s\" item %d"), entry->key, i);
3466 prefs->modifier_labels[i] = NULL;
3470 WMReleasePropList(array);
3472 return 0;
3475 static int setHotCornerActions(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
3477 WMPropList *array = tdata;
3478 int i;
3479 struct WPreferences *prefs = foo;
3481 if (!WMIsPLArray(array) || WMGetPropListItemCount(array) != 4) {
3482 wwarning(_("Value for option \"%s\" must be an array of 4 strings"), entry->key);
3483 WMReleasePropList(array);
3484 return 0;
3487 DestroyWindowMenu(scr);
3489 for (i = 0; i < 4; i++) {
3490 if (prefs->hot_corner_actions[i])
3491 wfree(prefs->hot_corner_actions[i]);
3493 if (WMIsPLString(WMGetFromPLArray(array, i))) {
3494 const char *val;
3495 val = WMGetFromPLString(WMGetFromPLArray(array, i));
3496 if (strcasecmp(val, "NONE") != 0)
3497 prefs->hot_corner_actions[i] = wstrdup(val);
3498 else
3499 prefs->hot_corner_actions[i] = NULL;
3500 } else {
3501 wwarning(_("Invalid argument for option \"%s\" item %d"), entry->key, i);
3502 prefs->hot_corner_actions[i] = NULL;
3506 WMReleasePropList(array);
3508 return 0;
3512 static int setDoubleClick(WScreen *scr, WDefaultEntry *entry, void *tdata, void *foo)
3514 int *value = tdata;
3516 /* Parameter not used, but tell the compiler that it is ok */
3517 (void) entry;
3518 (void) scr;
3520 if (*value <= 0)
3521 *(int *)foo = 1;
3523 W_setconf_doubleClickDelay(*value);
3525 return 0;
3528 static int setCursor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *extra_data)
3530 Cursor *cursor = tdata;
3531 long widx = (long) extra_data;
3533 /* Parameter not used, but tell the compiler that it is ok */
3534 (void) entry;
3536 if (wPreferences.cursor[widx] != None) {
3537 XFreeCursor(dpy, wPreferences.cursor[widx]);
3540 wPreferences.cursor[widx] = *cursor;
3542 if (widx == WCUR_ROOT && *cursor != None) {
3543 XDefineCursor(dpy, scr->root_win, *cursor);
3546 return 0;
3549 static int updateDock(WScreen * scr, WDefaultEntry * entry,
3550 void *tdata, void *extra_data) {
3551 (void) entry;
3552 (void) tdata;
3553 (void) extra_data;
3555 if (scr->dock)
3556 wDockSwap(scr->dock);
3558 return 0;