WPrefs.app: Add ability to set behavior when dragging a maximized window.
[wmaker-crm.git] / src / defaults.c
blob6ca7f3f740de470c30ab2084a4dccaead5eea652
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 setFrameFocusedBorderColor;
130 static WDECallbackUpdate setFrameSelectedBorderColor;
131 static WDECallbackUpdate setLargeDisplayFont;
132 static WDECallbackUpdate setWTitleColor;
133 static WDECallbackUpdate setFTitleBack;
134 static WDECallbackUpdate setPTitleBack;
135 static WDECallbackUpdate setUTitleBack;
136 static WDECallbackUpdate setResizebarBack;
137 static WDECallbackUpdate setWorkspaceBack;
138 static WDECallbackUpdate setWorkspaceSpecificBack;
139 static WDECallbackUpdate setMenuTitleColor;
140 static WDECallbackUpdate setMenuTextColor;
141 static WDECallbackUpdate setMenuDisabledColor;
142 static WDECallbackUpdate setMenuTitleBack;
143 static WDECallbackUpdate setMenuTextBack;
144 static WDECallbackUpdate setHightlight;
145 static WDECallbackUpdate setHightlightText;
146 static WDECallbackUpdate setKeyGrab;
147 static WDECallbackUpdate setDoubleClick;
148 static WDECallbackUpdate setIconPosition;
150 static WDECallbackUpdate setClipTitleFont;
151 static WDECallbackUpdate setClipTitleColor;
153 static WDECallbackUpdate setMenuStyle;
154 static WDECallbackUpdate setSwPOptions;
155 static WDECallbackUpdate updateUsableArea;
157 static WDECallbackUpdate setModifierKeyLabels;
159 static WDECallbackConvert getCursor;
160 static WDECallbackUpdate setCursor;
163 * Tables to convert strings to enumeration values.
164 * Values stored are char
167 /* WARNING: sum of length of all value strings must not exceed
168 * this value */
169 #define TOTAL_VALUES_LENGTH 80
171 #define REFRESH_WINDOW_TEXTURES (1<<0)
172 #define REFRESH_MENU_TEXTURE (1<<1)
173 #define REFRESH_MENU_FONT (1<<2)
174 #define REFRESH_MENU_COLOR (1<<3)
175 #define REFRESH_MENU_TITLE_TEXTURE (1<<4)
176 #define REFRESH_MENU_TITLE_FONT (1<<5)
177 #define REFRESH_MENU_TITLE_COLOR (1<<6)
178 #define REFRESH_WINDOW_TITLE_COLOR (1<<7)
179 #define REFRESH_WINDOW_FONT (1<<8)
180 #define REFRESH_ICON_TILE (1<<9)
181 #define REFRESH_ICON_FONT (1<<10)
182 #define REFRESH_WORKSPACE_BACK (1<<11)
184 #define REFRESH_BUTTON_IMAGES (1<<12)
186 #define REFRESH_ICON_TITLE_COLOR (1<<13)
187 #define REFRESH_ICON_TITLE_BACK (1<<14)
189 #define REFRESH_WORKSPACE_MENU (1<<15)
191 #define REFRESH_FRAME_BORDER REFRESH_MENU_FONT|REFRESH_WINDOW_FONT
193 static WOptionEnumeration seFocusModes[] = {
194 {"Manual", WKF_CLICK, 0}, {"ClickToFocus", WKF_CLICK, 1},
195 {"Sloppy", WKF_SLOPPY, 0}, {"SemiAuto", WKF_SLOPPY, 1}, {"Auto", WKF_SLOPPY, 1},
196 {NULL, 0, 0}
199 static WOptionEnumeration seTitlebarModes[] = {
200 {"new", TS_NEW, 0}, {"old", TS_OLD, 0},
201 {"next", TS_NEXT, 0}, {NULL, 0, 0}
204 static WOptionEnumeration seColormapModes[] = {
205 {"Manual", WCM_CLICK, 0}, {"ClickToFocus", WCM_CLICK, 1},
206 {"Auto", WCM_POINTER, 0}, {"FocusFollowMouse", WCM_POINTER, 1},
207 {NULL, 0, 0}
210 static WOptionEnumeration sePlacements[] = {
211 {"Auto", WPM_AUTO, 0},
212 {"Smart", WPM_SMART, 0},
213 {"Cascade", WPM_CASCADE, 0},
214 {"Random", WPM_RANDOM, 0},
215 {"Manual", WPM_MANUAL, 0},
216 {"Center", WPM_CENTER, 0},
217 {NULL, 0, 0}
220 static WOptionEnumeration seGeomDisplays[] = {
221 {"None", WDIS_NONE, 0},
222 {"Center", WDIS_CENTER, 0},
223 {"Corner", WDIS_TOPLEFT, 0},
224 {"Floating", WDIS_FRAME_CENTER, 0},
225 {"Line", WDIS_NEW, 0},
226 {NULL, 0, 0}
229 static WOptionEnumeration seSpeeds[] = {
230 {"UltraFast", SPEED_ULTRAFAST, 0},
231 {"Fast", SPEED_FAST, 0},
232 {"Medium", SPEED_MEDIUM, 0},
233 {"Slow", SPEED_SLOW, 0},
234 {"UltraSlow", SPEED_ULTRASLOW, 0},
235 {NULL, 0, 0}
238 static WOptionEnumeration seMouseButtonActions[] = {
239 {"None", WA_NONE, 0},
240 {"SelectWindows", WA_SELECT_WINDOWS, 0},
241 {"OpenApplicationsMenu", WA_OPEN_APPMENU, 0},
242 {"OpenWindowListMenu", WA_OPEN_WINLISTMENU, 0},
243 {"MoveToPrevWorkspace", WA_MOVE_PREVWORKSPACE, 0},
244 {"MoveToNextWorkspace", WA_MOVE_NEXTWORKSPACE, 0},
245 {"MoveToPrevWindow", WA_MOVE_PREVWINDOW, 0},
246 {"MoveToNextWindow", WA_MOVE_NEXTWINDOW, 0},
247 {NULL, 0, 0}
250 static WOptionEnumeration seMouseWheelActions[] = {
251 {"None", WA_NONE, 0},
252 {"SwitchWorkspaces", WA_SWITCH_WORKSPACES, 0},
253 {"SwitchWindows", WA_SWITCH_WINDOWS, 0},
254 {NULL, 0, 0}
257 static WOptionEnumeration seIconificationStyles[] = {
258 {"Zoom", WIS_ZOOM, 0},
259 {"Twist", WIS_TWIST, 0},
260 {"Flip", WIS_FLIP, 0},
261 {"None", WIS_NONE, 0},
262 {"random", WIS_RANDOM, 0},
263 {NULL, 0, 0}
266 static WOptionEnumeration seJustifications[] = {
267 {"Left", WTJ_LEFT, 0},
268 {"Center", WTJ_CENTER, 0},
269 {"Right", WTJ_RIGHT, 0},
270 {NULL, 0, 0}
273 static WOptionEnumeration seIconPositions[] = {
274 {"blv", IY_BOTTOM | IY_LEFT | IY_VERT, 0},
275 {"blh", IY_BOTTOM | IY_LEFT | IY_HORIZ, 0},
276 {"brv", IY_BOTTOM | IY_RIGHT | IY_VERT, 0},
277 {"brh", IY_BOTTOM | IY_RIGHT | IY_HORIZ, 0},
278 {"tlv", IY_TOP | IY_LEFT | IY_VERT, 0},
279 {"tlh", IY_TOP | IY_LEFT | IY_HORIZ, 0},
280 {"trv", IY_TOP | IY_RIGHT | IY_VERT, 0},
281 {"trh", IY_TOP | IY_RIGHT | IY_HORIZ, 0},
282 {NULL, 0, 0}
285 static WOptionEnumeration seMenuStyles[] = {
286 {"normal", MS_NORMAL, 0},
287 {"singletexture", MS_SINGLE_TEXTURE, 0},
288 {"flat", MS_FLAT, 0},
289 {NULL, 0, 0}
292 static WOptionEnumeration seDisplayPositions[] = {
293 {"none", WD_NONE, 0},
294 {"center", WD_CENTER, 0},
295 {"top", WD_TOP, 0},
296 {"bottom", WD_BOTTOM, 0},
297 {"topleft", WD_TOPLEFT, 0},
298 {"topright", WD_TOPRIGHT, 0},
299 {"bottomleft", WD_BOTTOMLEFT, 0},
300 {"bottomright", WD_BOTTOMRIGHT, 0},
301 {NULL, 0, 0}
304 static WOptionEnumeration seWorkspaceBorder[] = {
305 {"None", WB_NONE, 0},
306 {"LeftRight", WB_LEFTRIGHT, 0},
307 {"TopBottom", WB_TOPBOTTOM, 0},
308 {"AllDirections", WB_ALLDIRS, 0},
309 {NULL, 0, 0}
312 static WOptionEnumeration seDragMaximizedWindow[] = {
313 {"Move", DRAGMAX_MOVE, 0},
314 {"RestoreGeometry", DRAGMAX_RESTORE, 0},
315 {"Unmaximize", DRAGMAX_UNMAXIMIZE, 0},
316 {"NoMove", DRAGMAX_NOMOVE, 0},
317 {NULL, 0, 0}
321 * ALL entries in the tables bellow, NEED to have a default value
322 * defined, and this value needs to be correct.
325 /* these options will only affect the window manager on startup
327 * static defaults can't access the screen data, because it is
328 * created after these defaults are read
330 WDefaultEntry staticOptionList[] = {
332 {"ColormapSize", "4", NULL,
333 &wPreferences.cmap_size, getInt, NULL, NULL, NULL},
334 {"DisableDithering", "NO", NULL,
335 &wPreferences.no_dithering, getBool, NULL, NULL, NULL},
336 {"IconSize", "64", NULL,
337 &wPreferences.icon_size, getInt, NULL, NULL, NULL},
338 {"ModifierKey", "Mod1", NULL,
339 &wPreferences.modifier_mask, getModMask, NULL, NULL, NULL},
340 {"FocusMode", "manual", seFocusModes, /* have a problem when switching from */
341 &wPreferences.focus_mode, getEnum, NULL, NULL, NULL}, /* manual to sloppy without restart */
342 {"NewStyle", "new", seTitlebarModes,
343 &wPreferences.new_style, getEnum, NULL, NULL, NULL},
344 {"DisableDock", "NO", (void *)WM_DOCK,
345 NULL, getBool, setIfDockPresent, NULL, NULL},
346 {"DisableClip", "NO", (void *)WM_CLIP,
347 NULL, getBool, setIfDockPresent, NULL, NULL},
348 {"DisableDrawers", "NO", (void *)WM_DRAWER,
349 NULL, getBool, setIfDockPresent, NULL, NULL},
350 {"ClipMergedInDock", "NO", NULL,
351 NULL, getBool, setClipMergedInDock, NULL, NULL},
352 {"DisableMiniwindows", "NO", NULL,
353 &wPreferences.disable_miniwindows, getBool, NULL, NULL, NULL}
356 #define NUM2STRING_(x) #x
357 #define NUM2STRING(x) NUM2STRING_(x)
359 WDefaultEntry optionList[] = {
361 /* dynamic options */
363 {"IconPosition", "blh", seIconPositions,
364 &wPreferences.icon_yard, getEnum, setIconPosition, NULL, NULL},
365 {"IconificationStyle", "Zoom", seIconificationStyles,
366 &wPreferences.iconification_style, getEnum, NULL, NULL, NULL},
367 {"DisableWSMouseActions", "NO", NULL,
368 &wPreferences.disable_root_mouse, getBool, NULL, NULL, NULL},
369 {"MouseLeftButtonAction", "SelectWindows", seMouseButtonActions,
370 &wPreferences.mouse_button1, getEnum, NULL, NULL, NULL},
371 {"MouseMiddleButtonAction", "OpenWindowListMenu", seMouseButtonActions,
372 &wPreferences.mouse_button2, getEnum, NULL, NULL, NULL},
373 {"MouseRightButtonAction", "OpenApplicationsMenu", seMouseButtonActions,
374 &wPreferences.mouse_button3, getEnum, NULL, NULL, NULL},
375 {"MouseBackwardButtonAction", "None", seMouseButtonActions,
376 &wPreferences.mouse_button8, getEnum, NULL, NULL, NULL},
377 {"MouseForwardButtonAction", "None", seMouseButtonActions,
378 &wPreferences.mouse_button9, getEnum, NULL, NULL, NULL},
379 {"MouseWheelAction", "None", seMouseWheelActions,
380 &wPreferences.mouse_wheel_scroll, getEnum, NULL, NULL, NULL},
381 {"MouseWheelTiltAction", "None", seMouseWheelActions,
382 &wPreferences.mouse_wheel_tilt, getEnum, NULL, NULL, NULL},
383 {"PixmapPath", DEF_PIXMAP_PATHS, NULL,
384 &wPreferences.pixmap_path, getPathList, NULL, NULL, NULL},
385 {"IconPath", DEF_ICON_PATHS, NULL,
386 &wPreferences.icon_path, getPathList, NULL, NULL, NULL},
387 {"ColormapMode", "auto", seColormapModes,
388 &wPreferences.colormap_mode, getEnum, NULL, NULL, NULL},
389 {"AutoFocus", "NO", NULL,
390 &wPreferences.auto_focus, getBool, NULL, NULL, NULL},
391 {"RaiseDelay", "0", NULL,
392 &wPreferences.raise_delay, getInt, NULL, NULL, NULL},
393 {"CirculateRaise", "NO", NULL,
394 &wPreferences.circ_raise, getBool, NULL, NULL, NULL},
395 {"Superfluous", "NO", NULL,
396 &wPreferences.superfluous, getBool, NULL, NULL, NULL},
397 {"AdvanceToNewWorkspace", "NO", NULL,
398 &wPreferences.ws_advance, getBool, NULL, NULL, NULL},
399 {"CycleWorkspaces", "NO", NULL,
400 &wPreferences.ws_cycle, getBool, NULL, NULL, NULL},
401 {"WorkspaceNameDisplayPosition", "center", seDisplayPositions,
402 &wPreferences.workspace_name_display_position, getEnum, NULL, NULL, NULL},
403 {"WorkspaceBorder", "None", seWorkspaceBorder,
404 &wPreferences.workspace_border_position, getEnum, updateUsableArea, NULL, NULL},
405 {"WorkspaceBorderSize", "0", NULL,
406 &wPreferences.workspace_border_size, getInt, updateUsableArea, NULL, NULL},
407 {"StickyIcons", "NO", NULL,
408 &wPreferences.sticky_icons, getBool, setStickyIcons, NULL, NULL},
409 {"SaveSessionOnExit", "NO", NULL,
410 &wPreferences.save_session_on_exit, getBool, NULL, NULL, NULL},
411 {"WrapMenus", "NO", NULL,
412 &wPreferences.wrap_menus, getBool, NULL, NULL, NULL},
413 {"ScrollableMenus", "NO", NULL,
414 &wPreferences.scrollable_menus, getBool, NULL, NULL, NULL},
415 {"MenuScrollSpeed", "medium", seSpeeds,
416 &wPreferences.menu_scroll_speed, getEnum, NULL, NULL, NULL},
417 {"IconSlideSpeed", "medium", seSpeeds,
418 &wPreferences.icon_slide_speed, getEnum, NULL, NULL, NULL},
419 {"ShadeSpeed", "medium", seSpeeds,
420 &wPreferences.shade_speed, getEnum, NULL, NULL, NULL},
421 {"BounceAppIconsWhenUrgent", "YES", NULL,
422 &wPreferences.bounce_appicons_when_urgent, getBool, NULL, NULL, NULL},
423 {"RaiseAppIconsWhenBouncing", "NO", NULL,
424 &wPreferences.raise_appicons_when_bouncing, getBool, NULL, NULL, NULL},
425 {"DoNotMakeAppIconsBounce", "NO", NULL,
426 &wPreferences.do_not_make_appicons_bounce, getBool, NULL, NULL, NULL},
427 {"DoubleClickTime", "250", (void *)&wPreferences.dblclick_time,
428 &wPreferences.dblclick_time, getInt, setDoubleClick, NULL, NULL},
429 {"ClipAutoraiseDelay", "600", NULL,
430 &wPreferences.clip_auto_raise_delay, getInt, NULL, NULL, NULL},
431 {"ClipAutolowerDelay", "1000", NULL,
432 &wPreferences.clip_auto_lower_delay, getInt, NULL, NULL, NULL},
433 {"ClipAutoexpandDelay", "600", NULL,
434 &wPreferences.clip_auto_expand_delay, getInt, NULL, NULL, NULL},
435 {"ClipAutocollapseDelay", "1000", NULL,
436 &wPreferences.clip_auto_collapse_delay, getInt, NULL, NULL, NULL},
437 {"WrapAppiconsInDock", "YES", NULL,
438 NULL, getBool, setWrapAppiconsInDock, NULL, NULL},
439 {"AlignSubmenus", "NO", NULL,
440 &wPreferences.align_menus, getBool, NULL, NULL, NULL},
441 {"ViKeyMenus", "NO", NULL,
442 &wPreferences.vi_key_menus, getBool, NULL, NULL, NULL},
443 {"OpenTransientOnOwnerWorkspace", "NO", NULL,
444 &wPreferences.open_transients_with_parent, getBool, NULL, NULL, NULL},
445 {"WindowPlacement", "auto", sePlacements,
446 &wPreferences.window_placement, getEnum, NULL, NULL, NULL},
447 {"IgnoreFocusClick", "NO", NULL,
448 &wPreferences.ignore_focus_click, getBool, NULL, NULL, NULL},
449 {"UseSaveUnders", "NO", NULL,
450 &wPreferences.use_saveunders, getBool, NULL, NULL, NULL},
451 {"OpaqueMove", "NO", NULL,
452 &wPreferences.opaque_move, getBool, NULL, NULL, NULL},
453 {"OpaqueResize", "NO", NULL,
454 &wPreferences.opaque_resize, getBool, NULL, NULL, NULL},
455 {"OpaqueMoveResizeKeyboard", "NO", NULL,
456 &wPreferences.opaque_move_resize_keyboard, getBool, NULL, NULL, NULL},
457 {"DisableAnimations", "NO", NULL,
458 &wPreferences.no_animations, getBool, NULL, NULL, NULL},
459 {"DontLinkWorkspaces", "NO", NULL,
460 &wPreferences.no_autowrap, getBool, NULL, NULL, NULL},
461 {"WindowSnapping", "NO", NULL,
462 &wPreferences.window_snapping, getBool, NULL, NULL, NULL},
463 {"DragMaximizedWindow", "Move", seDragMaximizedWindow,
464 &wPreferences.drag_maximized_window, getEnum, NULL, NULL, NULL},
465 {"HighlightActiveApp", "YES", NULL,
466 &wPreferences.highlight_active_app, getBool, NULL, NULL, NULL},
467 {"AutoArrangeIcons", "NO", NULL,
468 &wPreferences.auto_arrange_icons, getBool, NULL, NULL, NULL},
469 {"NoWindowOverDock", "NO", NULL,
470 &wPreferences.no_window_over_dock, getBool, updateUsableArea, NULL, NULL},
471 {"NoWindowOverIcons", "NO", NULL,
472 &wPreferences.no_window_over_icons, getBool, updateUsableArea, NULL, NULL},
473 {"WindowPlaceOrigin", "(0, 0)", NULL,
474 &wPreferences.window_place_origin, getCoord, NULL, NULL, NULL},
475 {"ResizeDisplay", "corner", seGeomDisplays,
476 &wPreferences.size_display, getEnum, NULL, NULL, NULL},
477 {"MoveDisplay", "corner", seGeomDisplays,
478 &wPreferences.move_display, getEnum, NULL, NULL, NULL},
479 {"DontConfirmKill", "NO", NULL,
480 &wPreferences.dont_confirm_kill, getBool, NULL, NULL, NULL},
481 {"WindowTitleBalloons", "NO", NULL,
482 &wPreferences.window_balloon, getBool, NULL, NULL, NULL},
483 {"MiniwindowTitleBalloons", "NO", NULL,
484 &wPreferences.miniwin_title_balloon, getBool, NULL, NULL, NULL},
485 {"MiniwindowApercuBalloons", "NO", NULL,
486 &wPreferences.miniwin_apercu_balloon, getBool, NULL, NULL, NULL},
487 {"AppIconBalloons", "NO", NULL,
488 &wPreferences.appicon_balloon, getBool, NULL, NULL, NULL},
489 {"HelpBalloons", "NO", NULL,
490 &wPreferences.help_balloon, getBool, NULL, NULL, NULL},
491 {"EdgeResistance", "30", NULL,
492 &wPreferences.edge_resistance, getInt, NULL, NULL, NULL},
493 {"ResizeIncrement", "0", NULL,
494 &wPreferences.resize_increment, getInt, NULL, NULL, NULL},
495 {"Attraction", "NO", NULL,
496 &wPreferences.attract, getBool, NULL, NULL, NULL},
497 {"DisableBlinking", "NO", NULL,
498 &wPreferences.dont_blink, getBool, NULL, NULL, NULL},
499 {"SingleClickLaunch", "NO", NULL,
500 &wPreferences.single_click, getBool, NULL, NULL, NULL},
501 {"StrictWindozeCycle", "YES", NULL,
502 &wPreferences.strict_windoze_cycle, getBool, NULL, NULL, NULL},
503 {"SwitchPanelOnlyOpen", "NO", NULL,
504 &wPreferences.panel_only_open, getBool, NULL, NULL, NULL},
505 {"ApercuSize", "2", NULL,
506 &wPreferences.apercu_size, getInt, NULL, NULL, NULL},
508 /* style options */
510 {"MenuStyle", "normal", seMenuStyles,
511 &wPreferences.menu_style, getEnum, setMenuStyle, NULL, NULL},
512 {"WidgetColor", "(solid, gray)", NULL,
513 NULL, getTexture, setWidgetColor, NULL, NULL},
514 {"WorkspaceSpecificBack", "()", NULL,
515 NULL, getWSSpecificBackground, setWorkspaceSpecificBack, NULL, NULL},
516 /* WorkspaceBack must come after WorkspaceSpecificBack or
517 * WorkspaceBack wont know WorkspaceSpecificBack was also
518 * specified and 2 copies of wmsetbg will be launched */
519 {"WorkspaceBack", "(solid, black)", NULL,
520 NULL, getWSBackground, setWorkspaceBack, NULL, NULL},
521 {"SmoothWorkspaceBack", "NO", NULL,
522 NULL, getBool, NULL, NULL, NULL},
523 {"IconBack", "(solid, gray)", NULL,
524 NULL, getTexture, setIconTile, NULL, NULL},
525 {"TitleJustify", "center", seJustifications,
526 &wPreferences.title_justification, getEnum, setJustify, NULL, NULL},
527 {"WindowTitleFont", DEF_TITLE_FONT, NULL,
528 NULL, getFont, setWinTitleFont, NULL, NULL},
529 {"WindowTitleExtendSpace", DEF_WINDOW_TITLE_EXTEND_SPACE, NULL,
530 &wPreferences.window_title_clearance, getInt, setClearance, NULL, NULL},
531 {"WindowTitleMinHeight", "0", NULL,
532 &wPreferences.window_title_min_height, getInt, setClearance, NULL, NULL},
533 {"WindowTitleMaxHeight", NUM2STRING(INT_MAX), NULL,
534 &wPreferences.window_title_max_height, getInt, setClearance, NULL, NULL},
535 {"MenuTitleExtendSpace", DEF_MENU_TITLE_EXTEND_SPACE, NULL,
536 &wPreferences.menu_title_clearance, getInt, setClearance, NULL, NULL},
537 {"MenuTitleMinHeight", "0", NULL,
538 &wPreferences.menu_title_min_height, getInt, setClearance, NULL, NULL},
539 {"MenuTitleMaxHeight", NUM2STRING(INT_MAX), NULL,
540 &wPreferences.menu_title_max_height, getInt, setClearance, NULL, NULL},
541 {"MenuTextExtendSpace", DEF_MENU_TEXT_EXTEND_SPACE, NULL,
542 &wPreferences.menu_text_clearance, getInt, setClearance, NULL, NULL},
543 {"MenuTitleFont", DEF_MENU_TITLE_FONT, NULL,
544 NULL, getFont, setMenuTitleFont, NULL, NULL},
545 {"MenuTextFont", DEF_MENU_ENTRY_FONT, NULL,
546 NULL, getFont, setMenuTextFont, NULL, NULL},
547 {"IconTitleFont", DEF_ICON_TITLE_FONT, NULL,
548 NULL, getFont, setIconTitleFont, NULL, NULL},
549 {"ClipTitleFont", DEF_CLIP_TITLE_FONT, NULL,
550 NULL, getFont, setClipTitleFont, NULL, NULL},
551 {"ShowClipTitle", "YES", NULL,
552 &wPreferences.show_clip_title, getBool, NULL, NULL, NULL},
553 {"LargeDisplayFont", DEF_WORKSPACE_NAME_FONT, NULL,
554 NULL, getFont, setLargeDisplayFont, NULL, NULL},
555 {"HighlightColor", "white", NULL,
556 NULL, getColor, setHightlight, NULL, NULL},
557 {"HighlightTextColor", "black", NULL,
558 NULL, getColor, setHightlightText, NULL, NULL},
559 {"ClipTitleColor", "black", (void *)CLIP_NORMAL,
560 NULL, getColor, setClipTitleColor, NULL, NULL},
561 {"CClipTitleColor", "\"#454045\"", (void *)CLIP_COLLAPSED,
562 NULL, getColor, setClipTitleColor, NULL, NULL},
563 {"FTitleColor", "white", (void *)WS_FOCUSED,
564 NULL, getColor, setWTitleColor, NULL, NULL},
565 {"PTitleColor", "white", (void *)WS_PFOCUSED,
566 NULL, getColor, setWTitleColor, NULL, NULL},
567 {"UTitleColor", "black", (void *)WS_UNFOCUSED,
568 NULL, getColor, setWTitleColor, NULL, NULL},
569 {"FTitleBack", "(solid, black)", NULL,
570 NULL, getTexture, setFTitleBack, NULL, NULL},
571 {"PTitleBack", "(solid, \"#616161\")", NULL,
572 NULL, getTexture, setPTitleBack, NULL, NULL},
573 {"UTitleBack", "(solid, gray)", NULL,
574 NULL, getTexture, setUTitleBack, NULL, NULL},
575 {"ResizebarBack", "(solid, gray)", NULL,
576 NULL, getTexture, setResizebarBack, NULL, NULL},
577 {"MenuTitleColor", "white", NULL,
578 NULL, getColor, setMenuTitleColor, NULL, NULL},
579 {"MenuTextColor", "black", NULL,
580 NULL, getColor, setMenuTextColor, NULL, NULL},
581 {"MenuDisabledColor", "\"#616161\"", NULL,
582 NULL, getColor, setMenuDisabledColor, NULL, NULL},
583 {"MenuTitleBack", "(solid, black)", NULL,
584 NULL, getTexture, setMenuTitleBack, NULL, NULL},
585 {"MenuTextBack", "(solid, gray)", NULL,
586 NULL, getTexture, setMenuTextBack, NULL, NULL},
587 {"IconTitleColor", "white", NULL,
588 NULL, getColor, setIconTitleColor, NULL, NULL},
589 {"IconTitleBack", "black", NULL,
590 NULL, getColor, setIconTitleBack, NULL, NULL},
591 {"SwitchPanelImages", "(swtile.png, swback.png, 30, 40)", &wPreferences,
592 NULL, getPropList, setSwPOptions, NULL, NULL},
593 {"ModifierKeyLabels", "(\"Shift+\", \"Control+\", \"Mod1+\", \"Mod2+\", \"Mod3+\", \"Mod4+\", \"Mod5+\")", &wPreferences,
594 NULL, getPropList, setModifierKeyLabels, NULL, NULL},
595 {"FrameBorderWidth", "1", NULL,
596 NULL, getInt, setFrameBorderWidth, NULL, NULL},
597 {"FrameBorderColor", "black", NULL,
598 NULL, getColor, setFrameBorderColor, NULL, NULL},
599 {"FrameFocusedBorderColor", "black", NULL,
600 NULL, getColor, setFrameFocusedBorderColor, NULL, NULL},
601 {"FrameSelectedBorderColor", "white", NULL,
602 NULL, getColor, setFrameSelectedBorderColor, NULL, NULL},
604 /* keybindings */
606 {"RootMenuKey", "None", (void *)WKBD_ROOTMENU,
607 NULL, getKeybind, setKeyGrab, NULL, NULL},
608 {"WindowListKey", "None", (void *)WKBD_WINDOWLIST,
609 NULL, getKeybind, setKeyGrab, NULL, NULL},
610 {"WindowMenuKey", "None", (void *)WKBD_WINDOWMENU,
611 NULL, getKeybind, setKeyGrab, NULL, NULL},
612 {"DockRaiseLowerKey", "None", (void*)WKBD_DOCKRAISELOWER,
613 NULL, getKeybind, setKeyGrab, NULL, NULL},
614 {"ClipRaiseLowerKey", "None", (void *)WKBD_CLIPRAISELOWER,
615 NULL, getKeybind, setKeyGrab, NULL, NULL},
616 {"MiniaturizeKey", "None", (void *)WKBD_MINIATURIZE,
617 NULL, getKeybind, setKeyGrab, NULL, NULL},
618 {"MinimizeAllKey", "None", (void *)WKBD_MINIMIZEALL,
619 NULL, getKeybind, setKeyGrab, NULL, NULL },
620 {"HideKey", "None", (void *)WKBD_HIDE,
621 NULL, getKeybind, setKeyGrab, NULL, NULL},
622 {"HideOthersKey", "None", (void *)WKBD_HIDE_OTHERS,
623 NULL, getKeybind, setKeyGrab, NULL, NULL},
624 {"MoveResizeKey", "None", (void *)WKBD_MOVERESIZE,
625 NULL, getKeybind, setKeyGrab, NULL, NULL},
626 {"CloseKey", "None", (void *)WKBD_CLOSE,
627 NULL, getKeybind, setKeyGrab, NULL, NULL},
628 {"MaximizeKey", "None", (void *)WKBD_MAXIMIZE,
629 NULL, getKeybind, setKeyGrab, NULL, NULL},
630 {"VMaximizeKey", "None", (void *)WKBD_VMAXIMIZE,
631 NULL, getKeybind, setKeyGrab, NULL, NULL},
632 {"HMaximizeKey", "None", (void *)WKBD_HMAXIMIZE,
633 NULL, getKeybind, setKeyGrab, NULL, NULL},
634 {"LHMaximizeKey", "None", (void*)WKBD_LHMAXIMIZE,
635 NULL, getKeybind, setKeyGrab, NULL, NULL},
636 {"RHMaximizeKey", "None", (void*)WKBD_RHMAXIMIZE,
637 NULL, getKeybind, setKeyGrab, NULL, NULL},
638 {"THMaximizeKey", "None", (void*)WKBD_THMAXIMIZE,
639 NULL, getKeybind, setKeyGrab, NULL, NULL},
640 {"BHMaximizeKey", "None", (void*)WKBD_BHMAXIMIZE,
641 NULL, getKeybind, setKeyGrab, NULL, NULL},
642 {"LTCMaximizeKey", "None", (void*)WKBD_LTCMAXIMIZE,
643 NULL, getKeybind, setKeyGrab, NULL, NULL},
644 {"RTCMaximizeKey", "None", (void*)WKBD_RTCMAXIMIZE,
645 NULL, getKeybind, setKeyGrab, NULL, NULL},
646 {"LBCMaximizeKey", "None", (void*)WKBD_LBCMAXIMIZE,
647 NULL, getKeybind, setKeyGrab, NULL, NULL},
648 {"RBCMaximizeKey", "None", (void*)WKBD_RBCMAXIMIZE,
649 NULL, getKeybind, setKeyGrab, NULL, NULL},
650 {"MaximusKey", "None", (void*)WKBD_MAXIMUS,
651 NULL, getKeybind, setKeyGrab, NULL, NULL},
652 {"RaiseKey", "\"Meta+Up\"", (void *)WKBD_RAISE,
653 NULL, getKeybind, setKeyGrab, NULL, NULL},
654 {"LowerKey", "\"Meta+Down\"", (void *)WKBD_LOWER,
655 NULL, getKeybind, setKeyGrab, NULL, NULL},
656 {"RaiseLowerKey", "None", (void *)WKBD_RAISELOWER,
657 NULL, getKeybind, setKeyGrab, NULL, NULL},
658 {"ShadeKey", "None", (void *)WKBD_SHADE,
659 NULL, getKeybind, setKeyGrab, NULL, NULL},
660 {"SelectKey", "None", (void *)WKBD_SELECT,
661 NULL, getKeybind, setKeyGrab, NULL, NULL},
662 {"FocusNextKey", "None", (void *)WKBD_FOCUSNEXT,
663 NULL, getKeybind, setKeyGrab, NULL, NULL},
664 {"FocusPrevKey", "None", (void *)WKBD_FOCUSPREV,
665 NULL, getKeybind, setKeyGrab, NULL, NULL},
666 {"GroupNextKey", "None", (void *)WKBD_GROUPNEXT,
667 NULL, getKeybind, setKeyGrab, NULL, NULL},
668 {"GroupPrevKey", "None", (void *)WKBD_GROUPPREV,
669 NULL, getKeybind, setKeyGrab, NULL, NULL},
670 {"NextWorkspaceKey", "None", (void *)WKBD_NEXTWORKSPACE,
671 NULL, getKeybind, setKeyGrab, NULL, NULL},
672 {"PrevWorkspaceKey", "None", (void *)WKBD_PREVWORKSPACE,
673 NULL, getKeybind, setKeyGrab, NULL, NULL},
674 {"LastWorkspaceKey", "None", (void *)WKBD_LASTWORKSPACE,
675 NULL, getKeybind, setKeyGrab, NULL, NULL},
676 {"NextWorkspaceLayerKey", "None", (void *)WKBD_NEXTWSLAYER,
677 NULL, getKeybind, setKeyGrab, NULL, NULL},
678 {"PrevWorkspaceLayerKey", "None", (void *)WKBD_PREVWSLAYER,
679 NULL, getKeybind, setKeyGrab, NULL, NULL},
680 {"Workspace1Key", "None", (void *)WKBD_WORKSPACE1,
681 NULL, getKeybind, setKeyGrab, NULL, NULL},
682 {"Workspace2Key", "None", (void *)WKBD_WORKSPACE2,
683 NULL, getKeybind, setKeyGrab, NULL, NULL},
684 {"Workspace3Key", "None", (void *)WKBD_WORKSPACE3,
685 NULL, getKeybind, setKeyGrab, NULL, NULL},
686 {"Workspace4Key", "None", (void *)WKBD_WORKSPACE4,
687 NULL, getKeybind, setKeyGrab, NULL, NULL},
688 {"Workspace5Key", "None", (void *)WKBD_WORKSPACE5,
689 NULL, getKeybind, setKeyGrab, NULL, NULL},
690 {"Workspace6Key", "None", (void *)WKBD_WORKSPACE6,
691 NULL, getKeybind, setKeyGrab, NULL, NULL},
692 {"Workspace7Key", "None", (void *)WKBD_WORKSPACE7,
693 NULL, getKeybind, setKeyGrab, NULL, NULL},
694 {"Workspace8Key", "None", (void *)WKBD_WORKSPACE8,
695 NULL, getKeybind, setKeyGrab, NULL, NULL},
696 {"Workspace9Key", "None", (void *)WKBD_WORKSPACE9,
697 NULL, getKeybind, setKeyGrab, NULL, NULL},
698 {"Workspace10Key", "None", (void *)WKBD_WORKSPACE10,
699 NULL, getKeybind, setKeyGrab, NULL, NULL},
700 {"MoveToWorkspace1Key", "None", (void *)WKBD_MOVE_WORKSPACE1,
701 NULL, getKeybind, setKeyGrab, NULL, NULL},
702 {"MoveToWorkspace2Key", "None", (void *)WKBD_MOVE_WORKSPACE2,
703 NULL, getKeybind, setKeyGrab, NULL, NULL},
704 {"MoveToWorkspace3Key", "None", (void *)WKBD_MOVE_WORKSPACE3,
705 NULL, getKeybind, setKeyGrab, NULL, NULL},
706 {"MoveToWorkspace4Key", "None", (void *)WKBD_MOVE_WORKSPACE4,
707 NULL, getKeybind, setKeyGrab, NULL, NULL},
708 {"MoveToWorkspace5Key", "None", (void *)WKBD_MOVE_WORKSPACE5,
709 NULL, getKeybind, setKeyGrab, NULL, NULL},
710 {"MoveToWorkspace6Key", "None", (void *)WKBD_MOVE_WORKSPACE6,
711 NULL, getKeybind, setKeyGrab, NULL, NULL},
712 {"MoveToWorkspace7Key", "None", (void *)WKBD_MOVE_WORKSPACE7,
713 NULL, getKeybind, setKeyGrab, NULL, NULL},
714 {"MoveToWorkspace8Key", "None", (void *)WKBD_MOVE_WORKSPACE8,
715 NULL, getKeybind, setKeyGrab, NULL, NULL},
716 {"MoveToWorkspace9Key", "None", (void *)WKBD_MOVE_WORKSPACE9,
717 NULL, getKeybind, setKeyGrab, NULL, NULL},
718 {"MoveToWorkspace10Key", "None", (void *)WKBD_MOVE_WORKSPACE10,
719 NULL, getKeybind, setKeyGrab, NULL, NULL},
720 {"MoveToNextWorkspaceKey", "None", (void *)WKBD_MOVE_NEXTWORKSPACE,
721 NULL, getKeybind, setKeyGrab, NULL, NULL},
722 {"MoveToPrevWorkspaceKey", "None", (void *)WKBD_MOVE_PREVWORKSPACE,
723 NULL, getKeybind, setKeyGrab, NULL, NULL},
724 {"MoveToLastWorkspaceKey", "None", (void *)WKBD_MOVE_LASTWORKSPACE,
725 NULL, getKeybind, setKeyGrab, NULL, NULL},
726 {"MoveToNextWorkspaceLayerKey", "None", (void *)WKBD_MOVE_NEXTWSLAYER,
727 NULL, getKeybind, setKeyGrab, NULL, NULL},
728 {"MoveToPrevWorkspaceLayerKey", "None", (void *)WKBD_MOVE_PREVWSLAYER,
729 NULL, getKeybind, setKeyGrab, NULL, NULL},
730 {"WindowShortcut1Key", "None", (void *)WKBD_WINDOW1,
731 NULL, getKeybind, setKeyGrab, NULL, NULL},
732 {"WindowShortcut2Key", "None", (void *)WKBD_WINDOW2,
733 NULL, getKeybind, setKeyGrab, NULL, NULL},
734 {"WindowShortcut3Key", "None", (void *)WKBD_WINDOW3,
735 NULL, getKeybind, setKeyGrab, NULL, NULL},
736 {"WindowShortcut4Key", "None", (void *)WKBD_WINDOW4,
737 NULL, getKeybind, setKeyGrab, NULL, NULL},
738 {"WindowShortcut5Key", "None", (void *)WKBD_WINDOW5,
739 NULL, getKeybind, setKeyGrab, NULL, NULL},
740 {"WindowShortcut6Key", "None", (void *)WKBD_WINDOW6,
741 NULL, getKeybind, setKeyGrab, NULL, NULL},
742 {"WindowShortcut7Key", "None", (void *)WKBD_WINDOW7,
743 NULL, getKeybind, setKeyGrab, NULL, NULL},
744 {"WindowShortcut8Key", "None", (void *)WKBD_WINDOW8,
745 NULL, getKeybind, setKeyGrab, NULL, NULL},
746 {"WindowShortcut9Key", "None", (void *)WKBD_WINDOW9,
747 NULL, getKeybind, setKeyGrab, NULL, NULL},
748 {"WindowShortcut10Key", "None", (void *)WKBD_WINDOW10,
749 NULL, getKeybind, setKeyGrab, NULL, NULL},
750 {"WindowRelaunchKey", "None", (void *)WKBD_RELAUNCH,
751 NULL, getKeybind, setKeyGrab, NULL, NULL},
752 {"ScreenSwitchKey", "None", (void *)WKBD_SWITCH_SCREEN,
753 NULL, getKeybind, setKeyGrab, NULL, NULL},
754 {"RunKey", "None", (void *)WKBD_RUN,
755 NULL, getKeybind, setKeyGrab, NULL, NULL},
757 #ifdef KEEP_XKB_LOCK_STATUS
758 {"ToggleKbdModeKey", "None", (void *)WKBD_TOGGLE,
759 NULL, getKeybind, setKeyGrab, NULL, NULL},
760 {"KbdModeLock", "NO", NULL,
761 &wPreferences.modelock, getBool, NULL, NULL, NULL},
762 #endif /* KEEP_XKB_LOCK_STATUS */
764 {"NormalCursor", "(builtin, left_ptr)", (void *)WCUR_ROOT,
765 NULL, getCursor, setCursor, NULL, NULL},
766 {"ArrowCursor", "(builtin, top_left_arrow)", (void *)WCUR_ARROW,
767 NULL, getCursor, setCursor, NULL, NULL},
768 {"MoveCursor", "(builtin, fleur)", (void *)WCUR_MOVE,
769 NULL, getCursor, setCursor, NULL, NULL},
770 {"ResizeCursor", "(builtin, sizing)", (void *)WCUR_RESIZE,
771 NULL, getCursor, setCursor, NULL, NULL},
772 {"TopLeftResizeCursor", "(builtin, top_left_corner)", (void *)WCUR_TOPLEFTRESIZE,
773 NULL, getCursor, setCursor, NULL, NULL},
774 {"TopRightResizeCursor", "(builtin, top_right_corner)", (void *)WCUR_TOPRIGHTRESIZE,
775 NULL, getCursor, setCursor, NULL, NULL},
776 {"BottomLeftResizeCursor", "(builtin, bottom_left_corner)", (void *)WCUR_BOTTOMLEFTRESIZE,
777 NULL, getCursor, setCursor, NULL, NULL},
778 {"BottomRightResizeCursor", "(builtin, bottom_right_corner)", (void *)WCUR_BOTTOMRIGHTRESIZE,
779 NULL, getCursor, setCursor, NULL, NULL},
780 {"VerticalResizeCursor", "(builtin, sb_v_double_arrow)", (void *)WCUR_VERTICALRESIZE,
781 NULL, getCursor, setCursor, NULL, NULL},
782 {"HorizontalResizeCursor", "(builtin, sb_h_double_arrow)", (void *)WCUR_HORIZONRESIZE,
783 NULL, getCursor, setCursor, NULL, NULL},
784 {"WaitCursor", "(builtin, watch)", (void *)WCUR_WAIT,
785 NULL, getCursor, setCursor, NULL, NULL},
786 {"QuestionCursor", "(builtin, question_arrow)", (void *)WCUR_QUESTION,
787 NULL, getCursor, setCursor, NULL, NULL},
788 {"TextCursor", "(builtin, xterm)", (void *)WCUR_TEXT,
789 NULL, getCursor, setCursor, NULL, NULL},
790 {"SelectCursor", "(builtin, cross)", (void *)WCUR_SELECT,
791 NULL, getCursor, setCursor, NULL, NULL},
792 {"DialogHistoryLines", "500", NULL,
793 &wPreferences.history_lines, getInt, NULL, NULL, NULL},
794 {"CycleActiveHeadOnly", "NO", NULL,
795 &wPreferences.cycle_active_head_only, getBool, NULL, NULL, NULL},
796 {"CycleIgnoreMinimized", "NO", NULL,
797 &wPreferences.cycle_ignore_minimized, getBool, NULL, NULL, NULL}
800 static void initDefaults(void)
802 unsigned int i;
803 WDefaultEntry *entry;
805 WMPLSetCaseSensitive(False);
807 for (i = 0; i < wlengthof(optionList); i++) {
808 entry = &optionList[i];
810 entry->plkey = WMCreatePLString(entry->key);
811 if (entry->default_value)
812 entry->plvalue = WMCreatePropListFromDescription(entry->default_value);
813 else
814 entry->plvalue = NULL;
817 for (i = 0; i < wlengthof(staticOptionList); i++) {
818 entry = &staticOptionList[i];
820 entry->plkey = WMCreatePLString(entry->key);
821 if (entry->default_value)
822 entry->plvalue = WMCreatePropListFromDescription(entry->default_value);
823 else
824 entry->plvalue = NULL;
828 static WMPropList *readGlobalDomain(const char *domainName, Bool requireDictionary)
830 WMPropList *globalDict = NULL;
831 char path[PATH_MAX];
832 struct stat stbuf;
834 snprintf(path, sizeof(path), "%s/%s/%s", SYSCONFDIR, GLOBAL_DEFAULTS_SUBDIR, domainName);
835 if (stat(path, &stbuf) >= 0) {
836 globalDict = WMReadPropListFromFile(path);
837 if (globalDict && requireDictionary && !WMIsPLDictionary(globalDict)) {
838 wwarning(_("Domain %s (%s) of global defaults database is corrupted!"), domainName, path);
839 WMReleasePropList(globalDict);
840 globalDict = NULL;
841 } else if (!globalDict) {
842 wwarning(_("could not load domain %s from global defaults database"), domainName);
846 return globalDict;
849 #if defined(GLOBAL_PREAMBLE_MENU_FILE) || defined(GLOBAL_EPILOGUE_MENU_FILE)
850 static void prependMenu(WMPropList * destarr, WMPropList * array)
852 WMPropList *item;
853 int i;
855 for (i = 0; i < WMGetPropListItemCount(array); i++) {
856 item = WMGetFromPLArray(array, i);
857 if (item)
858 WMInsertInPLArray(destarr, i + 1, item);
862 static void appendMenu(WMPropList * destarr, WMPropList * array)
864 WMPropList *item;
865 int i;
867 for (i = 0; i < WMGetPropListItemCount(array); i++) {
868 item = WMGetFromPLArray(array, i);
869 if (item)
870 WMAddToPLArray(destarr, item);
873 #endif
875 void wDefaultsMergeGlobalMenus(WDDomain * menuDomain)
877 WMPropList *menu = menuDomain->dictionary;
878 WMPropList *submenu;
880 if (!menu || !WMIsPLArray(menu))
881 return;
883 #ifdef GLOBAL_PREAMBLE_MENU_FILE
884 submenu = WMReadPropListFromFile(SYSCONFDIR "/" GLOBAL_DEFAULTS_SUBDIR "/" GLOBAL_PREAMBLE_MENU_FILE);
886 if (submenu && !WMIsPLArray(submenu)) {
887 wwarning(_("invalid global menu file %s"), GLOBAL_PREAMBLE_MENU_FILE);
888 WMReleasePropList(submenu);
889 submenu = NULL;
891 if (submenu) {
892 prependMenu(menu, submenu);
893 WMReleasePropList(submenu);
895 #endif
897 #ifdef GLOBAL_EPILOGUE_MENU_FILE
898 submenu = WMReadPropListFromFile(SYSCONFDIR "/" GLOBAL_DEFAULTS_SUBDIR "/" GLOBAL_EPILOGUE_MENU_FILE);
900 if (submenu && !WMIsPLArray(submenu)) {
901 wwarning(_("invalid global menu file %s"), GLOBAL_EPILOGUE_MENU_FILE);
902 WMReleasePropList(submenu);
903 submenu = NULL;
905 if (submenu) {
906 appendMenu(menu, submenu);
907 WMReleasePropList(submenu);
909 #endif
911 menuDomain->dictionary = menu;
914 WDDomain *wDefaultsInitDomain(const char *domain, Bool requireDictionary)
916 WDDomain *db;
917 struct stat stbuf;
918 static int inited = 0;
919 WMPropList *shared_dict = NULL;
921 if (!inited) {
922 inited = 1;
923 initDefaults();
926 db = wmalloc(sizeof(WDDomain));
927 db->domain_name = domain;
928 db->path = wdefaultspathfordomain(domain);
930 if (stat(db->path, &stbuf) >= 0) {
931 db->dictionary = WMReadPropListFromFile(db->path);
932 if (db->dictionary) {
933 if (requireDictionary && !WMIsPLDictionary(db->dictionary)) {
934 WMReleasePropList(db->dictionary);
935 db->dictionary = NULL;
936 wwarning(_("Domain %s (%s) of defaults database is corrupted!"), domain, db->path);
938 db->timestamp = stbuf.st_mtime;
939 } else {
940 wwarning(_("could not load domain %s from user defaults database"), domain);
944 /* global system dictionary */
945 shared_dict = readGlobalDomain(domain, requireDictionary);
947 if (shared_dict && db->dictionary && WMIsPLDictionary(shared_dict) &&
948 WMIsPLDictionary(db->dictionary)) {
949 WMMergePLDictionaries(shared_dict, db->dictionary, True);
950 WMReleasePropList(db->dictionary);
951 db->dictionary = shared_dict;
952 if (stbuf.st_mtime > db->timestamp)
953 db->timestamp = stbuf.st_mtime;
954 } else if (!db->dictionary) {
955 db->dictionary = shared_dict;
956 if (stbuf.st_mtime > db->timestamp)
957 db->timestamp = stbuf.st_mtime;
960 return db;
963 void wReadStaticDefaults(WMPropList * dict)
965 WMPropList *plvalue;
966 WDefaultEntry *entry;
967 unsigned int i;
968 void *tdata;
970 for (i = 0; i < wlengthof(staticOptionList); i++) {
971 entry = &staticOptionList[i];
973 if (dict)
974 plvalue = WMGetFromPLDictionary(dict, entry->plkey);
975 else
976 plvalue = NULL;
978 /* no default in the DB. Use builtin default */
979 if (!plvalue)
980 plvalue = entry->plvalue;
982 if (plvalue) {
983 /* convert data */
984 (*entry->convert) (NULL, entry, plvalue, entry->addr, &tdata);
985 if (entry->update)
986 (*entry->update) (NULL, entry, tdata, entry->extra_data);
991 void wDefaultsCheckDomains(void* arg)
993 WScreen *scr;
994 struct stat stbuf;
995 WMPropList *shared_dict = NULL;
996 WMPropList *dict;
997 int i;
999 /* Parameter not used, but tell the compiler that it is ok */
1000 (void) arg;
1002 if (stat(w_global.domain.wmaker->path, &stbuf) >= 0 && w_global.domain.wmaker->timestamp < stbuf.st_mtime) {
1003 w_global.domain.wmaker->timestamp = stbuf.st_mtime;
1005 /* Global dictionary */
1006 shared_dict = readGlobalDomain("WindowMaker", True);
1008 /* User dictionary */
1009 dict = WMReadPropListFromFile(w_global.domain.wmaker->path);
1011 if (dict) {
1012 if (!WMIsPLDictionary(dict)) {
1013 WMReleasePropList(dict);
1014 dict = NULL;
1015 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
1016 "WindowMaker", w_global.domain.wmaker->path);
1017 } else {
1018 if (shared_dict) {
1019 WMMergePLDictionaries(shared_dict, dict, True);
1020 WMReleasePropList(dict);
1021 dict = shared_dict;
1022 shared_dict = NULL;
1025 for (i = 0; i < w_global.screen_count; i++) {
1026 scr = wScreenWithNumber(i);
1027 if (scr)
1028 wReadDefaults(scr, dict);
1031 if (w_global.domain.wmaker->dictionary)
1032 WMReleasePropList(w_global.domain.wmaker->dictionary);
1034 w_global.domain.wmaker->dictionary = dict;
1036 } else {
1037 wwarning(_("could not load domain %s from user defaults database"), "WindowMaker");
1040 if (shared_dict)
1041 WMReleasePropList(shared_dict);
1045 if (stat(w_global.domain.window_attr->path, &stbuf) >= 0 && w_global.domain.window_attr->timestamp < stbuf.st_mtime) {
1046 /* global dictionary */
1047 shared_dict = readGlobalDomain("WMWindowAttributes", True);
1048 /* user dictionary */
1049 dict = WMReadPropListFromFile(w_global.domain.window_attr->path);
1050 if (dict) {
1051 if (!WMIsPLDictionary(dict)) {
1052 WMReleasePropList(dict);
1053 dict = NULL;
1054 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
1055 "WMWindowAttributes", w_global.domain.window_attr->path);
1056 } else {
1057 if (shared_dict) {
1058 WMMergePLDictionaries(shared_dict, dict, True);
1059 WMReleasePropList(dict);
1060 dict = shared_dict;
1061 shared_dict = NULL;
1064 if (w_global.domain.window_attr->dictionary)
1065 WMReleasePropList(w_global.domain.window_attr->dictionary);
1067 w_global.domain.window_attr->dictionary = dict;
1068 for (i = 0; i < w_global.screen_count; i++) {
1069 scr = wScreenWithNumber(i);
1070 if (scr) {
1071 wDefaultUpdateIcons(scr);
1073 /* Update the panel image if changed */
1074 /* Don't worry. If the image is the same these
1075 * functions will have no performance impact. */
1076 create_logo_image(scr);
1080 } else {
1081 wwarning(_("could not load domain %s from user defaults database"), "WMWindowAttributes");
1084 w_global.domain.window_attr->timestamp = stbuf.st_mtime;
1085 if (shared_dict)
1086 WMReleasePropList(shared_dict);
1089 if (stat(w_global.domain.root_menu->path, &stbuf) >= 0 && w_global.domain.root_menu->timestamp < stbuf.st_mtime) {
1090 dict = WMReadPropListFromFile(w_global.domain.root_menu->path);
1091 if (dict) {
1092 if (!WMIsPLArray(dict) && !WMIsPLString(dict)) {
1093 WMReleasePropList(dict);
1094 dict = NULL;
1095 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
1096 "WMRootMenu", w_global.domain.root_menu->path);
1097 } else {
1098 if (w_global.domain.root_menu->dictionary)
1099 WMReleasePropList(w_global.domain.root_menu->dictionary);
1101 w_global.domain.root_menu->dictionary = dict;
1102 wDefaultsMergeGlobalMenus(w_global.domain.root_menu);
1104 } else {
1105 wwarning(_("could not load domain %s from user defaults database"), "WMRootMenu");
1107 w_global.domain.root_menu->timestamp = stbuf.st_mtime;
1109 #ifndef HAVE_INOTIFY
1110 if (!arg)
1111 WMAddTimerHandler(DEFAULTS_CHECK_INTERVAL, wDefaultsCheckDomains, arg);
1112 #endif
1115 void wReadDefaults(WScreen * scr, WMPropList * new_dict)
1117 WMPropList *plvalue, *old_value;
1118 WDefaultEntry *entry;
1119 unsigned int i;
1120 int update_workspace_back = 0; /* kluge :/ */
1121 unsigned int needs_refresh;
1122 void *tdata;
1123 WMPropList *old_dict = (w_global.domain.wmaker->dictionary != new_dict ? w_global.domain.wmaker->dictionary : NULL);
1125 needs_refresh = 0;
1127 for (i = 0; i < wlengthof(optionList); i++) {
1128 entry = &optionList[i];
1130 if (new_dict)
1131 plvalue = WMGetFromPLDictionary(new_dict, entry->plkey);
1132 else
1133 plvalue = NULL;
1135 if (!old_dict)
1136 old_value = NULL;
1137 else
1138 old_value = WMGetFromPLDictionary(old_dict, entry->plkey);
1140 if (!plvalue && !old_value) {
1141 /* no default in the DB. Use builtin default */
1142 plvalue = entry->plvalue;
1143 if (plvalue && new_dict)
1144 WMPutInPLDictionary(new_dict, entry->plkey, plvalue);
1146 } else if (!plvalue) {
1147 /* value was deleted from DB. Keep current value */
1148 continue;
1149 } else if (!old_value) {
1150 /* set value for the 1st time */
1151 } else if (!WMIsPropListEqualTo(plvalue, old_value)) {
1152 /* value has changed */
1153 } else {
1154 if (strcmp(entry->key, "WorkspaceBack") == 0
1155 && update_workspace_back && scr->flags.backimage_helper_launched) {
1156 } else {
1157 /* value was not changed since last time */
1158 continue;
1162 if (plvalue) {
1163 /* convert data */
1164 if ((*entry->convert) (scr, entry, plvalue, entry->addr, &tdata)) {
1166 * If the WorkspaceSpecificBack data has been changed
1167 * so that the helper will be launched now, we must be
1168 * sure to send the default background texture config
1169 * to the helper.
1171 if (strcmp(entry->key, "WorkspaceSpecificBack") == 0 &&
1172 !scr->flags.backimage_helper_launched)
1173 update_workspace_back = 1;
1175 if (entry->update)
1176 needs_refresh |= (*entry->update) (scr, entry, tdata, entry->extra_data);
1182 if (needs_refresh != 0 && !scr->flags.startup) {
1183 int foo;
1185 foo = 0;
1186 if (needs_refresh & REFRESH_MENU_TITLE_TEXTURE)
1187 foo |= WTextureSettings;
1188 if (needs_refresh & REFRESH_MENU_TITLE_FONT)
1189 foo |= WFontSettings;
1190 if (needs_refresh & REFRESH_MENU_TITLE_COLOR)
1191 foo |= WColorSettings;
1192 if (foo)
1193 WMPostNotificationName(WNMenuTitleAppearanceSettingsChanged, NULL,
1194 (void *)(uintptr_t) foo);
1196 foo = 0;
1197 if (needs_refresh & REFRESH_MENU_TEXTURE)
1198 foo |= WTextureSettings;
1199 if (needs_refresh & REFRESH_MENU_FONT)
1200 foo |= WFontSettings;
1201 if (needs_refresh & REFRESH_MENU_COLOR)
1202 foo |= WColorSettings;
1203 if (foo)
1204 WMPostNotificationName(WNMenuAppearanceSettingsChanged, NULL, (void *)(uintptr_t) foo);
1206 foo = 0;
1207 if (needs_refresh & REFRESH_WINDOW_FONT)
1208 foo |= WFontSettings;
1209 if (needs_refresh & REFRESH_WINDOW_TEXTURES)
1210 foo |= WTextureSettings;
1211 if (needs_refresh & REFRESH_WINDOW_TITLE_COLOR)
1212 foo |= WColorSettings;
1213 if (foo)
1214 WMPostNotificationName(WNWindowAppearanceSettingsChanged, NULL, (void *)(uintptr_t) foo);
1216 if (!(needs_refresh & REFRESH_ICON_TILE)) {
1217 foo = 0;
1218 if (needs_refresh & REFRESH_ICON_FONT)
1219 foo |= WFontSettings;
1220 if (needs_refresh & REFRESH_ICON_TITLE_COLOR)
1221 foo |= WTextureSettings;
1222 if (needs_refresh & REFRESH_ICON_TITLE_BACK)
1223 foo |= WTextureSettings;
1224 if (foo)
1225 WMPostNotificationName(WNIconAppearanceSettingsChanged, NULL,
1226 (void *)(uintptr_t) foo);
1228 if (needs_refresh & REFRESH_ICON_TILE)
1229 WMPostNotificationName(WNIconTileSettingsChanged, NULL, NULL);
1231 if (needs_refresh & REFRESH_WORKSPACE_MENU) {
1232 if (w_global.workspace.menu)
1233 wWorkspaceMenuUpdate(w_global.workspace.menu);
1234 if (w_global.clip.ws_menu)
1235 wWorkspaceMenuUpdate(w_global.clip.ws_menu);
1236 if (w_global.workspace.submenu)
1237 w_global.workspace.submenu->flags.realized = 0;
1238 if (w_global.clip.submenu)
1239 w_global.clip.submenu->flags.realized = 0;
1244 void wDefaultUpdateIcons(WScreen *scr)
1246 WAppIcon *aicon = w_global.app_icon_list;
1247 WDrawerChain *dc;
1248 WWindow *wwin = scr->focused_window;
1250 while (aicon) {
1251 /* Get the application icon, default included */
1252 wIconChangeImageFile(aicon->icon, NULL);
1253 wAppIconPaint(aicon);
1254 aicon = aicon->next;
1257 if (!wPreferences.flags.noclip || wPreferences.flags.clip_merged_in_dock)
1258 wClipIconPaint();
1260 for (dc = scr->drawers; dc != NULL; dc = dc->next)
1261 wDrawerIconPaint(dc->adrawer->icon_array[0]);
1263 while (wwin) {
1264 if (wwin->icon && wwin->flags.miniaturized)
1265 wIconChangeImageFile(wwin->icon, NULL);
1266 wwin = wwin->prev;
1270 /* --------------------------- Local ----------------------- */
1272 #define GET_STRING_OR_DEFAULT(x, var) if (!WMIsPLString(value)) { \
1273 wwarning(_("Wrong option format for key \"%s\". Should be %s."), \
1274 entry->key, x); \
1275 wwarning(_("using default \"%s\" instead"), entry->default_value); \
1276 var = entry->default_value;\
1277 } else var = WMGetFromPLString(value)\
1280 static int string2index(WMPropList *key, WMPropList *val, const char *def, WOptionEnumeration * values)
1282 char *str;
1283 WOptionEnumeration *v;
1284 char buffer[TOTAL_VALUES_LENGTH];
1286 if (WMIsPLString(val) && (str = WMGetFromPLString(val))) {
1287 for (v = values; v->string != NULL; v++) {
1288 if (strcasecmp(v->string, str) == 0)
1289 return v->value;
1293 buffer[0] = 0;
1294 for (v = values; v->string != NULL; v++) {
1295 if (!v->is_alias) {
1296 if (buffer[0] != 0)
1297 strcat(buffer, ", ");
1298 snprintf(buffer+strlen(buffer),
1299 sizeof(buffer)-strlen(buffer)-1, "\"%s\"", v->string);
1302 wwarning(_("wrong option value for key \"%s\"; got \"%s\", should be one of %s."),
1303 WMGetFromPLString(key),
1304 WMIsPLString(val) ? WMGetFromPLString(val) : "(unknown)",
1305 buffer);
1307 if (def) {
1308 return string2index(key, val, NULL, values);
1311 return -1;
1315 * value - is the value in the defaults DB
1316 * addr - is the address to store the data
1317 * ret - is the address to store a pointer to a temporary buffer. ret
1318 * must not be freed and is used by the set functions
1320 static int getBool(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1322 static char data;
1323 const char *val;
1324 int second_pass = 0;
1326 /* Parameter not used, but tell the compiler that it is ok */
1327 (void) scr;
1329 GET_STRING_OR_DEFAULT("Boolean", val);
1331 again:
1332 if ((val[1] == '\0' && (val[0] == 'y' || val[0] == 'Y'))
1333 || strcasecmp(val, "YES") == 0) {
1335 data = 1;
1336 } else if ((val[1] == '\0' && (val[0] == 'n' || val[0] == 'N'))
1337 || strcasecmp(val, "NO") == 0) {
1338 data = 0;
1339 } else {
1340 int i;
1341 if (sscanf(val, "%i", &i) == 1) {
1342 if (i != 0)
1343 data = 1;
1344 else
1345 data = 0;
1346 } else {
1347 wwarning(_("can't convert \"%s\" to boolean for key \"%s\""), val, entry->key);
1348 if (second_pass == 0) {
1349 val = WMGetFromPLString(entry->plvalue);
1350 second_pass = 1;
1351 wwarning(_("using default \"%s\" instead"), val);
1352 goto again;
1354 return False;
1358 if (ret)
1359 *ret = &data;
1360 if (addr)
1361 *(char *)addr = data;
1363 return True;
1366 static int getInt(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1368 static int data;
1369 const char *val;
1371 /* Parameter not used, but tell the compiler that it is ok */
1372 (void) scr;
1374 GET_STRING_OR_DEFAULT("Integer", val);
1376 if (sscanf(val, "%i", &data) != 1) {
1377 wwarning(_("can't convert \"%s\" to integer for key \"%s\""), val, entry->key);
1378 val = WMGetFromPLString(entry->plvalue);
1379 wwarning(_("using default \"%s\" instead"), val);
1380 if (sscanf(val, "%i", &data) != 1) {
1381 return False;
1385 if (ret)
1386 *ret = &data;
1387 if (addr)
1388 *(int *)addr = data;
1390 return True;
1393 static int getCoord(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1395 static WCoord data;
1396 char *val_x, *val_y;
1397 int nelem, changed = 0;
1398 WMPropList *elem_x, *elem_y;
1400 again:
1401 if (!WMIsPLArray(value)) {
1402 wwarning(_("Wrong option format for key \"%s\". Should be %s."), entry->key, "Coordinate");
1403 if (changed == 0) {
1404 value = entry->plvalue;
1405 changed = 1;
1406 wwarning(_("using default \"%s\" instead"), entry->default_value);
1407 goto again;
1409 return False;
1412 nelem = WMGetPropListItemCount(value);
1413 if (nelem != 2) {
1414 wwarning(_("Incorrect number of elements in array for key \"%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 elem_x = WMGetFromPLArray(value, 0);
1425 elem_y = WMGetFromPLArray(value, 1);
1427 if (!elem_x || !elem_y || !WMIsPLString(elem_x) || !WMIsPLString(elem_y)) {
1428 wwarning(_("Wrong value for key \"%s\". Should be Coordinate."), entry->key);
1429 if (changed == 0) {
1430 value = entry->plvalue;
1431 changed = 1;
1432 wwarning(_("using default \"%s\" instead"), entry->default_value);
1433 goto again;
1435 return False;
1438 val_x = WMGetFromPLString(elem_x);
1439 val_y = WMGetFromPLString(elem_y);
1441 if (sscanf(val_x, "%i", &data.x) != 1 || sscanf(val_y, "%i", &data.y) != 1) {
1442 wwarning(_("can't convert array to integers for \"%s\"."), entry->key);
1443 if (changed == 0) {
1444 value = entry->plvalue;
1445 changed = 1;
1446 wwarning(_("using default \"%s\" instead"), entry->default_value);
1447 goto again;
1449 return False;
1452 if (data.x < 0)
1453 data.x = 0;
1454 else if (data.x > scr->scr_width / 3)
1455 data.x = scr->scr_width / 3;
1456 if (data.y < 0)
1457 data.y = 0;
1458 else if (data.y > scr->scr_height / 3)
1459 data.y = scr->scr_height / 3;
1461 if (ret)
1462 *ret = &data;
1463 if (addr)
1464 *(WCoord *) addr = data;
1466 return True;
1469 static int getPropList(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1471 /* Parameter not used, but tell the compiler that it is ok */
1472 (void) scr;
1473 (void) entry;
1474 (void) addr;
1476 WMRetainPropList(value);
1478 *ret = value;
1480 return True;
1483 static int getPathList(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1485 static char *data;
1486 int i, count, len;
1487 char *ptr;
1488 WMPropList *d;
1489 int changed = 0;
1491 /* Parameter not used, but tell the compiler that it is ok */
1492 (void) scr;
1493 (void) ret;
1495 again:
1496 if (!WMIsPLArray(value)) {
1497 wwarning(_("Wrong option format for key \"%s\". Should be %s."), entry->key, "an array of paths");
1498 if (changed == 0) {
1499 value = entry->plvalue;
1500 changed = 1;
1501 wwarning(_("using default \"%s\" instead"), entry->default_value);
1502 goto again;
1504 return False;
1507 i = 0;
1508 count = WMGetPropListItemCount(value);
1509 if (count < 1) {
1510 if (changed == 0) {
1511 value = entry->plvalue;
1512 changed = 1;
1513 wwarning(_("using default \"%s\" instead"), entry->default_value);
1514 goto again;
1516 return False;
1519 len = 0;
1520 for (i = 0; i < count; i++) {
1521 d = WMGetFromPLArray(value, i);
1522 if (!d || !WMIsPLString(d)) {
1523 count = i;
1524 break;
1526 len += strlen(WMGetFromPLString(d)) + 1;
1529 ptr = data = wmalloc(len + 1);
1531 for (i = 0; i < count; i++) {
1532 d = WMGetFromPLArray(value, i);
1533 if (!d || !WMIsPLString(d)) {
1534 break;
1536 strcpy(ptr, WMGetFromPLString(d));
1537 ptr += strlen(WMGetFromPLString(d));
1538 *ptr = ':';
1539 ptr++;
1541 ptr--;
1542 *(ptr--) = 0;
1544 if (*(char **)addr != NULL) {
1545 wfree(*(char **)addr);
1547 *(char **)addr = data;
1549 return True;
1552 static int getEnum(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1554 static signed char data;
1556 /* Parameter not used, but tell the compiler that it is ok */
1557 (void) scr;
1559 data = string2index(entry->plkey, value, entry->default_value, (WOptionEnumeration *) entry->extra_data);
1560 if (data < 0)
1561 return False;
1563 if (ret)
1564 *ret = &data;
1565 if (addr)
1566 *(signed char *)addr = data;
1568 return True;
1572 * (solid <color>)
1573 * (hgradient <color> <color>)
1574 * (vgradient <color> <color>)
1575 * (dgradient <color> <color>)
1576 * (mhgradient <color> <color> ...)
1577 * (mvgradient <color> <color> ...)
1578 * (mdgradient <color> <color> ...)
1579 * (igradient <color1> <color1> <thickness1> <color2> <color2> <thickness2>)
1580 * (tpixmap <file> <color>)
1581 * (spixmap <file> <color>)
1582 * (cpixmap <file> <color>)
1583 * (thgradient <file> <opaqueness> <color> <color>)
1584 * (tvgradient <file> <opaqueness> <color> <color>)
1585 * (tdgradient <file> <opaqueness> <color> <color>)
1586 * (function <lib> <function> ...)
1589 static WTexture *parse_texture(WScreen * scr, WMPropList * pl)
1591 WMPropList *elem;
1592 char *val;
1593 int nelem;
1594 WTexture *texture = NULL;
1596 nelem = WMGetPropListItemCount(pl);
1597 if (nelem < 1)
1598 return NULL;
1600 elem = WMGetFromPLArray(pl, 0);
1601 if (!elem || !WMIsPLString(elem))
1602 return NULL;
1603 val = WMGetFromPLString(elem);
1605 if (strcasecmp(val, "solid") == 0) {
1606 XColor color;
1608 if (nelem != 2)
1609 return NULL;
1611 /* get color */
1613 elem = WMGetFromPLArray(pl, 1);
1614 if (!elem || !WMIsPLString(elem))
1615 return NULL;
1616 val = WMGetFromPLString(elem);
1618 if (!XParseColor(dpy, scr->w_colormap, val, &color)) {
1619 wwarning(_("\"%s\" is not a valid color name"), val);
1620 return NULL;
1623 texture = (WTexture *) wTextureMakeSolid(scr, &color);
1624 } else if (strcasecmp(val, "dgradient") == 0
1625 || strcasecmp(val, "vgradient") == 0 || strcasecmp(val, "hgradient") == 0) {
1626 RColor color1, color2;
1627 XColor xcolor;
1628 int type;
1630 if (nelem != 3) {
1631 wwarning(_("bad number of arguments in gradient specification"));
1632 return NULL;
1635 if (val[0] == 'd' || val[0] == 'D')
1636 type = WTEX_DGRADIENT;
1637 else if (val[0] == 'h' || val[0] == 'H')
1638 type = WTEX_HGRADIENT;
1639 else
1640 type = WTEX_VGRADIENT;
1642 /* get from color */
1643 elem = WMGetFromPLArray(pl, 1);
1644 if (!elem || !WMIsPLString(elem))
1645 return NULL;
1646 val = WMGetFromPLString(elem);
1648 if (!XParseColor(dpy, scr->w_colormap, val, &xcolor)) {
1649 wwarning(_("\"%s\" is not a valid color name"), val);
1650 return NULL;
1652 color1.alpha = 255;
1653 color1.red = xcolor.red >> 8;
1654 color1.green = xcolor.green >> 8;
1655 color1.blue = xcolor.blue >> 8;
1657 /* get to color */
1658 elem = WMGetFromPLArray(pl, 2);
1659 if (!elem || !WMIsPLString(elem)) {
1660 return NULL;
1662 val = WMGetFromPLString(elem);
1664 if (!XParseColor(dpy, scr->w_colormap, val, &xcolor)) {
1665 wwarning(_("\"%s\" is not a valid color name"), val);
1666 return NULL;
1668 color2.alpha = 255;
1669 color2.red = xcolor.red >> 8;
1670 color2.green = xcolor.green >> 8;
1671 color2.blue = xcolor.blue >> 8;
1673 texture = (WTexture *) wTextureMakeGradient(scr, type, &color1, &color2);
1675 } else if (strcasecmp(val, "igradient") == 0) {
1676 RColor colors1[2], colors2[2];
1677 int th1, th2;
1678 XColor xcolor;
1679 int i;
1681 if (nelem != 7) {
1682 wwarning(_("bad number of arguments in gradient specification"));
1683 return NULL;
1686 /* get from color */
1687 for (i = 0; i < 2; i++) {
1688 elem = WMGetFromPLArray(pl, 1 + i);
1689 if (!elem || !WMIsPLString(elem))
1690 return NULL;
1691 val = WMGetFromPLString(elem);
1693 if (!XParseColor(dpy, scr->w_colormap, val, &xcolor)) {
1694 wwarning(_("\"%s\" is not a valid color name"), val);
1695 return NULL;
1697 colors1[i].alpha = 255;
1698 colors1[i].red = xcolor.red >> 8;
1699 colors1[i].green = xcolor.green >> 8;
1700 colors1[i].blue = xcolor.blue >> 8;
1702 elem = WMGetFromPLArray(pl, 3);
1703 if (!elem || !WMIsPLString(elem))
1704 return NULL;
1705 val = WMGetFromPLString(elem);
1706 th1 = atoi(val);
1708 /* get from color */
1709 for (i = 0; i < 2; i++) {
1710 elem = WMGetFromPLArray(pl, 4 + i);
1711 if (!elem || !WMIsPLString(elem))
1712 return NULL;
1713 val = WMGetFromPLString(elem);
1715 if (!XParseColor(dpy, scr->w_colormap, val, &xcolor)) {
1716 wwarning(_("\"%s\" is not a valid color name"), val);
1717 return NULL;
1719 colors2[i].alpha = 255;
1720 colors2[i].red = xcolor.red >> 8;
1721 colors2[i].green = xcolor.green >> 8;
1722 colors2[i].blue = xcolor.blue >> 8;
1724 elem = WMGetFromPLArray(pl, 6);
1725 if (!elem || !WMIsPLString(elem))
1726 return NULL;
1727 val = WMGetFromPLString(elem);
1728 th2 = atoi(val);
1730 texture = (WTexture *) wTextureMakeIGradient(scr, th1, colors1, th2, colors2);
1732 } else if (strcasecmp(val, "mhgradient") == 0
1733 || strcasecmp(val, "mvgradient") == 0 || strcasecmp(val, "mdgradient") == 0) {
1734 XColor color;
1735 RColor **colors;
1736 int i, count;
1737 int type;
1739 if (nelem < 3) {
1740 wwarning(_("too few arguments in multicolor gradient specification"));
1741 return NULL;
1744 if (val[1] == 'h' || val[1] == 'H')
1745 type = WTEX_MHGRADIENT;
1746 else if (val[1] == 'v' || val[1] == 'V')
1747 type = WTEX_MVGRADIENT;
1748 else
1749 type = WTEX_MDGRADIENT;
1751 count = nelem - 1;
1753 colors = wmalloc(sizeof(RColor *) * (count + 1));
1755 for (i = 0; i < count; i++) {
1756 elem = WMGetFromPLArray(pl, i + 1);
1757 if (!elem || !WMIsPLString(elem)) {
1758 for (--i; i >= 0; --i) {
1759 wfree(colors[i]);
1761 wfree(colors);
1762 return NULL;
1764 val = WMGetFromPLString(elem);
1766 if (!XParseColor(dpy, scr->w_colormap, val, &color)) {
1767 wwarning(_("\"%s\" is not a valid color name"), val);
1768 for (--i; i >= 0; --i) {
1769 wfree(colors[i]);
1771 wfree(colors);
1772 return NULL;
1773 } else {
1774 colors[i] = wmalloc(sizeof(RColor));
1775 colors[i]->red = color.red >> 8;
1776 colors[i]->green = color.green >> 8;
1777 colors[i]->blue = color.blue >> 8;
1780 colors[i] = NULL;
1782 texture = (WTexture *) wTextureMakeMGradient(scr, type, colors);
1783 } else if (strcasecmp(val, "spixmap") == 0 ||
1784 strcasecmp(val, "cpixmap") == 0 || strcasecmp(val, "tpixmap") == 0) {
1785 XColor color;
1786 int type;
1788 if (nelem != 3)
1789 return NULL;
1791 if (val[0] == 's' || val[0] == 'S')
1792 type = WTP_SCALE;
1793 else if (val[0] == 'c' || val[0] == 'C')
1794 type = WTP_CENTER;
1795 else
1796 type = WTP_TILE;
1798 /* get color */
1799 elem = WMGetFromPLArray(pl, 2);
1800 if (!elem || !WMIsPLString(elem)) {
1801 return NULL;
1803 val = WMGetFromPLString(elem);
1805 if (!XParseColor(dpy, scr->w_colormap, val, &color)) {
1806 wwarning(_("\"%s\" is not a valid color name"), val);
1807 return NULL;
1810 /* file name */
1811 elem = WMGetFromPLArray(pl, 1);
1812 if (!elem || !WMIsPLString(elem))
1813 return NULL;
1814 val = WMGetFromPLString(elem);
1816 texture = (WTexture *) wTextureMakePixmap(scr, type, val, &color);
1817 } else if (strcasecmp(val, "thgradient") == 0
1818 || strcasecmp(val, "tvgradient") == 0 || strcasecmp(val, "tdgradient") == 0) {
1819 RColor color1, color2;
1820 XColor xcolor;
1821 int opacity;
1822 int style;
1824 if (val[1] == 'h' || val[1] == 'H')
1825 style = WTEX_THGRADIENT;
1826 else if (val[1] == 'v' || val[1] == 'V')
1827 style = WTEX_TVGRADIENT;
1828 else
1829 style = WTEX_TDGRADIENT;
1831 if (nelem != 5) {
1832 wwarning(_("bad number of arguments in textured gradient specification"));
1833 return NULL;
1836 /* get from color */
1837 elem = WMGetFromPLArray(pl, 3);
1838 if (!elem || !WMIsPLString(elem))
1839 return NULL;
1840 val = WMGetFromPLString(elem);
1842 if (!XParseColor(dpy, scr->w_colormap, val, &xcolor)) {
1843 wwarning(_("\"%s\" is not a valid color name"), val);
1844 return NULL;
1846 color1.alpha = 255;
1847 color1.red = xcolor.red >> 8;
1848 color1.green = xcolor.green >> 8;
1849 color1.blue = xcolor.blue >> 8;
1851 /* get to color */
1852 elem = WMGetFromPLArray(pl, 4);
1853 if (!elem || !WMIsPLString(elem)) {
1854 return NULL;
1856 val = WMGetFromPLString(elem);
1858 if (!XParseColor(dpy, scr->w_colormap, val, &xcolor)) {
1859 wwarning(_("\"%s\" is not a valid color name"), val);
1860 return NULL;
1862 color2.alpha = 255;
1863 color2.red = xcolor.red >> 8;
1864 color2.green = xcolor.green >> 8;
1865 color2.blue = xcolor.blue >> 8;
1867 /* get opacity */
1868 elem = WMGetFromPLArray(pl, 2);
1869 if (!elem || !WMIsPLString(elem))
1870 opacity = 128;
1871 else
1872 val = WMGetFromPLString(elem);
1874 if (!val || (opacity = atoi(val)) < 0 || opacity > 255) {
1875 wwarning(_("bad opacity value for tgradient texture \"%s\". Should be [0..255]"), val);
1876 opacity = 128;
1879 /* get file name */
1880 elem = WMGetFromPLArray(pl, 1);
1881 if (!elem || !WMIsPLString(elem))
1882 return NULL;
1883 val = WMGetFromPLString(elem);
1885 texture = (WTexture *) wTextureMakeTGradient(scr, style, &color1, &color2, val, opacity);
1886 } else if (strcasecmp(val, "function") == 0) {
1887 /* Leave this in to handle the unlikely case of
1888 * someone actually having function textures configured */
1889 wwarning("function texture support has been removed");
1890 return NULL;
1891 } else {
1892 wwarning(_("invalid texture type %s"), val);
1893 return NULL;
1895 return texture;
1898 static int getTexture(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1900 static WTexture *texture;
1901 int changed = 0;
1903 again:
1904 if (!WMIsPLArray(value)) {
1905 wwarning(_("Wrong option format for key \"%s\". Should be %s."), entry->key, "Texture");
1906 if (changed == 0) {
1907 value = entry->plvalue;
1908 changed = 1;
1909 wwarning(_("using default \"%s\" instead"), entry->default_value);
1910 goto again;
1912 return False;
1915 if (strcmp(entry->key, "WidgetColor") == 0 && !changed) {
1916 WMPropList *pl;
1918 pl = WMGetFromPLArray(value, 0);
1919 if (!pl || !WMIsPLString(pl) || !WMGetFromPLString(pl)
1920 || strcasecmp(WMGetFromPLString(pl), "solid") != 0) {
1921 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1922 entry->key, "Solid Texture");
1924 value = entry->plvalue;
1925 changed = 1;
1926 wwarning(_("using default \"%s\" instead"), entry->default_value);
1927 goto again;
1931 texture = parse_texture(scr, value);
1933 if (!texture) {
1934 wwarning(_("Error in texture specification for key \"%s\""), entry->key);
1935 if (changed == 0) {
1936 value = entry->plvalue;
1937 changed = 1;
1938 wwarning(_("using default \"%s\" instead"), entry->default_value);
1939 goto again;
1941 return False;
1944 if (ret)
1945 *ret = &texture;
1947 if (addr)
1948 *(WTexture **) addr = texture;
1950 return True;
1953 static int getWSBackground(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
1955 WMPropList *elem;
1956 int changed = 0;
1957 char *val;
1958 int nelem;
1960 /* Parameter not used, but tell the compiler that it is ok */
1961 (void) scr;
1962 (void) addr;
1964 again:
1965 if (!WMIsPLArray(value)) {
1966 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1967 "WorkspaceBack", "Texture or None");
1968 if (changed == 0) {
1969 value = entry->plvalue;
1970 changed = 1;
1971 wwarning(_("using default \"%s\" instead"), entry->default_value);
1972 goto again;
1974 return False;
1977 /* only do basic error checking and verify for None texture */
1979 nelem = WMGetPropListItemCount(value);
1980 if (nelem > 0) {
1981 elem = WMGetFromPLArray(value, 0);
1982 if (!elem || !WMIsPLString(elem)) {
1983 wwarning(_("Wrong type for workspace background. Should be a texture type."));
1984 if (changed == 0) {
1985 value = entry->plvalue;
1986 changed = 1;
1987 wwarning(_("using default \"%s\" instead"), entry->default_value);
1988 goto again;
1990 return False;
1992 val = WMGetFromPLString(elem);
1994 if (strcasecmp(val, "None") == 0)
1995 return True;
1997 *ret = WMRetainPropList(value);
1999 return True;
2002 static int
2003 getWSSpecificBackground(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
2005 WMPropList *elem;
2006 int nelem;
2007 int changed = 0;
2009 /* Parameter not used, but tell the compiler that it is ok */
2010 (void) scr;
2011 (void) addr;
2013 again:
2014 if (!WMIsPLArray(value)) {
2015 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
2016 "WorkspaceSpecificBack", "an array of textures");
2017 if (changed == 0) {
2018 value = entry->plvalue;
2019 changed = 1;
2020 wwarning(_("using default \"%s\" instead"), entry->default_value);
2021 goto again;
2023 return False;
2026 /* only do basic error checking and verify for None texture */
2028 nelem = WMGetPropListItemCount(value);
2029 if (nelem > 0) {
2030 while (nelem--) {
2031 elem = WMGetFromPLArray(value, nelem);
2032 if (!elem || !WMIsPLArray(elem)) {
2033 wwarning(_("Wrong type for background of workspace %i. Should be a texture."),
2034 nelem);
2039 *ret = WMRetainPropList(value);
2041 #ifdef notworking
2043 * Kluge to force wmsetbg helper to set the default background.
2044 * If the WorkspaceSpecificBack is changed once wmaker has started,
2045 * the WorkspaceBack won't be sent to the helper, unless the user
2046 * changes it's value too. So, we must force this by removing the
2047 * value from the defaults DB.
2049 if (!scr->flags.backimage_helper_launched && !scr->flags.startup) {
2050 WMPropList *key = WMCreatePLString("WorkspaceBack");
2052 WMRemoveFromPLDictionary(w_global.domain.wmaker->dictionary, key);
2054 WMReleasePropList(key);
2056 #endif
2057 return True;
2060 static int getFont(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
2062 static WMFont *font;
2063 const char *val;
2065 (void) addr;
2067 GET_STRING_OR_DEFAULT("Font", val);
2069 font = WMCreateFont(scr->wmscreen, val);
2070 if (!font)
2071 font = WMCreateFont(scr->wmscreen, "fixed");
2073 if (!font) {
2074 wfatal(_("could not load any usable font!!!"));
2075 exit(1);
2078 if (ret)
2079 *ret = font;
2081 /* can't assign font value outside update function */
2082 wassertrv(addr == NULL, True);
2084 return True;
2087 static int getColor(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
2089 static XColor color;
2090 const char *val;
2091 int second_pass = 0;
2093 (void) addr;
2095 GET_STRING_OR_DEFAULT("Color", val);
2097 again:
2098 if (!wGetColor(scr, val, &color)) {
2099 wwarning(_("could not get color for key \"%s\""), entry->key);
2100 if (second_pass == 0) {
2101 val = WMGetFromPLString(entry->plvalue);
2102 second_pass = 1;
2103 wwarning(_("using default \"%s\" instead"), val);
2104 goto again;
2106 return False;
2109 if (ret)
2110 *ret = &color;
2112 assert(addr == NULL);
2114 if (addr)
2115 *(unsigned long*)addr = pixel;
2118 return True;
2121 static int getKeybind(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
2123 static WShortKey shortcut;
2124 KeySym ksym;
2125 const char *val;
2126 char *k;
2127 char buf[MAX_SHORTCUT_LENGTH], *b;
2129 /* Parameter not used, but tell the compiler that it is ok */
2130 (void) scr;
2131 (void) addr;
2133 GET_STRING_OR_DEFAULT("Key spec", val);
2135 if (!val || strcasecmp(val, "NONE") == 0) {
2136 shortcut.keycode = 0;
2137 shortcut.modifier = 0;
2138 if (ret)
2139 *ret = &shortcut;
2140 return True;
2143 wstrlcpy(buf, val, MAX_SHORTCUT_LENGTH);
2145 b = (char *)buf;
2147 /* get modifiers */
2148 shortcut.modifier = 0;
2149 while ((k = strchr(b, '+')) != NULL) {
2150 int mod;
2152 *k = 0;
2153 mod = wXModifierFromKey(b);
2154 if (mod < 0) {
2155 wwarning(_("%s: invalid key modifier \"%s\""), entry->key, b);
2156 return False;
2158 shortcut.modifier |= mod;
2160 b = k + 1;
2163 /* get key */
2164 ksym = XStringToKeysym(b);
2166 if (ksym == NoSymbol) {
2167 wwarning(_("%s:invalid kbd shortcut specification \"%s\""), entry->key, val);
2168 return False;
2171 shortcut.keycode = XKeysymToKeycode(dpy, ksym);
2172 if (shortcut.keycode == 0) {
2173 wwarning(_("%s:invalid key in shortcut \"%s\""), entry->key, val);
2174 return False;
2177 if (ret)
2178 *ret = &shortcut;
2180 return True;
2183 static int getModMask(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
2185 static int mask;
2186 const char *str;
2188 /* Parameter not used, but tell the compiler that it is ok */
2189 (void) scr;
2191 GET_STRING_OR_DEFAULT("Modifier Key", str);
2193 if (!str)
2194 return False;
2196 mask = wXModifierFromKey(str);
2197 if (mask < 0) {
2198 wwarning(_("%s: modifier key %s is not valid"), entry->key, str);
2199 mask = 0;
2200 return False;
2203 if (addr)
2204 *(int *)addr = mask;
2206 if (ret)
2207 *ret = &mask;
2209 return True;
2212 # include <X11/cursorfont.h>
2213 typedef struct {
2214 const char *name;
2215 int id;
2216 } WCursorLookup;
2218 #define CURSOR_ID_NONE (XC_num_glyphs)
2220 static const WCursorLookup cursor_table[] = {
2221 {"X_cursor", XC_X_cursor},
2222 {"arrow", XC_arrow},
2223 {"based_arrow_down", XC_based_arrow_down},
2224 {"based_arrow_up", XC_based_arrow_up},
2225 {"boat", XC_boat},
2226 {"bogosity", XC_bogosity},
2227 {"bottom_left_corner", XC_bottom_left_corner},
2228 {"bottom_right_corner", XC_bottom_right_corner},
2229 {"bottom_side", XC_bottom_side},
2230 {"bottom_tee", XC_bottom_tee},
2231 {"box_spiral", XC_box_spiral},
2232 {"center_ptr", XC_center_ptr},
2233 {"circle", XC_circle},
2234 {"clock", XC_clock},
2235 {"coffee_mug", XC_coffee_mug},
2236 {"cross", XC_cross},
2237 {"cross_reverse", XC_cross_reverse},
2238 {"crosshair", XC_crosshair},
2239 {"diamond_cross", XC_diamond_cross},
2240 {"dot", XC_dot},
2241 {"dotbox", XC_dotbox},
2242 {"double_arrow", XC_double_arrow},
2243 {"draft_large", XC_draft_large},
2244 {"draft_small", XC_draft_small},
2245 {"draped_box", XC_draped_box},
2246 {"exchange", XC_exchange},
2247 {"fleur", XC_fleur},
2248 {"gobbler", XC_gobbler},
2249 {"gumby", XC_gumby},
2250 {"hand1", XC_hand1},
2251 {"hand2", XC_hand2},
2252 {"heart", XC_heart},
2253 {"icon", XC_icon},
2254 {"iron_cross", XC_iron_cross},
2255 {"left_ptr", XC_left_ptr},
2256 {"left_side", XC_left_side},
2257 {"left_tee", XC_left_tee},
2258 {"leftbutton", XC_leftbutton},
2259 {"ll_angle", XC_ll_angle},
2260 {"lr_angle", XC_lr_angle},
2261 {"man", XC_man},
2262 {"middlebutton", XC_middlebutton},
2263 {"mouse", XC_mouse},
2264 {"pencil", XC_pencil},
2265 {"pirate", XC_pirate},
2266 {"plus", XC_plus},
2267 {"question_arrow", XC_question_arrow},
2268 {"right_ptr", XC_right_ptr},
2269 {"right_side", XC_right_side},
2270 {"right_tee", XC_right_tee},
2271 {"rightbutton", XC_rightbutton},
2272 {"rtl_logo", XC_rtl_logo},
2273 {"sailboat", XC_sailboat},
2274 {"sb_down_arrow", XC_sb_down_arrow},
2275 {"sb_h_double_arrow", XC_sb_h_double_arrow},
2276 {"sb_left_arrow", XC_sb_left_arrow},
2277 {"sb_right_arrow", XC_sb_right_arrow},
2278 {"sb_up_arrow", XC_sb_up_arrow},
2279 {"sb_v_double_arrow", XC_sb_v_double_arrow},
2280 {"shuttle", XC_shuttle},
2281 {"sizing", XC_sizing},
2282 {"spider", XC_spider},
2283 {"spraycan", XC_spraycan},
2284 {"star", XC_star},
2285 {"target", XC_target},
2286 {"tcross", XC_tcross},
2287 {"top_left_arrow", XC_top_left_arrow},
2288 {"top_left_corner", XC_top_left_corner},
2289 {"top_right_corner", XC_top_right_corner},
2290 {"top_side", XC_top_side},
2291 {"top_tee", XC_top_tee},
2292 {"trek", XC_trek},
2293 {"ul_angle", XC_ul_angle},
2294 {"umbrella", XC_umbrella},
2295 {"ur_angle", XC_ur_angle},
2296 {"watch", XC_watch},
2297 {"xterm", XC_xterm},
2298 {NULL, CURSOR_ID_NONE}
2301 static void check_bitmap_status(int status, const char *filename, Pixmap bitmap)
2303 switch (status) {
2304 case BitmapOpenFailed:
2305 wwarning(_("failed to open bitmap file \"%s\""), filename);
2306 break;
2307 case BitmapFileInvalid:
2308 wwarning(_("\"%s\" is not a valid bitmap file"), filename);
2309 break;
2310 case BitmapNoMemory:
2311 wwarning(_("out of memory reading bitmap file \"%s\""), filename);
2312 break;
2313 case BitmapSuccess:
2314 XFreePixmap(dpy, bitmap);
2315 break;
2320 * (none)
2321 * (builtin, <cursor_name>)
2322 * (bitmap, <cursor_bitmap>, <cursor_mask>)
2324 static int parse_cursor(WScreen * scr, WMPropList * pl, Cursor * cursor)
2326 WMPropList *elem;
2327 char *val;
2328 int nelem;
2329 int status = 0;
2331 nelem = WMGetPropListItemCount(pl);
2332 if (nelem < 1) {
2333 return (status);
2335 elem = WMGetFromPLArray(pl, 0);
2336 if (!elem || !WMIsPLString(elem)) {
2337 return (status);
2339 val = WMGetFromPLString(elem);
2341 if (strcasecmp(val, "none") == 0) {
2342 status = 1;
2343 *cursor = None;
2344 } else if (strcasecmp(val, "builtin") == 0) {
2345 int i;
2346 int cursor_id = CURSOR_ID_NONE;
2348 if (nelem != 2) {
2349 wwarning(_("bad number of arguments in cursor specification"));
2350 return (status);
2352 elem = WMGetFromPLArray(pl, 1);
2353 if (!elem || !WMIsPLString(elem)) {
2354 return (status);
2356 val = WMGetFromPLString(elem);
2358 for (i = 0; cursor_table[i].name != NULL; i++) {
2359 if (strcasecmp(val, cursor_table[i].name) == 0) {
2360 cursor_id = cursor_table[i].id;
2361 break;
2364 if (CURSOR_ID_NONE == cursor_id) {
2365 wwarning(_("unknown builtin cursor name \"%s\""), val);
2366 } else {
2367 *cursor = XCreateFontCursor(dpy, cursor_id);
2368 status = 1;
2370 } else if (strcasecmp(val, "bitmap") == 0) {
2371 char *bitmap_name;
2372 char *mask_name;
2373 int bitmap_status;
2374 int mask_status;
2375 Pixmap bitmap;
2376 Pixmap mask;
2377 unsigned int w, h;
2378 int x, y;
2379 XColor fg, bg;
2381 if (nelem != 3) {
2382 wwarning(_("bad number of arguments in cursor specification"));
2383 return (status);
2385 elem = WMGetFromPLArray(pl, 1);
2386 if (!elem || !WMIsPLString(elem)) {
2387 return (status);
2389 val = WMGetFromPLString(elem);
2390 bitmap_name = FindImage(wPreferences.pixmap_path, val);
2391 if (!bitmap_name) {
2392 wwarning(_("could not find cursor bitmap file \"%s\""), val);
2393 return (status);
2395 elem = WMGetFromPLArray(pl, 2);
2396 if (!elem || !WMIsPLString(elem)) {
2397 wfree(bitmap_name);
2398 return (status);
2400 val = WMGetFromPLString(elem);
2401 mask_name = FindImage(wPreferences.pixmap_path, val);
2402 if (!mask_name) {
2403 wfree(bitmap_name);
2404 wwarning(_("could not find cursor bitmap file \"%s\""), val);
2405 return (status);
2407 mask_status = XReadBitmapFile(dpy, scr->w_win, mask_name, &w, &h, &mask, &x, &y);
2408 bitmap_status = XReadBitmapFile(dpy, scr->w_win, bitmap_name, &w, &h, &bitmap, &x, &y);
2409 if ((BitmapSuccess == bitmap_status) && (BitmapSuccess == mask_status)) {
2410 fg.pixel = scr->black_pixel;
2411 bg.pixel = scr->white_pixel;
2412 XQueryColor(dpy, scr->w_colormap, &fg);
2413 XQueryColor(dpy, scr->w_colormap, &bg);
2414 *cursor = XCreatePixmapCursor(dpy, bitmap, mask, &fg, &bg, x, y);
2415 status = 1;
2417 check_bitmap_status(bitmap_status, bitmap_name, bitmap);
2418 check_bitmap_status(mask_status, mask_name, mask);
2419 wfree(bitmap_name);
2420 wfree(mask_name);
2422 return (status);
2425 static int getCursor(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
2427 static Cursor cursor;
2428 int status;
2429 int changed = 0;
2431 again:
2432 if (!WMIsPLArray(value)) {
2433 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
2434 entry->key, "cursor specification");
2435 if (!changed) {
2436 value = entry->plvalue;
2437 changed = 1;
2438 wwarning(_("using default \"%s\" instead"), entry->default_value);
2439 goto again;
2441 return (False);
2443 status = parse_cursor(scr, value, &cursor);
2444 if (!status) {
2445 wwarning(_("Error in cursor specification for key \"%s\""), entry->key);
2446 if (!changed) {
2447 value = entry->plvalue;
2448 changed = 1;
2449 wwarning(_("using default \"%s\" instead"), entry->default_value);
2450 goto again;
2452 return (False);
2454 if (ret) {
2455 *ret = &cursor;
2457 if (addr) {
2458 *(Cursor *) addr = cursor;
2460 return (True);
2463 #undef CURSOR_ID_NONE
2465 /* ---------------- value setting functions --------------- */
2466 static int setJustify(WScreen * scr, WDefaultEntry * entry, void *tdata, void *extra_data)
2468 /* Parameter not used, but tell the compiler that it is ok */
2469 (void) scr;
2470 (void) entry;
2471 (void) tdata;
2472 (void) extra_data;
2474 return REFRESH_WINDOW_TITLE_COLOR;
2477 static int setClearance(WScreen * scr, WDefaultEntry * entry, void *bar, void *foo)
2479 /* Parameter not used, but tell the compiler that it is ok */
2480 (void) scr;
2481 (void) entry;
2482 (void) bar;
2483 (void) foo;
2485 return REFRESH_WINDOW_FONT | REFRESH_BUTTON_IMAGES | REFRESH_MENU_TITLE_FONT | REFRESH_MENU_FONT;
2488 static int setIfDockPresent(WScreen * scr, WDefaultEntry * entry, void *tdata, void *extra_data)
2490 char *flag = tdata;
2491 long which = (long) extra_data;
2493 /* Parameter not used, but tell the compiler that it is ok */
2494 (void) scr;
2495 (void) entry;
2497 switch (which) {
2498 case WM_DOCK:
2499 wPreferences.flags.nodock = wPreferences.flags.nodock || *flag;
2500 // Drawers require the dock
2501 wPreferences.flags.nodrawer = wPreferences.flags.nodrawer || wPreferences.flags.nodock;
2502 break;
2503 case WM_CLIP:
2504 wPreferences.flags.noclip = wPreferences.flags.noclip || *flag;
2505 break;
2506 case WM_DRAWER:
2507 wPreferences.flags.nodrawer = wPreferences.flags.nodrawer || *flag;
2508 break;
2509 default:
2510 break;
2512 return 0;
2515 static int setClipMergedInDock(WScreen *scr, WDefaultEntry *entry, void *tdata, void *foo)
2517 char *flag = tdata;
2519 /* Parameter not used, but tell the compiler that it is ok */
2520 (void) scr;
2521 (void) entry;
2522 (void) foo;
2524 wPreferences.flags.clip_merged_in_dock = *flag;
2525 wPreferences.flags.noclip = wPreferences.flags.noclip || *flag;
2526 return 0;
2529 static int setWrapAppiconsInDock(WScreen *scr, WDefaultEntry *entry, void *tdata, void *foo)
2531 char *flag = tdata;
2533 /* Parameter not used, but tell the compiler that it is ok */
2534 (void) scr;
2535 (void) entry;
2536 (void) foo;
2538 wPreferences.flags.wrap_appicons_in_dock = *flag;
2539 return 0;
2542 static int setStickyIcons(WScreen * scr, WDefaultEntry * entry, void *bar, void *foo)
2544 /* Parameter not used, but tell the compiler that it is ok */
2545 (void) entry;
2546 (void) bar;
2547 (void) foo;
2549 if (w_global.workspace.array) {
2550 wWorkspaceForceChange(scr, w_global.workspace.current);
2551 wArrangeIcons(scr, False);
2553 return 0;
2556 static int setIconTile(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2558 Pixmap pixmap;
2559 RImage *img;
2560 WTexture ** texture = tdata;
2561 int reset = 0;
2563 /* Parameter not used, but tell the compiler that it is ok */
2564 (void) foo;
2566 img = wTextureRenderImage(*texture, wPreferences.icon_size,
2567 wPreferences.icon_size, ((*texture)->any.type & WREL_BORDER_MASK)
2568 ? WREL_ICON : WREL_FLAT);
2569 if (!img) {
2570 wwarning(_("could not render texture for icon background"));
2571 if (!entry->addr)
2572 wTextureDestroy(scr, *texture);
2573 return 0;
2575 RConvertImage(scr->rcontext, img, &pixmap);
2577 if (scr->icon_tile) {
2578 reset = 1;
2579 RReleaseImage(scr->icon_tile);
2580 XFreePixmap(dpy, scr->icon_tile_pixmap);
2583 scr->icon_tile = img;
2585 /* put the icon in the noticeboard hint */
2586 PropSetIconTileHint(scr, img);
2588 if (!wPreferences.flags.noclip || wPreferences.flags.clip_merged_in_dock) {
2589 if (scr->clip_tile) {
2590 RReleaseImage(scr->clip_tile);
2592 scr->clip_tile = wClipMakeTile(img);
2595 if (!wPreferences.flags.nodrawer) {
2596 if (scr->drawer_tile) {
2597 RReleaseImage(scr->drawer_tile);
2599 scr->drawer_tile = wDrawerMakeTile(scr, img);
2602 scr->icon_tile_pixmap = pixmap;
2604 if (scr->def_icon_rimage) {
2605 RReleaseImage(scr->def_icon_rimage);
2606 scr->def_icon_rimage = NULL;
2609 if (scr->icon_back_texture)
2610 wTextureDestroy(scr, (WTexture *) scr->icon_back_texture);
2612 scr->icon_back_texture = wTextureMakeSolid(scr, &((*texture)->any.color));
2614 /* Free the texture as nobody else will use it, nor refer to it. */
2615 if (!entry->addr)
2616 wTextureDestroy(scr, *texture);
2618 return (reset ? REFRESH_ICON_TILE : 0);
2621 static int setWinTitleFont(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2623 WMFont *font = tdata;
2625 /* Parameter not used, but tell the compiler that it is ok */
2626 (void) entry;
2627 (void) foo;
2629 if (scr->title_font) {
2630 WMReleaseFont(scr->title_font);
2632 scr->title_font = font;
2634 return REFRESH_WINDOW_FONT | REFRESH_BUTTON_IMAGES;
2637 static int setMenuTitleFont(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2639 WMFont *font = tdata;
2641 /* Parameter not used, but tell the compiler that it is ok */
2642 (void) entry;
2643 (void) foo;
2645 if (scr->menu_title_font) {
2646 WMReleaseFont(scr->menu_title_font);
2649 scr->menu_title_font = font;
2651 return REFRESH_MENU_TITLE_FONT;
2654 static int setMenuTextFont(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2656 WMFont *font = tdata;
2658 /* Parameter not used, but tell the compiler that it is ok */
2659 (void) entry;
2660 (void) foo;
2662 if (scr->menu_entry_font) {
2663 WMReleaseFont(scr->menu_entry_font);
2665 scr->menu_entry_font = font;
2667 return REFRESH_MENU_FONT;
2670 static int setIconTitleFont(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2672 WMFont *font = tdata;
2674 /* Parameter not used, but tell the compiler that it is ok */
2675 (void) entry;
2676 (void) foo;
2678 if (scr->icon_title_font) {
2679 WMReleaseFont(scr->icon_title_font);
2682 scr->icon_title_font = font;
2684 return REFRESH_ICON_FONT;
2687 static int setClipTitleFont(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2689 WMFont *font = tdata;
2691 /* Parameter not used, but tell the compiler that it is ok */
2692 (void) entry;
2693 (void) foo;
2695 if (scr->clip_title_font) {
2696 WMReleaseFont(scr->clip_title_font);
2699 scr->clip_title_font = font;
2701 return REFRESH_ICON_FONT;
2704 static int setLargeDisplayFont(WScreen *scr, WDefaultEntry *entry, void *tdata, void *foo)
2706 WMFont *font = tdata;
2708 /* Parameter not used, but tell the compiler that it is ok */
2709 (void) scr;
2710 (void) entry;
2711 (void) foo;
2713 if (w_global.workspace.font_for_name)
2714 WMReleaseFont(w_global.workspace.font_for_name);
2716 w_global.workspace.font_for_name = font;
2718 return 0;
2721 static int setHightlight(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2723 XColor *color = tdata;
2725 /* Parameter not used, but tell the compiler that it is ok */
2726 (void) entry;
2727 (void) foo;
2729 if (scr->select_color)
2730 WMReleaseColor(scr->select_color);
2732 scr->select_color = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2734 wFreeColor(scr, color->pixel);
2736 return REFRESH_MENU_COLOR;
2739 static int setHightlightText(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2741 XColor *color = tdata;
2743 /* Parameter not used, but tell the compiler that it is ok */
2744 (void) entry;
2745 (void) foo;
2747 if (scr->select_text_color)
2748 WMReleaseColor(scr->select_text_color);
2750 scr->select_text_color = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2752 wFreeColor(scr, color->pixel);
2754 return REFRESH_MENU_COLOR;
2757 static int setClipTitleColor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *extra_data)
2759 XColor *color = tdata;
2760 long widx = (long) extra_data;
2762 /* Parameter not used, but tell the compiler that it is ok */
2763 (void) entry;
2765 if (scr->clip_title_color[widx])
2766 WMReleaseColor(scr->clip_title_color[widx]);
2768 scr->clip_title_color[widx] = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2769 wFreeColor(scr, color->pixel);
2771 return REFRESH_ICON_TITLE_COLOR;
2774 static int setWTitleColor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *extra_data)
2776 XColor *color = tdata;
2777 long widx = (long) extra_data;
2779 /* Parameter not used, but tell the compiler that it is ok */
2780 (void) entry;
2782 if (scr->window_title_color[widx])
2783 WMReleaseColor(scr->window_title_color[widx]);
2785 scr->window_title_color[widx] =
2786 WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2788 wFreeColor(scr, color->pixel);
2790 return REFRESH_WINDOW_TITLE_COLOR;
2793 static int setMenuTitleColor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *extra_data)
2795 XColor *color = tdata;
2797 /* Parameter not used, but tell the compiler that it is ok */
2798 (void) entry;
2799 (void) extra_data;
2801 if (scr->menu_title_color[0])
2802 WMReleaseColor(scr->menu_title_color[0]);
2804 scr->menu_title_color[0] = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2806 wFreeColor(scr, color->pixel);
2808 return REFRESH_MENU_TITLE_COLOR;
2811 static int setMenuTextColor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2813 XColor *color = tdata;
2815 /* Parameter not used, but tell the compiler that it is ok */
2816 (void) entry;
2817 (void) foo;
2819 if (scr->mtext_color)
2820 WMReleaseColor(scr->mtext_color);
2822 scr->mtext_color = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2824 if (WMColorPixel(scr->dtext_color) == WMColorPixel(scr->mtext_color)) {
2825 WMSetColorAlpha(scr->dtext_color, 0x7fff);
2826 } else {
2827 WMSetColorAlpha(scr->dtext_color, 0xffff);
2830 wFreeColor(scr, color->pixel);
2832 return REFRESH_MENU_COLOR;
2835 static int setMenuDisabledColor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2837 XColor *color = tdata;
2839 /* Parameter not used, but tell the compiler that it is ok */
2840 (void) entry;
2841 (void) foo;
2843 if (scr->dtext_color)
2844 WMReleaseColor(scr->dtext_color);
2846 scr->dtext_color = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2848 if (WMColorPixel(scr->dtext_color) == WMColorPixel(scr->mtext_color)) {
2849 WMSetColorAlpha(scr->dtext_color, 0x7fff);
2850 } else {
2851 WMSetColorAlpha(scr->dtext_color, 0xffff);
2854 wFreeColor(scr, color->pixel);
2856 return REFRESH_MENU_COLOR;
2859 static int setIconTitleColor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2861 XColor *color = tdata;
2863 /* Parameter not used, but tell the compiler that it is ok */
2864 (void) entry;
2865 (void) foo;
2867 if (scr->icon_title_color)
2868 WMReleaseColor(scr->icon_title_color);
2869 scr->icon_title_color = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2871 wFreeColor(scr, color->pixel);
2873 return REFRESH_ICON_TITLE_COLOR;
2876 static int setIconTitleBack(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2878 XColor *color = tdata;
2880 /* Parameter not used, but tell the compiler that it is ok */
2881 (void) entry;
2882 (void) foo;
2884 if (scr->icon_title_texture) {
2885 wTextureDestroy(scr, (WTexture *) scr->icon_title_texture);
2887 scr->icon_title_texture = wTextureMakeSolid(scr, color);
2889 return REFRESH_ICON_TITLE_BACK;
2892 static int setFrameBorderWidth(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2894 int *value = tdata;
2896 /* Parameter not used, but tell the compiler that it is ok */
2897 (void) entry;
2898 (void) foo;
2900 scr->frame_border_width = *value;
2902 return REFRESH_FRAME_BORDER;
2905 static int setFrameBorderColor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2907 XColor *color = tdata;
2909 /* Parameter not used, but tell the compiler that it is ok */
2910 (void) entry;
2911 (void) foo;
2913 if (scr->frame_border_color)
2914 WMReleaseColor(scr->frame_border_color);
2915 scr->frame_border_color = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2917 wFreeColor(scr, color->pixel);
2919 return REFRESH_FRAME_BORDER;
2922 static int setFrameFocusedBorderColor(WScreen *scr, WDefaultEntry *entry, void *tdata, void *foo)
2924 XColor *color = tdata;
2926 /* Parameter not used, but tell the compiler that it is ok */
2927 (void) entry;
2928 (void) foo;
2930 if (scr->frame_focused_border_color)
2931 WMReleaseColor(scr->frame_focused_border_color);
2932 scr->frame_focused_border_color = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2934 wFreeColor(scr, color->pixel);
2936 return REFRESH_FRAME_BORDER;
2939 static int setFrameSelectedBorderColor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
2941 XColor *color = tdata;
2943 /* Parameter not used, but tell the compiler that it is ok */
2944 (void) entry;
2945 (void) foo;
2947 if (scr->frame_selected_border_color)
2948 WMReleaseColor(scr->frame_selected_border_color);
2949 scr->frame_selected_border_color = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True);
2951 wFreeColor(scr, color->pixel);
2953 return REFRESH_FRAME_BORDER;
2956 static void trackDeadProcess(pid_t pid, unsigned int status, void *client_data)
2958 WScreen *scr = (WScreen *) client_data;
2960 /* Parameter not used, but tell the compiler that it is ok */
2961 (void) pid;
2962 (void) status;
2964 close(scr->helper_fd);
2965 scr->helper_fd = 0;
2966 scr->helper_pid = 0;
2967 scr->flags.backimage_helper_launched = 0;
2970 static int setWorkspaceSpecificBack(WScreen * scr, WDefaultEntry * entry, void *tdata, void *bar)
2972 WMPropList *value = tdata;
2973 WMPropList *val;
2974 char *str;
2975 int i;
2977 /* Parameter not used, but tell the compiler that it is ok */
2978 (void) entry;
2979 (void) bar;
2981 if (scr->flags.backimage_helper_launched) {
2982 if (WMGetPropListItemCount(value) == 0) {
2983 SendHelperMessage(scr, 'C', 0, NULL);
2984 SendHelperMessage(scr, 'K', 0, NULL);
2986 WMReleasePropList(value);
2987 return 0;
2989 } else {
2990 pid_t pid;
2991 int filedes[2];
2993 if (WMGetPropListItemCount(value) == 0)
2994 return 0;
2996 if (pipe(filedes) < 0) {
2997 werror("pipe() failed:can't set workspace specific background image");
2999 WMReleasePropList(value);
3000 return 0;
3003 pid = fork();
3004 if (pid < 0) {
3005 werror("fork() failed:can't set workspace specific background image");
3006 if (close(filedes[0]) < 0)
3007 werror("could not close pipe");
3008 if (close(filedes[1]) < 0)
3009 werror("could not close pipe");
3011 } else if (pid == 0) {
3012 char *dither;
3014 SetupEnvironment(scr);
3016 if (close(0) < 0)
3017 werror("could not close pipe");
3018 if (dup(filedes[0]) < 0) {
3019 werror("dup() failed:can't set workspace specific background image");
3021 dither = wPreferences.no_dithering ? "-m" : "-d";
3022 if (wPreferences.smooth_workspace_back)
3023 execlp("wmsetbg", "wmsetbg", "-helper", "-S", dither, NULL);
3024 else
3025 execlp("wmsetbg", "wmsetbg", "-helper", dither, NULL);
3026 werror("could not execute wmsetbg");
3027 exit(1);
3028 } else {
3030 if (fcntl(filedes[0], F_SETFD, FD_CLOEXEC) < 0) {
3031 werror("error setting close-on-exec flag");
3033 if (fcntl(filedes[1], F_SETFD, FD_CLOEXEC) < 0) {
3034 werror("error setting close-on-exec flag");
3037 scr->helper_fd = filedes[1];
3038 scr->helper_pid = pid;
3039 scr->flags.backimage_helper_launched = 1;
3041 wAddDeathHandler(pid, trackDeadProcess, scr);
3043 SendHelperMessage(scr, 'P', -1, wPreferences.pixmap_path);
3048 for (i = 0; i < WMGetPropListItemCount(value); i++) {
3049 val = WMGetFromPLArray(value, i);
3050 if (val && WMIsPLArray(val) && WMGetPropListItemCount(val) > 0) {
3051 str = WMGetPropListDescription(val, False);
3053 SendHelperMessage(scr, 'S', i + 1, str);
3055 wfree(str);
3056 } else {
3057 SendHelperMessage(scr, 'U', i + 1, NULL);
3060 sleep(1);
3062 WMReleasePropList(value);
3063 return 0;
3066 static int setWorkspaceBack(WScreen * scr, WDefaultEntry * entry, void *tdata, void *bar)
3068 WMPropList *value = tdata;
3070 /* Parameter not used, but tell the compiler that it is ok */
3071 (void) entry;
3072 (void) bar;
3074 if (scr->flags.backimage_helper_launched) {
3075 char *str;
3077 if (WMGetPropListItemCount(value) == 0) {
3078 SendHelperMessage(scr, 'U', 0, NULL);
3079 } else {
3080 /* set the default workspace background to this one */
3081 str = WMGetPropListDescription(value, False);
3082 if (str) {
3083 SendHelperMessage(scr, 'S', 0, str);
3084 wfree(str);
3085 SendHelperMessage(scr, 'C', w_global.workspace.current + 1, NULL);
3086 } else {
3087 SendHelperMessage(scr, 'U', 0, NULL);
3090 } else if (WMGetPropListItemCount(value) > 0) {
3091 char *command;
3092 char *text;
3093 char *dither;
3094 int len;
3096 text = WMGetPropListDescription(value, False);
3097 len = strlen(text) + 40;
3098 command = wmalloc(len);
3099 dither = wPreferences.no_dithering ? "-m" : "-d";
3100 if (wPreferences.smooth_workspace_back)
3101 snprintf(command, len, "wmsetbg %s -S -p '%s' &", dither, text);
3102 else
3103 snprintf(command, len, "wmsetbg %s -p '%s' &", dither, text);
3104 wfree(text);
3105 ExecuteShellCommand(scr, command);
3106 wfree(command);
3108 WMReleasePropList(value);
3110 return 0;
3113 static int setWidgetColor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
3115 WTexture **texture = tdata;
3117 /* Parameter not used, but tell the compiler that it is ok */
3118 (void) entry;
3119 (void) foo;
3121 if (scr->widget_texture) {
3122 wTextureDestroy(scr, (WTexture *) scr->widget_texture);
3124 scr->widget_texture = *(WTexSolid **) texture;
3126 return 0;
3129 static int setFTitleBack(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
3131 WTexture **texture = tdata;
3133 /* Parameter not used, but tell the compiler that it is ok */
3134 (void) entry;
3135 (void) foo;
3137 if (scr->window_title_texture[WS_FOCUSED]) {
3138 wTextureDestroy(scr, scr->window_title_texture[WS_FOCUSED]);
3140 scr->window_title_texture[WS_FOCUSED] = *texture;
3142 return REFRESH_WINDOW_TEXTURES;
3145 static int setPTitleBack(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
3147 WTexture **texture = tdata;
3149 /* Parameter not used, but tell the compiler that it is ok */
3150 (void) entry;
3151 (void) foo;
3153 if (scr->window_title_texture[WS_PFOCUSED]) {
3154 wTextureDestroy(scr, scr->window_title_texture[WS_PFOCUSED]);
3156 scr->window_title_texture[WS_PFOCUSED] = *texture;
3158 return REFRESH_WINDOW_TEXTURES;
3161 static int setUTitleBack(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
3163 WTexture **texture = tdata;
3165 /* Parameter not used, but tell the compiler that it is ok */
3166 (void) entry;
3167 (void) foo;
3169 if (scr->window_title_texture[WS_UNFOCUSED]) {
3170 wTextureDestroy(scr, scr->window_title_texture[WS_UNFOCUSED]);
3172 scr->window_title_texture[WS_UNFOCUSED] = *texture;
3174 return REFRESH_WINDOW_TEXTURES;
3177 static int setResizebarBack(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
3179 WTexture **texture = tdata;
3181 /* Parameter not used, but tell the compiler that it is ok */
3182 (void) entry;
3183 (void) foo;
3185 if (scr->resizebar_texture[0]) {
3186 wTextureDestroy(scr, scr->resizebar_texture[0]);
3188 scr->resizebar_texture[0] = *texture;
3190 return REFRESH_WINDOW_TEXTURES;
3193 static int setMenuTitleBack(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
3195 WTexture **texture = tdata;
3197 /* Parameter not used, but tell the compiler that it is ok */
3198 (void) entry;
3199 (void) foo;
3201 if (scr->menu_title_texture[0]) {
3202 wTextureDestroy(scr, scr->menu_title_texture[0]);
3204 scr->menu_title_texture[0] = *texture;
3206 return REFRESH_MENU_TITLE_TEXTURE;
3209 static int setMenuTextBack(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
3211 WTexture **texture = tdata;
3213 /* Parameter not used, but tell the compiler that it is ok */
3214 (void) entry;
3215 (void) foo;
3217 if (scr->menu_item_texture) {
3218 wTextureDestroy(scr, scr->menu_item_texture);
3219 wTextureDestroy(scr, (WTexture *) scr->menu_item_auxtexture);
3221 scr->menu_item_texture = *texture;
3223 scr->menu_item_auxtexture = wTextureMakeSolid(scr, &scr->menu_item_texture->any.color);
3225 return REFRESH_MENU_TEXTURE;
3228 static int setKeyGrab(WScreen * scr, WDefaultEntry * entry, void *tdata, void *extra_data)
3230 WShortKey *shortcut = tdata;
3231 WWindow *wwin;
3232 long widx = (long) extra_data;
3234 /* Parameter not used, but tell the compiler that it is ok */
3235 (void) entry;
3237 wKeyBindings[widx] = *shortcut;
3239 wwin = scr->focused_window;
3241 while (wwin != NULL) {
3242 XUngrabKey(dpy, AnyKey, AnyModifier, wwin->frame->core->window);
3244 if (!WFLAGP(wwin, no_bind_keys)) {
3245 wWindowSetKeyGrabs(wwin);
3247 wwin = wwin->prev;
3250 /* do we need to update window menus? */
3251 if (widx >= WKBD_WORKSPACE1 && widx <= WKBD_WORKSPACE10)
3252 return REFRESH_WORKSPACE_MENU;
3253 if (widx == WKBD_LASTWORKSPACE)
3254 return REFRESH_WORKSPACE_MENU;
3255 if (widx >= WKBD_MOVE_WORKSPACE1 && widx <= WKBD_MOVE_WORKSPACE10)
3256 return REFRESH_WORKSPACE_MENU;
3258 return 0;
3261 static int setIconPosition(WScreen * scr, WDefaultEntry * entry, void *bar, void *foo)
3263 /* Parameter not used, but tell the compiler that it is ok */
3264 (void) entry;
3265 (void) bar;
3266 (void) foo;
3268 wScreenUpdateUsableArea(scr);
3269 wArrangeIcons(scr, True);
3271 return 0;
3274 static int updateUsableArea(WScreen * scr, WDefaultEntry * entry, void *bar, void *foo)
3276 /* Parameter not used, but tell the compiler that it is ok */
3277 (void) entry;
3278 (void) bar;
3279 (void) foo;
3281 wScreenUpdateUsableArea(scr);
3283 return 0;
3286 static int setMenuStyle(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
3288 /* Parameter not used, but tell the compiler that it is ok */
3289 (void) scr;
3290 (void) entry;
3291 (void) tdata;
3292 (void) foo;
3294 return REFRESH_MENU_TEXTURE;
3297 static RImage *chopOffImage(RImage * image, int x, int y, int w, int h)
3299 RImage *img = RCreateImage(w, h, image->format == RRGBAFormat);
3301 RCopyArea(img, image, x, y, w, h, 0, 0);
3303 return img;
3306 static int setSwPOptions(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
3308 WMPropList *array = tdata;
3309 char *path;
3310 RImage *bgimage;
3311 int cwidth, cheight;
3312 struct WPreferences *prefs = foo;
3314 if (!WMIsPLArray(array) || WMGetPropListItemCount(array) == 0) {
3315 if (prefs->swtileImage)
3316 RReleaseImage(prefs->swtileImage);
3317 prefs->swtileImage = NULL;
3319 WMReleasePropList(array);
3320 return 0;
3323 switch (WMGetPropListItemCount(array)) {
3324 case 4:
3325 if (!WMIsPLString(WMGetFromPLArray(array, 1))) {
3326 wwarning(_("Invalid arguments for option \"%s\""), entry->key);
3327 break;
3328 } else
3329 path = FindImage(wPreferences.pixmap_path, WMGetFromPLString(WMGetFromPLArray(array, 1)));
3331 if (!path) {
3332 wwarning(_("Could not find image \"%s\" for option \"%s\""),
3333 WMGetFromPLString(WMGetFromPLArray(array, 1)), entry->key);
3334 } else {
3335 bgimage = RLoadImage(scr->rcontext, path, 0);
3336 if (!bgimage) {
3337 wwarning(_("Could not load image \"%s\" for option \"%s\""), path, entry->key);
3338 wfree(path);
3339 } else {
3340 wfree(path);
3342 cwidth = atoi(WMGetFromPLString(WMGetFromPLArray(array, 2)));
3343 cheight = atoi(WMGetFromPLString(WMGetFromPLArray(array, 3)));
3345 if (cwidth <= 0 || cheight <= 0 ||
3346 cwidth >= bgimage->width - 2 || cheight >= bgimage->height - 2)
3347 wwarning(_("Invalid split sizes for switch panel back image."));
3348 else {
3349 int i;
3350 int swidth, theight;
3351 for (i = 0; i < 9; i++) {
3352 if (prefs->swbackImage[i])
3353 RReleaseImage(prefs->swbackImage[i]);
3354 prefs->swbackImage[i] = NULL;
3356 swidth = (bgimage->width - cwidth) / 2;
3357 theight = (bgimage->height - cheight) / 2;
3359 prefs->swbackImage[0] = chopOffImage(bgimage, 0, 0, swidth, theight);
3360 prefs->swbackImage[1] = chopOffImage(bgimage, swidth, 0, cwidth, theight);
3361 prefs->swbackImage[2] = chopOffImage(bgimage, swidth + cwidth, 0,
3362 swidth, theight);
3364 prefs->swbackImage[3] = chopOffImage(bgimage, 0, theight, swidth, cheight);
3365 prefs->swbackImage[4] = chopOffImage(bgimage, swidth, theight,
3366 cwidth, cheight);
3367 prefs->swbackImage[5] = chopOffImage(bgimage, swidth + cwidth, theight,
3368 swidth, cheight);
3370 prefs->swbackImage[6] = chopOffImage(bgimage, 0, theight + cheight,
3371 swidth, theight);
3372 prefs->swbackImage[7] = chopOffImage(bgimage, swidth, theight + cheight,
3373 cwidth, theight);
3374 prefs->swbackImage[8] =
3375 chopOffImage(bgimage, swidth + cwidth, theight + cheight, swidth,
3376 theight);
3378 // check if anything failed
3379 for (i = 0; i < 9; i++) {
3380 if (!prefs->swbackImage[i]) {
3381 for (; i >= 0; --i) {
3382 RReleaseImage(prefs->swbackImage[i]);
3383 prefs->swbackImage[i] = NULL;
3385 break;
3389 RReleaseImage(bgimage);
3393 case 1:
3394 if (!WMIsPLString(WMGetFromPLArray(array, 0))) {
3395 wwarning(_("Invalid arguments for option \"%s\""), entry->key);
3396 break;
3397 } else
3398 path = FindImage(wPreferences.pixmap_path, WMGetFromPLString(WMGetFromPLArray(array, 0)));
3400 if (!path) {
3401 wwarning(_("Could not find image \"%s\" for option \"%s\""),
3402 WMGetFromPLString(WMGetFromPLArray(array, 0)), entry->key);
3403 } else {
3404 if (prefs->swtileImage)
3405 RReleaseImage(prefs->swtileImage);
3407 prefs->swtileImage = RLoadImage(scr->rcontext, path, 0);
3408 if (!prefs->swtileImage) {
3409 wwarning(_("Could not load image \"%s\" for option \"%s\""), path, entry->key);
3411 wfree(path);
3413 break;
3415 default:
3416 wwarning(_("Invalid number of arguments for option \"%s\""), entry->key);
3417 break;
3420 WMReleasePropList(array);
3422 return 0;
3425 static int setModifierKeyLabels(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
3427 WMPropList *array = tdata;
3428 int i;
3429 struct WPreferences *prefs = foo;
3431 if (!WMIsPLArray(array) || WMGetPropListItemCount(array) != 7) {
3432 wwarning(_("Value for option \"%s\" must be an array of 7 strings"), entry->key);
3433 WMReleasePropList(array);
3434 return 0;
3437 DestroyWindowMenu(scr);
3439 for (i = 0; i < 7; i++) {
3440 if (prefs->modifier_labels[i])
3441 wfree(prefs->modifier_labels[i]);
3443 if (WMIsPLString(WMGetFromPLArray(array, i))) {
3444 prefs->modifier_labels[i] = wstrdup(WMGetFromPLString(WMGetFromPLArray(array, i)));
3445 } else {
3446 wwarning(_("Invalid argument for option \"%s\" item %d"), entry->key, i);
3447 prefs->modifier_labels[i] = NULL;
3451 WMReleasePropList(array);
3453 return 0;
3456 static int setDoubleClick(WScreen *scr, WDefaultEntry *entry, void *tdata, void *foo)
3458 int *value = tdata;
3460 /* Parameter not used, but tell the compiler that it is ok */
3461 (void) entry;
3462 (void) scr;
3464 if (*value <= 0)
3465 *(int *)foo = 1;
3467 W_setconf_doubleClickDelay(*value);
3469 return 0;
3472 static int setCursor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *extra_data)
3474 Cursor *cursor = tdata;
3475 long widx = (long) extra_data;
3477 /* Parameter not used, but tell the compiler that it is ok */
3478 (void) entry;
3480 if (wPreferences.cursor[widx] != None) {
3481 XFreeCursor(dpy, wPreferences.cursor[widx]);
3484 wPreferences.cursor[widx] = *cursor;
3486 if (widx == WCUR_ROOT && *cursor != None) {
3487 XDefineCursor(dpy, scr->root_win, *cursor);
3490 return 0;