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},
207 {"Center", WPM_CENTER
, 0},
211 static WOptionEnumeration seGeomDisplays
[] = {
212 {"None", WDIS_NONE
, 0},
213 {"Center", WDIS_CENTER
, 0},
214 {"Corner", WDIS_TOPLEFT
, 0},
215 {"Floating", WDIS_FRAME_CENTER
, 0},
216 {"Line", WDIS_NEW
, 0},
220 static WOptionEnumeration seSpeeds
[] = {
221 {"UltraFast", SPEED_ULTRAFAST
, 0},
222 {"Fast", SPEED_FAST
, 0},
223 {"Medium", SPEED_MEDIUM
, 0},
224 {"Slow", SPEED_SLOW
, 0},
225 {"UltraSlow", SPEED_ULTRASLOW
, 0},
229 static WOptionEnumeration seMouseButtonActions
[] = {
230 {"None", WA_NONE
, 0},
231 {"SelectWindows", WA_SELECT_WINDOWS
, 0},
232 {"OpenApplicationsMenu", WA_OPEN_APPMENU
, 0},
233 {"OpenWindowListMenu", WA_OPEN_WINLISTMENU
, 0},
237 static WOptionEnumeration seMouseWheelActions
[] = {
238 {"None", WA_NONE
, 0},
239 {"SwitchWorkspaces", WA_SWITCH_WORKSPACES
, 0},
243 static WOptionEnumeration seIconificationStyles
[] = {
244 {"Zoom", WIS_ZOOM
, 0},
245 {"Twist", WIS_TWIST
, 0},
246 {"Flip", WIS_FLIP
, 0},
247 {"None", WIS_NONE
, 0},
248 {"random", WIS_RANDOM
, 0},
252 static WOptionEnumeration seJustifications
[] = {
253 {"Left", WTJ_LEFT
, 0},
254 {"Center", WTJ_CENTER
, 0},
255 {"Right", WTJ_RIGHT
, 0},
259 static WOptionEnumeration seIconPositions
[] = {
260 {"blv", IY_BOTTOM
| IY_LEFT
| IY_VERT
, 0},
261 {"blh", IY_BOTTOM
| IY_LEFT
| IY_HORIZ
, 0},
262 {"brv", IY_BOTTOM
| IY_RIGHT
| IY_VERT
, 0},
263 {"brh", IY_BOTTOM
| IY_RIGHT
| IY_HORIZ
, 0},
264 {"tlv", IY_TOP
| IY_LEFT
| IY_VERT
, 0},
265 {"tlh", IY_TOP
| IY_LEFT
| IY_HORIZ
, 0},
266 {"trv", IY_TOP
| IY_RIGHT
| IY_VERT
, 0},
267 {"trh", IY_TOP
| IY_RIGHT
| IY_HORIZ
, 0},
271 static WOptionEnumeration seMenuStyles
[] = {
272 {"normal", MS_NORMAL
, 0},
273 {"singletexture", MS_SINGLE_TEXTURE
, 0},
274 {"flat", MS_FLAT
, 0},
278 static WOptionEnumeration seDisplayPositions
[] = {
279 {"none", WD_NONE
, 0},
280 {"center", WD_CENTER
, 0},
282 {"bottom", WD_BOTTOM
, 0},
283 {"topleft", WD_TOPLEFT
, 0},
284 {"topright", WD_TOPRIGHT
, 0},
285 {"bottomleft", WD_BOTTOMLEFT
, 0},
286 {"bottomright", WD_BOTTOMRIGHT
, 0},
290 static WOptionEnumeration seWorkspaceBorder
[] = {
291 {"None", WB_NONE
, 0},
292 {"LeftRight", WB_LEFTRIGHT
, 0},
293 {"TopBottom", WB_TOPBOTTOM
, 0},
294 {"AllDirections", WB_ALLDIRS
, 0},
299 * ALL entries in the tables bellow, NEED to have a default value
300 * defined, and this value needs to be correct.
303 /* these options will only affect the window manager on startup
305 * static defaults can't access the screen data, because it is
306 * created after these defaults are read
308 WDefaultEntry staticOptionList
[] = {
310 {"ColormapSize", "4", NULL
,
311 &wPreferences
.cmap_size
, getInt
, NULL
, NULL
, NULL
},
312 {"DisableDithering", "NO", NULL
,
313 &wPreferences
.no_dithering
, getBool
, NULL
, NULL
, NULL
},
314 {"IconSize", "64", NULL
,
315 &wPreferences
.icon_size
, getInt
, NULL
, NULL
, NULL
},
316 {"ModifierKey", "Mod1", NULL
,
317 &wPreferences
.modifier_mask
, getModMask
, NULL
, NULL
, NULL
},
318 {"DisableWSMouseActions", "NO", NULL
,
319 &wPreferences
.disable_root_mouse
, getBool
, NULL
, NULL
, NULL
},
320 {"FocusMode", "manual", seFocusModes
, /* have a problem when switching from */
321 &wPreferences
.focus_mode
, getEnum
, NULL
, NULL
, NULL
}, /* manual to sloppy without restart */
322 {"NewStyle", "new", seTitlebarModes
,
323 &wPreferences
.new_style
, getEnum
, NULL
, NULL
, NULL
},
324 {"DisableDock", "NO", (void *)WM_DOCK
,
325 NULL
, getBool
, setIfDockPresent
, NULL
, NULL
},
326 {"DisableClip", "NO", (void *)WM_CLIP
,
327 NULL
, getBool
, setIfDockPresent
, NULL
, NULL
},
328 {"DisableMiniwindows", "NO", NULL
,
329 &wPreferences
.disable_miniwindows
, getBool
, NULL
, NULL
, NULL
}
332 #define NUM2STRING_(x) #x
333 #define NUM2STRING(x) NUM2STRING_(x)
335 WDefaultEntry optionList
[] = {
337 /* dynamic options */
339 {"IconPosition", "blh", seIconPositions
,
340 &wPreferences
.icon_yard
, getEnum
, setIconPosition
, NULL
, NULL
},
341 {"IconificationStyle", "Zoom", seIconificationStyles
,
342 &wPreferences
.iconification_style
, getEnum
, NULL
, NULL
, NULL
},
343 {"MouseLeftButtonAction", "SelectWindows", seMouseButtonActions
,
344 &wPreferences
.mouse_button1
, getEnum
, NULL
, NULL
, NULL
},
345 {"MouseMiddleButtonAction", "OpenWindowListMenu", seMouseButtonActions
,
346 &wPreferences
.mouse_button2
, getEnum
, NULL
, NULL
, NULL
},
347 {"MouseRightButtonAction", "OpenApplicationsMenu", seMouseButtonActions
,
348 &wPreferences
.mouse_button3
, getEnum
, NULL
, NULL
, NULL
},
349 {"MouseWheelAction", "None", seMouseWheelActions
,
350 &wPreferences
.mouse_wheel
, getEnum
, NULL
, NULL
, NULL
},
351 {"PixmapPath", DEF_PIXMAP_PATHS
, NULL
,
352 &wPreferences
.pixmap_path
, getPathList
, NULL
, NULL
, NULL
},
353 {"IconPath", DEF_ICON_PATHS
, NULL
,
354 &wPreferences
.icon_path
, getPathList
, NULL
, NULL
, NULL
},
355 {"ColormapMode", "auto", seColormapModes
,
356 &wPreferences
.colormap_mode
, getEnum
, NULL
, NULL
, NULL
},
357 {"AutoFocus", "NO", NULL
,
358 &wPreferences
.auto_focus
, getBool
, NULL
, NULL
, NULL
},
359 {"RaiseDelay", "0", NULL
,
360 &wPreferences
.raise_delay
, getInt
, NULL
, NULL
, NULL
},
361 {"CirculateRaise", "NO", NULL
,
362 &wPreferences
.circ_raise
, getBool
, NULL
, NULL
, NULL
},
363 {"Superfluous", "NO", NULL
,
364 &wPreferences
.superfluous
, getBool
, NULL
, NULL
, NULL
},
365 {"AdvanceToNewWorkspace", "NO", NULL
,
366 &wPreferences
.ws_advance
, getBool
, NULL
, NULL
, NULL
},
367 {"CycleWorkspaces", "NO", NULL
,
368 &wPreferences
.ws_cycle
, getBool
, NULL
, NULL
, NULL
},
369 {"WorkspaceNameDisplayPosition", "center", seDisplayPositions
,
370 &wPreferences
.workspace_name_display_position
, getEnum
, NULL
, NULL
, NULL
},
371 {"WorkspaceBorder", "None", seWorkspaceBorder
,
372 &wPreferences
.workspace_border_position
, getEnum
, updateUsableArea
, NULL
, NULL
},
373 {"WorkspaceBorderSize", "0", NULL
,
374 &wPreferences
.workspace_border_size
, getInt
, updateUsableArea
, NULL
, NULL
},
375 {"StickyIcons", "NO", NULL
,
376 &wPreferences
.sticky_icons
, getBool
, setStickyIcons
, NULL
, NULL
},
377 {"SaveSessionOnExit", "NO", NULL
,
378 &wPreferences
.save_session_on_exit
, getBool
, NULL
, NULL
, NULL
},
379 {"WrapMenus", "NO", NULL
,
380 &wPreferences
.wrap_menus
, getBool
, NULL
, NULL
, NULL
},
381 {"ScrollableMenus", "NO", NULL
,
382 &wPreferences
.scrollable_menus
, getBool
, NULL
, NULL
, NULL
},
383 {"MenuScrollSpeed", "medium", seSpeeds
,
384 &wPreferences
.menu_scroll_speed
, getEnum
, NULL
, NULL
, NULL
},
385 {"IconSlideSpeed", "medium", seSpeeds
,
386 &wPreferences
.icon_slide_speed
, getEnum
, NULL
, NULL
, NULL
},
387 {"ShadeSpeed", "medium", seSpeeds
,
388 &wPreferences
.shade_speed
, getEnum
, NULL
, NULL
, NULL
},
389 {"BounceAppIconsWhenUrgent", "YES", NULL
,
390 &wPreferences
.bounce_appicons_when_urgent
, getBool
, NULL
, NULL
, NULL
},
391 {"RaiseAppIconsWhenBouncing", "NO", NULL
,
392 &wPreferences
.raise_appicons_when_bouncing
, getBool
, NULL
, NULL
, NULL
},
393 {"DoNotMakeAppIconsBounce", "NO", NULL
,
394 &wPreferences
.do_not_make_appicons_bounce
, getBool
, NULL
, NULL
, NULL
},
395 {"DoubleClickTime", "250", (void *)&wPreferences
.dblclick_time
,
396 &wPreferences
.dblclick_time
, getInt
, setDoubleClick
, NULL
, NULL
},
397 {"AlignSubmenus", "NO", NULL
,
398 &wPreferences
.align_menus
, getBool
, NULL
, NULL
, NULL
},
399 {"ViKeyMenus", "NO", NULL
,
400 &wPreferences
.vi_key_menus
, getBool
, NULL
, NULL
, NULL
},
401 {"OpenTransientOnOwnerWorkspace", "NO", NULL
,
402 &wPreferences
.open_transients_with_parent
, getBool
, NULL
, NULL
, NULL
},
403 {"WindowPlacement", "auto", sePlacements
,
404 &wPreferences
.window_placement
, getEnum
, NULL
, NULL
, NULL
},
405 {"IgnoreFocusClick", "NO", NULL
,
406 &wPreferences
.ignore_focus_click
, getBool
, NULL
, NULL
, NULL
},
407 {"UseSaveUnders", "NO", NULL
,
408 &wPreferences
.use_saveunders
, getBool
, NULL
, NULL
, NULL
},
409 {"OpaqueMove", "NO", NULL
,
410 &wPreferences
.opaque_move
, getBool
, NULL
, NULL
, NULL
},
411 {"OpaqueResize", "NO", NULL
,
412 &wPreferences
.opaque_resize
, getBool
, NULL
, NULL
, NULL
},
413 {"OpaqueMoveResizeKeyboard", "NO", NULL
,
414 &wPreferences
.opaque_move_resize_keyboard
, getBool
, NULL
, NULL
, NULL
},
415 {"DisableAnimations", "NO", NULL
,
416 &wPreferences
.no_animations
, getBool
, NULL
, NULL
, NULL
},
417 {"DontLinkWorkspaces", "NO", NULL
,
418 &wPreferences
.no_autowrap
, getBool
, NULL
, NULL
, NULL
},
419 {"AutoArrangeIcons", "NO", NULL
,
420 &wPreferences
.auto_arrange_icons
, getBool
, NULL
, NULL
, NULL
},
421 {"NoWindowOverDock", "NO", NULL
,
422 &wPreferences
.no_window_over_dock
, getBool
, updateUsableArea
, NULL
, NULL
},
423 {"NoWindowOverIcons", "NO", NULL
,
424 &wPreferences
.no_window_over_icons
, getBool
, updateUsableArea
, NULL
, NULL
},
425 {"WindowPlaceOrigin", "(0, 0)", NULL
,
426 &wPreferences
.window_place_origin
, getCoord
, NULL
, NULL
, NULL
},
427 {"ResizeDisplay", "corner", seGeomDisplays
,
428 &wPreferences
.size_display
, getEnum
, NULL
, NULL
, NULL
},
429 {"MoveDisplay", "corner", seGeomDisplays
,
430 &wPreferences
.move_display
, getEnum
, NULL
, NULL
, NULL
},
431 {"DontConfirmKill", "NO", NULL
,
432 &wPreferences
.dont_confirm_kill
, getBool
, NULL
, NULL
, NULL
},
433 {"WindowTitleBalloons", "NO", NULL
,
434 &wPreferences
.window_balloon
, getBool
, NULL
, NULL
, NULL
},
435 {"MiniwindowTitleBalloons", "NO", NULL
,
436 &wPreferences
.miniwin_balloon
, getBool
, NULL
, NULL
, NULL
},
437 {"AppIconBalloons", "NO", NULL
,
438 &wPreferences
.appicon_balloon
, getBool
, NULL
, NULL
, NULL
},
439 {"HelpBalloons", "NO", NULL
,
440 &wPreferences
.help_balloon
, getBool
, NULL
, NULL
, NULL
},
441 {"EdgeResistance", "30", NULL
,
442 &wPreferences
.edge_resistance
, getInt
, NULL
, NULL
, NULL
},
443 {"ResizeIncrement", "32", NULL
,
444 &wPreferences
.resize_increment
, getInt
, NULL
, NULL
, NULL
},
445 {"Attraction", "NO", NULL
,
446 &wPreferences
.attract
, getBool
, NULL
, NULL
, NULL
},
447 {"DisableBlinking", "NO", NULL
,
448 &wPreferences
.dont_blink
, getBool
, NULL
, NULL
, NULL
},
449 {"SingleClickLaunch", "NO", NULL
,
450 &wPreferences
.single_click
, getBool
, NULL
, NULL
, NULL
},
454 {"MenuStyle", "normal", seMenuStyles
,
455 &wPreferences
.menu_style
, getEnum
, setMenuStyle
, NULL
, NULL
},
456 {"WidgetColor", "(solid, gray)", NULL
,
457 NULL
, getTexture
, setWidgetColor
, NULL
, NULL
},
458 {"WorkspaceSpecificBack", "()", NULL
,
459 NULL
, getWSSpecificBackground
, setWorkspaceSpecificBack
, NULL
, NULL
},
460 /* WorkspaceBack must come after WorkspaceSpecificBack or
461 * WorkspaceBack wont know WorkspaceSpecificBack was also
462 * specified and 2 copies of wmsetbg will be launched */
463 {"WorkspaceBack", "(solid, black)", NULL
,
464 NULL
, getWSBackground
, setWorkspaceBack
, NULL
, NULL
},
465 {"SmoothWorkspaceBack", "NO", NULL
,
466 NULL
, getBool
, NULL
, NULL
, NULL
},
467 {"IconBack", "(solid, gray)", NULL
,
468 NULL
, getTexture
, setIconTile
, NULL
, NULL
},
469 {"TitleJustify", "center", seJustifications
,
470 &wPreferences
.title_justification
, getEnum
, setJustify
, NULL
, NULL
},
471 {"WindowTitleFont", DEF_TITLE_FONT
, NULL
,
472 NULL
, getFont
, setWinTitleFont
, NULL
, NULL
},
473 {"WindowTitleExtendSpace", DEF_WINDOW_TITLE_EXTEND_SPACE
, NULL
,
474 &wPreferences
.window_title_clearance
, getInt
, setClearance
, NULL
, NULL
},
475 {"WindowTitleMinHeight", "0", NULL
,
476 &wPreferences
.window_title_min_height
, getInt
, setClearance
, NULL
, NULL
},
477 {"WindowTitleMaxHeight", NUM2STRING(INT_MAX
), NULL
,
478 &wPreferences
.window_title_max_height
, getInt
, setClearance
, NULL
, NULL
},
479 {"MenuTitleExtendSpace", DEF_MENU_TITLE_EXTEND_SPACE
, NULL
,
480 &wPreferences
.menu_title_clearance
, getInt
, setClearance
, NULL
, NULL
},
481 {"MenuTitleMinHeight", "0", NULL
,
482 &wPreferences
.menu_title_min_height
, getInt
, setClearance
, NULL
, NULL
},
483 {"MenuTitleMaxHeight", NUM2STRING(INT_MAX
), NULL
,
484 &wPreferences
.menu_title_max_height
, getInt
, setClearance
, NULL
, NULL
},
485 {"MenuTextExtendSpace", DEF_MENU_TEXT_EXTEND_SPACE
, NULL
,
486 &wPreferences
.menu_text_clearance
, getInt
, setClearance
, NULL
, NULL
},
487 {"MenuTitleFont", DEF_MENU_TITLE_FONT
, NULL
,
488 NULL
, getFont
, setMenuTitleFont
, NULL
, NULL
},
489 {"MenuTextFont", DEF_MENU_ENTRY_FONT
, NULL
,
490 NULL
, getFont
, setMenuTextFont
, NULL
, NULL
},
491 {"IconTitleFont", DEF_ICON_TITLE_FONT
, NULL
,
492 NULL
, getFont
, setIconTitleFont
, NULL
, NULL
},
493 {"ClipTitleFont", DEF_CLIP_TITLE_FONT
, NULL
,
494 NULL
, getFont
, setClipTitleFont
, NULL
, NULL
},
495 {"ShowClipTitle", "YES", NULL
,
496 &wPreferences
.show_clip_title
, getBool
, NULL
, NULL
, NULL
},
497 {"LargeDisplayFont", DEF_WORKSPACE_NAME_FONT
, NULL
,
498 NULL
, getFont
, setLargeDisplayFont
, NULL
, NULL
},
499 {"HighlightColor", "white", NULL
,
500 NULL
, getColor
, setHightlight
, NULL
, NULL
},
501 {"HighlightTextColor", "black", NULL
,
502 NULL
, getColor
, setHightlightText
, NULL
, NULL
},
503 {"ClipTitleColor", "black", (void *)CLIP_NORMAL
,
504 NULL
, getColor
, setClipTitleColor
, NULL
, NULL
},
505 {"CClipTitleColor", "\"#454045\"", (void *)CLIP_COLLAPSED
,
506 NULL
, getColor
, setClipTitleColor
, NULL
, NULL
},
507 {"FTitleColor", "white", (void *)WS_FOCUSED
,
508 NULL
, getColor
, setWTitleColor
, NULL
, NULL
},
509 {"PTitleColor", "white", (void *)WS_PFOCUSED
,
510 NULL
, getColor
, setWTitleColor
, NULL
, NULL
},
511 {"UTitleColor", "black", (void *)WS_UNFOCUSED
,
512 NULL
, getColor
, setWTitleColor
, NULL
, NULL
},
513 {"FTitleBack", "(solid, black)", NULL
,
514 NULL
, getTexture
, setFTitleBack
, NULL
, NULL
},
515 {"PTitleBack", "(solid, \"#616161\")", NULL
,
516 NULL
, getTexture
, setPTitleBack
, NULL
, NULL
},
517 {"UTitleBack", "(solid, gray)", NULL
,
518 NULL
, getTexture
, setUTitleBack
, NULL
, NULL
},
519 {"ResizebarBack", "(solid, gray)", NULL
,
520 NULL
, getTexture
, setResizebarBack
, NULL
, NULL
},
521 {"MenuTitleColor", "white", NULL
,
522 NULL
, getColor
, setMenuTitleColor
, NULL
, NULL
},
523 {"MenuTextColor", "black", NULL
,
524 NULL
, getColor
, setMenuTextColor
, NULL
, NULL
},
525 {"MenuDisabledColor", "\"#616161\"", NULL
,
526 NULL
, getColor
, setMenuDisabledColor
, NULL
, NULL
},
527 {"MenuTitleBack", "(solid, black)", NULL
,
528 NULL
, getTexture
, setMenuTitleBack
, NULL
, NULL
},
529 {"MenuTextBack", "(solid, gray)", NULL
,
530 NULL
, getTexture
, setMenuTextBack
, NULL
, NULL
},
531 {"IconTitleColor", "white", NULL
,
532 NULL
, getColor
, setIconTitleColor
, NULL
, NULL
},
533 {"IconTitleBack", "black", NULL
,
534 NULL
, getColor
, setIconTitleBack
, NULL
, NULL
},
535 {"SwitchPanelImages", "(swtile.png, swback.png, 30, 40)", &wPreferences
,
536 NULL
, getPropList
, setSwPOptions
, NULL
, NULL
},
537 {"ModifierKeyLabels", "(\"Shift+\", \"Ctrl+\", \"Mod1+\", \"Mod2+\", \"Mod3+\", \"Mod4+\", \"Mod5+\")", &wPreferences
,
538 NULL
, getPropList
, setModifierKeyLabels
, NULL
, NULL
},
542 {"RootMenuKey", "None", (void *)WKBD_ROOTMENU
,
543 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
544 {"WindowListKey", "None", (void *)WKBD_WINDOWLIST
,
545 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
546 {"WindowMenuKey", "None", (void *)WKBD_WINDOWMENU
,
547 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
548 {"DockRaiseLowerKey", "None", (void*)WKBD_DOCKRAISELOWER
,
549 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
550 {"ClipRaiseLowerKey", "None", (void *)WKBD_CLIPRAISELOWER
,
551 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
552 {"MiniaturizeKey", "None", (void *)WKBD_MINIATURIZE
,
553 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
554 {"MinimizeAllKey", "None", (void *)WKBD_MINIMIZEALL
,
555 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
556 {"HideKey", "None", (void *)WKBD_HIDE
,
557 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
558 {"HideOthersKey", "None", (void *)WKBD_HIDE_OTHERS
,
559 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
560 {"MoveResizeKey", "None", (void *)WKBD_MOVERESIZE
,
561 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
562 {"CloseKey", "None", (void *)WKBD_CLOSE
,
563 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
564 {"MaximizeKey", "None", (void *)WKBD_MAXIMIZE
,
565 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
566 {"VMaximizeKey", "None", (void *)WKBD_VMAXIMIZE
,
567 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
568 {"HMaximizeKey", "None", (void *)WKBD_HMAXIMIZE
,
569 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
570 {"LHMaximizeKey", "None", (void*)WKBD_LHMAXIMIZE
,
571 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
572 {"RHMaximizeKey", "None", (void*)WKBD_RHMAXIMIZE
,
573 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
574 {"MaximusKey", "None", (void*)WKBD_MAXIMUS
,
575 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
576 {"RaiseKey", "\"Meta+Up\"", (void *)WKBD_RAISE
,
577 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
578 {"LowerKey", "\"Meta+Down\"", (void *)WKBD_LOWER
,
579 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
580 {"RaiseLowerKey", "None", (void *)WKBD_RAISELOWER
,
581 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
582 {"ShadeKey", "None", (void *)WKBD_SHADE
,
583 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
584 {"SelectKey", "None", (void *)WKBD_SELECT
,
585 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
586 {"FocusNextKey", "None", (void *)WKBD_FOCUSNEXT
,
587 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
588 {"FocusPrevKey", "None", (void *)WKBD_FOCUSPREV
,
589 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
590 {"GroupNextKey", "None", (void *)WKBD_GROUPNEXT
,
591 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
592 {"GroupPrevKey", "None", (void *)WKBD_GROUPPREV
,
593 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
594 {"NextWorkspaceKey", "None", (void *)WKBD_NEXTWORKSPACE
,
595 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
596 {"PrevWorkspaceKey", "None", (void *)WKBD_PREVWORKSPACE
,
597 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
598 {"NextWorkspaceLayerKey", "None", (void *)WKBD_NEXTWSLAYER
,
599 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
600 {"PrevWorkspaceLayerKey", "None", (void *)WKBD_PREVWSLAYER
,
601 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
602 {"Workspace1Key", "None", (void *)WKBD_WORKSPACE1
,
603 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
604 {"Workspace2Key", "None", (void *)WKBD_WORKSPACE2
,
605 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
606 {"Workspace3Key", "None", (void *)WKBD_WORKSPACE3
,
607 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
608 {"Workspace4Key", "None", (void *)WKBD_WORKSPACE4
,
609 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
610 {"Workspace5Key", "None", (void *)WKBD_WORKSPACE5
,
611 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
612 {"Workspace6Key", "None", (void *)WKBD_WORKSPACE6
,
613 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
614 {"Workspace7Key", "None", (void *)WKBD_WORKSPACE7
,
615 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
616 {"Workspace8Key", "None", (void *)WKBD_WORKSPACE8
,
617 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
618 {"Workspace9Key", "None", (void *)WKBD_WORKSPACE9
,
619 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
620 {"Workspace10Key", "None", (void *)WKBD_WORKSPACE10
,
621 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
622 {"WindowShortcut1Key", "None", (void *)WKBD_WINDOW1
,
623 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
624 {"WindowShortcut2Key", "None", (void *)WKBD_WINDOW2
,
625 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
626 {"WindowShortcut3Key", "None", (void *)WKBD_WINDOW3
,
627 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
628 {"WindowShortcut4Key", "None", (void *)WKBD_WINDOW4
,
629 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
630 {"WindowShortcut5Key", "None", (void *)WKBD_WINDOW5
,
631 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
632 {"WindowShortcut6Key", "None", (void *)WKBD_WINDOW6
,
633 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
634 {"WindowShortcut7Key", "None", (void *)WKBD_WINDOW7
,
635 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
636 {"WindowShortcut8Key", "None", (void *)WKBD_WINDOW8
,
637 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
638 {"WindowShortcut9Key", "None", (void *)WKBD_WINDOW9
,
639 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
640 {"WindowShortcut10Key", "None", (void *)WKBD_WINDOW10
,
641 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
642 {"WindowRelaunchKey", "None", (void *)WKBD_RELAUNCH
,
643 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
644 {"ScreenSwitchKey", "None", (void *)WKBD_SWITCH_SCREEN
,
645 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
647 #ifdef KEEP_XKB_LOCK_STATUS
648 {"ToggleKbdModeKey", "None", (void *)WKBD_TOGGLE
,
649 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
650 {"KbdModeLock", "NO", NULL
,
651 &wPreferences
.modelock
, getBool
, NULL
, NULL
, NULL
},
652 #endif /* KEEP_XKB_LOCK_STATUS */
654 {"NormalCursor", "(builtin, left_ptr)", (void *)WCUR_ROOT
,
655 NULL
, getCursor
, setCursor
, NULL
, NULL
},
656 {"ArrowCursor", "(builtin, top_left_arrow)", (void *)WCUR_ARROW
,
657 NULL
, getCursor
, setCursor
, NULL
, NULL
},
658 {"MoveCursor", "(builtin, fleur)", (void *)WCUR_MOVE
,
659 NULL
, getCursor
, setCursor
, NULL
, NULL
},
660 {"ResizeCursor", "(builtin, sizing)", (void *)WCUR_RESIZE
,
661 NULL
, getCursor
, setCursor
, NULL
, NULL
},
662 {"TopLeftResizeCursor", "(builtin, top_left_corner)", (void *)WCUR_TOPLEFTRESIZE
,
663 NULL
, getCursor
, setCursor
, NULL
, NULL
},
664 {"TopRightResizeCursor", "(builtin, top_right_corner)", (void *)WCUR_TOPRIGHTRESIZE
,
665 NULL
, getCursor
, setCursor
, NULL
, NULL
},
666 {"BottomLeftResizeCursor", "(builtin, bottom_left_corner)", (void *)WCUR_BOTTOMLEFTRESIZE
,
667 NULL
, getCursor
, setCursor
, NULL
, NULL
},
668 {"BottomRightResizeCursor", "(builtin, bottom_right_corner)", (void *)WCUR_BOTTOMRIGHTRESIZE
,
669 NULL
, getCursor
, setCursor
, NULL
, NULL
},
670 {"VerticalResizeCursor", "(builtin, sb_v_double_arrow)", (void *)WCUR_VERTICALRESIZE
,
671 NULL
, getCursor
, setCursor
, NULL
, NULL
},
672 {"HorizontalResizeCursor", "(builtin, sb_h_double_arrow)", (void *)WCUR_HORIZONRESIZE
,
673 NULL
, getCursor
, setCursor
, NULL
, NULL
},
674 {"WaitCursor", "(builtin, watch)", (void *)WCUR_WAIT
,
675 NULL
, getCursor
, setCursor
, NULL
, NULL
},
676 {"QuestionCursor", "(builtin, question_arrow)", (void *)WCUR_QUESTION
,
677 NULL
, getCursor
, setCursor
, NULL
, NULL
},
678 {"TextCursor", "(builtin, xterm)", (void *)WCUR_TEXT
,
679 NULL
, getCursor
, setCursor
, NULL
, NULL
},
680 {"SelectCursor", "(builtin, cross)", (void *)WCUR_SELECT
,
681 NULL
, getCursor
, setCursor
, NULL
, NULL
},
682 {"DialogHistoryLines", "500", NULL
,
683 &wPreferences
.history_lines
, getInt
, NULL
, NULL
, NULL
},
684 {"CycleActiveHeadOnly", "NO", NULL
,
685 &wPreferences
.cycle_active_head_only
, getBool
, NULL
, NULL
, NULL
}
688 static void initDefaults()
691 WDefaultEntry
*entry
;
693 WMPLSetCaseSensitive(False
);
695 for (i
= 0; i
< sizeof(optionList
) / sizeof(WDefaultEntry
); i
++) {
696 entry
= &optionList
[i
];
698 entry
->plkey
= WMCreatePLString(entry
->key
);
699 if (entry
->default_value
)
700 entry
->plvalue
= WMCreatePropListFromDescription(entry
->default_value
);
702 entry
->plvalue
= NULL
;
705 for (i
= 0; i
< sizeof(staticOptionList
) / sizeof(WDefaultEntry
); i
++) {
706 entry
= &staticOptionList
[i
];
708 entry
->plkey
= WMCreatePLString(entry
->key
);
709 if (entry
->default_value
)
710 entry
->plvalue
= WMCreatePropListFromDescription(entry
->default_value
);
712 entry
->plvalue
= NULL
;
716 static WMPropList
*readGlobalDomain(char *domainName
, Bool requireDictionary
)
718 WMPropList
*globalDict
= NULL
;
722 snprintf(path
, sizeof(path
), "%s/%s/%s", SYSCONFDIR
, GLOBAL_DEFAULTS_SUBDIR
, domainName
);
723 if (stat(path
, &stbuf
) >= 0) {
724 globalDict
= WMReadPropListFromFile(path
);
725 if (globalDict
&& requireDictionary
&& !WMIsPLDictionary(globalDict
)) {
726 wwarning(_("Domain %s (%s) of global defaults database is corrupted!"), domainName
, path
);
727 WMReleasePropList(globalDict
);
729 } else if (!globalDict
) {
730 wwarning(_("could not load domain %s from global defaults database"), domainName
);
737 #if defined(GLOBAL_PREAMBLE_MENU_FILE) || defined(GLOBAL_EPILOGUE_MENU_FILE)
738 static void prependMenu(WMPropList
* destarr
, WMPropList
* array
)
743 for (i
= 0; i
< WMGetPropListItemCount(array
); i
++) {
744 item
= WMGetFromPLArray(array
, i
);
746 WMInsertInPLArray(destarr
, i
+ 1, item
);
750 static void appendMenu(WMPropList
* destarr
, WMPropList
* array
)
755 for (i
= 0; i
< WMGetPropListItemCount(array
); i
++) {
756 item
= WMGetFromPLArray(array
, i
);
758 WMAddToPLArray(destarr
, item
);
763 void wDefaultsMergeGlobalMenus(WDDomain
* menuDomain
)
765 WMPropList
*menu
= menuDomain
->dictionary
;
768 if (!menu
|| !WMIsPLArray(menu
))
771 #ifdef GLOBAL_PREAMBLE_MENU_FILE
772 submenu
= WMReadPropListFromFile(SYSCONFDIR
"/" GLOBAL_DEFAULTS_SUBDIR
"/" GLOBAL_PREAMBLE_MENU_FILE
);
774 if (submenu
&& !WMIsPLArray(submenu
)) {
775 wwarning(_("invalid global menu file %s"), GLOBAL_PREAMBLE_MENU_FILE
);
776 WMReleasePropList(submenu
);
780 prependMenu(menu
, submenu
);
781 WMReleasePropList(submenu
);
785 #ifdef GLOBAL_EPILOGUE_MENU_FILE
786 submenu
= WMReadPropListFromFile(SYSCONFDIR
"/" GLOBAL_DEFAULTS_SUBDIR
"/" GLOBAL_EPILOGUE_MENU_FILE
);
788 if (submenu
&& !WMIsPLArray(submenu
)) {
789 wwarning(_("invalid global menu file %s"), GLOBAL_EPILOGUE_MENU_FILE
);
790 WMReleasePropList(submenu
);
794 appendMenu(menu
, submenu
);
795 WMReleasePropList(submenu
);
799 menuDomain
->dictionary
= menu
;
802 WDDomain
*wDefaultsInitDomain(char *domain
, Bool requireDictionary
)
806 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 shared_dict
= readGlobalDomain(domain
, requireDictionary
);
837 if (shared_dict
&& db
->dictionary
&& WMIsPLDictionary(shared_dict
) &&
838 WMIsPLDictionary(db
->dictionary
)) {
839 WMMergePLDictionaries(shared_dict
, db
->dictionary
, True
);
840 WMReleasePropList(db
->dictionary
);
841 db
->dictionary
= shared_dict
;
842 if (stbuf
.st_mtime
> db
->timestamp
)
843 db
->timestamp
= stbuf
.st_mtime
;
844 } else if (!db
->dictionary
) {
845 db
->dictionary
= shared_dict
;
846 if (stbuf
.st_mtime
> db
->timestamp
)
847 db
->timestamp
= stbuf
.st_mtime
;
853 void wReadStaticDefaults(WMPropList
* dict
)
856 WDefaultEntry
*entry
;
860 for (i
= 0; i
< sizeof(staticOptionList
) / sizeof(WDefaultEntry
); i
++) {
861 entry
= &staticOptionList
[i
];
864 plvalue
= WMGetFromPLDictionary(dict
, entry
->plkey
);
869 /* no default in the DB. Use builtin default */
870 plvalue
= entry
->plvalue
;
875 (*entry
->convert
) (NULL
, entry
, plvalue
, entry
->addr
, &tdata
);
877 (*entry
->update
) (NULL
, entry
, tdata
, entry
->extra_data
);
883 void wDefaultsCheckDomains(void* arg
)
887 WMPropList
*shared_dict
= NULL
;
891 if (stat(WDWindowMaker
->path
, &stbuf
) >= 0 && WDWindowMaker
->timestamp
< stbuf
.st_mtime
) {
892 WDWindowMaker
->timestamp
= stbuf
.st_mtime
;
894 /* Global dictionary */
895 shared_dict
= readGlobalDomain("WindowMaker", True
);
897 /* User dictionary */
898 dict
= WMReadPropListFromFile(WDWindowMaker
->path
);
901 if (!WMIsPLDictionary(dict
)) {
902 WMReleasePropList(dict
);
904 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
905 "WindowMaker", WDWindowMaker
->path
);
908 WMMergePLDictionaries(shared_dict
, dict
, True
);
909 WMReleasePropList(dict
);
914 for (i
= 0; i
< wScreenCount
; i
++) {
915 scr
= wScreenWithNumber(i
);
917 wReadDefaults(scr
, dict
);
920 if (WDWindowMaker
->dictionary
)
921 WMReleasePropList(WDWindowMaker
->dictionary
);
923 WDWindowMaker
->dictionary
= dict
;
926 wwarning(_("could not load domain %s from user defaults database"), "WindowMaker");
930 WMReleasePropList(shared_dict
);
934 if (stat(WDWindowAttributes
->path
, &stbuf
) >= 0 && WDWindowAttributes
->timestamp
< stbuf
.st_mtime
) {
935 /* global dictionary */
936 shared_dict
= readGlobalDomain("WMWindowAttributes", True
);
937 /* user dictionary */
938 dict
= WMReadPropListFromFile(WDWindowAttributes
->path
);
940 if (!WMIsPLDictionary(dict
)) {
941 WMReleasePropList(dict
);
943 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
944 "WMWindowAttributes", WDWindowAttributes
->path
);
947 WMMergePLDictionaries(shared_dict
, dict
, True
);
948 WMReleasePropList(dict
);
952 if (WDWindowAttributes
->dictionary
) {
953 WMReleasePropList(WDWindowAttributes
->dictionary
);
955 WDWindowAttributes
->dictionary
= dict
;
956 for (i
= 0; i
< wScreenCount
; i
++) {
957 scr
= wScreenWithNumber(i
);
959 wDefaultUpdateIcons(scr
);
961 /* Update the panel image if changed */
962 /* Don't worry. If the image is the same these
963 * functions will have no performance impact. */
964 create_logo_image(scr
);
969 wwarning(_("could not load domain %s from user defaults database"), "WMWindowAttributes");
971 WDWindowAttributes
->timestamp
= stbuf
.st_mtime
;
973 WMReleasePropList(shared_dict
);
977 if (stat(WDRootMenu
->path
, &stbuf
) >= 0 && WDRootMenu
->timestamp
< stbuf
.st_mtime
) {
978 dict
= WMReadPropListFromFile(WDRootMenu
->path
);
980 if (!WMIsPLArray(dict
) && !WMIsPLString(dict
)) {
981 WMReleasePropList(dict
);
983 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
984 "WMRootMenu", WDRootMenu
->path
);
986 if (WDRootMenu
->dictionary
) {
987 WMReleasePropList(WDRootMenu
->dictionary
);
989 WDRootMenu
->dictionary
= dict
;
990 wDefaultsMergeGlobalMenus(WDRootMenu
);
993 wwarning(_("could not load domain %s from user defaults database"), "WMRootMenu");
995 WDRootMenu
->timestamp
= stbuf
.st_mtime
;
999 WMAddTimerHandler(DEFAULTS_CHECK_INTERVAL
, wDefaultsCheckDomains
, arg
);
1003 void wReadDefaults(WScreen
* scr
, WMPropList
* new_dict
)
1005 WMPropList
*plvalue
, *old_value
;
1006 WDefaultEntry
*entry
;
1008 int update_workspace_back
= 0; /* kluge :/ */
1009 unsigned int needs_refresh
;
1011 WMPropList
*old_dict
= (WDWindowMaker
->dictionary
!= new_dict
? WDWindowMaker
->dictionary
: NULL
);
1015 for (i
= 0; i
< sizeof(optionList
) / sizeof(WDefaultEntry
); i
++) {
1016 entry
= &optionList
[i
];
1019 plvalue
= WMGetFromPLDictionary(new_dict
, entry
->plkey
);
1026 old_value
= WMGetFromPLDictionary(old_dict
, entry
->plkey
);
1028 if (!plvalue
&& !old_value
) {
1029 /* no default in the DB. Use builtin default */
1030 plvalue
= entry
->plvalue
;
1031 if (plvalue
&& new_dict
)
1032 WMPutInPLDictionary(new_dict
, entry
->plkey
, plvalue
);
1034 } else if (!plvalue
) {
1035 /* value was deleted from DB. Keep current value */
1037 } else if (!old_value
) {
1038 /* set value for the 1st time */
1039 } else if (!WMIsPropListEqualTo(plvalue
, old_value
)) {
1040 /* value has changed */
1042 if (strcmp(entry
->key
, "WorkspaceBack") == 0
1043 && update_workspace_back
&& scr
->flags
.backimage_helper_launched
) {
1045 /* value was not changed since last time */
1052 if ((*entry
->convert
) (scr
, entry
, plvalue
, entry
->addr
, &tdata
)) {
1054 * If the WorkspaceSpecificBack data has been changed
1055 * so that the helper will be launched now, we must be
1056 * sure to send the default background texture config
1059 if (strcmp(entry
->key
, "WorkspaceSpecificBack") == 0 &&
1060 !scr
->flags
.backimage_helper_launched
)
1061 update_workspace_back
= 1;
1064 needs_refresh
|= (*entry
->update
) (scr
, entry
, tdata
, entry
->extra_data
);
1070 if (needs_refresh
!= 0 && !scr
->flags
.startup
) {
1074 if (needs_refresh
& REFRESH_MENU_TITLE_TEXTURE
)
1075 foo
|= WTextureSettings
;
1076 if (needs_refresh
& REFRESH_MENU_TITLE_FONT
)
1077 foo
|= WFontSettings
;
1078 if (needs_refresh
& REFRESH_MENU_TITLE_COLOR
)
1079 foo
|= WColorSettings
;
1081 WMPostNotificationName(WNMenuTitleAppearanceSettingsChanged
, NULL
,
1082 (void *)(uintptr_t) foo
);
1085 if (needs_refresh
& REFRESH_MENU_TEXTURE
)
1086 foo
|= WTextureSettings
;
1087 if (needs_refresh
& REFRESH_MENU_FONT
)
1088 foo
|= WFontSettings
;
1089 if (needs_refresh
& REFRESH_MENU_COLOR
)
1090 foo
|= WColorSettings
;
1092 WMPostNotificationName(WNMenuAppearanceSettingsChanged
, NULL
, (void *)(uintptr_t) foo
);
1095 if (needs_refresh
& REFRESH_WINDOW_FONT
)
1096 foo
|= WFontSettings
;
1097 if (needs_refresh
& REFRESH_WINDOW_TEXTURES
)
1098 foo
|= WTextureSettings
;
1099 if (needs_refresh
& REFRESH_WINDOW_TITLE_COLOR
)
1100 foo
|= WColorSettings
;
1102 WMPostNotificationName(WNWindowAppearanceSettingsChanged
, NULL
, (void *)(uintptr_t) foo
);
1104 if (!(needs_refresh
& REFRESH_ICON_TILE
)) {
1106 if (needs_refresh
& REFRESH_ICON_FONT
)
1107 foo
|= WFontSettings
;
1108 if (needs_refresh
& REFRESH_ICON_TITLE_COLOR
)
1109 foo
|= WTextureSettings
;
1110 if (needs_refresh
& REFRESH_ICON_TITLE_BACK
)
1111 foo
|= WTextureSettings
;
1113 WMPostNotificationName(WNIconAppearanceSettingsChanged
, NULL
,
1114 (void *)(uintptr_t) foo
);
1116 if (needs_refresh
& REFRESH_ICON_TILE
)
1117 WMPostNotificationName(WNIconTileSettingsChanged
, NULL
, NULL
);
1121 void wDefaultUpdateIcons(WScreen
* scr
)
1123 WAppIcon
*aicon
= scr
->app_icon_list
;
1124 WWindow
*wwin
= scr
->focused_window
;
1128 /* Get the application icon, default included */
1129 file
= wDefaultGetIconFile(aicon
->wm_instance
, aicon
->wm_class
, True
);
1130 if ((file
&& aicon
->icon
->file
&& strcmp(file
, aicon
->icon
->file
) != 0)
1131 || (file
&& !aicon
->icon
->file
)) {
1132 wIconChangeImageFile(aicon
->icon
, file
);
1133 wAppIconPaint(aicon
);
1135 aicon
= aicon
->next
;
1138 if (!wPreferences
.flags
.noclip
)
1139 wClipIconPaint(scr
->clip_icon
);
1142 if (wwin
->icon
&& wwin
->flags
.miniaturized
) {
1143 /* Get the application icon, default included */
1144 file
= wDefaultGetIconFile(wwin
->wm_instance
, wwin
->wm_class
, True
);
1145 if ((file
&& wwin
->icon
->file
&& strcmp(file
, wwin
->icon
->file
) != 0)
1146 || (file
&& !wwin
->icon
->file
)) {
1147 wIconChangeImageFile(wwin
->icon
, file
);
1154 /* --------------------------- Local ----------------------- */
1156 #define GET_STRING_OR_DEFAULT(x, var) if (!WMIsPLString(value)) { \
1157 wwarning(_("Wrong option format for key \"%s\". Should be %s."), \
1159 wwarning(_("using default \"%s\" instead"), entry->default_value); \
1160 var = entry->default_value;\
1161 } else var = WMGetFromPLString(value)\
1164 static int string2index(WMPropList * key, WMPropList * val, char *def, WOptionEnumeration * values)
1167 WOptionEnumeration
*v
;
1168 char buffer
[TOTAL_VALUES_LENGTH
];
1170 if (WMIsPLString(val
) && (str
= WMGetFromPLString(val
))) {
1171 for (v
= values
; v
->string
!= NULL
; v
++) {
1172 if (strcasecmp(v
->string
, str
) == 0)
1178 for (v
= values
; v
->string
!= NULL
; v
++) {
1181 strcat(buffer
, ", ");
1182 snprintf(buffer
+strlen(buffer
),
1183 sizeof(buffer
)-strlen(buffer
)-1, "\"%s\"", v
->string
);
1186 wwarning(_("wrong option value for key \"%s\"; got \"%s\", should be one of %s."),
1187 WMGetFromPLString(key
),
1188 WMIsPLString(val
) ? WMGetFromPLString(val
) : "(unknown)",
1192 return string2index(key
, val
, NULL
, values
);
1199 * value - is the value in the defaults DB
1200 * addr - is the address to store the data
1201 * ret - is the address to store a pointer to a temporary buffer. ret
1202 * must not be freed and is used by the set functions
1204 static int getBool(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1208 int second_pass
= 0;
1210 GET_STRING_OR_DEFAULT("Boolean", val
);
1213 if ((val
[1] == '\0' && (val
[0] == 'y' || val
[0] == 'Y'))
1214 || strcasecmp(val
, "YES") == 0) {
1217 } else if ((val
[1] == '\0' && (val
[0] == 'n' || val
[0] == 'N'))
1218 || strcasecmp(val
, "NO") == 0) {
1222 if (sscanf(val
, "%i", &i
) == 1) {
1228 wwarning(_("can't convert \"%s\" to boolean for key \"%s\""), val
, entry
->key
);
1229 if (second_pass
== 0) {
1230 val
= WMGetFromPLString(entry
->plvalue
);
1232 wwarning(_("using default \"%s\" instead"), val
);
1242 *(char *)addr
= data
;
1247 static int getInt(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1252 GET_STRING_OR_DEFAULT("Integer", val
);
1254 if (sscanf(val
, "%i", &data
) != 1) {
1255 wwarning(_("can't convert \"%s\" to integer for key \"%s\""), val
, entry
->key
);
1256 val
= WMGetFromPLString(entry
->plvalue
);
1257 wwarning(_("using default \"%s\" instead"), val
);
1258 if (sscanf(val
, "%i", &data
) != 1) {
1266 *(int *)addr
= data
;
1271 static int getCoord(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1274 char *val_x
, *val_y
;
1275 int nelem
, changed
= 0;
1276 WMPropList
*elem_x
, *elem_y
;
1279 if (!WMIsPLArray(value
)) {
1280 wwarning(_("Wrong option format for key \"%s\". Should be %s."), entry
->key
, "Coordinate");
1282 value
= entry
->plvalue
;
1284 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1290 nelem
= WMGetPropListItemCount(value
);
1292 wwarning(_("Incorrect number of elements in array for key \"%s\"."), entry
->key
);
1294 value
= entry
->plvalue
;
1296 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1302 elem_x
= WMGetFromPLArray(value
, 0);
1303 elem_y
= WMGetFromPLArray(value
, 1);
1305 if (!elem_x
|| !elem_y
|| !WMIsPLString(elem_x
) || !WMIsPLString(elem_y
)) {
1306 wwarning(_("Wrong value for key \"%s\". Should be Coordinate."), entry
->key
);
1308 value
= entry
->plvalue
;
1310 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1316 val_x
= WMGetFromPLString(elem_x
);
1317 val_y
= WMGetFromPLString(elem_y
);
1319 if (sscanf(val_x
, "%i", &data
.x
) != 1 || sscanf(val_y
, "%i", &data
.y
) != 1) {
1320 wwarning(_("can't convert array to integers for \"%s\"."), entry
->key
);
1322 value
= entry
->plvalue
;
1324 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1332 else if (data
.x
> scr
->scr_width
/ 3)
1333 data
.x
= scr
->scr_width
/ 3;
1336 else if (data
.y
> scr
->scr_height
/ 3)
1337 data
.y
= scr
->scr_height
/ 3;
1342 *(WCoord
*) addr
= data
;
1347 static int getPropList(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1349 WMRetainPropList(value
);
1356 static int getPathList(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1365 if (!WMIsPLArray(value
)) {
1366 wwarning(_("Wrong option format for key \"%s\". Should be %s."), entry
->key
, "an array of paths");
1368 value
= entry
->plvalue
;
1370 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1377 count
= WMGetPropListItemCount(value
);
1380 value
= entry
->plvalue
;
1382 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1389 for (i
= 0; i
< count
; i
++) {
1390 d
= WMGetFromPLArray(value
, i
);
1391 if (!d
|| !WMIsPLString(d
)) {
1395 len
+= strlen(WMGetFromPLString(d
)) + 1;
1398 ptr
= data
= wmalloc(len
+ 1);
1400 for (i
= 0; i
< count
; i
++) {
1401 d
= WMGetFromPLArray(value
, i
);
1402 if (!d
|| !WMIsPLString(d
)) {
1405 strcpy(ptr
, WMGetFromPLString(d
));
1406 ptr
+= strlen(WMGetFromPLString(d
));
1413 if (*(char **)addr
!= NULL
) {
1414 wfree(*(char **)addr
);
1416 *(char **)addr
= data
;
1421 static int getEnum(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1423 static signed char data
;
1425 data
= string2index(entry
->plkey
, value
, entry
->default_value
, (WOptionEnumeration
*) entry
->extra_data
);
1432 *(signed char *)addr
= data
;
1439 * (hgradient <color> <color>)
1440 * (vgradient <color> <color>)
1441 * (dgradient <color> <color>)
1442 * (mhgradient <color> <color> ...)
1443 * (mvgradient <color> <color> ...)
1444 * (mdgradient <color> <color> ...)
1445 * (igradient <color1> <color1> <thickness1> <color2> <color2> <thickness2>)
1446 * (tpixmap <file> <color>)
1447 * (spixmap <file> <color>)
1448 * (cpixmap <file> <color>)
1449 * (thgradient <file> <opaqueness> <color> <color>)
1450 * (tvgradient <file> <opaqueness> <color> <color>)
1451 * (tdgradient <file> <opaqueness> <color> <color>)
1452 * (function <lib> <function> ...)
1455 static WTexture
*parse_texture(WScreen
* scr
, WMPropList
* pl
)
1460 WTexture
*texture
= NULL
;
1462 nelem
= WMGetPropListItemCount(pl
);
1466 elem
= WMGetFromPLArray(pl
, 0);
1467 if (!elem
|| !WMIsPLString(elem
))
1469 val
= WMGetFromPLString(elem
);
1471 if (strcasecmp(val
, "solid") == 0) {
1479 elem
= WMGetFromPLArray(pl
, 1);
1480 if (!elem
|| !WMIsPLString(elem
))
1482 val
= WMGetFromPLString(elem
);
1484 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &color
)) {
1485 wwarning(_("\"%s\" is not a valid color name"), val
);
1489 texture
= (WTexture
*) wTextureMakeSolid(scr
, &color
);
1490 } else if (strcasecmp(val
, "dgradient") == 0
1491 || strcasecmp(val
, "vgradient") == 0 || strcasecmp(val
, "hgradient") == 0) {
1492 RColor color1
, color2
;
1497 wwarning(_("bad number of arguments in gradient specification"));
1501 if (val
[0] == 'd' || val
[0] == 'D')
1502 type
= WTEX_DGRADIENT
;
1503 else if (val
[0] == 'h' || val
[0] == 'H')
1504 type
= WTEX_HGRADIENT
;
1506 type
= WTEX_VGRADIENT
;
1508 /* get from color */
1509 elem
= WMGetFromPLArray(pl
, 1);
1510 if (!elem
|| !WMIsPLString(elem
))
1512 val
= WMGetFromPLString(elem
);
1514 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1515 wwarning(_("\"%s\" is not a valid color name"), val
);
1519 color1
.red
= xcolor
.red
>> 8;
1520 color1
.green
= xcolor
.green
>> 8;
1521 color1
.blue
= xcolor
.blue
>> 8;
1524 elem
= WMGetFromPLArray(pl
, 2);
1525 if (!elem
|| !WMIsPLString(elem
)) {
1528 val
= WMGetFromPLString(elem
);
1530 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1531 wwarning(_("\"%s\" is not a valid color name"), val
);
1535 color2
.red
= xcolor
.red
>> 8;
1536 color2
.green
= xcolor
.green
>> 8;
1537 color2
.blue
= xcolor
.blue
>> 8;
1539 texture
= (WTexture
*) wTextureMakeGradient(scr
, type
, &color1
, &color2
);
1541 } else if (strcasecmp(val
, "igradient") == 0) {
1542 RColor colors1
[2], colors2
[2];
1548 wwarning(_("bad number of arguments in gradient specification"));
1552 /* get from color */
1553 for (i
= 0; i
< 2; i
++) {
1554 elem
= WMGetFromPLArray(pl
, 1 + i
);
1555 if (!elem
|| !WMIsPLString(elem
))
1557 val
= WMGetFromPLString(elem
);
1559 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1560 wwarning(_("\"%s\" is not a valid color name"), val
);
1563 colors1
[i
].alpha
= 255;
1564 colors1
[i
].red
= xcolor
.red
>> 8;
1565 colors1
[i
].green
= xcolor
.green
>> 8;
1566 colors1
[i
].blue
= xcolor
.blue
>> 8;
1568 elem
= WMGetFromPLArray(pl
, 3);
1569 if (!elem
|| !WMIsPLString(elem
))
1571 val
= WMGetFromPLString(elem
);
1574 /* get from color */
1575 for (i
= 0; i
< 2; i
++) {
1576 elem
= WMGetFromPLArray(pl
, 4 + 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 colors2
[i
].alpha
= 255;
1586 colors2
[i
].red
= xcolor
.red
>> 8;
1587 colors2
[i
].green
= xcolor
.green
>> 8;
1588 colors2
[i
].blue
= xcolor
.blue
>> 8;
1590 elem
= WMGetFromPLArray(pl
, 6);
1591 if (!elem
|| !WMIsPLString(elem
))
1593 val
= WMGetFromPLString(elem
);
1596 texture
= (WTexture
*) wTextureMakeIGradient(scr
, th1
, colors1
, th2
, colors2
);
1598 } else if (strcasecmp(val
, "mhgradient") == 0
1599 || strcasecmp(val
, "mvgradient") == 0 || strcasecmp(val
, "mdgradient") == 0) {
1606 wwarning(_("too few arguments in multicolor gradient specification"));
1610 if (val
[1] == 'h' || val
[1] == 'H')
1611 type
= WTEX_MHGRADIENT
;
1612 else if (val
[1] == 'v' || val
[1] == 'V')
1613 type
= WTEX_MVGRADIENT
;
1615 type
= WTEX_MDGRADIENT
;
1619 colors
= wmalloc(sizeof(RColor
*) * (count
+ 1));
1621 for (i
= 0; i
< count
; i
++) {
1622 elem
= WMGetFromPLArray(pl
, i
+ 1);
1623 if (!elem
|| !WMIsPLString(elem
)) {
1624 for (--i
; i
>= 0; --i
) {
1630 val
= WMGetFromPLString(elem
);
1632 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &color
)) {
1633 wwarning(_("\"%s\" is not a valid color name"), val
);
1634 for (--i
; i
>= 0; --i
) {
1640 colors
[i
] = wmalloc(sizeof(RColor
));
1641 colors
[i
]->red
= color
.red
>> 8;
1642 colors
[i
]->green
= color
.green
>> 8;
1643 colors
[i
]->blue
= color
.blue
>> 8;
1648 texture
= (WTexture
*) wTextureMakeMGradient(scr
, type
, colors
);
1649 } else if (strcasecmp(val
, "spixmap") == 0 ||
1650 strcasecmp(val
, "cpixmap") == 0 || strcasecmp(val
, "tpixmap") == 0) {
1657 if (val
[0] == 's' || val
[0] == 'S')
1659 else if (val
[0] == 'c' || val
[0] == 'C')
1665 elem
= WMGetFromPLArray(pl
, 2);
1666 if (!elem
|| !WMIsPLString(elem
)) {
1669 val
= WMGetFromPLString(elem
);
1671 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &color
)) {
1672 wwarning(_("\"%s\" is not a valid color name"), val
);
1677 elem
= WMGetFromPLArray(pl
, 1);
1678 if (!elem
|| !WMIsPLString(elem
))
1680 val
= WMGetFromPLString(elem
);
1682 texture
= (WTexture
*) wTextureMakePixmap(scr
, type
, val
, &color
);
1683 } else if (strcasecmp(val
, "thgradient") == 0
1684 || strcasecmp(val
, "tvgradient") == 0 || strcasecmp(val
, "tdgradient") == 0) {
1685 RColor color1
, color2
;
1690 if (val
[1] == 'h' || val
[1] == 'H')
1691 style
= WTEX_THGRADIENT
;
1692 else if (val
[1] == 'v' || val
[1] == 'V')
1693 style
= WTEX_TVGRADIENT
;
1695 style
= WTEX_TDGRADIENT
;
1698 wwarning(_("bad number of arguments in textured gradient specification"));
1702 /* get from color */
1703 elem
= WMGetFromPLArray(pl
, 3);
1704 if (!elem
|| !WMIsPLString(elem
))
1706 val
= WMGetFromPLString(elem
);
1708 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1709 wwarning(_("\"%s\" is not a valid color name"), val
);
1713 color1
.red
= xcolor
.red
>> 8;
1714 color1
.green
= xcolor
.green
>> 8;
1715 color1
.blue
= xcolor
.blue
>> 8;
1718 elem
= WMGetFromPLArray(pl
, 4);
1719 if (!elem
|| !WMIsPLString(elem
)) {
1722 val
= WMGetFromPLString(elem
);
1724 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1725 wwarning(_("\"%s\" is not a valid color name"), val
);
1729 color2
.red
= xcolor
.red
>> 8;
1730 color2
.green
= xcolor
.green
>> 8;
1731 color2
.blue
= xcolor
.blue
>> 8;
1734 elem
= WMGetFromPLArray(pl
, 2);
1735 if (!elem
|| !WMIsPLString(elem
))
1738 val
= WMGetFromPLString(elem
);
1740 if (!val
|| (opacity
= atoi(val
)) < 0 || opacity
> 255) {
1741 wwarning(_("bad opacity value for tgradient texture \"%s\". Should be [0..255]"), val
);
1746 elem
= WMGetFromPLArray(pl
, 1);
1747 if (!elem
|| !WMIsPLString(elem
))
1749 val
= WMGetFromPLString(elem
);
1751 texture
= (WTexture
*) wTextureMakeTGradient(scr
, style
, &color1
, &color2
, val
, opacity
);
1752 } else if (strcasecmp(val
, "function") == 0) {
1753 /* Leave this in to handle the unlikely case of
1754 * someone actually having function textures configured */
1755 wwarning("function texture support has been removed");
1758 wwarning(_("invalid texture type %s"), val
);
1764 static int getTexture(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1766 static WTexture
*texture
;
1770 if (!WMIsPLArray(value
)) {
1771 wwarning(_("Wrong option format for key \"%s\". Should be %s."), entry
->key
, "Texture");
1773 value
= entry
->plvalue
;
1775 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1781 if (strcmp(entry
->key
, "WidgetColor") == 0 && !changed
) {
1784 pl
= WMGetFromPLArray(value
, 0);
1785 if (!pl
|| !WMIsPLString(pl
) || !WMGetFromPLString(pl
)
1786 || strcasecmp(WMGetFromPLString(pl
), "solid") != 0) {
1787 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1788 entry
->key
, "Solid Texture");
1790 value
= entry
->plvalue
;
1792 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1797 texture
= parse_texture(scr
, value
);
1800 wwarning(_("Error in texture specification for key \"%s\""), entry
->key
);
1802 value
= entry
->plvalue
;
1804 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1814 *(WTexture
**) addr
= texture
;
1819 static int getWSBackground(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1827 if (!WMIsPLArray(value
)) {
1828 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1829 "WorkspaceBack", "Texture or None");
1831 value
= entry
->plvalue
;
1833 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1839 /* only do basic error checking and verify for None texture */
1841 nelem
= WMGetPropListItemCount(value
);
1843 elem
= WMGetFromPLArray(value
, 0);
1844 if (!elem
|| !WMIsPLString(elem
)) {
1845 wwarning(_("Wrong type for workspace background. Should be a texture type."));
1847 value
= entry
->plvalue
;
1849 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1854 val
= WMGetFromPLString(elem
);
1856 if (strcasecmp(val
, "None") == 0)
1859 *ret
= WMRetainPropList(value
);
1865 getWSSpecificBackground(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1872 if (!WMIsPLArray(value
)) {
1873 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1874 "WorkspaceSpecificBack", "an array of textures");
1876 value
= entry
->plvalue
;
1878 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1884 /* only do basic error checking and verify for None texture */
1886 nelem
= WMGetPropListItemCount(value
);
1889 elem
= WMGetFromPLArray(value
, nelem
);
1890 if (!elem
|| !WMIsPLArray(elem
)) {
1891 wwarning(_("Wrong type for background of workspace %i. Should be a texture."),
1897 *ret
= WMRetainPropList(value
);
1901 * Kluge to force wmsetbg helper to set the default background.
1902 * If the WorkspaceSpecificBack is changed once wmaker has started,
1903 * the WorkspaceBack won't be sent to the helper, unless the user
1904 * changes it's value too. So, we must force this by removing the
1905 * value from the defaults DB.
1907 if (!scr
->flags
.backimage_helper_launched
&& !scr
->flags
.startup
) {
1908 WMPropList
*key
= WMCreatePLString("WorkspaceBack");
1910 WMRemoveFromPLDictionary(WDWindowMaker
->dictionary
, key
);
1912 WMReleasePropList(key
);
1918 static int getFont(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1920 static WMFont
*font
;
1923 GET_STRING_OR_DEFAULT("Font", val
);
1925 font
= WMCreateFont(scr
->wmscreen
, val
);
1927 font
= WMCreateFont(scr
->wmscreen
, "fixed");
1930 wfatal(_("could not load any usable font!!!"));
1937 /* can't assign font value outside update function */
1938 wassertrv(addr
== NULL
, True
);
1943 static int getColor(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1945 static XColor color
;
1947 int second_pass
= 0;
1949 GET_STRING_OR_DEFAULT("Color", val
);
1952 if (!wGetColor(scr
, val
, &color
)) {
1953 wwarning(_("could not get color for key \"%s\""), entry
->key
);
1954 if (second_pass
== 0) {
1955 val
= WMGetFromPLString(entry
->plvalue
);
1957 wwarning(_("using default \"%s\" instead"), val
);
1966 assert(addr
== NULL
);
1969 *(unsigned long*)addr = pixel;
1975 static int getKeybind(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1977 static WShortKey shortcut
;
1981 char buf
[MAX_SHORTCUT_LENGTH
], *b
;
1983 GET_STRING_OR_DEFAULT("Key spec", val
);
1985 if (!val
|| strcasecmp(val
, "NONE") == 0) {
1986 shortcut
.keycode
= 0;
1987 shortcut
.modifier
= 0;
1993 wstrlcpy(buf
, val
, MAX_SHORTCUT_LENGTH
);
1998 shortcut
.modifier
= 0;
1999 while ((k
= strchr(b
, '+')) != NULL
) {
2003 mod
= wXModifierFromKey(b
);
2005 wwarning(_("%s: invalid key modifier \"%s\""), entry
->key
, b
);
2008 shortcut
.modifier
|= mod
;
2014 ksym
= XStringToKeysym(b
);
2016 if (ksym
== NoSymbol
) {
2017 wwarning(_("%s:invalid kbd shortcut specification \"%s\""), entry
->key
, val
);
2021 shortcut
.keycode
= XKeysymToKeycode(dpy
, ksym
);
2022 if (shortcut
.keycode
== 0) {
2023 wwarning(_("%s:invalid key in shortcut \"%s\""), entry
->key
, val
);
2033 static int getModMask(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
2038 GET_STRING_OR_DEFAULT("Modifier Key", str
);
2043 mask
= wXModifierFromKey(str
);
2045 wwarning(_("%s: modifier key %s is not valid"), entry
->key
, str
);
2051 *(int *)addr
= mask
;
2059 # include <X11/cursorfont.h>
2065 #define CURSOR_ID_NONE (XC_num_glyphs)
2067 static WCursorLookup cursor_table
[] = {
2068 {"X_cursor", XC_X_cursor
},
2069 {"arrow", XC_arrow
},
2070 {"based_arrow_down", XC_based_arrow_down
},
2071 {"based_arrow_up", XC_based_arrow_up
},
2073 {"bogosity", XC_bogosity
},
2074 {"bottom_left_corner", XC_bottom_left_corner
},
2075 {"bottom_right_corner", XC_bottom_right_corner
},
2076 {"bottom_side", XC_bottom_side
},
2077 {"bottom_tee", XC_bottom_tee
},
2078 {"box_spiral", XC_box_spiral
},
2079 {"center_ptr", XC_center_ptr
},
2080 {"circle", XC_circle
},
2081 {"clock", XC_clock
},
2082 {"coffee_mug", XC_coffee_mug
},
2083 {"cross", XC_cross
},
2084 {"cross_reverse", XC_cross_reverse
},
2085 {"crosshair", XC_crosshair
},
2086 {"diamond_cross", XC_diamond_cross
},
2088 {"dotbox", XC_dotbox
},
2089 {"double_arrow", XC_double_arrow
},
2090 {"draft_large", XC_draft_large
},
2091 {"draft_small", XC_draft_small
},
2092 {"draped_box", XC_draped_box
},
2093 {"exchange", XC_exchange
},
2094 {"fleur", XC_fleur
},
2095 {"gobbler", XC_gobbler
},
2096 {"gumby", XC_gumby
},
2097 {"hand1", XC_hand1
},
2098 {"hand2", XC_hand2
},
2099 {"heart", XC_heart
},
2101 {"iron_cross", XC_iron_cross
},
2102 {"left_ptr", XC_left_ptr
},
2103 {"left_side", XC_left_side
},
2104 {"left_tee", XC_left_tee
},
2105 {"leftbutton", XC_leftbutton
},
2106 {"ll_angle", XC_ll_angle
},
2107 {"lr_angle", XC_lr_angle
},
2109 {"middlebutton", XC_middlebutton
},
2110 {"mouse", XC_mouse
},
2111 {"pencil", XC_pencil
},
2112 {"pirate", XC_pirate
},
2114 {"question_arrow", XC_question_arrow
},
2115 {"right_ptr", XC_right_ptr
},
2116 {"right_side", XC_right_side
},
2117 {"right_tee", XC_right_tee
},
2118 {"rightbutton", XC_rightbutton
},
2119 {"rtl_logo", XC_rtl_logo
},
2120 {"sailboat", XC_sailboat
},
2121 {"sb_down_arrow", XC_sb_down_arrow
},
2122 {"sb_h_double_arrow", XC_sb_h_double_arrow
},
2123 {"sb_left_arrow", XC_sb_left_arrow
},
2124 {"sb_right_arrow", XC_sb_right_arrow
},
2125 {"sb_up_arrow", XC_sb_up_arrow
},
2126 {"sb_v_double_arrow", XC_sb_v_double_arrow
},
2127 {"shuttle", XC_shuttle
},
2128 {"sizing", XC_sizing
},
2129 {"spider", XC_spider
},
2130 {"spraycan", XC_spraycan
},
2132 {"target", XC_target
},
2133 {"tcross", XC_tcross
},
2134 {"top_left_arrow", XC_top_left_arrow
},
2135 {"top_left_corner", XC_top_left_corner
},
2136 {"top_right_corner", XC_top_right_corner
},
2137 {"top_side", XC_top_side
},
2138 {"top_tee", XC_top_tee
},
2140 {"ul_angle", XC_ul_angle
},
2141 {"umbrella", XC_umbrella
},
2142 {"ur_angle", XC_ur_angle
},
2143 {"watch", XC_watch
},
2144 {"xterm", XC_xterm
},
2145 {NULL
, CURSOR_ID_NONE
}
2148 static void check_bitmap_status(int status
, char *filename
, Pixmap bitmap
)
2151 case BitmapOpenFailed
:
2152 wwarning(_("failed to open bitmap file \"%s\""), filename
);
2154 case BitmapFileInvalid
:
2155 wwarning(_("\"%s\" is not a valid bitmap file"), filename
);
2157 case BitmapNoMemory
:
2158 wwarning(_("out of memory reading bitmap file \"%s\""), filename
);
2161 XFreePixmap(dpy
, bitmap
);
2168 * (builtin, <cursor_name>)
2169 * (bitmap, <cursor_bitmap>, <cursor_mask>)
2171 static int parse_cursor(WScreen
* scr
, WMPropList
* pl
, Cursor
* cursor
)
2178 nelem
= WMGetPropListItemCount(pl
);
2182 elem
= WMGetFromPLArray(pl
, 0);
2183 if (!elem
|| !WMIsPLString(elem
)) {
2186 val
= WMGetFromPLString(elem
);
2188 if (strcasecmp(val
, "none") == 0) {
2191 } else if (strcasecmp(val
, "builtin") == 0) {
2193 int cursor_id
= CURSOR_ID_NONE
;
2196 wwarning(_("bad number of arguments in cursor specification"));
2199 elem
= WMGetFromPLArray(pl
, 1);
2200 if (!elem
|| !WMIsPLString(elem
)) {
2203 val
= WMGetFromPLString(elem
);
2205 for (i
= 0; cursor_table
[i
].name
!= NULL
; i
++) {
2206 if (strcasecmp(val
, cursor_table
[i
].name
) == 0) {
2207 cursor_id
= cursor_table
[i
].id
;
2211 if (CURSOR_ID_NONE
== cursor_id
) {
2212 wwarning(_("unknown builtin cursor name \"%s\""), val
);
2214 *cursor
= XCreateFontCursor(dpy
, cursor_id
);
2217 } else if (strcasecmp(val
, "bitmap") == 0) {
2229 wwarning(_("bad number of arguments in cursor specification"));
2232 elem
= WMGetFromPLArray(pl
, 1);
2233 if (!elem
|| !WMIsPLString(elem
)) {
2236 val
= WMGetFromPLString(elem
);
2237 bitmap_name
= FindImage(wPreferences
.pixmap_path
, val
);
2239 wwarning(_("could not find cursor bitmap file \"%s\""), val
);
2242 elem
= WMGetFromPLArray(pl
, 2);
2243 if (!elem
|| !WMIsPLString(elem
)) {
2247 val
= WMGetFromPLString(elem
);
2248 mask_name
= FindImage(wPreferences
.pixmap_path
, val
);
2251 wwarning(_("could not find cursor bitmap file \"%s\""), val
);
2254 mask_status
= XReadBitmapFile(dpy
, scr
->w_win
, mask_name
, &w
, &h
, &mask
, &x
, &y
);
2255 bitmap_status
= XReadBitmapFile(dpy
, scr
->w_win
, bitmap_name
, &w
, &h
, &bitmap
, &x
, &y
);
2256 if ((BitmapSuccess
== bitmap_status
) && (BitmapSuccess
== mask_status
)) {
2257 fg
.pixel
= scr
->black_pixel
;
2258 bg
.pixel
= scr
->white_pixel
;
2259 XQueryColor(dpy
, scr
->w_colormap
, &fg
);
2260 XQueryColor(dpy
, scr
->w_colormap
, &bg
);
2261 *cursor
= XCreatePixmapCursor(dpy
, bitmap
, mask
, &fg
, &bg
, x
, y
);
2264 check_bitmap_status(bitmap_status
, bitmap_name
, bitmap
);
2265 check_bitmap_status(mask_status
, mask_name
, mask
);
2272 static int getCursor(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
2274 static Cursor cursor
;
2279 if (!WMIsPLArray(value
)) {
2280 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
2281 entry
->key
, "cursor specification");
2283 value
= entry
->plvalue
;
2285 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
2290 status
= parse_cursor(scr
, value
, &cursor
);
2292 wwarning(_("Error in cursor specification for key \"%s\""), entry
->key
);
2294 value
= entry
->plvalue
;
2296 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
2305 *(Cursor
*) addr
= cursor
;
2310 #undef CURSOR_ID_NONE
2312 /* ---------------- value setting functions --------------- */
2313 static int setJustify(WScreen
* scr
, WDefaultEntry
* entry
, WTexture
** texture
, void *foo
)
2315 return REFRESH_WINDOW_TITLE_COLOR
;
2318 static int setClearance(WScreen
* scr
, WDefaultEntry
* entry
, void *bar
, void *foo
)
2320 return REFRESH_WINDOW_FONT
| REFRESH_BUTTON_IMAGES
| REFRESH_MENU_TITLE_FONT
| REFRESH_MENU_FONT
;
2323 static int setIfDockPresent(WScreen
* scr
, WDefaultEntry
* entry
, char *flag
, long which
)
2327 wPreferences
.flags
.nodock
= wPreferences
.flags
.nodock
|| *flag
;
2330 wPreferences
.flags
.noclip
= wPreferences
.flags
.noclip
|| *flag
;
2338 static int setStickyIcons(WScreen
* scr
, WDefaultEntry
* entry
, void *bar
, void *foo
)
2340 if (scr
->workspaces
) {
2341 wWorkspaceForceChange(scr
, scr
->current_workspace
);
2342 wArrangeIcons(scr
, False
);
2347 static int setIconTile(WScreen
* scr
, WDefaultEntry
* entry
, WTexture
** texture
, void *foo
)
2353 img
= wTextureRenderImage(*texture
, wPreferences
.icon_size
,
2354 wPreferences
.icon_size
, ((*texture
)->any
.type
& WREL_BORDER_MASK
)
2355 ? WREL_ICON
: WREL_FLAT
);
2357 wwarning(_("could not render texture for icon background"));
2359 wTextureDestroy(scr
, *texture
);
2362 RConvertImage(scr
->rcontext
, img
, &pixmap
);
2364 if (scr
->icon_tile
) {
2366 RReleaseImage(scr
->icon_tile
);
2367 XFreePixmap(dpy
, scr
->icon_tile_pixmap
);
2370 scr
->icon_tile
= img
;
2372 /* put the icon in the noticeboard hint */
2373 PropSetIconTileHint(scr
, img
);
2375 if (!wPreferences
.flags
.noclip
) {
2376 if (scr
->clip_tile
) {
2377 RReleaseImage(scr
->clip_tile
);
2379 scr
->clip_tile
= wClipMakeTile(scr
, img
);
2382 scr
->icon_tile_pixmap
= pixmap
;
2384 if (scr
->def_icon_rimage
) {
2385 RReleaseImage(scr
->def_icon_rimage
);
2386 scr
->def_icon_rimage
= NULL
;
2389 if (scr
->icon_back_texture
)
2390 wTextureDestroy(scr
, (WTexture
*) scr
->icon_back_texture
);
2392 scr
->icon_back_texture
= wTextureMakeSolid(scr
, &((*texture
)->any
.color
));
2394 if (scr
->clip_balloon
)
2395 XSetWindowBackground(dpy
, scr
->clip_balloon
, (*texture
)->any
.color
.pixel
);
2398 * Free the texture as nobody else will use it, nor refer to it.
2401 wTextureDestroy(scr
, *texture
);
2403 return (reset
? REFRESH_ICON_TILE
: 0);
2406 static int setWinTitleFont(WScreen
* scr
, WDefaultEntry
* entry
, WMFont
* font
, void *foo
)
2408 if (scr
->title_font
) {
2409 WMReleaseFont(scr
->title_font
);
2411 scr
->title_font
= font
;
2413 return REFRESH_WINDOW_FONT
| REFRESH_BUTTON_IMAGES
;
2416 static int setMenuTitleFont(WScreen
* scr
, WDefaultEntry
* entry
, WMFont
* font
, void *foo
)
2418 if (scr
->menu_title_font
) {
2419 WMReleaseFont(scr
->menu_title_font
);
2422 scr
->menu_title_font
= font
;
2424 return REFRESH_MENU_TITLE_FONT
;
2427 static int setMenuTextFont(WScreen
* scr
, WDefaultEntry
* entry
, WMFont
* font
, void *foo
)
2429 if (scr
->menu_entry_font
) {
2430 WMReleaseFont(scr
->menu_entry_font
);
2432 scr
->menu_entry_font
= font
;
2434 return REFRESH_MENU_FONT
;
2437 static int setIconTitleFont(WScreen
* scr
, WDefaultEntry
* entry
, WMFont
* font
, void *foo
)
2439 if (scr
->icon_title_font
) {
2440 WMReleaseFont(scr
->icon_title_font
);
2443 scr
->icon_title_font
= font
;
2445 return REFRESH_ICON_FONT
;
2448 static int setClipTitleFont(WScreen
* scr
, WDefaultEntry
* entry
, WMFont
* font
, void *foo
)
2450 if (scr
->clip_title_font
) {
2451 WMReleaseFont(scr
->clip_title_font
);
2454 scr
->clip_title_font
= font
;
2456 return REFRESH_ICON_FONT
;
2459 static int setLargeDisplayFont(WScreen
* scr
, WDefaultEntry
* entry
, WMFont
* font
, void *foo
)
2461 if (scr
->workspace_name_font
) {
2462 WMReleaseFont(scr
->workspace_name_font
);
2465 scr
->workspace_name_font
= font
;
2470 static int setHightlight(WScreen
* scr
, WDefaultEntry
* entry
, XColor
* color
, void *foo
)
2472 if (scr
->select_color
)
2473 WMReleaseColor(scr
->select_color
);
2475 scr
->select_color
= WMCreateRGBColor(scr
->wmscreen
, color
->red
, color
->green
, color
->blue
, True
);
2477 wFreeColor(scr
, color
->pixel
);
2479 return REFRESH_MENU_COLOR
;
2482 static int setHightlightText(WScreen
* scr
, WDefaultEntry
* entry
, XColor
* color
, void *foo
)
2484 if (scr
->select_text_color
)
2485 WMReleaseColor(scr
->select_text_color
);
2487 scr
->select_text_color
= WMCreateRGBColor(scr
->wmscreen
, color
->red
, color
->green
, color
->blue
, True
);
2489 wFreeColor(scr
, color
->pixel
);
2491 return REFRESH_MENU_COLOR
;
2494 static int setClipTitleColor(WScreen
* scr
, WDefaultEntry
* entry
, XColor
* color
, long widx
)
2496 if (scr
->clip_title_color
[widx
])
2497 WMReleaseColor(scr
->clip_title_color
[widx
]);
2499 scr
->clip_title_color
[widx
] = WMCreateRGBColor(scr
->wmscreen
, color
->red
, color
->green
, color
->blue
, True
);
2500 wFreeColor(scr
, color
->pixel
);
2502 return REFRESH_ICON_TITLE_COLOR
;
2505 static int setWTitleColor(WScreen
* scr
, WDefaultEntry
* entry
, XColor
* color
, long widx
)
2507 if (scr
->window_title_color
[widx
])
2508 WMReleaseColor(scr
->window_title_color
[widx
]);
2510 scr
->window_title_color
[widx
] =
2511 WMCreateRGBColor(scr
->wmscreen
, color
->red
, color
->green
, color
->blue
, True
);
2513 wFreeColor(scr
, color
->pixel
);
2515 return REFRESH_WINDOW_TITLE_COLOR
;
2518 static int setMenuTitleColor(WScreen
* scr
, WDefaultEntry
* entry
, XColor
* color
, long widx
)
2520 if (scr
->menu_title_color
[0])
2521 WMReleaseColor(scr
->menu_title_color
[0]);
2523 scr
->menu_title_color
[0] = WMCreateRGBColor(scr
->wmscreen
, color
->red
, color
->green
, color
->blue
, True
);
2525 wFreeColor(scr
, color
->pixel
);
2527 return REFRESH_MENU_TITLE_COLOR
;
2530 static int setMenuTextColor(WScreen
* scr
, WDefaultEntry
* entry
, XColor
* color
, void *foo
)
2532 if (scr
->mtext_color
)
2533 WMReleaseColor(scr
->mtext_color
);
2535 scr
->mtext_color
= WMCreateRGBColor(scr
->wmscreen
, color
->red
, color
->green
, color
->blue
, True
);
2537 if (WMColorPixel(scr
->dtext_color
) == WMColorPixel(scr
->mtext_color
)) {
2538 WMSetColorAlpha(scr
->dtext_color
, 0x7fff);
2540 WMSetColorAlpha(scr
->dtext_color
, 0xffff);
2543 wFreeColor(scr
, color
->pixel
);
2545 return REFRESH_MENU_COLOR
;
2548 static int setMenuDisabledColor(WScreen
* scr
, WDefaultEntry
* entry
, XColor
* color
, void *foo
)
2550 if (scr
->dtext_color
)
2551 WMReleaseColor(scr
->dtext_color
);
2553 scr
->dtext_color
= WMCreateRGBColor(scr
->wmscreen
, color
->red
, color
->green
, color
->blue
, True
);
2555 if (WMColorPixel(scr
->dtext_color
) == WMColorPixel(scr
->mtext_color
)) {
2556 WMSetColorAlpha(scr
->dtext_color
, 0x7fff);
2558 WMSetColorAlpha(scr
->dtext_color
, 0xffff);
2561 wFreeColor(scr
, color
->pixel
);
2563 return REFRESH_MENU_COLOR
;
2566 static int setIconTitleColor(WScreen
* scr
, WDefaultEntry
* entry
, XColor
* color
, void *foo
)
2568 if (scr
->icon_title_color
)
2569 WMReleaseColor(scr
->icon_title_color
);
2570 scr
->icon_title_color
= WMCreateRGBColor(scr
->wmscreen
, color
->red
, color
->green
, color
->blue
, True
);
2572 wFreeColor(scr
, color
->pixel
);
2574 return REFRESH_ICON_TITLE_COLOR
;
2577 static int setIconTitleBack(WScreen
* scr
, WDefaultEntry
* entry
, XColor
* color
, void *foo
)
2579 if (scr
->icon_title_texture
) {
2580 wTextureDestroy(scr
, (WTexture
*) scr
->icon_title_texture
);
2582 scr
->icon_title_texture
= wTextureMakeSolid(scr
, color
);
2584 return REFRESH_ICON_TITLE_BACK
;
2587 static void trackDeadProcess(pid_t pid
, unsigned char status
, WScreen
* scr
)
2589 close(scr
->helper_fd
);
2591 scr
->helper_pid
= 0;
2592 scr
->flags
.backimage_helper_launched
= 0;
2595 static int setWorkspaceSpecificBack(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *bar
)
2601 if (scr
->flags
.backimage_helper_launched
) {
2602 if (WMGetPropListItemCount(value
) == 0) {
2603 SendHelperMessage(scr
, 'C', 0, NULL
);
2604 SendHelperMessage(scr
, 'K', 0, NULL
);
2606 WMReleasePropList(value
);
2613 if (WMGetPropListItemCount(value
) == 0)
2616 if (pipe(filedes
) < 0) {
2617 werror("pipe() failed:can't set workspace specific background image");
2619 WMReleasePropList(value
);
2625 werror("fork() failed:can't set workspace specific background image");
2626 if (close(filedes
[0]) < 0)
2627 werror("could not close pipe");
2628 if (close(filedes
[1]) < 0)
2629 werror("could not close pipe");
2631 } else if (pid
== 0) {
2634 SetupEnvironment(scr
);
2637 werror("could not close pipe");
2638 if (dup(filedes
[0]) < 0) {
2639 werror("dup() failed:can't set workspace specific background image");
2641 dither
= wPreferences
.no_dithering
? "-m" : "-d";
2642 if (wPreferences
.smooth_workspace_back
)
2643 execlp("wmsetbg", "wmsetbg", "-helper", "-S", dither
, NULL
);
2645 execlp("wmsetbg", "wmsetbg", "-helper", dither
, NULL
);
2646 werror("could not execute wmsetbg");
2650 if (fcntl(filedes
[0], F_SETFD
, FD_CLOEXEC
) < 0) {
2651 werror("error setting close-on-exec flag");
2653 if (fcntl(filedes
[1], F_SETFD
, FD_CLOEXEC
) < 0) {
2654 werror("error setting close-on-exec flag");
2657 scr
->helper_fd
= filedes
[1];
2658 scr
->helper_pid
= pid
;
2659 scr
->flags
.backimage_helper_launched
= 1;
2661 wAddDeathHandler(pid
, (WDeathHandler
*) trackDeadProcess
, scr
);
2663 SendHelperMessage(scr
, 'P', -1, wPreferences
.pixmap_path
);
2668 for (i
= 0; i
< WMGetPropListItemCount(value
); i
++) {
2669 val
= WMGetFromPLArray(value
, i
);
2670 if (val
&& WMIsPLArray(val
) && WMGetPropListItemCount(val
) > 0) {
2671 str
= WMGetPropListDescription(val
, False
);
2673 SendHelperMessage(scr
, 'S', i
+ 1, str
);
2677 SendHelperMessage(scr
, 'U', i
+ 1, NULL
);
2682 WMReleasePropList(value
);
2686 static int setWorkspaceBack(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *bar
)
2688 if (scr
->flags
.backimage_helper_launched
) {
2691 if (WMGetPropListItemCount(value
) == 0) {
2692 SendHelperMessage(scr
, 'U', 0, NULL
);
2694 /* set the default workspace background to this one */
2695 str
= WMGetPropListDescription(value
, False
);
2697 SendHelperMessage(scr
, 'S', 0, str
);
2699 SendHelperMessage(scr
, 'C', scr
->current_workspace
+ 1, NULL
);
2701 SendHelperMessage(scr
, 'U', 0, NULL
);
2704 } else if (WMGetPropListItemCount(value
) > 0) {
2710 text
= WMGetPropListDescription(value
, False
);
2711 len
= strlen(text
) + 40;
2712 command
= wmalloc(len
);
2713 dither
= wPreferences
.no_dithering
? "-m" : "-d";
2714 if (wPreferences
.smooth_workspace_back
)
2715 snprintf(command
, len
, "wmsetbg %s -S -p '%s' &", dither
, text
);
2717 snprintf(command
, len
, "wmsetbg %s -p '%s' &", dither
, text
);
2719 ExecuteShellCommand(scr
, command
);
2722 WMReleasePropList(value
);
2727 static int setWidgetColor(WScreen
* scr
, WDefaultEntry
* entry
, WTexture
** texture
, void *foo
)
2729 if (scr
->widget_texture
) {
2730 wTextureDestroy(scr
, (WTexture
*) scr
->widget_texture
);
2732 scr
->widget_texture
= *(WTexSolid
**) texture
;
2737 static int setFTitleBack(WScreen
* scr
, WDefaultEntry
* entry
, WTexture
** texture
, void *foo
)
2739 if (scr
->window_title_texture
[WS_FOCUSED
]) {
2740 wTextureDestroy(scr
, scr
->window_title_texture
[WS_FOCUSED
]);
2742 scr
->window_title_texture
[WS_FOCUSED
] = *texture
;
2744 return REFRESH_WINDOW_TEXTURES
;
2747 static int setPTitleBack(WScreen
* scr
, WDefaultEntry
* entry
, WTexture
** texture
, void *foo
)
2749 if (scr
->window_title_texture
[WS_PFOCUSED
]) {
2750 wTextureDestroy(scr
, scr
->window_title_texture
[WS_PFOCUSED
]);
2752 scr
->window_title_texture
[WS_PFOCUSED
] = *texture
;
2754 return REFRESH_WINDOW_TEXTURES
;
2757 static int setUTitleBack(WScreen
* scr
, WDefaultEntry
* entry
, WTexture
** texture
, void *foo
)
2759 if (scr
->window_title_texture
[WS_UNFOCUSED
]) {
2760 wTextureDestroy(scr
, scr
->window_title_texture
[WS_UNFOCUSED
]);
2762 scr
->window_title_texture
[WS_UNFOCUSED
] = *texture
;
2764 return REFRESH_WINDOW_TEXTURES
;
2767 static int setResizebarBack(WScreen
* scr
, WDefaultEntry
* entry
, WTexture
** texture
, void *foo
)
2769 if (scr
->resizebar_texture
[0]) {
2770 wTextureDestroy(scr
, scr
->resizebar_texture
[0]);
2772 scr
->resizebar_texture
[0] = *texture
;
2774 return REFRESH_WINDOW_TEXTURES
;
2777 static int setMenuTitleBack(WScreen
* scr
, WDefaultEntry
* entry
, WTexture
** texture
, void *foo
)
2779 if (scr
->menu_title_texture
[0]) {
2780 wTextureDestroy(scr
, scr
->menu_title_texture
[0]);
2782 scr
->menu_title_texture
[0] = *texture
;
2784 return REFRESH_MENU_TITLE_TEXTURE
;
2787 static int setMenuTextBack(WScreen
* scr
, WDefaultEntry
* entry
, WTexture
** texture
, void *foo
)
2789 if (scr
->menu_item_texture
) {
2790 wTextureDestroy(scr
, scr
->menu_item_texture
);
2791 wTextureDestroy(scr
, (WTexture
*) scr
->menu_item_auxtexture
);
2793 scr
->menu_item_texture
= *texture
;
2795 scr
->menu_item_auxtexture
= wTextureMakeSolid(scr
, &scr
->menu_item_texture
->any
.color
);
2797 return REFRESH_MENU_TEXTURE
;
2800 static int setKeyGrab(WScreen
* scr
, WDefaultEntry
* entry
, WShortKey
* shortcut
, long widx
)
2803 wKeyBindings
[widx
] = *shortcut
;
2805 wwin
= scr
->focused_window
;
2807 while (wwin
!= NULL
) {
2808 XUngrabKey(dpy
, AnyKey
, AnyModifier
, wwin
->frame
->core
->window
);
2810 if (!WFLAGP(wwin
, no_bind_keys
)) {
2811 wWindowSetKeyGrabs(wwin
);
2819 static int setIconPosition(WScreen
* scr
, WDefaultEntry
* entry
, void *bar
, void *foo
)
2821 wScreenUpdateUsableArea(scr
);
2822 wArrangeIcons(scr
, True
);
2827 static int updateUsableArea(WScreen
* scr
, WDefaultEntry
* entry
, void *bar
, void *foo
)
2829 wScreenUpdateUsableArea(scr
);
2834 static int setMenuStyle(WScreen
* scr
, WDefaultEntry
* entry
, int *value
, void *foo
)
2836 return REFRESH_MENU_TEXTURE
;
2839 static RImage
*chopOffImage(RImage
* image
, int x
, int y
, int w
, int h
)
2841 RImage
*img
= RCreateImage(w
, h
, image
->format
== RRGBAFormat
);
2843 RCopyArea(img
, image
, x
, y
, w
, h
, 0, 0);
2848 static int setSwPOptions(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* array
, void *foo
)
2852 int cwidth
, cheight
;
2853 WPreferences
*prefs
= (WPreferences
*) foo
;
2855 if (!WMIsPLArray(array
) || WMGetPropListItemCount(array
) == 0) {
2856 if (prefs
->swtileImage
)
2857 RReleaseImage(prefs
->swtileImage
);
2858 prefs
->swtileImage
= NULL
;
2860 WMReleasePropList(array
);
2864 switch (WMGetPropListItemCount(array
)) {
2866 if (!WMIsPLString(WMGetFromPLArray(array
, 1))) {
2867 wwarning(_("Invalid arguments for option \"%s\""), entry
->key
);
2870 path
= FindImage(wPreferences
.pixmap_path
, WMGetFromPLString(WMGetFromPLArray(array
, 1)));
2873 wwarning(_("Could not find image \"%s\" for option \"%s\""),
2874 WMGetFromPLString(WMGetFromPLArray(array
, 1)), entry
->key
);
2876 bgimage
= RLoadImage(scr
->rcontext
, path
, 0);
2878 wwarning(_("Could not load image \"%s\" for option \"%s\""), path
, entry
->key
);
2883 cwidth
= atoi(WMGetFromPLString(WMGetFromPLArray(array
, 2)));
2884 cheight
= atoi(WMGetFromPLString(WMGetFromPLArray(array
, 3)));
2886 if (cwidth
<= 0 || cheight
<= 0 ||
2887 cwidth
>= bgimage
->width
- 2 || cheight
>= bgimage
->height
- 2)
2888 wwarning(_("Invalid split sizes for SwitchPanel back image."));
2891 int swidth
, theight
;
2892 for (i
= 0; i
< 9; i
++) {
2893 if (prefs
->swbackImage
[i
])
2894 RReleaseImage(prefs
->swbackImage
[i
]);
2895 prefs
->swbackImage
[i
] = NULL
;
2897 swidth
= (bgimage
->width
- cwidth
) / 2;
2898 theight
= (bgimage
->height
- cheight
) / 2;
2900 prefs
->swbackImage
[0] = chopOffImage(bgimage
, 0, 0, swidth
, theight
);
2901 prefs
->swbackImage
[1] = chopOffImage(bgimage
, swidth
, 0, cwidth
, theight
);
2902 prefs
->swbackImage
[2] = chopOffImage(bgimage
, swidth
+ cwidth
, 0,
2905 prefs
->swbackImage
[3] = chopOffImage(bgimage
, 0, theight
, swidth
, cheight
);
2906 prefs
->swbackImage
[4] = chopOffImage(bgimage
, swidth
, theight
,
2908 prefs
->swbackImage
[5] = chopOffImage(bgimage
, swidth
+ cwidth
, theight
,
2911 prefs
->swbackImage
[6] = chopOffImage(bgimage
, 0, theight
+ cheight
,
2913 prefs
->swbackImage
[7] = chopOffImage(bgimage
, swidth
, theight
+ cheight
,
2915 prefs
->swbackImage
[8] =
2916 chopOffImage(bgimage
, swidth
+ cwidth
, theight
+ cheight
, swidth
,
2919 // check if anything failed
2920 for (i
= 0; i
< 9; i
++) {
2921 if (!prefs
->swbackImage
[i
]) {
2922 for (; i
>= 0; --i
) {
2923 RReleaseImage(prefs
->swbackImage
[i
]);
2924 prefs
->swbackImage
[i
] = NULL
;
2930 RReleaseImage(bgimage
);
2935 if (!WMIsPLString(WMGetFromPLArray(array
, 0))) {
2936 wwarning(_("Invalid arguments for option \"%s\""), entry
->key
);
2939 path
= FindImage(wPreferences
.pixmap_path
, WMGetFromPLString(WMGetFromPLArray(array
, 0)));
2942 wwarning(_("Could not find image \"%s\" for option \"%s\""),
2943 WMGetFromPLString(WMGetFromPLArray(array
, 0)), entry
->key
);
2945 if (prefs
->swtileImage
)
2946 RReleaseImage(prefs
->swtileImage
);
2948 prefs
->swtileImage
= RLoadImage(scr
->rcontext
, path
, 0);
2949 if (!prefs
->swtileImage
) {
2950 wwarning(_("Could not load image \"%s\" for option \"%s\""), path
, entry
->key
);
2957 wwarning(_("Invalid number of arguments for option \"%s\""), entry
->key
);
2961 WMReleasePropList(array
);
2966 static int setModifierKeyLabels(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* array
, void *foo
)
2969 WPreferences
*prefs
= (WPreferences
*) foo
;
2971 if (!WMIsPLArray(array
) || WMGetPropListItemCount(array
) != 7) {
2972 wwarning(_("Value for option \"%s\" must be an array of 7 strings"), entry
->key
);
2973 WMReleasePropList(array
);
2977 DestroyWindowMenu(scr
);
2979 for (i
= 0; i
< 7; i
++) {
2980 if (prefs
->modifier_labels
[i
])
2981 wfree(prefs
->modifier_labels
[i
]);
2983 if (WMIsPLString(WMGetFromPLArray(array
, i
))) {
2984 prefs
->modifier_labels
[i
] = wstrdup(WMGetFromPLString(WMGetFromPLArray(array
, i
)));
2986 wwarning(_("Invalid argument for option \"%s\" item %d"), entry
->key
, i
);
2987 prefs
->modifier_labels
[i
] = NULL
;
2991 WMReleasePropList(array
);
2998 * Need access to the double click variables, so that all widgets in
2999 * wmaker panels will have the same dbl-click values.
3000 * TODO: figure a better way of dealing with it.
3002 #include <WINGs/WINGsP.h>
3004 static int setDoubleClick(WScreen
* scr
, WDefaultEntry
* entry
, int *value
, void *foo
)
3006 extern _WINGsConfiguration WINGsConfiguration
;
3011 WINGsConfiguration
.doubleClickDelay
= *value
;
3016 static int setCursor(WScreen
* scr
, WDefaultEntry
* entry
, Cursor
* cursor
, long widx
)
3018 if (wCursor
[widx
] != None
) {
3019 XFreeCursor(dpy
, wCursor
[widx
]);
3022 wCursor
[widx
] = *cursor
;
3024 if (widx
== WCUR_ROOT
&& *cursor
!= None
) {
3025 XDefineCursor(dpy
, scr
->root_win
, *cursor
);