1 /* defaults.c - manage configuration through defaults db
3 * Window Maker window manager
5 * Copyright (c) 1997, 1998 Alfredo K. Kojima
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
31 #include <sys/types.h>
44 #define PATH_MAX DEFAULT_PATH_MAX
48 #include <X11/Xutil.h>
49 #include <X11/keysym.h>
54 #include "WindowMaker.h"
60 #include "resources.h"
63 #include "xmodifier.h"
68 #include "workspace.h"
72 * Our own proplist reader parser. This one will not accept any
73 * syntax errors and is more descriptive in the error messages.
74 * It also doesn't seem to crash.
76 extern proplist_t
ReadProplistFromFile(char *file
);
81 extern WDDomain
*WDWindowMaker
;
82 extern WDDomain
*WDWindowAttributes
;
83 extern WDDomain
*WDRootMenu
;
85 extern int wScreenCount
;
88 extern proplist_t wDomainName;
89 extern proplist_t wAttributeDomainName;
91 extern WPreferences wPreferences
;
93 extern WShortKey wKeyBindings
[WKBD_LAST
];
103 proplist_t plvalue
; /* default value */
107 /* used to map strings to integers */
112 } WOptionEnumeration
;
116 /* type converters */
117 static int getBool();
119 static int getCoord();
121 /* this is not used yet */
122 static int getString();
124 static int getPathList();
125 static int getEnum();
126 static int getTexture();
127 static int getWSBackground();
128 static int getWSSpecificBackground();
129 static int getFont();
130 static int getColor();
131 static int getKeybind();
132 static int getModMask();
134 static int getRImage();
137 /* value setting functions */
138 static int setJustify();
139 static int setIfDockPresent();
140 static int setStickyIcons();
142 static int setPositive();
144 static int setWidgetColor();
145 static int setIconTile();
146 static int setWinTitleFont();
147 static int setMenuTitleFont();
148 static int setMenuTextFont();
149 static int setIconTitleFont();
150 static int setIconTitleColor();
151 static int setIconTitleBack();
152 static int setDisplayFont();
153 static int setWTitleColor();
154 static int setFTitleBack();
155 static int setPTitleBack();
156 static int setUTitleBack();
157 static int setWorkspaceBack();
158 static int setWorkspaceSpecificBack();
159 static int setMenuTitleColor();
160 static int setMenuTextColor();
161 static int setMenuDisabledColor();
162 static int setMenuTitleBack();
163 static int setMenuTextBack();
164 static int setHightlight();
165 static int setHightlightText();
166 static int setKeyGrab();
167 static int setDoubleClick();
168 static int setIconPosition();
170 static int setClipTitleFont();
171 static int setClipTitleColor();
174 static int setButtonImages();
177 static int updateUsableArea();
182 * Tables to convert strings to enumeration values.
183 * Values stored are char
187 /* WARNING: sum of length of all value strings must not exceed
189 #define TOTAL_VALUES_LENGTH 80
193 static WOptionEnumeration seFocusModes
[] = {
194 {"Manual", WKF_CLICK
, 0}, {"ClickToFocus", WKF_CLICK
, 1},
195 {"Auto", WKF_POINTER
, 0}, {"FocusFollowMouse", WKF_POINTER
, 1},
196 {"Sloppy", WKF_SLOPPY
, 0}, {"SemiAuto", WKF_SLOPPY
, 1},
200 static WOptionEnumeration seColormapModes
[] = {
201 {"Manual", WKF_CLICK
, 0}, {"ClickToFocus", WKF_CLICK
, 1},
202 {"Auto", WKF_POINTER
, 0}, {"FocusFollowMouse", WKF_POINTER
, 1},
206 static WOptionEnumeration sePlacements
[] = {
207 {"Auto", WPM_SMART
, 0}, {"Smart", WPM_SMART
, 1},
208 {"Cascade", WPM_CASCADE
, 0},
209 {"Random", WPM_RANDOM
, 0},
210 {"Manual", WPM_MANUAL
, 0},
214 static WOptionEnumeration seGeomDisplays
[] = {
215 {"Center", WDIS_CENTER
, 0},
216 {"Corner", WDIS_TOPLEFT
, 0},
217 {"Floating", WDIS_FRAME_CENTER
, 0},
218 {"Line", WDIS_NEW
, 0},
222 static WOptionEnumeration seSpeeds
[] = {
223 {"UltraFast", SPEED_ULTRAFAST
, 0},
224 {"Fast", SPEED_FAST
, 0},
225 {"Medium", SPEED_MEDIUM
, 0},
226 {"Slow", SPEED_SLOW
, 0},
227 {"UltraSlow", SPEED_ULTRASLOW
, 0},
231 static WOptionEnumeration seMouseButtons
[] = {
232 {"Left", Button1
, 0}, {"Button1", Button1
, 1},
233 {"Middle", Button2
, 0}, {"Button2", Button2
, 1},
234 {"Right", Button3
, 0}, {"Button3", Button3
, 1},
235 {"Button4", Button4
, 0},
236 {"Button5", Button5
, 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},
271 * All entries in the tables bellow, NEED to have a default value
272 * defined, and this value needs to be correct.
275 /* these options will only affect the window manager on startup
277 * static defaults can't access the screen data, because it is
278 * created after these defaults are read
280 WDefaultEntry staticOptionList
[] = {
282 {"DisableDithering", "NO", NULL
,
283 &wPreferences
.no_dithering
, getBool
, NULL
285 {"ColormapSize", "4", NULL
,
286 &wPreferences
.cmap_size
, getInt
, NULL
288 /* static by laziness */
289 {"IconSize", "64", NULL
,
290 &wPreferences
.icon_size
, getInt
, NULL
292 {"ModifierKey", "Mod1", NULL
,
293 &wPreferences
.modifier_mask
, getModMask
, NULL
295 {"DisableWSMouseActions", "NO", NULL
,
296 &wPreferences
.disable_root_mouse
, getBool
, NULL
298 {"FocusMode", "manual", seFocusModes
,
299 &wPreferences
.focus_mode
, getEnum
, NULL
300 }, /* have a problem when switching from manual to sloppy without restart */
301 {"NewStyle", "NO", NULL
,
302 &wPreferences
.new_style
, getBool
, NULL
304 {"DisableDock", "NO", (void*) WM_DOCK
,
305 NULL
, getBool
, setIfDockPresent
307 {"DisableClip", "NO", (void*) WM_CLIP
,
308 NULL
, getBool
, setIfDockPresent
310 {"DisableMiniwindows", "NO", NULL
,
311 &wPreferences
.disable_miniwindows
, getBool
, NULL
317 WDefaultEntry optionList
[] = {
318 /* dynamic options */
319 {"IconPosition", "blh", seIconPositions
,
320 &wPreferences
.icon_yard
, getEnum
, setIconPosition
322 {"IconificationStyle", "Zoom", seIconificationStyles
,
323 &wPreferences
.iconification_style
, getEnum
, NULL
325 {"SelectWindowsMouseButton", "Left", seMouseButtons
,
326 &wPreferences
.select_button
, getEnum
, NULL
328 {"WindowListMouseButton", "Middle", seMouseButtons
,
329 &wPreferences
.windowl_button
, getEnum
, NULL
331 {"ApplicationMenuMouseButton", "Right", seMouseButtons
,
332 &wPreferences
.menu_button
, getEnum
, NULL
334 {"PixmapPath", DEF_PIXMAP_PATHS
, NULL
,
335 &wPreferences
.pixmap_path
, getPathList
, NULL
337 {"IconPath", DEF_ICON_PATHS
, NULL
,
338 &wPreferences
.icon_path
, getPathList
, NULL
340 {"ColormapMode", "auto", seColormapModes
,
341 &wPreferences
.colormap_mode
, getEnum
, NULL
343 {"AutoFocus", "NO", NULL
,
344 &wPreferences
.auto_focus
, getBool
, NULL
346 {"RaiseDelay", "0", NULL
,
347 &wPreferences
.raise_delay
, getInt
, NULL
349 {"CirculateRaise", "NO", NULL
,
350 &wPreferences
.circ_raise
, getBool
, NULL
352 {"Superfluous", "NO", NULL
,
353 &wPreferences
.superfluous
, getBool
, NULL
355 {"AdvanceToNewWorkspace", "NO", NULL
,
356 &wPreferences
.ws_advance
, getBool
, NULL
358 {"CycleWorkspaces", "NO", NULL
,
359 &wPreferences
.ws_cycle
, getBool
, NULL
361 {"StickyIcons", "NO", NULL
,
362 &wPreferences
.sticky_icons
, getBool
, setStickyIcons
364 {"SaveSessionOnExit", "NO", NULL
,
365 &wPreferences
.save_session_on_exit
, getBool
, NULL
367 {"WrapMenus", "NO", NULL
,
368 &wPreferences
.wrap_menus
, getBool
, NULL
370 {"ScrollableMenus", "NO", NULL
,
371 &wPreferences
.scrollable_menus
, getBool
, NULL
373 {"MenuScrollSpeed", "medium", seSpeeds
,
374 &wPreferences
.menu_scroll_speed
, getEnum
, NULL
376 {"IconSlideSpeed", "medium", seSpeeds
,
377 &wPreferences
.icon_slide_speed
, getEnum
, NULL
379 {"ShadeSpeed", "medium", seSpeeds
,
380 &wPreferences
.shade_speed
, getEnum
, NULL
382 {"DoubleClickTime", "250", (void*) &wPreferences
.dblclick_time
,
383 &wPreferences
.dblclick_time
, getInt
, setDoubleClick
,
385 {"AlignSubmenus", "NO", NULL
,
386 &wPreferences
.align_menus
, getBool
, NULL
388 {"OpenTransientOnOwnerWorkspace", "NO", NULL
,
389 &wPreferences
.open_transients_with_parent
, getBool
, NULL
391 {"WindowPlacement", "auto", sePlacements
,
392 &wPreferences
.window_placement
, getEnum
, NULL
394 {"IgnoreFocusClick","NO", NULL
,
395 &wPreferences
.ignore_focus_click
, getBool
, NULL
397 {"UseSaveUnders", "NO", NULL
,
398 &wPreferences
.use_saveunders
, getBool
, NULL
400 {"OpaqueMove", "NO", NULL
,
401 &wPreferences
.opaque_move
, getBool
, NULL
403 {"DisableSound", "NO", NULL
,
404 &wPreferences
.no_sound
, getBool
, NULL
406 {"DisableAnimations", "NO", NULL
,
407 &wPreferences
.no_animations
, getBool
, NULL
409 {"DontLinkWorkspaces","NO", NULL
,
410 &wPreferences
.no_autowrap
, getBool
, NULL
412 {"AutoArrangeIcons", "NO", NULL
,
413 &wPreferences
.auto_arrange_icons
, getBool
, NULL
415 {"NoWindowOverDock", "NO", NULL
,
416 &wPreferences
.no_window_over_dock
, getBool
, updateUsableArea
418 {"NoWindowOverIcons", "NO", NULL
,
419 &wPreferences
.no_window_over_icons
, getBool
, updateUsableArea
421 {"WindowPlaceOrigin", "(0, 0)", NULL
,
422 &wPreferences
.window_place_origin
, getCoord
, NULL
424 {"ResizeDisplay", "corner", seGeomDisplays
,
425 &wPreferences
.size_display
, getEnum
, NULL
427 {"MoveDisplay", "corner", seGeomDisplays
,
428 &wPreferences
.move_display
, getEnum
, NULL
430 {"DontConfirmKill", "NO", NULL
,
431 &wPreferences
.dont_confirm_kill
, getBool
,NULL
433 {"WindowTitleBalloons", "NO", NULL
,
434 &wPreferences
.window_balloon
, getBool
, NULL
436 {"MiniwindowTitleBalloons", "NO", NULL
,
437 &wPreferences
.miniwin_balloon
,getBool
, NULL
439 {"AppIconBalloons", "NO", NULL
,
440 &wPreferences
.appicon_balloon
,getBool
, NULL
442 {"EdgeResistance", "30", NULL
,
443 &wPreferences
.edge_resistance
,getInt
, NULL
445 {"DisableBlinking", "NO", NULL
,
446 &wPreferences
.dont_blink
, getBool
, NULL
448 #ifdef WEENDOZE_CYCLE
449 {"WindozeCycling","NO", NULL
,
450 &wPreferences
.windoze_cycling
, getBool
, NULL
452 {"PopupSwitchMenu","YES",NULL
,
453 &wPreferences
.popup_switchmenu
, getBool
, NULL
455 #endif /* WEENDOZE_CYCLE */
458 {"WindowButtonImages", DEF_BUTTON_IMAGES
, NULL
,
459 &wPreferences
.button_images
, getRImage
, setButtonImages
462 {"WidgetColor", "(solid, gray)", NULL
,
463 NULL
, getTexture
, setWidgetColor
,
466 {"WorkspaceSpecificBack","()", NULL
,
467 NULL
, getWSSpecificBackground
, setWorkspaceSpecificBack
469 /* WorkspaceBack must come after WorkspaceSpecificBack or
470 * WorkspaceBack wont know WorkspaceSpecificBack was also
471 * specified and 2 copies of wmsetbg will be launched */
472 {"WorkspaceBack", "(solid, black)", NULL
,
473 NULL
, getWSBackground
,setWorkspaceBack
475 {"IconBack", "(solid, gray)", NULL
,
476 NULL
, getTexture
, setIconTile
478 {"TitleJustify", "center", seJustifications
,
479 &wPreferences
.title_justification
, getEnum
, setJustify
481 {"WindowTitleFont", DEF_TITLE_FONT
, NULL
,
482 NULL
, getFont
, setWinTitleFont
484 {"MenuTitleFont", DEF_MENU_TITLE_FONT
, NULL
,
485 NULL
, getFont
, setMenuTitleFont
487 {"MenuTextFont", DEF_MENU_ENTRY_FONT
, NULL
,
488 NULL
, getFont
, setMenuTextFont
490 {"IconTitleFont", DEF_ICON_TITLE_FONT
, NULL
,
491 NULL
, getFont
, setIconTitleFont
493 {"ClipTitleFont", DEF_CLIP_TITLE_FONT
, NULL
,
494 NULL
, getFont
, setClipTitleFont
496 {"DisplayFont", DEF_INFO_TEXT_FONT
, NULL
,
497 NULL
, getFont
, setDisplayFont
499 {"HighlightColor", "white", NULL
,
500 NULL
, getColor
, setHightlight
502 {"HighlightTextColor", "black", NULL
,
503 NULL
, getColor
, setHightlightText
505 {"ClipTitleColor", "black", (void*)CLIP_NORMAL
,
506 NULL
, getColor
, setClipTitleColor
508 {"CClipTitleColor", "\"#454045\"", (void*)CLIP_COLLAPSED
,
509 NULL
, getColor
, setClipTitleColor
511 {"FTitleColor", "white", (void*)WS_FOCUSED
,
512 NULL
, getColor
, setWTitleColor
514 {"PTitleColor", "white", (void*)WS_PFOCUSED
,
515 NULL
, getColor
, setWTitleColor
517 {"UTitleColor", "black", (void*)WS_UNFOCUSED
,
518 NULL
, getColor
, setWTitleColor
520 {"FTitleBack", "(solid, black)", NULL
,
521 NULL
, getTexture
, setFTitleBack
523 {"PTitleBack", "(solid, \"#616161\")", NULL
,
524 NULL
, getTexture
, setPTitleBack
526 {"UTitleBack", "(solid, gray)", NULL
,
527 NULL
, getTexture
, setUTitleBack
529 {"MenuTitleColor", "white", NULL
,
530 NULL
, getColor
, setMenuTitleColor
532 {"MenuTextColor", "black", NULL
,
533 NULL
, getColor
, setMenuTextColor
535 {"MenuDisabledColor", "\"#616161\"", NULL
,
536 NULL
, getColor
, setMenuDisabledColor
538 {"MenuTitleBack", "(solid, black)", NULL
,
539 NULL
, getTexture
, setMenuTitleBack
541 {"MenuTextBack", "(solid, gray)", NULL
,
542 NULL
, getTexture
, setMenuTextBack
544 {"IconTitleColor", "white", NULL
,
545 NULL
, getColor
, setIconTitleColor
547 {"IconTitleBack", "black", NULL
,
548 NULL
, getColor
, setIconTitleBack
552 {"RootMenuKey", "None", (void*)WKBD_ROOTMENU
,
553 NULL
, getKeybind
, setKeyGrab
555 {"WindowListKey", "None", (void*)WKBD_WINDOWLIST
,
556 NULL
, getKeybind
, setKeyGrab
559 {"WindowMenuKey", "None", (void*)WKBD_WINDOWMENU
,
560 NULL
, getKeybind
, setKeyGrab
562 {"ClipLowerKey", "None", (void*)WKBD_CLIPLOWER
,
563 NULL
, getKeybind
, setKeyGrab
565 {"ClipRaiseKey", "None", (void*)WKBD_CLIPRAISE
,
566 NULL
, getKeybind
, setKeyGrab
568 {"ClipRaiseLowerKey", "None", (void*)WKBD_CLIPRAISELOWER
,
569 NULL
, getKeybind
, setKeyGrab
571 {"MiniaturizeKey", "None", (void*)WKBD_MINIATURIZE
,
572 NULL
, getKeybind
, setKeyGrab
574 {"HideKey", "None", (void*)WKBD_HIDE
,
575 NULL
, getKeybind
, setKeyGrab
577 {"MoveResizeKey", "None", (void*)WKBD_MOVERESIZE
,
578 NULL
, getKeybind
, setKeyGrab
580 {"CloseKey", "None", (void*)WKBD_CLOSE
,
581 NULL
, getKeybind
, setKeyGrab
583 {"MaximizeKey", "None", (void*)WKBD_MAXIMIZE
,
584 NULL
, getKeybind
, setKeyGrab
586 {"VMaximizeKey", "None", (void*)WKBD_VMAXIMIZE
,
587 NULL
, getKeybind
, setKeyGrab
589 {"RaiseKey", "Meta+Up", (void*)WKBD_RAISE
,
590 NULL
, getKeybind
, setKeyGrab
592 {"LowerKey", "Meta+Down", (void*)WKBD_LOWER
,
593 NULL
, getKeybind
, setKeyGrab
595 {"RaiseLowerKey", "None", (void*)WKBD_RAISELOWER
,
596 NULL
, getKeybind
, setKeyGrab
598 {"ShadeKey", "None", (void*)WKBD_SHADE
,
599 NULL
, getKeybind
, setKeyGrab
601 {"SelectKey", "None", (void*)WKBD_SELECT
,
602 NULL
, getKeybind
, setKeyGrab
604 {"FocusNextKey", "None", (void*)WKBD_FOCUSNEXT
,
605 NULL
, getKeybind
, setKeyGrab
607 {"FocusPrevKey", "None", (void*)WKBD_FOCUSPREV
,
608 NULL
, getKeybind
, setKeyGrab
610 {"NextWorkspaceKey", "None", (void*)WKBD_NEXTWORKSPACE
,
611 NULL
, getKeybind
, setKeyGrab
613 {"PrevWorkspaceKey", "None", (void*)WKBD_PREVWORKSPACE
,
614 NULL
, getKeybind
, setKeyGrab
616 {"NextWorkspaceLayerKey", "None", (void*)WKBD_NEXTWSLAYER
,
617 NULL
, getKeybind
, setKeyGrab
619 {"PrevWorkspaceLayerKey", "None", (void*)WKBD_PREVWSLAYER
,
620 NULL
, getKeybind
, setKeyGrab
622 {"Workspace1Key", "None", (void*)WKBD_WORKSPACE1
,
623 NULL
, getKeybind
, setKeyGrab
625 {"Workspace2Key", "None", (void*)WKBD_WORKSPACE2
,
626 NULL
, getKeybind
, setKeyGrab
628 {"Workspace3Key", "None", (void*)WKBD_WORKSPACE3
,
629 NULL
, getKeybind
, setKeyGrab
631 {"Workspace4Key", "None", (void*)WKBD_WORKSPACE4
,
632 NULL
, getKeybind
, setKeyGrab
634 {"Workspace5Key", "None", (void*)WKBD_WORKSPACE5
,
635 NULL
, getKeybind
, setKeyGrab
637 {"Workspace6Key", "None", (void*)WKBD_WORKSPACE6
,
638 NULL
, getKeybind
, setKeyGrab
640 {"Workspace7Key", "None", (void*)WKBD_WORKSPACE7
,
641 NULL
, getKeybind
, setKeyGrab
643 {"Workspace8Key", "None", (void*)WKBD_WORKSPACE8
,
644 NULL
, getKeybind
, setKeyGrab
646 {"Workspace9Key", "None", (void*)WKBD_WORKSPACE9
,
647 NULL
, getKeybind
, setKeyGrab
649 {"Workspace10Key", "None", (void*)WKBD_WORKSPACE10
,
650 NULL
, getKeybind
, setKeyGrab
652 {"WindowShortcut1Key","None", (void*)WKBD_WINDOW1
,
653 NULL
, getKeybind
, setKeyGrab
655 {"WindowShortcut2Key","None", (void*)WKBD_WINDOW2
,
656 NULL
, getKeybind
, setKeyGrab
658 {"WindowShortcut3Key","None", (void*)WKBD_WINDOW3
,
659 NULL
, getKeybind
, setKeyGrab
661 {"WindowShortcut4Key","None", (void*)WKBD_WINDOW4
,
662 NULL
, getKeybind
, setKeyGrab
664 #ifdef EXTEND_WINDOWSHORTCUT
665 ,{"WindowShortcut5Key","None", (void*)WKBD_WINDOW5
,
666 NULL
, getKeybind
, setKeyGrab
668 {"WindowShortcut6Key","None", (void*)WKBD_WINDOW6
,
669 NULL
, getKeybind
, setKeyGrab
671 {"WindowShortcut7Key","None", (void*)WKBD_WINDOW7
,
672 NULL
, getKeybind
, setKeyGrab
674 {"WindowShortcut8Key","None", (void*)WKBD_WINDOW8
,
675 NULL
, getKeybind
, setKeyGrab
677 {"WindowShortcut9Key","None", (void*)WKBD_WINDOW9
,
678 NULL
, getKeybind
, setKeyGrab
680 {"WindowShortcut10Key","None", (void*)WKBD_WINDOW10
,
681 NULL
, getKeybind
, setKeyGrab
683 #endif /* EXTEND_WINDOWSHORTCUT */
685 #ifdef KEEP_XKB_LOCK_STATUS
686 ,{"ToggleKbdModeKey", "None", (void*)WKBD_TOGGLE
,
687 NULL
, getKeybind
, setKeyGrab
689 {"KbdModeLock", "NO", NULL
,
690 &wPreferences
.modelock
, getBool
, NULL
692 #endif /* KEEP_XKB_LOCK_STATUS */
693 #ifdef TITLE_TEXT_SHADOW
694 ,{"FShadowColor", "black", (void*)WS_SFOCUSED
,
695 NULL
, getColor
, setWTitleColor
697 {"PShadowColor", "black", (void*)WS_SPFOCUSED
,
698 NULL
, getColor
, setWTitleColor
700 {"UShadowColor", "grey50", (void*)WS_SUNFOCUSED
,
701 NULL
, getColor
, setWTitleColor
703 {"MShadowColor", "black", (void*)WS_SMENU
,
704 NULL
, getColor
, setMenuTitleColor
706 {"Shadow", "Yes", NULL
,
707 &wPreferences
.title_shadow
, getBool
, setJustify
709 #endif /* TITLE_TEXT_SHADOW */
714 static void rereadDefaults(void);
721 /* must defer the update because accessing X data from a
722 * signal handler can mess up Xlib */
731 WDefaultEntry
*entry
;
733 PLSetStringCmpHook(StringCompareHook
);
735 for (i
=0; i
<sizeof(optionList
)/sizeof(WDefaultEntry
); i
++) {
736 entry
= &optionList
[i
];
738 entry
->plkey
= PLMakeString(entry
->key
);
739 if (entry
->default_value
)
740 entry
->plvalue
= PLGetProplistWithDescription(entry
->default_value
);
742 entry
->plvalue
= NULL
;
745 for (i
=0; i
<sizeof(staticOptionList
)/sizeof(WDefaultEntry
); i
++) {
746 entry
= &staticOptionList
[i
];
748 entry
->plkey
= PLMakeString(entry
->key
);
749 if (entry
->default_value
)
750 entry
->plvalue
= PLGetProplistWithDescription(entry
->default_value
);
752 entry
->plvalue
= NULL
;
756 wDomainName = PLMakeString(WMDOMAIN_NAME);
757 wAttributeDomainName = PLMakeString(WMATTRIBUTE_DOMAIN_NAME);
759 PLRegister(wDomainName, rereadDefaults);
760 PLRegister(wAttributeDomainName, rereadDefaults);
769 wDefaultsInit(int screen_number
)
771 static int defaults_inited
= 0;
774 if (!defaults_inited
) {
778 dict
= PLGetDomain(wDomainName
);
780 wwarning(_("could not read domain \"%s\" from defaults database"),
781 PLGetString(wDomainName
));
790 wDefaultsDestroyDomain(WDDomain
*domain
)
792 if (domain
->dictionary
)
793 PLRelease(domain
->dictionary
);
800 wDefaultsInitDomain(char *domain
, Bool requireDictionary
)
804 static int inited
= 0;
807 proplist_t shared_dict
=NULL
;
814 db
= wmalloc(sizeof(WDDomain
));
815 memset(db
, 0, sizeof(WDDomain
));
816 db
->domain_name
= domain
;
817 db
->path
= wdefaultspathfordomain(domain
);
820 if (the_path
&& stat(the_path
, &stbuf
)>=0) {
821 db
->dictionary
= ReadProplistFromFile(the_path
);
822 if (db
->dictionary
) {
823 if (requireDictionary
&& !PLIsDictionary(db
->dictionary
)) {
824 PLRelease(db
->dictionary
);
825 db
->dictionary
= NULL
;
826 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
829 db
->timestamp
= stbuf
.st_mtime
;
831 wwarning(_("could not load domain %s from user defaults database"),
836 /* global system dictionary */
837 sprintf(path
, "%s/%s", SYSCONFDIR
, domain
);
838 if (stat(path
, &stbuf
)>=0) {
839 shared_dict
= ReadProplistFromFile(path
);
841 if (requireDictionary
&& !PLIsDictionary(shared_dict
)) {
842 wwarning(_("Domain %s (%s) of global defaults database is corrupted!"),
844 PLRelease(shared_dict
);
847 if (db
->dictionary
&& PLIsDictionary(shared_dict
) &&
848 PLIsDictionary(db
->dictionary
)) {
849 PLMergeDictionaries(shared_dict
, db
->dictionary
);
850 PLRelease(db
->dictionary
);
851 db
->dictionary
= shared_dict
;
852 if (stbuf
.st_mtime
> db
->timestamp
)
853 db
->timestamp
= stbuf
.st_mtime
;
854 } else if (!db
->dictionary
) {
855 db
->dictionary
= shared_dict
;
856 if (stbuf
.st_mtime
> db
->timestamp
)
857 db
->timestamp
= stbuf
.st_mtime
;
861 wwarning(_("could not load domain %s from global defaults database"),
866 /* set to save it in user's directory, no matter from where it was read */
867 if (db
->dictionary
) {
868 proplist_t tmp
= PLMakeString(db
->path
);
870 PLSetFilename(db
->dictionary
, tmp
);
879 wReadStaticDefaults(proplist_t dict
)
882 WDefaultEntry
*entry
;
887 for (i
=0; i
<sizeof(staticOptionList
)/sizeof(WDefaultEntry
); i
++) {
888 entry
= &staticOptionList
[i
];
891 plvalue
= PLGetDictionaryEntry(dict
, entry
->plkey
);
896 /* no default in the DB. Use builtin default */
897 plvalue
= entry
->plvalue
;
902 (*entry
->convert
)(NULL
, entry
, plvalue
, entry
->addr
, &tdata
);
904 (*entry
->update
)(NULL
, entry
, tdata
, entry
->extra_data
);
911 wDefaultsCheckDomains(void *foo
)
920 puts("Checking domains...");
922 if (stat(WDWindowMaker
->path
, &stbuf
)>=0
923 && WDWindowMaker
->timestamp
< stbuf
.st_mtime
) {
924 proplist_t shared_dict
= NULL
;
926 puts("Checking WindowMaker domain");
928 WDWindowMaker
->timestamp
= stbuf
.st_mtime
;
930 /* global dictionary */
931 sprintf(path
, "%s/WindowMaker", SYSCONFDIR
);
932 if (stat(path
, &stbuf
)>=0) {
933 shared_dict
= ReadProplistFromFile(path
);
934 if (shared_dict
&& !PLIsDictionary(shared_dict
)) {
935 wwarning(_("Domain %s (%s) of global defaults database is corrupted!"),
936 "WindowMaker", path
);
937 PLRelease(shared_dict
);
939 } else if (!shared_dict
) {
940 wwarning(_("could not load domain %s from global defaults database"),
944 /* user dictionary */
945 dict
= ReadProplistFromFile(WDWindowMaker
->path
);
947 if (!PLIsDictionary(dict
)) {
950 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
951 "WindowMaker", WDWindowMaker
->path
);
954 PLSetFilename(shared_dict
, PLGetFilename(dict
));
955 PLMergeDictionaries(shared_dict
, dict
);
960 for (i
=0; i
<wScreenCount
; i
++) {
961 scr
= wScreenWithNumber(i
);
963 wReadDefaults(scr
, dict
);
965 if (WDWindowMaker
->dictionary
) {
966 PLRelease(WDWindowMaker
->dictionary
);
968 WDWindowMaker
->dictionary
= dict
;
971 wwarning(_("could not load domain %s from user defaults database"),
975 PLRelease(shared_dict
);
979 if (stat(WDWindowAttributes
->path
, &stbuf
)>=0
980 && WDWindowAttributes
->timestamp
< stbuf
.st_mtime
) {
982 puts("Checking WMWindowAttributes domain");
984 dict
= ReadProplistFromFile(WDWindowAttributes
->path
);
986 if (!PLIsDictionary(dict
)) {
989 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
990 "WMWindowAttributes", WDWindowAttributes
->path
);
992 if (WDWindowAttributes
->dictionary
)
993 PLRelease(WDWindowAttributes
->dictionary
);
994 WDWindowAttributes
->dictionary
= dict
;
995 for (i
=0; i
<wScreenCount
; i
++) {
996 scr
= wScreenWithNumber(i
);
998 wDefaultUpdateIcons(scr
);
1002 wwarning(_("could not load domain %s from user defaults database"),
1003 "WMWindowAttributes");
1005 WDWindowAttributes
->timestamp
= stbuf
.st_mtime
;
1009 if (stat(WDRootMenu
->path
, &stbuf
)>=0
1010 && WDRootMenu
->timestamp
< stbuf
.st_mtime
) {
1011 dict
= ReadProplistFromFile(WDRootMenu
->path
);
1013 puts("Checking WMRootMenu domain");
1016 if (!PLIsArray(dict
) && !PLIsString(dict
)) {
1019 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
1020 "WMRootMenu", WDRootMenu
->path
);
1022 if (WDRootMenu
->dictionary
) {
1023 PLRelease(WDRootMenu
->dictionary
);
1025 WDRootMenu
->dictionary
= dict
;
1028 wwarning(_("could not load domain %s from user defaults database"),
1031 WDRootMenu
->timestamp
= stbuf
.st_mtime
;
1035 WMAddTimerHandler(DEFAULTS_CHECK_INTERVAL
, wDefaultsCheckDomains
, foo
);
1040 #define REFRESH_WINDOW_TEXTURES (1<<0)
1041 #define REFRESH_MENU_TEXTURES (1<<1)
1042 #define REFRESH_WINDOW_FONT (1<<2)
1043 #define REFRESH_MENU_TITLE_FONT (1<<3)
1044 #define REFRESH_MENU_FONT (1<<4)
1045 #define REFRESH_FORE_COLOR (1<<5)
1046 #define REFRESH_ICON_TILE (1<<6)
1047 #define REFRESH_ICON_FONT (1<<7)
1048 #define REFRESH_WORKSPACE_BACK (1<<8)
1050 #define REFRESH_BUTTON_IMAGES (1<<9)
1053 refreshMenus(WScreen
*scr
, int flags
)
1058 menu
= scr
->root_menu
;
1060 wMenuRefresh(!menu
->flags
.brother
? menu
: menu
->brother
, flags
);
1062 menu
= scr
->switch_menu
;
1064 wMenuRefresh(!menu
->flags
.brother
? menu
: menu
->brother
, flags
);
1068 menu
= scr
->workspace_menu
;
1070 wMenuRefresh(!menu
->flags
.brother
? menu
: menu
->brother
, flags
);
1072 menu
= scr
->window_menu
;
1074 wMenuRefresh(!menu
->flags
.brother
? menu
: menu
->brother
, flags
);
1076 menu
= scr
->icon_menu
;
1078 wMenuRefresh(!menu
->flags
.brother
? menu
: menu
->brother
, flags
);
1081 menu
= scr
->dock
->menu
;
1083 wMenuRefresh(!menu
->flags
.brother
? menu
: menu
->brother
, flags
);
1085 menu
= scr
->clip_menu
;
1087 wMenuRefresh(!menu
->flags
.brother
? menu
: menu
->brother
, flags
);
1089 menu
= scr
->clip_submenu
;
1091 wMenuRefresh(!menu
->flags
.brother
? menu
: menu
->brother
, flags
);
1093 menu
= scr
->clip_options
;
1095 wMenuRefresh(!menu
->flags
.brother
? menu
: menu
->brother
, flags
);
1100 refreshAppIcons(WScreen
*scr
, int flags
)
1102 WAppIcon
*aicon
= scr
->app_icon_list
;
1106 aicon
->icon
->force_paint
= 1;
1108 aicon
= aicon
->next
;
1114 refreshWindows(WScreen
*scr
, int flags
)
1118 wwin
= scr
->focused_window
;
1120 if (flags
& REFRESH_WINDOW_FONT
) {
1121 wWindowConfigureBorders(wwin
);
1123 if ((flags
& (REFRESH_ICON_TILE
|REFRESH_WINDOW_TEXTURES
)) &&
1124 wwin
->flags
.miniaturized
&& wwin
->icon
) {
1125 wwin
->icon
->force_paint
= 1;
1127 if (flags
& REFRESH_WINDOW_TEXTURES
) {
1128 wwin
->frame
->flags
.need_texture_remake
= 1;
1136 wReadDefaults(WScreen
*scr
, proplist_t new_dict
)
1138 proplist_t plvalue
, old_value
;
1139 WDefaultEntry
*entry
;
1143 proplist_t old_dict
= (WDWindowMaker
->dictionary
!=new_dict
1144 ? WDWindowMaker
->dictionary
: NULL
);
1150 for (i
=0; i
<sizeof(optionList
)/sizeof(WDefaultEntry
); i
++) {
1151 entry
= &optionList
[i
];
1154 plvalue
= PLGetDictionaryEntry(new_dict
, entry
->plkey
);
1161 old_value
= PLGetDictionaryEntry(old_dict
, entry
->plkey
);
1164 if (!plvalue
&& !old_value
) {
1165 /* no default in the DB. Use builtin default */
1166 plvalue
= entry
->plvalue
;
1167 if (plvalue
&& new_dict
) {
1168 PLInsertDictionaryEntry(new_dict
, entry
->plkey
, plvalue
);
1171 } else if (!plvalue
) {
1172 /* value was deleted from DB. Keep current value */
1174 } else if (!old_value
) {
1175 /* set value for the 1st time */
1176 } else if (!PLIsEqual(plvalue
, old_value
)) {
1177 /* value has changed */
1179 /* value was not changed since last time */
1185 printf("Updating %s to %s\n", entry
->key
, PLGetDescription(plvalue
));
1188 if ((*entry
->convert
)(scr
, entry
, plvalue
, entry
->addr
, &tdata
)) {
1189 if (entry
->update
) {
1191 (*entry
->update
)(scr
, entry
, tdata
, entry
->extra_data
);
1197 if (needs_refresh
!=0) {
1201 if (needs_refresh
& REFRESH_MENU_TEXTURES
)
1202 foo
|= MR_TEXT_BACK
;
1203 if (needs_refresh
& REFRESH_MENU_FONT
)
1205 if (needs_refresh
& REFRESH_MENU_TITLE_FONT
)
1206 foo
|= MR_TITLE_TEXT
;
1209 refreshMenus(scr
, foo
);
1211 if (needs_refresh
& (REFRESH_WINDOW_TEXTURES
|REFRESH_WINDOW_FONT
|
1213 refreshWindows(scr
, needs_refresh
);
1215 if (needs_refresh
& REFRESH_ICON_TILE
)
1216 refreshAppIcons(scr
, needs_refresh
);
1219 if ((needs_refresh
& REFRESH_BUTTON_IMAGES
)
1220 && wPreferences
.button_images
) {
1223 RImage
*image
= wPreferences
.button_images
;
1227 w
= wPreferences
.button_images
->width
/ 2;
1228 h
= wPreferences
.button_images
->height
/ PRED_BPIXMAPS
;
1230 theight
= scr
->title_font
->height
+ TITLEBAR_EXTRA_HEIGHT
- 3;
1232 for (i
= 0; i
< PRED_BPIXMAPS
; i
++) {
1233 tmp
= RGetSubImage(image
, 0, i
* h
, w
, h
);
1234 if (scr
->button_images
[0][i
])
1235 RDestroyImage(scr
->button_images
[0][i
]);
1237 scr
->button_images
[0][i
] = RScaleImage(tmp
, theight
, theight
);
1240 tmp
= RGetSubImage(image
, w
, i
* h
, image
->width
- w
, h
);
1241 if (scr
->button_images
[1][i
])
1242 RDestroyImage(scr
->button_images
[1][i
]);
1244 scr
->button_images
[1][i
] = RScaleImage(tmp
, theight
, theight
);
1248 #endif /* NEWSTUFF */
1249 wRefreshDesktop(scr
);
1255 wDefaultUpdateIcons(WScreen
*scr
)
1257 WAppIcon
*aicon
= scr
->app_icon_list
;
1258 WWindow
*wwin
= scr
->focused_window
;
1262 file
= wDefaultGetIconFile(scr
, aicon
->wm_instance
, aicon
->wm_class
,
1264 if ((file
&& aicon
->icon
->file
&& strcmp(file
, aicon
->icon
->file
)!=0)
1265 || (file
&& !aicon
->icon
->file
)) {
1268 if (aicon
->icon
->file
)
1269 free(aicon
->icon
->file
);
1270 aicon
->icon
->file
= wstrdup(file
);
1272 new_image
= wDefaultGetImage(scr
, aicon
->wm_instance
,
1275 wIconChangeImage(aicon
->icon
, new_image
);
1276 wAppIconPaint(aicon
);
1279 aicon
= aicon
->next
;
1282 if (!wPreferences
.flags
.noclip
)
1283 wClipIconPaint(scr
->clip_icon
);
1286 if (wwin
->icon
&& wwin
->flags
.miniaturized
) {
1287 file
= wDefaultGetIconFile(scr
, wwin
->wm_instance
, wwin
->wm_class
,
1289 if ((file
&& wwin
->icon
->file
&& strcmp(file
, wwin
->icon
->file
)!=0)
1290 || (file
&& !wwin
->icon
->file
)) {
1293 if (wwin
->icon
->file
)
1294 free(wwin
->icon
->file
);
1295 wwin
->icon
->file
= wstrdup(file
);
1297 new_image
= wDefaultGetImage(scr
, wwin
->wm_instance
,
1300 wIconChangeImage(wwin
->icon
, new_image
);
1308 /* --------------------------- Local ----------------------- */
1310 #define STRINGP(x) if (!PLIsString(value)) { \
1311 wwarning(_("Wrong option format for key \"%s\". Should be %s."), \
1318 string2index(proplist_t key
, proplist_t val
, proplist_t def
,
1319 WOptionEnumeration
*values
)
1322 WOptionEnumeration
*v
;
1323 char buffer
[TOTAL_VALUES_LENGTH
];
1325 if (PLIsString(val
) && (str
= PLGetString(val
))) {
1326 for (v
=values
; v
->string
!=NULL
; v
++) {
1327 if (strcasecmp(v
->string
, str
)==0)
1333 for (v
=values
; v
->string
!=NULL
; v
++) {
1336 strcat(buffer
, ", ");
1337 strcat(buffer
, v
->string
);
1340 wwarning(_("wrong option value for key \"%s\". Should be one of %s"),
1341 PLGetString(key
), buffer
);
1344 return string2index(key
, val
, NULL
, values
);
1354 * value - is the value in the defaults DB
1355 * addr - is the address to store the data
1356 * ret - is the address to store a pointer to a temporary buffer. ret
1357 * must not be freed and is used by the set functions
1360 getBool(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
1369 val
= PLGetString(value
);
1372 if ((val
[1]=='\0' && (val
[0]=='y' || val
[0]=='Y'))
1373 || strcasecmp(val
, "YES")==0) {
1376 } else if ((val
[1]=='\0' && (val
[0]=='n' || val
[0]=='N'))
1377 || strcasecmp(val
, "NO")==0) {
1381 if (sscanf(val
, "%i", &i
)==1) {
1387 wwarning(_("can't convert \"%s\" to boolean for key \"%s\""),
1389 if (second_pass
==0) {
1390 val
= PLGetString(entry
->plvalue
);
1392 wwarning(_("using default \"%s\" instead"), val
);
1403 *(char*)addr
= data
;
1411 getInt(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
1420 val
= PLGetString(value
);
1422 if (sscanf(val
, "%i", &data
)!=1) {
1423 wwarning(_("can't convert \"%s\" to integer for key \"%s\""),
1425 val
= PLGetString(entry
->plvalue
);
1426 wwarning(_("using default \"%s\" instead"), val
);
1427 if (sscanf(val
, "%i", &data
)!=1) {
1443 getCoord(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
1447 char *val_x
, *val_y
;
1448 int nelem
, changed
=0;
1449 proplist_t elem_x
, elem_y
;
1452 if (!PLIsArray(value
)) {
1453 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1454 entry
->key
, "Coordinate");
1456 value
= entry
->plvalue
;
1458 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1464 nelem
= PLGetNumberOfElements(value
);
1466 wwarning(_("Incorrect number of elements in array for key \"%s\"."),
1469 value
= entry
->plvalue
;
1471 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1477 elem_x
= PLGetArrayElement(value
, 0);
1478 elem_y
= PLGetArrayElement(value
, 1);
1480 if (!elem_x
|| !elem_y
|| !PLIsString(elem_x
) || !PLIsString(elem_y
)) {
1481 wwarning(_("Wrong value for key \"%s\". Should be Coordinate."),
1484 value
= entry
->plvalue
;
1486 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1492 val_x
= PLGetString(elem_x
);
1493 val_y
= PLGetString(elem_y
);
1495 if (sscanf(val_x
, "%i", &data
.x
)!=1 || sscanf(val_y
, "%i", &data
.y
)!=1) {
1496 wwarning(_("can't convert array to integers for \"%s\"."), entry
->key
);
1498 value
= entry
->plvalue
;
1500 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1508 else if (data
.x
> scr
->scr_width
/3)
1509 data
.x
= scr
->scr_width
/3;
1512 else if (data
.y
> scr
->scr_height
/3)
1513 data
.y
= scr
->scr_height
/3;
1519 *(WCoord
*)addr
= data
;
1527 /* This function is not used at the moment. */
1529 getString(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
1536 data
= PLGetString(value
);
1539 data
= PLGetString(entry
->plvalue
);
1548 *(char**)addr
= wstrdup(data
);
1556 getPathList(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
1566 if (!PLIsArray(value
)) {
1567 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1568 entry
->key
, "an array of paths");
1570 value
= entry
->plvalue
;
1572 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1579 count
= PLGetNumberOfElements(value
);
1582 value
= entry
->plvalue
;
1584 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1591 for (i
=0; i
<count
; i
++) {
1592 d
= PLGetArrayElement(value
, i
);
1593 if (!d
|| !PLIsString(d
)) {
1597 len
+= strlen(PLGetString(d
))+1;
1600 ptr
= data
= wmalloc(len
+1);
1602 for (i
=0; i
<count
; i
++) {
1603 d
= PLGetArrayElement(value
, i
);
1604 if (!d
|| !PLIsString(d
)) {
1607 strcpy(ptr
, PLGetString(d
));
1608 ptr
+= strlen(PLGetString(d
));
1612 ptr
--; *(ptr
--) = 0;
1614 if (*(char**)addr
!=NULL
) {
1615 free(*(char**)addr
);
1617 *(char**)addr
= data
;
1624 getEnum(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
1627 static signed char data
;
1629 data
= string2index(entry
->plkey
, value
, entry
->default_value
,
1630 (WOptionEnumeration
*)entry
->extra_data
);
1638 *(signed char*)addr
= data
;
1647 * (hgradient <color> <color>)
1648 * (vgradient <color> <color>)
1649 * (dgradient <color> <color>)
1650 * (mhgradient <color> <color> ...)
1651 * (mvgradient <color> <color> ...)
1652 * (tpixmap <file> <color>)
1653 * (spixmap <file> <color>)
1654 * (cpixmap <file> <color>)
1655 * (thgradient <file> <opaqueness> <color> <color>)
1656 * (tvgradient <file> <opaqueness> <color> <color>)
1657 * (tdgradient <file> <opaqueness> <color> <color>)
1658 * (function <lib> <function> ...)
1662 parse_texture(WScreen
*scr
, proplist_t pl
)
1667 WTexture
*texture
=NULL
;
1669 nelem
= PLGetNumberOfElements(pl
);
1674 elem
= PLGetArrayElement(pl
, 0);
1675 if (!elem
|| !PLIsString(elem
))
1677 val
= PLGetString(elem
);
1680 if (strcasecmp(val
, "solid")==0) {
1688 elem
= PLGetArrayElement(pl
, 1);
1689 if (!elem
|| !PLIsString(elem
))
1691 val
= PLGetString(elem
);
1693 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &color
)) {
1694 wwarning(_("\"%s\" is not a valid color name"), val
);
1698 texture
= (WTexture
*)wTextureMakeSolid(scr
, &color
);
1699 } else if (strcasecmp(val
, "dgradient")==0
1700 || strcasecmp(val
, "vgradient")==0
1701 || strcasecmp(val
, "hgradient")==0) {
1702 RColor color1
, color2
;
1707 wwarning(_("bad number of arguments in gradient specification"));
1711 if (val
[0]=='d' || val
[0]=='D')
1712 type
= WTEX_DGRADIENT
;
1713 else if (val
[0]=='h' || val
[0]=='H')
1714 type
= WTEX_HGRADIENT
;
1716 type
= WTEX_VGRADIENT
;
1719 /* get from color */
1720 elem
= PLGetArrayElement(pl
, 1);
1721 if (!elem
|| !PLIsString(elem
))
1723 val
= PLGetString(elem
);
1725 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1726 wwarning(_("\"%s\" is not a valid color name"), val
);
1730 color1
.red
= xcolor
.red
>> 8;
1731 color1
.green
= xcolor
.green
>> 8;
1732 color1
.blue
= xcolor
.blue
>> 8;
1735 elem
= PLGetArrayElement(pl
, 2);
1736 if (!elem
|| !PLIsString(elem
)) {
1739 val
= PLGetString(elem
);
1741 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1742 wwarning(_("\"%s\" is not a valid color name"), val
);
1746 color2
.red
= xcolor
.red
>> 8;
1747 color2
.green
= xcolor
.green
>> 8;
1748 color2
.blue
= xcolor
.blue
>> 8;
1750 texture
= (WTexture
*)wTextureMakeGradient(scr
, type
, &color1
, &color2
);
1752 } else if (strcasecmp(val
, "mhgradient")==0
1753 || strcasecmp(val
, "mvgradient")==0
1754 || strcasecmp(val
, "mdgradient")==0) {
1761 wwarning(_("too few arguments in multicolor gradient specification"));
1765 if (val
[1]=='h' || val
[1]=='H')
1766 type
= WTEX_MHGRADIENT
;
1767 else if (val
[1]=='v' || val
[1]=='V')
1768 type
= WTEX_MVGRADIENT
;
1770 type
= WTEX_MDGRADIENT
;
1774 colors
= wmalloc(sizeof(RColor
*)*(count
+1));
1776 for (i
=0; i
<count
; i
++) {
1777 elem
= PLGetArrayElement(pl
, i
+1);
1778 if (!elem
|| !PLIsString(elem
)) {
1779 for (--i
; i
>=0; --i
) {
1785 val
= PLGetString(elem
);
1787 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &color
)) {
1788 wwarning(_("\"%s\" is not a valid color name"), val
);
1789 for (--i
; i
>=0; --i
) {
1795 colors
[i
] = wmalloc(sizeof(RColor
));
1796 colors
[i
]->red
= color
.red
>> 8;
1797 colors
[i
]->green
= color
.green
>> 8;
1798 colors
[i
]->blue
= color
.blue
>> 8;
1803 texture
= (WTexture
*)wTextureMakeMGradient(scr
, type
, colors
);
1804 } else if (strcasecmp(val
, "spixmap")==0 ||
1805 strcasecmp(val
, "cpixmap")==0 ||
1806 strcasecmp(val
, "tpixmap")==0) {
1813 if (val
[0] == 's' || val
[0] == 'S')
1815 else if (val
[0] == 'c' || val
[0] == 'C')
1821 elem
= PLGetArrayElement(pl
, 2);
1822 if (!elem
|| !PLIsString(elem
)) {
1825 val
= PLGetString(elem
);
1827 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &color
)) {
1828 wwarning(_("\"%s\" is not a valid color name"), val
);
1833 elem
= PLGetArrayElement(pl
, 1);
1834 if (!elem
|| !PLIsString(elem
))
1836 val
= PLGetString(elem
);
1838 texture
= (WTexture
*)wTextureMakePixmap(scr
, type
, val
, &color
);
1839 } else if (strcasecmp(val
, "thgradient")==0
1840 || strcasecmp(val
, "tvgradient")==0
1841 || strcasecmp(val
, "tdgradient")==0) {
1842 RColor color1
, color2
;
1847 if (val
[1]=='h' || val
[1]=='H')
1848 style
= WTEX_THGRADIENT
;
1849 else if (val
[1]=='v' || val
[1]=='V')
1850 style
= WTEX_TVGRADIENT
;
1852 style
= WTEX_TDGRADIENT
;
1855 wwarning(_("bad number of arguments in textured gradient specification"));
1859 /* get from color */
1860 elem
= PLGetArrayElement(pl
, 3);
1861 if (!elem
|| !PLIsString(elem
))
1863 val
= PLGetString(elem
);
1865 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1866 wwarning(_("\"%s\" is not a valid color name"), val
);
1870 color1
.red
= xcolor
.red
>> 8;
1871 color1
.green
= xcolor
.green
>> 8;
1872 color1
.blue
= xcolor
.blue
>> 8;
1875 elem
= PLGetArrayElement(pl
, 4);
1876 if (!elem
|| !PLIsString(elem
)) {
1879 val
= PLGetString(elem
);
1881 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1882 wwarning(_("\"%s\" is not a valid color name"), val
);
1886 color2
.red
= xcolor
.red
>> 8;
1887 color2
.green
= xcolor
.green
>> 8;
1888 color2
.blue
= xcolor
.blue
>> 8;
1891 elem
= PLGetArrayElement(pl
, 2);
1892 if (!elem
|| !PLIsString(elem
))
1895 val
= PLGetString(elem
);
1897 if (!val
|| (opacity
= atoi(val
)) < 0 || opacity
> 255) {
1898 wwarning(_("bad opacity value for tgradient texture \"%s\". Should be [0..255]"), val
);
1903 elem
= PLGetArrayElement(pl
, 1);
1904 if (!elem
|| !PLIsString(elem
))
1906 val
= PLGetString(elem
);
1908 texture
= (WTexture
*)wTextureMakeTGradient(scr
, style
, &color1
, &color2
,
1911 #ifdef TEXTURE_PLUGIN
1912 else if (strcasecmp(val
, "function")==0) {
1913 WTexFunction
*function
;
1914 void (*initFunc
) (Display
*, Colormap
);
1915 char *lib
, *func
, **argv
;
1921 /* get the library name */
1922 elem
= PLGetArrayElement(pl
, 1);
1923 if (!elem
|| !PLIsString(elem
)) {
1926 lib
= PLGetString(elem
);
1928 /* get the function name */
1929 elem
= PLGetArrayElement(pl
, 2);
1930 if (!elem
|| !PLIsString(elem
)) {
1933 func
= PLGetString(elem
);
1936 argv
= (char **)wmalloc(argc
* sizeof(char *));
1938 /* get the parameters */
1939 argv
[0] = wstrdup(func
);
1940 for (i
= 0; i
< argc
- 1; i
++) {
1941 elem
= PLGetArrayElement(pl
, 3 + i
);
1942 if (!elem
|| !PLIsString(elem
)) {
1947 argv
[i
+1] = wstrdup(PLGetString(elem
));
1950 function
= wTextureMakeFunction(scr
, lib
, func
, argc
, argv
);
1954 initFunc
= dlsym(function
->handle
, "initWindowMaker");
1956 initFunc(dpy
, scr
->w_colormap
);
1958 wwarning(_("could not initialize library %s"), lib
);
1961 wwarning(_("could not find function %s::%s"), lib
, func
);
1963 #endif /* HAVE_DLFCN_H */
1964 texture
= (WTexture
*)function
;
1966 #endif /* TEXTURE_PLUGIN */
1968 wwarning(_("invalid texture type %s"), val
);
1977 getTexture(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
1980 static WTexture
*texture
;
1984 if (!PLIsArray(value
)) {
1985 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1986 entry
->key
, "Texture");
1988 value
= entry
->plvalue
;
1990 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1996 if (strcmp(entry
->key
, "WidgetColor")==0 && !changed
) {
1999 pl
= PLGetArrayElement(value
, 0);
2000 if (!pl
|| !PLIsString(pl
) || !PLGetString(pl
)
2001 || strcasecmp(PLGetString(pl
), "solid")!=0) {
2002 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
2003 entry
->key
, "Solid Texture");
2005 value
= entry
->plvalue
;
2007 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
2012 texture
= parse_texture(scr
, value
);
2015 wwarning(_("Error in texture specification for key \"%s\""),
2018 value
= entry
->plvalue
;
2020 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
2030 *(WTexture
**)addr
= texture
;
2038 getWSBackground(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
,
2039 void *addr
, void **ret
)
2047 if (!PLIsArray(value
)) {
2048 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
2049 "WorkspaceBack", "Texture or None");
2051 value
= entry
->plvalue
;
2053 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
2059 /* only do basic error checking and verify for None texture */
2061 nelem
= PLGetNumberOfElements(value
);
2063 elem
= PLGetArrayElement(value
, 0);
2064 if (!elem
|| !PLIsString(elem
)) {
2065 wwarning(_("Wrong type for workspace background. Should be a texture type."));
2067 value
= entry
->plvalue
;
2069 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
2074 val
= PLGetString(elem
);
2076 if (strcasecmp(val
, "None")==0)
2079 *ret
= PLRetain(value
);
2086 getWSSpecificBackground(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
,
2087 void *addr
, void **ret
)
2094 if (!PLIsArray(value
)) {
2095 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
2096 "WorkspaceSpecificBack", "an array of textures");
2098 value
= entry
->plvalue
;
2100 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
2106 /* only do basic error checking and verify for None texture */
2108 nelem
= PLGetNumberOfElements(value
);
2111 elem
= PLGetArrayElement(value
, nelem
);
2112 if (!elem
|| !PLIsArray(elem
)) {
2113 wwarning(_("Wrong type for background of workspace %i. Should be a texture."),
2119 *ret
= PLRetain(value
);
2123 * Kluge to force wmsetbg helper to set the default background.
2124 * If the WorkspaceSpecificBack is changed once wmaker has started,
2125 * the WorkspaceBack won't be sent to the helper, unless the user
2126 * changes it's value too. So, we must force this by removing the
2127 * value from the defaults DB.
2129 if (!scr
->flags
.backimage_helper_launched
&& !scr
->flags
.startup
) {
2130 proplist_t key
= PLMakeString("WorkspaceBack");
2132 PLRemoveDictionaryEntry(WDWindowMaker
->dictionary
, key
);
2142 getFont(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
2150 val
= PLGetString(value
);
2152 font
= wLoadFont(val
);
2154 wfatal(_("could not load any usable font!!!"));
2161 /* can't assign font value outside update function */
2162 wassertrv(addr
== NULL
, True
);
2169 getColor(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
2172 static unsigned long pixel
;
2179 val
= PLGetString(value
);
2182 if (!wGetColor(scr
, val
, &color
)) {
2183 wwarning(_("could not get color for key \"%s\""),
2185 if (second_pass
==0) {
2186 val
= PLGetString(entry
->plvalue
);
2188 wwarning(_("using default \"%s\" instead"), val
);
2194 pixel
= color
.pixel
;
2200 *(unsigned long*)addr
= pixel
;
2208 getKeybind(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
2211 static WShortKey shortcut
;
2218 STRINGP("Key spec");
2220 val
= PLGetString(value
);
2222 if (!val
|| strcasecmp(val
, "NONE")==0) {
2223 shortcut
.keycode
= 0;
2224 shortcut
.modifier
= 0;
2235 shortcut
.modifier
= 0;
2236 while ((k
= strchr(b
, '+'))!=NULL
) {
2240 mod
= wXModifierFromKey(b
);
2242 wwarning(_("%s:invalid key modifier \"%s\""), entry
->key
, b
);
2245 shortcut
.modifier
|= mod
;
2251 ksym
= XStringToKeysym(b
);
2253 if (ksym
==NoSymbol
) {
2254 wwarning(_("%s:invalid kbd shortcut specification \"%s\""), entry
->key
,
2259 shortcut
.keycode
= XKeysymToKeycode(dpy
, ksym
);
2260 if (shortcut
.keycode
==0) {
2261 wwarning(_("%s:invalid key in shortcut \"%s\""), entry
->key
, val
);
2273 getModMask(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
2279 STRINGP("Modifier Key");
2281 str
= PLGetString(value
);
2285 mask
= wXModifierFromKey(str
);
2287 wwarning(_("%s: modifier key %s is not valid"), entry
->key
, str
);
2293 *(unsigned int*)addr
= mask
;
2304 getRImages(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
,
2305 void *addr
, void **ret
)
2313 STRINGP("Image File Path");
2315 str
= PLGetString(value
);
2319 image
= RLoadImage(scr
->rcontext
, str
, 0);
2321 wwarning(_("could not load image in option %s: %s"), entry
->key
,
2322 RMessageForError(RErrorCode
));
2326 if (*(RImage
**)addr
) {
2327 RDestroyImage(*(RImage
**)addr
);
2330 *(RImage
**)addr
= image
;
2332 assert(ret
== NULL
);
2335 *(RImage**)ret = image;
2343 /* ---------------- value setting functions --------------- */
2345 setJustify(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
2347 return REFRESH_FORE_COLOR
;
2352 setIfDockPresent(WScreen
*scr
, WDefaultEntry
*entry
, int *flag
, long which
)
2356 wPreferences
.flags
.nodock
= wPreferences
.flags
.nodock
|| *flag
;
2359 wPreferences
.flags
.noclip
= wPreferences
.flags
.noclip
|| *flag
;
2369 setStickyIcons(WScreen
*scr
, WDefaultEntry
*entry
, void *bar
, void *foo
)
2371 if (scr
->workspaces
) {
2372 wWorkspaceForceChange(scr
, scr
->current_workspace
);
2373 wArrangeIcons(scr
, False
);
2380 setPositive(WScreen
*scr
, WDefaultEntry
*entry
, int *value
, void *foo
)
2392 setIconTile(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
2398 img
= wTextureRenderImage(*texture
, wPreferences
.icon_size
,
2399 wPreferences
.icon_size
,
2400 ((*texture
)->any
.type
& WREL_BORDER_MASK
)
2401 ? WREL_ICON
: WREL_FLAT
);
2403 wwarning(_("could not render texture for icon background"));
2405 wTextureDestroy(scr
, *texture
);
2408 RConvertImage(scr
->rcontext
, img
, &pixmap
);
2410 if (scr
->icon_tile
) {
2412 RDestroyImage(scr
->icon_tile
);
2413 XFreePixmap(dpy
, scr
->icon_tile_pixmap
);
2416 scr
->icon_tile
= img
;
2418 if (!wPreferences
.flags
.noclip
) {
2419 if (scr
->clip_tile
) {
2420 RDestroyImage(scr
->clip_tile
);
2422 scr
->clip_tile
= wClipMakeTile(scr
, img
);
2425 scr
->icon_tile_pixmap
= pixmap
;
2427 if (scr
->def_icon_pixmap
) {
2428 XFreePixmap(dpy
, scr
->def_icon_pixmap
);
2429 scr
->def_icon_pixmap
= None
;
2431 if (scr
->def_ticon_pixmap
) {
2432 XFreePixmap(dpy
, scr
->def_ticon_pixmap
);
2433 scr
->def_ticon_pixmap
= None
;
2436 if (scr
->icon_back_texture
) {
2437 wTextureDestroy(scr
, (WTexture
*)scr
->icon_back_texture
);
2439 scr
->icon_back_texture
= wTextureMakeSolid(scr
, &((*texture
)->any
.color
));
2441 if (scr
->clip_balloon
)
2442 XSetWindowBackground(dpy
, scr
->clip_balloon
,
2443 (*texture
)->any
.color
.pixel
);
2446 * Free the texture as nobody else will use it, nor refer to it.
2449 wTextureDestroy(scr
, *texture
);
2451 return (reset
? REFRESH_ICON_TILE
: 0);
2457 setWinTitleFont(WScreen
*scr
, WDefaultEntry
*entry
, WFont
*font
, void *foo
)
2459 if (scr
->title_font
) {
2460 wFreeFont(scr
->title_font
);
2463 scr
->title_font
= font
;
2466 XSetFont(dpy
, scr
->window_title_gc
, font
->font
->fid
);
2469 return REFRESH_WINDOW_FONT
|REFRESH_BUTTON_IMAGES
;
2474 setMenuTitleFont(WScreen
*scr
, WDefaultEntry
*entry
, WFont
*font
, void *foo
)
2476 if (scr
->menu_title_font
) {
2477 wFreeFont(scr
->menu_title_font
);
2480 scr
->menu_title_font
= font
;
2483 XSetFont(dpy
, scr
->menu_title_gc
, font
->font
->fid
);
2486 return REFRESH_MENU_TITLE_FONT
;
2491 setMenuTextFont(WScreen
*scr
, WDefaultEntry
*entry
, WFont
*font
, void *foo
)
2493 if (scr
->menu_entry_font
) {
2494 wFreeFont(scr
->menu_entry_font
);
2497 scr
->menu_entry_font
= font
;
2500 XSetFont(dpy
, scr
->menu_entry_gc
, font
->font
->fid
);
2501 XSetFont(dpy
, scr
->disabled_menu_entry_gc
, font
->font
->fid
);
2502 XSetFont(dpy
, scr
->select_menu_gc
, font
->font
->fid
);
2505 return REFRESH_MENU_FONT
;
2511 setIconTitleFont(WScreen
*scr
, WDefaultEntry
*entry
, WFont
*font
, void *foo
)
2513 if (scr
->icon_title_font
) {
2514 wFreeFont(scr
->icon_title_font
);
2517 scr
->icon_title_font
= font
;
2520 XSetFont(dpy
, scr
->icon_title_gc
, font
->font
->fid
);
2523 return REFRESH_ICON_FONT
;
2528 setClipTitleFont(WScreen
*scr
, WDefaultEntry
*entry
, WFont
*font
, void *foo
)
2530 if (scr
->clip_title_font
) {
2531 wFreeFont(scr
->clip_title_font
);
2534 scr
->clip_title_font
= font
;
2537 XSetFont(dpy
, scr
->clip_title_gc
, font
->font
->fid
);
2540 return REFRESH_ICON_FONT
;
2545 setDisplayFont(WScreen
*scr
, WDefaultEntry
*entry
, WFont
*font
, void *foo
)
2547 if (scr
->info_text_font
) {
2548 wFreeFont(scr
->info_text_font
);
2551 scr
->info_text_font
= font
;
2554 XSetFont(dpy
, scr
->info_text_gc
, font
->font
->fid
);
2555 XSetFont(dpy
, scr
->line_gc
, font
->font
->fid
);
2558 /* This test works because the scr structure is initially zeroed out
2559 and None = 0. Any other time, the window should be valid. */
2560 if (scr
->geometry_display
!= None
) {
2561 wGetGeometryWindowSize(scr
, &scr
->geometry_display_width
,
2562 &scr
->geometry_display_height
);
2563 XResizeWindow(dpy
, scr
->geometry_display
,
2564 scr
->geometry_display_width
, scr
->geometry_display_height
);
2572 setHightlight(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, void *foo
)
2574 if (scr
->select_pixel
!=scr
->white_pixel
&&
2575 scr
->select_pixel
!=scr
->black_pixel
) {
2576 wFreeColor(scr
, scr
->select_pixel
);
2579 scr
->select_pixel
= color
->pixel
;
2581 return REFRESH_FORE_COLOR
;
2586 setHightlightText(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, void *foo
)
2588 if (scr
->select_text_pixel
!=scr
->white_pixel
&&
2589 scr
->select_text_pixel
!=scr
->black_pixel
) {
2590 wFreeColor(scr
, scr
->select_text_pixel
);
2593 scr
->select_text_pixel
= color
->pixel
;
2595 return REFRESH_FORE_COLOR
;
2600 setClipTitleColor(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, long index
)
2602 if (scr
->clip_title_pixel
[index
]!=scr
->white_pixel
&&
2603 scr
->clip_title_pixel
[index
]!=scr
->black_pixel
) {
2604 wFreeColor(scr
, scr
->clip_title_pixel
[index
]);
2607 scr
->clip_title_pixel
[index
] = color
->pixel
;
2609 return REFRESH_FORE_COLOR
;
2614 setWTitleColor(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, long index
)
2616 if (scr
->window_title_pixel
[index
]!=scr
->white_pixel
&&
2617 scr
->window_title_pixel
[index
]!=scr
->black_pixel
) {
2618 wFreeColor(scr
, scr
->window_title_pixel
[index
]);
2621 scr
->window_title_pixel
[index
] = color
->pixel
;
2623 if (index
== WS_UNFOCUSED
)
2624 XSetForeground(dpy
, scr
->info_text_gc
, color
->pixel
);
2626 return REFRESH_FORE_COLOR
;
2631 setMenuTitleColor(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, long index
)
2633 #ifdef TITLE_TEXT_SHADOW
2634 if (index
== WS_SMENU
){
2635 if (scr
->menu_title_pixel
[WS_SMENU
]!=scr
->white_pixel
&&
2636 scr
->menu_title_pixel
[WS_SMENU
]!=scr
->black_pixel
) {
2637 wFreeColor(scr
, scr
->menu_title_pixel
[WS_SMENU
]);
2639 scr
->menu_title_pixel
[WS_SMENU
] = color
->pixel
;
2642 if (scr
->menu_title_pixel
[0]!=scr
->white_pixel
&&
2643 scr
->menu_title_pixel
[0]!=scr
->black_pixel
) {
2644 wFreeColor(scr
, scr
->menu_title_pixel
[0]);
2646 scr
->menu_title_pixel
[0] = color
->pixel
;
2648 #else /* !TITLE_TEXT_SHADOW */
2649 if (scr
->menu_title_pixel
[0]!=scr
->white_pixel
&&
2650 scr
->menu_title_pixel
[0]!=scr
->black_pixel
) {
2651 wFreeColor(scr
, scr
->menu_title_pixel
[0]);
2654 scr
->menu_title_pixel
[0] = color
->pixel
;
2655 #endif /* !TITLE_TEXT_SHADOW */
2656 XSetForeground(dpy
, scr
->menu_title_gc
, color
->pixel
);
2658 return REFRESH_FORE_COLOR
;
2663 setMenuTextColor(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, void *foo
)
2666 #define gcm (GCForeground|GCBackground|GCFillStyle)
2668 if (scr
->mtext_pixel
!=scr
->white_pixel
&&
2669 scr
->mtext_pixel
!=scr
->black_pixel
) {
2670 wFreeColor(scr
, scr
->mtext_pixel
);
2673 scr
->mtext_pixel
= color
->pixel
;
2675 XSetForeground(dpy
, scr
->menu_entry_gc
, color
->pixel
);
2678 if (scr
->dtext_pixel
== scr
->mtext_pixel
) {
2679 gcv
.foreground
= scr
->white_pixel
;
2680 gcv
.background
= scr
->black_pixel
;
2681 gcv
.fill_style
= FillStippled
;
2683 gcv
.foreground
= scr
->dtext_pixel
;
2684 gcv
.fill_style
= FillSolid
;
2686 XChangeGC(dpy
, scr
->disabled_menu_entry_gc
, gcm
, &gcv
);
2688 return REFRESH_FORE_COLOR
;
2694 setMenuDisabledColor(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, void *foo
)
2697 #define gcm (GCForeground|GCBackground|GCFillStyle)
2699 if (scr
->dtext_pixel
!=scr
->white_pixel
&&
2700 scr
->dtext_pixel
!=scr
->black_pixel
) {
2701 wFreeColor(scr
, scr
->dtext_pixel
);
2704 scr
->dtext_pixel
= color
->pixel
;
2706 if (scr
->dtext_pixel
== scr
->mtext_pixel
) {
2707 gcv
.foreground
= scr
->white_pixel
;
2708 gcv
.background
= scr
->black_pixel
;
2709 gcv
.fill_style
= FillStippled
;
2711 gcv
.foreground
= scr
->dtext_pixel
;
2712 gcv
.fill_style
= FillSolid
;
2714 XChangeGC(dpy
, scr
->disabled_menu_entry_gc
, gcm
, &gcv
);
2716 return REFRESH_FORE_COLOR
;
2721 setIconTitleColor(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, void *foo
)
2723 XSetForeground(dpy
, scr
->icon_title_gc
, color
->pixel
);
2725 return REFRESH_FORE_COLOR
;
2729 setIconTitleBack(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, void *foo
)
2731 if (scr
->icon_title_texture
) {
2732 wTextureDestroy(scr
, (WTexture
*)scr
->icon_title_texture
);
2734 XQueryColor (dpy
, scr
->w_colormap
, color
);
2735 scr
->icon_title_texture
= wTextureMakeSolid(scr
, color
);
2737 return REFRESH_WINDOW_TEXTURES
;
2742 trackDeadProcess(pid_t pid
, unsigned char status
, WScreen
*scr
)
2744 close(scr
->helper_fd
);
2746 scr
->helper_pid
= 0;
2747 scr
->flags
.backimage_helper_launched
= 0;
2752 setWorkspaceSpecificBack(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
,
2759 if (scr
->flags
.backimage_helper_launched
) {
2760 if (PLGetNumberOfElements(value
)==0) {
2761 SendHelperMessage(scr
, 'C', 0, NULL
);
2762 SendHelperMessage(scr
, 'K', 0, NULL
);
2771 if (PLGetNumberOfElements(value
) == 0)
2774 if (pipe(filedes
) < 0) {
2775 wsyserror("pipe() failed:can't set workspace specific background image");
2783 wsyserror("fork() failed:can't set workspace specific background image");
2784 if (close(filedes
[0]) < 0)
2785 wsyserror("could not close pipe");
2786 if (close(filedes
[1]) < 0)
2787 wsyserror("could not close pipe");
2789 } else if (pid
== 0) {
2790 SetupEnvironment(scr
);
2793 wsyserror("could not close pipe");
2794 if (dup(filedes
[0]) < 0) {
2795 wsyserror("dup() failed:can't set workspace specific background image");
2797 execlp("wmsetbg", "wmsetbg", "-helper", "-d", NULL
);
2798 wsyserror("could not execute wmsetbg");
2802 if (fcntl(filedes
[0], F_SETFD
, FD_CLOEXEC
) < 0) {
2803 wsyserror("error setting close-on-exec flag");
2805 if (fcntl(filedes
[1], F_SETFD
, FD_CLOEXEC
) < 0) {
2806 wsyserror("error setting close-on-exec flag");
2809 scr
->helper_fd
= filedes
[1];
2810 scr
->helper_pid
= pid
;
2811 scr
->flags
.backimage_helper_launched
= 1;
2813 wAddDeathHandler(pid
, (WDeathHandler
*)trackDeadProcess
, scr
);
2815 SendHelperMessage(scr
, 'P', -1, wPreferences
.pixmap_path
);
2819 for (i
= 0; i
< PLGetNumberOfElements(value
); i
++) {
2820 val
= PLGetArrayElement(value
, i
);
2821 if (val
&& PLIsArray(val
) && PLGetNumberOfElements(val
)>0) {
2822 str
= PLGetDescription(val
);
2824 SendHelperMessage(scr
, 'S', i
+1, str
);
2828 SendHelperMessage(scr
, 'U', i
+1, NULL
);
2839 setWorkspaceBack(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
,
2842 if (scr
->flags
.backimage_helper_launched
) {
2845 if (PLGetNumberOfElements(value
)==0) {
2846 SendHelperMessage(scr
, 'U', 0, NULL
);
2848 /* set the default workspace background to this one */
2849 str
= PLGetDescription(value
);
2851 SendHelperMessage(scr
, 'S', 0, str
);
2853 SendHelperMessage(scr
, 'C', scr
->current_workspace
+1, NULL
);
2855 SendHelperMessage(scr
, 'U', 0, NULL
);
2862 SetupEnvironment(scr
);
2863 text
= PLGetDescription(value
);
2864 command
= wmalloc(strlen(text
)+40);
2865 sprintf(command
, "wmsetbg -d -p '%s' &", text
);
2877 setWidgetColor(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
2879 if (scr
->widget_texture
) {
2880 wTextureDestroy(scr
, (WTexture
*)scr
->widget_texture
);
2882 scr
->widget_texture
= *(WTexSolid
**)texture
;
2889 setFTitleBack(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
2891 if (scr
->window_title_texture
[WS_FOCUSED
]) {
2892 wTextureDestroy(scr
, scr
->window_title_texture
[WS_FOCUSED
]);
2894 scr
->window_title_texture
[WS_FOCUSED
] = *texture
;
2896 return REFRESH_WINDOW_TEXTURES
;
2901 setPTitleBack(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
2903 if (scr
->window_title_texture
[WS_PFOCUSED
]) {
2904 wTextureDestroy(scr
, scr
->window_title_texture
[WS_PFOCUSED
]);
2906 scr
->window_title_texture
[WS_PFOCUSED
] = *texture
;
2908 return REFRESH_WINDOW_TEXTURES
;
2913 setUTitleBack(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
2915 if (scr
->window_title_texture
[WS_UNFOCUSED
]) {
2916 wTextureDestroy(scr
, scr
->window_title_texture
[WS_UNFOCUSED
]);
2918 scr
->window_title_texture
[WS_UNFOCUSED
] = *texture
;
2920 if (scr
->resizebar_texture
[0]) {
2921 wTextureDestroy(scr
, (WTexture
*)scr
->resizebar_texture
[0]);
2923 scr
->resizebar_texture
[0]
2924 = wTextureMakeSolid(scr
, &scr
->window_title_texture
[WS_UNFOCUSED
]->any
.color
);
2926 if (scr
->geometry_display
!= None
)
2927 XSetWindowBackground(dpy
, scr
->geometry_display
,
2928 scr
->resizebar_texture
[0]->normal
.pixel
);
2930 return REFRESH_WINDOW_TEXTURES
;
2935 setMenuTitleBack(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
2937 if (scr
->menu_title_texture
[0]) {
2938 wTextureDestroy(scr
, scr
->menu_title_texture
[0]);
2940 scr
->menu_title_texture
[0] = *texture
;
2942 return REFRESH_MENU_TEXTURES
;
2947 setMenuTextBack(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
2949 if (scr
->menu_item_texture
) {
2950 wTextureDestroy(scr
, scr
->menu_item_texture
);
2951 wTextureDestroy(scr
, (WTexture
*)scr
->menu_item_auxtexture
);
2953 scr
->menu_item_texture
= *texture
;
2955 scr
->menu_item_auxtexture
2956 = wTextureMakeSolid(scr
, &scr
->menu_item_texture
->any
.color
);
2958 return REFRESH_MENU_TEXTURES
;
2963 setKeyGrab(WScreen
*scr
, WDefaultEntry
*entry
, WShortKey
*shortcut
, long index
)
2966 wKeyBindings
[index
] = *shortcut
;
2968 wwin
= scr
->focused_window
;
2970 while (wwin
!=NULL
) {
2971 XUngrabKey(dpy
, AnyKey
, AnyModifier
, wwin
->frame
->core
->window
);
2973 if (!WFLAGP(wwin
, no_bind_keys
)) {
2974 wWindowSetKeyGrabs(wwin
);
2984 setIconPosition(WScreen
*scr
, WDefaultEntry
*entry
, void *bar
, void *foo
)
2986 wArrangeIcons(scr
, True
);
2993 updateUsableArea(WScreen
*scr
, WDefaultEntry
*entry
, void *bar
, void *foo
)
2995 wScreenUpdateUsableArea(scr
);
3003 setButtonImages(WScreen
*scr
, WDefaultEntry
*entry
, int *value
, void *foo
)
3005 return REFRESH_BUTTON_IMAGES
;
3011 * Need access to the double click variables, so that all widgets in
3012 * wmaker panels will have the same dbl-click values.
3013 * TODO: figure a better way of dealing with it.
3018 setDoubleClick(WScreen
*scr
, WDefaultEntry
*entry
, int *value
, void *foo
)
3020 extern _WINGsConfiguration WINGsConfiguration
;
3025 WINGsConfiguration
.doubleClickDelay
= *value
;