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
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
33 #include <sys/types.h>
40 #define PATH_MAX DEFAULT_PATH_MAX
44 #include <X11/Xutil.h>
45 #include <X11/keysym.h>
49 #include "WindowMaker.h"
54 #include "resources.h"
57 #include "xmodifier.h"
62 #include "workspace.h"
63 #include "properties.h"
65 #define MAX_SHORTCUT_LENGTH 32
67 #ifndef GLOBAL_DEFAULTS_SUBDIR
68 #define GLOBAL_DEFAULTS_SUBDIR "WindowMaker"
72 extern WDDomain
*WDWindowMaker
;
73 extern WDDomain
*WDWindowAttributes
;
74 extern WDDomain
*WDRootMenu
;
75 extern int wScreenCount
;
76 extern WPreferences wPreferences
;
77 extern WShortKey wKeyBindings
[WKBD_LAST
];
87 WMPropList
*plvalue
; /* default value */
90 /* used to map strings to integers */
100 static int getCoord();
101 static int getPathList();
102 static int getEnum();
103 static int getTexture();
104 static int getWSBackground();
105 static int getWSSpecificBackground();
106 static int getFont();
107 static int getColor();
108 static int getKeybind();
109 static int getModMask();
110 static int getPropList();
112 /* value setting functions */
113 static int setJustify();
114 static int setClearance();
115 static int setIfDockPresent();
116 static int setStickyIcons();
117 static int setWidgetColor();
118 static int setIconTile();
119 static int setWinTitleFont();
120 static int setMenuTitleFont();
121 static int setMenuTextFont();
122 static int setIconTitleFont();
123 static int setIconTitleColor();
124 static int setIconTitleBack();
125 static int setLargeDisplayFont();
126 static int setWTitleColor();
127 static int setFTitleBack();
128 static int setPTitleBack();
129 static int setUTitleBack();
130 static int setResizebarBack();
131 static int setWorkspaceBack();
132 static int setWorkspaceSpecificBack();
133 static int setMenuTitleColor();
134 static int setMenuTextColor();
135 static int setMenuDisabledColor();
136 static int setMenuTitleBack();
137 static int setMenuTextBack();
138 static int setHightlight();
139 static int setHightlightText();
140 static int setKeyGrab();
141 static int setDoubleClick();
142 static int setIconPosition();
144 static int setClipTitleFont();
145 static int setClipTitleColor();
147 static int setMenuStyle();
148 static int setSwPOptions();
149 static int updateUsableArea();
151 extern Cursor wCursor
[WCUR_LAST
];
152 static int getCursor();
153 static int setCursor();
156 * Tables to convert strings to enumeration values.
157 * Values stored are char
160 /* WARNING: sum of length of all value strings must not exceed
162 #define TOTAL_VALUES_LENGTH 80
164 #define REFRESH_WINDOW_TEXTURES (1<<0)
165 #define REFRESH_MENU_TEXTURE (1<<1)
166 #define REFRESH_MENU_FONT (1<<2)
167 #define REFRESH_MENU_COLOR (1<<3)
168 #define REFRESH_MENU_TITLE_TEXTURE (1<<4)
169 #define REFRESH_MENU_TITLE_FONT (1<<5)
170 #define REFRESH_MENU_TITLE_COLOR (1<<6)
171 #define REFRESH_WINDOW_TITLE_COLOR (1<<7)
172 #define REFRESH_WINDOW_FONT (1<<8)
173 #define REFRESH_ICON_TILE (1<<9)
174 #define REFRESH_ICON_FONT (1<<10)
175 #define REFRESH_WORKSPACE_BACK (1<<11)
177 #define REFRESH_BUTTON_IMAGES (1<<12)
179 #define REFRESH_ICON_TITLE_COLOR (1<<13)
180 #define REFRESH_ICON_TITLE_BACK (1<<14)
182 static WOptionEnumeration seFocusModes
[] = {
183 {"Manual", WKF_CLICK
, 0}, {"ClickToFocus", WKF_CLICK
, 1},
184 {"Sloppy", WKF_SLOPPY
, 0}, {"SemiAuto", WKF_SLOPPY
, 1}, {"Auto", WKF_SLOPPY
, 1},
188 static WOptionEnumeration seTitlebarModes
[] = {
189 {"new", TS_NEW
, 0}, {"old", TS_OLD
, 0},
190 {"next", TS_NEXT
, 0}, {NULL
, 0, 0}
193 static WOptionEnumeration seColormapModes
[] = {
194 {"Manual", WCM_CLICK
, 0}, {"ClickToFocus", WCM_CLICK
, 1},
195 {"Auto", WCM_POINTER
, 0}, {"FocusFollowMouse", WCM_POINTER
, 1},
199 static WOptionEnumeration sePlacements
[] = {
200 {"Auto", WPM_AUTO
, 0},
201 {"Smart", WPM_SMART
, 0},
202 {"Cascade", WPM_CASCADE
, 0},
203 {"Random", WPM_RANDOM
, 0},
204 {"Manual", WPM_MANUAL
, 0},
208 static WOptionEnumeration seGeomDisplays
[] = {
209 {"None", WDIS_NONE
, 0},
210 {"Center", WDIS_CENTER
, 0},
211 {"Corner", WDIS_TOPLEFT
, 0},
212 {"Floating", WDIS_FRAME_CENTER
, 0},
213 {"Line", WDIS_NEW
, 0},
217 static WOptionEnumeration seSpeeds
[] = {
218 {"UltraFast", SPEED_ULTRAFAST
, 0},
219 {"Fast", SPEED_FAST
, 0},
220 {"Medium", SPEED_MEDIUM
, 0},
221 {"Slow", SPEED_SLOW
, 0},
222 {"UltraSlow", SPEED_ULTRASLOW
, 0},
226 static WOptionEnumeration seMouseButtonActions
[] = {
227 {"None", WA_NONE
, 0},
228 {"SelectWindows", WA_SELECT_WINDOWS
, 0},
229 {"OpenApplicationsMenu", WA_OPEN_APPMENU
, 0},
230 {"OpenWindowListMenu", WA_OPEN_WINLISTMENU
, 0},
234 static WOptionEnumeration seMouseWheelActions
[] = {
235 {"None", WA_NONE
, 0},
236 {"SwitchWorkspaces", WA_SWITCH_WORKSPACES
, 0},
240 static WOptionEnumeration seIconificationStyles
[] = {
241 {"Zoom", WIS_ZOOM
, 0},
242 {"Twist", WIS_TWIST
, 0},
243 {"Flip", WIS_FLIP
, 0},
244 {"None", WIS_NONE
, 0},
245 {"random", WIS_RANDOM
, 0},
249 static WOptionEnumeration seJustifications
[] = {
250 {"Left", WTJ_LEFT
, 0},
251 {"Center", WTJ_CENTER
, 0},
252 {"Right", WTJ_RIGHT
, 0},
256 static WOptionEnumeration seIconPositions
[] = {
257 {"blv", IY_BOTTOM
| IY_LEFT
| IY_VERT
, 0},
258 {"blh", IY_BOTTOM
| IY_LEFT
| IY_HORIZ
, 0},
259 {"brv", IY_BOTTOM
| IY_RIGHT
| IY_VERT
, 0},
260 {"brh", IY_BOTTOM
| IY_RIGHT
| IY_HORIZ
, 0},
261 {"tlv", IY_TOP
| IY_LEFT
| IY_VERT
, 0},
262 {"tlh", IY_TOP
| IY_LEFT
| IY_HORIZ
, 0},
263 {"trv", IY_TOP
| IY_RIGHT
| IY_VERT
, 0},
264 {"trh", IY_TOP
| IY_RIGHT
| IY_HORIZ
, 0},
268 static WOptionEnumeration seMenuStyles
[] = {
269 {"normal", MS_NORMAL
, 0},
270 {"singletexture", MS_SINGLE_TEXTURE
, 0},
271 {"flat", MS_FLAT
, 0},
275 static WOptionEnumeration seDisplayPositions
[] = {
276 {"none", WD_NONE
, 0},
277 {"center", WD_CENTER
, 0},
279 {"bottom", WD_BOTTOM
, 0},
280 {"topleft", WD_TOPLEFT
, 0},
281 {"topright", WD_TOPRIGHT
, 0},
282 {"bottomleft", WD_BOTTOMLEFT
, 0},
283 {"bottomright", WD_BOTTOMRIGHT
, 0},
287 static WOptionEnumeration seWorkspaceBorder
[] = {
288 {"None", WB_NONE
, 0},
289 {"LeftRight", WB_LEFTRIGHT
, 0},
290 {"TopBottom", WB_TOPBOTTOM
, 0},
291 {"AllDirections", WB_ALLDIRS
, 0},
296 * ALL entries in the tables bellow, NEED to have a default value
297 * defined, and this value needs to be correct.
300 /* these options will only affect the window manager on startup
302 * static defaults can't access the screen data, because it is
303 * created after these defaults are read
305 WDefaultEntry staticOptionList
[] = {
307 {"ColormapSize", "4", NULL
,
308 &wPreferences
.cmap_size
, getInt
, NULL
, NULL
, NULL
},
309 {"DisableDithering", "NO", NULL
,
310 &wPreferences
.no_dithering
, getBool
, NULL
, NULL
, NULL
},
311 {"IconSize", "64", NULL
,
312 &wPreferences
.icon_size
, getInt
, NULL
, NULL
, NULL
},
313 {"ModifierKey", "Mod1", NULL
,
314 &wPreferences
.modifier_mask
, getModMask
, NULL
, NULL
, NULL
},
315 {"DisableWSMouseActions", "NO", NULL
,
316 &wPreferences
.disable_root_mouse
, getBool
, NULL
, NULL
, NULL
},
317 {"FocusMode", "manual", seFocusModes
, /* have a problem when switching from */
318 &wPreferences
.focus_mode
, getEnum
, NULL
, NULL
, NULL
}, /* manual to sloppy without restart */
319 {"NewStyle", "new", seTitlebarModes
,
320 &wPreferences
.new_style
, getEnum
, NULL
, NULL
, NULL
},
321 {"DisableDock", "NO", (void *)WM_DOCK
,
322 NULL
, getBool
, setIfDockPresent
, NULL
, NULL
},
323 {"DisableClip", "NO", (void *)WM_CLIP
,
324 NULL
, getBool
, setIfDockPresent
, NULL
, NULL
},
325 {"DisableMiniwindows", "NO", NULL
,
326 &wPreferences
.disable_miniwindows
, getBool
, NULL
, NULL
, NULL
}
329 WDefaultEntry optionList
[] = {
331 /* dynamic options */
333 {"IconPosition", "blh", seIconPositions
,
334 &wPreferences
.icon_yard
, getEnum
, setIconPosition
, NULL
, NULL
},
335 {"IconificationStyle", "Zoom", seIconificationStyles
,
336 &wPreferences
.iconification_style
, getEnum
, NULL
, NULL
, NULL
},
337 {"MouseLeftButtonAction", "SelectWindows", seMouseButtonActions
,
338 &wPreferences
.mouse_button1
, getEnum
, NULL
, NULL
, NULL
},
339 {"MouseMiddleButtonAction", "OpenWindowListMenu", seMouseButtonActions
,
340 &wPreferences
.mouse_button2
, getEnum
, NULL
, NULL
, NULL
},
341 {"MouseRightButtonAction", "OpenApplicationsMenu", seMouseButtonActions
,
342 &wPreferences
.mouse_button3
, getEnum
, NULL
, NULL
, NULL
},
343 {"MouseWheelAction", "None", seMouseWheelActions
,
344 &wPreferences
.mouse_wheel
, getEnum
, NULL
, NULL
, NULL
},
345 {"PixmapPath", DEF_PIXMAP_PATHS
, NULL
,
346 &wPreferences
.pixmap_path
, getPathList
, NULL
, NULL
, NULL
},
347 {"IconPath", DEF_ICON_PATHS
, NULL
,
348 &wPreferences
.icon_path
, getPathList
, NULL
, NULL
, NULL
},
349 {"ColormapMode", "auto", seColormapModes
,
350 &wPreferences
.colormap_mode
, getEnum
, NULL
, NULL
, NULL
},
351 {"AutoFocus", "NO", NULL
,
352 &wPreferences
.auto_focus
, getBool
, NULL
, NULL
, NULL
},
353 {"RaiseDelay", "0", NULL
,
354 &wPreferences
.raise_delay
, getInt
, NULL
, NULL
, NULL
},
355 {"CirculateRaise", "NO", NULL
,
356 &wPreferences
.circ_raise
, getBool
, NULL
, NULL
, NULL
},
357 {"Superfluous", "NO", NULL
,
358 &wPreferences
.superfluous
, getBool
, NULL
, NULL
, NULL
},
359 {"AdvanceToNewWorkspace", "NO", NULL
,
360 &wPreferences
.ws_advance
, getBool
, NULL
, NULL
, NULL
},
361 {"CycleWorkspaces", "NO", NULL
,
362 &wPreferences
.ws_cycle
, getBool
, NULL
, NULL
, NULL
},
363 {"WorkspaceNameDisplayPosition", "center", seDisplayPositions
,
364 &wPreferences
.workspace_name_display_position
, getEnum
, NULL
, NULL
, NULL
},
365 {"WorkspaceBorder", "None", seWorkspaceBorder
,
366 &wPreferences
.workspace_border_position
, getEnum
, updateUsableArea
, NULL
, NULL
},
367 {"WorkspaceBorderSize", "0", NULL
,
368 &wPreferences
.workspace_border_size
, getInt
, updateUsableArea
, NULL
, NULL
},
369 {"StickyIcons", "NO", NULL
,
370 &wPreferences
.sticky_icons
, getBool
, setStickyIcons
, NULL
, NULL
},
371 {"SaveSessionOnExit", "NO", NULL
,
372 &wPreferences
.save_session_on_exit
, getBool
, NULL
, NULL
, NULL
},
373 {"WrapMenus", "NO", NULL
,
374 &wPreferences
.wrap_menus
, getBool
, NULL
, NULL
, NULL
},
375 {"ScrollableMenus", "NO", NULL
,
376 &wPreferences
.scrollable_menus
, getBool
, NULL
, NULL
, NULL
},
377 {"MenuScrollSpeed", "medium", seSpeeds
,
378 &wPreferences
.menu_scroll_speed
, getEnum
, NULL
, NULL
, NULL
},
379 {"IconSlideSpeed", "medium", seSpeeds
,
380 &wPreferences
.icon_slide_speed
, getEnum
, NULL
, NULL
, NULL
},
381 {"ShadeSpeed", "medium", seSpeeds
,
382 &wPreferences
.shade_speed
, getEnum
, NULL
, NULL
, NULL
},
383 {"BounceAppIconsWhenUrgent", "YES", NULL
,
384 &wPreferences
.bounce_appicons_when_urgent
, getBool
, NULL
, NULL
, NULL
},
385 {"RaiseAppIconsWhenBouncing", "NO", NULL
,
386 &wPreferences
.raise_appicons_when_bouncing
, getBool
, NULL
, NULL
, NULL
},
387 {"DoubleClickTime", "250", (void *)&wPreferences
.dblclick_time
,
388 &wPreferences
.dblclick_time
, getInt
, setDoubleClick
, NULL
, NULL
},
389 {"AlignSubmenus", "NO", NULL
,
390 &wPreferences
.align_menus
, getBool
, NULL
, NULL
, NULL
},
391 {"OpenTransientOnOwnerWorkspace", "NO", NULL
,
392 &wPreferences
.open_transients_with_parent
, getBool
, NULL
, NULL
, NULL
},
393 {"WindowPlacement", "auto", sePlacements
,
394 &wPreferences
.window_placement
, getEnum
, NULL
, NULL
, NULL
},
395 {"IgnoreFocusClick", "NO", NULL
,
396 &wPreferences
.ignore_focus_click
, getBool
, NULL
, NULL
, NULL
},
397 {"UseSaveUnders", "NO", NULL
,
398 &wPreferences
.use_saveunders
, getBool
, NULL
, NULL
, NULL
},
399 {"OpaqueMove", "NO", NULL
,
400 &wPreferences
.opaque_move
, getBool
, NULL
, NULL
, NULL
},
401 {"DisableAnimations", "NO", NULL
,
402 &wPreferences
.no_animations
, getBool
, NULL
, NULL
, NULL
},
403 {"DontLinkWorkspaces", "NO", NULL
,
404 &wPreferences
.no_autowrap
, getBool
, NULL
, NULL
, NULL
},
405 {"AutoArrangeIcons", "NO", NULL
,
406 &wPreferences
.auto_arrange_icons
, getBool
, NULL
, NULL
, NULL
},
407 {"NoWindowOverDock", "NO", NULL
,
408 &wPreferences
.no_window_over_dock
, getBool
, updateUsableArea
, NULL
, NULL
},
409 {"NoWindowOverIcons", "NO", NULL
,
410 &wPreferences
.no_window_over_icons
, getBool
, updateUsableArea
, NULL
, NULL
},
411 {"WindowPlaceOrigin", "(0, 0)", NULL
,
412 &wPreferences
.window_place_origin
, getCoord
, NULL
, NULL
, NULL
},
413 {"ResizeDisplay", "corner", seGeomDisplays
,
414 &wPreferences
.size_display
, getEnum
, NULL
, NULL
, NULL
},
415 {"MoveDisplay", "corner", seGeomDisplays
,
416 &wPreferences
.move_display
, getEnum
, NULL
, NULL
, NULL
},
417 {"DontConfirmKill", "NO", NULL
,
418 &wPreferences
.dont_confirm_kill
, getBool
, NULL
, NULL
, NULL
},
419 {"WindowTitleBalloons", "NO", NULL
,
420 &wPreferences
.window_balloon
, getBool
, NULL
, NULL
, NULL
},
421 {"MiniwindowTitleBalloons", "NO", NULL
,
422 &wPreferences
.miniwin_balloon
, getBool
, NULL
, NULL
, NULL
},
423 {"AppIconBalloons", "NO", NULL
,
424 &wPreferences
.appicon_balloon
, getBool
, NULL
, NULL
, NULL
},
425 {"HelpBalloons", "NO", NULL
,
426 &wPreferences
.help_balloon
, getBool
, NULL
, NULL
, NULL
},
427 {"EdgeResistance", "30", NULL
,
428 &wPreferences
.edge_resistance
, getInt
, NULL
, NULL
, NULL
},
429 {"ResizeIncrement", "32", NULL
,
430 &wPreferences
.resize_increment
, getInt
, NULL
, NULL
, NULL
},
431 {"Attraction", "NO", NULL
,
432 &wPreferences
.attract
, getBool
, NULL
, NULL
, NULL
},
433 {"DisableBlinking", "NO", NULL
,
434 &wPreferences
.dont_blink
, getBool
, NULL
, NULL
, NULL
},
435 {"SingleClickLaunch", "NO", NULL
,
436 &wPreferences
.single_click
, getBool
, NULL
, NULL
, NULL
},
440 {"MenuStyle", "normal", seMenuStyles
,
441 &wPreferences
.menu_style
, getEnum
, setMenuStyle
, NULL
, NULL
},
442 {"WidgetColor", "(solid, gray)", NULL
,
443 NULL
, getTexture
, setWidgetColor
, NULL
, NULL
},
444 {"WorkspaceSpecificBack", "()", NULL
,
445 NULL
, getWSSpecificBackground
, setWorkspaceSpecificBack
, NULL
, NULL
},
446 /* WorkspaceBack must come after WorkspaceSpecificBack or
447 * WorkspaceBack wont know WorkspaceSpecificBack was also
448 * specified and 2 copies of wmsetbg will be launched */
449 {"WorkspaceBack", "(solid, black)", NULL
,
450 NULL
, getWSBackground
, setWorkspaceBack
, NULL
, NULL
},
451 {"SmoothWorkspaceBack", "NO", NULL
,
452 NULL
, getBool
, NULL
, NULL
, NULL
},
453 {"IconBack", "(solid, gray)", NULL
,
454 NULL
, getTexture
, setIconTile
, NULL
, NULL
},
455 {"TitleJustify", "center", seJustifications
,
456 &wPreferences
.title_justification
, getEnum
, setJustify
, NULL
, NULL
},
457 {"WindowTitleFont", DEF_TITLE_FONT
, NULL
,
458 NULL
, getFont
, setWinTitleFont
, NULL
, NULL
},
459 {"WindowTitleExtendSpace", DEF_WINDOW_TITLE_EXTEND_SPACE
, NULL
,
460 &wPreferences
.window_title_clearance
, getInt
, setClearance
, NULL
, NULL
},
461 {"MenuTitleExtendSpace", DEF_MENU_TITLE_EXTEND_SPACE
, NULL
,
462 &wPreferences
.menu_title_clearance
, getInt
, setClearance
, NULL
, NULL
},
463 {"MenuTextExtendSpace", DEF_MENU_TEXT_EXTEND_SPACE
, NULL
,
464 &wPreferences
.menu_text_clearance
, getInt
, setClearance
, NULL
, NULL
},
465 {"MenuTitleFont", DEF_MENU_TITLE_FONT
, NULL
,
466 NULL
, getFont
, setMenuTitleFont
, NULL
, NULL
},
467 {"MenuTextFont", DEF_MENU_ENTRY_FONT
, NULL
,
468 NULL
, getFont
, setMenuTextFont
, NULL
, NULL
},
469 {"IconTitleFont", DEF_ICON_TITLE_FONT
, NULL
,
470 NULL
, getFont
, setIconTitleFont
, NULL
, NULL
},
471 {"ClipTitleFont", DEF_CLIP_TITLE_FONT
, NULL
,
472 NULL
, getFont
, setClipTitleFont
, NULL
, NULL
},
473 {"ShowClipTitle", "YES", NULL
,
474 &wPreferences
.show_clip_title
, getBool
, NULL
, NULL
, NULL
},
475 {"LargeDisplayFont", DEF_WORKSPACE_NAME_FONT
, NULL
,
476 NULL
, getFont
, setLargeDisplayFont
, NULL
, NULL
},
477 {"HighlightColor", "white", NULL
,
478 NULL
, getColor
, setHightlight
, NULL
, NULL
},
479 {"HighlightTextColor", "black", NULL
,
480 NULL
, getColor
, setHightlightText
, NULL
, NULL
},
481 {"ClipTitleColor", "black", (void *)CLIP_NORMAL
,
482 NULL
, getColor
, setClipTitleColor
, NULL
, NULL
},
483 {"CClipTitleColor", "\"#454045\"", (void *)CLIP_COLLAPSED
,
484 NULL
, getColor
, setClipTitleColor
, NULL
, NULL
},
485 {"FTitleColor", "white", (void *)WS_FOCUSED
,
486 NULL
, getColor
, setWTitleColor
, NULL
, NULL
},
487 {"PTitleColor", "white", (void *)WS_PFOCUSED
,
488 NULL
, getColor
, setWTitleColor
, NULL
, NULL
},
489 {"UTitleColor", "black", (void *)WS_UNFOCUSED
,
490 NULL
, getColor
, setWTitleColor
, NULL
, NULL
},
491 {"FTitleBack", "(solid, black)", NULL
,
492 NULL
, getTexture
, setFTitleBack
, NULL
, NULL
},
493 {"PTitleBack", "(solid, \"#616161\")", NULL
,
494 NULL
, getTexture
, setPTitleBack
, NULL
, NULL
},
495 {"UTitleBack", "(solid, gray)", NULL
,
496 NULL
, getTexture
, setUTitleBack
, NULL
, NULL
},
497 {"ResizebarBack", "(solid, gray)", NULL
,
498 NULL
, getTexture
, setResizebarBack
, NULL
, NULL
},
499 {"MenuTitleColor", "white", NULL
,
500 NULL
, getColor
, setMenuTitleColor
, NULL
, NULL
},
501 {"MenuTextColor", "black", NULL
,
502 NULL
, getColor
, setMenuTextColor
, NULL
, NULL
},
503 {"MenuDisabledColor", "\"#616161\"", NULL
,
504 NULL
, getColor
, setMenuDisabledColor
, NULL
, NULL
},
505 {"MenuTitleBack", "(solid, black)", NULL
,
506 NULL
, getTexture
, setMenuTitleBack
, NULL
, NULL
},
507 {"MenuTextBack", "(solid, gray)", NULL
,
508 NULL
, getTexture
, setMenuTextBack
, NULL
, NULL
},
509 {"IconTitleColor", "white", NULL
,
510 NULL
, getColor
, setIconTitleColor
, NULL
, NULL
},
511 {"IconTitleBack", "black", NULL
,
512 NULL
, getColor
, setIconTitleBack
, NULL
, NULL
},
513 {"SwitchPanelImages", "(swtile.png, swback.png, 30, 40)", &wPreferences
,
514 NULL
, getPropList
, setSwPOptions
, NULL
, NULL
},
518 {"RootMenuKey", "None", (void *)WKBD_ROOTMENU
,
519 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
520 {"WindowListKey", "None", (void *)WKBD_WINDOWLIST
,
521 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
522 {"WindowMenuKey", "None", (void *)WKBD_WINDOWMENU
,
523 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
524 {"DockRaiseLowerKey", "None", (void*)WKBD_DOCKRAISELOWER
,
525 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
526 {"ClipRaiseLowerKey", "None", (void *)WKBD_CLIPRAISELOWER
,
527 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
528 {"MiniaturizeKey", "None", (void *)WKBD_MINIATURIZE
,
529 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
530 {"MinimizeAllKey", "None", (void *)WKBD_MINIMIZEALL
,
531 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
532 {"HideKey", "None", (void *)WKBD_HIDE
,
533 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
534 {"HideOthersKey", "None", (void *)WKBD_HIDE_OTHERS
,
535 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
536 {"MoveResizeKey", "None", (void *)WKBD_MOVERESIZE
,
537 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
538 {"CloseKey", "None", (void *)WKBD_CLOSE
,
539 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
540 {"MaximizeKey", "None", (void *)WKBD_MAXIMIZE
,
541 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
542 {"VMaximizeKey", "None", (void *)WKBD_VMAXIMIZE
,
543 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
544 {"HMaximizeKey", "None", (void *)WKBD_HMAXIMIZE
,
545 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
546 {"LHMaximizeKey", "None", (void*)WKBD_LHMAXIMIZE
,
547 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
548 {"RHMaximizeKey", "None", (void*)WKBD_RHMAXIMIZE
,
549 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
550 {"MaximusKey", "None", (void*)WKBD_MAXIMUS
,
551 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
552 {"RaiseKey", "\"Meta+Up\"", (void *)WKBD_RAISE
,
553 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
554 {"LowerKey", "\"Meta+Down\"", (void *)WKBD_LOWER
,
555 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
556 {"RaiseLowerKey", "None", (void *)WKBD_RAISELOWER
,
557 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
558 {"ShadeKey", "None", (void *)WKBD_SHADE
,
559 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
560 {"SelectKey", "None", (void *)WKBD_SELECT
,
561 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
562 {"FocusNextKey", "None", (void *)WKBD_FOCUSNEXT
,
563 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
564 {"FocusPrevKey", "None", (void *)WKBD_FOCUSPREV
,
565 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
566 {"GroupNextKey", "None", (void *)WKBD_GROUPNEXT
,
567 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
568 {"GroupPrevKey", "None", (void *)WKBD_GROUPPREV
,
569 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
570 {"NextWorkspaceKey", "None", (void *)WKBD_NEXTWORKSPACE
,
571 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
572 {"PrevWorkspaceKey", "None", (void *)WKBD_PREVWORKSPACE
,
573 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
574 {"NextWorkspaceLayerKey", "None", (void *)WKBD_NEXTWSLAYER
,
575 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
576 {"PrevWorkspaceLayerKey", "None", (void *)WKBD_PREVWSLAYER
,
577 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
578 {"Workspace1Key", "None", (void *)WKBD_WORKSPACE1
,
579 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
580 {"Workspace2Key", "None", (void *)WKBD_WORKSPACE2
,
581 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
582 {"Workspace3Key", "None", (void *)WKBD_WORKSPACE3
,
583 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
584 {"Workspace4Key", "None", (void *)WKBD_WORKSPACE4
,
585 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
586 {"Workspace5Key", "None", (void *)WKBD_WORKSPACE5
,
587 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
588 {"Workspace6Key", "None", (void *)WKBD_WORKSPACE6
,
589 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
590 {"Workspace7Key", "None", (void *)WKBD_WORKSPACE7
,
591 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
592 {"Workspace8Key", "None", (void *)WKBD_WORKSPACE8
,
593 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
594 {"Workspace9Key", "None", (void *)WKBD_WORKSPACE9
,
595 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
596 {"Workspace10Key", "None", (void *)WKBD_WORKSPACE10
,
597 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
598 {"WindowShortcut1Key", "None", (void *)WKBD_WINDOW1
,
599 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
600 {"WindowShortcut2Key", "None", (void *)WKBD_WINDOW2
,
601 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
602 {"WindowShortcut3Key", "None", (void *)WKBD_WINDOW3
,
603 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
604 {"WindowShortcut4Key", "None", (void *)WKBD_WINDOW4
,
605 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
606 {"WindowShortcut5Key", "None", (void *)WKBD_WINDOW5
,
607 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
608 {"WindowShortcut6Key", "None", (void *)WKBD_WINDOW6
,
609 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
610 {"WindowShortcut7Key", "None", (void *)WKBD_WINDOW7
,
611 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
612 {"WindowShortcut8Key", "None", (void *)WKBD_WINDOW8
,
613 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
614 {"WindowShortcut9Key", "None", (void *)WKBD_WINDOW9
,
615 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
616 {"WindowShortcut10Key", "None", (void *)WKBD_WINDOW10
,
617 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
618 {"ScreenSwitchKey", "None", (void *)WKBD_SWITCH_SCREEN
,
619 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
621 #ifdef KEEP_XKB_LOCK_STATUS
622 {"ToggleKbdModeKey", "None", (void *)WKBD_TOGGLE
,
623 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
624 {"KbdModeLock", "NO", NULL
,
625 &wPreferences
.modelock
, getBool
, NULL
, NULL
, NULL
},
626 #endif /* KEEP_XKB_LOCK_STATUS */
628 {"NormalCursor", "(builtin, left_ptr)", (void *)WCUR_ROOT
,
629 NULL
, getCursor
, setCursor
, NULL
, NULL
},
630 {"ArrowCursor", "(builtin, top_left_arrow)", (void *)WCUR_ARROW
,
631 NULL
, getCursor
, setCursor
, NULL
, NULL
},
632 {"MoveCursor", "(builtin, fleur)", (void *)WCUR_MOVE
,
633 NULL
, getCursor
, setCursor
, NULL
, NULL
},
634 {"ResizeCursor", "(builtin, sizing)", (void *)WCUR_RESIZE
,
635 NULL
, getCursor
, setCursor
, NULL
, NULL
},
636 {"TopLeftResizeCursor", "(builtin, top_left_corner)", (void *)WCUR_TOPLEFTRESIZE
,
637 NULL
, getCursor
, setCursor
, NULL
, NULL
},
638 {"TopRightResizeCursor", "(builtin, top_right_corner)", (void *)WCUR_TOPRIGHTRESIZE
,
639 NULL
, getCursor
, setCursor
, NULL
, NULL
},
640 {"BottomLeftResizeCursor", "(builtin, bottom_left_corner)", (void *)WCUR_BOTTOMLEFTRESIZE
,
641 NULL
, getCursor
, setCursor
, NULL
, NULL
},
642 {"BottomRightResizeCursor", "(builtin, bottom_right_corner)", (void *)WCUR_BOTTOMRIGHTRESIZE
,
643 NULL
, getCursor
, setCursor
, NULL
, NULL
},
644 {"VerticalResizeCursor", "(builtin, sb_v_double_arrow)", (void *)WCUR_VERTICALRESIZE
,
645 NULL
, getCursor
, setCursor
, NULL
, NULL
},
646 {"HorizontalResizeCursor", "(builtin, sb_h_double_arrow)", (void *)WCUR_HORIZONRESIZE
,
647 NULL
, getCursor
, setCursor
, NULL
, NULL
},
648 {"WaitCursor", "(builtin, watch)", (void *)WCUR_WAIT
,
649 NULL
, getCursor
, setCursor
, NULL
, NULL
},
650 {"QuestionCursor", "(builtin, question_arrow)", (void *)WCUR_QUESTION
,
651 NULL
, getCursor
, setCursor
, NULL
, NULL
},
652 {"TextCursor", "(builtin, xterm)", (void *)WCUR_TEXT
,
653 NULL
, getCursor
, setCursor
, NULL
, NULL
},
654 {"SelectCursor", "(builtin, cross)", (void *)WCUR_SELECT
,
655 NULL
, getCursor
, setCursor
, NULL
, NULL
},
656 {"DialogHistoryLines", "500", NULL
,
657 &wPreferences
.history_lines
, getInt
, NULL
, NULL
, NULL
},
658 {"CycleActiveHeadOnly", "NO", NULL
,
659 &wPreferences
.cycle_active_head_only
, getBool
, NULL
, NULL
, NULL
}
662 static void initDefaults()
665 WDefaultEntry
*entry
;
667 WMPLSetCaseSensitive(False
);
669 for (i
= 0; i
< sizeof(optionList
) / sizeof(WDefaultEntry
); i
++) {
670 entry
= &optionList
[i
];
672 entry
->plkey
= WMCreatePLString(entry
->key
);
673 if (entry
->default_value
)
674 entry
->plvalue
= WMCreatePropListFromDescription(entry
->default_value
);
676 entry
->plvalue
= NULL
;
679 for (i
= 0; i
< sizeof(staticOptionList
) / sizeof(WDefaultEntry
); i
++) {
680 entry
= &staticOptionList
[i
];
682 entry
->plkey
= WMCreatePLString(entry
->key
);
683 if (entry
->default_value
)
684 entry
->plvalue
= WMCreatePropListFromDescription(entry
->default_value
);
686 entry
->plvalue
= NULL
;
690 static WMPropList
*readGlobalDomain(char *domainName
, Bool requireDictionary
)
692 WMPropList
*globalDict
= NULL
;
696 snprintf(path
, sizeof(path
), "%s/%s/%s", SYSCONFDIR
, GLOBAL_DEFAULTS_SUBDIR
, domainName
);
697 if (stat(path
, &stbuf
) >= 0) {
698 globalDict
= WMReadPropListFromFile(path
);
699 if (globalDict
&& requireDictionary
&& !WMIsPLDictionary(globalDict
)) {
700 wwarning(_("Domain %s (%s) of global defaults database is corrupted!"), domainName
, path
);
701 WMReleasePropList(globalDict
);
703 } else if (!globalDict
) {
704 wwarning(_("could not load domain %s from global defaults database"), domainName
);
711 #if defined(GLOBAL_PREAMBLE_MENU_FILE) || defined(GLOBAL_EPILOGUE_MENU_FILE)
712 static void prependMenu(WMPropList
* destarr
, WMPropList
* array
)
717 for (i
= 0; i
< WMGetPropListItemCount(array
); i
++) {
718 item
= WMGetFromPLArray(array
, i
);
720 WMInsertInPLArray(destarr
, i
+ 1, item
);
724 static void appendMenu(WMPropList
* destarr
, WMPropList
* array
)
729 for (i
= 0; i
< WMGetPropListItemCount(array
); i
++) {
730 item
= WMGetFromPLArray(array
, i
);
732 WMAddToPLArray(destarr
, item
);
737 void wDefaultsMergeGlobalMenus(WDDomain
* menuDomain
)
739 WMPropList
*menu
= menuDomain
->dictionary
;
742 if (!menu
|| !WMIsPLArray(menu
))
745 #ifdef GLOBAL_PREAMBLE_MENU_FILE
746 submenu
= WMReadPropListFromFile(SYSCONFDIR
"/" GLOBAL_DEFAULTS_SUBDIR
"/" GLOBAL_PREAMBLE_MENU_FILE
);
748 if (submenu
&& !WMIsPLArray(submenu
)) {
749 wwarning(_("invalid global menu file %s"), GLOBAL_PREAMBLE_MENU_FILE
);
750 WMReleasePropList(submenu
);
754 prependMenu(menu
, submenu
);
755 WMReleasePropList(submenu
);
759 #ifdef GLOBAL_EPILOGUE_MENU_FILE
760 submenu
= WMReadPropListFromFile(SYSCONFDIR
"/" GLOBAL_DEFAULTS_SUBDIR
"/" GLOBAL_EPILOGUE_MENU_FILE
);
762 if (submenu
&& !WMIsPLArray(submenu
)) {
763 wwarning(_("invalid global menu file %s"), GLOBAL_EPILOGUE_MENU_FILE
);
764 WMReleasePropList(submenu
);
768 appendMenu(menu
, submenu
);
769 WMReleasePropList(submenu
);
773 menuDomain
->dictionary
= menu
;
776 void wDefaultsDestroyDomain(WDDomain
* domain
)
778 if (domain
->dictionary
)
779 WMReleasePropList(domain
->dictionary
);
784 WDDomain
*wDefaultsInitDomain(char *domain
, Bool requireDictionary
)
788 static int inited
= 0;
791 WMPropList
*shared_dict
= NULL
;
798 db
= wmalloc(sizeof(WDDomain
));
799 memset(db
, 0, sizeof(WDDomain
));
800 db
->domain_name
= domain
;
801 db
->path
= wdefaultspathfordomain(domain
);
804 if (the_path
&& stat(the_path
, &stbuf
) >= 0) {
805 db
->dictionary
= WMReadPropListFromFile(the_path
);
806 if (db
->dictionary
) {
807 if (requireDictionary
&& !WMIsPLDictionary(db
->dictionary
)) {
808 WMReleasePropList(db
->dictionary
);
809 db
->dictionary
= NULL
;
810 wwarning(_("Domain %s (%s) of defaults database is corrupted!"), domain
, the_path
);
812 db
->timestamp
= stbuf
.st_mtime
;
814 wwarning(_("could not load domain %s from user defaults database"), domain
);
818 /* global system dictionary */
819 snprintf(path
, sizeof(path
), "%s/%s/%s", SYSCONFDIR
, GLOBAL_DEFAULTS_SUBDIR
, domain
);
820 if (stat(path
, &stbuf
) >= 0) {
821 shared_dict
= WMReadPropListFromFile(path
);
823 if (requireDictionary
&& !WMIsPLDictionary(shared_dict
)) {
824 wwarning(_("Domain %s (%s) of global defaults database is corrupted!"),
826 WMReleasePropList(shared_dict
);
829 if (db
->dictionary
&& WMIsPLDictionary(shared_dict
) &&
830 WMIsPLDictionary(db
->dictionary
)) {
831 WMMergePLDictionaries(shared_dict
, db
->dictionary
, True
);
832 WMReleasePropList(db
->dictionary
);
833 db
->dictionary
= shared_dict
;
834 if (stbuf
.st_mtime
> db
->timestamp
)
835 db
->timestamp
= stbuf
.st_mtime
;
836 } else if (!db
->dictionary
) {
837 db
->dictionary
= shared_dict
;
838 if (stbuf
.st_mtime
> db
->timestamp
)
839 db
->timestamp
= stbuf
.st_mtime
;
843 wwarning(_("could not load domain %s from global defaults database (%s)"), domain
, path
);
850 void wReadStaticDefaults(WMPropList
* dict
)
853 WDefaultEntry
*entry
;
857 for (i
= 0; i
< sizeof(staticOptionList
) / sizeof(WDefaultEntry
); i
++) {
858 entry
= &staticOptionList
[i
];
861 plvalue
= WMGetFromPLDictionary(dict
, entry
->plkey
);
866 /* no default in the DB. Use builtin default */
867 plvalue
= entry
->plvalue
;
872 (*entry
->convert
) (NULL
, entry
, plvalue
, entry
->addr
, &tdata
);
874 (*entry
->update
) (NULL
, entry
, tdata
, entry
->extra_data
);
880 void wDefaultsCheckDomains(void* arg
)
884 WMPropList
*shared_dict
= NULL
;
888 if (stat(WDWindowMaker
->path
, &stbuf
) >= 0 && WDWindowMaker
->timestamp
< stbuf
.st_mtime
) {
889 WDWindowMaker
->timestamp
= stbuf
.st_mtime
;
891 /* global dictionary */
892 shared_dict
= readGlobalDomain("WindowMaker", True
);
893 /* user dictionary */
894 dict
= WMReadPropListFromFile(WDWindowMaker
->path
);
896 if (!WMIsPLDictionary(dict
)) {
897 WMReleasePropList(dict
);
899 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
900 "WindowMaker", WDWindowMaker
->path
);
903 WMMergePLDictionaries(shared_dict
, dict
, True
);
904 WMReleasePropList(dict
);
908 for (i
= 0; i
< wScreenCount
; i
++) {
909 scr
= wScreenWithNumber(i
);
911 wReadDefaults(scr
, dict
);
913 if (WDWindowMaker
->dictionary
) {
914 WMReleasePropList(WDWindowMaker
->dictionary
);
916 WDWindowMaker
->dictionary
= dict
;
919 wwarning(_("could not load domain %s from user defaults database"), "WindowMaker");
922 WMReleasePropList(shared_dict
);
926 if (stat(WDWindowAttributes
->path
, &stbuf
) >= 0 && WDWindowAttributes
->timestamp
< stbuf
.st_mtime
) {
927 /* global dictionary */
928 shared_dict
= readGlobalDomain("WMWindowAttributes", True
);
929 /* user dictionary */
930 dict
= WMReadPropListFromFile(WDWindowAttributes
->path
);
932 if (!WMIsPLDictionary(dict
)) {
933 WMReleasePropList(dict
);
935 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
936 "WMWindowAttributes", WDWindowAttributes
->path
);
939 WMMergePLDictionaries(shared_dict
, dict
, True
);
940 WMReleasePropList(dict
);
944 if (WDWindowAttributes
->dictionary
) {
945 WMReleasePropList(WDWindowAttributes
->dictionary
);
947 WDWindowAttributes
->dictionary
= dict
;
948 for (i
= 0; i
< wScreenCount
; i
++) {
949 scr
= wScreenWithNumber(i
);
953 wDefaultUpdateIcons(scr
);
955 /* Update the panel image if changed */
956 /* Don't worry. If the image is the same these
957 * functions will have no performance impact. */
958 image
= wDefaultGetImage(scr
, "Logo", "WMPanel");
961 wwarning(_("could not load logo image for panels: %s"),
962 RMessageForError(RErrorCode
));
964 WMSetApplicationIconImage(scr
->wmscreen
, image
);
965 RReleaseImage(image
);
971 wwarning(_("could not load domain %s from user defaults database"), "WMWindowAttributes");
973 WDWindowAttributes
->timestamp
= stbuf
.st_mtime
;
975 WMReleasePropList(shared_dict
);
979 if (stat(WDRootMenu
->path
, &stbuf
) >= 0 && WDRootMenu
->timestamp
< stbuf
.st_mtime
) {
980 dict
= WMReadPropListFromFile(WDRootMenu
->path
);
982 if (!WMIsPLArray(dict
) && !WMIsPLString(dict
)) {
983 WMReleasePropList(dict
);
985 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
986 "WMRootMenu", WDRootMenu
->path
);
988 if (WDRootMenu
->dictionary
) {
989 WMReleasePropList(WDRootMenu
->dictionary
);
991 WDRootMenu
->dictionary
= dict
;
992 wDefaultsMergeGlobalMenus(WDRootMenu
);
995 wwarning(_("could not load domain %s from user defaults database"), "WMRootMenu");
997 WDRootMenu
->timestamp
= stbuf
.st_mtime
;
1001 WMAddTimerHandler(DEFAULTS_CHECK_INTERVAL
, wDefaultsCheckDomains
, arg
);
1005 void wReadDefaults(WScreen
* scr
, WMPropList
* new_dict
)
1007 WMPropList
*plvalue
, *old_value
;
1008 WDefaultEntry
*entry
;
1009 unsigned int i
, must_update
;
1010 int update_workspace_back
= 0; /* kluge :/ */
1011 unsigned int needs_refresh
;
1013 WMPropList
*old_dict
= (WDWindowMaker
->dictionary
!= new_dict
? WDWindowMaker
->dictionary
: NULL
);
1019 for (i
= 0; i
< sizeof(optionList
) / sizeof(WDefaultEntry
); i
++) {
1020 entry
= &optionList
[i
];
1023 plvalue
= WMGetFromPLDictionary(new_dict
, entry
->plkey
);
1030 old_value
= WMGetFromPLDictionary(old_dict
, entry
->plkey
);
1032 if (!plvalue
&& !old_value
) {
1033 /* no default in the DB. Use builtin default */
1034 plvalue
= entry
->plvalue
;
1035 if (plvalue
&& new_dict
) {
1036 WMPutInPLDictionary(new_dict
, entry
->plkey
, plvalue
);
1039 } else if (!plvalue
) {
1040 /* value was deleted from DB. Keep current value */
1042 } else if (!old_value
) {
1043 /* set value for the 1st time */
1044 } else if (!WMIsPropListEqualTo(plvalue
, old_value
)) {
1045 /* value has changed */
1048 if (strcmp(entry
->key
, "WorkspaceBack") == 0
1049 && update_workspace_back
&& scr
->flags
.backimage_helper_launched
) {
1051 /* value was not changed since last time */
1058 if ((*entry
->convert
) (scr
, entry
, plvalue
, entry
->addr
, &tdata
)) {
1060 * If the WorkspaceSpecificBack data has been changed
1061 * so that the helper will be launched now, we must be
1062 * sure to send the default background texture config
1065 if (strcmp(entry
->key
, "WorkspaceSpecificBack") == 0
1066 && !scr
->flags
.backimage_helper_launched
) {
1067 update_workspace_back
= 1;
1069 if (entry
->update
) {
1070 needs_refresh
|= (*entry
->update
) (scr
, entry
, tdata
, entry
->extra_data
);
1076 if (needs_refresh
!= 0 && !scr
->flags
.startup
) {
1080 if (needs_refresh
& REFRESH_MENU_TITLE_TEXTURE
)
1081 foo
|= WTextureSettings
;
1082 if (needs_refresh
& REFRESH_MENU_TITLE_FONT
)
1083 foo
|= WFontSettings
;
1084 if (needs_refresh
& REFRESH_MENU_TITLE_COLOR
)
1085 foo
|= WColorSettings
;
1087 WMPostNotificationName(WNMenuTitleAppearanceSettingsChanged
, NULL
,
1088 (void *)(uintptr_t) foo
);
1091 if (needs_refresh
& REFRESH_MENU_TEXTURE
)
1092 foo
|= WTextureSettings
;
1093 if (needs_refresh
& REFRESH_MENU_FONT
)
1094 foo
|= WFontSettings
;
1095 if (needs_refresh
& REFRESH_MENU_COLOR
)
1096 foo
|= WColorSettings
;
1098 WMPostNotificationName(WNMenuAppearanceSettingsChanged
, NULL
, (void *)(uintptr_t) foo
);
1101 if (needs_refresh
& REFRESH_WINDOW_FONT
) {
1102 foo
|= WFontSettings
;
1104 if (needs_refresh
& REFRESH_WINDOW_TEXTURES
) {
1105 foo
|= WTextureSettings
;
1107 if (needs_refresh
& REFRESH_WINDOW_TITLE_COLOR
) {
1108 foo
|= WColorSettings
;
1111 WMPostNotificationName(WNWindowAppearanceSettingsChanged
, NULL
, (void *)(uintptr_t) foo
);
1113 if (!(needs_refresh
& REFRESH_ICON_TILE
)) {
1115 if (needs_refresh
& REFRESH_ICON_FONT
) {
1116 foo
|= WFontSettings
;
1118 if (needs_refresh
& REFRESH_ICON_TITLE_COLOR
) {
1119 foo
|= WTextureSettings
;
1121 if (needs_refresh
& REFRESH_ICON_TITLE_BACK
) {
1122 foo
|= WTextureSettings
;
1125 WMPostNotificationName(WNIconAppearanceSettingsChanged
, NULL
,
1126 (void *)(uintptr_t) foo
);
1128 if (needs_refresh
& REFRESH_ICON_TILE
)
1129 WMPostNotificationName(WNIconTileSettingsChanged
, NULL
, NULL
);
1133 void wDefaultUpdateIcons(WScreen
* scr
)
1135 WAppIcon
*aicon
= scr
->app_icon_list
;
1136 WWindow
*wwin
= scr
->focused_window
;
1140 file
= wDefaultGetIconFile(scr
, aicon
->wm_instance
, aicon
->wm_class
, False
);
1141 if ((file
&& aicon
->icon
->file
&& strcmp(file
, aicon
->icon
->file
) != 0)
1142 || (file
&& !aicon
->icon
->file
)) {
1145 if (aicon
->icon
->file
)
1146 wfree(aicon
->icon
->file
);
1147 aicon
->icon
->file
= wstrdup(file
);
1149 new_image
= wDefaultGetImage(scr
, aicon
->wm_instance
, aicon
->wm_class
);
1151 wIconChangeImage(aicon
->icon
, new_image
);
1152 wAppIconPaint(aicon
);
1155 aicon
= aicon
->next
;
1158 if (!wPreferences
.flags
.noclip
)
1159 wClipIconPaint(scr
->clip_icon
);
1162 if (wwin
->icon
&& wwin
->flags
.miniaturized
) {
1163 file
= wDefaultGetIconFile(scr
, wwin
->wm_instance
, wwin
->wm_class
, False
);
1164 if ((file
&& wwin
->icon
->file
&& strcmp(file
, wwin
->icon
->file
) != 0)
1165 || (file
&& !wwin
->icon
->file
)) {
1168 if (wwin
->icon
->file
)
1169 wfree(wwin
->icon
->file
);
1170 wwin
->icon
->file
= wstrdup(file
);
1172 new_image
= wDefaultGetImage(scr
, wwin
->wm_instance
, wwin
->wm_class
);
1174 wIconChangeImage(wwin
->icon
, new_image
);
1181 /* --------------------------- Local ----------------------- */
1183 #define GET_STRING_OR_DEFAULT(x, var) if (!WMIsPLString(value)) { \
1184 wwarning(_("Wrong option format for key \"%s\". Should be %s."), \
1186 wwarning(_("using default \"%s\" instead"), entry->default_value); \
1187 var = entry->default_value;\
1188 } else var = WMGetFromPLString(value)\
1191 static int string2index(WMPropList * key, WMPropList * val, char *def, WOptionEnumeration * values)
1194 WOptionEnumeration
*v
;
1195 char buffer
[TOTAL_VALUES_LENGTH
];
1197 if (WMIsPLString(val
) && (str
= WMGetFromPLString(val
))) {
1198 for (v
= values
; v
->string
!= NULL
; v
++) {
1199 if (strcasecmp(v
->string
, str
) == 0)
1205 for (v
= values
; v
->string
!= NULL
; v
++) {
1208 strcat(buffer
, ", ");
1209 snprintf(buffer
+strlen(buffer
),
1210 sizeof(buffer
)-strlen(buffer
)-1, "\"%s\"", v
->string
);
1213 wwarning(_("wrong option value for key \"%s\"; got \"%s\", should be one of %s."),
1214 WMGetFromPLString(key
),
1215 WMIsPLString(val
) ? WMGetFromPLString(val
) : "(unknown)",
1219 return string2index(key
, val
, NULL
, values
);
1226 * value - is the value in the defaults DB
1227 * addr - is the address to store the data
1228 * ret - is the address to store a pointer to a temporary buffer. ret
1229 * must not be freed and is used by the set functions
1231 static int getBool(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1235 int second_pass
= 0;
1237 GET_STRING_OR_DEFAULT("Boolean", val
);
1240 if ((val
[1] == '\0' && (val
[0] == 'y' || val
[0] == 'Y'))
1241 || strcasecmp(val
, "YES") == 0) {
1244 } else if ((val
[1] == '\0' && (val
[0] == 'n' || val
[0] == 'N'))
1245 || strcasecmp(val
, "NO") == 0) {
1249 if (sscanf(val
, "%i", &i
) == 1) {
1255 wwarning(_("can't convert \"%s\" to boolean for key \"%s\""), val
, entry
->key
);
1256 if (second_pass
== 0) {
1257 val
= WMGetFromPLString(entry
->plvalue
);
1259 wwarning(_("using default \"%s\" instead"), val
);
1269 *(char *)addr
= data
;
1274 static int getInt(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1279 GET_STRING_OR_DEFAULT("Integer", val
);
1281 if (sscanf(val
, "%i", &data
) != 1) {
1282 wwarning(_("can't convert \"%s\" to integer for key \"%s\""), val
, entry
->key
);
1283 val
= WMGetFromPLString(entry
->plvalue
);
1284 wwarning(_("using default \"%s\" instead"), val
);
1285 if (sscanf(val
, "%i", &data
) != 1) {
1293 *(int *)addr
= data
;
1298 static int getCoord(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1301 char *val_x
, *val_y
;
1302 int nelem
, changed
= 0;
1303 WMPropList
*elem_x
, *elem_y
;
1306 if (!WMIsPLArray(value
)) {
1307 wwarning(_("Wrong option format for key \"%s\". Should be %s."), entry
->key
, "Coordinate");
1309 value
= entry
->plvalue
;
1311 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1317 nelem
= WMGetPropListItemCount(value
);
1319 wwarning(_("Incorrect number of elements in array for key \"%s\"."), entry
->key
);
1321 value
= entry
->plvalue
;
1323 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1329 elem_x
= WMGetFromPLArray(value
, 0);
1330 elem_y
= WMGetFromPLArray(value
, 1);
1332 if (!elem_x
|| !elem_y
|| !WMIsPLString(elem_x
) || !WMIsPLString(elem_y
)) {
1333 wwarning(_("Wrong value for key \"%s\". Should be Coordinate."), entry
->key
);
1335 value
= entry
->plvalue
;
1337 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1343 val_x
= WMGetFromPLString(elem_x
);
1344 val_y
= WMGetFromPLString(elem_y
);
1346 if (sscanf(val_x
, "%i", &data
.x
) != 1 || sscanf(val_y
, "%i", &data
.y
) != 1) {
1347 wwarning(_("can't convert array to integers for \"%s\"."), entry
->key
);
1349 value
= entry
->plvalue
;
1351 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1359 else if (data
.x
> scr
->scr_width
/ 3)
1360 data
.x
= scr
->scr_width
/ 3;
1363 else if (data
.y
> scr
->scr_height
/ 3)
1364 data
.y
= scr
->scr_height
/ 3;
1369 *(WCoord
*) addr
= data
;
1374 static int getPropList(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1376 WMRetainPropList(value
);
1383 static int getPathList(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1392 if (!WMIsPLArray(value
)) {
1393 wwarning(_("Wrong option format for key \"%s\". Should be %s."), entry
->key
, "an array of paths");
1395 value
= entry
->plvalue
;
1397 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1404 count
= WMGetPropListItemCount(value
);
1407 value
= entry
->plvalue
;
1409 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1416 for (i
= 0; i
< count
; i
++) {
1417 d
= WMGetFromPLArray(value
, i
);
1418 if (!d
|| !WMIsPLString(d
)) {
1422 len
+= strlen(WMGetFromPLString(d
)) + 1;
1425 ptr
= data
= wmalloc(len
+ 1);
1427 for (i
= 0; i
< count
; i
++) {
1428 d
= WMGetFromPLArray(value
, i
);
1429 if (!d
|| !WMIsPLString(d
)) {
1432 strcpy(ptr
, WMGetFromPLString(d
));
1433 ptr
+= strlen(WMGetFromPLString(d
));
1440 if (*(char **)addr
!= NULL
) {
1441 wfree(*(char **)addr
);
1443 *(char **)addr
= data
;
1448 static int getEnum(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1450 static signed char data
;
1452 data
= string2index(entry
->plkey
, value
, entry
->default_value
, (WOptionEnumeration
*) entry
->extra_data
);
1459 *(signed char *)addr
= data
;
1466 * (hgradient <color> <color>)
1467 * (vgradient <color> <color>)
1468 * (dgradient <color> <color>)
1469 * (mhgradient <color> <color> ...)
1470 * (mvgradient <color> <color> ...)
1471 * (mdgradient <color> <color> ...)
1472 * (igradient <color1> <color1> <thickness1> <color2> <color2> <thickness2>)
1473 * (tpixmap <file> <color>)
1474 * (spixmap <file> <color>)
1475 * (cpixmap <file> <color>)
1476 * (thgradient <file> <opaqueness> <color> <color>)
1477 * (tvgradient <file> <opaqueness> <color> <color>)
1478 * (tdgradient <file> <opaqueness> <color> <color>)
1479 * (function <lib> <function> ...)
1482 static WTexture
*parse_texture(WScreen
* scr
, WMPropList
* pl
)
1487 WTexture
*texture
= NULL
;
1489 nelem
= WMGetPropListItemCount(pl
);
1493 elem
= WMGetFromPLArray(pl
, 0);
1494 if (!elem
|| !WMIsPLString(elem
))
1496 val
= WMGetFromPLString(elem
);
1498 if (strcasecmp(val
, "solid") == 0) {
1506 elem
= WMGetFromPLArray(pl
, 1);
1507 if (!elem
|| !WMIsPLString(elem
))
1509 val
= WMGetFromPLString(elem
);
1511 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &color
)) {
1512 wwarning(_("\"%s\" is not a valid color name"), val
);
1516 texture
= (WTexture
*) wTextureMakeSolid(scr
, &color
);
1517 } else if (strcasecmp(val
, "dgradient") == 0
1518 || strcasecmp(val
, "vgradient") == 0 || strcasecmp(val
, "hgradient") == 0) {
1519 RColor color1
, color2
;
1524 wwarning(_("bad number of arguments in gradient specification"));
1528 if (val
[0] == 'd' || val
[0] == 'D')
1529 type
= WTEX_DGRADIENT
;
1530 else if (val
[0] == 'h' || val
[0] == 'H')
1531 type
= WTEX_HGRADIENT
;
1533 type
= WTEX_VGRADIENT
;
1535 /* get from color */
1536 elem
= WMGetFromPLArray(pl
, 1);
1537 if (!elem
|| !WMIsPLString(elem
))
1539 val
= WMGetFromPLString(elem
);
1541 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1542 wwarning(_("\"%s\" is not a valid color name"), val
);
1546 color1
.red
= xcolor
.red
>> 8;
1547 color1
.green
= xcolor
.green
>> 8;
1548 color1
.blue
= xcolor
.blue
>> 8;
1551 elem
= WMGetFromPLArray(pl
, 2);
1552 if (!elem
|| !WMIsPLString(elem
)) {
1555 val
= WMGetFromPLString(elem
);
1557 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1558 wwarning(_("\"%s\" is not a valid color name"), val
);
1562 color2
.red
= xcolor
.red
>> 8;
1563 color2
.green
= xcolor
.green
>> 8;
1564 color2
.blue
= xcolor
.blue
>> 8;
1566 texture
= (WTexture
*) wTextureMakeGradient(scr
, type
, &color1
, &color2
);
1568 } else if (strcasecmp(val
, "igradient") == 0) {
1569 RColor colors1
[2], colors2
[2];
1575 wwarning(_("bad number of arguments in gradient specification"));
1579 /* get from color */
1580 for (i
= 0; i
< 2; i
++) {
1581 elem
= WMGetFromPLArray(pl
, 1 + i
);
1582 if (!elem
|| !WMIsPLString(elem
))
1584 val
= WMGetFromPLString(elem
);
1586 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1587 wwarning(_("\"%s\" is not a valid color name"), val
);
1590 colors1
[i
].alpha
= 255;
1591 colors1
[i
].red
= xcolor
.red
>> 8;
1592 colors1
[i
].green
= xcolor
.green
>> 8;
1593 colors1
[i
].blue
= xcolor
.blue
>> 8;
1595 elem
= WMGetFromPLArray(pl
, 3);
1596 if (!elem
|| !WMIsPLString(elem
))
1598 val
= WMGetFromPLString(elem
);
1601 /* get from color */
1602 for (i
= 0; i
< 2; i
++) {
1603 elem
= WMGetFromPLArray(pl
, 4 + i
);
1604 if (!elem
|| !WMIsPLString(elem
))
1606 val
= WMGetFromPLString(elem
);
1608 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1609 wwarning(_("\"%s\" is not a valid color name"), val
);
1612 colors2
[i
].alpha
= 255;
1613 colors2
[i
].red
= xcolor
.red
>> 8;
1614 colors2
[i
].green
= xcolor
.green
>> 8;
1615 colors2
[i
].blue
= xcolor
.blue
>> 8;
1617 elem
= WMGetFromPLArray(pl
, 6);
1618 if (!elem
|| !WMIsPLString(elem
))
1620 val
= WMGetFromPLString(elem
);
1623 texture
= (WTexture
*) wTextureMakeIGradient(scr
, th1
, colors1
, th2
, colors2
);
1625 } else if (strcasecmp(val
, "mhgradient") == 0
1626 || strcasecmp(val
, "mvgradient") == 0 || strcasecmp(val
, "mdgradient") == 0) {
1633 wwarning(_("too few arguments in multicolor gradient specification"));
1637 if (val
[1] == 'h' || val
[1] == 'H')
1638 type
= WTEX_MHGRADIENT
;
1639 else if (val
[1] == 'v' || val
[1] == 'V')
1640 type
= WTEX_MVGRADIENT
;
1642 type
= WTEX_MDGRADIENT
;
1646 colors
= wmalloc(sizeof(RColor
*) * (count
+ 1));
1648 for (i
= 0; i
< count
; i
++) {
1649 elem
= WMGetFromPLArray(pl
, i
+ 1);
1650 if (!elem
|| !WMIsPLString(elem
)) {
1651 for (--i
; i
>= 0; --i
) {
1657 val
= WMGetFromPLString(elem
);
1659 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &color
)) {
1660 wwarning(_("\"%s\" is not a valid color name"), val
);
1661 for (--i
; i
>= 0; --i
) {
1667 colors
[i
] = wmalloc(sizeof(RColor
));
1668 colors
[i
]->red
= color
.red
>> 8;
1669 colors
[i
]->green
= color
.green
>> 8;
1670 colors
[i
]->blue
= color
.blue
>> 8;
1675 texture
= (WTexture
*) wTextureMakeMGradient(scr
, type
, colors
);
1676 } else if (strcasecmp(val
, "spixmap") == 0 ||
1677 strcasecmp(val
, "cpixmap") == 0 || strcasecmp(val
, "tpixmap") == 0) {
1684 if (val
[0] == 's' || val
[0] == 'S')
1686 else if (val
[0] == 'c' || val
[0] == 'C')
1692 elem
= WMGetFromPLArray(pl
, 2);
1693 if (!elem
|| !WMIsPLString(elem
)) {
1696 val
= WMGetFromPLString(elem
);
1698 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &color
)) {
1699 wwarning(_("\"%s\" is not a valid color name"), val
);
1704 elem
= WMGetFromPLArray(pl
, 1);
1705 if (!elem
|| !WMIsPLString(elem
))
1707 val
= WMGetFromPLString(elem
);
1709 texture
= (WTexture
*) wTextureMakePixmap(scr
, type
, val
, &color
);
1710 } else if (strcasecmp(val
, "thgradient") == 0
1711 || strcasecmp(val
, "tvgradient") == 0 || strcasecmp(val
, "tdgradient") == 0) {
1712 RColor color1
, color2
;
1717 if (val
[1] == 'h' || val
[1] == 'H')
1718 style
= WTEX_THGRADIENT
;
1719 else if (val
[1] == 'v' || val
[1] == 'V')
1720 style
= WTEX_TVGRADIENT
;
1722 style
= WTEX_TDGRADIENT
;
1725 wwarning(_("bad number of arguments in textured gradient specification"));
1729 /* get from color */
1730 elem
= WMGetFromPLArray(pl
, 3);
1731 if (!elem
|| !WMIsPLString(elem
))
1733 val
= WMGetFromPLString(elem
);
1735 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1736 wwarning(_("\"%s\" is not a valid color name"), val
);
1740 color1
.red
= xcolor
.red
>> 8;
1741 color1
.green
= xcolor
.green
>> 8;
1742 color1
.blue
= xcolor
.blue
>> 8;
1745 elem
= WMGetFromPLArray(pl
, 4);
1746 if (!elem
|| !WMIsPLString(elem
)) {
1749 val
= WMGetFromPLString(elem
);
1751 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1752 wwarning(_("\"%s\" is not a valid color name"), val
);
1756 color2
.red
= xcolor
.red
>> 8;
1757 color2
.green
= xcolor
.green
>> 8;
1758 color2
.blue
= xcolor
.blue
>> 8;
1761 elem
= WMGetFromPLArray(pl
, 2);
1762 if (!elem
|| !WMIsPLString(elem
))
1765 val
= WMGetFromPLString(elem
);
1767 if (!val
|| (opacity
= atoi(val
)) < 0 || opacity
> 255) {
1768 wwarning(_("bad opacity value for tgradient texture \"%s\". Should be [0..255]"), val
);
1773 elem
= WMGetFromPLArray(pl
, 1);
1774 if (!elem
|| !WMIsPLString(elem
))
1776 val
= WMGetFromPLString(elem
);
1778 texture
= (WTexture
*) wTextureMakeTGradient(scr
, style
, &color1
, &color2
, val
, opacity
);
1779 } else if (strcasecmp(val
, "function") == 0) {
1780 /* Leave this in to handle the unlikely case of
1781 * someone actually having function textures configured */
1782 wwarning("function texture support has been removed");
1785 wwarning(_("invalid texture type %s"), val
);
1791 static int getTexture(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1793 static WTexture
*texture
;
1797 if (!WMIsPLArray(value
)) {
1798 wwarning(_("Wrong option format for key \"%s\". Should be %s."), entry
->key
, "Texture");
1800 value
= entry
->plvalue
;
1802 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1808 if (strcmp(entry
->key
, "WidgetColor") == 0 && !changed
) {
1811 pl
= WMGetFromPLArray(value
, 0);
1812 if (!pl
|| !WMIsPLString(pl
) || !WMGetFromPLString(pl
)
1813 || strcasecmp(WMGetFromPLString(pl
), "solid") != 0) {
1814 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1815 entry
->key
, "Solid Texture");
1817 value
= entry
->plvalue
;
1819 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1824 texture
= parse_texture(scr
, value
);
1827 wwarning(_("Error in texture specification for key \"%s\""), entry
->key
);
1829 value
= entry
->plvalue
;
1831 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1841 *(WTexture
**) addr
= texture
;
1846 static int getWSBackground(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1854 if (!WMIsPLArray(value
)) {
1855 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1856 "WorkspaceBack", "Texture or None");
1858 value
= entry
->plvalue
;
1860 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1866 /* only do basic error checking and verify for None texture */
1868 nelem
= WMGetPropListItemCount(value
);
1870 elem
= WMGetFromPLArray(value
, 0);
1871 if (!elem
|| !WMIsPLString(elem
)) {
1872 wwarning(_("Wrong type for workspace background. Should be a texture type."));
1874 value
= entry
->plvalue
;
1876 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1881 val
= WMGetFromPLString(elem
);
1883 if (strcasecmp(val
, "None") == 0)
1886 *ret
= WMRetainPropList(value
);
1892 getWSSpecificBackground(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1899 if (!WMIsPLArray(value
)) {
1900 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1901 "WorkspaceSpecificBack", "an array of textures");
1903 value
= entry
->plvalue
;
1905 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1911 /* only do basic error checking and verify for None texture */
1913 nelem
= WMGetPropListItemCount(value
);
1916 elem
= WMGetFromPLArray(value
, nelem
);
1917 if (!elem
|| !WMIsPLArray(elem
)) {
1918 wwarning(_("Wrong type for background of workspace %i. Should be a texture."),
1924 *ret
= WMRetainPropList(value
);
1928 * Kluge to force wmsetbg helper to set the default background.
1929 * If the WorkspaceSpecificBack is changed once wmaker has started,
1930 * the WorkspaceBack won't be sent to the helper, unless the user
1931 * changes it's value too. So, we must force this by removing the
1932 * value from the defaults DB.
1934 if (!scr
->flags
.backimage_helper_launched
&& !scr
->flags
.startup
) {
1935 WMPropList
*key
= WMCreatePLString("WorkspaceBack");
1937 WMRemoveFromPLDictionary(WDWindowMaker
->dictionary
, key
);
1939 WMReleasePropList(key
);
1945 static int getFont(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1947 static WMFont
*font
;
1950 GET_STRING_OR_DEFAULT("Font", val
);
1952 font
= WMCreateFont(scr
->wmscreen
, val
);
1954 font
= WMCreateFont(scr
->wmscreen
, "fixed");
1957 wfatal(_("could not load any usable font!!!"));
1964 /* can't assign font value outside update function */
1965 wassertrv(addr
== NULL
, True
);
1970 static int getColor(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1972 static XColor color
;
1974 int second_pass
= 0;
1976 GET_STRING_OR_DEFAULT("Color", val
);
1979 if (!wGetColor(scr
, val
, &color
)) {
1980 wwarning(_("could not get color for key \"%s\""), entry
->key
);
1981 if (second_pass
== 0) {
1982 val
= WMGetFromPLString(entry
->plvalue
);
1984 wwarning(_("using default \"%s\" instead"), val
);
1993 assert(addr
== NULL
);
1996 *(unsigned long*)addr = pixel;
2002 static int getKeybind(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
2004 static WShortKey shortcut
;
2008 char buf
[MAX_SHORTCUT_LENGTH
], *b
;
2010 GET_STRING_OR_DEFAULT("Key spec", val
);
2012 if (!val
|| strcasecmp(val
, "NONE") == 0) {
2013 shortcut
.keycode
= 0;
2014 shortcut
.modifier
= 0;
2020 strncpy(buf
, val
, MAX_SHORTCUT_LENGTH
);
2025 shortcut
.modifier
= 0;
2026 while ((k
= strchr(b
, '+')) != NULL
) {
2030 mod
= wXModifierFromKey(b
);
2032 wwarning(_("%s: invalid key modifier \"%s\""), entry
->key
, b
);
2035 shortcut
.modifier
|= mod
;
2041 ksym
= XStringToKeysym(b
);
2043 if (ksym
== NoSymbol
) {
2044 wwarning(_("%s:invalid kbd shortcut specification \"%s\""), entry
->key
, val
);
2048 shortcut
.keycode
= XKeysymToKeycode(dpy
, ksym
);
2049 if (shortcut
.keycode
== 0) {
2050 wwarning(_("%s:invalid key in shortcut \"%s\""), entry
->key
, val
);
2060 static int getModMask(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
2065 GET_STRING_OR_DEFAULT("Modifier Key", str
);
2070 mask
= wXModifierFromKey(str
);
2072 wwarning(_("%s: modifier key %s is not valid"), entry
->key
, str
);
2078 *(int *)addr
= mask
;
2086 # include <X11/cursorfont.h>
2092 #define CURSOR_ID_NONE (XC_num_glyphs)
2094 static WCursorLookup cursor_table
[] = {
2095 {"X_cursor", XC_X_cursor
},
2096 {"arrow", XC_arrow
},
2097 {"based_arrow_down", XC_based_arrow_down
},
2098 {"based_arrow_up", XC_based_arrow_up
},
2100 {"bogosity", XC_bogosity
},
2101 {"bottom_left_corner", XC_bottom_left_corner
},
2102 {"bottom_right_corner", XC_bottom_right_corner
},
2103 {"bottom_side", XC_bottom_side
},
2104 {"bottom_tee", XC_bottom_tee
},
2105 {"box_spiral", XC_box_spiral
},
2106 {"center_ptr", XC_center_ptr
},
2107 {"circle", XC_circle
},
2108 {"clock", XC_clock
},
2109 {"coffee_mug", XC_coffee_mug
},
2110 {"cross", XC_cross
},
2111 {"cross_reverse", XC_cross_reverse
},
2112 {"crosshair", XC_crosshair
},
2113 {"diamond_cross", XC_diamond_cross
},
2115 {"dotbox", XC_dotbox
},
2116 {"double_arrow", XC_double_arrow
},
2117 {"draft_large", XC_draft_large
},
2118 {"draft_small", XC_draft_small
},
2119 {"draped_box", XC_draped_box
},
2120 {"exchange", XC_exchange
},
2121 {"fleur", XC_fleur
},
2122 {"gobbler", XC_gobbler
},
2123 {"gumby", XC_gumby
},
2124 {"hand1", XC_hand1
},
2125 {"hand2", XC_hand2
},
2126 {"heart", XC_heart
},
2128 {"iron_cross", XC_iron_cross
},
2129 {"left_ptr", XC_left_ptr
},
2130 {"left_side", XC_left_side
},
2131 {"left_tee", XC_left_tee
},
2132 {"leftbutton", XC_leftbutton
},
2133 {"ll_angle", XC_ll_angle
},
2134 {"lr_angle", XC_lr_angle
},
2136 {"middlebutton", XC_middlebutton
},
2137 {"mouse", XC_mouse
},
2138 {"pencil", XC_pencil
},
2139 {"pirate", XC_pirate
},
2141 {"question_arrow", XC_question_arrow
},
2142 {"right_ptr", XC_right_ptr
},
2143 {"right_side", XC_right_side
},
2144 {"right_tee", XC_right_tee
},
2145 {"rightbutton", XC_rightbutton
},
2146 {"rtl_logo", XC_rtl_logo
},
2147 {"sailboat", XC_sailboat
},
2148 {"sb_down_arrow", XC_sb_down_arrow
},
2149 {"sb_h_double_arrow", XC_sb_h_double_arrow
},
2150 {"sb_left_arrow", XC_sb_left_arrow
},
2151 {"sb_right_arrow", XC_sb_right_arrow
},
2152 {"sb_up_arrow", XC_sb_up_arrow
},
2153 {"sb_v_double_arrow", XC_sb_v_double_arrow
},
2154 {"shuttle", XC_shuttle
},
2155 {"sizing", XC_sizing
},
2156 {"spider", XC_spider
},
2157 {"spraycan", XC_spraycan
},
2159 {"target", XC_target
},
2160 {"tcross", XC_tcross
},
2161 {"top_left_arrow", XC_top_left_arrow
},
2162 {"top_left_corner", XC_top_left_corner
},
2163 {"top_right_corner", XC_top_right_corner
},
2164 {"top_side", XC_top_side
},
2165 {"top_tee", XC_top_tee
},
2167 {"ul_angle", XC_ul_angle
},
2168 {"umbrella", XC_umbrella
},
2169 {"ur_angle", XC_ur_angle
},
2170 {"watch", XC_watch
},
2171 {"xterm", XC_xterm
},
2172 {NULL
, CURSOR_ID_NONE
}
2175 static void check_bitmap_status(int status
, char *filename
, Pixmap bitmap
)
2178 case BitmapOpenFailed
:
2179 wwarning(_("failed to open bitmap file \"%s\""), filename
);
2181 case BitmapFileInvalid
:
2182 wwarning(_("\"%s\" is not a valid bitmap file"), filename
);
2184 case BitmapNoMemory
:
2185 wwarning(_("out of memory reading bitmap file \"%s\""), filename
);
2188 XFreePixmap(dpy
, bitmap
);
2195 * (builtin, <cursor_name>)
2196 * (bitmap, <cursor_bitmap>, <cursor_mask>)
2198 static int parse_cursor(WScreen
* scr
, WMPropList
* pl
, Cursor
* cursor
)
2205 nelem
= WMGetPropListItemCount(pl
);
2209 elem
= WMGetFromPLArray(pl
, 0);
2210 if (!elem
|| !WMIsPLString(elem
)) {
2213 val
= WMGetFromPLString(elem
);
2215 if (strcasecmp(val
, "none") == 0) {
2218 } else if (strcasecmp(val
, "builtin") == 0) {
2220 int cursor_id
= CURSOR_ID_NONE
;
2223 wwarning(_("bad number of arguments in cursor specification"));
2226 elem
= WMGetFromPLArray(pl
, 1);
2227 if (!elem
|| !WMIsPLString(elem
)) {
2230 val
= WMGetFromPLString(elem
);
2232 for (i
= 0; cursor_table
[i
].name
!= NULL
; i
++) {
2233 if (strcasecmp(val
, cursor_table
[i
].name
) == 0) {
2234 cursor_id
= cursor_table
[i
].id
;
2238 if (CURSOR_ID_NONE
== cursor_id
) {
2239 wwarning(_("unknown builtin cursor name \"%s\""), val
);
2241 *cursor
= XCreateFontCursor(dpy
, cursor_id
);
2244 } else if (strcasecmp(val
, "bitmap") == 0) {
2256 wwarning(_("bad number of arguments in cursor specification"));
2259 elem
= WMGetFromPLArray(pl
, 1);
2260 if (!elem
|| !WMIsPLString(elem
)) {
2263 val
= WMGetFromPLString(elem
);
2264 bitmap_name
= FindImage(wPreferences
.pixmap_path
, val
);
2266 wwarning(_("could not find cursor bitmap file \"%s\""), val
);
2269 elem
= WMGetFromPLArray(pl
, 2);
2270 if (!elem
|| !WMIsPLString(elem
)) {
2274 val
= WMGetFromPLString(elem
);
2275 mask_name
= FindImage(wPreferences
.pixmap_path
, val
);
2278 wwarning(_("could not find cursor bitmap file \"%s\""), val
);
2281 mask_status
= XReadBitmapFile(dpy
, scr
->w_win
, mask_name
, &w
, &h
, &mask
, &x
, &y
);
2282 bitmap_status
= XReadBitmapFile(dpy
, scr
->w_win
, bitmap_name
, &w
, &h
, &bitmap
, &x
, &y
);
2283 if ((BitmapSuccess
== bitmap_status
) && (BitmapSuccess
== mask_status
)) {
2284 fg
.pixel
= scr
->black_pixel
;
2285 bg
.pixel
= scr
->white_pixel
;
2286 XQueryColor(dpy
, scr
->w_colormap
, &fg
);
2287 XQueryColor(dpy
, scr
->w_colormap
, &bg
);
2288 *cursor
= XCreatePixmapCursor(dpy
, bitmap
, mask
, &fg
, &bg
, x
, y
);
2291 check_bitmap_status(bitmap_status
, bitmap_name
, bitmap
);
2292 check_bitmap_status(mask_status
, mask_name
, mask
);
2299 static int getCursor(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
2301 static Cursor cursor
;
2306 if (!WMIsPLArray(value
)) {
2307 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
2308 entry
->key
, "cursor specification");
2310 value
= entry
->plvalue
;
2312 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
2317 status
= parse_cursor(scr
, value
, &cursor
);
2319 wwarning(_("Error in cursor specification for key \"%s\""), entry
->key
);
2321 value
= entry
->plvalue
;
2323 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
2332 *(Cursor
*) addr
= cursor
;
2337 #undef CURSOR_ID_NONE
2339 /* ---------------- value setting functions --------------- */
2340 static int setJustify(WScreen
* scr
, WDefaultEntry
* entry
, WTexture
** texture
, void *foo
)
2342 return REFRESH_WINDOW_TITLE_COLOR
;
2345 static int setClearance(WScreen
* scr
, WDefaultEntry
* entry
, void *bar
, void *foo
)
2347 return REFRESH_WINDOW_FONT
| REFRESH_BUTTON_IMAGES
| REFRESH_MENU_TITLE_FONT
| REFRESH_MENU_FONT
;
2350 static int setIfDockPresent(WScreen
* scr
, WDefaultEntry
* entry
, char *flag
, long which
)
2354 wPreferences
.flags
.nodock
= wPreferences
.flags
.nodock
|| *flag
;
2357 wPreferences
.flags
.noclip
= wPreferences
.flags
.noclip
|| *flag
;
2365 static int setStickyIcons(WScreen
* scr
, WDefaultEntry
* entry
, void *bar
, void *foo
)
2367 if (scr
->workspaces
) {
2368 wWorkspaceForceChange(scr
, scr
->current_workspace
);
2369 wArrangeIcons(scr
, False
);
2374 static int setIconTile(WScreen
* scr
, WDefaultEntry
* entry
, WTexture
** texture
, void *foo
)
2380 img
= wTextureRenderImage(*texture
, wPreferences
.icon_size
,
2381 wPreferences
.icon_size
, ((*texture
)->any
.type
& WREL_BORDER_MASK
)
2382 ? WREL_ICON
: WREL_FLAT
);
2384 wwarning(_("could not render texture for icon background"));
2386 wTextureDestroy(scr
, *texture
);
2389 RConvertImage(scr
->rcontext
, img
, &pixmap
);
2391 if (scr
->icon_tile
) {
2393 RReleaseImage(scr
->icon_tile
);
2394 XFreePixmap(dpy
, scr
->icon_tile_pixmap
);
2397 scr
->icon_tile
= img
;
2399 /* put the icon in the noticeboard hint */
2400 PropSetIconTileHint(scr
, img
);
2402 if (!wPreferences
.flags
.noclip
) {
2403 if (scr
->clip_tile
) {
2404 RReleaseImage(scr
->clip_tile
);
2406 scr
->clip_tile
= wClipMakeTile(scr
, img
);
2409 scr
->icon_tile_pixmap
= pixmap
;
2411 if (scr
->def_icon_pixmap
) {
2412 XFreePixmap(dpy
, scr
->def_icon_pixmap
);
2413 scr
->def_icon_pixmap
= None
;
2415 if (scr
->def_ticon_pixmap
) {
2416 XFreePixmap(dpy
, scr
->def_ticon_pixmap
);
2417 scr
->def_ticon_pixmap
= None
;
2420 if (scr
->icon_back_texture
) {
2421 wTextureDestroy(scr
, (WTexture
*) scr
->icon_back_texture
);
2423 scr
->icon_back_texture
= wTextureMakeSolid(scr
, &((*texture
)->any
.color
));
2425 if (scr
->clip_balloon
)
2426 XSetWindowBackground(dpy
, scr
->clip_balloon
, (*texture
)->any
.color
.pixel
);
2429 * Free the texture as nobody else will use it, nor refer to it.
2432 wTextureDestroy(scr
, *texture
);
2434 return (reset
? REFRESH_ICON_TILE
: 0);
2437 static int setWinTitleFont(WScreen
* scr
, WDefaultEntry
* entry
, WMFont
* font
, void *foo
)
2439 if (scr
->title_font
) {
2440 WMReleaseFont(scr
->title_font
);
2442 scr
->title_font
= font
;
2444 return REFRESH_WINDOW_FONT
| REFRESH_BUTTON_IMAGES
;
2447 static int setMenuTitleFont(WScreen
* scr
, WDefaultEntry
* entry
, WMFont
* font
, void *foo
)
2449 if (scr
->menu_title_font
) {
2450 WMReleaseFont(scr
->menu_title_font
);
2453 scr
->menu_title_font
= font
;
2455 return REFRESH_MENU_TITLE_FONT
;
2458 static int setMenuTextFont(WScreen
* scr
, WDefaultEntry
* entry
, WMFont
* font
, void *foo
)
2460 if (scr
->menu_entry_font
) {
2461 WMReleaseFont(scr
->menu_entry_font
);
2463 scr
->menu_entry_font
= font
;
2465 return REFRESH_MENU_FONT
;
2468 static int setIconTitleFont(WScreen
* scr
, WDefaultEntry
* entry
, WMFont
* font
, void *foo
)
2470 if (scr
->icon_title_font
) {
2471 WMReleaseFont(scr
->icon_title_font
);
2474 scr
->icon_title_font
= font
;
2476 return REFRESH_ICON_FONT
;
2479 static int setClipTitleFont(WScreen
* scr
, WDefaultEntry
* entry
, WMFont
* font
, void *foo
)
2481 if (scr
->clip_title_font
) {
2482 WMReleaseFont(scr
->clip_title_font
);
2485 scr
->clip_title_font
= font
;
2487 return REFRESH_ICON_FONT
;
2490 static int setLargeDisplayFont(WScreen
* scr
, WDefaultEntry
* entry
, WMFont
* font
, void *foo
)
2492 if (scr
->workspace_name_font
) {
2493 WMReleaseFont(scr
->workspace_name_font
);
2496 scr
->workspace_name_font
= font
;
2501 static int setHightlight(WScreen
* scr
, WDefaultEntry
* entry
, XColor
* color
, void *foo
)
2503 if (scr
->select_color
)
2504 WMReleaseColor(scr
->select_color
);
2506 scr
->select_color
= WMCreateRGBColor(scr
->wmscreen
, color
->red
, color
->green
, color
->blue
, True
);
2508 wFreeColor(scr
, color
->pixel
);
2510 return REFRESH_MENU_COLOR
;
2513 static int setHightlightText(WScreen
* scr
, WDefaultEntry
* entry
, XColor
* color
, void *foo
)
2515 if (scr
->select_text_color
)
2516 WMReleaseColor(scr
->select_text_color
);
2518 scr
->select_text_color
= WMCreateRGBColor(scr
->wmscreen
, color
->red
, color
->green
, color
->blue
, True
);
2520 wFreeColor(scr
, color
->pixel
);
2522 return REFRESH_MENU_COLOR
;
2525 static int setClipTitleColor(WScreen
* scr
, WDefaultEntry
* entry
, XColor
* color
, long widx
)
2527 if (scr
->clip_title_color
[widx
])
2528 WMReleaseColor(scr
->clip_title_color
[widx
]);
2529 scr
->clip_title_color
[widx
] = WMCreateRGBColor(scr
->wmscreen
, color
->red
, color
->green
, color
->blue
, True
);
2530 #ifdef GRADIENT_CLIP_ARROW
2531 if (widx
== CLIP_NORMAL
) {
2533 RColor color1
, color2
;
2534 int pt
= CLIP_BUTTON_SIZE
* wPreferences
.icon_size
/ 64;
2535 int as
= pt
- 15; /* 15 = 5+5+5 */
2537 FREE_PIXMAP(scr
->clip_arrow_gradient
);
2539 color1
.red
= (color
->red
>> 8) * 6 / 10;
2540 color1
.green
= (color
->green
>> 8) * 6 / 10;
2541 color1
.blue
= (color
->blue
>> 8) * 6 / 10;
2543 color2
.red
= WMIN((color
->red
>> 8) * 20 / 10, 255);
2544 color2
.green
= WMIN((color
->green
>> 8) * 20 / 10, 255);
2545 color2
.blue
= WMIN((color
->blue
>> 8) * 20 / 10, 255);
2547 image
= RRenderGradient(as
+ 1, as
+ 1, &color1
, &color2
, RDiagonalGradient
);
2548 RConvertImage(scr
->rcontext
, image
, &scr
->clip_arrow_gradient
);
2549 RReleaseImage(image
);
2551 #endif /* GRADIENT_CLIP_ARROW */
2553 wFreeColor(scr
, color
->pixel
);
2555 return REFRESH_ICON_TITLE_COLOR
;
2558 static int setWTitleColor(WScreen
* scr
, WDefaultEntry
* entry
, XColor
* color
, long widx
)
2560 if (scr
->window_title_color
[widx
])
2561 WMReleaseColor(scr
->window_title_color
[widx
]);
2563 scr
->window_title_color
[widx
] =
2564 WMCreateRGBColor(scr
->wmscreen
, color
->red
, color
->green
, color
->blue
, True
);
2566 wFreeColor(scr
, color
->pixel
);
2568 return REFRESH_WINDOW_TITLE_COLOR
;
2571 static int setMenuTitleColor(WScreen
* scr
, WDefaultEntry
* entry
, XColor
* color
, long widx
)
2573 if (scr
->menu_title_color
[0])
2574 WMReleaseColor(scr
->menu_title_color
[0]);
2576 scr
->menu_title_color
[0] = WMCreateRGBColor(scr
->wmscreen
, color
->red
, color
->green
, color
->blue
, True
);
2578 wFreeColor(scr
, color
->pixel
);
2580 return REFRESH_MENU_TITLE_COLOR
;
2583 static int setMenuTextColor(WScreen
* scr
, WDefaultEntry
* entry
, XColor
* color
, void *foo
)
2585 if (scr
->mtext_color
)
2586 WMReleaseColor(scr
->mtext_color
);
2588 scr
->mtext_color
= WMCreateRGBColor(scr
->wmscreen
, color
->red
, color
->green
, color
->blue
, True
);
2590 if (WMColorPixel(scr
->dtext_color
) == WMColorPixel(scr
->mtext_color
)) {
2591 WMSetColorAlpha(scr
->dtext_color
, 0x7fff);
2593 WMSetColorAlpha(scr
->dtext_color
, 0xffff);
2596 wFreeColor(scr
, color
->pixel
);
2598 return REFRESH_MENU_COLOR
;
2601 static int setMenuDisabledColor(WScreen
* scr
, WDefaultEntry
* entry
, XColor
* color
, void *foo
)
2603 if (scr
->dtext_color
)
2604 WMReleaseColor(scr
->dtext_color
);
2606 scr
->dtext_color
= WMCreateRGBColor(scr
->wmscreen
, color
->red
, color
->green
, color
->blue
, True
);
2608 if (WMColorPixel(scr
->dtext_color
) == WMColorPixel(scr
->mtext_color
)) {
2609 WMSetColorAlpha(scr
->dtext_color
, 0x7fff);
2611 WMSetColorAlpha(scr
->dtext_color
, 0xffff);
2614 wFreeColor(scr
, color
->pixel
);
2616 return REFRESH_MENU_COLOR
;
2619 static int setIconTitleColor(WScreen
* scr
, WDefaultEntry
* entry
, XColor
* color
, void *foo
)
2621 if (scr
->icon_title_color
)
2622 WMReleaseColor(scr
->icon_title_color
);
2623 scr
->icon_title_color
= WMCreateRGBColor(scr
->wmscreen
, color
->red
, color
->green
, color
->blue
, True
);
2625 wFreeColor(scr
, color
->pixel
);
2627 return REFRESH_ICON_TITLE_COLOR
;
2630 static int setIconTitleBack(WScreen
* scr
, WDefaultEntry
* entry
, XColor
* color
, void *foo
)
2632 if (scr
->icon_title_texture
) {
2633 wTextureDestroy(scr
, (WTexture
*) scr
->icon_title_texture
);
2635 scr
->icon_title_texture
= wTextureMakeSolid(scr
, color
);
2637 return REFRESH_ICON_TITLE_BACK
;
2640 static void trackDeadProcess(pid_t pid
, unsigned char status
, WScreen
* scr
)
2642 close(scr
->helper_fd
);
2644 scr
->helper_pid
= 0;
2645 scr
->flags
.backimage_helper_launched
= 0;
2648 static int setWorkspaceSpecificBack(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *bar
)
2654 if (scr
->flags
.backimage_helper_launched
) {
2655 if (WMGetPropListItemCount(value
) == 0) {
2656 SendHelperMessage(scr
, 'C', 0, NULL
);
2657 SendHelperMessage(scr
, 'K', 0, NULL
);
2659 WMReleasePropList(value
);
2666 if (WMGetPropListItemCount(value
) == 0)
2669 if (pipe(filedes
) < 0) {
2670 wsyserror("pipe() failed:can't set workspace specific background image");
2672 WMReleasePropList(value
);
2678 wsyserror("fork() failed:can't set workspace specific background image");
2679 if (close(filedes
[0]) < 0)
2680 wsyserror("could not close pipe");
2681 if (close(filedes
[1]) < 0)
2682 wsyserror("could not close pipe");
2684 } else if (pid
== 0) {
2687 SetupEnvironment(scr
);
2690 wsyserror("could not close pipe");
2691 if (dup(filedes
[0]) < 0) {
2692 wsyserror("dup() failed:can't set workspace specific background image");
2694 dither
= wPreferences
.no_dithering
? "-m" : "-d";
2695 if (wPreferences
.smooth_workspace_back
)
2696 execlp("wmsetbg", "wmsetbg", "-helper", "-S", dither
, NULL
);
2698 execlp("wmsetbg", "wmsetbg", "-helper", dither
, NULL
);
2699 wsyserror("could not execute wmsetbg");
2703 if (fcntl(filedes
[0], F_SETFD
, FD_CLOEXEC
) < 0) {
2704 wsyserror("error setting close-on-exec flag");
2706 if (fcntl(filedes
[1], F_SETFD
, FD_CLOEXEC
) < 0) {
2707 wsyserror("error setting close-on-exec flag");
2710 scr
->helper_fd
= filedes
[1];
2711 scr
->helper_pid
= pid
;
2712 scr
->flags
.backimage_helper_launched
= 1;
2714 wAddDeathHandler(pid
, (WDeathHandler
*) trackDeadProcess
, scr
);
2716 SendHelperMessage(scr
, 'P', -1, wPreferences
.pixmap_path
);
2721 for (i
= 0; i
< WMGetPropListItemCount(value
); i
++) {
2722 val
= WMGetFromPLArray(value
, i
);
2723 if (val
&& WMIsPLArray(val
) && WMGetPropListItemCount(val
) > 0) {
2724 str
= WMGetPropListDescription(val
, False
);
2726 SendHelperMessage(scr
, 'S', i
+ 1, str
);
2730 SendHelperMessage(scr
, 'U', i
+ 1, NULL
);
2735 WMReleasePropList(value
);
2739 static int setWorkspaceBack(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *bar
)
2741 if (scr
->flags
.backimage_helper_launched
) {
2744 if (WMGetPropListItemCount(value
) == 0) {
2745 SendHelperMessage(scr
, 'U', 0, NULL
);
2747 /* set the default workspace background to this one */
2748 str
= WMGetPropListDescription(value
, False
);
2750 SendHelperMessage(scr
, 'S', 0, str
);
2752 SendHelperMessage(scr
, 'C', scr
->current_workspace
+ 1, NULL
);
2754 SendHelperMessage(scr
, 'U', 0, NULL
);
2757 } else if (WMGetPropListItemCount(value
) > 0) {
2763 text
= WMGetPropListDescription(value
, False
);
2764 len
= strlen(text
) + 40;
2765 command
= wmalloc(len
);
2766 dither
= wPreferences
.no_dithering
? "-m" : "-d";
2767 if (wPreferences
.smooth_workspace_back
)
2768 snprintf(command
, len
, "wmsetbg %s -S -p '%s' &", dither
, text
);
2770 snprintf(command
, len
, "wmsetbg %s -p '%s' &", dither
, text
);
2772 ExecuteShellCommand(scr
, command
);
2775 WMReleasePropList(value
);
2780 static int setWidgetColor(WScreen
* scr
, WDefaultEntry
* entry
, WTexture
** texture
, void *foo
)
2782 if (scr
->widget_texture
) {
2783 wTextureDestroy(scr
, (WTexture
*) scr
->widget_texture
);
2785 scr
->widget_texture
= *(WTexSolid
**) texture
;
2790 static int setFTitleBack(WScreen
* scr
, WDefaultEntry
* entry
, WTexture
** texture
, void *foo
)
2792 if (scr
->window_title_texture
[WS_FOCUSED
]) {
2793 wTextureDestroy(scr
, scr
->window_title_texture
[WS_FOCUSED
]);
2795 scr
->window_title_texture
[WS_FOCUSED
] = *texture
;
2797 return REFRESH_WINDOW_TEXTURES
;
2800 static int setPTitleBack(WScreen
* scr
, WDefaultEntry
* entry
, WTexture
** texture
, void *foo
)
2802 if (scr
->window_title_texture
[WS_PFOCUSED
]) {
2803 wTextureDestroy(scr
, scr
->window_title_texture
[WS_PFOCUSED
]);
2805 scr
->window_title_texture
[WS_PFOCUSED
] = *texture
;
2807 return REFRESH_WINDOW_TEXTURES
;
2810 static int setUTitleBack(WScreen
* scr
, WDefaultEntry
* entry
, WTexture
** texture
, void *foo
)
2812 if (scr
->window_title_texture
[WS_UNFOCUSED
]) {
2813 wTextureDestroy(scr
, scr
->window_title_texture
[WS_UNFOCUSED
]);
2815 scr
->window_title_texture
[WS_UNFOCUSED
] = *texture
;
2817 return REFRESH_WINDOW_TEXTURES
;
2820 static int setResizebarBack(WScreen
* scr
, WDefaultEntry
* entry
, WTexture
** texture
, void *foo
)
2822 if (scr
->resizebar_texture
[0]) {
2823 wTextureDestroy(scr
, scr
->resizebar_texture
[0]);
2825 scr
->resizebar_texture
[0] = *texture
;
2827 return REFRESH_WINDOW_TEXTURES
;
2830 static int setMenuTitleBack(WScreen
* scr
, WDefaultEntry
* entry
, WTexture
** texture
, void *foo
)
2832 if (scr
->menu_title_texture
[0]) {
2833 wTextureDestroy(scr
, scr
->menu_title_texture
[0]);
2835 scr
->menu_title_texture
[0] = *texture
;
2837 return REFRESH_MENU_TITLE_TEXTURE
;
2840 static int setMenuTextBack(WScreen
* scr
, WDefaultEntry
* entry
, WTexture
** texture
, void *foo
)
2842 if (scr
->menu_item_texture
) {
2843 wTextureDestroy(scr
, scr
->menu_item_texture
);
2844 wTextureDestroy(scr
, (WTexture
*) scr
->menu_item_auxtexture
);
2846 scr
->menu_item_texture
= *texture
;
2848 scr
->menu_item_auxtexture
= wTextureMakeSolid(scr
, &scr
->menu_item_texture
->any
.color
);
2850 return REFRESH_MENU_TEXTURE
;
2853 static int setKeyGrab(WScreen
* scr
, WDefaultEntry
* entry
, WShortKey
* shortcut
, long widx
)
2856 wKeyBindings
[widx
] = *shortcut
;
2858 wwin
= scr
->focused_window
;
2860 while (wwin
!= NULL
) {
2861 XUngrabKey(dpy
, AnyKey
, AnyModifier
, wwin
->frame
->core
->window
);
2863 if (!WFLAGP(wwin
, no_bind_keys
)) {
2864 wWindowSetKeyGrabs(wwin
);
2872 static int setIconPosition(WScreen
* scr
, WDefaultEntry
* entry
, void *bar
, void *foo
)
2874 wScreenUpdateUsableArea(scr
);
2875 wArrangeIcons(scr
, True
);
2880 static int updateUsableArea(WScreen
* scr
, WDefaultEntry
* entry
, void *bar
, void *foo
)
2882 wScreenUpdateUsableArea(scr
);
2887 static int setMenuStyle(WScreen
* scr
, WDefaultEntry
* entry
, int *value
, void *foo
)
2889 return REFRESH_MENU_TEXTURE
;
2892 static RImage
*chopOffImage(RImage
* image
, int x
, int y
, int w
, int h
)
2894 RImage
*img
= RCreateImage(w
, h
, image
->format
== RRGBAFormat
);
2896 RCopyArea(img
, image
, x
, y
, w
, h
, 0, 0);
2901 static int setSwPOptions(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* array
, void *foo
)
2905 int cwidth
, cheight
;
2906 WPreferences
*prefs
= (WPreferences
*) foo
;
2908 if (!WMIsPLArray(array
) || WMGetPropListItemCount(array
) == 0) {
2909 if (prefs
->swtileImage
)
2910 RReleaseImage(prefs
->swtileImage
);
2911 prefs
->swtileImage
= NULL
;
2913 WMReleasePropList(array
);
2917 switch (WMGetPropListItemCount(array
)) {
2919 if (!WMIsPLString(WMGetFromPLArray(array
, 1))) {
2920 wwarning(_("Invalid arguments for option \"%s\""), entry
->key
);
2923 path
= FindImage(wPreferences
.pixmap_path
, WMGetFromPLString(WMGetFromPLArray(array
, 1)));
2926 wwarning(_("Could not find image \"%s\" for option \"%s\""),
2927 WMGetFromPLString(WMGetFromPLArray(array
, 1)), entry
->key
);
2929 bgimage
= RLoadImage(scr
->rcontext
, path
, 0);
2931 wwarning(_("Could not load image \"%s\" for option \"%s\""), path
, entry
->key
);
2936 cwidth
= atoi(WMGetFromPLString(WMGetFromPLArray(array
, 2)));
2937 cheight
= atoi(WMGetFromPLString(WMGetFromPLArray(array
, 3)));
2939 if (cwidth
<= 0 || cheight
<= 0 ||
2940 cwidth
>= bgimage
->width
- 2 || cheight
>= bgimage
->height
- 2)
2941 wwarning(_("Invalid split sizes for SwitchPanel back image."));
2944 int swidth
, theight
;
2945 for (i
= 0; i
< 9; i
++) {
2946 if (prefs
->swbackImage
[i
])
2947 RReleaseImage(prefs
->swbackImage
[i
]);
2948 prefs
->swbackImage
[i
] = NULL
;
2950 swidth
= (bgimage
->width
- cwidth
) / 2;
2951 theight
= (bgimage
->height
- cheight
) / 2;
2953 prefs
->swbackImage
[0] = chopOffImage(bgimage
, 0, 0, swidth
, theight
);
2954 prefs
->swbackImage
[1] = chopOffImage(bgimage
, swidth
, 0, cwidth
, theight
);
2955 prefs
->swbackImage
[2] = chopOffImage(bgimage
, swidth
+ cwidth
, 0,
2958 prefs
->swbackImage
[3] = chopOffImage(bgimage
, 0, theight
, swidth
, cheight
);
2959 prefs
->swbackImage
[4] = chopOffImage(bgimage
, swidth
, theight
,
2961 prefs
->swbackImage
[5] = chopOffImage(bgimage
, swidth
+ cwidth
, theight
,
2964 prefs
->swbackImage
[6] = chopOffImage(bgimage
, 0, theight
+ cheight
,
2966 prefs
->swbackImage
[7] = chopOffImage(bgimage
, swidth
, theight
+ cheight
,
2968 prefs
->swbackImage
[8] =
2969 chopOffImage(bgimage
, swidth
+ cwidth
, theight
+ cheight
, swidth
,
2972 // check if anything failed
2973 for (i
= 0; i
< 9; i
++) {
2974 if (!prefs
->swbackImage
[i
]) {
2975 for (; i
>= 0; --i
) {
2976 RReleaseImage(prefs
->swbackImage
[i
]);
2977 prefs
->swbackImage
[i
] = NULL
;
2983 RReleaseImage(bgimage
);
2988 if (!WMIsPLString(WMGetFromPLArray(array
, 0))) {
2989 wwarning(_("Invalid arguments for option \"%s\""), entry
->key
);
2992 path
= FindImage(wPreferences
.pixmap_path
, WMGetFromPLString(WMGetFromPLArray(array
, 0)));
2995 wwarning(_("Could not find image \"%s\" for option \"%s\""),
2996 WMGetFromPLString(WMGetFromPLArray(array
, 0)), entry
->key
);
2998 if (prefs
->swtileImage
)
2999 RReleaseImage(prefs
->swtileImage
);
3001 prefs
->swtileImage
= RLoadImage(scr
->rcontext
, path
, 0);
3002 if (!prefs
->swtileImage
) {
3003 wwarning(_("Could not load image \"%s\" for option \"%s\""), path
, entry
->key
);
3010 wwarning(_("Invalid number of arguments for option \"%s\""), entry
->key
);
3014 WMReleasePropList(array
);
3021 * Need access to the double click variables, so that all widgets in
3022 * wmaker panels will have the same dbl-click values.
3023 * TODO: figure a better way of dealing with it.
3025 #include <WINGs/WINGsP.h>
3027 static int setDoubleClick(WScreen
* scr
, WDefaultEntry
* entry
, int *value
, void *foo
)
3029 extern _WINGsConfiguration WINGsConfiguration
;
3034 WINGsConfiguration
.doubleClickDelay
= *value
;
3039 static int setCursor(WScreen
* scr
, WDefaultEntry
* entry
, Cursor
* cursor
, long widx
)
3041 if (wCursor
[widx
] != None
) {
3042 XFreeCursor(dpy
, wCursor
[widx
]);
3045 wCursor
[widx
] = *cursor
;
3047 if (widx
== WCUR_ROOT
&& *cursor
!= None
) {
3048 XDefineCursor(dpy
, scr
->root_win
, *cursor
);