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"
68 #define MAX_SHORTCUT_LENGTH 32
70 #ifndef GLOBAL_DEFAULTS_SUBDIR
71 #define GLOBAL_DEFAULTS_SUBDIR "WindowMaker"
75 typedef struct _WDefaultEntry WDefaultEntry
;
76 typedef int (WDECallbackConvert
) (WScreen
*scr
, WDefaultEntry
*entry
, WMPropList
*plvalue
, void *addr
, void **tdata
);
77 typedef int (WDECallbackUpdate
) (WScreen
*scr
, WDefaultEntry
*entry
, void *tdata
, void *extra_data
);
79 struct _WDefaultEntry
{
81 const char *default_value
;
84 WDECallbackConvert
*convert
;
85 WDECallbackUpdate
*update
;
87 WMPropList
*plvalue
; /* default value */
90 /* used to map strings to integers */
98 static WDECallbackConvert getBool
;
99 static WDECallbackConvert getInt
;
100 static WDECallbackConvert getCoord
;
101 static WDECallbackConvert getPathList
;
102 static WDECallbackConvert getEnum
;
103 static WDECallbackConvert getTexture
;
104 static WDECallbackConvert getWSBackground
;
105 static WDECallbackConvert getWSSpecificBackground
;
106 static WDECallbackConvert getFont
;
107 static WDECallbackConvert getColor
;
108 static WDECallbackConvert getKeybind
;
109 static WDECallbackConvert getModMask
;
110 static WDECallbackConvert getPropList
;
112 /* value setting functions */
113 static WDECallbackUpdate setJustify
;
114 static WDECallbackUpdate setClearance
;
115 static WDECallbackUpdate setIfDockPresent
;
116 static WDECallbackUpdate setClipMergedInDock
;
117 static WDECallbackUpdate setWrapAppiconsInDock
;
118 static WDECallbackUpdate setStickyIcons
;
119 static WDECallbackUpdate setWidgetColor
;
120 static WDECallbackUpdate setIconTile
;
121 static WDECallbackUpdate setWinTitleFont
;
122 static WDECallbackUpdate setMenuTitleFont
;
123 static WDECallbackUpdate setMenuTextFont
;
124 static WDECallbackUpdate setIconTitleFont
;
125 static WDECallbackUpdate setIconTitleColor
;
126 static WDECallbackUpdate setIconTitleBack
;
127 static WDECallbackUpdate setFrameBorderWidth
;
128 static WDECallbackUpdate setFrameBorderColor
;
129 static WDECallbackUpdate setFrameFocusedBorderColor
;
130 static WDECallbackUpdate setFrameSelectedBorderColor
;
131 static WDECallbackUpdate setLargeDisplayFont
;
132 static WDECallbackUpdate setWTitleColor
;
133 static WDECallbackUpdate setFTitleBack
;
134 static WDECallbackUpdate setPTitleBack
;
135 static WDECallbackUpdate setUTitleBack
;
136 static WDECallbackUpdate setResizebarBack
;
137 static WDECallbackUpdate setWorkspaceBack
;
138 static WDECallbackUpdate setWorkspaceSpecificBack
;
139 static WDECallbackUpdate setMenuTitleColor
;
140 static WDECallbackUpdate setMenuTextColor
;
141 static WDECallbackUpdate setMenuDisabledColor
;
142 static WDECallbackUpdate setMenuTitleBack
;
143 static WDECallbackUpdate setMenuTextBack
;
144 static WDECallbackUpdate setHightlight
;
145 static WDECallbackUpdate setHightlightText
;
146 static WDECallbackUpdate setKeyGrab
;
147 static WDECallbackUpdate setDoubleClick
;
148 static WDECallbackUpdate setIconPosition
;
150 static WDECallbackUpdate setClipTitleFont
;
151 static WDECallbackUpdate setClipTitleColor
;
153 static WDECallbackUpdate setMenuStyle
;
154 static WDECallbackUpdate setSwPOptions
;
155 static WDECallbackUpdate updateUsableArea
;
157 static WDECallbackUpdate setModifierKeyLabels
;
159 static WDECallbackConvert getCursor
;
160 static WDECallbackUpdate setCursor
;
163 * Tables to convert strings to enumeration values.
164 * Values stored are char
167 /* WARNING: sum of length of all value strings must not exceed
169 #define TOTAL_VALUES_LENGTH 80
171 #define REFRESH_WINDOW_TEXTURES (1<<0)
172 #define REFRESH_MENU_TEXTURE (1<<1)
173 #define REFRESH_MENU_FONT (1<<2)
174 #define REFRESH_MENU_COLOR (1<<3)
175 #define REFRESH_MENU_TITLE_TEXTURE (1<<4)
176 #define REFRESH_MENU_TITLE_FONT (1<<5)
177 #define REFRESH_MENU_TITLE_COLOR (1<<6)
178 #define REFRESH_WINDOW_TITLE_COLOR (1<<7)
179 #define REFRESH_WINDOW_FONT (1<<8)
180 #define REFRESH_ICON_TILE (1<<9)
181 #define REFRESH_ICON_FONT (1<<10)
182 #define REFRESH_WORKSPACE_BACK (1<<11)
184 #define REFRESH_BUTTON_IMAGES (1<<12)
186 #define REFRESH_ICON_TITLE_COLOR (1<<13)
187 #define REFRESH_ICON_TITLE_BACK (1<<14)
189 #define REFRESH_WORKSPACE_MENU (1<<15)
191 #define REFRESH_FRAME_BORDER REFRESH_MENU_FONT|REFRESH_WINDOW_FONT
193 static WOptionEnumeration seFocusModes
[] = {
194 {"Manual", WKF_CLICK
, 0}, {"ClickToFocus", WKF_CLICK
, 1},
195 {"Sloppy", WKF_SLOPPY
, 0}, {"SemiAuto", WKF_SLOPPY
, 1}, {"Auto", WKF_SLOPPY
, 1},
199 static WOptionEnumeration seTitlebarModes
[] = {
200 {"new", TS_NEW
, 0}, {"old", TS_OLD
, 0},
201 {"next", TS_NEXT
, 0}, {NULL
, 0, 0}
204 static WOptionEnumeration seColormapModes
[] = {
205 {"Manual", WCM_CLICK
, 0}, {"ClickToFocus", WCM_CLICK
, 1},
206 {"Auto", WCM_POINTER
, 0}, {"FocusFollowMouse", WCM_POINTER
, 1},
210 static WOptionEnumeration sePlacements
[] = {
211 {"Auto", WPM_AUTO
, 0},
212 {"Smart", WPM_SMART
, 0},
213 {"Cascade", WPM_CASCADE
, 0},
214 {"Random", WPM_RANDOM
, 0},
215 {"Manual", WPM_MANUAL
, 0},
216 {"Center", WPM_CENTER
, 0},
220 static WOptionEnumeration seGeomDisplays
[] = {
221 {"None", WDIS_NONE
, 0},
222 {"Center", WDIS_CENTER
, 0},
223 {"Corner", WDIS_TOPLEFT
, 0},
224 {"Floating", WDIS_FRAME_CENTER
, 0},
225 {"Line", WDIS_NEW
, 0},
229 static WOptionEnumeration seSpeeds
[] = {
230 {"UltraFast", SPEED_ULTRAFAST
, 0},
231 {"Fast", SPEED_FAST
, 0},
232 {"Medium", SPEED_MEDIUM
, 0},
233 {"Slow", SPEED_SLOW
, 0},
234 {"UltraSlow", SPEED_ULTRASLOW
, 0},
238 static WOptionEnumeration seMouseButtonActions
[] = {
239 {"None", WA_NONE
, 0},
240 {"SelectWindows", WA_SELECT_WINDOWS
, 0},
241 {"OpenApplicationsMenu", WA_OPEN_APPMENU
, 0},
242 {"OpenWindowListMenu", WA_OPEN_WINLISTMENU
, 0},
246 static WOptionEnumeration seMouseWheelActions
[] = {
247 {"None", WA_NONE
, 0},
248 {"SwitchWorkspaces", WA_SWITCH_WORKSPACES
, 0},
252 static WOptionEnumeration seIconificationStyles
[] = {
253 {"Zoom", WIS_ZOOM
, 0},
254 {"Twist", WIS_TWIST
, 0},
255 {"Flip", WIS_FLIP
, 0},
256 {"None", WIS_NONE
, 0},
257 {"random", WIS_RANDOM
, 0},
261 static WOptionEnumeration seJustifications
[] = {
262 {"Left", WTJ_LEFT
, 0},
263 {"Center", WTJ_CENTER
, 0},
264 {"Right", WTJ_RIGHT
, 0},
268 static WOptionEnumeration seIconPositions
[] = {
269 {"blv", IY_BOTTOM
| IY_LEFT
| IY_VERT
, 0},
270 {"blh", IY_BOTTOM
| IY_LEFT
| IY_HORIZ
, 0},
271 {"brv", IY_BOTTOM
| IY_RIGHT
| IY_VERT
, 0},
272 {"brh", IY_BOTTOM
| IY_RIGHT
| IY_HORIZ
, 0},
273 {"tlv", IY_TOP
| IY_LEFT
| IY_VERT
, 0},
274 {"tlh", IY_TOP
| IY_LEFT
| IY_HORIZ
, 0},
275 {"trv", IY_TOP
| IY_RIGHT
| IY_VERT
, 0},
276 {"trh", IY_TOP
| IY_RIGHT
| IY_HORIZ
, 0},
280 static WOptionEnumeration seMenuStyles
[] = {
281 {"normal", MS_NORMAL
, 0},
282 {"singletexture", MS_SINGLE_TEXTURE
, 0},
283 {"flat", MS_FLAT
, 0},
287 static WOptionEnumeration seDisplayPositions
[] = {
288 {"none", WD_NONE
, 0},
289 {"center", WD_CENTER
, 0},
291 {"bottom", WD_BOTTOM
, 0},
292 {"topleft", WD_TOPLEFT
, 0},
293 {"topright", WD_TOPRIGHT
, 0},
294 {"bottomleft", WD_BOTTOMLEFT
, 0},
295 {"bottomright", WD_BOTTOMRIGHT
, 0},
299 static WOptionEnumeration seWorkspaceBorder
[] = {
300 {"None", WB_NONE
, 0},
301 {"LeftRight", WB_LEFTRIGHT
, 0},
302 {"TopBottom", WB_TOPBOTTOM
, 0},
303 {"AllDirections", WB_ALLDIRS
, 0},
308 * ALL entries in the tables bellow, NEED to have a default value
309 * defined, and this value needs to be correct.
312 /* these options will only affect the window manager on startup
314 * static defaults can't access the screen data, because it is
315 * created after these defaults are read
317 WDefaultEntry staticOptionList
[] = {
319 {"ColormapSize", "4", NULL
,
320 &wPreferences
.cmap_size
, getInt
, NULL
, NULL
, NULL
},
321 {"DisableDithering", "NO", NULL
,
322 &wPreferences
.no_dithering
, getBool
, NULL
, NULL
, NULL
},
323 {"IconSize", "64", NULL
,
324 &wPreferences
.icon_size
, getInt
, NULL
, NULL
, NULL
},
325 {"ModifierKey", "Mod1", NULL
,
326 &wPreferences
.modifier_mask
, getModMask
, NULL
, NULL
, NULL
},
327 {"DisableWSMouseActions", "NO", NULL
,
328 &wPreferences
.disable_root_mouse
, getBool
, NULL
, NULL
, NULL
},
329 {"FocusMode", "manual", seFocusModes
, /* have a problem when switching from */
330 &wPreferences
.focus_mode
, getEnum
, NULL
, NULL
, NULL
}, /* manual to sloppy without restart */
331 {"NewStyle", "new", seTitlebarModes
,
332 &wPreferences
.new_style
, getEnum
, NULL
, NULL
, NULL
},
333 {"DisableDock", "NO", (void *)WM_DOCK
,
334 NULL
, getBool
, setIfDockPresent
, NULL
, NULL
},
335 {"DisableClip", "NO", (void *)WM_CLIP
,
336 NULL
, getBool
, setIfDockPresent
, NULL
, NULL
},
337 {"DisableDrawers", "NO", (void *)WM_DRAWER
,
338 NULL
, getBool
, setIfDockPresent
, NULL
, NULL
},
339 {"ClipMergedInDock", "NO", NULL
,
340 NULL
, getBool
, setClipMergedInDock
, NULL
, NULL
},
341 {"DisableMiniwindows", "NO", NULL
,
342 &wPreferences
.disable_miniwindows
, getBool
, NULL
, NULL
, NULL
}
345 #define NUM2STRING_(x) #x
346 #define NUM2STRING(x) NUM2STRING_(x)
348 WDefaultEntry optionList
[] = {
350 /* dynamic options */
352 {"IconPosition", "blh", seIconPositions
,
353 &wPreferences
.icon_yard
, getEnum
, setIconPosition
, NULL
, NULL
},
354 {"IconificationStyle", "Zoom", seIconificationStyles
,
355 &wPreferences
.iconification_style
, getEnum
, NULL
, NULL
, NULL
},
356 {"MouseLeftButtonAction", "SelectWindows", seMouseButtonActions
,
357 &wPreferences
.mouse_button1
, getEnum
, NULL
, NULL
, NULL
},
358 {"MouseMiddleButtonAction", "OpenWindowListMenu", seMouseButtonActions
,
359 &wPreferences
.mouse_button2
, getEnum
, NULL
, NULL
, NULL
},
360 {"MouseRightButtonAction", "OpenApplicationsMenu", seMouseButtonActions
,
361 &wPreferences
.mouse_button3
, getEnum
, NULL
, NULL
, NULL
},
362 {"MouseWheelAction", "None", seMouseWheelActions
,
363 &wPreferences
.mouse_wheel
, getEnum
, NULL
, NULL
, NULL
},
364 {"PixmapPath", DEF_PIXMAP_PATHS
, NULL
,
365 &wPreferences
.pixmap_path
, getPathList
, NULL
, NULL
, NULL
},
366 {"IconPath", DEF_ICON_PATHS
, NULL
,
367 &wPreferences
.icon_path
, getPathList
, NULL
, NULL
, NULL
},
368 {"ColormapMode", "auto", seColormapModes
,
369 &wPreferences
.colormap_mode
, getEnum
, NULL
, NULL
, NULL
},
370 {"AutoFocus", "NO", NULL
,
371 &wPreferences
.auto_focus
, getBool
, NULL
, NULL
, NULL
},
372 {"RaiseDelay", "0", NULL
,
373 &wPreferences
.raise_delay
, getInt
, NULL
, NULL
, NULL
},
374 {"CirculateRaise", "NO", NULL
,
375 &wPreferences
.circ_raise
, getBool
, NULL
, NULL
, NULL
},
376 {"Superfluous", "NO", NULL
,
377 &wPreferences
.superfluous
, getBool
, NULL
, NULL
, NULL
},
378 {"AdvanceToNewWorkspace", "NO", NULL
,
379 &wPreferences
.ws_advance
, getBool
, NULL
, NULL
, NULL
},
380 {"CycleWorkspaces", "NO", NULL
,
381 &wPreferences
.ws_cycle
, getBool
, NULL
, NULL
, NULL
},
382 {"WorkspaceNameDisplayPosition", "center", seDisplayPositions
,
383 &wPreferences
.workspace_name_display_position
, getEnum
, NULL
, NULL
, NULL
},
384 {"WorkspaceBorder", "None", seWorkspaceBorder
,
385 &wPreferences
.workspace_border_position
, getEnum
, updateUsableArea
, NULL
, NULL
},
386 {"WorkspaceBorderSize", "0", NULL
,
387 &wPreferences
.workspace_border_size
, getInt
, updateUsableArea
, NULL
, NULL
},
388 {"StickyIcons", "NO", NULL
,
389 &wPreferences
.sticky_icons
, getBool
, setStickyIcons
, NULL
, NULL
},
390 {"SaveSessionOnExit", "NO", NULL
,
391 &wPreferences
.save_session_on_exit
, getBool
, NULL
, NULL
, NULL
},
392 {"WrapMenus", "NO", NULL
,
393 &wPreferences
.wrap_menus
, getBool
, NULL
, NULL
, NULL
},
394 {"ScrollableMenus", "NO", NULL
,
395 &wPreferences
.scrollable_menus
, getBool
, NULL
, NULL
, NULL
},
396 {"MenuScrollSpeed", "medium", seSpeeds
,
397 &wPreferences
.menu_scroll_speed
, getEnum
, NULL
, NULL
, NULL
},
398 {"IconSlideSpeed", "medium", seSpeeds
,
399 &wPreferences
.icon_slide_speed
, getEnum
, NULL
, NULL
, NULL
},
400 {"ShadeSpeed", "medium", seSpeeds
,
401 &wPreferences
.shade_speed
, getEnum
, NULL
, NULL
, NULL
},
402 {"BounceAppIconsWhenUrgent", "YES", NULL
,
403 &wPreferences
.bounce_appicons_when_urgent
, getBool
, NULL
, NULL
, NULL
},
404 {"RaiseAppIconsWhenBouncing", "NO", NULL
,
405 &wPreferences
.raise_appicons_when_bouncing
, getBool
, NULL
, NULL
, NULL
},
406 {"DoNotMakeAppIconsBounce", "NO", NULL
,
407 &wPreferences
.do_not_make_appicons_bounce
, getBool
, NULL
, NULL
, NULL
},
408 {"DoubleClickTime", "250", (void *)&wPreferences
.dblclick_time
,
409 &wPreferences
.dblclick_time
, getInt
, setDoubleClick
, NULL
, NULL
},
410 {"ClipAutoraiseDelay", "600", NULL
,
411 &wPreferences
.clip_auto_raise_delay
, getInt
, NULL
, NULL
, NULL
},
412 {"ClipAutolowerDelay", "1000", NULL
,
413 &wPreferences
.clip_auto_lower_delay
, getInt
, NULL
, NULL
, NULL
},
414 {"ClipAutoexpandDelay", "600", NULL
,
415 &wPreferences
.clip_auto_expand_delay
, getInt
, NULL
, NULL
, NULL
},
416 {"ClipAutocollapseDelay", "1000", NULL
,
417 &wPreferences
.clip_auto_collapse_delay
, getInt
, NULL
, NULL
, NULL
},
418 {"WrapAppiconsInDock", "YES", NULL
,
419 NULL
, getBool
, setWrapAppiconsInDock
, NULL
, NULL
},
420 {"AlignSubmenus", "NO", NULL
,
421 &wPreferences
.align_menus
, getBool
, NULL
, NULL
, NULL
},
422 {"ViKeyMenus", "NO", NULL
,
423 &wPreferences
.vi_key_menus
, getBool
, NULL
, NULL
, NULL
},
424 {"OpenTransientOnOwnerWorkspace", "NO", NULL
,
425 &wPreferences
.open_transients_with_parent
, getBool
, NULL
, NULL
, NULL
},
426 {"WindowPlacement", "auto", sePlacements
,
427 &wPreferences
.window_placement
, getEnum
, NULL
, NULL
, NULL
},
428 {"IgnoreFocusClick", "NO", NULL
,
429 &wPreferences
.ignore_focus_click
, getBool
, NULL
, NULL
, NULL
},
430 {"UseSaveUnders", "NO", NULL
,
431 &wPreferences
.use_saveunders
, getBool
, NULL
, NULL
, NULL
},
432 {"OpaqueMove", "NO", NULL
,
433 &wPreferences
.opaque_move
, getBool
, NULL
, NULL
, NULL
},
434 {"OpaqueResize", "NO", NULL
,
435 &wPreferences
.opaque_resize
, getBool
, NULL
, NULL
, NULL
},
436 {"OpaqueMoveResizeKeyboard", "NO", NULL
,
437 &wPreferences
.opaque_move_resize_keyboard
, getBool
, NULL
, NULL
, NULL
},
438 {"DisableAnimations", "NO", NULL
,
439 &wPreferences
.no_animations
, getBool
, NULL
, NULL
, NULL
},
440 {"DontLinkWorkspaces", "NO", NULL
,
441 &wPreferences
.no_autowrap
, getBool
, NULL
, NULL
, NULL
},
442 {"HighlightActiveApp", "YES", NULL
,
443 &wPreferences
.highlight_active_app
, getBool
, NULL
, NULL
, NULL
},
444 {"AutoArrangeIcons", "NO", NULL
,
445 &wPreferences
.auto_arrange_icons
, getBool
, NULL
, NULL
, NULL
},
446 {"NoWindowOverDock", "NO", NULL
,
447 &wPreferences
.no_window_over_dock
, getBool
, updateUsableArea
, NULL
, NULL
},
448 {"NoWindowOverIcons", "NO", NULL
,
449 &wPreferences
.no_window_over_icons
, getBool
, updateUsableArea
, NULL
, NULL
},
450 {"WindowPlaceOrigin", "(0, 0)", NULL
,
451 &wPreferences
.window_place_origin
, getCoord
, NULL
, NULL
, NULL
},
452 {"ResizeDisplay", "corner", seGeomDisplays
,
453 &wPreferences
.size_display
, getEnum
, NULL
, NULL
, NULL
},
454 {"MoveDisplay", "corner", seGeomDisplays
,
455 &wPreferences
.move_display
, getEnum
, NULL
, NULL
, NULL
},
456 {"DontConfirmKill", "NO", NULL
,
457 &wPreferences
.dont_confirm_kill
, getBool
, NULL
, NULL
, NULL
},
458 {"WindowTitleBalloons", "NO", NULL
,
459 &wPreferences
.window_balloon
, getBool
, NULL
, NULL
, NULL
},
460 {"MiniwindowTitleBalloons", "NO", NULL
,
461 &wPreferences
.miniwin_balloon
, getBool
, NULL
, NULL
, NULL
},
462 {"AppIconBalloons", "NO", NULL
,
463 &wPreferences
.appicon_balloon
, getBool
, NULL
, NULL
, NULL
},
464 {"HelpBalloons", "NO", NULL
,
465 &wPreferences
.help_balloon
, getBool
, NULL
, NULL
, NULL
},
466 {"EdgeResistance", "30", NULL
,
467 &wPreferences
.edge_resistance
, getInt
, NULL
, NULL
, NULL
},
468 {"ResizeIncrement", "0", NULL
,
469 &wPreferences
.resize_increment
, getInt
, NULL
, NULL
, NULL
},
470 {"Attraction", "NO", NULL
,
471 &wPreferences
.attract
, getBool
, NULL
, NULL
, NULL
},
472 {"DisableBlinking", "NO", NULL
,
473 &wPreferences
.dont_blink
, getBool
, NULL
, NULL
, NULL
},
474 {"SingleClickLaunch", "NO", NULL
,
475 &wPreferences
.single_click
, getBool
, NULL
, NULL
, NULL
},
476 {"StrictWindozeCycle", "YES", NULL
,
477 &wPreferences
.strict_windoze_cycle
, getBool
, NULL
, NULL
, NULL
},
478 {"SwitchPanelOnlyOpen", "NO", NULL
,
479 &wPreferences
.panel_only_open
, 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 {"FrameFocusedBorderColor", "black", NULL
,
573 NULL
, getColor
, setFrameFocusedBorderColor
, NULL
, NULL
},
574 {"FrameSelectedBorderColor", "white", NULL
,
575 NULL
, getColor
, setFrameSelectedBorderColor
, NULL
, NULL
},
579 {"RootMenuKey", "None", (void *)WKBD_ROOTMENU
,
580 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
581 {"WindowListKey", "None", (void *)WKBD_WINDOWLIST
,
582 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
583 {"WindowMenuKey", "None", (void *)WKBD_WINDOWMENU
,
584 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
585 {"DockRaiseLowerKey", "None", (void*)WKBD_DOCKRAISELOWER
,
586 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
587 {"ClipRaiseLowerKey", "None", (void *)WKBD_CLIPRAISELOWER
,
588 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
589 {"MiniaturizeKey", "None", (void *)WKBD_MINIATURIZE
,
590 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
591 {"MinimizeAllKey", "None", (void *)WKBD_MINIMIZEALL
,
592 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
593 {"HideKey", "None", (void *)WKBD_HIDE
,
594 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
595 {"HideOthersKey", "None", (void *)WKBD_HIDE_OTHERS
,
596 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
597 {"MoveResizeKey", "None", (void *)WKBD_MOVERESIZE
,
598 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
599 {"CloseKey", "None", (void *)WKBD_CLOSE
,
600 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
601 {"MaximizeKey", "None", (void *)WKBD_MAXIMIZE
,
602 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
603 {"VMaximizeKey", "None", (void *)WKBD_VMAXIMIZE
,
604 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
605 {"HMaximizeKey", "None", (void *)WKBD_HMAXIMIZE
,
606 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
607 {"LHMaximizeKey", "None", (void*)WKBD_LHMAXIMIZE
,
608 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
609 {"RHMaximizeKey", "None", (void*)WKBD_RHMAXIMIZE
,
610 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
611 {"THMaximizeKey", "None", (void*)WKBD_THMAXIMIZE
,
612 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
613 {"BHMaximizeKey", "None", (void*)WKBD_BHMAXIMIZE
,
614 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
615 {"LTCMaximizeKey", "None", (void*)WKBD_LTCMAXIMIZE
,
616 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
617 {"RTCMaximizeKey", "None", (void*)WKBD_RTCMAXIMIZE
,
618 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
619 {"LBCMaximizeKey", "None", (void*)WKBD_LBCMAXIMIZE
,
620 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
621 {"RBCMaximizeKey", "None", (void*)WKBD_RBCMAXIMIZE
,
622 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
623 {"MaximusKey", "None", (void*)WKBD_MAXIMUS
,
624 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
625 {"RaiseKey", "\"Meta+Up\"", (void *)WKBD_RAISE
,
626 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
627 {"LowerKey", "\"Meta+Down\"", (void *)WKBD_LOWER
,
628 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
629 {"RaiseLowerKey", "None", (void *)WKBD_RAISELOWER
,
630 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
631 {"ShadeKey", "None", (void *)WKBD_SHADE
,
632 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
633 {"SelectKey", "None", (void *)WKBD_SELECT
,
634 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
635 {"FocusNextKey", "None", (void *)WKBD_FOCUSNEXT
,
636 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
637 {"FocusPrevKey", "None", (void *)WKBD_FOCUSPREV
,
638 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
639 {"GroupNextKey", "None", (void *)WKBD_GROUPNEXT
,
640 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
641 {"GroupPrevKey", "None", (void *)WKBD_GROUPPREV
,
642 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
643 {"NextWorkspaceKey", "None", (void *)WKBD_NEXTWORKSPACE
,
644 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
645 {"PrevWorkspaceKey", "None", (void *)WKBD_PREVWORKSPACE
,
646 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
647 {"LastWorkspaceKey", "None", (void *)WKBD_LASTWORKSPACE
,
648 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
649 {"NextWorkspaceLayerKey", "None", (void *)WKBD_NEXTWSLAYER
,
650 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
651 {"PrevWorkspaceLayerKey", "None", (void *)WKBD_PREVWSLAYER
,
652 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
653 {"Workspace1Key", "None", (void *)WKBD_WORKSPACE1
,
654 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
655 {"Workspace2Key", "None", (void *)WKBD_WORKSPACE2
,
656 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
657 {"Workspace3Key", "None", (void *)WKBD_WORKSPACE3
,
658 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
659 {"Workspace4Key", "None", (void *)WKBD_WORKSPACE4
,
660 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
661 {"Workspace5Key", "None", (void *)WKBD_WORKSPACE5
,
662 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
663 {"Workspace6Key", "None", (void *)WKBD_WORKSPACE6
,
664 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
665 {"Workspace7Key", "None", (void *)WKBD_WORKSPACE7
,
666 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
667 {"Workspace8Key", "None", (void *)WKBD_WORKSPACE8
,
668 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
669 {"Workspace9Key", "None", (void *)WKBD_WORKSPACE9
,
670 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
671 {"Workspace10Key", "None", (void *)WKBD_WORKSPACE10
,
672 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
673 {"MoveToWorkspace1Key", "None", (void *)WKBD_MOVE_WORKSPACE1
,
674 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
675 {"MoveToWorkspace2Key", "None", (void *)WKBD_MOVE_WORKSPACE2
,
676 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
677 {"MoveToWorkspace3Key", "None", (void *)WKBD_MOVE_WORKSPACE3
,
678 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
679 {"MoveToWorkspace4Key", "None", (void *)WKBD_MOVE_WORKSPACE4
,
680 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
681 {"MoveToWorkspace5Key", "None", (void *)WKBD_MOVE_WORKSPACE5
,
682 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
683 {"MoveToWorkspace6Key", "None", (void *)WKBD_MOVE_WORKSPACE6
,
684 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
685 {"MoveToWorkspace7Key", "None", (void *)WKBD_MOVE_WORKSPACE7
,
686 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
687 {"MoveToWorkspace8Key", "None", (void *)WKBD_MOVE_WORKSPACE8
,
688 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
689 {"MoveToWorkspace9Key", "None", (void *)WKBD_MOVE_WORKSPACE9
,
690 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
691 {"MoveToWorkspace10Key", "None", (void *)WKBD_MOVE_WORKSPACE10
,
692 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
693 {"MoveToNextWorkspaceKey", "None", (void *)WKBD_MOVE_NEXTWORKSPACE
,
694 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
695 {"MoveToPrevWorkspaceKey", "None", (void *)WKBD_MOVE_PREVWORKSPACE
,
696 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
697 {"MoveToLastWorkspaceKey", "None", (void *)WKBD_MOVE_LASTWORKSPACE
,
698 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
699 {"MoveToNextWorkspaceLayerKey", "None", (void *)WKBD_MOVE_NEXTWSLAYER
,
700 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
701 {"MoveToPrevWorkspaceLayerKey", "None", (void *)WKBD_MOVE_PREVWSLAYER
,
702 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
703 {"WindowShortcut1Key", "None", (void *)WKBD_WINDOW1
,
704 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
705 {"WindowShortcut2Key", "None", (void *)WKBD_WINDOW2
,
706 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
707 {"WindowShortcut3Key", "None", (void *)WKBD_WINDOW3
,
708 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
709 {"WindowShortcut4Key", "None", (void *)WKBD_WINDOW4
,
710 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
711 {"WindowShortcut5Key", "None", (void *)WKBD_WINDOW5
,
712 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
713 {"WindowShortcut6Key", "None", (void *)WKBD_WINDOW6
,
714 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
715 {"WindowShortcut7Key", "None", (void *)WKBD_WINDOW7
,
716 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
717 {"WindowShortcut8Key", "None", (void *)WKBD_WINDOW8
,
718 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
719 {"WindowShortcut9Key", "None", (void *)WKBD_WINDOW9
,
720 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
721 {"WindowShortcut10Key", "None", (void *)WKBD_WINDOW10
,
722 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
723 {"WindowRelaunchKey", "None", (void *)WKBD_RELAUNCH
,
724 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
725 {"ScreenSwitchKey", "None", (void *)WKBD_SWITCH_SCREEN
,
726 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
727 {"RunKey", "None", (void *)WKBD_RUN
,
728 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
730 #ifdef KEEP_XKB_LOCK_STATUS
731 {"ToggleKbdModeKey", "None", (void *)WKBD_TOGGLE
,
732 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
733 {"KbdModeLock", "NO", NULL
,
734 &wPreferences
.modelock
, getBool
, NULL
, NULL
, NULL
},
735 #endif /* KEEP_XKB_LOCK_STATUS */
737 {"NormalCursor", "(builtin, left_ptr)", (void *)WCUR_ROOT
,
738 NULL
, getCursor
, setCursor
, NULL
, NULL
},
739 {"ArrowCursor", "(builtin, top_left_arrow)", (void *)WCUR_ARROW
,
740 NULL
, getCursor
, setCursor
, NULL
, NULL
},
741 {"MoveCursor", "(builtin, fleur)", (void *)WCUR_MOVE
,
742 NULL
, getCursor
, setCursor
, NULL
, NULL
},
743 {"ResizeCursor", "(builtin, sizing)", (void *)WCUR_RESIZE
,
744 NULL
, getCursor
, setCursor
, NULL
, NULL
},
745 {"TopLeftResizeCursor", "(builtin, top_left_corner)", (void *)WCUR_TOPLEFTRESIZE
,
746 NULL
, getCursor
, setCursor
, NULL
, NULL
},
747 {"TopRightResizeCursor", "(builtin, top_right_corner)", (void *)WCUR_TOPRIGHTRESIZE
,
748 NULL
, getCursor
, setCursor
, NULL
, NULL
},
749 {"BottomLeftResizeCursor", "(builtin, bottom_left_corner)", (void *)WCUR_BOTTOMLEFTRESIZE
,
750 NULL
, getCursor
, setCursor
, NULL
, NULL
},
751 {"BottomRightResizeCursor", "(builtin, bottom_right_corner)", (void *)WCUR_BOTTOMRIGHTRESIZE
,
752 NULL
, getCursor
, setCursor
, NULL
, NULL
},
753 {"VerticalResizeCursor", "(builtin, sb_v_double_arrow)", (void *)WCUR_VERTICALRESIZE
,
754 NULL
, getCursor
, setCursor
, NULL
, NULL
},
755 {"HorizontalResizeCursor", "(builtin, sb_h_double_arrow)", (void *)WCUR_HORIZONRESIZE
,
756 NULL
, getCursor
, setCursor
, NULL
, NULL
},
757 {"WaitCursor", "(builtin, watch)", (void *)WCUR_WAIT
,
758 NULL
, getCursor
, setCursor
, NULL
, NULL
},
759 {"QuestionCursor", "(builtin, question_arrow)", (void *)WCUR_QUESTION
,
760 NULL
, getCursor
, setCursor
, NULL
, NULL
},
761 {"TextCursor", "(builtin, xterm)", (void *)WCUR_TEXT
,
762 NULL
, getCursor
, setCursor
, NULL
, NULL
},
763 {"SelectCursor", "(builtin, cross)", (void *)WCUR_SELECT
,
764 NULL
, getCursor
, setCursor
, NULL
, NULL
},
765 {"DialogHistoryLines", "500", NULL
,
766 &wPreferences
.history_lines
, getInt
, NULL
, NULL
, NULL
},
767 {"CycleActiveHeadOnly", "NO", NULL
,
768 &wPreferences
.cycle_active_head_only
, getBool
, NULL
, NULL
, NULL
},
769 {"CycleIgnoreMinimized", "NO", NULL
,
770 &wPreferences
.cycle_ignore_minimized
, getBool
, NULL
, NULL
, NULL
}
773 static void initDefaults(void)
776 WDefaultEntry
*entry
;
778 WMPLSetCaseSensitive(False
);
780 for (i
= 0; i
< wlengthof(optionList
); i
++) {
781 entry
= &optionList
[i
];
783 entry
->plkey
= WMCreatePLString(entry
->key
);
784 if (entry
->default_value
)
785 entry
->plvalue
= WMCreatePropListFromDescription(entry
->default_value
);
787 entry
->plvalue
= NULL
;
790 for (i
= 0; i
< wlengthof(staticOptionList
); i
++) {
791 entry
= &staticOptionList
[i
];
793 entry
->plkey
= WMCreatePLString(entry
->key
);
794 if (entry
->default_value
)
795 entry
->plvalue
= WMCreatePropListFromDescription(entry
->default_value
);
797 entry
->plvalue
= NULL
;
801 static WMPropList
*readGlobalDomain(const char *domainName
, Bool requireDictionary
)
803 WMPropList
*globalDict
= NULL
;
807 snprintf(path
, sizeof(path
), "%s/%s/%s", SYSCONFDIR
, GLOBAL_DEFAULTS_SUBDIR
, domainName
);
808 if (stat(path
, &stbuf
) >= 0) {
809 globalDict
= WMReadPropListFromFile(path
);
810 if (globalDict
&& requireDictionary
&& !WMIsPLDictionary(globalDict
)) {
811 wwarning(_("Domain %s (%s) of global defaults database is corrupted!"), domainName
, path
);
812 WMReleasePropList(globalDict
);
814 } else if (!globalDict
) {
815 wwarning(_("could not load domain %s from global defaults database"), domainName
);
822 #if defined(GLOBAL_PREAMBLE_MENU_FILE) || defined(GLOBAL_EPILOGUE_MENU_FILE)
823 static void prependMenu(WMPropList
* destarr
, WMPropList
* array
)
828 for (i
= 0; i
< WMGetPropListItemCount(array
); i
++) {
829 item
= WMGetFromPLArray(array
, i
);
831 WMInsertInPLArray(destarr
, i
+ 1, item
);
835 static void appendMenu(WMPropList
* destarr
, WMPropList
* array
)
840 for (i
= 0; i
< WMGetPropListItemCount(array
); i
++) {
841 item
= WMGetFromPLArray(array
, i
);
843 WMAddToPLArray(destarr
, item
);
848 void wDefaultsMergeGlobalMenus(WDDomain
* menuDomain
)
850 WMPropList
*menu
= menuDomain
->dictionary
;
853 if (!menu
|| !WMIsPLArray(menu
))
856 #ifdef GLOBAL_PREAMBLE_MENU_FILE
857 submenu
= WMReadPropListFromFile(SYSCONFDIR
"/" GLOBAL_DEFAULTS_SUBDIR
"/" GLOBAL_PREAMBLE_MENU_FILE
);
859 if (submenu
&& !WMIsPLArray(submenu
)) {
860 wwarning(_("invalid global menu file %s"), GLOBAL_PREAMBLE_MENU_FILE
);
861 WMReleasePropList(submenu
);
865 prependMenu(menu
, submenu
);
866 WMReleasePropList(submenu
);
870 #ifdef GLOBAL_EPILOGUE_MENU_FILE
871 submenu
= WMReadPropListFromFile(SYSCONFDIR
"/" GLOBAL_DEFAULTS_SUBDIR
"/" GLOBAL_EPILOGUE_MENU_FILE
);
873 if (submenu
&& !WMIsPLArray(submenu
)) {
874 wwarning(_("invalid global menu file %s"), GLOBAL_EPILOGUE_MENU_FILE
);
875 WMReleasePropList(submenu
);
879 appendMenu(menu
, submenu
);
880 WMReleasePropList(submenu
);
884 menuDomain
->dictionary
= menu
;
887 WDDomain
*wDefaultsInitDomain(const char *domain
, Bool requireDictionary
)
891 static int inited
= 0;
892 WMPropList
*shared_dict
= NULL
;
899 db
= wmalloc(sizeof(WDDomain
));
900 db
->domain_name
= domain
;
901 db
->path
= wdefaultspathfordomain(domain
);
903 if (stat(db
->path
, &stbuf
) >= 0) {
904 db
->dictionary
= WMReadPropListFromFile(db
->path
);
905 if (db
->dictionary
) {
906 if (requireDictionary
&& !WMIsPLDictionary(db
->dictionary
)) {
907 WMReleasePropList(db
->dictionary
);
908 db
->dictionary
= NULL
;
909 wwarning(_("Domain %s (%s) of defaults database is corrupted!"), domain
, db
->path
);
911 db
->timestamp
= stbuf
.st_mtime
;
913 wwarning(_("could not load domain %s from user defaults database"), domain
);
917 /* global system dictionary */
918 shared_dict
= readGlobalDomain(domain
, requireDictionary
);
920 if (shared_dict
&& db
->dictionary
&& WMIsPLDictionary(shared_dict
) &&
921 WMIsPLDictionary(db
->dictionary
)) {
922 WMMergePLDictionaries(shared_dict
, db
->dictionary
, True
);
923 WMReleasePropList(db
->dictionary
);
924 db
->dictionary
= shared_dict
;
925 if (stbuf
.st_mtime
> db
->timestamp
)
926 db
->timestamp
= stbuf
.st_mtime
;
927 } else if (!db
->dictionary
) {
928 db
->dictionary
= shared_dict
;
929 if (stbuf
.st_mtime
> db
->timestamp
)
930 db
->timestamp
= stbuf
.st_mtime
;
936 void wReadStaticDefaults(WMPropList
* dict
)
939 WDefaultEntry
*entry
;
943 for (i
= 0; i
< wlengthof(staticOptionList
); i
++) {
944 entry
= &staticOptionList
[i
];
947 plvalue
= WMGetFromPLDictionary(dict
, entry
->plkey
);
951 /* no default in the DB. Use builtin default */
953 plvalue
= entry
->plvalue
;
957 (*entry
->convert
) (NULL
, entry
, plvalue
, entry
->addr
, &tdata
);
959 (*entry
->update
) (NULL
, entry
, tdata
, entry
->extra_data
);
964 void wDefaultsCheckDomains(void* arg
)
968 WMPropList
*shared_dict
= NULL
;
972 /* Parameter not used, but tell the compiler that it is ok */
975 if (stat(w_global
.domain
.wmaker
->path
, &stbuf
) >= 0 && w_global
.domain
.wmaker
->timestamp
< stbuf
.st_mtime
) {
976 w_global
.domain
.wmaker
->timestamp
= stbuf
.st_mtime
;
978 /* Global dictionary */
979 shared_dict
= readGlobalDomain("WindowMaker", True
);
981 /* User dictionary */
982 dict
= WMReadPropListFromFile(w_global
.domain
.wmaker
->path
);
985 if (!WMIsPLDictionary(dict
)) {
986 WMReleasePropList(dict
);
988 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
989 "WindowMaker", w_global
.domain
.wmaker
->path
);
992 WMMergePLDictionaries(shared_dict
, dict
, True
);
993 WMReleasePropList(dict
);
998 for (i
= 0; i
< w_global
.screen_count
; i
++) {
999 scr
= wScreenWithNumber(i
);
1001 wReadDefaults(scr
, dict
);
1004 if (w_global
.domain
.wmaker
->dictionary
)
1005 WMReleasePropList(w_global
.domain
.wmaker
->dictionary
);
1007 w_global
.domain
.wmaker
->dictionary
= dict
;
1010 wwarning(_("could not load domain %s from user defaults database"), "WindowMaker");
1014 WMReleasePropList(shared_dict
);
1018 if (stat(w_global
.domain
.window_attr
->path
, &stbuf
) >= 0 && w_global
.domain
.window_attr
->timestamp
< stbuf
.st_mtime
) {
1019 /* global dictionary */
1020 shared_dict
= readGlobalDomain("WMWindowAttributes", True
);
1021 /* user dictionary */
1022 dict
= WMReadPropListFromFile(w_global
.domain
.window_attr
->path
);
1024 if (!WMIsPLDictionary(dict
)) {
1025 WMReleasePropList(dict
);
1027 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
1028 "WMWindowAttributes", w_global
.domain
.window_attr
->path
);
1031 WMMergePLDictionaries(shared_dict
, dict
, True
);
1032 WMReleasePropList(dict
);
1037 if (w_global
.domain
.window_attr
->dictionary
)
1038 WMReleasePropList(w_global
.domain
.window_attr
->dictionary
);
1040 w_global
.domain
.window_attr
->dictionary
= dict
;
1041 for (i
= 0; i
< w_global
.screen_count
; i
++) {
1042 scr
= wScreenWithNumber(i
);
1044 wDefaultUpdateIcons(scr
);
1046 /* Update the panel image if changed */
1047 /* Don't worry. If the image is the same these
1048 * functions will have no performance impact. */
1049 create_logo_image(scr
);
1054 wwarning(_("could not load domain %s from user defaults database"), "WMWindowAttributes");
1057 w_global
.domain
.window_attr
->timestamp
= stbuf
.st_mtime
;
1059 WMReleasePropList(shared_dict
);
1062 if (stat(w_global
.domain
.root_menu
->path
, &stbuf
) >= 0 && w_global
.domain
.root_menu
->timestamp
< stbuf
.st_mtime
) {
1063 dict
= WMReadPropListFromFile(w_global
.domain
.root_menu
->path
);
1065 if (!WMIsPLArray(dict
) && !WMIsPLString(dict
)) {
1066 WMReleasePropList(dict
);
1068 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
1069 "WMRootMenu", w_global
.domain
.root_menu
->path
);
1071 if (w_global
.domain
.root_menu
->dictionary
)
1072 WMReleasePropList(w_global
.domain
.root_menu
->dictionary
);
1074 w_global
.domain
.root_menu
->dictionary
= dict
;
1075 wDefaultsMergeGlobalMenus(w_global
.domain
.root_menu
);
1078 wwarning(_("could not load domain %s from user defaults database"), "WMRootMenu");
1080 w_global
.domain
.root_menu
->timestamp
= stbuf
.st_mtime
;
1082 #ifndef HAVE_INOTIFY
1084 WMAddTimerHandler(DEFAULTS_CHECK_INTERVAL
, wDefaultsCheckDomains
, arg
);
1088 void wReadDefaults(WScreen
* scr
, WMPropList
* new_dict
)
1090 WMPropList
*plvalue
, *old_value
;
1091 WDefaultEntry
*entry
;
1093 int update_workspace_back
= 0; /* kluge :/ */
1094 unsigned int needs_refresh
;
1096 WMPropList
*old_dict
= (w_global
.domain
.wmaker
->dictionary
!= new_dict
? w_global
.domain
.wmaker
->dictionary
: NULL
);
1100 for (i
= 0; i
< wlengthof(optionList
); i
++) {
1101 entry
= &optionList
[i
];
1104 plvalue
= WMGetFromPLDictionary(new_dict
, entry
->plkey
);
1111 old_value
= WMGetFromPLDictionary(old_dict
, entry
->plkey
);
1113 if (!plvalue
&& !old_value
) {
1114 /* no default in the DB. Use builtin default */
1115 plvalue
= entry
->plvalue
;
1116 if (plvalue
&& new_dict
)
1117 WMPutInPLDictionary(new_dict
, entry
->plkey
, plvalue
);
1119 } else if (!plvalue
) {
1120 /* value was deleted from DB. Keep current value */
1122 } else if (!old_value
) {
1123 /* set value for the 1st time */
1124 } else if (!WMIsPropListEqualTo(plvalue
, old_value
)) {
1125 /* value has changed */
1127 if (strcmp(entry
->key
, "WorkspaceBack") == 0
1128 && update_workspace_back
&& scr
->flags
.backimage_helper_launched
) {
1130 /* value was not changed since last time */
1137 if ((*entry
->convert
) (scr
, entry
, plvalue
, entry
->addr
, &tdata
)) {
1139 * If the WorkspaceSpecificBack data has been changed
1140 * so that the helper will be launched now, we must be
1141 * sure to send the default background texture config
1144 if (strcmp(entry
->key
, "WorkspaceSpecificBack") == 0 &&
1145 !scr
->flags
.backimage_helper_launched
)
1146 update_workspace_back
= 1;
1149 needs_refresh
|= (*entry
->update
) (scr
, entry
, tdata
, entry
->extra_data
);
1155 if (needs_refresh
!= 0 && !scr
->flags
.startup
) {
1159 if (needs_refresh
& REFRESH_MENU_TITLE_TEXTURE
)
1160 foo
|= WTextureSettings
;
1161 if (needs_refresh
& REFRESH_MENU_TITLE_FONT
)
1162 foo
|= WFontSettings
;
1163 if (needs_refresh
& REFRESH_MENU_TITLE_COLOR
)
1164 foo
|= WColorSettings
;
1166 WMPostNotificationName(WNMenuTitleAppearanceSettingsChanged
, NULL
,
1167 (void *)(uintptr_t) foo
);
1170 if (needs_refresh
& REFRESH_MENU_TEXTURE
)
1171 foo
|= WTextureSettings
;
1172 if (needs_refresh
& REFRESH_MENU_FONT
)
1173 foo
|= WFontSettings
;
1174 if (needs_refresh
& REFRESH_MENU_COLOR
)
1175 foo
|= WColorSettings
;
1177 WMPostNotificationName(WNMenuAppearanceSettingsChanged
, NULL
, (void *)(uintptr_t) foo
);
1180 if (needs_refresh
& REFRESH_WINDOW_FONT
)
1181 foo
|= WFontSettings
;
1182 if (needs_refresh
& REFRESH_WINDOW_TEXTURES
)
1183 foo
|= WTextureSettings
;
1184 if (needs_refresh
& REFRESH_WINDOW_TITLE_COLOR
)
1185 foo
|= WColorSettings
;
1187 WMPostNotificationName(WNWindowAppearanceSettingsChanged
, NULL
, (void *)(uintptr_t) foo
);
1189 if (!(needs_refresh
& REFRESH_ICON_TILE
)) {
1191 if (needs_refresh
& REFRESH_ICON_FONT
)
1192 foo
|= WFontSettings
;
1193 if (needs_refresh
& REFRESH_ICON_TITLE_COLOR
)
1194 foo
|= WTextureSettings
;
1195 if (needs_refresh
& REFRESH_ICON_TITLE_BACK
)
1196 foo
|= WTextureSettings
;
1198 WMPostNotificationName(WNIconAppearanceSettingsChanged
, NULL
,
1199 (void *)(uintptr_t) foo
);
1201 if (needs_refresh
& REFRESH_ICON_TILE
)
1202 WMPostNotificationName(WNIconTileSettingsChanged
, NULL
, NULL
);
1204 if (needs_refresh
& REFRESH_WORKSPACE_MENU
) {
1205 if (w_global
.workspace
.menu
)
1206 wWorkspaceMenuUpdate(w_global
.workspace
.menu
);
1207 if (w_global
.clip
.ws_menu
)
1208 wWorkspaceMenuUpdate(w_global
.clip
.ws_menu
);
1209 if (w_global
.workspace
.submenu
)
1210 w_global
.workspace
.submenu
->flags
.realized
= 0;
1211 if (w_global
.clip
.submenu
)
1212 w_global
.clip
.submenu
->flags
.realized
= 0;
1217 void wDefaultUpdateIcons(WScreen
*scr
)
1219 WAppIcon
*aicon
= w_global
.app_icon_list
;
1221 WWindow
*wwin
= scr
->focused_window
;
1224 /* Get the application icon, default included */
1225 wIconChangeImageFile(aicon
->icon
, NULL
);
1226 wAppIconPaint(aicon
);
1227 aicon
= aicon
->next
;
1230 if (!wPreferences
.flags
.noclip
|| wPreferences
.flags
.clip_merged_in_dock
)
1233 for (dc
= scr
->drawers
; dc
!= NULL
; dc
= dc
->next
)
1234 wDrawerIconPaint(dc
->adrawer
->icon_array
[0]);
1237 if (wwin
->icon
&& wwin
->flags
.miniaturized
)
1238 wIconChangeImageFile(wwin
->icon
, NULL
);
1243 /* --------------------------- Local ----------------------- */
1245 #define GET_STRING_OR_DEFAULT(x, var) if (!WMIsPLString(value)) { \
1246 wwarning(_("Wrong option format for key \"%s\". Should be %s."), \
1248 wwarning(_("using default \"%s\" instead"), entry->default_value); \
1249 var = entry->default_value;\
1250 } else var = WMGetFromPLString(value)\
1253 static int string2index(WMPropList *key, WMPropList *val, const char *def, WOptionEnumeration * values)
1256 WOptionEnumeration
*v
;
1257 char buffer
[TOTAL_VALUES_LENGTH
];
1259 if (WMIsPLString(val
) && (str
= WMGetFromPLString(val
))) {
1260 for (v
= values
; v
->string
!= NULL
; v
++) {
1261 if (strcasecmp(v
->string
, str
) == 0)
1267 for (v
= values
; v
->string
!= NULL
; v
++) {
1270 strcat(buffer
, ", ");
1271 snprintf(buffer
+strlen(buffer
),
1272 sizeof(buffer
)-strlen(buffer
)-1, "\"%s\"", v
->string
);
1275 wwarning(_("wrong option value for key \"%s\"; got \"%s\", should be one of %s."),
1276 WMGetFromPLString(key
),
1277 WMIsPLString(val
) ? WMGetFromPLString(val
) : "(unknown)",
1281 return string2index(key
, val
, NULL
, values
);
1288 * value - is the value in the defaults DB
1289 * addr - is the address to store the data
1290 * ret - is the address to store a pointer to a temporary buffer. ret
1291 * must not be freed and is used by the set functions
1293 static int getBool(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1297 int second_pass
= 0;
1299 /* Parameter not used, but tell the compiler that it is ok */
1302 GET_STRING_OR_DEFAULT("Boolean", val
);
1305 if ((val
[1] == '\0' && (val
[0] == 'y' || val
[0] == 'Y'))
1306 || strcasecmp(val
, "YES") == 0) {
1309 } else if ((val
[1] == '\0' && (val
[0] == 'n' || val
[0] == 'N'))
1310 || strcasecmp(val
, "NO") == 0) {
1314 if (sscanf(val
, "%i", &i
) == 1) {
1320 wwarning(_("can't convert \"%s\" to boolean for key \"%s\""), val
, entry
->key
);
1321 if (second_pass
== 0) {
1322 val
= WMGetFromPLString(entry
->plvalue
);
1324 wwarning(_("using default \"%s\" instead"), val
);
1334 *(char *)addr
= data
;
1339 static int getInt(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1344 /* Parameter not used, but tell the compiler that it is ok */
1347 GET_STRING_OR_DEFAULT("Integer", val
);
1349 if (sscanf(val
, "%i", &data
) != 1) {
1350 wwarning(_("can't convert \"%s\" to integer for key \"%s\""), val
, entry
->key
);
1351 val
= WMGetFromPLString(entry
->plvalue
);
1352 wwarning(_("using default \"%s\" instead"), val
);
1353 if (sscanf(val
, "%i", &data
) != 1) {
1361 *(int *)addr
= data
;
1366 static int getCoord(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1369 char *val_x
, *val_y
;
1370 int nelem
, changed
= 0;
1371 WMPropList
*elem_x
, *elem_y
;
1374 if (!WMIsPLArray(value
)) {
1375 wwarning(_("Wrong option format for key \"%s\". Should be %s."), entry
->key
, "Coordinate");
1377 value
= entry
->plvalue
;
1379 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1385 nelem
= WMGetPropListItemCount(value
);
1387 wwarning(_("Incorrect number of elements in array for key \"%s\"."), entry
->key
);
1389 value
= entry
->plvalue
;
1391 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1397 elem_x
= WMGetFromPLArray(value
, 0);
1398 elem_y
= WMGetFromPLArray(value
, 1);
1400 if (!elem_x
|| !elem_y
|| !WMIsPLString(elem_x
) || !WMIsPLString(elem_y
)) {
1401 wwarning(_("Wrong value for key \"%s\". Should be Coordinate."), entry
->key
);
1403 value
= entry
->plvalue
;
1405 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1411 val_x
= WMGetFromPLString(elem_x
);
1412 val_y
= WMGetFromPLString(elem_y
);
1414 if (sscanf(val_x
, "%i", &data
.x
) != 1 || sscanf(val_y
, "%i", &data
.y
) != 1) {
1415 wwarning(_("can't convert array to integers for \"%s\"."), entry
->key
);
1417 value
= entry
->plvalue
;
1419 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1427 else if (data
.x
> scr
->scr_width
/ 3)
1428 data
.x
= scr
->scr_width
/ 3;
1431 else if (data
.y
> scr
->scr_height
/ 3)
1432 data
.y
= scr
->scr_height
/ 3;
1437 *(WCoord
*) addr
= data
;
1442 static int getPropList(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1444 /* Parameter not used, but tell the compiler that it is ok */
1449 WMRetainPropList(value
);
1456 static int getPathList(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1464 /* Parameter not used, but tell the compiler that it is ok */
1469 if (!WMIsPLArray(value
)) {
1470 wwarning(_("Wrong option format for key \"%s\". Should be %s."), entry
->key
, "an array of paths");
1472 value
= entry
->plvalue
;
1474 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1481 count
= WMGetPropListItemCount(value
);
1484 value
= entry
->plvalue
;
1486 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1493 for (i
= 0; i
< count
; i
++) {
1494 d
= WMGetFromPLArray(value
, i
);
1495 if (!d
|| !WMIsPLString(d
)) {
1499 len
+= strlen(WMGetFromPLString(d
)) + 1;
1502 ptr
= data
= wmalloc(len
+ 1);
1504 for (i
= 0; i
< count
; i
++) {
1505 d
= WMGetFromPLArray(value
, i
);
1506 if (!d
|| !WMIsPLString(d
)) {
1509 strcpy(ptr
, WMGetFromPLString(d
));
1510 ptr
+= strlen(WMGetFromPLString(d
));
1517 if (*(char **)addr
!= NULL
) {
1518 wfree(*(char **)addr
);
1520 *(char **)addr
= data
;
1525 static int getEnum(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1527 static signed char data
;
1529 /* Parameter not used, but tell the compiler that it is ok */
1532 data
= string2index(entry
->plkey
, value
, entry
->default_value
, (WOptionEnumeration
*) entry
->extra_data
);
1539 *(signed char *)addr
= data
;
1546 * (hgradient <color> <color>)
1547 * (vgradient <color> <color>)
1548 * (dgradient <color> <color>)
1549 * (mhgradient <color> <color> ...)
1550 * (mvgradient <color> <color> ...)
1551 * (mdgradient <color> <color> ...)
1552 * (igradient <color1> <color1> <thickness1> <color2> <color2> <thickness2>)
1553 * (tpixmap <file> <color>)
1554 * (spixmap <file> <color>)
1555 * (cpixmap <file> <color>)
1556 * (thgradient <file> <opaqueness> <color> <color>)
1557 * (tvgradient <file> <opaqueness> <color> <color>)
1558 * (tdgradient <file> <opaqueness> <color> <color>)
1559 * (function <lib> <function> ...)
1562 static WTexture
*parse_texture(WScreen
* scr
, WMPropList
* pl
)
1567 WTexture
*texture
= NULL
;
1569 nelem
= WMGetPropListItemCount(pl
);
1573 elem
= WMGetFromPLArray(pl
, 0);
1574 if (!elem
|| !WMIsPLString(elem
))
1576 val
= WMGetFromPLString(elem
);
1578 if (strcasecmp(val
, "solid") == 0) {
1586 elem
= WMGetFromPLArray(pl
, 1);
1587 if (!elem
|| !WMIsPLString(elem
))
1589 val
= WMGetFromPLString(elem
);
1591 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &color
)) {
1592 wwarning(_("\"%s\" is not a valid color name"), val
);
1596 texture
= (WTexture
*) wTextureMakeSolid(scr
, &color
);
1597 } else if (strcasecmp(val
, "dgradient") == 0
1598 || strcasecmp(val
, "vgradient") == 0 || strcasecmp(val
, "hgradient") == 0) {
1599 RColor color1
, color2
;
1604 wwarning(_("bad number of arguments in gradient specification"));
1608 if (val
[0] == 'd' || val
[0] == 'D')
1609 type
= WTEX_DGRADIENT
;
1610 else if (val
[0] == 'h' || val
[0] == 'H')
1611 type
= WTEX_HGRADIENT
;
1613 type
= WTEX_VGRADIENT
;
1615 /* get from color */
1616 elem
= WMGetFromPLArray(pl
, 1);
1617 if (!elem
|| !WMIsPLString(elem
))
1619 val
= WMGetFromPLString(elem
);
1621 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1622 wwarning(_("\"%s\" is not a valid color name"), val
);
1626 color1
.red
= xcolor
.red
>> 8;
1627 color1
.green
= xcolor
.green
>> 8;
1628 color1
.blue
= xcolor
.blue
>> 8;
1631 elem
= WMGetFromPLArray(pl
, 2);
1632 if (!elem
|| !WMIsPLString(elem
)) {
1635 val
= WMGetFromPLString(elem
);
1637 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1638 wwarning(_("\"%s\" is not a valid color name"), val
);
1642 color2
.red
= xcolor
.red
>> 8;
1643 color2
.green
= xcolor
.green
>> 8;
1644 color2
.blue
= xcolor
.blue
>> 8;
1646 texture
= (WTexture
*) wTextureMakeGradient(scr
, type
, &color1
, &color2
);
1648 } else if (strcasecmp(val
, "igradient") == 0) {
1649 RColor colors1
[2], colors2
[2];
1655 wwarning(_("bad number of arguments in gradient specification"));
1659 /* get from color */
1660 for (i
= 0; i
< 2; i
++) {
1661 elem
= WMGetFromPLArray(pl
, 1 + i
);
1662 if (!elem
|| !WMIsPLString(elem
))
1664 val
= WMGetFromPLString(elem
);
1666 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1667 wwarning(_("\"%s\" is not a valid color name"), val
);
1670 colors1
[i
].alpha
= 255;
1671 colors1
[i
].red
= xcolor
.red
>> 8;
1672 colors1
[i
].green
= xcolor
.green
>> 8;
1673 colors1
[i
].blue
= xcolor
.blue
>> 8;
1675 elem
= WMGetFromPLArray(pl
, 3);
1676 if (!elem
|| !WMIsPLString(elem
))
1678 val
= WMGetFromPLString(elem
);
1681 /* get from color */
1682 for (i
= 0; i
< 2; i
++) {
1683 elem
= WMGetFromPLArray(pl
, 4 + i
);
1684 if (!elem
|| !WMIsPLString(elem
))
1686 val
= WMGetFromPLString(elem
);
1688 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1689 wwarning(_("\"%s\" is not a valid color name"), val
);
1692 colors2
[i
].alpha
= 255;
1693 colors2
[i
].red
= xcolor
.red
>> 8;
1694 colors2
[i
].green
= xcolor
.green
>> 8;
1695 colors2
[i
].blue
= xcolor
.blue
>> 8;
1697 elem
= WMGetFromPLArray(pl
, 6);
1698 if (!elem
|| !WMIsPLString(elem
))
1700 val
= WMGetFromPLString(elem
);
1703 texture
= (WTexture
*) wTextureMakeIGradient(scr
, th1
, colors1
, th2
, colors2
);
1705 } else if (strcasecmp(val
, "mhgradient") == 0
1706 || strcasecmp(val
, "mvgradient") == 0 || strcasecmp(val
, "mdgradient") == 0) {
1713 wwarning(_("too few arguments in multicolor gradient specification"));
1717 if (val
[1] == 'h' || val
[1] == 'H')
1718 type
= WTEX_MHGRADIENT
;
1719 else if (val
[1] == 'v' || val
[1] == 'V')
1720 type
= WTEX_MVGRADIENT
;
1722 type
= WTEX_MDGRADIENT
;
1726 colors
= wmalloc(sizeof(RColor
*) * (count
+ 1));
1728 for (i
= 0; i
< count
; i
++) {
1729 elem
= WMGetFromPLArray(pl
, i
+ 1);
1730 if (!elem
|| !WMIsPLString(elem
)) {
1731 for (--i
; i
>= 0; --i
) {
1737 val
= WMGetFromPLString(elem
);
1739 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &color
)) {
1740 wwarning(_("\"%s\" is not a valid color name"), val
);
1741 for (--i
; i
>= 0; --i
) {
1747 colors
[i
] = wmalloc(sizeof(RColor
));
1748 colors
[i
]->red
= color
.red
>> 8;
1749 colors
[i
]->green
= color
.green
>> 8;
1750 colors
[i
]->blue
= color
.blue
>> 8;
1755 texture
= (WTexture
*) wTextureMakeMGradient(scr
, type
, colors
);
1756 } else if (strcasecmp(val
, "spixmap") == 0 ||
1757 strcasecmp(val
, "cpixmap") == 0 || strcasecmp(val
, "tpixmap") == 0) {
1764 if (val
[0] == 's' || val
[0] == 'S')
1766 else if (val
[0] == 'c' || val
[0] == 'C')
1772 elem
= WMGetFromPLArray(pl
, 2);
1773 if (!elem
|| !WMIsPLString(elem
)) {
1776 val
= WMGetFromPLString(elem
);
1778 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &color
)) {
1779 wwarning(_("\"%s\" is not a valid color name"), val
);
1784 elem
= WMGetFromPLArray(pl
, 1);
1785 if (!elem
|| !WMIsPLString(elem
))
1787 val
= WMGetFromPLString(elem
);
1789 texture
= (WTexture
*) wTextureMakePixmap(scr
, type
, val
, &color
);
1790 } else if (strcasecmp(val
, "thgradient") == 0
1791 || strcasecmp(val
, "tvgradient") == 0 || strcasecmp(val
, "tdgradient") == 0) {
1792 RColor color1
, color2
;
1797 if (val
[1] == 'h' || val
[1] == 'H')
1798 style
= WTEX_THGRADIENT
;
1799 else if (val
[1] == 'v' || val
[1] == 'V')
1800 style
= WTEX_TVGRADIENT
;
1802 style
= WTEX_TDGRADIENT
;
1805 wwarning(_("bad number of arguments in textured gradient specification"));
1809 /* get from color */
1810 elem
= WMGetFromPLArray(pl
, 3);
1811 if (!elem
|| !WMIsPLString(elem
))
1813 val
= WMGetFromPLString(elem
);
1815 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1816 wwarning(_("\"%s\" is not a valid color name"), val
);
1820 color1
.red
= xcolor
.red
>> 8;
1821 color1
.green
= xcolor
.green
>> 8;
1822 color1
.blue
= xcolor
.blue
>> 8;
1825 elem
= WMGetFromPLArray(pl
, 4);
1826 if (!elem
|| !WMIsPLString(elem
)) {
1829 val
= WMGetFromPLString(elem
);
1831 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1832 wwarning(_("\"%s\" is not a valid color name"), val
);
1836 color2
.red
= xcolor
.red
>> 8;
1837 color2
.green
= xcolor
.green
>> 8;
1838 color2
.blue
= xcolor
.blue
>> 8;
1841 elem
= WMGetFromPLArray(pl
, 2);
1842 if (!elem
|| !WMIsPLString(elem
))
1845 val
= WMGetFromPLString(elem
);
1847 if (!val
|| (opacity
= atoi(val
)) < 0 || opacity
> 255) {
1848 wwarning(_("bad opacity value for tgradient texture \"%s\". Should be [0..255]"), val
);
1853 elem
= WMGetFromPLArray(pl
, 1);
1854 if (!elem
|| !WMIsPLString(elem
))
1856 val
= WMGetFromPLString(elem
);
1858 texture
= (WTexture
*) wTextureMakeTGradient(scr
, style
, &color1
, &color2
, val
, opacity
);
1859 } else if (strcasecmp(val
, "function") == 0) {
1860 /* Leave this in to handle the unlikely case of
1861 * someone actually having function textures configured */
1862 wwarning("function texture support has been removed");
1865 wwarning(_("invalid texture type %s"), val
);
1871 static int getTexture(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1873 static WTexture
*texture
;
1877 if (!WMIsPLArray(value
)) {
1878 wwarning(_("Wrong option format for key \"%s\". Should be %s."), entry
->key
, "Texture");
1880 value
= entry
->plvalue
;
1882 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1888 if (strcmp(entry
->key
, "WidgetColor") == 0 && !changed
) {
1891 pl
= WMGetFromPLArray(value
, 0);
1892 if (!pl
|| !WMIsPLString(pl
) || !WMGetFromPLString(pl
)
1893 || strcasecmp(WMGetFromPLString(pl
), "solid") != 0) {
1894 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1895 entry
->key
, "Solid Texture");
1897 value
= entry
->plvalue
;
1899 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1904 texture
= parse_texture(scr
, value
);
1907 wwarning(_("Error in texture specification for key \"%s\""), entry
->key
);
1909 value
= entry
->plvalue
;
1911 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1921 *(WTexture
**) addr
= texture
;
1926 static int getWSBackground(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1933 /* Parameter not used, but tell the compiler that it is ok */
1938 if (!WMIsPLArray(value
)) {
1939 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1940 "WorkspaceBack", "Texture or None");
1942 value
= entry
->plvalue
;
1944 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1950 /* only do basic error checking and verify for None texture */
1952 nelem
= WMGetPropListItemCount(value
);
1954 elem
= WMGetFromPLArray(value
, 0);
1955 if (!elem
|| !WMIsPLString(elem
)) {
1956 wwarning(_("Wrong type for workspace background. Should be a texture type."));
1958 value
= entry
->plvalue
;
1960 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1965 val
= WMGetFromPLString(elem
);
1967 if (strcasecmp(val
, "None") == 0)
1970 *ret
= WMRetainPropList(value
);
1976 getWSSpecificBackground(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1982 /* Parameter not used, but tell the compiler that it is ok */
1987 if (!WMIsPLArray(value
)) {
1988 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1989 "WorkspaceSpecificBack", "an array of textures");
1991 value
= entry
->plvalue
;
1993 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1999 /* only do basic error checking and verify for None texture */
2001 nelem
= WMGetPropListItemCount(value
);
2004 elem
= WMGetFromPLArray(value
, nelem
);
2005 if (!elem
|| !WMIsPLArray(elem
)) {
2006 wwarning(_("Wrong type for background of workspace %i. Should be a texture."),
2012 *ret
= WMRetainPropList(value
);
2016 * Kluge to force wmsetbg helper to set the default background.
2017 * If the WorkspaceSpecificBack is changed once wmaker has started,
2018 * the WorkspaceBack won't be sent to the helper, unless the user
2019 * changes it's value too. So, we must force this by removing the
2020 * value from the defaults DB.
2022 if (!scr
->flags
.backimage_helper_launched
&& !scr
->flags
.startup
) {
2023 WMPropList
*key
= WMCreatePLString("WorkspaceBack");
2025 WMRemoveFromPLDictionary(w_global
.domain
.wmaker
->dictionary
, key
);
2027 WMReleasePropList(key
);
2033 static int getFont(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
2035 static WMFont
*font
;
2040 GET_STRING_OR_DEFAULT("Font", val
);
2042 font
= WMCreateFont(scr
->wmscreen
, val
);
2044 font
= WMCreateFont(scr
->wmscreen
, "fixed");
2047 wfatal(_("could not load any usable font!!!"));
2054 /* can't assign font value outside update function */
2055 wassertrv(addr
== NULL
, True
);
2060 static int getColor(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
2062 static XColor color
;
2064 int second_pass
= 0;
2068 GET_STRING_OR_DEFAULT("Color", val
);
2071 if (!wGetColor(scr
, val
, &color
)) {
2072 wwarning(_("could not get color for key \"%s\""), entry
->key
);
2073 if (second_pass
== 0) {
2074 val
= WMGetFromPLString(entry
->plvalue
);
2076 wwarning(_("using default \"%s\" instead"), val
);
2085 assert(addr
== NULL
);
2088 *(unsigned long*)addr = pixel;
2094 static int getKeybind(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
2096 static WShortKey shortcut
;
2100 char buf
[MAX_SHORTCUT_LENGTH
], *b
;
2102 /* Parameter not used, but tell the compiler that it is ok */
2106 GET_STRING_OR_DEFAULT("Key spec", val
);
2108 if (!val
|| strcasecmp(val
, "NONE") == 0) {
2109 shortcut
.keycode
= 0;
2110 shortcut
.modifier
= 0;
2116 wstrlcpy(buf
, val
, MAX_SHORTCUT_LENGTH
);
2121 shortcut
.modifier
= 0;
2122 while ((k
= strchr(b
, '+')) != NULL
) {
2126 mod
= wXModifierFromKey(b
);
2128 wwarning(_("%s: invalid key modifier \"%s\""), entry
->key
, b
);
2131 shortcut
.modifier
|= mod
;
2137 ksym
= XStringToKeysym(b
);
2139 if (ksym
== NoSymbol
) {
2140 wwarning(_("%s:invalid kbd shortcut specification \"%s\""), entry
->key
, val
);
2144 shortcut
.keycode
= XKeysymToKeycode(dpy
, ksym
);
2145 if (shortcut
.keycode
== 0) {
2146 wwarning(_("%s:invalid key in shortcut \"%s\""), entry
->key
, val
);
2156 static int getModMask(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
2161 /* Parameter not used, but tell the compiler that it is ok */
2164 GET_STRING_OR_DEFAULT("Modifier Key", str
);
2169 mask
= wXModifierFromKey(str
);
2171 wwarning(_("%s: modifier key %s is not valid"), entry
->key
, str
);
2177 *(int *)addr
= mask
;
2185 # include <X11/cursorfont.h>
2191 #define CURSOR_ID_NONE (XC_num_glyphs)
2193 static const WCursorLookup cursor_table
[] = {
2194 {"X_cursor", XC_X_cursor
},
2195 {"arrow", XC_arrow
},
2196 {"based_arrow_down", XC_based_arrow_down
},
2197 {"based_arrow_up", XC_based_arrow_up
},
2199 {"bogosity", XC_bogosity
},
2200 {"bottom_left_corner", XC_bottom_left_corner
},
2201 {"bottom_right_corner", XC_bottom_right_corner
},
2202 {"bottom_side", XC_bottom_side
},
2203 {"bottom_tee", XC_bottom_tee
},
2204 {"box_spiral", XC_box_spiral
},
2205 {"center_ptr", XC_center_ptr
},
2206 {"circle", XC_circle
},
2207 {"clock", XC_clock
},
2208 {"coffee_mug", XC_coffee_mug
},
2209 {"cross", XC_cross
},
2210 {"cross_reverse", XC_cross_reverse
},
2211 {"crosshair", XC_crosshair
},
2212 {"diamond_cross", XC_diamond_cross
},
2214 {"dotbox", XC_dotbox
},
2215 {"double_arrow", XC_double_arrow
},
2216 {"draft_large", XC_draft_large
},
2217 {"draft_small", XC_draft_small
},
2218 {"draped_box", XC_draped_box
},
2219 {"exchange", XC_exchange
},
2220 {"fleur", XC_fleur
},
2221 {"gobbler", XC_gobbler
},
2222 {"gumby", XC_gumby
},
2223 {"hand1", XC_hand1
},
2224 {"hand2", XC_hand2
},
2225 {"heart", XC_heart
},
2227 {"iron_cross", XC_iron_cross
},
2228 {"left_ptr", XC_left_ptr
},
2229 {"left_side", XC_left_side
},
2230 {"left_tee", XC_left_tee
},
2231 {"leftbutton", XC_leftbutton
},
2232 {"ll_angle", XC_ll_angle
},
2233 {"lr_angle", XC_lr_angle
},
2235 {"middlebutton", XC_middlebutton
},
2236 {"mouse", XC_mouse
},
2237 {"pencil", XC_pencil
},
2238 {"pirate", XC_pirate
},
2240 {"question_arrow", XC_question_arrow
},
2241 {"right_ptr", XC_right_ptr
},
2242 {"right_side", XC_right_side
},
2243 {"right_tee", XC_right_tee
},
2244 {"rightbutton", XC_rightbutton
},
2245 {"rtl_logo", XC_rtl_logo
},
2246 {"sailboat", XC_sailboat
},
2247 {"sb_down_arrow", XC_sb_down_arrow
},
2248 {"sb_h_double_arrow", XC_sb_h_double_arrow
},
2249 {"sb_left_arrow", XC_sb_left_arrow
},
2250 {"sb_right_arrow", XC_sb_right_arrow
},
2251 {"sb_up_arrow", XC_sb_up_arrow
},
2252 {"sb_v_double_arrow", XC_sb_v_double_arrow
},
2253 {"shuttle", XC_shuttle
},
2254 {"sizing", XC_sizing
},
2255 {"spider", XC_spider
},
2256 {"spraycan", XC_spraycan
},
2258 {"target", XC_target
},
2259 {"tcross", XC_tcross
},
2260 {"top_left_arrow", XC_top_left_arrow
},
2261 {"top_left_corner", XC_top_left_corner
},
2262 {"top_right_corner", XC_top_right_corner
},
2263 {"top_side", XC_top_side
},
2264 {"top_tee", XC_top_tee
},
2266 {"ul_angle", XC_ul_angle
},
2267 {"umbrella", XC_umbrella
},
2268 {"ur_angle", XC_ur_angle
},
2269 {"watch", XC_watch
},
2270 {"xterm", XC_xterm
},
2271 {NULL
, CURSOR_ID_NONE
}
2274 static void check_bitmap_status(int status
, const char *filename
, Pixmap bitmap
)
2277 case BitmapOpenFailed
:
2278 wwarning(_("failed to open bitmap file \"%s\""), filename
);
2280 case BitmapFileInvalid
:
2281 wwarning(_("\"%s\" is not a valid bitmap file"), filename
);
2283 case BitmapNoMemory
:
2284 wwarning(_("out of memory reading bitmap file \"%s\""), filename
);
2287 XFreePixmap(dpy
, bitmap
);
2294 * (builtin, <cursor_name>)
2295 * (bitmap, <cursor_bitmap>, <cursor_mask>)
2297 static int parse_cursor(WScreen
* scr
, WMPropList
* pl
, Cursor
* cursor
)
2304 nelem
= WMGetPropListItemCount(pl
);
2308 elem
= WMGetFromPLArray(pl
, 0);
2309 if (!elem
|| !WMIsPLString(elem
)) {
2312 val
= WMGetFromPLString(elem
);
2314 if (strcasecmp(val
, "none") == 0) {
2317 } else if (strcasecmp(val
, "builtin") == 0) {
2319 int cursor_id
= CURSOR_ID_NONE
;
2322 wwarning(_("bad number of arguments in cursor specification"));
2325 elem
= WMGetFromPLArray(pl
, 1);
2326 if (!elem
|| !WMIsPLString(elem
)) {
2329 val
= WMGetFromPLString(elem
);
2331 for (i
= 0; cursor_table
[i
].name
!= NULL
; i
++) {
2332 if (strcasecmp(val
, cursor_table
[i
].name
) == 0) {
2333 cursor_id
= cursor_table
[i
].id
;
2337 if (CURSOR_ID_NONE
== cursor_id
) {
2338 wwarning(_("unknown builtin cursor name \"%s\""), val
);
2340 *cursor
= XCreateFontCursor(dpy
, cursor_id
);
2343 } else if (strcasecmp(val
, "bitmap") == 0) {
2355 wwarning(_("bad number of arguments in cursor specification"));
2358 elem
= WMGetFromPLArray(pl
, 1);
2359 if (!elem
|| !WMIsPLString(elem
)) {
2362 val
= WMGetFromPLString(elem
);
2363 bitmap_name
= FindImage(wPreferences
.pixmap_path
, val
);
2365 wwarning(_("could not find cursor bitmap file \"%s\""), val
);
2368 elem
= WMGetFromPLArray(pl
, 2);
2369 if (!elem
|| !WMIsPLString(elem
)) {
2373 val
= WMGetFromPLString(elem
);
2374 mask_name
= FindImage(wPreferences
.pixmap_path
, val
);
2377 wwarning(_("could not find cursor bitmap file \"%s\""), val
);
2380 mask_status
= XReadBitmapFile(dpy
, scr
->w_win
, mask_name
, &w
, &h
, &mask
, &x
, &y
);
2381 bitmap_status
= XReadBitmapFile(dpy
, scr
->w_win
, bitmap_name
, &w
, &h
, &bitmap
, &x
, &y
);
2382 if ((BitmapSuccess
== bitmap_status
) && (BitmapSuccess
== mask_status
)) {
2383 fg
.pixel
= scr
->black_pixel
;
2384 bg
.pixel
= scr
->white_pixel
;
2385 XQueryColor(dpy
, scr
->w_colormap
, &fg
);
2386 XQueryColor(dpy
, scr
->w_colormap
, &bg
);
2387 *cursor
= XCreatePixmapCursor(dpy
, bitmap
, mask
, &fg
, &bg
, x
, y
);
2390 check_bitmap_status(bitmap_status
, bitmap_name
, bitmap
);
2391 check_bitmap_status(mask_status
, mask_name
, mask
);
2398 static int getCursor(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
2400 static Cursor cursor
;
2405 if (!WMIsPLArray(value
)) {
2406 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
2407 entry
->key
, "cursor specification");
2409 value
= entry
->plvalue
;
2411 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
2416 status
= parse_cursor(scr
, value
, &cursor
);
2418 wwarning(_("Error in cursor specification for key \"%s\""), entry
->key
);
2420 value
= entry
->plvalue
;
2422 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
2431 *(Cursor
*) addr
= cursor
;
2436 #undef CURSOR_ID_NONE
2438 /* ---------------- value setting functions --------------- */
2439 static int setJustify(WScreen
* scr
, WDefaultEntry
* entry
, void *tdata
, void *extra_data
)
2441 /* Parameter not used, but tell the compiler that it is ok */
2447 return REFRESH_WINDOW_TITLE_COLOR
;
2450 static int setClearance(WScreen
* scr
, WDefaultEntry
* entry
, void *bar
, void *foo
)
2452 /* Parameter not used, but tell the compiler that it is ok */
2458 return REFRESH_WINDOW_FONT
| REFRESH_BUTTON_IMAGES
| REFRESH_MENU_TITLE_FONT
| REFRESH_MENU_FONT
;
2461 static int setIfDockPresent(WScreen
* scr
, WDefaultEntry
* entry
, void *tdata
, void *extra_data
)
2464 long which
= (long) extra_data
;
2466 /* Parameter not used, but tell the compiler that it is ok */
2472 wPreferences
.flags
.nodock
= wPreferences
.flags
.nodock
|| *flag
;
2473 // Drawers require the dock
2474 wPreferences
.flags
.nodrawer
= wPreferences
.flags
.nodrawer
|| wPreferences
.flags
.nodock
;
2477 wPreferences
.flags
.noclip
= wPreferences
.flags
.noclip
|| *flag
;
2480 wPreferences
.flags
.nodrawer
= wPreferences
.flags
.nodrawer
|| *flag
;
2488 static int setClipMergedInDock(WScreen
*scr
, WDefaultEntry
*entry
, void *tdata
, void *foo
)
2492 /* Parameter not used, but tell the compiler that it is ok */
2497 wPreferences
.flags
.clip_merged_in_dock
= *flag
;
2498 wPreferences
.flags
.noclip
= wPreferences
.flags
.noclip
|| *flag
;
2502 static int setWrapAppiconsInDock(WScreen
*scr
, WDefaultEntry
*entry
, void *tdata
, void *foo
)
2506 /* Parameter not used, but tell the compiler that it is ok */
2511 wPreferences
.flags
.wrap_appicons_in_dock
= *flag
;
2515 static int setStickyIcons(WScreen
* scr
, WDefaultEntry
* entry
, void *bar
, void *foo
)
2517 /* Parameter not used, but tell the compiler that it is ok */
2522 if (w_global
.workspace
.array
) {
2523 wWorkspaceForceChange(scr
, w_global
.workspace
.current
);
2524 wArrangeIcons(scr
, False
);
2529 static int setIconTile(WScreen
* scr
, WDefaultEntry
* entry
, void *tdata
, void *foo
)
2533 WTexture
** texture
= tdata
;
2536 /* Parameter not used, but tell the compiler that it is ok */
2539 img
= wTextureRenderImage(*texture
, wPreferences
.icon_size
,
2540 wPreferences
.icon_size
, ((*texture
)->any
.type
& WREL_BORDER_MASK
)
2541 ? WREL_ICON
: WREL_FLAT
);
2543 wwarning(_("could not render texture for icon background"));
2545 wTextureDestroy(scr
, *texture
);
2548 RConvertImage(scr
->rcontext
, img
, &pixmap
);
2550 if (scr
->icon_tile
) {
2552 RReleaseImage(scr
->icon_tile
);
2553 XFreePixmap(dpy
, scr
->icon_tile_pixmap
);
2556 scr
->icon_tile
= img
;
2558 /* put the icon in the noticeboard hint */
2559 PropSetIconTileHint(scr
, img
);
2561 if (!wPreferences
.flags
.noclip
|| wPreferences
.flags
.clip_merged_in_dock
) {
2562 if (scr
->clip_tile
) {
2563 RReleaseImage(scr
->clip_tile
);
2565 scr
->clip_tile
= wClipMakeTile(img
);
2568 if (!wPreferences
.flags
.nodrawer
) {
2569 if (scr
->drawer_tile
) {
2570 RReleaseImage(scr
->drawer_tile
);
2572 scr
->drawer_tile
= wDrawerMakeTile(scr
, img
);
2575 scr
->icon_tile_pixmap
= pixmap
;
2577 if (scr
->def_icon_rimage
) {
2578 RReleaseImage(scr
->def_icon_rimage
);
2579 scr
->def_icon_rimage
= NULL
;
2582 if (scr
->icon_back_texture
)
2583 wTextureDestroy(scr
, (WTexture
*) scr
->icon_back_texture
);
2585 scr
->icon_back_texture
= wTextureMakeSolid(scr
, &((*texture
)->any
.color
));
2587 /* Free the texture as nobody else will use it, nor refer to it. */
2589 wTextureDestroy(scr
, *texture
);
2591 return (reset
? REFRESH_ICON_TILE
: 0);
2594 static int setWinTitleFont(WScreen
* scr
, WDefaultEntry
* entry
, void *tdata
, void *foo
)
2596 WMFont
*font
= tdata
;
2598 /* Parameter not used, but tell the compiler that it is ok */
2602 if (scr
->title_font
) {
2603 WMReleaseFont(scr
->title_font
);
2605 scr
->title_font
= font
;
2607 return REFRESH_WINDOW_FONT
| REFRESH_BUTTON_IMAGES
;
2610 static int setMenuTitleFont(WScreen
* scr
, WDefaultEntry
* entry
, void *tdata
, void *foo
)
2612 WMFont
*font
= tdata
;
2614 /* Parameter not used, but tell the compiler that it is ok */
2618 if (scr
->menu_title_font
) {
2619 WMReleaseFont(scr
->menu_title_font
);
2622 scr
->menu_title_font
= font
;
2624 return REFRESH_MENU_TITLE_FONT
;
2627 static int setMenuTextFont(WScreen
* scr
, WDefaultEntry
* entry
, void *tdata
, void *foo
)
2629 WMFont
*font
= tdata
;
2631 /* Parameter not used, but tell the compiler that it is ok */
2635 if (scr
->menu_entry_font
) {
2636 WMReleaseFont(scr
->menu_entry_font
);
2638 scr
->menu_entry_font
= font
;
2640 return REFRESH_MENU_FONT
;
2643 static int setIconTitleFont(WScreen
* scr
, WDefaultEntry
* entry
, void *tdata
, void *foo
)
2645 WMFont
*font
= tdata
;
2647 /* Parameter not used, but tell the compiler that it is ok */
2651 if (scr
->icon_title_font
) {
2652 WMReleaseFont(scr
->icon_title_font
);
2655 scr
->icon_title_font
= font
;
2657 return REFRESH_ICON_FONT
;
2660 static int setClipTitleFont(WScreen
* scr
, WDefaultEntry
* entry
, void *tdata
, void *foo
)
2662 WMFont
*font
= tdata
;
2664 /* Parameter not used, but tell the compiler that it is ok */
2668 if (scr
->clip_title_font
) {
2669 WMReleaseFont(scr
->clip_title_font
);
2672 scr
->clip_title_font
= font
;
2674 return REFRESH_ICON_FONT
;
2677 static int setLargeDisplayFont(WScreen
*scr
, WDefaultEntry
*entry
, void *tdata
, void *foo
)
2679 WMFont
*font
= tdata
;
2681 /* Parameter not used, but tell the compiler that it is ok */
2686 if (w_global
.workspace
.font_for_name
)
2687 WMReleaseFont(w_global
.workspace
.font_for_name
);
2689 w_global
.workspace
.font_for_name
= font
;
2694 static int setHightlight(WScreen
* scr
, WDefaultEntry
* entry
, void *tdata
, void *foo
)
2696 XColor
*color
= tdata
;
2698 /* Parameter not used, but tell the compiler that it is ok */
2702 if (scr
->select_color
)
2703 WMReleaseColor(scr
->select_color
);
2705 scr
->select_color
= WMCreateRGBColor(scr
->wmscreen
, color
->red
, color
->green
, color
->blue
, True
);
2707 wFreeColor(scr
, color
->pixel
);
2709 return REFRESH_MENU_COLOR
;
2712 static int setHightlightText(WScreen
* scr
, WDefaultEntry
* entry
, void *tdata
, void *foo
)
2714 XColor
*color
= tdata
;
2716 /* Parameter not used, but tell the compiler that it is ok */
2720 if (scr
->select_text_color
)
2721 WMReleaseColor(scr
->select_text_color
);
2723 scr
->select_text_color
= WMCreateRGBColor(scr
->wmscreen
, color
->red
, color
->green
, color
->blue
, True
);
2725 wFreeColor(scr
, color
->pixel
);
2727 return REFRESH_MENU_COLOR
;
2730 static int setClipTitleColor(WScreen
* scr
, WDefaultEntry
* entry
, void *tdata
, void *extra_data
)
2732 XColor
*color
= tdata
;
2733 long widx
= (long) extra_data
;
2735 /* Parameter not used, but tell the compiler that it is ok */
2738 if (scr
->clip_title_color
[widx
])
2739 WMReleaseColor(scr
->clip_title_color
[widx
]);
2741 scr
->clip_title_color
[widx
] = WMCreateRGBColor(scr
->wmscreen
, color
->red
, color
->green
, color
->blue
, True
);
2742 wFreeColor(scr
, color
->pixel
);
2744 return REFRESH_ICON_TITLE_COLOR
;
2747 static int setWTitleColor(WScreen
* scr
, WDefaultEntry
* entry
, void *tdata
, void *extra_data
)
2749 XColor
*color
= tdata
;
2750 long widx
= (long) extra_data
;
2752 /* Parameter not used, but tell the compiler that it is ok */
2755 if (scr
->window_title_color
[widx
])
2756 WMReleaseColor(scr
->window_title_color
[widx
]);
2758 scr
->window_title_color
[widx
] =
2759 WMCreateRGBColor(scr
->wmscreen
, color
->red
, color
->green
, color
->blue
, True
);
2761 wFreeColor(scr
, color
->pixel
);
2763 return REFRESH_WINDOW_TITLE_COLOR
;
2766 static int setMenuTitleColor(WScreen
* scr
, WDefaultEntry
* entry
, void *tdata
, void *extra_data
)
2768 XColor
*color
= tdata
;
2770 /* Parameter not used, but tell the compiler that it is ok */
2774 if (scr
->menu_title_color
[0])
2775 WMReleaseColor(scr
->menu_title_color
[0]);
2777 scr
->menu_title_color
[0] = WMCreateRGBColor(scr
->wmscreen
, color
->red
, color
->green
, color
->blue
, True
);
2779 wFreeColor(scr
, color
->pixel
);
2781 return REFRESH_MENU_TITLE_COLOR
;
2784 static int setMenuTextColor(WScreen
* scr
, WDefaultEntry
* entry
, void *tdata
, void *foo
)
2786 XColor
*color
= tdata
;
2788 /* Parameter not used, but tell the compiler that it is ok */
2792 if (scr
->mtext_color
)
2793 WMReleaseColor(scr
->mtext_color
);
2795 scr
->mtext_color
= WMCreateRGBColor(scr
->wmscreen
, color
->red
, color
->green
, color
->blue
, True
);
2797 if (WMColorPixel(scr
->dtext_color
) == WMColorPixel(scr
->mtext_color
)) {
2798 WMSetColorAlpha(scr
->dtext_color
, 0x7fff);
2800 WMSetColorAlpha(scr
->dtext_color
, 0xffff);
2803 wFreeColor(scr
, color
->pixel
);
2805 return REFRESH_MENU_COLOR
;
2808 static int setMenuDisabledColor(WScreen
* scr
, WDefaultEntry
* entry
, void *tdata
, void *foo
)
2810 XColor
*color
= tdata
;
2812 /* Parameter not used, but tell the compiler that it is ok */
2816 if (scr
->dtext_color
)
2817 WMReleaseColor(scr
->dtext_color
);
2819 scr
->dtext_color
= WMCreateRGBColor(scr
->wmscreen
, color
->red
, color
->green
, color
->blue
, True
);
2821 if (WMColorPixel(scr
->dtext_color
) == WMColorPixel(scr
->mtext_color
)) {
2822 WMSetColorAlpha(scr
->dtext_color
, 0x7fff);
2824 WMSetColorAlpha(scr
->dtext_color
, 0xffff);
2827 wFreeColor(scr
, color
->pixel
);
2829 return REFRESH_MENU_COLOR
;
2832 static int setIconTitleColor(WScreen
* scr
, WDefaultEntry
* entry
, void *tdata
, void *foo
)
2834 XColor
*color
= tdata
;
2836 /* Parameter not used, but tell the compiler that it is ok */
2840 if (scr
->icon_title_color
)
2841 WMReleaseColor(scr
->icon_title_color
);
2842 scr
->icon_title_color
= WMCreateRGBColor(scr
->wmscreen
, color
->red
, color
->green
, color
->blue
, True
);
2844 wFreeColor(scr
, color
->pixel
);
2846 return REFRESH_ICON_TITLE_COLOR
;
2849 static int setIconTitleBack(WScreen
* scr
, WDefaultEntry
* entry
, void *tdata
, void *foo
)
2851 XColor
*color
= tdata
;
2853 /* Parameter not used, but tell the compiler that it is ok */
2857 if (scr
->icon_title_texture
) {
2858 wTextureDestroy(scr
, (WTexture
*) scr
->icon_title_texture
);
2860 scr
->icon_title_texture
= wTextureMakeSolid(scr
, color
);
2862 return REFRESH_ICON_TITLE_BACK
;
2865 static int setFrameBorderWidth(WScreen
* scr
, WDefaultEntry
* entry
, void *tdata
, void *foo
)
2869 /* Parameter not used, but tell the compiler that it is ok */
2873 scr
->frame_border_width
= *value
;
2875 return REFRESH_FRAME_BORDER
;
2878 static int setFrameBorderColor(WScreen
* scr
, WDefaultEntry
* entry
, void *tdata
, void *foo
)
2880 XColor
*color
= tdata
;
2882 /* Parameter not used, but tell the compiler that it is ok */
2886 if (scr
->frame_border_color
)
2887 WMReleaseColor(scr
->frame_border_color
);
2888 scr
->frame_border_color
= WMCreateRGBColor(scr
->wmscreen
, color
->red
, color
->green
, color
->blue
, True
);
2890 wFreeColor(scr
, color
->pixel
);
2892 return REFRESH_FRAME_BORDER
;
2895 static int setFrameFocusedBorderColor(WScreen
*scr
, WDefaultEntry
*entry
, void *tdata
, void *foo
)
2897 XColor
*color
= tdata
;
2899 /* Parameter not used, but tell the compiler that it is ok */
2903 if (scr
->frame_focused_border_color
)
2904 WMReleaseColor(scr
->frame_focused_border_color
);
2905 scr
->frame_focused_border_color
= WMCreateRGBColor(scr
->wmscreen
, color
->red
, color
->green
, color
->blue
, True
);
2907 wFreeColor(scr
, color
->pixel
);
2909 return REFRESH_FRAME_BORDER
;
2912 static int setFrameSelectedBorderColor(WScreen
* scr
, WDefaultEntry
* entry
, void *tdata
, void *foo
)
2914 XColor
*color
= tdata
;
2916 /* Parameter not used, but tell the compiler that it is ok */
2920 if (scr
->frame_selected_border_color
)
2921 WMReleaseColor(scr
->frame_selected_border_color
);
2922 scr
->frame_selected_border_color
= WMCreateRGBColor(scr
->wmscreen
, color
->red
, color
->green
, color
->blue
, True
);
2924 wFreeColor(scr
, color
->pixel
);
2926 return REFRESH_FRAME_BORDER
;
2929 static void trackDeadProcess(pid_t pid
, unsigned int status
, void *client_data
)
2931 WScreen
*scr
= (WScreen
*) client_data
;
2933 /* Parameter not used, but tell the compiler that it is ok */
2937 close(scr
->helper_fd
);
2939 scr
->helper_pid
= 0;
2940 scr
->flags
.backimage_helper_launched
= 0;
2943 static int setWorkspaceSpecificBack(WScreen
* scr
, WDefaultEntry
* entry
, void *tdata
, void *bar
)
2945 WMPropList
*value
= tdata
;
2950 /* Parameter not used, but tell the compiler that it is ok */
2954 if (scr
->flags
.backimage_helper_launched
) {
2955 if (WMGetPropListItemCount(value
) == 0) {
2956 SendHelperMessage(scr
, 'C', 0, NULL
);
2957 SendHelperMessage(scr
, 'K', 0, NULL
);
2959 WMReleasePropList(value
);
2966 if (WMGetPropListItemCount(value
) == 0)
2969 if (pipe(filedes
) < 0) {
2970 werror("pipe() failed:can't set workspace specific background image");
2972 WMReleasePropList(value
);
2978 werror("fork() failed:can't set workspace specific background image");
2979 if (close(filedes
[0]) < 0)
2980 werror("could not close pipe");
2981 if (close(filedes
[1]) < 0)
2982 werror("could not close pipe");
2984 } else if (pid
== 0) {
2987 SetupEnvironment(scr
);
2990 werror("could not close pipe");
2991 if (dup(filedes
[0]) < 0) {
2992 werror("dup() failed:can't set workspace specific background image");
2994 dither
= wPreferences
.no_dithering
? "-m" : "-d";
2995 if (wPreferences
.smooth_workspace_back
)
2996 execlp("wmsetbg", "wmsetbg", "-helper", "-S", dither
, NULL
);
2998 execlp("wmsetbg", "wmsetbg", "-helper", dither
, NULL
);
2999 werror("could not execute wmsetbg");
3003 if (fcntl(filedes
[0], F_SETFD
, FD_CLOEXEC
) < 0) {
3004 werror("error setting close-on-exec flag");
3006 if (fcntl(filedes
[1], F_SETFD
, FD_CLOEXEC
) < 0) {
3007 werror("error setting close-on-exec flag");
3010 scr
->helper_fd
= filedes
[1];
3011 scr
->helper_pid
= pid
;
3012 scr
->flags
.backimage_helper_launched
= 1;
3014 wAddDeathHandler(pid
, trackDeadProcess
, scr
);
3016 SendHelperMessage(scr
, 'P', -1, wPreferences
.pixmap_path
);
3021 for (i
= 0; i
< WMGetPropListItemCount(value
); i
++) {
3022 val
= WMGetFromPLArray(value
, i
);
3023 if (val
&& WMIsPLArray(val
) && WMGetPropListItemCount(val
) > 0) {
3024 str
= WMGetPropListDescription(val
, False
);
3026 SendHelperMessage(scr
, 'S', i
+ 1, str
);
3030 SendHelperMessage(scr
, 'U', i
+ 1, NULL
);
3035 WMReleasePropList(value
);
3039 static int setWorkspaceBack(WScreen
* scr
, WDefaultEntry
* entry
, void *tdata
, void *bar
)
3041 WMPropList
*value
= tdata
;
3043 /* Parameter not used, but tell the compiler that it is ok */
3047 if (scr
->flags
.backimage_helper_launched
) {
3050 if (WMGetPropListItemCount(value
) == 0) {
3051 SendHelperMessage(scr
, 'U', 0, NULL
);
3053 /* set the default workspace background to this one */
3054 str
= WMGetPropListDescription(value
, False
);
3056 SendHelperMessage(scr
, 'S', 0, str
);
3058 SendHelperMessage(scr
, 'C', w_global
.workspace
.current
+ 1, NULL
);
3060 SendHelperMessage(scr
, 'U', 0, NULL
);
3063 } else if (WMGetPropListItemCount(value
) > 0) {
3069 text
= WMGetPropListDescription(value
, False
);
3070 len
= strlen(text
) + 40;
3071 command
= wmalloc(len
);
3072 dither
= wPreferences
.no_dithering
? "-m" : "-d";
3073 if (wPreferences
.smooth_workspace_back
)
3074 snprintf(command
, len
, "wmsetbg %s -S -p '%s' &", dither
, text
);
3076 snprintf(command
, len
, "wmsetbg %s -p '%s' &", dither
, text
);
3078 ExecuteShellCommand(scr
, command
);
3081 WMReleasePropList(value
);
3086 static int setWidgetColor(WScreen
* scr
, WDefaultEntry
* entry
, void *tdata
, void *foo
)
3088 WTexture
**texture
= tdata
;
3090 /* Parameter not used, but tell the compiler that it is ok */
3094 if (scr
->widget_texture
) {
3095 wTextureDestroy(scr
, (WTexture
*) scr
->widget_texture
);
3097 scr
->widget_texture
= *(WTexSolid
**) texture
;
3102 static int setFTitleBack(WScreen
* scr
, WDefaultEntry
* entry
, void *tdata
, void *foo
)
3104 WTexture
**texture
= tdata
;
3106 /* Parameter not used, but tell the compiler that it is ok */
3110 if (scr
->window_title_texture
[WS_FOCUSED
]) {
3111 wTextureDestroy(scr
, scr
->window_title_texture
[WS_FOCUSED
]);
3113 scr
->window_title_texture
[WS_FOCUSED
] = *texture
;
3115 return REFRESH_WINDOW_TEXTURES
;
3118 static int setPTitleBack(WScreen
* scr
, WDefaultEntry
* entry
, void *tdata
, void *foo
)
3120 WTexture
**texture
= tdata
;
3122 /* Parameter not used, but tell the compiler that it is ok */
3126 if (scr
->window_title_texture
[WS_PFOCUSED
]) {
3127 wTextureDestroy(scr
, scr
->window_title_texture
[WS_PFOCUSED
]);
3129 scr
->window_title_texture
[WS_PFOCUSED
] = *texture
;
3131 return REFRESH_WINDOW_TEXTURES
;
3134 static int setUTitleBack(WScreen
* scr
, WDefaultEntry
* entry
, void *tdata
, void *foo
)
3136 WTexture
**texture
= tdata
;
3138 /* Parameter not used, but tell the compiler that it is ok */
3142 if (scr
->window_title_texture
[WS_UNFOCUSED
]) {
3143 wTextureDestroy(scr
, scr
->window_title_texture
[WS_UNFOCUSED
]);
3145 scr
->window_title_texture
[WS_UNFOCUSED
] = *texture
;
3147 return REFRESH_WINDOW_TEXTURES
;
3150 static int setResizebarBack(WScreen
* scr
, WDefaultEntry
* entry
, void *tdata
, void *foo
)
3152 WTexture
**texture
= tdata
;
3154 /* Parameter not used, but tell the compiler that it is ok */
3158 if (scr
->resizebar_texture
[0]) {
3159 wTextureDestroy(scr
, scr
->resizebar_texture
[0]);
3161 scr
->resizebar_texture
[0] = *texture
;
3163 return REFRESH_WINDOW_TEXTURES
;
3166 static int setMenuTitleBack(WScreen
* scr
, WDefaultEntry
* entry
, void *tdata
, void *foo
)
3168 WTexture
**texture
= tdata
;
3170 /* Parameter not used, but tell the compiler that it is ok */
3174 if (scr
->menu_title_texture
[0]) {
3175 wTextureDestroy(scr
, scr
->menu_title_texture
[0]);
3177 scr
->menu_title_texture
[0] = *texture
;
3179 return REFRESH_MENU_TITLE_TEXTURE
;
3182 static int setMenuTextBack(WScreen
* scr
, WDefaultEntry
* entry
, void *tdata
, void *foo
)
3184 WTexture
**texture
= tdata
;
3186 /* Parameter not used, but tell the compiler that it is ok */
3190 if (scr
->menu_item_texture
) {
3191 wTextureDestroy(scr
, scr
->menu_item_texture
);
3192 wTextureDestroy(scr
, (WTexture
*) scr
->menu_item_auxtexture
);
3194 scr
->menu_item_texture
= *texture
;
3196 scr
->menu_item_auxtexture
= wTextureMakeSolid(scr
, &scr
->menu_item_texture
->any
.color
);
3198 return REFRESH_MENU_TEXTURE
;
3201 static int setKeyGrab(WScreen
* scr
, WDefaultEntry
* entry
, void *tdata
, void *extra_data
)
3203 WShortKey
*shortcut
= tdata
;
3205 long widx
= (long) extra_data
;
3207 /* Parameter not used, but tell the compiler that it is ok */
3210 wKeyBindings
[widx
] = *shortcut
;
3212 wwin
= scr
->focused_window
;
3214 while (wwin
!= NULL
) {
3215 XUngrabKey(dpy
, AnyKey
, AnyModifier
, wwin
->frame
->core
->window
);
3217 if (!WFLAGP(wwin
, no_bind_keys
)) {
3218 wWindowSetKeyGrabs(wwin
);
3223 /* do we need to update window menus? */
3224 if (widx
>= WKBD_WORKSPACE1
&& widx
<= WKBD_WORKSPACE10
)
3225 return REFRESH_WORKSPACE_MENU
;
3226 if (widx
== WKBD_LASTWORKSPACE
)
3227 return REFRESH_WORKSPACE_MENU
;
3228 if (widx
>= WKBD_MOVE_WORKSPACE1
&& widx
<= WKBD_MOVE_WORKSPACE10
)
3229 return REFRESH_WORKSPACE_MENU
;
3234 static int setIconPosition(WScreen
* scr
, WDefaultEntry
* entry
, void *bar
, void *foo
)
3236 /* Parameter not used, but tell the compiler that it is ok */
3241 wScreenUpdateUsableArea(scr
);
3242 wArrangeIcons(scr
, True
);
3247 static int updateUsableArea(WScreen
* scr
, WDefaultEntry
* entry
, void *bar
, void *foo
)
3249 /* Parameter not used, but tell the compiler that it is ok */
3254 wScreenUpdateUsableArea(scr
);
3259 static int setMenuStyle(WScreen
* scr
, WDefaultEntry
* entry
, void *tdata
, void *foo
)
3261 /* Parameter not used, but tell the compiler that it is ok */
3267 return REFRESH_MENU_TEXTURE
;
3270 static RImage
*chopOffImage(RImage
* image
, int x
, int y
, int w
, int h
)
3272 RImage
*img
= RCreateImage(w
, h
, image
->format
== RRGBAFormat
);
3274 RCopyArea(img
, image
, x
, y
, w
, h
, 0, 0);
3279 static int setSwPOptions(WScreen
* scr
, WDefaultEntry
* entry
, void *tdata
, void *foo
)
3281 WMPropList
*array
= tdata
;
3284 int cwidth
, cheight
;
3285 struct WPreferences
*prefs
= foo
;
3287 if (!WMIsPLArray(array
) || WMGetPropListItemCount(array
) == 0) {
3288 if (prefs
->swtileImage
)
3289 RReleaseImage(prefs
->swtileImage
);
3290 prefs
->swtileImage
= NULL
;
3292 WMReleasePropList(array
);
3296 switch (WMGetPropListItemCount(array
)) {
3298 if (!WMIsPLString(WMGetFromPLArray(array
, 1))) {
3299 wwarning(_("Invalid arguments for option \"%s\""), entry
->key
);
3302 path
= FindImage(wPreferences
.pixmap_path
, WMGetFromPLString(WMGetFromPLArray(array
, 1)));
3305 wwarning(_("Could not find image \"%s\" for option \"%s\""),
3306 WMGetFromPLString(WMGetFromPLArray(array
, 1)), entry
->key
);
3308 bgimage
= RLoadImage(scr
->rcontext
, path
, 0);
3310 wwarning(_("Could not load image \"%s\" for option \"%s\""), path
, entry
->key
);
3315 cwidth
= atoi(WMGetFromPLString(WMGetFromPLArray(array
, 2)));
3316 cheight
= atoi(WMGetFromPLString(WMGetFromPLArray(array
, 3)));
3318 if (cwidth
<= 0 || cheight
<= 0 ||
3319 cwidth
>= bgimage
->width
- 2 || cheight
>= bgimage
->height
- 2)
3320 wwarning(_("Invalid split sizes for switch panel back image."));
3323 int swidth
, theight
;
3324 for (i
= 0; i
< 9; i
++) {
3325 if (prefs
->swbackImage
[i
])
3326 RReleaseImage(prefs
->swbackImage
[i
]);
3327 prefs
->swbackImage
[i
] = NULL
;
3329 swidth
= (bgimage
->width
- cwidth
) / 2;
3330 theight
= (bgimage
->height
- cheight
) / 2;
3332 prefs
->swbackImage
[0] = chopOffImage(bgimage
, 0, 0, swidth
, theight
);
3333 prefs
->swbackImage
[1] = chopOffImage(bgimage
, swidth
, 0, cwidth
, theight
);
3334 prefs
->swbackImage
[2] = chopOffImage(bgimage
, swidth
+ cwidth
, 0,
3337 prefs
->swbackImage
[3] = chopOffImage(bgimage
, 0, theight
, swidth
, cheight
);
3338 prefs
->swbackImage
[4] = chopOffImage(bgimage
, swidth
, theight
,
3340 prefs
->swbackImage
[5] = chopOffImage(bgimage
, swidth
+ cwidth
, theight
,
3343 prefs
->swbackImage
[6] = chopOffImage(bgimage
, 0, theight
+ cheight
,
3345 prefs
->swbackImage
[7] = chopOffImage(bgimage
, swidth
, theight
+ cheight
,
3347 prefs
->swbackImage
[8] =
3348 chopOffImage(bgimage
, swidth
+ cwidth
, theight
+ cheight
, swidth
,
3351 // check if anything failed
3352 for (i
= 0; i
< 9; i
++) {
3353 if (!prefs
->swbackImage
[i
]) {
3354 for (; i
>= 0; --i
) {
3355 RReleaseImage(prefs
->swbackImage
[i
]);
3356 prefs
->swbackImage
[i
] = NULL
;
3362 RReleaseImage(bgimage
);
3367 if (!WMIsPLString(WMGetFromPLArray(array
, 0))) {
3368 wwarning(_("Invalid arguments for option \"%s\""), entry
->key
);
3371 path
= FindImage(wPreferences
.pixmap_path
, WMGetFromPLString(WMGetFromPLArray(array
, 0)));
3374 wwarning(_("Could not find image \"%s\" for option \"%s\""),
3375 WMGetFromPLString(WMGetFromPLArray(array
, 0)), entry
->key
);
3377 if (prefs
->swtileImage
)
3378 RReleaseImage(prefs
->swtileImage
);
3380 prefs
->swtileImage
= RLoadImage(scr
->rcontext
, path
, 0);
3381 if (!prefs
->swtileImage
) {
3382 wwarning(_("Could not load image \"%s\" for option \"%s\""), path
, entry
->key
);
3389 wwarning(_("Invalid number of arguments for option \"%s\""), entry
->key
);
3393 WMReleasePropList(array
);
3398 static int setModifierKeyLabels(WScreen
* scr
, WDefaultEntry
* entry
, void *tdata
, void *foo
)
3400 WMPropList
*array
= tdata
;
3402 struct WPreferences
*prefs
= foo
;
3404 if (!WMIsPLArray(array
) || WMGetPropListItemCount(array
) != 7) {
3405 wwarning(_("Value for option \"%s\" must be an array of 7 strings"), entry
->key
);
3406 WMReleasePropList(array
);
3410 DestroyWindowMenu(scr
);
3412 for (i
= 0; i
< 7; i
++) {
3413 if (prefs
->modifier_labels
[i
])
3414 wfree(prefs
->modifier_labels
[i
]);
3416 if (WMIsPLString(WMGetFromPLArray(array
, i
))) {
3417 prefs
->modifier_labels
[i
] = wstrdup(WMGetFromPLString(WMGetFromPLArray(array
, i
)));
3419 wwarning(_("Invalid argument for option \"%s\" item %d"), entry
->key
, i
);
3420 prefs
->modifier_labels
[i
] = NULL
;
3424 WMReleasePropList(array
);
3429 static int setDoubleClick(WScreen
*scr
, WDefaultEntry
*entry
, void *tdata
, void *foo
)
3433 /* Parameter not used, but tell the compiler that it is ok */
3440 W_setconf_doubleClickDelay(*value
);
3445 static int setCursor(WScreen
* scr
, WDefaultEntry
* entry
, void *tdata
, void *extra_data
)
3447 Cursor
*cursor
= tdata
;
3448 long widx
= (long) extra_data
;
3450 /* Parameter not used, but tell the compiler that it is ok */
3453 if (wPreferences
.cursor
[widx
] != None
) {
3454 XFreeCursor(dpy
, wPreferences
.cursor
[widx
]);
3457 wPreferences
.cursor
[widx
] = *cursor
;
3459 if (widx
== WCUR_ROOT
&& *cursor
!= None
) {
3460 XDefineCursor(dpy
, scr
->root_win
, *cursor
);