support moving window between heads using keyboard
[wmaker-crm.git] / src / defaults.c
blob23a0cff990b26a7b0594d4c79a97e2d8247fad7c
1 /* defaults.c - manage configuration through defaults db
3 * Window Maker window manager
5 * Copyright (c) 1997-2003 Alfredo K. Kojima
6 * Copyright (c) 1998-2003 Dan Pascu
7 * Copyright (c) 2014 Window Maker Team
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License along
21 * with this program; if not, write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 #include "wconfig.h"
27 #include <stdio.h>
28 #include <stdint.h>
29 #include <stdlib.h>
30 #include <unistd.h>
31 #include <string.h>
32 #include <strings.h>
33 #include <ctype.h>
34 #include <time.h>
35 #include <sys/types.h>
36 #include <sys/stat.h>
37 #include <limits.h>
38 #include <signal.h>
40 #ifndef PATH_MAX
41 #define PATH_MAX DEFAULT_PATH_MAX
42 #endif
44 #include <X11/Xlib.h>
45 #include <X11/Xutil.h>
46 #include <X11/keysym.h>
48 #include <wraster.h>
50 #include "WindowMaker.h"
51 #include "framewin.h"
52 #include "window.h"
53 #include "texture.h"
54 #include "screen.h"
55 #include "resources.h"
56 #include "defaults.h"
57 #include "keybind.h"
58 #include "xmodifier.h"
59 #include "icon.h"
60 #include "main.h"
61 #include "actions.h"
62 #include "dock.h"
63 #include "workspace.h"
64 #include "properties.h"
65 #include "misc.h"
66 #include "winmenu.h"
68 #define MAX_SHORTCUT_LENGTH 32
70 typedef struct _WDefaultEntry WDefaultEntry;
71 typedef int (WDECallbackConvert) (WScreen *scr, WDefaultEntry *entry, WMPropList *plvalue, void *addr, void **tdata);
72 typedef int (WDECallbackUpdate) (WScreen *scr, WDefaultEntry *entry, void *tdata, void *extra_data);
74 struct _WDefaultEntry {
75 const char *key;
76 const char *default_value;
77 void *extra_data;
78 void *addr;
79 WDECallbackConvert *convert;
80 WDECallbackUpdate *update;
81 WMPropList *plkey;
82 WMPropList *plvalue; /* default value */
85 /* used to map strings to integers */
86 typedef struct {
87 const char *string;
88 short value;
89 char is_alias;
90 } WOptionEnumeration;
92 /* type converters */
93 static WDECallbackConvert getBool;
94 static WDECallbackConvert getInt;
95 static WDECallbackConvert getCoord;
96 static WDECallbackConvert getPathList;
97 static WDECallbackConvert getEnum;
98 static WDECallbackConvert getTexture;
99 static WDECallbackConvert getWSBackground;
100 static WDECallbackConvert getWSSpecificBackground;
101 static WDECallbackConvert getFont;
102 static WDECallbackConvert getColor;
103 static WDECallbackConvert getKeybind;
104 static WDECallbackConvert getModMask;
105 static WDECallbackConvert getPropList;
107 /* value setting functions */
108 static WDECallbackUpdate setJustify;
109 static WDECallbackUpdate setClearance;
110 static WDECallbackUpdate setIfDockPresent;
111 static WDECallbackUpdate setClipMergedInDock;
112 static WDECallbackUpdate setWrapAppiconsInDock;
113 static WDECallbackUpdate setStickyIcons;
114 static WDECallbackUpdate setWidgetColor;
115 static WDECallbackUpdate setIconTile;
116 static WDECallbackUpdate setWinTitleFont;
117 static WDECallbackUpdate setMenuTitleFont;
118 static WDECallbackUpdate setMenuTextFont;
119 static WDECallbackUpdate setIconTitleFont;
120 static WDECallbackUpdate setIconTitleColor;
121 static WDECallbackUpdate setIconTitleBack;
122 static WDECallbackUpdate setFrameBorderWidth;
123 static WDECallbackUpdate setFrameBorderColor;
124 static WDECallbackUpdate setFrameFocusedBorderColor;
125 static WDECallbackUpdate setFrameSelectedBorderColor;
126 static WDECallbackUpdate setLargeDisplayFont;
127 static WDECallbackUpdate setWTitleColor;
128 static WDECallbackUpdate setFTitleBack;
129 static WDECallbackUpdate setPTitleBack;
130 static WDECallbackUpdate setUTitleBack;
131 static WDECallbackUpdate setResizebarBack;
132 static WDECallbackUpdate setWorkspaceBack;
133 static WDECallbackUpdate setWorkspaceSpecificBack;
134 static WDECallbackUpdate setMenuTitleColor;
135 static WDECallbackUpdate setMenuTextColor;
136 static WDECallbackUpdate setMenuDisabledColor;
137 static WDECallbackUpdate setMenuTitleBack;
138 static WDECallbackUpdate setMenuTextBack;
139 static WDECallbackUpdate setHightlight;
140 static WDECallbackUpdate setHightlightText;
141 static WDECallbackUpdate setKeyGrab;
142 static WDECallbackUpdate setDoubleClick;
143 static WDECallbackUpdate setIconPosition;
144 static WDECallbackUpdate setWorkspaceMapBackground;
146 static WDECallbackUpdate setClipTitleFont;
147 static WDECallbackUpdate setClipTitleColor;
149 static WDECallbackUpdate setMenuStyle;
150 static WDECallbackUpdate setSwPOptions;
151 static WDECallbackUpdate updateUsableArea;
153 static WDECallbackUpdate setModifierKeyLabels;
155 static WDECallbackConvert getCursor;
156 static WDECallbackUpdate setCursor;
159 * Tables to convert strings to enumeration values.
160 * Values stored are char
163 /* WARNING: sum of length of all value strings must not exceed
164 * this value */
165 #define TOTAL_VALUES_LENGTH 80
167 #define REFRESH_WINDOW_TEXTURES (1<<0)
168 #define REFRESH_MENU_TEXTURE (1<<1)
169 #define REFRESH_MENU_FONT (1<<2)
170 #define REFRESH_MENU_COLOR (1<<3)
171 #define REFRESH_MENU_TITLE_TEXTURE (1<<4)
172 #define REFRESH_MENU_TITLE_FONT (1<<5)
173 #define REFRESH_MENU_TITLE_COLOR (1<<6)
174 #define REFRESH_WINDOW_TITLE_COLOR (1<<7)
175 #define REFRESH_WINDOW_FONT (1<<8)
176 #define REFRESH_ICON_TILE (1<<9)
177 #define REFRESH_ICON_FONT (1<<10)
179 #define REFRESH_BUTTON_IMAGES (1<<11)
181 #define REFRESH_ICON_TITLE_COLOR (1<<12)
182 #define REFRESH_ICON_TITLE_BACK (1<<13)
184 #define REFRESH_WORKSPACE_MENU (1<<14)
186 #define REFRESH_FRAME_BORDER REFRESH_MENU_FONT|REFRESH_WINDOW_FONT
188 static WOptionEnumeration seFocusModes[] = {
189 {"Manual", WKF_CLICK, 0}, {"ClickToFocus", WKF_CLICK, 1},
190 {"Sloppy", WKF_SLOPPY, 0}, {"SemiAuto", WKF_SLOPPY, 1}, {"Auto", WKF_SLOPPY, 1},
191 {NULL, 0, 0}
194 static WOptionEnumeration seTitlebarModes[] = {
195 {"new", TS_NEW, 0}, {"old", TS_OLD, 0},
196 {"next", TS_NEXT, 0}, {NULL, 0, 0}
199 static WOptionEnumeration seColormapModes[] = {
200 {"Manual", WCM_CLICK, 0}, {"ClickToFocus", WCM_CLICK, 1},
201 {"Auto", WCM_POINTER, 0}, {"FocusFollowMouse", WCM_POINTER, 1},
202 {NULL, 0, 0}
205 static WOptionEnumeration sePlacements[] = {
206 {"Auto", WPM_AUTO, 0},
207 {"Smart", WPM_SMART, 0},
208 {"Cascade", WPM_CASCADE, 0},
209 {"Random", WPM_RANDOM, 0},
210 {"Manual", WPM_MANUAL, 0},
211 {"Center", WPM_CENTER, 0},
212 {NULL, 0, 0}
215 static WOptionEnumeration seGeomDisplays[] = {
216 {"None", WDIS_NONE, 0},
217 {"Center", WDIS_CENTER, 0},
218 {"Corner", WDIS_TOPLEFT, 0},
219 {"Floating", WDIS_FRAME_CENTER, 0},
220 {"Line", WDIS_NEW, 0},
221 {NULL, 0, 0}
224 static WOptionEnumeration seSpeeds[] = {
225 {"UltraFast", SPEED_ULTRAFAST, 0},
226 {"Fast", SPEED_FAST, 0},
227 {"Medium", SPEED_MEDIUM, 0},
228 {"Slow", SPEED_SLOW, 0},
229 {"UltraSlow", SPEED_ULTRASLOW, 0},
230 {NULL, 0, 0}
233 static WOptionEnumeration seMouseButtonActions[] = {
234 {"None", WA_NONE, 0},
235 {"SelectWindows", WA_SELECT_WINDOWS, 0},
236 {"OpenApplicationsMenu", WA_OPEN_APPMENU, 0},
237 {"OpenWindowListMenu", WA_OPEN_WINLISTMENU, 0},
238 {"MoveToPrevWorkspace", WA_MOVE_PREVWORKSPACE, 0},
239 {"MoveToNextWorkspace", WA_MOVE_NEXTWORKSPACE, 0},
240 {"MoveToPrevWindow", WA_MOVE_PREVWINDOW, 0},
241 {"MoveToNextWindow", WA_MOVE_NEXTWINDOW, 0},
242 {NULL, 0, 0}
245 static WOptionEnumeration seMouseWheelActions[] = {
246 {"None", WA_NONE, 0},
247 {"SwitchWorkspaces", WA_SWITCH_WORKSPACES, 0},
248 {"SwitchWindows", WA_SWITCH_WINDOWS, 0},
249 {NULL, 0, 0}
252 static WOptionEnumeration seIconificationStyles[] = {
253 {"Zoom", WIS_ZOOM, 0},
254 {"Twist", WIS_TWIST, 0},
255 {"Flip", WIS_FLIP, 0},
256 {"None", WIS_NONE, 0},
257 {"random", WIS_RANDOM, 0},
258 {NULL, 0, 0}
261 static WOptionEnumeration seJustifications[] = {
262 {"Left", WTJ_LEFT, 0},
263 {"Center", WTJ_CENTER, 0},
264 {"Right", WTJ_RIGHT, 0},
265 {NULL, 0, 0}
268 static WOptionEnumeration seIconPositions[] = {
269 {"blv", IY_BOTTOM | IY_LEFT | IY_VERT, 0},
270 {"blh", IY_BOTTOM | IY_LEFT | IY_HORIZ, 0},
271 {"brv", IY_BOTTOM | IY_RIGHT | IY_VERT, 0},
272 {"brh", IY_BOTTOM | IY_RIGHT | IY_HORIZ, 0},
273 {"tlv", IY_TOP | IY_LEFT | IY_VERT, 0},
274 {"tlh", IY_TOP | IY_LEFT | IY_HORIZ, 0},
275 {"trv", IY_TOP | IY_RIGHT | IY_VERT, 0},
276 {"trh", IY_TOP | IY_RIGHT | IY_HORIZ, 0},
277 {NULL, 0, 0}
280 static WOptionEnumeration seMenuStyles[] = {
281 {"normal", MS_NORMAL, 0},
282 {"singletexture", MS_SINGLE_TEXTURE, 0},
283 {"flat", MS_FLAT, 0},
284 {NULL, 0, 0}
287 static WOptionEnumeration seDisplayPositions[] = {
288 {"none", WD_NONE, 0},
289 {"center", WD_CENTER, 0},
290 {"top", WD_TOP, 0},
291 {"bottom", WD_BOTTOM, 0},
292 {"topleft", WD_TOPLEFT, 0},
293 {"topright", WD_TOPRIGHT, 0},
294 {"bottomleft", WD_BOTTOMLEFT, 0},
295 {"bottomright", WD_BOTTOMRIGHT, 0},
296 {NULL, 0, 0}
299 static WOptionEnumeration seWorkspaceBorder[] = {
300 {"None", WB_NONE, 0},
301 {"LeftRight", WB_LEFTRIGHT, 0},
302 {"TopBottom", WB_TOPBOTTOM, 0},
303 {"AllDirections", WB_ALLDIRS, 0},
304 {NULL, 0, 0}
307 static WOptionEnumeration seDragMaximizedWindow[] = {
308 {"Move", DRAGMAX_MOVE, 0},
309 {"RestoreGeometry", DRAGMAX_RESTORE, 0},
310 {"Unmaximize", DRAGMAX_UNMAXIMIZE, 0},
311 {"NoMove", DRAGMAX_NOMOVE, 0},
312 {NULL, 0, 0}
316 * ALL entries in the tables below NEED to have a default value
317 * defined, and this value needs to be correct.
319 * Also add the default key/value pair to WindowMaker/Defaults/WindowMaker.in
322 /* these options will only affect the window manager on startup
324 * static defaults can't access the screen data, because it is
325 * created after these defaults are read
327 WDefaultEntry staticOptionList[] = {
329 {"ColormapSize", "4", NULL,
330 &wPreferences.cmap_size, getInt, NULL, NULL, NULL},
331 {"DisableDithering", "NO", NULL,
332 &wPreferences.no_dithering, getBool, NULL, NULL, NULL},
333 {"IconSize", "64", NULL,
334 &wPreferences.icon_size, getInt, NULL, NULL, NULL},
335 {"ModifierKey", "Mod1", NULL,
336 &wPreferences.modifier_mask, getModMask, NULL, NULL, NULL},
337 {"FocusMode", "manual", seFocusModes, /* have a problem when switching from */
338 &wPreferences.focus_mode, getEnum, NULL, NULL, NULL}, /* manual to sloppy without restart */
339 {"NewStyle", "new", seTitlebarModes,
340 &wPreferences.new_style, getEnum, NULL, NULL, NULL},
341 {"DisableDock", "NO", (void *)WM_DOCK,
342 NULL, getBool, setIfDockPresent, NULL, NULL},
343 {"DisableClip", "NO", (void *)WM_CLIP,
344 NULL, getBool, setIfDockPresent, NULL, NULL},
345 {"DisableDrawers", "NO", (void *)WM_DRAWER,
346 NULL, getBool, setIfDockPresent, NULL, NULL},
347 {"ClipMergedInDock", "NO", NULL,
348 NULL, getBool, setClipMergedInDock, NULL, NULL},
349 {"DisableMiniwindows", "NO", NULL,
350 &wPreferences.disable_miniwindows, getBool, NULL, NULL, NULL},
351 {"EnableWorkspacePager", "NO", NULL,
352 &wPreferences.enable_workspace_pager, getBool, NULL, NULL, NULL}
355 #define NUM2STRING_(x) #x
356 #define NUM2STRING(x) NUM2STRING_(x)
358 WDefaultEntry optionList[] = {
360 /* dynamic options */
362 {"IconPosition", "blh", seIconPositions,
363 &wPreferences.icon_yard, getEnum, setIconPosition, NULL, NULL},
364 {"IconificationStyle", "Zoom", seIconificationStyles,
365 &wPreferences.iconification_style, getEnum, NULL, NULL, NULL},
366 {"DisableWSMouseActions", "NO", NULL,
367 &wPreferences.disable_root_mouse, getBool, NULL, NULL, NULL},
368 {"MouseLeftButtonAction", "SelectWindows", seMouseButtonActions,
369 &wPreferences.mouse_button1, getEnum, NULL, NULL, NULL},
370 {"MouseMiddleButtonAction", "OpenWindowListMenu", seMouseButtonActions,
371 &wPreferences.mouse_button2, getEnum, NULL, NULL, NULL},
372 {"MouseRightButtonAction", "OpenApplicationsMenu", seMouseButtonActions,
373 &wPreferences.mouse_button3, getEnum, NULL, NULL, NULL},
374 {"MouseBackwardButtonAction", "None", seMouseButtonActions,
375 &wPreferences.mouse_button8, getEnum, NULL, NULL, NULL},
376 {"MouseForwardButtonAction", "None", seMouseButtonActions,
377 &wPreferences.mouse_button9, getEnum, NULL, NULL, NULL},
378 {"MouseWheelAction", "None", seMouseWheelActions,
379 &wPreferences.mouse_wheel_scroll, getEnum, NULL, NULL, NULL},
380 {"MouseWheelTiltAction", "None", seMouseWheelActions,
381 &wPreferences.mouse_wheel_tilt, getEnum, NULL, NULL, NULL},
382 {"PixmapPath", DEF_PIXMAP_PATHS, NULL,
383 &wPreferences.pixmap_path, getPathList, NULL, NULL, NULL},
384 {"IconPath", DEF_ICON_PATHS, NULL,
385 &wPreferences.icon_path, getPathList, NULL, NULL, NULL},
386 {"ColormapMode", "auto", seColormapModes,
387 &wPreferences.colormap_mode, getEnum, NULL, NULL, NULL},
388 {"AutoFocus", "YES", NULL,
389 &wPreferences.auto_focus, getBool, NULL, NULL, NULL},
390 {"RaiseDelay", "0", NULL,
391 &wPreferences.raise_delay, getInt, NULL, NULL, NULL},
392 {"CirculateRaise", "NO", NULL,
393 &wPreferences.circ_raise, getBool, NULL, NULL, NULL},
394 {"Superfluous", "YES", NULL,
395 &wPreferences.superfluous, getBool, NULL, NULL, NULL},
396 {"AdvanceToNewWorkspace", "NO", NULL,
397 &wPreferences.ws_advance, getBool, NULL, NULL, NULL},
398 {"CycleWorkspaces", "NO", NULL,
399 &wPreferences.ws_cycle, getBool, NULL, NULL, NULL},
400 {"WorkspaceNameDisplayPosition", "center", seDisplayPositions,
401 &wPreferences.workspace_name_display_position, getEnum, NULL, NULL, NULL},
402 {"WorkspaceBorder", "None", seWorkspaceBorder,
403 &wPreferences.workspace_border_position, getEnum, updateUsableArea, NULL, NULL},
404 {"WorkspaceBorderSize", "0", NULL,
405 &wPreferences.workspace_border_size, getInt, updateUsableArea, NULL, NULL},
406 {"StickyIcons", "NO", NULL,
407 &wPreferences.sticky_icons, getBool, setStickyIcons, NULL, NULL},
408 {"SaveSessionOnExit", "NO", NULL,
409 &wPreferences.save_session_on_exit, getBool, NULL, NULL, NULL},
410 {"WrapMenus", "NO", NULL,
411 &wPreferences.wrap_menus, getBool, NULL, NULL, NULL},
412 {"ScrollableMenus", "YES", NULL,
413 &wPreferences.scrollable_menus, getBool, NULL, NULL, NULL},
414 {"MenuScrollSpeed", "fast", seSpeeds,
415 &wPreferences.menu_scroll_speed, getEnum, NULL, NULL, NULL},
416 {"IconSlideSpeed", "fast", seSpeeds,
417 &wPreferences.icon_slide_speed, getEnum, NULL, NULL, NULL},
418 {"ShadeSpeed", "fast", seSpeeds,
419 &wPreferences.shade_speed, getEnum, NULL, NULL, NULL},
420 {"BounceAppIconsWhenUrgent", "YES", NULL,
421 &wPreferences.bounce_appicons_when_urgent, getBool, NULL, NULL, NULL},
422 {"RaiseAppIconsWhenBouncing", "NO", NULL,
423 &wPreferences.raise_appicons_when_bouncing, getBool, NULL, NULL, NULL},
424 {"DoNotMakeAppIconsBounce", "NO", NULL,
425 &wPreferences.do_not_make_appicons_bounce, getBool, NULL, NULL, NULL},
426 {"DoubleClickTime", "250", (void *)&wPreferences.dblclick_time,
427 &wPreferences.dblclick_time, getInt, setDoubleClick, NULL, NULL},
428 {"ClipAutoraiseDelay", "600", NULL,
429 &wPreferences.clip_auto_raise_delay, getInt, NULL, NULL, NULL},
430 {"ClipAutolowerDelay", "1000", NULL,
431 &wPreferences.clip_auto_lower_delay, getInt, NULL, NULL, NULL},
432 {"ClipAutoexpandDelay", "600", NULL,
433 &wPreferences.clip_auto_expand_delay, getInt, NULL, NULL, NULL},
434 {"ClipAutocollapseDelay", "1000", NULL,
435 &wPreferences.clip_auto_collapse_delay, getInt, NULL, NULL, NULL},
436 {"WrapAppiconsInDock", "YES", NULL,
437 NULL, getBool, setWrapAppiconsInDock, NULL, NULL},
438 {"AlignSubmenus", "NO", NULL,
439 &wPreferences.align_menus, getBool, NULL, NULL, NULL},
440 {"ViKeyMenus", "NO", NULL,
441 &wPreferences.vi_key_menus, getBool, NULL, NULL, NULL},
442 {"OpenTransientOnOwnerWorkspace", "NO", NULL,
443 &wPreferences.open_transients_with_parent, getBool, NULL, NULL, NULL},
444 {"WindowPlacement", "auto", sePlacements,
445 &wPreferences.window_placement, getEnum, NULL, NULL, NULL},
446 {"IgnoreFocusClick", "NO", NULL,
447 &wPreferences.ignore_focus_click, getBool, NULL, NULL, NULL},
448 {"UseSaveUnders", "NO", NULL,
449 &wPreferences.use_saveunders, getBool, NULL, NULL, NULL},
450 {"OpaqueMove", "YES", NULL,
451 &wPreferences.opaque_move, getBool, NULL, NULL, NULL},
452 {"OpaqueResize", "NO", NULL,
453 &wPreferences.opaque_resize, getBool, NULL, NULL, NULL},
454 {"OpaqueMoveResizeKeyboard", "NO", NULL,
455 &wPreferences.opaque_move_resize_keyboard, getBool, NULL, NULL, NULL},
456 {"DisableAnimations", "NO", NULL,
457 &wPreferences.no_animations, getBool, NULL, NULL, NULL},
458 {"DontLinkWorkspaces", "YES", NULL,
459 &wPreferences.no_autowrap, getBool, NULL, NULL, NULL},
460 {"WindowSnapping", "NO", NULL,
461 &wPreferences.window_snapping, getBool, NULL, NULL, NULL},
462 {"SnapEdgeDetect", "1", NULL,
463 &wPreferences.snap_edge_detect, getInt, NULL, NULL, NULL},
464 {"SnapCornerDetect", "10", NULL,
465 &wPreferences.snap_corner_detect, getInt, NULL, NULL, NULL},
466 {"SnapToTopMaximizesFullscreen", "NO", NULL,
467 &wPreferences.snap_to_top_maximizes_fullscreen, getBool, NULL, NULL, NULL},
468 {"DragMaximizedWindow", "Move", seDragMaximizedWindow,
469 &wPreferences.drag_maximized_window, getEnum, NULL, NULL, NULL},
470 {"MoveHalfMaximizedWindowsBetweenScreens", "NO", NULL,
471 &wPreferences.move_half_max_between_heads, getBool, NULL, NULL, NULL},
472 {"AlternativeHalfMaximized", "NO", NULL,
473 &wPreferences.alt_half_maximize, getBool, NULL, NULL, NULL},
474 {"PointerWithHalfMaxWindows", "NO", NULL,
475 &wPreferences.pointer_with_half_max_windows, getBool, NULL, NULL, NULL},
476 {"HighlightActiveApp", "YES", NULL,
477 &wPreferences.highlight_active_app, getBool, NULL, NULL, NULL},
478 {"AutoArrangeIcons", "NO", NULL,
479 &wPreferences.auto_arrange_icons, getBool, NULL, NULL, NULL},
480 {"NoWindowOverDock", "NO", NULL,
481 &wPreferences.no_window_over_dock, getBool, updateUsableArea, NULL, NULL},
482 {"NoWindowOverIcons", "NO", NULL,
483 &wPreferences.no_window_over_icons, getBool, updateUsableArea, NULL, NULL},
484 {"WindowPlaceOrigin", "(64, 0)", NULL,
485 &wPreferences.window_place_origin, getCoord, NULL, NULL, NULL},
486 {"ResizeDisplay", "center", seGeomDisplays,
487 &wPreferences.size_display, getEnum, NULL, NULL, NULL},
488 {"MoveDisplay", "floating", seGeomDisplays,
489 &wPreferences.move_display, getEnum, NULL, NULL, NULL},
490 {"DontConfirmKill", "NO", NULL,
491 &wPreferences.dont_confirm_kill, getBool, NULL, NULL, NULL},
492 {"WindowTitleBalloons", "YES", NULL,
493 &wPreferences.window_balloon, getBool, NULL, NULL, NULL},
494 {"MiniwindowTitleBalloons", "NO", NULL,
495 &wPreferences.miniwin_title_balloon, getBool, NULL, NULL, NULL},
496 {"MiniwindowPreviewBalloons", "NO", NULL,
497 &wPreferences.miniwin_preview_balloon, getBool, NULL, NULL, NULL},
498 {"AppIconBalloons", "NO", NULL,
499 &wPreferences.appicon_balloon, getBool, NULL, NULL, NULL},
500 {"HelpBalloons", "NO", NULL,
501 &wPreferences.help_balloon, getBool, NULL, NULL, NULL},
502 {"EdgeResistance", "30", NULL,
503 &wPreferences.edge_resistance, getInt, NULL, NULL, NULL},
504 {"ResizeIncrement", "0", NULL,
505 &wPreferences.resize_increment, getInt, NULL, NULL, NULL},
506 {"Attraction", "NO", NULL,
507 &wPreferences.attract, getBool, NULL, NULL, NULL},
508 {"DisableBlinking", "NO", NULL,
509 &wPreferences.dont_blink, getBool, NULL, NULL, NULL},
510 {"SingleClickLaunch", "NO", NULL,
511 &wPreferences.single_click, getBool, NULL, NULL, NULL},
512 {"StrictWindozeCycle", "YES", NULL,
513 &wPreferences.strict_windoze_cycle, getBool, NULL, NULL, NULL},
514 {"SwitchPanelOnlyOpen", "NO", NULL,
515 &wPreferences.panel_only_open, getBool, NULL, NULL, NULL},
516 {"MiniPreviewSize", "128", NULL,
517 &wPreferences.minipreview_size, getInt, NULL, NULL, NULL},
518 {"IgnoreGtkHints", "NO", NULL,
519 &wPreferences.ignore_gtk_decoration_hints, getBool, NULL, NULL, NULL},
521 /* style options */
523 {"MenuStyle", "normal", seMenuStyles,
524 &wPreferences.menu_style, getEnum, setMenuStyle, NULL, NULL},
525 {"WidgetColor", "(solid, gray)", NULL,
526 NULL, getTexture, setWidgetColor, NULL, NULL},
527 {"WorkspaceSpecificBack", "()", NULL,
528 NULL, getWSSpecificBackground, setWorkspaceSpecificBack, NULL, NULL},
529 /* WorkspaceBack must come after WorkspaceSpecificBack or
530 * WorkspaceBack won't know WorkspaceSpecificBack was also
531 * specified and 2 copies of wmsetbg will be launched */
532 {"WorkspaceBack", "(solid, \"rgb:50/50/75\")", NULL,
533 NULL, getWSBackground, setWorkspaceBack, NULL, NULL},
534 {"SmoothWorkspaceBack", "NO", NULL,
535 NULL, getBool, NULL, NULL, NULL},
536 {"IconBack", "(dgradient, \"rgb:a6/a6/b6\", \"rgb:51/55/61\")", NULL,
537 NULL, getTexture, setIconTile, NULL, NULL},
538 {"TitleJustify", "center", seJustifications,
539 &wPreferences.title_justification, getEnum, setJustify, NULL, NULL},
540 {"WindowTitleFont", DEF_TITLE_FONT, NULL,
541 NULL, getFont, setWinTitleFont, NULL, NULL},
542 {"WindowTitleExtendSpace", DEF_WINDOW_TITLE_EXTEND_SPACE, NULL,
543 &wPreferences.window_title_clearance, getInt, setClearance, NULL, NULL},
544 {"WindowTitleMinHeight", "0", NULL,
545 &wPreferences.window_title_min_height, getInt, setClearance, NULL, NULL},
546 {"WindowTitleMaxHeight", NUM2STRING(INT_MAX), NULL,
547 &wPreferences.window_title_max_height, getInt, setClearance, NULL, NULL},
548 {"MenuTitleExtendSpace", DEF_MENU_TITLE_EXTEND_SPACE, NULL,
549 &wPreferences.menu_title_clearance, getInt, setClearance, NULL, NULL},
550 {"MenuTitleMinHeight", "0", NULL,
551 &wPreferences.menu_title_min_height, getInt, setClearance, NULL, NULL},
552 {"MenuTitleMaxHeight", NUM2STRING(INT_MAX), NULL,
553 &wPreferences.menu_title_max_height, getInt, setClearance, NULL, NULL},
554 {"MenuTextExtendSpace", DEF_MENU_TEXT_EXTEND_SPACE, NULL,
555 &wPreferences.menu_text_clearance, getInt, setClearance, NULL, NULL},
556 {"MenuTitleFont", DEF_MENU_TITLE_FONT, NULL,
557 NULL, getFont, setMenuTitleFont, NULL, NULL},
558 {"MenuTextFont", DEF_MENU_ENTRY_FONT, NULL,
559 NULL, getFont, setMenuTextFont, NULL, NULL},
560 {"IconTitleFont", DEF_ICON_TITLE_FONT, NULL,
561 NULL, getFont, setIconTitleFont, NULL, NULL},
562 {"ClipTitleFont", DEF_CLIP_TITLE_FONT, NULL,
563 NULL, getFont, setClipTitleFont, NULL, NULL},
564 {"ShowClipTitle", "YES", NULL,
565 &wPreferences.show_clip_title, getBool, NULL, NULL, NULL},
566 {"LargeDisplayFont", DEF_WORKSPACE_NAME_FONT, NULL,
567 NULL, getFont, setLargeDisplayFont, NULL, NULL},
568 {"HighlightColor", "white", NULL,
569 NULL, getColor, setHightlight, NULL, NULL},
570 {"HighlightTextColor", "black", NULL,
571 NULL, getColor, setHightlightText, NULL, NULL},
572 {"ClipTitleColor", "black", (void *)CLIP_NORMAL,
573 NULL, getColor, setClipTitleColor, NULL, NULL},
574 {"CClipTitleColor", "\"rgb:61/61/61\"", (void *)CLIP_COLLAPSED,
575 NULL, getColor, setClipTitleColor, NULL, NULL},
576 {"FTitleColor", "white", (void *)WS_FOCUSED,
577 NULL, getColor, setWTitleColor, NULL, NULL},
578 {"PTitleColor", "white", (void *)WS_PFOCUSED,
579 NULL, getColor, setWTitleColor, NULL, NULL},
580 {"UTitleColor", "black", (void *)WS_UNFOCUSED,
581 NULL, getColor, setWTitleColor, NULL, NULL},
582 {"FTitleBack", "(solid, black)", NULL,
583 NULL, getTexture, setFTitleBack, NULL, NULL},
584 {"PTitleBack", "(solid, gray40)", NULL,
585 NULL, getTexture, setPTitleBack, NULL, NULL},
586 {"UTitleBack", "(solid, \"rgb:aa/aa/aa\")", NULL,
587 NULL, getTexture, setUTitleBack, NULL, NULL},
588 {"ResizebarBack", "(solid, \"rgb:aa/aa/aa\")", NULL,
589 NULL, getTexture, setResizebarBack, NULL, NULL},
590 {"MenuTitleColor", "white", NULL,
591 NULL, getColor, setMenuTitleColor, NULL, NULL},
592 {"MenuTextColor", "black", NULL,
593 NULL, getColor, setMenuTextColor, NULL, NULL},
594 {"MenuDisabledColor", "gray50", NULL,
595 NULL, getColor, setMenuDisabledColor, NULL, NULL},
596 {"MenuTitleBack", "(solid, black)", NULL,
597 NULL, getTexture, setMenuTitleBack, NULL, NULL},
598 {"MenuTextBack", "(solid, \"rgb:aa/aa/aa\")", NULL,
599 NULL, getTexture, setMenuTextBack, NULL, NULL},
600 {"IconTitleColor", "white", NULL,
601 NULL, getColor, setIconTitleColor, NULL, NULL},
602 {"IconTitleBack", "black", NULL,
603 NULL, getColor, setIconTitleBack, NULL, NULL},
604 {"SwitchPanelImages", "(swtile.png, swback.png, 30, 40)", &wPreferences,
605 NULL, getPropList, setSwPOptions, NULL, NULL},
606 {"ModifierKeyLabels", "(\"Shift+\", \"Control+\", \"Mod1+\", \"Mod2+\", \"Mod3+\", \"Mod4+\", \"Mod5+\")", &wPreferences,
607 NULL, getPropList, setModifierKeyLabels, NULL, NULL},
608 {"FrameBorderWidth", "1", NULL,
609 NULL, getInt, setFrameBorderWidth, NULL, NULL},
610 {"FrameBorderColor", "black", NULL,
611 NULL, getColor, setFrameBorderColor, NULL, NULL},
612 {"FrameFocusedBorderColor", "black", NULL,
613 NULL, getColor, setFrameFocusedBorderColor, NULL, NULL},
614 {"FrameSelectedBorderColor", "white", NULL,
615 NULL, getColor, setFrameSelectedBorderColor, NULL, NULL},
616 {"WorkspaceMapBack", "(solid, black)", NULL,
617 NULL, getTexture, setWorkspaceMapBackground, NULL, NULL},
619 /* keybindings */
621 {"RootMenuKey", "F12", (void *)WKBD_ROOTMENU,
622 NULL, getKeybind, setKeyGrab, NULL, NULL},
623 {"WindowListKey", "F11", (void *)WKBD_WINDOWLIST,
624 NULL, getKeybind, setKeyGrab, NULL, NULL},
625 {"WindowMenuKey", "Control+Escape", (void *)WKBD_WINDOWMENU,
626 NULL, getKeybind, setKeyGrab, NULL, NULL},
627 {"DockRaiseLowerKey", "None", (void*)WKBD_DOCKRAISELOWER,
628 NULL, getKeybind, setKeyGrab, NULL, NULL},
629 {"ClipRaiseLowerKey", "None", (void *)WKBD_CLIPRAISELOWER,
630 NULL, getKeybind, setKeyGrab, NULL, NULL},
631 {"MiniaturizeKey", "Mod1+M", (void *)WKBD_MINIATURIZE,
632 NULL, getKeybind, setKeyGrab, NULL, NULL},
633 {"MinimizeAllKey", "None", (void *)WKBD_MINIMIZEALL,
634 NULL, getKeybind, setKeyGrab, NULL, NULL },
635 {"HideKey", "Mod1+H", (void *)WKBD_HIDE,
636 NULL, getKeybind, setKeyGrab, NULL, NULL},
637 {"HideOthersKey", "None", (void *)WKBD_HIDE_OTHERS,
638 NULL, getKeybind, setKeyGrab, NULL, NULL},
639 {"MoveResizeKey", "None", (void *)WKBD_MOVERESIZE,
640 NULL, getKeybind, setKeyGrab, NULL, NULL},
641 {"CloseKey", "None", (void *)WKBD_CLOSE,
642 NULL, getKeybind, setKeyGrab, NULL, NULL},
643 {"MaximizeKey", "None", (void *)WKBD_MAXIMIZE,
644 NULL, getKeybind, setKeyGrab, NULL, NULL},
645 {"VMaximizeKey", "None", (void *)WKBD_VMAXIMIZE,
646 NULL, getKeybind, setKeyGrab, NULL, NULL},
647 {"HMaximizeKey", "None", (void *)WKBD_HMAXIMIZE,
648 NULL, getKeybind, setKeyGrab, NULL, NULL},
649 {"LHMaximizeKey", "None", (void*)WKBD_LHMAXIMIZE,
650 NULL, getKeybind, setKeyGrab, NULL, NULL},
651 {"RHMaximizeKey", "None", (void*)WKBD_RHMAXIMIZE,
652 NULL, getKeybind, setKeyGrab, NULL, NULL},
653 {"THMaximizeKey", "None", (void*)WKBD_THMAXIMIZE,
654 NULL, getKeybind, setKeyGrab, NULL, NULL},
655 {"BHMaximizeKey", "None", (void*)WKBD_BHMAXIMIZE,
656 NULL, getKeybind, setKeyGrab, NULL, NULL},
657 {"LTCMaximizeKey", "None", (void*)WKBD_LTCMAXIMIZE,
658 NULL, getKeybind, setKeyGrab, NULL, NULL},
659 {"RTCMaximizeKey", "None", (void*)WKBD_RTCMAXIMIZE,
660 NULL, getKeybind, setKeyGrab, NULL, NULL},
661 {"LBCMaximizeKey", "None", (void*)WKBD_LBCMAXIMIZE,
662 NULL, getKeybind, setKeyGrab, NULL, NULL},
663 {"RBCMaximizeKey", "None", (void*)WKBD_RBCMAXIMIZE,
664 NULL, getKeybind, setKeyGrab, NULL, NULL},
665 {"MaximusKey", "None", (void*)WKBD_MAXIMUS,
666 NULL, getKeybind, setKeyGrab, NULL, NULL},
667 {"KeepOnTopKey", "None", (void *)WKBD_KEEP_ON_TOP,
668 NULL, getKeybind, setKeyGrab, NULL, NULL},
669 {"KeepAtBottomKey", "None", (void *)WKBD_KEEP_AT_BOTTOM,
670 NULL, getKeybind, setKeyGrab, NULL, NULL},
671 {"OmnipresentKey", "None", (void *)WKBD_OMNIPRESENT,
672 NULL, getKeybind, setKeyGrab, NULL, NULL},
673 {"RaiseKey", "Mod1+Up", (void *)WKBD_RAISE,
674 NULL, getKeybind, setKeyGrab, NULL, NULL},
675 {"LowerKey", "Mod1+Down", (void *)WKBD_LOWER,
676 NULL, getKeybind, setKeyGrab, NULL, NULL},
677 {"RaiseLowerKey", "None", (void *)WKBD_RAISELOWER,
678 NULL, getKeybind, setKeyGrab, NULL, NULL},
679 {"ShadeKey", "None", (void *)WKBD_SHADE,
680 NULL, getKeybind, setKeyGrab, NULL, NULL},
681 {"SelectKey", "None", (void *)WKBD_SELECT,
682 NULL, getKeybind, setKeyGrab, NULL, NULL},
683 {"WorkspaceMapKey", "None", (void *)WKBD_WORKSPACEMAP,
684 NULL, getKeybind, setKeyGrab, NULL, NULL},
685 {"FocusNextKey", "Mod1+Tab", (void *)WKBD_FOCUSNEXT,
686 NULL, getKeybind, setKeyGrab, NULL, NULL},
687 {"FocusPrevKey", "Mod1+Shift+Tab", (void *)WKBD_FOCUSPREV,
688 NULL, getKeybind, setKeyGrab, NULL, NULL},
689 {"GroupNextKey", "None", (void *)WKBD_GROUPNEXT,
690 NULL, getKeybind, setKeyGrab, NULL, NULL},
691 {"GroupPrevKey", "None", (void *)WKBD_GROUPPREV,
692 NULL, getKeybind, setKeyGrab, NULL, NULL},
693 {"NextWorkspaceKey", "Mod1+Control+Right", (void *)WKBD_NEXTWORKSPACE,
694 NULL, getKeybind, setKeyGrab, NULL, NULL},
695 {"PrevWorkspaceKey", "Mod1+Control+Left", (void *)WKBD_PREVWORKSPACE,
696 NULL, getKeybind, setKeyGrab, NULL, NULL},
697 {"LastWorkspaceKey", "None", (void *)WKBD_LASTWORKSPACE,
698 NULL, getKeybind, setKeyGrab, NULL, NULL},
699 {"NextWorkspaceLayerKey", "None", (void *)WKBD_NEXTWSLAYER,
700 NULL, getKeybind, setKeyGrab, NULL, NULL},
701 {"PrevWorkspaceLayerKey", "None", (void *)WKBD_PREVWSLAYER,
702 NULL, getKeybind, setKeyGrab, NULL, NULL},
703 {"Workspace1Key", "Mod1+1", (void *)WKBD_WORKSPACE1,
704 NULL, getKeybind, setKeyGrab, NULL, NULL},
705 {"Workspace2Key", "Mod1+2", (void *)WKBD_WORKSPACE2,
706 NULL, getKeybind, setKeyGrab, NULL, NULL},
707 {"Workspace3Key", "Mod1+3", (void *)WKBD_WORKSPACE3,
708 NULL, getKeybind, setKeyGrab, NULL, NULL},
709 {"Workspace4Key", "Mod1+4", (void *)WKBD_WORKSPACE4,
710 NULL, getKeybind, setKeyGrab, NULL, NULL},
711 {"Workspace5Key", "Mod1+5", (void *)WKBD_WORKSPACE5,
712 NULL, getKeybind, setKeyGrab, NULL, NULL},
713 {"Workspace6Key", "Mod1+6", (void *)WKBD_WORKSPACE6,
714 NULL, getKeybind, setKeyGrab, NULL, NULL},
715 {"Workspace7Key", "Mod1+7", (void *)WKBD_WORKSPACE7,
716 NULL, getKeybind, setKeyGrab, NULL, NULL},
717 {"Workspace8Key", "Mod1+8", (void *)WKBD_WORKSPACE8,
718 NULL, getKeybind, setKeyGrab, NULL, NULL},
719 {"Workspace9Key", "Mod1+9", (void *)WKBD_WORKSPACE9,
720 NULL, getKeybind, setKeyGrab, NULL, NULL},
721 {"Workspace10Key", "Mod1+0", (void *)WKBD_WORKSPACE10,
722 NULL, getKeybind, setKeyGrab, NULL, NULL},
723 {"MoveToWorkspace1Key", "None", (void *)WKBD_MOVE_WORKSPACE1,
724 NULL, getKeybind, setKeyGrab, NULL, NULL},
725 {"MoveToWorkspace2Key", "None", (void *)WKBD_MOVE_WORKSPACE2,
726 NULL, getKeybind, setKeyGrab, NULL, NULL},
727 {"MoveToWorkspace3Key", "None", (void *)WKBD_MOVE_WORKSPACE3,
728 NULL, getKeybind, setKeyGrab, NULL, NULL},
729 {"MoveToWorkspace4Key", "None", (void *)WKBD_MOVE_WORKSPACE4,
730 NULL, getKeybind, setKeyGrab, NULL, NULL},
731 {"MoveToWorkspace5Key", "None", (void *)WKBD_MOVE_WORKSPACE5,
732 NULL, getKeybind, setKeyGrab, NULL, NULL},
733 {"MoveToWorkspace6Key", "None", (void *)WKBD_MOVE_WORKSPACE6,
734 NULL, getKeybind, setKeyGrab, NULL, NULL},
735 {"MoveToWorkspace7Key", "None", (void *)WKBD_MOVE_WORKSPACE7,
736 NULL, getKeybind, setKeyGrab, NULL, NULL},
737 {"MoveToWorkspace8Key", "None", (void *)WKBD_MOVE_WORKSPACE8,
738 NULL, getKeybind, setKeyGrab, NULL, NULL},
739 {"MoveToWorkspace9Key", "None", (void *)WKBD_MOVE_WORKSPACE9,
740 NULL, getKeybind, setKeyGrab, NULL, NULL},
741 {"MoveToWorkspace10Key", "None", (void *)WKBD_MOVE_WORKSPACE10,
742 NULL, getKeybind, setKeyGrab, NULL, NULL},
743 {"MoveToNextWorkspaceKey", "None", (void *)WKBD_MOVE_NEXTWORKSPACE,
744 NULL, getKeybind, setKeyGrab, NULL, NULL},
745 {"MoveToPrevWorkspaceKey", "None", (void *)WKBD_MOVE_PREVWORKSPACE,
746 NULL, getKeybind, setKeyGrab, NULL, NULL},
747 {"MoveToLastWorkspaceKey", "None", (void *)WKBD_MOVE_LASTWORKSPACE,
748 NULL, getKeybind, setKeyGrab, NULL, NULL},
749 {"MoveToNextWorkspaceLayerKey", "None", (void *)WKBD_MOVE_NEXTWSLAYER,
750 NULL, getKeybind, setKeyGrab, NULL, NULL},
751 {"MoveToPrevWorkspaceLayerKey", "None", (void *)WKBD_MOVE_PREVWSLAYER,
752 NULL, getKeybind, setKeyGrab, NULL, NULL},
753 {"WindowShortcut1Key", "None", (void *)WKBD_WINDOW1,
754 NULL, getKeybind, setKeyGrab, NULL, NULL},
755 {"WindowShortcut2Key", "None", (void *)WKBD_WINDOW2,
756 NULL, getKeybind, setKeyGrab, NULL, NULL},
757 {"WindowShortcut3Key", "None", (void *)WKBD_WINDOW3,
758 NULL, getKeybind, setKeyGrab, NULL, NULL},
759 {"WindowShortcut4Key", "None", (void *)WKBD_WINDOW4,
760 NULL, getKeybind, setKeyGrab, NULL, NULL},
761 {"WindowShortcut5Key", "None", (void *)WKBD_WINDOW5,
762 NULL, getKeybind, setKeyGrab, NULL, NULL},
763 {"WindowShortcut6Key", "None", (void *)WKBD_WINDOW6,
764 NULL, getKeybind, setKeyGrab, NULL, NULL},
765 {"WindowShortcut7Key", "None", (void *)WKBD_WINDOW7,
766 NULL, getKeybind, setKeyGrab, NULL, NULL},
767 {"WindowShortcut8Key", "None", (void *)WKBD_WINDOW8,
768 NULL, getKeybind, setKeyGrab, NULL, NULL},
769 {"WindowShortcut9Key", "None", (void *)WKBD_WINDOW9,
770 NULL, getKeybind, setKeyGrab, NULL, NULL},
771 {"WindowShortcut10Key", "None", (void *)WKBD_WINDOW10,
772 NULL, getKeybind, setKeyGrab, NULL, NULL},
773 {"MoveTo12to6Head", "None", (void *)WKBD_MOVE_12_TO_6_HEAD,
774 NULL, getKeybind, setKeyGrab, NULL, NULL},
775 {"MoveTo6to12Head", "None", (void *)WKBD_MOVE_6_TO_12_HEAD,
776 NULL, getKeybind, setKeyGrab, NULL, NULL},
777 {"WindowRelaunchKey", "None", (void *)WKBD_RELAUNCH,
778 NULL, getKeybind, setKeyGrab, NULL, NULL},
779 {"ScreenSwitchKey", "None", (void *)WKBD_SWITCH_SCREEN,
780 NULL, getKeybind, setKeyGrab, NULL, NULL},
781 {"RunKey", "None", (void *)WKBD_RUN,
782 NULL, getKeybind, setKeyGrab, NULL, NULL},
784 #ifdef KEEP_XKB_LOCK_STATUS
785 {"ToggleKbdModeKey", "None", (void *)WKBD_TOGGLE,
786 NULL, getKeybind, setKeyGrab, NULL, NULL},
787 {"KbdModeLock", "NO", NULL,
788 &wPreferences.modelock, getBool, NULL, NULL, NULL},
789 #endif /* KEEP_XKB_LOCK_STATUS */
791 {"NormalCursor", "(builtin, left_ptr)", (void *)WCUR_ROOT,
792 NULL, getCursor, setCursor, NULL, NULL},
793 {"ArrowCursor", "(builtin, top_left_arrow)", (void *)WCUR_ARROW,
794 NULL, getCursor, setCursor, NULL, NULL},
795 {"MoveCursor", "(builtin, fleur)", (void *)WCUR_MOVE,
796 NULL, getCursor, setCursor, NULL, NULL},
797 {"ResizeCursor", "(builtin, sizing)", (void *)WCUR_RESIZE,
798 NULL, getCursor, setCursor, NULL, NULL},
799 {"TopLeftResizeCursor", "(builtin, top_left_corner)", (void *)WCUR_TOPLEFTRESIZE,
800 NULL, getCursor, setCursor, NULL, NULL},
801 {"TopRightResizeCursor", "(builtin, top_right_corner)", (void *)WCUR_TOPRIGHTRESIZE,
802 NULL, getCursor, setCursor, NULL, NULL},
803 {"BottomLeftResizeCursor", "(builtin, bottom_left_corner)", (void *)WCUR_BOTTOMLEFTRESIZE,
804 NULL, getCursor, setCursor, NULL, NULL},
805 {"BottomRightResizeCursor", "(builtin, bottom_right_corner)", (void *)WCUR_BOTTOMRIGHTRESIZE,
806 NULL, getCursor, setCursor, NULL, NULL},
807 {"VerticalResizeCursor", "(builtin, sb_v_double_arrow)", (void *)WCUR_VERTICALRESIZE,
808 NULL, getCursor, setCursor, NULL, NULL},
809 {"HorizontalResizeCursor", "(builtin, sb_h_double_arrow)", (void *)WCUR_HORIZONRESIZE,
810 NULL, getCursor, setCursor, NULL, NULL},
811 {"WaitCursor", "(builtin, watch)", (void *)WCUR_WAIT,
812 NULL, getCursor, setCursor, NULL, NULL},
813 {"QuestionCursor", "(builtin, question_arrow)", (void *)WCUR_QUESTION,
814 NULL, getCursor, setCursor, NULL, NULL},
815 {"TextCursor", "(builtin, xterm)", (void *)WCUR_TEXT,
816 NULL, getCursor, setCursor, NULL, NULL},
817 {"SelectCursor", "(builtin, cross)", (void *)WCUR_SELECT,
818 NULL, getCursor, setCursor, NULL, NULL},
819 {"DialogHistoryLines", "500", NULL,
820 &wPreferences.history_lines, getInt, NULL, NULL, NULL},
821 {"CycleActiveHeadOnly", "NO", NULL,
822 &wPreferences.cycle_active_head_only, getBool, NULL, NULL, NULL},
823 {"CycleIgnoreMinimized", "NO", NULL,
824 &wPreferences.cycle_ignore_minimized, getBool, NULL, NULL, NULL}
827 static void initDefaults(void)
829 unsigned int i;
830 WDefaultEntry *entry;
832 WMPLSetCaseSensitive(False);
834 for (i = 0; i < wlengthof(optionList); i++) {
835 entry = &optionList[i];
837 entry->plkey = WMCreatePLString(entry->key);
838 if (entry->default_value)
839 entry->plvalue = WMCreatePropListFromDescription(entry->default_value);
840 else
841 entry->plvalue = NULL;
844 for (i = 0; i < wlengthof(staticOptionList); i++) {
845 entry = &staticOptionList[i];
847 entry->plkey = WMCreatePLString(entry->key);
848 if (entry->default_value)
849 entry->plvalue = WMCreatePropListFromDescription(entry->default_value);
850 else
851 entry->plvalue = NULL;
855 static WMPropList *readGlobalDomain(const char *domainName, Bool requireDictionary)
857 WMPropList *globalDict = NULL;
858 char path[PATH_MAX];
859 struct stat stbuf;
861 snprintf(path, sizeof(path), "%s/%s", DEFSDATADIR, domainName);
862 if (stat(path, &stbuf) >= 0) {
863 globalDict = WMReadPropListFromFile(path);
864 if (globalDict && requireDictionary && !WMIsPLDictionary(globalDict)) {
865 wwarning(_("Domain %s (%s) of global defaults database is corrupted!"), domainName, path);
866 WMReleasePropList(globalDict);
867 globalDict = NULL;
868 } else if (!globalDict) {
869 wwarning(_("could not load domain %s from global defaults database"), domainName);
873 return globalDict;
876 #if defined(GLOBAL_PREAMBLE_MENU_FILE) || defined(GLOBAL_EPILOGUE_MENU_FILE)
877 static void prependMenu(WMPropList * destarr, WMPropList * array)
879 WMPropList *item;
880 int i;
882 for (i = 0; i < WMGetPropListItemCount(array); i++) {
883 item = WMGetFromPLArray(array, i);
884 if (item)
885 WMInsertInPLArray(destarr, i + 1, item);
889 static void appendMenu(WMPropList * destarr, WMPropList * array)
891 WMPropList *item;
892 int i;
894 for (i = 0; i < WMGetPropListItemCount(array); i++) {
895 item = WMGetFromPLArray(array, i);
896 if (item)
897 WMAddToPLArray(destarr, item);
900 #endif
902 void wDefaultsMergeGlobalMenus(WDDomain * menuDomain)
904 WMPropList *menu = menuDomain->dictionary;
905 WMPropList *submenu;
907 if (!menu || !WMIsPLArray(menu))
908 return;
910 #ifdef GLOBAL_PREAMBLE_MENU_FILE
911 submenu = WMReadPropListFromFile(DEFSDATADIR "/" GLOBAL_PREAMBLE_MENU_FILE);
913 if (submenu && !WMIsPLArray(submenu)) {
914 wwarning(_("invalid global menu file %s"), GLOBAL_PREAMBLE_MENU_FILE);
915 WMReleasePropList(submenu);
916 submenu = NULL;
918 if (submenu) {
919 prependMenu(menu, submenu);
920 WMReleasePropList(submenu);
922 #endif
924 #ifdef GLOBAL_EPILOGUE_MENU_FILE
925 submenu = WMReadPropListFromFile(DEFSDATADIR "/" GLOBAL_EPILOGUE_MENU_FILE);
927 if (submenu && !WMIsPLArray(submenu)) {
928 wwarning(_("invalid global menu file %s"), GLOBAL_EPILOGUE_MENU_FILE);
929 WMReleasePropList(submenu);
930 submenu = NULL;
932 if (submenu) {
933 appendMenu(menu, submenu);
934 WMReleasePropList(submenu);
936 #endif
938 menuDomain->dictionary = menu;
941 WDDomain *wDefaultsInitDomain(const char *domain, Bool requireDictionary)
943 WDDomain *db;
944 struct stat stbuf;
945 static int inited = 0;
946 WMPropList *shared_dict = NULL;
948 if (!inited) {
949 inited = 1;
950 initDefaults();
953 db = wmalloc(sizeof(WDDomain));
954 db->domain_name = domain;
955 db->path = wdefaultspathfordomain(domain);
957 if (stat(db->path, &stbuf) >= 0) {
958 db->dictionary = WMReadPropListFromFile(db->path);
959 if (db->dictionary) {
960 if (requireDictionary && !WMIsPLDictionary(db->dictionary)) {
961 WMReleasePropList(db->dictionary);
962 db->dictionary = NULL;
963 wwarning(_("Domain %s (%s) of defaults database is corrupted!"), domain, db->path);
965 db->timestamp = stbuf.st_mtime;
966 } else {
967 wwarning(_("could not load domain %s from user defaults database"), domain);
971 /* global system dictionary */
972 shared_dict = readGlobalDomain(domain, requireDictionary);
974 if (shared_dict && db->dictionary && WMIsPLDictionary(shared_dict) &&
975 WMIsPLDictionary(db->dictionary)) {
976 WMMergePLDictionaries(shared_dict, db->dictionary, True);
977 WMReleasePropList(db->dictionary);
978 db->dictionary = shared_dict;
979 if (stbuf.st_mtime > db->timestamp)
980 db->timestamp = stbuf.st_mtime;
981 } else if (!db->dictionary) {
982 db->dictionary = shared_dict;
983 if (stbuf.st_mtime > db->timestamp)
984 db->timestamp = stbuf.st_mtime;
987 return db;
990 void wReadStaticDefaults(WMPropList * dict)
992 WMPropList *plvalue;
993 WDefaultEntry *entry;
994 unsigned int i;
995 void *tdata;
997 for (i = 0; i < wlengthof(staticOptionList); i++) {
998 entry = &staticOptionList[i];
1000 if (dict)
1001 plvalue = WMGetFromPLDictionary(dict, entry->plkey);
1002 else
1003 plvalue = NULL;
1005 /* no default in the DB. Use builtin default */
1006 if (!plvalue)
1007 plvalue = entry->plvalue;
1009 if (plvalue) {
1010 /* convert data */
1011 (*entry->convert) (NULL, entry, plvalue, entry->addr, &tdata);
1012 if (entry->update)
1013 (*entry->update) (NULL, entry, tdata, entry->extra_data);
1018 void wDefaultsCheckDomains(void* arg)
1020 WScreen *scr;
1021 struct stat stbuf;
1022 WMPropList *shared_dict = NULL;
1023 WMPropList *dict;
1024 int i;
1026 /* Parameter not used, but tell the compiler that it is ok */
1027 (void) arg;
1029 if (stat(w_global.domain.wmaker->path, &stbuf) >= 0 && w_global.domain.wmaker->timestamp < stbuf.st_mtime) {
1030 w_global.domain.wmaker->timestamp = stbuf.st_mtime;
1032 /* Global dictionary */
1033 shared_dict = readGlobalDomain("WindowMaker", True);
1035 /* User dictionary */
1036 dict = WMReadPropListFromFile(w_global.domain.wmaker->path);
1038 if (dict) {
1039 if (!WMIsPLDictionary(dict)) {
1040 WMReleasePropList(dict);
1041 dict = NULL;
1042 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
1043 "WindowMaker", w_global.domain.wmaker->path);
1044 } else {
1045 if (shared_dict) {
1046 WMMergePLDictionaries(shared_dict, dict, True);
1047 WMReleasePropList(dict);
1048 dict = shared_dict;
1049 shared_dict = NULL;
1052 for (i = 0; i < w_global.screen_count; i++) {
1053 scr = wScreenWithNumber(i);
1054 if (scr)
1055 wReadDefaults(scr, dict);
1058 if (w_global.domain.wmaker->dictionary)
1059 WMReleasePropList(w_global.domain.wmaker->dictionary);
1061 w_global.domain.wmaker->dictionary = dict;
1063 } else {
1064 wwarning(_("could not load domain %s from user defaults database"), "WindowMaker");
1067 if (shared_dict)
1068 WMReleasePropList(shared_dict);
1072 if (stat(w_global.domain.window_attr->path, &stbuf) >= 0 && w_global.domain.window_attr->timestamp < stbuf.st_mtime) {
1073 /* global dictionary */
1074 shared_dict = readGlobalDomain("WMWindowAttributes", True);
1075 /* user dictionary */
1076 dict = WMReadPropListFromFile(w_global.domain.window_attr->path);
1077 if (dict) {
1078 if (!WMIsPLDictionary(dict)) {
1079 WMReleasePropList(dict);
1080 dict = NULL;
1081 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
1082 "WMWindowAttributes", w_global.domain.window_attr->path);
1083 } else {
1084 if (shared_dict) {
1085 WMMergePLDictionaries(shared_dict, dict, True);
1086 WMReleasePropList(dict);
1087 dict = shared_dict;
1088 shared_dict = NULL;
1091 if (w_global.domain.window_attr->dictionary)
1092 WMReleasePropList(w_global.domain.window_attr->dictionary);
1094 w_global.domain.window_attr->dictionary = dict;
1095 for (i = 0; i < w_global.screen_count; i++) {
1096 scr = wScreenWithNumber(i);
1097 if (scr) {
1098 wDefaultUpdateIcons(scr);
1100 /* Update the panel image if changed */
1101 /* Don't worry. If the image is the same these
1102 * functions will have no performance impact. */
1103 create_logo_image(scr);
1107 } else {
1108 wwarning(_("could not load domain %s from user defaults database"), "WMWindowAttributes");
1111 w_global.domain.window_attr->timestamp = stbuf.st_mtime;
1112 if (shared_dict)
1113 WMReleasePropList(shared_dict);
1116 if (stat(w_global.domain.root_menu->path, &stbuf) >= 0 && w_global.domain.root_menu->timestamp < stbuf.st_mtime) {
1117 dict = WMReadPropListFromFile(w_global.domain.root_menu->path);
1118 if (dict) {
1119 if (!WMIsPLArray(dict) && !WMIsPLString(dict)) {
1120 WMReleasePropList(dict);
1121 dict = NULL;
1122 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
1123 "WMRootMenu", w_global.domain.root_menu->path);
1124 } else {
1125 if (w_global.domain.root_menu->dictionary)
1126 WMReleasePropList(w_global.domain.root_menu->dictionary);
1128 w_global.domain.root_menu->dictionary = dict;
1129 wDefaultsMergeGlobalMenus(w_global.domain.root_menu);
1131 } else {
1132 wwarning(_("could not load domain %s from user defaults database"), "WMRootMenu");
1134 w_global.domain.root_menu->timestamp = stbuf.st_mtime;
1136 #ifndef HAVE_INOTIFY
1137 if (!arg)
1138 WMAddTimerHandler(DEFAULTS_CHECK_INTERVAL, wDefaultsCheckDomains, arg);
1139 #endif
1142 void wReadDefaults(WScreen * scr, WMPropList * new_dict)
1144 WMPropList *plvalue, *old_value;
1145 WDefaultEntry *entry;
1146 unsigned int i;
1147 int update_workspace_back = 0; /* kluge :/ */
1148 unsigned int needs_refresh;
1149 void *tdata;
1150 WMPropList *old_dict = (w_global.domain.wmaker->dictionary != new_dict ? w_global.domain.wmaker->dictionary : NULL);
1152 needs_refresh = 0;
1154 for (i = 0; i < wlengthof(optionList); i++) {
1155 entry = &optionList[i];
1157 if (new_dict)
1158 plvalue = WMGetFromPLDictionary(new_dict, entry->plkey);
1159 else
1160 plvalue = NULL;
1162 if (!old_dict)
1163 old_value = NULL;
1164 else
1165 old_value = WMGetFromPLDictionary(old_dict, entry->plkey);
1167 if (!plvalue && !old_value) {
1168 /* no default in the DB. Use builtin default */
1169 plvalue = entry->plvalue;
1170 if (plvalue && new_dict)
1171 WMPutInPLDictionary(new_dict, entry->plkey, plvalue);
1173 } else if (!plvalue) {
1174 /* value was deleted from DB. Keep current value */
1175 continue;
1176 } else if (!old_value) {
1177 /* set value for the 1st time */
1178 } else if (!WMIsPropListEqualTo(plvalue, old_value)) {
1179 /* value has changed */
1180 } else {
1181 if (strcmp(entry->key, "WorkspaceBack") == 0
1182 && update_workspace_back && scr->flags.backimage_helper_launched) {
1183 } else {
1184 /* value was not changed since last time */
1185 continue;
1189 if (plvalue) {
1190 /* convert data */
1191 if ((*entry->convert) (scr, entry, plvalue, entry->addr, &tdata)) {
1193 * If the WorkspaceSpecificBack data has been changed
1194 * so that the helper will be launched now, we must be
1195 * sure to send the default background texture config
1196 * to the helper.
1198 if (strcmp(entry->key, "WorkspaceSpecificBack") == 0 &&
1199 !scr->flags.backimage_helper_launched)
1200 update_workspace_back = 1;
1202 if (entry->update)
1203 needs_refresh |= (*entry->update) (scr, entry, tdata, entry->extra_data);
1209 if (needs_refresh != 0 && !scr->flags.startup) {
1210 int foo;
1212 foo = 0;
1213 if (needs_refresh & REFRESH_MENU_TITLE_TEXTURE)
1214 foo |= WTextureSettings;
1215 if (needs_refresh & REFRESH_MENU_TITLE_FONT)
1216 foo |= WFontSettings;
1217 if (needs_refresh & REFRESH_MENU_TITLE_COLOR)
1218 foo |= WColorSettings;
1219 if (foo)
1220 WMPostNotificationName(WNMenuTitleAppearanceSettingsChanged, NULL,
1221 (void *)(uintptr_t) foo);
1223 foo = 0;
1224 if (needs_refresh & REFRESH_MENU_TEXTURE)
1225 foo |= WTextureSettings;
1226 if (needs_refresh & REFRESH_MENU_FONT)
1227 foo |= WFontSettings;
1228 if (needs_refresh & REFRESH_MENU_COLOR)
1229 foo |= WColorSettings;
1230 if (foo)
1231 WMPostNotificationName(WNMenuAppearanceSettingsChanged, NULL, (void *)(uintptr_t) foo);
1233 foo = 0;
1234 if (needs_refresh & REFRESH_WINDOW_FONT)
1235 foo |= WFontSettings;
1236 if (needs_refresh & REFRESH_WINDOW_TEXTURES)
1237 foo |= WTextureSettings;
1238 if (needs_refresh & REFRESH_WINDOW_TITLE_COLOR)
1239 foo |= WColorSettings;
1240 if (foo)
1241 WMPostNotificationName(WNWindowAppearanceSettingsChanged, NULL, (void *)(uintptr_t) foo);
1243 if (!(needs_refresh & REFRESH_ICON_TILE)) {
1244 foo = 0;
1245 if (needs_refresh & REFRESH_ICON_FONT)
1246 foo |= WFontSettings;
1247 if (needs_refresh & REFRESH_ICON_TITLE_COLOR)
1248 foo |= WTextureSettings;
1249 if (needs_refresh & REFRESH_ICON_TITLE_BACK)
1250 foo |= WTextureSettings;
1251 if (foo)
1252 WMPostNotificationName(WNIconAppearanceSettingsChanged, NULL,
1253 (void *)(uintptr_t) foo);
1255 if (needs_refresh & REFRESH_ICON_TILE)
1256 WMPostNotificationName(WNIconTileSettingsChanged, NULL, NULL);
1258 if (needs_refresh & REFRESH_WORKSPACE_MENU) {
1259 if (scr->workspace_menu)
1260 wWorkspaceMenuUpdate(scr, scr->workspace_menu);
1261 if (scr->clip_ws_menu)
1262 wWorkspaceMenuUpdate(scr, scr->clip_ws_menu);
1263 if (scr->workspace_submenu)
1264 scr->workspace_submenu->flags.realized = 0;
1265 if (scr->clip_submenu)
1266 scr->clip_submenu->flags.realized = 0;
1271 void wDefaultUpdateIcons(WScreen *scr)
1273 WAppIcon *aicon = scr->app_icon_list;
1274 WDrawerChain *dc;
1275 WWindow *wwin = scr->focused_window;
1277 while (aicon) {
1278 /* Get the application icon, default included */
1279 wIconChangeImageFile(aicon->icon, NULL);
1280 wAppIconPaint(aicon);
1281 aicon = aicon->next;
1284 if (!wPreferences.flags.noclip || wPreferences.flags.clip_merged_in_dock)
1285 wClipIconPaint(scr->clip_icon);
1287 for (dc = scr->drawers; dc != NULL; dc = dc->next)
1288 wDrawerIconPaint(dc->adrawer->icon_array[0]);
1290 while (wwin) {
1291 if (wwin->icon && wwin->flags.miniaturized)
1292 wIconChangeImageFile(wwin->icon, NULL);
1293 wwin = wwin->prev;
1297 /* --------------------------- Local ----------------------- */
1299 #define GET_STRING_OR_DEFAULT(x, var) if (!WMIsPLString(value)) { \
1300 wwarning(_("Wrong option format for key \"%s\". Should be %s."), \
1301 entry->key, x); \
1302 wwarning(_("using default \"%s\" instead"), entry->default_value); \
1303 var = entry->default_value;\
1304 } else var = WMGetFromPLString(value)\
1307 static int string2index(WMPropList *key, WMPropList *val, const char *def, WOptionEnumeration * values)
1309 char *str;
1310 WOptionEnumeration *v;
1311 char buffer[TOTAL_VALUES_LENGTH];
1313 if (WMIsPLString(val) && (str = WMGetFromPLString(val))) {
1314 for (v = values; v->string != NULL; v++) {
1315 if (strcasecmp(v->string, str) == 0)
1316 return v->value;
1320 buffer[0] = 0;
1321 for (v = values; v->string != NULL; v++) {
1322 if (!v->is_alias) {
1323 if (buffer[0] != 0)
1324 strcat(buffer, ", ");
1325 snprintf(buffer+strlen(buffer),
1326 sizeof(buffer)-strlen(buffer)-1, "\"%s\"", v->string);
1329 wwarning(_("wrong option value for key \"%s\"; got \"%s\", should be one of %s."),
1330 WMGetFromPLString(key),
1331 WMIsPLString(val) ? WMGetFromPLString(val) : "(unknown)",
1332 buffer);
1334 if (def) {
1335 return string2index(key, val, NULL, values);
1338 return -1;
1342 * value - is the value in the defaults DB
1343 * addr - is the address to store the data
1344 * ret - is the address to store a pointer to a temporary buffer. ret
1345 * must not be freed and is used by the set functions
1347 static int getBool(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1349 static char data;
1350 const char *val;
1351 int second_pass = 0;
1353 /* Parameter not used, but tell the compiler that it is ok */
1354 (void) scr;
1356 GET_STRING_OR_DEFAULT("Boolean", val);
1358 again:
1359 if ((val[1] == '\0' && (val[0] == 'y' || val[0] == 'Y'))
1360 || strcasecmp(val, "YES") == 0) {
1362 data = 1;
1363 } else if ((val[1] == '\0' && (val[0] == 'n' || val[0] == 'N'))
1364 || strcasecmp(val, "NO") == 0) {
1365 data = 0;
1366 } else {
1367 int i;
1368 if (sscanf(val, "%i", &i) == 1) {
1369 if (i != 0)
1370 data = 1;
1371 else
1372 data = 0;
1373 } else {
1374 wwarning(_("can't convert \"%s\" to boolean for key \"%s\""), val, entry->key);
1375 if (second_pass == 0) {
1376 val = WMGetFromPLString(entry->plvalue);
1377 second_pass = 1;
1378 wwarning(_("using default \"%s\" instead"), val);
1379 goto again;
1381 return False;
1385 if (ret)
1386 *ret = &data;
1387 if (addr)
1388 *(char *)addr = data;
1390 return True;
1393 static int getInt(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1395 static int data;
1396 const char *val;
1398 /* Parameter not used, but tell the compiler that it is ok */
1399 (void) scr;
1401 GET_STRING_OR_DEFAULT("Integer", val);
1403 if (sscanf(val, "%i", &data) != 1) {
1404 wwarning(_("can't convert \"%s\" to integer for key \"%s\""), val, entry->key);
1405 val = WMGetFromPLString(entry->plvalue);
1406 wwarning(_("using default \"%s\" instead"), val);
1407 if (sscanf(val, "%i", &data) != 1) {
1408 return False;
1412 if (ret)
1413 *ret = &data;
1414 if (addr)
1415 *(int *)addr = data;
1417 return True;
1420 static int getCoord(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1422 static WCoord data;
1423 char *val_x, *val_y;
1424 int nelem, changed = 0;
1425 WMPropList *elem_x, *elem_y;
1427 again:
1428 if (!WMIsPLArray(value)) {
1429 wwarning(_("Wrong option format for key \"%s\". Should be %s."), entry->key, "Coordinate");
1430 if (changed == 0) {
1431 value = entry->plvalue;
1432 changed = 1;
1433 wwarning(_("using default \"%s\" instead"), entry->default_value);
1434 goto again;
1436 return False;
1439 nelem = WMGetPropListItemCount(value);
1440 if (nelem != 2) {
1441 wwarning(_("Incorrect number of elements in array for key \"%s\"."), entry->key);
1442 if (changed == 0) {
1443 value = entry->plvalue;
1444 changed = 1;
1445 wwarning(_("using default \"%s\" instead"), entry->default_value);
1446 goto again;
1448 return False;
1451 elem_x = WMGetFromPLArray(value, 0);
1452 elem_y = WMGetFromPLArray(value, 1);
1454 if (!elem_x || !elem_y || !WMIsPLString(elem_x) || !WMIsPLString(elem_y)) {
1455 wwarning(_("Wrong value for key \"%s\". Should be Coordinate."), entry->key);
1456 if (changed == 0) {
1457 value = entry->plvalue;
1458 changed = 1;
1459 wwarning(_("using default \"%s\" instead"), entry->default_value);
1460 goto again;
1462 return False;
1465 val_x = WMGetFromPLString(elem_x);
1466 val_y = WMGetFromPLString(elem_y);
1468 if (sscanf(val_x, "%i", &data.x) != 1 || sscanf(val_y, "%i", &data.y) != 1) {
1469 wwarning(_("can't convert array to integers for \"%s\"."), entry->key);
1470 if (changed == 0) {
1471 value = entry->plvalue;
1472 changed = 1;
1473 wwarning(_("using default \"%s\" instead"), entry->default_value);
1474 goto again;
1476 return False;
1479 if (data.x < 0)
1480 data.x = 0;
1481 else if (data.x > scr->scr_width / 3)
1482 data.x = scr->scr_width / 3;
1483 if (data.y < 0)
1484 data.y = 0;
1485 else if (data.y > scr->scr_height / 3)
1486 data.y = scr->scr_height / 3;
1488 if (ret)
1489 *ret = &data;
1490 if (addr)
1491 *(WCoord *) addr = data;
1493 return True;
1496 static int getPropList(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1498 /* Parameter not used, but tell the compiler that it is ok */
1499 (void) scr;
1500 (void) entry;
1501 (void) addr;
1503 WMRetainPropList(value);
1505 *ret = value;
1507 return True;
1510 static int getPathList(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1512 static char *data;
1513 int i, count, len;
1514 char *ptr;
1515 WMPropList *d;
1516 int changed = 0;
1518 /* Parameter not used, but tell the compiler that it is ok */
1519 (void) scr;
1520 (void) ret;
1522 again:
1523 if (!WMIsPLArray(value)) {
1524 wwarning(_("Wrong option format for key \"%s\". Should be %s."), entry->key, "an array of paths");
1525 if (changed == 0) {
1526 value = entry->plvalue;
1527 changed = 1;
1528 wwarning(_("using default \"%s\" instead"), entry->default_value);
1529 goto again;
1531 return False;
1534 i = 0;
1535 count = WMGetPropListItemCount(value);
1536 if (count < 1) {
1537 if (changed == 0) {
1538 value = entry->plvalue;
1539 changed = 1;
1540 wwarning(_("using default \"%s\" instead"), entry->default_value);
1541 goto again;
1543 return False;
1546 len = 0;
1547 for (i = 0; i < count; i++) {
1548 d = WMGetFromPLArray(value, i);
1549 if (!d || !WMIsPLString(d)) {
1550 count = i;
1551 break;
1553 len += strlen(WMGetFromPLString(d)) + 1;
1556 ptr = data = wmalloc(len + 1);
1558 for (i = 0; i < count; i++) {
1559 d = WMGetFromPLArray(value, i);
1560 if (!d || !WMIsPLString(d)) {
1561 break;
1563 strcpy(ptr, WMGetFromPLString(d));
1564 ptr += strlen(WMGetFromPLString(d));
1565 *ptr = ':';
1566 ptr++;
1568 ptr--;
1569 *(ptr--) = 0;
1571 if (*(char **)addr != NULL) {
1572 wfree(*(char **)addr);
1574 *(char **)addr = data;
1576 return True;
1579 static int getEnum(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1581 static signed char data;
1583 /* Parameter not used, but tell the compiler that it is ok */
1584 (void) scr;
1586 data = string2index(entry->plkey, value, entry->default_value, (WOptionEnumeration *) entry->extra_data);
1587 if (data < 0)
1588 return False;
1590 if (ret)
1591 *ret = &data;
1592 if (addr)
1593 *(signed char *)addr = data;
1595 return True;
1599 * (solid <color>)
1600 * (hgradient <color> <color>)
1601 * (vgradient <color> <color>)
1602 * (dgradient <color> <color>)
1603 * (mhgradient <color> <color> ...)
1604 * (mvgradient <color> <color> ...)
1605 * (mdgradient <color> <color> ...)
1606 * (igradient <color1> <color1> <thickness1> <color2> <color2> <thickness2>)
1607 * (tpixmap <file> <color>)
1608 * (spixmap <file> <color>)
1609 * (cpixmap <file> <color>)
1610 * (thgradient <file> <opaqueness> <color> <color>)
1611 * (tvgradient <file> <opaqueness> <color> <color>)
1612 * (tdgradient <file> <opaqueness> <color> <color>)
1613 * (function <lib> <function> ...)
1616 static WTexture *parse_texture(WScreen * scr, WMPropList * pl)
1618 WMPropList *elem;
1619 char *val;
1620 int nelem;
1621 WTexture *texture = NULL;
1623 nelem = WMGetPropListItemCount(pl);
1624 if (nelem < 1)
1625 return NULL;
1627 elem = WMGetFromPLArray(pl, 0);
1628 if (!elem || !WMIsPLString(elem))
1629 return NULL;
1630 val = WMGetFromPLString(elem);
1632 if (strcasecmp(val, "solid") == 0) {
1633 XColor color;
1635 if (nelem != 2)
1636 return NULL;
1638 /* get color */
1640 elem = WMGetFromPLArray(pl, 1);
1641 if (!elem || !WMIsPLString(elem))
1642 return NULL;
1643 val = WMGetFromPLString(elem);
1645 if (!XParseColor(dpy, scr->w_colormap, val, &color)) {
1646 wwarning(_("\"%s\" is not a valid color name"), val);
1647 return NULL;
1650 texture = (WTexture *) wTextureMakeSolid(scr, &color);
1651 } else if (strcasecmp(val, "dgradient") == 0
1652 || strcasecmp(val, "vgradient") == 0 || strcasecmp(val, "hgradient") == 0) {
1653 RColor color1, color2;
1654 XColor xcolor;
1655 int type;
1657 if (nelem != 3) {
1658 wwarning(_("bad number of arguments in gradient specification"));
1659 return NULL;
1662 if (val[0] == 'd' || val[0] == 'D')
1663 type = WTEX_DGRADIENT;
1664 else if (val[0] == 'h' || val[0] == 'H')
1665 type = WTEX_HGRADIENT;
1666 else
1667 type = WTEX_VGRADIENT;
1669 /* get from color */
1670 elem = WMGetFromPLArray(pl, 1);
1671 if (!elem || !WMIsPLString(elem))
1672 return NULL;
1673 val = WMGetFromPLString(elem);
1675 if (!XParseColor(dpy, scr->w_colormap, val, &xcolor)) {
1676 wwarning(_("\"%s\" is not a valid color name"), val);
1677 return NULL;
1679 color1.alpha = 255;
1680 color1.red = xcolor.red >> 8;
1681 color1.green = xcolor.green >> 8;
1682 color1.blue = xcolor.blue >> 8;
1684 /* get to color */
1685 elem = WMGetFromPLArray(pl, 2);
1686 if (!elem || !WMIsPLString(elem)) {
1687 return NULL;
1689 val = WMGetFromPLString(elem);
1691 if (!XParseColor(dpy, scr->w_colormap, val, &xcolor)) {
1692 wwarning(_("\"%s\" is not a valid color name"), val);
1693 return NULL;
1695 color2.alpha = 255;
1696 color2.red = xcolor.red >> 8;
1697 color2.green = xcolor.green >> 8;
1698 color2.blue = xcolor.blue >> 8;
1700 texture = (WTexture *) wTextureMakeGradient(scr, type, &color1, &color2);
1702 } else if (strcasecmp(val, "igradient") == 0) {
1703 RColor colors1[2], colors2[2];
1704 int th1, th2;
1705 XColor xcolor;
1706 int i;
1708 if (nelem != 7) {
1709 wwarning(_("bad number of arguments in gradient specification"));
1710 return NULL;
1713 /* get from color */
1714 for (i = 0; i < 2; i++) {
1715 elem = WMGetFromPLArray(pl, 1 + i);
1716 if (!elem || !WMIsPLString(elem))
1717 return NULL;
1718 val = WMGetFromPLString(elem);
1720 if (!XParseColor(dpy, scr->w_colormap, val, &xcolor)) {
1721 wwarning(_("\"%s\" is not a valid color name"), val);
1722 return NULL;
1724 colors1[i].alpha = 255;
1725 colors1[i].red = xcolor.red >> 8;
1726 colors1[i].green = xcolor.green >> 8;
1727 colors1[i].blue = xcolor.blue >> 8;
1729 elem = WMGetFromPLArray(pl, 3);
1730 if (!elem || !WMIsPLString(elem))
1731 return NULL;
1732 val = WMGetFromPLString(elem);
1733 th1 = atoi(val);
1735 /* get from color */
1736 for (i = 0; i < 2; i++) {
1737 elem = WMGetFromPLArray(pl, 4 + 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 colors2[i].alpha = 255;
1747 colors2[i].red = xcolor.red >> 8;
1748 colors2[i].green = xcolor.green >> 8;
1749 colors2[i].blue = xcolor.blue >> 8;
1751 elem = WMGetFromPLArray(pl, 6);
1752 if (!elem || !WMIsPLString(elem))
1753 return NULL;
1754 val = WMGetFromPLString(elem);
1755 th2 = atoi(val);
1757 texture = (WTexture *) wTextureMakeIGradient(scr, th1, colors1, th2, colors2);
1759 } else if (strcasecmp(val, "mhgradient") == 0
1760 || strcasecmp(val, "mvgradient") == 0 || strcasecmp(val, "mdgradient") == 0) {
1761 XColor color;
1762 RColor **colors;
1763 int i, count;
1764 int type;
1766 if (nelem < 3) {
1767 wwarning(_("too few arguments in multicolor gradient specification"));
1768 return NULL;
1771 if (val[1] == 'h' || val[1] == 'H')
1772 type = WTEX_MHGRADIENT;
1773 else if (val[1] == 'v' || val[1] == 'V')
1774 type = WTEX_MVGRADIENT;
1775 else
1776 type = WTEX_MDGRADIENT;
1778 count = nelem - 1;
1780 colors = wmalloc(sizeof(RColor *) * (count + 1));
1782 for (i = 0; i < count; i++) {
1783 elem = WMGetFromPLArray(pl, i + 1);
1784 if (!elem || !WMIsPLString(elem)) {
1785 for (--i; i >= 0; --i) {
1786 wfree(colors[i]);
1788 wfree(colors);
1789 return NULL;
1791 val = WMGetFromPLString(elem);
1793 if (!XParseColor(dpy, scr->w_colormap, val, &color)) {
1794 wwarning(_("\"%s\" is not a valid color name"), val);
1795 for (--i; i >= 0; --i) {
1796 wfree(colors[i]);
1798 wfree(colors);
1799 return NULL;
1800 } else {
1801 colors[i] = wmalloc(sizeof(RColor));
1802 colors[i]->red = color.red >> 8;
1803 colors[i]->green = color.green >> 8;
1804 colors[i]->blue = color.blue >> 8;
1807 colors[i] = NULL;
1809 texture = (WTexture *) wTextureMakeMGradient(scr, type, colors);
1810 } else if (strcasecmp(val, "spixmap") == 0 ||
1811 strcasecmp(val, "cpixmap") == 0 || strcasecmp(val, "tpixmap") == 0) {
1812 XColor color;
1813 int type;
1815 if (nelem != 3)
1816 return NULL;
1818 if (val[0] == 's' || val[0] == 'S')
1819 type = WTP_SCALE;
1820 else if (val[0] == 'c' || val[0] == 'C')
1821 type = WTP_CENTER;
1822 else
1823 type = WTP_TILE;
1825 /* get color */
1826 elem = WMGetFromPLArray(pl, 2);
1827 if (!elem || !WMIsPLString(elem)) {
1828 return NULL;
1830 val = WMGetFromPLString(elem);
1832 if (!XParseColor(dpy, scr->w_colormap, val, &color)) {
1833 wwarning(_("\"%s\" is not a valid color name"), val);
1834 return NULL;
1837 /* file name */
1838 elem = WMGetFromPLArray(pl, 1);
1839 if (!elem || !WMIsPLString(elem))
1840 return NULL;
1841 val = WMGetFromPLString(elem);
1843 texture = (WTexture *) wTextureMakePixmap(scr, type, val, &color);
1844 } else if (strcasecmp(val, "thgradient") == 0
1845 || strcasecmp(val, "tvgradient") == 0 || strcasecmp(val, "tdgradient") == 0) {
1846 RColor color1, color2;
1847 XColor xcolor;
1848 int opacity;
1849 int style;
1851 if (val[1] == 'h' || val[1] == 'H')
1852 style = WTEX_THGRADIENT;
1853 else if (val[1] == 'v' || val[1] == 'V')
1854 style = WTEX_TVGRADIENT;
1855 else
1856 style = WTEX_TDGRADIENT;
1858 if (nelem != 5) {
1859 wwarning(_("bad number of arguments in textured gradient specification"));
1860 return NULL;
1863 /* get from color */
1864 elem = WMGetFromPLArray(pl, 3);
1865 if (!elem || !WMIsPLString(elem))
1866 return NULL;
1867 val = WMGetFromPLString(elem);
1869 if (!XParseColor(dpy, scr->w_colormap, val, &xcolor)) {
1870 wwarning(_("\"%s\" is not a valid color name"), val);
1871 return NULL;
1873 color1.alpha = 255;
1874 color1.red = xcolor.red >> 8;
1875 color1.green = xcolor.green >> 8;
1876 color1.blue = xcolor.blue >> 8;
1878 /* get to color */
1879 elem = WMGetFromPLArray(pl, 4);
1880 if (!elem || !WMIsPLString(elem)) {
1881 return NULL;
1883 val = WMGetFromPLString(elem);
1885 if (!XParseColor(dpy, scr->w_colormap, val, &xcolor)) {
1886 wwarning(_("\"%s\" is not a valid color name"), val);
1887 return NULL;
1889 color2.alpha = 255;
1890 color2.red = xcolor.red >> 8;
1891 color2.green = xcolor.green >> 8;
1892 color2.blue = xcolor.blue >> 8;
1894 /* get opacity */
1895 elem = WMGetFromPLArray(pl, 2);
1896 if (!elem || !WMIsPLString(elem))
1897 opacity = 128;
1898 else
1899 val = WMGetFromPLString(elem);
1901 if (!val || (opacity = atoi(val)) < 0 || opacity > 255) {
1902 wwarning(_("bad opacity value for tgradient texture \"%s\". Should be [0..255]"), val);
1903 opacity = 128;
1906 /* get file name */
1907 elem = WMGetFromPLArray(pl, 1);
1908 if (!elem || !WMIsPLString(elem))
1909 return NULL;
1910 val = WMGetFromPLString(elem);
1912 texture = (WTexture *) wTextureMakeTGradient(scr, style, &color1, &color2, val, opacity);
1913 } else if (strcasecmp(val, "function") == 0) {
1914 /* Leave this in to handle the unlikely case of
1915 * someone actually having function textures configured */
1916 wwarning("function texture support has been removed");
1917 return NULL;
1918 } else {
1919 wwarning(_("invalid texture type %s"), val);
1920 return NULL;
1922 return texture;
1925 static int getTexture(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1927 static WTexture *texture;
1928 int changed = 0;
1930 again:
1931 if (!WMIsPLArray(value)) {
1932 wwarning(_("Wrong option format for key \"%s\". Should be %s."), entry->key, "Texture");
1933 if (changed == 0) {
1934 value = entry->plvalue;
1935 changed = 1;
1936 wwarning(_("using default \"%s\" instead"), entry->default_value);
1937 goto again;
1939 return False;
1942 if (strcmp(entry->key, "WidgetColor") == 0 && !changed) {
1943 WMPropList *pl;
1945 pl = WMGetFromPLArray(value, 0);
1946 if (!pl || !WMIsPLString(pl) || !WMGetFromPLString(pl)
1947 || strcasecmp(WMGetFromPLString(pl), "solid") != 0) {
1948 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1949 entry->key, "Solid Texture");
1951 value = entry->plvalue;
1952 changed = 1;
1953 wwarning(_("using default \"%s\" instead"), entry->default_value);
1954 goto again;
1958 texture = parse_texture(scr, value);
1960 if (!texture) {
1961 wwarning(_("Error in texture specification for key \"%s\""), entry->key);
1962 if (changed == 0) {
1963 value = entry->plvalue;
1964 changed = 1;
1965 wwarning(_("using default \"%s\" instead"), entry->default_value);
1966 goto again;
1968 return False;
1971 if (ret)
1972 *ret = &texture;
1974 if (addr)
1975 *(WTexture **) addr = texture;
1977 return True;
1980 static int getWSBackground(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1982 WMPropList *elem;
1983 int changed = 0;
1984 char *val;
1985 int nelem;
1987 /* Parameter not used, but tell the compiler that it is ok */
1988 (void) scr;
1989 (void) addr;
1991 again:
1992 if (!WMIsPLArray(value)) {
1993 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1994 "WorkspaceBack", "Texture or None");
1995 if (changed == 0) {
1996 value = entry->plvalue;
1997 changed = 1;
1998 wwarning(_("using default \"%s\" instead"), entry->default_value);
1999 goto again;
2001 return False;
2004 /* only do basic error checking and verify for None texture */
2006 nelem = WMGetPropListItemCount(value);
2007 if (nelem > 0) {
2008 elem = WMGetFromPLArray(value, 0);
2009 if (!elem || !WMIsPLString(elem)) {
2010 wwarning(_("Wrong type for workspace background. Should be a texture type."));
2011 if (changed == 0) {
2012 value = entry->plvalue;
2013 changed = 1;
2014 wwarning(_("using default \"%s\" instead"), entry->default_value);
2015 goto again;
2017 return False;
2019 val = WMGetFromPLString(elem);
2021 if (strcasecmp(val, "None") == 0)
2022 return True;
2024 *ret = WMRetainPropList(value);
2026 return True;
2029 static int
2030 getWSSpecificBackground(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
2032 WMPropList *elem;
2033 int nelem;
2034 int changed = 0;
2036 /* Parameter not used, but tell the compiler that it is ok */
2037 (void) scr;
2038 (void) addr;
2040 again:
2041 if (!WMIsPLArray(value)) {
2042 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
2043 "WorkspaceSpecificBack", "an array of textures");
2044 if (changed == 0) {
2045 value = entry->plvalue;
2046 changed = 1;
2047 wwarning(_("using default \"%s\" instead"), entry->default_value);
2048 goto again;
2050 return False;
2053 /* only do basic error checking and verify for None texture */
2055 nelem = WMGetPropListItemCount(value);
2056 if (nelem > 0) {
2057 while (nelem--) {
2058 elem = WMGetFromPLArray(value, nelem);
2059 if (!elem || !WMIsPLArray(elem)) {
2060 wwarning(_("Wrong type for background of workspace %i. Should be a texture."),
2061 nelem);
2066 *ret = WMRetainPropList(value);
2068 #ifdef notworking
2070 * Kluge to force wmsetbg helper to set the default background.
2071 * If the WorkspaceSpecificBack is changed once wmaker has started,
2072 * the WorkspaceBack won't be sent to the helper, unless the user
2073 * changes it's value too. So, we must force this by removing the
2074 * value from the defaults DB.
2076 if (!scr->flags.backimage_helper_launched && !scr->flags.startup) {
2077 WMPropList *key = WMCreatePLString("WorkspaceBack");
2079 WMRemoveFromPLDictionary(w_global.domain.wmaker->dictionary, key);
2081 WMReleasePropList(key);
2083 #endif
2084 return True;
2087 static int getFont(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
2089 static WMFont *font;
2090 const char *val;
2092 (void) addr;
2094 GET_STRING_OR_DEFAULT("Font", val);
2096 font = WMCreateFont(scr->wmscreen, val);
2097 if (!font)
2098 font = WMCreateFont(scr->wmscreen, "fixed");
2100 if (!font) {
2101 wfatal(_("could not load any usable font!!!"));
2102 exit(1);
2105 if (ret)
2106 *ret = font;
2108 /* can't assign font value outside update function */
2109 wassertrv(addr == NULL, True);
2111 return True;
2114 static int getColor(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
2116 static XColor color;
2117 const char *val;
2118 int second_pass = 0;
2120 (void) addr;
2122 GET_STRING_OR_DEFAULT("Color", val);
2124 again:
2125 if (!wGetColor(scr, val, &color)) {
2126 wwarning(_("could not get color for key \"%s\""), entry->key);
2127 if (second_pass == 0) {
2128 val = WMGetFromPLString(entry->plvalue);
2129 second_pass = 1;
2130 wwarning(_("using default \"%s\" instead"), val);
2131 goto again;
2133 return False;
2136 if (ret)
2137 *ret = &color;
2139 assert(addr == NULL);
2141 if (addr)
2142 *(unsigned long*)addr = pixel;
2145 return True;
2148 static int getKeybind(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
2150 static WShortKey shortcut;
2151 KeySym ksym;
2152 const char *val;
2153 char *k;
2154 char buf[MAX_SHORTCUT_LENGTH], *b;
2156 /* Parameter not used, but tell the compiler that it is ok */
2157 (void) scr;
2158 (void) addr;
2160 GET_STRING_OR_DEFAULT("Key spec", val);
2162 if (!val || strcasecmp(val, "NONE") == 0) {
2163 shortcut.keycode = 0;
2164 shortcut.modifier = 0;
2165 if (ret)
2166 *ret = &shortcut;
2167 return True;
2170 wstrlcpy(buf, val, MAX_SHORTCUT_LENGTH);
2172 b = (char *)buf;
2174 /* get modifiers */
2175 shortcut.modifier = 0;
2176 while ((k = strchr(b, '+')) != NULL) {
2177 int mod;
2179 *k = 0;
2180 mod = wXModifierFromKey(b);
2181 if (mod < 0) {
2182 wwarning(_("%s: invalid key modifier \"%s\""), entry->key, b);
2183 return False;
2185 shortcut.modifier |= mod;
2187 b = k + 1;
2190 /* get key */
2191 ksym = XStringToKeysym(b);
2193 if (ksym == NoSymbol) {
2194 wwarning(_("%s:invalid kbd shortcut specification \"%s\""), entry->key, val);
2195 return False;
2198 shortcut.keycode = XKeysymToKeycode(dpy, ksym);
2199 if (shortcut.keycode == 0) {
2200 wwarning(_("%s:invalid key in shortcut \"%s\""), entry->key, val);
2201 return False;
2204 if (ret)
2205 *ret = &shortcut;
2207 return True;
2210 static int getModMask(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
2212 static int mask;
2213 const char *str;
2215 /* Parameter not used, but tell the compiler that it is ok */
2216 (void) scr;
2218 GET_STRING_OR_DEFAULT("Modifier Key", str);
2220 if (!str)
2221 return False;
2223 mask = wXModifierFromKey(str);
2224 if (mask < 0) {
2225 wwarning(_("%s: modifier key %s is not valid"), entry->key, str);
2226 mask = 0;
2227 return False;
2230 if (addr)
2231 *(int *)addr = mask;
2233 if (ret)
2234 *ret = &mask;
2236 return True;
2239 # include <X11/cursorfont.h>
2240 typedef struct {
2241 const char *name;
2242 int id;
2243 } WCursorLookup;
2245 #define CURSOR_ID_NONE (XC_num_glyphs)
2247 static const WCursorLookup cursor_table[] = {
2248 {"X_cursor", XC_X_cursor},
2249 {"arrow", XC_arrow},
2250 {"based_arrow_down", XC_based_arrow_down},
2251 {"based_arrow_up", XC_based_arrow_up},
2252 {"boat", XC_boat},
2253 {"bogosity", XC_bogosity},
2254 {"bottom_left_corner", XC_bottom_left_corner},
2255 {"bottom_right_corner", XC_bottom_right_corner},
2256 {"bottom_side", XC_bottom_side},
2257 {"bottom_tee", XC_bottom_tee},
2258 {"box_spiral", XC_box_spiral},
2259 {"center_ptr", XC_center_ptr},
2260 {"circle", XC_circle},
2261 {"clock", XC_clock},
2262 {"coffee_mug", XC_coffee_mug},
2263 {"cross", XC_cross},
2264 {"cross_reverse", XC_cross_reverse},
2265 {"crosshair", XC_crosshair},
2266 {"diamond_cross", XC_diamond_cross},
2267 {"dot", XC_dot},
2268 {"dotbox", XC_dotbox},
2269 {"double_arrow", XC_double_arrow},
2270 {"draft_large", XC_draft_large},
2271 {"draft_small", XC_draft_small},
2272 {"draped_box", XC_draped_box},
2273 {"exchange", XC_exchange},
2274 {"fleur", XC_fleur},
2275 {"gobbler", XC_gobbler},
2276 {"gumby", XC_gumby},
2277 {"hand1", XC_hand1},
2278 {"hand2", XC_hand2},
2279 {"heart", XC_heart},
2280 {"icon", XC_icon},
2281 {"iron_cross", XC_iron_cross},
2282 {"left_ptr", XC_left_ptr},
2283 {"left_side", XC_left_side},
2284 {"left_tee", XC_left_tee},
2285 {"leftbutton", XC_leftbutton},
2286 {"ll_angle", XC_ll_angle},
2287 {"lr_angle", XC_lr_angle},
2288 {"man", XC_man},
2289 {"middlebutton", XC_middlebutton},
2290 {"mouse", XC_mouse},
2291 {"pencil", XC_pencil},
2292 {"pirate", XC_pirate},
2293 {"plus", XC_plus},
2294 {"question_arrow", XC_question_arrow},
2295 {"right_ptr", XC_right_ptr},
2296 {"right_side", XC_right_side},
2297 {"right_tee", XC_right_tee},
2298 {"rightbutton", XC_rightbutton},
2299 {"rtl_logo", XC_rtl_logo},
2300 {"sailboat", XC_sailboat},
2301 {"sb_down_arrow", XC_sb_down_arrow},
2302 {"sb_h_double_arrow", XC_sb_h_double_arrow},
2303 {"sb_left_arrow", XC_sb_left_arrow},
2304 {"sb_right_arrow", XC_sb_right_arrow},
2305 {"sb_up_arrow", XC_sb_up_arrow},
2306 {"sb_v_double_arrow", XC_sb_v_double_arrow},
2307 {"shuttle", XC_shuttle},
2308 {"sizing", XC_sizing},
2309 {"spider", XC_spider},
2310 {"spraycan", XC_spraycan},
2311 {"star", XC_star},
2312 {"target", XC_target},
2313 {"tcross", XC_tcross},
2314 {"top_left_arrow", XC_top_left_arrow},
2315 {"top_left_corner", XC_top_left_corner},
2316 {"top_right_corner", XC_top_right_corner},
2317 {"top_side", XC_top_side},
2318 {"top_tee", XC_top_tee},
2319 {"trek", XC_trek},
2320 {"ul_angle", XC_ul_angle},
2321 {"umbrella", XC_umbrella},
2322 {"ur_angle", XC_ur_angle},
2323 {"watch", XC_watch},
2324 {"xterm", XC_xterm},
2325 {NULL, CURSOR_ID_NONE}
2328 static void check_bitmap_status(int status, const char *filename, Pixmap bitmap)
2330 switch (status) {
2331 case BitmapOpenFailed:
2332 wwarning(_("failed to open bitmap file \"%s\""), filename);
2333 break;
2334 case BitmapFileInvalid:
2335 wwarning(_("\"%s\" is not a valid bitmap file"), filename);
2336 break;
2337 case BitmapNoMemory:
2338 wwarning(_("out of memory reading bitmap file \"%s\""), filename);
2339 break;
2340 case BitmapSuccess:
2341 XFreePixmap(dpy, bitmap);
2342 break;
2347 * (none)
2348 * (builtin, <cursor_name>)
2349 * (bitmap, <cursor_bitmap>, <cursor_mask>)
2351 static int parse_cursor(WScreen * scr, WMPropList * pl, Cursor * cursor)
2353 WMPropList *elem;
2354 char *val;
2355 int nelem;
2356 int status = 0;
2358 nelem = WMGetPropListItemCount(pl);
2359 if (nelem < 1) {
2360 return (status);
2362 elem = WMGetFromPLArray(pl, 0);
2363 if (!elem || !WMIsPLString(elem)) {
2364 return (status);
2366 val = WMGetFromPLString(elem);
2368 if (strcasecmp(val, "none") == 0) {
2369 status = 1;
2370 *cursor = None;
2371 } else if (strcasecmp(val, "builtin") == 0) {
2372 int i;
2373 int cursor_id = CURSOR_ID_NONE;
2375 if (nelem != 2) {
2376 wwarning(_("bad number of arguments in cursor specification"));
2377 return (status);
2379 elem = WMGetFromPLArray(pl, 1);
2380 if (!elem || !WMIsPLString(elem)) {
2381 return (status);
2383 val = WMGetFromPLString(elem);
2385 for (i = 0; cursor_table[i].name != NULL; i++) {
2386 if (strcasecmp(val, cursor_table[i].name) == 0) {
2387 cursor_id = cursor_table[i].id;
2388 break;
2391 if (CURSOR_ID_NONE == cursor_id) {
2392 wwarning(_("unknown builtin cursor name \"%s\""), val);
2393 } else {
2394 *cursor = XCreateFontCursor(dpy, cursor_id);
2395 status = 1;
2397 } else if (strcasecmp(val, "bitmap") == 0) {
2398 char *bitmap_name;
2399 char *mask_name;
2400 int bitmap_status;
2401 int mask_status;
2402 Pixmap bitmap;
2403 Pixmap mask;
2404 unsigned int w, h;
2405 int x, y;
2406 XColor fg, bg;
2408 if (nelem != 3) {
2409 wwarning(_("bad number of arguments in cursor specification"));
2410 return (status);
2412 elem = WMGetFromPLArray(pl, 1);
2413 if (!elem || !WMIsPLString(elem)) {
2414 return (status);
2416 val = WMGetFromPLString(elem);
2417 bitmap_name = FindImage(wPreferences.pixmap_path, val);
2418 if (!bitmap_name) {
2419 wwarning(_("could not find cursor bitmap file \"%s\""), val);
2420 return (status);
2422 elem = WMGetFromPLArray(pl, 2);
2423 if (!elem || !WMIsPLString(elem)) {
2424 wfree(bitmap_name);
2425 return (status);
2427 val = WMGetFromPLString(elem);
2428 mask_name = FindImage(wPreferences.pixmap_path, val);
2429 if (!mask_name) {
2430 wfree(bitmap_name);
2431 wwarning(_("could not find cursor bitmap file \"%s\""), val);
2432 return (status);
2434 mask_status = XReadBitmapFile(dpy, scr->w_win, mask_name, &w, &h, &mask, &x, &y);
2435 bitmap_status = XReadBitmapFile(dpy, scr->w_win, bitmap_name, &w, &h, &bitmap, &x, &y);
2436 if ((BitmapSuccess == bitmap_status) && (BitmapSuccess == mask_status)) {
2437 fg.pixel = scr->black_pixel;
2438 bg.pixel = scr->white_pixel;
2439 XQueryColor(dpy, scr->w_colormap, &fg);
2440 XQueryColor(dpy, scr->w_colormap, &bg);
2441 *cursor = XCreatePixmapCursor(dpy, bitmap, mask, &fg, &bg, x, y);
2442 status = 1;
2444 check_bitmap_status(bitmap_status, bitmap_name, bitmap);
2445 check_bitmap_status(mask_status, mask_name, mask);
2446 wfree(bitmap_name);
2447 wfree(mask_name);
2449 return (status);
2452 static int getCursor(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
2454 static Cursor cursor;
2455 int status;
2456 int changed = 0;
2458 again:
2459 if (!WMIsPLArray(value)) {
2460 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
2461 entry->key, "cursor specification");
2462 if (!changed) {
2463 value = entry->plvalue;
2464 changed = 1;
2465 wwarning(_("using default \"%s\" instead"), entry->default_value);
2466 goto again;
2468 return (False);
2470 status = parse_cursor(scr, value, &cursor);
2471 if (!status) {
2472 wwarning(_("Error in cursor specification for key \"%s\""), entry->key);
2473 if (!changed) {
2474 value = entry->plvalue;
2475 changed = 1;
2476 wwarning(_("using default \"%s\" instead"), entry->default_value);
2477 goto again;
2479 return (False);
2481 if (ret) {
2482 *ret = &cursor;
2484 if (addr) {
2485 *(Cursor *) addr = cursor;
2487 return (True);
2490 #undef CURSOR_ID_NONE
2492 /* ---------------- value setting functions --------------- */
2493 static int setJustify(WScreen * scr, WDefaultEntry * entry, void *tdata, void *extra_data)
2495 /* Parameter not used, but tell the compiler that it is ok */
2496 (void) scr;
2497 (void) entry;
2498 (void) tdata;
2499 (void) extra_data;
2501 return REFRESH_WINDOW_TITLE_COLOR;
2504 static int setClearance(WScreen * scr, WDefaultEntry * entry, void *bar, void *foo)
2506 /* Parameter not used, but tell the compiler that it is ok */
2507 (void) scr;
2508 (void) entry;
2509 (void) bar;
2510 (void) foo;
2512 return REFRESH_WINDOW_FONT | REFRESH_BUTTON_IMAGES | REFRESH_MENU_TITLE_FONT | REFRESH_MENU_FONT;
2515 static int setIfDockPresent(WScreen * scr, WDefaultEntry * entry, void *tdata, void *extra_data)
2517 char *flag = tdata;
2518 long which = (long) extra_data;
2520 /* Parameter not used, but tell the compiler that it is ok */
2521 (void) scr;
2522 (void) entry;
2524 switch (which) {
2525 case WM_DOCK:
2526 wPreferences.flags.nodock = wPreferences.flags.nodock || *flag;
2527 // Drawers require the dock
2528 wPreferences.flags.nodrawer = wPreferences.flags.nodrawer || wPreferences.flags.nodock;
2529 break;
2530 case WM_CLIP:
2531 wPreferences.flags.noclip = wPreferences.flags.noclip || *flag;
2532 break;
2533 case WM_DRAWER:
2534 wPreferences.flags.nodrawer = wPreferences.flags.nodrawer || *flag;
2535 break;
2536 default:
2537 break;
2539 return 0;
2542 static int setClipMergedInDock(WScreen *scr, WDefaultEntry *entry, void *tdata, void *foo)
2544 char *flag = tdata;
2546 /* Parameter not used, but tell the compiler that it is ok */
2547 (void) scr;
2548 (void) entry;
2549 (void) foo;
2551 wPreferences.flags.clip_merged_in_dock = *flag;
2552 wPreferences.flags.noclip = wPreferences.flags.noclip || *flag;
2553 return 0;
2556 static int setWrapAppiconsInDock(WScreen *scr, WDefaultEntry *entry, void *tdata, void *foo)
2558 char *flag = tdata;
2560 /* Parameter not used, but tell the compiler that it is ok */
2561 (void) scr;
2562 (void) entry;
2563 (void) foo;
2565 wPreferences.flags.wrap_appicons_in_dock = *flag;
2566 return 0;
2569 static int setStickyIcons(WScreen * scr, WDefaultEntry * entry, void *bar, void *foo)
2571 /* Parameter not used, but tell the compiler that it is ok */
2572 (void) entry;
2573 (void) bar;
2574 (void) foo;
2576 if (scr->workspaces) {
2577 wWorkspaceForceChange(scr, scr->current_workspace);
2578 wArrangeIcons(scr, False);
2580 return 0;
2583 static int setIconTile(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2585 Pixmap pixmap;
2586 RImage *img;
2587 WTexture ** texture = tdata;
2588 int reset = 0;
2590 /* Parameter not used, but tell the compiler that it is ok */
2591 (void) foo;
2593 img = wTextureRenderImage(*texture, wPreferences.icon_size,
2594 wPreferences.icon_size, ((*texture)->any.type & WREL_BORDER_MASK)
2595 ? WREL_ICON : WREL_FLAT);
2596 if (!img) {
2597 wwarning(_("could not render texture for icon background"));
2598 if (!entry->addr)
2599 wTextureDestroy(scr, *texture);
2600 return 0;
2602 RConvertImage(scr->rcontext, img, &pixmap);
2604 if (scr->icon_tile) {
2605 reset = 1;
2606 RReleaseImage(scr->icon_tile);
2607 XFreePixmap(dpy, scr->icon_tile_pixmap);
2610 scr->icon_tile = img;
2612 /* put the icon in the noticeboard hint */
2613 PropSetIconTileHint(scr, img);
2615 if (!wPreferences.flags.noclip || wPreferences.flags.clip_merged_in_dock) {
2616 if (scr->clip_tile) {
2617 RReleaseImage(scr->clip_tile);
2619 scr->clip_tile = wClipMakeTile(img);
2622 if (!wPreferences.flags.nodrawer) {
2623 if (scr->drawer_tile) {
2624 RReleaseImage(scr->drawer_tile);
2626 scr->drawer_tile = wDrawerMakeTile(scr, img);
2629 scr->icon_tile_pixmap = pixmap;
2631 if (scr->def_icon_rimage) {
2632 RReleaseImage(scr->def_icon_rimage);
2633 scr->def_icon_rimage = NULL;
2636 if (scr->icon_back_texture)
2637 wTextureDestroy(scr, (WTexture *) scr->icon_back_texture);
2639 scr->icon_back_texture = wTextureMakeSolid(scr, &((*texture)->any.color));
2641 /* Free the texture as nobody else will use it, nor refer to it. */
2642 if (!entry->addr)
2643 wTextureDestroy(scr, *texture);
2645 return (reset ? REFRESH_ICON_TILE : 0);
2648 static int setWinTitleFont(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2650 WMFont *font = tdata;
2652 /* Parameter not used, but tell the compiler that it is ok */
2653 (void) entry;
2654 (void) foo;
2656 if (scr->title_font) {
2657 WMReleaseFont(scr->title_font);
2659 scr->title_font = font;
2661 return REFRESH_WINDOW_FONT | REFRESH_BUTTON_IMAGES;
2664 static int setMenuTitleFont(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2666 WMFont *font = tdata;
2668 /* Parameter not used, but tell the compiler that it is ok */
2669 (void) entry;
2670 (void) foo;
2672 if (scr->menu_title_font) {
2673 WMReleaseFont(scr->menu_title_font);
2676 scr->menu_title_font = font;
2678 return REFRESH_MENU_TITLE_FONT;
2681 static int setMenuTextFont(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2683 WMFont *font = tdata;
2685 /* Parameter not used, but tell the compiler that it is ok */
2686 (void) entry;
2687 (void) foo;
2689 if (scr->menu_entry_font) {
2690 WMReleaseFont(scr->menu_entry_font);
2692 scr->menu_entry_font = font;
2694 return REFRESH_MENU_FONT;
2697 static int setIconTitleFont(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2699 WMFont *font = tdata;
2701 /* Parameter not used, but tell the compiler that it is ok */
2702 (void) entry;
2703 (void) foo;
2705 if (scr->icon_title_font) {
2706 WMReleaseFont(scr->icon_title_font);
2709 scr->icon_title_font = font;
2711 return REFRESH_ICON_FONT;
2714 static int setClipTitleFont(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2716 WMFont *font = tdata;
2718 /* Parameter not used, but tell the compiler that it is ok */
2719 (void) entry;
2720 (void) foo;
2722 if (scr->clip_title_font) {
2723 WMReleaseFont(scr->clip_title_font);
2726 scr->clip_title_font = font;
2728 return REFRESH_ICON_FONT;
2731 static int setLargeDisplayFont(WScreen *scr, WDefaultEntry *entry, void *tdata, void *foo)
2733 WMFont *font = tdata;
2735 /* Parameter not used, but tell the compiler that it is ok */
2736 (void) scr;
2737 (void) entry;
2738 (void) foo;
2740 if (scr->workspace_name_font)
2741 WMReleaseFont(scr->workspace_name_font);
2743 scr->workspace_name_font = font;
2745 return 0;
2748 static int setHightlight(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2750 XColor *color = tdata;
2752 /* Parameter not used, but tell the compiler that it is ok */
2753 (void) entry;
2754 (void) foo;
2756 if (scr->select_color)
2757 WMReleaseColor(scr->select_color);
2759 scr->select_color = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2761 wFreeColor(scr, color->pixel);
2763 return REFRESH_MENU_COLOR;
2766 static int setHightlightText(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2768 XColor *color = tdata;
2770 /* Parameter not used, but tell the compiler that it is ok */
2771 (void) entry;
2772 (void) foo;
2774 if (scr->select_text_color)
2775 WMReleaseColor(scr->select_text_color);
2777 scr->select_text_color = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2779 wFreeColor(scr, color->pixel);
2781 return REFRESH_MENU_COLOR;
2784 static int setClipTitleColor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *extra_data)
2786 XColor *color = tdata;
2787 long widx = (long) extra_data;
2789 /* Parameter not used, but tell the compiler that it is ok */
2790 (void) entry;
2792 if (scr->clip_title_color[widx])
2793 WMReleaseColor(scr->clip_title_color[widx]);
2795 scr->clip_title_color[widx] = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2796 wFreeColor(scr, color->pixel);
2798 return REFRESH_ICON_TITLE_COLOR;
2801 static int setWTitleColor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *extra_data)
2803 XColor *color = tdata;
2804 long widx = (long) extra_data;
2806 /* Parameter not used, but tell the compiler that it is ok */
2807 (void) entry;
2809 if (scr->window_title_color[widx])
2810 WMReleaseColor(scr->window_title_color[widx]);
2812 scr->window_title_color[widx] =
2813 WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2815 wFreeColor(scr, color->pixel);
2817 return REFRESH_WINDOW_TITLE_COLOR;
2820 static int setMenuTitleColor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *extra_data)
2822 XColor *color = tdata;
2824 /* Parameter not used, but tell the compiler that it is ok */
2825 (void) entry;
2826 (void) extra_data;
2828 if (scr->menu_title_color[0])
2829 WMReleaseColor(scr->menu_title_color[0]);
2831 scr->menu_title_color[0] = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2833 wFreeColor(scr, color->pixel);
2835 return REFRESH_MENU_TITLE_COLOR;
2838 static int setMenuTextColor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2840 XColor *color = tdata;
2842 /* Parameter not used, but tell the compiler that it is ok */
2843 (void) entry;
2844 (void) foo;
2846 if (scr->mtext_color)
2847 WMReleaseColor(scr->mtext_color);
2849 scr->mtext_color = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2851 if (WMColorPixel(scr->dtext_color) == WMColorPixel(scr->mtext_color)) {
2852 WMSetColorAlpha(scr->dtext_color, 0x7fff);
2853 } else {
2854 WMSetColorAlpha(scr->dtext_color, 0xffff);
2857 wFreeColor(scr, color->pixel);
2859 return REFRESH_MENU_COLOR;
2862 static int setMenuDisabledColor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2864 XColor *color = tdata;
2866 /* Parameter not used, but tell the compiler that it is ok */
2867 (void) entry;
2868 (void) foo;
2870 if (scr->dtext_color)
2871 WMReleaseColor(scr->dtext_color);
2873 scr->dtext_color = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2875 if (WMColorPixel(scr->dtext_color) == WMColorPixel(scr->mtext_color)) {
2876 WMSetColorAlpha(scr->dtext_color, 0x7fff);
2877 } else {
2878 WMSetColorAlpha(scr->dtext_color, 0xffff);
2881 wFreeColor(scr, color->pixel);
2883 return REFRESH_MENU_COLOR;
2886 static int setIconTitleColor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2888 XColor *color = tdata;
2890 /* Parameter not used, but tell the compiler that it is ok */
2891 (void) entry;
2892 (void) foo;
2894 if (scr->icon_title_color)
2895 WMReleaseColor(scr->icon_title_color);
2896 scr->icon_title_color = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2898 wFreeColor(scr, color->pixel);
2900 return REFRESH_ICON_TITLE_COLOR;
2903 static int setIconTitleBack(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2905 XColor *color = tdata;
2907 /* Parameter not used, but tell the compiler that it is ok */
2908 (void) entry;
2909 (void) foo;
2911 if (scr->icon_title_texture) {
2912 wTextureDestroy(scr, (WTexture *) scr->icon_title_texture);
2914 scr->icon_title_texture = wTextureMakeSolid(scr, color);
2916 return REFRESH_ICON_TITLE_BACK;
2919 static int setFrameBorderWidth(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2921 int *value = tdata;
2923 /* Parameter not used, but tell the compiler that it is ok */
2924 (void) entry;
2925 (void) foo;
2927 scr->frame_border_width = *value;
2929 return REFRESH_FRAME_BORDER;
2932 static int setFrameBorderColor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2934 XColor *color = tdata;
2936 /* Parameter not used, but tell the compiler that it is ok */
2937 (void) entry;
2938 (void) foo;
2940 if (scr->frame_border_color)
2941 WMReleaseColor(scr->frame_border_color);
2942 scr->frame_border_color = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2944 wFreeColor(scr, color->pixel);
2946 return REFRESH_FRAME_BORDER;
2949 static int setFrameFocusedBorderColor(WScreen *scr, WDefaultEntry *entry, void *tdata, void *foo)
2951 XColor *color = tdata;
2953 /* Parameter not used, but tell the compiler that it is ok */
2954 (void) entry;
2955 (void) foo;
2957 if (scr->frame_focused_border_color)
2958 WMReleaseColor(scr->frame_focused_border_color);
2959 scr->frame_focused_border_color = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2961 wFreeColor(scr, color->pixel);
2963 return REFRESH_FRAME_BORDER;
2966 static int setFrameSelectedBorderColor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2968 XColor *color = tdata;
2970 /* Parameter not used, but tell the compiler that it is ok */
2971 (void) entry;
2972 (void) foo;
2974 if (scr->frame_selected_border_color)
2975 WMReleaseColor(scr->frame_selected_border_color);
2976 scr->frame_selected_border_color = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2978 wFreeColor(scr, color->pixel);
2980 return REFRESH_FRAME_BORDER;
2983 static int setWorkspaceSpecificBack(WScreen * scr, WDefaultEntry * entry, void *tdata, void *bar)
2985 WMPropList *value = tdata;
2986 WMPropList *val;
2987 char *str;
2988 int i;
2990 /* Parameter not used, but tell the compiler that it is ok */
2991 (void) entry;
2992 (void) bar;
2994 if (scr->flags.backimage_helper_launched) {
2995 if (WMGetPropListItemCount(value) == 0) {
2996 SendHelperMessage(scr, 'C', 0, NULL);
2997 SendHelperMessage(scr, 'K', 0, NULL);
2999 WMReleasePropList(value);
3000 return 0;
3002 } else {
3003 if (WMGetPropListItemCount(value) == 0)
3004 return 0;
3006 if (!start_bg_helper(scr)) {
3007 WMReleasePropList(value);
3008 return 0;
3011 SendHelperMessage(scr, 'P', -1, wPreferences.pixmap_path);
3014 for (i = 0; i < WMGetPropListItemCount(value); i++) {
3015 val = WMGetFromPLArray(value, i);
3016 if (val && WMIsPLArray(val) && WMGetPropListItemCount(val) > 0) {
3017 str = WMGetPropListDescription(val, False);
3019 SendHelperMessage(scr, 'S', i + 1, str);
3021 wfree(str);
3022 } else {
3023 SendHelperMessage(scr, 'U', i + 1, NULL);
3026 sleep(1);
3028 WMReleasePropList(value);
3029 return 0;
3032 static int setWorkspaceBack(WScreen * scr, WDefaultEntry * entry, void *tdata, void *bar)
3034 WMPropList *value = tdata;
3036 /* Parameter not used, but tell the compiler that it is ok */
3037 (void) entry;
3038 (void) bar;
3040 if (scr->flags.backimage_helper_launched) {
3041 char *str;
3043 if (WMGetPropListItemCount(value) == 0) {
3044 SendHelperMessage(scr, 'U', 0, NULL);
3045 } else {
3046 /* set the default workspace background to this one */
3047 str = WMGetPropListDescription(value, False);
3048 if (str) {
3049 SendHelperMessage(scr, 'S', 0, str);
3050 wfree(str);
3051 SendHelperMessage(scr, 'C', scr->current_workspace + 1, NULL);
3052 } else {
3053 SendHelperMessage(scr, 'U', 0, NULL);
3056 } else if (WMGetPropListItemCount(value) > 0) {
3057 char *text;
3058 char *dither;
3059 int len;
3061 text = WMGetPropListDescription(value, False);
3062 len = strlen(text) + 40;
3063 dither = wPreferences.no_dithering ? "-m" : "-d";
3064 if (!strchr(text, '\'') && !strchr(text, '\\')) {
3065 char command[len];
3067 if (wPreferences.smooth_workspace_back)
3068 snprintf(command, len, "wmsetbg %s -S -p '%s' &", dither, text);
3069 else
3070 snprintf(command, len, "wmsetbg %s -p '%s' &", dither, text);
3071 ExecuteShellCommand(scr, command);
3072 } else
3073 wwarning(_("Invalid arguments for background \"%s\""), text);
3074 wfree(text);
3076 WMReleasePropList(value);
3078 return 0;
3081 static int setWidgetColor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
3083 WTexture **texture = tdata;
3085 /* Parameter not used, but tell the compiler that it is ok */
3086 (void) entry;
3087 (void) foo;
3089 if (scr->widget_texture) {
3090 wTextureDestroy(scr, (WTexture *) scr->widget_texture);
3092 scr->widget_texture = *(WTexSolid **) texture;
3094 return 0;
3097 static int setFTitleBack(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
3099 WTexture **texture = tdata;
3101 /* Parameter not used, but tell the compiler that it is ok */
3102 (void) entry;
3103 (void) foo;
3105 if (scr->window_title_texture[WS_FOCUSED]) {
3106 wTextureDestroy(scr, scr->window_title_texture[WS_FOCUSED]);
3108 scr->window_title_texture[WS_FOCUSED] = *texture;
3110 return REFRESH_WINDOW_TEXTURES;
3113 static int setPTitleBack(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
3115 WTexture **texture = tdata;
3117 /* Parameter not used, but tell the compiler that it is ok */
3118 (void) entry;
3119 (void) foo;
3121 if (scr->window_title_texture[WS_PFOCUSED]) {
3122 wTextureDestroy(scr, scr->window_title_texture[WS_PFOCUSED]);
3124 scr->window_title_texture[WS_PFOCUSED] = *texture;
3126 return REFRESH_WINDOW_TEXTURES;
3129 static int setUTitleBack(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
3131 WTexture **texture = tdata;
3133 /* Parameter not used, but tell the compiler that it is ok */
3134 (void) entry;
3135 (void) foo;
3137 if (scr->window_title_texture[WS_UNFOCUSED]) {
3138 wTextureDestroy(scr, scr->window_title_texture[WS_UNFOCUSED]);
3140 scr->window_title_texture[WS_UNFOCUSED] = *texture;
3142 return REFRESH_WINDOW_TEXTURES;
3145 static int setResizebarBack(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
3147 WTexture **texture = tdata;
3149 /* Parameter not used, but tell the compiler that it is ok */
3150 (void) entry;
3151 (void) foo;
3153 if (scr->resizebar_texture[0]) {
3154 wTextureDestroy(scr, scr->resizebar_texture[0]);
3156 scr->resizebar_texture[0] = *texture;
3158 return REFRESH_WINDOW_TEXTURES;
3161 static int setMenuTitleBack(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
3163 WTexture **texture = tdata;
3165 /* Parameter not used, but tell the compiler that it is ok */
3166 (void) entry;
3167 (void) foo;
3169 if (scr->menu_title_texture[0]) {
3170 wTextureDestroy(scr, scr->menu_title_texture[0]);
3172 scr->menu_title_texture[0] = *texture;
3174 return REFRESH_MENU_TITLE_TEXTURE;
3177 static int setMenuTextBack(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
3179 WTexture **texture = tdata;
3181 /* Parameter not used, but tell the compiler that it is ok */
3182 (void) entry;
3183 (void) foo;
3185 if (scr->menu_item_texture) {
3186 wTextureDestroy(scr, scr->menu_item_texture);
3187 wTextureDestroy(scr, (WTexture *) scr->menu_item_auxtexture);
3189 scr->menu_item_texture = *texture;
3191 scr->menu_item_auxtexture = wTextureMakeSolid(scr, &scr->menu_item_texture->any.color);
3193 return REFRESH_MENU_TEXTURE;
3196 static int setKeyGrab(WScreen * scr, WDefaultEntry * entry, void *tdata, void *extra_data)
3198 WShortKey *shortcut = tdata;
3199 WWindow *wwin;
3200 long widx = (long) extra_data;
3202 /* Parameter not used, but tell the compiler that it is ok */
3203 (void) entry;
3205 wKeyBindings[widx] = *shortcut;
3207 wwin = scr->focused_window;
3209 while (wwin != NULL) {
3210 XUngrabKey(dpy, AnyKey, AnyModifier, wwin->frame->core->window);
3212 if (!WFLAGP(wwin, no_bind_keys)) {
3213 wWindowSetKeyGrabs(wwin);
3215 wwin = wwin->prev;
3218 /* do we need to update window menus? */
3219 if (widx >= WKBD_WORKSPACE1 && widx <= WKBD_WORKSPACE10)
3220 return REFRESH_WORKSPACE_MENU;
3221 if (widx == WKBD_LASTWORKSPACE)
3222 return REFRESH_WORKSPACE_MENU;
3223 if (widx >= WKBD_MOVE_WORKSPACE1 && widx <= WKBD_MOVE_WORKSPACE10)
3224 return REFRESH_WORKSPACE_MENU;
3226 return 0;
3229 static int setIconPosition(WScreen * scr, WDefaultEntry * entry, void *bar, void *foo)
3231 /* Parameter not used, but tell the compiler that it is ok */
3232 (void) entry;
3233 (void) bar;
3234 (void) foo;
3236 wScreenUpdateUsableArea(scr);
3237 wArrangeIcons(scr, True);
3239 return 0;
3242 static int updateUsableArea(WScreen * scr, WDefaultEntry * entry, void *bar, void *foo)
3244 /* Parameter not used, but tell the compiler that it is ok */
3245 (void) entry;
3246 (void) bar;
3247 (void) foo;
3249 wScreenUpdateUsableArea(scr);
3251 return 0;
3254 static int setWorkspaceMapBackground(WScreen *scr, WDefaultEntry *entry, void *tdata, void *foo)
3256 WTexture **texture = tdata;
3258 /* Parameter not used, but tell the compiler that it is ok */
3259 (void) entry;
3260 (void) foo;
3262 if (wPreferences.wsmbackTexture)
3263 wTextureDestroy(scr, wPreferences.wsmbackTexture);
3265 wPreferences.wsmbackTexture = *texture;
3267 return REFRESH_WINDOW_TEXTURES;
3270 static int setMenuStyle(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
3272 /* Parameter not used, but tell the compiler that it is ok */
3273 (void) scr;
3274 (void) entry;
3275 (void) tdata;
3276 (void) foo;
3278 return REFRESH_MENU_TEXTURE;
3281 static RImage *chopOffImage(RImage * image, int x, int y, int w, int h)
3283 RImage *img = RCreateImage(w, h, image->format == RRGBAFormat);
3285 RCopyArea(img, image, x, y, w, h, 0, 0);
3287 return img;
3290 static int setSwPOptions(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
3292 WMPropList *array = tdata;
3293 char *path;
3294 RImage *bgimage;
3295 int cwidth, cheight;
3296 struct WPreferences *prefs = foo;
3298 if (!WMIsPLArray(array) || WMGetPropListItemCount(array) == 0) {
3299 if (prefs->swtileImage)
3300 RReleaseImage(prefs->swtileImage);
3301 prefs->swtileImage = NULL;
3303 WMReleasePropList(array);
3304 return 0;
3307 switch (WMGetPropListItemCount(array)) {
3308 case 4:
3309 if (!WMIsPLString(WMGetFromPLArray(array, 1))) {
3310 wwarning(_("Invalid arguments for option \"%s\""), entry->key);
3311 break;
3312 } else
3313 path = FindImage(wPreferences.pixmap_path, WMGetFromPLString(WMGetFromPLArray(array, 1)));
3315 if (!path) {
3316 wwarning(_("Could not find image \"%s\" for option \"%s\""),
3317 WMGetFromPLString(WMGetFromPLArray(array, 1)), entry->key);
3318 } else {
3319 bgimage = RLoadImage(scr->rcontext, path, 0);
3320 if (!bgimage) {
3321 wwarning(_("Could not load image \"%s\" for option \"%s\""), path, entry->key);
3322 wfree(path);
3323 } else {
3324 wfree(path);
3326 cwidth = atoi(WMGetFromPLString(WMGetFromPLArray(array, 2)));
3327 cheight = atoi(WMGetFromPLString(WMGetFromPLArray(array, 3)));
3329 if (cwidth <= 0 || cheight <= 0 ||
3330 cwidth >= bgimage->width - 2 || cheight >= bgimage->height - 2)
3331 wwarning(_("Invalid split sizes for switch panel back image."));
3332 else {
3333 int i;
3334 int swidth, theight;
3335 for (i = 0; i < 9; i++) {
3336 if (prefs->swbackImage[i])
3337 RReleaseImage(prefs->swbackImage[i]);
3338 prefs->swbackImage[i] = NULL;
3340 swidth = (bgimage->width - cwidth) / 2;
3341 theight = (bgimage->height - cheight) / 2;
3343 prefs->swbackImage[0] = chopOffImage(bgimage, 0, 0, swidth, theight);
3344 prefs->swbackImage[1] = chopOffImage(bgimage, swidth, 0, cwidth, theight);
3345 prefs->swbackImage[2] = chopOffImage(bgimage, swidth + cwidth, 0,
3346 swidth, theight);
3348 prefs->swbackImage[3] = chopOffImage(bgimage, 0, theight, swidth, cheight);
3349 prefs->swbackImage[4] = chopOffImage(bgimage, swidth, theight,
3350 cwidth, cheight);
3351 prefs->swbackImage[5] = chopOffImage(bgimage, swidth + cwidth, theight,
3352 swidth, cheight);
3354 prefs->swbackImage[6] = chopOffImage(bgimage, 0, theight + cheight,
3355 swidth, theight);
3356 prefs->swbackImage[7] = chopOffImage(bgimage, swidth, theight + cheight,
3357 cwidth, theight);
3358 prefs->swbackImage[8] =
3359 chopOffImage(bgimage, swidth + cwidth, theight + cheight, swidth,
3360 theight);
3362 // check if anything failed
3363 for (i = 0; i < 9; i++) {
3364 if (!prefs->swbackImage[i]) {
3365 for (; i >= 0; --i) {
3366 RReleaseImage(prefs->swbackImage[i]);
3367 prefs->swbackImage[i] = NULL;
3369 break;
3373 RReleaseImage(bgimage);
3377 case 1:
3378 if (!WMIsPLString(WMGetFromPLArray(array, 0))) {
3379 wwarning(_("Invalid arguments for option \"%s\""), entry->key);
3380 break;
3381 } else
3382 path = FindImage(wPreferences.pixmap_path, WMGetFromPLString(WMGetFromPLArray(array, 0)));
3384 if (!path) {
3385 wwarning(_("Could not find image \"%s\" for option \"%s\""),
3386 WMGetFromPLString(WMGetFromPLArray(array, 0)), entry->key);
3387 } else {
3388 if (prefs->swtileImage)
3389 RReleaseImage(prefs->swtileImage);
3391 prefs->swtileImage = RLoadImage(scr->rcontext, path, 0);
3392 if (!prefs->swtileImage) {
3393 wwarning(_("Could not load image \"%s\" for option \"%s\""), path, entry->key);
3395 wfree(path);
3397 break;
3399 default:
3400 wwarning(_("Invalid number of arguments for option \"%s\""), entry->key);
3401 break;
3404 WMReleasePropList(array);
3406 return 0;
3409 static int setModifierKeyLabels(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
3411 WMPropList *array = tdata;
3412 int i;
3413 struct WPreferences *prefs = foo;
3415 if (!WMIsPLArray(array) || WMGetPropListItemCount(array) != 7) {
3416 wwarning(_("Value for option \"%s\" must be an array of 7 strings"), entry->key);
3417 WMReleasePropList(array);
3418 return 0;
3421 DestroyWindowMenu(scr);
3423 for (i = 0; i < 7; i++) {
3424 if (prefs->modifier_labels[i])
3425 wfree(prefs->modifier_labels[i]);
3427 if (WMIsPLString(WMGetFromPLArray(array, i))) {
3428 prefs->modifier_labels[i] = wstrdup(WMGetFromPLString(WMGetFromPLArray(array, i)));
3429 } else {
3430 wwarning(_("Invalid argument for option \"%s\" item %d"), entry->key, i);
3431 prefs->modifier_labels[i] = NULL;
3435 WMReleasePropList(array);
3437 return 0;
3440 static int setDoubleClick(WScreen *scr, WDefaultEntry *entry, void *tdata, void *foo)
3442 int *value = tdata;
3444 /* Parameter not used, but tell the compiler that it is ok */
3445 (void) entry;
3446 (void) scr;
3448 if (*value <= 0)
3449 *(int *)foo = 1;
3451 W_setconf_doubleClickDelay(*value);
3453 return 0;
3456 static int setCursor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *extra_data)
3458 Cursor *cursor = tdata;
3459 long widx = (long) extra_data;
3461 /* Parameter not used, but tell the compiler that it is ok */
3462 (void) entry;
3464 if (wPreferences.cursor[widx] != None) {
3465 XFreeCursor(dpy, wPreferences.cursor[widx]);
3468 wPreferences.cursor[widx] = *cursor;
3470 if (widx == WCUR_ROOT && *cursor != None) {
3471 XDefineCursor(dpy, scr->root_win, *cursor);
3474 return 0;