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 memset(db
, 0, sizeof(WDDomain
));
817 db
->domain_name
= domain
;
818 db
->path
= wdefaultspathfordomain(domain
);
821 if (the_path
&& stat(the_path
, &stbuf
) >= 0) {
822 db
->dictionary
= WMReadPropListFromFile(the_path
);
823 if (db
->dictionary
) {
824 if (requireDictionary
&& !WMIsPLDictionary(db
->dictionary
)) {
825 WMReleasePropList(db
->dictionary
);
826 db
->dictionary
= NULL
;
827 wwarning(_("Domain %s (%s) of defaults database is corrupted!"), domain
, the_path
);
829 db
->timestamp
= stbuf
.st_mtime
;
831 wwarning(_("could not load domain %s from user defaults database"), domain
);
835 /* global system dictionary */
836 snprintf(path
, sizeof(path
), "%s/%s/%s", SYSCONFDIR
, GLOBAL_DEFAULTS_SUBDIR
, domain
);
837 if (stat(path
, &stbuf
) >= 0) {
838 shared_dict
= WMReadPropListFromFile(path
);
840 if (requireDictionary
&& !WMIsPLDictionary(shared_dict
)) {
841 wwarning(_("Domain %s (%s) of global defaults database is corrupted!"),
843 WMReleasePropList(shared_dict
);
846 if (db
->dictionary
&& WMIsPLDictionary(shared_dict
) &&
847 WMIsPLDictionary(db
->dictionary
)) {
848 WMMergePLDictionaries(shared_dict
, db
->dictionary
, True
);
849 WMReleasePropList(db
->dictionary
);
850 db
->dictionary
= shared_dict
;
851 if (stbuf
.st_mtime
> db
->timestamp
)
852 db
->timestamp
= stbuf
.st_mtime
;
853 } else if (!db
->dictionary
) {
854 db
->dictionary
= shared_dict
;
855 if (stbuf
.st_mtime
> db
->timestamp
)
856 db
->timestamp
= stbuf
.st_mtime
;
860 wwarning(_("could not load domain %s from global defaults database (%s)"), domain
, path
);
867 void wReadStaticDefaults(WMPropList
* dict
)
870 WDefaultEntry
*entry
;
874 for (i
= 0; i
< sizeof(staticOptionList
) / sizeof(WDefaultEntry
); i
++) {
875 entry
= &staticOptionList
[i
];
878 plvalue
= WMGetFromPLDictionary(dict
, entry
->plkey
);
883 /* no default in the DB. Use builtin default */
884 plvalue
= entry
->plvalue
;
889 (*entry
->convert
) (NULL
, entry
, plvalue
, entry
->addr
, &tdata
);
891 (*entry
->update
) (NULL
, entry
, tdata
, entry
->extra_data
);
897 void wDefaultsCheckDomains(void* arg
)
901 WMPropList
*shared_dict
= NULL
;
905 if (stat(WDWindowMaker
->path
, &stbuf
) >= 0 && WDWindowMaker
->timestamp
< stbuf
.st_mtime
) {
906 WDWindowMaker
->timestamp
= stbuf
.st_mtime
;
908 /* Global dictionary */
909 shared_dict
= readGlobalDomain("WindowMaker", True
);
911 /* User dictionary */
912 dict
= WMReadPropListFromFile(WDWindowMaker
->path
);
915 if (!WMIsPLDictionary(dict
)) {
916 WMReleasePropList(dict
);
918 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
919 "WindowMaker", WDWindowMaker
->path
);
922 WMMergePLDictionaries(shared_dict
, dict
, True
);
923 WMReleasePropList(dict
);
928 for (i
= 0; i
< wScreenCount
; i
++) {
929 scr
= wScreenWithNumber(i
);
931 wReadDefaults(scr
, dict
);
934 if (WDWindowMaker
->dictionary
)
935 WMReleasePropList(WDWindowMaker
->dictionary
);
937 WDWindowMaker
->dictionary
= dict
;
940 wwarning(_("could not load domain %s from user defaults database"), "WindowMaker");
944 WMReleasePropList(shared_dict
);
948 if (stat(WDWindowAttributes
->path
, &stbuf
) >= 0 && WDWindowAttributes
->timestamp
< stbuf
.st_mtime
) {
949 /* global dictionary */
950 shared_dict
= readGlobalDomain("WMWindowAttributes", True
);
951 /* user dictionary */
952 dict
= WMReadPropListFromFile(WDWindowAttributes
->path
);
954 if (!WMIsPLDictionary(dict
)) {
955 WMReleasePropList(dict
);
957 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
958 "WMWindowAttributes", WDWindowAttributes
->path
);
961 WMMergePLDictionaries(shared_dict
, dict
, True
);
962 WMReleasePropList(dict
);
966 if (WDWindowAttributes
->dictionary
) {
967 WMReleasePropList(WDWindowAttributes
->dictionary
);
969 WDWindowAttributes
->dictionary
= dict
;
970 for (i
= 0; i
< wScreenCount
; i
++) {
971 scr
= wScreenWithNumber(i
);
975 wDefaultUpdateIcons(scr
);
977 /* Update the panel image if changed */
978 /* Don't worry. If the image is the same these
979 * functions will have no performance impact. */
980 image
= wDefaultGetImage(scr
, "Logo", "WMPanel", wPreferences
.icon_size
);
983 wwarning(_("could not load logo image for panels: %s"),
984 RMessageForError(RErrorCode
));
986 WMSetApplicationIconImage(scr
->wmscreen
, image
);
987 RReleaseImage(image
);
993 wwarning(_("could not load domain %s from user defaults database"), "WMWindowAttributes");
995 WDWindowAttributes
->timestamp
= stbuf
.st_mtime
;
997 WMReleasePropList(shared_dict
);
1001 if (stat(WDRootMenu
->path
, &stbuf
) >= 0 && WDRootMenu
->timestamp
< stbuf
.st_mtime
) {
1002 dict
= WMReadPropListFromFile(WDRootMenu
->path
);
1004 if (!WMIsPLArray(dict
) && !WMIsPLString(dict
)) {
1005 WMReleasePropList(dict
);
1007 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
1008 "WMRootMenu", WDRootMenu
->path
);
1010 if (WDRootMenu
->dictionary
) {
1011 WMReleasePropList(WDRootMenu
->dictionary
);
1013 WDRootMenu
->dictionary
= dict
;
1014 wDefaultsMergeGlobalMenus(WDRootMenu
);
1017 wwarning(_("could not load domain %s from user defaults database"), "WMRootMenu");
1019 WDRootMenu
->timestamp
= stbuf
.st_mtime
;
1021 #ifndef HAVE_INOTIFY
1023 WMAddTimerHandler(DEFAULTS_CHECK_INTERVAL
, wDefaultsCheckDomains
, arg
);
1027 void wReadDefaults(WScreen
* scr
, WMPropList
* new_dict
)
1029 WMPropList
*plvalue
, *old_value
;
1030 WDefaultEntry
*entry
;
1032 int update_workspace_back
= 0; /* kluge :/ */
1033 unsigned int needs_refresh
;
1035 WMPropList
*old_dict
= (WDWindowMaker
->dictionary
!= new_dict
? WDWindowMaker
->dictionary
: NULL
);
1039 for (i
= 0; i
< sizeof(optionList
) / sizeof(WDefaultEntry
); i
++) {
1040 entry
= &optionList
[i
];
1043 plvalue
= WMGetFromPLDictionary(new_dict
, entry
->plkey
);
1050 old_value
= WMGetFromPLDictionary(old_dict
, entry
->plkey
);
1052 if (!plvalue
&& !old_value
) {
1053 /* no default in the DB. Use builtin default */
1054 plvalue
= entry
->plvalue
;
1055 if (plvalue
&& new_dict
)
1056 WMPutInPLDictionary(new_dict
, entry
->plkey
, plvalue
);
1058 } else if (!plvalue
) {
1059 /* value was deleted from DB. Keep current value */
1061 } else if (!old_value
) {
1062 /* set value for the 1st time */
1063 } else if (!WMIsPropListEqualTo(plvalue
, old_value
)) {
1064 /* value has changed */
1066 if (strcmp(entry
->key
, "WorkspaceBack") == 0
1067 && update_workspace_back
&& scr
->flags
.backimage_helper_launched
) {
1069 /* value was not changed since last time */
1076 if ((*entry
->convert
) (scr
, entry
, plvalue
, entry
->addr
, &tdata
)) {
1078 * If the WorkspaceSpecificBack data has been changed
1079 * so that the helper will be launched now, we must be
1080 * sure to send the default background texture config
1083 if (strcmp(entry
->key
, "WorkspaceSpecificBack") == 0 &&
1084 !scr
->flags
.backimage_helper_launched
)
1085 update_workspace_back
= 1;
1088 needs_refresh
|= (*entry
->update
) (scr
, entry
, tdata
, entry
->extra_data
);
1094 if (needs_refresh
!= 0 && !scr
->flags
.startup
) {
1098 if (needs_refresh
& REFRESH_MENU_TITLE_TEXTURE
)
1099 foo
|= WTextureSettings
;
1100 if (needs_refresh
& REFRESH_MENU_TITLE_FONT
)
1101 foo
|= WFontSettings
;
1102 if (needs_refresh
& REFRESH_MENU_TITLE_COLOR
)
1103 foo
|= WColorSettings
;
1105 WMPostNotificationName(WNMenuTitleAppearanceSettingsChanged
, NULL
,
1106 (void *)(uintptr_t) foo
);
1109 if (needs_refresh
& REFRESH_MENU_TEXTURE
)
1110 foo
|= WTextureSettings
;
1111 if (needs_refresh
& REFRESH_MENU_FONT
)
1112 foo
|= WFontSettings
;
1113 if (needs_refresh
& REFRESH_MENU_COLOR
)
1114 foo
|= WColorSettings
;
1116 WMPostNotificationName(WNMenuAppearanceSettingsChanged
, NULL
, (void *)(uintptr_t) foo
);
1119 if (needs_refresh
& REFRESH_WINDOW_FONT
)
1120 foo
|= WFontSettings
;
1121 if (needs_refresh
& REFRESH_WINDOW_TEXTURES
)
1122 foo
|= WTextureSettings
;
1123 if (needs_refresh
& REFRESH_WINDOW_TITLE_COLOR
)
1124 foo
|= WColorSettings
;
1126 WMPostNotificationName(WNWindowAppearanceSettingsChanged
, NULL
, (void *)(uintptr_t) foo
);
1128 if (!(needs_refresh
& REFRESH_ICON_TILE
)) {
1130 if (needs_refresh
& REFRESH_ICON_FONT
)
1131 foo
|= WFontSettings
;
1132 if (needs_refresh
& REFRESH_ICON_TITLE_COLOR
)
1133 foo
|= WTextureSettings
;
1134 if (needs_refresh
& REFRESH_ICON_TITLE_BACK
)
1135 foo
|= WTextureSettings
;
1137 WMPostNotificationName(WNIconAppearanceSettingsChanged
, NULL
,
1138 (void *)(uintptr_t) foo
);
1140 if (needs_refresh
& REFRESH_ICON_TILE
)
1141 WMPostNotificationName(WNIconTileSettingsChanged
, NULL
, NULL
);
1145 void wDefaultUpdateIcons(WScreen
* scr
)
1147 WAppIcon
*aicon
= scr
->app_icon_list
;
1148 WWindow
*wwin
= scr
->focused_window
;
1152 file
= wDefaultGetIconFile(scr
, aicon
->wm_instance
, aicon
->wm_class
, False
);
1153 if ((file
&& aicon
->icon
->file
&& strcmp(file
, aicon
->icon
->file
) != 0)
1154 || (file
&& !aicon
->icon
->file
)) {
1155 wIconChangeImageFile(aicon
->icon
, file
);
1156 wAppIconPaint(aicon
);
1158 aicon
= aicon
->next
;
1161 if (!wPreferences
.flags
.noclip
)
1162 wClipIconPaint(scr
->clip_icon
);
1165 if (wwin
->icon
&& wwin
->flags
.miniaturized
) {
1166 file
= wDefaultGetIconFile(scr
, wwin
->wm_instance
, wwin
->wm_class
, False
);
1167 if ((file
&& wwin
->icon
->file
&& strcmp(file
, wwin
->icon
->file
) != 0)
1168 || (file
&& !wwin
->icon
->file
)) {
1169 wIconChangeImageFile(wwin
->icon
, file
);
1176 /* --------------------------- Local ----------------------- */
1178 #define GET_STRING_OR_DEFAULT(x, var) if (!WMIsPLString(value)) { \
1179 wwarning(_("Wrong option format for key \"%s\". Should be %s."), \
1181 wwarning(_("using default \"%s\" instead"), entry->default_value); \
1182 var = entry->default_value;\
1183 } else var = WMGetFromPLString(value)\
1186 static int string2index(WMPropList * key, WMPropList * val, char *def, WOptionEnumeration * values)
1189 WOptionEnumeration
*v
;
1190 char buffer
[TOTAL_VALUES_LENGTH
];
1192 if (WMIsPLString(val
) && (str
= WMGetFromPLString(val
))) {
1193 for (v
= values
; v
->string
!= NULL
; v
++) {
1194 if (strcasecmp(v
->string
, str
) == 0)
1200 for (v
= values
; v
->string
!= NULL
; v
++) {
1203 strcat(buffer
, ", ");
1204 snprintf(buffer
+strlen(buffer
),
1205 sizeof(buffer
)-strlen(buffer
)-1, "\"%s\"", v
->string
);
1208 wwarning(_("wrong option value for key \"%s\"; got \"%s\", should be one of %s."),
1209 WMGetFromPLString(key
),
1210 WMIsPLString(val
) ? WMGetFromPLString(val
) : "(unknown)",
1214 return string2index(key
, val
, NULL
, values
);
1221 * value - is the value in the defaults DB
1222 * addr - is the address to store the data
1223 * ret - is the address to store a pointer to a temporary buffer. ret
1224 * must not be freed and is used by the set functions
1226 static int getBool(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1230 int second_pass
= 0;
1232 GET_STRING_OR_DEFAULT("Boolean", val
);
1235 if ((val
[1] == '\0' && (val
[0] == 'y' || val
[0] == 'Y'))
1236 || strcasecmp(val
, "YES") == 0) {
1239 } else if ((val
[1] == '\0' && (val
[0] == 'n' || val
[0] == 'N'))
1240 || strcasecmp(val
, "NO") == 0) {
1244 if (sscanf(val
, "%i", &i
) == 1) {
1250 wwarning(_("can't convert \"%s\" to boolean for key \"%s\""), val
, entry
->key
);
1251 if (second_pass
== 0) {
1252 val
= WMGetFromPLString(entry
->plvalue
);
1254 wwarning(_("using default \"%s\" instead"), val
);
1264 *(char *)addr
= data
;
1269 static int getInt(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1274 GET_STRING_OR_DEFAULT("Integer", val
);
1276 if (sscanf(val
, "%i", &data
) != 1) {
1277 wwarning(_("can't convert \"%s\" to integer for key \"%s\""), val
, entry
->key
);
1278 val
= WMGetFromPLString(entry
->plvalue
);
1279 wwarning(_("using default \"%s\" instead"), val
);
1280 if (sscanf(val
, "%i", &data
) != 1) {
1288 *(int *)addr
= data
;
1293 static int getCoord(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1296 char *val_x
, *val_y
;
1297 int nelem
, changed
= 0;
1298 WMPropList
*elem_x
, *elem_y
;
1301 if (!WMIsPLArray(value
)) {
1302 wwarning(_("Wrong option format for key \"%s\". Should be %s."), entry
->key
, "Coordinate");
1304 value
= entry
->plvalue
;
1306 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1312 nelem
= WMGetPropListItemCount(value
);
1314 wwarning(_("Incorrect number of elements in array for key \"%s\"."), entry
->key
);
1316 value
= entry
->plvalue
;
1318 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1324 elem_x
= WMGetFromPLArray(value
, 0);
1325 elem_y
= WMGetFromPLArray(value
, 1);
1327 if (!elem_x
|| !elem_y
|| !WMIsPLString(elem_x
) || !WMIsPLString(elem_y
)) {
1328 wwarning(_("Wrong value for key \"%s\". Should be Coordinate."), entry
->key
);
1330 value
= entry
->plvalue
;
1332 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1338 val_x
= WMGetFromPLString(elem_x
);
1339 val_y
= WMGetFromPLString(elem_y
);
1341 if (sscanf(val_x
, "%i", &data
.x
) != 1 || sscanf(val_y
, "%i", &data
.y
) != 1) {
1342 wwarning(_("can't convert array to integers for \"%s\"."), entry
->key
);
1344 value
= entry
->plvalue
;
1346 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1354 else if (data
.x
> scr
->scr_width
/ 3)
1355 data
.x
= scr
->scr_width
/ 3;
1358 else if (data
.y
> scr
->scr_height
/ 3)
1359 data
.y
= scr
->scr_height
/ 3;
1364 *(WCoord
*) addr
= data
;
1369 static int getPropList(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1371 WMRetainPropList(value
);
1378 static int getPathList(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1387 if (!WMIsPLArray(value
)) {
1388 wwarning(_("Wrong option format for key \"%s\". Should be %s."), entry
->key
, "an array of paths");
1390 value
= entry
->plvalue
;
1392 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1399 count
= WMGetPropListItemCount(value
);
1402 value
= entry
->plvalue
;
1404 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1411 for (i
= 0; i
< count
; i
++) {
1412 d
= WMGetFromPLArray(value
, i
);
1413 if (!d
|| !WMIsPLString(d
)) {
1417 len
+= strlen(WMGetFromPLString(d
)) + 1;
1420 ptr
= data
= wmalloc(len
+ 1);
1422 for (i
= 0; i
< count
; i
++) {
1423 d
= WMGetFromPLArray(value
, i
);
1424 if (!d
|| !WMIsPLString(d
)) {
1427 strcpy(ptr
, WMGetFromPLString(d
));
1428 ptr
+= strlen(WMGetFromPLString(d
));
1435 if (*(char **)addr
!= NULL
) {
1436 wfree(*(char **)addr
);
1438 *(char **)addr
= data
;
1443 static int getEnum(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1445 static signed char data
;
1447 data
= string2index(entry
->plkey
, value
, entry
->default_value
, (WOptionEnumeration
*) entry
->extra_data
);
1454 *(signed char *)addr
= data
;
1461 * (hgradient <color> <color>)
1462 * (vgradient <color> <color>)
1463 * (dgradient <color> <color>)
1464 * (mhgradient <color> <color> ...)
1465 * (mvgradient <color> <color> ...)
1466 * (mdgradient <color> <color> ...)
1467 * (igradient <color1> <color1> <thickness1> <color2> <color2> <thickness2>)
1468 * (tpixmap <file> <color>)
1469 * (spixmap <file> <color>)
1470 * (cpixmap <file> <color>)
1471 * (thgradient <file> <opaqueness> <color> <color>)
1472 * (tvgradient <file> <opaqueness> <color> <color>)
1473 * (tdgradient <file> <opaqueness> <color> <color>)
1474 * (function <lib> <function> ...)
1477 static WTexture
*parse_texture(WScreen
* scr
, WMPropList
* pl
)
1482 WTexture
*texture
= NULL
;
1484 nelem
= WMGetPropListItemCount(pl
);
1488 elem
= WMGetFromPLArray(pl
, 0);
1489 if (!elem
|| !WMIsPLString(elem
))
1491 val
= WMGetFromPLString(elem
);
1493 if (strcasecmp(val
, "solid") == 0) {
1501 elem
= WMGetFromPLArray(pl
, 1);
1502 if (!elem
|| !WMIsPLString(elem
))
1504 val
= WMGetFromPLString(elem
);
1506 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &color
)) {
1507 wwarning(_("\"%s\" is not a valid color name"), val
);
1511 texture
= (WTexture
*) wTextureMakeSolid(scr
, &color
);
1512 } else if (strcasecmp(val
, "dgradient") == 0
1513 || strcasecmp(val
, "vgradient") == 0 || strcasecmp(val
, "hgradient") == 0) {
1514 RColor color1
, color2
;
1519 wwarning(_("bad number of arguments in gradient specification"));
1523 if (val
[0] == 'd' || val
[0] == 'D')
1524 type
= WTEX_DGRADIENT
;
1525 else if (val
[0] == 'h' || val
[0] == 'H')
1526 type
= WTEX_HGRADIENT
;
1528 type
= WTEX_VGRADIENT
;
1530 /* get from color */
1531 elem
= WMGetFromPLArray(pl
, 1);
1532 if (!elem
|| !WMIsPLString(elem
))
1534 val
= WMGetFromPLString(elem
);
1536 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1537 wwarning(_("\"%s\" is not a valid color name"), val
);
1541 color1
.red
= xcolor
.red
>> 8;
1542 color1
.green
= xcolor
.green
>> 8;
1543 color1
.blue
= xcolor
.blue
>> 8;
1546 elem
= WMGetFromPLArray(pl
, 2);
1547 if (!elem
|| !WMIsPLString(elem
)) {
1550 val
= WMGetFromPLString(elem
);
1552 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1553 wwarning(_("\"%s\" is not a valid color name"), val
);
1557 color2
.red
= xcolor
.red
>> 8;
1558 color2
.green
= xcolor
.green
>> 8;
1559 color2
.blue
= xcolor
.blue
>> 8;
1561 texture
= (WTexture
*) wTextureMakeGradient(scr
, type
, &color1
, &color2
);
1563 } else if (strcasecmp(val
, "igradient") == 0) {
1564 RColor colors1
[2], colors2
[2];
1570 wwarning(_("bad number of arguments in gradient specification"));
1574 /* get from color */
1575 for (i
= 0; i
< 2; i
++) {
1576 elem
= WMGetFromPLArray(pl
, 1 + i
);
1577 if (!elem
|| !WMIsPLString(elem
))
1579 val
= WMGetFromPLString(elem
);
1581 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1582 wwarning(_("\"%s\" is not a valid color name"), val
);
1585 colors1
[i
].alpha
= 255;
1586 colors1
[i
].red
= xcolor
.red
>> 8;
1587 colors1
[i
].green
= xcolor
.green
>> 8;
1588 colors1
[i
].blue
= xcolor
.blue
>> 8;
1590 elem
= WMGetFromPLArray(pl
, 3);
1591 if (!elem
|| !WMIsPLString(elem
))
1593 val
= WMGetFromPLString(elem
);
1596 /* get from color */
1597 for (i
= 0; i
< 2; i
++) {
1598 elem
= WMGetFromPLArray(pl
, 4 + i
);
1599 if (!elem
|| !WMIsPLString(elem
))
1601 val
= WMGetFromPLString(elem
);
1603 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1604 wwarning(_("\"%s\" is not a valid color name"), val
);
1607 colors2
[i
].alpha
= 255;
1608 colors2
[i
].red
= xcolor
.red
>> 8;
1609 colors2
[i
].green
= xcolor
.green
>> 8;
1610 colors2
[i
].blue
= xcolor
.blue
>> 8;
1612 elem
= WMGetFromPLArray(pl
, 6);
1613 if (!elem
|| !WMIsPLString(elem
))
1615 val
= WMGetFromPLString(elem
);
1618 texture
= (WTexture
*) wTextureMakeIGradient(scr
, th1
, colors1
, th2
, colors2
);
1620 } else if (strcasecmp(val
, "mhgradient") == 0
1621 || strcasecmp(val
, "mvgradient") == 0 || strcasecmp(val
, "mdgradient") == 0) {
1628 wwarning(_("too few arguments in multicolor gradient specification"));
1632 if (val
[1] == 'h' || val
[1] == 'H')
1633 type
= WTEX_MHGRADIENT
;
1634 else if (val
[1] == 'v' || val
[1] == 'V')
1635 type
= WTEX_MVGRADIENT
;
1637 type
= WTEX_MDGRADIENT
;
1641 colors
= wmalloc(sizeof(RColor
*) * (count
+ 1));
1643 for (i
= 0; i
< count
; i
++) {
1644 elem
= WMGetFromPLArray(pl
, i
+ 1);
1645 if (!elem
|| !WMIsPLString(elem
)) {
1646 for (--i
; i
>= 0; --i
) {
1652 val
= WMGetFromPLString(elem
);
1654 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &color
)) {
1655 wwarning(_("\"%s\" is not a valid color name"), val
);
1656 for (--i
; i
>= 0; --i
) {
1662 colors
[i
] = wmalloc(sizeof(RColor
));
1663 colors
[i
]->red
= color
.red
>> 8;
1664 colors
[i
]->green
= color
.green
>> 8;
1665 colors
[i
]->blue
= color
.blue
>> 8;
1670 texture
= (WTexture
*) wTextureMakeMGradient(scr
, type
, colors
);
1671 } else if (strcasecmp(val
, "spixmap") == 0 ||
1672 strcasecmp(val
, "cpixmap") == 0 || strcasecmp(val
, "tpixmap") == 0) {
1679 if (val
[0] == 's' || val
[0] == 'S')
1681 else if (val
[0] == 'c' || val
[0] == 'C')
1687 elem
= WMGetFromPLArray(pl
, 2);
1688 if (!elem
|| !WMIsPLString(elem
)) {
1691 val
= WMGetFromPLString(elem
);
1693 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &color
)) {
1694 wwarning(_("\"%s\" is not a valid color name"), val
);
1699 elem
= WMGetFromPLArray(pl
, 1);
1700 if (!elem
|| !WMIsPLString(elem
))
1702 val
= WMGetFromPLString(elem
);
1704 texture
= (WTexture
*) wTextureMakePixmap(scr
, type
, val
, &color
);
1705 } else if (strcasecmp(val
, "thgradient") == 0
1706 || strcasecmp(val
, "tvgradient") == 0 || strcasecmp(val
, "tdgradient") == 0) {
1707 RColor color1
, color2
;
1712 if (val
[1] == 'h' || val
[1] == 'H')
1713 style
= WTEX_THGRADIENT
;
1714 else if (val
[1] == 'v' || val
[1] == 'V')
1715 style
= WTEX_TVGRADIENT
;
1717 style
= WTEX_TDGRADIENT
;
1720 wwarning(_("bad number of arguments in textured gradient specification"));
1724 /* get from color */
1725 elem
= WMGetFromPLArray(pl
, 3);
1726 if (!elem
|| !WMIsPLString(elem
))
1728 val
= WMGetFromPLString(elem
);
1730 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1731 wwarning(_("\"%s\" is not a valid color name"), val
);
1735 color1
.red
= xcolor
.red
>> 8;
1736 color1
.green
= xcolor
.green
>> 8;
1737 color1
.blue
= xcolor
.blue
>> 8;
1740 elem
= WMGetFromPLArray(pl
, 4);
1741 if (!elem
|| !WMIsPLString(elem
)) {
1744 val
= WMGetFromPLString(elem
);
1746 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1747 wwarning(_("\"%s\" is not a valid color name"), val
);
1751 color2
.red
= xcolor
.red
>> 8;
1752 color2
.green
= xcolor
.green
>> 8;
1753 color2
.blue
= xcolor
.blue
>> 8;
1756 elem
= WMGetFromPLArray(pl
, 2);
1757 if (!elem
|| !WMIsPLString(elem
))
1760 val
= WMGetFromPLString(elem
);
1762 if (!val
|| (opacity
= atoi(val
)) < 0 || opacity
> 255) {
1763 wwarning(_("bad opacity value for tgradient texture \"%s\". Should be [0..255]"), val
);
1768 elem
= WMGetFromPLArray(pl
, 1);
1769 if (!elem
|| !WMIsPLString(elem
))
1771 val
= WMGetFromPLString(elem
);
1773 texture
= (WTexture
*) wTextureMakeTGradient(scr
, style
, &color1
, &color2
, val
, opacity
);
1774 } else if (strcasecmp(val
, "function") == 0) {
1775 /* Leave this in to handle the unlikely case of
1776 * someone actually having function textures configured */
1777 wwarning("function texture support has been removed");
1780 wwarning(_("invalid texture type %s"), val
);
1786 static int getTexture(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1788 static WTexture
*texture
;
1792 if (!WMIsPLArray(value
)) {
1793 wwarning(_("Wrong option format for key \"%s\". Should be %s."), entry
->key
, "Texture");
1795 value
= entry
->plvalue
;
1797 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1803 if (strcmp(entry
->key
, "WidgetColor") == 0 && !changed
) {
1806 pl
= WMGetFromPLArray(value
, 0);
1807 if (!pl
|| !WMIsPLString(pl
) || !WMGetFromPLString(pl
)
1808 || strcasecmp(WMGetFromPLString(pl
), "solid") != 0) {
1809 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1810 entry
->key
, "Solid Texture");
1812 value
= entry
->plvalue
;
1814 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1819 texture
= parse_texture(scr
, value
);
1822 wwarning(_("Error in texture specification for key \"%s\""), entry
->key
);
1824 value
= entry
->plvalue
;
1826 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1836 *(WTexture
**) addr
= texture
;
1841 static int getWSBackground(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1849 if (!WMIsPLArray(value
)) {
1850 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1851 "WorkspaceBack", "Texture or None");
1853 value
= entry
->plvalue
;
1855 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1861 /* only do basic error checking and verify for None texture */
1863 nelem
= WMGetPropListItemCount(value
);
1865 elem
= WMGetFromPLArray(value
, 0);
1866 if (!elem
|| !WMIsPLString(elem
)) {
1867 wwarning(_("Wrong type for workspace background. Should be a texture type."));
1869 value
= entry
->plvalue
;
1871 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1876 val
= WMGetFromPLString(elem
);
1878 if (strcasecmp(val
, "None") == 0)
1881 *ret
= WMRetainPropList(value
);
1887 getWSSpecificBackground(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1894 if (!WMIsPLArray(value
)) {
1895 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1896 "WorkspaceSpecificBack", "an array of textures");
1898 value
= entry
->plvalue
;
1900 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1906 /* only do basic error checking and verify for None texture */
1908 nelem
= WMGetPropListItemCount(value
);
1911 elem
= WMGetFromPLArray(value
, nelem
);
1912 if (!elem
|| !WMIsPLArray(elem
)) {
1913 wwarning(_("Wrong type for background of workspace %i. Should be a texture."),
1919 *ret
= WMRetainPropList(value
);
1923 * Kluge to force wmsetbg helper to set the default background.
1924 * If the WorkspaceSpecificBack is changed once wmaker has started,
1925 * the WorkspaceBack won't be sent to the helper, unless the user
1926 * changes it's value too. So, we must force this by removing the
1927 * value from the defaults DB.
1929 if (!scr
->flags
.backimage_helper_launched
&& !scr
->flags
.startup
) {
1930 WMPropList
*key
= WMCreatePLString("WorkspaceBack");
1932 WMRemoveFromPLDictionary(WDWindowMaker
->dictionary
, key
);
1934 WMReleasePropList(key
);
1940 static int getFont(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1942 static WMFont
*font
;
1945 GET_STRING_OR_DEFAULT("Font", val
);
1947 font
= WMCreateFont(scr
->wmscreen
, val
);
1949 font
= WMCreateFont(scr
->wmscreen
, "fixed");
1952 wfatal(_("could not load any usable font!!!"));
1959 /* can't assign font value outside update function */
1960 wassertrv(addr
== NULL
, True
);
1965 static int getColor(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1967 static XColor color
;
1969 int second_pass
= 0;
1971 GET_STRING_OR_DEFAULT("Color", val
);
1974 if (!wGetColor(scr
, val
, &color
)) {
1975 wwarning(_("could not get color for key \"%s\""), entry
->key
);
1976 if (second_pass
== 0) {
1977 val
= WMGetFromPLString(entry
->plvalue
);
1979 wwarning(_("using default \"%s\" instead"), val
);
1988 assert(addr
== NULL
);
1991 *(unsigned long*)addr = pixel;
1997 static int getKeybind(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1999 static WShortKey shortcut
;
2003 char buf
[MAX_SHORTCUT_LENGTH
], *b
;
2005 GET_STRING_OR_DEFAULT("Key spec", val
);
2007 if (!val
|| strcasecmp(val
, "NONE") == 0) {
2008 shortcut
.keycode
= 0;
2009 shortcut
.modifier
= 0;
2015 wstrlcpy(buf
, val
, MAX_SHORTCUT_LENGTH
);
2020 shortcut
.modifier
= 0;
2021 while ((k
= strchr(b
, '+')) != NULL
) {
2025 mod
= wXModifierFromKey(b
);
2027 wwarning(_("%s: invalid key modifier \"%s\""), entry
->key
, b
);
2030 shortcut
.modifier
|= mod
;
2036 ksym
= XStringToKeysym(b
);
2038 if (ksym
== NoSymbol
) {
2039 wwarning(_("%s:invalid kbd shortcut specification \"%s\""), entry
->key
, val
);
2043 shortcut
.keycode
= XKeysymToKeycode(dpy
, ksym
);
2044 if (shortcut
.keycode
== 0) {
2045 wwarning(_("%s:invalid key in shortcut \"%s\""), entry
->key
, val
);
2055 static int getModMask(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
2060 GET_STRING_OR_DEFAULT("Modifier Key", str
);
2065 mask
= wXModifierFromKey(str
);
2067 wwarning(_("%s: modifier key %s is not valid"), entry
->key
, str
);
2073 *(int *)addr
= mask
;
2081 # include <X11/cursorfont.h>
2087 #define CURSOR_ID_NONE (XC_num_glyphs)
2089 static WCursorLookup cursor_table
[] = {
2090 {"X_cursor", XC_X_cursor
},
2091 {"arrow", XC_arrow
},
2092 {"based_arrow_down", XC_based_arrow_down
},
2093 {"based_arrow_up", XC_based_arrow_up
},
2095 {"bogosity", XC_bogosity
},
2096 {"bottom_left_corner", XC_bottom_left_corner
},
2097 {"bottom_right_corner", XC_bottom_right_corner
},
2098 {"bottom_side", XC_bottom_side
},
2099 {"bottom_tee", XC_bottom_tee
},
2100 {"box_spiral", XC_box_spiral
},
2101 {"center_ptr", XC_center_ptr
},
2102 {"circle", XC_circle
},
2103 {"clock", XC_clock
},
2104 {"coffee_mug", XC_coffee_mug
},
2105 {"cross", XC_cross
},
2106 {"cross_reverse", XC_cross_reverse
},
2107 {"crosshair", XC_crosshair
},
2108 {"diamond_cross", XC_diamond_cross
},
2110 {"dotbox", XC_dotbox
},
2111 {"double_arrow", XC_double_arrow
},
2112 {"draft_large", XC_draft_large
},
2113 {"draft_small", XC_draft_small
},
2114 {"draped_box", XC_draped_box
},
2115 {"exchange", XC_exchange
},
2116 {"fleur", XC_fleur
},
2117 {"gobbler", XC_gobbler
},
2118 {"gumby", XC_gumby
},
2119 {"hand1", XC_hand1
},
2120 {"hand2", XC_hand2
},
2121 {"heart", XC_heart
},
2123 {"iron_cross", XC_iron_cross
},
2124 {"left_ptr", XC_left_ptr
},
2125 {"left_side", XC_left_side
},
2126 {"left_tee", XC_left_tee
},
2127 {"leftbutton", XC_leftbutton
},
2128 {"ll_angle", XC_ll_angle
},
2129 {"lr_angle", XC_lr_angle
},
2131 {"middlebutton", XC_middlebutton
},
2132 {"mouse", XC_mouse
},
2133 {"pencil", XC_pencil
},
2134 {"pirate", XC_pirate
},
2136 {"question_arrow", XC_question_arrow
},
2137 {"right_ptr", XC_right_ptr
},
2138 {"right_side", XC_right_side
},
2139 {"right_tee", XC_right_tee
},
2140 {"rightbutton", XC_rightbutton
},
2141 {"rtl_logo", XC_rtl_logo
},
2142 {"sailboat", XC_sailboat
},
2143 {"sb_down_arrow", XC_sb_down_arrow
},
2144 {"sb_h_double_arrow", XC_sb_h_double_arrow
},
2145 {"sb_left_arrow", XC_sb_left_arrow
},
2146 {"sb_right_arrow", XC_sb_right_arrow
},
2147 {"sb_up_arrow", XC_sb_up_arrow
},
2148 {"sb_v_double_arrow", XC_sb_v_double_arrow
},
2149 {"shuttle", XC_shuttle
},
2150 {"sizing", XC_sizing
},
2151 {"spider", XC_spider
},
2152 {"spraycan", XC_spraycan
},
2154 {"target", XC_target
},
2155 {"tcross", XC_tcross
},
2156 {"top_left_arrow", XC_top_left_arrow
},
2157 {"top_left_corner", XC_top_left_corner
},
2158 {"top_right_corner", XC_top_right_corner
},
2159 {"top_side", XC_top_side
},
2160 {"top_tee", XC_top_tee
},
2162 {"ul_angle", XC_ul_angle
},
2163 {"umbrella", XC_umbrella
},
2164 {"ur_angle", XC_ur_angle
},
2165 {"watch", XC_watch
},
2166 {"xterm", XC_xterm
},
2167 {NULL
, CURSOR_ID_NONE
}
2170 static void check_bitmap_status(int status
, char *filename
, Pixmap bitmap
)
2173 case BitmapOpenFailed
:
2174 wwarning(_("failed to open bitmap file \"%s\""), filename
);
2176 case BitmapFileInvalid
:
2177 wwarning(_("\"%s\" is not a valid bitmap file"), filename
);
2179 case BitmapNoMemory
:
2180 wwarning(_("out of memory reading bitmap file \"%s\""), filename
);
2183 XFreePixmap(dpy
, bitmap
);
2190 * (builtin, <cursor_name>)
2191 * (bitmap, <cursor_bitmap>, <cursor_mask>)
2193 static int parse_cursor(WScreen
* scr
, WMPropList
* pl
, Cursor
* cursor
)
2200 nelem
= WMGetPropListItemCount(pl
);
2204 elem
= WMGetFromPLArray(pl
, 0);
2205 if (!elem
|| !WMIsPLString(elem
)) {
2208 val
= WMGetFromPLString(elem
);
2210 if (strcasecmp(val
, "none") == 0) {
2213 } else if (strcasecmp(val
, "builtin") == 0) {
2215 int cursor_id
= CURSOR_ID_NONE
;
2218 wwarning(_("bad number of arguments in cursor specification"));
2221 elem
= WMGetFromPLArray(pl
, 1);
2222 if (!elem
|| !WMIsPLString(elem
)) {
2225 val
= WMGetFromPLString(elem
);
2227 for (i
= 0; cursor_table
[i
].name
!= NULL
; i
++) {
2228 if (strcasecmp(val
, cursor_table
[i
].name
) == 0) {
2229 cursor_id
= cursor_table
[i
].id
;
2233 if (CURSOR_ID_NONE
== cursor_id
) {
2234 wwarning(_("unknown builtin cursor name \"%s\""), val
);
2236 *cursor
= XCreateFontCursor(dpy
, cursor_id
);
2239 } else if (strcasecmp(val
, "bitmap") == 0) {
2251 wwarning(_("bad number of arguments in cursor specification"));
2254 elem
= WMGetFromPLArray(pl
, 1);
2255 if (!elem
|| !WMIsPLString(elem
)) {
2258 val
= WMGetFromPLString(elem
);
2259 bitmap_name
= FindImage(wPreferences
.pixmap_path
, val
);
2261 wwarning(_("could not find cursor bitmap file \"%s\""), val
);
2264 elem
= WMGetFromPLArray(pl
, 2);
2265 if (!elem
|| !WMIsPLString(elem
)) {
2269 val
= WMGetFromPLString(elem
);
2270 mask_name
= FindImage(wPreferences
.pixmap_path
, val
);
2273 wwarning(_("could not find cursor bitmap file \"%s\""), val
);
2276 mask_status
= XReadBitmapFile(dpy
, scr
->w_win
, mask_name
, &w
, &h
, &mask
, &x
, &y
);
2277 bitmap_status
= XReadBitmapFile(dpy
, scr
->w_win
, bitmap_name
, &w
, &h
, &bitmap
, &x
, &y
);
2278 if ((BitmapSuccess
== bitmap_status
) && (BitmapSuccess
== mask_status
)) {
2279 fg
.pixel
= scr
->black_pixel
;
2280 bg
.pixel
= scr
->white_pixel
;
2281 XQueryColor(dpy
, scr
->w_colormap
, &fg
);
2282 XQueryColor(dpy
, scr
->w_colormap
, &bg
);
2283 *cursor
= XCreatePixmapCursor(dpy
, bitmap
, mask
, &fg
, &bg
, x
, y
);
2286 check_bitmap_status(bitmap_status
, bitmap_name
, bitmap
);
2287 check_bitmap_status(mask_status
, mask_name
, mask
);
2294 static int getCursor(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
2296 static Cursor cursor
;
2301 if (!WMIsPLArray(value
)) {
2302 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
2303 entry
->key
, "cursor specification");
2305 value
= entry
->plvalue
;
2307 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
2312 status
= parse_cursor(scr
, value
, &cursor
);
2314 wwarning(_("Error in cursor specification for key \"%s\""), entry
->key
);
2316 value
= entry
->plvalue
;
2318 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
2327 *(Cursor
*) addr
= cursor
;
2332 #undef CURSOR_ID_NONE
2334 /* ---------------- value setting functions --------------- */
2335 static int setJustify(WScreen
* scr
, WDefaultEntry
* entry
, WTexture
** texture
, void *foo
)
2337 return REFRESH_WINDOW_TITLE_COLOR
;
2340 static int setClearance(WScreen
* scr
, WDefaultEntry
* entry
, void *bar
, void *foo
)
2342 return REFRESH_WINDOW_FONT
| REFRESH_BUTTON_IMAGES
| REFRESH_MENU_TITLE_FONT
| REFRESH_MENU_FONT
;
2345 static int setIfDockPresent(WScreen
* scr
, WDefaultEntry
* entry
, char *flag
, long which
)
2349 wPreferences
.flags
.nodock
= wPreferences
.flags
.nodock
|| *flag
;
2352 wPreferences
.flags
.noclip
= wPreferences
.flags
.noclip
|| *flag
;
2360 static int setStickyIcons(WScreen
* scr
, WDefaultEntry
* entry
, void *bar
, void *foo
)
2362 if (scr
->workspaces
) {
2363 wWorkspaceForceChange(scr
, scr
->current_workspace
);
2364 wArrangeIcons(scr
, False
);
2369 static int setIconTile(WScreen
* scr
, WDefaultEntry
* entry
, WTexture
** texture
, void *foo
)
2375 img
= wTextureRenderImage(*texture
, wPreferences
.icon_size
,
2376 wPreferences
.icon_size
, ((*texture
)->any
.type
& WREL_BORDER_MASK
)
2377 ? WREL_ICON
: WREL_FLAT
);
2379 wwarning(_("could not render texture for icon background"));
2381 wTextureDestroy(scr
, *texture
);
2384 RConvertImage(scr
->rcontext
, img
, &pixmap
);
2386 if (scr
->icon_tile
) {
2388 RReleaseImage(scr
->icon_tile
);
2389 XFreePixmap(dpy
, scr
->icon_tile_pixmap
);
2392 scr
->icon_tile
= img
;
2394 /* put the icon in the noticeboard hint */
2395 PropSetIconTileHint(scr
, img
);
2397 if (!wPreferences
.flags
.noclip
) {
2398 if (scr
->clip_tile
) {
2399 RReleaseImage(scr
->clip_tile
);
2401 scr
->clip_tile
= wClipMakeTile(scr
, img
);
2404 scr
->icon_tile_pixmap
= pixmap
;
2406 if (scr
->def_icon_pixmap
) {
2407 XFreePixmap(dpy
, scr
->def_icon_pixmap
);
2408 scr
->def_icon_pixmap
= None
;
2410 if (scr
->def_ticon_pixmap
) {
2411 XFreePixmap(dpy
, scr
->def_ticon_pixmap
);
2412 scr
->def_ticon_pixmap
= None
;
2415 if (scr
->icon_back_texture
) {
2416 wTextureDestroy(scr
, (WTexture
*) scr
->icon_back_texture
);
2418 scr
->icon_back_texture
= wTextureMakeSolid(scr
, &((*texture
)->any
.color
));
2420 if (scr
->clip_balloon
)
2421 XSetWindowBackground(dpy
, scr
->clip_balloon
, (*texture
)->any
.color
.pixel
);
2424 * Free the texture as nobody else will use it, nor refer to it.
2427 wTextureDestroy(scr
, *texture
);
2429 return (reset
? REFRESH_ICON_TILE
: 0);
2432 static int setWinTitleFont(WScreen
* scr
, WDefaultEntry
* entry
, WMFont
* font
, void *foo
)
2434 if (scr
->title_font
) {
2435 WMReleaseFont(scr
->title_font
);
2437 scr
->title_font
= font
;
2439 return REFRESH_WINDOW_FONT
| REFRESH_BUTTON_IMAGES
;
2442 static int setMenuTitleFont(WScreen
* scr
, WDefaultEntry
* entry
, WMFont
* font
, void *foo
)
2444 if (scr
->menu_title_font
) {
2445 WMReleaseFont(scr
->menu_title_font
);
2448 scr
->menu_title_font
= font
;
2450 return REFRESH_MENU_TITLE_FONT
;
2453 static int setMenuTextFont(WScreen
* scr
, WDefaultEntry
* entry
, WMFont
* font
, void *foo
)
2455 if (scr
->menu_entry_font
) {
2456 WMReleaseFont(scr
->menu_entry_font
);
2458 scr
->menu_entry_font
= font
;
2460 return REFRESH_MENU_FONT
;
2463 static int setIconTitleFont(WScreen
* scr
, WDefaultEntry
* entry
, WMFont
* font
, void *foo
)
2465 if (scr
->icon_title_font
) {
2466 WMReleaseFont(scr
->icon_title_font
);
2469 scr
->icon_title_font
= font
;
2471 return REFRESH_ICON_FONT
;
2474 static int setClipTitleFont(WScreen
* scr
, WDefaultEntry
* entry
, WMFont
* font
, void *foo
)
2476 if (scr
->clip_title_font
) {
2477 WMReleaseFont(scr
->clip_title_font
);
2480 scr
->clip_title_font
= font
;
2482 return REFRESH_ICON_FONT
;
2485 static int setLargeDisplayFont(WScreen
* scr
, WDefaultEntry
* entry
, WMFont
* font
, void *foo
)
2487 if (scr
->workspace_name_font
) {
2488 WMReleaseFont(scr
->workspace_name_font
);
2491 scr
->workspace_name_font
= font
;
2496 static int setHightlight(WScreen
* scr
, WDefaultEntry
* entry
, XColor
* color
, void *foo
)
2498 if (scr
->select_color
)
2499 WMReleaseColor(scr
->select_color
);
2501 scr
->select_color
= WMCreateRGBColor(scr
->wmscreen
, color
->red
, color
->green
, color
->blue
, True
);
2503 wFreeColor(scr
, color
->pixel
);
2505 return REFRESH_MENU_COLOR
;
2508 static int setHightlightText(WScreen
* scr
, WDefaultEntry
* entry
, XColor
* color
, void *foo
)
2510 if (scr
->select_text_color
)
2511 WMReleaseColor(scr
->select_text_color
);
2513 scr
->select_text_color
= WMCreateRGBColor(scr
->wmscreen
, color
->red
, color
->green
, color
->blue
, True
);
2515 wFreeColor(scr
, color
->pixel
);
2517 return REFRESH_MENU_COLOR
;
2520 static int setClipTitleColor(WScreen
* scr
, WDefaultEntry
* entry
, XColor
* color
, long widx
)
2522 if (scr
->clip_title_color
[widx
])
2523 WMReleaseColor(scr
->clip_title_color
[widx
]);
2525 scr
->clip_title_color
[widx
] = WMCreateRGBColor(scr
->wmscreen
, color
->red
, color
->green
, color
->blue
, True
);
2526 wFreeColor(scr
, color
->pixel
);
2528 return REFRESH_ICON_TITLE_COLOR
;
2531 static int setWTitleColor(WScreen
* scr
, WDefaultEntry
* entry
, XColor
* color
, long widx
)
2533 if (scr
->window_title_color
[widx
])
2534 WMReleaseColor(scr
->window_title_color
[widx
]);
2536 scr
->window_title_color
[widx
] =
2537 WMCreateRGBColor(scr
->wmscreen
, color
->red
, color
->green
, color
->blue
, True
);
2539 wFreeColor(scr
, color
->pixel
);
2541 return REFRESH_WINDOW_TITLE_COLOR
;
2544 static int setMenuTitleColor(WScreen
* scr
, WDefaultEntry
* entry
, XColor
* color
, long widx
)
2546 if (scr
->menu_title_color
[0])
2547 WMReleaseColor(scr
->menu_title_color
[0]);
2549 scr
->menu_title_color
[0] = WMCreateRGBColor(scr
->wmscreen
, color
->red
, color
->green
, color
->blue
, True
);
2551 wFreeColor(scr
, color
->pixel
);
2553 return REFRESH_MENU_TITLE_COLOR
;
2556 static int setMenuTextColor(WScreen
* scr
, WDefaultEntry
* entry
, XColor
* color
, void *foo
)
2558 if (scr
->mtext_color
)
2559 WMReleaseColor(scr
->mtext_color
);
2561 scr
->mtext_color
= WMCreateRGBColor(scr
->wmscreen
, color
->red
, color
->green
, color
->blue
, True
);
2563 if (WMColorPixel(scr
->dtext_color
) == WMColorPixel(scr
->mtext_color
)) {
2564 WMSetColorAlpha(scr
->dtext_color
, 0x7fff);
2566 WMSetColorAlpha(scr
->dtext_color
, 0xffff);
2569 wFreeColor(scr
, color
->pixel
);
2571 return REFRESH_MENU_COLOR
;
2574 static int setMenuDisabledColor(WScreen
* scr
, WDefaultEntry
* entry
, XColor
* color
, void *foo
)
2576 if (scr
->dtext_color
)
2577 WMReleaseColor(scr
->dtext_color
);
2579 scr
->dtext_color
= WMCreateRGBColor(scr
->wmscreen
, color
->red
, color
->green
, color
->blue
, True
);
2581 if (WMColorPixel(scr
->dtext_color
) == WMColorPixel(scr
->mtext_color
)) {
2582 WMSetColorAlpha(scr
->dtext_color
, 0x7fff);
2584 WMSetColorAlpha(scr
->dtext_color
, 0xffff);
2587 wFreeColor(scr
, color
->pixel
);
2589 return REFRESH_MENU_COLOR
;
2592 static int setIconTitleColor(WScreen
* scr
, WDefaultEntry
* entry
, XColor
* color
, void *foo
)
2594 if (scr
->icon_title_color
)
2595 WMReleaseColor(scr
->icon_title_color
);
2596 scr
->icon_title_color
= WMCreateRGBColor(scr
->wmscreen
, color
->red
, color
->green
, color
->blue
, True
);
2598 wFreeColor(scr
, color
->pixel
);
2600 return REFRESH_ICON_TITLE_COLOR
;
2603 static int setIconTitleBack(WScreen
* scr
, WDefaultEntry
* entry
, XColor
* color
, void *foo
)
2605 if (scr
->icon_title_texture
) {
2606 wTextureDestroy(scr
, (WTexture
*) scr
->icon_title_texture
);
2608 scr
->icon_title_texture
= wTextureMakeSolid(scr
, color
);
2610 return REFRESH_ICON_TITLE_BACK
;
2613 static void trackDeadProcess(pid_t pid
, unsigned char status
, WScreen
* scr
)
2615 close(scr
->helper_fd
);
2617 scr
->helper_pid
= 0;
2618 scr
->flags
.backimage_helper_launched
= 0;
2621 static int setWorkspaceSpecificBack(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *bar
)
2627 if (scr
->flags
.backimage_helper_launched
) {
2628 if (WMGetPropListItemCount(value
) == 0) {
2629 SendHelperMessage(scr
, 'C', 0, NULL
);
2630 SendHelperMessage(scr
, 'K', 0, NULL
);
2632 WMReleasePropList(value
);
2639 if (WMGetPropListItemCount(value
) == 0)
2642 if (pipe(filedes
) < 0) {
2643 werror("pipe() failed:can't set workspace specific background image");
2645 WMReleasePropList(value
);
2651 werror("fork() failed:can't set workspace specific background image");
2652 if (close(filedes
[0]) < 0)
2653 werror("could not close pipe");
2654 if (close(filedes
[1]) < 0)
2655 werror("could not close pipe");
2657 } else if (pid
== 0) {
2660 SetupEnvironment(scr
);
2663 werror("could not close pipe");
2664 if (dup(filedes
[0]) < 0) {
2665 werror("dup() failed:can't set workspace specific background image");
2667 dither
= wPreferences
.no_dithering
? "-m" : "-d";
2668 if (wPreferences
.smooth_workspace_back
)
2669 execlp("wmsetbg", "wmsetbg", "-helper", "-S", dither
, NULL
);
2671 execlp("wmsetbg", "wmsetbg", "-helper", dither
, NULL
);
2672 werror("could not execute wmsetbg");
2676 if (fcntl(filedes
[0], F_SETFD
, FD_CLOEXEC
) < 0) {
2677 werror("error setting close-on-exec flag");
2679 if (fcntl(filedes
[1], F_SETFD
, FD_CLOEXEC
) < 0) {
2680 werror("error setting close-on-exec flag");
2683 scr
->helper_fd
= filedes
[1];
2684 scr
->helper_pid
= pid
;
2685 scr
->flags
.backimage_helper_launched
= 1;
2687 wAddDeathHandler(pid
, (WDeathHandler
*) trackDeadProcess
, scr
);
2689 SendHelperMessage(scr
, 'P', -1, wPreferences
.pixmap_path
);
2694 for (i
= 0; i
< WMGetPropListItemCount(value
); i
++) {
2695 val
= WMGetFromPLArray(value
, i
);
2696 if (val
&& WMIsPLArray(val
) && WMGetPropListItemCount(val
) > 0) {
2697 str
= WMGetPropListDescription(val
, False
);
2699 SendHelperMessage(scr
, 'S', i
+ 1, str
);
2703 SendHelperMessage(scr
, 'U', i
+ 1, NULL
);
2708 WMReleasePropList(value
);
2712 static int setWorkspaceBack(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *bar
)
2714 if (scr
->flags
.backimage_helper_launched
) {
2717 if (WMGetPropListItemCount(value
) == 0) {
2718 SendHelperMessage(scr
, 'U', 0, NULL
);
2720 /* set the default workspace background to this one */
2721 str
= WMGetPropListDescription(value
, False
);
2723 SendHelperMessage(scr
, 'S', 0, str
);
2725 SendHelperMessage(scr
, 'C', scr
->current_workspace
+ 1, NULL
);
2727 SendHelperMessage(scr
, 'U', 0, NULL
);
2730 } else if (WMGetPropListItemCount(value
) > 0) {
2736 text
= WMGetPropListDescription(value
, False
);
2737 len
= strlen(text
) + 40;
2738 command
= wmalloc(len
);
2739 dither
= wPreferences
.no_dithering
? "-m" : "-d";
2740 if (wPreferences
.smooth_workspace_back
)
2741 snprintf(command
, len
, "wmsetbg %s -S -p '%s' &", dither
, text
);
2743 snprintf(command
, len
, "wmsetbg %s -p '%s' &", dither
, text
);
2745 ExecuteShellCommand(scr
, command
);
2748 WMReleasePropList(value
);
2753 static int setWidgetColor(WScreen
* scr
, WDefaultEntry
* entry
, WTexture
** texture
, void *foo
)
2755 if (scr
->widget_texture
) {
2756 wTextureDestroy(scr
, (WTexture
*) scr
->widget_texture
);
2758 scr
->widget_texture
= *(WTexSolid
**) texture
;
2763 static int setFTitleBack(WScreen
* scr
, WDefaultEntry
* entry
, WTexture
** texture
, void *foo
)
2765 if (scr
->window_title_texture
[WS_FOCUSED
]) {
2766 wTextureDestroy(scr
, scr
->window_title_texture
[WS_FOCUSED
]);
2768 scr
->window_title_texture
[WS_FOCUSED
] = *texture
;
2770 return REFRESH_WINDOW_TEXTURES
;
2773 static int setPTitleBack(WScreen
* scr
, WDefaultEntry
* entry
, WTexture
** texture
, void *foo
)
2775 if (scr
->window_title_texture
[WS_PFOCUSED
]) {
2776 wTextureDestroy(scr
, scr
->window_title_texture
[WS_PFOCUSED
]);
2778 scr
->window_title_texture
[WS_PFOCUSED
] = *texture
;
2780 return REFRESH_WINDOW_TEXTURES
;
2783 static int setUTitleBack(WScreen
* scr
, WDefaultEntry
* entry
, WTexture
** texture
, void *foo
)
2785 if (scr
->window_title_texture
[WS_UNFOCUSED
]) {
2786 wTextureDestroy(scr
, scr
->window_title_texture
[WS_UNFOCUSED
]);
2788 scr
->window_title_texture
[WS_UNFOCUSED
] = *texture
;
2790 return REFRESH_WINDOW_TEXTURES
;
2793 static int setResizebarBack(WScreen
* scr
, WDefaultEntry
* entry
, WTexture
** texture
, void *foo
)
2795 if (scr
->resizebar_texture
[0]) {
2796 wTextureDestroy(scr
, scr
->resizebar_texture
[0]);
2798 scr
->resizebar_texture
[0] = *texture
;
2800 return REFRESH_WINDOW_TEXTURES
;
2803 static int setMenuTitleBack(WScreen
* scr
, WDefaultEntry
* entry
, WTexture
** texture
, void *foo
)
2805 if (scr
->menu_title_texture
[0]) {
2806 wTextureDestroy(scr
, scr
->menu_title_texture
[0]);
2808 scr
->menu_title_texture
[0] = *texture
;
2810 return REFRESH_MENU_TITLE_TEXTURE
;
2813 static int setMenuTextBack(WScreen
* scr
, WDefaultEntry
* entry
, WTexture
** texture
, void *foo
)
2815 if (scr
->menu_item_texture
) {
2816 wTextureDestroy(scr
, scr
->menu_item_texture
);
2817 wTextureDestroy(scr
, (WTexture
*) scr
->menu_item_auxtexture
);
2819 scr
->menu_item_texture
= *texture
;
2821 scr
->menu_item_auxtexture
= wTextureMakeSolid(scr
, &scr
->menu_item_texture
->any
.color
);
2823 return REFRESH_MENU_TEXTURE
;
2826 static int setKeyGrab(WScreen
* scr
, WDefaultEntry
* entry
, WShortKey
* shortcut
, long widx
)
2829 wKeyBindings
[widx
] = *shortcut
;
2831 wwin
= scr
->focused_window
;
2833 while (wwin
!= NULL
) {
2834 XUngrabKey(dpy
, AnyKey
, AnyModifier
, wwin
->frame
->core
->window
);
2836 if (!WFLAGP(wwin
, no_bind_keys
)) {
2837 wWindowSetKeyGrabs(wwin
);
2845 static int setIconPosition(WScreen
* scr
, WDefaultEntry
* entry
, void *bar
, void *foo
)
2847 wScreenUpdateUsableArea(scr
);
2848 wArrangeIcons(scr
, True
);
2853 static int updateUsableArea(WScreen
* scr
, WDefaultEntry
* entry
, void *bar
, void *foo
)
2855 wScreenUpdateUsableArea(scr
);
2860 static int setMenuStyle(WScreen
* scr
, WDefaultEntry
* entry
, int *value
, void *foo
)
2862 return REFRESH_MENU_TEXTURE
;
2865 static RImage
*chopOffImage(RImage
* image
, int x
, int y
, int w
, int h
)
2867 RImage
*img
= RCreateImage(w
, h
, image
->format
== RRGBAFormat
);
2869 RCopyArea(img
, image
, x
, y
, w
, h
, 0, 0);
2874 static int setSwPOptions(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* array
, void *foo
)
2878 int cwidth
, cheight
;
2879 WPreferences
*prefs
= (WPreferences
*) foo
;
2881 if (!WMIsPLArray(array
) || WMGetPropListItemCount(array
) == 0) {
2882 if (prefs
->swtileImage
)
2883 RReleaseImage(prefs
->swtileImage
);
2884 prefs
->swtileImage
= NULL
;
2886 WMReleasePropList(array
);
2890 switch (WMGetPropListItemCount(array
)) {
2892 if (!WMIsPLString(WMGetFromPLArray(array
, 1))) {
2893 wwarning(_("Invalid arguments for option \"%s\""), entry
->key
);
2896 path
= FindImage(wPreferences
.pixmap_path
, WMGetFromPLString(WMGetFromPLArray(array
, 1)));
2899 wwarning(_("Could not find image \"%s\" for option \"%s\""),
2900 WMGetFromPLString(WMGetFromPLArray(array
, 1)), entry
->key
);
2902 bgimage
= RLoadImage(scr
->rcontext
, path
, 0);
2904 wwarning(_("Could not load image \"%s\" for option \"%s\""), path
, entry
->key
);
2909 cwidth
= atoi(WMGetFromPLString(WMGetFromPLArray(array
, 2)));
2910 cheight
= atoi(WMGetFromPLString(WMGetFromPLArray(array
, 3)));
2912 if (cwidth
<= 0 || cheight
<= 0 ||
2913 cwidth
>= bgimage
->width
- 2 || cheight
>= bgimage
->height
- 2)
2914 wwarning(_("Invalid split sizes for SwitchPanel back image."));
2917 int swidth
, theight
;
2918 for (i
= 0; i
< 9; i
++) {
2919 if (prefs
->swbackImage
[i
])
2920 RReleaseImage(prefs
->swbackImage
[i
]);
2921 prefs
->swbackImage
[i
] = NULL
;
2923 swidth
= (bgimage
->width
- cwidth
) / 2;
2924 theight
= (bgimage
->height
- cheight
) / 2;
2926 prefs
->swbackImage
[0] = chopOffImage(bgimage
, 0, 0, swidth
, theight
);
2927 prefs
->swbackImage
[1] = chopOffImage(bgimage
, swidth
, 0, cwidth
, theight
);
2928 prefs
->swbackImage
[2] = chopOffImage(bgimage
, swidth
+ cwidth
, 0,
2931 prefs
->swbackImage
[3] = chopOffImage(bgimage
, 0, theight
, swidth
, cheight
);
2932 prefs
->swbackImage
[4] = chopOffImage(bgimage
, swidth
, theight
,
2934 prefs
->swbackImage
[5] = chopOffImage(bgimage
, swidth
+ cwidth
, theight
,
2937 prefs
->swbackImage
[6] = chopOffImage(bgimage
, 0, theight
+ cheight
,
2939 prefs
->swbackImage
[7] = chopOffImage(bgimage
, swidth
, theight
+ cheight
,
2941 prefs
->swbackImage
[8] =
2942 chopOffImage(bgimage
, swidth
+ cwidth
, theight
+ cheight
, swidth
,
2945 // check if anything failed
2946 for (i
= 0; i
< 9; i
++) {
2947 if (!prefs
->swbackImage
[i
]) {
2948 for (; i
>= 0; --i
) {
2949 RReleaseImage(prefs
->swbackImage
[i
]);
2950 prefs
->swbackImage
[i
] = NULL
;
2956 RReleaseImage(bgimage
);
2961 if (!WMIsPLString(WMGetFromPLArray(array
, 0))) {
2962 wwarning(_("Invalid arguments for option \"%s\""), entry
->key
);
2965 path
= FindImage(wPreferences
.pixmap_path
, WMGetFromPLString(WMGetFromPLArray(array
, 0)));
2968 wwarning(_("Could not find image \"%s\" for option \"%s\""),
2969 WMGetFromPLString(WMGetFromPLArray(array
, 0)), entry
->key
);
2971 if (prefs
->swtileImage
)
2972 RReleaseImage(prefs
->swtileImage
);
2974 prefs
->swtileImage
= RLoadImage(scr
->rcontext
, path
, 0);
2975 if (!prefs
->swtileImage
) {
2976 wwarning(_("Could not load image \"%s\" for option \"%s\""), path
, entry
->key
);
2983 wwarning(_("Invalid number of arguments for option \"%s\""), entry
->key
);
2987 WMReleasePropList(array
);
2992 static int setModifierKeyLabels(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* array
, void *foo
)
2995 WPreferences
*prefs
= (WPreferences
*) foo
;
2997 if (!WMIsPLArray(array
) || WMGetPropListItemCount(array
) != 7) {
2998 wwarning(_("Value for option \"%s\" must be an array of 7 strings"), entry
->key
);
2999 WMReleasePropList(array
);
3003 DestroyWindowMenu(scr
);
3005 for (i
= 0; i
< 7; i
++) {
3006 if (prefs
->modifier_labels
[i
])
3007 wfree(prefs
->modifier_labels
[i
]);
3009 if (WMIsPLString(WMGetFromPLArray(array
, i
))) {
3010 prefs
->modifier_labels
[i
] = wstrdup(WMGetFromPLString(WMGetFromPLArray(array
, i
)));
3012 wwarning(_("Invalid argument for option \"%s\" item %d"), entry
->key
, i
);
3013 prefs
->modifier_labels
[i
] = NULL
;
3017 WMReleasePropList(array
);
3024 * Need access to the double click variables, so that all widgets in
3025 * wmaker panels will have the same dbl-click values.
3026 * TODO: figure a better way of dealing with it.
3028 #include <WINGs/WINGsP.h>
3030 static int setDoubleClick(WScreen
* scr
, WDefaultEntry
* entry
, int *value
, void *foo
)
3032 extern _WINGsConfiguration WINGsConfiguration
;
3037 WINGsConfiguration
.doubleClickDelay
= *value
;
3042 static int setCursor(WScreen
* scr
, WDefaultEntry
* entry
, Cursor
* cursor
, long widx
)
3044 if (wCursor
[widx
] != None
) {
3045 XFreeCursor(dpy
, wCursor
[widx
]);
3048 wCursor
[widx
] = *cursor
;
3050 if (widx
== WCUR_ROOT
&& *cursor
!= None
) {
3051 XDefineCursor(dpy
, scr
->root_win
, *cursor
);