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 setFrameBorderWidth();
126 static int setFrameBorderColor();
127 static int setFrameSelectedBorderColor();
128 static int setLargeDisplayFont();
129 static int setWTitleColor();
130 static int setFTitleBack();
131 static int setPTitleBack();
132 static int setUTitleBack();
133 static int setResizebarBack();
134 static int setWorkspaceBack();
135 static int setWorkspaceSpecificBack();
136 static int setMenuTitleColor();
137 static int setMenuTextColor();
138 static int setMenuDisabledColor();
139 static int setMenuTitleBack();
140 static int setMenuTextBack();
141 static int setHightlight();
142 static int setHightlightText();
143 static int setKeyGrab();
144 static int setDoubleClick();
145 static int setIconPosition();
147 static int setClipTitleFont();
148 static int setClipTitleColor();
150 static int setMenuStyle();
151 static int setSwPOptions();
152 static int updateUsableArea();
154 static int setModifierKeyLabels();
156 extern Cursor wCursor
[WCUR_LAST
];
157 static int getCursor();
158 static int setCursor();
161 * Tables to convert strings to enumeration values.
162 * Values stored are char
165 /* WARNING: sum of length of all value strings must not exceed
167 #define TOTAL_VALUES_LENGTH 80
169 #define REFRESH_WINDOW_TEXTURES (1<<0)
170 #define REFRESH_MENU_TEXTURE (1<<1)
171 #define REFRESH_MENU_FONT (1<<2)
172 #define REFRESH_MENU_COLOR (1<<3)
173 #define REFRESH_MENU_TITLE_TEXTURE (1<<4)
174 #define REFRESH_MENU_TITLE_FONT (1<<5)
175 #define REFRESH_MENU_TITLE_COLOR (1<<6)
176 #define REFRESH_WINDOW_TITLE_COLOR (1<<7)
177 #define REFRESH_WINDOW_FONT (1<<8)
178 #define REFRESH_ICON_TILE (1<<9)
179 #define REFRESH_ICON_FONT (1<<10)
180 #define REFRESH_WORKSPACE_BACK (1<<11)
182 #define REFRESH_BUTTON_IMAGES (1<<12)
184 #define REFRESH_ICON_TITLE_COLOR (1<<13)
185 #define REFRESH_ICON_TITLE_BACK (1<<14)
187 #define REFRESH_WORKSPACE_MENU (1<<15)
189 #define REFRESH_FRAME_BORDER REFRESH_MENU_FONT|REFRESH_WINDOW_FONT
191 static WOptionEnumeration seFocusModes
[] = {
192 {"Manual", WKF_CLICK
, 0}, {"ClickToFocus", WKF_CLICK
, 1},
193 {"Sloppy", WKF_SLOPPY
, 0}, {"SemiAuto", WKF_SLOPPY
, 1}, {"Auto", WKF_SLOPPY
, 1},
197 static WOptionEnumeration seTitlebarModes
[] = {
198 {"new", TS_NEW
, 0}, {"old", TS_OLD
, 0},
199 {"next", TS_NEXT
, 0}, {NULL
, 0, 0}
202 static WOptionEnumeration seColormapModes
[] = {
203 {"Manual", WCM_CLICK
, 0}, {"ClickToFocus", WCM_CLICK
, 1},
204 {"Auto", WCM_POINTER
, 0}, {"FocusFollowMouse", WCM_POINTER
, 1},
208 static WOptionEnumeration sePlacements
[] = {
209 {"Auto", WPM_AUTO
, 0},
210 {"Smart", WPM_SMART
, 0},
211 {"Cascade", WPM_CASCADE
, 0},
212 {"Random", WPM_RANDOM
, 0},
213 {"Manual", WPM_MANUAL
, 0},
214 {"Center", WPM_CENTER
, 0},
218 static WOptionEnumeration seGeomDisplays
[] = {
219 {"None", WDIS_NONE
, 0},
220 {"Center", WDIS_CENTER
, 0},
221 {"Corner", WDIS_TOPLEFT
, 0},
222 {"Floating", WDIS_FRAME_CENTER
, 0},
223 {"Line", WDIS_NEW
, 0},
227 static WOptionEnumeration seSpeeds
[] = {
228 {"UltraFast", SPEED_ULTRAFAST
, 0},
229 {"Fast", SPEED_FAST
, 0},
230 {"Medium", SPEED_MEDIUM
, 0},
231 {"Slow", SPEED_SLOW
, 0},
232 {"UltraSlow", SPEED_ULTRASLOW
, 0},
236 static WOptionEnumeration seMouseButtonActions
[] = {
237 {"None", WA_NONE
, 0},
238 {"SelectWindows", WA_SELECT_WINDOWS
, 0},
239 {"OpenApplicationsMenu", WA_OPEN_APPMENU
, 0},
240 {"OpenWindowListMenu", WA_OPEN_WINLISTMENU
, 0},
244 static WOptionEnumeration seMouseWheelActions
[] = {
245 {"None", WA_NONE
, 0},
246 {"SwitchWorkspaces", WA_SWITCH_WORKSPACES
, 0},
250 static WOptionEnumeration seIconificationStyles
[] = {
251 {"Zoom", WIS_ZOOM
, 0},
252 {"Twist", WIS_TWIST
, 0},
253 {"Flip", WIS_FLIP
, 0},
254 {"None", WIS_NONE
, 0},
255 {"random", WIS_RANDOM
, 0},
259 static WOptionEnumeration seJustifications
[] = {
260 {"Left", WTJ_LEFT
, 0},
261 {"Center", WTJ_CENTER
, 0},
262 {"Right", WTJ_RIGHT
, 0},
266 static WOptionEnumeration seIconPositions
[] = {
267 {"blv", IY_BOTTOM
| IY_LEFT
| IY_VERT
, 0},
268 {"blh", IY_BOTTOM
| IY_LEFT
| IY_HORIZ
, 0},
269 {"brv", IY_BOTTOM
| IY_RIGHT
| IY_VERT
, 0},
270 {"brh", IY_BOTTOM
| IY_RIGHT
| IY_HORIZ
, 0},
271 {"tlv", IY_TOP
| IY_LEFT
| IY_VERT
, 0},
272 {"tlh", IY_TOP
| IY_LEFT
| IY_HORIZ
, 0},
273 {"trv", IY_TOP
| IY_RIGHT
| IY_VERT
, 0},
274 {"trh", IY_TOP
| IY_RIGHT
| IY_HORIZ
, 0},
278 static WOptionEnumeration seMenuStyles
[] = {
279 {"normal", MS_NORMAL
, 0},
280 {"singletexture", MS_SINGLE_TEXTURE
, 0},
281 {"flat", MS_FLAT
, 0},
285 static WOptionEnumeration seDisplayPositions
[] = {
286 {"none", WD_NONE
, 0},
287 {"center", WD_CENTER
, 0},
289 {"bottom", WD_BOTTOM
, 0},
290 {"topleft", WD_TOPLEFT
, 0},
291 {"topright", WD_TOPRIGHT
, 0},
292 {"bottomleft", WD_BOTTOMLEFT
, 0},
293 {"bottomright", WD_BOTTOMRIGHT
, 0},
297 static WOptionEnumeration seWorkspaceBorder
[] = {
298 {"None", WB_NONE
, 0},
299 {"LeftRight", WB_LEFTRIGHT
, 0},
300 {"TopBottom", WB_TOPBOTTOM
, 0},
301 {"AllDirections", WB_ALLDIRS
, 0},
306 * ALL entries in the tables bellow, NEED to have a default value
307 * defined, and this value needs to be correct.
310 /* these options will only affect the window manager on startup
312 * static defaults can't access the screen data, because it is
313 * created after these defaults are read
315 WDefaultEntry staticOptionList
[] = {
317 {"ColormapSize", "4", NULL
,
318 &wPreferences
.cmap_size
, getInt
, NULL
, NULL
, NULL
},
319 {"DisableDithering", "NO", NULL
,
320 &wPreferences
.no_dithering
, getBool
, NULL
, NULL
, NULL
},
321 {"IconSize", "64", NULL
,
322 &wPreferences
.icon_size
, getInt
, NULL
, NULL
, NULL
},
323 {"ModifierKey", "Mod1", NULL
,
324 &wPreferences
.modifier_mask
, getModMask
, NULL
, NULL
, NULL
},
325 {"DisableWSMouseActions", "NO", NULL
,
326 &wPreferences
.disable_root_mouse
, getBool
, NULL
, NULL
, NULL
},
327 {"FocusMode", "manual", seFocusModes
, /* have a problem when switching from */
328 &wPreferences
.focus_mode
, getEnum
, NULL
, NULL
, NULL
}, /* manual to sloppy without restart */
329 {"NewStyle", "new", seTitlebarModes
,
330 &wPreferences
.new_style
, getEnum
, NULL
, NULL
, NULL
},
331 {"DisableDock", "NO", (void *)WM_DOCK
,
332 NULL
, getBool
, setIfDockPresent
, NULL
, NULL
},
333 {"DisableClip", "NO", (void *)WM_CLIP
,
334 NULL
, getBool
, setIfDockPresent
, NULL
, NULL
},
335 {"DisableMiniwindows", "NO", NULL
,
336 &wPreferences
.disable_miniwindows
, getBool
, NULL
, NULL
, NULL
}
339 #define NUM2STRING_(x) #x
340 #define NUM2STRING(x) NUM2STRING_(x)
342 WDefaultEntry optionList
[] = {
344 /* dynamic options */
346 {"IconPosition", "blh", seIconPositions
,
347 &wPreferences
.icon_yard
, getEnum
, setIconPosition
, NULL
, NULL
},
348 {"IconificationStyle", "Zoom", seIconificationStyles
,
349 &wPreferences
.iconification_style
, getEnum
, NULL
, NULL
, NULL
},
350 {"MouseLeftButtonAction", "SelectWindows", seMouseButtonActions
,
351 &wPreferences
.mouse_button1
, getEnum
, NULL
, NULL
, NULL
},
352 {"MouseMiddleButtonAction", "OpenWindowListMenu", seMouseButtonActions
,
353 &wPreferences
.mouse_button2
, getEnum
, NULL
, NULL
, NULL
},
354 {"MouseRightButtonAction", "OpenApplicationsMenu", seMouseButtonActions
,
355 &wPreferences
.mouse_button3
, getEnum
, NULL
, NULL
, NULL
},
356 {"MouseWheelAction", "None", seMouseWheelActions
,
357 &wPreferences
.mouse_wheel
, getEnum
, NULL
, NULL
, NULL
},
358 {"PixmapPath", DEF_PIXMAP_PATHS
, NULL
,
359 &wPreferences
.pixmap_path
, getPathList
, NULL
, NULL
, NULL
},
360 {"IconPath", DEF_ICON_PATHS
, NULL
,
361 &wPreferences
.icon_path
, getPathList
, NULL
, NULL
, NULL
},
362 {"ColormapMode", "auto", seColormapModes
,
363 &wPreferences
.colormap_mode
, getEnum
, NULL
, NULL
, NULL
},
364 {"AutoFocus", "NO", NULL
,
365 &wPreferences
.auto_focus
, getBool
, NULL
, NULL
, NULL
},
366 {"RaiseDelay", "0", NULL
,
367 &wPreferences
.raise_delay
, getInt
, NULL
, NULL
, NULL
},
368 {"CirculateRaise", "NO", NULL
,
369 &wPreferences
.circ_raise
, getBool
, NULL
, NULL
, NULL
},
370 {"Superfluous", "NO", NULL
,
371 &wPreferences
.superfluous
, getBool
, NULL
, NULL
, NULL
},
372 {"AdvanceToNewWorkspace", "NO", NULL
,
373 &wPreferences
.ws_advance
, getBool
, NULL
, NULL
, NULL
},
374 {"CycleWorkspaces", "NO", NULL
,
375 &wPreferences
.ws_cycle
, getBool
, NULL
, NULL
, NULL
},
376 {"WorkspaceNameDisplayPosition", "center", seDisplayPositions
,
377 &wPreferences
.workspace_name_display_position
, getEnum
, NULL
, NULL
, NULL
},
378 {"WorkspaceBorder", "None", seWorkspaceBorder
,
379 &wPreferences
.workspace_border_position
, getEnum
, updateUsableArea
, NULL
, NULL
},
380 {"WorkspaceBorderSize", "0", NULL
,
381 &wPreferences
.workspace_border_size
, getInt
, updateUsableArea
, NULL
, NULL
},
382 {"StickyIcons", "NO", NULL
,
383 &wPreferences
.sticky_icons
, getBool
, setStickyIcons
, NULL
, NULL
},
384 {"SaveSessionOnExit", "NO", NULL
,
385 &wPreferences
.save_session_on_exit
, getBool
, NULL
, NULL
, NULL
},
386 {"WrapMenus", "NO", NULL
,
387 &wPreferences
.wrap_menus
, getBool
, NULL
, NULL
, NULL
},
388 {"ScrollableMenus", "NO", NULL
,
389 &wPreferences
.scrollable_menus
, getBool
, NULL
, NULL
, NULL
},
390 {"MenuScrollSpeed", "medium", seSpeeds
,
391 &wPreferences
.menu_scroll_speed
, getEnum
, NULL
, NULL
, NULL
},
392 {"IconSlideSpeed", "medium", seSpeeds
,
393 &wPreferences
.icon_slide_speed
, getEnum
, NULL
, NULL
, NULL
},
394 {"ShadeSpeed", "medium", seSpeeds
,
395 &wPreferences
.shade_speed
, getEnum
, NULL
, NULL
, NULL
},
396 {"BounceAppIconsWhenUrgent", "YES", NULL
,
397 &wPreferences
.bounce_appicons_when_urgent
, getBool
, NULL
, NULL
, NULL
},
398 {"RaiseAppIconsWhenBouncing", "NO", NULL
,
399 &wPreferences
.raise_appicons_when_bouncing
, getBool
, NULL
, NULL
, NULL
},
400 {"DoNotMakeAppIconsBounce", "NO", NULL
,
401 &wPreferences
.do_not_make_appicons_bounce
, getBool
, NULL
, NULL
, NULL
},
402 {"DoubleClickTime", "250", (void *)&wPreferences
.dblclick_time
,
403 &wPreferences
.dblclick_time
, getInt
, setDoubleClick
, NULL
, NULL
},
404 {"AlignSubmenus", "NO", NULL
,
405 &wPreferences
.align_menus
, getBool
, NULL
, NULL
, NULL
},
406 {"ViKeyMenus", "NO", NULL
,
407 &wPreferences
.vi_key_menus
, getBool
, NULL
, NULL
, NULL
},
408 {"OpenTransientOnOwnerWorkspace", "NO", NULL
,
409 &wPreferences
.open_transients_with_parent
, getBool
, NULL
, NULL
, NULL
},
410 {"WindowPlacement", "auto", sePlacements
,
411 &wPreferences
.window_placement
, getEnum
, NULL
, NULL
, NULL
},
412 {"IgnoreFocusClick", "NO", NULL
,
413 &wPreferences
.ignore_focus_click
, getBool
, NULL
, NULL
, NULL
},
414 {"UseSaveUnders", "NO", NULL
,
415 &wPreferences
.use_saveunders
, getBool
, NULL
, NULL
, NULL
},
416 {"OpaqueMove", "NO", NULL
,
417 &wPreferences
.opaque_move
, getBool
, NULL
, NULL
, NULL
},
418 {"OpaqueResize", "NO", NULL
,
419 &wPreferences
.opaque_resize
, getBool
, NULL
, NULL
, NULL
},
420 {"OpaqueMoveResizeKeyboard", "NO", NULL
,
421 &wPreferences
.opaque_move_resize_keyboard
, getBool
, NULL
, NULL
, NULL
},
422 {"DisableAnimations", "NO", NULL
,
423 &wPreferences
.no_animations
, getBool
, NULL
, NULL
, NULL
},
424 {"DontLinkWorkspaces", "NO", NULL
,
425 &wPreferences
.no_autowrap
, getBool
, NULL
, NULL
, NULL
},
426 {"HighlightActiveApp", "YES", NULL
,
427 &wPreferences
.highlight_active_app
, getBool
, NULL
, NULL
, NULL
},
428 {"AutoArrangeIcons", "NO", NULL
,
429 &wPreferences
.auto_arrange_icons
, getBool
, NULL
, NULL
, NULL
},
430 {"NoWindowOverDock", "NO", NULL
,
431 &wPreferences
.no_window_over_dock
, getBool
, updateUsableArea
, NULL
, NULL
},
432 {"NoWindowOverIcons", "NO", NULL
,
433 &wPreferences
.no_window_over_icons
, getBool
, updateUsableArea
, NULL
, NULL
},
434 {"WindowPlaceOrigin", "(0, 0)", NULL
,
435 &wPreferences
.window_place_origin
, getCoord
, NULL
, NULL
, NULL
},
436 {"ResizeDisplay", "corner", seGeomDisplays
,
437 &wPreferences
.size_display
, getEnum
, NULL
, NULL
, NULL
},
438 {"MoveDisplay", "corner", seGeomDisplays
,
439 &wPreferences
.move_display
, getEnum
, NULL
, NULL
, NULL
},
440 {"DontConfirmKill", "NO", NULL
,
441 &wPreferences
.dont_confirm_kill
, getBool
, NULL
, NULL
, NULL
},
442 {"WindowTitleBalloons", "NO", NULL
,
443 &wPreferences
.window_balloon
, getBool
, NULL
, NULL
, NULL
},
444 {"MiniwindowTitleBalloons", "NO", NULL
,
445 &wPreferences
.miniwin_balloon
, getBool
, NULL
, NULL
, NULL
},
446 {"AppIconBalloons", "NO", NULL
,
447 &wPreferences
.appicon_balloon
, getBool
, NULL
, NULL
, NULL
},
448 {"HelpBalloons", "NO", NULL
,
449 &wPreferences
.help_balloon
, getBool
, NULL
, NULL
, NULL
},
450 {"EdgeResistance", "30", NULL
,
451 &wPreferences
.edge_resistance
, getInt
, NULL
, NULL
, NULL
},
452 {"ResizeIncrement", "0", NULL
,
453 &wPreferences
.resize_increment
, getInt
, NULL
, NULL
, NULL
},
454 {"Attraction", "NO", NULL
,
455 &wPreferences
.attract
, getBool
, NULL
, NULL
, NULL
},
456 {"DisableBlinking", "NO", NULL
,
457 &wPreferences
.dont_blink
, getBool
, NULL
, NULL
, NULL
},
458 {"SingleClickLaunch", "NO", NULL
,
459 &wPreferences
.single_click
, getBool
, NULL
, NULL
, NULL
},
463 {"MenuStyle", "normal", seMenuStyles
,
464 &wPreferences
.menu_style
, getEnum
, setMenuStyle
, NULL
, NULL
},
465 {"WidgetColor", "(solid, gray)", NULL
,
466 NULL
, getTexture
, setWidgetColor
, NULL
, NULL
},
467 {"WorkspaceSpecificBack", "()", NULL
,
468 NULL
, getWSSpecificBackground
, setWorkspaceSpecificBack
, NULL
, NULL
},
469 /* WorkspaceBack must come after WorkspaceSpecificBack or
470 * WorkspaceBack wont know WorkspaceSpecificBack was also
471 * specified and 2 copies of wmsetbg will be launched */
472 {"WorkspaceBack", "(solid, black)", NULL
,
473 NULL
, getWSBackground
, setWorkspaceBack
, NULL
, NULL
},
474 {"SmoothWorkspaceBack", "NO", NULL
,
475 NULL
, getBool
, NULL
, NULL
, NULL
},
476 {"IconBack", "(solid, gray)", NULL
,
477 NULL
, getTexture
, setIconTile
, NULL
, NULL
},
478 {"TitleJustify", "center", seJustifications
,
479 &wPreferences
.title_justification
, getEnum
, setJustify
, NULL
, NULL
},
480 {"WindowTitleFont", DEF_TITLE_FONT
, NULL
,
481 NULL
, getFont
, setWinTitleFont
, NULL
, NULL
},
482 {"WindowTitleExtendSpace", DEF_WINDOW_TITLE_EXTEND_SPACE
, NULL
,
483 &wPreferences
.window_title_clearance
, getInt
, setClearance
, NULL
, NULL
},
484 {"WindowTitleMinHeight", "0", NULL
,
485 &wPreferences
.window_title_min_height
, getInt
, setClearance
, NULL
, NULL
},
486 {"WindowTitleMaxHeight", NUM2STRING(INT_MAX
), NULL
,
487 &wPreferences
.window_title_max_height
, getInt
, setClearance
, NULL
, NULL
},
488 {"MenuTitleExtendSpace", DEF_MENU_TITLE_EXTEND_SPACE
, NULL
,
489 &wPreferences
.menu_title_clearance
, getInt
, setClearance
, NULL
, NULL
},
490 {"MenuTitleMinHeight", "0", NULL
,
491 &wPreferences
.menu_title_min_height
, getInt
, setClearance
, NULL
, NULL
},
492 {"MenuTitleMaxHeight", NUM2STRING(INT_MAX
), NULL
,
493 &wPreferences
.menu_title_max_height
, getInt
, setClearance
, NULL
, NULL
},
494 {"MenuTextExtendSpace", DEF_MENU_TEXT_EXTEND_SPACE
, NULL
,
495 &wPreferences
.menu_text_clearance
, getInt
, setClearance
, NULL
, NULL
},
496 {"MenuTitleFont", DEF_MENU_TITLE_FONT
, NULL
,
497 NULL
, getFont
, setMenuTitleFont
, NULL
, NULL
},
498 {"MenuTextFont", DEF_MENU_ENTRY_FONT
, NULL
,
499 NULL
, getFont
, setMenuTextFont
, NULL
, NULL
},
500 {"IconTitleFont", DEF_ICON_TITLE_FONT
, NULL
,
501 NULL
, getFont
, setIconTitleFont
, NULL
, NULL
},
502 {"ClipTitleFont", DEF_CLIP_TITLE_FONT
, NULL
,
503 NULL
, getFont
, setClipTitleFont
, NULL
, NULL
},
504 {"ShowClipTitle", "YES", NULL
,
505 &wPreferences
.show_clip_title
, getBool
, NULL
, NULL
, NULL
},
506 {"LargeDisplayFont", DEF_WORKSPACE_NAME_FONT
, NULL
,
507 NULL
, getFont
, setLargeDisplayFont
, NULL
, NULL
},
508 {"HighlightColor", "white", NULL
,
509 NULL
, getColor
, setHightlight
, NULL
, NULL
},
510 {"HighlightTextColor", "black", NULL
,
511 NULL
, getColor
, setHightlightText
, NULL
, NULL
},
512 {"ClipTitleColor", "black", (void *)CLIP_NORMAL
,
513 NULL
, getColor
, setClipTitleColor
, NULL
, NULL
},
514 {"CClipTitleColor", "\"#454045\"", (void *)CLIP_COLLAPSED
,
515 NULL
, getColor
, setClipTitleColor
, NULL
, NULL
},
516 {"FTitleColor", "white", (void *)WS_FOCUSED
,
517 NULL
, getColor
, setWTitleColor
, NULL
, NULL
},
518 {"PTitleColor", "white", (void *)WS_PFOCUSED
,
519 NULL
, getColor
, setWTitleColor
, NULL
, NULL
},
520 {"UTitleColor", "black", (void *)WS_UNFOCUSED
,
521 NULL
, getColor
, setWTitleColor
, NULL
, NULL
},
522 {"FTitleBack", "(solid, black)", NULL
,
523 NULL
, getTexture
, setFTitleBack
, NULL
, NULL
},
524 {"PTitleBack", "(solid, \"#616161\")", NULL
,
525 NULL
, getTexture
, setPTitleBack
, NULL
, NULL
},
526 {"UTitleBack", "(solid, gray)", NULL
,
527 NULL
, getTexture
, setUTitleBack
, NULL
, NULL
},
528 {"ResizebarBack", "(solid, gray)", NULL
,
529 NULL
, getTexture
, setResizebarBack
, NULL
, NULL
},
530 {"MenuTitleColor", "white", NULL
,
531 NULL
, getColor
, setMenuTitleColor
, NULL
, NULL
},
532 {"MenuTextColor", "black", NULL
,
533 NULL
, getColor
, setMenuTextColor
, NULL
, NULL
},
534 {"MenuDisabledColor", "\"#616161\"", NULL
,
535 NULL
, getColor
, setMenuDisabledColor
, NULL
, NULL
},
536 {"MenuTitleBack", "(solid, black)", NULL
,
537 NULL
, getTexture
, setMenuTitleBack
, NULL
, NULL
},
538 {"MenuTextBack", "(solid, gray)", NULL
,
539 NULL
, getTexture
, setMenuTextBack
, NULL
, NULL
},
540 {"IconTitleColor", "white", NULL
,
541 NULL
, getColor
, setIconTitleColor
, NULL
, NULL
},
542 {"IconTitleBack", "black", NULL
,
543 NULL
, getColor
, setIconTitleBack
, NULL
, NULL
},
544 {"SwitchPanelImages", "(swtile.png, swback.png, 30, 40)", &wPreferences
,
545 NULL
, getPropList
, setSwPOptions
, NULL
, NULL
},
546 {"ModifierKeyLabels", "(\"Shift+\", \"Ctrl+\", \"Mod1+\", \"Mod2+\", \"Mod3+\", \"Mod4+\", \"Mod5+\")", &wPreferences
,
547 NULL
, getPropList
, setModifierKeyLabels
, NULL
, NULL
},
548 {"FrameBorderWidth", "1", NULL
,
549 NULL
, getInt
, setFrameBorderWidth
, NULL
, NULL
},
550 {"FrameBorderColor", "black", NULL
,
551 NULL
, getColor
, setFrameBorderColor
, NULL
, NULL
},
552 {"FrameSelectedBorderColor", "white", NULL
,
553 NULL
, getColor
, setFrameSelectedBorderColor
, NULL
, NULL
},
557 {"RootMenuKey", "None", (void *)WKBD_ROOTMENU
,
558 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
559 {"WindowListKey", "None", (void *)WKBD_WINDOWLIST
,
560 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
561 {"WindowMenuKey", "None", (void *)WKBD_WINDOWMENU
,
562 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
563 {"DockRaiseLowerKey", "None", (void*)WKBD_DOCKRAISELOWER
,
564 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
565 {"ClipRaiseLowerKey", "None", (void *)WKBD_CLIPRAISELOWER
,
566 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
567 {"MiniaturizeKey", "None", (void *)WKBD_MINIATURIZE
,
568 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
569 {"MinimizeAllKey", "None", (void *)WKBD_MINIMIZEALL
,
570 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
571 {"HideKey", "None", (void *)WKBD_HIDE
,
572 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
573 {"HideOthersKey", "None", (void *)WKBD_HIDE_OTHERS
,
574 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
575 {"MoveResizeKey", "None", (void *)WKBD_MOVERESIZE
,
576 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
577 {"CloseKey", "None", (void *)WKBD_CLOSE
,
578 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
579 {"MaximizeKey", "None", (void *)WKBD_MAXIMIZE
,
580 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
581 {"VMaximizeKey", "None", (void *)WKBD_VMAXIMIZE
,
582 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
583 {"HMaximizeKey", "None", (void *)WKBD_HMAXIMIZE
,
584 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
585 {"LHMaximizeKey", "None", (void*)WKBD_LHMAXIMIZE
,
586 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
587 {"RHMaximizeKey", "None", (void*)WKBD_RHMAXIMIZE
,
588 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
589 {"MaximusKey", "None", (void*)WKBD_MAXIMUS
,
590 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
591 {"RaiseKey", "\"Meta+Up\"", (void *)WKBD_RAISE
,
592 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
593 {"LowerKey", "\"Meta+Down\"", (void *)WKBD_LOWER
,
594 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
595 {"RaiseLowerKey", "None", (void *)WKBD_RAISELOWER
,
596 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
597 {"ShadeKey", "None", (void *)WKBD_SHADE
,
598 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
599 {"SelectKey", "None", (void *)WKBD_SELECT
,
600 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
601 {"FocusNextKey", "None", (void *)WKBD_FOCUSNEXT
,
602 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
603 {"FocusPrevKey", "None", (void *)WKBD_FOCUSPREV
,
604 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
605 {"GroupNextKey", "None", (void *)WKBD_GROUPNEXT
,
606 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
607 {"GroupPrevKey", "None", (void *)WKBD_GROUPPREV
,
608 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
609 {"NextWorkspaceKey", "None", (void *)WKBD_NEXTWORKSPACE
,
610 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
611 {"PrevWorkspaceKey", "None", (void *)WKBD_PREVWORKSPACE
,
612 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
613 {"LastWorkspaceKey", "None", (void *)WKBD_LASTWORKSPACE
,
614 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
615 {"NextWorkspaceLayerKey", "None", (void *)WKBD_NEXTWSLAYER
,
616 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
617 {"PrevWorkspaceLayerKey", "None", (void *)WKBD_PREVWSLAYER
,
618 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
619 {"Workspace1Key", "None", (void *)WKBD_WORKSPACE1
,
620 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
621 {"Workspace2Key", "None", (void *)WKBD_WORKSPACE2
,
622 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
623 {"Workspace3Key", "None", (void *)WKBD_WORKSPACE3
,
624 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
625 {"Workspace4Key", "None", (void *)WKBD_WORKSPACE4
,
626 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
627 {"Workspace5Key", "None", (void *)WKBD_WORKSPACE5
,
628 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
629 {"Workspace6Key", "None", (void *)WKBD_WORKSPACE6
,
630 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
631 {"Workspace7Key", "None", (void *)WKBD_WORKSPACE7
,
632 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
633 {"Workspace8Key", "None", (void *)WKBD_WORKSPACE8
,
634 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
635 {"Workspace9Key", "None", (void *)WKBD_WORKSPACE9
,
636 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
637 {"Workspace10Key", "None", (void *)WKBD_WORKSPACE10
,
638 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
639 {"MoveToWorkspace1Key", "None", (void *)WKBD_MOVE_WORKSPACE1
,
640 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
641 {"MoveToWorkspace2Key", "None", (void *)WKBD_MOVE_WORKSPACE2
,
642 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
643 {"MoveToWorkspace3Key", "None", (void *)WKBD_MOVE_WORKSPACE3
,
644 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
645 {"MoveToWorkspace4Key", "None", (void *)WKBD_MOVE_WORKSPACE4
,
646 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
647 {"MoveToWorkspace5Key", "None", (void *)WKBD_MOVE_WORKSPACE5
,
648 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
649 {"MoveToWorkspace6Key", "None", (void *)WKBD_MOVE_WORKSPACE6
,
650 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
651 {"MoveToWorkspace7Key", "None", (void *)WKBD_MOVE_WORKSPACE7
,
652 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
653 {"MoveToWorkspace8Key", "None", (void *)WKBD_MOVE_WORKSPACE8
,
654 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
655 {"MoveToWorkspace9Key", "None", (void *)WKBD_MOVE_WORKSPACE9
,
656 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
657 {"MoveToWorkspace10Key", "None", (void *)WKBD_MOVE_WORKSPACE10
,
658 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
659 {"MoveToNextWorkspaceKey", "None", (void *)WKBD_MOVE_NEXTWORKSPACE
,
660 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
661 {"MoveToPrevWorkspaceKey", "None", (void *)WKBD_MOVE_PREVWORKSPACE
,
662 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
663 {"MoveToLastWorkspaceKey", "None", (void *)WKBD_MOVE_LASTWORKSPACE
,
664 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
665 {"MoveToNextWorkspaceLayerKey", "None", (void *)WKBD_MOVE_NEXTWSLAYER
,
666 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
667 {"MoveToPrevWorkspaceLayerKey", "None", (void *)WKBD_MOVE_PREVWSLAYER
,
668 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
669 {"WindowShortcut1Key", "None", (void *)WKBD_WINDOW1
,
670 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
671 {"WindowShortcut2Key", "None", (void *)WKBD_WINDOW2
,
672 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
673 {"WindowShortcut3Key", "None", (void *)WKBD_WINDOW3
,
674 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
675 {"WindowShortcut4Key", "None", (void *)WKBD_WINDOW4
,
676 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
677 {"WindowShortcut5Key", "None", (void *)WKBD_WINDOW5
,
678 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
679 {"WindowShortcut6Key", "None", (void *)WKBD_WINDOW6
,
680 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
681 {"WindowShortcut7Key", "None", (void *)WKBD_WINDOW7
,
682 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
683 {"WindowShortcut8Key", "None", (void *)WKBD_WINDOW8
,
684 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
685 {"WindowShortcut9Key", "None", (void *)WKBD_WINDOW9
,
686 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
687 {"WindowShortcut10Key", "None", (void *)WKBD_WINDOW10
,
688 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
689 {"WindowRelaunchKey", "None", (void *)WKBD_RELAUNCH
,
690 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
691 {"ScreenSwitchKey", "None", (void *)WKBD_SWITCH_SCREEN
,
692 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
694 #ifdef KEEP_XKB_LOCK_STATUS
695 {"ToggleKbdModeKey", "None", (void *)WKBD_TOGGLE
,
696 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
697 {"KbdModeLock", "NO", NULL
,
698 &wPreferences
.modelock
, getBool
, NULL
, NULL
, NULL
},
699 #endif /* KEEP_XKB_LOCK_STATUS */
701 {"NormalCursor", "(builtin, left_ptr)", (void *)WCUR_ROOT
,
702 NULL
, getCursor
, setCursor
, NULL
, NULL
},
703 {"ArrowCursor", "(builtin, top_left_arrow)", (void *)WCUR_ARROW
,
704 NULL
, getCursor
, setCursor
, NULL
, NULL
},
705 {"MoveCursor", "(builtin, fleur)", (void *)WCUR_MOVE
,
706 NULL
, getCursor
, setCursor
, NULL
, NULL
},
707 {"ResizeCursor", "(builtin, sizing)", (void *)WCUR_RESIZE
,
708 NULL
, getCursor
, setCursor
, NULL
, NULL
},
709 {"TopLeftResizeCursor", "(builtin, top_left_corner)", (void *)WCUR_TOPLEFTRESIZE
,
710 NULL
, getCursor
, setCursor
, NULL
, NULL
},
711 {"TopRightResizeCursor", "(builtin, top_right_corner)", (void *)WCUR_TOPRIGHTRESIZE
,
712 NULL
, getCursor
, setCursor
, NULL
, NULL
},
713 {"BottomLeftResizeCursor", "(builtin, bottom_left_corner)", (void *)WCUR_BOTTOMLEFTRESIZE
,
714 NULL
, getCursor
, setCursor
, NULL
, NULL
},
715 {"BottomRightResizeCursor", "(builtin, bottom_right_corner)", (void *)WCUR_BOTTOMRIGHTRESIZE
,
716 NULL
, getCursor
, setCursor
, NULL
, NULL
},
717 {"VerticalResizeCursor", "(builtin, sb_v_double_arrow)", (void *)WCUR_VERTICALRESIZE
,
718 NULL
, getCursor
, setCursor
, NULL
, NULL
},
719 {"HorizontalResizeCursor", "(builtin, sb_h_double_arrow)", (void *)WCUR_HORIZONRESIZE
,
720 NULL
, getCursor
, setCursor
, NULL
, NULL
},
721 {"WaitCursor", "(builtin, watch)", (void *)WCUR_WAIT
,
722 NULL
, getCursor
, setCursor
, NULL
, NULL
},
723 {"QuestionCursor", "(builtin, question_arrow)", (void *)WCUR_QUESTION
,
724 NULL
, getCursor
, setCursor
, NULL
, NULL
},
725 {"TextCursor", "(builtin, xterm)", (void *)WCUR_TEXT
,
726 NULL
, getCursor
, setCursor
, NULL
, NULL
},
727 {"SelectCursor", "(builtin, cross)", (void *)WCUR_SELECT
,
728 NULL
, getCursor
, setCursor
, NULL
, NULL
},
729 {"DialogHistoryLines", "500", NULL
,
730 &wPreferences
.history_lines
, getInt
, NULL
, NULL
, NULL
},
731 {"CycleActiveHeadOnly", "NO", NULL
,
732 &wPreferences
.cycle_active_head_only
, getBool
, NULL
, NULL
, NULL
},
733 {"CycleIgnoreMinimized", "NO", NULL
,
734 &wPreferences
.cycle_ignore_minimized
, getBool
, NULL
, NULL
, NULL
}
737 static void initDefaults()
740 WDefaultEntry
*entry
;
742 WMPLSetCaseSensitive(False
);
744 for (i
= 0; i
< sizeof(optionList
) / sizeof(WDefaultEntry
); i
++) {
745 entry
= &optionList
[i
];
747 entry
->plkey
= WMCreatePLString(entry
->key
);
748 if (entry
->default_value
)
749 entry
->plvalue
= WMCreatePropListFromDescription(entry
->default_value
);
751 entry
->plvalue
= NULL
;
754 for (i
= 0; i
< sizeof(staticOptionList
) / sizeof(WDefaultEntry
); i
++) {
755 entry
= &staticOptionList
[i
];
757 entry
->plkey
= WMCreatePLString(entry
->key
);
758 if (entry
->default_value
)
759 entry
->plvalue
= WMCreatePropListFromDescription(entry
->default_value
);
761 entry
->plvalue
= NULL
;
765 static WMPropList
*readGlobalDomain(char *domainName
, Bool requireDictionary
)
767 WMPropList
*globalDict
= NULL
;
771 snprintf(path
, sizeof(path
), "%s/%s/%s", SYSCONFDIR
, GLOBAL_DEFAULTS_SUBDIR
, domainName
);
772 if (stat(path
, &stbuf
) >= 0) {
773 globalDict
= WMReadPropListFromFile(path
);
774 if (globalDict
&& requireDictionary
&& !WMIsPLDictionary(globalDict
)) {
775 wwarning(_("Domain %s (%s) of global defaults database is corrupted!"), domainName
, path
);
776 WMReleasePropList(globalDict
);
778 } else if (!globalDict
) {
779 wwarning(_("could not load domain %s from global defaults database"), domainName
);
786 #if defined(GLOBAL_PREAMBLE_MENU_FILE) || defined(GLOBAL_EPILOGUE_MENU_FILE)
787 static void prependMenu(WMPropList
* destarr
, WMPropList
* array
)
792 for (i
= 0; i
< WMGetPropListItemCount(array
); i
++) {
793 item
= WMGetFromPLArray(array
, i
);
795 WMInsertInPLArray(destarr
, i
+ 1, item
);
799 static void appendMenu(WMPropList
* destarr
, WMPropList
* array
)
804 for (i
= 0; i
< WMGetPropListItemCount(array
); i
++) {
805 item
= WMGetFromPLArray(array
, i
);
807 WMAddToPLArray(destarr
, item
);
812 void wDefaultsMergeGlobalMenus(WDDomain
* menuDomain
)
814 WMPropList
*menu
= menuDomain
->dictionary
;
817 if (!menu
|| !WMIsPLArray(menu
))
820 #ifdef GLOBAL_PREAMBLE_MENU_FILE
821 submenu
= WMReadPropListFromFile(SYSCONFDIR
"/" GLOBAL_DEFAULTS_SUBDIR
"/" GLOBAL_PREAMBLE_MENU_FILE
);
823 if (submenu
&& !WMIsPLArray(submenu
)) {
824 wwarning(_("invalid global menu file %s"), GLOBAL_PREAMBLE_MENU_FILE
);
825 WMReleasePropList(submenu
);
829 prependMenu(menu
, submenu
);
830 WMReleasePropList(submenu
);
834 #ifdef GLOBAL_EPILOGUE_MENU_FILE
835 submenu
= WMReadPropListFromFile(SYSCONFDIR
"/" GLOBAL_DEFAULTS_SUBDIR
"/" GLOBAL_EPILOGUE_MENU_FILE
);
837 if (submenu
&& !WMIsPLArray(submenu
)) {
838 wwarning(_("invalid global menu file %s"), GLOBAL_EPILOGUE_MENU_FILE
);
839 WMReleasePropList(submenu
);
843 appendMenu(menu
, submenu
);
844 WMReleasePropList(submenu
);
848 menuDomain
->dictionary
= menu
;
851 WDDomain
*wDefaultsInitDomain(char *domain
, Bool requireDictionary
)
855 static int inited
= 0;
857 WMPropList
*shared_dict
= NULL
;
864 db
= wmalloc(sizeof(WDDomain
));
865 db
->domain_name
= domain
;
866 db
->path
= wdefaultspathfordomain(domain
);
869 if (the_path
&& stat(the_path
, &stbuf
) >= 0) {
870 db
->dictionary
= WMReadPropListFromFile(the_path
);
871 if (db
->dictionary
) {
872 if (requireDictionary
&& !WMIsPLDictionary(db
->dictionary
)) {
873 WMReleasePropList(db
->dictionary
);
874 db
->dictionary
= NULL
;
875 wwarning(_("Domain %s (%s) of defaults database is corrupted!"), domain
, the_path
);
877 db
->timestamp
= stbuf
.st_mtime
;
879 wwarning(_("could not load domain %s from user defaults database"), domain
);
883 /* global system dictionary */
884 shared_dict
= readGlobalDomain(domain
, requireDictionary
);
886 if (shared_dict
&& db
->dictionary
&& WMIsPLDictionary(shared_dict
) &&
887 WMIsPLDictionary(db
->dictionary
)) {
888 WMMergePLDictionaries(shared_dict
, db
->dictionary
, True
);
889 WMReleasePropList(db
->dictionary
);
890 db
->dictionary
= shared_dict
;
891 if (stbuf
.st_mtime
> db
->timestamp
)
892 db
->timestamp
= stbuf
.st_mtime
;
893 } else if (!db
->dictionary
) {
894 db
->dictionary
= shared_dict
;
895 if (stbuf
.st_mtime
> db
->timestamp
)
896 db
->timestamp
= stbuf
.st_mtime
;
902 void wReadStaticDefaults(WMPropList
* dict
)
905 WDefaultEntry
*entry
;
909 for (i
= 0; i
< sizeof(staticOptionList
) / sizeof(WDefaultEntry
); i
++) {
910 entry
= &staticOptionList
[i
];
913 plvalue
= WMGetFromPLDictionary(dict
, entry
->plkey
);
917 /* no default in the DB. Use builtin default */
919 plvalue
= entry
->plvalue
;
923 (*entry
->convert
) (NULL
, entry
, plvalue
, entry
->addr
, &tdata
);
925 (*entry
->update
) (NULL
, entry
, tdata
, entry
->extra_data
);
930 void wDefaultsCheckDomains(void* arg
)
934 WMPropList
*shared_dict
= NULL
;
938 if (stat(WDWindowMaker
->path
, &stbuf
) >= 0 && WDWindowMaker
->timestamp
< stbuf
.st_mtime
) {
939 WDWindowMaker
->timestamp
= stbuf
.st_mtime
;
941 /* Global dictionary */
942 shared_dict
= readGlobalDomain("WindowMaker", True
);
944 /* User dictionary */
945 dict
= WMReadPropListFromFile(WDWindowMaker
->path
);
948 if (!WMIsPLDictionary(dict
)) {
949 WMReleasePropList(dict
);
951 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
952 "WindowMaker", WDWindowMaker
->path
);
955 WMMergePLDictionaries(shared_dict
, dict
, True
);
956 WMReleasePropList(dict
);
961 for (i
= 0; i
< wScreenCount
; i
++) {
962 scr
= wScreenWithNumber(i
);
964 wReadDefaults(scr
, dict
);
967 if (WDWindowMaker
->dictionary
)
968 WMReleasePropList(WDWindowMaker
->dictionary
);
970 WDWindowMaker
->dictionary
= dict
;
973 wwarning(_("could not load domain %s from user defaults database"), "WindowMaker");
977 WMReleasePropList(shared_dict
);
981 if (stat(WDWindowAttributes
->path
, &stbuf
) >= 0 && WDWindowAttributes
->timestamp
< stbuf
.st_mtime
) {
982 /* global dictionary */
983 shared_dict
= readGlobalDomain("WMWindowAttributes", True
);
984 /* user dictionary */
985 dict
= WMReadPropListFromFile(WDWindowAttributes
->path
);
987 if (!WMIsPLDictionary(dict
)) {
988 WMReleasePropList(dict
);
990 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
991 "WMWindowAttributes", WDWindowAttributes
->path
);
994 WMMergePLDictionaries(shared_dict
, dict
, True
);
995 WMReleasePropList(dict
);
1000 if (WDWindowAttributes
->dictionary
)
1001 WMReleasePropList(WDWindowAttributes
->dictionary
);
1003 WDWindowAttributes
->dictionary
= dict
;
1004 for (i
= 0; i
< wScreenCount
; i
++) {
1005 scr
= wScreenWithNumber(i
);
1007 wDefaultUpdateIcons(scr
);
1009 /* Update the panel image if changed */
1010 /* Don't worry. If the image is the same these
1011 * functions will have no performance impact. */
1012 create_logo_image(scr
);
1017 wwarning(_("could not load domain %s from user defaults database"), "WMWindowAttributes");
1020 WDWindowAttributes
->timestamp
= stbuf
.st_mtime
;
1022 WMReleasePropList(shared_dict
);
1025 if (stat(WDRootMenu
->path
, &stbuf
) >= 0 && WDRootMenu
->timestamp
< stbuf
.st_mtime
) {
1026 dict
= WMReadPropListFromFile(WDRootMenu
->path
);
1028 if (!WMIsPLArray(dict
) && !WMIsPLString(dict
)) {
1029 WMReleasePropList(dict
);
1031 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
1032 "WMRootMenu", WDRootMenu
->path
);
1034 if (WDRootMenu
->dictionary
)
1035 WMReleasePropList(WDRootMenu
->dictionary
);
1037 WDRootMenu
->dictionary
= dict
;
1038 wDefaultsMergeGlobalMenus(WDRootMenu
);
1041 wwarning(_("could not load domain %s from user defaults database"), "WMRootMenu");
1043 WDRootMenu
->timestamp
= stbuf
.st_mtime
;
1045 #ifndef HAVE_INOTIFY
1047 WMAddTimerHandler(DEFAULTS_CHECK_INTERVAL
, wDefaultsCheckDomains
, arg
);
1051 void wReadDefaults(WScreen
* scr
, WMPropList
* new_dict
)
1053 WMPropList
*plvalue
, *old_value
;
1054 WDefaultEntry
*entry
;
1056 int update_workspace_back
= 0; /* kluge :/ */
1057 unsigned int needs_refresh
;
1059 WMPropList
*old_dict
= (WDWindowMaker
->dictionary
!= new_dict
? WDWindowMaker
->dictionary
: NULL
);
1063 for (i
= 0; i
< sizeof(optionList
) / sizeof(WDefaultEntry
); i
++) {
1064 entry
= &optionList
[i
];
1067 plvalue
= WMGetFromPLDictionary(new_dict
, entry
->plkey
);
1074 old_value
= WMGetFromPLDictionary(old_dict
, entry
->plkey
);
1076 if (!plvalue
&& !old_value
) {
1077 /* no default in the DB. Use builtin default */
1078 plvalue
= entry
->plvalue
;
1079 if (plvalue
&& new_dict
)
1080 WMPutInPLDictionary(new_dict
, entry
->plkey
, plvalue
);
1082 } else if (!plvalue
) {
1083 /* value was deleted from DB. Keep current value */
1085 } else if (!old_value
) {
1086 /* set value for the 1st time */
1087 } else if (!WMIsPropListEqualTo(plvalue
, old_value
)) {
1088 /* value has changed */
1090 if (strcmp(entry
->key
, "WorkspaceBack") == 0
1091 && update_workspace_back
&& scr
->flags
.backimage_helper_launched
) {
1093 /* value was not changed since last time */
1100 if ((*entry
->convert
) (scr
, entry
, plvalue
, entry
->addr
, &tdata
)) {
1102 * If the WorkspaceSpecificBack data has been changed
1103 * so that the helper will be launched now, we must be
1104 * sure to send the default background texture config
1107 if (strcmp(entry
->key
, "WorkspaceSpecificBack") == 0 &&
1108 !scr
->flags
.backimage_helper_launched
)
1109 update_workspace_back
= 1;
1112 needs_refresh
|= (*entry
->update
) (scr
, entry
, tdata
, entry
->extra_data
);
1118 if (needs_refresh
!= 0 && !scr
->flags
.startup
) {
1122 if (needs_refresh
& REFRESH_MENU_TITLE_TEXTURE
)
1123 foo
|= WTextureSettings
;
1124 if (needs_refresh
& REFRESH_MENU_TITLE_FONT
)
1125 foo
|= WFontSettings
;
1126 if (needs_refresh
& REFRESH_MENU_TITLE_COLOR
)
1127 foo
|= WColorSettings
;
1129 WMPostNotificationName(WNMenuTitleAppearanceSettingsChanged
, NULL
,
1130 (void *)(uintptr_t) foo
);
1133 if (needs_refresh
& REFRESH_MENU_TEXTURE
)
1134 foo
|= WTextureSettings
;
1135 if (needs_refresh
& REFRESH_MENU_FONT
)
1136 foo
|= WFontSettings
;
1137 if (needs_refresh
& REFRESH_MENU_COLOR
)
1138 foo
|= WColorSettings
;
1140 WMPostNotificationName(WNMenuAppearanceSettingsChanged
, NULL
, (void *)(uintptr_t) foo
);
1143 if (needs_refresh
& REFRESH_WINDOW_FONT
)
1144 foo
|= WFontSettings
;
1145 if (needs_refresh
& REFRESH_WINDOW_TEXTURES
)
1146 foo
|= WTextureSettings
;
1147 if (needs_refresh
& REFRESH_WINDOW_TITLE_COLOR
)
1148 foo
|= WColorSettings
;
1150 WMPostNotificationName(WNWindowAppearanceSettingsChanged
, NULL
, (void *)(uintptr_t) foo
);
1152 if (!(needs_refresh
& REFRESH_ICON_TILE
)) {
1154 if (needs_refresh
& REFRESH_ICON_FONT
)
1155 foo
|= WFontSettings
;
1156 if (needs_refresh
& REFRESH_ICON_TITLE_COLOR
)
1157 foo
|= WTextureSettings
;
1158 if (needs_refresh
& REFRESH_ICON_TITLE_BACK
)
1159 foo
|= WTextureSettings
;
1161 WMPostNotificationName(WNIconAppearanceSettingsChanged
, NULL
,
1162 (void *)(uintptr_t) foo
);
1164 if (needs_refresh
& REFRESH_ICON_TILE
)
1165 WMPostNotificationName(WNIconTileSettingsChanged
, NULL
, NULL
);
1167 if (needs_refresh
& REFRESH_WORKSPACE_MENU
) {
1168 if (scr
->workspace_menu
)
1169 wWorkspaceMenuUpdate(scr
, scr
->workspace_menu
);
1170 if (scr
->clip_ws_menu
)
1171 wWorkspaceMenuUpdate(scr
, scr
->clip_ws_menu
);
1172 if (scr
->workspace_submenu
)
1173 scr
->workspace_submenu
->flags
.realized
= 0;
1174 if (scr
->clip_submenu
)
1175 scr
->clip_submenu
->flags
.realized
= 0;
1180 void wDefaultUpdateIcons(WScreen
*scr
)
1182 WAppIcon
*aicon
= scr
->app_icon_list
;
1183 WWindow
*wwin
= scr
->focused_window
;
1186 /* Get the application icon, default included */
1187 wIconChangeImageFile(aicon
->icon
, NULL
);
1188 wAppIconPaint(aicon
);
1189 aicon
= aicon
->next
;
1192 if (!wPreferences
.flags
.noclip
)
1193 wClipIconPaint(scr
->clip_icon
);
1196 if (wwin
->icon
&& wwin
->flags
.miniaturized
)
1197 wIconChangeImageFile(wwin
->icon
, NULL
);
1202 /* --------------------------- Local ----------------------- */
1204 #define GET_STRING_OR_DEFAULT(x, var) if (!WMIsPLString(value)) { \
1205 wwarning(_("Wrong option format for key \"%s\". Should be %s."), \
1207 wwarning(_("using default \"%s\" instead"), entry->default_value); \
1208 var = entry->default_value;\
1209 } else var = WMGetFromPLString(value)\
1212 static int string2index(WMPropList * key, WMPropList * val, char *def, WOptionEnumeration * values)
1215 WOptionEnumeration
*v
;
1216 char buffer
[TOTAL_VALUES_LENGTH
];
1218 if (WMIsPLString(val
) && (str
= WMGetFromPLString(val
))) {
1219 for (v
= values
; v
->string
!= NULL
; v
++) {
1220 if (strcasecmp(v
->string
, str
) == 0)
1226 for (v
= values
; v
->string
!= NULL
; v
++) {
1229 strcat(buffer
, ", ");
1230 snprintf(buffer
+strlen(buffer
),
1231 sizeof(buffer
)-strlen(buffer
)-1, "\"%s\"", v
->string
);
1234 wwarning(_("wrong option value for key \"%s\"; got \"%s\", should be one of %s."),
1235 WMGetFromPLString(key
),
1236 WMIsPLString(val
) ? WMGetFromPLString(val
) : "(unknown)",
1240 return string2index(key
, val
, NULL
, values
);
1247 * value - is the value in the defaults DB
1248 * addr - is the address to store the data
1249 * ret - is the address to store a pointer to a temporary buffer. ret
1250 * must not be freed and is used by the set functions
1252 static int getBool(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1256 int second_pass
= 0;
1258 GET_STRING_OR_DEFAULT("Boolean", val
);
1261 if ((val
[1] == '\0' && (val
[0] == 'y' || val
[0] == 'Y'))
1262 || strcasecmp(val
, "YES") == 0) {
1265 } else if ((val
[1] == '\0' && (val
[0] == 'n' || val
[0] == 'N'))
1266 || strcasecmp(val
, "NO") == 0) {
1270 if (sscanf(val
, "%i", &i
) == 1) {
1276 wwarning(_("can't convert \"%s\" to boolean for key \"%s\""), val
, entry
->key
);
1277 if (second_pass
== 0) {
1278 val
= WMGetFromPLString(entry
->plvalue
);
1280 wwarning(_("using default \"%s\" instead"), val
);
1290 *(char *)addr
= data
;
1295 static int getInt(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1300 GET_STRING_OR_DEFAULT("Integer", val
);
1302 if (sscanf(val
, "%i", &data
) != 1) {
1303 wwarning(_("can't convert \"%s\" to integer for key \"%s\""), val
, entry
->key
);
1304 val
= WMGetFromPLString(entry
->plvalue
);
1305 wwarning(_("using default \"%s\" instead"), val
);
1306 if (sscanf(val
, "%i", &data
) != 1) {
1314 *(int *)addr
= data
;
1319 static int getCoord(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1322 char *val_x
, *val_y
;
1323 int nelem
, changed
= 0;
1324 WMPropList
*elem_x
, *elem_y
;
1327 if (!WMIsPLArray(value
)) {
1328 wwarning(_("Wrong option format for key \"%s\". Should be %s."), entry
->key
, "Coordinate");
1330 value
= entry
->plvalue
;
1332 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1338 nelem
= WMGetPropListItemCount(value
);
1340 wwarning(_("Incorrect number of elements in array for key \"%s\"."), entry
->key
);
1342 value
= entry
->plvalue
;
1344 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1350 elem_x
= WMGetFromPLArray(value
, 0);
1351 elem_y
= WMGetFromPLArray(value
, 1);
1353 if (!elem_x
|| !elem_y
|| !WMIsPLString(elem_x
) || !WMIsPLString(elem_y
)) {
1354 wwarning(_("Wrong value for key \"%s\". Should be Coordinate."), entry
->key
);
1356 value
= entry
->plvalue
;
1358 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1364 val_x
= WMGetFromPLString(elem_x
);
1365 val_y
= WMGetFromPLString(elem_y
);
1367 if (sscanf(val_x
, "%i", &data
.x
) != 1 || sscanf(val_y
, "%i", &data
.y
) != 1) {
1368 wwarning(_("can't convert array to integers for \"%s\"."), entry
->key
);
1370 value
= entry
->plvalue
;
1372 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1380 else if (data
.x
> scr
->scr_width
/ 3)
1381 data
.x
= scr
->scr_width
/ 3;
1384 else if (data
.y
> scr
->scr_height
/ 3)
1385 data
.y
= scr
->scr_height
/ 3;
1390 *(WCoord
*) addr
= data
;
1395 static int getPropList(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1397 WMRetainPropList(value
);
1404 static int getPathList(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1413 if (!WMIsPLArray(value
)) {
1414 wwarning(_("Wrong option format for key \"%s\". Should be %s."), entry
->key
, "an array of paths");
1416 value
= entry
->plvalue
;
1418 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1425 count
= WMGetPropListItemCount(value
);
1428 value
= entry
->plvalue
;
1430 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1437 for (i
= 0; i
< count
; i
++) {
1438 d
= WMGetFromPLArray(value
, i
);
1439 if (!d
|| !WMIsPLString(d
)) {
1443 len
+= strlen(WMGetFromPLString(d
)) + 1;
1446 ptr
= data
= wmalloc(len
+ 1);
1448 for (i
= 0; i
< count
; i
++) {
1449 d
= WMGetFromPLArray(value
, i
);
1450 if (!d
|| !WMIsPLString(d
)) {
1453 strcpy(ptr
, WMGetFromPLString(d
));
1454 ptr
+= strlen(WMGetFromPLString(d
));
1461 if (*(char **)addr
!= NULL
) {
1462 wfree(*(char **)addr
);
1464 *(char **)addr
= data
;
1469 static int getEnum(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1471 static signed char data
;
1473 data
= string2index(entry
->plkey
, value
, entry
->default_value
, (WOptionEnumeration
*) entry
->extra_data
);
1480 *(signed char *)addr
= data
;
1487 * (hgradient <color> <color>)
1488 * (vgradient <color> <color>)
1489 * (dgradient <color> <color>)
1490 * (mhgradient <color> <color> ...)
1491 * (mvgradient <color> <color> ...)
1492 * (mdgradient <color> <color> ...)
1493 * (igradient <color1> <color1> <thickness1> <color2> <color2> <thickness2>)
1494 * (tpixmap <file> <color>)
1495 * (spixmap <file> <color>)
1496 * (cpixmap <file> <color>)
1497 * (thgradient <file> <opaqueness> <color> <color>)
1498 * (tvgradient <file> <opaqueness> <color> <color>)
1499 * (tdgradient <file> <opaqueness> <color> <color>)
1500 * (function <lib> <function> ...)
1503 static WTexture
*parse_texture(WScreen
* scr
, WMPropList
* pl
)
1508 WTexture
*texture
= NULL
;
1510 nelem
= WMGetPropListItemCount(pl
);
1514 elem
= WMGetFromPLArray(pl
, 0);
1515 if (!elem
|| !WMIsPLString(elem
))
1517 val
= WMGetFromPLString(elem
);
1519 if (strcasecmp(val
, "solid") == 0) {
1527 elem
= WMGetFromPLArray(pl
, 1);
1528 if (!elem
|| !WMIsPLString(elem
))
1530 val
= WMGetFromPLString(elem
);
1532 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &color
)) {
1533 wwarning(_("\"%s\" is not a valid color name"), val
);
1537 texture
= (WTexture
*) wTextureMakeSolid(scr
, &color
);
1538 } else if (strcasecmp(val
, "dgradient") == 0
1539 || strcasecmp(val
, "vgradient") == 0 || strcasecmp(val
, "hgradient") == 0) {
1540 RColor color1
, color2
;
1545 wwarning(_("bad number of arguments in gradient specification"));
1549 if (val
[0] == 'd' || val
[0] == 'D')
1550 type
= WTEX_DGRADIENT
;
1551 else if (val
[0] == 'h' || val
[0] == 'H')
1552 type
= WTEX_HGRADIENT
;
1554 type
= WTEX_VGRADIENT
;
1556 /* get from color */
1557 elem
= WMGetFromPLArray(pl
, 1);
1558 if (!elem
|| !WMIsPLString(elem
))
1560 val
= WMGetFromPLString(elem
);
1562 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1563 wwarning(_("\"%s\" is not a valid color name"), val
);
1567 color1
.red
= xcolor
.red
>> 8;
1568 color1
.green
= xcolor
.green
>> 8;
1569 color1
.blue
= xcolor
.blue
>> 8;
1572 elem
= WMGetFromPLArray(pl
, 2);
1573 if (!elem
|| !WMIsPLString(elem
)) {
1576 val
= WMGetFromPLString(elem
);
1578 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1579 wwarning(_("\"%s\" is not a valid color name"), val
);
1583 color2
.red
= xcolor
.red
>> 8;
1584 color2
.green
= xcolor
.green
>> 8;
1585 color2
.blue
= xcolor
.blue
>> 8;
1587 texture
= (WTexture
*) wTextureMakeGradient(scr
, type
, &color1
, &color2
);
1589 } else if (strcasecmp(val
, "igradient") == 0) {
1590 RColor colors1
[2], colors2
[2];
1596 wwarning(_("bad number of arguments in gradient specification"));
1600 /* get from color */
1601 for (i
= 0; i
< 2; i
++) {
1602 elem
= WMGetFromPLArray(pl
, 1 + i
);
1603 if (!elem
|| !WMIsPLString(elem
))
1605 val
= WMGetFromPLString(elem
);
1607 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1608 wwarning(_("\"%s\" is not a valid color name"), val
);
1611 colors1
[i
].alpha
= 255;
1612 colors1
[i
].red
= xcolor
.red
>> 8;
1613 colors1
[i
].green
= xcolor
.green
>> 8;
1614 colors1
[i
].blue
= xcolor
.blue
>> 8;
1616 elem
= WMGetFromPLArray(pl
, 3);
1617 if (!elem
|| !WMIsPLString(elem
))
1619 val
= WMGetFromPLString(elem
);
1622 /* get from color */
1623 for (i
= 0; i
< 2; i
++) {
1624 elem
= WMGetFromPLArray(pl
, 4 + i
);
1625 if (!elem
|| !WMIsPLString(elem
))
1627 val
= WMGetFromPLString(elem
);
1629 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1630 wwarning(_("\"%s\" is not a valid color name"), val
);
1633 colors2
[i
].alpha
= 255;
1634 colors2
[i
].red
= xcolor
.red
>> 8;
1635 colors2
[i
].green
= xcolor
.green
>> 8;
1636 colors2
[i
].blue
= xcolor
.blue
>> 8;
1638 elem
= WMGetFromPLArray(pl
, 6);
1639 if (!elem
|| !WMIsPLString(elem
))
1641 val
= WMGetFromPLString(elem
);
1644 texture
= (WTexture
*) wTextureMakeIGradient(scr
, th1
, colors1
, th2
, colors2
);
1646 } else if (strcasecmp(val
, "mhgradient") == 0
1647 || strcasecmp(val
, "mvgradient") == 0 || strcasecmp(val
, "mdgradient") == 0) {
1654 wwarning(_("too few arguments in multicolor gradient specification"));
1658 if (val
[1] == 'h' || val
[1] == 'H')
1659 type
= WTEX_MHGRADIENT
;
1660 else if (val
[1] == 'v' || val
[1] == 'V')
1661 type
= WTEX_MVGRADIENT
;
1663 type
= WTEX_MDGRADIENT
;
1667 colors
= wmalloc(sizeof(RColor
*) * (count
+ 1));
1669 for (i
= 0; i
< count
; i
++) {
1670 elem
= WMGetFromPLArray(pl
, i
+ 1);
1671 if (!elem
|| !WMIsPLString(elem
)) {
1672 for (--i
; i
>= 0; --i
) {
1678 val
= WMGetFromPLString(elem
);
1680 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &color
)) {
1681 wwarning(_("\"%s\" is not a valid color name"), val
);
1682 for (--i
; i
>= 0; --i
) {
1688 colors
[i
] = wmalloc(sizeof(RColor
));
1689 colors
[i
]->red
= color
.red
>> 8;
1690 colors
[i
]->green
= color
.green
>> 8;
1691 colors
[i
]->blue
= color
.blue
>> 8;
1696 texture
= (WTexture
*) wTextureMakeMGradient(scr
, type
, colors
);
1697 } else if (strcasecmp(val
, "spixmap") == 0 ||
1698 strcasecmp(val
, "cpixmap") == 0 || strcasecmp(val
, "tpixmap") == 0) {
1705 if (val
[0] == 's' || val
[0] == 'S')
1707 else if (val
[0] == 'c' || val
[0] == 'C')
1713 elem
= WMGetFromPLArray(pl
, 2);
1714 if (!elem
|| !WMIsPLString(elem
)) {
1717 val
= WMGetFromPLString(elem
);
1719 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &color
)) {
1720 wwarning(_("\"%s\" is not a valid color name"), val
);
1725 elem
= WMGetFromPLArray(pl
, 1);
1726 if (!elem
|| !WMIsPLString(elem
))
1728 val
= WMGetFromPLString(elem
);
1730 texture
= (WTexture
*) wTextureMakePixmap(scr
, type
, val
, &color
);
1731 } else if (strcasecmp(val
, "thgradient") == 0
1732 || strcasecmp(val
, "tvgradient") == 0 || strcasecmp(val
, "tdgradient") == 0) {
1733 RColor color1
, color2
;
1738 if (val
[1] == 'h' || val
[1] == 'H')
1739 style
= WTEX_THGRADIENT
;
1740 else if (val
[1] == 'v' || val
[1] == 'V')
1741 style
= WTEX_TVGRADIENT
;
1743 style
= WTEX_TDGRADIENT
;
1746 wwarning(_("bad number of arguments in textured gradient specification"));
1750 /* get from color */
1751 elem
= WMGetFromPLArray(pl
, 3);
1752 if (!elem
|| !WMIsPLString(elem
))
1754 val
= WMGetFromPLString(elem
);
1756 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1757 wwarning(_("\"%s\" is not a valid color name"), val
);
1761 color1
.red
= xcolor
.red
>> 8;
1762 color1
.green
= xcolor
.green
>> 8;
1763 color1
.blue
= xcolor
.blue
>> 8;
1766 elem
= WMGetFromPLArray(pl
, 4);
1767 if (!elem
|| !WMIsPLString(elem
)) {
1770 val
= WMGetFromPLString(elem
);
1772 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1773 wwarning(_("\"%s\" is not a valid color name"), val
);
1777 color2
.red
= xcolor
.red
>> 8;
1778 color2
.green
= xcolor
.green
>> 8;
1779 color2
.blue
= xcolor
.blue
>> 8;
1782 elem
= WMGetFromPLArray(pl
, 2);
1783 if (!elem
|| !WMIsPLString(elem
))
1786 val
= WMGetFromPLString(elem
);
1788 if (!val
|| (opacity
= atoi(val
)) < 0 || opacity
> 255) {
1789 wwarning(_("bad opacity value for tgradient texture \"%s\". Should be [0..255]"), val
);
1794 elem
= WMGetFromPLArray(pl
, 1);
1795 if (!elem
|| !WMIsPLString(elem
))
1797 val
= WMGetFromPLString(elem
);
1799 texture
= (WTexture
*) wTextureMakeTGradient(scr
, style
, &color1
, &color2
, val
, opacity
);
1800 } else if (strcasecmp(val
, "function") == 0) {
1801 /* Leave this in to handle the unlikely case of
1802 * someone actually having function textures configured */
1803 wwarning("function texture support has been removed");
1806 wwarning(_("invalid texture type %s"), val
);
1812 static int getTexture(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1814 static WTexture
*texture
;
1818 if (!WMIsPLArray(value
)) {
1819 wwarning(_("Wrong option format for key \"%s\". Should be %s."), entry
->key
, "Texture");
1821 value
= entry
->plvalue
;
1823 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1829 if (strcmp(entry
->key
, "WidgetColor") == 0 && !changed
) {
1832 pl
= WMGetFromPLArray(value
, 0);
1833 if (!pl
|| !WMIsPLString(pl
) || !WMGetFromPLString(pl
)
1834 || strcasecmp(WMGetFromPLString(pl
), "solid") != 0) {
1835 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1836 entry
->key
, "Solid Texture");
1838 value
= entry
->plvalue
;
1840 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1845 texture
= parse_texture(scr
, value
);
1848 wwarning(_("Error in texture specification for key \"%s\""), entry
->key
);
1850 value
= entry
->plvalue
;
1852 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1862 *(WTexture
**) addr
= texture
;
1867 static int getWSBackground(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1875 if (!WMIsPLArray(value
)) {
1876 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1877 "WorkspaceBack", "Texture or None");
1879 value
= entry
->plvalue
;
1881 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1887 /* only do basic error checking and verify for None texture */
1889 nelem
= WMGetPropListItemCount(value
);
1891 elem
= WMGetFromPLArray(value
, 0);
1892 if (!elem
|| !WMIsPLString(elem
)) {
1893 wwarning(_("Wrong type for workspace background. Should be a texture type."));
1895 value
= entry
->plvalue
;
1897 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1902 val
= WMGetFromPLString(elem
);
1904 if (strcasecmp(val
, "None") == 0)
1907 *ret
= WMRetainPropList(value
);
1913 getWSSpecificBackground(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1920 if (!WMIsPLArray(value
)) {
1921 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1922 "WorkspaceSpecificBack", "an array of textures");
1924 value
= entry
->plvalue
;
1926 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1932 /* only do basic error checking and verify for None texture */
1934 nelem
= WMGetPropListItemCount(value
);
1937 elem
= WMGetFromPLArray(value
, nelem
);
1938 if (!elem
|| !WMIsPLArray(elem
)) {
1939 wwarning(_("Wrong type for background of workspace %i. Should be a texture."),
1945 *ret
= WMRetainPropList(value
);
1949 * Kluge to force wmsetbg helper to set the default background.
1950 * If the WorkspaceSpecificBack is changed once wmaker has started,
1951 * the WorkspaceBack won't be sent to the helper, unless the user
1952 * changes it's value too. So, we must force this by removing the
1953 * value from the defaults DB.
1955 if (!scr
->flags
.backimage_helper_launched
&& !scr
->flags
.startup
) {
1956 WMPropList
*key
= WMCreatePLString("WorkspaceBack");
1958 WMRemoveFromPLDictionary(WDWindowMaker
->dictionary
, key
);
1960 WMReleasePropList(key
);
1966 static int getFont(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1968 static WMFont
*font
;
1971 GET_STRING_OR_DEFAULT("Font", val
);
1973 font
= WMCreateFont(scr
->wmscreen
, val
);
1975 font
= WMCreateFont(scr
->wmscreen
, "fixed");
1978 wfatal(_("could not load any usable font!!!"));
1985 /* can't assign font value outside update function */
1986 wassertrv(addr
== NULL
, True
);
1991 static int getColor(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1993 static XColor color
;
1995 int second_pass
= 0;
1997 GET_STRING_OR_DEFAULT("Color", val
);
2000 if (!wGetColor(scr
, val
, &color
)) {
2001 wwarning(_("could not get color for key \"%s\""), entry
->key
);
2002 if (second_pass
== 0) {
2003 val
= WMGetFromPLString(entry
->plvalue
);
2005 wwarning(_("using default \"%s\" instead"), val
);
2014 assert(addr
== NULL
);
2017 *(unsigned long*)addr = pixel;
2023 static int getKeybind(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
2025 static WShortKey shortcut
;
2029 char buf
[MAX_SHORTCUT_LENGTH
], *b
;
2031 GET_STRING_OR_DEFAULT("Key spec", val
);
2033 if (!val
|| strcasecmp(val
, "NONE") == 0) {
2034 shortcut
.keycode
= 0;
2035 shortcut
.modifier
= 0;
2041 wstrlcpy(buf
, val
, MAX_SHORTCUT_LENGTH
);
2046 shortcut
.modifier
= 0;
2047 while ((k
= strchr(b
, '+')) != NULL
) {
2051 mod
= wXModifierFromKey(b
);
2053 wwarning(_("%s: invalid key modifier \"%s\""), entry
->key
, b
);
2056 shortcut
.modifier
|= mod
;
2062 ksym
= XStringToKeysym(b
);
2064 if (ksym
== NoSymbol
) {
2065 wwarning(_("%s:invalid kbd shortcut specification \"%s\""), entry
->key
, val
);
2069 shortcut
.keycode
= XKeysymToKeycode(dpy
, ksym
);
2070 if (shortcut
.keycode
== 0) {
2071 wwarning(_("%s:invalid key in shortcut \"%s\""), entry
->key
, val
);
2081 static int getModMask(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
2086 GET_STRING_OR_DEFAULT("Modifier Key", str
);
2091 mask
= wXModifierFromKey(str
);
2093 wwarning(_("%s: modifier key %s is not valid"), entry
->key
, str
);
2099 *(int *)addr
= mask
;
2107 # include <X11/cursorfont.h>
2113 #define CURSOR_ID_NONE (XC_num_glyphs)
2115 static WCursorLookup cursor_table
[] = {
2116 {"X_cursor", XC_X_cursor
},
2117 {"arrow", XC_arrow
},
2118 {"based_arrow_down", XC_based_arrow_down
},
2119 {"based_arrow_up", XC_based_arrow_up
},
2121 {"bogosity", XC_bogosity
},
2122 {"bottom_left_corner", XC_bottom_left_corner
},
2123 {"bottom_right_corner", XC_bottom_right_corner
},
2124 {"bottom_side", XC_bottom_side
},
2125 {"bottom_tee", XC_bottom_tee
},
2126 {"box_spiral", XC_box_spiral
},
2127 {"center_ptr", XC_center_ptr
},
2128 {"circle", XC_circle
},
2129 {"clock", XC_clock
},
2130 {"coffee_mug", XC_coffee_mug
},
2131 {"cross", XC_cross
},
2132 {"cross_reverse", XC_cross_reverse
},
2133 {"crosshair", XC_crosshair
},
2134 {"diamond_cross", XC_diamond_cross
},
2136 {"dotbox", XC_dotbox
},
2137 {"double_arrow", XC_double_arrow
},
2138 {"draft_large", XC_draft_large
},
2139 {"draft_small", XC_draft_small
},
2140 {"draped_box", XC_draped_box
},
2141 {"exchange", XC_exchange
},
2142 {"fleur", XC_fleur
},
2143 {"gobbler", XC_gobbler
},
2144 {"gumby", XC_gumby
},
2145 {"hand1", XC_hand1
},
2146 {"hand2", XC_hand2
},
2147 {"heart", XC_heart
},
2149 {"iron_cross", XC_iron_cross
},
2150 {"left_ptr", XC_left_ptr
},
2151 {"left_side", XC_left_side
},
2152 {"left_tee", XC_left_tee
},
2153 {"leftbutton", XC_leftbutton
},
2154 {"ll_angle", XC_ll_angle
},
2155 {"lr_angle", XC_lr_angle
},
2157 {"middlebutton", XC_middlebutton
},
2158 {"mouse", XC_mouse
},
2159 {"pencil", XC_pencil
},
2160 {"pirate", XC_pirate
},
2162 {"question_arrow", XC_question_arrow
},
2163 {"right_ptr", XC_right_ptr
},
2164 {"right_side", XC_right_side
},
2165 {"right_tee", XC_right_tee
},
2166 {"rightbutton", XC_rightbutton
},
2167 {"rtl_logo", XC_rtl_logo
},
2168 {"sailboat", XC_sailboat
},
2169 {"sb_down_arrow", XC_sb_down_arrow
},
2170 {"sb_h_double_arrow", XC_sb_h_double_arrow
},
2171 {"sb_left_arrow", XC_sb_left_arrow
},
2172 {"sb_right_arrow", XC_sb_right_arrow
},
2173 {"sb_up_arrow", XC_sb_up_arrow
},
2174 {"sb_v_double_arrow", XC_sb_v_double_arrow
},
2175 {"shuttle", XC_shuttle
},
2176 {"sizing", XC_sizing
},
2177 {"spider", XC_spider
},
2178 {"spraycan", XC_spraycan
},
2180 {"target", XC_target
},
2181 {"tcross", XC_tcross
},
2182 {"top_left_arrow", XC_top_left_arrow
},
2183 {"top_left_corner", XC_top_left_corner
},
2184 {"top_right_corner", XC_top_right_corner
},
2185 {"top_side", XC_top_side
},
2186 {"top_tee", XC_top_tee
},
2188 {"ul_angle", XC_ul_angle
},
2189 {"umbrella", XC_umbrella
},
2190 {"ur_angle", XC_ur_angle
},
2191 {"watch", XC_watch
},
2192 {"xterm", XC_xterm
},
2193 {NULL
, CURSOR_ID_NONE
}
2196 static void check_bitmap_status(int status
, char *filename
, Pixmap bitmap
)
2199 case BitmapOpenFailed
:
2200 wwarning(_("failed to open bitmap file \"%s\""), filename
);
2202 case BitmapFileInvalid
:
2203 wwarning(_("\"%s\" is not a valid bitmap file"), filename
);
2205 case BitmapNoMemory
:
2206 wwarning(_("out of memory reading bitmap file \"%s\""), filename
);
2209 XFreePixmap(dpy
, bitmap
);
2216 * (builtin, <cursor_name>)
2217 * (bitmap, <cursor_bitmap>, <cursor_mask>)
2219 static int parse_cursor(WScreen
* scr
, WMPropList
* pl
, Cursor
* cursor
)
2226 nelem
= WMGetPropListItemCount(pl
);
2230 elem
= WMGetFromPLArray(pl
, 0);
2231 if (!elem
|| !WMIsPLString(elem
)) {
2234 val
= WMGetFromPLString(elem
);
2236 if (strcasecmp(val
, "none") == 0) {
2239 } else if (strcasecmp(val
, "builtin") == 0) {
2241 int cursor_id
= CURSOR_ID_NONE
;
2244 wwarning(_("bad number of arguments in cursor specification"));
2247 elem
= WMGetFromPLArray(pl
, 1);
2248 if (!elem
|| !WMIsPLString(elem
)) {
2251 val
= WMGetFromPLString(elem
);
2253 for (i
= 0; cursor_table
[i
].name
!= NULL
; i
++) {
2254 if (strcasecmp(val
, cursor_table
[i
].name
) == 0) {
2255 cursor_id
= cursor_table
[i
].id
;
2259 if (CURSOR_ID_NONE
== cursor_id
) {
2260 wwarning(_("unknown builtin cursor name \"%s\""), val
);
2262 *cursor
= XCreateFontCursor(dpy
, cursor_id
);
2265 } else if (strcasecmp(val
, "bitmap") == 0) {
2277 wwarning(_("bad number of arguments in cursor specification"));
2280 elem
= WMGetFromPLArray(pl
, 1);
2281 if (!elem
|| !WMIsPLString(elem
)) {
2284 val
= WMGetFromPLString(elem
);
2285 bitmap_name
= FindImage(wPreferences
.pixmap_path
, val
);
2287 wwarning(_("could not find cursor bitmap file \"%s\""), val
);
2290 elem
= WMGetFromPLArray(pl
, 2);
2291 if (!elem
|| !WMIsPLString(elem
)) {
2295 val
= WMGetFromPLString(elem
);
2296 mask_name
= FindImage(wPreferences
.pixmap_path
, val
);
2299 wwarning(_("could not find cursor bitmap file \"%s\""), val
);
2302 mask_status
= XReadBitmapFile(dpy
, scr
->w_win
, mask_name
, &w
, &h
, &mask
, &x
, &y
);
2303 bitmap_status
= XReadBitmapFile(dpy
, scr
->w_win
, bitmap_name
, &w
, &h
, &bitmap
, &x
, &y
);
2304 if ((BitmapSuccess
== bitmap_status
) && (BitmapSuccess
== mask_status
)) {
2305 fg
.pixel
= scr
->black_pixel
;
2306 bg
.pixel
= scr
->white_pixel
;
2307 XQueryColor(dpy
, scr
->w_colormap
, &fg
);
2308 XQueryColor(dpy
, scr
->w_colormap
, &bg
);
2309 *cursor
= XCreatePixmapCursor(dpy
, bitmap
, mask
, &fg
, &bg
, x
, y
);
2312 check_bitmap_status(bitmap_status
, bitmap_name
, bitmap
);
2313 check_bitmap_status(mask_status
, mask_name
, mask
);
2320 static int getCursor(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
2322 static Cursor cursor
;
2327 if (!WMIsPLArray(value
)) {
2328 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
2329 entry
->key
, "cursor specification");
2331 value
= entry
->plvalue
;
2333 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
2338 status
= parse_cursor(scr
, value
, &cursor
);
2340 wwarning(_("Error in cursor specification for key \"%s\""), entry
->key
);
2342 value
= entry
->plvalue
;
2344 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
2353 *(Cursor
*) addr
= cursor
;
2358 #undef CURSOR_ID_NONE
2360 /* ---------------- value setting functions --------------- */
2361 static int setJustify(WScreen
* scr
, WDefaultEntry
* entry
, WTexture
** texture
, void *foo
)
2363 return REFRESH_WINDOW_TITLE_COLOR
;
2366 static int setClearance(WScreen
* scr
, WDefaultEntry
* entry
, void *bar
, void *foo
)
2368 return REFRESH_WINDOW_FONT
| REFRESH_BUTTON_IMAGES
| REFRESH_MENU_TITLE_FONT
| REFRESH_MENU_FONT
;
2371 static int setIfDockPresent(WScreen
* scr
, WDefaultEntry
* entry
, char *flag
, long which
)
2375 wPreferences
.flags
.nodock
= wPreferences
.flags
.nodock
|| *flag
;
2378 wPreferences
.flags
.noclip
= wPreferences
.flags
.noclip
|| *flag
;
2386 static int setStickyIcons(WScreen
* scr
, WDefaultEntry
* entry
, void *bar
, void *foo
)
2388 if (scr
->workspaces
) {
2389 wWorkspaceForceChange(scr
, scr
->current_workspace
);
2390 wArrangeIcons(scr
, False
);
2395 static int setIconTile(WScreen
* scr
, WDefaultEntry
* entry
, WTexture
** texture
, void *foo
)
2401 img
= wTextureRenderImage(*texture
, wPreferences
.icon_size
,
2402 wPreferences
.icon_size
, ((*texture
)->any
.type
& WREL_BORDER_MASK
)
2403 ? WREL_ICON
: WREL_FLAT
);
2405 wwarning(_("could not render texture for icon background"));
2407 wTextureDestroy(scr
, *texture
);
2410 RConvertImage(scr
->rcontext
, img
, &pixmap
);
2412 if (scr
->icon_tile
) {
2414 RReleaseImage(scr
->icon_tile
);
2415 XFreePixmap(dpy
, scr
->icon_tile_pixmap
);
2418 scr
->icon_tile
= img
;
2420 /* put the icon in the noticeboard hint */
2421 PropSetIconTileHint(scr
, img
);
2423 if (!wPreferences
.flags
.noclip
) {
2424 if (scr
->clip_tile
) {
2425 RReleaseImage(scr
->clip_tile
);
2427 scr
->clip_tile
= wClipMakeTile(scr
, img
);
2430 scr
->icon_tile_pixmap
= pixmap
;
2432 if (scr
->def_icon_rimage
) {
2433 RReleaseImage(scr
->def_icon_rimage
);
2434 scr
->def_icon_rimage
= NULL
;
2437 if (scr
->icon_back_texture
)
2438 wTextureDestroy(scr
, (WTexture
*) scr
->icon_back_texture
);
2440 scr
->icon_back_texture
= wTextureMakeSolid(scr
, &((*texture
)->any
.color
));
2442 /* Free the texture as nobody else will use it, nor refer to it. */
2444 wTextureDestroy(scr
, *texture
);
2446 return (reset
? REFRESH_ICON_TILE
: 0);
2449 static int setWinTitleFont(WScreen
* scr
, WDefaultEntry
* entry
, WMFont
* font
, void *foo
)
2451 if (scr
->title_font
) {
2452 WMReleaseFont(scr
->title_font
);
2454 scr
->title_font
= font
;
2456 return REFRESH_WINDOW_FONT
| REFRESH_BUTTON_IMAGES
;
2459 static int setMenuTitleFont(WScreen
* scr
, WDefaultEntry
* entry
, WMFont
* font
, void *foo
)
2461 if (scr
->menu_title_font
) {
2462 WMReleaseFont(scr
->menu_title_font
);
2465 scr
->menu_title_font
= font
;
2467 return REFRESH_MENU_TITLE_FONT
;
2470 static int setMenuTextFont(WScreen
* scr
, WDefaultEntry
* entry
, WMFont
* font
, void *foo
)
2472 if (scr
->menu_entry_font
) {
2473 WMReleaseFont(scr
->menu_entry_font
);
2475 scr
->menu_entry_font
= font
;
2477 return REFRESH_MENU_FONT
;
2480 static int setIconTitleFont(WScreen
* scr
, WDefaultEntry
* entry
, WMFont
* font
, void *foo
)
2482 if (scr
->icon_title_font
) {
2483 WMReleaseFont(scr
->icon_title_font
);
2486 scr
->icon_title_font
= font
;
2488 return REFRESH_ICON_FONT
;
2491 static int setClipTitleFont(WScreen
* scr
, WDefaultEntry
* entry
, WMFont
* font
, void *foo
)
2493 if (scr
->clip_title_font
) {
2494 WMReleaseFont(scr
->clip_title_font
);
2497 scr
->clip_title_font
= font
;
2499 return REFRESH_ICON_FONT
;
2502 static int setLargeDisplayFont(WScreen
* scr
, WDefaultEntry
* entry
, WMFont
* font
, void *foo
)
2504 if (scr
->workspace_name_font
) {
2505 WMReleaseFont(scr
->workspace_name_font
);
2508 scr
->workspace_name_font
= font
;
2513 static int setHightlight(WScreen
* scr
, WDefaultEntry
* entry
, XColor
* color
, void *foo
)
2515 if (scr
->select_color
)
2516 WMReleaseColor(scr
->select_color
);
2518 scr
->select_color
= WMCreateRGBColor(scr
->wmscreen
, color
->red
, color
->green
, color
->blue
, True
);
2520 wFreeColor(scr
, color
->pixel
);
2522 return REFRESH_MENU_COLOR
;
2525 static int setHightlightText(WScreen
* scr
, WDefaultEntry
* entry
, XColor
* color
, void *foo
)
2527 if (scr
->select_text_color
)
2528 WMReleaseColor(scr
->select_text_color
);
2530 scr
->select_text_color
= WMCreateRGBColor(scr
->wmscreen
, color
->red
, color
->green
, color
->blue
, True
);
2532 wFreeColor(scr
, color
->pixel
);
2534 return REFRESH_MENU_COLOR
;
2537 static int setClipTitleColor(WScreen
* scr
, WDefaultEntry
* entry
, XColor
* color
, long widx
)
2539 if (scr
->clip_title_color
[widx
])
2540 WMReleaseColor(scr
->clip_title_color
[widx
]);
2542 scr
->clip_title_color
[widx
] = WMCreateRGBColor(scr
->wmscreen
, color
->red
, color
->green
, color
->blue
, True
);
2543 wFreeColor(scr
, color
->pixel
);
2545 return REFRESH_ICON_TITLE_COLOR
;
2548 static int setWTitleColor(WScreen
* scr
, WDefaultEntry
* entry
, XColor
* color
, long widx
)
2550 if (scr
->window_title_color
[widx
])
2551 WMReleaseColor(scr
->window_title_color
[widx
]);
2553 scr
->window_title_color
[widx
] =
2554 WMCreateRGBColor(scr
->wmscreen
, color
->red
, color
->green
, color
->blue
, True
);
2556 wFreeColor(scr
, color
->pixel
);
2558 return REFRESH_WINDOW_TITLE_COLOR
;
2561 static int setMenuTitleColor(WScreen
* scr
, WDefaultEntry
* entry
, XColor
* color
, long widx
)
2563 if (scr
->menu_title_color
[0])
2564 WMReleaseColor(scr
->menu_title_color
[0]);
2566 scr
->menu_title_color
[0] = WMCreateRGBColor(scr
->wmscreen
, color
->red
, color
->green
, color
->blue
, True
);
2568 wFreeColor(scr
, color
->pixel
);
2570 return REFRESH_MENU_TITLE_COLOR
;
2573 static int setMenuTextColor(WScreen
* scr
, WDefaultEntry
* entry
, XColor
* color
, void *foo
)
2575 if (scr
->mtext_color
)
2576 WMReleaseColor(scr
->mtext_color
);
2578 scr
->mtext_color
= WMCreateRGBColor(scr
->wmscreen
, color
->red
, color
->green
, color
->blue
, True
);
2580 if (WMColorPixel(scr
->dtext_color
) == WMColorPixel(scr
->mtext_color
)) {
2581 WMSetColorAlpha(scr
->dtext_color
, 0x7fff);
2583 WMSetColorAlpha(scr
->dtext_color
, 0xffff);
2586 wFreeColor(scr
, color
->pixel
);
2588 return REFRESH_MENU_COLOR
;
2591 static int setMenuDisabledColor(WScreen
* scr
, WDefaultEntry
* entry
, XColor
* color
, void *foo
)
2593 if (scr
->dtext_color
)
2594 WMReleaseColor(scr
->dtext_color
);
2596 scr
->dtext_color
= WMCreateRGBColor(scr
->wmscreen
, color
->red
, color
->green
, color
->blue
, True
);
2598 if (WMColorPixel(scr
->dtext_color
) == WMColorPixel(scr
->mtext_color
)) {
2599 WMSetColorAlpha(scr
->dtext_color
, 0x7fff);
2601 WMSetColorAlpha(scr
->dtext_color
, 0xffff);
2604 wFreeColor(scr
, color
->pixel
);
2606 return REFRESH_MENU_COLOR
;
2609 static int setIconTitleColor(WScreen
* scr
, WDefaultEntry
* entry
, XColor
* color
, void *foo
)
2611 if (scr
->icon_title_color
)
2612 WMReleaseColor(scr
->icon_title_color
);
2613 scr
->icon_title_color
= WMCreateRGBColor(scr
->wmscreen
, color
->red
, color
->green
, color
->blue
, True
);
2615 wFreeColor(scr
, color
->pixel
);
2617 return REFRESH_ICON_TITLE_COLOR
;
2620 static int setIconTitleBack(WScreen
* scr
, WDefaultEntry
* entry
, XColor
* color
, void *foo
)
2622 if (scr
->icon_title_texture
) {
2623 wTextureDestroy(scr
, (WTexture
*) scr
->icon_title_texture
);
2625 scr
->icon_title_texture
= wTextureMakeSolid(scr
, color
);
2627 return REFRESH_ICON_TITLE_BACK
;
2630 static int setFrameBorderWidth(WScreen
* scr
, WDefaultEntry
* entry
, int * value
, void *foo
)
2632 scr
->frame_border_width
= *value
;
2634 return REFRESH_FRAME_BORDER
;
2637 static int setFrameBorderColor(WScreen
* scr
, WDefaultEntry
* entry
, XColor
* color
, void *foo
)
2639 if (scr
->frame_border_color
)
2640 WMReleaseColor(scr
->frame_border_color
);
2641 scr
->frame_border_color
= WMCreateRGBColor(scr
->wmscreen
, color
->red
, color
->green
, color
->blue
, True
);
2643 wFreeColor(scr
, color
->pixel
);
2645 return REFRESH_FRAME_BORDER
;
2648 static int setFrameSelectedBorderColor(WScreen
* scr
, WDefaultEntry
* entry
, XColor
* color
, void *foo
)
2650 if (scr
->frame_selected_border_color
)
2651 WMReleaseColor(scr
->frame_selected_border_color
);
2652 scr
->frame_selected_border_color
= WMCreateRGBColor(scr
->wmscreen
, color
->red
, color
->green
, color
->blue
, True
);
2654 wFreeColor(scr
, color
->pixel
);
2656 return REFRESH_FRAME_BORDER
;
2659 static void trackDeadProcess(pid_t pid
, unsigned char status
, WScreen
* scr
)
2661 close(scr
->helper_fd
);
2663 scr
->helper_pid
= 0;
2664 scr
->flags
.backimage_helper_launched
= 0;
2667 static int setWorkspaceSpecificBack(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *bar
)
2673 if (scr
->flags
.backimage_helper_launched
) {
2674 if (WMGetPropListItemCount(value
) == 0) {
2675 SendHelperMessage(scr
, 'C', 0, NULL
);
2676 SendHelperMessage(scr
, 'K', 0, NULL
);
2678 WMReleasePropList(value
);
2685 if (WMGetPropListItemCount(value
) == 0)
2688 if (pipe(filedes
) < 0) {
2689 werror("pipe() failed:can't set workspace specific background image");
2691 WMReleasePropList(value
);
2697 werror("fork() failed:can't set workspace specific background image");
2698 if (close(filedes
[0]) < 0)
2699 werror("could not close pipe");
2700 if (close(filedes
[1]) < 0)
2701 werror("could not close pipe");
2703 } else if (pid
== 0) {
2706 SetupEnvironment(scr
);
2709 werror("could not close pipe");
2710 if (dup(filedes
[0]) < 0) {
2711 werror("dup() failed:can't set workspace specific background image");
2713 dither
= wPreferences
.no_dithering
? "-m" : "-d";
2714 if (wPreferences
.smooth_workspace_back
)
2715 execlp("wmsetbg", "wmsetbg", "-helper", "-S", dither
, NULL
);
2717 execlp("wmsetbg", "wmsetbg", "-helper", dither
, NULL
);
2718 werror("could not execute wmsetbg");
2722 if (fcntl(filedes
[0], F_SETFD
, FD_CLOEXEC
) < 0) {
2723 werror("error setting close-on-exec flag");
2725 if (fcntl(filedes
[1], F_SETFD
, FD_CLOEXEC
) < 0) {
2726 werror("error setting close-on-exec flag");
2729 scr
->helper_fd
= filedes
[1];
2730 scr
->helper_pid
= pid
;
2731 scr
->flags
.backimage_helper_launched
= 1;
2733 wAddDeathHandler(pid
, (WDeathHandler
*) trackDeadProcess
, scr
);
2735 SendHelperMessage(scr
, 'P', -1, wPreferences
.pixmap_path
);
2740 for (i
= 0; i
< WMGetPropListItemCount(value
); i
++) {
2741 val
= WMGetFromPLArray(value
, i
);
2742 if (val
&& WMIsPLArray(val
) && WMGetPropListItemCount(val
) > 0) {
2743 str
= WMGetPropListDescription(val
, False
);
2745 SendHelperMessage(scr
, 'S', i
+ 1, str
);
2749 SendHelperMessage(scr
, 'U', i
+ 1, NULL
);
2754 WMReleasePropList(value
);
2758 static int setWorkspaceBack(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *bar
)
2760 if (scr
->flags
.backimage_helper_launched
) {
2763 if (WMGetPropListItemCount(value
) == 0) {
2764 SendHelperMessage(scr
, 'U', 0, NULL
);
2766 /* set the default workspace background to this one */
2767 str
= WMGetPropListDescription(value
, False
);
2769 SendHelperMessage(scr
, 'S', 0, str
);
2771 SendHelperMessage(scr
, 'C', scr
->current_workspace
+ 1, NULL
);
2773 SendHelperMessage(scr
, 'U', 0, NULL
);
2776 } else if (WMGetPropListItemCount(value
) > 0) {
2782 text
= WMGetPropListDescription(value
, False
);
2783 len
= strlen(text
) + 40;
2784 command
= wmalloc(len
);
2785 dither
= wPreferences
.no_dithering
? "-m" : "-d";
2786 if (wPreferences
.smooth_workspace_back
)
2787 snprintf(command
, len
, "wmsetbg %s -S -p '%s' &", dither
, text
);
2789 snprintf(command
, len
, "wmsetbg %s -p '%s' &", dither
, text
);
2791 ExecuteShellCommand(scr
, command
);
2794 WMReleasePropList(value
);
2799 static int setWidgetColor(WScreen
* scr
, WDefaultEntry
* entry
, WTexture
** texture
, void *foo
)
2801 if (scr
->widget_texture
) {
2802 wTextureDestroy(scr
, (WTexture
*) scr
->widget_texture
);
2804 scr
->widget_texture
= *(WTexSolid
**) texture
;
2809 static int setFTitleBack(WScreen
* scr
, WDefaultEntry
* entry
, WTexture
** texture
, void *foo
)
2811 if (scr
->window_title_texture
[WS_FOCUSED
]) {
2812 wTextureDestroy(scr
, scr
->window_title_texture
[WS_FOCUSED
]);
2814 scr
->window_title_texture
[WS_FOCUSED
] = *texture
;
2816 return REFRESH_WINDOW_TEXTURES
;
2819 static int setPTitleBack(WScreen
* scr
, WDefaultEntry
* entry
, WTexture
** texture
, void *foo
)
2821 if (scr
->window_title_texture
[WS_PFOCUSED
]) {
2822 wTextureDestroy(scr
, scr
->window_title_texture
[WS_PFOCUSED
]);
2824 scr
->window_title_texture
[WS_PFOCUSED
] = *texture
;
2826 return REFRESH_WINDOW_TEXTURES
;
2829 static int setUTitleBack(WScreen
* scr
, WDefaultEntry
* entry
, WTexture
** texture
, void *foo
)
2831 if (scr
->window_title_texture
[WS_UNFOCUSED
]) {
2832 wTextureDestroy(scr
, scr
->window_title_texture
[WS_UNFOCUSED
]);
2834 scr
->window_title_texture
[WS_UNFOCUSED
] = *texture
;
2836 return REFRESH_WINDOW_TEXTURES
;
2839 static int setResizebarBack(WScreen
* scr
, WDefaultEntry
* entry
, WTexture
** texture
, void *foo
)
2841 if (scr
->resizebar_texture
[0]) {
2842 wTextureDestroy(scr
, scr
->resizebar_texture
[0]);
2844 scr
->resizebar_texture
[0] = *texture
;
2846 return REFRESH_WINDOW_TEXTURES
;
2849 static int setMenuTitleBack(WScreen
* scr
, WDefaultEntry
* entry
, WTexture
** texture
, void *foo
)
2851 if (scr
->menu_title_texture
[0]) {
2852 wTextureDestroy(scr
, scr
->menu_title_texture
[0]);
2854 scr
->menu_title_texture
[0] = *texture
;
2856 return REFRESH_MENU_TITLE_TEXTURE
;
2859 static int setMenuTextBack(WScreen
* scr
, WDefaultEntry
* entry
, WTexture
** texture
, void *foo
)
2861 if (scr
->menu_item_texture
) {
2862 wTextureDestroy(scr
, scr
->menu_item_texture
);
2863 wTextureDestroy(scr
, (WTexture
*) scr
->menu_item_auxtexture
);
2865 scr
->menu_item_texture
= *texture
;
2867 scr
->menu_item_auxtexture
= wTextureMakeSolid(scr
, &scr
->menu_item_texture
->any
.color
);
2869 return REFRESH_MENU_TEXTURE
;
2872 static int setKeyGrab(WScreen
* scr
, WDefaultEntry
* entry
, WShortKey
* shortcut
, long widx
)
2875 wKeyBindings
[widx
] = *shortcut
;
2877 wwin
= scr
->focused_window
;
2879 while (wwin
!= NULL
) {
2880 XUngrabKey(dpy
, AnyKey
, AnyModifier
, wwin
->frame
->core
->window
);
2882 if (!WFLAGP(wwin
, no_bind_keys
)) {
2883 wWindowSetKeyGrabs(wwin
);
2888 /* do we need to update window menus? */
2889 if (widx
>= WKBD_WORKSPACE1
&& widx
<= WKBD_WORKSPACE10
)
2890 return REFRESH_WORKSPACE_MENU
;
2891 if (widx
== WKBD_LASTWORKSPACE
)
2892 return REFRESH_WORKSPACE_MENU
;
2893 if (widx
>= WKBD_MOVE_WORKSPACE1
&& widx
<= WKBD_MOVE_WORKSPACE10
)
2894 return REFRESH_WORKSPACE_MENU
;
2899 static int setIconPosition(WScreen
* scr
, WDefaultEntry
* entry
, void *bar
, void *foo
)
2901 wScreenUpdateUsableArea(scr
);
2902 wArrangeIcons(scr
, True
);
2907 static int updateUsableArea(WScreen
* scr
, WDefaultEntry
* entry
, void *bar
, void *foo
)
2909 wScreenUpdateUsableArea(scr
);
2914 static int setMenuStyle(WScreen
* scr
, WDefaultEntry
* entry
, int *value
, void *foo
)
2916 return REFRESH_MENU_TEXTURE
;
2919 static RImage
*chopOffImage(RImage
* image
, int x
, int y
, int w
, int h
)
2921 RImage
*img
= RCreateImage(w
, h
, image
->format
== RRGBAFormat
);
2923 RCopyArea(img
, image
, x
, y
, w
, h
, 0, 0);
2928 static int setSwPOptions(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* array
, void *foo
)
2932 int cwidth
, cheight
;
2933 WPreferences
*prefs
= (WPreferences
*) foo
;
2935 if (!WMIsPLArray(array
) || WMGetPropListItemCount(array
) == 0) {
2936 if (prefs
->swtileImage
)
2937 RReleaseImage(prefs
->swtileImage
);
2938 prefs
->swtileImage
= NULL
;
2940 WMReleasePropList(array
);
2944 switch (WMGetPropListItemCount(array
)) {
2946 if (!WMIsPLString(WMGetFromPLArray(array
, 1))) {
2947 wwarning(_("Invalid arguments for option \"%s\""), entry
->key
);
2950 path
= FindImage(wPreferences
.pixmap_path
, WMGetFromPLString(WMGetFromPLArray(array
, 1)));
2953 wwarning(_("Could not find image \"%s\" for option \"%s\""),
2954 WMGetFromPLString(WMGetFromPLArray(array
, 1)), entry
->key
);
2956 bgimage
= RLoadImage(scr
->rcontext
, path
, 0);
2958 wwarning(_("Could not load image \"%s\" for option \"%s\""), path
, entry
->key
);
2963 cwidth
= atoi(WMGetFromPLString(WMGetFromPLArray(array
, 2)));
2964 cheight
= atoi(WMGetFromPLString(WMGetFromPLArray(array
, 3)));
2966 if (cwidth
<= 0 || cheight
<= 0 ||
2967 cwidth
>= bgimage
->width
- 2 || cheight
>= bgimage
->height
- 2)
2968 wwarning(_("Invalid split sizes for SwitchPanel back image."));
2971 int swidth
, theight
;
2972 for (i
= 0; i
< 9; i
++) {
2973 if (prefs
->swbackImage
[i
])
2974 RReleaseImage(prefs
->swbackImage
[i
]);
2975 prefs
->swbackImage
[i
] = NULL
;
2977 swidth
= (bgimage
->width
- cwidth
) / 2;
2978 theight
= (bgimage
->height
- cheight
) / 2;
2980 prefs
->swbackImage
[0] = chopOffImage(bgimage
, 0, 0, swidth
, theight
);
2981 prefs
->swbackImage
[1] = chopOffImage(bgimage
, swidth
, 0, cwidth
, theight
);
2982 prefs
->swbackImage
[2] = chopOffImage(bgimage
, swidth
+ cwidth
, 0,
2985 prefs
->swbackImage
[3] = chopOffImage(bgimage
, 0, theight
, swidth
, cheight
);
2986 prefs
->swbackImage
[4] = chopOffImage(bgimage
, swidth
, theight
,
2988 prefs
->swbackImage
[5] = chopOffImage(bgimage
, swidth
+ cwidth
, theight
,
2991 prefs
->swbackImage
[6] = chopOffImage(bgimage
, 0, theight
+ cheight
,
2993 prefs
->swbackImage
[7] = chopOffImage(bgimage
, swidth
, theight
+ cheight
,
2995 prefs
->swbackImage
[8] =
2996 chopOffImage(bgimage
, swidth
+ cwidth
, theight
+ cheight
, swidth
,
2999 // check if anything failed
3000 for (i
= 0; i
< 9; i
++) {
3001 if (!prefs
->swbackImage
[i
]) {
3002 for (; i
>= 0; --i
) {
3003 RReleaseImage(prefs
->swbackImage
[i
]);
3004 prefs
->swbackImage
[i
] = NULL
;
3010 RReleaseImage(bgimage
);
3015 if (!WMIsPLString(WMGetFromPLArray(array
, 0))) {
3016 wwarning(_("Invalid arguments for option \"%s\""), entry
->key
);
3019 path
= FindImage(wPreferences
.pixmap_path
, WMGetFromPLString(WMGetFromPLArray(array
, 0)));
3022 wwarning(_("Could not find image \"%s\" for option \"%s\""),
3023 WMGetFromPLString(WMGetFromPLArray(array
, 0)), entry
->key
);
3025 if (prefs
->swtileImage
)
3026 RReleaseImage(prefs
->swtileImage
);
3028 prefs
->swtileImage
= RLoadImage(scr
->rcontext
, path
, 0);
3029 if (!prefs
->swtileImage
) {
3030 wwarning(_("Could not load image \"%s\" for option \"%s\""), path
, entry
->key
);
3037 wwarning(_("Invalid number of arguments for option \"%s\""), entry
->key
);
3041 WMReleasePropList(array
);
3046 static int setModifierKeyLabels(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* array
, void *foo
)
3049 WPreferences
*prefs
= (WPreferences
*) foo
;
3051 if (!WMIsPLArray(array
) || WMGetPropListItemCount(array
) != 7) {
3052 wwarning(_("Value for option \"%s\" must be an array of 7 strings"), entry
->key
);
3053 WMReleasePropList(array
);
3057 DestroyWindowMenu(scr
);
3059 for (i
= 0; i
< 7; i
++) {
3060 if (prefs
->modifier_labels
[i
])
3061 wfree(prefs
->modifier_labels
[i
]);
3063 if (WMIsPLString(WMGetFromPLArray(array
, i
))) {
3064 prefs
->modifier_labels
[i
] = wstrdup(WMGetFromPLString(WMGetFromPLArray(array
, i
)));
3066 wwarning(_("Invalid argument for option \"%s\" item %d"), entry
->key
, i
);
3067 prefs
->modifier_labels
[i
] = NULL
;
3071 WMReleasePropList(array
);
3076 static int setDoubleClick(WScreen
*scr
, WDefaultEntry
*entry
, int *value
, void *foo
)
3081 W_setconf_doubleClickDelay(*value
);
3086 static int setCursor(WScreen
* scr
, WDefaultEntry
* entry
, Cursor
* cursor
, long widx
)
3088 if (wCursor
[widx
] != None
) {
3089 XFreeCursor(dpy
, wCursor
[widx
]);
3092 wCursor
[widx
] = *cursor
;
3094 if (widx
== WCUR_ROOT
&& *cursor
!= None
) {
3095 XDefineCursor(dpy
, scr
->root_win
, *cursor
);