WPrefs: update maximization feature descriptions
[wmaker-crm.git] / src / defaults.c
blobf5cbf46f9d83156c355e5125f9cc3cd20fcc31dc
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;
155 static WDECallbackConvert getCursor;
156 static WDECallbackUpdate setCursor;
157 static WDECallbackUpdate updateDock;
160 * Tables to convert strings to enumeration values.
161 * Values stored are char
164 /* WARNING: sum of length of all value strings must not exceed
165 * this value */
166 #define TOTAL_VALUES_LENGTH 80
168 #define REFRESH_WINDOW_TEXTURES (1<<0)
169 #define REFRESH_MENU_TEXTURE (1<<1)
170 #define REFRESH_MENU_FONT (1<<2)
171 #define REFRESH_MENU_COLOR (1<<3)
172 #define REFRESH_MENU_TITLE_TEXTURE (1<<4)
173 #define REFRESH_MENU_TITLE_FONT (1<<5)
174 #define REFRESH_MENU_TITLE_COLOR (1<<6)
175 #define REFRESH_WINDOW_TITLE_COLOR (1<<7)
176 #define REFRESH_WINDOW_FONT (1<<8)
177 #define REFRESH_ICON_TILE (1<<9)
178 #define REFRESH_ICON_FONT (1<<10)
180 #define REFRESH_BUTTON_IMAGES (1<<11)
182 #define REFRESH_ICON_TITLE_COLOR (1<<12)
183 #define REFRESH_ICON_TITLE_BACK (1<<13)
185 #define REFRESH_WORKSPACE_MENU (1<<14)
187 #define REFRESH_FRAME_BORDER REFRESH_MENU_FONT|REFRESH_WINDOW_FONT
189 static WOptionEnumeration seFocusModes[] = {
190 {"Manual", WKF_CLICK, 0}, {"ClickToFocus", WKF_CLICK, 1},
191 {"Sloppy", WKF_SLOPPY, 0}, {"SemiAuto", WKF_SLOPPY, 1}, {"Auto", WKF_SLOPPY, 1},
192 {NULL, 0, 0}
195 static WOptionEnumeration seTitlebarModes[] = {
196 {"new", TS_NEW, 0}, {"old", TS_OLD, 0},
197 {"next", TS_NEXT, 0}, {NULL, 0, 0}
200 static WOptionEnumeration seColormapModes[] = {
201 {"Manual", WCM_CLICK, 0}, {"ClickToFocus", WCM_CLICK, 1},
202 {"Auto", WCM_POINTER, 0}, {"FocusFollowMouse", WCM_POINTER, 1},
203 {NULL, 0, 0}
206 static WOptionEnumeration sePlacements[] = {
207 {"Auto", WPM_AUTO, 0},
208 {"Smart", WPM_SMART, 0},
209 {"Cascade", WPM_CASCADE, 0},
210 {"Random", WPM_RANDOM, 0},
211 {"Manual", WPM_MANUAL, 0},
212 {"Center", WPM_CENTER, 0},
213 {NULL, 0, 0}
216 static WOptionEnumeration seGeomDisplays[] = {
217 {"None", WDIS_NONE, 0},
218 {"Center", WDIS_CENTER, 0},
219 {"Corner", WDIS_TOPLEFT, 0},
220 {"Floating", WDIS_FRAME_CENTER, 0},
221 {"Line", WDIS_NEW, 0},
222 {NULL, 0, 0}
225 static WOptionEnumeration seSpeeds[] = {
226 {"UltraFast", SPEED_ULTRAFAST, 0},
227 {"Fast", SPEED_FAST, 0},
228 {"Medium", SPEED_MEDIUM, 0},
229 {"Slow", SPEED_SLOW, 0},
230 {"UltraSlow", SPEED_ULTRASLOW, 0},
231 {NULL, 0, 0}
234 static WOptionEnumeration seMouseButtonActions[] = {
235 {"None", WA_NONE, 0},
236 {"SelectWindows", WA_SELECT_WINDOWS, 0},
237 {"OpenApplicationsMenu", WA_OPEN_APPMENU, 0},
238 {"OpenWindowListMenu", WA_OPEN_WINLISTMENU, 0},
239 {"MoveToPrevWorkspace", WA_MOVE_PREVWORKSPACE, 0},
240 {"MoveToNextWorkspace", WA_MOVE_NEXTWORKSPACE, 0},
241 {"MoveToPrevWindow", WA_MOVE_PREVWINDOW, 0},
242 {"MoveToNextWindow", WA_MOVE_NEXTWINDOW, 0},
243 {NULL, 0, 0}
246 static WOptionEnumeration seMouseWheelActions[] = {
247 {"None", WA_NONE, 0},
248 {"SwitchWorkspaces", WA_SWITCH_WORKSPACES, 0},
249 {"SwitchWindows", WA_SWITCH_WINDOWS, 0},
250 {NULL, 0, 0}
253 static WOptionEnumeration seIconificationStyles[] = {
254 {"Zoom", WIS_ZOOM, 0},
255 {"Twist", WIS_TWIST, 0},
256 {"Flip", WIS_FLIP, 0},
257 {"None", WIS_NONE, 0},
258 {"random", WIS_RANDOM, 0},
259 {NULL, 0, 0}
262 static WOptionEnumeration seJustifications[] = {
263 {"Left", WTJ_LEFT, 0},
264 {"Center", WTJ_CENTER, 0},
265 {"Right", WTJ_RIGHT, 0},
266 {NULL, 0, 0}
269 static WOptionEnumeration seIconPositions[] = {
270 {"blv", IY_BOTTOM | IY_LEFT | IY_VERT, 0},
271 {"blh", IY_BOTTOM | IY_LEFT | IY_HORIZ, 0},
272 {"brv", IY_BOTTOM | IY_RIGHT | IY_VERT, 0},
273 {"brh", IY_BOTTOM | IY_RIGHT | IY_HORIZ, 0},
274 {"tlv", IY_TOP | IY_LEFT | IY_VERT, 0},
275 {"tlh", IY_TOP | IY_LEFT | IY_HORIZ, 0},
276 {"trv", IY_TOP | IY_RIGHT | IY_VERT, 0},
277 {"trh", IY_TOP | IY_RIGHT | IY_HORIZ, 0},
278 {NULL, 0, 0}
281 static WOptionEnumeration seMenuStyles[] = {
282 {"normal", MS_NORMAL, 0},
283 {"singletexture", MS_SINGLE_TEXTURE, 0},
284 {"flat", MS_FLAT, 0},
285 {NULL, 0, 0}
288 static WOptionEnumeration seDisplayPositions[] = {
289 {"none", WD_NONE, 0},
290 {"center", WD_CENTER, 0},
291 {"top", WD_TOP, 0},
292 {"bottom", WD_BOTTOM, 0},
293 {"topleft", WD_TOPLEFT, 0},
294 {"topright", WD_TOPRIGHT, 0},
295 {"bottomleft", WD_BOTTOMLEFT, 0},
296 {"bottomright", WD_BOTTOMRIGHT, 0},
297 {NULL, 0, 0}
300 static WOptionEnumeration seWorkspaceBorder[] = {
301 {"None", WB_NONE, 0},
302 {"LeftRight", WB_LEFTRIGHT, 0},
303 {"TopBottom", WB_TOPBOTTOM, 0},
304 {"AllDirections", WB_ALLDIRS, 0},
305 {NULL, 0, 0}
308 static WOptionEnumeration seDragMaximizedWindow[] = {
309 {"Move", DRAGMAX_MOVE, 0},
310 {"RestoreGeometry", DRAGMAX_RESTORE, 0},
311 {"Unmaximize", DRAGMAX_UNMAXIMIZE, 0},
312 {"NoMove", DRAGMAX_NOMOVE, 0},
313 {NULL, 0, 0}
317 * ALL entries in the tables below NEED to have a default value
318 * defined, and this value needs to be correct.
320 * Also add the default key/value pair to WindowMaker/Defaults/WindowMaker.in
323 /* these options will only affect the window manager on startup
325 * static defaults can't access the screen data, because it is
326 * created after these defaults are read
328 WDefaultEntry staticOptionList[] = {
330 {"ColormapSize", "4", NULL,
331 &wPreferences.cmap_size, getInt, NULL, NULL, NULL},
332 {"DisableDithering", "NO", NULL,
333 &wPreferences.no_dithering, getBool, NULL, NULL, NULL},
334 {"IconSize", "64", NULL,
335 &wPreferences.icon_size, getInt, NULL, NULL, NULL},
336 {"ModifierKey", "Mod1", NULL,
337 &wPreferences.modifier_mask, getModMask, NULL, NULL, NULL},
338 {"FocusMode", "manual", seFocusModes, /* have a problem when switching from */
339 &wPreferences.focus_mode, getEnum, NULL, NULL, NULL}, /* manual to sloppy without restart */
340 {"NewStyle", "new", seTitlebarModes,
341 &wPreferences.new_style, getEnum, NULL, NULL, NULL},
342 {"DisableDock", "NO", (void *)WM_DOCK,
343 NULL, getBool, setIfDockPresent, NULL, NULL},
344 {"DisableClip", "NO", (void *)WM_CLIP,
345 NULL, getBool, setIfDockPresent, NULL, NULL},
346 {"DisableDrawers", "NO", (void *)WM_DRAWER,
347 NULL, getBool, setIfDockPresent, NULL, NULL},
348 {"ClipMergedInDock", "NO", NULL,
349 NULL, getBool, setClipMergedInDock, NULL, NULL},
350 {"DisableMiniwindows", "NO", NULL,
351 &wPreferences.disable_miniwindows, getBool, NULL, NULL, NULL},
352 {"EnableWorkspacePager", "NO", NULL,
353 &wPreferences.enable_workspace_pager, getBool, NULL, NULL, NULL},
354 {"SwitchPanelIconSize", "64", NULL,
355 &wPreferences.switch_panel_icon_size, getInt, NULL, NULL, NULL},
358 #define NUM2STRING_(x) #x
359 #define NUM2STRING(x) NUM2STRING_(x)
361 WDefaultEntry optionList[] = {
363 /* dynamic options */
365 {"IconPosition", "blh", seIconPositions,
366 &wPreferences.icon_yard, getEnum, setIconPosition, NULL, NULL},
367 {"IconificationStyle", "Zoom", seIconificationStyles,
368 &wPreferences.iconification_style, getEnum, NULL, NULL, NULL},
369 {"EnforceIconMargin", "NO", NULL,
370 &wPreferences.enforce_icon_margin, getBool, NULL, NULL, NULL},
371 {"DisableWSMouseActions", "NO", NULL,
372 &wPreferences.disable_root_mouse, getBool, NULL, NULL, NULL},
373 {"MouseLeftButtonAction", "SelectWindows", seMouseButtonActions,
374 &wPreferences.mouse_button1, getEnum, NULL, NULL, NULL},
375 {"MouseMiddleButtonAction", "OpenWindowListMenu", seMouseButtonActions,
376 &wPreferences.mouse_button2, getEnum, NULL, NULL, NULL},
377 {"MouseRightButtonAction", "OpenApplicationsMenu", seMouseButtonActions,
378 &wPreferences.mouse_button3, getEnum, NULL, NULL, NULL},
379 {"MouseBackwardButtonAction", "None", seMouseButtonActions,
380 &wPreferences.mouse_button8, getEnum, NULL, NULL, NULL},
381 {"MouseForwardButtonAction", "None", seMouseButtonActions,
382 &wPreferences.mouse_button9, getEnum, NULL, NULL, NULL},
383 {"MouseWheelAction", "None", seMouseWheelActions,
384 &wPreferences.mouse_wheel_scroll, getEnum, NULL, NULL, NULL},
385 {"MouseWheelTiltAction", "None", seMouseWheelActions,
386 &wPreferences.mouse_wheel_tilt, getEnum, NULL, NULL, NULL},
387 {"PixmapPath", DEF_PIXMAP_PATHS, NULL,
388 &wPreferences.pixmap_path, getPathList, NULL, NULL, NULL},
389 {"IconPath", DEF_ICON_PATHS, NULL,
390 &wPreferences.icon_path, getPathList, NULL, NULL, NULL},
391 {"ColormapMode", "auto", seColormapModes,
392 &wPreferences.colormap_mode, getEnum, NULL, NULL, NULL},
393 {"AutoFocus", "YES", NULL,
394 &wPreferences.auto_focus, getBool, NULL, NULL, NULL},
395 {"RaiseDelay", "0", NULL,
396 &wPreferences.raise_delay, getInt, NULL, NULL, NULL},
397 {"CirculateRaise", "NO", NULL,
398 &wPreferences.circ_raise, getBool, NULL, NULL, NULL},
399 {"Superfluous", "YES", NULL,
400 &wPreferences.superfluous, getBool, NULL, NULL, NULL},
401 {"AdvanceToNewWorkspace", "NO", NULL,
402 &wPreferences.ws_advance, getBool, NULL, NULL, NULL},
403 {"CycleWorkspaces", "NO", NULL,
404 &wPreferences.ws_cycle, getBool, NULL, NULL, NULL},
405 {"WorkspaceNameDisplayPosition", "center", seDisplayPositions,
406 &wPreferences.workspace_name_display_position, getEnum, NULL, NULL, NULL},
407 {"WorkspaceBorder", "None", seWorkspaceBorder,
408 &wPreferences.workspace_border_position, getEnum, updateUsableArea, NULL, NULL},
409 {"WorkspaceBorderSize", "0", NULL,
410 &wPreferences.workspace_border_size, getInt, updateUsableArea, NULL, NULL},
411 {"StickyIcons", "NO", NULL,
412 &wPreferences.sticky_icons, getBool, setStickyIcons, NULL, NULL},
413 {"SaveSessionOnExit", "NO", NULL,
414 &wPreferences.save_session_on_exit, getBool, NULL, NULL, NULL},
415 {"WrapMenus", "NO", NULL,
416 &wPreferences.wrap_menus, getBool, NULL, NULL, NULL},
417 {"ScrollableMenus", "YES", NULL,
418 &wPreferences.scrollable_menus, getBool, NULL, NULL, NULL},
419 {"MenuScrollSpeed", "fast", seSpeeds,
420 &wPreferences.menu_scroll_speed, getEnum, NULL, NULL, NULL},
421 {"IconSlideSpeed", "fast", seSpeeds,
422 &wPreferences.icon_slide_speed, getEnum, NULL, NULL, NULL},
423 {"ShadeSpeed", "fast", seSpeeds,
424 &wPreferences.shade_speed, getEnum, NULL, NULL, NULL},
425 {"BounceAppIconsWhenUrgent", "YES", NULL,
426 &wPreferences.bounce_appicons_when_urgent, getBool, NULL, NULL, NULL},
427 {"RaiseAppIconsWhenBouncing", "NO", NULL,
428 &wPreferences.raise_appicons_when_bouncing, getBool, NULL, NULL, NULL},
429 {"DoNotMakeAppIconsBounce", "NO", NULL,
430 &wPreferences.do_not_make_appicons_bounce, getBool, NULL, NULL, NULL},
431 {"DoubleClickTime", "250", (void *)&wPreferences.dblclick_time,
432 &wPreferences.dblclick_time, getInt, setDoubleClick, NULL, NULL},
433 {"ClipAutoraiseDelay", "600", NULL,
434 &wPreferences.clip_auto_raise_delay, getInt, NULL, NULL, NULL},
435 {"ClipAutolowerDelay", "1000", NULL,
436 &wPreferences.clip_auto_lower_delay, getInt, NULL, NULL, NULL},
437 {"ClipAutoexpandDelay", "600", NULL,
438 &wPreferences.clip_auto_expand_delay, getInt, NULL, NULL, NULL},
439 {"ClipAutocollapseDelay", "1000", NULL,
440 &wPreferences.clip_auto_collapse_delay, getInt, NULL, NULL, NULL},
441 {"WrapAppiconsInDock", "YES", NULL,
442 NULL, getBool, setWrapAppiconsInDock, NULL, NULL},
443 {"AlignSubmenus", "NO", NULL,
444 &wPreferences.align_menus, getBool, NULL, NULL, NULL},
445 {"ViKeyMenus", "NO", NULL,
446 &wPreferences.vi_key_menus, getBool, NULL, NULL, NULL},
447 {"OpenTransientOnOwnerWorkspace", "NO", NULL,
448 &wPreferences.open_transients_with_parent, getBool, NULL, NULL, NULL},
449 {"WindowPlacement", "auto", sePlacements,
450 &wPreferences.window_placement, getEnum, NULL, NULL, NULL},
451 {"IgnoreFocusClick", "NO", NULL,
452 &wPreferences.ignore_focus_click, getBool, NULL, NULL, NULL},
453 {"UseSaveUnders", "NO", NULL,
454 &wPreferences.use_saveunders, getBool, NULL, NULL, NULL},
455 {"OpaqueMove", "YES", NULL,
456 &wPreferences.opaque_move, getBool, NULL, NULL, NULL},
457 {"OpaqueResize", "NO", NULL,
458 &wPreferences.opaque_resize, getBool, NULL, NULL, NULL},
459 {"OpaqueMoveResizeKeyboard", "NO", NULL,
460 &wPreferences.opaque_move_resize_keyboard, getBool, NULL, NULL, NULL},
461 {"DisableAnimations", "NO", NULL,
462 &wPreferences.no_animations, getBool, NULL, NULL, NULL},
463 {"DontLinkWorkspaces", "YES", NULL,
464 &wPreferences.no_autowrap, getBool, NULL, NULL, NULL},
465 {"WindowSnapping", "NO", NULL,
466 &wPreferences.window_snapping, getBool, NULL, NULL, NULL},
467 {"SnapEdgeDetect", "1", NULL,
468 &wPreferences.snap_edge_detect, getInt, NULL, NULL, NULL},
469 {"SnapCornerDetect", "10", NULL,
470 &wPreferences.snap_corner_detect, getInt, NULL, NULL, NULL},
471 {"SnapToTopMaximizesFullscreen", "NO", NULL,
472 &wPreferences.snap_to_top_maximizes_fullscreen, getBool, NULL, NULL, NULL},
473 {"DragMaximizedWindow", "Move", seDragMaximizedWindow,
474 &wPreferences.drag_maximized_window, getEnum, NULL, NULL, NULL},
475 {"MoveHalfMaximizedWindowsBetweenScreens", "NO", NULL,
476 &wPreferences.move_half_max_between_heads, getBool, NULL, NULL, NULL},
477 {"AlternativeHalfMaximized", "NO", NULL,
478 &wPreferences.alt_half_maximize, getBool, NULL, NULL, NULL},
479 {"PointerWithHalfMaxWindows", "NO", NULL,
480 &wPreferences.pointer_with_half_max_windows, getBool, NULL, NULL, NULL},
481 {"HighlightActiveApp", "YES", NULL,
482 &wPreferences.highlight_active_app, getBool, NULL, NULL, NULL},
483 {"AutoArrangeIcons", "NO", NULL,
484 &wPreferences.auto_arrange_icons, getBool, NULL, NULL, NULL},
485 {"NoWindowOverDock", "NO", NULL,
486 &wPreferences.no_window_over_dock, getBool, updateUsableArea, NULL, NULL},
487 {"NoWindowOverIcons", "NO", NULL,
488 &wPreferences.no_window_over_icons, getBool, updateUsableArea, NULL, NULL},
489 {"WindowPlaceOrigin", "(64, 0)", NULL,
490 &wPreferences.window_place_origin, getCoord, NULL, NULL, NULL},
491 {"ResizeDisplay", "center", seGeomDisplays,
492 &wPreferences.size_display, getEnum, NULL, NULL, NULL},
493 {"MoveDisplay", "floating", seGeomDisplays,
494 &wPreferences.move_display, getEnum, NULL, NULL, NULL},
495 {"DontConfirmKill", "NO", NULL,
496 &wPreferences.dont_confirm_kill, getBool, NULL, NULL, NULL},
497 {"WindowTitleBalloons", "YES", NULL,
498 &wPreferences.window_balloon, getBool, NULL, NULL, NULL},
499 {"MiniwindowTitleBalloons", "NO", NULL,
500 &wPreferences.miniwin_title_balloon, getBool, NULL, NULL, NULL},
501 {"MiniwindowPreviewBalloons", "NO", NULL,
502 &wPreferences.miniwin_preview_balloon, getBool, NULL, NULL, NULL},
503 {"AppIconBalloons", "NO", NULL,
504 &wPreferences.appicon_balloon, getBool, NULL, NULL, NULL},
505 {"HelpBalloons", "NO", NULL,
506 &wPreferences.help_balloon, getBool, NULL, NULL, NULL},
507 {"EdgeResistance", "30", NULL,
508 &wPreferences.edge_resistance, getInt, NULL, NULL, NULL},
509 {"ResizeIncrement", "0", NULL,
510 &wPreferences.resize_increment, getInt, NULL, NULL, NULL},
511 {"Attraction", "NO", NULL,
512 &wPreferences.attract, getBool, NULL, NULL, NULL},
513 {"DisableBlinking", "NO", NULL,
514 &wPreferences.dont_blink, getBool, NULL, NULL, NULL},
515 {"SingleClickLaunch", "NO", NULL,
516 &wPreferences.single_click, getBool, NULL, NULL, NULL},
517 {"StrictWindozeCycle", "YES", NULL,
518 &wPreferences.strict_windoze_cycle, getBool, NULL, NULL, NULL},
519 {"SwitchPanelOnlyOpen", "NO", NULL,
520 &wPreferences.panel_only_open, getBool, NULL, NULL, NULL},
521 {"MiniPreviewSize", "128", NULL,
522 &wPreferences.minipreview_size, getInt, NULL, NULL, NULL},
523 {"IgnoreGtkHints", "NO", NULL,
524 &wPreferences.ignore_gtk_decoration_hints, getBool, NULL, NULL, NULL},
525 {"KeepDockOnPrimaryHead", "NO", NULL,
526 &wPreferences.keep_dock_on_primary_head, getBool, updateDock,
527 NULL, NULL},
529 /* style options */
531 {"MenuStyle", "normal", seMenuStyles,
532 &wPreferences.menu_style, getEnum, setMenuStyle, NULL, NULL},
533 {"WidgetColor", "(solid, gray)", NULL,
534 NULL, getTexture, setWidgetColor, NULL, NULL},
535 {"WorkspaceSpecificBack", "()", NULL,
536 NULL, getWSSpecificBackground, setWorkspaceSpecificBack, NULL, NULL},
537 /* WorkspaceBack must come after WorkspaceSpecificBack or
538 * WorkspaceBack won't know WorkspaceSpecificBack was also
539 * specified and 2 copies of wmsetbg will be launched */
540 {"WorkspaceBack", "(solid, \"rgb:50/50/75\")", NULL,
541 NULL, getWSBackground, setWorkspaceBack, NULL, NULL},
542 {"SmoothWorkspaceBack", "NO", NULL,
543 NULL, getBool, NULL, NULL, NULL},
544 {"IconBack", "(dgradient, \"rgb:a6/a6/b6\", \"rgb:51/55/61\")", NULL,
545 NULL, getTexture, setIconTile, NULL, NULL},
546 {"TitleJustify", "center", seJustifications,
547 &wPreferences.title_justification, getEnum, setJustify, NULL, NULL},
548 {"WindowTitleFont", DEF_TITLE_FONT, NULL,
549 NULL, getFont, setWinTitleFont, NULL, NULL},
550 {"WindowTitleExtendSpace", DEF_WINDOW_TITLE_EXTEND_SPACE, NULL,
551 &wPreferences.window_title_clearance, getInt, setClearance, NULL, NULL},
552 {"WindowTitleMinHeight", "0", NULL,
553 &wPreferences.window_title_min_height, getInt, setClearance, NULL, NULL},
554 {"WindowTitleMaxHeight", NUM2STRING(INT_MAX), NULL,
555 &wPreferences.window_title_max_height, getInt, setClearance, NULL, NULL},
556 {"MenuTitleExtendSpace", DEF_MENU_TITLE_EXTEND_SPACE, NULL,
557 &wPreferences.menu_title_clearance, getInt, setClearance, NULL, NULL},
558 {"MenuTitleMinHeight", "0", NULL,
559 &wPreferences.menu_title_min_height, getInt, setClearance, NULL, NULL},
560 {"MenuTitleMaxHeight", NUM2STRING(INT_MAX), NULL,
561 &wPreferences.menu_title_max_height, getInt, setClearance, NULL, NULL},
562 {"MenuTextExtendSpace", DEF_MENU_TEXT_EXTEND_SPACE, NULL,
563 &wPreferences.menu_text_clearance, getInt, setClearance, NULL, NULL},
564 {"MenuTitleFont", DEF_MENU_TITLE_FONT, NULL,
565 NULL, getFont, setMenuTitleFont, NULL, NULL},
566 {"MenuTextFont", DEF_MENU_ENTRY_FONT, NULL,
567 NULL, getFont, setMenuTextFont, NULL, NULL},
568 {"IconTitleFont", DEF_ICON_TITLE_FONT, NULL,
569 NULL, getFont, setIconTitleFont, NULL, NULL},
570 {"ClipTitleFont", DEF_CLIP_TITLE_FONT, NULL,
571 NULL, getFont, setClipTitleFont, NULL, NULL},
572 {"ShowClipTitle", "YES", NULL,
573 &wPreferences.show_clip_title, getBool, NULL, NULL, NULL},
574 {"LargeDisplayFont", DEF_WORKSPACE_NAME_FONT, NULL,
575 NULL, getFont, setLargeDisplayFont, NULL, NULL},
576 {"HighlightColor", "white", NULL,
577 NULL, getColor, setHightlight, NULL, NULL},
578 {"HighlightTextColor", "black", NULL,
579 NULL, getColor, setHightlightText, NULL, NULL},
580 {"ClipTitleColor", "black", (void *)CLIP_NORMAL,
581 NULL, getColor, setClipTitleColor, NULL, NULL},
582 {"CClipTitleColor", "\"rgb:61/61/61\"", (void *)CLIP_COLLAPSED,
583 NULL, getColor, setClipTitleColor, NULL, NULL},
584 {"FTitleColor", "white", (void *)WS_FOCUSED,
585 NULL, getColor, setWTitleColor, NULL, NULL},
586 {"PTitleColor", "white", (void *)WS_PFOCUSED,
587 NULL, getColor, setWTitleColor, NULL, NULL},
588 {"UTitleColor", "black", (void *)WS_UNFOCUSED,
589 NULL, getColor, setWTitleColor, NULL, NULL},
590 {"FTitleBack", "(solid, black)", NULL,
591 NULL, getTexture, setFTitleBack, NULL, NULL},
592 {"PTitleBack", "(solid, gray40)", NULL,
593 NULL, getTexture, setPTitleBack, NULL, NULL},
594 {"UTitleBack", "(solid, \"rgb:aa/aa/aa\")", NULL,
595 NULL, getTexture, setUTitleBack, NULL, NULL},
596 {"ResizebarBack", "(solid, \"rgb:aa/aa/aa\")", NULL,
597 NULL, getTexture, setResizebarBack, NULL, NULL},
598 {"MenuTitleColor", "white", NULL,
599 NULL, getColor, setMenuTitleColor, NULL, NULL},
600 {"MenuTextColor", "black", NULL,
601 NULL, getColor, setMenuTextColor, NULL, NULL},
602 {"MenuDisabledColor", "gray50", NULL,
603 NULL, getColor, setMenuDisabledColor, NULL, NULL},
604 {"MenuTitleBack", "(solid, black)", NULL,
605 NULL, getTexture, setMenuTitleBack, NULL, NULL},
606 {"MenuTextBack", "(solid, \"rgb:aa/aa/aa\")", NULL,
607 NULL, getTexture, setMenuTextBack, NULL, NULL},
608 {"IconTitleColor", "white", NULL,
609 NULL, getColor, setIconTitleColor, NULL, NULL},
610 {"IconTitleBack", "black", NULL,
611 NULL, getColor, setIconTitleBack, NULL, NULL},
612 {"SwitchPanelImages", "(swtile.png, swback.png, 30, 40)", &wPreferences,
613 NULL, getPropList, setSwPOptions, NULL, NULL},
614 {"ModifierKeyLabels", "(\"Shift+\", \"Control+\", \"Mod1+\", \"Mod2+\", \"Mod3+\", \"Mod4+\", \"Mod5+\")", &wPreferences,
615 NULL, getPropList, setModifierKeyLabels, NULL, NULL},
616 {"FrameBorderWidth", "1", NULL,
617 NULL, getInt, setFrameBorderWidth, NULL, NULL},
618 {"FrameBorderColor", "black", NULL,
619 NULL, getColor, setFrameBorderColor, NULL, NULL},
620 {"FrameFocusedBorderColor", "black", NULL,
621 NULL, getColor, setFrameFocusedBorderColor, NULL, NULL},
622 {"FrameSelectedBorderColor", "white", NULL,
623 NULL, getColor, setFrameSelectedBorderColor, NULL, NULL},
624 {"WorkspaceMapBack", "(solid, black)", NULL,
625 NULL, getTexture, setWorkspaceMapBackground, NULL, NULL},
627 /* keybindings */
629 {"RootMenuKey", "F12", (void *)WKBD_ROOTMENU,
630 NULL, getKeybind, setKeyGrab, NULL, NULL},
631 {"WindowListKey", "F11", (void *)WKBD_WINDOWLIST,
632 NULL, getKeybind, setKeyGrab, NULL, NULL},
633 {"WindowMenuKey", "Control+Escape", (void *)WKBD_WINDOWMENU,
634 NULL, getKeybind, setKeyGrab, NULL, NULL},
635 {"DockRaiseLowerKey", "None", (void*)WKBD_DOCKRAISELOWER,
636 NULL, getKeybind, setKeyGrab, NULL, NULL},
637 {"ClipRaiseLowerKey", "None", (void *)WKBD_CLIPRAISELOWER,
638 NULL, getKeybind, setKeyGrab, NULL, NULL},
639 {"MiniaturizeKey", "Mod1+M", (void *)WKBD_MINIATURIZE,
640 NULL, getKeybind, setKeyGrab, NULL, NULL},
641 {"MinimizeAllKey", "None", (void *)WKBD_MINIMIZEALL,
642 NULL, getKeybind, setKeyGrab, NULL, NULL },
643 {"HideKey", "Mod1+H", (void *)WKBD_HIDE,
644 NULL, getKeybind, setKeyGrab, NULL, NULL},
645 {"HideOthersKey", "None", (void *)WKBD_HIDE_OTHERS,
646 NULL, getKeybind, setKeyGrab, NULL, NULL},
647 {"MoveResizeKey", "None", (void *)WKBD_MOVERESIZE,
648 NULL, getKeybind, setKeyGrab, NULL, NULL},
649 {"CloseKey", "None", (void *)WKBD_CLOSE,
650 NULL, getKeybind, setKeyGrab, NULL, NULL},
651 {"MaximizeKey", "None", (void *)WKBD_MAXIMIZE,
652 NULL, getKeybind, setKeyGrab, NULL, NULL},
653 {"VMaximizeKey", "None", (void *)WKBD_VMAXIMIZE,
654 NULL, getKeybind, setKeyGrab, NULL, NULL},
655 {"HMaximizeKey", "None", (void *)WKBD_HMAXIMIZE,
656 NULL, getKeybind, setKeyGrab, NULL, NULL},
657 {"LHMaximizeKey", "None", (void*)WKBD_LHMAXIMIZE,
658 NULL, getKeybind, setKeyGrab, NULL, NULL},
659 {"RHMaximizeKey", "None", (void*)WKBD_RHMAXIMIZE,
660 NULL, getKeybind, setKeyGrab, NULL, NULL},
661 {"THMaximizeKey", "None", (void*)WKBD_THMAXIMIZE,
662 NULL, getKeybind, setKeyGrab, NULL, NULL},
663 {"BHMaximizeKey", "None", (void*)WKBD_BHMAXIMIZE,
664 NULL, getKeybind, setKeyGrab, NULL, NULL},
665 {"TLCMaximizeKey", "None", (void*)WKBD_LTCMAXIMIZE,
666 NULL, getKeybind, setKeyGrab, NULL, NULL},
667 {"TRCMaximizeKey", "None", (void*)WKBD_RTCMAXIMIZE,
668 NULL, getKeybind, setKeyGrab, NULL, NULL},
669 {"BLCMaximizeKey", "None", (void*)WKBD_LBCMAXIMIZE,
670 NULL, getKeybind, setKeyGrab, NULL, NULL},
671 {"BRCMaximizeKey", "None", (void*)WKBD_RBCMAXIMIZE,
672 NULL, getKeybind, setKeyGrab, NULL, NULL},
673 {"MaximusKey", "None", (void*)WKBD_MAXIMUS,
674 NULL, getKeybind, setKeyGrab, NULL, NULL},
675 {"KeepOnTopKey", "None", (void *)WKBD_KEEP_ON_TOP,
676 NULL, getKeybind, setKeyGrab, NULL, NULL},
677 {"KeepAtBottomKey", "None", (void *)WKBD_KEEP_AT_BOTTOM,
678 NULL, getKeybind, setKeyGrab, NULL, NULL},
679 {"OmnipresentKey", "None", (void *)WKBD_OMNIPRESENT,
680 NULL, getKeybind, setKeyGrab, NULL, NULL},
681 {"RaiseKey", "Mod1+Up", (void *)WKBD_RAISE,
682 NULL, getKeybind, setKeyGrab, NULL, NULL},
683 {"LowerKey", "Mod1+Down", (void *)WKBD_LOWER,
684 NULL, getKeybind, setKeyGrab, NULL, NULL},
685 {"RaiseLowerKey", "None", (void *)WKBD_RAISELOWER,
686 NULL, getKeybind, setKeyGrab, NULL, NULL},
687 {"ShadeKey", "None", (void *)WKBD_SHADE,
688 NULL, getKeybind, setKeyGrab, NULL, NULL},
689 {"SelectKey", "None", (void *)WKBD_SELECT,
690 NULL, getKeybind, setKeyGrab, NULL, NULL},
691 {"WorkspaceMapKey", "None", (void *)WKBD_WORKSPACEMAP,
692 NULL, getKeybind, setKeyGrab, NULL, NULL},
693 {"FocusNextKey", "Mod1+Tab", (void *)WKBD_FOCUSNEXT,
694 NULL, getKeybind, setKeyGrab, NULL, NULL},
695 {"FocusPrevKey", "Mod1+Shift+Tab", (void *)WKBD_FOCUSPREV,
696 NULL, getKeybind, setKeyGrab, NULL, NULL},
697 {"GroupNextKey", "None", (void *)WKBD_GROUPNEXT,
698 NULL, getKeybind, setKeyGrab, NULL, NULL},
699 {"GroupPrevKey", "None", (void *)WKBD_GROUPPREV,
700 NULL, getKeybind, setKeyGrab, NULL, NULL},
701 {"NextWorkspaceKey", "Mod1+Control+Right", (void *)WKBD_NEXTWORKSPACE,
702 NULL, getKeybind, setKeyGrab, NULL, NULL},
703 {"PrevWorkspaceKey", "Mod1+Control+Left", (void *)WKBD_PREVWORKSPACE,
704 NULL, getKeybind, setKeyGrab, NULL, NULL},
705 {"LastWorkspaceKey", "None", (void *)WKBD_LASTWORKSPACE,
706 NULL, getKeybind, setKeyGrab, NULL, NULL},
707 {"NextWorkspaceLayerKey", "None", (void *)WKBD_NEXTWSLAYER,
708 NULL, getKeybind, setKeyGrab, NULL, NULL},
709 {"PrevWorkspaceLayerKey", "None", (void *)WKBD_PREVWSLAYER,
710 NULL, getKeybind, setKeyGrab, NULL, NULL},
711 {"Workspace1Key", "Mod1+1", (void *)WKBD_WORKSPACE1,
712 NULL, getKeybind, setKeyGrab, NULL, NULL},
713 {"Workspace2Key", "Mod1+2", (void *)WKBD_WORKSPACE2,
714 NULL, getKeybind, setKeyGrab, NULL, NULL},
715 {"Workspace3Key", "Mod1+3", (void *)WKBD_WORKSPACE3,
716 NULL, getKeybind, setKeyGrab, NULL, NULL},
717 {"Workspace4Key", "Mod1+4", (void *)WKBD_WORKSPACE4,
718 NULL, getKeybind, setKeyGrab, NULL, NULL},
719 {"Workspace5Key", "Mod1+5", (void *)WKBD_WORKSPACE5,
720 NULL, getKeybind, setKeyGrab, NULL, NULL},
721 {"Workspace6Key", "Mod1+6", (void *)WKBD_WORKSPACE6,
722 NULL, getKeybind, setKeyGrab, NULL, NULL},
723 {"Workspace7Key", "Mod1+7", (void *)WKBD_WORKSPACE7,
724 NULL, getKeybind, setKeyGrab, NULL, NULL},
725 {"Workspace8Key", "Mod1+8", (void *)WKBD_WORKSPACE8,
726 NULL, getKeybind, setKeyGrab, NULL, NULL},
727 {"Workspace9Key", "Mod1+9", (void *)WKBD_WORKSPACE9,
728 NULL, getKeybind, setKeyGrab, NULL, NULL},
729 {"Workspace10Key", "Mod1+0", (void *)WKBD_WORKSPACE10,
730 NULL, getKeybind, setKeyGrab, NULL, NULL},
731 {"MoveToWorkspace1Key", "None", (void *)WKBD_MOVE_WORKSPACE1,
732 NULL, getKeybind, setKeyGrab, NULL, NULL},
733 {"MoveToWorkspace2Key", "None", (void *)WKBD_MOVE_WORKSPACE2,
734 NULL, getKeybind, setKeyGrab, NULL, NULL},
735 {"MoveToWorkspace3Key", "None", (void *)WKBD_MOVE_WORKSPACE3,
736 NULL, getKeybind, setKeyGrab, NULL, NULL},
737 {"MoveToWorkspace4Key", "None", (void *)WKBD_MOVE_WORKSPACE4,
738 NULL, getKeybind, setKeyGrab, NULL, NULL},
739 {"MoveToWorkspace5Key", "None", (void *)WKBD_MOVE_WORKSPACE5,
740 NULL, getKeybind, setKeyGrab, NULL, NULL},
741 {"MoveToWorkspace6Key", "None", (void *)WKBD_MOVE_WORKSPACE6,
742 NULL, getKeybind, setKeyGrab, NULL, NULL},
743 {"MoveToWorkspace7Key", "None", (void *)WKBD_MOVE_WORKSPACE7,
744 NULL, getKeybind, setKeyGrab, NULL, NULL},
745 {"MoveToWorkspace8Key", "None", (void *)WKBD_MOVE_WORKSPACE8,
746 NULL, getKeybind, setKeyGrab, NULL, NULL},
747 {"MoveToWorkspace9Key", "None", (void *)WKBD_MOVE_WORKSPACE9,
748 NULL, getKeybind, setKeyGrab, NULL, NULL},
749 {"MoveToWorkspace10Key", "None", (void *)WKBD_MOVE_WORKSPACE10,
750 NULL, getKeybind, setKeyGrab, NULL, NULL},
751 {"MoveToNextWorkspaceKey", "None", (void *)WKBD_MOVE_NEXTWORKSPACE,
752 NULL, getKeybind, setKeyGrab, NULL, NULL},
753 {"MoveToPrevWorkspaceKey", "None", (void *)WKBD_MOVE_PREVWORKSPACE,
754 NULL, getKeybind, setKeyGrab, NULL, NULL},
755 {"MoveToLastWorkspaceKey", "None", (void *)WKBD_MOVE_LASTWORKSPACE,
756 NULL, getKeybind, setKeyGrab, NULL, NULL},
757 {"MoveToNextWorkspaceLayerKey", "None", (void *)WKBD_MOVE_NEXTWSLAYER,
758 NULL, getKeybind, setKeyGrab, NULL, NULL},
759 {"MoveToPrevWorkspaceLayerKey", "None", (void *)WKBD_MOVE_PREVWSLAYER,
760 NULL, getKeybind, setKeyGrab, NULL, NULL},
761 {"WindowShortcut1Key", "None", (void *)WKBD_WINDOW1,
762 NULL, getKeybind, setKeyGrab, NULL, NULL},
763 {"WindowShortcut2Key", "None", (void *)WKBD_WINDOW2,
764 NULL, getKeybind, setKeyGrab, NULL, NULL},
765 {"WindowShortcut3Key", "None", (void *)WKBD_WINDOW3,
766 NULL, getKeybind, setKeyGrab, NULL, NULL},
767 {"WindowShortcut4Key", "None", (void *)WKBD_WINDOW4,
768 NULL, getKeybind, setKeyGrab, NULL, NULL},
769 {"WindowShortcut5Key", "None", (void *)WKBD_WINDOW5,
770 NULL, getKeybind, setKeyGrab, NULL, NULL},
771 {"WindowShortcut6Key", "None", (void *)WKBD_WINDOW6,
772 NULL, getKeybind, setKeyGrab, NULL, NULL},
773 {"WindowShortcut7Key", "None", (void *)WKBD_WINDOW7,
774 NULL, getKeybind, setKeyGrab, NULL, NULL},
775 {"WindowShortcut8Key", "None", (void *)WKBD_WINDOW8,
776 NULL, getKeybind, setKeyGrab, NULL, NULL},
777 {"WindowShortcut9Key", "None", (void *)WKBD_WINDOW9,
778 NULL, getKeybind, setKeyGrab, NULL, NULL},
779 {"WindowShortcut10Key", "None", (void *)WKBD_WINDOW10,
780 NULL, getKeybind, setKeyGrab, NULL, NULL},
781 {"MoveTo12to6Head", "None", (void *)WKBD_MOVE_12_TO_6_HEAD,
782 NULL, getKeybind, setKeyGrab, NULL, NULL},
783 {"MoveTo6to12Head", "None", (void *)WKBD_MOVE_6_TO_12_HEAD,
784 NULL, getKeybind, setKeyGrab, NULL, NULL},
785 {"WindowRelaunchKey", "None", (void *)WKBD_RELAUNCH,
786 NULL, getKeybind, setKeyGrab, NULL, NULL},
787 {"ScreenSwitchKey", "None", (void *)WKBD_SWITCH_SCREEN,
788 NULL, getKeybind, setKeyGrab, NULL, NULL},
789 {"RunKey", "None", (void *)WKBD_RUN,
790 NULL, getKeybind, setKeyGrab, NULL, NULL},
791 {"ExitKey", "None", (void *)WKBD_EXIT,
792 NULL, getKeybind, setKeyGrab, NULL, NULL},
793 {"ScreenCaptureKey", "None", (void *)WKBD_PRINTS,
794 NULL, getKeybind, setKeyGrab, NULL, NULL},
795 {"WindowCaptureKey", "None", (void *)WKBD_PRINTW,
796 NULL, getKeybind, setKeyGrab, NULL, NULL},
797 {"PartialCaptureKey", "None", (void *)WKBD_PRINTP,
798 NULL, getKeybind, setKeyGrab, NULL, NULL},
800 #ifdef KEEP_XKB_LOCK_STATUS
801 {"ToggleKbdModeKey", "None", (void *)WKBD_TOGGLE,
802 NULL, getKeybind, setKeyGrab, NULL, NULL},
803 {"KbdModeLock", "NO", NULL,
804 &wPreferences.modelock, getBool, NULL, NULL, NULL},
805 #endif /* KEEP_XKB_LOCK_STATUS */
807 {"NormalCursor", "(builtin, left_ptr)", (void *)WCUR_ROOT,
808 NULL, getCursor, setCursor, NULL, NULL},
809 {"ArrowCursor", "(builtin, top_left_arrow)", (void *)WCUR_ARROW,
810 NULL, getCursor, setCursor, NULL, NULL},
811 {"MoveCursor", "(builtin, fleur)", (void *)WCUR_MOVE,
812 NULL, getCursor, setCursor, NULL, NULL},
813 {"ResizeCursor", "(builtin, sizing)", (void *)WCUR_RESIZE,
814 NULL, getCursor, setCursor, NULL, NULL},
815 {"TopLeftResizeCursor", "(builtin, top_left_corner)", (void *)WCUR_TOPLEFTRESIZE,
816 NULL, getCursor, setCursor, NULL, NULL},
817 {"TopRightResizeCursor", "(builtin, top_right_corner)", (void *)WCUR_TOPRIGHTRESIZE,
818 NULL, getCursor, setCursor, NULL, NULL},
819 {"BottomLeftResizeCursor", "(builtin, bottom_left_corner)", (void *)WCUR_BOTTOMLEFTRESIZE,
820 NULL, getCursor, setCursor, NULL, NULL},
821 {"BottomRightResizeCursor", "(builtin, bottom_right_corner)", (void *)WCUR_BOTTOMRIGHTRESIZE,
822 NULL, getCursor, setCursor, NULL, NULL},
823 {"VerticalResizeCursor", "(builtin, sb_v_double_arrow)", (void *)WCUR_VERTICALRESIZE,
824 NULL, getCursor, setCursor, NULL, NULL},
825 {"HorizontalResizeCursor", "(builtin, sb_h_double_arrow)", (void *)WCUR_HORIZONRESIZE,
826 NULL, getCursor, setCursor, NULL, NULL},
827 {"WaitCursor", "(builtin, watch)", (void *)WCUR_WAIT,
828 NULL, getCursor, setCursor, NULL, NULL},
829 {"QuestionCursor", "(builtin, question_arrow)", (void *)WCUR_QUESTION,
830 NULL, getCursor, setCursor, NULL, NULL},
831 {"TextCursor", "(builtin, xterm)", (void *)WCUR_TEXT,
832 NULL, getCursor, setCursor, NULL, NULL},
833 {"SelectCursor", "(builtin, cross)", (void *)WCUR_SELECT,
834 NULL, getCursor, setCursor, NULL, NULL},
835 {"CaptureCursor", "(builtin, crosshair)", (void *)WCUR_CAPTURE,
836 NULL, getCursor, setCursor, NULL, NULL},
837 {"DialogHistoryLines", "500", NULL,
838 &wPreferences.history_lines, getInt, NULL, NULL, NULL},
839 {"CycleActiveHeadOnly", "NO", NULL,
840 &wPreferences.cycle_active_head_only, getBool, NULL, NULL, NULL},
841 {"CycleIgnoreMinimized", "NO", NULL,
842 &wPreferences.cycle_ignore_minimized, getBool, NULL, NULL, NULL},
843 {"DbClickFullScreen", "NO", NULL,
844 &wPreferences.double_click_fullscreen, getBool, NULL, NULL, NULL},
845 {"CloseRootMenuByLeftOrRightMouseClick", "NO", NULL,
846 &wPreferences.close_rootmenu_left_right_click, getBool, NULL, NULL, NULL}
849 static void initDefaults(void)
851 unsigned int i;
852 WDefaultEntry *entry;
854 WMPLSetCaseSensitive(False);
856 for (i = 0; i < wlengthof(optionList); i++) {
857 entry = &optionList[i];
859 entry->plkey = WMCreatePLString(entry->key);
860 if (entry->default_value)
861 entry->plvalue = WMCreatePropListFromDescription(entry->default_value);
862 else
863 entry->plvalue = NULL;
866 for (i = 0; i < wlengthof(staticOptionList); i++) {
867 entry = &staticOptionList[i];
869 entry->plkey = WMCreatePLString(entry->key);
870 if (entry->default_value)
871 entry->plvalue = WMCreatePropListFromDescription(entry->default_value);
872 else
873 entry->plvalue = NULL;
877 static WMPropList *readGlobalDomain(const char *domainName, Bool requireDictionary)
879 WMPropList *globalDict = NULL;
880 char path[PATH_MAX];
881 struct stat stbuf;
883 snprintf(path, sizeof(path), "%s/%s", PKGCONFDIR, domainName);
884 if (stat(path, &stbuf) >= 0) {
885 globalDict = WMReadPropListFromFile(path);
886 if (globalDict && requireDictionary && !WMIsPLDictionary(globalDict)) {
887 wwarning(_("Domain %s (%s) of global defaults database is corrupted!"), domainName, path);
888 WMReleasePropList(globalDict);
889 globalDict = NULL;
890 } else if (!globalDict) {
891 wwarning(_("could not load domain %s from global defaults database"), domainName);
895 return globalDict;
898 #if defined(GLOBAL_PREAMBLE_MENU_FILE) || defined(GLOBAL_EPILOGUE_MENU_FILE)
899 static void prependMenu(WMPropList * destarr, WMPropList * array)
901 WMPropList *item;
902 int i;
904 for (i = 0; i < WMGetPropListItemCount(array); i++) {
905 item = WMGetFromPLArray(array, i);
906 if (item)
907 WMInsertInPLArray(destarr, i + 1, item);
911 static void appendMenu(WMPropList * destarr, WMPropList * array)
913 WMPropList *item;
914 int i;
916 for (i = 0; i < WMGetPropListItemCount(array); i++) {
917 item = WMGetFromPLArray(array, i);
918 if (item)
919 WMAddToPLArray(destarr, item);
922 #endif
924 void wDefaultsMergeGlobalMenus(WDDomain * menuDomain)
926 WMPropList *menu = menuDomain->dictionary;
927 WMPropList *submenu;
929 if (!menu || !WMIsPLArray(menu))
930 return;
932 #ifdef GLOBAL_PREAMBLE_MENU_FILE
933 submenu = WMReadPropListFromFile(PKGCONFDIR "/" GLOBAL_PREAMBLE_MENU_FILE);
935 if (submenu && !WMIsPLArray(submenu)) {
936 wwarning(_("invalid global menu file %s"), GLOBAL_PREAMBLE_MENU_FILE);
937 WMReleasePropList(submenu);
938 submenu = NULL;
940 if (submenu) {
941 prependMenu(menu, submenu);
942 WMReleasePropList(submenu);
944 #endif
946 #ifdef GLOBAL_EPILOGUE_MENU_FILE
947 submenu = WMReadPropListFromFile(PKGCONFDIR "/" GLOBAL_EPILOGUE_MENU_FILE);
949 if (submenu && !WMIsPLArray(submenu)) {
950 wwarning(_("invalid global menu file %s"), GLOBAL_EPILOGUE_MENU_FILE);
951 WMReleasePropList(submenu);
952 submenu = NULL;
954 if (submenu) {
955 appendMenu(menu, submenu);
956 WMReleasePropList(submenu);
958 #endif
960 menuDomain->dictionary = menu;
963 WDDomain *wDefaultsInitDomain(const char *domain, Bool requireDictionary)
965 WDDomain *db;
966 struct stat stbuf;
967 static int inited = 0;
968 WMPropList *shared_dict = NULL;
970 if (!inited) {
971 inited = 1;
972 initDefaults();
975 db = wmalloc(sizeof(WDDomain));
976 db->domain_name = domain;
977 db->path = wdefaultspathfordomain(domain);
979 if (stat(db->path, &stbuf) >= 0) {
980 db->dictionary = WMReadPropListFromFile(db->path);
981 if (db->dictionary) {
982 if (requireDictionary && !WMIsPLDictionary(db->dictionary)) {
983 WMReleasePropList(db->dictionary);
984 db->dictionary = NULL;
985 wwarning(_("Domain %s (%s) of defaults database is corrupted!"), domain, db->path);
987 db->timestamp = stbuf.st_mtime;
988 } else {
989 wwarning(_("could not load domain %s from user defaults database"), domain);
993 /* global system dictionary */
994 shared_dict = readGlobalDomain(domain, requireDictionary);
996 if (shared_dict && db->dictionary && WMIsPLDictionary(shared_dict) &&
997 WMIsPLDictionary(db->dictionary)) {
998 WMMergePLDictionaries(shared_dict, db->dictionary, True);
999 WMReleasePropList(db->dictionary);
1000 db->dictionary = shared_dict;
1001 if (stbuf.st_mtime > db->timestamp)
1002 db->timestamp = stbuf.st_mtime;
1003 } else if (!db->dictionary) {
1004 db->dictionary = shared_dict;
1005 if (stbuf.st_mtime > db->timestamp)
1006 db->timestamp = stbuf.st_mtime;
1009 return db;
1012 void wReadStaticDefaults(WMPropList * dict)
1014 WMPropList *plvalue;
1015 WDefaultEntry *entry;
1016 unsigned int i;
1017 void *tdata;
1019 for (i = 0; i < wlengthof(staticOptionList); i++) {
1020 entry = &staticOptionList[i];
1022 if (dict)
1023 plvalue = WMGetFromPLDictionary(dict, entry->plkey);
1024 else
1025 plvalue = NULL;
1027 /* no default in the DB. Use builtin default */
1028 if (!plvalue)
1029 plvalue = entry->plvalue;
1031 if (plvalue) {
1032 /* convert data */
1033 (*entry->convert) (NULL, entry, plvalue, entry->addr, &tdata);
1034 if (entry->update)
1035 (*entry->update) (NULL, entry, tdata, entry->extra_data);
1040 void wDefaultsCheckDomains(void* arg)
1042 WScreen *scr;
1043 struct stat stbuf;
1044 WMPropList *shared_dict = NULL;
1045 WMPropList *dict;
1046 int i;
1048 /* Parameter not used, but tell the compiler that it is ok */
1049 (void) arg;
1051 if (stat(w_global.domain.wmaker->path, &stbuf) >= 0 && w_global.domain.wmaker->timestamp < stbuf.st_mtime) {
1052 w_global.domain.wmaker->timestamp = stbuf.st_mtime;
1054 /* Global dictionary */
1055 shared_dict = readGlobalDomain("WindowMaker", True);
1057 /* User dictionary */
1058 dict = WMReadPropListFromFile(w_global.domain.wmaker->path);
1060 if (dict) {
1061 if (!WMIsPLDictionary(dict)) {
1062 WMReleasePropList(dict);
1063 dict = NULL;
1064 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
1065 "WindowMaker", w_global.domain.wmaker->path);
1066 } else {
1067 if (shared_dict) {
1068 WMMergePLDictionaries(shared_dict, dict, True);
1069 WMReleasePropList(dict);
1070 dict = shared_dict;
1071 shared_dict = NULL;
1074 for (i = 0; i < w_global.screen_count; i++) {
1075 scr = wScreenWithNumber(i);
1076 if (scr)
1077 wReadDefaults(scr, dict);
1080 if (w_global.domain.wmaker->dictionary)
1081 WMReleasePropList(w_global.domain.wmaker->dictionary);
1083 w_global.domain.wmaker->dictionary = dict;
1085 } else {
1086 wwarning(_("could not load domain %s from user defaults database"), "WindowMaker");
1089 if (shared_dict)
1090 WMReleasePropList(shared_dict);
1094 if (stat(w_global.domain.window_attr->path, &stbuf) >= 0 && w_global.domain.window_attr->timestamp < stbuf.st_mtime) {
1095 /* global dictionary */
1096 shared_dict = readGlobalDomain("WMWindowAttributes", True);
1097 /* user dictionary */
1098 dict = WMReadPropListFromFile(w_global.domain.window_attr->path);
1099 if (dict) {
1100 if (!WMIsPLDictionary(dict)) {
1101 WMReleasePropList(dict);
1102 dict = NULL;
1103 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
1104 "WMWindowAttributes", w_global.domain.window_attr->path);
1105 } else {
1106 if (shared_dict) {
1107 WMMergePLDictionaries(shared_dict, dict, True);
1108 WMReleasePropList(dict);
1109 dict = shared_dict;
1110 shared_dict = NULL;
1113 if (w_global.domain.window_attr->dictionary)
1114 WMReleasePropList(w_global.domain.window_attr->dictionary);
1116 w_global.domain.window_attr->dictionary = dict;
1117 for (i = 0; i < w_global.screen_count; i++) {
1118 scr = wScreenWithNumber(i);
1119 if (scr) {
1120 wDefaultUpdateIcons(scr);
1122 /* Update the panel image if changed */
1123 /* Don't worry. If the image is the same these
1124 * functions will have no performance impact. */
1125 create_logo_image(scr);
1129 } else {
1130 wwarning(_("could not load domain %s from user defaults database"), "WMWindowAttributes");
1133 w_global.domain.window_attr->timestamp = stbuf.st_mtime;
1134 if (shared_dict)
1135 WMReleasePropList(shared_dict);
1138 if (stat(w_global.domain.root_menu->path, &stbuf) >= 0 && w_global.domain.root_menu->timestamp < stbuf.st_mtime) {
1139 dict = WMReadPropListFromFile(w_global.domain.root_menu->path);
1140 if (dict) {
1141 if (!WMIsPLArray(dict) && !WMIsPLString(dict)) {
1142 WMReleasePropList(dict);
1143 dict = NULL;
1144 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
1145 "WMRootMenu", w_global.domain.root_menu->path);
1146 } else {
1147 if (w_global.domain.root_menu->dictionary)
1148 WMReleasePropList(w_global.domain.root_menu->dictionary);
1150 w_global.domain.root_menu->dictionary = dict;
1151 wDefaultsMergeGlobalMenus(w_global.domain.root_menu);
1153 } else {
1154 wwarning(_("could not load domain %s from user defaults database"), "WMRootMenu");
1156 w_global.domain.root_menu->timestamp = stbuf.st_mtime;
1158 #ifndef HAVE_INOTIFY
1159 if (!arg)
1160 WMAddTimerHandler(DEFAULTS_CHECK_INTERVAL, wDefaultsCheckDomains, arg);
1161 #endif
1164 void wReadDefaults(WScreen * scr, WMPropList * new_dict)
1166 WMPropList *plvalue, *old_value;
1167 WDefaultEntry *entry;
1168 unsigned int i;
1169 int update_workspace_back = 0; /* kluge :/ */
1170 unsigned int needs_refresh;
1171 void *tdata;
1172 WMPropList *old_dict = (w_global.domain.wmaker->dictionary != new_dict ? w_global.domain.wmaker->dictionary : NULL);
1174 needs_refresh = 0;
1176 for (i = 0; i < wlengthof(optionList); i++) {
1177 entry = &optionList[i];
1179 if (new_dict)
1180 plvalue = WMGetFromPLDictionary(new_dict, entry->plkey);
1181 else
1182 plvalue = NULL;
1184 if (!old_dict)
1185 old_value = NULL;
1186 else
1187 old_value = WMGetFromPLDictionary(old_dict, entry->plkey);
1189 if (!plvalue && !old_value) {
1190 /* no default in the DB. Use builtin default */
1191 plvalue = entry->plvalue;
1192 if (plvalue && new_dict)
1193 WMPutInPLDictionary(new_dict, entry->plkey, plvalue);
1195 } else if (!plvalue) {
1196 /* value was deleted from DB. Keep current value */
1197 continue;
1198 } else if (!old_value) {
1199 /* set value for the 1st time */
1200 } else if (!WMIsPropListEqualTo(plvalue, old_value)) {
1201 /* value has changed */
1202 } else {
1203 if (strcmp(entry->key, "WorkspaceBack") == 0
1204 && update_workspace_back && scr->flags.backimage_helper_launched) {
1205 } else {
1206 /* value was not changed since last time */
1207 continue;
1211 if (plvalue) {
1212 /* convert data */
1213 if ((*entry->convert) (scr, entry, plvalue, entry->addr, &tdata)) {
1215 * If the WorkspaceSpecificBack data has been changed
1216 * so that the helper will be launched now, we must be
1217 * sure to send the default background texture config
1218 * to the helper.
1220 if (strcmp(entry->key, "WorkspaceSpecificBack") == 0 &&
1221 !scr->flags.backimage_helper_launched)
1222 update_workspace_back = 1;
1224 if (entry->update)
1225 needs_refresh |= (*entry->update) (scr, entry, tdata, entry->extra_data);
1231 if (needs_refresh != 0 && !scr->flags.startup) {
1232 int foo;
1234 foo = 0;
1235 if (needs_refresh & REFRESH_MENU_TITLE_TEXTURE)
1236 foo |= WTextureSettings;
1237 if (needs_refresh & REFRESH_MENU_TITLE_FONT)
1238 foo |= WFontSettings;
1239 if (needs_refresh & REFRESH_MENU_TITLE_COLOR)
1240 foo |= WColorSettings;
1241 if (foo)
1242 WMPostNotificationName(WNMenuTitleAppearanceSettingsChanged, NULL,
1243 (void *)(uintptr_t) foo);
1245 foo = 0;
1246 if (needs_refresh & REFRESH_MENU_TEXTURE)
1247 foo |= WTextureSettings;
1248 if (needs_refresh & REFRESH_MENU_FONT)
1249 foo |= WFontSettings;
1250 if (needs_refresh & REFRESH_MENU_COLOR)
1251 foo |= WColorSettings;
1252 if (foo)
1253 WMPostNotificationName(WNMenuAppearanceSettingsChanged, NULL, (void *)(uintptr_t) foo);
1255 foo = 0;
1256 if (needs_refresh & REFRESH_WINDOW_FONT)
1257 foo |= WFontSettings;
1258 if (needs_refresh & REFRESH_WINDOW_TEXTURES)
1259 foo |= WTextureSettings;
1260 if (needs_refresh & REFRESH_WINDOW_TITLE_COLOR)
1261 foo |= WColorSettings;
1262 if (foo)
1263 WMPostNotificationName(WNWindowAppearanceSettingsChanged, NULL, (void *)(uintptr_t) foo);
1265 if (!(needs_refresh & REFRESH_ICON_TILE)) {
1266 foo = 0;
1267 if (needs_refresh & REFRESH_ICON_FONT)
1268 foo |= WFontSettings;
1269 if (needs_refresh & REFRESH_ICON_TITLE_COLOR)
1270 foo |= WTextureSettings;
1271 if (needs_refresh & REFRESH_ICON_TITLE_BACK)
1272 foo |= WTextureSettings;
1273 if (foo)
1274 WMPostNotificationName(WNIconAppearanceSettingsChanged, NULL,
1275 (void *)(uintptr_t) foo);
1277 if (needs_refresh & REFRESH_ICON_TILE)
1278 WMPostNotificationName(WNIconTileSettingsChanged, NULL, NULL);
1280 if (needs_refresh & REFRESH_WORKSPACE_MENU) {
1281 if (scr->workspace_menu)
1282 wWorkspaceMenuUpdate(scr, scr->workspace_menu);
1283 if (scr->clip_ws_menu)
1284 wWorkspaceMenuUpdate(scr, scr->clip_ws_menu);
1285 if (scr->workspace_submenu)
1286 scr->workspace_submenu->flags.realized = 0;
1287 if (scr->clip_submenu)
1288 scr->clip_submenu->flags.realized = 0;
1293 void wDefaultUpdateIcons(WScreen *scr)
1295 WAppIcon *aicon = scr->app_icon_list;
1296 WDrawerChain *dc;
1297 WWindow *wwin = scr->focused_window;
1299 while (aicon) {
1300 /* Get the application icon, default included */
1301 wIconChangeImageFile(aicon->icon, NULL);
1302 wAppIconPaint(aicon);
1303 aicon = aicon->next;
1306 if (!wPreferences.flags.noclip || wPreferences.flags.clip_merged_in_dock)
1307 wClipIconPaint(scr->clip_icon);
1309 for (dc = scr->drawers; dc != NULL; dc = dc->next)
1310 wDrawerIconPaint(dc->adrawer->icon_array[0]);
1312 while (wwin) {
1313 if (wwin->icon && wwin->flags.miniaturized)
1314 wIconChangeImageFile(wwin->icon, NULL);
1315 wwin = wwin->prev;
1319 /* --------------------------- Local ----------------------- */
1321 #define GET_STRING_OR_DEFAULT(x, var) if (!WMIsPLString(value)) { \
1322 wwarning(_("Wrong option format for key \"%s\". Should be %s."), \
1323 entry->key, x); \
1324 wwarning(_("using default \"%s\" instead"), entry->default_value); \
1325 var = entry->default_value;\
1326 } else var = WMGetFromPLString(value)\
1329 static int string2index(WMPropList *key, WMPropList *val, const char *def, WOptionEnumeration * values)
1331 char *str;
1332 WOptionEnumeration *v;
1333 char buffer[TOTAL_VALUES_LENGTH];
1335 if (WMIsPLString(val) && (str = WMGetFromPLString(val))) {
1336 for (v = values; v->string != NULL; v++) {
1337 if (strcasecmp(v->string, str) == 0)
1338 return v->value;
1342 buffer[0] = 0;
1343 for (v = values; v->string != NULL; v++) {
1344 if (!v->is_alias) {
1345 if (buffer[0] != 0)
1346 strcat(buffer, ", ");
1347 snprintf(buffer+strlen(buffer),
1348 sizeof(buffer)-strlen(buffer)-1, "\"%s\"", v->string);
1351 wwarning(_("wrong option value for key \"%s\"; got \"%s\", should be one of %s."),
1352 WMGetFromPLString(key),
1353 WMIsPLString(val) ? WMGetFromPLString(val) : "(unknown)",
1354 buffer);
1356 if (def) {
1357 return string2index(key, val, NULL, values);
1360 return -1;
1364 * value - is the value in the defaults DB
1365 * addr - is the address to store the data
1366 * ret - is the address to store a pointer to a temporary buffer. ret
1367 * must not be freed and is used by the set functions
1369 static int getBool(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1371 static char data;
1372 const char *val;
1373 int second_pass = 0;
1375 /* Parameter not used, but tell the compiler that it is ok */
1376 (void) scr;
1378 GET_STRING_OR_DEFAULT("Boolean", val);
1380 again:
1381 if ((val[1] == '\0' && (val[0] == 'y' || val[0] == 'Y'))
1382 || strcasecmp(val, "YES") == 0) {
1384 data = 1;
1385 } else if ((val[1] == '\0' && (val[0] == 'n' || val[0] == 'N'))
1386 || strcasecmp(val, "NO") == 0) {
1387 data = 0;
1388 } else {
1389 int i;
1390 if (sscanf(val, "%i", &i) == 1) {
1391 if (i != 0)
1392 data = 1;
1393 else
1394 data = 0;
1395 } else {
1396 wwarning(_("can't convert \"%s\" to boolean for key \"%s\""), val, entry->key);
1397 if (second_pass == 0) {
1398 val = WMGetFromPLString(entry->plvalue);
1399 second_pass = 1;
1400 wwarning(_("using default \"%s\" instead"), val);
1401 goto again;
1403 return False;
1407 if (ret)
1408 *ret = &data;
1409 if (addr)
1410 *(char *)addr = data;
1412 return True;
1415 static int getInt(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1417 static int data;
1418 const char *val;
1420 /* Parameter not used, but tell the compiler that it is ok */
1421 (void) scr;
1423 GET_STRING_OR_DEFAULT("Integer", val);
1425 if (sscanf(val, "%i", &data) != 1) {
1426 wwarning(_("can't convert \"%s\" to integer for key \"%s\""), val, entry->key);
1427 val = WMGetFromPLString(entry->plvalue);
1428 wwarning(_("using default \"%s\" instead"), val);
1429 if (sscanf(val, "%i", &data) != 1) {
1430 return False;
1434 if (ret)
1435 *ret = &data;
1436 if (addr)
1437 *(int *)addr = data;
1439 return True;
1442 static int getCoord(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1444 static WCoord data;
1445 char *val_x, *val_y;
1446 int nelem, changed = 0;
1447 WMPropList *elem_x, *elem_y;
1449 again:
1450 if (!WMIsPLArray(value)) {
1451 wwarning(_("Wrong option format for key \"%s\". Should be %s."), entry->key, "Coordinate");
1452 if (changed == 0) {
1453 value = entry->plvalue;
1454 changed = 1;
1455 wwarning(_("using default \"%s\" instead"), entry->default_value);
1456 goto again;
1458 return False;
1461 nelem = WMGetPropListItemCount(value);
1462 if (nelem != 2) {
1463 wwarning(_("Incorrect number of elements in array for key \"%s\"."), entry->key);
1464 if (changed == 0) {
1465 value = entry->plvalue;
1466 changed = 1;
1467 wwarning(_("using default \"%s\" instead"), entry->default_value);
1468 goto again;
1470 return False;
1473 elem_x = WMGetFromPLArray(value, 0);
1474 elem_y = WMGetFromPLArray(value, 1);
1476 if (!elem_x || !elem_y || !WMIsPLString(elem_x) || !WMIsPLString(elem_y)) {
1477 wwarning(_("Wrong value for key \"%s\". Should be Coordinate."), entry->key);
1478 if (changed == 0) {
1479 value = entry->plvalue;
1480 changed = 1;
1481 wwarning(_("using default \"%s\" instead"), entry->default_value);
1482 goto again;
1484 return False;
1487 val_x = WMGetFromPLString(elem_x);
1488 val_y = WMGetFromPLString(elem_y);
1490 if (sscanf(val_x, "%i", &data.x) != 1 || sscanf(val_y, "%i", &data.y) != 1) {
1491 wwarning(_("can't convert array to integers for \"%s\"."), entry->key);
1492 if (changed == 0) {
1493 value = entry->plvalue;
1494 changed = 1;
1495 wwarning(_("using default \"%s\" instead"), entry->default_value);
1496 goto again;
1498 return False;
1501 if (data.x < 0)
1502 data.x = 0;
1503 else if (data.x > scr->scr_width / 3)
1504 data.x = scr->scr_width / 3;
1505 if (data.y < 0)
1506 data.y = 0;
1507 else if (data.y > scr->scr_height / 3)
1508 data.y = scr->scr_height / 3;
1510 if (ret)
1511 *ret = &data;
1512 if (addr)
1513 *(WCoord *) addr = data;
1515 return True;
1518 static int getPropList(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1520 /* Parameter not used, but tell the compiler that it is ok */
1521 (void) scr;
1522 (void) entry;
1523 (void) addr;
1525 WMRetainPropList(value);
1527 *ret = value;
1529 return True;
1532 static int getPathList(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1534 static char *data;
1535 int i, count, len;
1536 char *ptr;
1537 WMPropList *d;
1538 int changed = 0;
1540 /* Parameter not used, but tell the compiler that it is ok */
1541 (void) scr;
1542 (void) ret;
1544 again:
1545 if (!WMIsPLArray(value)) {
1546 wwarning(_("Wrong option format for key \"%s\". Should be %s."), entry->key, "an array of paths");
1547 if (changed == 0) {
1548 value = entry->plvalue;
1549 changed = 1;
1550 wwarning(_("using default \"%s\" instead"), entry->default_value);
1551 goto again;
1553 return False;
1556 i = 0;
1557 count = WMGetPropListItemCount(value);
1558 if (count < 1) {
1559 if (changed == 0) {
1560 value = entry->plvalue;
1561 changed = 1;
1562 wwarning(_("using default \"%s\" instead"), entry->default_value);
1563 goto again;
1565 return False;
1568 len = 0;
1569 for (i = 0; i < count; i++) {
1570 d = WMGetFromPLArray(value, i);
1571 if (!d || !WMIsPLString(d)) {
1572 count = i;
1573 break;
1575 len += strlen(WMGetFromPLString(d)) + 1;
1578 ptr = data = wmalloc(len + 1);
1580 for (i = 0; i < count; i++) {
1581 d = WMGetFromPLArray(value, i);
1582 if (!d || !WMIsPLString(d)) {
1583 break;
1585 strcpy(ptr, WMGetFromPLString(d));
1586 ptr += strlen(WMGetFromPLString(d));
1587 *ptr = ':';
1588 ptr++;
1590 ptr--;
1591 *(ptr--) = 0;
1593 if (*(char **)addr != NULL) {
1594 wfree(*(char **)addr);
1596 *(char **)addr = data;
1598 return True;
1601 static int getEnum(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1603 static signed char data;
1605 /* Parameter not used, but tell the compiler that it is ok */
1606 (void) scr;
1608 data = string2index(entry->plkey, value, entry->default_value, (WOptionEnumeration *) entry->extra_data);
1609 if (data < 0)
1610 return False;
1612 if (ret)
1613 *ret = &data;
1614 if (addr)
1615 *(signed char *)addr = data;
1617 return True;
1621 * (solid <color>)
1622 * (hgradient <color> <color>)
1623 * (vgradient <color> <color>)
1624 * (dgradient <color> <color>)
1625 * (mhgradient <color> <color> ...)
1626 * (mvgradient <color> <color> ...)
1627 * (mdgradient <color> <color> ...)
1628 * (igradient <color1> <color1> <thickness1> <color2> <color2> <thickness2>)
1629 * (tpixmap <file> <color>)
1630 * (spixmap <file> <color>)
1631 * (cpixmap <file> <color>)
1632 * (thgradient <file> <opaqueness> <color> <color>)
1633 * (tvgradient <file> <opaqueness> <color> <color>)
1634 * (tdgradient <file> <opaqueness> <color> <color>)
1635 * (function <lib> <function> ...)
1638 static WTexture *parse_texture(WScreen * scr, WMPropList * pl)
1640 WMPropList *elem;
1641 char *val;
1642 int nelem;
1643 WTexture *texture = NULL;
1645 nelem = WMGetPropListItemCount(pl);
1646 if (nelem < 1)
1647 return NULL;
1649 elem = WMGetFromPLArray(pl, 0);
1650 if (!elem || !WMIsPLString(elem))
1651 return NULL;
1652 val = WMGetFromPLString(elem);
1654 if (strcasecmp(val, "solid") == 0) {
1655 XColor color;
1657 if (nelem != 2)
1658 return NULL;
1660 /* get color */
1662 elem = WMGetFromPLArray(pl, 1);
1663 if (!elem || !WMIsPLString(elem))
1664 return NULL;
1665 val = WMGetFromPLString(elem);
1667 if (!XParseColor(dpy, scr->w_colormap, val, &color)) {
1668 wwarning(_("\"%s\" is not a valid color name"), val);
1669 return NULL;
1672 texture = (WTexture *) wTextureMakeSolid(scr, &color);
1673 } else if (strcasecmp(val, "dgradient") == 0
1674 || strcasecmp(val, "vgradient") == 0 || strcasecmp(val, "hgradient") == 0) {
1675 RColor color1, color2;
1676 XColor xcolor;
1677 int type;
1679 if (nelem != 3) {
1680 wwarning(_("bad number of arguments in gradient specification"));
1681 return NULL;
1684 if (val[0] == 'd' || val[0] == 'D')
1685 type = WTEX_DGRADIENT;
1686 else if (val[0] == 'h' || val[0] == 'H')
1687 type = WTEX_HGRADIENT;
1688 else
1689 type = WTEX_VGRADIENT;
1691 /* get from color */
1692 elem = WMGetFromPLArray(pl, 1);
1693 if (!elem || !WMIsPLString(elem))
1694 return NULL;
1695 val = WMGetFromPLString(elem);
1697 if (!XParseColor(dpy, scr->w_colormap, val, &xcolor)) {
1698 wwarning(_("\"%s\" is not a valid color name"), val);
1699 return NULL;
1701 color1.alpha = 255;
1702 color1.red = xcolor.red >> 8;
1703 color1.green = xcolor.green >> 8;
1704 color1.blue = xcolor.blue >> 8;
1706 /* get to color */
1707 elem = WMGetFromPLArray(pl, 2);
1708 if (!elem || !WMIsPLString(elem)) {
1709 return NULL;
1711 val = WMGetFromPLString(elem);
1713 if (!XParseColor(dpy, scr->w_colormap, val, &xcolor)) {
1714 wwarning(_("\"%s\" is not a valid color name"), val);
1715 return NULL;
1717 color2.alpha = 255;
1718 color2.red = xcolor.red >> 8;
1719 color2.green = xcolor.green >> 8;
1720 color2.blue = xcolor.blue >> 8;
1722 texture = (WTexture *) wTextureMakeGradient(scr, type, &color1, &color2);
1724 } else if (strcasecmp(val, "igradient") == 0) {
1725 RColor colors1[2], colors2[2];
1726 int th1, th2;
1727 XColor xcolor;
1728 int i;
1730 if (nelem != 7) {
1731 wwarning(_("bad number of arguments in gradient specification"));
1732 return NULL;
1735 /* get from color */
1736 for (i = 0; i < 2; i++) {
1737 elem = WMGetFromPLArray(pl, 1 + i);
1738 if (!elem || !WMIsPLString(elem))
1739 return NULL;
1740 val = WMGetFromPLString(elem);
1742 if (!XParseColor(dpy, scr->w_colormap, val, &xcolor)) {
1743 wwarning(_("\"%s\" is not a valid color name"), val);
1744 return NULL;
1746 colors1[i].alpha = 255;
1747 colors1[i].red = xcolor.red >> 8;
1748 colors1[i].green = xcolor.green >> 8;
1749 colors1[i].blue = xcolor.blue >> 8;
1751 elem = WMGetFromPLArray(pl, 3);
1752 if (!elem || !WMIsPLString(elem))
1753 return NULL;
1754 val = WMGetFromPLString(elem);
1755 th1 = atoi(val);
1757 /* get from color */
1758 for (i = 0; i < 2; i++) {
1759 elem = WMGetFromPLArray(pl, 4 + i);
1760 if (!elem || !WMIsPLString(elem))
1761 return NULL;
1762 val = WMGetFromPLString(elem);
1764 if (!XParseColor(dpy, scr->w_colormap, val, &xcolor)) {
1765 wwarning(_("\"%s\" is not a valid color name"), val);
1766 return NULL;
1768 colors2[i].alpha = 255;
1769 colors2[i].red = xcolor.red >> 8;
1770 colors2[i].green = xcolor.green >> 8;
1771 colors2[i].blue = xcolor.blue >> 8;
1773 elem = WMGetFromPLArray(pl, 6);
1774 if (!elem || !WMIsPLString(elem))
1775 return NULL;
1776 val = WMGetFromPLString(elem);
1777 th2 = atoi(val);
1779 texture = (WTexture *) wTextureMakeIGradient(scr, th1, colors1, th2, colors2);
1781 } else if (strcasecmp(val, "mhgradient") == 0
1782 || strcasecmp(val, "mvgradient") == 0 || strcasecmp(val, "mdgradient") == 0) {
1783 XColor color;
1784 RColor **colors;
1785 int i, count;
1786 int type;
1788 if (nelem < 3) {
1789 wwarning(_("too few arguments in multicolor gradient specification"));
1790 return NULL;
1793 if (val[1] == 'h' || val[1] == 'H')
1794 type = WTEX_MHGRADIENT;
1795 else if (val[1] == 'v' || val[1] == 'V')
1796 type = WTEX_MVGRADIENT;
1797 else
1798 type = WTEX_MDGRADIENT;
1800 count = nelem - 1;
1802 colors = wmalloc(sizeof(RColor *) * (count + 1));
1804 for (i = 0; i < count; i++) {
1805 elem = WMGetFromPLArray(pl, i + 1);
1806 if (!elem || !WMIsPLString(elem)) {
1807 for (--i; i >= 0; --i) {
1808 wfree(colors[i]);
1810 wfree(colors);
1811 return NULL;
1813 val = WMGetFromPLString(elem);
1815 if (!XParseColor(dpy, scr->w_colormap, val, &color)) {
1816 wwarning(_("\"%s\" is not a valid color name"), val);
1817 for (--i; i >= 0; --i) {
1818 wfree(colors[i]);
1820 wfree(colors);
1821 return NULL;
1822 } else {
1823 colors[i] = wmalloc(sizeof(RColor));
1824 colors[i]->red = color.red >> 8;
1825 colors[i]->green = color.green >> 8;
1826 colors[i]->blue = color.blue >> 8;
1829 colors[i] = NULL;
1831 texture = (WTexture *) wTextureMakeMGradient(scr, type, colors);
1832 } else if (strcasecmp(val, "spixmap") == 0 ||
1833 strcasecmp(val, "cpixmap") == 0 || strcasecmp(val, "tpixmap") == 0) {
1834 XColor color;
1835 int type;
1837 if (nelem != 3)
1838 return NULL;
1840 if (val[0] == 's' || val[0] == 'S')
1841 type = WTP_SCALE;
1842 else if (val[0] == 'c' || val[0] == 'C')
1843 type = WTP_CENTER;
1844 else
1845 type = WTP_TILE;
1847 /* get color */
1848 elem = WMGetFromPLArray(pl, 2);
1849 if (!elem || !WMIsPLString(elem)) {
1850 return NULL;
1852 val = WMGetFromPLString(elem);
1854 if (!XParseColor(dpy, scr->w_colormap, val, &color)) {
1855 wwarning(_("\"%s\" is not a valid color name"), val);
1856 return NULL;
1859 /* file name */
1860 elem = WMGetFromPLArray(pl, 1);
1861 if (!elem || !WMIsPLString(elem))
1862 return NULL;
1863 val = WMGetFromPLString(elem);
1865 texture = (WTexture *) wTextureMakePixmap(scr, type, val, &color);
1866 } else if (strcasecmp(val, "thgradient") == 0
1867 || strcasecmp(val, "tvgradient") == 0 || strcasecmp(val, "tdgradient") == 0) {
1868 RColor color1, color2;
1869 XColor xcolor;
1870 int opacity;
1871 int style;
1873 if (val[1] == 'h' || val[1] == 'H')
1874 style = WTEX_THGRADIENT;
1875 else if (val[1] == 'v' || val[1] == 'V')
1876 style = WTEX_TVGRADIENT;
1877 else
1878 style = WTEX_TDGRADIENT;
1880 if (nelem != 5) {
1881 wwarning(_("bad number of arguments in textured gradient specification"));
1882 return NULL;
1885 /* get from color */
1886 elem = WMGetFromPLArray(pl, 3);
1887 if (!elem || !WMIsPLString(elem))
1888 return NULL;
1889 val = WMGetFromPLString(elem);
1891 if (!XParseColor(dpy, scr->w_colormap, val, &xcolor)) {
1892 wwarning(_("\"%s\" is not a valid color name"), val);
1893 return NULL;
1895 color1.alpha = 255;
1896 color1.red = xcolor.red >> 8;
1897 color1.green = xcolor.green >> 8;
1898 color1.blue = xcolor.blue >> 8;
1900 /* get to color */
1901 elem = WMGetFromPLArray(pl, 4);
1902 if (!elem || !WMIsPLString(elem)) {
1903 return NULL;
1905 val = WMGetFromPLString(elem);
1907 if (!XParseColor(dpy, scr->w_colormap, val, &xcolor)) {
1908 wwarning(_("\"%s\" is not a valid color name"), val);
1909 return NULL;
1911 color2.alpha = 255;
1912 color2.red = xcolor.red >> 8;
1913 color2.green = xcolor.green >> 8;
1914 color2.blue = xcolor.blue >> 8;
1916 /* get opacity */
1917 elem = WMGetFromPLArray(pl, 2);
1918 if (!elem || !WMIsPLString(elem))
1919 opacity = 128;
1920 else
1921 val = WMGetFromPLString(elem);
1923 if (!val || (opacity = atoi(val)) < 0 || opacity > 255) {
1924 wwarning(_("bad opacity value for tgradient texture \"%s\". Should be [0..255]"), val);
1925 opacity = 128;
1928 /* get file name */
1929 elem = WMGetFromPLArray(pl, 1);
1930 if (!elem || !WMIsPLString(elem))
1931 return NULL;
1932 val = WMGetFromPLString(elem);
1934 texture = (WTexture *) wTextureMakeTGradient(scr, style, &color1, &color2, val, opacity);
1935 } else if (strcasecmp(val, "function") == 0) {
1936 /* Leave this in to handle the unlikely case of
1937 * someone actually having function textures configured */
1938 wwarning("function texture support has been removed");
1939 return NULL;
1940 } else {
1941 wwarning(_("invalid texture type %s"), val);
1942 return NULL;
1944 return texture;
1947 static int getTexture(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1949 static WTexture *texture;
1950 int changed = 0;
1952 again:
1953 if (!WMIsPLArray(value)) {
1954 wwarning(_("Wrong option format for key \"%s\". Should be %s."), entry->key, "Texture");
1955 if (changed == 0) {
1956 value = entry->plvalue;
1957 changed = 1;
1958 wwarning(_("using default \"%s\" instead"), entry->default_value);
1959 goto again;
1961 return False;
1964 if (strcmp(entry->key, "WidgetColor") == 0 && !changed) {
1965 WMPropList *pl;
1967 pl = WMGetFromPLArray(value, 0);
1968 if (!pl || !WMIsPLString(pl) || !WMGetFromPLString(pl)
1969 || strcasecmp(WMGetFromPLString(pl), "solid") != 0) {
1970 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1971 entry->key, "Solid Texture");
1973 value = entry->plvalue;
1974 changed = 1;
1975 wwarning(_("using default \"%s\" instead"), entry->default_value);
1976 goto again;
1980 texture = parse_texture(scr, value);
1982 if (!texture) {
1983 wwarning(_("Error in texture specification for key \"%s\""), entry->key);
1984 if (changed == 0) {
1985 value = entry->plvalue;
1986 changed = 1;
1987 wwarning(_("using default \"%s\" instead"), entry->default_value);
1988 goto again;
1990 return False;
1993 if (ret)
1994 *ret = &texture;
1996 if (addr)
1997 *(WTexture **) addr = texture;
1999 return True;
2002 static int getWSBackground(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
2004 WMPropList *elem;
2005 int changed = 0;
2006 char *val;
2007 int nelem;
2009 /* Parameter not used, but tell the compiler that it is ok */
2010 (void) scr;
2011 (void) addr;
2013 again:
2014 if (!WMIsPLArray(value)) {
2015 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
2016 "WorkspaceBack", "Texture or None");
2017 if (changed == 0) {
2018 value = entry->plvalue;
2019 changed = 1;
2020 wwarning(_("using default \"%s\" instead"), entry->default_value);
2021 goto again;
2023 return False;
2026 /* only do basic error checking and verify for None texture */
2028 nelem = WMGetPropListItemCount(value);
2029 if (nelem > 0) {
2030 elem = WMGetFromPLArray(value, 0);
2031 if (!elem || !WMIsPLString(elem)) {
2032 wwarning(_("Wrong type for workspace background. Should be a texture type."));
2033 if (changed == 0) {
2034 value = entry->plvalue;
2035 changed = 1;
2036 wwarning(_("using default \"%s\" instead"), entry->default_value);
2037 goto again;
2039 return False;
2041 val = WMGetFromPLString(elem);
2043 if (strcasecmp(val, "None") == 0)
2044 return True;
2046 *ret = WMRetainPropList(value);
2048 return True;
2051 static int
2052 getWSSpecificBackground(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
2054 WMPropList *elem;
2055 int nelem;
2056 int changed = 0;
2058 /* Parameter not used, but tell the compiler that it is ok */
2059 (void) scr;
2060 (void) addr;
2062 again:
2063 if (!WMIsPLArray(value)) {
2064 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
2065 "WorkspaceSpecificBack", "an array of textures");
2066 if (changed == 0) {
2067 value = entry->plvalue;
2068 changed = 1;
2069 wwarning(_("using default \"%s\" instead"), entry->default_value);
2070 goto again;
2072 return False;
2075 /* only do basic error checking and verify for None texture */
2077 nelem = WMGetPropListItemCount(value);
2078 if (nelem > 0) {
2079 while (nelem--) {
2080 elem = WMGetFromPLArray(value, nelem);
2081 if (!elem || !WMIsPLArray(elem)) {
2082 wwarning(_("Wrong type for background of workspace %i. Should be a texture."),
2083 nelem);
2088 *ret = WMRetainPropList(value);
2090 #ifdef notworking
2092 * Kluge to force wmsetbg helper to set the default background.
2093 * If the WorkspaceSpecificBack is changed once wmaker has started,
2094 * the WorkspaceBack won't be sent to the helper, unless the user
2095 * changes its value too. So, we must force this by removing the
2096 * value from the defaults DB.
2098 if (!scr->flags.backimage_helper_launched && !scr->flags.startup) {
2099 WMPropList *key = WMCreatePLString("WorkspaceBack");
2101 WMRemoveFromPLDictionary(w_global.domain.wmaker->dictionary, key);
2103 WMReleasePropList(key);
2105 #endif
2106 return True;
2109 static int getFont(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
2111 static WMFont *font;
2112 const char *val;
2114 (void) addr;
2116 GET_STRING_OR_DEFAULT("Font", val);
2118 font = WMCreateFont(scr->wmscreen, val);
2119 if (!font)
2120 font = WMCreateFont(scr->wmscreen, "fixed");
2122 if (!font) {
2123 wfatal(_("could not load any usable font!!!"));
2124 exit(1);
2127 if (ret)
2128 *ret = font;
2130 /* can't assign font value outside update function */
2131 wassertrv(addr == NULL, True);
2133 return True;
2136 static int getColor(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
2138 static XColor color;
2139 const char *val;
2140 int second_pass = 0;
2142 (void) addr;
2144 GET_STRING_OR_DEFAULT("Color", val);
2146 again:
2147 if (!wGetColor(scr, val, &color)) {
2148 wwarning(_("could not get color for key \"%s\""), entry->key);
2149 if (second_pass == 0) {
2150 val = WMGetFromPLString(entry->plvalue);
2151 second_pass = 1;
2152 wwarning(_("using default \"%s\" instead"), val);
2153 goto again;
2155 return False;
2158 if (ret)
2159 *ret = &color;
2161 assert(addr == NULL);
2163 if (addr)
2164 *(unsigned long*)addr = pixel;
2167 return True;
2170 static int getKeybind(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
2172 static WShortKey shortcut;
2173 KeySym ksym;
2174 const char *val;
2175 char *k;
2176 char buf[MAX_SHORTCUT_LENGTH], *b;
2178 /* Parameter not used, but tell the compiler that it is ok */
2179 (void) scr;
2180 (void) addr;
2182 GET_STRING_OR_DEFAULT("Key spec", val);
2184 if (!val || strcasecmp(val, "NONE") == 0) {
2185 shortcut.keycode = 0;
2186 shortcut.modifier = 0;
2187 if (ret)
2188 *ret = &shortcut;
2189 return True;
2192 wstrlcpy(buf, val, MAX_SHORTCUT_LENGTH);
2194 b = (char *)buf;
2196 /* get modifiers */
2197 shortcut.modifier = 0;
2198 while ((k = strchr(b, '+')) != NULL) {
2199 int mod;
2201 *k = 0;
2202 mod = wXModifierFromKey(b);
2203 if (mod < 0) {
2204 wwarning(_("%s: invalid key modifier \"%s\""), entry->key, b);
2205 return False;
2207 shortcut.modifier |= mod;
2209 b = k + 1;
2212 /* get key */
2213 ksym = XStringToKeysym(b);
2215 if (ksym == NoSymbol) {
2216 wwarning(_("%s:invalid kbd shortcut specification \"%s\""), entry->key, val);
2217 return False;
2220 shortcut.keycode = XKeysymToKeycode(dpy, ksym);
2221 if (shortcut.keycode == 0) {
2222 wwarning(_("%s:invalid key in shortcut \"%s\""), entry->key, val);
2223 return False;
2226 if (ret)
2227 *ret = &shortcut;
2229 return True;
2232 static int getModMask(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
2234 static int mask;
2235 const char *str;
2237 /* Parameter not used, but tell the compiler that it is ok */
2238 (void) scr;
2240 GET_STRING_OR_DEFAULT("Modifier Key", str);
2242 if (!str)
2243 return False;
2245 mask = wXModifierFromKey(str);
2246 if (mask < 0) {
2247 wwarning(_("%s: modifier key %s is not valid"), entry->key, str);
2248 mask = 0;
2249 return False;
2252 if (addr)
2253 *(int *)addr = mask;
2255 if (ret)
2256 *ret = &mask;
2258 return True;
2261 # include <X11/cursorfont.h>
2262 typedef struct {
2263 const char *name;
2264 int id;
2265 } WCursorLookup;
2267 #define CURSOR_ID_NONE (XC_num_glyphs)
2269 static const WCursorLookup cursor_table[] = {
2270 {"X_cursor", XC_X_cursor},
2271 {"arrow", XC_arrow},
2272 {"based_arrow_down", XC_based_arrow_down},
2273 {"based_arrow_up", XC_based_arrow_up},
2274 {"boat", XC_boat},
2275 {"bogosity", XC_bogosity},
2276 {"bottom_left_corner", XC_bottom_left_corner},
2277 {"bottom_right_corner", XC_bottom_right_corner},
2278 {"bottom_side", XC_bottom_side},
2279 {"bottom_tee", XC_bottom_tee},
2280 {"box_spiral", XC_box_spiral},
2281 {"center_ptr", XC_center_ptr},
2282 {"circle", XC_circle},
2283 {"clock", XC_clock},
2284 {"coffee_mug", XC_coffee_mug},
2285 {"cross", XC_cross},
2286 {"cross_reverse", XC_cross_reverse},
2287 {"crosshair", XC_crosshair},
2288 {"diamond_cross", XC_diamond_cross},
2289 {"dot", XC_dot},
2290 {"dotbox", XC_dotbox},
2291 {"double_arrow", XC_double_arrow},
2292 {"draft_large", XC_draft_large},
2293 {"draft_small", XC_draft_small},
2294 {"draped_box", XC_draped_box},
2295 {"exchange", XC_exchange},
2296 {"fleur", XC_fleur},
2297 {"gobbler", XC_gobbler},
2298 {"gumby", XC_gumby},
2299 {"hand1", XC_hand1},
2300 {"hand2", XC_hand2},
2301 {"heart", XC_heart},
2302 {"icon", XC_icon},
2303 {"iron_cross", XC_iron_cross},
2304 {"left_ptr", XC_left_ptr},
2305 {"left_side", XC_left_side},
2306 {"left_tee", XC_left_tee},
2307 {"leftbutton", XC_leftbutton},
2308 {"ll_angle", XC_ll_angle},
2309 {"lr_angle", XC_lr_angle},
2310 {"man", XC_man},
2311 {"middlebutton", XC_middlebutton},
2312 {"mouse", XC_mouse},
2313 {"pencil", XC_pencil},
2314 {"pirate", XC_pirate},
2315 {"plus", XC_plus},
2316 {"question_arrow", XC_question_arrow},
2317 {"right_ptr", XC_right_ptr},
2318 {"right_side", XC_right_side},
2319 {"right_tee", XC_right_tee},
2320 {"rightbutton", XC_rightbutton},
2321 {"rtl_logo", XC_rtl_logo},
2322 {"sailboat", XC_sailboat},
2323 {"sb_down_arrow", XC_sb_down_arrow},
2324 {"sb_h_double_arrow", XC_sb_h_double_arrow},
2325 {"sb_left_arrow", XC_sb_left_arrow},
2326 {"sb_right_arrow", XC_sb_right_arrow},
2327 {"sb_up_arrow", XC_sb_up_arrow},
2328 {"sb_v_double_arrow", XC_sb_v_double_arrow},
2329 {"shuttle", XC_shuttle},
2330 {"sizing", XC_sizing},
2331 {"spider", XC_spider},
2332 {"spraycan", XC_spraycan},
2333 {"star", XC_star},
2334 {"target", XC_target},
2335 {"tcross", XC_tcross},
2336 {"top_left_arrow", XC_top_left_arrow},
2337 {"top_left_corner", XC_top_left_corner},
2338 {"top_right_corner", XC_top_right_corner},
2339 {"top_side", XC_top_side},
2340 {"top_tee", XC_top_tee},
2341 {"trek", XC_trek},
2342 {"ul_angle", XC_ul_angle},
2343 {"umbrella", XC_umbrella},
2344 {"ur_angle", XC_ur_angle},
2345 {"watch", XC_watch},
2346 {"xterm", XC_xterm},
2347 {NULL, CURSOR_ID_NONE}
2350 static void check_bitmap_status(int status, const char *filename, Pixmap bitmap)
2352 switch (status) {
2353 case BitmapOpenFailed:
2354 wwarning(_("failed to open bitmap file \"%s\""), filename);
2355 break;
2356 case BitmapFileInvalid:
2357 wwarning(_("\"%s\" is not a valid bitmap file"), filename);
2358 break;
2359 case BitmapNoMemory:
2360 wwarning(_("out of memory reading bitmap file \"%s\""), filename);
2361 break;
2362 case BitmapSuccess:
2363 XFreePixmap(dpy, bitmap);
2364 break;
2369 * (none)
2370 * (builtin, <cursor_name>)
2371 * (bitmap, <cursor_bitmap>, <cursor_mask>)
2373 static int parse_cursor(WScreen * scr, WMPropList * pl, Cursor * cursor)
2375 WMPropList *elem;
2376 char *val;
2377 int nelem;
2378 int status = 0;
2380 nelem = WMGetPropListItemCount(pl);
2381 if (nelem < 1) {
2382 return (status);
2384 elem = WMGetFromPLArray(pl, 0);
2385 if (!elem || !WMIsPLString(elem)) {
2386 return (status);
2388 val = WMGetFromPLString(elem);
2390 if (strcasecmp(val, "none") == 0) {
2391 status = 1;
2392 *cursor = None;
2393 } else if (strcasecmp(val, "builtin") == 0) {
2394 int i;
2395 int cursor_id = CURSOR_ID_NONE;
2397 if (nelem != 2) {
2398 wwarning(_("bad number of arguments in cursor specification"));
2399 return (status);
2401 elem = WMGetFromPLArray(pl, 1);
2402 if (!elem || !WMIsPLString(elem)) {
2403 return (status);
2405 val = WMGetFromPLString(elem);
2407 for (i = 0; cursor_table[i].name != NULL; i++) {
2408 if (strcasecmp(val, cursor_table[i].name) == 0) {
2409 cursor_id = cursor_table[i].id;
2410 break;
2413 if (CURSOR_ID_NONE == cursor_id) {
2414 wwarning(_("unknown builtin cursor name \"%s\""), val);
2415 } else {
2416 *cursor = XCreateFontCursor(dpy, cursor_id);
2417 status = 1;
2419 } else if (strcasecmp(val, "bitmap") == 0) {
2420 char *bitmap_name;
2421 char *mask_name;
2422 int bitmap_status;
2423 int mask_status;
2424 Pixmap bitmap;
2425 Pixmap mask;
2426 unsigned int w, h;
2427 int x, y;
2428 XColor fg, bg;
2430 if (nelem != 3) {
2431 wwarning(_("bad number of arguments in cursor specification"));
2432 return (status);
2434 elem = WMGetFromPLArray(pl, 1);
2435 if (!elem || !WMIsPLString(elem)) {
2436 return (status);
2438 val = WMGetFromPLString(elem);
2439 bitmap_name = FindImage(wPreferences.pixmap_path, val);
2440 if (!bitmap_name) {
2441 wwarning(_("could not find cursor bitmap file \"%s\""), val);
2442 return (status);
2444 elem = WMGetFromPLArray(pl, 2);
2445 if (!elem || !WMIsPLString(elem)) {
2446 wfree(bitmap_name);
2447 return (status);
2449 val = WMGetFromPLString(elem);
2450 mask_name = FindImage(wPreferences.pixmap_path, val);
2451 if (!mask_name) {
2452 wfree(bitmap_name);
2453 wwarning(_("could not find cursor bitmap file \"%s\""), val);
2454 return (status);
2456 mask_status = XReadBitmapFile(dpy, scr->w_win, mask_name, &w, &h, &mask, &x, &y);
2457 bitmap_status = XReadBitmapFile(dpy, scr->w_win, bitmap_name, &w, &h, &bitmap, &x, &y);
2458 if ((BitmapSuccess == bitmap_status) && (BitmapSuccess == mask_status)) {
2459 fg.pixel = scr->black_pixel;
2460 bg.pixel = scr->white_pixel;
2461 XQueryColor(dpy, scr->w_colormap, &fg);
2462 XQueryColor(dpy, scr->w_colormap, &bg);
2463 *cursor = XCreatePixmapCursor(dpy, bitmap, mask, &fg, &bg, x, y);
2464 status = 1;
2466 check_bitmap_status(bitmap_status, bitmap_name, bitmap);
2467 check_bitmap_status(mask_status, mask_name, mask);
2468 wfree(bitmap_name);
2469 wfree(mask_name);
2471 return (status);
2474 static int getCursor(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
2476 static Cursor cursor;
2477 int status;
2478 int changed = 0;
2480 again:
2481 if (!WMIsPLArray(value)) {
2482 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
2483 entry->key, "cursor specification");
2484 if (!changed) {
2485 value = entry->plvalue;
2486 changed = 1;
2487 wwarning(_("using default \"%s\" instead"), entry->default_value);
2488 goto again;
2490 return (False);
2492 status = parse_cursor(scr, value, &cursor);
2493 if (!status) {
2494 wwarning(_("Error in cursor specification for key \"%s\""), entry->key);
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 if (ret) {
2504 *ret = &cursor;
2506 if (addr) {
2507 *(Cursor *) addr = cursor;
2509 return (True);
2512 #undef CURSOR_ID_NONE
2514 /* ---------------- value setting functions --------------- */
2515 static int setJustify(WScreen * scr, WDefaultEntry * entry, void *tdata, void *extra_data)
2517 /* Parameter not used, but tell the compiler that it is ok */
2518 (void) scr;
2519 (void) entry;
2520 (void) tdata;
2521 (void) extra_data;
2523 return REFRESH_WINDOW_TITLE_COLOR;
2526 static int setClearance(WScreen * scr, WDefaultEntry * entry, void *bar, void *foo)
2528 /* Parameter not used, but tell the compiler that it is ok */
2529 (void) scr;
2530 (void) entry;
2531 (void) bar;
2532 (void) foo;
2534 return REFRESH_WINDOW_FONT | REFRESH_BUTTON_IMAGES | REFRESH_MENU_TITLE_FONT | REFRESH_MENU_FONT;
2537 static int setIfDockPresent(WScreen * scr, WDefaultEntry * entry, void *tdata, void *extra_data)
2539 char *flag = tdata;
2540 long which = (long) extra_data;
2542 /* Parameter not used, but tell the compiler that it is ok */
2543 (void) scr;
2544 (void) entry;
2546 switch (which) {
2547 case WM_DOCK:
2548 wPreferences.flags.nodock = wPreferences.flags.nodock || *flag;
2549 // Drawers require the dock
2550 wPreferences.flags.nodrawer = wPreferences.flags.nodrawer || wPreferences.flags.nodock;
2551 break;
2552 case WM_CLIP:
2553 wPreferences.flags.noclip = wPreferences.flags.noclip || *flag;
2554 break;
2555 case WM_DRAWER:
2556 wPreferences.flags.nodrawer = wPreferences.flags.nodrawer || *flag;
2557 break;
2558 default:
2559 break;
2561 return 0;
2564 static int setClipMergedInDock(WScreen *scr, WDefaultEntry *entry, void *tdata, void *foo)
2566 char *flag = tdata;
2568 /* Parameter not used, but tell the compiler that it is ok */
2569 (void) scr;
2570 (void) entry;
2571 (void) foo;
2573 wPreferences.flags.clip_merged_in_dock = *flag;
2574 wPreferences.flags.noclip = wPreferences.flags.noclip || *flag;
2575 return 0;
2578 static int setWrapAppiconsInDock(WScreen *scr, WDefaultEntry *entry, void *tdata, void *foo)
2580 char *flag = tdata;
2582 /* Parameter not used, but tell the compiler that it is ok */
2583 (void) scr;
2584 (void) entry;
2585 (void) foo;
2587 wPreferences.flags.wrap_appicons_in_dock = *flag;
2588 return 0;
2591 static int setStickyIcons(WScreen * scr, WDefaultEntry * entry, void *bar, void *foo)
2593 /* Parameter not used, but tell the compiler that it is ok */
2594 (void) entry;
2595 (void) bar;
2596 (void) foo;
2598 if (scr->workspaces) {
2599 wWorkspaceForceChange(scr, scr->current_workspace);
2600 wArrangeIcons(scr, False);
2602 return 0;
2605 static int setIconTile(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2607 Pixmap pixmap;
2608 RImage *img;
2609 WTexture ** texture = tdata;
2610 int reset = 0;
2612 /* Parameter not used, but tell the compiler that it is ok */
2613 (void) foo;
2615 img = wTextureRenderImage(*texture, wPreferences.icon_size,
2616 wPreferences.icon_size, ((*texture)->any.type & WREL_BORDER_MASK)
2617 ? WREL_ICON : WREL_FLAT);
2618 if (!img) {
2619 wwarning(_("could not render texture for icon background"));
2620 if (!entry->addr)
2621 wTextureDestroy(scr, *texture);
2622 return 0;
2624 RConvertImage(scr->rcontext, img, &pixmap);
2626 if (scr->icon_tile) {
2627 reset = 1;
2628 RReleaseImage(scr->icon_tile);
2629 XFreePixmap(dpy, scr->icon_tile_pixmap);
2632 scr->icon_tile = img;
2634 /* put the icon in the noticeboard hint */
2635 PropSetIconTileHint(scr, img);
2637 if (!wPreferences.flags.noclip || wPreferences.flags.clip_merged_in_dock) {
2638 if (scr->clip_tile) {
2639 RReleaseImage(scr->clip_tile);
2641 scr->clip_tile = wClipMakeTile(img);
2644 if (!wPreferences.flags.nodrawer) {
2645 if (scr->drawer_tile) {
2646 RReleaseImage(scr->drawer_tile);
2648 scr->drawer_tile = wDrawerMakeTile(scr, img);
2651 scr->icon_tile_pixmap = pixmap;
2653 if (scr->def_icon_rimage) {
2654 RReleaseImage(scr->def_icon_rimage);
2655 scr->def_icon_rimage = NULL;
2658 if (scr->icon_back_texture)
2659 wTextureDestroy(scr, (WTexture *) scr->icon_back_texture);
2661 scr->icon_back_texture = wTextureMakeSolid(scr, &((*texture)->any.color));
2663 /* Free the texture as nobody else will use it, nor refer to it. */
2664 if (!entry->addr)
2665 wTextureDestroy(scr, *texture);
2667 return (reset ? REFRESH_ICON_TILE : 0);
2670 static int setWinTitleFont(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2672 WMFont *font = tdata;
2674 /* Parameter not used, but tell the compiler that it is ok */
2675 (void) entry;
2676 (void) foo;
2678 if (scr->title_font) {
2679 WMReleaseFont(scr->title_font);
2681 scr->title_font = font;
2683 return REFRESH_WINDOW_FONT | REFRESH_BUTTON_IMAGES;
2686 static int setMenuTitleFont(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2688 WMFont *font = tdata;
2690 /* Parameter not used, but tell the compiler that it is ok */
2691 (void) entry;
2692 (void) foo;
2694 if (scr->menu_title_font) {
2695 WMReleaseFont(scr->menu_title_font);
2698 scr->menu_title_font = font;
2700 return REFRESH_MENU_TITLE_FONT;
2703 static int setMenuTextFont(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2705 WMFont *font = tdata;
2707 /* Parameter not used, but tell the compiler that it is ok */
2708 (void) entry;
2709 (void) foo;
2711 if (scr->menu_entry_font) {
2712 WMReleaseFont(scr->menu_entry_font);
2714 scr->menu_entry_font = font;
2716 return REFRESH_MENU_FONT;
2719 static int setIconTitleFont(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2721 WMFont *font = tdata;
2723 /* Parameter not used, but tell the compiler that it is ok */
2724 (void) entry;
2725 (void) foo;
2727 if (scr->icon_title_font) {
2728 WMReleaseFont(scr->icon_title_font);
2731 scr->icon_title_font = font;
2733 return REFRESH_ICON_FONT;
2736 static int setClipTitleFont(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2738 WMFont *font = tdata;
2740 /* Parameter not used, but tell the compiler that it is ok */
2741 (void) entry;
2742 (void) foo;
2744 if (scr->clip_title_font) {
2745 WMReleaseFont(scr->clip_title_font);
2748 scr->clip_title_font = font;
2750 return REFRESH_ICON_FONT;
2753 static int setLargeDisplayFont(WScreen *scr, WDefaultEntry *entry, void *tdata, void *foo)
2755 WMFont *font = tdata;
2757 /* Parameter not used, but tell the compiler that it is ok */
2758 (void) scr;
2759 (void) entry;
2760 (void) foo;
2762 if (scr->workspace_name_font)
2763 WMReleaseFont(scr->workspace_name_font);
2765 scr->workspace_name_font = font;
2767 return 0;
2770 static int setHightlight(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2772 XColor *color = tdata;
2774 /* Parameter not used, but tell the compiler that it is ok */
2775 (void) entry;
2776 (void) foo;
2778 if (scr->select_color)
2779 WMReleaseColor(scr->select_color);
2781 scr->select_color = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2783 wFreeColor(scr, color->pixel);
2785 return REFRESH_MENU_COLOR;
2788 static int setHightlightText(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2790 XColor *color = tdata;
2792 /* Parameter not used, but tell the compiler that it is ok */
2793 (void) entry;
2794 (void) foo;
2796 if (scr->select_text_color)
2797 WMReleaseColor(scr->select_text_color);
2799 scr->select_text_color = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2801 wFreeColor(scr, color->pixel);
2803 return REFRESH_MENU_COLOR;
2806 static int setClipTitleColor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *extra_data)
2808 XColor *color = tdata;
2809 long widx = (long) extra_data;
2811 /* Parameter not used, but tell the compiler that it is ok */
2812 (void) entry;
2814 if (scr->clip_title_color[widx])
2815 WMReleaseColor(scr->clip_title_color[widx]);
2817 scr->clip_title_color[widx] = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2818 wFreeColor(scr, color->pixel);
2820 return REFRESH_ICON_TITLE_COLOR;
2823 static int setWTitleColor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *extra_data)
2825 XColor *color = tdata;
2826 long widx = (long) extra_data;
2828 /* Parameter not used, but tell the compiler that it is ok */
2829 (void) entry;
2831 if (scr->window_title_color[widx])
2832 WMReleaseColor(scr->window_title_color[widx]);
2834 scr->window_title_color[widx] =
2835 WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2837 wFreeColor(scr, color->pixel);
2839 return REFRESH_WINDOW_TITLE_COLOR;
2842 static int setMenuTitleColor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *extra_data)
2844 XColor *color = tdata;
2846 /* Parameter not used, but tell the compiler that it is ok */
2847 (void) entry;
2848 (void) extra_data;
2850 if (scr->menu_title_color[0])
2851 WMReleaseColor(scr->menu_title_color[0]);
2853 scr->menu_title_color[0] = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2855 wFreeColor(scr, color->pixel);
2857 return REFRESH_MENU_TITLE_COLOR;
2860 static int setMenuTextColor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2862 XColor *color = tdata;
2864 /* Parameter not used, but tell the compiler that it is ok */
2865 (void) entry;
2866 (void) foo;
2868 if (scr->mtext_color)
2869 WMReleaseColor(scr->mtext_color);
2871 scr->mtext_color = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2873 if (WMColorPixel(scr->dtext_color) == WMColorPixel(scr->mtext_color)) {
2874 WMSetColorAlpha(scr->dtext_color, 0x7fff);
2875 } else {
2876 WMSetColorAlpha(scr->dtext_color, 0xffff);
2879 wFreeColor(scr, color->pixel);
2881 return REFRESH_MENU_COLOR;
2884 static int setMenuDisabledColor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2886 XColor *color = tdata;
2888 /* Parameter not used, but tell the compiler that it is ok */
2889 (void) entry;
2890 (void) foo;
2892 if (scr->dtext_color)
2893 WMReleaseColor(scr->dtext_color);
2895 scr->dtext_color = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2897 if (WMColorPixel(scr->dtext_color) == WMColorPixel(scr->mtext_color)) {
2898 WMSetColorAlpha(scr->dtext_color, 0x7fff);
2899 } else {
2900 WMSetColorAlpha(scr->dtext_color, 0xffff);
2903 wFreeColor(scr, color->pixel);
2905 return REFRESH_MENU_COLOR;
2908 static int setIconTitleColor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2910 XColor *color = tdata;
2912 /* Parameter not used, but tell the compiler that it is ok */
2913 (void) entry;
2914 (void) foo;
2916 if (scr->icon_title_color)
2917 WMReleaseColor(scr->icon_title_color);
2918 scr->icon_title_color = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2920 wFreeColor(scr, color->pixel);
2922 return REFRESH_ICON_TITLE_COLOR;
2925 static int setIconTitleBack(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2927 XColor *color = tdata;
2929 /* Parameter not used, but tell the compiler that it is ok */
2930 (void) entry;
2931 (void) foo;
2933 if (scr->icon_title_texture) {
2934 wTextureDestroy(scr, (WTexture *) scr->icon_title_texture);
2936 scr->icon_title_texture = wTextureMakeSolid(scr, color);
2938 return REFRESH_ICON_TITLE_BACK;
2941 static int setFrameBorderWidth(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2943 int *value = tdata;
2945 /* Parameter not used, but tell the compiler that it is ok */
2946 (void) entry;
2947 (void) foo;
2949 scr->frame_border_width = *value;
2951 return REFRESH_FRAME_BORDER;
2954 static int setFrameBorderColor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2956 XColor *color = tdata;
2958 /* Parameter not used, but tell the compiler that it is ok */
2959 (void) entry;
2960 (void) foo;
2962 if (scr->frame_border_color)
2963 WMReleaseColor(scr->frame_border_color);
2964 scr->frame_border_color = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2966 wFreeColor(scr, color->pixel);
2968 return REFRESH_FRAME_BORDER;
2971 static int setFrameFocusedBorderColor(WScreen *scr, WDefaultEntry *entry, void *tdata, void *foo)
2973 XColor *color = tdata;
2975 /* Parameter not used, but tell the compiler that it is ok */
2976 (void) entry;
2977 (void) foo;
2979 if (scr->frame_focused_border_color)
2980 WMReleaseColor(scr->frame_focused_border_color);
2981 scr->frame_focused_border_color = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2983 wFreeColor(scr, color->pixel);
2985 return REFRESH_FRAME_BORDER;
2988 static int setFrameSelectedBorderColor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2990 XColor *color = tdata;
2992 /* Parameter not used, but tell the compiler that it is ok */
2993 (void) entry;
2994 (void) foo;
2996 if (scr->frame_selected_border_color)
2997 WMReleaseColor(scr->frame_selected_border_color);
2998 scr->frame_selected_border_color = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
3000 wFreeColor(scr, color->pixel);
3002 return REFRESH_FRAME_BORDER;
3005 static int setWorkspaceSpecificBack(WScreen * scr, WDefaultEntry * entry, void *tdata, void *bar)
3007 WMPropList *value = tdata;
3008 WMPropList *val;
3009 char *str;
3010 int i;
3012 /* Parameter not used, but tell the compiler that it is ok */
3013 (void) entry;
3014 (void) bar;
3016 if (scr->flags.backimage_helper_launched) {
3017 if (WMGetPropListItemCount(value) == 0) {
3018 SendHelperMessage(scr, 'C', 0, NULL);
3019 SendHelperMessage(scr, 'K', 0, NULL);
3021 WMReleasePropList(value);
3022 return 0;
3024 } else {
3025 if (WMGetPropListItemCount(value) == 0)
3026 return 0;
3028 if (!start_bg_helper(scr)) {
3029 WMReleasePropList(value);
3030 return 0;
3033 SendHelperMessage(scr, 'P', -1, wPreferences.pixmap_path);
3036 for (i = 0; i < WMGetPropListItemCount(value); i++) {
3037 val = WMGetFromPLArray(value, i);
3038 if (val && WMIsPLArray(val) && WMGetPropListItemCount(val) > 0) {
3039 str = WMGetPropListDescription(val, False);
3041 SendHelperMessage(scr, 'S', i + 1, str);
3043 wfree(str);
3044 } else {
3045 SendHelperMessage(scr, 'U', i + 1, NULL);
3048 sleep(1);
3050 WMReleasePropList(value);
3051 return 0;
3054 static int setWorkspaceBack(WScreen * scr, WDefaultEntry * entry, void *tdata, void *bar)
3056 WMPropList *value = tdata;
3058 /* Parameter not used, but tell the compiler that it is ok */
3059 (void) entry;
3060 (void) bar;
3062 if (scr->flags.backimage_helper_launched) {
3063 char *str;
3065 if (WMGetPropListItemCount(value) == 0) {
3066 SendHelperMessage(scr, 'U', 0, NULL);
3067 } else {
3068 /* set the default workspace background to this one */
3069 str = WMGetPropListDescription(value, False);
3070 if (str) {
3071 SendHelperMessage(scr, 'S', 0, str);
3072 wfree(str);
3073 SendHelperMessage(scr, 'C', scr->current_workspace + 1, NULL);
3074 } else {
3075 SendHelperMessage(scr, 'U', 0, NULL);
3078 } else if (WMGetPropListItemCount(value) > 0) {
3079 char *text;
3080 char *dither;
3081 int len;
3083 text = WMGetPropListDescription(value, False);
3084 len = strlen(text) + 40;
3085 dither = wPreferences.no_dithering ? "-m" : "-d";
3086 if (!strchr(text, '\'') && !strchr(text, '\\')) {
3087 char command[len];
3089 if (wPreferences.smooth_workspace_back)
3090 snprintf(command, len, "wmsetbg %s -S -p '%s' &", dither, text);
3091 else
3092 snprintf(command, len, "wmsetbg %s -p '%s' &", dither, text);
3093 ExecuteShellCommand(scr, command);
3094 } else
3095 wwarning(_("Invalid arguments for background \"%s\""), text);
3096 wfree(text);
3098 WMReleasePropList(value);
3100 return 0;
3103 static int setWidgetColor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
3105 WTexture **texture = tdata;
3107 /* Parameter not used, but tell the compiler that it is ok */
3108 (void) entry;
3109 (void) foo;
3111 if (scr->widget_texture) {
3112 wTextureDestroy(scr, (WTexture *) scr->widget_texture);
3114 scr->widget_texture = *(WTexSolid **) texture;
3116 return 0;
3119 static int setFTitleBack(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
3121 WTexture **texture = tdata;
3123 /* Parameter not used, but tell the compiler that it is ok */
3124 (void) entry;
3125 (void) foo;
3127 if (scr->window_title_texture[WS_FOCUSED]) {
3128 wTextureDestroy(scr, scr->window_title_texture[WS_FOCUSED]);
3130 scr->window_title_texture[WS_FOCUSED] = *texture;
3132 return REFRESH_WINDOW_TEXTURES;
3135 static int setPTitleBack(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
3137 WTexture **texture = tdata;
3139 /* Parameter not used, but tell the compiler that it is ok */
3140 (void) entry;
3141 (void) foo;
3143 if (scr->window_title_texture[WS_PFOCUSED]) {
3144 wTextureDestroy(scr, scr->window_title_texture[WS_PFOCUSED]);
3146 scr->window_title_texture[WS_PFOCUSED] = *texture;
3148 return REFRESH_WINDOW_TEXTURES;
3151 static int setUTitleBack(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
3153 WTexture **texture = tdata;
3155 /* Parameter not used, but tell the compiler that it is ok */
3156 (void) entry;
3157 (void) foo;
3159 if (scr->window_title_texture[WS_UNFOCUSED]) {
3160 wTextureDestroy(scr, scr->window_title_texture[WS_UNFOCUSED]);
3162 scr->window_title_texture[WS_UNFOCUSED] = *texture;
3164 return REFRESH_WINDOW_TEXTURES;
3167 static int setResizebarBack(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
3169 WTexture **texture = tdata;
3171 /* Parameter not used, but tell the compiler that it is ok */
3172 (void) entry;
3173 (void) foo;
3175 if (scr->resizebar_texture[0]) {
3176 wTextureDestroy(scr, scr->resizebar_texture[0]);
3178 scr->resizebar_texture[0] = *texture;
3180 return REFRESH_WINDOW_TEXTURES;
3183 static int setMenuTitleBack(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
3185 WTexture **texture = tdata;
3187 /* Parameter not used, but tell the compiler that it is ok */
3188 (void) entry;
3189 (void) foo;
3191 if (scr->menu_title_texture[0]) {
3192 wTextureDestroy(scr, scr->menu_title_texture[0]);
3194 scr->menu_title_texture[0] = *texture;
3196 return REFRESH_MENU_TITLE_TEXTURE;
3199 static int setMenuTextBack(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
3201 WTexture **texture = tdata;
3203 /* Parameter not used, but tell the compiler that it is ok */
3204 (void) entry;
3205 (void) foo;
3207 if (scr->menu_item_texture) {
3208 wTextureDestroy(scr, scr->menu_item_texture);
3209 wTextureDestroy(scr, (WTexture *) scr->menu_item_auxtexture);
3211 scr->menu_item_texture = *texture;
3213 scr->menu_item_auxtexture = wTextureMakeSolid(scr, &scr->menu_item_texture->any.color);
3215 return REFRESH_MENU_TEXTURE;
3218 static int setKeyGrab(WScreen * scr, WDefaultEntry * entry, void *tdata, void *extra_data)
3220 WShortKey *shortcut = tdata;
3221 WWindow *wwin;
3222 long widx = (long) extra_data;
3224 /* Parameter not used, but tell the compiler that it is ok */
3225 (void) entry;
3227 wKeyBindings[widx] = *shortcut;
3229 wwin = scr->focused_window;
3231 while (wwin != NULL) {
3232 XUngrabKey(dpy, AnyKey, AnyModifier, wwin->frame->core->window);
3234 if (!WFLAGP(wwin, no_bind_keys)) {
3235 wWindowSetKeyGrabs(wwin);
3237 wwin = wwin->prev;
3240 /* do we need to update window menus? */
3241 if (widx >= WKBD_WORKSPACE1 && widx <= WKBD_WORKSPACE10)
3242 return REFRESH_WORKSPACE_MENU;
3243 if (widx == WKBD_LASTWORKSPACE)
3244 return REFRESH_WORKSPACE_MENU;
3245 if (widx >= WKBD_MOVE_WORKSPACE1 && widx <= WKBD_MOVE_WORKSPACE10)
3246 return REFRESH_WORKSPACE_MENU;
3248 return 0;
3251 static int setIconPosition(WScreen * scr, WDefaultEntry * entry, void *bar, void *foo)
3253 /* Parameter not used, but tell the compiler that it is ok */
3254 (void) entry;
3255 (void) bar;
3256 (void) foo;
3258 wScreenUpdateUsableArea(scr);
3259 wArrangeIcons(scr, True);
3261 return 0;
3264 static int updateUsableArea(WScreen * scr, WDefaultEntry * entry, void *bar, void *foo)
3266 /* Parameter not used, but tell the compiler that it is ok */
3267 (void) entry;
3268 (void) bar;
3269 (void) foo;
3271 wScreenUpdateUsableArea(scr);
3273 return 0;
3276 static int setWorkspaceMapBackground(WScreen *scr, WDefaultEntry *entry, void *tdata, void *foo)
3278 WTexture **texture = tdata;
3280 /* Parameter not used, but tell the compiler that it is ok */
3281 (void) entry;
3282 (void) foo;
3284 if (wPreferences.wsmbackTexture)
3285 wTextureDestroy(scr, wPreferences.wsmbackTexture);
3287 wPreferences.wsmbackTexture = *texture;
3289 return REFRESH_WINDOW_TEXTURES;
3292 static int setMenuStyle(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
3294 /* Parameter not used, but tell the compiler that it is ok */
3295 (void) scr;
3296 (void) entry;
3297 (void) tdata;
3298 (void) foo;
3300 return REFRESH_MENU_TEXTURE;
3303 static RImage *chopOffImage(RImage * image, int x, int y, int w, int h)
3305 RImage *img = RCreateImage(w, h, image->format == RRGBAFormat);
3307 RCopyArea(img, image, x, y, w, h, 0, 0);
3309 return img;
3312 static int setSwPOptions(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
3314 WMPropList *array = tdata;
3315 char *path;
3316 RImage *bgimage;
3317 int cwidth, cheight;
3318 struct WPreferences *prefs = foo;
3320 if (!WMIsPLArray(array) || WMGetPropListItemCount(array) == 0) {
3321 if (prefs->swtileImage)
3322 RReleaseImage(prefs->swtileImage);
3323 prefs->swtileImage = NULL;
3325 WMReleasePropList(array);
3326 return 0;
3329 switch (WMGetPropListItemCount(array)) {
3330 case 4:
3331 if (!WMIsPLString(WMGetFromPLArray(array, 1))) {
3332 wwarning(_("Invalid arguments for option \"%s\""), entry->key);
3333 break;
3334 } else
3335 path = FindImage(wPreferences.pixmap_path, WMGetFromPLString(WMGetFromPLArray(array, 1)));
3337 if (!path) {
3338 wwarning(_("Could not find image \"%s\" for option \"%s\""),
3339 WMGetFromPLString(WMGetFromPLArray(array, 1)), entry->key);
3340 } else {
3341 bgimage = RLoadImage(scr->rcontext, path, 0);
3342 if (!bgimage) {
3343 wwarning(_("Could not load image \"%s\" for option \"%s\""), path, entry->key);
3344 wfree(path);
3345 } else {
3346 wfree(path);
3348 cwidth = atoi(WMGetFromPLString(WMGetFromPLArray(array, 2)));
3349 cheight = atoi(WMGetFromPLString(WMGetFromPLArray(array, 3)));
3351 if (cwidth <= 0 || cheight <= 0 ||
3352 cwidth >= bgimage->width - 2 || cheight >= bgimage->height - 2)
3353 wwarning(_("Invalid split sizes for switch panel back image."));
3354 else {
3355 int i;
3356 int swidth, theight;
3357 for (i = 0; i < 9; i++) {
3358 if (prefs->swbackImage[i])
3359 RReleaseImage(prefs->swbackImage[i]);
3360 prefs->swbackImage[i] = NULL;
3362 swidth = (bgimage->width - cwidth) / 2;
3363 theight = (bgimage->height - cheight) / 2;
3365 prefs->swbackImage[0] = chopOffImage(bgimage, 0, 0, swidth, theight);
3366 prefs->swbackImage[1] = chopOffImage(bgimage, swidth, 0, cwidth, theight);
3367 prefs->swbackImage[2] = chopOffImage(bgimage, swidth + cwidth, 0,
3368 swidth, theight);
3370 prefs->swbackImage[3] = chopOffImage(bgimage, 0, theight, swidth, cheight);
3371 prefs->swbackImage[4] = chopOffImage(bgimage, swidth, theight,
3372 cwidth, cheight);
3373 prefs->swbackImage[5] = chopOffImage(bgimage, swidth + cwidth, theight,
3374 swidth, cheight);
3376 prefs->swbackImage[6] = chopOffImage(bgimage, 0, theight + cheight,
3377 swidth, theight);
3378 prefs->swbackImage[7] = chopOffImage(bgimage, swidth, theight + cheight,
3379 cwidth, theight);
3380 prefs->swbackImage[8] =
3381 chopOffImage(bgimage, swidth + cwidth, theight + cheight, swidth,
3382 theight);
3384 // check if anything failed
3385 for (i = 0; i < 9; i++) {
3386 if (!prefs->swbackImage[i]) {
3387 for (; i >= 0; --i) {
3388 RReleaseImage(prefs->swbackImage[i]);
3389 prefs->swbackImage[i] = NULL;
3391 break;
3395 RReleaseImage(bgimage);
3399 /* Fall through. */
3401 case 1:
3402 if (!WMIsPLString(WMGetFromPLArray(array, 0))) {
3403 wwarning(_("Invalid arguments for option \"%s\""), entry->key);
3404 break;
3405 } else
3406 path = FindImage(wPreferences.pixmap_path, WMGetFromPLString(WMGetFromPLArray(array, 0)));
3408 if (!path) {
3409 wwarning(_("Could not find image \"%s\" for option \"%s\""),
3410 WMGetFromPLString(WMGetFromPLArray(array, 0)), entry->key);
3411 } else {
3412 if (prefs->swtileImage)
3413 RReleaseImage(prefs->swtileImage);
3415 prefs->swtileImage = RLoadImage(scr->rcontext, path, 0);
3416 if (!prefs->swtileImage) {
3417 wwarning(_("Could not load image \"%s\" for option \"%s\""), path, entry->key);
3419 wfree(path);
3421 break;
3423 default:
3424 wwarning(_("Invalid number of arguments for option \"%s\""), entry->key);
3425 break;
3428 WMReleasePropList(array);
3430 return 0;
3433 static int setModifierKeyLabels(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
3435 WMPropList *array = tdata;
3436 int i;
3437 struct WPreferences *prefs = foo;
3439 if (!WMIsPLArray(array) || WMGetPropListItemCount(array) != 7) {
3440 wwarning(_("Value for option \"%s\" must be an array of 7 strings"), entry->key);
3441 WMReleasePropList(array);
3442 return 0;
3445 DestroyWindowMenu(scr);
3447 for (i = 0; i < 7; i++) {
3448 if (prefs->modifier_labels[i])
3449 wfree(prefs->modifier_labels[i]);
3451 if (WMIsPLString(WMGetFromPLArray(array, i))) {
3452 prefs->modifier_labels[i] = wstrdup(WMGetFromPLString(WMGetFromPLArray(array, i)));
3453 } else {
3454 wwarning(_("Invalid argument for option \"%s\" item %d"), entry->key, i);
3455 prefs->modifier_labels[i] = NULL;
3459 WMReleasePropList(array);
3461 return 0;
3464 static int setDoubleClick(WScreen *scr, WDefaultEntry *entry, void *tdata, void *foo)
3466 int *value = tdata;
3468 /* Parameter not used, but tell the compiler that it is ok */
3469 (void) entry;
3470 (void) scr;
3472 if (*value <= 0)
3473 *(int *)foo = 1;
3475 W_setconf_doubleClickDelay(*value);
3477 return 0;
3480 static int setCursor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *extra_data)
3482 Cursor *cursor = tdata;
3483 long widx = (long) extra_data;
3485 /* Parameter not used, but tell the compiler that it is ok */
3486 (void) entry;
3488 if (wPreferences.cursor[widx] != None) {
3489 XFreeCursor(dpy, wPreferences.cursor[widx]);
3492 wPreferences.cursor[widx] = *cursor;
3494 if (widx == WCUR_ROOT && *cursor != None) {
3495 XDefineCursor(dpy, scr->root_win, *cursor);
3498 return 0;
3501 static int updateDock(WScreen * scr, WDefaultEntry * entry,
3502 void *tdata, void *extra_data) {
3503 (void) entry;
3504 (void) tdata;
3505 (void) extra_data;
3507 if (scr->dock)
3508 wDockSwap(scr->dock);
3510 return 0;