doc: Update getstyle and setstyle manpages.
[wmaker-crm.git] / src / defaults.c
blob7d66372e71f3ed0374d3f91bb241833d7ad93f0e
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
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 #include "wconfig.h"
25 #include <stdio.h>
26 #include <stdint.h>
27 #include <stdlib.h>
28 #include <unistd.h>
29 #include <string.h>
30 #include <strings.h>
31 #include <ctype.h>
32 #include <time.h>
33 #include <sys/types.h>
34 #include <sys/stat.h>
35 #include <fcntl.h>
36 #include <limits.h>
37 #include <signal.h>
39 #ifndef PATH_MAX
40 #define PATH_MAX DEFAULT_PATH_MAX
41 #endif
43 #include <X11/Xlib.h>
44 #include <X11/Xutil.h>
45 #include <X11/keysym.h>
47 #include <wraster.h>
49 #include "WindowMaker.h"
50 #include "framewin.h"
51 #include "window.h"
52 #include "texture.h"
53 #include "screen.h"
54 #include "resources.h"
55 #include "defaults.h"
56 #include "keybind.h"
57 #include "xmodifier.h"
58 #include "icon.h"
59 #include "main.h"
60 #include "actions.h"
61 #include "dock.h"
62 #include "workspace.h"
63 #include "properties.h"
64 #include "misc.h"
65 #include "event.h"
66 #include "winmenu.h"
68 #define MAX_SHORTCUT_LENGTH 32
70 #ifndef GLOBAL_DEFAULTS_SUBDIR
71 #define GLOBAL_DEFAULTS_SUBDIR "WindowMaker"
72 #endif
75 typedef struct _WDefaultEntry WDefaultEntry;
76 typedef int (WDECallbackConvert) (WScreen *scr, WDefaultEntry *entry, WMPropList *plvalue, void *addr, void **tdata);
77 typedef int (WDECallbackUpdate) (WScreen *scr, WDefaultEntry *entry, void *tdata, void *extra_data);
79 struct _WDefaultEntry {
80 const char *key;
81 const char *default_value;
82 void *extra_data;
83 void *addr;
84 WDECallbackConvert *convert;
85 WDECallbackUpdate *update;
86 WMPropList *plkey;
87 WMPropList *plvalue; /* default value */
90 /* used to map strings to integers */
91 typedef struct {
92 const char *string;
93 short value;
94 char is_alias;
95 } WOptionEnumeration;
97 /* type converters */
98 static WDECallbackConvert getBool;
99 static WDECallbackConvert getInt;
100 static WDECallbackConvert getCoord;
101 static WDECallbackConvert getPathList;
102 static WDECallbackConvert getEnum;
103 static WDECallbackConvert getTexture;
104 static WDECallbackConvert getWSBackground;
105 static WDECallbackConvert getWSSpecificBackground;
106 static WDECallbackConvert getFont;
107 static WDECallbackConvert getColor;
108 static WDECallbackConvert getKeybind;
109 static WDECallbackConvert getModMask;
110 static WDECallbackConvert getPropList;
112 /* value setting functions */
113 static WDECallbackUpdate setJustify;
114 static WDECallbackUpdate setClearance;
115 static WDECallbackUpdate setIfDockPresent;
116 static WDECallbackUpdate setClipMergedInDock;
117 static WDECallbackUpdate setWrapAppiconsInDock;
118 static WDECallbackUpdate setStickyIcons;
119 static WDECallbackUpdate setWidgetColor;
120 static WDECallbackUpdate setIconTile;
121 static WDECallbackUpdate setWinTitleFont;
122 static WDECallbackUpdate setMenuTitleFont;
123 static WDECallbackUpdate setMenuTextFont;
124 static WDECallbackUpdate setIconTitleFont;
125 static WDECallbackUpdate setIconTitleColor;
126 static WDECallbackUpdate setIconTitleBack;
127 static WDECallbackUpdate setFrameBorderWidth;
128 static WDECallbackUpdate setFrameBorderColor;
129 static WDECallbackUpdate setFrameSelectedBorderColor;
130 static WDECallbackUpdate setLargeDisplayFont;
131 static WDECallbackUpdate setWTitleColor;
132 static WDECallbackUpdate setFTitleBack;
133 static WDECallbackUpdate setPTitleBack;
134 static WDECallbackUpdate setUTitleBack;
135 static WDECallbackUpdate setResizebarBack;
136 static WDECallbackUpdate setWorkspaceBack;
137 static WDECallbackUpdate setWorkspaceSpecificBack;
138 static WDECallbackUpdate setMenuTitleColor;
139 static WDECallbackUpdate setMenuTextColor;
140 static WDECallbackUpdate setMenuDisabledColor;
141 static WDECallbackUpdate setMenuTitleBack;
142 static WDECallbackUpdate setMenuTextBack;
143 static WDECallbackUpdate setHightlight;
144 static WDECallbackUpdate setHightlightText;
145 static WDECallbackUpdate setKeyGrab;
146 static WDECallbackUpdate setDoubleClick;
147 static WDECallbackUpdate setIconPosition;
149 static WDECallbackUpdate setClipTitleFont;
150 static WDECallbackUpdate setClipTitleColor;
152 static WDECallbackUpdate setMenuStyle;
153 static WDECallbackUpdate setSwPOptions;
154 static WDECallbackUpdate updateUsableArea;
156 static WDECallbackUpdate setModifierKeyLabels;
158 static WDECallbackConvert getCursor;
159 static WDECallbackUpdate setCursor;
162 * Tables to convert strings to enumeration values.
163 * Values stored are char
166 /* WARNING: sum of length of all value strings must not exceed
167 * this value */
168 #define TOTAL_VALUES_LENGTH 80
170 #define REFRESH_WINDOW_TEXTURES (1<<0)
171 #define REFRESH_MENU_TEXTURE (1<<1)
172 #define REFRESH_MENU_FONT (1<<2)
173 #define REFRESH_MENU_COLOR (1<<3)
174 #define REFRESH_MENU_TITLE_TEXTURE (1<<4)
175 #define REFRESH_MENU_TITLE_FONT (1<<5)
176 #define REFRESH_MENU_TITLE_COLOR (1<<6)
177 #define REFRESH_WINDOW_TITLE_COLOR (1<<7)
178 #define REFRESH_WINDOW_FONT (1<<8)
179 #define REFRESH_ICON_TILE (1<<9)
180 #define REFRESH_ICON_FONT (1<<10)
181 #define REFRESH_WORKSPACE_BACK (1<<11)
183 #define REFRESH_BUTTON_IMAGES (1<<12)
185 #define REFRESH_ICON_TITLE_COLOR (1<<13)
186 #define REFRESH_ICON_TITLE_BACK (1<<14)
188 #define REFRESH_WORKSPACE_MENU (1<<15)
190 #define REFRESH_FRAME_BORDER REFRESH_MENU_FONT|REFRESH_WINDOW_FONT
192 static WOptionEnumeration seFocusModes[] = {
193 {"Manual", WKF_CLICK, 0}, {"ClickToFocus", WKF_CLICK, 1},
194 {"Sloppy", WKF_SLOPPY, 0}, {"SemiAuto", WKF_SLOPPY, 1}, {"Auto", WKF_SLOPPY, 1},
195 {NULL, 0, 0}
198 static WOptionEnumeration seTitlebarModes[] = {
199 {"new", TS_NEW, 0}, {"old", TS_OLD, 0},
200 {"next", TS_NEXT, 0}, {NULL, 0, 0}
203 static WOptionEnumeration seColormapModes[] = {
204 {"Manual", WCM_CLICK, 0}, {"ClickToFocus", WCM_CLICK, 1},
205 {"Auto", WCM_POINTER, 0}, {"FocusFollowMouse", WCM_POINTER, 1},
206 {NULL, 0, 0}
209 static WOptionEnumeration sePlacements[] = {
210 {"Auto", WPM_AUTO, 0},
211 {"Smart", WPM_SMART, 0},
212 {"Cascade", WPM_CASCADE, 0},
213 {"Random", WPM_RANDOM, 0},
214 {"Manual", WPM_MANUAL, 0},
215 {"Center", WPM_CENTER, 0},
216 {NULL, 0, 0}
219 static WOptionEnumeration seGeomDisplays[] = {
220 {"None", WDIS_NONE, 0},
221 {"Center", WDIS_CENTER, 0},
222 {"Corner", WDIS_TOPLEFT, 0},
223 {"Floating", WDIS_FRAME_CENTER, 0},
224 {"Line", WDIS_NEW, 0},
225 {NULL, 0, 0}
228 static WOptionEnumeration seSpeeds[] = {
229 {"UltraFast", SPEED_ULTRAFAST, 0},
230 {"Fast", SPEED_FAST, 0},
231 {"Medium", SPEED_MEDIUM, 0},
232 {"Slow", SPEED_SLOW, 0},
233 {"UltraSlow", SPEED_ULTRASLOW, 0},
234 {NULL, 0, 0}
237 static WOptionEnumeration seMouseButtonActions[] = {
238 {"None", WA_NONE, 0},
239 {"SelectWindows", WA_SELECT_WINDOWS, 0},
240 {"OpenApplicationsMenu", WA_OPEN_APPMENU, 0},
241 {"OpenWindowListMenu", WA_OPEN_WINLISTMENU, 0},
242 {NULL, 0, 0}
245 static WOptionEnumeration seMouseWheelActions[] = {
246 {"None", WA_NONE, 0},
247 {"SwitchWorkspaces", WA_SWITCH_WORKSPACES, 0},
248 {NULL, 0, 0}
251 static WOptionEnumeration seIconificationStyles[] = {
252 {"Zoom", WIS_ZOOM, 0},
253 {"Twist", WIS_TWIST, 0},
254 {"Flip", WIS_FLIP, 0},
255 {"None", WIS_NONE, 0},
256 {"random", WIS_RANDOM, 0},
257 {NULL, 0, 0}
260 static WOptionEnumeration seJustifications[] = {
261 {"Left", WTJ_LEFT, 0},
262 {"Center", WTJ_CENTER, 0},
263 {"Right", WTJ_RIGHT, 0},
264 {NULL, 0, 0}
267 static WOptionEnumeration seIconPositions[] = {
268 {"blv", IY_BOTTOM | IY_LEFT | IY_VERT, 0},
269 {"blh", IY_BOTTOM | IY_LEFT | IY_HORIZ, 0},
270 {"brv", IY_BOTTOM | IY_RIGHT | IY_VERT, 0},
271 {"brh", IY_BOTTOM | IY_RIGHT | IY_HORIZ, 0},
272 {"tlv", IY_TOP | IY_LEFT | IY_VERT, 0},
273 {"tlh", IY_TOP | IY_LEFT | IY_HORIZ, 0},
274 {"trv", IY_TOP | IY_RIGHT | IY_VERT, 0},
275 {"trh", IY_TOP | IY_RIGHT | IY_HORIZ, 0},
276 {NULL, 0, 0}
279 static WOptionEnumeration seMenuStyles[] = {
280 {"normal", MS_NORMAL, 0},
281 {"singletexture", MS_SINGLE_TEXTURE, 0},
282 {"flat", MS_FLAT, 0},
283 {NULL, 0, 0}
286 static WOptionEnumeration seDisplayPositions[] = {
287 {"none", WD_NONE, 0},
288 {"center", WD_CENTER, 0},
289 {"top", WD_TOP, 0},
290 {"bottom", WD_BOTTOM, 0},
291 {"topleft", WD_TOPLEFT, 0},
292 {"topright", WD_TOPRIGHT, 0},
293 {"bottomleft", WD_BOTTOMLEFT, 0},
294 {"bottomright", WD_BOTTOMRIGHT, 0},
295 {NULL, 0, 0}
298 static WOptionEnumeration seWorkspaceBorder[] = {
299 {"None", WB_NONE, 0},
300 {"LeftRight", WB_LEFTRIGHT, 0},
301 {"TopBottom", WB_TOPBOTTOM, 0},
302 {"AllDirections", WB_ALLDIRS, 0},
303 {NULL, 0, 0}
307 * ALL entries in the tables bellow, NEED to have a default value
308 * defined, and this value needs to be correct.
311 /* these options will only affect the window manager on startup
313 * static defaults can't access the screen data, because it is
314 * created after these defaults are read
316 WDefaultEntry staticOptionList[] = {
318 {"ColormapSize", "4", NULL,
319 &wPreferences.cmap_size, getInt, NULL, NULL, NULL},
320 {"DisableDithering", "NO", NULL,
321 &wPreferences.no_dithering, getBool, NULL, NULL, NULL},
322 {"IconSize", "64", NULL,
323 &wPreferences.icon_size, getInt, NULL, NULL, NULL},
324 {"ModifierKey", "Mod1", NULL,
325 &wPreferences.modifier_mask, getModMask, NULL, NULL, NULL},
326 {"DisableWSMouseActions", "NO", NULL,
327 &wPreferences.disable_root_mouse, getBool, NULL, NULL, NULL},
328 {"FocusMode", "manual", seFocusModes, /* have a problem when switching from */
329 &wPreferences.focus_mode, getEnum, NULL, NULL, NULL}, /* manual to sloppy without restart */
330 {"NewStyle", "new", seTitlebarModes,
331 &wPreferences.new_style, getEnum, NULL, NULL, NULL},
332 {"DisableDock", "NO", (void *)WM_DOCK,
333 NULL, getBool, setIfDockPresent, NULL, NULL},
334 {"DisableClip", "NO", (void *)WM_CLIP,
335 NULL, getBool, setIfDockPresent, NULL, NULL},
336 {"DisableDrawers", "NO", (void *)WM_DRAWER,
337 NULL, getBool, setIfDockPresent, NULL, NULL},
338 {"ClipMergedInDock", "NO", NULL,
339 NULL, getBool, setClipMergedInDock, NULL, NULL},
340 {"DisableMiniwindows", "NO", NULL,
341 &wPreferences.disable_miniwindows, getBool, NULL, NULL, NULL}
344 #define NUM2STRING_(x) #x
345 #define NUM2STRING(x) NUM2STRING_(x)
347 WDefaultEntry optionList[] = {
349 /* dynamic options */
351 {"IconPosition", "blh", seIconPositions,
352 &wPreferences.icon_yard, getEnum, setIconPosition, NULL, NULL},
353 {"IconificationStyle", "Zoom", seIconificationStyles,
354 &wPreferences.iconification_style, getEnum, NULL, NULL, NULL},
355 {"MouseLeftButtonAction", "SelectWindows", seMouseButtonActions,
356 &wPreferences.mouse_button1, getEnum, NULL, NULL, NULL},
357 {"MouseMiddleButtonAction", "OpenWindowListMenu", seMouseButtonActions,
358 &wPreferences.mouse_button2, getEnum, NULL, NULL, NULL},
359 {"MouseRightButtonAction", "OpenApplicationsMenu", seMouseButtonActions,
360 &wPreferences.mouse_button3, getEnum, NULL, NULL, NULL},
361 {"MouseWheelAction", "None", seMouseWheelActions,
362 &wPreferences.mouse_wheel, getEnum, NULL, NULL, NULL},
363 {"PixmapPath", DEF_PIXMAP_PATHS, NULL,
364 &wPreferences.pixmap_path, getPathList, NULL, NULL, NULL},
365 {"IconPath", DEF_ICON_PATHS, NULL,
366 &wPreferences.icon_path, getPathList, NULL, NULL, NULL},
367 {"ColormapMode", "auto", seColormapModes,
368 &wPreferences.colormap_mode, getEnum, NULL, NULL, NULL},
369 {"AutoFocus", "NO", NULL,
370 &wPreferences.auto_focus, getBool, NULL, NULL, NULL},
371 {"RaiseDelay", "0", NULL,
372 &wPreferences.raise_delay, getInt, NULL, NULL, NULL},
373 {"CirculateRaise", "NO", NULL,
374 &wPreferences.circ_raise, getBool, NULL, NULL, NULL},
375 {"Superfluous", "NO", NULL,
376 &wPreferences.superfluous, getBool, NULL, NULL, NULL},
377 {"AdvanceToNewWorkspace", "NO", NULL,
378 &wPreferences.ws_advance, getBool, NULL, NULL, NULL},
379 {"CycleWorkspaces", "NO", NULL,
380 &wPreferences.ws_cycle, getBool, NULL, NULL, NULL},
381 {"WorkspaceNameDisplayPosition", "center", seDisplayPositions,
382 &wPreferences.workspace_name_display_position, getEnum, NULL, NULL, NULL},
383 {"WorkspaceBorder", "None", seWorkspaceBorder,
384 &wPreferences.workspace_border_position, getEnum, updateUsableArea, NULL, NULL},
385 {"WorkspaceBorderSize", "0", NULL,
386 &wPreferences.workspace_border_size, getInt, updateUsableArea, NULL, NULL},
387 {"StickyIcons", "NO", NULL,
388 &wPreferences.sticky_icons, getBool, setStickyIcons, NULL, NULL},
389 {"SaveSessionOnExit", "NO", NULL,
390 &wPreferences.save_session_on_exit, getBool, NULL, NULL, NULL},
391 {"WrapMenus", "NO", NULL,
392 &wPreferences.wrap_menus, getBool, NULL, NULL, NULL},
393 {"ScrollableMenus", "NO", NULL,
394 &wPreferences.scrollable_menus, getBool, NULL, NULL, NULL},
395 {"MenuScrollSpeed", "medium", seSpeeds,
396 &wPreferences.menu_scroll_speed, getEnum, NULL, NULL, NULL},
397 {"IconSlideSpeed", "medium", seSpeeds,
398 &wPreferences.icon_slide_speed, getEnum, NULL, NULL, NULL},
399 {"ShadeSpeed", "medium", seSpeeds,
400 &wPreferences.shade_speed, getEnum, NULL, NULL, NULL},
401 {"BounceAppIconsWhenUrgent", "YES", NULL,
402 &wPreferences.bounce_appicons_when_urgent, getBool, NULL, NULL, NULL},
403 {"RaiseAppIconsWhenBouncing", "NO", NULL,
404 &wPreferences.raise_appicons_when_bouncing, getBool, NULL, NULL, NULL},
405 {"DoNotMakeAppIconsBounce", "NO", NULL,
406 &wPreferences.do_not_make_appicons_bounce, getBool, NULL, NULL, NULL},
407 {"DoubleClickTime", "250", (void *)&wPreferences.dblclick_time,
408 &wPreferences.dblclick_time, getInt, setDoubleClick, NULL, NULL},
409 {"ClipAutoraiseDelay", "600", NULL,
410 &wPreferences.clip_auto_raise_delay, getInt, NULL, NULL, NULL},
411 {"ClipAutolowerDelay", "1000", NULL,
412 &wPreferences.clip_auto_lower_delay, getInt, NULL, NULL, NULL},
413 {"ClipAutoexpandDelay", "600", NULL,
414 &wPreferences.clip_auto_expand_delay, getInt, NULL, NULL, NULL},
415 {"ClipAutocollapseDelay", "1000", NULL,
416 &wPreferences.clip_auto_collapse_delay, getInt, NULL, NULL, NULL},
417 {"WrapAppiconsInDock", "YES", NULL,
418 NULL, getBool, setWrapAppiconsInDock, NULL, NULL},
419 {"AlignSubmenus", "NO", NULL,
420 &wPreferences.align_menus, getBool, NULL, NULL, NULL},
421 {"ViKeyMenus", "NO", NULL,
422 &wPreferences.vi_key_menus, getBool, NULL, NULL, NULL},
423 {"OpenTransientOnOwnerWorkspace", "NO", NULL,
424 &wPreferences.open_transients_with_parent, getBool, NULL, NULL, NULL},
425 {"WindowPlacement", "auto", sePlacements,
426 &wPreferences.window_placement, getEnum, NULL, NULL, NULL},
427 {"IgnoreFocusClick", "NO", NULL,
428 &wPreferences.ignore_focus_click, getBool, NULL, NULL, NULL},
429 {"UseSaveUnders", "NO", NULL,
430 &wPreferences.use_saveunders, getBool, NULL, NULL, NULL},
431 {"OpaqueMove", "NO", NULL,
432 &wPreferences.opaque_move, getBool, NULL, NULL, NULL},
433 {"OpaqueResize", "NO", NULL,
434 &wPreferences.opaque_resize, getBool, NULL, NULL, NULL},
435 {"OpaqueMoveResizeKeyboard", "NO", NULL,
436 &wPreferences.opaque_move_resize_keyboard, getBool, NULL, NULL, NULL},
437 {"DisableAnimations", "NO", NULL,
438 &wPreferences.no_animations, getBool, NULL, NULL, NULL},
439 {"DontLinkWorkspaces", "NO", NULL,
440 &wPreferences.no_autowrap, getBool, NULL, NULL, NULL},
441 {"HighlightActiveApp", "YES", NULL,
442 &wPreferences.highlight_active_app, getBool, NULL, NULL, NULL},
443 {"AutoArrangeIcons", "NO", NULL,
444 &wPreferences.auto_arrange_icons, getBool, NULL, NULL, NULL},
445 {"NoWindowOverDock", "NO", NULL,
446 &wPreferences.no_window_over_dock, getBool, updateUsableArea, NULL, NULL},
447 {"NoWindowOverIcons", "NO", NULL,
448 &wPreferences.no_window_over_icons, getBool, updateUsableArea, NULL, NULL},
449 {"WindowPlaceOrigin", "(0, 0)", NULL,
450 &wPreferences.window_place_origin, getCoord, NULL, NULL, NULL},
451 {"ResizeDisplay", "corner", seGeomDisplays,
452 &wPreferences.size_display, getEnum, NULL, NULL, NULL},
453 {"MoveDisplay", "corner", seGeomDisplays,
454 &wPreferences.move_display, getEnum, NULL, NULL, NULL},
455 {"DontConfirmKill", "NO", NULL,
456 &wPreferences.dont_confirm_kill, getBool, NULL, NULL, NULL},
457 {"WindowTitleBalloons", "NO", NULL,
458 &wPreferences.window_balloon, getBool, NULL, NULL, NULL},
459 {"MiniwindowTitleBalloons", "NO", NULL,
460 &wPreferences.miniwin_balloon, getBool, NULL, NULL, NULL},
461 {"AppIconBalloons", "NO", NULL,
462 &wPreferences.appicon_balloon, getBool, NULL, NULL, NULL},
463 {"HelpBalloons", "NO", NULL,
464 &wPreferences.help_balloon, getBool, NULL, NULL, NULL},
465 {"EdgeResistance", "30", NULL,
466 &wPreferences.edge_resistance, getInt, NULL, NULL, NULL},
467 {"ResizeIncrement", "0", NULL,
468 &wPreferences.resize_increment, getInt, NULL, NULL, NULL},
469 {"Attraction", "NO", NULL,
470 &wPreferences.attract, getBool, NULL, NULL, NULL},
471 {"DisableBlinking", "NO", NULL,
472 &wPreferences.dont_blink, getBool, NULL, NULL, NULL},
473 {"SingleClickLaunch", "NO", NULL,
474 &wPreferences.single_click, getBool, NULL, NULL, NULL},
475 {"StrictWindozeCycle", "YES", NULL,
476 &wPreferences.strict_windoze_cycle, getBool, NULL, NULL, NULL},
477 {"SwitchPanelOnlyOpen", "NO", NULL,
478 &wPreferences.panel_only_open, getBool, NULL, NULL, NULL},
480 /* style options */
482 {"MenuStyle", "normal", seMenuStyles,
483 &wPreferences.menu_style, getEnum, setMenuStyle, NULL, NULL},
484 {"WidgetColor", "(solid, gray)", NULL,
485 NULL, getTexture, setWidgetColor, NULL, NULL},
486 {"WorkspaceSpecificBack", "()", NULL,
487 NULL, getWSSpecificBackground, setWorkspaceSpecificBack, NULL, NULL},
488 /* WorkspaceBack must come after WorkspaceSpecificBack or
489 * WorkspaceBack wont know WorkspaceSpecificBack was also
490 * specified and 2 copies of wmsetbg will be launched */
491 {"WorkspaceBack", "(solid, black)", NULL,
492 NULL, getWSBackground, setWorkspaceBack, NULL, NULL},
493 {"SmoothWorkspaceBack", "NO", NULL,
494 NULL, getBool, NULL, NULL, NULL},
495 {"IconBack", "(solid, gray)", NULL,
496 NULL, getTexture, setIconTile, NULL, NULL},
497 {"TitleJustify", "center", seJustifications,
498 &wPreferences.title_justification, getEnum, setJustify, NULL, NULL},
499 {"WindowTitleFont", DEF_TITLE_FONT, NULL,
500 NULL, getFont, setWinTitleFont, NULL, NULL},
501 {"WindowTitleExtendSpace", DEF_WINDOW_TITLE_EXTEND_SPACE, NULL,
502 &wPreferences.window_title_clearance, getInt, setClearance, NULL, NULL},
503 {"WindowTitleMinHeight", "0", NULL,
504 &wPreferences.window_title_min_height, getInt, setClearance, NULL, NULL},
505 {"WindowTitleMaxHeight", NUM2STRING(INT_MAX), NULL,
506 &wPreferences.window_title_max_height, getInt, setClearance, NULL, NULL},
507 {"MenuTitleExtendSpace", DEF_MENU_TITLE_EXTEND_SPACE, NULL,
508 &wPreferences.menu_title_clearance, getInt, setClearance, NULL, NULL},
509 {"MenuTitleMinHeight", "0", NULL,
510 &wPreferences.menu_title_min_height, getInt, setClearance, NULL, NULL},
511 {"MenuTitleMaxHeight", NUM2STRING(INT_MAX), NULL,
512 &wPreferences.menu_title_max_height, getInt, setClearance, NULL, NULL},
513 {"MenuTextExtendSpace", DEF_MENU_TEXT_EXTEND_SPACE, NULL,
514 &wPreferences.menu_text_clearance, getInt, setClearance, NULL, NULL},
515 {"MenuTitleFont", DEF_MENU_TITLE_FONT, NULL,
516 NULL, getFont, setMenuTitleFont, NULL, NULL},
517 {"MenuTextFont", DEF_MENU_ENTRY_FONT, NULL,
518 NULL, getFont, setMenuTextFont, NULL, NULL},
519 {"IconTitleFont", DEF_ICON_TITLE_FONT, NULL,
520 NULL, getFont, setIconTitleFont, NULL, NULL},
521 {"ClipTitleFont", DEF_CLIP_TITLE_FONT, NULL,
522 NULL, getFont, setClipTitleFont, NULL, NULL},
523 {"ShowClipTitle", "YES", NULL,
524 &wPreferences.show_clip_title, getBool, NULL, NULL, NULL},
525 {"LargeDisplayFont", DEF_WORKSPACE_NAME_FONT, NULL,
526 NULL, getFont, setLargeDisplayFont, NULL, NULL},
527 {"HighlightColor", "white", NULL,
528 NULL, getColor, setHightlight, NULL, NULL},
529 {"HighlightTextColor", "black", NULL,
530 NULL, getColor, setHightlightText, NULL, NULL},
531 {"ClipTitleColor", "black", (void *)CLIP_NORMAL,
532 NULL, getColor, setClipTitleColor, NULL, NULL},
533 {"CClipTitleColor", "\"#454045\"", (void *)CLIP_COLLAPSED,
534 NULL, getColor, setClipTitleColor, NULL, NULL},
535 {"FTitleColor", "white", (void *)WS_FOCUSED,
536 NULL, getColor, setWTitleColor, NULL, NULL},
537 {"PTitleColor", "white", (void *)WS_PFOCUSED,
538 NULL, getColor, setWTitleColor, NULL, NULL},
539 {"UTitleColor", "black", (void *)WS_UNFOCUSED,
540 NULL, getColor, setWTitleColor, NULL, NULL},
541 {"FTitleBack", "(solid, black)", NULL,
542 NULL, getTexture, setFTitleBack, NULL, NULL},
543 {"PTitleBack", "(solid, \"#616161\")", NULL,
544 NULL, getTexture, setPTitleBack, NULL, NULL},
545 {"UTitleBack", "(solid, gray)", NULL,
546 NULL, getTexture, setUTitleBack, NULL, NULL},
547 {"ResizebarBack", "(solid, gray)", NULL,
548 NULL, getTexture, setResizebarBack, NULL, NULL},
549 {"MenuTitleColor", "white", NULL,
550 NULL, getColor, setMenuTitleColor, NULL, NULL},
551 {"MenuTextColor", "black", NULL,
552 NULL, getColor, setMenuTextColor, NULL, NULL},
553 {"MenuDisabledColor", "\"#616161\"", NULL,
554 NULL, getColor, setMenuDisabledColor, NULL, NULL},
555 {"MenuTitleBack", "(solid, black)", NULL,
556 NULL, getTexture, setMenuTitleBack, NULL, NULL},
557 {"MenuTextBack", "(solid, gray)", NULL,
558 NULL, getTexture, setMenuTextBack, NULL, NULL},
559 {"IconTitleColor", "white", NULL,
560 NULL, getColor, setIconTitleColor, NULL, NULL},
561 {"IconTitleBack", "black", NULL,
562 NULL, getColor, setIconTitleBack, NULL, NULL},
563 {"SwitchPanelImages", "(swtile.png, swback.png, 30, 40)", &wPreferences,
564 NULL, getPropList, setSwPOptions, NULL, NULL},
565 {"ModifierKeyLabels", "(\"Shift+\", \"Ctrl+\", \"Mod1+\", \"Mod2+\", \"Mod3+\", \"Mod4+\", \"Mod5+\")", &wPreferences,
566 NULL, getPropList, setModifierKeyLabels, NULL, NULL},
567 {"FrameBorderWidth", "1", NULL,
568 NULL, getInt, setFrameBorderWidth, NULL, NULL},
569 {"FrameBorderColor", "black", NULL,
570 NULL, getColor, setFrameBorderColor, NULL, NULL},
571 {"FrameSelectedBorderColor", "white", NULL,
572 NULL, getColor, setFrameSelectedBorderColor, NULL, NULL},
574 /* keybindings */
576 {"RootMenuKey", "None", (void *)WKBD_ROOTMENU,
577 NULL, getKeybind, setKeyGrab, NULL, NULL},
578 {"WindowListKey", "None", (void *)WKBD_WINDOWLIST,
579 NULL, getKeybind, setKeyGrab, NULL, NULL},
580 {"WindowMenuKey", "None", (void *)WKBD_WINDOWMENU,
581 NULL, getKeybind, setKeyGrab, NULL, NULL},
582 {"DockRaiseLowerKey", "None", (void*)WKBD_DOCKRAISELOWER,
583 NULL, getKeybind, setKeyGrab, NULL, NULL},
584 {"ClipRaiseLowerKey", "None", (void *)WKBD_CLIPRAISELOWER,
585 NULL, getKeybind, setKeyGrab, NULL, NULL},
586 {"MiniaturizeKey", "None", (void *)WKBD_MINIATURIZE,
587 NULL, getKeybind, setKeyGrab, NULL, NULL},
588 {"MinimizeAllKey", "None", (void *)WKBD_MINIMIZEALL,
589 NULL, getKeybind, setKeyGrab, NULL, NULL },
590 {"HideKey", "None", (void *)WKBD_HIDE,
591 NULL, getKeybind, setKeyGrab, NULL, NULL},
592 {"HideOthersKey", "None", (void *)WKBD_HIDE_OTHERS,
593 NULL, getKeybind, setKeyGrab, NULL, NULL},
594 {"MoveResizeKey", "None", (void *)WKBD_MOVERESIZE,
595 NULL, getKeybind, setKeyGrab, NULL, NULL},
596 {"CloseKey", "None", (void *)WKBD_CLOSE,
597 NULL, getKeybind, setKeyGrab, NULL, NULL},
598 {"MaximizeKey", "None", (void *)WKBD_MAXIMIZE,
599 NULL, getKeybind, setKeyGrab, NULL, NULL},
600 {"VMaximizeKey", "None", (void *)WKBD_VMAXIMIZE,
601 NULL, getKeybind, setKeyGrab, NULL, NULL},
602 {"HMaximizeKey", "None", (void *)WKBD_HMAXIMIZE,
603 NULL, getKeybind, setKeyGrab, NULL, NULL},
604 {"LHMaximizeKey", "None", (void*)WKBD_LHMAXIMIZE,
605 NULL, getKeybind, setKeyGrab, NULL, NULL},
606 {"RHMaximizeKey", "None", (void*)WKBD_RHMAXIMIZE,
607 NULL, getKeybind, setKeyGrab, NULL, NULL},
608 {"THMaximizeKey", "None", (void*)WKBD_THMAXIMIZE,
609 NULL, getKeybind, setKeyGrab, NULL, NULL},
610 {"BHMaximizeKey", "None", (void*)WKBD_BHMAXIMIZE,
611 NULL, getKeybind, setKeyGrab, NULL, NULL},
612 {"LTCMaximizeKey", "None", (void*)WKBD_LTCMAXIMIZE,
613 NULL, getKeybind, setKeyGrab, NULL, NULL},
614 {"RTCMaximizeKey", "None", (void*)WKBD_RTCMAXIMIZE,
615 NULL, getKeybind, setKeyGrab, NULL, NULL},
616 {"LBCMaximizeKey", "None", (void*)WKBD_LBCMAXIMIZE,
617 NULL, getKeybind, setKeyGrab, NULL, NULL},
618 {"RBCMaximizeKey", "None", (void*)WKBD_RBCMAXIMIZE,
619 NULL, getKeybind, setKeyGrab, NULL, NULL},
620 {"MaximusKey", "None", (void*)WKBD_MAXIMUS,
621 NULL, getKeybind, setKeyGrab, NULL, NULL},
622 {"RaiseKey", "\"Meta+Up\"", (void *)WKBD_RAISE,
623 NULL, getKeybind, setKeyGrab, NULL, NULL},
624 {"LowerKey", "\"Meta+Down\"", (void *)WKBD_LOWER,
625 NULL, getKeybind, setKeyGrab, NULL, NULL},
626 {"RaiseLowerKey", "None", (void *)WKBD_RAISELOWER,
627 NULL, getKeybind, setKeyGrab, NULL, NULL},
628 {"ShadeKey", "None", (void *)WKBD_SHADE,
629 NULL, getKeybind, setKeyGrab, NULL, NULL},
630 {"SelectKey", "None", (void *)WKBD_SELECT,
631 NULL, getKeybind, setKeyGrab, NULL, NULL},
632 {"FocusNextKey", "None", (void *)WKBD_FOCUSNEXT,
633 NULL, getKeybind, setKeyGrab, NULL, NULL},
634 {"FocusPrevKey", "None", (void *)WKBD_FOCUSPREV,
635 NULL, getKeybind, setKeyGrab, NULL, NULL},
636 {"GroupNextKey", "None", (void *)WKBD_GROUPNEXT,
637 NULL, getKeybind, setKeyGrab, NULL, NULL},
638 {"GroupPrevKey", "None", (void *)WKBD_GROUPPREV,
639 NULL, getKeybind, setKeyGrab, NULL, NULL},
640 {"NextWorkspaceKey", "None", (void *)WKBD_NEXTWORKSPACE,
641 NULL, getKeybind, setKeyGrab, NULL, NULL},
642 {"PrevWorkspaceKey", "None", (void *)WKBD_PREVWORKSPACE,
643 NULL, getKeybind, setKeyGrab, NULL, NULL},
644 {"LastWorkspaceKey", "None", (void *)WKBD_LASTWORKSPACE,
645 NULL, getKeybind, setKeyGrab, NULL, NULL},
646 {"NextWorkspaceLayerKey", "None", (void *)WKBD_NEXTWSLAYER,
647 NULL, getKeybind, setKeyGrab, NULL, NULL},
648 {"PrevWorkspaceLayerKey", "None", (void *)WKBD_PREVWSLAYER,
649 NULL, getKeybind, setKeyGrab, NULL, NULL},
650 {"Workspace1Key", "None", (void *)WKBD_WORKSPACE1,
651 NULL, getKeybind, setKeyGrab, NULL, NULL},
652 {"Workspace2Key", "None", (void *)WKBD_WORKSPACE2,
653 NULL, getKeybind, setKeyGrab, NULL, NULL},
654 {"Workspace3Key", "None", (void *)WKBD_WORKSPACE3,
655 NULL, getKeybind, setKeyGrab, NULL, NULL},
656 {"Workspace4Key", "None", (void *)WKBD_WORKSPACE4,
657 NULL, getKeybind, setKeyGrab, NULL, NULL},
658 {"Workspace5Key", "None", (void *)WKBD_WORKSPACE5,
659 NULL, getKeybind, setKeyGrab, NULL, NULL},
660 {"Workspace6Key", "None", (void *)WKBD_WORKSPACE6,
661 NULL, getKeybind, setKeyGrab, NULL, NULL},
662 {"Workspace7Key", "None", (void *)WKBD_WORKSPACE7,
663 NULL, getKeybind, setKeyGrab, NULL, NULL},
664 {"Workspace8Key", "None", (void *)WKBD_WORKSPACE8,
665 NULL, getKeybind, setKeyGrab, NULL, NULL},
666 {"Workspace9Key", "None", (void *)WKBD_WORKSPACE9,
667 NULL, getKeybind, setKeyGrab, NULL, NULL},
668 {"Workspace10Key", "None", (void *)WKBD_WORKSPACE10,
669 NULL, getKeybind, setKeyGrab, NULL, NULL},
670 {"MoveToWorkspace1Key", "None", (void *)WKBD_MOVE_WORKSPACE1,
671 NULL, getKeybind, setKeyGrab, NULL, NULL},
672 {"MoveToWorkspace2Key", "None", (void *)WKBD_MOVE_WORKSPACE2,
673 NULL, getKeybind, setKeyGrab, NULL, NULL},
674 {"MoveToWorkspace3Key", "None", (void *)WKBD_MOVE_WORKSPACE3,
675 NULL, getKeybind, setKeyGrab, NULL, NULL},
676 {"MoveToWorkspace4Key", "None", (void *)WKBD_MOVE_WORKSPACE4,
677 NULL, getKeybind, setKeyGrab, NULL, NULL},
678 {"MoveToWorkspace5Key", "None", (void *)WKBD_MOVE_WORKSPACE5,
679 NULL, getKeybind, setKeyGrab, NULL, NULL},
680 {"MoveToWorkspace6Key", "None", (void *)WKBD_MOVE_WORKSPACE6,
681 NULL, getKeybind, setKeyGrab, NULL, NULL},
682 {"MoveToWorkspace7Key", "None", (void *)WKBD_MOVE_WORKSPACE7,
683 NULL, getKeybind, setKeyGrab, NULL, NULL},
684 {"MoveToWorkspace8Key", "None", (void *)WKBD_MOVE_WORKSPACE8,
685 NULL, getKeybind, setKeyGrab, NULL, NULL},
686 {"MoveToWorkspace9Key", "None", (void *)WKBD_MOVE_WORKSPACE9,
687 NULL, getKeybind, setKeyGrab, NULL, NULL},
688 {"MoveToWorkspace10Key", "None", (void *)WKBD_MOVE_WORKSPACE10,
689 NULL, getKeybind, setKeyGrab, NULL, NULL},
690 {"MoveToNextWorkspaceKey", "None", (void *)WKBD_MOVE_NEXTWORKSPACE,
691 NULL, getKeybind, setKeyGrab, NULL, NULL},
692 {"MoveToPrevWorkspaceKey", "None", (void *)WKBD_MOVE_PREVWORKSPACE,
693 NULL, getKeybind, setKeyGrab, NULL, NULL},
694 {"MoveToLastWorkspaceKey", "None", (void *)WKBD_MOVE_LASTWORKSPACE,
695 NULL, getKeybind, setKeyGrab, NULL, NULL},
696 {"MoveToNextWorkspaceLayerKey", "None", (void *)WKBD_MOVE_NEXTWSLAYER,
697 NULL, getKeybind, setKeyGrab, NULL, NULL},
698 {"MoveToPrevWorkspaceLayerKey", "None", (void *)WKBD_MOVE_PREVWSLAYER,
699 NULL, getKeybind, setKeyGrab, NULL, NULL},
700 {"WindowShortcut1Key", "None", (void *)WKBD_WINDOW1,
701 NULL, getKeybind, setKeyGrab, NULL, NULL},
702 {"WindowShortcut2Key", "None", (void *)WKBD_WINDOW2,
703 NULL, getKeybind, setKeyGrab, NULL, NULL},
704 {"WindowShortcut3Key", "None", (void *)WKBD_WINDOW3,
705 NULL, getKeybind, setKeyGrab, NULL, NULL},
706 {"WindowShortcut4Key", "None", (void *)WKBD_WINDOW4,
707 NULL, getKeybind, setKeyGrab, NULL, NULL},
708 {"WindowShortcut5Key", "None", (void *)WKBD_WINDOW5,
709 NULL, getKeybind, setKeyGrab, NULL, NULL},
710 {"WindowShortcut6Key", "None", (void *)WKBD_WINDOW6,
711 NULL, getKeybind, setKeyGrab, NULL, NULL},
712 {"WindowShortcut7Key", "None", (void *)WKBD_WINDOW7,
713 NULL, getKeybind, setKeyGrab, NULL, NULL},
714 {"WindowShortcut8Key", "None", (void *)WKBD_WINDOW8,
715 NULL, getKeybind, setKeyGrab, NULL, NULL},
716 {"WindowShortcut9Key", "None", (void *)WKBD_WINDOW9,
717 NULL, getKeybind, setKeyGrab, NULL, NULL},
718 {"WindowShortcut10Key", "None", (void *)WKBD_WINDOW10,
719 NULL, getKeybind, setKeyGrab, NULL, NULL},
720 {"WindowRelaunchKey", "None", (void *)WKBD_RELAUNCH,
721 NULL, getKeybind, setKeyGrab, NULL, NULL},
722 {"ScreenSwitchKey", "None", (void *)WKBD_SWITCH_SCREEN,
723 NULL, getKeybind, setKeyGrab, NULL, NULL},
724 {"RunKey", "None", (void *)WKBD_RUN,
725 NULL, getKeybind, setKeyGrab, NULL, NULL},
727 #ifdef KEEP_XKB_LOCK_STATUS
728 {"ToggleKbdModeKey", "None", (void *)WKBD_TOGGLE,
729 NULL, getKeybind, setKeyGrab, NULL, NULL},
730 {"KbdModeLock", "NO", NULL,
731 &wPreferences.modelock, getBool, NULL, NULL, NULL},
732 #endif /* KEEP_XKB_LOCK_STATUS */
734 {"NormalCursor", "(builtin, left_ptr)", (void *)WCUR_ROOT,
735 NULL, getCursor, setCursor, NULL, NULL},
736 {"ArrowCursor", "(builtin, top_left_arrow)", (void *)WCUR_ARROW,
737 NULL, getCursor, setCursor, NULL, NULL},
738 {"MoveCursor", "(builtin, fleur)", (void *)WCUR_MOVE,
739 NULL, getCursor, setCursor, NULL, NULL},
740 {"ResizeCursor", "(builtin, sizing)", (void *)WCUR_RESIZE,
741 NULL, getCursor, setCursor, NULL, NULL},
742 {"TopLeftResizeCursor", "(builtin, top_left_corner)", (void *)WCUR_TOPLEFTRESIZE,
743 NULL, getCursor, setCursor, NULL, NULL},
744 {"TopRightResizeCursor", "(builtin, top_right_corner)", (void *)WCUR_TOPRIGHTRESIZE,
745 NULL, getCursor, setCursor, NULL, NULL},
746 {"BottomLeftResizeCursor", "(builtin, bottom_left_corner)", (void *)WCUR_BOTTOMLEFTRESIZE,
747 NULL, getCursor, setCursor, NULL, NULL},
748 {"BottomRightResizeCursor", "(builtin, bottom_right_corner)", (void *)WCUR_BOTTOMRIGHTRESIZE,
749 NULL, getCursor, setCursor, NULL, NULL},
750 {"VerticalResizeCursor", "(builtin, sb_v_double_arrow)", (void *)WCUR_VERTICALRESIZE,
751 NULL, getCursor, setCursor, NULL, NULL},
752 {"HorizontalResizeCursor", "(builtin, sb_h_double_arrow)", (void *)WCUR_HORIZONRESIZE,
753 NULL, getCursor, setCursor, NULL, NULL},
754 {"WaitCursor", "(builtin, watch)", (void *)WCUR_WAIT,
755 NULL, getCursor, setCursor, NULL, NULL},
756 {"QuestionCursor", "(builtin, question_arrow)", (void *)WCUR_QUESTION,
757 NULL, getCursor, setCursor, NULL, NULL},
758 {"TextCursor", "(builtin, xterm)", (void *)WCUR_TEXT,
759 NULL, getCursor, setCursor, NULL, NULL},
760 {"SelectCursor", "(builtin, cross)", (void *)WCUR_SELECT,
761 NULL, getCursor, setCursor, NULL, NULL},
762 {"DialogHistoryLines", "500", NULL,
763 &wPreferences.history_lines, getInt, NULL, NULL, NULL},
764 {"CycleActiveHeadOnly", "NO", NULL,
765 &wPreferences.cycle_active_head_only, getBool, NULL, NULL, NULL},
766 {"CycleIgnoreMinimized", "NO", NULL,
767 &wPreferences.cycle_ignore_minimized, getBool, NULL, NULL, NULL}
770 static void initDefaults(void)
772 unsigned int i;
773 WDefaultEntry *entry;
775 WMPLSetCaseSensitive(False);
777 for (i = 0; i < wlengthof(optionList); i++) {
778 entry = &optionList[i];
780 entry->plkey = WMCreatePLString(entry->key);
781 if (entry->default_value)
782 entry->plvalue = WMCreatePropListFromDescription(entry->default_value);
783 else
784 entry->plvalue = NULL;
787 for (i = 0; i < wlengthof(staticOptionList); i++) {
788 entry = &staticOptionList[i];
790 entry->plkey = WMCreatePLString(entry->key);
791 if (entry->default_value)
792 entry->plvalue = WMCreatePropListFromDescription(entry->default_value);
793 else
794 entry->plvalue = NULL;
798 static WMPropList *readGlobalDomain(const char *domainName, Bool requireDictionary)
800 WMPropList *globalDict = NULL;
801 char path[PATH_MAX];
802 struct stat stbuf;
804 snprintf(path, sizeof(path), "%s/%s/%s", SYSCONFDIR, GLOBAL_DEFAULTS_SUBDIR, domainName);
805 if (stat(path, &stbuf) >= 0) {
806 globalDict = WMReadPropListFromFile(path);
807 if (globalDict && requireDictionary && !WMIsPLDictionary(globalDict)) {
808 wwarning(_("Domain %s (%s) of global defaults database is corrupted!"), domainName, path);
809 WMReleasePropList(globalDict);
810 globalDict = NULL;
811 } else if (!globalDict) {
812 wwarning(_("could not load domain %s from global defaults database"), domainName);
816 return globalDict;
819 #if defined(GLOBAL_PREAMBLE_MENU_FILE) || defined(GLOBAL_EPILOGUE_MENU_FILE)
820 static void prependMenu(WMPropList * destarr, WMPropList * array)
822 WMPropList *item;
823 int i;
825 for (i = 0; i < WMGetPropListItemCount(array); i++) {
826 item = WMGetFromPLArray(array, i);
827 if (item)
828 WMInsertInPLArray(destarr, i + 1, item);
832 static void appendMenu(WMPropList * destarr, WMPropList * array)
834 WMPropList *item;
835 int i;
837 for (i = 0; i < WMGetPropListItemCount(array); i++) {
838 item = WMGetFromPLArray(array, i);
839 if (item)
840 WMAddToPLArray(destarr, item);
843 #endif
845 void wDefaultsMergeGlobalMenus(WDDomain * menuDomain)
847 WMPropList *menu = menuDomain->dictionary;
848 WMPropList *submenu;
850 if (!menu || !WMIsPLArray(menu))
851 return;
853 #ifdef GLOBAL_PREAMBLE_MENU_FILE
854 submenu = WMReadPropListFromFile(SYSCONFDIR "/" GLOBAL_DEFAULTS_SUBDIR "/" GLOBAL_PREAMBLE_MENU_FILE);
856 if (submenu && !WMIsPLArray(submenu)) {
857 wwarning(_("invalid global menu file %s"), GLOBAL_PREAMBLE_MENU_FILE);
858 WMReleasePropList(submenu);
859 submenu = NULL;
861 if (submenu) {
862 prependMenu(menu, submenu);
863 WMReleasePropList(submenu);
865 #endif
867 #ifdef GLOBAL_EPILOGUE_MENU_FILE
868 submenu = WMReadPropListFromFile(SYSCONFDIR "/" GLOBAL_DEFAULTS_SUBDIR "/" GLOBAL_EPILOGUE_MENU_FILE);
870 if (submenu && !WMIsPLArray(submenu)) {
871 wwarning(_("invalid global menu file %s"), GLOBAL_EPILOGUE_MENU_FILE);
872 WMReleasePropList(submenu);
873 submenu = NULL;
875 if (submenu) {
876 appendMenu(menu, submenu);
877 WMReleasePropList(submenu);
879 #endif
881 menuDomain->dictionary = menu;
884 WDDomain *wDefaultsInitDomain(const char *domain, Bool requireDictionary)
886 WDDomain *db;
887 struct stat stbuf;
888 static int inited = 0;
889 const char *the_path;
890 WMPropList *shared_dict = NULL;
892 if (!inited) {
893 inited = 1;
894 initDefaults();
897 db = wmalloc(sizeof(WDDomain));
898 db->domain_name = domain;
899 db->path = wdefaultspathfordomain(domain);
900 the_path = db->path;
902 if (the_path && stat(the_path, &stbuf) >= 0) {
903 db->dictionary = WMReadPropListFromFile(the_path);
904 if (db->dictionary) {
905 if (requireDictionary && !WMIsPLDictionary(db->dictionary)) {
906 WMReleasePropList(db->dictionary);
907 db->dictionary = NULL;
908 wwarning(_("Domain %s (%s) of defaults database is corrupted!"), domain, the_path);
910 db->timestamp = stbuf.st_mtime;
911 } else {
912 wwarning(_("could not load domain %s from user defaults database"), domain);
916 /* global system dictionary */
917 shared_dict = readGlobalDomain(domain, requireDictionary);
919 if (shared_dict && db->dictionary && WMIsPLDictionary(shared_dict) &&
920 WMIsPLDictionary(db->dictionary)) {
921 WMMergePLDictionaries(shared_dict, db->dictionary, True);
922 WMReleasePropList(db->dictionary);
923 db->dictionary = shared_dict;
924 if (stbuf.st_mtime > db->timestamp)
925 db->timestamp = stbuf.st_mtime;
926 } else if (!db->dictionary) {
927 db->dictionary = shared_dict;
928 if (stbuf.st_mtime > db->timestamp)
929 db->timestamp = stbuf.st_mtime;
932 return db;
935 void wReadStaticDefaults(WMPropList * dict)
937 WMPropList *plvalue;
938 WDefaultEntry *entry;
939 unsigned int i;
940 void *tdata;
942 for (i = 0; i < wlengthof(staticOptionList); i++) {
943 entry = &staticOptionList[i];
945 if (dict)
946 plvalue = WMGetFromPLDictionary(dict, entry->plkey);
947 else
948 plvalue = NULL;
950 /* no default in the DB. Use builtin default */
951 if (!plvalue)
952 plvalue = entry->plvalue;
954 if (plvalue) {
955 /* convert data */
956 (*entry->convert) (NULL, entry, plvalue, entry->addr, &tdata);
957 if (entry->update)
958 (*entry->update) (NULL, entry, tdata, entry->extra_data);
963 void wDefaultsCheckDomains(void* arg)
965 WScreen *scr;
966 struct stat stbuf;
967 WMPropList *shared_dict = NULL;
968 WMPropList *dict;
969 int i;
971 /* Parameter not used, but tell the compiler that it is ok */
972 (void) arg;
974 if (stat(w_global.domain.wmaker->path, &stbuf) >= 0 && w_global.domain.wmaker->timestamp < stbuf.st_mtime) {
975 w_global.domain.wmaker->timestamp = stbuf.st_mtime;
977 /* Global dictionary */
978 shared_dict = readGlobalDomain("WindowMaker", True);
980 /* User dictionary */
981 dict = WMReadPropListFromFile(w_global.domain.wmaker->path);
983 if (dict) {
984 if (!WMIsPLDictionary(dict)) {
985 WMReleasePropList(dict);
986 dict = NULL;
987 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
988 "WindowMaker", w_global.domain.wmaker->path);
989 } else {
990 if (shared_dict) {
991 WMMergePLDictionaries(shared_dict, dict, True);
992 WMReleasePropList(dict);
993 dict = shared_dict;
994 shared_dict = NULL;
997 for (i = 0; i < w_global.screen_count; i++) {
998 scr = wScreenWithNumber(i);
999 if (scr)
1000 wReadDefaults(scr, dict);
1003 if (w_global.domain.wmaker->dictionary)
1004 WMReleasePropList(w_global.domain.wmaker->dictionary);
1006 w_global.domain.wmaker->dictionary = dict;
1008 } else {
1009 wwarning(_("could not load domain %s from user defaults database"), "WindowMaker");
1012 if (shared_dict)
1013 WMReleasePropList(shared_dict);
1017 if (stat(w_global.domain.window_attr->path, &stbuf) >= 0 && w_global.domain.window_attr->timestamp < stbuf.st_mtime) {
1018 /* global dictionary */
1019 shared_dict = readGlobalDomain("WMWindowAttributes", True);
1020 /* user dictionary */
1021 dict = WMReadPropListFromFile(w_global.domain.window_attr->path);
1022 if (dict) {
1023 if (!WMIsPLDictionary(dict)) {
1024 WMReleasePropList(dict);
1025 dict = NULL;
1026 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
1027 "WMWindowAttributes", w_global.domain.window_attr->path);
1028 } else {
1029 if (shared_dict) {
1030 WMMergePLDictionaries(shared_dict, dict, True);
1031 WMReleasePropList(dict);
1032 dict = shared_dict;
1033 shared_dict = NULL;
1036 if (w_global.domain.window_attr->dictionary)
1037 WMReleasePropList(w_global.domain.window_attr->dictionary);
1039 w_global.domain.window_attr->dictionary = dict;
1040 for (i = 0; i < w_global.screen_count; i++) {
1041 scr = wScreenWithNumber(i);
1042 if (scr) {
1043 wDefaultUpdateIcons(scr);
1045 /* Update the panel image if changed */
1046 /* Don't worry. If the image is the same these
1047 * functions will have no performance impact. */
1048 create_logo_image(scr);
1052 } else {
1053 wwarning(_("could not load domain %s from user defaults database"), "WMWindowAttributes");
1056 w_global.domain.window_attr->timestamp = stbuf.st_mtime;
1057 if (shared_dict)
1058 WMReleasePropList(shared_dict);
1061 if (stat(w_global.domain.root_menu->path, &stbuf) >= 0 && w_global.domain.root_menu->timestamp < stbuf.st_mtime) {
1062 dict = WMReadPropListFromFile(w_global.domain.root_menu->path);
1063 if (dict) {
1064 if (!WMIsPLArray(dict) && !WMIsPLString(dict)) {
1065 WMReleasePropList(dict);
1066 dict = NULL;
1067 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
1068 "WMRootMenu", w_global.domain.root_menu->path);
1069 } else {
1070 if (w_global.domain.root_menu->dictionary)
1071 WMReleasePropList(w_global.domain.root_menu->dictionary);
1073 w_global.domain.root_menu->dictionary = dict;
1074 wDefaultsMergeGlobalMenus(w_global.domain.root_menu);
1076 } else {
1077 wwarning(_("could not load domain %s from user defaults database"), "WMRootMenu");
1079 w_global.domain.root_menu->timestamp = stbuf.st_mtime;
1081 #ifndef HAVE_INOTIFY
1082 if (!arg)
1083 WMAddTimerHandler(DEFAULTS_CHECK_INTERVAL, wDefaultsCheckDomains, arg);
1084 #endif
1087 void wReadDefaults(WScreen * scr, WMPropList * new_dict)
1089 WMPropList *plvalue, *old_value;
1090 WDefaultEntry *entry;
1091 unsigned int i;
1092 int update_workspace_back = 0; /* kluge :/ */
1093 unsigned int needs_refresh;
1094 void *tdata;
1095 WMPropList *old_dict = (w_global.domain.wmaker->dictionary != new_dict ? w_global.domain.wmaker->dictionary : NULL);
1097 needs_refresh = 0;
1099 for (i = 0; i < wlengthof(optionList); i++) {
1100 entry = &optionList[i];
1102 if (new_dict)
1103 plvalue = WMGetFromPLDictionary(new_dict, entry->plkey);
1104 else
1105 plvalue = NULL;
1107 if (!old_dict)
1108 old_value = NULL;
1109 else
1110 old_value = WMGetFromPLDictionary(old_dict, entry->plkey);
1112 if (!plvalue && !old_value) {
1113 /* no default in the DB. Use builtin default */
1114 plvalue = entry->plvalue;
1115 if (plvalue && new_dict)
1116 WMPutInPLDictionary(new_dict, entry->plkey, plvalue);
1118 } else if (!plvalue) {
1119 /* value was deleted from DB. Keep current value */
1120 continue;
1121 } else if (!old_value) {
1122 /* set value for the 1st time */
1123 } else if (!WMIsPropListEqualTo(plvalue, old_value)) {
1124 /* value has changed */
1125 } else {
1126 if (strcmp(entry->key, "WorkspaceBack") == 0
1127 && update_workspace_back && scr->flags.backimage_helper_launched) {
1128 } else {
1129 /* value was not changed since last time */
1130 continue;
1134 if (plvalue) {
1135 /* convert data */
1136 if ((*entry->convert) (scr, entry, plvalue, entry->addr, &tdata)) {
1138 * If the WorkspaceSpecificBack data has been changed
1139 * so that the helper will be launched now, we must be
1140 * sure to send the default background texture config
1141 * to the helper.
1143 if (strcmp(entry->key, "WorkspaceSpecificBack") == 0 &&
1144 !scr->flags.backimage_helper_launched)
1145 update_workspace_back = 1;
1147 if (entry->update)
1148 needs_refresh |= (*entry->update) (scr, entry, tdata, entry->extra_data);
1154 if (needs_refresh != 0 && !scr->flags.startup) {
1155 int foo;
1157 foo = 0;
1158 if (needs_refresh & REFRESH_MENU_TITLE_TEXTURE)
1159 foo |= WTextureSettings;
1160 if (needs_refresh & REFRESH_MENU_TITLE_FONT)
1161 foo |= WFontSettings;
1162 if (needs_refresh & REFRESH_MENU_TITLE_COLOR)
1163 foo |= WColorSettings;
1164 if (foo)
1165 WMPostNotificationName(WNMenuTitleAppearanceSettingsChanged, NULL,
1166 (void *)(uintptr_t) foo);
1168 foo = 0;
1169 if (needs_refresh & REFRESH_MENU_TEXTURE)
1170 foo |= WTextureSettings;
1171 if (needs_refresh & REFRESH_MENU_FONT)
1172 foo |= WFontSettings;
1173 if (needs_refresh & REFRESH_MENU_COLOR)
1174 foo |= WColorSettings;
1175 if (foo)
1176 WMPostNotificationName(WNMenuAppearanceSettingsChanged, NULL, (void *)(uintptr_t) foo);
1178 foo = 0;
1179 if (needs_refresh & REFRESH_WINDOW_FONT)
1180 foo |= WFontSettings;
1181 if (needs_refresh & REFRESH_WINDOW_TEXTURES)
1182 foo |= WTextureSettings;
1183 if (needs_refresh & REFRESH_WINDOW_TITLE_COLOR)
1184 foo |= WColorSettings;
1185 if (foo)
1186 WMPostNotificationName(WNWindowAppearanceSettingsChanged, NULL, (void *)(uintptr_t) foo);
1188 if (!(needs_refresh & REFRESH_ICON_TILE)) {
1189 foo = 0;
1190 if (needs_refresh & REFRESH_ICON_FONT)
1191 foo |= WFontSettings;
1192 if (needs_refresh & REFRESH_ICON_TITLE_COLOR)
1193 foo |= WTextureSettings;
1194 if (needs_refresh & REFRESH_ICON_TITLE_BACK)
1195 foo |= WTextureSettings;
1196 if (foo)
1197 WMPostNotificationName(WNIconAppearanceSettingsChanged, NULL,
1198 (void *)(uintptr_t) foo);
1200 if (needs_refresh & REFRESH_ICON_TILE)
1201 WMPostNotificationName(WNIconTileSettingsChanged, NULL, NULL);
1203 if (needs_refresh & REFRESH_WORKSPACE_MENU) {
1204 if (w_global.workspace.menu)
1205 wWorkspaceMenuUpdate(w_global.workspace.menu);
1206 if (w_global.clip.ws_menu)
1207 wWorkspaceMenuUpdate(w_global.clip.ws_menu);
1208 if (w_global.workspace.submenu)
1209 w_global.workspace.submenu->flags.realized = 0;
1210 if (w_global.clip.submenu)
1211 w_global.clip.submenu->flags.realized = 0;
1216 void wDefaultUpdateIcons(WScreen *scr)
1218 WAppIcon *aicon = w_global.app_icon_list;
1219 WDrawerChain *dc;
1220 WWindow *wwin = scr->focused_window;
1222 while (aicon) {
1223 /* Get the application icon, default included */
1224 wIconChangeImageFile(aicon->icon, NULL);
1225 wAppIconPaint(aicon);
1226 aicon = aicon->next;
1229 if (!wPreferences.flags.noclip || wPreferences.flags.clip_merged_in_dock)
1230 wClipIconPaint();
1232 for (dc = scr->drawers; dc != NULL; dc = dc->next)
1233 wDrawerIconPaint(dc->adrawer->icon_array[0]);
1235 while (wwin) {
1236 if (wwin->icon && wwin->flags.miniaturized)
1237 wIconChangeImageFile(wwin->icon, NULL);
1238 wwin = wwin->prev;
1242 /* --------------------------- Local ----------------------- */
1244 #define GET_STRING_OR_DEFAULT(x, var) if (!WMIsPLString(value)) { \
1245 wwarning(_("Wrong option format for key \"%s\". Should be %s."), \
1246 entry->key, x); \
1247 wwarning(_("using default \"%s\" instead"), entry->default_value); \
1248 var = entry->default_value;\
1249 } else var = WMGetFromPLString(value)\
1252 static int string2index(WMPropList *key, WMPropList *val, const char *def, WOptionEnumeration * values)
1254 char *str;
1255 WOptionEnumeration *v;
1256 char buffer[TOTAL_VALUES_LENGTH];
1258 if (WMIsPLString(val) && (str = WMGetFromPLString(val))) {
1259 for (v = values; v->string != NULL; v++) {
1260 if (strcasecmp(v->string, str) == 0)
1261 return v->value;
1265 buffer[0] = 0;
1266 for (v = values; v->string != NULL; v++) {
1267 if (!v->is_alias) {
1268 if (buffer[0] != 0)
1269 strcat(buffer, ", ");
1270 snprintf(buffer+strlen(buffer),
1271 sizeof(buffer)-strlen(buffer)-1, "\"%s\"", v->string);
1274 wwarning(_("wrong option value for key \"%s\"; got \"%s\", should be one of %s."),
1275 WMGetFromPLString(key),
1276 WMIsPLString(val) ? WMGetFromPLString(val) : "(unknown)",
1277 buffer);
1279 if (def) {
1280 return string2index(key, val, NULL, values);
1283 return -1;
1287 * value - is the value in the defaults DB
1288 * addr - is the address to store the data
1289 * ret - is the address to store a pointer to a temporary buffer. ret
1290 * must not be freed and is used by the set functions
1292 static int getBool(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1294 static char data;
1295 const char *val;
1296 int second_pass = 0;
1298 /* Parameter not used, but tell the compiler that it is ok */
1299 (void) scr;
1301 GET_STRING_OR_DEFAULT("Boolean", val);
1303 again:
1304 if ((val[1] == '\0' && (val[0] == 'y' || val[0] == 'Y'))
1305 || strcasecmp(val, "YES") == 0) {
1307 data = 1;
1308 } else if ((val[1] == '\0' && (val[0] == 'n' || val[0] == 'N'))
1309 || strcasecmp(val, "NO") == 0) {
1310 data = 0;
1311 } else {
1312 int i;
1313 if (sscanf(val, "%i", &i) == 1) {
1314 if (i != 0)
1315 data = 1;
1316 else
1317 data = 0;
1318 } else {
1319 wwarning(_("can't convert \"%s\" to boolean for key \"%s\""), val, entry->key);
1320 if (second_pass == 0) {
1321 val = WMGetFromPLString(entry->plvalue);
1322 second_pass = 1;
1323 wwarning(_("using default \"%s\" instead"), val);
1324 goto again;
1326 return False;
1330 if (ret)
1331 *ret = &data;
1332 if (addr)
1333 *(char *)addr = data;
1335 return True;
1338 static int getInt(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1340 static int data;
1341 const char *val;
1343 /* Parameter not used, but tell the compiler that it is ok */
1344 (void) scr;
1346 GET_STRING_OR_DEFAULT("Integer", val);
1348 if (sscanf(val, "%i", &data) != 1) {
1349 wwarning(_("can't convert \"%s\" to integer for key \"%s\""), val, entry->key);
1350 val = WMGetFromPLString(entry->plvalue);
1351 wwarning(_("using default \"%s\" instead"), val);
1352 if (sscanf(val, "%i", &data) != 1) {
1353 return False;
1357 if (ret)
1358 *ret = &data;
1359 if (addr)
1360 *(int *)addr = data;
1362 return True;
1365 static int getCoord(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1367 static WCoord data;
1368 char *val_x, *val_y;
1369 int nelem, changed = 0;
1370 WMPropList *elem_x, *elem_y;
1372 again:
1373 if (!WMIsPLArray(value)) {
1374 wwarning(_("Wrong option format for key \"%s\". Should be %s."), entry->key, "Coordinate");
1375 if (changed == 0) {
1376 value = entry->plvalue;
1377 changed = 1;
1378 wwarning(_("using default \"%s\" instead"), entry->default_value);
1379 goto again;
1381 return False;
1384 nelem = WMGetPropListItemCount(value);
1385 if (nelem != 2) {
1386 wwarning(_("Incorrect number of elements in array for key \"%s\"."), entry->key);
1387 if (changed == 0) {
1388 value = entry->plvalue;
1389 changed = 1;
1390 wwarning(_("using default \"%s\" instead"), entry->default_value);
1391 goto again;
1393 return False;
1396 elem_x = WMGetFromPLArray(value, 0);
1397 elem_y = WMGetFromPLArray(value, 1);
1399 if (!elem_x || !elem_y || !WMIsPLString(elem_x) || !WMIsPLString(elem_y)) {
1400 wwarning(_("Wrong value for key \"%s\". Should be Coordinate."), entry->key);
1401 if (changed == 0) {
1402 value = entry->plvalue;
1403 changed = 1;
1404 wwarning(_("using default \"%s\" instead"), entry->default_value);
1405 goto again;
1407 return False;
1410 val_x = WMGetFromPLString(elem_x);
1411 val_y = WMGetFromPLString(elem_y);
1413 if (sscanf(val_x, "%i", &data.x) != 1 || sscanf(val_y, "%i", &data.y) != 1) {
1414 wwarning(_("can't convert array to integers for \"%s\"."), entry->key);
1415 if (changed == 0) {
1416 value = entry->plvalue;
1417 changed = 1;
1418 wwarning(_("using default \"%s\" instead"), entry->default_value);
1419 goto again;
1421 return False;
1424 if (data.x < 0)
1425 data.x = 0;
1426 else if (data.x > scr->scr_width / 3)
1427 data.x = scr->scr_width / 3;
1428 if (data.y < 0)
1429 data.y = 0;
1430 else if (data.y > scr->scr_height / 3)
1431 data.y = scr->scr_height / 3;
1433 if (ret)
1434 *ret = &data;
1435 if (addr)
1436 *(WCoord *) addr = data;
1438 return True;
1441 static int getPropList(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1443 /* Parameter not used, but tell the compiler that it is ok */
1444 (void) scr;
1445 (void) entry;
1446 (void) addr;
1448 WMRetainPropList(value);
1450 *ret = value;
1452 return True;
1455 static int getPathList(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1457 static char *data;
1458 int i, count, len;
1459 char *ptr;
1460 WMPropList *d;
1461 int changed = 0;
1463 /* Parameter not used, but tell the compiler that it is ok */
1464 (void) scr;
1465 (void) ret;
1467 again:
1468 if (!WMIsPLArray(value)) {
1469 wwarning(_("Wrong option format for key \"%s\". Should be %s."), entry->key, "an array of paths");
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 i = 0;
1480 count = WMGetPropListItemCount(value);
1481 if (count < 1) {
1482 if (changed == 0) {
1483 value = entry->plvalue;
1484 changed = 1;
1485 wwarning(_("using default \"%s\" instead"), entry->default_value);
1486 goto again;
1488 return False;
1491 len = 0;
1492 for (i = 0; i < count; i++) {
1493 d = WMGetFromPLArray(value, i);
1494 if (!d || !WMIsPLString(d)) {
1495 count = i;
1496 break;
1498 len += strlen(WMGetFromPLString(d)) + 1;
1501 ptr = data = wmalloc(len + 1);
1503 for (i = 0; i < count; i++) {
1504 d = WMGetFromPLArray(value, i);
1505 if (!d || !WMIsPLString(d)) {
1506 break;
1508 strcpy(ptr, WMGetFromPLString(d));
1509 ptr += strlen(WMGetFromPLString(d));
1510 *ptr = ':';
1511 ptr++;
1513 ptr--;
1514 *(ptr--) = 0;
1516 if (*(char **)addr != NULL) {
1517 wfree(*(char **)addr);
1519 *(char **)addr = data;
1521 return True;
1524 static int getEnum(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1526 static signed char data;
1528 /* Parameter not used, but tell the compiler that it is ok */
1529 (void) scr;
1531 data = string2index(entry->plkey, value, entry->default_value, (WOptionEnumeration *) entry->extra_data);
1532 if (data < 0)
1533 return False;
1535 if (ret)
1536 *ret = &data;
1537 if (addr)
1538 *(signed char *)addr = data;
1540 return True;
1544 * (solid <color>)
1545 * (hgradient <color> <color>)
1546 * (vgradient <color> <color>)
1547 * (dgradient <color> <color>)
1548 * (mhgradient <color> <color> ...)
1549 * (mvgradient <color> <color> ...)
1550 * (mdgradient <color> <color> ...)
1551 * (igradient <color1> <color1> <thickness1> <color2> <color2> <thickness2>)
1552 * (tpixmap <file> <color>)
1553 * (spixmap <file> <color>)
1554 * (cpixmap <file> <color>)
1555 * (thgradient <file> <opaqueness> <color> <color>)
1556 * (tvgradient <file> <opaqueness> <color> <color>)
1557 * (tdgradient <file> <opaqueness> <color> <color>)
1558 * (function <lib> <function> ...)
1561 static WTexture *parse_texture(WScreen * scr, WMPropList * pl)
1563 WMPropList *elem;
1564 char *val;
1565 int nelem;
1566 WTexture *texture = NULL;
1568 nelem = WMGetPropListItemCount(pl);
1569 if (nelem < 1)
1570 return NULL;
1572 elem = WMGetFromPLArray(pl, 0);
1573 if (!elem || !WMIsPLString(elem))
1574 return NULL;
1575 val = WMGetFromPLString(elem);
1577 if (strcasecmp(val, "solid") == 0) {
1578 XColor color;
1580 if (nelem != 2)
1581 return NULL;
1583 /* get color */
1585 elem = WMGetFromPLArray(pl, 1);
1586 if (!elem || !WMIsPLString(elem))
1587 return NULL;
1588 val = WMGetFromPLString(elem);
1590 if (!XParseColor(dpy, scr->w_colormap, val, &color)) {
1591 wwarning(_("\"%s\" is not a valid color name"), val);
1592 return NULL;
1595 texture = (WTexture *) wTextureMakeSolid(scr, &color);
1596 } else if (strcasecmp(val, "dgradient") == 0
1597 || strcasecmp(val, "vgradient") == 0 || strcasecmp(val, "hgradient") == 0) {
1598 RColor color1, color2;
1599 XColor xcolor;
1600 int type;
1602 if (nelem != 3) {
1603 wwarning(_("bad number of arguments in gradient specification"));
1604 return NULL;
1607 if (val[0] == 'd' || val[0] == 'D')
1608 type = WTEX_DGRADIENT;
1609 else if (val[0] == 'h' || val[0] == 'H')
1610 type = WTEX_HGRADIENT;
1611 else
1612 type = WTEX_VGRADIENT;
1614 /* get from color */
1615 elem = WMGetFromPLArray(pl, 1);
1616 if (!elem || !WMIsPLString(elem))
1617 return NULL;
1618 val = WMGetFromPLString(elem);
1620 if (!XParseColor(dpy, scr->w_colormap, val, &xcolor)) {
1621 wwarning(_("\"%s\" is not a valid color name"), val);
1622 return NULL;
1624 color1.alpha = 255;
1625 color1.red = xcolor.red >> 8;
1626 color1.green = xcolor.green >> 8;
1627 color1.blue = xcolor.blue >> 8;
1629 /* get to color */
1630 elem = WMGetFromPLArray(pl, 2);
1631 if (!elem || !WMIsPLString(elem)) {
1632 return NULL;
1634 val = WMGetFromPLString(elem);
1636 if (!XParseColor(dpy, scr->w_colormap, val, &xcolor)) {
1637 wwarning(_("\"%s\" is not a valid color name"), val);
1638 return NULL;
1640 color2.alpha = 255;
1641 color2.red = xcolor.red >> 8;
1642 color2.green = xcolor.green >> 8;
1643 color2.blue = xcolor.blue >> 8;
1645 texture = (WTexture *) wTextureMakeGradient(scr, type, &color1, &color2);
1647 } else if (strcasecmp(val, "igradient") == 0) {
1648 RColor colors1[2], colors2[2];
1649 int th1, th2;
1650 XColor xcolor;
1651 int i;
1653 if (nelem != 7) {
1654 wwarning(_("bad number of arguments in gradient specification"));
1655 return NULL;
1658 /* get from color */
1659 for (i = 0; i < 2; i++) {
1660 elem = WMGetFromPLArray(pl, 1 + i);
1661 if (!elem || !WMIsPLString(elem))
1662 return NULL;
1663 val = WMGetFromPLString(elem);
1665 if (!XParseColor(dpy, scr->w_colormap, val, &xcolor)) {
1666 wwarning(_("\"%s\" is not a valid color name"), val);
1667 return NULL;
1669 colors1[i].alpha = 255;
1670 colors1[i].red = xcolor.red >> 8;
1671 colors1[i].green = xcolor.green >> 8;
1672 colors1[i].blue = xcolor.blue >> 8;
1674 elem = WMGetFromPLArray(pl, 3);
1675 if (!elem || !WMIsPLString(elem))
1676 return NULL;
1677 val = WMGetFromPLString(elem);
1678 th1 = atoi(val);
1680 /* get from color */
1681 for (i = 0; i < 2; i++) {
1682 elem = WMGetFromPLArray(pl, 4 + i);
1683 if (!elem || !WMIsPLString(elem))
1684 return NULL;
1685 val = WMGetFromPLString(elem);
1687 if (!XParseColor(dpy, scr->w_colormap, val, &xcolor)) {
1688 wwarning(_("\"%s\" is not a valid color name"), val);
1689 return NULL;
1691 colors2[i].alpha = 255;
1692 colors2[i].red = xcolor.red >> 8;
1693 colors2[i].green = xcolor.green >> 8;
1694 colors2[i].blue = xcolor.blue >> 8;
1696 elem = WMGetFromPLArray(pl, 6);
1697 if (!elem || !WMIsPLString(elem))
1698 return NULL;
1699 val = WMGetFromPLString(elem);
1700 th2 = atoi(val);
1702 texture = (WTexture *) wTextureMakeIGradient(scr, th1, colors1, th2, colors2);
1704 } else if (strcasecmp(val, "mhgradient") == 0
1705 || strcasecmp(val, "mvgradient") == 0 || strcasecmp(val, "mdgradient") == 0) {
1706 XColor color;
1707 RColor **colors;
1708 int i, count;
1709 int type;
1711 if (nelem < 3) {
1712 wwarning(_("too few arguments in multicolor gradient specification"));
1713 return NULL;
1716 if (val[1] == 'h' || val[1] == 'H')
1717 type = WTEX_MHGRADIENT;
1718 else if (val[1] == 'v' || val[1] == 'V')
1719 type = WTEX_MVGRADIENT;
1720 else
1721 type = WTEX_MDGRADIENT;
1723 count = nelem - 1;
1725 colors = wmalloc(sizeof(RColor *) * (count + 1));
1727 for (i = 0; i < count; i++) {
1728 elem = WMGetFromPLArray(pl, i + 1);
1729 if (!elem || !WMIsPLString(elem)) {
1730 for (--i; i >= 0; --i) {
1731 wfree(colors[i]);
1733 wfree(colors);
1734 return NULL;
1736 val = WMGetFromPLString(elem);
1738 if (!XParseColor(dpy, scr->w_colormap, val, &color)) {
1739 wwarning(_("\"%s\" is not a valid color name"), val);
1740 for (--i; i >= 0; --i) {
1741 wfree(colors[i]);
1743 wfree(colors);
1744 return NULL;
1745 } else {
1746 colors[i] = wmalloc(sizeof(RColor));
1747 colors[i]->red = color.red >> 8;
1748 colors[i]->green = color.green >> 8;
1749 colors[i]->blue = color.blue >> 8;
1752 colors[i] = NULL;
1754 texture = (WTexture *) wTextureMakeMGradient(scr, type, colors);
1755 } else if (strcasecmp(val, "spixmap") == 0 ||
1756 strcasecmp(val, "cpixmap") == 0 || strcasecmp(val, "tpixmap") == 0) {
1757 XColor color;
1758 int type;
1760 if (nelem != 3)
1761 return NULL;
1763 if (val[0] == 's' || val[0] == 'S')
1764 type = WTP_SCALE;
1765 else if (val[0] == 'c' || val[0] == 'C')
1766 type = WTP_CENTER;
1767 else
1768 type = WTP_TILE;
1770 /* get color */
1771 elem = WMGetFromPLArray(pl, 2);
1772 if (!elem || !WMIsPLString(elem)) {
1773 return NULL;
1775 val = WMGetFromPLString(elem);
1777 if (!XParseColor(dpy, scr->w_colormap, val, &color)) {
1778 wwarning(_("\"%s\" is not a valid color name"), val);
1779 return NULL;
1782 /* file name */
1783 elem = WMGetFromPLArray(pl, 1);
1784 if (!elem || !WMIsPLString(elem))
1785 return NULL;
1786 val = WMGetFromPLString(elem);
1788 texture = (WTexture *) wTextureMakePixmap(scr, type, val, &color);
1789 } else if (strcasecmp(val, "thgradient") == 0
1790 || strcasecmp(val, "tvgradient") == 0 || strcasecmp(val, "tdgradient") == 0) {
1791 RColor color1, color2;
1792 XColor xcolor;
1793 int opacity;
1794 int style;
1796 if (val[1] == 'h' || val[1] == 'H')
1797 style = WTEX_THGRADIENT;
1798 else if (val[1] == 'v' || val[1] == 'V')
1799 style = WTEX_TVGRADIENT;
1800 else
1801 style = WTEX_TDGRADIENT;
1803 if (nelem != 5) {
1804 wwarning(_("bad number of arguments in textured gradient specification"));
1805 return NULL;
1808 /* get from color */
1809 elem = WMGetFromPLArray(pl, 3);
1810 if (!elem || !WMIsPLString(elem))
1811 return NULL;
1812 val = WMGetFromPLString(elem);
1814 if (!XParseColor(dpy, scr->w_colormap, val, &xcolor)) {
1815 wwarning(_("\"%s\" is not a valid color name"), val);
1816 return NULL;
1818 color1.alpha = 255;
1819 color1.red = xcolor.red >> 8;
1820 color1.green = xcolor.green >> 8;
1821 color1.blue = xcolor.blue >> 8;
1823 /* get to color */
1824 elem = WMGetFromPLArray(pl, 4);
1825 if (!elem || !WMIsPLString(elem)) {
1826 return NULL;
1828 val = WMGetFromPLString(elem);
1830 if (!XParseColor(dpy, scr->w_colormap, val, &xcolor)) {
1831 wwarning(_("\"%s\" is not a valid color name"), val);
1832 return NULL;
1834 color2.alpha = 255;
1835 color2.red = xcolor.red >> 8;
1836 color2.green = xcolor.green >> 8;
1837 color2.blue = xcolor.blue >> 8;
1839 /* get opacity */
1840 elem = WMGetFromPLArray(pl, 2);
1841 if (!elem || !WMIsPLString(elem))
1842 opacity = 128;
1843 else
1844 val = WMGetFromPLString(elem);
1846 if (!val || (opacity = atoi(val)) < 0 || opacity > 255) {
1847 wwarning(_("bad opacity value for tgradient texture \"%s\". Should be [0..255]"), val);
1848 opacity = 128;
1851 /* get file name */
1852 elem = WMGetFromPLArray(pl, 1);
1853 if (!elem || !WMIsPLString(elem))
1854 return NULL;
1855 val = WMGetFromPLString(elem);
1857 texture = (WTexture *) wTextureMakeTGradient(scr, style, &color1, &color2, val, opacity);
1858 } else if (strcasecmp(val, "function") == 0) {
1859 /* Leave this in to handle the unlikely case of
1860 * someone actually having function textures configured */
1861 wwarning("function texture support has been removed");
1862 return NULL;
1863 } else {
1864 wwarning(_("invalid texture type %s"), val);
1865 return NULL;
1867 return texture;
1870 static int getTexture(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1872 static WTexture *texture;
1873 int changed = 0;
1875 again:
1876 if (!WMIsPLArray(value)) {
1877 wwarning(_("Wrong option format for key \"%s\". Should be %s."), entry->key, "Texture");
1878 if (changed == 0) {
1879 value = entry->plvalue;
1880 changed = 1;
1881 wwarning(_("using default \"%s\" instead"), entry->default_value);
1882 goto again;
1884 return False;
1887 if (strcmp(entry->key, "WidgetColor") == 0 && !changed) {
1888 WMPropList *pl;
1890 pl = WMGetFromPLArray(value, 0);
1891 if (!pl || !WMIsPLString(pl) || !WMGetFromPLString(pl)
1892 || strcasecmp(WMGetFromPLString(pl), "solid") != 0) {
1893 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1894 entry->key, "Solid Texture");
1896 value = entry->plvalue;
1897 changed = 1;
1898 wwarning(_("using default \"%s\" instead"), entry->default_value);
1899 goto again;
1903 texture = parse_texture(scr, value);
1905 if (!texture) {
1906 wwarning(_("Error in texture specification for key \"%s\""), entry->key);
1907 if (changed == 0) {
1908 value = entry->plvalue;
1909 changed = 1;
1910 wwarning(_("using default \"%s\" instead"), entry->default_value);
1911 goto again;
1913 return False;
1916 if (ret)
1917 *ret = &texture;
1919 if (addr)
1920 *(WTexture **) addr = texture;
1922 return True;
1925 static int getWSBackground(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1927 WMPropList *elem;
1928 int changed = 0;
1929 char *val;
1930 int nelem;
1932 /* Parameter not used, but tell the compiler that it is ok */
1933 (void) scr;
1934 (void) addr;
1936 again:
1937 if (!WMIsPLArray(value)) {
1938 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1939 "WorkspaceBack", "Texture or None");
1940 if (changed == 0) {
1941 value = entry->plvalue;
1942 changed = 1;
1943 wwarning(_("using default \"%s\" instead"), entry->default_value);
1944 goto again;
1946 return False;
1949 /* only do basic error checking and verify for None texture */
1951 nelem = WMGetPropListItemCount(value);
1952 if (nelem > 0) {
1953 elem = WMGetFromPLArray(value, 0);
1954 if (!elem || !WMIsPLString(elem)) {
1955 wwarning(_("Wrong type for workspace background. Should be a texture type."));
1956 if (changed == 0) {
1957 value = entry->plvalue;
1958 changed = 1;
1959 wwarning(_("using default \"%s\" instead"), entry->default_value);
1960 goto again;
1962 return False;
1964 val = WMGetFromPLString(elem);
1966 if (strcasecmp(val, "None") == 0)
1967 return True;
1969 *ret = WMRetainPropList(value);
1971 return True;
1974 static int
1975 getWSSpecificBackground(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1977 WMPropList *elem;
1978 int nelem;
1979 int changed = 0;
1981 /* Parameter not used, but tell the compiler that it is ok */
1982 (void) scr;
1983 (void) addr;
1985 again:
1986 if (!WMIsPLArray(value)) {
1987 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1988 "WorkspaceSpecificBack", "an array of textures");
1989 if (changed == 0) {
1990 value = entry->plvalue;
1991 changed = 1;
1992 wwarning(_("using default \"%s\" instead"), entry->default_value);
1993 goto again;
1995 return False;
1998 /* only do basic error checking and verify for None texture */
2000 nelem = WMGetPropListItemCount(value);
2001 if (nelem > 0) {
2002 while (nelem--) {
2003 elem = WMGetFromPLArray(value, nelem);
2004 if (!elem || !WMIsPLArray(elem)) {
2005 wwarning(_("Wrong type for background of workspace %i. Should be a texture."),
2006 nelem);
2011 *ret = WMRetainPropList(value);
2013 #ifdef notworking
2015 * Kluge to force wmsetbg helper to set the default background.
2016 * If the WorkspaceSpecificBack is changed once wmaker has started,
2017 * the WorkspaceBack won't be sent to the helper, unless the user
2018 * changes it's value too. So, we must force this by removing the
2019 * value from the defaults DB.
2021 if (!scr->flags.backimage_helper_launched && !scr->flags.startup) {
2022 WMPropList *key = WMCreatePLString("WorkspaceBack");
2024 WMRemoveFromPLDictionary(w_global.domain.wmaker->dictionary, key);
2026 WMReleasePropList(key);
2028 #endif
2029 return True;
2032 static int getFont(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
2034 static WMFont *font;
2035 const char *val;
2037 (void) addr;
2039 GET_STRING_OR_DEFAULT("Font", val);
2041 font = WMCreateFont(scr->wmscreen, val);
2042 if (!font)
2043 font = WMCreateFont(scr->wmscreen, "fixed");
2045 if (!font) {
2046 wfatal(_("could not load any usable font!!!"));
2047 exit(1);
2050 if (ret)
2051 *ret = font;
2053 /* can't assign font value outside update function */
2054 wassertrv(addr == NULL, True);
2056 return True;
2059 static int getColor(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
2061 static XColor color;
2062 const char *val;
2063 int second_pass = 0;
2065 (void) addr;
2067 GET_STRING_OR_DEFAULT("Color", val);
2069 again:
2070 if (!wGetColor(scr, val, &color)) {
2071 wwarning(_("could not get color for key \"%s\""), entry->key);
2072 if (second_pass == 0) {
2073 val = WMGetFromPLString(entry->plvalue);
2074 second_pass = 1;
2075 wwarning(_("using default \"%s\" instead"), val);
2076 goto again;
2078 return False;
2081 if (ret)
2082 *ret = &color;
2084 assert(addr == NULL);
2086 if (addr)
2087 *(unsigned long*)addr = pixel;
2090 return True;
2093 static int getKeybind(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
2095 static WShortKey shortcut;
2096 KeySym ksym;
2097 const char *val;
2098 char *k;
2099 char buf[MAX_SHORTCUT_LENGTH], *b;
2101 /* Parameter not used, but tell the compiler that it is ok */
2102 (void) scr;
2103 (void) addr;
2105 GET_STRING_OR_DEFAULT("Key spec", val);
2107 if (!val || strcasecmp(val, "NONE") == 0) {
2108 shortcut.keycode = 0;
2109 shortcut.modifier = 0;
2110 if (ret)
2111 *ret = &shortcut;
2112 return True;
2115 wstrlcpy(buf, val, MAX_SHORTCUT_LENGTH);
2117 b = (char *)buf;
2119 /* get modifiers */
2120 shortcut.modifier = 0;
2121 while ((k = strchr(b, '+')) != NULL) {
2122 int mod;
2124 *k = 0;
2125 mod = wXModifierFromKey(b);
2126 if (mod < 0) {
2127 wwarning(_("%s: invalid key modifier \"%s\""), entry->key, b);
2128 return False;
2130 shortcut.modifier |= mod;
2132 b = k + 1;
2135 /* get key */
2136 ksym = XStringToKeysym(b);
2138 if (ksym == NoSymbol) {
2139 wwarning(_("%s:invalid kbd shortcut specification \"%s\""), entry->key, val);
2140 return False;
2143 shortcut.keycode = XKeysymToKeycode(dpy, ksym);
2144 if (shortcut.keycode == 0) {
2145 wwarning(_("%s:invalid key in shortcut \"%s\""), entry->key, val);
2146 return False;
2149 if (ret)
2150 *ret = &shortcut;
2152 return True;
2155 static int getModMask(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
2157 static int mask;
2158 const char *str;
2160 /* Parameter not used, but tell the compiler that it is ok */
2161 (void) scr;
2163 GET_STRING_OR_DEFAULT("Modifier Key", str);
2165 if (!str)
2166 return False;
2168 mask = wXModifierFromKey(str);
2169 if (mask < 0) {
2170 wwarning(_("%s: modifier key %s is not valid"), entry->key, str);
2171 mask = 0;
2172 return False;
2175 if (addr)
2176 *(int *)addr = mask;
2178 if (ret)
2179 *ret = &mask;
2181 return True;
2184 # include <X11/cursorfont.h>
2185 typedef struct {
2186 const char *name;
2187 int id;
2188 } WCursorLookup;
2190 #define CURSOR_ID_NONE (XC_num_glyphs)
2192 static const WCursorLookup cursor_table[] = {
2193 {"X_cursor", XC_X_cursor},
2194 {"arrow", XC_arrow},
2195 {"based_arrow_down", XC_based_arrow_down},
2196 {"based_arrow_up", XC_based_arrow_up},
2197 {"boat", XC_boat},
2198 {"bogosity", XC_bogosity},
2199 {"bottom_left_corner", XC_bottom_left_corner},
2200 {"bottom_right_corner", XC_bottom_right_corner},
2201 {"bottom_side", XC_bottom_side},
2202 {"bottom_tee", XC_bottom_tee},
2203 {"box_spiral", XC_box_spiral},
2204 {"center_ptr", XC_center_ptr},
2205 {"circle", XC_circle},
2206 {"clock", XC_clock},
2207 {"coffee_mug", XC_coffee_mug},
2208 {"cross", XC_cross},
2209 {"cross_reverse", XC_cross_reverse},
2210 {"crosshair", XC_crosshair},
2211 {"diamond_cross", XC_diamond_cross},
2212 {"dot", XC_dot},
2213 {"dotbox", XC_dotbox},
2214 {"double_arrow", XC_double_arrow},
2215 {"draft_large", XC_draft_large},
2216 {"draft_small", XC_draft_small},
2217 {"draped_box", XC_draped_box},
2218 {"exchange", XC_exchange},
2219 {"fleur", XC_fleur},
2220 {"gobbler", XC_gobbler},
2221 {"gumby", XC_gumby},
2222 {"hand1", XC_hand1},
2223 {"hand2", XC_hand2},
2224 {"heart", XC_heart},
2225 {"icon", XC_icon},
2226 {"iron_cross", XC_iron_cross},
2227 {"left_ptr", XC_left_ptr},
2228 {"left_side", XC_left_side},
2229 {"left_tee", XC_left_tee},
2230 {"leftbutton", XC_leftbutton},
2231 {"ll_angle", XC_ll_angle},
2232 {"lr_angle", XC_lr_angle},
2233 {"man", XC_man},
2234 {"middlebutton", XC_middlebutton},
2235 {"mouse", XC_mouse},
2236 {"pencil", XC_pencil},
2237 {"pirate", XC_pirate},
2238 {"plus", XC_plus},
2239 {"question_arrow", XC_question_arrow},
2240 {"right_ptr", XC_right_ptr},
2241 {"right_side", XC_right_side},
2242 {"right_tee", XC_right_tee},
2243 {"rightbutton", XC_rightbutton},
2244 {"rtl_logo", XC_rtl_logo},
2245 {"sailboat", XC_sailboat},
2246 {"sb_down_arrow", XC_sb_down_arrow},
2247 {"sb_h_double_arrow", XC_sb_h_double_arrow},
2248 {"sb_left_arrow", XC_sb_left_arrow},
2249 {"sb_right_arrow", XC_sb_right_arrow},
2250 {"sb_up_arrow", XC_sb_up_arrow},
2251 {"sb_v_double_arrow", XC_sb_v_double_arrow},
2252 {"shuttle", XC_shuttle},
2253 {"sizing", XC_sizing},
2254 {"spider", XC_spider},
2255 {"spraycan", XC_spraycan},
2256 {"star", XC_star},
2257 {"target", XC_target},
2258 {"tcross", XC_tcross},
2259 {"top_left_arrow", XC_top_left_arrow},
2260 {"top_left_corner", XC_top_left_corner},
2261 {"top_right_corner", XC_top_right_corner},
2262 {"top_side", XC_top_side},
2263 {"top_tee", XC_top_tee},
2264 {"trek", XC_trek},
2265 {"ul_angle", XC_ul_angle},
2266 {"umbrella", XC_umbrella},
2267 {"ur_angle", XC_ur_angle},
2268 {"watch", XC_watch},
2269 {"xterm", XC_xterm},
2270 {NULL, CURSOR_ID_NONE}
2273 static void check_bitmap_status(int status, const char *filename, Pixmap bitmap)
2275 switch (status) {
2276 case BitmapOpenFailed:
2277 wwarning(_("failed to open bitmap file \"%s\""), filename);
2278 break;
2279 case BitmapFileInvalid:
2280 wwarning(_("\"%s\" is not a valid bitmap file"), filename);
2281 break;
2282 case BitmapNoMemory:
2283 wwarning(_("out of memory reading bitmap file \"%s\""), filename);
2284 break;
2285 case BitmapSuccess:
2286 XFreePixmap(dpy, bitmap);
2287 break;
2292 * (none)
2293 * (builtin, <cursor_name>)
2294 * (bitmap, <cursor_bitmap>, <cursor_mask>)
2296 static int parse_cursor(WScreen * scr, WMPropList * pl, Cursor * cursor)
2298 WMPropList *elem;
2299 char *val;
2300 int nelem;
2301 int status = 0;
2303 nelem = WMGetPropListItemCount(pl);
2304 if (nelem < 1) {
2305 return (status);
2307 elem = WMGetFromPLArray(pl, 0);
2308 if (!elem || !WMIsPLString(elem)) {
2309 return (status);
2311 val = WMGetFromPLString(elem);
2313 if (strcasecmp(val, "none") == 0) {
2314 status = 1;
2315 *cursor = None;
2316 } else if (strcasecmp(val, "builtin") == 0) {
2317 int i;
2318 int cursor_id = CURSOR_ID_NONE;
2320 if (nelem != 2) {
2321 wwarning(_("bad number of arguments in cursor specification"));
2322 return (status);
2324 elem = WMGetFromPLArray(pl, 1);
2325 if (!elem || !WMIsPLString(elem)) {
2326 return (status);
2328 val = WMGetFromPLString(elem);
2330 for (i = 0; cursor_table[i].name != NULL; i++) {
2331 if (strcasecmp(val, cursor_table[i].name) == 0) {
2332 cursor_id = cursor_table[i].id;
2333 break;
2336 if (CURSOR_ID_NONE == cursor_id) {
2337 wwarning(_("unknown builtin cursor name \"%s\""), val);
2338 } else {
2339 *cursor = XCreateFontCursor(dpy, cursor_id);
2340 status = 1;
2342 } else if (strcasecmp(val, "bitmap") == 0) {
2343 char *bitmap_name;
2344 char *mask_name;
2345 int bitmap_status;
2346 int mask_status;
2347 Pixmap bitmap;
2348 Pixmap mask;
2349 unsigned int w, h;
2350 int x, y;
2351 XColor fg, bg;
2353 if (nelem != 3) {
2354 wwarning(_("bad number of arguments in cursor specification"));
2355 return (status);
2357 elem = WMGetFromPLArray(pl, 1);
2358 if (!elem || !WMIsPLString(elem)) {
2359 return (status);
2361 val = WMGetFromPLString(elem);
2362 bitmap_name = FindImage(wPreferences.pixmap_path, val);
2363 if (!bitmap_name) {
2364 wwarning(_("could not find cursor bitmap file \"%s\""), val);
2365 return (status);
2367 elem = WMGetFromPLArray(pl, 2);
2368 if (!elem || !WMIsPLString(elem)) {
2369 wfree(bitmap_name);
2370 return (status);
2372 val = WMGetFromPLString(elem);
2373 mask_name = FindImage(wPreferences.pixmap_path, val);
2374 if (!mask_name) {
2375 wfree(bitmap_name);
2376 wwarning(_("could not find cursor bitmap file \"%s\""), val);
2377 return (status);
2379 mask_status = XReadBitmapFile(dpy, scr->w_win, mask_name, &w, &h, &mask, &x, &y);
2380 bitmap_status = XReadBitmapFile(dpy, scr->w_win, bitmap_name, &w, &h, &bitmap, &x, &y);
2381 if ((BitmapSuccess == bitmap_status) && (BitmapSuccess == mask_status)) {
2382 fg.pixel = scr->black_pixel;
2383 bg.pixel = scr->white_pixel;
2384 XQueryColor(dpy, scr->w_colormap, &fg);
2385 XQueryColor(dpy, scr->w_colormap, &bg);
2386 *cursor = XCreatePixmapCursor(dpy, bitmap, mask, &fg, &bg, x, y);
2387 status = 1;
2389 check_bitmap_status(bitmap_status, bitmap_name, bitmap);
2390 check_bitmap_status(mask_status, mask_name, mask);
2391 wfree(bitmap_name);
2392 wfree(mask_name);
2394 return (status);
2397 static int getCursor(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
2399 static Cursor cursor;
2400 int status;
2401 int changed = 0;
2403 again:
2404 if (!WMIsPLArray(value)) {
2405 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
2406 entry->key, "cursor specification");
2407 if (!changed) {
2408 value = entry->plvalue;
2409 changed = 1;
2410 wwarning(_("using default \"%s\" instead"), entry->default_value);
2411 goto again;
2413 return (False);
2415 status = parse_cursor(scr, value, &cursor);
2416 if (!status) {
2417 wwarning(_("Error in cursor specification for key \"%s\""), entry->key);
2418 if (!changed) {
2419 value = entry->plvalue;
2420 changed = 1;
2421 wwarning(_("using default \"%s\" instead"), entry->default_value);
2422 goto again;
2424 return (False);
2426 if (ret) {
2427 *ret = &cursor;
2429 if (addr) {
2430 *(Cursor *) addr = cursor;
2432 return (True);
2435 #undef CURSOR_ID_NONE
2437 /* ---------------- value setting functions --------------- */
2438 static int setJustify(WScreen * scr, WDefaultEntry * entry, void *tdata, void *extra_data)
2440 /* Parameter not used, but tell the compiler that it is ok */
2441 (void) scr;
2442 (void) entry;
2443 (void) tdata;
2444 (void) extra_data;
2446 return REFRESH_WINDOW_TITLE_COLOR;
2449 static int setClearance(WScreen * scr, WDefaultEntry * entry, void *bar, void *foo)
2451 /* Parameter not used, but tell the compiler that it is ok */
2452 (void) scr;
2453 (void) entry;
2454 (void) bar;
2455 (void) foo;
2457 return REFRESH_WINDOW_FONT | REFRESH_BUTTON_IMAGES | REFRESH_MENU_TITLE_FONT | REFRESH_MENU_FONT;
2460 static int setIfDockPresent(WScreen * scr, WDefaultEntry * entry, void *tdata, void *extra_data)
2462 char *flag = tdata;
2463 long which = (long) extra_data;
2465 /* Parameter not used, but tell the compiler that it is ok */
2466 (void) scr;
2467 (void) entry;
2469 switch (which) {
2470 case WM_DOCK:
2471 wPreferences.flags.nodock = wPreferences.flags.nodock || *flag;
2472 // Drawers require the dock
2473 wPreferences.flags.nodrawer = wPreferences.flags.nodrawer || wPreferences.flags.nodock;
2474 break;
2475 case WM_CLIP:
2476 wPreferences.flags.noclip = wPreferences.flags.noclip || *flag;
2477 break;
2478 case WM_DRAWER:
2479 wPreferences.flags.nodrawer = wPreferences.flags.nodrawer || *flag;
2480 break;
2481 default:
2482 break;
2484 return 0;
2487 static int setClipMergedInDock(WScreen *scr, WDefaultEntry *entry, void *tdata, void *foo)
2489 char *flag = tdata;
2491 /* Parameter not used, but tell the compiler that it is ok */
2492 (void) scr;
2493 (void) entry;
2494 (void) foo;
2496 wPreferences.flags.clip_merged_in_dock = *flag;
2497 wPreferences.flags.noclip = wPreferences.flags.noclip || *flag;
2498 return 0;
2501 static int setWrapAppiconsInDock(WScreen *scr, WDefaultEntry *entry, void *tdata, void *foo)
2503 char *flag = tdata;
2505 /* Parameter not used, but tell the compiler that it is ok */
2506 (void) scr;
2507 (void) entry;
2508 (void) foo;
2510 wPreferences.flags.wrap_appicons_in_dock = *flag;
2511 return 0;
2514 static int setStickyIcons(WScreen * scr, WDefaultEntry * entry, void *bar, void *foo)
2516 /* Parameter not used, but tell the compiler that it is ok */
2517 (void) entry;
2518 (void) bar;
2519 (void) foo;
2521 if (w_global.workspace.array) {
2522 wWorkspaceForceChange(scr, w_global.workspace.current);
2523 wArrangeIcons(scr, False);
2525 return 0;
2528 static int setIconTile(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2530 Pixmap pixmap;
2531 RImage *img;
2532 WTexture ** texture = tdata;
2533 int reset = 0;
2535 /* Parameter not used, but tell the compiler that it is ok */
2536 (void) foo;
2538 img = wTextureRenderImage(*texture, wPreferences.icon_size,
2539 wPreferences.icon_size, ((*texture)->any.type & WREL_BORDER_MASK)
2540 ? WREL_ICON : WREL_FLAT);
2541 if (!img) {
2542 wwarning(_("could not render texture for icon background"));
2543 if (!entry->addr)
2544 wTextureDestroy(scr, *texture);
2545 return 0;
2547 RConvertImage(scr->rcontext, img, &pixmap);
2549 if (scr->icon_tile) {
2550 reset = 1;
2551 RReleaseImage(scr->icon_tile);
2552 XFreePixmap(dpy, scr->icon_tile_pixmap);
2555 scr->icon_tile = img;
2557 /* put the icon in the noticeboard hint */
2558 PropSetIconTileHint(scr, img);
2560 if (!wPreferences.flags.noclip || wPreferences.flags.clip_merged_in_dock) {
2561 if (scr->clip_tile) {
2562 RReleaseImage(scr->clip_tile);
2564 scr->clip_tile = wClipMakeTile(img);
2567 if (!wPreferences.flags.nodrawer) {
2568 if (scr->drawer_tile) {
2569 RReleaseImage(scr->drawer_tile);
2571 scr->drawer_tile = wDrawerMakeTile(scr, img);
2574 scr->icon_tile_pixmap = pixmap;
2576 if (scr->def_icon_rimage) {
2577 RReleaseImage(scr->def_icon_rimage);
2578 scr->def_icon_rimage = NULL;
2581 if (scr->icon_back_texture)
2582 wTextureDestroy(scr, (WTexture *) scr->icon_back_texture);
2584 scr->icon_back_texture = wTextureMakeSolid(scr, &((*texture)->any.color));
2586 /* Free the texture as nobody else will use it, nor refer to it. */
2587 if (!entry->addr)
2588 wTextureDestroy(scr, *texture);
2590 return (reset ? REFRESH_ICON_TILE : 0);
2593 static int setWinTitleFont(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2595 WMFont *font = tdata;
2597 /* Parameter not used, but tell the compiler that it is ok */
2598 (void) entry;
2599 (void) foo;
2601 if (scr->title_font) {
2602 WMReleaseFont(scr->title_font);
2604 scr->title_font = font;
2606 return REFRESH_WINDOW_FONT | REFRESH_BUTTON_IMAGES;
2609 static int setMenuTitleFont(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2611 WMFont *font = tdata;
2613 /* Parameter not used, but tell the compiler that it is ok */
2614 (void) entry;
2615 (void) foo;
2617 if (scr->menu_title_font) {
2618 WMReleaseFont(scr->menu_title_font);
2621 scr->menu_title_font = font;
2623 return REFRESH_MENU_TITLE_FONT;
2626 static int setMenuTextFont(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2628 WMFont *font = tdata;
2630 /* Parameter not used, but tell the compiler that it is ok */
2631 (void) entry;
2632 (void) foo;
2634 if (scr->menu_entry_font) {
2635 WMReleaseFont(scr->menu_entry_font);
2637 scr->menu_entry_font = font;
2639 return REFRESH_MENU_FONT;
2642 static int setIconTitleFont(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2644 WMFont *font = tdata;
2646 /* Parameter not used, but tell the compiler that it is ok */
2647 (void) entry;
2648 (void) foo;
2650 if (scr->icon_title_font) {
2651 WMReleaseFont(scr->icon_title_font);
2654 scr->icon_title_font = font;
2656 return REFRESH_ICON_FONT;
2659 static int setClipTitleFont(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2661 WMFont *font = tdata;
2663 /* Parameter not used, but tell the compiler that it is ok */
2664 (void) entry;
2665 (void) foo;
2667 if (scr->clip_title_font) {
2668 WMReleaseFont(scr->clip_title_font);
2671 scr->clip_title_font = font;
2673 return REFRESH_ICON_FONT;
2676 static int setLargeDisplayFont(WScreen *scr, WDefaultEntry *entry, void *tdata, void *foo)
2678 WMFont *font = tdata;
2680 /* Parameter not used, but tell the compiler that it is ok */
2681 (void) scr;
2682 (void) entry;
2683 (void) foo;
2685 if (w_global.workspace.font_for_name)
2686 WMReleaseFont(w_global.workspace.font_for_name);
2688 w_global.workspace.font_for_name = font;
2690 return 0;
2693 static int setHightlight(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2695 XColor *color = tdata;
2697 /* Parameter not used, but tell the compiler that it is ok */
2698 (void) entry;
2699 (void) foo;
2701 if (scr->select_color)
2702 WMReleaseColor(scr->select_color);
2704 scr->select_color = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2706 wFreeColor(scr, color->pixel);
2708 return REFRESH_MENU_COLOR;
2711 static int setHightlightText(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2713 XColor *color = tdata;
2715 /* Parameter not used, but tell the compiler that it is ok */
2716 (void) entry;
2717 (void) foo;
2719 if (scr->select_text_color)
2720 WMReleaseColor(scr->select_text_color);
2722 scr->select_text_color = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2724 wFreeColor(scr, color->pixel);
2726 return REFRESH_MENU_COLOR;
2729 static int setClipTitleColor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *extra_data)
2731 XColor *color = tdata;
2732 long widx = (long) extra_data;
2734 /* Parameter not used, but tell the compiler that it is ok */
2735 (void) entry;
2737 if (scr->clip_title_color[widx])
2738 WMReleaseColor(scr->clip_title_color[widx]);
2740 scr->clip_title_color[widx] = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2741 wFreeColor(scr, color->pixel);
2743 return REFRESH_ICON_TITLE_COLOR;
2746 static int setWTitleColor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *extra_data)
2748 XColor *color = tdata;
2749 long widx = (long) extra_data;
2751 /* Parameter not used, but tell the compiler that it is ok */
2752 (void) entry;
2754 if (scr->window_title_color[widx])
2755 WMReleaseColor(scr->window_title_color[widx]);
2757 scr->window_title_color[widx] =
2758 WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2760 wFreeColor(scr, color->pixel);
2762 return REFRESH_WINDOW_TITLE_COLOR;
2765 static int setMenuTitleColor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *extra_data)
2767 XColor *color = tdata;
2769 /* Parameter not used, but tell the compiler that it is ok */
2770 (void) entry;
2771 (void) extra_data;
2773 if (scr->menu_title_color[0])
2774 WMReleaseColor(scr->menu_title_color[0]);
2776 scr->menu_title_color[0] = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2778 wFreeColor(scr, color->pixel);
2780 return REFRESH_MENU_TITLE_COLOR;
2783 static int setMenuTextColor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2785 XColor *color = tdata;
2787 /* Parameter not used, but tell the compiler that it is ok */
2788 (void) entry;
2789 (void) foo;
2791 if (scr->mtext_color)
2792 WMReleaseColor(scr->mtext_color);
2794 scr->mtext_color = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2796 if (WMColorPixel(scr->dtext_color) == WMColorPixel(scr->mtext_color)) {
2797 WMSetColorAlpha(scr->dtext_color, 0x7fff);
2798 } else {
2799 WMSetColorAlpha(scr->dtext_color, 0xffff);
2802 wFreeColor(scr, color->pixel);
2804 return REFRESH_MENU_COLOR;
2807 static int setMenuDisabledColor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2809 XColor *color = tdata;
2811 /* Parameter not used, but tell the compiler that it is ok */
2812 (void) entry;
2813 (void) foo;
2815 if (scr->dtext_color)
2816 WMReleaseColor(scr->dtext_color);
2818 scr->dtext_color = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2820 if (WMColorPixel(scr->dtext_color) == WMColorPixel(scr->mtext_color)) {
2821 WMSetColorAlpha(scr->dtext_color, 0x7fff);
2822 } else {
2823 WMSetColorAlpha(scr->dtext_color, 0xffff);
2826 wFreeColor(scr, color->pixel);
2828 return REFRESH_MENU_COLOR;
2831 static int setIconTitleColor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2833 XColor *color = tdata;
2835 /* Parameter not used, but tell the compiler that it is ok */
2836 (void) entry;
2837 (void) foo;
2839 if (scr->icon_title_color)
2840 WMReleaseColor(scr->icon_title_color);
2841 scr->icon_title_color = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2843 wFreeColor(scr, color->pixel);
2845 return REFRESH_ICON_TITLE_COLOR;
2848 static int setIconTitleBack(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2850 XColor *color = tdata;
2852 /* Parameter not used, but tell the compiler that it is ok */
2853 (void) entry;
2854 (void) foo;
2856 if (scr->icon_title_texture) {
2857 wTextureDestroy(scr, (WTexture *) scr->icon_title_texture);
2859 scr->icon_title_texture = wTextureMakeSolid(scr, color);
2861 return REFRESH_ICON_TITLE_BACK;
2864 static int setFrameBorderWidth(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2866 int *value = tdata;
2868 /* Parameter not used, but tell the compiler that it is ok */
2869 (void) entry;
2870 (void) foo;
2872 scr->frame_border_width = *value;
2874 return REFRESH_FRAME_BORDER;
2877 static int setFrameBorderColor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2879 XColor *color = tdata;
2881 /* Parameter not used, but tell the compiler that it is ok */
2882 (void) entry;
2883 (void) foo;
2885 if (scr->frame_border_color)
2886 WMReleaseColor(scr->frame_border_color);
2887 scr->frame_border_color = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2889 wFreeColor(scr, color->pixel);
2891 return REFRESH_FRAME_BORDER;
2894 static int setFrameSelectedBorderColor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2896 XColor *color = tdata;
2898 /* Parameter not used, but tell the compiler that it is ok */
2899 (void) entry;
2900 (void) foo;
2902 if (scr->frame_selected_border_color)
2903 WMReleaseColor(scr->frame_selected_border_color);
2904 scr->frame_selected_border_color = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2906 wFreeColor(scr, color->pixel);
2908 return REFRESH_FRAME_BORDER;
2911 static void trackDeadProcess(pid_t pid, unsigned int status, void *client_data)
2913 WScreen *scr = (WScreen *) client_data;
2915 /* Parameter not used, but tell the compiler that it is ok */
2916 (void) pid;
2917 (void) status;
2919 close(scr->helper_fd);
2920 scr->helper_fd = 0;
2921 scr->helper_pid = 0;
2922 scr->flags.backimage_helper_launched = 0;
2925 static int setWorkspaceSpecificBack(WScreen * scr, WDefaultEntry * entry, void *tdata, void *bar)
2927 WMPropList *value = tdata;
2928 WMPropList *val;
2929 char *str;
2930 int i;
2932 /* Parameter not used, but tell the compiler that it is ok */
2933 (void) entry;
2934 (void) bar;
2936 if (scr->flags.backimage_helper_launched) {
2937 if (WMGetPropListItemCount(value) == 0) {
2938 SendHelperMessage(scr, 'C', 0, NULL);
2939 SendHelperMessage(scr, 'K', 0, NULL);
2941 WMReleasePropList(value);
2942 return 0;
2944 } else {
2945 pid_t pid;
2946 int filedes[2];
2948 if (WMGetPropListItemCount(value) == 0)
2949 return 0;
2951 if (pipe(filedes) < 0) {
2952 werror("pipe() failed:can't set workspace specific background image");
2954 WMReleasePropList(value);
2955 return 0;
2958 pid = fork();
2959 if (pid < 0) {
2960 werror("fork() failed:can't set workspace specific background image");
2961 if (close(filedes[0]) < 0)
2962 werror("could not close pipe");
2963 if (close(filedes[1]) < 0)
2964 werror("could not close pipe");
2966 } else if (pid == 0) {
2967 char *dither;
2969 SetupEnvironment(scr);
2971 if (close(0) < 0)
2972 werror("could not close pipe");
2973 if (dup(filedes[0]) < 0) {
2974 werror("dup() failed:can't set workspace specific background image");
2976 dither = wPreferences.no_dithering ? "-m" : "-d";
2977 if (wPreferences.smooth_workspace_back)
2978 execlp("wmsetbg", "wmsetbg", "-helper", "-S", dither, NULL);
2979 else
2980 execlp("wmsetbg", "wmsetbg", "-helper", dither, NULL);
2981 werror("could not execute wmsetbg");
2982 exit(1);
2983 } else {
2985 if (fcntl(filedes[0], F_SETFD, FD_CLOEXEC) < 0) {
2986 werror("error setting close-on-exec flag");
2988 if (fcntl(filedes[1], F_SETFD, FD_CLOEXEC) < 0) {
2989 werror("error setting close-on-exec flag");
2992 scr->helper_fd = filedes[1];
2993 scr->helper_pid = pid;
2994 scr->flags.backimage_helper_launched = 1;
2996 wAddDeathHandler(pid, trackDeadProcess, scr);
2998 SendHelperMessage(scr, 'P', -1, wPreferences.pixmap_path);
3003 for (i = 0; i < WMGetPropListItemCount(value); i++) {
3004 val = WMGetFromPLArray(value, i);
3005 if (val && WMIsPLArray(val) && WMGetPropListItemCount(val) > 0) {
3006 str = WMGetPropListDescription(val, False);
3008 SendHelperMessage(scr, 'S', i + 1, str);
3010 wfree(str);
3011 } else {
3012 SendHelperMessage(scr, 'U', i + 1, NULL);
3015 sleep(1);
3017 WMReleasePropList(value);
3018 return 0;
3021 static int setWorkspaceBack(WScreen * scr, WDefaultEntry * entry, void *tdata, void *bar)
3023 WMPropList *value = tdata;
3025 /* Parameter not used, but tell the compiler that it is ok */
3026 (void) entry;
3027 (void) bar;
3029 if (scr->flags.backimage_helper_launched) {
3030 char *str;
3032 if (WMGetPropListItemCount(value) == 0) {
3033 SendHelperMessage(scr, 'U', 0, NULL);
3034 } else {
3035 /* set the default workspace background to this one */
3036 str = WMGetPropListDescription(value, False);
3037 if (str) {
3038 SendHelperMessage(scr, 'S', 0, str);
3039 wfree(str);
3040 SendHelperMessage(scr, 'C', w_global.workspace.current + 1, NULL);
3041 } else {
3042 SendHelperMessage(scr, 'U', 0, NULL);
3045 } else if (WMGetPropListItemCount(value) > 0) {
3046 char *command;
3047 char *text;
3048 char *dither;
3049 int len;
3051 text = WMGetPropListDescription(value, False);
3052 len = strlen(text) + 40;
3053 command = wmalloc(len);
3054 dither = wPreferences.no_dithering ? "-m" : "-d";
3055 if (wPreferences.smooth_workspace_back)
3056 snprintf(command, len, "wmsetbg %s -S -p '%s' &", dither, text);
3057 else
3058 snprintf(command, len, "wmsetbg %s -p '%s' &", dither, text);
3059 wfree(text);
3060 ExecuteShellCommand(scr, command);
3061 wfree(command);
3063 WMReleasePropList(value);
3065 return 0;
3068 static int setWidgetColor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
3070 WTexture **texture = tdata;
3072 /* Parameter not used, but tell the compiler that it is ok */
3073 (void) entry;
3074 (void) foo;
3076 if (scr->widget_texture) {
3077 wTextureDestroy(scr, (WTexture *) scr->widget_texture);
3079 scr->widget_texture = *(WTexSolid **) texture;
3081 return 0;
3084 static int setFTitleBack(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
3086 WTexture **texture = tdata;
3088 /* Parameter not used, but tell the compiler that it is ok */
3089 (void) entry;
3090 (void) foo;
3092 if (scr->window_title_texture[WS_FOCUSED]) {
3093 wTextureDestroy(scr, scr->window_title_texture[WS_FOCUSED]);
3095 scr->window_title_texture[WS_FOCUSED] = *texture;
3097 return REFRESH_WINDOW_TEXTURES;
3100 static int setPTitleBack(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
3102 WTexture **texture = tdata;
3104 /* Parameter not used, but tell the compiler that it is ok */
3105 (void) entry;
3106 (void) foo;
3108 if (scr->window_title_texture[WS_PFOCUSED]) {
3109 wTextureDestroy(scr, scr->window_title_texture[WS_PFOCUSED]);
3111 scr->window_title_texture[WS_PFOCUSED] = *texture;
3113 return REFRESH_WINDOW_TEXTURES;
3116 static int setUTitleBack(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
3118 WTexture **texture = tdata;
3120 /* Parameter not used, but tell the compiler that it is ok */
3121 (void) entry;
3122 (void) foo;
3124 if (scr->window_title_texture[WS_UNFOCUSED]) {
3125 wTextureDestroy(scr, scr->window_title_texture[WS_UNFOCUSED]);
3127 scr->window_title_texture[WS_UNFOCUSED] = *texture;
3129 return REFRESH_WINDOW_TEXTURES;
3132 static int setResizebarBack(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
3134 WTexture **texture = tdata;
3136 /* Parameter not used, but tell the compiler that it is ok */
3137 (void) entry;
3138 (void) foo;
3140 if (scr->resizebar_texture[0]) {
3141 wTextureDestroy(scr, scr->resizebar_texture[0]);
3143 scr->resizebar_texture[0] = *texture;
3145 return REFRESH_WINDOW_TEXTURES;
3148 static int setMenuTitleBack(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
3150 WTexture **texture = tdata;
3152 /* Parameter not used, but tell the compiler that it is ok */
3153 (void) entry;
3154 (void) foo;
3156 if (scr->menu_title_texture[0]) {
3157 wTextureDestroy(scr, scr->menu_title_texture[0]);
3159 scr->menu_title_texture[0] = *texture;
3161 return REFRESH_MENU_TITLE_TEXTURE;
3164 static int setMenuTextBack(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
3166 WTexture **texture = tdata;
3168 /* Parameter not used, but tell the compiler that it is ok */
3169 (void) entry;
3170 (void) foo;
3172 if (scr->menu_item_texture) {
3173 wTextureDestroy(scr, scr->menu_item_texture);
3174 wTextureDestroy(scr, (WTexture *) scr->menu_item_auxtexture);
3176 scr->menu_item_texture = *texture;
3178 scr->menu_item_auxtexture = wTextureMakeSolid(scr, &scr->menu_item_texture->any.color);
3180 return REFRESH_MENU_TEXTURE;
3183 static int setKeyGrab(WScreen * scr, WDefaultEntry * entry, void *tdata, void *extra_data)
3185 WShortKey *shortcut = tdata;
3186 WWindow *wwin;
3187 long widx = (long) extra_data;
3189 /* Parameter not used, but tell the compiler that it is ok */
3190 (void) entry;
3192 wKeyBindings[widx] = *shortcut;
3194 wwin = scr->focused_window;
3196 while (wwin != NULL) {
3197 XUngrabKey(dpy, AnyKey, AnyModifier, wwin->frame->core->window);
3199 if (!WFLAGP(wwin, no_bind_keys)) {
3200 wWindowSetKeyGrabs(wwin);
3202 wwin = wwin->prev;
3205 /* do we need to update window menus? */
3206 if (widx >= WKBD_WORKSPACE1 && widx <= WKBD_WORKSPACE10)
3207 return REFRESH_WORKSPACE_MENU;
3208 if (widx == WKBD_LASTWORKSPACE)
3209 return REFRESH_WORKSPACE_MENU;
3210 if (widx >= WKBD_MOVE_WORKSPACE1 && widx <= WKBD_MOVE_WORKSPACE10)
3211 return REFRESH_WORKSPACE_MENU;
3213 return 0;
3216 static int setIconPosition(WScreen * scr, WDefaultEntry * entry, void *bar, void *foo)
3218 /* Parameter not used, but tell the compiler that it is ok */
3219 (void) entry;
3220 (void) bar;
3221 (void) foo;
3223 wScreenUpdateUsableArea(scr);
3224 wArrangeIcons(scr, True);
3226 return 0;
3229 static int updateUsableArea(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);
3238 return 0;
3241 static int setMenuStyle(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
3243 /* Parameter not used, but tell the compiler that it is ok */
3244 (void) scr;
3245 (void) entry;
3246 (void) tdata;
3247 (void) foo;
3249 return REFRESH_MENU_TEXTURE;
3252 static RImage *chopOffImage(RImage * image, int x, int y, int w, int h)
3254 RImage *img = RCreateImage(w, h, image->format == RRGBAFormat);
3256 RCopyArea(img, image, x, y, w, h, 0, 0);
3258 return img;
3261 static int setSwPOptions(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
3263 WMPropList *array = tdata;
3264 char *path;
3265 RImage *bgimage;
3266 int cwidth, cheight;
3267 struct WPreferences *prefs = foo;
3269 if (!WMIsPLArray(array) || WMGetPropListItemCount(array) == 0) {
3270 if (prefs->swtileImage)
3271 RReleaseImage(prefs->swtileImage);
3272 prefs->swtileImage = NULL;
3274 WMReleasePropList(array);
3275 return 0;
3278 switch (WMGetPropListItemCount(array)) {
3279 case 4:
3280 if (!WMIsPLString(WMGetFromPLArray(array, 1))) {
3281 wwarning(_("Invalid arguments for option \"%s\""), entry->key);
3282 break;
3283 } else
3284 path = FindImage(wPreferences.pixmap_path, WMGetFromPLString(WMGetFromPLArray(array, 1)));
3286 if (!path) {
3287 wwarning(_("Could not find image \"%s\" for option \"%s\""),
3288 WMGetFromPLString(WMGetFromPLArray(array, 1)), entry->key);
3289 } else {
3290 bgimage = RLoadImage(scr->rcontext, path, 0);
3291 if (!bgimage) {
3292 wwarning(_("Could not load image \"%s\" for option \"%s\""), path, entry->key);
3293 wfree(path);
3294 } else {
3295 wfree(path);
3297 cwidth = atoi(WMGetFromPLString(WMGetFromPLArray(array, 2)));
3298 cheight = atoi(WMGetFromPLString(WMGetFromPLArray(array, 3)));
3300 if (cwidth <= 0 || cheight <= 0 ||
3301 cwidth >= bgimage->width - 2 || cheight >= bgimage->height - 2)
3302 wwarning(_("Invalid split sizes for SwitchPanel back image."));
3303 else {
3304 int i;
3305 int swidth, theight;
3306 for (i = 0; i < 9; i++) {
3307 if (prefs->swbackImage[i])
3308 RReleaseImage(prefs->swbackImage[i]);
3309 prefs->swbackImage[i] = NULL;
3311 swidth = (bgimage->width - cwidth) / 2;
3312 theight = (bgimage->height - cheight) / 2;
3314 prefs->swbackImage[0] = chopOffImage(bgimage, 0, 0, swidth, theight);
3315 prefs->swbackImage[1] = chopOffImage(bgimage, swidth, 0, cwidth, theight);
3316 prefs->swbackImage[2] = chopOffImage(bgimage, swidth + cwidth, 0,
3317 swidth, theight);
3319 prefs->swbackImage[3] = chopOffImage(bgimage, 0, theight, swidth, cheight);
3320 prefs->swbackImage[4] = chopOffImage(bgimage, swidth, theight,
3321 cwidth, cheight);
3322 prefs->swbackImage[5] = chopOffImage(bgimage, swidth + cwidth, theight,
3323 swidth, cheight);
3325 prefs->swbackImage[6] = chopOffImage(bgimage, 0, theight + cheight,
3326 swidth, theight);
3327 prefs->swbackImage[7] = chopOffImage(bgimage, swidth, theight + cheight,
3328 cwidth, theight);
3329 prefs->swbackImage[8] =
3330 chopOffImage(bgimage, swidth + cwidth, theight + cheight, swidth,
3331 theight);
3333 // check if anything failed
3334 for (i = 0; i < 9; i++) {
3335 if (!prefs->swbackImage[i]) {
3336 for (; i >= 0; --i) {
3337 RReleaseImage(prefs->swbackImage[i]);
3338 prefs->swbackImage[i] = NULL;
3340 break;
3344 RReleaseImage(bgimage);
3348 case 1:
3349 if (!WMIsPLString(WMGetFromPLArray(array, 0))) {
3350 wwarning(_("Invalid arguments for option \"%s\""), entry->key);
3351 break;
3352 } else
3353 path = FindImage(wPreferences.pixmap_path, WMGetFromPLString(WMGetFromPLArray(array, 0)));
3355 if (!path) {
3356 wwarning(_("Could not find image \"%s\" for option \"%s\""),
3357 WMGetFromPLString(WMGetFromPLArray(array, 0)), entry->key);
3358 } else {
3359 if (prefs->swtileImage)
3360 RReleaseImage(prefs->swtileImage);
3362 prefs->swtileImage = RLoadImage(scr->rcontext, path, 0);
3363 if (!prefs->swtileImage) {
3364 wwarning(_("Could not load image \"%s\" for option \"%s\""), path, entry->key);
3366 wfree(path);
3368 break;
3370 default:
3371 wwarning(_("Invalid number of arguments for option \"%s\""), entry->key);
3372 break;
3375 WMReleasePropList(array);
3377 return 0;
3380 static int setModifierKeyLabels(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
3382 WMPropList *array = tdata;
3383 int i;
3384 struct WPreferences *prefs = foo;
3386 if (!WMIsPLArray(array) || WMGetPropListItemCount(array) != 7) {
3387 wwarning(_("Value for option \"%s\" must be an array of 7 strings"), entry->key);
3388 WMReleasePropList(array);
3389 return 0;
3392 DestroyWindowMenu(scr);
3394 for (i = 0; i < 7; i++) {
3395 if (prefs->modifier_labels[i])
3396 wfree(prefs->modifier_labels[i]);
3398 if (WMIsPLString(WMGetFromPLArray(array, i))) {
3399 prefs->modifier_labels[i] = wstrdup(WMGetFromPLString(WMGetFromPLArray(array, i)));
3400 } else {
3401 wwarning(_("Invalid argument for option \"%s\" item %d"), entry->key, i);
3402 prefs->modifier_labels[i] = NULL;
3406 WMReleasePropList(array);
3408 return 0;
3411 static int setDoubleClick(WScreen *scr, WDefaultEntry *entry, void *tdata, void *foo)
3413 int *value = tdata;
3415 /* Parameter not used, but tell the compiler that it is ok */
3416 (void) entry;
3417 (void) scr;
3419 if (*value <= 0)
3420 *(int *)foo = 1;
3422 W_setconf_doubleClickDelay(*value);
3424 return 0;
3427 static int setCursor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *extra_data)
3429 Cursor *cursor = tdata;
3430 long widx = (long) extra_data;
3432 /* Parameter not used, but tell the compiler that it is ok */
3433 (void) entry;
3435 if (wPreferences.cursor[widx] != None) {
3436 XFreeCursor(dpy, wPreferences.cursor[widx]);
3439 wPreferences.cursor[widx] = *cursor;
3441 if (widx == WCUR_ROOT && *cursor != None) {
3442 XDefineCursor(dpy, scr->root_win, *cursor);
3445 return 0;