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"
67 #define MAX_SHORTCUT_LENGTH 32
69 #ifndef GLOBAL_DEFAULTS_SUBDIR
70 #define GLOBAL_DEFAULTS_SUBDIR "WindowMaker"
74 extern WDDomain
*WDWindowMaker
;
75 extern WDDomain
*WDWindowAttributes
;
76 extern WDDomain
*WDRootMenu
;
77 extern int wScreenCount
;
78 extern WPreferences wPreferences
;
79 extern WShortKey wKeyBindings
[WKBD_LAST
];
89 WMPropList
*plvalue
; /* default value */
92 /* used to map strings to integers */
100 static int getBool();
102 static int getCoord();
103 static int getPathList();
104 static int getEnum();
105 static int getTexture();
106 static int getWSBackground();
107 static int getWSSpecificBackground();
108 static int getFont();
109 static int getColor();
110 static int getKeybind();
111 static int getModMask();
112 static int getPropList();
114 /* value setting functions */
115 static int setJustify();
116 static int setClearance();
117 static int setIfDockPresent();
118 static int setClipMergedInDock();
119 static int setWrapAppiconsInDock();
120 static int setStickyIcons();
121 static int setWidgetColor();
122 static int setIconTile();
123 static int setWinTitleFont();
124 static int setMenuTitleFont();
125 static int setMenuTextFont();
126 static int setIconTitleFont();
127 static int setIconTitleColor();
128 static int setIconTitleBack();
129 static int setFrameBorderWidth();
130 static int setFrameBorderColor();
131 static int setFrameSelectedBorderColor();
132 static int setLargeDisplayFont();
133 static int setWTitleColor();
134 static int setFTitleBack();
135 static int setPTitleBack();
136 static int setUTitleBack();
137 static int setResizebarBack();
138 static int setWorkspaceBack();
139 static int setWorkspaceSpecificBack();
140 static int setMenuTitleColor();
141 static int setMenuTextColor();
142 static int setMenuDisabledColor();
143 static int setMenuTitleBack();
144 static int setMenuTextBack();
145 static int setHightlight();
146 static int setHightlightText();
147 static int setKeyGrab();
148 static int setDoubleClick();
149 static int setIconPosition();
151 static int setClipTitleFont();
152 static int setClipTitleColor();
154 static int setMenuStyle();
155 static int setSwPOptions();
156 static int updateUsableArea();
158 static int setModifierKeyLabels();
160 extern Cursor wCursor
[WCUR_LAST
];
161 static int getCursor();
162 static int setCursor();
165 * Tables to convert strings to enumeration values.
166 * Values stored are char
169 /* WARNING: sum of length of all value strings must not exceed
171 #define TOTAL_VALUES_LENGTH 80
173 #define REFRESH_WINDOW_TEXTURES (1<<0)
174 #define REFRESH_MENU_TEXTURE (1<<1)
175 #define REFRESH_MENU_FONT (1<<2)
176 #define REFRESH_MENU_COLOR (1<<3)
177 #define REFRESH_MENU_TITLE_TEXTURE (1<<4)
178 #define REFRESH_MENU_TITLE_FONT (1<<5)
179 #define REFRESH_MENU_TITLE_COLOR (1<<6)
180 #define REFRESH_WINDOW_TITLE_COLOR (1<<7)
181 #define REFRESH_WINDOW_FONT (1<<8)
182 #define REFRESH_ICON_TILE (1<<9)
183 #define REFRESH_ICON_FONT (1<<10)
184 #define REFRESH_WORKSPACE_BACK (1<<11)
186 #define REFRESH_BUTTON_IMAGES (1<<12)
188 #define REFRESH_ICON_TITLE_COLOR (1<<13)
189 #define REFRESH_ICON_TITLE_BACK (1<<14)
191 #define REFRESH_WORKSPACE_MENU (1<<15)
193 #define REFRESH_FRAME_BORDER REFRESH_MENU_FONT|REFRESH_WINDOW_FONT
195 static WOptionEnumeration seFocusModes
[] = {
196 {"Manual", WKF_CLICK
, 0}, {"ClickToFocus", WKF_CLICK
, 1},
197 {"Sloppy", WKF_SLOPPY
, 0}, {"SemiAuto", WKF_SLOPPY
, 1}, {"Auto", WKF_SLOPPY
, 1},
201 static WOptionEnumeration seTitlebarModes
[] = {
202 {"new", TS_NEW
, 0}, {"old", TS_OLD
, 0},
203 {"next", TS_NEXT
, 0}, {NULL
, 0, 0}
206 static WOptionEnumeration seColormapModes
[] = {
207 {"Manual", WCM_CLICK
, 0}, {"ClickToFocus", WCM_CLICK
, 1},
208 {"Auto", WCM_POINTER
, 0}, {"FocusFollowMouse", WCM_POINTER
, 1},
212 static WOptionEnumeration sePlacements
[] = {
213 {"Auto", WPM_AUTO
, 0},
214 {"Smart", WPM_SMART
, 0},
215 {"Cascade", WPM_CASCADE
, 0},
216 {"Random", WPM_RANDOM
, 0},
217 {"Manual", WPM_MANUAL
, 0},
218 {"Center", WPM_CENTER
, 0},
222 static WOptionEnumeration seGeomDisplays
[] = {
223 {"None", WDIS_NONE
, 0},
224 {"Center", WDIS_CENTER
, 0},
225 {"Corner", WDIS_TOPLEFT
, 0},
226 {"Floating", WDIS_FRAME_CENTER
, 0},
227 {"Line", WDIS_NEW
, 0},
231 static WOptionEnumeration seSpeeds
[] = {
232 {"UltraFast", SPEED_ULTRAFAST
, 0},
233 {"Fast", SPEED_FAST
, 0},
234 {"Medium", SPEED_MEDIUM
, 0},
235 {"Slow", SPEED_SLOW
, 0},
236 {"UltraSlow", SPEED_ULTRASLOW
, 0},
240 static WOptionEnumeration seMouseButtonActions
[] = {
241 {"None", WA_NONE
, 0},
242 {"SelectWindows", WA_SELECT_WINDOWS
, 0},
243 {"OpenApplicationsMenu", WA_OPEN_APPMENU
, 0},
244 {"OpenWindowListMenu", WA_OPEN_WINLISTMENU
, 0},
248 static WOptionEnumeration seMouseWheelActions
[] = {
249 {"None", WA_NONE
, 0},
250 {"SwitchWorkspaces", WA_SWITCH_WORKSPACES
, 0},
254 static WOptionEnumeration seIconificationStyles
[] = {
255 {"Zoom", WIS_ZOOM
, 0},
256 {"Twist", WIS_TWIST
, 0},
257 {"Flip", WIS_FLIP
, 0},
258 {"None", WIS_NONE
, 0},
259 {"random", WIS_RANDOM
, 0},
263 static WOptionEnumeration seJustifications
[] = {
264 {"Left", WTJ_LEFT
, 0},
265 {"Center", WTJ_CENTER
, 0},
266 {"Right", WTJ_RIGHT
, 0},
270 static WOptionEnumeration seIconPositions
[] = {
271 {"blv", IY_BOTTOM
| IY_LEFT
| IY_VERT
, 0},
272 {"blh", IY_BOTTOM
| IY_LEFT
| IY_HORIZ
, 0},
273 {"brv", IY_BOTTOM
| IY_RIGHT
| IY_VERT
, 0},
274 {"brh", IY_BOTTOM
| IY_RIGHT
| IY_HORIZ
, 0},
275 {"tlv", IY_TOP
| IY_LEFT
| IY_VERT
, 0},
276 {"tlh", IY_TOP
| IY_LEFT
| IY_HORIZ
, 0},
277 {"trv", IY_TOP
| IY_RIGHT
| IY_VERT
, 0},
278 {"trh", IY_TOP
| IY_RIGHT
| IY_HORIZ
, 0},
282 static WOptionEnumeration seMenuStyles
[] = {
283 {"normal", MS_NORMAL
, 0},
284 {"singletexture", MS_SINGLE_TEXTURE
, 0},
285 {"flat", MS_FLAT
, 0},
289 static WOptionEnumeration seDisplayPositions
[] = {
290 {"none", WD_NONE
, 0},
291 {"center", WD_CENTER
, 0},
293 {"bottom", WD_BOTTOM
, 0},
294 {"topleft", WD_TOPLEFT
, 0},
295 {"topright", WD_TOPRIGHT
, 0},
296 {"bottomleft", WD_BOTTOMLEFT
, 0},
297 {"bottomright", WD_BOTTOMRIGHT
, 0},
301 static WOptionEnumeration seWorkspaceBorder
[] = {
302 {"None", WB_NONE
, 0},
303 {"LeftRight", WB_LEFTRIGHT
, 0},
304 {"TopBottom", WB_TOPBOTTOM
, 0},
305 {"AllDirections", WB_ALLDIRS
, 0},
310 * ALL entries in the tables bellow, NEED to have a default value
311 * defined, and this value needs to be correct.
314 /* these options will only affect the window manager on startup
316 * static defaults can't access the screen data, because it is
317 * created after these defaults are read
319 WDefaultEntry staticOptionList
[] = {
321 {"ColormapSize", "4", NULL
,
322 &wPreferences
.cmap_size
, getInt
, NULL
, NULL
, NULL
},
323 {"DisableDithering", "NO", NULL
,
324 &wPreferences
.no_dithering
, getBool
, NULL
, NULL
, NULL
},
325 {"IconSize", "64", NULL
,
326 &wPreferences
.icon_size
, getInt
, NULL
, NULL
, NULL
},
327 {"ModifierKey", "Mod1", NULL
,
328 &wPreferences
.modifier_mask
, getModMask
, NULL
, NULL
, NULL
},
329 {"DisableWSMouseActions", "NO", NULL
,
330 &wPreferences
.disable_root_mouse
, getBool
, NULL
, NULL
, NULL
},
331 {"FocusMode", "manual", seFocusModes
, /* have a problem when switching from */
332 &wPreferences
.focus_mode
, getEnum
, NULL
, NULL
, NULL
}, /* manual to sloppy without restart */
333 {"NewStyle", "new", seTitlebarModes
,
334 &wPreferences
.new_style
, getEnum
, NULL
, NULL
, NULL
},
335 {"DisableDock", "NO", (void *)WM_DOCK
,
336 NULL
, getBool
, setIfDockPresent
, NULL
, NULL
},
337 {"DisableClip", "NO", (void *)WM_CLIP
,
338 NULL
, getBool
, setIfDockPresent
, NULL
, NULL
},
339 {"DisableDrawers", "NO", (void *)WM_DRAWER
,
340 NULL
, getBool
, setIfDockPresent
, NULL
, NULL
},
341 {"ClipMergedInDock", "NO", NULL
,
342 NULL
, getBool
, setClipMergedInDock
, NULL
, NULL
},
343 {"DisableMiniwindows", "NO", NULL
,
344 &wPreferences
.disable_miniwindows
, getBool
, NULL
, NULL
, NULL
}
347 #define NUM2STRING_(x) #x
348 #define NUM2STRING(x) NUM2STRING_(x)
350 WDefaultEntry optionList
[] = {
352 /* dynamic options */
354 {"IconPosition", "blh", seIconPositions
,
355 &wPreferences
.icon_yard
, getEnum
, setIconPosition
, NULL
, NULL
},
356 {"IconificationStyle", "Zoom", seIconificationStyles
,
357 &wPreferences
.iconification_style
, getEnum
, NULL
, NULL
, NULL
},
358 {"MouseLeftButtonAction", "SelectWindows", seMouseButtonActions
,
359 &wPreferences
.mouse_button1
, getEnum
, NULL
, NULL
, NULL
},
360 {"MouseMiddleButtonAction", "OpenWindowListMenu", seMouseButtonActions
,
361 &wPreferences
.mouse_button2
, getEnum
, NULL
, NULL
, NULL
},
362 {"MouseRightButtonAction", "OpenApplicationsMenu", seMouseButtonActions
,
363 &wPreferences
.mouse_button3
, getEnum
, NULL
, NULL
, NULL
},
364 {"MouseWheelAction", "None", seMouseWheelActions
,
365 &wPreferences
.mouse_wheel
, getEnum
, NULL
, NULL
, NULL
},
366 {"PixmapPath", DEF_PIXMAP_PATHS
, NULL
,
367 &wPreferences
.pixmap_path
, getPathList
, NULL
, NULL
, NULL
},
368 {"IconPath", DEF_ICON_PATHS
, NULL
,
369 &wPreferences
.icon_path
, getPathList
, NULL
, NULL
, NULL
},
370 {"ColormapMode", "auto", seColormapModes
,
371 &wPreferences
.colormap_mode
, getEnum
, NULL
, NULL
, NULL
},
372 {"AutoFocus", "NO", NULL
,
373 &wPreferences
.auto_focus
, getBool
, NULL
, NULL
, NULL
},
374 {"RaiseDelay", "0", NULL
,
375 &wPreferences
.raise_delay
, getInt
, NULL
, NULL
, NULL
},
376 {"CirculateRaise", "NO", NULL
,
377 &wPreferences
.circ_raise
, getBool
, NULL
, NULL
, NULL
},
378 {"Superfluous", "NO", NULL
,
379 &wPreferences
.superfluous
, getBool
, NULL
, NULL
, NULL
},
380 {"AdvanceToNewWorkspace", "NO", NULL
,
381 &wPreferences
.ws_advance
, getBool
, NULL
, NULL
, NULL
},
382 {"CycleWorkspaces", "NO", NULL
,
383 &wPreferences
.ws_cycle
, getBool
, NULL
, NULL
, NULL
},
384 {"WorkspaceNameDisplayPosition", "center", seDisplayPositions
,
385 &wPreferences
.workspace_name_display_position
, getEnum
, NULL
, NULL
, NULL
},
386 {"WorkspaceBorder", "None", seWorkspaceBorder
,
387 &wPreferences
.workspace_border_position
, getEnum
, updateUsableArea
, NULL
, NULL
},
388 {"WorkspaceBorderSize", "0", NULL
,
389 &wPreferences
.workspace_border_size
, getInt
, updateUsableArea
, NULL
, NULL
},
390 {"StickyIcons", "NO", NULL
,
391 &wPreferences
.sticky_icons
, getBool
, setStickyIcons
, NULL
, NULL
},
392 {"SaveSessionOnExit", "NO", NULL
,
393 &wPreferences
.save_session_on_exit
, getBool
, NULL
, NULL
, NULL
},
394 {"WrapMenus", "NO", NULL
,
395 &wPreferences
.wrap_menus
, getBool
, NULL
, NULL
, NULL
},
396 {"ScrollableMenus", "NO", NULL
,
397 &wPreferences
.scrollable_menus
, getBool
, NULL
, NULL
, NULL
},
398 {"MenuScrollSpeed", "medium", seSpeeds
,
399 &wPreferences
.menu_scroll_speed
, getEnum
, NULL
, NULL
, NULL
},
400 {"IconSlideSpeed", "medium", seSpeeds
,
401 &wPreferences
.icon_slide_speed
, getEnum
, NULL
, NULL
, NULL
},
402 {"ShadeSpeed", "medium", seSpeeds
,
403 &wPreferences
.shade_speed
, getEnum
, NULL
, NULL
, NULL
},
404 {"BounceAppIconsWhenUrgent", "YES", NULL
,
405 &wPreferences
.bounce_appicons_when_urgent
, getBool
, NULL
, NULL
, NULL
},
406 {"RaiseAppIconsWhenBouncing", "NO", NULL
,
407 &wPreferences
.raise_appicons_when_bouncing
, getBool
, NULL
, NULL
, NULL
},
408 {"DoNotMakeAppIconsBounce", "NO", NULL
,
409 &wPreferences
.do_not_make_appicons_bounce
, getBool
, NULL
, NULL
, NULL
},
410 {"DoubleClickTime", "250", (void *)&wPreferences
.dblclick_time
,
411 &wPreferences
.dblclick_time
, getInt
, setDoubleClick
, NULL
, NULL
},
412 {"ClipAutoraiseDelay", "600", NULL
,
413 &wPreferences
.clip_auto_raise_delay
, getInt
, NULL
, NULL
, NULL
},
414 {"ClipAutolowerDelay", "1000", NULL
,
415 &wPreferences
.clip_auto_lower_delay
, getInt
, NULL
, NULL
, NULL
},
416 {"ClipAutoexpandDelay", "600", NULL
,
417 &wPreferences
.clip_auto_expand_delay
, getInt
, NULL
, NULL
, NULL
},
418 {"ClipAutocollapseDelay", "1000", NULL
,
419 &wPreferences
.clip_auto_collapse_delay
, getInt
, NULL
, NULL
, NULL
},
420 {"WrapAppiconsInDock", "YES", NULL
,
421 NULL
, getBool
, setWrapAppiconsInDock
, NULL
, NULL
},
422 {"AlignSubmenus", "NO", NULL
,
423 &wPreferences
.align_menus
, getBool
, NULL
, NULL
, NULL
},
424 {"ViKeyMenus", "NO", NULL
,
425 &wPreferences
.vi_key_menus
, getBool
, NULL
, NULL
, NULL
},
426 {"OpenTransientOnOwnerWorkspace", "NO", NULL
,
427 &wPreferences
.open_transients_with_parent
, getBool
, NULL
, NULL
, NULL
},
428 {"WindowPlacement", "auto", sePlacements
,
429 &wPreferences
.window_placement
, getEnum
, NULL
, NULL
, NULL
},
430 {"IgnoreFocusClick", "NO", NULL
,
431 &wPreferences
.ignore_focus_click
, getBool
, NULL
, NULL
, NULL
},
432 {"UseSaveUnders", "NO", NULL
,
433 &wPreferences
.use_saveunders
, getBool
, NULL
, NULL
, NULL
},
434 {"OpaqueMove", "NO", NULL
,
435 &wPreferences
.opaque_move
, getBool
, NULL
, NULL
, NULL
},
436 {"OpaqueResize", "NO", NULL
,
437 &wPreferences
.opaque_resize
, getBool
, NULL
, NULL
, NULL
},
438 {"OpaqueMoveResizeKeyboard", "NO", NULL
,
439 &wPreferences
.opaque_move_resize_keyboard
, getBool
, NULL
, NULL
, NULL
},
440 {"DisableAnimations", "NO", NULL
,
441 &wPreferences
.no_animations
, getBool
, NULL
, NULL
, NULL
},
442 {"DontLinkWorkspaces", "NO", NULL
,
443 &wPreferences
.no_autowrap
, getBool
, NULL
, NULL
, NULL
},
444 {"HighlightActiveApp", "YES", NULL
,
445 &wPreferences
.highlight_active_app
, getBool
, NULL
, NULL
, NULL
},
446 {"AutoArrangeIcons", "NO", NULL
,
447 &wPreferences
.auto_arrange_icons
, getBool
, NULL
, NULL
, NULL
},
448 {"NoWindowOverDock", "NO", NULL
,
449 &wPreferences
.no_window_over_dock
, getBool
, updateUsableArea
, NULL
, NULL
},
450 {"NoWindowOverIcons", "NO", NULL
,
451 &wPreferences
.no_window_over_icons
, getBool
, updateUsableArea
, NULL
, NULL
},
452 {"WindowPlaceOrigin", "(0, 0)", NULL
,
453 &wPreferences
.window_place_origin
, getCoord
, NULL
, NULL
, NULL
},
454 {"ResizeDisplay", "corner", seGeomDisplays
,
455 &wPreferences
.size_display
, getEnum
, NULL
, NULL
, NULL
},
456 {"MoveDisplay", "corner", seGeomDisplays
,
457 &wPreferences
.move_display
, getEnum
, NULL
, NULL
, NULL
},
458 {"DontConfirmKill", "NO", NULL
,
459 &wPreferences
.dont_confirm_kill
, getBool
, NULL
, NULL
, NULL
},
460 {"WindowTitleBalloons", "NO", NULL
,
461 &wPreferences
.window_balloon
, getBool
, NULL
, NULL
, NULL
},
462 {"MiniwindowTitleBalloons", "NO", NULL
,
463 &wPreferences
.miniwin_balloon
, getBool
, NULL
, NULL
, NULL
},
464 {"AppIconBalloons", "NO", NULL
,
465 &wPreferences
.appicon_balloon
, getBool
, NULL
, NULL
, NULL
},
466 {"HelpBalloons", "NO", NULL
,
467 &wPreferences
.help_balloon
, getBool
, NULL
, NULL
, NULL
},
468 {"EdgeResistance", "30", NULL
,
469 &wPreferences
.edge_resistance
, getInt
, NULL
, NULL
, NULL
},
470 {"ResizeIncrement", "0", NULL
,
471 &wPreferences
.resize_increment
, getInt
, NULL
, NULL
, NULL
},
472 {"Attraction", "NO", NULL
,
473 &wPreferences
.attract
, getBool
, NULL
, NULL
, NULL
},
474 {"DisableBlinking", "NO", NULL
,
475 &wPreferences
.dont_blink
, getBool
, NULL
, NULL
, NULL
},
476 {"SingleClickLaunch", "NO", NULL
,
477 &wPreferences
.single_click
, getBool
, NULL
, NULL
, NULL
},
478 {"StrictWindozeCycle", "YES", NULL
,
479 &wPreferences
.strict_windoze_cycle
, getBool
, NULL
, NULL
, NULL
},
483 {"MenuStyle", "normal", seMenuStyles
,
484 &wPreferences
.menu_style
, getEnum
, setMenuStyle
, NULL
, NULL
},
485 {"WidgetColor", "(solid, gray)", NULL
,
486 NULL
, getTexture
, setWidgetColor
, NULL
, NULL
},
487 {"WorkspaceSpecificBack", "()", NULL
,
488 NULL
, getWSSpecificBackground
, setWorkspaceSpecificBack
, NULL
, NULL
},
489 /* WorkspaceBack must come after WorkspaceSpecificBack or
490 * WorkspaceBack wont know WorkspaceSpecificBack was also
491 * specified and 2 copies of wmsetbg will be launched */
492 {"WorkspaceBack", "(solid, black)", NULL
,
493 NULL
, getWSBackground
, setWorkspaceBack
, NULL
, NULL
},
494 {"SmoothWorkspaceBack", "NO", NULL
,
495 NULL
, getBool
, NULL
, NULL
, NULL
},
496 {"IconBack", "(solid, gray)", NULL
,
497 NULL
, getTexture
, setIconTile
, NULL
, NULL
},
498 {"TitleJustify", "center", seJustifications
,
499 &wPreferences
.title_justification
, getEnum
, setJustify
, NULL
, NULL
},
500 {"WindowTitleFont", DEF_TITLE_FONT
, NULL
,
501 NULL
, getFont
, setWinTitleFont
, NULL
, NULL
},
502 {"WindowTitleExtendSpace", DEF_WINDOW_TITLE_EXTEND_SPACE
, NULL
,
503 &wPreferences
.window_title_clearance
, getInt
, setClearance
, NULL
, NULL
},
504 {"WindowTitleMinHeight", "0", NULL
,
505 &wPreferences
.window_title_min_height
, getInt
, setClearance
, NULL
, NULL
},
506 {"WindowTitleMaxHeight", NUM2STRING(INT_MAX
), NULL
,
507 &wPreferences
.window_title_max_height
, getInt
, setClearance
, NULL
, NULL
},
508 {"MenuTitleExtendSpace", DEF_MENU_TITLE_EXTEND_SPACE
, NULL
,
509 &wPreferences
.menu_title_clearance
, getInt
, setClearance
, NULL
, NULL
},
510 {"MenuTitleMinHeight", "0", NULL
,
511 &wPreferences
.menu_title_min_height
, getInt
, setClearance
, NULL
, NULL
},
512 {"MenuTitleMaxHeight", NUM2STRING(INT_MAX
), NULL
,
513 &wPreferences
.menu_title_max_height
, getInt
, setClearance
, NULL
, NULL
},
514 {"MenuTextExtendSpace", DEF_MENU_TEXT_EXTEND_SPACE
, NULL
,
515 &wPreferences
.menu_text_clearance
, getInt
, setClearance
, NULL
, NULL
},
516 {"MenuTitleFont", DEF_MENU_TITLE_FONT
, NULL
,
517 NULL
, getFont
, setMenuTitleFont
, NULL
, NULL
},
518 {"MenuTextFont", DEF_MENU_ENTRY_FONT
, NULL
,
519 NULL
, getFont
, setMenuTextFont
, NULL
, NULL
},
520 {"IconTitleFont", DEF_ICON_TITLE_FONT
, NULL
,
521 NULL
, getFont
, setIconTitleFont
, NULL
, NULL
},
522 {"ClipTitleFont", DEF_CLIP_TITLE_FONT
, NULL
,
523 NULL
, getFont
, setClipTitleFont
, NULL
, NULL
},
524 {"ShowClipTitle", "YES", NULL
,
525 &wPreferences
.show_clip_title
, getBool
, NULL
, NULL
, NULL
},
526 {"LargeDisplayFont", DEF_WORKSPACE_NAME_FONT
, NULL
,
527 NULL
, getFont
, setLargeDisplayFont
, NULL
, NULL
},
528 {"HighlightColor", "white", NULL
,
529 NULL
, getColor
, setHightlight
, NULL
, NULL
},
530 {"HighlightTextColor", "black", NULL
,
531 NULL
, getColor
, setHightlightText
, NULL
, NULL
},
532 {"ClipTitleColor", "black", (void *)CLIP_NORMAL
,
533 NULL
, getColor
, setClipTitleColor
, NULL
, NULL
},
534 {"CClipTitleColor", "\"#454045\"", (void *)CLIP_COLLAPSED
,
535 NULL
, getColor
, setClipTitleColor
, NULL
, NULL
},
536 {"FTitleColor", "white", (void *)WS_FOCUSED
,
537 NULL
, getColor
, setWTitleColor
, NULL
, NULL
},
538 {"PTitleColor", "white", (void *)WS_PFOCUSED
,
539 NULL
, getColor
, setWTitleColor
, NULL
, NULL
},
540 {"UTitleColor", "black", (void *)WS_UNFOCUSED
,
541 NULL
, getColor
, setWTitleColor
, NULL
, NULL
},
542 {"FTitleBack", "(solid, black)", NULL
,
543 NULL
, getTexture
, setFTitleBack
, NULL
, NULL
},
544 {"PTitleBack", "(solid, \"#616161\")", NULL
,
545 NULL
, getTexture
, setPTitleBack
, NULL
, NULL
},
546 {"UTitleBack", "(solid, gray)", NULL
,
547 NULL
, getTexture
, setUTitleBack
, NULL
, NULL
},
548 {"ResizebarBack", "(solid, gray)", NULL
,
549 NULL
, getTexture
, setResizebarBack
, NULL
, NULL
},
550 {"MenuTitleColor", "white", NULL
,
551 NULL
, getColor
, setMenuTitleColor
, NULL
, NULL
},
552 {"MenuTextColor", "black", NULL
,
553 NULL
, getColor
, setMenuTextColor
, NULL
, NULL
},
554 {"MenuDisabledColor", "\"#616161\"", NULL
,
555 NULL
, getColor
, setMenuDisabledColor
, NULL
, NULL
},
556 {"MenuTitleBack", "(solid, black)", NULL
,
557 NULL
, getTexture
, setMenuTitleBack
, NULL
, NULL
},
558 {"MenuTextBack", "(solid, gray)", NULL
,
559 NULL
, getTexture
, setMenuTextBack
, NULL
, NULL
},
560 {"IconTitleColor", "white", NULL
,
561 NULL
, getColor
, setIconTitleColor
, NULL
, NULL
},
562 {"IconTitleBack", "black", NULL
,
563 NULL
, getColor
, setIconTitleBack
, NULL
, NULL
},
564 {"SwitchPanelImages", "(swtile.png, swback.png, 30, 40)", &wPreferences
,
565 NULL
, getPropList
, setSwPOptions
, NULL
, NULL
},
566 {"ModifierKeyLabels", "(\"Shift+\", \"Ctrl+\", \"Mod1+\", \"Mod2+\", \"Mod3+\", \"Mod4+\", \"Mod5+\")", &wPreferences
,
567 NULL
, getPropList
, setModifierKeyLabels
, NULL
, NULL
},
568 {"FrameBorderWidth", "1", NULL
,
569 NULL
, getInt
, setFrameBorderWidth
, NULL
, NULL
},
570 {"FrameBorderColor", "black", NULL
,
571 NULL
, getColor
, setFrameBorderColor
, NULL
, NULL
},
572 {"FrameSelectedBorderColor", "white", NULL
,
573 NULL
, getColor
, setFrameSelectedBorderColor
, NULL
, NULL
},
577 {"RootMenuKey", "None", (void *)WKBD_ROOTMENU
,
578 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
579 {"WindowListKey", "None", (void *)WKBD_WINDOWLIST
,
580 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
581 {"WindowMenuKey", "None", (void *)WKBD_WINDOWMENU
,
582 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
583 {"DockRaiseLowerKey", "None", (void*)WKBD_DOCKRAISELOWER
,
584 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
585 {"ClipRaiseLowerKey", "None", (void *)WKBD_CLIPRAISELOWER
,
586 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
587 {"MiniaturizeKey", "None", (void *)WKBD_MINIATURIZE
,
588 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
589 {"MinimizeAllKey", "None", (void *)WKBD_MINIMIZEALL
,
590 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
591 {"HideKey", "None", (void *)WKBD_HIDE
,
592 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
593 {"HideOthersKey", "None", (void *)WKBD_HIDE_OTHERS
,
594 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
595 {"MoveResizeKey", "None", (void *)WKBD_MOVERESIZE
,
596 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
597 {"CloseKey", "None", (void *)WKBD_CLOSE
,
598 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
599 {"MaximizeKey", "None", (void *)WKBD_MAXIMIZE
,
600 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
601 {"VMaximizeKey", "None", (void *)WKBD_VMAXIMIZE
,
602 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
603 {"HMaximizeKey", "None", (void *)WKBD_HMAXIMIZE
,
604 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
605 {"LHMaximizeKey", "None", (void*)WKBD_LHMAXIMIZE
,
606 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
607 {"RHMaximizeKey", "None", (void*)WKBD_RHMAXIMIZE
,
608 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
609 {"THMaximizeKey", "None", (void*)WKBD_THMAXIMIZE
,
610 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
611 {"BHMaximizeKey", "None", (void*)WKBD_BHMAXIMIZE
,
612 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
613 {"LTCMaximizeKey", "None", (void*)WKBD_LTCMAXIMIZE
,
614 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
615 {"RTCMaximizeKey", "None", (void*)WKBD_RTCMAXIMIZE
,
616 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
617 {"LBCMaximizeKey", "None", (void*)WKBD_LBCMAXIMIZE
,
618 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
619 {"RBCMaximizeKey", "None", (void*)WKBD_RBCMAXIMIZE
,
620 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
621 {"MaximusKey", "None", (void*)WKBD_MAXIMUS
,
622 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
623 {"RaiseKey", "\"Meta+Up\"", (void *)WKBD_RAISE
,
624 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
625 {"LowerKey", "\"Meta+Down\"", (void *)WKBD_LOWER
,
626 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
627 {"RaiseLowerKey", "None", (void *)WKBD_RAISELOWER
,
628 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
629 {"ShadeKey", "None", (void *)WKBD_SHADE
,
630 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
631 {"SelectKey", "None", (void *)WKBD_SELECT
,
632 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
633 {"FocusNextKey", "None", (void *)WKBD_FOCUSNEXT
,
634 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
635 {"FocusPrevKey", "None", (void *)WKBD_FOCUSPREV
,
636 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
637 {"GroupNextKey", "None", (void *)WKBD_GROUPNEXT
,
638 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
639 {"GroupPrevKey", "None", (void *)WKBD_GROUPPREV
,
640 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
641 {"NextWorkspaceKey", "None", (void *)WKBD_NEXTWORKSPACE
,
642 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
643 {"PrevWorkspaceKey", "None", (void *)WKBD_PREVWORKSPACE
,
644 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
645 {"LastWorkspaceKey", "None", (void *)WKBD_LASTWORKSPACE
,
646 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
647 {"NextWorkspaceLayerKey", "None", (void *)WKBD_NEXTWSLAYER
,
648 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
649 {"PrevWorkspaceLayerKey", "None", (void *)WKBD_PREVWSLAYER
,
650 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
651 {"Workspace1Key", "None", (void *)WKBD_WORKSPACE1
,
652 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
653 {"Workspace2Key", "None", (void *)WKBD_WORKSPACE2
,
654 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
655 {"Workspace3Key", "None", (void *)WKBD_WORKSPACE3
,
656 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
657 {"Workspace4Key", "None", (void *)WKBD_WORKSPACE4
,
658 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
659 {"Workspace5Key", "None", (void *)WKBD_WORKSPACE5
,
660 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
661 {"Workspace6Key", "None", (void *)WKBD_WORKSPACE6
,
662 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
663 {"Workspace7Key", "None", (void *)WKBD_WORKSPACE7
,
664 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
665 {"Workspace8Key", "None", (void *)WKBD_WORKSPACE8
,
666 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
667 {"Workspace9Key", "None", (void *)WKBD_WORKSPACE9
,
668 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
669 {"Workspace10Key", "None", (void *)WKBD_WORKSPACE10
,
670 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
671 {"MoveToWorkspace1Key", "None", (void *)WKBD_MOVE_WORKSPACE1
,
672 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
673 {"MoveToWorkspace2Key", "None", (void *)WKBD_MOVE_WORKSPACE2
,
674 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
675 {"MoveToWorkspace3Key", "None", (void *)WKBD_MOVE_WORKSPACE3
,
676 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
677 {"MoveToWorkspace4Key", "None", (void *)WKBD_MOVE_WORKSPACE4
,
678 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
679 {"MoveToWorkspace5Key", "None", (void *)WKBD_MOVE_WORKSPACE5
,
680 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
681 {"MoveToWorkspace6Key", "None", (void *)WKBD_MOVE_WORKSPACE6
,
682 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
683 {"MoveToWorkspace7Key", "None", (void *)WKBD_MOVE_WORKSPACE7
,
684 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
685 {"MoveToWorkspace8Key", "None", (void *)WKBD_MOVE_WORKSPACE8
,
686 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
687 {"MoveToWorkspace9Key", "None", (void *)WKBD_MOVE_WORKSPACE9
,
688 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
689 {"MoveToWorkspace10Key", "None", (void *)WKBD_MOVE_WORKSPACE10
,
690 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
691 {"MoveToNextWorkspaceKey", "None", (void *)WKBD_MOVE_NEXTWORKSPACE
,
692 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
693 {"MoveToPrevWorkspaceKey", "None", (void *)WKBD_MOVE_PREVWORKSPACE
,
694 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
695 {"MoveToLastWorkspaceKey", "None", (void *)WKBD_MOVE_LASTWORKSPACE
,
696 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
697 {"MoveToNextWorkspaceLayerKey", "None", (void *)WKBD_MOVE_NEXTWSLAYER
,
698 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
699 {"MoveToPrevWorkspaceLayerKey", "None", (void *)WKBD_MOVE_PREVWSLAYER
,
700 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
701 {"WindowShortcut1Key", "None", (void *)WKBD_WINDOW1
,
702 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
703 {"WindowShortcut2Key", "None", (void *)WKBD_WINDOW2
,
704 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
705 {"WindowShortcut3Key", "None", (void *)WKBD_WINDOW3
,
706 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
707 {"WindowShortcut4Key", "None", (void *)WKBD_WINDOW4
,
708 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
709 {"WindowShortcut5Key", "None", (void *)WKBD_WINDOW5
,
710 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
711 {"WindowShortcut6Key", "None", (void *)WKBD_WINDOW6
,
712 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
713 {"WindowShortcut7Key", "None", (void *)WKBD_WINDOW7
,
714 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
715 {"WindowShortcut8Key", "None", (void *)WKBD_WINDOW8
,
716 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
717 {"WindowShortcut9Key", "None", (void *)WKBD_WINDOW9
,
718 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
719 {"WindowShortcut10Key", "None", (void *)WKBD_WINDOW10
,
720 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
721 {"WindowRelaunchKey", "None", (void *)WKBD_RELAUNCH
,
722 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
723 {"ScreenSwitchKey", "None", (void *)WKBD_SWITCH_SCREEN
,
724 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
726 #ifdef KEEP_XKB_LOCK_STATUS
727 {"ToggleKbdModeKey", "None", (void *)WKBD_TOGGLE
,
728 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
729 {"KbdModeLock", "NO", NULL
,
730 &wPreferences
.modelock
, getBool
, NULL
, NULL
, NULL
},
731 #endif /* KEEP_XKB_LOCK_STATUS */
733 {"NormalCursor", "(builtin, left_ptr)", (void *)WCUR_ROOT
,
734 NULL
, getCursor
, setCursor
, NULL
, NULL
},
735 {"ArrowCursor", "(builtin, top_left_arrow)", (void *)WCUR_ARROW
,
736 NULL
, getCursor
, setCursor
, NULL
, NULL
},
737 {"MoveCursor", "(builtin, fleur)", (void *)WCUR_MOVE
,
738 NULL
, getCursor
, setCursor
, NULL
, NULL
},
739 {"ResizeCursor", "(builtin, sizing)", (void *)WCUR_RESIZE
,
740 NULL
, getCursor
, setCursor
, NULL
, NULL
},
741 {"TopLeftResizeCursor", "(builtin, top_left_corner)", (void *)WCUR_TOPLEFTRESIZE
,
742 NULL
, getCursor
, setCursor
, NULL
, NULL
},
743 {"TopRightResizeCursor", "(builtin, top_right_corner)", (void *)WCUR_TOPRIGHTRESIZE
,
744 NULL
, getCursor
, setCursor
, NULL
, NULL
},
745 {"BottomLeftResizeCursor", "(builtin, bottom_left_corner)", (void *)WCUR_BOTTOMLEFTRESIZE
,
746 NULL
, getCursor
, setCursor
, NULL
, NULL
},
747 {"BottomRightResizeCursor", "(builtin, bottom_right_corner)", (void *)WCUR_BOTTOMRIGHTRESIZE
,
748 NULL
, getCursor
, setCursor
, NULL
, NULL
},
749 {"VerticalResizeCursor", "(builtin, sb_v_double_arrow)", (void *)WCUR_VERTICALRESIZE
,
750 NULL
, getCursor
, setCursor
, NULL
, NULL
},
751 {"HorizontalResizeCursor", "(builtin, sb_h_double_arrow)", (void *)WCUR_HORIZONRESIZE
,
752 NULL
, getCursor
, setCursor
, NULL
, NULL
},
753 {"WaitCursor", "(builtin, watch)", (void *)WCUR_WAIT
,
754 NULL
, getCursor
, setCursor
, NULL
, NULL
},
755 {"QuestionCursor", "(builtin, question_arrow)", (void *)WCUR_QUESTION
,
756 NULL
, getCursor
, setCursor
, NULL
, NULL
},
757 {"TextCursor", "(builtin, xterm)", (void *)WCUR_TEXT
,
758 NULL
, getCursor
, setCursor
, NULL
, NULL
},
759 {"SelectCursor", "(builtin, cross)", (void *)WCUR_SELECT
,
760 NULL
, getCursor
, setCursor
, NULL
, NULL
},
761 {"DialogHistoryLines", "500", NULL
,
762 &wPreferences
.history_lines
, getInt
, NULL
, NULL
, NULL
},
763 {"CycleActiveHeadOnly", "NO", NULL
,
764 &wPreferences
.cycle_active_head_only
, getBool
, NULL
, NULL
, NULL
},
765 {"CycleIgnoreMinimized", "NO", NULL
,
766 &wPreferences
.cycle_ignore_minimized
, getBool
, NULL
, NULL
, NULL
}
769 static void initDefaults(void)
772 WDefaultEntry
*entry
;
774 WMPLSetCaseSensitive(False
);
776 for (i
= 0; i
< sizeof(optionList
) / sizeof(optionList
[0]); i
++) {
777 entry
= &optionList
[i
];
779 entry
->plkey
= WMCreatePLString(entry
->key
);
780 if (entry
->default_value
)
781 entry
->plvalue
= WMCreatePropListFromDescription(entry
->default_value
);
783 entry
->plvalue
= NULL
;
786 for (i
= 0; i
< sizeof(staticOptionList
) / sizeof(staticOptionList
[0]); i
++) {
787 entry
= &staticOptionList
[i
];
789 entry
->plkey
= WMCreatePLString(entry
->key
);
790 if (entry
->default_value
)
791 entry
->plvalue
= WMCreatePropListFromDescription(entry
->default_value
);
793 entry
->plvalue
= NULL
;
797 static WMPropList
*readGlobalDomain(char *domainName
, Bool requireDictionary
)
799 WMPropList
*globalDict
= NULL
;
803 snprintf(path
, sizeof(path
), "%s/%s/%s", SYSCONFDIR
, GLOBAL_DEFAULTS_SUBDIR
, domainName
);
804 if (stat(path
, &stbuf
) >= 0) {
805 globalDict
= WMReadPropListFromFile(path
);
806 if (globalDict
&& requireDictionary
&& !WMIsPLDictionary(globalDict
)) {
807 wwarning(_("Domain %s (%s) of global defaults database is corrupted!"), domainName
, path
);
808 WMReleasePropList(globalDict
);
810 } else if (!globalDict
) {
811 wwarning(_("could not load domain %s from global defaults database"), domainName
);
818 #if defined(GLOBAL_PREAMBLE_MENU_FILE) || defined(GLOBAL_EPILOGUE_MENU_FILE)
819 static void prependMenu(WMPropList
* destarr
, WMPropList
* array
)
824 for (i
= 0; i
< WMGetPropListItemCount(array
); i
++) {
825 item
= WMGetFromPLArray(array
, i
);
827 WMInsertInPLArray(destarr
, i
+ 1, item
);
831 static void appendMenu(WMPropList
* destarr
, WMPropList
* array
)
836 for (i
= 0; i
< WMGetPropListItemCount(array
); i
++) {
837 item
= WMGetFromPLArray(array
, i
);
839 WMAddToPLArray(destarr
, item
);
844 void wDefaultsMergeGlobalMenus(WDDomain
* menuDomain
)
846 WMPropList
*menu
= menuDomain
->dictionary
;
849 if (!menu
|| !WMIsPLArray(menu
))
852 #ifdef GLOBAL_PREAMBLE_MENU_FILE
853 submenu
= WMReadPropListFromFile(SYSCONFDIR
"/" GLOBAL_DEFAULTS_SUBDIR
"/" GLOBAL_PREAMBLE_MENU_FILE
);
855 if (submenu
&& !WMIsPLArray(submenu
)) {
856 wwarning(_("invalid global menu file %s"), GLOBAL_PREAMBLE_MENU_FILE
);
857 WMReleasePropList(submenu
);
861 prependMenu(menu
, submenu
);
862 WMReleasePropList(submenu
);
866 #ifdef GLOBAL_EPILOGUE_MENU_FILE
867 submenu
= WMReadPropListFromFile(SYSCONFDIR
"/" GLOBAL_DEFAULTS_SUBDIR
"/" GLOBAL_EPILOGUE_MENU_FILE
);
869 if (submenu
&& !WMIsPLArray(submenu
)) {
870 wwarning(_("invalid global menu file %s"), GLOBAL_EPILOGUE_MENU_FILE
);
871 WMReleasePropList(submenu
);
875 appendMenu(menu
, submenu
);
876 WMReleasePropList(submenu
);
880 menuDomain
->dictionary
= menu
;
883 WDDomain
*wDefaultsInitDomain(char *domain
, Bool requireDictionary
)
887 static int inited
= 0;
889 WMPropList
*shared_dict
= NULL
;
896 db
= wmalloc(sizeof(WDDomain
));
897 db
->domain_name
= domain
;
898 db
->path
= wdefaultspathfordomain(domain
);
901 if (the_path
&& stat(the_path
, &stbuf
) >= 0) {
902 db
->dictionary
= WMReadPropListFromFile(the_path
);
903 if (db
->dictionary
) {
904 if (requireDictionary
&& !WMIsPLDictionary(db
->dictionary
)) {
905 WMReleasePropList(db
->dictionary
);
906 db
->dictionary
= NULL
;
907 wwarning(_("Domain %s (%s) of defaults database is corrupted!"), domain
, the_path
);
909 db
->timestamp
= stbuf
.st_mtime
;
911 wwarning(_("could not load domain %s from user defaults database"), domain
);
915 /* global system dictionary */
916 shared_dict
= readGlobalDomain(domain
, requireDictionary
);
918 if (shared_dict
&& db
->dictionary
&& WMIsPLDictionary(shared_dict
) &&
919 WMIsPLDictionary(db
->dictionary
)) {
920 WMMergePLDictionaries(shared_dict
, db
->dictionary
, True
);
921 WMReleasePropList(db
->dictionary
);
922 db
->dictionary
= shared_dict
;
923 if (stbuf
.st_mtime
> db
->timestamp
)
924 db
->timestamp
= stbuf
.st_mtime
;
925 } else if (!db
->dictionary
) {
926 db
->dictionary
= shared_dict
;
927 if (stbuf
.st_mtime
> db
->timestamp
)
928 db
->timestamp
= stbuf
.st_mtime
;
934 void wReadStaticDefaults(WMPropList
* dict
)
937 WDefaultEntry
*entry
;
941 for (i
= 0; i
< sizeof(staticOptionList
) / sizeof(staticOptionList
[0]); i
++) {
942 entry
= &staticOptionList
[i
];
945 plvalue
= WMGetFromPLDictionary(dict
, entry
->plkey
);
949 /* no default in the DB. Use builtin default */
951 plvalue
= entry
->plvalue
;
955 (*entry
->convert
) (NULL
, entry
, plvalue
, entry
->addr
, &tdata
);
957 (*entry
->update
) (NULL
, entry
, tdata
, entry
->extra_data
);
962 void wDefaultsCheckDomains(void* arg
)
966 WMPropList
*shared_dict
= NULL
;
970 if (stat(WDWindowMaker
->path
, &stbuf
) >= 0 && WDWindowMaker
->timestamp
< stbuf
.st_mtime
) {
971 WDWindowMaker
->timestamp
= stbuf
.st_mtime
;
973 /* Global dictionary */
974 shared_dict
= readGlobalDomain("WindowMaker", True
);
976 /* User dictionary */
977 dict
= WMReadPropListFromFile(WDWindowMaker
->path
);
980 if (!WMIsPLDictionary(dict
)) {
981 WMReleasePropList(dict
);
983 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
984 "WindowMaker", WDWindowMaker
->path
);
987 WMMergePLDictionaries(shared_dict
, dict
, True
);
988 WMReleasePropList(dict
);
993 for (i
= 0; i
< wScreenCount
; i
++) {
994 scr
= wScreenWithNumber(i
);
996 wReadDefaults(scr
, dict
);
999 if (WDWindowMaker
->dictionary
)
1000 WMReleasePropList(WDWindowMaker
->dictionary
);
1002 WDWindowMaker
->dictionary
= dict
;
1005 wwarning(_("could not load domain %s from user defaults database"), "WindowMaker");
1009 WMReleasePropList(shared_dict
);
1013 if (stat(WDWindowAttributes
->path
, &stbuf
) >= 0 && WDWindowAttributes
->timestamp
< stbuf
.st_mtime
) {
1014 /* global dictionary */
1015 shared_dict
= readGlobalDomain("WMWindowAttributes", True
);
1016 /* user dictionary */
1017 dict
= WMReadPropListFromFile(WDWindowAttributes
->path
);
1019 if (!WMIsPLDictionary(dict
)) {
1020 WMReleasePropList(dict
);
1022 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
1023 "WMWindowAttributes", WDWindowAttributes
->path
);
1026 WMMergePLDictionaries(shared_dict
, dict
, True
);
1027 WMReleasePropList(dict
);
1032 if (WDWindowAttributes
->dictionary
)
1033 WMReleasePropList(WDWindowAttributes
->dictionary
);
1035 WDWindowAttributes
->dictionary
= dict
;
1036 for (i
= 0; i
< wScreenCount
; i
++) {
1037 scr
= wScreenWithNumber(i
);
1039 wDefaultUpdateIcons(scr
);
1041 /* Update the panel image if changed */
1042 /* Don't worry. If the image is the same these
1043 * functions will have no performance impact. */
1044 create_logo_image(scr
);
1049 wwarning(_("could not load domain %s from user defaults database"), "WMWindowAttributes");
1052 WDWindowAttributes
->timestamp
= stbuf
.st_mtime
;
1054 WMReleasePropList(shared_dict
);
1057 if (stat(WDRootMenu
->path
, &stbuf
) >= 0 && WDRootMenu
->timestamp
< stbuf
.st_mtime
) {
1058 dict
= WMReadPropListFromFile(WDRootMenu
->path
);
1060 if (!WMIsPLArray(dict
) && !WMIsPLString(dict
)) {
1061 WMReleasePropList(dict
);
1063 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
1064 "WMRootMenu", WDRootMenu
->path
);
1066 if (WDRootMenu
->dictionary
)
1067 WMReleasePropList(WDRootMenu
->dictionary
);
1069 WDRootMenu
->dictionary
= dict
;
1070 wDefaultsMergeGlobalMenus(WDRootMenu
);
1073 wwarning(_("could not load domain %s from user defaults database"), "WMRootMenu");
1075 WDRootMenu
->timestamp
= stbuf
.st_mtime
;
1077 #ifndef HAVE_INOTIFY
1079 WMAddTimerHandler(DEFAULTS_CHECK_INTERVAL
, wDefaultsCheckDomains
, arg
);
1083 void wReadDefaults(WScreen
* scr
, WMPropList
* new_dict
)
1085 WMPropList
*plvalue
, *old_value
;
1086 WDefaultEntry
*entry
;
1088 int update_workspace_back
= 0; /* kluge :/ */
1089 unsigned int needs_refresh
;
1091 WMPropList
*old_dict
= (WDWindowMaker
->dictionary
!= new_dict
? WDWindowMaker
->dictionary
: NULL
);
1095 for (i
= 0; i
< sizeof(optionList
) / sizeof(optionList
[0]); i
++) {
1096 entry
= &optionList
[i
];
1099 plvalue
= WMGetFromPLDictionary(new_dict
, entry
->plkey
);
1106 old_value
= WMGetFromPLDictionary(old_dict
, entry
->plkey
);
1108 if (!plvalue
&& !old_value
) {
1109 /* no default in the DB. Use builtin default */
1110 plvalue
= entry
->plvalue
;
1111 if (plvalue
&& new_dict
)
1112 WMPutInPLDictionary(new_dict
, entry
->plkey
, plvalue
);
1114 } else if (!plvalue
) {
1115 /* value was deleted from DB. Keep current value */
1117 } else if (!old_value
) {
1118 /* set value for the 1st time */
1119 } else if (!WMIsPropListEqualTo(plvalue
, old_value
)) {
1120 /* value has changed */
1122 if (strcmp(entry
->key
, "WorkspaceBack") == 0
1123 && update_workspace_back
&& scr
->flags
.backimage_helper_launched
) {
1125 /* value was not changed since last time */
1132 if ((*entry
->convert
) (scr
, entry
, plvalue
, entry
->addr
, &tdata
)) {
1134 * If the WorkspaceSpecificBack data has been changed
1135 * so that the helper will be launched now, we must be
1136 * sure to send the default background texture config
1139 if (strcmp(entry
->key
, "WorkspaceSpecificBack") == 0 &&
1140 !scr
->flags
.backimage_helper_launched
)
1141 update_workspace_back
= 1;
1144 needs_refresh
|= (*entry
->update
) (scr
, entry
, tdata
, entry
->extra_data
);
1150 if (needs_refresh
!= 0 && !scr
->flags
.startup
) {
1154 if (needs_refresh
& REFRESH_MENU_TITLE_TEXTURE
)
1155 foo
|= WTextureSettings
;
1156 if (needs_refresh
& REFRESH_MENU_TITLE_FONT
)
1157 foo
|= WFontSettings
;
1158 if (needs_refresh
& REFRESH_MENU_TITLE_COLOR
)
1159 foo
|= WColorSettings
;
1161 WMPostNotificationName(WNMenuTitleAppearanceSettingsChanged
, NULL
,
1162 (void *)(uintptr_t) foo
);
1165 if (needs_refresh
& REFRESH_MENU_TEXTURE
)
1166 foo
|= WTextureSettings
;
1167 if (needs_refresh
& REFRESH_MENU_FONT
)
1168 foo
|= WFontSettings
;
1169 if (needs_refresh
& REFRESH_MENU_COLOR
)
1170 foo
|= WColorSettings
;
1172 WMPostNotificationName(WNMenuAppearanceSettingsChanged
, NULL
, (void *)(uintptr_t) foo
);
1175 if (needs_refresh
& REFRESH_WINDOW_FONT
)
1176 foo
|= WFontSettings
;
1177 if (needs_refresh
& REFRESH_WINDOW_TEXTURES
)
1178 foo
|= WTextureSettings
;
1179 if (needs_refresh
& REFRESH_WINDOW_TITLE_COLOR
)
1180 foo
|= WColorSettings
;
1182 WMPostNotificationName(WNWindowAppearanceSettingsChanged
, NULL
, (void *)(uintptr_t) foo
);
1184 if (!(needs_refresh
& REFRESH_ICON_TILE
)) {
1186 if (needs_refresh
& REFRESH_ICON_FONT
)
1187 foo
|= WFontSettings
;
1188 if (needs_refresh
& REFRESH_ICON_TITLE_COLOR
)
1189 foo
|= WTextureSettings
;
1190 if (needs_refresh
& REFRESH_ICON_TITLE_BACK
)
1191 foo
|= WTextureSettings
;
1193 WMPostNotificationName(WNIconAppearanceSettingsChanged
, NULL
,
1194 (void *)(uintptr_t) foo
);
1196 if (needs_refresh
& REFRESH_ICON_TILE
)
1197 WMPostNotificationName(WNIconTileSettingsChanged
, NULL
, NULL
);
1199 if (needs_refresh
& REFRESH_WORKSPACE_MENU
) {
1200 if (scr
->workspace_menu
)
1201 wWorkspaceMenuUpdate(scr
, scr
->workspace_menu
);
1202 if (scr
->clip_ws_menu
)
1203 wWorkspaceMenuUpdate(scr
, scr
->clip_ws_menu
);
1204 if (scr
->workspace_submenu
)
1205 scr
->workspace_submenu
->flags
.realized
= 0;
1206 if (scr
->clip_submenu
)
1207 scr
->clip_submenu
->flags
.realized
= 0;
1212 void wDefaultUpdateIcons(WScreen
*scr
)
1214 WAppIcon
*aicon
= scr
->app_icon_list
;
1216 WWindow
*wwin
= scr
->focused_window
;
1219 /* Get the application icon, default included */
1220 wIconChangeImageFile(aicon
->icon
, NULL
);
1221 wAppIconPaint(aicon
);
1222 aicon
= aicon
->next
;
1225 if (!wPreferences
.flags
.noclip
|| wPreferences
.flags
.clip_merged_in_dock
)
1226 wClipIconPaint(scr
->clip_icon
);
1228 for (dc
= scr
->drawers
; dc
!= NULL
; dc
= dc
->next
)
1229 wDrawerIconPaint(dc
->adrawer
->icon_array
[0]);
1232 if (wwin
->icon
&& wwin
->flags
.miniaturized
)
1233 wIconChangeImageFile(wwin
->icon
, NULL
);
1238 /* --------------------------- Local ----------------------- */
1240 #define GET_STRING_OR_DEFAULT(x, var) if (!WMIsPLString(value)) { \
1241 wwarning(_("Wrong option format for key \"%s\". Should be %s."), \
1243 wwarning(_("using default \"%s\" instead"), entry->default_value); \
1244 var = entry->default_value;\
1245 } else var = WMGetFromPLString(value)\
1248 static int string2index(WMPropList * key, WMPropList * val, char *def, WOptionEnumeration * values)
1251 WOptionEnumeration
*v
;
1252 char buffer
[TOTAL_VALUES_LENGTH
];
1254 if (WMIsPLString(val
) && (str
= WMGetFromPLString(val
))) {
1255 for (v
= values
; v
->string
!= NULL
; v
++) {
1256 if (strcasecmp(v
->string
, str
) == 0)
1262 for (v
= values
; v
->string
!= NULL
; v
++) {
1265 strcat(buffer
, ", ");
1266 snprintf(buffer
+strlen(buffer
),
1267 sizeof(buffer
)-strlen(buffer
)-1, "\"%s\"", v
->string
);
1270 wwarning(_("wrong option value for key \"%s\"; got \"%s\", should be one of %s."),
1271 WMGetFromPLString(key
),
1272 WMIsPLString(val
) ? WMGetFromPLString(val
) : "(unknown)",
1276 return string2index(key
, val
, NULL
, values
);
1283 * value - is the value in the defaults DB
1284 * addr - is the address to store the data
1285 * ret - is the address to store a pointer to a temporary buffer. ret
1286 * must not be freed and is used by the set functions
1288 static int getBool(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1292 int second_pass
= 0;
1294 GET_STRING_OR_DEFAULT("Boolean", val
);
1297 if ((val
[1] == '\0' && (val
[0] == 'y' || val
[0] == 'Y'))
1298 || strcasecmp(val
, "YES") == 0) {
1301 } else if ((val
[1] == '\0' && (val
[0] == 'n' || val
[0] == 'N'))
1302 || strcasecmp(val
, "NO") == 0) {
1306 if (sscanf(val
, "%i", &i
) == 1) {
1312 wwarning(_("can't convert \"%s\" to boolean for key \"%s\""), val
, entry
->key
);
1313 if (second_pass
== 0) {
1314 val
= WMGetFromPLString(entry
->plvalue
);
1316 wwarning(_("using default \"%s\" instead"), val
);
1326 *(char *)addr
= data
;
1331 static int getInt(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1336 GET_STRING_OR_DEFAULT("Integer", val
);
1338 if (sscanf(val
, "%i", &data
) != 1) {
1339 wwarning(_("can't convert \"%s\" to integer for key \"%s\""), val
, entry
->key
);
1340 val
= WMGetFromPLString(entry
->plvalue
);
1341 wwarning(_("using default \"%s\" instead"), val
);
1342 if (sscanf(val
, "%i", &data
) != 1) {
1350 *(int *)addr
= data
;
1355 static int getCoord(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1358 char *val_x
, *val_y
;
1359 int nelem
, changed
= 0;
1360 WMPropList
*elem_x
, *elem_y
;
1363 if (!WMIsPLArray(value
)) {
1364 wwarning(_("Wrong option format for key \"%s\". Should be %s."), entry
->key
, "Coordinate");
1366 value
= entry
->plvalue
;
1368 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1374 nelem
= WMGetPropListItemCount(value
);
1376 wwarning(_("Incorrect number of elements in array for key \"%s\"."), entry
->key
);
1378 value
= entry
->plvalue
;
1380 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1386 elem_x
= WMGetFromPLArray(value
, 0);
1387 elem_y
= WMGetFromPLArray(value
, 1);
1389 if (!elem_x
|| !elem_y
|| !WMIsPLString(elem_x
) || !WMIsPLString(elem_y
)) {
1390 wwarning(_("Wrong value for key \"%s\". Should be Coordinate."), entry
->key
);
1392 value
= entry
->plvalue
;
1394 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1400 val_x
= WMGetFromPLString(elem_x
);
1401 val_y
= WMGetFromPLString(elem_y
);
1403 if (sscanf(val_x
, "%i", &data
.x
) != 1 || sscanf(val_y
, "%i", &data
.y
) != 1) {
1404 wwarning(_("can't convert array to integers for \"%s\"."), entry
->key
);
1406 value
= entry
->plvalue
;
1408 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1416 else if (data
.x
> scr
->scr_width
/ 3)
1417 data
.x
= scr
->scr_width
/ 3;
1420 else if (data
.y
> scr
->scr_height
/ 3)
1421 data
.y
= scr
->scr_height
/ 3;
1426 *(WCoord
*) addr
= data
;
1431 static int getPropList(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1433 WMRetainPropList(value
);
1440 static int getPathList(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1449 if (!WMIsPLArray(value
)) {
1450 wwarning(_("Wrong option format for key \"%s\". Should be %s."), entry
->key
, "an array of paths");
1452 value
= entry
->plvalue
;
1454 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1461 count
= WMGetPropListItemCount(value
);
1464 value
= entry
->plvalue
;
1466 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1473 for (i
= 0; i
< count
; i
++) {
1474 d
= WMGetFromPLArray(value
, i
);
1475 if (!d
|| !WMIsPLString(d
)) {
1479 len
+= strlen(WMGetFromPLString(d
)) + 1;
1482 ptr
= data
= wmalloc(len
+ 1);
1484 for (i
= 0; i
< count
; i
++) {
1485 d
= WMGetFromPLArray(value
, i
);
1486 if (!d
|| !WMIsPLString(d
)) {
1489 strcpy(ptr
, WMGetFromPLString(d
));
1490 ptr
+= strlen(WMGetFromPLString(d
));
1497 if (*(char **)addr
!= NULL
) {
1498 wfree(*(char **)addr
);
1500 *(char **)addr
= data
;
1505 static int getEnum(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1507 static signed char data
;
1509 data
= string2index(entry
->plkey
, value
, entry
->default_value
, (WOptionEnumeration
*) entry
->extra_data
);
1516 *(signed char *)addr
= data
;
1523 * (hgradient <color> <color>)
1524 * (vgradient <color> <color>)
1525 * (dgradient <color> <color>)
1526 * (mhgradient <color> <color> ...)
1527 * (mvgradient <color> <color> ...)
1528 * (mdgradient <color> <color> ...)
1529 * (igradient <color1> <color1> <thickness1> <color2> <color2> <thickness2>)
1530 * (tpixmap <file> <color>)
1531 * (spixmap <file> <color>)
1532 * (cpixmap <file> <color>)
1533 * (thgradient <file> <opaqueness> <color> <color>)
1534 * (tvgradient <file> <opaqueness> <color> <color>)
1535 * (tdgradient <file> <opaqueness> <color> <color>)
1536 * (function <lib> <function> ...)
1539 static WTexture
*parse_texture(WScreen
* scr
, WMPropList
* pl
)
1544 WTexture
*texture
= NULL
;
1546 nelem
= WMGetPropListItemCount(pl
);
1550 elem
= WMGetFromPLArray(pl
, 0);
1551 if (!elem
|| !WMIsPLString(elem
))
1553 val
= WMGetFromPLString(elem
);
1555 if (strcasecmp(val
, "solid") == 0) {
1563 elem
= WMGetFromPLArray(pl
, 1);
1564 if (!elem
|| !WMIsPLString(elem
))
1566 val
= WMGetFromPLString(elem
);
1568 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &color
)) {
1569 wwarning(_("\"%s\" is not a valid color name"), val
);
1573 texture
= (WTexture
*) wTextureMakeSolid(scr
, &color
);
1574 } else if (strcasecmp(val
, "dgradient") == 0
1575 || strcasecmp(val
, "vgradient") == 0 || strcasecmp(val
, "hgradient") == 0) {
1576 RColor color1
, color2
;
1581 wwarning(_("bad number of arguments in gradient specification"));
1585 if (val
[0] == 'd' || val
[0] == 'D')
1586 type
= WTEX_DGRADIENT
;
1587 else if (val
[0] == 'h' || val
[0] == 'H')
1588 type
= WTEX_HGRADIENT
;
1590 type
= WTEX_VGRADIENT
;
1592 /* get from color */
1593 elem
= WMGetFromPLArray(pl
, 1);
1594 if (!elem
|| !WMIsPLString(elem
))
1596 val
= WMGetFromPLString(elem
);
1598 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1599 wwarning(_("\"%s\" is not a valid color name"), val
);
1603 color1
.red
= xcolor
.red
>> 8;
1604 color1
.green
= xcolor
.green
>> 8;
1605 color1
.blue
= xcolor
.blue
>> 8;
1608 elem
= WMGetFromPLArray(pl
, 2);
1609 if (!elem
|| !WMIsPLString(elem
)) {
1612 val
= WMGetFromPLString(elem
);
1614 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1615 wwarning(_("\"%s\" is not a valid color name"), val
);
1619 color2
.red
= xcolor
.red
>> 8;
1620 color2
.green
= xcolor
.green
>> 8;
1621 color2
.blue
= xcolor
.blue
>> 8;
1623 texture
= (WTexture
*) wTextureMakeGradient(scr
, type
, &color1
, &color2
);
1625 } else if (strcasecmp(val
, "igradient") == 0) {
1626 RColor colors1
[2], colors2
[2];
1632 wwarning(_("bad number of arguments in gradient specification"));
1636 /* get from color */
1637 for (i
= 0; i
< 2; i
++) {
1638 elem
= WMGetFromPLArray(pl
, 1 + i
);
1639 if (!elem
|| !WMIsPLString(elem
))
1641 val
= WMGetFromPLString(elem
);
1643 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1644 wwarning(_("\"%s\" is not a valid color name"), val
);
1647 colors1
[i
].alpha
= 255;
1648 colors1
[i
].red
= xcolor
.red
>> 8;
1649 colors1
[i
].green
= xcolor
.green
>> 8;
1650 colors1
[i
].blue
= xcolor
.blue
>> 8;
1652 elem
= WMGetFromPLArray(pl
, 3);
1653 if (!elem
|| !WMIsPLString(elem
))
1655 val
= WMGetFromPLString(elem
);
1658 /* get from color */
1659 for (i
= 0; i
< 2; i
++) {
1660 elem
= WMGetFromPLArray(pl
, 4 + i
);
1661 if (!elem
|| !WMIsPLString(elem
))
1663 val
= WMGetFromPLString(elem
);
1665 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1666 wwarning(_("\"%s\" is not a valid color name"), val
);
1669 colors2
[i
].alpha
= 255;
1670 colors2
[i
].red
= xcolor
.red
>> 8;
1671 colors2
[i
].green
= xcolor
.green
>> 8;
1672 colors2
[i
].blue
= xcolor
.blue
>> 8;
1674 elem
= WMGetFromPLArray(pl
, 6);
1675 if (!elem
|| !WMIsPLString(elem
))
1677 val
= WMGetFromPLString(elem
);
1680 texture
= (WTexture
*) wTextureMakeIGradient(scr
, th1
, colors1
, th2
, colors2
);
1682 } else if (strcasecmp(val
, "mhgradient") == 0
1683 || strcasecmp(val
, "mvgradient") == 0 || strcasecmp(val
, "mdgradient") == 0) {
1690 wwarning(_("too few arguments in multicolor gradient specification"));
1694 if (val
[1] == 'h' || val
[1] == 'H')
1695 type
= WTEX_MHGRADIENT
;
1696 else if (val
[1] == 'v' || val
[1] == 'V')
1697 type
= WTEX_MVGRADIENT
;
1699 type
= WTEX_MDGRADIENT
;
1703 colors
= wmalloc(sizeof(RColor
*) * (count
+ 1));
1705 for (i
= 0; i
< count
; i
++) {
1706 elem
= WMGetFromPLArray(pl
, i
+ 1);
1707 if (!elem
|| !WMIsPLString(elem
)) {
1708 for (--i
; i
>= 0; --i
) {
1714 val
= WMGetFromPLString(elem
);
1716 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &color
)) {
1717 wwarning(_("\"%s\" is not a valid color name"), val
);
1718 for (--i
; i
>= 0; --i
) {
1724 colors
[i
] = wmalloc(sizeof(RColor
));
1725 colors
[i
]->red
= color
.red
>> 8;
1726 colors
[i
]->green
= color
.green
>> 8;
1727 colors
[i
]->blue
= color
.blue
>> 8;
1732 texture
= (WTexture
*) wTextureMakeMGradient(scr
, type
, colors
);
1733 } else if (strcasecmp(val
, "spixmap") == 0 ||
1734 strcasecmp(val
, "cpixmap") == 0 || strcasecmp(val
, "tpixmap") == 0) {
1741 if (val
[0] == 's' || val
[0] == 'S')
1743 else if (val
[0] == 'c' || val
[0] == 'C')
1749 elem
= WMGetFromPLArray(pl
, 2);
1750 if (!elem
|| !WMIsPLString(elem
)) {
1753 val
= WMGetFromPLString(elem
);
1755 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &color
)) {
1756 wwarning(_("\"%s\" is not a valid color name"), val
);
1761 elem
= WMGetFromPLArray(pl
, 1);
1762 if (!elem
|| !WMIsPLString(elem
))
1764 val
= WMGetFromPLString(elem
);
1766 texture
= (WTexture
*) wTextureMakePixmap(scr
, type
, val
, &color
);
1767 } else if (strcasecmp(val
, "thgradient") == 0
1768 || strcasecmp(val
, "tvgradient") == 0 || strcasecmp(val
, "tdgradient") == 0) {
1769 RColor color1
, color2
;
1774 if (val
[1] == 'h' || val
[1] == 'H')
1775 style
= WTEX_THGRADIENT
;
1776 else if (val
[1] == 'v' || val
[1] == 'V')
1777 style
= WTEX_TVGRADIENT
;
1779 style
= WTEX_TDGRADIENT
;
1782 wwarning(_("bad number of arguments in textured gradient specification"));
1786 /* get from color */
1787 elem
= WMGetFromPLArray(pl
, 3);
1788 if (!elem
|| !WMIsPLString(elem
))
1790 val
= WMGetFromPLString(elem
);
1792 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1793 wwarning(_("\"%s\" is not a valid color name"), val
);
1797 color1
.red
= xcolor
.red
>> 8;
1798 color1
.green
= xcolor
.green
>> 8;
1799 color1
.blue
= xcolor
.blue
>> 8;
1802 elem
= WMGetFromPLArray(pl
, 4);
1803 if (!elem
|| !WMIsPLString(elem
)) {
1806 val
= WMGetFromPLString(elem
);
1808 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1809 wwarning(_("\"%s\" is not a valid color name"), val
);
1813 color2
.red
= xcolor
.red
>> 8;
1814 color2
.green
= xcolor
.green
>> 8;
1815 color2
.blue
= xcolor
.blue
>> 8;
1818 elem
= WMGetFromPLArray(pl
, 2);
1819 if (!elem
|| !WMIsPLString(elem
))
1822 val
= WMGetFromPLString(elem
);
1824 if (!val
|| (opacity
= atoi(val
)) < 0 || opacity
> 255) {
1825 wwarning(_("bad opacity value for tgradient texture \"%s\". Should be [0..255]"), val
);
1830 elem
= WMGetFromPLArray(pl
, 1);
1831 if (!elem
|| !WMIsPLString(elem
))
1833 val
= WMGetFromPLString(elem
);
1835 texture
= (WTexture
*) wTextureMakeTGradient(scr
, style
, &color1
, &color2
, val
, opacity
);
1836 } else if (strcasecmp(val
, "function") == 0) {
1837 /* Leave this in to handle the unlikely case of
1838 * someone actually having function textures configured */
1839 wwarning("function texture support has been removed");
1842 wwarning(_("invalid texture type %s"), val
);
1848 static int getTexture(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1850 static WTexture
*texture
;
1854 if (!WMIsPLArray(value
)) {
1855 wwarning(_("Wrong option format for key \"%s\". Should be %s."), entry
->key
, "Texture");
1857 value
= entry
->plvalue
;
1859 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1865 if (strcmp(entry
->key
, "WidgetColor") == 0 && !changed
) {
1868 pl
= WMGetFromPLArray(value
, 0);
1869 if (!pl
|| !WMIsPLString(pl
) || !WMGetFromPLString(pl
)
1870 || strcasecmp(WMGetFromPLString(pl
), "solid") != 0) {
1871 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1872 entry
->key
, "Solid Texture");
1874 value
= entry
->plvalue
;
1876 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1881 texture
= parse_texture(scr
, value
);
1884 wwarning(_("Error in texture specification for key \"%s\""), entry
->key
);
1886 value
= entry
->plvalue
;
1888 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1898 *(WTexture
**) addr
= texture
;
1903 static int getWSBackground(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1911 if (!WMIsPLArray(value
)) {
1912 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1913 "WorkspaceBack", "Texture or None");
1915 value
= entry
->plvalue
;
1917 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1923 /* only do basic error checking and verify for None texture */
1925 nelem
= WMGetPropListItemCount(value
);
1927 elem
= WMGetFromPLArray(value
, 0);
1928 if (!elem
|| !WMIsPLString(elem
)) {
1929 wwarning(_("Wrong type for workspace background. Should be a texture type."));
1931 value
= entry
->plvalue
;
1933 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1938 val
= WMGetFromPLString(elem
);
1940 if (strcasecmp(val
, "None") == 0)
1943 *ret
= WMRetainPropList(value
);
1949 getWSSpecificBackground(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1956 if (!WMIsPLArray(value
)) {
1957 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1958 "WorkspaceSpecificBack", "an array of textures");
1960 value
= entry
->plvalue
;
1962 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1968 /* only do basic error checking and verify for None texture */
1970 nelem
= WMGetPropListItemCount(value
);
1973 elem
= WMGetFromPLArray(value
, nelem
);
1974 if (!elem
|| !WMIsPLArray(elem
)) {
1975 wwarning(_("Wrong type for background of workspace %i. Should be a texture."),
1981 *ret
= WMRetainPropList(value
);
1985 * Kluge to force wmsetbg helper to set the default background.
1986 * If the WorkspaceSpecificBack is changed once wmaker has started,
1987 * the WorkspaceBack won't be sent to the helper, unless the user
1988 * changes it's value too. So, we must force this by removing the
1989 * value from the defaults DB.
1991 if (!scr
->flags
.backimage_helper_launched
&& !scr
->flags
.startup
) {
1992 WMPropList
*key
= WMCreatePLString("WorkspaceBack");
1994 WMRemoveFromPLDictionary(WDWindowMaker
->dictionary
, key
);
1996 WMReleasePropList(key
);
2002 static int getFont(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
2004 static WMFont
*font
;
2007 GET_STRING_OR_DEFAULT("Font", val
);
2009 font
= WMCreateFont(scr
->wmscreen
, val
);
2011 font
= WMCreateFont(scr
->wmscreen
, "fixed");
2014 wfatal(_("could not load any usable font!!!"));
2021 /* can't assign font value outside update function */
2022 wassertrv(addr
== NULL
, True
);
2027 static int getColor(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
2029 static XColor color
;
2031 int second_pass
= 0;
2033 GET_STRING_OR_DEFAULT("Color", val
);
2036 if (!wGetColor(scr
, val
, &color
)) {
2037 wwarning(_("could not get color for key \"%s\""), entry
->key
);
2038 if (second_pass
== 0) {
2039 val
= WMGetFromPLString(entry
->plvalue
);
2041 wwarning(_("using default \"%s\" instead"), val
);
2050 assert(addr
== NULL
);
2053 *(unsigned long*)addr = pixel;
2059 static int getKeybind(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
2061 static WShortKey shortcut
;
2065 char buf
[MAX_SHORTCUT_LENGTH
], *b
;
2067 GET_STRING_OR_DEFAULT("Key spec", val
);
2069 if (!val
|| strcasecmp(val
, "NONE") == 0) {
2070 shortcut
.keycode
= 0;
2071 shortcut
.modifier
= 0;
2077 wstrlcpy(buf
, val
, MAX_SHORTCUT_LENGTH
);
2082 shortcut
.modifier
= 0;
2083 while ((k
= strchr(b
, '+')) != NULL
) {
2087 mod
= wXModifierFromKey(b
);
2089 wwarning(_("%s: invalid key modifier \"%s\""), entry
->key
, b
);
2092 shortcut
.modifier
|= mod
;
2098 ksym
= XStringToKeysym(b
);
2100 if (ksym
== NoSymbol
) {
2101 wwarning(_("%s:invalid kbd shortcut specification \"%s\""), entry
->key
, val
);
2105 shortcut
.keycode
= XKeysymToKeycode(dpy
, ksym
);
2106 if (shortcut
.keycode
== 0) {
2107 wwarning(_("%s:invalid key in shortcut \"%s\""), entry
->key
, val
);
2117 static int getModMask(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
2122 GET_STRING_OR_DEFAULT("Modifier Key", str
);
2127 mask
= wXModifierFromKey(str
);
2129 wwarning(_("%s: modifier key %s is not valid"), entry
->key
, str
);
2135 *(int *)addr
= mask
;
2143 # include <X11/cursorfont.h>
2149 #define CURSOR_ID_NONE (XC_num_glyphs)
2151 static WCursorLookup cursor_table
[] = {
2152 {"X_cursor", XC_X_cursor
},
2153 {"arrow", XC_arrow
},
2154 {"based_arrow_down", XC_based_arrow_down
},
2155 {"based_arrow_up", XC_based_arrow_up
},
2157 {"bogosity", XC_bogosity
},
2158 {"bottom_left_corner", XC_bottom_left_corner
},
2159 {"bottom_right_corner", XC_bottom_right_corner
},
2160 {"bottom_side", XC_bottom_side
},
2161 {"bottom_tee", XC_bottom_tee
},
2162 {"box_spiral", XC_box_spiral
},
2163 {"center_ptr", XC_center_ptr
},
2164 {"circle", XC_circle
},
2165 {"clock", XC_clock
},
2166 {"coffee_mug", XC_coffee_mug
},
2167 {"cross", XC_cross
},
2168 {"cross_reverse", XC_cross_reverse
},
2169 {"crosshair", XC_crosshair
},
2170 {"diamond_cross", XC_diamond_cross
},
2172 {"dotbox", XC_dotbox
},
2173 {"double_arrow", XC_double_arrow
},
2174 {"draft_large", XC_draft_large
},
2175 {"draft_small", XC_draft_small
},
2176 {"draped_box", XC_draped_box
},
2177 {"exchange", XC_exchange
},
2178 {"fleur", XC_fleur
},
2179 {"gobbler", XC_gobbler
},
2180 {"gumby", XC_gumby
},
2181 {"hand1", XC_hand1
},
2182 {"hand2", XC_hand2
},
2183 {"heart", XC_heart
},
2185 {"iron_cross", XC_iron_cross
},
2186 {"left_ptr", XC_left_ptr
},
2187 {"left_side", XC_left_side
},
2188 {"left_tee", XC_left_tee
},
2189 {"leftbutton", XC_leftbutton
},
2190 {"ll_angle", XC_ll_angle
},
2191 {"lr_angle", XC_lr_angle
},
2193 {"middlebutton", XC_middlebutton
},
2194 {"mouse", XC_mouse
},
2195 {"pencil", XC_pencil
},
2196 {"pirate", XC_pirate
},
2198 {"question_arrow", XC_question_arrow
},
2199 {"right_ptr", XC_right_ptr
},
2200 {"right_side", XC_right_side
},
2201 {"right_tee", XC_right_tee
},
2202 {"rightbutton", XC_rightbutton
},
2203 {"rtl_logo", XC_rtl_logo
},
2204 {"sailboat", XC_sailboat
},
2205 {"sb_down_arrow", XC_sb_down_arrow
},
2206 {"sb_h_double_arrow", XC_sb_h_double_arrow
},
2207 {"sb_left_arrow", XC_sb_left_arrow
},
2208 {"sb_right_arrow", XC_sb_right_arrow
},
2209 {"sb_up_arrow", XC_sb_up_arrow
},
2210 {"sb_v_double_arrow", XC_sb_v_double_arrow
},
2211 {"shuttle", XC_shuttle
},
2212 {"sizing", XC_sizing
},
2213 {"spider", XC_spider
},
2214 {"spraycan", XC_spraycan
},
2216 {"target", XC_target
},
2217 {"tcross", XC_tcross
},
2218 {"top_left_arrow", XC_top_left_arrow
},
2219 {"top_left_corner", XC_top_left_corner
},
2220 {"top_right_corner", XC_top_right_corner
},
2221 {"top_side", XC_top_side
},
2222 {"top_tee", XC_top_tee
},
2224 {"ul_angle", XC_ul_angle
},
2225 {"umbrella", XC_umbrella
},
2226 {"ur_angle", XC_ur_angle
},
2227 {"watch", XC_watch
},
2228 {"xterm", XC_xterm
},
2229 {NULL
, CURSOR_ID_NONE
}
2232 static void check_bitmap_status(int status
, char *filename
, Pixmap bitmap
)
2235 case BitmapOpenFailed
:
2236 wwarning(_("failed to open bitmap file \"%s\""), filename
);
2238 case BitmapFileInvalid
:
2239 wwarning(_("\"%s\" is not a valid bitmap file"), filename
);
2241 case BitmapNoMemory
:
2242 wwarning(_("out of memory reading bitmap file \"%s\""), filename
);
2245 XFreePixmap(dpy
, bitmap
);
2252 * (builtin, <cursor_name>)
2253 * (bitmap, <cursor_bitmap>, <cursor_mask>)
2255 static int parse_cursor(WScreen
* scr
, WMPropList
* pl
, Cursor
* cursor
)
2262 nelem
= WMGetPropListItemCount(pl
);
2266 elem
= WMGetFromPLArray(pl
, 0);
2267 if (!elem
|| !WMIsPLString(elem
)) {
2270 val
= WMGetFromPLString(elem
);
2272 if (strcasecmp(val
, "none") == 0) {
2275 } else if (strcasecmp(val
, "builtin") == 0) {
2277 int cursor_id
= CURSOR_ID_NONE
;
2280 wwarning(_("bad number of arguments in cursor specification"));
2283 elem
= WMGetFromPLArray(pl
, 1);
2284 if (!elem
|| !WMIsPLString(elem
)) {
2287 val
= WMGetFromPLString(elem
);
2289 for (i
= 0; cursor_table
[i
].name
!= NULL
; i
++) {
2290 if (strcasecmp(val
, cursor_table
[i
].name
) == 0) {
2291 cursor_id
= cursor_table
[i
].id
;
2295 if (CURSOR_ID_NONE
== cursor_id
) {
2296 wwarning(_("unknown builtin cursor name \"%s\""), val
);
2298 *cursor
= XCreateFontCursor(dpy
, cursor_id
);
2301 } else if (strcasecmp(val
, "bitmap") == 0) {
2313 wwarning(_("bad number of arguments in cursor specification"));
2316 elem
= WMGetFromPLArray(pl
, 1);
2317 if (!elem
|| !WMIsPLString(elem
)) {
2320 val
= WMGetFromPLString(elem
);
2321 bitmap_name
= FindImage(wPreferences
.pixmap_path
, val
);
2323 wwarning(_("could not find cursor bitmap file \"%s\""), val
);
2326 elem
= WMGetFromPLArray(pl
, 2);
2327 if (!elem
|| !WMIsPLString(elem
)) {
2331 val
= WMGetFromPLString(elem
);
2332 mask_name
= FindImage(wPreferences
.pixmap_path
, val
);
2335 wwarning(_("could not find cursor bitmap file \"%s\""), val
);
2338 mask_status
= XReadBitmapFile(dpy
, scr
->w_win
, mask_name
, &w
, &h
, &mask
, &x
, &y
);
2339 bitmap_status
= XReadBitmapFile(dpy
, scr
->w_win
, bitmap_name
, &w
, &h
, &bitmap
, &x
, &y
);
2340 if ((BitmapSuccess
== bitmap_status
) && (BitmapSuccess
== mask_status
)) {
2341 fg
.pixel
= scr
->black_pixel
;
2342 bg
.pixel
= scr
->white_pixel
;
2343 XQueryColor(dpy
, scr
->w_colormap
, &fg
);
2344 XQueryColor(dpy
, scr
->w_colormap
, &bg
);
2345 *cursor
= XCreatePixmapCursor(dpy
, bitmap
, mask
, &fg
, &bg
, x
, y
);
2348 check_bitmap_status(bitmap_status
, bitmap_name
, bitmap
);
2349 check_bitmap_status(mask_status
, mask_name
, mask
);
2356 static int getCursor(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
2358 static Cursor cursor
;
2363 if (!WMIsPLArray(value
)) {
2364 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
2365 entry
->key
, "cursor specification");
2367 value
= entry
->plvalue
;
2369 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
2374 status
= parse_cursor(scr
, value
, &cursor
);
2376 wwarning(_("Error in cursor specification for key \"%s\""), entry
->key
);
2378 value
= entry
->plvalue
;
2380 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
2389 *(Cursor
*) addr
= cursor
;
2394 #undef CURSOR_ID_NONE
2396 /* ---------------- value setting functions --------------- */
2397 static int setJustify(WScreen
* scr
, WDefaultEntry
* entry
, WTexture
** texture
, void *foo
)
2399 return REFRESH_WINDOW_TITLE_COLOR
;
2402 static int setClearance(WScreen
* scr
, WDefaultEntry
* entry
, void *bar
, void *foo
)
2404 return REFRESH_WINDOW_FONT
| REFRESH_BUTTON_IMAGES
| REFRESH_MENU_TITLE_FONT
| REFRESH_MENU_FONT
;
2407 static int setIfDockPresent(WScreen
* scr
, WDefaultEntry
* entry
, char *flag
, long which
)
2411 wPreferences
.flags
.nodock
= wPreferences
.flags
.nodock
|| *flag
;
2412 // Drawers require the dock
2413 wPreferences
.flags
.nodrawer
= wPreferences
.flags
.nodrawer
|| wPreferences
.flags
.nodock
;
2416 wPreferences
.flags
.noclip
= wPreferences
.flags
.noclip
|| *flag
;
2419 wPreferences
.flags
.nodrawer
= wPreferences
.flags
.nodrawer
|| *flag
;
2427 static int setClipMergedInDock(WScreen
*scr
, WDefaultEntry
*entry
, char *flag
, void *foo
)
2429 wPreferences
.flags
.clip_merged_in_dock
= *flag
;
2430 wPreferences
.flags
.noclip
= wPreferences
.flags
.noclip
|| *flag
;
2434 static int setWrapAppiconsInDock(WScreen
*scr
, WDefaultEntry
*entry
, char *flag
, void *foo
)
2436 wPreferences
.flags
.wrap_appicons_in_dock
= *flag
;
2440 static int setStickyIcons(WScreen
* scr
, WDefaultEntry
* entry
, void *bar
, void *foo
)
2442 if (scr
->workspaces
) {
2443 wWorkspaceForceChange(scr
, scr
->current_workspace
);
2444 wArrangeIcons(scr
, False
);
2449 static int setIconTile(WScreen
* scr
, WDefaultEntry
* entry
, WTexture
** texture
, void *foo
)
2455 img
= wTextureRenderImage(*texture
, wPreferences
.icon_size
,
2456 wPreferences
.icon_size
, ((*texture
)->any
.type
& WREL_BORDER_MASK
)
2457 ? WREL_ICON
: WREL_FLAT
);
2459 wwarning(_("could not render texture for icon background"));
2461 wTextureDestroy(scr
, *texture
);
2464 RConvertImage(scr
->rcontext
, img
, &pixmap
);
2466 if (scr
->icon_tile
) {
2468 RReleaseImage(scr
->icon_tile
);
2469 XFreePixmap(dpy
, scr
->icon_tile_pixmap
);
2472 scr
->icon_tile
= img
;
2474 /* put the icon in the noticeboard hint */
2475 PropSetIconTileHint(scr
, img
);
2477 if (!wPreferences
.flags
.noclip
|| wPreferences
.flags
.clip_merged_in_dock
) {
2478 if (scr
->clip_tile
) {
2479 RReleaseImage(scr
->clip_tile
);
2481 scr
->clip_tile
= wClipMakeTile(scr
, img
);
2484 if (!wPreferences
.flags
.nodrawer
) {
2485 if (scr
->drawer_tile
) {
2486 RReleaseImage(scr
->drawer_tile
);
2488 scr
->drawer_tile
= wDrawerMakeTile(scr
, img
);
2491 scr
->icon_tile_pixmap
= pixmap
;
2493 if (scr
->def_icon_rimage
) {
2494 RReleaseImage(scr
->def_icon_rimage
);
2495 scr
->def_icon_rimage
= NULL
;
2498 if (scr
->icon_back_texture
)
2499 wTextureDestroy(scr
, (WTexture
*) scr
->icon_back_texture
);
2501 scr
->icon_back_texture
= wTextureMakeSolid(scr
, &((*texture
)->any
.color
));
2503 /* Free the texture as nobody else will use it, nor refer to it. */
2505 wTextureDestroy(scr
, *texture
);
2507 return (reset
? REFRESH_ICON_TILE
: 0);
2510 static int setWinTitleFont(WScreen
* scr
, WDefaultEntry
* entry
, WMFont
* font
, void *foo
)
2512 if (scr
->title_font
) {
2513 WMReleaseFont(scr
->title_font
);
2515 scr
->title_font
= font
;
2517 return REFRESH_WINDOW_FONT
| REFRESH_BUTTON_IMAGES
;
2520 static int setMenuTitleFont(WScreen
* scr
, WDefaultEntry
* entry
, WMFont
* font
, void *foo
)
2522 if (scr
->menu_title_font
) {
2523 WMReleaseFont(scr
->menu_title_font
);
2526 scr
->menu_title_font
= font
;
2528 return REFRESH_MENU_TITLE_FONT
;
2531 static int setMenuTextFont(WScreen
* scr
, WDefaultEntry
* entry
, WMFont
* font
, void *foo
)
2533 if (scr
->menu_entry_font
) {
2534 WMReleaseFont(scr
->menu_entry_font
);
2536 scr
->menu_entry_font
= font
;
2538 return REFRESH_MENU_FONT
;
2541 static int setIconTitleFont(WScreen
* scr
, WDefaultEntry
* entry
, WMFont
* font
, void *foo
)
2543 if (scr
->icon_title_font
) {
2544 WMReleaseFont(scr
->icon_title_font
);
2547 scr
->icon_title_font
= font
;
2549 return REFRESH_ICON_FONT
;
2552 static int setClipTitleFont(WScreen
* scr
, WDefaultEntry
* entry
, WMFont
* font
, void *foo
)
2554 if (scr
->clip_title_font
) {
2555 WMReleaseFont(scr
->clip_title_font
);
2558 scr
->clip_title_font
= font
;
2560 return REFRESH_ICON_FONT
;
2563 static int setLargeDisplayFont(WScreen
* scr
, WDefaultEntry
* entry
, WMFont
* font
, void *foo
)
2565 if (scr
->workspace_name_font
) {
2566 WMReleaseFont(scr
->workspace_name_font
);
2569 scr
->workspace_name_font
= font
;
2574 static int setHightlight(WScreen
* scr
, WDefaultEntry
* entry
, XColor
* color
, void *foo
)
2576 if (scr
->select_color
)
2577 WMReleaseColor(scr
->select_color
);
2579 scr
->select_color
= WMCreateRGBColor(scr
->wmscreen
, color
->red
, color
->green
, color
->blue
, True
);
2581 wFreeColor(scr
, color
->pixel
);
2583 return REFRESH_MENU_COLOR
;
2586 static int setHightlightText(WScreen
* scr
, WDefaultEntry
* entry
, XColor
* color
, void *foo
)
2588 if (scr
->select_text_color
)
2589 WMReleaseColor(scr
->select_text_color
);
2591 scr
->select_text_color
= WMCreateRGBColor(scr
->wmscreen
, color
->red
, color
->green
, color
->blue
, True
);
2593 wFreeColor(scr
, color
->pixel
);
2595 return REFRESH_MENU_COLOR
;
2598 static int setClipTitleColor(WScreen
* scr
, WDefaultEntry
* entry
, XColor
* color
, long widx
)
2600 if (scr
->clip_title_color
[widx
])
2601 WMReleaseColor(scr
->clip_title_color
[widx
]);
2603 scr
->clip_title_color
[widx
] = WMCreateRGBColor(scr
->wmscreen
, color
->red
, color
->green
, color
->blue
, True
);
2604 wFreeColor(scr
, color
->pixel
);
2606 return REFRESH_ICON_TITLE_COLOR
;
2609 static int setWTitleColor(WScreen
* scr
, WDefaultEntry
* entry
, XColor
* color
, long widx
)
2611 if (scr
->window_title_color
[widx
])
2612 WMReleaseColor(scr
->window_title_color
[widx
]);
2614 scr
->window_title_color
[widx
] =
2615 WMCreateRGBColor(scr
->wmscreen
, color
->red
, color
->green
, color
->blue
, True
);
2617 wFreeColor(scr
, color
->pixel
);
2619 return REFRESH_WINDOW_TITLE_COLOR
;
2622 static int setMenuTitleColor(WScreen
* scr
, WDefaultEntry
* entry
, XColor
* color
, long widx
)
2624 if (scr
->menu_title_color
[0])
2625 WMReleaseColor(scr
->menu_title_color
[0]);
2627 scr
->menu_title_color
[0] = WMCreateRGBColor(scr
->wmscreen
, color
->red
, color
->green
, color
->blue
, True
);
2629 wFreeColor(scr
, color
->pixel
);
2631 return REFRESH_MENU_TITLE_COLOR
;
2634 static int setMenuTextColor(WScreen
* scr
, WDefaultEntry
* entry
, XColor
* color
, void *foo
)
2636 if (scr
->mtext_color
)
2637 WMReleaseColor(scr
->mtext_color
);
2639 scr
->mtext_color
= WMCreateRGBColor(scr
->wmscreen
, color
->red
, color
->green
, color
->blue
, True
);
2641 if (WMColorPixel(scr
->dtext_color
) == WMColorPixel(scr
->mtext_color
)) {
2642 WMSetColorAlpha(scr
->dtext_color
, 0x7fff);
2644 WMSetColorAlpha(scr
->dtext_color
, 0xffff);
2647 wFreeColor(scr
, color
->pixel
);
2649 return REFRESH_MENU_COLOR
;
2652 static int setMenuDisabledColor(WScreen
* scr
, WDefaultEntry
* entry
, XColor
* color
, void *foo
)
2654 if (scr
->dtext_color
)
2655 WMReleaseColor(scr
->dtext_color
);
2657 scr
->dtext_color
= WMCreateRGBColor(scr
->wmscreen
, color
->red
, color
->green
, color
->blue
, True
);
2659 if (WMColorPixel(scr
->dtext_color
) == WMColorPixel(scr
->mtext_color
)) {
2660 WMSetColorAlpha(scr
->dtext_color
, 0x7fff);
2662 WMSetColorAlpha(scr
->dtext_color
, 0xffff);
2665 wFreeColor(scr
, color
->pixel
);
2667 return REFRESH_MENU_COLOR
;
2670 static int setIconTitleColor(WScreen
* scr
, WDefaultEntry
* entry
, XColor
* color
, void *foo
)
2672 if (scr
->icon_title_color
)
2673 WMReleaseColor(scr
->icon_title_color
);
2674 scr
->icon_title_color
= WMCreateRGBColor(scr
->wmscreen
, color
->red
, color
->green
, color
->blue
, True
);
2676 wFreeColor(scr
, color
->pixel
);
2678 return REFRESH_ICON_TITLE_COLOR
;
2681 static int setIconTitleBack(WScreen
* scr
, WDefaultEntry
* entry
, XColor
* color
, void *foo
)
2683 if (scr
->icon_title_texture
) {
2684 wTextureDestroy(scr
, (WTexture
*) scr
->icon_title_texture
);
2686 scr
->icon_title_texture
= wTextureMakeSolid(scr
, color
);
2688 return REFRESH_ICON_TITLE_BACK
;
2691 static int setFrameBorderWidth(WScreen
* scr
, WDefaultEntry
* entry
, int * value
, void *foo
)
2693 scr
->frame_border_width
= *value
;
2695 return REFRESH_FRAME_BORDER
;
2698 static int setFrameBorderColor(WScreen
* scr
, WDefaultEntry
* entry
, XColor
* color
, void *foo
)
2700 if (scr
->frame_border_color
)
2701 WMReleaseColor(scr
->frame_border_color
);
2702 scr
->frame_border_color
= WMCreateRGBColor(scr
->wmscreen
, color
->red
, color
->green
, color
->blue
, True
);
2704 wFreeColor(scr
, color
->pixel
);
2706 return REFRESH_FRAME_BORDER
;
2709 static int setFrameSelectedBorderColor(WScreen
* scr
, WDefaultEntry
* entry
, XColor
* color
, void *foo
)
2711 if (scr
->frame_selected_border_color
)
2712 WMReleaseColor(scr
->frame_selected_border_color
);
2713 scr
->frame_selected_border_color
= WMCreateRGBColor(scr
->wmscreen
, color
->red
, color
->green
, color
->blue
, True
);
2715 wFreeColor(scr
, color
->pixel
);
2717 return REFRESH_FRAME_BORDER
;
2720 static void trackDeadProcess(pid_t pid
, unsigned char status
, WScreen
* scr
)
2722 close(scr
->helper_fd
);
2724 scr
->helper_pid
= 0;
2725 scr
->flags
.backimage_helper_launched
= 0;
2728 static int setWorkspaceSpecificBack(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *bar
)
2734 if (scr
->flags
.backimage_helper_launched
) {
2735 if (WMGetPropListItemCount(value
) == 0) {
2736 SendHelperMessage(scr
, 'C', 0, NULL
);
2737 SendHelperMessage(scr
, 'K', 0, NULL
);
2739 WMReleasePropList(value
);
2746 if (WMGetPropListItemCount(value
) == 0)
2749 if (pipe(filedes
) < 0) {
2750 werror("pipe() failed:can't set workspace specific background image");
2752 WMReleasePropList(value
);
2758 werror("fork() failed:can't set workspace specific background image");
2759 if (close(filedes
[0]) < 0)
2760 werror("could not close pipe");
2761 if (close(filedes
[1]) < 0)
2762 werror("could not close pipe");
2764 } else if (pid
== 0) {
2767 SetupEnvironment(scr
);
2770 werror("could not close pipe");
2771 if (dup(filedes
[0]) < 0) {
2772 werror("dup() failed:can't set workspace specific background image");
2774 dither
= wPreferences
.no_dithering
? "-m" : "-d";
2775 if (wPreferences
.smooth_workspace_back
)
2776 execlp("wmsetbg", "wmsetbg", "-helper", "-S", dither
, NULL
);
2778 execlp("wmsetbg", "wmsetbg", "-helper", dither
, NULL
);
2779 werror("could not execute wmsetbg");
2783 if (fcntl(filedes
[0], F_SETFD
, FD_CLOEXEC
) < 0) {
2784 werror("error setting close-on-exec flag");
2786 if (fcntl(filedes
[1], F_SETFD
, FD_CLOEXEC
) < 0) {
2787 werror("error setting close-on-exec flag");
2790 scr
->helper_fd
= filedes
[1];
2791 scr
->helper_pid
= pid
;
2792 scr
->flags
.backimage_helper_launched
= 1;
2794 wAddDeathHandler(pid
, (WDeathHandler
*) trackDeadProcess
, scr
);
2796 SendHelperMessage(scr
, 'P', -1, wPreferences
.pixmap_path
);
2801 for (i
= 0; i
< WMGetPropListItemCount(value
); i
++) {
2802 val
= WMGetFromPLArray(value
, i
);
2803 if (val
&& WMIsPLArray(val
) && WMGetPropListItemCount(val
) > 0) {
2804 str
= WMGetPropListDescription(val
, False
);
2806 SendHelperMessage(scr
, 'S', i
+ 1, str
);
2810 SendHelperMessage(scr
, 'U', i
+ 1, NULL
);
2815 WMReleasePropList(value
);
2819 static int setWorkspaceBack(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *bar
)
2821 if (scr
->flags
.backimage_helper_launched
) {
2824 if (WMGetPropListItemCount(value
) == 0) {
2825 SendHelperMessage(scr
, 'U', 0, NULL
);
2827 /* set the default workspace background to this one */
2828 str
= WMGetPropListDescription(value
, False
);
2830 SendHelperMessage(scr
, 'S', 0, str
);
2832 SendHelperMessage(scr
, 'C', scr
->current_workspace
+ 1, NULL
);
2834 SendHelperMessage(scr
, 'U', 0, NULL
);
2837 } else if (WMGetPropListItemCount(value
) > 0) {
2843 text
= WMGetPropListDescription(value
, False
);
2844 len
= strlen(text
) + 40;
2845 command
= wmalloc(len
);
2846 dither
= wPreferences
.no_dithering
? "-m" : "-d";
2847 if (wPreferences
.smooth_workspace_back
)
2848 snprintf(command
, len
, "wmsetbg %s -S -p '%s' &", dither
, text
);
2850 snprintf(command
, len
, "wmsetbg %s -p '%s' &", dither
, text
);
2852 ExecuteShellCommand(scr
, command
);
2855 WMReleasePropList(value
);
2860 static int setWidgetColor(WScreen
* scr
, WDefaultEntry
* entry
, WTexture
** texture
, void *foo
)
2862 if (scr
->widget_texture
) {
2863 wTextureDestroy(scr
, (WTexture
*) scr
->widget_texture
);
2865 scr
->widget_texture
= *(WTexSolid
**) texture
;
2870 static int setFTitleBack(WScreen
* scr
, WDefaultEntry
* entry
, WTexture
** texture
, void *foo
)
2872 if (scr
->window_title_texture
[WS_FOCUSED
]) {
2873 wTextureDestroy(scr
, scr
->window_title_texture
[WS_FOCUSED
]);
2875 scr
->window_title_texture
[WS_FOCUSED
] = *texture
;
2877 return REFRESH_WINDOW_TEXTURES
;
2880 static int setPTitleBack(WScreen
* scr
, WDefaultEntry
* entry
, WTexture
** texture
, void *foo
)
2882 if (scr
->window_title_texture
[WS_PFOCUSED
]) {
2883 wTextureDestroy(scr
, scr
->window_title_texture
[WS_PFOCUSED
]);
2885 scr
->window_title_texture
[WS_PFOCUSED
] = *texture
;
2887 return REFRESH_WINDOW_TEXTURES
;
2890 static int setUTitleBack(WScreen
* scr
, WDefaultEntry
* entry
, WTexture
** texture
, void *foo
)
2892 if (scr
->window_title_texture
[WS_UNFOCUSED
]) {
2893 wTextureDestroy(scr
, scr
->window_title_texture
[WS_UNFOCUSED
]);
2895 scr
->window_title_texture
[WS_UNFOCUSED
] = *texture
;
2897 return REFRESH_WINDOW_TEXTURES
;
2900 static int setResizebarBack(WScreen
* scr
, WDefaultEntry
* entry
, WTexture
** texture
, void *foo
)
2902 if (scr
->resizebar_texture
[0]) {
2903 wTextureDestroy(scr
, scr
->resizebar_texture
[0]);
2905 scr
->resizebar_texture
[0] = *texture
;
2907 return REFRESH_WINDOW_TEXTURES
;
2910 static int setMenuTitleBack(WScreen
* scr
, WDefaultEntry
* entry
, WTexture
** texture
, void *foo
)
2912 if (scr
->menu_title_texture
[0]) {
2913 wTextureDestroy(scr
, scr
->menu_title_texture
[0]);
2915 scr
->menu_title_texture
[0] = *texture
;
2917 return REFRESH_MENU_TITLE_TEXTURE
;
2920 static int setMenuTextBack(WScreen
* scr
, WDefaultEntry
* entry
, WTexture
** texture
, void *foo
)
2922 if (scr
->menu_item_texture
) {
2923 wTextureDestroy(scr
, scr
->menu_item_texture
);
2924 wTextureDestroy(scr
, (WTexture
*) scr
->menu_item_auxtexture
);
2926 scr
->menu_item_texture
= *texture
;
2928 scr
->menu_item_auxtexture
= wTextureMakeSolid(scr
, &scr
->menu_item_texture
->any
.color
);
2930 return REFRESH_MENU_TEXTURE
;
2933 static int setKeyGrab(WScreen
* scr
, WDefaultEntry
* entry
, WShortKey
* shortcut
, long widx
)
2936 wKeyBindings
[widx
] = *shortcut
;
2938 wwin
= scr
->focused_window
;
2940 while (wwin
!= NULL
) {
2941 XUngrabKey(dpy
, AnyKey
, AnyModifier
, wwin
->frame
->core
->window
);
2943 if (!WFLAGP(wwin
, no_bind_keys
)) {
2944 wWindowSetKeyGrabs(wwin
);
2949 /* do we need to update window menus? */
2950 if (widx
>= WKBD_WORKSPACE1
&& widx
<= WKBD_WORKSPACE10
)
2951 return REFRESH_WORKSPACE_MENU
;
2952 if (widx
== WKBD_LASTWORKSPACE
)
2953 return REFRESH_WORKSPACE_MENU
;
2954 if (widx
>= WKBD_MOVE_WORKSPACE1
&& widx
<= WKBD_MOVE_WORKSPACE10
)
2955 return REFRESH_WORKSPACE_MENU
;
2960 static int setIconPosition(WScreen
* scr
, WDefaultEntry
* entry
, void *bar
, void *foo
)
2962 wScreenUpdateUsableArea(scr
);
2963 wArrangeIcons(scr
, True
);
2968 static int updateUsableArea(WScreen
* scr
, WDefaultEntry
* entry
, void *bar
, void *foo
)
2970 wScreenUpdateUsableArea(scr
);
2975 static int setMenuStyle(WScreen
* scr
, WDefaultEntry
* entry
, int *value
, void *foo
)
2977 return REFRESH_MENU_TEXTURE
;
2980 static RImage
*chopOffImage(RImage
* image
, int x
, int y
, int w
, int h
)
2982 RImage
*img
= RCreateImage(w
, h
, image
->format
== RRGBAFormat
);
2984 RCopyArea(img
, image
, x
, y
, w
, h
, 0, 0);
2989 static int setSwPOptions(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* array
, void *foo
)
2993 int cwidth
, cheight
;
2994 WPreferences
*prefs
= (WPreferences
*) foo
;
2996 if (!WMIsPLArray(array
) || WMGetPropListItemCount(array
) == 0) {
2997 if (prefs
->swtileImage
)
2998 RReleaseImage(prefs
->swtileImage
);
2999 prefs
->swtileImage
= NULL
;
3001 WMReleasePropList(array
);
3005 switch (WMGetPropListItemCount(array
)) {
3007 if (!WMIsPLString(WMGetFromPLArray(array
, 1))) {
3008 wwarning(_("Invalid arguments for option \"%s\""), entry
->key
);
3011 path
= FindImage(wPreferences
.pixmap_path
, WMGetFromPLString(WMGetFromPLArray(array
, 1)));
3014 wwarning(_("Could not find image \"%s\" for option \"%s\""),
3015 WMGetFromPLString(WMGetFromPLArray(array
, 1)), entry
->key
);
3017 bgimage
= RLoadImage(scr
->rcontext
, path
, 0);
3019 wwarning(_("Could not load image \"%s\" for option \"%s\""), path
, entry
->key
);
3024 cwidth
= atoi(WMGetFromPLString(WMGetFromPLArray(array
, 2)));
3025 cheight
= atoi(WMGetFromPLString(WMGetFromPLArray(array
, 3)));
3027 if (cwidth
<= 0 || cheight
<= 0 ||
3028 cwidth
>= bgimage
->width
- 2 || cheight
>= bgimage
->height
- 2)
3029 wwarning(_("Invalid split sizes for SwitchPanel back image."));
3032 int swidth
, theight
;
3033 for (i
= 0; i
< 9; i
++) {
3034 if (prefs
->swbackImage
[i
])
3035 RReleaseImage(prefs
->swbackImage
[i
]);
3036 prefs
->swbackImage
[i
] = NULL
;
3038 swidth
= (bgimage
->width
- cwidth
) / 2;
3039 theight
= (bgimage
->height
- cheight
) / 2;
3041 prefs
->swbackImage
[0] = chopOffImage(bgimage
, 0, 0, swidth
, theight
);
3042 prefs
->swbackImage
[1] = chopOffImage(bgimage
, swidth
, 0, cwidth
, theight
);
3043 prefs
->swbackImage
[2] = chopOffImage(bgimage
, swidth
+ cwidth
, 0,
3046 prefs
->swbackImage
[3] = chopOffImage(bgimage
, 0, theight
, swidth
, cheight
);
3047 prefs
->swbackImage
[4] = chopOffImage(bgimage
, swidth
, theight
,
3049 prefs
->swbackImage
[5] = chopOffImage(bgimage
, swidth
+ cwidth
, theight
,
3052 prefs
->swbackImage
[6] = chopOffImage(bgimage
, 0, theight
+ cheight
,
3054 prefs
->swbackImage
[7] = chopOffImage(bgimage
, swidth
, theight
+ cheight
,
3056 prefs
->swbackImage
[8] =
3057 chopOffImage(bgimage
, swidth
+ cwidth
, theight
+ cheight
, swidth
,
3060 // check if anything failed
3061 for (i
= 0; i
< 9; i
++) {
3062 if (!prefs
->swbackImage
[i
]) {
3063 for (; i
>= 0; --i
) {
3064 RReleaseImage(prefs
->swbackImage
[i
]);
3065 prefs
->swbackImage
[i
] = NULL
;
3071 RReleaseImage(bgimage
);
3076 if (!WMIsPLString(WMGetFromPLArray(array
, 0))) {
3077 wwarning(_("Invalid arguments for option \"%s\""), entry
->key
);
3080 path
= FindImage(wPreferences
.pixmap_path
, WMGetFromPLString(WMGetFromPLArray(array
, 0)));
3083 wwarning(_("Could not find image \"%s\" for option \"%s\""),
3084 WMGetFromPLString(WMGetFromPLArray(array
, 0)), entry
->key
);
3086 if (prefs
->swtileImage
)
3087 RReleaseImage(prefs
->swtileImage
);
3089 prefs
->swtileImage
= RLoadImage(scr
->rcontext
, path
, 0);
3090 if (!prefs
->swtileImage
) {
3091 wwarning(_("Could not load image \"%s\" for option \"%s\""), path
, entry
->key
);
3098 wwarning(_("Invalid number of arguments for option \"%s\""), entry
->key
);
3102 WMReleasePropList(array
);
3107 static int setModifierKeyLabels(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* array
, void *foo
)
3110 WPreferences
*prefs
= (WPreferences
*) foo
;
3112 if (!WMIsPLArray(array
) || WMGetPropListItemCount(array
) != 7) {
3113 wwarning(_("Value for option \"%s\" must be an array of 7 strings"), entry
->key
);
3114 WMReleasePropList(array
);
3118 DestroyWindowMenu(scr
);
3120 for (i
= 0; i
< 7; i
++) {
3121 if (prefs
->modifier_labels
[i
])
3122 wfree(prefs
->modifier_labels
[i
]);
3124 if (WMIsPLString(WMGetFromPLArray(array
, i
))) {
3125 prefs
->modifier_labels
[i
] = wstrdup(WMGetFromPLString(WMGetFromPLArray(array
, i
)));
3127 wwarning(_("Invalid argument for option \"%s\" item %d"), entry
->key
, i
);
3128 prefs
->modifier_labels
[i
] = NULL
;
3132 WMReleasePropList(array
);
3137 static int setDoubleClick(WScreen
*scr
, WDefaultEntry
*entry
, int *value
, void *foo
)
3142 W_setconf_doubleClickDelay(*value
);
3147 static int setCursor(WScreen
* scr
, WDefaultEntry
* entry
, Cursor
* cursor
, long widx
)
3149 if (wCursor
[widx
] != None
) {
3150 XFreeCursor(dpy
, wCursor
[widx
]);
3153 wCursor
[widx
] = *cursor
;
3155 if (widx
== WCUR_ROOT
&& *cursor
!= None
) {
3156 XDefineCursor(dpy
, scr
->root_win
, *cursor
);