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.
33 #include <sys/types.h>
40 #define PATH_MAX DEFAULT_PATH_MAX
44 #include <X11/Xutil.h>
45 #include <X11/keysym.h>
49 #include "WindowMaker.h"
54 #include "resources.h"
57 #include "xmodifier.h"
62 #include "workspace.h"
63 #include "properties.h"
65 #define MAX_SHORTCUT_LENGTH 32
67 #ifndef GLOBAL_DEFAULTS_SUBDIR
68 #define GLOBAL_DEFAULTS_SUBDIR "WindowMaker"
72 extern WDDomain
*WDWindowMaker
;
73 extern WDDomain
*WDWindowAttributes
;
74 extern WDDomain
*WDRootMenu
;
75 extern int wScreenCount
;
76 extern WPreferences wPreferences
;
77 extern WShortKey wKeyBindings
[WKBD_LAST
];
87 WMPropList
*plvalue
; /* default value */
90 /* used to map strings to integers */
100 static int getCoord();
101 static int getPathList();
102 static int getEnum();
103 static int getTexture();
104 static int getWSBackground();
105 static int getWSSpecificBackground();
106 static int getFont();
107 static int getColor();
108 static int getKeybind();
109 static int getModMask();
110 static int getPropList();
112 /* value setting functions */
113 static int setJustify();
114 static int setClearance();
115 static int setIfDockPresent();
116 static int setStickyIcons();
117 static int setWidgetColor();
118 static int setIconTile();
119 static int setWinTitleFont();
120 static int setMenuTitleFont();
121 static int setMenuTextFont();
122 static int setIconTitleFont();
123 static int setIconTitleColor();
124 static int setIconTitleBack();
125 static int setLargeDisplayFont();
126 static int setWTitleColor();
127 static int setFTitleBack();
128 static int setPTitleBack();
129 static int setUTitleBack();
130 static int setResizebarBack();
131 static int setWorkspaceBack();
132 static int setWorkspaceSpecificBack();
133 static int setMenuTitleColor();
134 static int setMenuTextColor();
135 static int setMenuDisabledColor();
136 static int setMenuTitleBack();
137 static int setMenuTextBack();
138 static int setHightlight();
139 static int setHightlightText();
140 static int setKeyGrab();
141 static int setDoubleClick();
142 static int setIconPosition();
144 static int setClipTitleFont();
145 static int setClipTitleColor();
147 static int setMenuStyle();
148 static int setSwPOptions();
149 static int updateUsableArea();
151 static int setModifierKeyLabels();
153 extern Cursor wCursor
[WCUR_LAST
];
154 static int getCursor();
155 static int setCursor();
158 * Tables to convert strings to enumeration values.
159 * Values stored are char
162 /* WARNING: sum of length of all value strings must not exceed
164 #define TOTAL_VALUES_LENGTH 80
166 #define REFRESH_WINDOW_TEXTURES (1<<0)
167 #define REFRESH_MENU_TEXTURE (1<<1)
168 #define REFRESH_MENU_FONT (1<<2)
169 #define REFRESH_MENU_COLOR (1<<3)
170 #define REFRESH_MENU_TITLE_TEXTURE (1<<4)
171 #define REFRESH_MENU_TITLE_FONT (1<<5)
172 #define REFRESH_MENU_TITLE_COLOR (1<<6)
173 #define REFRESH_WINDOW_TITLE_COLOR (1<<7)
174 #define REFRESH_WINDOW_FONT (1<<8)
175 #define REFRESH_ICON_TILE (1<<9)
176 #define REFRESH_ICON_FONT (1<<10)
177 #define REFRESH_WORKSPACE_BACK (1<<11)
179 #define REFRESH_BUTTON_IMAGES (1<<12)
181 #define REFRESH_ICON_TITLE_COLOR (1<<13)
182 #define REFRESH_ICON_TITLE_BACK (1<<14)
184 static WOptionEnumeration seFocusModes
[] = {
185 {"Manual", WKF_CLICK
, 0}, {"ClickToFocus", WKF_CLICK
, 1},
186 {"Sloppy", WKF_SLOPPY
, 0}, {"SemiAuto", WKF_SLOPPY
, 1}, {"Auto", WKF_SLOPPY
, 1},
190 static WOptionEnumeration seTitlebarModes
[] = {
191 {"new", TS_NEW
, 0}, {"old", TS_OLD
, 0},
192 {"next", TS_NEXT
, 0}, {NULL
, 0, 0}
195 static WOptionEnumeration seColormapModes
[] = {
196 {"Manual", WCM_CLICK
, 0}, {"ClickToFocus", WCM_CLICK
, 1},
197 {"Auto", WCM_POINTER
, 0}, {"FocusFollowMouse", WCM_POINTER
, 1},
201 static WOptionEnumeration sePlacements
[] = {
202 {"Auto", WPM_AUTO
, 0},
203 {"Smart", WPM_SMART
, 0},
204 {"Cascade", WPM_CASCADE
, 0},
205 {"Random", WPM_RANDOM
, 0},
206 {"Manual", WPM_MANUAL
, 0},
210 static WOptionEnumeration seGeomDisplays
[] = {
211 {"None", WDIS_NONE
, 0},
212 {"Center", WDIS_CENTER
, 0},
213 {"Corner", WDIS_TOPLEFT
, 0},
214 {"Floating", WDIS_FRAME_CENTER
, 0},
215 {"Line", WDIS_NEW
, 0},
219 static WOptionEnumeration seSpeeds
[] = {
220 {"UltraFast", SPEED_ULTRAFAST
, 0},
221 {"Fast", SPEED_FAST
, 0},
222 {"Medium", SPEED_MEDIUM
, 0},
223 {"Slow", SPEED_SLOW
, 0},
224 {"UltraSlow", SPEED_ULTRASLOW
, 0},
228 static WOptionEnumeration seMouseButtonActions
[] = {
229 {"None", WA_NONE
, 0},
230 {"SelectWindows", WA_SELECT_WINDOWS
, 0},
231 {"OpenApplicationsMenu", WA_OPEN_APPMENU
, 0},
232 {"OpenWindowListMenu", WA_OPEN_WINLISTMENU
, 0},
236 static WOptionEnumeration seMouseWheelActions
[] = {
237 {"None", WA_NONE
, 0},
238 {"SwitchWorkspaces", WA_SWITCH_WORKSPACES
, 0},
242 static WOptionEnumeration seIconificationStyles
[] = {
243 {"Zoom", WIS_ZOOM
, 0},
244 {"Twist", WIS_TWIST
, 0},
245 {"Flip", WIS_FLIP
, 0},
246 {"None", WIS_NONE
, 0},
247 {"random", WIS_RANDOM
, 0},
251 static WOptionEnumeration seJustifications
[] = {
252 {"Left", WTJ_LEFT
, 0},
253 {"Center", WTJ_CENTER
, 0},
254 {"Right", WTJ_RIGHT
, 0},
258 static WOptionEnumeration seIconPositions
[] = {
259 {"blv", IY_BOTTOM
| IY_LEFT
| IY_VERT
, 0},
260 {"blh", IY_BOTTOM
| IY_LEFT
| IY_HORIZ
, 0},
261 {"brv", IY_BOTTOM
| IY_RIGHT
| IY_VERT
, 0},
262 {"brh", IY_BOTTOM
| IY_RIGHT
| IY_HORIZ
, 0},
263 {"tlv", IY_TOP
| IY_LEFT
| IY_VERT
, 0},
264 {"tlh", IY_TOP
| IY_LEFT
| IY_HORIZ
, 0},
265 {"trv", IY_TOP
| IY_RIGHT
| IY_VERT
, 0},
266 {"trh", IY_TOP
| IY_RIGHT
| IY_HORIZ
, 0},
270 static WOptionEnumeration seMenuStyles
[] = {
271 {"normal", MS_NORMAL
, 0},
272 {"singletexture", MS_SINGLE_TEXTURE
, 0},
273 {"flat", MS_FLAT
, 0},
277 static WOptionEnumeration seDisplayPositions
[] = {
278 {"none", WD_NONE
, 0},
279 {"center", WD_CENTER
, 0},
281 {"bottom", WD_BOTTOM
, 0},
282 {"topleft", WD_TOPLEFT
, 0},
283 {"topright", WD_TOPRIGHT
, 0},
284 {"bottomleft", WD_BOTTOMLEFT
, 0},
285 {"bottomright", WD_BOTTOMRIGHT
, 0},
289 static WOptionEnumeration seWorkspaceBorder
[] = {
290 {"None", WB_NONE
, 0},
291 {"LeftRight", WB_LEFTRIGHT
, 0},
292 {"TopBottom", WB_TOPBOTTOM
, 0},
293 {"AllDirections", WB_ALLDIRS
, 0},
298 * ALL entries in the tables bellow, NEED to have a default value
299 * defined, and this value needs to be correct.
302 /* these options will only affect the window manager on startup
304 * static defaults can't access the screen data, because it is
305 * created after these defaults are read
307 WDefaultEntry staticOptionList
[] = {
309 {"ColormapSize", "4", NULL
,
310 &wPreferences
.cmap_size
, getInt
, NULL
, NULL
, NULL
},
311 {"DisableDithering", "NO", NULL
,
312 &wPreferences
.no_dithering
, getBool
, NULL
, NULL
, NULL
},
313 {"IconSize", "64", NULL
,
314 &wPreferences
.icon_size
, getInt
, NULL
, NULL
, NULL
},
315 {"ModifierKey", "Mod1", NULL
,
316 &wPreferences
.modifier_mask
, getModMask
, NULL
, NULL
, NULL
},
317 {"DisableWSMouseActions", "NO", NULL
,
318 &wPreferences
.disable_root_mouse
, getBool
, NULL
, NULL
, NULL
},
319 {"FocusMode", "manual", seFocusModes
, /* have a problem when switching from */
320 &wPreferences
.focus_mode
, getEnum
, NULL
, NULL
, NULL
}, /* manual to sloppy without restart */
321 {"NewStyle", "new", seTitlebarModes
,
322 &wPreferences
.new_style
, getEnum
, NULL
, NULL
, NULL
},
323 {"DisableDock", "NO", (void *)WM_DOCK
,
324 NULL
, getBool
, setIfDockPresent
, NULL
, NULL
},
325 {"DisableClip", "NO", (void *)WM_CLIP
,
326 NULL
, getBool
, setIfDockPresent
, NULL
, NULL
},
327 {"DisableMiniwindows", "NO", NULL
,
328 &wPreferences
.disable_miniwindows
, getBool
, NULL
, NULL
, NULL
}
331 #define NUM2STRING_(x) #x
332 #define NUM2STRING(x) NUM2STRING_(x)
334 WDefaultEntry optionList
[] = {
336 /* dynamic options */
338 {"IconPosition", "blh", seIconPositions
,
339 &wPreferences
.icon_yard
, getEnum
, setIconPosition
, NULL
, NULL
},
340 {"IconificationStyle", "Zoom", seIconificationStyles
,
341 &wPreferences
.iconification_style
, getEnum
, NULL
, NULL
, NULL
},
342 {"MouseLeftButtonAction", "SelectWindows", seMouseButtonActions
,
343 &wPreferences
.mouse_button1
, getEnum
, NULL
, NULL
, NULL
},
344 {"MouseMiddleButtonAction", "OpenWindowListMenu", seMouseButtonActions
,
345 &wPreferences
.mouse_button2
, getEnum
, NULL
, NULL
, NULL
},
346 {"MouseRightButtonAction", "OpenApplicationsMenu", seMouseButtonActions
,
347 &wPreferences
.mouse_button3
, getEnum
, NULL
, NULL
, NULL
},
348 {"MouseWheelAction", "None", seMouseWheelActions
,
349 &wPreferences
.mouse_wheel
, getEnum
, NULL
, NULL
, NULL
},
350 {"PixmapPath", DEF_PIXMAP_PATHS
, NULL
,
351 &wPreferences
.pixmap_path
, getPathList
, NULL
, NULL
, NULL
},
352 {"IconPath", DEF_ICON_PATHS
, NULL
,
353 &wPreferences
.icon_path
, getPathList
, NULL
, NULL
, NULL
},
354 {"ColormapMode", "auto", seColormapModes
,
355 &wPreferences
.colormap_mode
, getEnum
, NULL
, NULL
, NULL
},
356 {"AutoFocus", "NO", NULL
,
357 &wPreferences
.auto_focus
, getBool
, NULL
, NULL
, NULL
},
358 {"RaiseDelay", "0", NULL
,
359 &wPreferences
.raise_delay
, getInt
, NULL
, NULL
, NULL
},
360 {"CirculateRaise", "NO", NULL
,
361 &wPreferences
.circ_raise
, getBool
, NULL
, NULL
, NULL
},
362 {"Superfluous", "NO", NULL
,
363 &wPreferences
.superfluous
, getBool
, NULL
, NULL
, NULL
},
364 {"AdvanceToNewWorkspace", "NO", NULL
,
365 &wPreferences
.ws_advance
, getBool
, NULL
, NULL
, NULL
},
366 {"CycleWorkspaces", "NO", NULL
,
367 &wPreferences
.ws_cycle
, getBool
, NULL
, NULL
, NULL
},
368 {"WorkspaceNameDisplayPosition", "center", seDisplayPositions
,
369 &wPreferences
.workspace_name_display_position
, getEnum
, NULL
, NULL
, NULL
},
370 {"WorkspaceBorder", "None", seWorkspaceBorder
,
371 &wPreferences
.workspace_border_position
, getEnum
, updateUsableArea
, NULL
, NULL
},
372 {"WorkspaceBorderSize", "0", NULL
,
373 &wPreferences
.workspace_border_size
, getInt
, updateUsableArea
, NULL
, NULL
},
374 {"StickyIcons", "NO", NULL
,
375 &wPreferences
.sticky_icons
, getBool
, setStickyIcons
, NULL
, NULL
},
376 {"SaveSessionOnExit", "NO", NULL
,
377 &wPreferences
.save_session_on_exit
, getBool
, NULL
, NULL
, NULL
},
378 {"WrapMenus", "NO", NULL
,
379 &wPreferences
.wrap_menus
, getBool
, NULL
, NULL
, NULL
},
380 {"ScrollableMenus", "NO", NULL
,
381 &wPreferences
.scrollable_menus
, getBool
, NULL
, NULL
, NULL
},
382 {"MenuScrollSpeed", "medium", seSpeeds
,
383 &wPreferences
.menu_scroll_speed
, getEnum
, NULL
, NULL
, NULL
},
384 {"IconSlideSpeed", "medium", seSpeeds
,
385 &wPreferences
.icon_slide_speed
, getEnum
, NULL
, NULL
, NULL
},
386 {"ShadeSpeed", "medium", seSpeeds
,
387 &wPreferences
.shade_speed
, getEnum
, NULL
, NULL
, NULL
},
388 {"BounceAppIconsWhenUrgent", "YES", NULL
,
389 &wPreferences
.bounce_appicons_when_urgent
, getBool
, NULL
, NULL
, NULL
},
390 {"RaiseAppIconsWhenBouncing", "NO", NULL
,
391 &wPreferences
.raise_appicons_when_bouncing
, getBool
, NULL
, NULL
, NULL
},
392 {"DoNotMakeAppIconsBounce", "NO", NULL
,
393 &wPreferences
.do_not_make_appicons_bounce
, getBool
, NULL
, NULL
, NULL
},
394 {"DoubleClickTime", "250", (void *)&wPreferences
.dblclick_time
,
395 &wPreferences
.dblclick_time
, getInt
, setDoubleClick
, NULL
, NULL
},
396 {"AlignSubmenus", "NO", NULL
,
397 &wPreferences
.align_menus
, getBool
, NULL
, NULL
, NULL
},
398 {"ViKeyMenus", "NO", NULL
,
399 &wPreferences
.vi_key_menus
, getBool
, NULL
, NULL
, NULL
},
400 {"OpenTransientOnOwnerWorkspace", "NO", NULL
,
401 &wPreferences
.open_transients_with_parent
, getBool
, NULL
, NULL
, NULL
},
402 {"WindowPlacement", "auto", sePlacements
,
403 &wPreferences
.window_placement
, getEnum
, NULL
, NULL
, NULL
},
404 {"IgnoreFocusClick", "NO", NULL
,
405 &wPreferences
.ignore_focus_click
, getBool
, NULL
, NULL
, NULL
},
406 {"UseSaveUnders", "NO", NULL
,
407 &wPreferences
.use_saveunders
, getBool
, NULL
, NULL
, NULL
},
408 {"OpaqueMove", "NO", NULL
,
409 &wPreferences
.opaque_move
, getBool
, NULL
, NULL
, NULL
},
410 {"OpaqueResize", "NO", NULL
,
411 &wPreferences
.opaque_resize
, getBool
, NULL
, NULL
, NULL
},
412 {"OpaqueMoveResizeKeyboard", "NO", NULL
,
413 &wPreferences
.opaque_move_resize_keyboard
, getBool
, NULL
, NULL
, NULL
},
414 {"DisableAnimations", "NO", NULL
,
415 &wPreferences
.no_animations
, getBool
, NULL
, NULL
, NULL
},
416 {"DontLinkWorkspaces", "NO", NULL
,
417 &wPreferences
.no_autowrap
, getBool
, NULL
, NULL
, NULL
},
418 {"AutoArrangeIcons", "NO", NULL
,
419 &wPreferences
.auto_arrange_icons
, getBool
, NULL
, NULL
, NULL
},
420 {"NoWindowOverDock", "NO", NULL
,
421 &wPreferences
.no_window_over_dock
, getBool
, updateUsableArea
, NULL
, NULL
},
422 {"NoWindowOverIcons", "NO", NULL
,
423 &wPreferences
.no_window_over_icons
, getBool
, updateUsableArea
, NULL
, NULL
},
424 {"WindowPlaceOrigin", "(0, 0)", NULL
,
425 &wPreferences
.window_place_origin
, getCoord
, NULL
, NULL
, NULL
},
426 {"ResizeDisplay", "corner", seGeomDisplays
,
427 &wPreferences
.size_display
, getEnum
, NULL
, NULL
, NULL
},
428 {"MoveDisplay", "corner", seGeomDisplays
,
429 &wPreferences
.move_display
, getEnum
, NULL
, NULL
, NULL
},
430 {"DontConfirmKill", "NO", NULL
,
431 &wPreferences
.dont_confirm_kill
, getBool
, NULL
, NULL
, NULL
},
432 {"WindowTitleBalloons", "NO", NULL
,
433 &wPreferences
.window_balloon
, getBool
, NULL
, NULL
, NULL
},
434 {"MiniwindowTitleBalloons", "NO", NULL
,
435 &wPreferences
.miniwin_balloon
, getBool
, NULL
, NULL
, NULL
},
436 {"AppIconBalloons", "NO", NULL
,
437 &wPreferences
.appicon_balloon
, getBool
, NULL
, NULL
, NULL
},
438 {"HelpBalloons", "NO", NULL
,
439 &wPreferences
.help_balloon
, getBool
, NULL
, NULL
, NULL
},
440 {"EdgeResistance", "30", NULL
,
441 &wPreferences
.edge_resistance
, getInt
, NULL
, NULL
, NULL
},
442 {"ResizeIncrement", "32", NULL
,
443 &wPreferences
.resize_increment
, getInt
, NULL
, NULL
, NULL
},
444 {"Attraction", "NO", NULL
,
445 &wPreferences
.attract
, getBool
, NULL
, NULL
, NULL
},
446 {"DisableBlinking", "NO", NULL
,
447 &wPreferences
.dont_blink
, getBool
, NULL
, NULL
, NULL
},
448 {"SingleClickLaunch", "NO", NULL
,
449 &wPreferences
.single_click
, getBool
, NULL
, NULL
, NULL
},
453 {"MenuStyle", "normal", seMenuStyles
,
454 &wPreferences
.menu_style
, getEnum
, setMenuStyle
, NULL
, NULL
},
455 {"WidgetColor", "(solid, gray)", NULL
,
456 NULL
, getTexture
, setWidgetColor
, NULL
, NULL
},
457 {"WorkspaceSpecificBack", "()", NULL
,
458 NULL
, getWSSpecificBackground
, setWorkspaceSpecificBack
, NULL
, NULL
},
459 /* WorkspaceBack must come after WorkspaceSpecificBack or
460 * WorkspaceBack wont know WorkspaceSpecificBack was also
461 * specified and 2 copies of wmsetbg will be launched */
462 {"WorkspaceBack", "(solid, black)", NULL
,
463 NULL
, getWSBackground
, setWorkspaceBack
, NULL
, NULL
},
464 {"SmoothWorkspaceBack", "NO", NULL
,
465 NULL
, getBool
, NULL
, NULL
, NULL
},
466 {"IconBack", "(solid, gray)", NULL
,
467 NULL
, getTexture
, setIconTile
, NULL
, NULL
},
468 {"TitleJustify", "center", seJustifications
,
469 &wPreferences
.title_justification
, getEnum
, setJustify
, NULL
, NULL
},
470 {"WindowTitleFont", DEF_TITLE_FONT
, NULL
,
471 NULL
, getFont
, setWinTitleFont
, NULL
, NULL
},
472 {"WindowTitleExtendSpace", DEF_WINDOW_TITLE_EXTEND_SPACE
, NULL
,
473 &wPreferences
.window_title_clearance
, getInt
, setClearance
, NULL
, NULL
},
474 {"WindowTitleMinHeight", "0", NULL
,
475 &wPreferences
.window_title_min_height
, getInt
, setClearance
, NULL
, NULL
},
476 {"WindowTitleMaxHeight", NUM2STRING(INT_MAX
), NULL
,
477 &wPreferences
.window_title_max_height
, getInt
, setClearance
, NULL
, NULL
},
478 {"MenuTitleExtendSpace", DEF_MENU_TITLE_EXTEND_SPACE
, NULL
,
479 &wPreferences
.menu_title_clearance
, getInt
, setClearance
, NULL
, NULL
},
480 {"MenuTitleMinHeight", "0", NULL
,
481 &wPreferences
.menu_title_min_height
, getInt
, setClearance
, NULL
, NULL
},
482 {"MenuTitleMaxHeight", NUM2STRING(INT_MAX
), NULL
,
483 &wPreferences
.menu_title_max_height
, getInt
, setClearance
, NULL
, NULL
},
484 {"MenuTextExtendSpace", DEF_MENU_TEXT_EXTEND_SPACE
, NULL
,
485 &wPreferences
.menu_text_clearance
, getInt
, setClearance
, NULL
, NULL
},
486 {"MenuTitleFont", DEF_MENU_TITLE_FONT
, NULL
,
487 NULL
, getFont
, setMenuTitleFont
, NULL
, NULL
},
488 {"MenuTextFont", DEF_MENU_ENTRY_FONT
, NULL
,
489 NULL
, getFont
, setMenuTextFont
, NULL
, NULL
},
490 {"IconTitleFont", DEF_ICON_TITLE_FONT
, NULL
,
491 NULL
, getFont
, setIconTitleFont
, NULL
, NULL
},
492 {"ClipTitleFont", DEF_CLIP_TITLE_FONT
, NULL
,
493 NULL
, getFont
, setClipTitleFont
, NULL
, NULL
},
494 {"ShowClipTitle", "YES", NULL
,
495 &wPreferences
.show_clip_title
, getBool
, NULL
, NULL
, NULL
},
496 {"LargeDisplayFont", DEF_WORKSPACE_NAME_FONT
, NULL
,
497 NULL
, getFont
, setLargeDisplayFont
, NULL
, NULL
},
498 {"HighlightColor", "white", NULL
,
499 NULL
, getColor
, setHightlight
, NULL
, NULL
},
500 {"HighlightTextColor", "black", NULL
,
501 NULL
, getColor
, setHightlightText
, NULL
, NULL
},
502 {"ClipTitleColor", "black", (void *)CLIP_NORMAL
,
503 NULL
, getColor
, setClipTitleColor
, NULL
, NULL
},
504 {"CClipTitleColor", "\"#454045\"", (void *)CLIP_COLLAPSED
,
505 NULL
, getColor
, setClipTitleColor
, NULL
, NULL
},
506 {"FTitleColor", "white", (void *)WS_FOCUSED
,
507 NULL
, getColor
, setWTitleColor
, NULL
, NULL
},
508 {"PTitleColor", "white", (void *)WS_PFOCUSED
,
509 NULL
, getColor
, setWTitleColor
, NULL
, NULL
},
510 {"UTitleColor", "black", (void *)WS_UNFOCUSED
,
511 NULL
, getColor
, setWTitleColor
, NULL
, NULL
},
512 {"FTitleBack", "(solid, black)", NULL
,
513 NULL
, getTexture
, setFTitleBack
, NULL
, NULL
},
514 {"PTitleBack", "(solid, \"#616161\")", NULL
,
515 NULL
, getTexture
, setPTitleBack
, NULL
, NULL
},
516 {"UTitleBack", "(solid, gray)", NULL
,
517 NULL
, getTexture
, setUTitleBack
, NULL
, NULL
},
518 {"ResizebarBack", "(solid, gray)", NULL
,
519 NULL
, getTexture
, setResizebarBack
, NULL
, NULL
},
520 {"MenuTitleColor", "white", NULL
,
521 NULL
, getColor
, setMenuTitleColor
, NULL
, NULL
},
522 {"MenuTextColor", "black", NULL
,
523 NULL
, getColor
, setMenuTextColor
, NULL
, NULL
},
524 {"MenuDisabledColor", "\"#616161\"", NULL
,
525 NULL
, getColor
, setMenuDisabledColor
, NULL
, NULL
},
526 {"MenuTitleBack", "(solid, black)", NULL
,
527 NULL
, getTexture
, setMenuTitleBack
, NULL
, NULL
},
528 {"MenuTextBack", "(solid, gray)", NULL
,
529 NULL
, getTexture
, setMenuTextBack
, NULL
, NULL
},
530 {"IconTitleColor", "white", NULL
,
531 NULL
, getColor
, setIconTitleColor
, NULL
, NULL
},
532 {"IconTitleBack", "black", NULL
,
533 NULL
, getColor
, setIconTitleBack
, NULL
, NULL
},
534 {"SwitchPanelImages", "(swtile.png, swback.png, 30, 40)", &wPreferences
,
535 NULL
, getPropList
, setSwPOptions
, NULL
, NULL
},
536 {"ModifierKeyLabels", "(\"Shift+\", \"Ctrl+\", \"Mod1+\", \"Mod2+\", \"Mod3+\", \"Mod4+\", \"Mod5+\")", &wPreferences
,
537 NULL
, getPropList
, setModifierKeyLabels
, NULL
, NULL
},
541 {"RootMenuKey", "None", (void *)WKBD_ROOTMENU
,
542 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
543 {"WindowListKey", "None", (void *)WKBD_WINDOWLIST
,
544 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
545 {"WindowMenuKey", "None", (void *)WKBD_WINDOWMENU
,
546 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
547 {"DockRaiseLowerKey", "None", (void*)WKBD_DOCKRAISELOWER
,
548 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
549 {"ClipRaiseLowerKey", "None", (void *)WKBD_CLIPRAISELOWER
,
550 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
551 {"MiniaturizeKey", "None", (void *)WKBD_MINIATURIZE
,
552 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
553 {"MinimizeAllKey", "None", (void *)WKBD_MINIMIZEALL
,
554 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
555 {"HideKey", "None", (void *)WKBD_HIDE
,
556 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
557 {"HideOthersKey", "None", (void *)WKBD_HIDE_OTHERS
,
558 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
559 {"MoveResizeKey", "None", (void *)WKBD_MOVERESIZE
,
560 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
561 {"CloseKey", "None", (void *)WKBD_CLOSE
,
562 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
563 {"MaximizeKey", "None", (void *)WKBD_MAXIMIZE
,
564 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
565 {"VMaximizeKey", "None", (void *)WKBD_VMAXIMIZE
,
566 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
567 {"HMaximizeKey", "None", (void *)WKBD_HMAXIMIZE
,
568 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
569 {"LHMaximizeKey", "None", (void*)WKBD_LHMAXIMIZE
,
570 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
571 {"RHMaximizeKey", "None", (void*)WKBD_RHMAXIMIZE
,
572 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
573 {"MaximusKey", "None", (void*)WKBD_MAXIMUS
,
574 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
575 {"RaiseKey", "\"Meta+Up\"", (void *)WKBD_RAISE
,
576 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
577 {"LowerKey", "\"Meta+Down\"", (void *)WKBD_LOWER
,
578 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
579 {"RaiseLowerKey", "None", (void *)WKBD_RAISELOWER
,
580 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
581 {"ShadeKey", "None", (void *)WKBD_SHADE
,
582 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
583 {"SelectKey", "None", (void *)WKBD_SELECT
,
584 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
585 {"FocusNextKey", "None", (void *)WKBD_FOCUSNEXT
,
586 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
587 {"FocusPrevKey", "None", (void *)WKBD_FOCUSPREV
,
588 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
589 {"GroupNextKey", "None", (void *)WKBD_GROUPNEXT
,
590 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
591 {"GroupPrevKey", "None", (void *)WKBD_GROUPPREV
,
592 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
593 {"NextWorkspaceKey", "None", (void *)WKBD_NEXTWORKSPACE
,
594 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
595 {"PrevWorkspaceKey", "None", (void *)WKBD_PREVWORKSPACE
,
596 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
597 {"NextWorkspaceLayerKey", "None", (void *)WKBD_NEXTWSLAYER
,
598 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
599 {"PrevWorkspaceLayerKey", "None", (void *)WKBD_PREVWSLAYER
,
600 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
601 {"Workspace1Key", "None", (void *)WKBD_WORKSPACE1
,
602 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
603 {"Workspace2Key", "None", (void *)WKBD_WORKSPACE2
,
604 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
605 {"Workspace3Key", "None", (void *)WKBD_WORKSPACE3
,
606 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
607 {"Workspace4Key", "None", (void *)WKBD_WORKSPACE4
,
608 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
609 {"Workspace5Key", "None", (void *)WKBD_WORKSPACE5
,
610 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
611 {"Workspace6Key", "None", (void *)WKBD_WORKSPACE6
,
612 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
613 {"Workspace7Key", "None", (void *)WKBD_WORKSPACE7
,
614 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
615 {"Workspace8Key", "None", (void *)WKBD_WORKSPACE8
,
616 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
617 {"Workspace9Key", "None", (void *)WKBD_WORKSPACE9
,
618 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
619 {"Workspace10Key", "None", (void *)WKBD_WORKSPACE10
,
620 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
621 {"WindowShortcut1Key", "None", (void *)WKBD_WINDOW1
,
622 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
623 {"WindowShortcut2Key", "None", (void *)WKBD_WINDOW2
,
624 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
625 {"WindowShortcut3Key", "None", (void *)WKBD_WINDOW3
,
626 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
627 {"WindowShortcut4Key", "None", (void *)WKBD_WINDOW4
,
628 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
629 {"WindowShortcut5Key", "None", (void *)WKBD_WINDOW5
,
630 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
631 {"WindowShortcut6Key", "None", (void *)WKBD_WINDOW6
,
632 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
633 {"WindowShortcut7Key", "None", (void *)WKBD_WINDOW7
,
634 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
635 {"WindowShortcut8Key", "None", (void *)WKBD_WINDOW8
,
636 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
637 {"WindowShortcut9Key", "None", (void *)WKBD_WINDOW9
,
638 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
639 {"WindowShortcut10Key", "None", (void *)WKBD_WINDOW10
,
640 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
641 {"WindowRelaunchKey", "None", (void *)WKBD_RELAUNCH
,
642 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
643 {"ScreenSwitchKey", "None", (void *)WKBD_SWITCH_SCREEN
,
644 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
646 #ifdef KEEP_XKB_LOCK_STATUS
647 {"ToggleKbdModeKey", "None", (void *)WKBD_TOGGLE
,
648 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
649 {"KbdModeLock", "NO", NULL
,
650 &wPreferences
.modelock
, getBool
, NULL
, NULL
, NULL
},
651 #endif /* KEEP_XKB_LOCK_STATUS */
653 {"NormalCursor", "(builtin, left_ptr)", (void *)WCUR_ROOT
,
654 NULL
, getCursor
, setCursor
, NULL
, NULL
},
655 {"ArrowCursor", "(builtin, top_left_arrow)", (void *)WCUR_ARROW
,
656 NULL
, getCursor
, setCursor
, NULL
, NULL
},
657 {"MoveCursor", "(builtin, fleur)", (void *)WCUR_MOVE
,
658 NULL
, getCursor
, setCursor
, NULL
, NULL
},
659 {"ResizeCursor", "(builtin, sizing)", (void *)WCUR_RESIZE
,
660 NULL
, getCursor
, setCursor
, NULL
, NULL
},
661 {"TopLeftResizeCursor", "(builtin, top_left_corner)", (void *)WCUR_TOPLEFTRESIZE
,
662 NULL
, getCursor
, setCursor
, NULL
, NULL
},
663 {"TopRightResizeCursor", "(builtin, top_right_corner)", (void *)WCUR_TOPRIGHTRESIZE
,
664 NULL
, getCursor
, setCursor
, NULL
, NULL
},
665 {"BottomLeftResizeCursor", "(builtin, bottom_left_corner)", (void *)WCUR_BOTTOMLEFTRESIZE
,
666 NULL
, getCursor
, setCursor
, NULL
, NULL
},
667 {"BottomRightResizeCursor", "(builtin, bottom_right_corner)", (void *)WCUR_BOTTOMRIGHTRESIZE
,
668 NULL
, getCursor
, setCursor
, NULL
, NULL
},
669 {"VerticalResizeCursor", "(builtin, sb_v_double_arrow)", (void *)WCUR_VERTICALRESIZE
,
670 NULL
, getCursor
, setCursor
, NULL
, NULL
},
671 {"HorizontalResizeCursor", "(builtin, sb_h_double_arrow)", (void *)WCUR_HORIZONRESIZE
,
672 NULL
, getCursor
, setCursor
, NULL
, NULL
},
673 {"WaitCursor", "(builtin, watch)", (void *)WCUR_WAIT
,
674 NULL
, getCursor
, setCursor
, NULL
, NULL
},
675 {"QuestionCursor", "(builtin, question_arrow)", (void *)WCUR_QUESTION
,
676 NULL
, getCursor
, setCursor
, NULL
, NULL
},
677 {"TextCursor", "(builtin, xterm)", (void *)WCUR_TEXT
,
678 NULL
, getCursor
, setCursor
, NULL
, NULL
},
679 {"SelectCursor", "(builtin, cross)", (void *)WCUR_SELECT
,
680 NULL
, getCursor
, setCursor
, NULL
, NULL
},
681 {"DialogHistoryLines", "500", NULL
,
682 &wPreferences
.history_lines
, getInt
, NULL
, NULL
, NULL
},
683 {"CycleActiveHeadOnly", "NO", NULL
,
684 &wPreferences
.cycle_active_head_only
, getBool
, NULL
, NULL
, NULL
}
687 static void initDefaults()
690 WDefaultEntry
*entry
;
692 WMPLSetCaseSensitive(False
);
694 for (i
= 0; i
< sizeof(optionList
) / sizeof(WDefaultEntry
); i
++) {
695 entry
= &optionList
[i
];
697 entry
->plkey
= WMCreatePLString(entry
->key
);
698 if (entry
->default_value
)
699 entry
->plvalue
= WMCreatePropListFromDescription(entry
->default_value
);
701 entry
->plvalue
= NULL
;
704 for (i
= 0; i
< sizeof(staticOptionList
) / sizeof(WDefaultEntry
); i
++) {
705 entry
= &staticOptionList
[i
];
707 entry
->plkey
= WMCreatePLString(entry
->key
);
708 if (entry
->default_value
)
709 entry
->plvalue
= WMCreatePropListFromDescription(entry
->default_value
);
711 entry
->plvalue
= NULL
;
715 static WMPropList
*readGlobalDomain(char *domainName
, Bool requireDictionary
)
717 WMPropList
*globalDict
= NULL
;
721 snprintf(path
, sizeof(path
), "%s/%s/%s", SYSCONFDIR
, GLOBAL_DEFAULTS_SUBDIR
, domainName
);
722 if (stat(path
, &stbuf
) >= 0) {
723 globalDict
= WMReadPropListFromFile(path
);
724 if (globalDict
&& requireDictionary
&& !WMIsPLDictionary(globalDict
)) {
725 wwarning(_("Domain %s (%s) of global defaults database is corrupted!"), domainName
, path
);
726 WMReleasePropList(globalDict
);
728 } else if (!globalDict
) {
729 wwarning(_("could not load domain %s from global defaults database"), domainName
);
736 #if defined(GLOBAL_PREAMBLE_MENU_FILE) || defined(GLOBAL_EPILOGUE_MENU_FILE)
737 static void prependMenu(WMPropList
* destarr
, WMPropList
* array
)
742 for (i
= 0; i
< WMGetPropListItemCount(array
); i
++) {
743 item
= WMGetFromPLArray(array
, i
);
745 WMInsertInPLArray(destarr
, i
+ 1, item
);
749 static void appendMenu(WMPropList
* destarr
, WMPropList
* array
)
754 for (i
= 0; i
< WMGetPropListItemCount(array
); i
++) {
755 item
= WMGetFromPLArray(array
, i
);
757 WMAddToPLArray(destarr
, item
);
762 void wDefaultsMergeGlobalMenus(WDDomain
* menuDomain
)
764 WMPropList
*menu
= menuDomain
->dictionary
;
767 if (!menu
|| !WMIsPLArray(menu
))
770 #ifdef GLOBAL_PREAMBLE_MENU_FILE
771 submenu
= WMReadPropListFromFile(SYSCONFDIR
"/" GLOBAL_DEFAULTS_SUBDIR
"/" GLOBAL_PREAMBLE_MENU_FILE
);
773 if (submenu
&& !WMIsPLArray(submenu
)) {
774 wwarning(_("invalid global menu file %s"), GLOBAL_PREAMBLE_MENU_FILE
);
775 WMReleasePropList(submenu
);
779 prependMenu(menu
, submenu
);
780 WMReleasePropList(submenu
);
784 #ifdef GLOBAL_EPILOGUE_MENU_FILE
785 submenu
= WMReadPropListFromFile(SYSCONFDIR
"/" GLOBAL_DEFAULTS_SUBDIR
"/" GLOBAL_EPILOGUE_MENU_FILE
);
787 if (submenu
&& !WMIsPLArray(submenu
)) {
788 wwarning(_("invalid global menu file %s"), GLOBAL_EPILOGUE_MENU_FILE
);
789 WMReleasePropList(submenu
);
793 appendMenu(menu
, submenu
);
794 WMReleasePropList(submenu
);
798 menuDomain
->dictionary
= menu
;
801 WDDomain
*wDefaultsInitDomain(char *domain
, Bool requireDictionary
)
805 static int inited
= 0;
808 WMPropList
*shared_dict
= NULL
;
815 db
= wmalloc(sizeof(WDDomain
));
816 db
->domain_name
= domain
;
817 db
->path
= wdefaultspathfordomain(domain
);
820 if (the_path
&& stat(the_path
, &stbuf
) >= 0) {
821 db
->dictionary
= WMReadPropListFromFile(the_path
);
822 if (db
->dictionary
) {
823 if (requireDictionary
&& !WMIsPLDictionary(db
->dictionary
)) {
824 WMReleasePropList(db
->dictionary
);
825 db
->dictionary
= NULL
;
826 wwarning(_("Domain %s (%s) of defaults database is corrupted!"), domain
, the_path
);
828 db
->timestamp
= stbuf
.st_mtime
;
830 wwarning(_("could not load domain %s from user defaults database"), domain
);
834 /* global system dictionary */
835 snprintf(path
, sizeof(path
), "%s/%s/%s", SYSCONFDIR
, GLOBAL_DEFAULTS_SUBDIR
, domain
);
836 if (stat(path
, &stbuf
) >= 0) {
837 shared_dict
= WMReadPropListFromFile(path
);
839 if (requireDictionary
&& !WMIsPLDictionary(shared_dict
)) {
840 wwarning(_("Domain %s (%s) of global defaults database is corrupted!"),
842 WMReleasePropList(shared_dict
);
845 if (db
->dictionary
&& WMIsPLDictionary(shared_dict
) &&
846 WMIsPLDictionary(db
->dictionary
)) {
847 WMMergePLDictionaries(shared_dict
, db
->dictionary
, True
);
848 WMReleasePropList(db
->dictionary
);
849 db
->dictionary
= shared_dict
;
850 if (stbuf
.st_mtime
> db
->timestamp
)
851 db
->timestamp
= stbuf
.st_mtime
;
852 } else if (!db
->dictionary
) {
853 db
->dictionary
= shared_dict
;
854 if (stbuf
.st_mtime
> db
->timestamp
)
855 db
->timestamp
= stbuf
.st_mtime
;
859 wwarning(_("could not load domain %s from global defaults database (%s)"), domain
, path
);
866 void wReadStaticDefaults(WMPropList
* dict
)
869 WDefaultEntry
*entry
;
873 for (i
= 0; i
< sizeof(staticOptionList
) / sizeof(WDefaultEntry
); i
++) {
874 entry
= &staticOptionList
[i
];
877 plvalue
= WMGetFromPLDictionary(dict
, entry
->plkey
);
882 /* no default in the DB. Use builtin default */
883 plvalue
= entry
->plvalue
;
888 (*entry
->convert
) (NULL
, entry
, plvalue
, entry
->addr
, &tdata
);
890 (*entry
->update
) (NULL
, entry
, tdata
, entry
->extra_data
);
896 void wDefaultsCheckDomains(void* arg
)
900 WMPropList
*shared_dict
= NULL
;
904 if (stat(WDWindowMaker
->path
, &stbuf
) >= 0 && WDWindowMaker
->timestamp
< stbuf
.st_mtime
) {
905 WDWindowMaker
->timestamp
= stbuf
.st_mtime
;
907 /* Global dictionary */
908 shared_dict
= readGlobalDomain("WindowMaker", True
);
910 /* User dictionary */
911 dict
= WMReadPropListFromFile(WDWindowMaker
->path
);
914 if (!WMIsPLDictionary(dict
)) {
915 WMReleasePropList(dict
);
917 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
918 "WindowMaker", WDWindowMaker
->path
);
921 WMMergePLDictionaries(shared_dict
, dict
, True
);
922 WMReleasePropList(dict
);
927 for (i
= 0; i
< wScreenCount
; i
++) {
928 scr
= wScreenWithNumber(i
);
930 wReadDefaults(scr
, dict
);
933 if (WDWindowMaker
->dictionary
)
934 WMReleasePropList(WDWindowMaker
->dictionary
);
936 WDWindowMaker
->dictionary
= dict
;
939 wwarning(_("could not load domain %s from user defaults database"), "WindowMaker");
943 WMReleasePropList(shared_dict
);
947 if (stat(WDWindowAttributes
->path
, &stbuf
) >= 0 && WDWindowAttributes
->timestamp
< stbuf
.st_mtime
) {
948 /* global dictionary */
949 shared_dict
= readGlobalDomain("WMWindowAttributes", True
);
950 /* user dictionary */
951 dict
= WMReadPropListFromFile(WDWindowAttributes
->path
);
953 if (!WMIsPLDictionary(dict
)) {
954 WMReleasePropList(dict
);
956 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
957 "WMWindowAttributes", WDWindowAttributes
->path
);
960 WMMergePLDictionaries(shared_dict
, dict
, True
);
961 WMReleasePropList(dict
);
965 if (WDWindowAttributes
->dictionary
) {
966 WMReleasePropList(WDWindowAttributes
->dictionary
);
968 WDWindowAttributes
->dictionary
= dict
;
969 for (i
= 0; i
< wScreenCount
; i
++) {
970 scr
= wScreenWithNumber(i
);
972 wDefaultUpdateIcons(scr
);
974 /* Update the panel image if changed */
975 /* Don't worry. If the image is the same these
976 * functions will have no performance impact. */
977 create_logo_image(scr
);
982 wwarning(_("could not load domain %s from user defaults database"), "WMWindowAttributes");
984 WDWindowAttributes
->timestamp
= stbuf
.st_mtime
;
986 WMReleasePropList(shared_dict
);
990 if (stat(WDRootMenu
->path
, &stbuf
) >= 0 && WDRootMenu
->timestamp
< stbuf
.st_mtime
) {
991 dict
= WMReadPropListFromFile(WDRootMenu
->path
);
993 if (!WMIsPLArray(dict
) && !WMIsPLString(dict
)) {
994 WMReleasePropList(dict
);
996 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
997 "WMRootMenu", WDRootMenu
->path
);
999 if (WDRootMenu
->dictionary
) {
1000 WMReleasePropList(WDRootMenu
->dictionary
);
1002 WDRootMenu
->dictionary
= dict
;
1003 wDefaultsMergeGlobalMenus(WDRootMenu
);
1006 wwarning(_("could not load domain %s from user defaults database"), "WMRootMenu");
1008 WDRootMenu
->timestamp
= stbuf
.st_mtime
;
1010 #ifndef HAVE_INOTIFY
1012 WMAddTimerHandler(DEFAULTS_CHECK_INTERVAL
, wDefaultsCheckDomains
, arg
);
1016 void wReadDefaults(WScreen
* scr
, WMPropList
* new_dict
)
1018 WMPropList
*plvalue
, *old_value
;
1019 WDefaultEntry
*entry
;
1021 int update_workspace_back
= 0; /* kluge :/ */
1022 unsigned int needs_refresh
;
1024 WMPropList
*old_dict
= (WDWindowMaker
->dictionary
!= new_dict
? WDWindowMaker
->dictionary
: NULL
);
1028 for (i
= 0; i
< sizeof(optionList
) / sizeof(WDefaultEntry
); i
++) {
1029 entry
= &optionList
[i
];
1032 plvalue
= WMGetFromPLDictionary(new_dict
, entry
->plkey
);
1039 old_value
= WMGetFromPLDictionary(old_dict
, entry
->plkey
);
1041 if (!plvalue
&& !old_value
) {
1042 /* no default in the DB. Use builtin default */
1043 plvalue
= entry
->plvalue
;
1044 if (plvalue
&& new_dict
)
1045 WMPutInPLDictionary(new_dict
, entry
->plkey
, plvalue
);
1047 } else if (!plvalue
) {
1048 /* value was deleted from DB. Keep current value */
1050 } else if (!old_value
) {
1051 /* set value for the 1st time */
1052 } else if (!WMIsPropListEqualTo(plvalue
, old_value
)) {
1053 /* value has changed */
1055 if (strcmp(entry
->key
, "WorkspaceBack") == 0
1056 && update_workspace_back
&& scr
->flags
.backimage_helper_launched
) {
1058 /* value was not changed since last time */
1065 if ((*entry
->convert
) (scr
, entry
, plvalue
, entry
->addr
, &tdata
)) {
1067 * If the WorkspaceSpecificBack data has been changed
1068 * so that the helper will be launched now, we must be
1069 * sure to send the default background texture config
1072 if (strcmp(entry
->key
, "WorkspaceSpecificBack") == 0 &&
1073 !scr
->flags
.backimage_helper_launched
)
1074 update_workspace_back
= 1;
1077 needs_refresh
|= (*entry
->update
) (scr
, entry
, tdata
, entry
->extra_data
);
1083 if (needs_refresh
!= 0 && !scr
->flags
.startup
) {
1087 if (needs_refresh
& REFRESH_MENU_TITLE_TEXTURE
)
1088 foo
|= WTextureSettings
;
1089 if (needs_refresh
& REFRESH_MENU_TITLE_FONT
)
1090 foo
|= WFontSettings
;
1091 if (needs_refresh
& REFRESH_MENU_TITLE_COLOR
)
1092 foo
|= WColorSettings
;
1094 WMPostNotificationName(WNMenuTitleAppearanceSettingsChanged
, NULL
,
1095 (void *)(uintptr_t) foo
);
1098 if (needs_refresh
& REFRESH_MENU_TEXTURE
)
1099 foo
|= WTextureSettings
;
1100 if (needs_refresh
& REFRESH_MENU_FONT
)
1101 foo
|= WFontSettings
;
1102 if (needs_refresh
& REFRESH_MENU_COLOR
)
1103 foo
|= WColorSettings
;
1105 WMPostNotificationName(WNMenuAppearanceSettingsChanged
, NULL
, (void *)(uintptr_t) foo
);
1108 if (needs_refresh
& REFRESH_WINDOW_FONT
)
1109 foo
|= WFontSettings
;
1110 if (needs_refresh
& REFRESH_WINDOW_TEXTURES
)
1111 foo
|= WTextureSettings
;
1112 if (needs_refresh
& REFRESH_WINDOW_TITLE_COLOR
)
1113 foo
|= WColorSettings
;
1115 WMPostNotificationName(WNWindowAppearanceSettingsChanged
, NULL
, (void *)(uintptr_t) foo
);
1117 if (!(needs_refresh
& REFRESH_ICON_TILE
)) {
1119 if (needs_refresh
& REFRESH_ICON_FONT
)
1120 foo
|= WFontSettings
;
1121 if (needs_refresh
& REFRESH_ICON_TITLE_COLOR
)
1122 foo
|= WTextureSettings
;
1123 if (needs_refresh
& REFRESH_ICON_TITLE_BACK
)
1124 foo
|= WTextureSettings
;
1126 WMPostNotificationName(WNIconAppearanceSettingsChanged
, NULL
,
1127 (void *)(uintptr_t) foo
);
1129 if (needs_refresh
& REFRESH_ICON_TILE
)
1130 WMPostNotificationName(WNIconTileSettingsChanged
, NULL
, NULL
);
1134 void wDefaultUpdateIcons(WScreen
* scr
)
1136 WAppIcon
*aicon
= scr
->app_icon_list
;
1137 WWindow
*wwin
= scr
->focused_window
;
1141 file
= wDefaultGetIconFile(scr
, aicon
->wm_instance
, aicon
->wm_class
, False
);
1142 if ((file
&& aicon
->icon
->file
&& strcmp(file
, aicon
->icon
->file
) != 0)
1143 || (file
&& !aicon
->icon
->file
)) {
1144 wIconChangeImageFile(aicon
->icon
, file
);
1145 wAppIconPaint(aicon
);
1147 aicon
= aicon
->next
;
1150 if (!wPreferences
.flags
.noclip
)
1151 wClipIconPaint(scr
->clip_icon
);
1154 if (wwin
->icon
&& wwin
->flags
.miniaturized
) {
1155 file
= wDefaultGetIconFile(scr
, wwin
->wm_instance
, wwin
->wm_class
, False
);
1156 if ((file
&& wwin
->icon
->file
&& strcmp(file
, wwin
->icon
->file
) != 0)
1157 || (file
&& !wwin
->icon
->file
)) {
1158 wIconChangeImageFile(wwin
->icon
, file
);
1165 /* --------------------------- Local ----------------------- */
1167 #define GET_STRING_OR_DEFAULT(x, var) if (!WMIsPLString(value)) { \
1168 wwarning(_("Wrong option format for key \"%s\". Should be %s."), \
1170 wwarning(_("using default \"%s\" instead"), entry->default_value); \
1171 var = entry->default_value;\
1172 } else var = WMGetFromPLString(value)\
1175 static int string2index(WMPropList * key, WMPropList * val, char *def, WOptionEnumeration * values)
1178 WOptionEnumeration
*v
;
1179 char buffer
[TOTAL_VALUES_LENGTH
];
1181 if (WMIsPLString(val
) && (str
= WMGetFromPLString(val
))) {
1182 for (v
= values
; v
->string
!= NULL
; v
++) {
1183 if (strcasecmp(v
->string
, str
) == 0)
1189 for (v
= values
; v
->string
!= NULL
; v
++) {
1192 strcat(buffer
, ", ");
1193 snprintf(buffer
+strlen(buffer
),
1194 sizeof(buffer
)-strlen(buffer
)-1, "\"%s\"", v
->string
);
1197 wwarning(_("wrong option value for key \"%s\"; got \"%s\", should be one of %s."),
1198 WMGetFromPLString(key
),
1199 WMIsPLString(val
) ? WMGetFromPLString(val
) : "(unknown)",
1203 return string2index(key
, val
, NULL
, values
);
1210 * value - is the value in the defaults DB
1211 * addr - is the address to store the data
1212 * ret - is the address to store a pointer to a temporary buffer. ret
1213 * must not be freed and is used by the set functions
1215 static int getBool(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1219 int second_pass
= 0;
1221 GET_STRING_OR_DEFAULT("Boolean", val
);
1224 if ((val
[1] == '\0' && (val
[0] == 'y' || val
[0] == 'Y'))
1225 || strcasecmp(val
, "YES") == 0) {
1228 } else if ((val
[1] == '\0' && (val
[0] == 'n' || val
[0] == 'N'))
1229 || strcasecmp(val
, "NO") == 0) {
1233 if (sscanf(val
, "%i", &i
) == 1) {
1239 wwarning(_("can't convert \"%s\" to boolean for key \"%s\""), val
, entry
->key
);
1240 if (second_pass
== 0) {
1241 val
= WMGetFromPLString(entry
->plvalue
);
1243 wwarning(_("using default \"%s\" instead"), val
);
1253 *(char *)addr
= data
;
1258 static int getInt(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1263 GET_STRING_OR_DEFAULT("Integer", val
);
1265 if (sscanf(val
, "%i", &data
) != 1) {
1266 wwarning(_("can't convert \"%s\" to integer for key \"%s\""), val
, entry
->key
);
1267 val
= WMGetFromPLString(entry
->plvalue
);
1268 wwarning(_("using default \"%s\" instead"), val
);
1269 if (sscanf(val
, "%i", &data
) != 1) {
1277 *(int *)addr
= data
;
1282 static int getCoord(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1285 char *val_x
, *val_y
;
1286 int nelem
, changed
= 0;
1287 WMPropList
*elem_x
, *elem_y
;
1290 if (!WMIsPLArray(value
)) {
1291 wwarning(_("Wrong option format for key \"%s\". Should be %s."), entry
->key
, "Coordinate");
1293 value
= entry
->plvalue
;
1295 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1301 nelem
= WMGetPropListItemCount(value
);
1303 wwarning(_("Incorrect number of elements in array for key \"%s\"."), entry
->key
);
1305 value
= entry
->plvalue
;
1307 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1313 elem_x
= WMGetFromPLArray(value
, 0);
1314 elem_y
= WMGetFromPLArray(value
, 1);
1316 if (!elem_x
|| !elem_y
|| !WMIsPLString(elem_x
) || !WMIsPLString(elem_y
)) {
1317 wwarning(_("Wrong value for key \"%s\". Should be Coordinate."), entry
->key
);
1319 value
= entry
->plvalue
;
1321 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1327 val_x
= WMGetFromPLString(elem_x
);
1328 val_y
= WMGetFromPLString(elem_y
);
1330 if (sscanf(val_x
, "%i", &data
.x
) != 1 || sscanf(val_y
, "%i", &data
.y
) != 1) {
1331 wwarning(_("can't convert array to integers for \"%s\"."), entry
->key
);
1333 value
= entry
->plvalue
;
1335 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1343 else if (data
.x
> scr
->scr_width
/ 3)
1344 data
.x
= scr
->scr_width
/ 3;
1347 else if (data
.y
> scr
->scr_height
/ 3)
1348 data
.y
= scr
->scr_height
/ 3;
1353 *(WCoord
*) addr
= data
;
1358 static int getPropList(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1360 WMRetainPropList(value
);
1367 static int getPathList(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1376 if (!WMIsPLArray(value
)) {
1377 wwarning(_("Wrong option format for key \"%s\". Should be %s."), entry
->key
, "an array of paths");
1379 value
= entry
->plvalue
;
1381 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1388 count
= WMGetPropListItemCount(value
);
1391 value
= entry
->plvalue
;
1393 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1400 for (i
= 0; i
< count
; i
++) {
1401 d
= WMGetFromPLArray(value
, i
);
1402 if (!d
|| !WMIsPLString(d
)) {
1406 len
+= strlen(WMGetFromPLString(d
)) + 1;
1409 ptr
= data
= wmalloc(len
+ 1);
1411 for (i
= 0; i
< count
; i
++) {
1412 d
= WMGetFromPLArray(value
, i
);
1413 if (!d
|| !WMIsPLString(d
)) {
1416 strcpy(ptr
, WMGetFromPLString(d
));
1417 ptr
+= strlen(WMGetFromPLString(d
));
1424 if (*(char **)addr
!= NULL
) {
1425 wfree(*(char **)addr
);
1427 *(char **)addr
= data
;
1432 static int getEnum(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1434 static signed char data
;
1436 data
= string2index(entry
->plkey
, value
, entry
->default_value
, (WOptionEnumeration
*) entry
->extra_data
);
1443 *(signed char *)addr
= data
;
1450 * (hgradient <color> <color>)
1451 * (vgradient <color> <color>)
1452 * (dgradient <color> <color>)
1453 * (mhgradient <color> <color> ...)
1454 * (mvgradient <color> <color> ...)
1455 * (mdgradient <color> <color> ...)
1456 * (igradient <color1> <color1> <thickness1> <color2> <color2> <thickness2>)
1457 * (tpixmap <file> <color>)
1458 * (spixmap <file> <color>)
1459 * (cpixmap <file> <color>)
1460 * (thgradient <file> <opaqueness> <color> <color>)
1461 * (tvgradient <file> <opaqueness> <color> <color>)
1462 * (tdgradient <file> <opaqueness> <color> <color>)
1463 * (function <lib> <function> ...)
1466 static WTexture
*parse_texture(WScreen
* scr
, WMPropList
* pl
)
1471 WTexture
*texture
= NULL
;
1473 nelem
= WMGetPropListItemCount(pl
);
1477 elem
= WMGetFromPLArray(pl
, 0);
1478 if (!elem
|| !WMIsPLString(elem
))
1480 val
= WMGetFromPLString(elem
);
1482 if (strcasecmp(val
, "solid") == 0) {
1490 elem
= WMGetFromPLArray(pl
, 1);
1491 if (!elem
|| !WMIsPLString(elem
))
1493 val
= WMGetFromPLString(elem
);
1495 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &color
)) {
1496 wwarning(_("\"%s\" is not a valid color name"), val
);
1500 texture
= (WTexture
*) wTextureMakeSolid(scr
, &color
);
1501 } else if (strcasecmp(val
, "dgradient") == 0
1502 || strcasecmp(val
, "vgradient") == 0 || strcasecmp(val
, "hgradient") == 0) {
1503 RColor color1
, color2
;
1508 wwarning(_("bad number of arguments in gradient specification"));
1512 if (val
[0] == 'd' || val
[0] == 'D')
1513 type
= WTEX_DGRADIENT
;
1514 else if (val
[0] == 'h' || val
[0] == 'H')
1515 type
= WTEX_HGRADIENT
;
1517 type
= WTEX_VGRADIENT
;
1519 /* get from color */
1520 elem
= WMGetFromPLArray(pl
, 1);
1521 if (!elem
|| !WMIsPLString(elem
))
1523 val
= WMGetFromPLString(elem
);
1525 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1526 wwarning(_("\"%s\" is not a valid color name"), val
);
1530 color1
.red
= xcolor
.red
>> 8;
1531 color1
.green
= xcolor
.green
>> 8;
1532 color1
.blue
= xcolor
.blue
>> 8;
1535 elem
= WMGetFromPLArray(pl
, 2);
1536 if (!elem
|| !WMIsPLString(elem
)) {
1539 val
= WMGetFromPLString(elem
);
1541 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1542 wwarning(_("\"%s\" is not a valid color name"), val
);
1546 color2
.red
= xcolor
.red
>> 8;
1547 color2
.green
= xcolor
.green
>> 8;
1548 color2
.blue
= xcolor
.blue
>> 8;
1550 texture
= (WTexture
*) wTextureMakeGradient(scr
, type
, &color1
, &color2
);
1552 } else if (strcasecmp(val
, "igradient") == 0) {
1553 RColor colors1
[2], colors2
[2];
1559 wwarning(_("bad number of arguments in gradient specification"));
1563 /* get from color */
1564 for (i
= 0; i
< 2; i
++) {
1565 elem
= WMGetFromPLArray(pl
, 1 + i
);
1566 if (!elem
|| !WMIsPLString(elem
))
1568 val
= WMGetFromPLString(elem
);
1570 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1571 wwarning(_("\"%s\" is not a valid color name"), val
);
1574 colors1
[i
].alpha
= 255;
1575 colors1
[i
].red
= xcolor
.red
>> 8;
1576 colors1
[i
].green
= xcolor
.green
>> 8;
1577 colors1
[i
].blue
= xcolor
.blue
>> 8;
1579 elem
= WMGetFromPLArray(pl
, 3);
1580 if (!elem
|| !WMIsPLString(elem
))
1582 val
= WMGetFromPLString(elem
);
1585 /* get from color */
1586 for (i
= 0; i
< 2; i
++) {
1587 elem
= WMGetFromPLArray(pl
, 4 + i
);
1588 if (!elem
|| !WMIsPLString(elem
))
1590 val
= WMGetFromPLString(elem
);
1592 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1593 wwarning(_("\"%s\" is not a valid color name"), val
);
1596 colors2
[i
].alpha
= 255;
1597 colors2
[i
].red
= xcolor
.red
>> 8;
1598 colors2
[i
].green
= xcolor
.green
>> 8;
1599 colors2
[i
].blue
= xcolor
.blue
>> 8;
1601 elem
= WMGetFromPLArray(pl
, 6);
1602 if (!elem
|| !WMIsPLString(elem
))
1604 val
= WMGetFromPLString(elem
);
1607 texture
= (WTexture
*) wTextureMakeIGradient(scr
, th1
, colors1
, th2
, colors2
);
1609 } else if (strcasecmp(val
, "mhgradient") == 0
1610 || strcasecmp(val
, "mvgradient") == 0 || strcasecmp(val
, "mdgradient") == 0) {
1617 wwarning(_("too few arguments in multicolor gradient specification"));
1621 if (val
[1] == 'h' || val
[1] == 'H')
1622 type
= WTEX_MHGRADIENT
;
1623 else if (val
[1] == 'v' || val
[1] == 'V')
1624 type
= WTEX_MVGRADIENT
;
1626 type
= WTEX_MDGRADIENT
;
1630 colors
= wmalloc(sizeof(RColor
*) * (count
+ 1));
1632 for (i
= 0; i
< count
; i
++) {
1633 elem
= WMGetFromPLArray(pl
, i
+ 1);
1634 if (!elem
|| !WMIsPLString(elem
)) {
1635 for (--i
; i
>= 0; --i
) {
1641 val
= WMGetFromPLString(elem
);
1643 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &color
)) {
1644 wwarning(_("\"%s\" is not a valid color name"), val
);
1645 for (--i
; i
>= 0; --i
) {
1651 colors
[i
] = wmalloc(sizeof(RColor
));
1652 colors
[i
]->red
= color
.red
>> 8;
1653 colors
[i
]->green
= color
.green
>> 8;
1654 colors
[i
]->blue
= color
.blue
>> 8;
1659 texture
= (WTexture
*) wTextureMakeMGradient(scr
, type
, colors
);
1660 } else if (strcasecmp(val
, "spixmap") == 0 ||
1661 strcasecmp(val
, "cpixmap") == 0 || strcasecmp(val
, "tpixmap") == 0) {
1668 if (val
[0] == 's' || val
[0] == 'S')
1670 else if (val
[0] == 'c' || val
[0] == 'C')
1676 elem
= WMGetFromPLArray(pl
, 2);
1677 if (!elem
|| !WMIsPLString(elem
)) {
1680 val
= WMGetFromPLString(elem
);
1682 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &color
)) {
1683 wwarning(_("\"%s\" is not a valid color name"), val
);
1688 elem
= WMGetFromPLArray(pl
, 1);
1689 if (!elem
|| !WMIsPLString(elem
))
1691 val
= WMGetFromPLString(elem
);
1693 texture
= (WTexture
*) wTextureMakePixmap(scr
, type
, val
, &color
);
1694 } else if (strcasecmp(val
, "thgradient") == 0
1695 || strcasecmp(val
, "tvgradient") == 0 || strcasecmp(val
, "tdgradient") == 0) {
1696 RColor color1
, color2
;
1701 if (val
[1] == 'h' || val
[1] == 'H')
1702 style
= WTEX_THGRADIENT
;
1703 else if (val
[1] == 'v' || val
[1] == 'V')
1704 style
= WTEX_TVGRADIENT
;
1706 style
= WTEX_TDGRADIENT
;
1709 wwarning(_("bad number of arguments in textured gradient specification"));
1713 /* get from color */
1714 elem
= WMGetFromPLArray(pl
, 3);
1715 if (!elem
|| !WMIsPLString(elem
))
1717 val
= WMGetFromPLString(elem
);
1719 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1720 wwarning(_("\"%s\" is not a valid color name"), val
);
1724 color1
.red
= xcolor
.red
>> 8;
1725 color1
.green
= xcolor
.green
>> 8;
1726 color1
.blue
= xcolor
.blue
>> 8;
1729 elem
= WMGetFromPLArray(pl
, 4);
1730 if (!elem
|| !WMIsPLString(elem
)) {
1733 val
= WMGetFromPLString(elem
);
1735 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1736 wwarning(_("\"%s\" is not a valid color name"), val
);
1740 color2
.red
= xcolor
.red
>> 8;
1741 color2
.green
= xcolor
.green
>> 8;
1742 color2
.blue
= xcolor
.blue
>> 8;
1745 elem
= WMGetFromPLArray(pl
, 2);
1746 if (!elem
|| !WMIsPLString(elem
))
1749 val
= WMGetFromPLString(elem
);
1751 if (!val
|| (opacity
= atoi(val
)) < 0 || opacity
> 255) {
1752 wwarning(_("bad opacity value for tgradient texture \"%s\". Should be [0..255]"), val
);
1757 elem
= WMGetFromPLArray(pl
, 1);
1758 if (!elem
|| !WMIsPLString(elem
))
1760 val
= WMGetFromPLString(elem
);
1762 texture
= (WTexture
*) wTextureMakeTGradient(scr
, style
, &color1
, &color2
, val
, opacity
);
1763 } else if (strcasecmp(val
, "function") == 0) {
1764 /* Leave this in to handle the unlikely case of
1765 * someone actually having function textures configured */
1766 wwarning("function texture support has been removed");
1769 wwarning(_("invalid texture type %s"), val
);
1775 static int getTexture(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1777 static WTexture
*texture
;
1781 if (!WMIsPLArray(value
)) {
1782 wwarning(_("Wrong option format for key \"%s\". Should be %s."), entry
->key
, "Texture");
1784 value
= entry
->plvalue
;
1786 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1792 if (strcmp(entry
->key
, "WidgetColor") == 0 && !changed
) {
1795 pl
= WMGetFromPLArray(value
, 0);
1796 if (!pl
|| !WMIsPLString(pl
) || !WMGetFromPLString(pl
)
1797 || strcasecmp(WMGetFromPLString(pl
), "solid") != 0) {
1798 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1799 entry
->key
, "Solid Texture");
1801 value
= entry
->plvalue
;
1803 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1808 texture
= parse_texture(scr
, value
);
1811 wwarning(_("Error in texture specification for key \"%s\""), entry
->key
);
1813 value
= entry
->plvalue
;
1815 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1825 *(WTexture
**) addr
= texture
;
1830 static int getWSBackground(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1838 if (!WMIsPLArray(value
)) {
1839 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1840 "WorkspaceBack", "Texture or None");
1842 value
= entry
->plvalue
;
1844 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1850 /* only do basic error checking and verify for None texture */
1852 nelem
= WMGetPropListItemCount(value
);
1854 elem
= WMGetFromPLArray(value
, 0);
1855 if (!elem
|| !WMIsPLString(elem
)) {
1856 wwarning(_("Wrong type for workspace background. Should be a texture type."));
1858 value
= entry
->plvalue
;
1860 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1865 val
= WMGetFromPLString(elem
);
1867 if (strcasecmp(val
, "None") == 0)
1870 *ret
= WMRetainPropList(value
);
1876 getWSSpecificBackground(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1883 if (!WMIsPLArray(value
)) {
1884 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1885 "WorkspaceSpecificBack", "an array of textures");
1887 value
= entry
->plvalue
;
1889 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1895 /* only do basic error checking and verify for None texture */
1897 nelem
= WMGetPropListItemCount(value
);
1900 elem
= WMGetFromPLArray(value
, nelem
);
1901 if (!elem
|| !WMIsPLArray(elem
)) {
1902 wwarning(_("Wrong type for background of workspace %i. Should be a texture."),
1908 *ret
= WMRetainPropList(value
);
1912 * Kluge to force wmsetbg helper to set the default background.
1913 * If the WorkspaceSpecificBack is changed once wmaker has started,
1914 * the WorkspaceBack won't be sent to the helper, unless the user
1915 * changes it's value too. So, we must force this by removing the
1916 * value from the defaults DB.
1918 if (!scr
->flags
.backimage_helper_launched
&& !scr
->flags
.startup
) {
1919 WMPropList
*key
= WMCreatePLString("WorkspaceBack");
1921 WMRemoveFromPLDictionary(WDWindowMaker
->dictionary
, key
);
1923 WMReleasePropList(key
);
1929 static int getFont(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1931 static WMFont
*font
;
1934 GET_STRING_OR_DEFAULT("Font", val
);
1936 font
= WMCreateFont(scr
->wmscreen
, val
);
1938 font
= WMCreateFont(scr
->wmscreen
, "fixed");
1941 wfatal(_("could not load any usable font!!!"));
1948 /* can't assign font value outside update function */
1949 wassertrv(addr
== NULL
, True
);
1954 static int getColor(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1956 static XColor color
;
1958 int second_pass
= 0;
1960 GET_STRING_OR_DEFAULT("Color", val
);
1963 if (!wGetColor(scr
, val
, &color
)) {
1964 wwarning(_("could not get color for key \"%s\""), entry
->key
);
1965 if (second_pass
== 0) {
1966 val
= WMGetFromPLString(entry
->plvalue
);
1968 wwarning(_("using default \"%s\" instead"), val
);
1977 assert(addr
== NULL
);
1980 *(unsigned long*)addr = pixel;
1986 static int getKeybind(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1988 static WShortKey shortcut
;
1992 char buf
[MAX_SHORTCUT_LENGTH
], *b
;
1994 GET_STRING_OR_DEFAULT("Key spec", val
);
1996 if (!val
|| strcasecmp(val
, "NONE") == 0) {
1997 shortcut
.keycode
= 0;
1998 shortcut
.modifier
= 0;
2004 wstrlcpy(buf
, val
, MAX_SHORTCUT_LENGTH
);
2009 shortcut
.modifier
= 0;
2010 while ((k
= strchr(b
, '+')) != NULL
) {
2014 mod
= wXModifierFromKey(b
);
2016 wwarning(_("%s: invalid key modifier \"%s\""), entry
->key
, b
);
2019 shortcut
.modifier
|= mod
;
2025 ksym
= XStringToKeysym(b
);
2027 if (ksym
== NoSymbol
) {
2028 wwarning(_("%s:invalid kbd shortcut specification \"%s\""), entry
->key
, val
);
2032 shortcut
.keycode
= XKeysymToKeycode(dpy
, ksym
);
2033 if (shortcut
.keycode
== 0) {
2034 wwarning(_("%s:invalid key in shortcut \"%s\""), entry
->key
, val
);
2044 static int getModMask(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
2049 GET_STRING_OR_DEFAULT("Modifier Key", str
);
2054 mask
= wXModifierFromKey(str
);
2056 wwarning(_("%s: modifier key %s is not valid"), entry
->key
, str
);
2062 *(int *)addr
= mask
;
2070 # include <X11/cursorfont.h>
2076 #define CURSOR_ID_NONE (XC_num_glyphs)
2078 static WCursorLookup cursor_table
[] = {
2079 {"X_cursor", XC_X_cursor
},
2080 {"arrow", XC_arrow
},
2081 {"based_arrow_down", XC_based_arrow_down
},
2082 {"based_arrow_up", XC_based_arrow_up
},
2084 {"bogosity", XC_bogosity
},
2085 {"bottom_left_corner", XC_bottom_left_corner
},
2086 {"bottom_right_corner", XC_bottom_right_corner
},
2087 {"bottom_side", XC_bottom_side
},
2088 {"bottom_tee", XC_bottom_tee
},
2089 {"box_spiral", XC_box_spiral
},
2090 {"center_ptr", XC_center_ptr
},
2091 {"circle", XC_circle
},
2092 {"clock", XC_clock
},
2093 {"coffee_mug", XC_coffee_mug
},
2094 {"cross", XC_cross
},
2095 {"cross_reverse", XC_cross_reverse
},
2096 {"crosshair", XC_crosshair
},
2097 {"diamond_cross", XC_diamond_cross
},
2099 {"dotbox", XC_dotbox
},
2100 {"double_arrow", XC_double_arrow
},
2101 {"draft_large", XC_draft_large
},
2102 {"draft_small", XC_draft_small
},
2103 {"draped_box", XC_draped_box
},
2104 {"exchange", XC_exchange
},
2105 {"fleur", XC_fleur
},
2106 {"gobbler", XC_gobbler
},
2107 {"gumby", XC_gumby
},
2108 {"hand1", XC_hand1
},
2109 {"hand2", XC_hand2
},
2110 {"heart", XC_heart
},
2112 {"iron_cross", XC_iron_cross
},
2113 {"left_ptr", XC_left_ptr
},
2114 {"left_side", XC_left_side
},
2115 {"left_tee", XC_left_tee
},
2116 {"leftbutton", XC_leftbutton
},
2117 {"ll_angle", XC_ll_angle
},
2118 {"lr_angle", XC_lr_angle
},
2120 {"middlebutton", XC_middlebutton
},
2121 {"mouse", XC_mouse
},
2122 {"pencil", XC_pencil
},
2123 {"pirate", XC_pirate
},
2125 {"question_arrow", XC_question_arrow
},
2126 {"right_ptr", XC_right_ptr
},
2127 {"right_side", XC_right_side
},
2128 {"right_tee", XC_right_tee
},
2129 {"rightbutton", XC_rightbutton
},
2130 {"rtl_logo", XC_rtl_logo
},
2131 {"sailboat", XC_sailboat
},
2132 {"sb_down_arrow", XC_sb_down_arrow
},
2133 {"sb_h_double_arrow", XC_sb_h_double_arrow
},
2134 {"sb_left_arrow", XC_sb_left_arrow
},
2135 {"sb_right_arrow", XC_sb_right_arrow
},
2136 {"sb_up_arrow", XC_sb_up_arrow
},
2137 {"sb_v_double_arrow", XC_sb_v_double_arrow
},
2138 {"shuttle", XC_shuttle
},
2139 {"sizing", XC_sizing
},
2140 {"spider", XC_spider
},
2141 {"spraycan", XC_spraycan
},
2143 {"target", XC_target
},
2144 {"tcross", XC_tcross
},
2145 {"top_left_arrow", XC_top_left_arrow
},
2146 {"top_left_corner", XC_top_left_corner
},
2147 {"top_right_corner", XC_top_right_corner
},
2148 {"top_side", XC_top_side
},
2149 {"top_tee", XC_top_tee
},
2151 {"ul_angle", XC_ul_angle
},
2152 {"umbrella", XC_umbrella
},
2153 {"ur_angle", XC_ur_angle
},
2154 {"watch", XC_watch
},
2155 {"xterm", XC_xterm
},
2156 {NULL
, CURSOR_ID_NONE
}
2159 static void check_bitmap_status(int status
, char *filename
, Pixmap bitmap
)
2162 case BitmapOpenFailed
:
2163 wwarning(_("failed to open bitmap file \"%s\""), filename
);
2165 case BitmapFileInvalid
:
2166 wwarning(_("\"%s\" is not a valid bitmap file"), filename
);
2168 case BitmapNoMemory
:
2169 wwarning(_("out of memory reading bitmap file \"%s\""), filename
);
2172 XFreePixmap(dpy
, bitmap
);
2179 * (builtin, <cursor_name>)
2180 * (bitmap, <cursor_bitmap>, <cursor_mask>)
2182 static int parse_cursor(WScreen
* scr
, WMPropList
* pl
, Cursor
* cursor
)
2189 nelem
= WMGetPropListItemCount(pl
);
2193 elem
= WMGetFromPLArray(pl
, 0);
2194 if (!elem
|| !WMIsPLString(elem
)) {
2197 val
= WMGetFromPLString(elem
);
2199 if (strcasecmp(val
, "none") == 0) {
2202 } else if (strcasecmp(val
, "builtin") == 0) {
2204 int cursor_id
= CURSOR_ID_NONE
;
2207 wwarning(_("bad number of arguments in cursor specification"));
2210 elem
= WMGetFromPLArray(pl
, 1);
2211 if (!elem
|| !WMIsPLString(elem
)) {
2214 val
= WMGetFromPLString(elem
);
2216 for (i
= 0; cursor_table
[i
].name
!= NULL
; i
++) {
2217 if (strcasecmp(val
, cursor_table
[i
].name
) == 0) {
2218 cursor_id
= cursor_table
[i
].id
;
2222 if (CURSOR_ID_NONE
== cursor_id
) {
2223 wwarning(_("unknown builtin cursor name \"%s\""), val
);
2225 *cursor
= XCreateFontCursor(dpy
, cursor_id
);
2228 } else if (strcasecmp(val
, "bitmap") == 0) {
2240 wwarning(_("bad number of arguments in cursor specification"));
2243 elem
= WMGetFromPLArray(pl
, 1);
2244 if (!elem
|| !WMIsPLString(elem
)) {
2247 val
= WMGetFromPLString(elem
);
2248 bitmap_name
= FindImage(wPreferences
.pixmap_path
, val
);
2250 wwarning(_("could not find cursor bitmap file \"%s\""), val
);
2253 elem
= WMGetFromPLArray(pl
, 2);
2254 if (!elem
|| !WMIsPLString(elem
)) {
2258 val
= WMGetFromPLString(elem
);
2259 mask_name
= FindImage(wPreferences
.pixmap_path
, val
);
2262 wwarning(_("could not find cursor bitmap file \"%s\""), val
);
2265 mask_status
= XReadBitmapFile(dpy
, scr
->w_win
, mask_name
, &w
, &h
, &mask
, &x
, &y
);
2266 bitmap_status
= XReadBitmapFile(dpy
, scr
->w_win
, bitmap_name
, &w
, &h
, &bitmap
, &x
, &y
);
2267 if ((BitmapSuccess
== bitmap_status
) && (BitmapSuccess
== mask_status
)) {
2268 fg
.pixel
= scr
->black_pixel
;
2269 bg
.pixel
= scr
->white_pixel
;
2270 XQueryColor(dpy
, scr
->w_colormap
, &fg
);
2271 XQueryColor(dpy
, scr
->w_colormap
, &bg
);
2272 *cursor
= XCreatePixmapCursor(dpy
, bitmap
, mask
, &fg
, &bg
, x
, y
);
2275 check_bitmap_status(bitmap_status
, bitmap_name
, bitmap
);
2276 check_bitmap_status(mask_status
, mask_name
, mask
);
2283 static int getCursor(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
2285 static Cursor cursor
;
2290 if (!WMIsPLArray(value
)) {
2291 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
2292 entry
->key
, "cursor specification");
2294 value
= entry
->plvalue
;
2296 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
2301 status
= parse_cursor(scr
, value
, &cursor
);
2303 wwarning(_("Error in cursor specification for key \"%s\""), entry
->key
);
2305 value
= entry
->plvalue
;
2307 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
2316 *(Cursor
*) addr
= cursor
;
2321 #undef CURSOR_ID_NONE
2323 /* ---------------- value setting functions --------------- */
2324 static int setJustify(WScreen
* scr
, WDefaultEntry
* entry
, WTexture
** texture
, void *foo
)
2326 return REFRESH_WINDOW_TITLE_COLOR
;
2329 static int setClearance(WScreen
* scr
, WDefaultEntry
* entry
, void *bar
, void *foo
)
2331 return REFRESH_WINDOW_FONT
| REFRESH_BUTTON_IMAGES
| REFRESH_MENU_TITLE_FONT
| REFRESH_MENU_FONT
;
2334 static int setIfDockPresent(WScreen
* scr
, WDefaultEntry
* entry
, char *flag
, long which
)
2338 wPreferences
.flags
.nodock
= wPreferences
.flags
.nodock
|| *flag
;
2341 wPreferences
.flags
.noclip
= wPreferences
.flags
.noclip
|| *flag
;
2349 static int setStickyIcons(WScreen
* scr
, WDefaultEntry
* entry
, void *bar
, void *foo
)
2351 if (scr
->workspaces
) {
2352 wWorkspaceForceChange(scr
, scr
->current_workspace
);
2353 wArrangeIcons(scr
, False
);
2358 static int setIconTile(WScreen
* scr
, WDefaultEntry
* entry
, WTexture
** texture
, void *foo
)
2364 img
= wTextureRenderImage(*texture
, wPreferences
.icon_size
,
2365 wPreferences
.icon_size
, ((*texture
)->any
.type
& WREL_BORDER_MASK
)
2366 ? WREL_ICON
: WREL_FLAT
);
2368 wwarning(_("could not render texture for icon background"));
2370 wTextureDestroy(scr
, *texture
);
2373 RConvertImage(scr
->rcontext
, img
, &pixmap
);
2375 if (scr
->icon_tile
) {
2377 RReleaseImage(scr
->icon_tile
);
2378 XFreePixmap(dpy
, scr
->icon_tile_pixmap
);
2381 scr
->icon_tile
= img
;
2383 /* put the icon in the noticeboard hint */
2384 PropSetIconTileHint(scr
, img
);
2386 if (!wPreferences
.flags
.noclip
) {
2387 if (scr
->clip_tile
) {
2388 RReleaseImage(scr
->clip_tile
);
2390 scr
->clip_tile
= wClipMakeTile(scr
, img
);
2393 scr
->icon_tile_pixmap
= pixmap
;
2395 if (scr
->def_icon_pixmap
) {
2396 XFreePixmap(dpy
, scr
->def_icon_pixmap
);
2397 scr
->def_icon_pixmap
= None
;
2399 if (scr
->def_ticon_pixmap
) {
2400 XFreePixmap(dpy
, scr
->def_ticon_pixmap
);
2401 scr
->def_ticon_pixmap
= None
;
2404 if (scr
->icon_back_texture
) {
2405 wTextureDestroy(scr
, (WTexture
*) scr
->icon_back_texture
);
2407 scr
->icon_back_texture
= wTextureMakeSolid(scr
, &((*texture
)->any
.color
));
2409 if (scr
->clip_balloon
)
2410 XSetWindowBackground(dpy
, scr
->clip_balloon
, (*texture
)->any
.color
.pixel
);
2413 * Free the texture as nobody else will use it, nor refer to it.
2416 wTextureDestroy(scr
, *texture
);
2418 return (reset
? REFRESH_ICON_TILE
: 0);
2421 static int setWinTitleFont(WScreen
* scr
, WDefaultEntry
* entry
, WMFont
* font
, void *foo
)
2423 if (scr
->title_font
) {
2424 WMReleaseFont(scr
->title_font
);
2426 scr
->title_font
= font
;
2428 return REFRESH_WINDOW_FONT
| REFRESH_BUTTON_IMAGES
;
2431 static int setMenuTitleFont(WScreen
* scr
, WDefaultEntry
* entry
, WMFont
* font
, void *foo
)
2433 if (scr
->menu_title_font
) {
2434 WMReleaseFont(scr
->menu_title_font
);
2437 scr
->menu_title_font
= font
;
2439 return REFRESH_MENU_TITLE_FONT
;
2442 static int setMenuTextFont(WScreen
* scr
, WDefaultEntry
* entry
, WMFont
* font
, void *foo
)
2444 if (scr
->menu_entry_font
) {
2445 WMReleaseFont(scr
->menu_entry_font
);
2447 scr
->menu_entry_font
= font
;
2449 return REFRESH_MENU_FONT
;
2452 static int setIconTitleFont(WScreen
* scr
, WDefaultEntry
* entry
, WMFont
* font
, void *foo
)
2454 if (scr
->icon_title_font
) {
2455 WMReleaseFont(scr
->icon_title_font
);
2458 scr
->icon_title_font
= font
;
2460 return REFRESH_ICON_FONT
;
2463 static int setClipTitleFont(WScreen
* scr
, WDefaultEntry
* entry
, WMFont
* font
, void *foo
)
2465 if (scr
->clip_title_font
) {
2466 WMReleaseFont(scr
->clip_title_font
);
2469 scr
->clip_title_font
= font
;
2471 return REFRESH_ICON_FONT
;
2474 static int setLargeDisplayFont(WScreen
* scr
, WDefaultEntry
* entry
, WMFont
* font
, void *foo
)
2476 if (scr
->workspace_name_font
) {
2477 WMReleaseFont(scr
->workspace_name_font
);
2480 scr
->workspace_name_font
= font
;
2485 static int setHightlight(WScreen
* scr
, WDefaultEntry
* entry
, XColor
* color
, void *foo
)
2487 if (scr
->select_color
)
2488 WMReleaseColor(scr
->select_color
);
2490 scr
->select_color
= WMCreateRGBColor(scr
->wmscreen
, color
->red
, color
->green
, color
->blue
, True
);
2492 wFreeColor(scr
, color
->pixel
);
2494 return REFRESH_MENU_COLOR
;
2497 static int setHightlightText(WScreen
* scr
, WDefaultEntry
* entry
, XColor
* color
, void *foo
)
2499 if (scr
->select_text_color
)
2500 WMReleaseColor(scr
->select_text_color
);
2502 scr
->select_text_color
= WMCreateRGBColor(scr
->wmscreen
, color
->red
, color
->green
, color
->blue
, True
);
2504 wFreeColor(scr
, color
->pixel
);
2506 return REFRESH_MENU_COLOR
;
2509 static int setClipTitleColor(WScreen
* scr
, WDefaultEntry
* entry
, XColor
* color
, long widx
)
2511 if (scr
->clip_title_color
[widx
])
2512 WMReleaseColor(scr
->clip_title_color
[widx
]);
2514 scr
->clip_title_color
[widx
] = WMCreateRGBColor(scr
->wmscreen
, color
->red
, color
->green
, color
->blue
, True
);
2515 wFreeColor(scr
, color
->pixel
);
2517 return REFRESH_ICON_TITLE_COLOR
;
2520 static int setWTitleColor(WScreen
* scr
, WDefaultEntry
* entry
, XColor
* color
, long widx
)
2522 if (scr
->window_title_color
[widx
])
2523 WMReleaseColor(scr
->window_title_color
[widx
]);
2525 scr
->window_title_color
[widx
] =
2526 WMCreateRGBColor(scr
->wmscreen
, color
->red
, color
->green
, color
->blue
, True
);
2528 wFreeColor(scr
, color
->pixel
);
2530 return REFRESH_WINDOW_TITLE_COLOR
;
2533 static int setMenuTitleColor(WScreen
* scr
, WDefaultEntry
* entry
, XColor
* color
, long widx
)
2535 if (scr
->menu_title_color
[0])
2536 WMReleaseColor(scr
->menu_title_color
[0]);
2538 scr
->menu_title_color
[0] = WMCreateRGBColor(scr
->wmscreen
, color
->red
, color
->green
, color
->blue
, True
);
2540 wFreeColor(scr
, color
->pixel
);
2542 return REFRESH_MENU_TITLE_COLOR
;
2545 static int setMenuTextColor(WScreen
* scr
, WDefaultEntry
* entry
, XColor
* color
, void *foo
)
2547 if (scr
->mtext_color
)
2548 WMReleaseColor(scr
->mtext_color
);
2550 scr
->mtext_color
= WMCreateRGBColor(scr
->wmscreen
, color
->red
, color
->green
, color
->blue
, True
);
2552 if (WMColorPixel(scr
->dtext_color
) == WMColorPixel(scr
->mtext_color
)) {
2553 WMSetColorAlpha(scr
->dtext_color
, 0x7fff);
2555 WMSetColorAlpha(scr
->dtext_color
, 0xffff);
2558 wFreeColor(scr
, color
->pixel
);
2560 return REFRESH_MENU_COLOR
;
2563 static int setMenuDisabledColor(WScreen
* scr
, WDefaultEntry
* entry
, XColor
* color
, void *foo
)
2565 if (scr
->dtext_color
)
2566 WMReleaseColor(scr
->dtext_color
);
2568 scr
->dtext_color
= WMCreateRGBColor(scr
->wmscreen
, color
->red
, color
->green
, color
->blue
, True
);
2570 if (WMColorPixel(scr
->dtext_color
) == WMColorPixel(scr
->mtext_color
)) {
2571 WMSetColorAlpha(scr
->dtext_color
, 0x7fff);
2573 WMSetColorAlpha(scr
->dtext_color
, 0xffff);
2576 wFreeColor(scr
, color
->pixel
);
2578 return REFRESH_MENU_COLOR
;
2581 static int setIconTitleColor(WScreen
* scr
, WDefaultEntry
* entry
, XColor
* color
, void *foo
)
2583 if (scr
->icon_title_color
)
2584 WMReleaseColor(scr
->icon_title_color
);
2585 scr
->icon_title_color
= WMCreateRGBColor(scr
->wmscreen
, color
->red
, color
->green
, color
->blue
, True
);
2587 wFreeColor(scr
, color
->pixel
);
2589 return REFRESH_ICON_TITLE_COLOR
;
2592 static int setIconTitleBack(WScreen
* scr
, WDefaultEntry
* entry
, XColor
* color
, void *foo
)
2594 if (scr
->icon_title_texture
) {
2595 wTextureDestroy(scr
, (WTexture
*) scr
->icon_title_texture
);
2597 scr
->icon_title_texture
= wTextureMakeSolid(scr
, color
);
2599 return REFRESH_ICON_TITLE_BACK
;
2602 static void trackDeadProcess(pid_t pid
, unsigned char status
, WScreen
* scr
)
2604 close(scr
->helper_fd
);
2606 scr
->helper_pid
= 0;
2607 scr
->flags
.backimage_helper_launched
= 0;
2610 static int setWorkspaceSpecificBack(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *bar
)
2616 if (scr
->flags
.backimage_helper_launched
) {
2617 if (WMGetPropListItemCount(value
) == 0) {
2618 SendHelperMessage(scr
, 'C', 0, NULL
);
2619 SendHelperMessage(scr
, 'K', 0, NULL
);
2621 WMReleasePropList(value
);
2628 if (WMGetPropListItemCount(value
) == 0)
2631 if (pipe(filedes
) < 0) {
2632 werror("pipe() failed:can't set workspace specific background image");
2634 WMReleasePropList(value
);
2640 werror("fork() failed:can't set workspace specific background image");
2641 if (close(filedes
[0]) < 0)
2642 werror("could not close pipe");
2643 if (close(filedes
[1]) < 0)
2644 werror("could not close pipe");
2646 } else if (pid
== 0) {
2649 SetupEnvironment(scr
);
2652 werror("could not close pipe");
2653 if (dup(filedes
[0]) < 0) {
2654 werror("dup() failed:can't set workspace specific background image");
2656 dither
= wPreferences
.no_dithering
? "-m" : "-d";
2657 if (wPreferences
.smooth_workspace_back
)
2658 execlp("wmsetbg", "wmsetbg", "-helper", "-S", dither
, NULL
);
2660 execlp("wmsetbg", "wmsetbg", "-helper", dither
, NULL
);
2661 werror("could not execute wmsetbg");
2665 if (fcntl(filedes
[0], F_SETFD
, FD_CLOEXEC
) < 0) {
2666 werror("error setting close-on-exec flag");
2668 if (fcntl(filedes
[1], F_SETFD
, FD_CLOEXEC
) < 0) {
2669 werror("error setting close-on-exec flag");
2672 scr
->helper_fd
= filedes
[1];
2673 scr
->helper_pid
= pid
;
2674 scr
->flags
.backimage_helper_launched
= 1;
2676 wAddDeathHandler(pid
, (WDeathHandler
*) trackDeadProcess
, scr
);
2678 SendHelperMessage(scr
, 'P', -1, wPreferences
.pixmap_path
);
2683 for (i
= 0; i
< WMGetPropListItemCount(value
); i
++) {
2684 val
= WMGetFromPLArray(value
, i
);
2685 if (val
&& WMIsPLArray(val
) && WMGetPropListItemCount(val
) > 0) {
2686 str
= WMGetPropListDescription(val
, False
);
2688 SendHelperMessage(scr
, 'S', i
+ 1, str
);
2692 SendHelperMessage(scr
, 'U', i
+ 1, NULL
);
2697 WMReleasePropList(value
);
2701 static int setWorkspaceBack(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *bar
)
2703 if (scr
->flags
.backimage_helper_launched
) {
2706 if (WMGetPropListItemCount(value
) == 0) {
2707 SendHelperMessage(scr
, 'U', 0, NULL
);
2709 /* set the default workspace background to this one */
2710 str
= WMGetPropListDescription(value
, False
);
2712 SendHelperMessage(scr
, 'S', 0, str
);
2714 SendHelperMessage(scr
, 'C', scr
->current_workspace
+ 1, NULL
);
2716 SendHelperMessage(scr
, 'U', 0, NULL
);
2719 } else if (WMGetPropListItemCount(value
) > 0) {
2725 text
= WMGetPropListDescription(value
, False
);
2726 len
= strlen(text
) + 40;
2727 command
= wmalloc(len
);
2728 dither
= wPreferences
.no_dithering
? "-m" : "-d";
2729 if (wPreferences
.smooth_workspace_back
)
2730 snprintf(command
, len
, "wmsetbg %s -S -p '%s' &", dither
, text
);
2732 snprintf(command
, len
, "wmsetbg %s -p '%s' &", dither
, text
);
2734 ExecuteShellCommand(scr
, command
);
2737 WMReleasePropList(value
);
2742 static int setWidgetColor(WScreen
* scr
, WDefaultEntry
* entry
, WTexture
** texture
, void *foo
)
2744 if (scr
->widget_texture
) {
2745 wTextureDestroy(scr
, (WTexture
*) scr
->widget_texture
);
2747 scr
->widget_texture
= *(WTexSolid
**) texture
;
2752 static int setFTitleBack(WScreen
* scr
, WDefaultEntry
* entry
, WTexture
** texture
, void *foo
)
2754 if (scr
->window_title_texture
[WS_FOCUSED
]) {
2755 wTextureDestroy(scr
, scr
->window_title_texture
[WS_FOCUSED
]);
2757 scr
->window_title_texture
[WS_FOCUSED
] = *texture
;
2759 return REFRESH_WINDOW_TEXTURES
;
2762 static int setPTitleBack(WScreen
* scr
, WDefaultEntry
* entry
, WTexture
** texture
, void *foo
)
2764 if (scr
->window_title_texture
[WS_PFOCUSED
]) {
2765 wTextureDestroy(scr
, scr
->window_title_texture
[WS_PFOCUSED
]);
2767 scr
->window_title_texture
[WS_PFOCUSED
] = *texture
;
2769 return REFRESH_WINDOW_TEXTURES
;
2772 static int setUTitleBack(WScreen
* scr
, WDefaultEntry
* entry
, WTexture
** texture
, void *foo
)
2774 if (scr
->window_title_texture
[WS_UNFOCUSED
]) {
2775 wTextureDestroy(scr
, scr
->window_title_texture
[WS_UNFOCUSED
]);
2777 scr
->window_title_texture
[WS_UNFOCUSED
] = *texture
;
2779 return REFRESH_WINDOW_TEXTURES
;
2782 static int setResizebarBack(WScreen
* scr
, WDefaultEntry
* entry
, WTexture
** texture
, void *foo
)
2784 if (scr
->resizebar_texture
[0]) {
2785 wTextureDestroy(scr
, scr
->resizebar_texture
[0]);
2787 scr
->resizebar_texture
[0] = *texture
;
2789 return REFRESH_WINDOW_TEXTURES
;
2792 static int setMenuTitleBack(WScreen
* scr
, WDefaultEntry
* entry
, WTexture
** texture
, void *foo
)
2794 if (scr
->menu_title_texture
[0]) {
2795 wTextureDestroy(scr
, scr
->menu_title_texture
[0]);
2797 scr
->menu_title_texture
[0] = *texture
;
2799 return REFRESH_MENU_TITLE_TEXTURE
;
2802 static int setMenuTextBack(WScreen
* scr
, WDefaultEntry
* entry
, WTexture
** texture
, void *foo
)
2804 if (scr
->menu_item_texture
) {
2805 wTextureDestroy(scr
, scr
->menu_item_texture
);
2806 wTextureDestroy(scr
, (WTexture
*) scr
->menu_item_auxtexture
);
2808 scr
->menu_item_texture
= *texture
;
2810 scr
->menu_item_auxtexture
= wTextureMakeSolid(scr
, &scr
->menu_item_texture
->any
.color
);
2812 return REFRESH_MENU_TEXTURE
;
2815 static int setKeyGrab(WScreen
* scr
, WDefaultEntry
* entry
, WShortKey
* shortcut
, long widx
)
2818 wKeyBindings
[widx
] = *shortcut
;
2820 wwin
= scr
->focused_window
;
2822 while (wwin
!= NULL
) {
2823 XUngrabKey(dpy
, AnyKey
, AnyModifier
, wwin
->frame
->core
->window
);
2825 if (!WFLAGP(wwin
, no_bind_keys
)) {
2826 wWindowSetKeyGrabs(wwin
);
2834 static int setIconPosition(WScreen
* scr
, WDefaultEntry
* entry
, void *bar
, void *foo
)
2836 wScreenUpdateUsableArea(scr
);
2837 wArrangeIcons(scr
, True
);
2842 static int updateUsableArea(WScreen
* scr
, WDefaultEntry
* entry
, void *bar
, void *foo
)
2844 wScreenUpdateUsableArea(scr
);
2849 static int setMenuStyle(WScreen
* scr
, WDefaultEntry
* entry
, int *value
, void *foo
)
2851 return REFRESH_MENU_TEXTURE
;
2854 static RImage
*chopOffImage(RImage
* image
, int x
, int y
, int w
, int h
)
2856 RImage
*img
= RCreateImage(w
, h
, image
->format
== RRGBAFormat
);
2858 RCopyArea(img
, image
, x
, y
, w
, h
, 0, 0);
2863 static int setSwPOptions(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* array
, void *foo
)
2867 int cwidth
, cheight
;
2868 WPreferences
*prefs
= (WPreferences
*) foo
;
2870 if (!WMIsPLArray(array
) || WMGetPropListItemCount(array
) == 0) {
2871 if (prefs
->swtileImage
)
2872 RReleaseImage(prefs
->swtileImage
);
2873 prefs
->swtileImage
= NULL
;
2875 WMReleasePropList(array
);
2879 switch (WMGetPropListItemCount(array
)) {
2881 if (!WMIsPLString(WMGetFromPLArray(array
, 1))) {
2882 wwarning(_("Invalid arguments for option \"%s\""), entry
->key
);
2885 path
= FindImage(wPreferences
.pixmap_path
, WMGetFromPLString(WMGetFromPLArray(array
, 1)));
2888 wwarning(_("Could not find image \"%s\" for option \"%s\""),
2889 WMGetFromPLString(WMGetFromPLArray(array
, 1)), entry
->key
);
2891 bgimage
= RLoadImage(scr
->rcontext
, path
, 0);
2893 wwarning(_("Could not load image \"%s\" for option \"%s\""), path
, entry
->key
);
2898 cwidth
= atoi(WMGetFromPLString(WMGetFromPLArray(array
, 2)));
2899 cheight
= atoi(WMGetFromPLString(WMGetFromPLArray(array
, 3)));
2901 if (cwidth
<= 0 || cheight
<= 0 ||
2902 cwidth
>= bgimage
->width
- 2 || cheight
>= bgimage
->height
- 2)
2903 wwarning(_("Invalid split sizes for SwitchPanel back image."));
2906 int swidth
, theight
;
2907 for (i
= 0; i
< 9; i
++) {
2908 if (prefs
->swbackImage
[i
])
2909 RReleaseImage(prefs
->swbackImage
[i
]);
2910 prefs
->swbackImage
[i
] = NULL
;
2912 swidth
= (bgimage
->width
- cwidth
) / 2;
2913 theight
= (bgimage
->height
- cheight
) / 2;
2915 prefs
->swbackImage
[0] = chopOffImage(bgimage
, 0, 0, swidth
, theight
);
2916 prefs
->swbackImage
[1] = chopOffImage(bgimage
, swidth
, 0, cwidth
, theight
);
2917 prefs
->swbackImage
[2] = chopOffImage(bgimage
, swidth
+ cwidth
, 0,
2920 prefs
->swbackImage
[3] = chopOffImage(bgimage
, 0, theight
, swidth
, cheight
);
2921 prefs
->swbackImage
[4] = chopOffImage(bgimage
, swidth
, theight
,
2923 prefs
->swbackImage
[5] = chopOffImage(bgimage
, swidth
+ cwidth
, theight
,
2926 prefs
->swbackImage
[6] = chopOffImage(bgimage
, 0, theight
+ cheight
,
2928 prefs
->swbackImage
[7] = chopOffImage(bgimage
, swidth
, theight
+ cheight
,
2930 prefs
->swbackImage
[8] =
2931 chopOffImage(bgimage
, swidth
+ cwidth
, theight
+ cheight
, swidth
,
2934 // check if anything failed
2935 for (i
= 0; i
< 9; i
++) {
2936 if (!prefs
->swbackImage
[i
]) {
2937 for (; i
>= 0; --i
) {
2938 RReleaseImage(prefs
->swbackImage
[i
]);
2939 prefs
->swbackImage
[i
] = NULL
;
2945 RReleaseImage(bgimage
);
2950 if (!WMIsPLString(WMGetFromPLArray(array
, 0))) {
2951 wwarning(_("Invalid arguments for option \"%s\""), entry
->key
);
2954 path
= FindImage(wPreferences
.pixmap_path
, WMGetFromPLString(WMGetFromPLArray(array
, 0)));
2957 wwarning(_("Could not find image \"%s\" for option \"%s\""),
2958 WMGetFromPLString(WMGetFromPLArray(array
, 0)), entry
->key
);
2960 if (prefs
->swtileImage
)
2961 RReleaseImage(prefs
->swtileImage
);
2963 prefs
->swtileImage
= RLoadImage(scr
->rcontext
, path
, 0);
2964 if (!prefs
->swtileImage
) {
2965 wwarning(_("Could not load image \"%s\" for option \"%s\""), path
, entry
->key
);
2972 wwarning(_("Invalid number of arguments for option \"%s\""), entry
->key
);
2976 WMReleasePropList(array
);
2981 static int setModifierKeyLabels(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* array
, void *foo
)
2984 WPreferences
*prefs
= (WPreferences
*) foo
;
2986 if (!WMIsPLArray(array
) || WMGetPropListItemCount(array
) != 7) {
2987 wwarning(_("Value for option \"%s\" must be an array of 7 strings"), entry
->key
);
2988 WMReleasePropList(array
);
2992 DestroyWindowMenu(scr
);
2994 for (i
= 0; i
< 7; i
++) {
2995 if (prefs
->modifier_labels
[i
])
2996 wfree(prefs
->modifier_labels
[i
]);
2998 if (WMIsPLString(WMGetFromPLArray(array
, i
))) {
2999 prefs
->modifier_labels
[i
] = wstrdup(WMGetFromPLString(WMGetFromPLArray(array
, i
)));
3001 wwarning(_("Invalid argument for option \"%s\" item %d"), entry
->key
, i
);
3002 prefs
->modifier_labels
[i
] = NULL
;
3006 WMReleasePropList(array
);
3013 * Need access to the double click variables, so that all widgets in
3014 * wmaker panels will have the same dbl-click values.
3015 * TODO: figure a better way of dealing with it.
3017 #include <WINGs/WINGsP.h>
3019 static int setDoubleClick(WScreen
* scr
, WDefaultEntry
* entry
, int *value
, void *foo
)
3021 extern _WINGsConfiguration WINGsConfiguration
;
3026 WINGsConfiguration
.doubleClickDelay
= *value
;
3031 static int setCursor(WScreen
* scr
, WDefaultEntry
* entry
, Cursor
* cursor
, long widx
)
3033 if (wCursor
[widx
] != None
) {
3034 XFreeCursor(dpy
, wCursor
[widx
]);
3037 wCursor
[widx
] = *cursor
;
3039 if (widx
== WCUR_ROOT
&& *cursor
!= None
) {
3040 XDefineCursor(dpy
, scr
->root_win
, *cursor
);