1 /* defaults.c - manage configuration through defaults db
3 * Window Maker window manager
5 * Copyright (c) 1997, 1998 Alfredo K. Kojima
6 * Copyright (c) 1998 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,
32 #include <sys/types.h>
45 #define PATH_MAX DEFAULT_PATH_MAX
49 #include <X11/Xutil.h>
50 #include <X11/keysym.h>
55 #include "WindowMaker.h"
61 #include "resources.h"
64 #include "xmodifier.h"
69 #include "workspace.h"
73 * Our own proplist reader parser. This one will not accept any
74 * syntax errors and is more descriptive in the error messages.
75 * It also doesn't seem to crash.
77 extern proplist_t
ReadProplistFromFile(char *file
);
82 extern WDDomain
*WDWindowMaker
;
83 extern WDDomain
*WDWindowAttributes
;
84 extern WDDomain
*WDRootMenu
;
86 extern int wScreenCount
;
89 extern proplist_t wDomainName;
90 extern proplist_t wAttributeDomainName;
92 extern WPreferences wPreferences
;
94 extern WShortKey wKeyBindings
[WKBD_LAST
];
104 proplist_t plvalue
; /* default value */
108 /* used to map strings to integers */
113 } 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();
138 /* value setting functions */
139 static int setJustify();
140 static int setIfDockPresent();
141 static int setStickyIcons();
143 static int setPositive();
145 static int setWidgetColor();
146 static int setIconTile();
147 static int setWinTitleFont();
148 static int setMenuTitleFont();
149 static int setMenuTextFont();
150 static int setIconTitleFont();
151 static int setIconTitleColor();
152 static int setIconTitleBack();
153 static int setDisplayFont();
154 static int setWTitleColor();
155 static int setFTitleBack();
156 static int setPTitleBack();
157 static int setUTitleBack();
158 static int setResizebarBack();
159 static int setWorkspaceBack();
160 static int setWorkspaceSpecificBack();
161 static int setMenuTitleColor();
162 static int setMenuTextColor();
163 static int setMenuDisabledColor();
164 static int setMenuTitleBack();
165 static int setMenuTextBack();
166 static int setHightlight();
167 static int setHightlightText();
168 static int setKeyGrab();
169 static int setDoubleClick();
170 static int setIconPosition();
172 static int setClipTitleFont();
173 static int setClipTitleColor();
175 static int setMenuStyle();
178 static int updateUsableArea();
183 * Tables to convert strings to enumeration values.
184 * Values stored are char
188 /* WARNING: sum of length of all value strings must not exceed
190 #define TOTAL_VALUES_LENGTH 80
195 #define REFRESH_WINDOW_TEXTURES (1<<0)
196 #define REFRESH_MENU_TEXTURE (1<<1)
197 #define REFRESH_MENU_FONT (1<<2)
198 #define REFRESH_MENU_COLOR (1<<3)
199 #define REFRESH_MENU_TITLE_TEXTURE (1<<4)
200 #define REFRESH_MENU_TITLE_FONT (1<<5)
201 #define REFRESH_MENU_TITLE_COLOR (1<<6)
202 #define REFRESH_WINDOW_TITLE_COLOR (1<<7)
203 #define REFRESH_WINDOW_FONT (1<<8)
204 #define REFRESH_ICON_TILE (1<<9)
205 #define REFRESH_ICON_FONT (1<<10)
206 #define REFRESH_WORKSPACE_BACK (1<<11)
208 #define REFRESH_BUTTON_IMAGES (1<<12)
210 #define REFRESH_ICON_TITLE_COLOR (1<<13)
211 #define REFRESH_ICON_TITLE_BACK (1<<14)
215 static WOptionEnumeration seFocusModes
[] = {
216 {"Manual", WKF_CLICK
, 0}, {"ClickToFocus", WKF_CLICK
, 1},
217 {"Auto", WKF_POINTER
, 0}, {"FocusFollowMouse", WKF_POINTER
, 1},
218 {"Sloppy", WKF_SLOPPY
, 0}, {"SemiAuto", WKF_SLOPPY
, 1},
222 static WOptionEnumeration seColormapModes
[] = {
223 {"Manual", WKF_CLICK
, 0}, {"ClickToFocus", WKF_CLICK
, 1},
224 {"Auto", WKF_POINTER
, 0}, {"FocusFollowMouse", WKF_POINTER
, 1},
228 static WOptionEnumeration sePlacements
[] = {
229 {"Auto", WPM_SMART
, 0}, {"Smart", WPM_SMART
, 1},
230 {"Cascade", WPM_CASCADE
, 0},
231 {"Random", WPM_RANDOM
, 0},
232 {"Manual", WPM_MANUAL
, 0},
236 static WOptionEnumeration seGeomDisplays
[] = {
237 {"Center", WDIS_CENTER
, 0},
238 {"Corner", WDIS_TOPLEFT
, 0},
239 {"Floating", WDIS_FRAME_CENTER
, 0},
240 {"Line", WDIS_NEW
, 0},
244 static WOptionEnumeration seSpeeds
[] = {
245 {"UltraFast", SPEED_ULTRAFAST
, 0},
246 {"Fast", SPEED_FAST
, 0},
247 {"Medium", SPEED_MEDIUM
, 0},
248 {"Slow", SPEED_SLOW
, 0},
249 {"UltraSlow", SPEED_ULTRASLOW
, 0},
253 static WOptionEnumeration seMouseButtons
[] = {
254 {"Left", Button1
, 0}, {"Button1", Button1
, 1},
255 {"Middle", Button2
, 0}, {"Button2", Button2
, 1},
256 {"Right", Button3
, 0}, {"Button3", Button3
, 1},
257 {"Button4", Button4
, 0},
258 {"Button5", Button5
, 0},
262 static WOptionEnumeration seIconificationStyles
[] = {
263 {"Zoom", WIS_ZOOM
, 0},
264 {"Twist", WIS_TWIST
, 0},
265 {"Flip", WIS_FLIP
, 0},
266 {"None", WIS_NONE
, 0},
267 {"random", WIS_RANDOM
, 0},
271 static WOptionEnumeration seJustifications
[] = {
272 {"Left", WTJ_LEFT
, 0},
273 {"Center", WTJ_CENTER
, 0},
274 {"Right", WTJ_RIGHT
, 0},
278 static WOptionEnumeration seIconPositions
[] = {
279 {"blv", IY_BOTTOM
|IY_LEFT
|IY_VERT
, 0},
280 {"blh", IY_BOTTOM
|IY_LEFT
|IY_HORIZ
, 0},
281 {"brv", IY_BOTTOM
|IY_RIGHT
|IY_VERT
, 0},
282 {"brh", IY_BOTTOM
|IY_RIGHT
|IY_HORIZ
, 0},
283 {"tlv", IY_TOP
|IY_LEFT
|IY_VERT
, 0},
284 {"tlh", IY_TOP
|IY_LEFT
|IY_HORIZ
, 0},
285 {"trv", IY_TOP
|IY_RIGHT
|IY_VERT
, 0},
286 {"trh", IY_TOP
|IY_RIGHT
|IY_HORIZ
, 0},
290 static WOptionEnumeration seMenuStyles
[] = {
291 {"normal", MS_NORMAL
, 0},
292 {"singletexture", MS_SINGLE_TEXTURE
, 0},
293 {"flat", MS_FLAT
, 0},
299 * ALL entries in the tables bellow, NEED to have a default value
300 * defined, and this value needs to be correct.
303 /* these options will only affect the window manager on startup
305 * static defaults can't access the screen data, because it is
306 * created after these defaults are read
308 WDefaultEntry staticOptionList
[] = {
310 {"DisableDithering", "NO", NULL
,
311 &wPreferences
.no_dithering
, getBool
, NULL
313 {"ColormapSize", "4", NULL
,
314 &wPreferences
.cmap_size
, getInt
, NULL
316 /* static by laziness */
317 {"IconSize", "64", NULL
,
318 &wPreferences
.icon_size
, getInt
, NULL
320 {"ModifierKey", "Mod1", NULL
,
321 &wPreferences
.modifier_mask
, getModMask
, NULL
323 {"DisableWSMouseActions", "NO", NULL
,
324 &wPreferences
.disable_root_mouse
, getBool
, NULL
326 {"FocusMode", "manual", seFocusModes
,
327 &wPreferences
.focus_mode
, getEnum
, NULL
328 }, /* have a problem when switching from manual to sloppy without restart */
329 {"NewStyle", "NO", NULL
,
330 &wPreferences
.new_style
, getBool
, NULL
332 {"DisableDock", "NO", (void*) WM_DOCK
,
333 NULL
, getBool
, setIfDockPresent
335 {"DisableClip", "NO", (void*) WM_CLIP
,
336 NULL
, getBool
, setIfDockPresent
338 {"DisableMiniwindows", "NO", NULL
,
339 &wPreferences
.disable_miniwindows
, getBool
, NULL
345 WDefaultEntry optionList
[] = {
346 /* dynamic options */
347 {"IconPosition", "blh", seIconPositions
,
348 &wPreferences
.icon_yard
, getEnum
, setIconPosition
350 {"IconificationStyle", "Zoom", seIconificationStyles
,
351 &wPreferences
.iconification_style
, getEnum
, NULL
353 {"SelectWindowsMouseButton", "Left", seMouseButtons
,
354 &wPreferences
.select_button
, getEnum
, NULL
356 {"WindowListMouseButton", "Middle", seMouseButtons
,
357 &wPreferences
.windowl_button
, getEnum
, NULL
359 {"ApplicationMenuMouseButton", "Right", seMouseButtons
,
360 &wPreferences
.menu_button
, getEnum
, NULL
362 {"PixmapPath", DEF_PIXMAP_PATHS
, NULL
,
363 &wPreferences
.pixmap_path
, getPathList
, NULL
365 {"IconPath", DEF_ICON_PATHS
, NULL
,
366 &wPreferences
.icon_path
, getPathList
, NULL
368 {"ColormapMode", "auto", seColormapModes
,
369 &wPreferences
.colormap_mode
, getEnum
, NULL
371 {"AutoFocus", "NO", NULL
,
372 &wPreferences
.auto_focus
, getBool
, NULL
374 {"RaiseDelay", "0", NULL
,
375 &wPreferences
.raise_delay
, getInt
, NULL
377 {"CirculateRaise", "NO", NULL
,
378 &wPreferences
.circ_raise
, getBool
, NULL
380 {"Superfluous", "NO", NULL
,
381 &wPreferences
.superfluous
, getBool
, NULL
383 {"AdvanceToNewWorkspace", "NO", NULL
,
384 &wPreferences
.ws_advance
, getBool
, NULL
386 {"CycleWorkspaces", "NO", NULL
,
387 &wPreferences
.ws_cycle
, getBool
, NULL
389 {"StickyIcons", "NO", NULL
,
390 &wPreferences
.sticky_icons
, getBool
, setStickyIcons
392 {"SaveSessionOnExit", "NO", NULL
,
393 &wPreferences
.save_session_on_exit
, getBool
, NULL
395 {"WrapMenus", "NO", NULL
,
396 &wPreferences
.wrap_menus
, getBool
, NULL
398 {"ScrollableMenus", "NO", NULL
,
399 &wPreferences
.scrollable_menus
, getBool
, NULL
401 {"MenuScrollSpeed", "medium", seSpeeds
,
402 &wPreferences
.menu_scroll_speed
, getEnum
, NULL
404 {"IconSlideSpeed", "medium", seSpeeds
,
405 &wPreferences
.icon_slide_speed
, getEnum
, NULL
407 {"ShadeSpeed", "medium", seSpeeds
,
408 &wPreferences
.shade_speed
, getEnum
, NULL
410 {"DoubleClickTime", "250", (void*) &wPreferences
.dblclick_time
,
411 &wPreferences
.dblclick_time
, getInt
, setDoubleClick
,
413 {"AlignSubmenus", "NO", NULL
,
414 &wPreferences
.align_menus
, getBool
, NULL
416 {"OpenTransientOnOwnerWorkspace", "NO", NULL
,
417 &wPreferences
.open_transients_with_parent
, getBool
, NULL
419 {"WindowPlacement", "auto", sePlacements
,
420 &wPreferences
.window_placement
, getEnum
, NULL
422 {"IgnoreFocusClick","NO", NULL
,
423 &wPreferences
.ignore_focus_click
, getBool
, NULL
425 {"UseSaveUnders", "NO", NULL
,
426 &wPreferences
.use_saveunders
, getBool
, NULL
428 {"OpaqueMove", "NO", NULL
,
429 &wPreferences
.opaque_move
, getBool
, NULL
431 {"DisableSound", "NO", NULL
,
432 &wPreferences
.no_sound
, getBool
, NULL
434 {"DisableAnimations", "NO", NULL
,
435 &wPreferences
.no_animations
, getBool
, NULL
437 {"DontLinkWorkspaces","NO", NULL
,
438 &wPreferences
.no_autowrap
, getBool
, NULL
440 {"AutoArrangeIcons", "NO", NULL
,
441 &wPreferences
.auto_arrange_icons
, getBool
, NULL
443 {"NoWindowOverDock", "NO", NULL
,
444 &wPreferences
.no_window_over_dock
, getBool
, updateUsableArea
446 {"NoWindowOverIcons", "NO", NULL
,
447 &wPreferences
.no_window_over_icons
, getBool
, updateUsableArea
449 {"WindowPlaceOrigin", "(0, 0)", NULL
,
450 &wPreferences
.window_place_origin
, getCoord
, NULL
452 {"ResizeDisplay", "corner", seGeomDisplays
,
453 &wPreferences
.size_display
, getEnum
, NULL
455 {"MoveDisplay", "corner", seGeomDisplays
,
456 &wPreferences
.move_display
, getEnum
, NULL
458 {"DontConfirmKill", "NO", NULL
,
459 &wPreferences
.dont_confirm_kill
, getBool
,NULL
461 {"WindowTitleBalloons", "NO", NULL
,
462 &wPreferences
.window_balloon
, getBool
, NULL
464 {"MiniwindowTitleBalloons", "NO", NULL
,
465 &wPreferences
.miniwin_balloon
,getBool
, NULL
467 {"AppIconBalloons", "NO", NULL
,
468 &wPreferences
.appicon_balloon
,getBool
, NULL
470 {"EdgeResistance", "30", NULL
,
471 &wPreferences
.edge_resistance
,getInt
, NULL
473 {"DisableBlinking", "NO", NULL
,
474 &wPreferences
.dont_blink
, getBool
, NULL
476 #ifdef WEENDOZE_CYCLE
477 {"WindozeCycling","NO", NULL
,
478 &wPreferences
.windoze_cycling
, getBool
, NULL
480 {"PopupSwitchMenu","YES", NULL
,
481 &wPreferences
.popup_switchmenu
, getBool
, NULL
483 #endif /* WEENDOZE_CYCLE */
485 {"MenuStyle", "normal", seMenuStyles
,
486 &wPreferences
.menu_style
, getEnum
, setMenuStyle
488 {"WidgetColor", "(solid, gray)", NULL
,
489 NULL
, getTexture
, setWidgetColor
,
491 {"WorkspaceSpecificBack","()", NULL
,
492 NULL
, getWSSpecificBackground
, setWorkspaceSpecificBack
494 /* WorkspaceBack must come after WorkspaceSpecificBack or
495 * WorkspaceBack wont know WorkspaceSpecificBack was also
496 * specified and 2 copies of wmsetbg will be launched */
497 {"WorkspaceBack", "(solid, black)", NULL
,
498 NULL
, getWSBackground
,setWorkspaceBack
500 {"IconBack", "(solid, gray)", NULL
,
501 NULL
, getTexture
, setIconTile
503 {"TitleJustify", "center", seJustifications
,
504 &wPreferences
.title_justification
, getEnum
, setJustify
506 {"WindowTitleFont", DEF_TITLE_FONT
, NULL
,
507 NULL
, getFont
, setWinTitleFont
,
509 {"MenuTitleFont", DEF_MENU_TITLE_FONT
, NULL
,
510 NULL
, getFont
, setMenuTitleFont
512 {"MenuTextFont", DEF_MENU_ENTRY_FONT
, NULL
,
513 NULL
, getFont
, setMenuTextFont
515 {"IconTitleFont", DEF_ICON_TITLE_FONT
, NULL
,
516 NULL
, getFont
, setIconTitleFont
518 {"ClipTitleFont", DEF_CLIP_TITLE_FONT
, NULL
,
519 NULL
, getFont
, setClipTitleFont
521 {"DisplayFont", DEF_INFO_TEXT_FONT
, NULL
,
522 NULL
, getFont
, setDisplayFont
524 {"HighlightColor", "white", NULL
,
525 NULL
, getColor
, setHightlight
527 {"HighlightTextColor", "black", NULL
,
528 NULL
, getColor
, setHightlightText
530 {"ClipTitleColor", "black", (void*)CLIP_NORMAL
,
531 NULL
, getColor
, setClipTitleColor
533 {"CClipTitleColor", "\"#454045\"", (void*)CLIP_COLLAPSED
,
534 NULL
, getColor
, setClipTitleColor
536 {"FTitleColor", "white", (void*)WS_FOCUSED
,
537 NULL
, getColor
, setWTitleColor
539 {"PTitleColor", "white", (void*)WS_PFOCUSED
,
540 NULL
, getColor
, setWTitleColor
542 {"UTitleColor", "black", (void*)WS_UNFOCUSED
,
543 NULL
, getColor
, setWTitleColor
545 {"FTitleBack", "(solid, black)", NULL
,
546 NULL
, getTexture
, setFTitleBack
548 {"PTitleBack", "(solid, \"#616161\")", NULL
,
549 NULL
, getTexture
, setPTitleBack
551 {"UTitleBack", "(solid, gray)", NULL
,
552 NULL
, getTexture
, setUTitleBack
554 {"ResizebarBack", "(solid, gray)", NULL
,
555 NULL
, getTexture
, setResizebarBack
557 {"MenuTitleColor", "white", NULL
,
558 NULL
, getColor
, setMenuTitleColor
560 {"MenuTextColor", "black", NULL
,
561 NULL
, getColor
, setMenuTextColor
563 {"MenuDisabledColor", "\"#616161\"", NULL
,
564 NULL
, getColor
, setMenuDisabledColor
566 {"MenuTitleBack", "(solid, black)", NULL
,
567 NULL
, getTexture
, setMenuTitleBack
569 {"MenuTextBack", "(solid, gray)", NULL
,
570 NULL
, getTexture
, setMenuTextBack
572 {"IconTitleColor", "white", NULL
,
573 NULL
, getColor
, setIconTitleColor
575 {"IconTitleBack", "black", NULL
,
576 NULL
, getColor
, setIconTitleBack
580 {"RootMenuKey", "None", (void*)WKBD_ROOTMENU
,
581 NULL
, getKeybind
, setKeyGrab
583 {"WindowListKey", "None", (void*)WKBD_WINDOWLIST
,
584 NULL
, getKeybind
, setKeyGrab
587 {"WindowMenuKey", "None", (void*)WKBD_WINDOWMENU
,
588 NULL
, getKeybind
, setKeyGrab
590 {"ClipLowerKey", "None", (void*)WKBD_CLIPLOWER
,
591 NULL
, getKeybind
, setKeyGrab
593 {"ClipRaiseKey", "None", (void*)WKBD_CLIPRAISE
,
594 NULL
, getKeybind
, setKeyGrab
596 {"ClipRaiseLowerKey", "None", (void*)WKBD_CLIPRAISELOWER
,
597 NULL
, getKeybind
, setKeyGrab
599 {"MiniaturizeKey", "None", (void*)WKBD_MINIATURIZE
,
600 NULL
, getKeybind
, setKeyGrab
602 {"HideKey", "None", (void*)WKBD_HIDE
,
603 NULL
, getKeybind
, setKeyGrab
605 {"MoveResizeKey", "None", (void*)WKBD_MOVERESIZE
,
606 NULL
, getKeybind
, setKeyGrab
608 {"CloseKey", "None", (void*)WKBD_CLOSE
,
609 NULL
, getKeybind
, setKeyGrab
611 {"MaximizeKey", "None", (void*)WKBD_MAXIMIZE
,
612 NULL
, getKeybind
, setKeyGrab
614 {"VMaximizeKey", "None", (void*)WKBD_VMAXIMIZE
,
615 NULL
, getKeybind
, setKeyGrab
617 {"RaiseKey", "Meta+Up", (void*)WKBD_RAISE
,
618 NULL
, getKeybind
, setKeyGrab
620 {"LowerKey", "Meta+Down", (void*)WKBD_LOWER
,
621 NULL
, getKeybind
, setKeyGrab
623 {"RaiseLowerKey", "None", (void*)WKBD_RAISELOWER
,
624 NULL
, getKeybind
, setKeyGrab
626 {"ShadeKey", "None", (void*)WKBD_SHADE
,
627 NULL
, getKeybind
, setKeyGrab
629 {"SelectKey", "None", (void*)WKBD_SELECT
,
630 NULL
, getKeybind
, setKeyGrab
632 {"FocusNextKey", "None", (void*)WKBD_FOCUSNEXT
,
633 NULL
, getKeybind
, setKeyGrab
635 {"FocusPrevKey", "None", (void*)WKBD_FOCUSPREV
,
636 NULL
, getKeybind
, setKeyGrab
638 {"NextWorkspaceKey", "None", (void*)WKBD_NEXTWORKSPACE
,
639 NULL
, getKeybind
, setKeyGrab
641 {"PrevWorkspaceKey", "None", (void*)WKBD_PREVWORKSPACE
,
642 NULL
, getKeybind
, setKeyGrab
644 {"NextWorkspaceLayerKey", "None", (void*)WKBD_NEXTWSLAYER
,
645 NULL
, getKeybind
, setKeyGrab
647 {"PrevWorkspaceLayerKey", "None", (void*)WKBD_PREVWSLAYER
,
648 NULL
, getKeybind
, setKeyGrab
650 {"Workspace1Key", "None", (void*)WKBD_WORKSPACE1
,
651 NULL
, getKeybind
, setKeyGrab
653 {"Workspace2Key", "None", (void*)WKBD_WORKSPACE2
,
654 NULL
, getKeybind
, setKeyGrab
656 {"Workspace3Key", "None", (void*)WKBD_WORKSPACE3
,
657 NULL
, getKeybind
, setKeyGrab
659 {"Workspace4Key", "None", (void*)WKBD_WORKSPACE4
,
660 NULL
, getKeybind
, setKeyGrab
662 {"Workspace5Key", "None", (void*)WKBD_WORKSPACE5
,
663 NULL
, getKeybind
, setKeyGrab
665 {"Workspace6Key", "None", (void*)WKBD_WORKSPACE6
,
666 NULL
, getKeybind
, setKeyGrab
668 {"Workspace7Key", "None", (void*)WKBD_WORKSPACE7
,
669 NULL
, getKeybind
, setKeyGrab
671 {"Workspace8Key", "None", (void*)WKBD_WORKSPACE8
,
672 NULL
, getKeybind
, setKeyGrab
674 {"Workspace9Key", "None", (void*)WKBD_WORKSPACE9
,
675 NULL
, getKeybind
, setKeyGrab
677 {"Workspace10Key", "None", (void*)WKBD_WORKSPACE10
,
678 NULL
, getKeybind
, setKeyGrab
680 {"WindowShortcut1Key","None", (void*)WKBD_WINDOW1
,
681 NULL
, getKeybind
, setKeyGrab
683 {"WindowShortcut2Key","None", (void*)WKBD_WINDOW2
,
684 NULL
, getKeybind
, setKeyGrab
686 {"WindowShortcut3Key","None", (void*)WKBD_WINDOW3
,
687 NULL
, getKeybind
, setKeyGrab
689 {"WindowShortcut4Key","None", (void*)WKBD_WINDOW4
,
690 NULL
, getKeybind
, setKeyGrab
692 #ifdef EXTEND_WINDOWSHORTCUT
693 ,{"WindowShortcut5Key","None", (void*)WKBD_WINDOW5
,
694 NULL
, getKeybind
, setKeyGrab
696 {"WindowShortcut6Key","None", (void*)WKBD_WINDOW6
,
697 NULL
, getKeybind
, setKeyGrab
699 {"WindowShortcut7Key","None", (void*)WKBD_WINDOW7
,
700 NULL
, getKeybind
, setKeyGrab
702 {"WindowShortcut8Key","None", (void*)WKBD_WINDOW8
,
703 NULL
, getKeybind
, setKeyGrab
705 {"WindowShortcut9Key","None", (void*)WKBD_WINDOW9
,
706 NULL
, getKeybind
, setKeyGrab
708 {"WindowShortcut10Key","None", (void*)WKBD_WINDOW10
,
709 NULL
, getKeybind
, setKeyGrab
711 #endif /* EXTEND_WINDOWSHORTCUT */
713 #ifdef KEEP_XKB_LOCK_STATUS
714 ,{"ToggleKbdModeKey", "None", (void*)WKBD_TOGGLE
,
715 NULL
, getKeybind
, setKeyGrab
717 {"KbdModeLock", "NO", NULL
,
718 &wPreferences
.modelock
, getBool
, NULL
720 #endif /* KEEP_XKB_LOCK_STATUS */
721 #ifdef TITLE_TEXT_SHADOW
722 ,{"FShadowColor", "black", (void*)WS_SFOCUSED
,
723 NULL
, getColor
, setWTitleColor
725 {"PShadowColor", "black", (void*)WS_SPFOCUSED
,
726 NULL
, getColor
, setWTitleColor
728 {"UShadowColor", "grey50", (void*)WS_SUNFOCUSED
,
729 NULL
, getColor
, setWTitleColor
731 {"MShadowColor", "black", (void*)WS_SMENU
,
732 NULL
, getColor
, setMenuTitleColor
734 {"Shadow", "Yes", NULL
,
735 &wPreferences
.title_shadow
, getBool
, setJustify
737 #endif /* TITLE_TEXT_SHADOW */
742 static void rereadDefaults(void);
749 /* must defer the update because accessing X data from a
750 * signal handler can mess up Xlib */
759 WDefaultEntry
*entry
;
761 PLSetStringCmpHook(StringCompareHook
);
763 for (i
=0; i
<sizeof(optionList
)/sizeof(WDefaultEntry
); i
++) {
764 entry
= &optionList
[i
];
766 entry
->plkey
= PLMakeString(entry
->key
);
767 if (entry
->default_value
)
768 entry
->plvalue
= PLGetProplistWithDescription(entry
->default_value
);
770 entry
->plvalue
= NULL
;
773 for (i
=0; i
<sizeof(staticOptionList
)/sizeof(WDefaultEntry
); i
++) {
774 entry
= &staticOptionList
[i
];
776 entry
->plkey
= PLMakeString(entry
->key
);
777 if (entry
->default_value
)
778 entry
->plvalue
= PLGetProplistWithDescription(entry
->default_value
);
780 entry
->plvalue
= NULL
;
784 wDomainName = PLMakeString(WMDOMAIN_NAME);
785 wAttributeDomainName = PLMakeString(WMATTRIBUTE_DOMAIN_NAME);
787 PLRegister(wDomainName, rereadDefaults);
788 PLRegister(wAttributeDomainName, rereadDefaults);
797 wDefaultsInit(int screen_number
)
799 static int defaults_inited
= 0;
802 if (!defaults_inited
) {
806 dict
= PLGetDomain(wDomainName
);
808 wwarning(_("could not read domain \"%s\" from defaults database"),
809 PLGetString(wDomainName
));
818 wDefaultsDestroyDomain(WDDomain
*domain
)
820 if (domain
->dictionary
)
821 PLRelease(domain
->dictionary
);
828 wDefaultsInitDomain(char *domain
, Bool requireDictionary
)
832 static int inited
= 0;
835 proplist_t shared_dict
=NULL
;
842 db
= wmalloc(sizeof(WDDomain
));
843 memset(db
, 0, sizeof(WDDomain
));
844 db
->domain_name
= domain
;
845 db
->path
= wdefaultspathfordomain(domain
);
848 if (the_path
&& stat(the_path
, &stbuf
)>=0) {
849 db
->dictionary
= ReadProplistFromFile(the_path
);
850 if (db
->dictionary
) {
851 if (requireDictionary
&& !PLIsDictionary(db
->dictionary
)) {
852 PLRelease(db
->dictionary
);
853 db
->dictionary
= NULL
;
854 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
857 db
->timestamp
= stbuf
.st_mtime
;
859 wwarning(_("could not load domain %s from user defaults database"),
864 /* global system dictionary */
865 sprintf(path
, "%s/%s", SYSCONFDIR
, domain
);
866 if (stat(path
, &stbuf
)>=0) {
867 shared_dict
= ReadProplistFromFile(path
);
869 if (requireDictionary
&& !PLIsDictionary(shared_dict
)) {
870 wwarning(_("Domain %s (%s) of global defaults database is corrupted!"),
872 PLRelease(shared_dict
);
875 if (db
->dictionary
&& PLIsDictionary(shared_dict
) &&
876 PLIsDictionary(db
->dictionary
)) {
877 PLMergeDictionaries(shared_dict
, db
->dictionary
);
878 PLRelease(db
->dictionary
);
879 db
->dictionary
= shared_dict
;
880 if (stbuf
.st_mtime
> db
->timestamp
)
881 db
->timestamp
= stbuf
.st_mtime
;
882 } else if (!db
->dictionary
) {
883 db
->dictionary
= shared_dict
;
884 if (stbuf
.st_mtime
> db
->timestamp
)
885 db
->timestamp
= stbuf
.st_mtime
;
889 wwarning(_("could not load domain %s from global defaults database"),
894 /* set to save it in user's directory, no matter from where it was read */
895 if (db
->dictionary
) {
896 proplist_t tmp
= PLMakeString(db
->path
);
898 PLSetFilename(db
->dictionary
, tmp
);
907 wReadStaticDefaults(proplist_t dict
)
910 WDefaultEntry
*entry
;
915 for (i
=0; i
<sizeof(staticOptionList
)/sizeof(WDefaultEntry
); i
++) {
916 entry
= &staticOptionList
[i
];
919 plvalue
= PLGetDictionaryEntry(dict
, entry
->plkey
);
924 /* no default in the DB. Use builtin default */
925 plvalue
= entry
->plvalue
;
930 (*entry
->convert
)(NULL
, entry
, plvalue
, entry
->addr
, &tdata
);
932 (*entry
->update
)(NULL
, entry
, tdata
, entry
->extra_data
);
940 wDefaultsCheckDomains(void *foo
)
949 puts("Checking domains...");
951 if (stat(WDWindowMaker
->path
, &stbuf
)>=0
952 && WDWindowMaker
->timestamp
< stbuf
.st_mtime
) {
953 proplist_t shared_dict
= NULL
;
955 puts("Checking WindowMaker domain");
957 WDWindowMaker
->timestamp
= stbuf
.st_mtime
;
959 /* global dictionary */
960 sprintf(path
, "%s/WindowMaker", SYSCONFDIR
);
961 if (stat(path
, &stbuf
)>=0) {
962 shared_dict
= ReadProplistFromFile(path
);
963 if (shared_dict
&& !PLIsDictionary(shared_dict
)) {
964 wwarning(_("Domain %s (%s) of global defaults database is corrupted!"),
965 "WindowMaker", path
);
966 PLRelease(shared_dict
);
968 } else if (!shared_dict
) {
969 wwarning(_("could not load domain %s from global defaults database"),
973 /* user dictionary */
974 dict
= ReadProplistFromFile(WDWindowMaker
->path
);
976 if (!PLIsDictionary(dict
)) {
979 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
980 "WindowMaker", WDWindowMaker
->path
);
983 PLSetFilename(shared_dict
, PLGetFilename(dict
));
984 PLMergeDictionaries(shared_dict
, dict
);
989 for (i
=0; i
<wScreenCount
; i
++) {
990 scr
= wScreenWithNumber(i
);
992 wReadDefaults(scr
, dict
);
994 if (WDWindowMaker
->dictionary
) {
995 PLRelease(WDWindowMaker
->dictionary
);
997 WDWindowMaker
->dictionary
= dict
;
1000 wwarning(_("could not load domain %s from user defaults database"),
1004 PLRelease(shared_dict
);
1008 if (stat(WDWindowAttributes
->path
, &stbuf
)>=0
1009 && WDWindowAttributes
->timestamp
< stbuf
.st_mtime
) {
1011 puts("Checking WMWindowAttributes domain");
1013 dict
= ReadProplistFromFile(WDWindowAttributes
->path
);
1015 if (!PLIsDictionary(dict
)) {
1018 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
1019 "WMWindowAttributes", WDWindowAttributes
->path
);
1021 if (WDWindowAttributes
->dictionary
)
1022 PLRelease(WDWindowAttributes
->dictionary
);
1023 WDWindowAttributes
->dictionary
= dict
;
1024 for (i
=0; i
<wScreenCount
; i
++) {
1025 scr
= wScreenWithNumber(i
);
1027 wDefaultUpdateIcons(scr
);
1031 wwarning(_("could not load domain %s from user defaults database"),
1032 "WMWindowAttributes");
1034 WDWindowAttributes
->timestamp
= stbuf
.st_mtime
;
1038 if (stat(WDRootMenu
->path
, &stbuf
)>=0
1039 && WDRootMenu
->timestamp
< stbuf
.st_mtime
) {
1040 dict
= ReadProplistFromFile(WDRootMenu
->path
);
1042 puts("Checking WMRootMenu domain");
1045 if (!PLIsArray(dict
) && !PLIsString(dict
)) {
1048 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
1049 "WMRootMenu", WDRootMenu
->path
);
1051 if (WDRootMenu
->dictionary
) {
1052 PLRelease(WDRootMenu
->dictionary
);
1054 WDRootMenu
->dictionary
= dict
;
1057 wwarning(_("could not load domain %s from user defaults database"),
1060 WDRootMenu
->timestamp
= stbuf
.st_mtime
;
1065 WMAddTimerHandler(DEFAULTS_CHECK_INTERVAL
, wDefaultsCheckDomains
, foo
);
1070 wReadDefaults(WScreen
*scr
, proplist_t new_dict
)
1072 proplist_t plvalue
, old_value
;
1073 WDefaultEntry
*entry
;
1077 proplist_t old_dict
= (WDWindowMaker
->dictionary
!=new_dict
1078 ? WDWindowMaker
->dictionary
: NULL
);
1084 for (i
=0; i
<sizeof(optionList
)/sizeof(WDefaultEntry
); i
++) {
1085 entry
= &optionList
[i
];
1088 plvalue
= PLGetDictionaryEntry(new_dict
, entry
->plkey
);
1095 old_value
= PLGetDictionaryEntry(old_dict
, entry
->plkey
);
1098 if (!plvalue
&& !old_value
) {
1099 /* no default in the DB. Use builtin default */
1100 plvalue
= entry
->plvalue
;
1101 if (plvalue
&& new_dict
) {
1102 PLInsertDictionaryEntry(new_dict
, entry
->plkey
, plvalue
);
1105 } else if (!plvalue
) {
1106 /* value was deleted from DB. Keep current value */
1108 } else if (!old_value
) {
1109 /* set value for the 1st time */
1110 } else if (!PLIsEqual(plvalue
, old_value
)) {
1111 /* value has changed */
1113 /* value was not changed since last time */
1119 printf("Updating %s to %s\n", entry
->key
, PLGetDescription(plvalue
));
1122 if ((*entry
->convert
)(scr
, entry
, plvalue
, entry
->addr
, &tdata
)) {
1123 if (entry
->update
) {
1125 (*entry
->update
)(scr
, entry
, tdata
, entry
->extra_data
);
1131 if (needs_refresh
!=0 && !scr
->flags
.startup
) {
1135 if (needs_refresh
& REFRESH_MENU_TITLE_TEXTURE
)
1136 foo
|= WTextureSettings
;
1137 if (needs_refresh
& REFRESH_MENU_TITLE_FONT
)
1138 foo
|= WFontSettings
;
1139 if (needs_refresh
& REFRESH_MENU_TITLE_COLOR
)
1140 foo
|= WColorSettings
;
1142 WMPostNotificationName(WNMenuTitleAppearanceSettingsChanged
, NULL
,
1146 if (needs_refresh
& REFRESH_MENU_TEXTURE
)
1147 foo
|= WTextureSettings
;
1148 if (needs_refresh
& REFRESH_MENU_FONT
)
1149 foo
|= WFontSettings
;
1150 if (needs_refresh
& REFRESH_MENU_COLOR
)
1151 foo
|= WColorSettings
;
1153 WMPostNotificationName(WNMenuAppearanceSettingsChanged
, NULL
,
1157 if (needs_refresh
& REFRESH_WINDOW_FONT
) {
1158 foo
|= WFontSettings
;
1160 if (needs_refresh
& REFRESH_WINDOW_TEXTURES
) {
1161 foo
|= WTextureSettings
;
1163 if (needs_refresh
& REFRESH_WINDOW_TITLE_COLOR
) {
1164 foo
|= WColorSettings
;
1167 WMPostNotificationName(WNWindowAppearanceSettingsChanged
, NULL
,
1170 if (!(needs_refresh
& REFRESH_ICON_TILE
)) {
1172 if (needs_refresh
& REFRESH_ICON_FONT
) {
1173 foo
|= WFontSettings
;
1175 if (needs_refresh
& REFRESH_ICON_TITLE_COLOR
) {
1176 foo
|= WTextureSettings
;
1178 if (needs_refresh
& REFRESH_ICON_TITLE_BACK
) {
1179 foo
|= WTextureSettings
;
1182 WMPostNotificationName(WNIconAppearanceSettingsChanged
, NULL
,
1185 if (needs_refresh
& REFRESH_ICON_TILE
)
1186 WMPostNotificationName(WNIconTileSettingsChanged
, NULL
, NULL
);
1192 wDefaultUpdateIcons(WScreen
*scr
)
1194 WAppIcon
*aicon
= scr
->app_icon_list
;
1195 WWindow
*wwin
= scr
->focused_window
;
1199 file
= wDefaultGetIconFile(scr
, aicon
->wm_instance
, aicon
->wm_class
,
1201 if ((file
&& aicon
->icon
->file
&& strcmp(file
, aicon
->icon
->file
)!=0)
1202 || (file
&& !aicon
->icon
->file
)) {
1205 if (aicon
->icon
->file
)
1206 free(aicon
->icon
->file
);
1207 aicon
->icon
->file
= wstrdup(file
);
1209 new_image
= wDefaultGetImage(scr
, aicon
->wm_instance
,
1212 wIconChangeImage(aicon
->icon
, new_image
);
1213 wAppIconPaint(aicon
);
1216 aicon
= aicon
->next
;
1219 if (!wPreferences
.flags
.noclip
)
1220 wClipIconPaint(scr
->clip_icon
);
1223 if (wwin
->icon
&& wwin
->flags
.miniaturized
) {
1224 file
= wDefaultGetIconFile(scr
, wwin
->wm_instance
, wwin
->wm_class
,
1226 if ((file
&& wwin
->icon
->file
&& strcmp(file
, wwin
->icon
->file
)!=0)
1227 || (file
&& !wwin
->icon
->file
)) {
1230 if (wwin
->icon
->file
)
1231 free(wwin
->icon
->file
);
1232 wwin
->icon
->file
= wstrdup(file
);
1234 new_image
= wDefaultGetImage(scr
, wwin
->wm_instance
,
1237 wIconChangeImage(wwin
->icon
, new_image
);
1245 /* --------------------------- Local ----------------------- */
1247 #define STRINGP(x) if (!PLIsString(value)) { \
1248 wwarning(_("Wrong option format for key \"%s\". Should be %s."), \
1255 string2index(proplist_t key
, proplist_t val
, proplist_t def
,
1256 WOptionEnumeration
*values
)
1259 WOptionEnumeration
*v
;
1260 char buffer
[TOTAL_VALUES_LENGTH
];
1262 if (PLIsString(val
) && (str
= PLGetString(val
))) {
1263 for (v
=values
; v
->string
!=NULL
; v
++) {
1264 if (strcasecmp(v
->string
, str
)==0)
1270 for (v
=values
; v
->string
!=NULL
; v
++) {
1273 strcat(buffer
, ", ");
1274 strcat(buffer
, v
->string
);
1277 wwarning(_("wrong option value for key \"%s\". Should be one of %s"),
1278 PLGetString(key
), buffer
);
1281 return string2index(key
, val
, NULL
, values
);
1291 * value - is the value in the defaults DB
1292 * addr - is the address to store the data
1293 * ret - is the address to store a pointer to a temporary buffer. ret
1294 * must not be freed and is used by the set functions
1297 getBool(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
1306 val
= PLGetString(value
);
1309 if ((val
[1]=='\0' && (val
[0]=='y' || val
[0]=='Y'))
1310 || strcasecmp(val
, "YES")==0) {
1313 } else if ((val
[1]=='\0' && (val
[0]=='n' || val
[0]=='N'))
1314 || strcasecmp(val
, "NO")==0) {
1318 if (sscanf(val
, "%i", &i
)==1) {
1324 wwarning(_("can't convert \"%s\" to boolean for key \"%s\""),
1326 if (second_pass
==0) {
1327 val
= PLGetString(entry
->plvalue
);
1329 wwarning(_("using default \"%s\" instead"), val
);
1340 *(char*)addr
= data
;
1348 getInt(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
1357 val
= PLGetString(value
);
1359 if (sscanf(val
, "%i", &data
)!=1) {
1360 wwarning(_("can't convert \"%s\" to integer for key \"%s\""),
1362 val
= PLGetString(entry
->plvalue
);
1363 wwarning(_("using default \"%s\" instead"), val
);
1364 if (sscanf(val
, "%i", &data
)!=1) {
1380 getCoord(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
1384 char *val_x
, *val_y
;
1385 int nelem
, changed
=0;
1386 proplist_t elem_x
, elem_y
;
1389 if (!PLIsArray(value
)) {
1390 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1391 entry
->key
, "Coordinate");
1393 value
= entry
->plvalue
;
1395 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1401 nelem
= PLGetNumberOfElements(value
);
1403 wwarning(_("Incorrect number of elements in array for key \"%s\"."),
1406 value
= entry
->plvalue
;
1408 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1414 elem_x
= PLGetArrayElement(value
, 0);
1415 elem_y
= PLGetArrayElement(value
, 1);
1417 if (!elem_x
|| !elem_y
|| !PLIsString(elem_x
) || !PLIsString(elem_y
)) {
1418 wwarning(_("Wrong value for key \"%s\". Should be Coordinate."),
1421 value
= entry
->plvalue
;
1423 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1429 val_x
= PLGetString(elem_x
);
1430 val_y
= PLGetString(elem_y
);
1432 if (sscanf(val_x
, "%i", &data
.x
)!=1 || sscanf(val_y
, "%i", &data
.y
)!=1) {
1433 wwarning(_("can't convert array to integers for \"%s\"."), entry
->key
);
1435 value
= entry
->plvalue
;
1437 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1445 else if (data
.x
> scr
->scr_width
/3)
1446 data
.x
= scr
->scr_width
/3;
1449 else if (data
.y
> scr
->scr_height
/3)
1450 data
.y
= scr
->scr_height
/3;
1456 *(WCoord
*)addr
= data
;
1464 /* This function is not used at the moment. */
1466 getString(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
1473 data
= PLGetString(value
);
1476 data
= PLGetString(entry
->plvalue
);
1485 *(char**)addr
= wstrdup(data
);
1493 getPathList(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
1503 if (!PLIsArray(value
)) {
1504 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1505 entry
->key
, "an array of paths");
1507 value
= entry
->plvalue
;
1509 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1516 count
= PLGetNumberOfElements(value
);
1519 value
= entry
->plvalue
;
1521 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1528 for (i
=0; i
<count
; i
++) {
1529 d
= PLGetArrayElement(value
, i
);
1530 if (!d
|| !PLIsString(d
)) {
1534 len
+= strlen(PLGetString(d
))+1;
1537 ptr
= data
= wmalloc(len
+1);
1539 for (i
=0; i
<count
; i
++) {
1540 d
= PLGetArrayElement(value
, i
);
1541 if (!d
|| !PLIsString(d
)) {
1544 strcpy(ptr
, PLGetString(d
));
1545 ptr
+= strlen(PLGetString(d
));
1549 ptr
--; *(ptr
--) = 0;
1551 if (*(char**)addr
!=NULL
) {
1552 free(*(char**)addr
);
1554 *(char**)addr
= data
;
1561 getEnum(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
1564 static signed char data
;
1566 data
= string2index(entry
->plkey
, value
, entry
->default_value
,
1567 (WOptionEnumeration
*)entry
->extra_data
);
1575 *(signed char*)addr
= data
;
1584 * (hgradient <color> <color>)
1585 * (vgradient <color> <color>)
1586 * (dgradient <color> <color>)
1587 * (mhgradient <color> <color> ...)
1588 * (mvgradient <color> <color> ...)
1589 * (tpixmap <file> <color>)
1590 * (spixmap <file> <color>)
1591 * (cpixmap <file> <color>)
1592 * (thgradient <file> <opaqueness> <color> <color>)
1593 * (tvgradient <file> <opaqueness> <color> <color>)
1594 * (tdgradient <file> <opaqueness> <color> <color>)
1595 * (function <lib> <function> ...)
1599 parse_texture(WScreen
*scr
, proplist_t pl
)
1604 WTexture
*texture
=NULL
;
1606 nelem
= PLGetNumberOfElements(pl
);
1611 elem
= PLGetArrayElement(pl
, 0);
1612 if (!elem
|| !PLIsString(elem
))
1614 val
= PLGetString(elem
);
1617 if (strcasecmp(val
, "solid")==0) {
1625 elem
= PLGetArrayElement(pl
, 1);
1626 if (!elem
|| !PLIsString(elem
))
1628 val
= PLGetString(elem
);
1630 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &color
)) {
1631 wwarning(_("\"%s\" is not a valid color name"), val
);
1635 texture
= (WTexture
*)wTextureMakeSolid(scr
, &color
);
1636 } else if (strcasecmp(val
, "dgradient")==0
1637 || strcasecmp(val
, "vgradient")==0
1638 || strcasecmp(val
, "hgradient")==0) {
1639 RColor color1
, color2
;
1644 wwarning(_("bad number of arguments in gradient specification"));
1648 if (val
[0]=='d' || val
[0]=='D')
1649 type
= WTEX_DGRADIENT
;
1650 else if (val
[0]=='h' || val
[0]=='H')
1651 type
= WTEX_HGRADIENT
;
1653 type
= WTEX_VGRADIENT
;
1656 /* get from color */
1657 elem
= PLGetArrayElement(pl
, 1);
1658 if (!elem
|| !PLIsString(elem
))
1660 val
= PLGetString(elem
);
1662 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1663 wwarning(_("\"%s\" is not a valid color name"), val
);
1667 color1
.red
= xcolor
.red
>> 8;
1668 color1
.green
= xcolor
.green
>> 8;
1669 color1
.blue
= xcolor
.blue
>> 8;
1672 elem
= PLGetArrayElement(pl
, 2);
1673 if (!elem
|| !PLIsString(elem
)) {
1676 val
= PLGetString(elem
);
1678 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1679 wwarning(_("\"%s\" is not a valid color name"), val
);
1683 color2
.red
= xcolor
.red
>> 8;
1684 color2
.green
= xcolor
.green
>> 8;
1685 color2
.blue
= xcolor
.blue
>> 8;
1687 texture
= (WTexture
*)wTextureMakeGradient(scr
, type
, &color1
, &color2
);
1689 } else if (strcasecmp(val
, "mhgradient")==0
1690 || strcasecmp(val
, "mvgradient")==0
1691 || strcasecmp(val
, "mdgradient")==0) {
1698 wwarning(_("too few arguments in multicolor gradient specification"));
1702 if (val
[1]=='h' || val
[1]=='H')
1703 type
= WTEX_MHGRADIENT
;
1704 else if (val
[1]=='v' || val
[1]=='V')
1705 type
= WTEX_MVGRADIENT
;
1707 type
= WTEX_MDGRADIENT
;
1711 colors
= wmalloc(sizeof(RColor
*)*(count
+1));
1713 for (i
=0; i
<count
; i
++) {
1714 elem
= PLGetArrayElement(pl
, i
+1);
1715 if (!elem
|| !PLIsString(elem
)) {
1716 for (--i
; i
>=0; --i
) {
1722 val
= PLGetString(elem
);
1724 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &color
)) {
1725 wwarning(_("\"%s\" is not a valid color name"), val
);
1726 for (--i
; i
>=0; --i
) {
1732 colors
[i
] = wmalloc(sizeof(RColor
));
1733 colors
[i
]->red
= color
.red
>> 8;
1734 colors
[i
]->green
= color
.green
>> 8;
1735 colors
[i
]->blue
= color
.blue
>> 8;
1740 texture
= (WTexture
*)wTextureMakeMGradient(scr
, type
, colors
);
1741 } else if (strcasecmp(val
, "spixmap")==0 ||
1742 strcasecmp(val
, "cpixmap")==0 ||
1743 strcasecmp(val
, "tpixmap")==0) {
1750 if (val
[0] == 's' || val
[0] == 'S')
1752 else if (val
[0] == 'c' || val
[0] == 'C')
1758 elem
= PLGetArrayElement(pl
, 2);
1759 if (!elem
|| !PLIsString(elem
)) {
1762 val
= PLGetString(elem
);
1764 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &color
)) {
1765 wwarning(_("\"%s\" is not a valid color name"), val
);
1770 elem
= PLGetArrayElement(pl
, 1);
1771 if (!elem
|| !PLIsString(elem
))
1773 val
= PLGetString(elem
);
1775 texture
= (WTexture
*)wTextureMakePixmap(scr
, type
, val
, &color
);
1776 } else if (strcasecmp(val
, "thgradient")==0
1777 || strcasecmp(val
, "tvgradient")==0
1778 || strcasecmp(val
, "tdgradient")==0) {
1779 RColor color1
, color2
;
1784 if (val
[1]=='h' || val
[1]=='H')
1785 style
= WTEX_THGRADIENT
;
1786 else if (val
[1]=='v' || val
[1]=='V')
1787 style
= WTEX_TVGRADIENT
;
1789 style
= WTEX_TDGRADIENT
;
1792 wwarning(_("bad number of arguments in textured gradient specification"));
1796 /* get from color */
1797 elem
= PLGetArrayElement(pl
, 3);
1798 if (!elem
|| !PLIsString(elem
))
1800 val
= PLGetString(elem
);
1802 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1803 wwarning(_("\"%s\" is not a valid color name"), val
);
1807 color1
.red
= xcolor
.red
>> 8;
1808 color1
.green
= xcolor
.green
>> 8;
1809 color1
.blue
= xcolor
.blue
>> 8;
1812 elem
= PLGetArrayElement(pl
, 4);
1813 if (!elem
|| !PLIsString(elem
)) {
1816 val
= PLGetString(elem
);
1818 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1819 wwarning(_("\"%s\" is not a valid color name"), val
);
1823 color2
.red
= xcolor
.red
>> 8;
1824 color2
.green
= xcolor
.green
>> 8;
1825 color2
.blue
= xcolor
.blue
>> 8;
1828 elem
= PLGetArrayElement(pl
, 2);
1829 if (!elem
|| !PLIsString(elem
))
1832 val
= PLGetString(elem
);
1834 if (!val
|| (opacity
= atoi(val
)) < 0 || opacity
> 255) {
1835 wwarning(_("bad opacity value for tgradient texture \"%s\". Should be [0..255]"), val
);
1840 elem
= PLGetArrayElement(pl
, 1);
1841 if (!elem
|| !PLIsString(elem
))
1843 val
= PLGetString(elem
);
1845 texture
= (WTexture
*)wTextureMakeTGradient(scr
, style
, &color1
, &color2
,
1848 #ifdef TEXTURE_PLUGIN
1849 else if (strcasecmp(val
, "function")==0) {
1850 WTexFunction
*function
;
1851 void (*initFunc
) (Display
*, Colormap
);
1852 char *lib
, *func
, **argv
;
1858 /* get the library name */
1859 elem
= PLGetArrayElement(pl
, 1);
1860 if (!elem
|| !PLIsString(elem
)) {
1863 lib
= PLGetString(elem
);
1865 /* get the function name */
1866 elem
= PLGetArrayElement(pl
, 2);
1867 if (!elem
|| !PLIsString(elem
)) {
1870 func
= PLGetString(elem
);
1873 argv
= (char **)wmalloc(argc
* sizeof(char *));
1875 /* get the parameters */
1876 argv
[0] = wstrdup(func
);
1877 for (i
= 0; i
< argc
- 1; i
++) {
1878 elem
= PLGetArrayElement(pl
, 3 + i
);
1879 if (!elem
|| !PLIsString(elem
)) {
1884 argv
[i
+1] = wstrdup(PLGetString(elem
));
1887 function
= wTextureMakeFunction(scr
, lib
, func
, argc
, argv
);
1891 initFunc
= dlsym(function
->handle
, "initWindowMaker");
1893 initFunc(dpy
, scr
->w_colormap
);
1895 wwarning(_("could not initialize library %s"), lib
);
1898 wwarning(_("could not find function %s::%s"), lib
, func
);
1900 #endif /* HAVE_DLFCN_H */
1901 texture
= (WTexture
*)function
;
1903 #endif /* TEXTURE_PLUGIN */
1905 wwarning(_("invalid texture type %s"), val
);
1914 getTexture(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
1917 static WTexture
*texture
;
1921 if (!PLIsArray(value
)) {
1922 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1923 entry
->key
, "Texture");
1925 value
= entry
->plvalue
;
1927 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1933 if (strcmp(entry
->key
, "WidgetColor")==0 && !changed
) {
1936 pl
= PLGetArrayElement(value
, 0);
1937 if (!pl
|| !PLIsString(pl
) || !PLGetString(pl
)
1938 || strcasecmp(PLGetString(pl
), "solid")!=0) {
1939 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1940 entry
->key
, "Solid Texture");
1942 value
= entry
->plvalue
;
1944 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1949 texture
= parse_texture(scr
, value
);
1952 wwarning(_("Error in texture specification for key \"%s\""),
1955 value
= entry
->plvalue
;
1957 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1967 *(WTexture
**)addr
= texture
;
1975 getWSBackground(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
,
1976 void *addr
, void **ret
)
1984 if (!PLIsArray(value
)) {
1985 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1986 "WorkspaceBack", "Texture or None");
1988 value
= entry
->plvalue
;
1990 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1996 /* only do basic error checking and verify for None texture */
1998 nelem
= PLGetNumberOfElements(value
);
2000 elem
= PLGetArrayElement(value
, 0);
2001 if (!elem
|| !PLIsString(elem
)) {
2002 wwarning(_("Wrong type for workspace background. Should be a texture type."));
2004 value
= entry
->plvalue
;
2006 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
2011 val
= PLGetString(elem
);
2013 if (strcasecmp(val
, "None")==0)
2016 *ret
= PLRetain(value
);
2023 getWSSpecificBackground(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
,
2024 void *addr
, void **ret
)
2031 if (!PLIsArray(value
)) {
2032 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
2033 "WorkspaceSpecificBack", "an array of textures");
2035 value
= entry
->plvalue
;
2037 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
2043 /* only do basic error checking and verify for None texture */
2045 nelem
= PLGetNumberOfElements(value
);
2048 elem
= PLGetArrayElement(value
, nelem
);
2049 if (!elem
|| !PLIsArray(elem
)) {
2050 wwarning(_("Wrong type for background of workspace %i. Should be a texture."),
2056 *ret
= PLRetain(value
);
2060 * Kluge to force wmsetbg helper to set the default background.
2061 * If the WorkspaceSpecificBack is changed once wmaker has started,
2062 * the WorkspaceBack won't be sent to the helper, unless the user
2063 * changes it's value too. So, we must force this by removing the
2064 * value from the defaults DB.
2066 if (!scr
->flags
.backimage_helper_launched
&& !scr
->flags
.startup
) {
2067 proplist_t key
= PLMakeString("WorkspaceBack");
2069 PLRemoveDictionaryEntry(WDWindowMaker
->dictionary
, key
);
2079 getFont(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
2087 val
= PLGetString(value
);
2089 font
= wLoadFont(val
);
2091 wfatal(_("could not load any usable font!!!"));
2098 /* can't assign font value outside update function */
2099 wassertrv(addr
== NULL
, True
);
2106 getColor(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
2109 static XColor color
;
2115 val
= PLGetString(value
);
2118 if (!wGetColor(scr
, val
, &color
)) {
2119 wwarning(_("could not get color for key \"%s\""),
2121 if (second_pass
==0) {
2122 val
= PLGetString(entry
->plvalue
);
2124 wwarning(_("using default \"%s\" instead"), val
);
2136 *(unsigned long*)addr = pixel;
2145 getKeybind(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
2148 static WShortKey shortcut
;
2155 STRINGP("Key spec");
2157 val
= PLGetString(value
);
2159 if (!val
|| strcasecmp(val
, "NONE")==0) {
2160 shortcut
.keycode
= 0;
2161 shortcut
.modifier
= 0;
2172 shortcut
.modifier
= 0;
2173 while ((k
= strchr(b
, '+'))!=NULL
) {
2177 mod
= wXModifierFromKey(b
);
2179 wwarning(_("%s:invalid key modifier \"%s\""), entry
->key
, b
);
2182 shortcut
.modifier
|= mod
;
2188 ksym
= XStringToKeysym(b
);
2190 if (ksym
==NoSymbol
) {
2191 wwarning(_("%s:invalid kbd shortcut specification \"%s\""), entry
->key
,
2196 shortcut
.keycode
= XKeysymToKeycode(dpy
, ksym
);
2197 if (shortcut
.keycode
==0) {
2198 wwarning(_("%s:invalid key in shortcut \"%s\""), entry
->key
, val
);
2210 getModMask(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
2213 static unsigned int mask
;
2216 STRINGP("Modifier Key");
2218 str
= PLGetString(value
);
2222 mask
= wXModifierFromKey(str
);
2224 wwarning(_("%s: modifier key %s is not valid"), entry
->key
, str
);
2230 *(unsigned int*)addr
= mask
;
2241 getRImages(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
,
2242 void *addr
, void **ret
)
2250 STRINGP("Image File Path");
2252 str
= PLGetString(value
);
2256 image
= RLoadImage(scr
->rcontext
, str
, 0);
2258 wwarning(_("could not load image in option %s: %s"), entry
->key
,
2259 RMessageForError(RErrorCode
));
2263 if (*(RImage
**)addr
) {
2264 RDestroyImage(*(RImage
**)addr
);
2267 *(RImage
**)addr
= image
;
2269 assert(ret
== NULL
);
2272 *(RImage**)ret = image;
2280 /* ---------------- value setting functions --------------- */
2282 setJustify(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
2284 return REFRESH_WINDOW_TITLE_COLOR
;
2289 setIfDockPresent(WScreen
*scr
, WDefaultEntry
*entry
, int *flag
, long which
)
2293 wPreferences
.flags
.nodock
= wPreferences
.flags
.nodock
|| *flag
;
2296 wPreferences
.flags
.noclip
= wPreferences
.flags
.noclip
|| *flag
;
2306 setStickyIcons(WScreen
*scr
, WDefaultEntry
*entry
, void *bar
, void *foo
)
2308 if (scr
->workspaces
) {
2309 wWorkspaceForceChange(scr
, scr
->current_workspace
);
2310 wArrangeIcons(scr
, False
);
2317 setPositive(WScreen
*scr
, WDefaultEntry
*entry
, int *value
, void *foo
)
2329 setIconTile(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
2335 img
= wTextureRenderImage(*texture
, wPreferences
.icon_size
,
2336 wPreferences
.icon_size
,
2337 ((*texture
)->any
.type
& WREL_BORDER_MASK
)
2338 ? WREL_ICON
: WREL_FLAT
);
2340 wwarning(_("could not render texture for icon background"));
2342 wTextureDestroy(scr
, *texture
);
2345 RConvertImage(scr
->rcontext
, img
, &pixmap
);
2347 if (scr
->icon_tile
) {
2349 RDestroyImage(scr
->icon_tile
);
2350 XFreePixmap(dpy
, scr
->icon_tile_pixmap
);
2353 scr
->icon_tile
= img
;
2355 if (!wPreferences
.flags
.noclip
) {
2356 if (scr
->clip_tile
) {
2357 RDestroyImage(scr
->clip_tile
);
2359 scr
->clip_tile
= wClipMakeTile(scr
, img
);
2362 scr
->icon_tile_pixmap
= pixmap
;
2364 if (scr
->def_icon_pixmap
) {
2365 XFreePixmap(dpy
, scr
->def_icon_pixmap
);
2366 scr
->def_icon_pixmap
= None
;
2368 if (scr
->def_ticon_pixmap
) {
2369 XFreePixmap(dpy
, scr
->def_ticon_pixmap
);
2370 scr
->def_ticon_pixmap
= None
;
2373 if (scr
->icon_back_texture
) {
2374 wTextureDestroy(scr
, (WTexture
*)scr
->icon_back_texture
);
2376 scr
->icon_back_texture
= wTextureMakeSolid(scr
, &((*texture
)->any
.color
));
2378 if (scr
->clip_balloon
)
2379 XSetWindowBackground(dpy
, scr
->clip_balloon
,
2380 (*texture
)->any
.color
.pixel
);
2383 * Free the texture as nobody else will use it, nor refer to it.
2386 wTextureDestroy(scr
, *texture
);
2388 return (reset
? REFRESH_ICON_TILE
: 0);
2394 setWinTitleFont(WScreen
*scr
, WDefaultEntry
*entry
, WFont
*font
, void *foo
)
2396 if (scr
->title_font
) {
2397 wFreeFont(scr
->title_font
);
2400 scr
->title_font
= font
;
2403 XSetFont(dpy
, scr
->window_title_gc
, font
->font
->fid
);
2406 return REFRESH_WINDOW_FONT
|REFRESH_BUTTON_IMAGES
;
2411 setMenuTitleFont(WScreen
*scr
, WDefaultEntry
*entry
, WFont
*font
, void *foo
)
2413 if (scr
->menu_title_font
) {
2414 wFreeFont(scr
->menu_title_font
);
2417 scr
->menu_title_font
= font
;
2420 XSetFont(dpy
, scr
->menu_title_gc
, font
->font
->fid
);
2423 return REFRESH_MENU_TITLE_FONT
;
2428 setMenuTextFont(WScreen
*scr
, WDefaultEntry
*entry
, WFont
*font
, void *foo
)
2430 if (scr
->menu_entry_font
) {
2431 wFreeFont(scr
->menu_entry_font
);
2434 scr
->menu_entry_font
= font
;
2437 XSetFont(dpy
, scr
->menu_entry_gc
, font
->font
->fid
);
2438 XSetFont(dpy
, scr
->disabled_menu_entry_gc
, font
->font
->fid
);
2439 XSetFont(dpy
, scr
->select_menu_gc
, font
->font
->fid
);
2442 return REFRESH_MENU_FONT
;
2448 setIconTitleFont(WScreen
*scr
, WDefaultEntry
*entry
, WFont
*font
, void *foo
)
2450 if (scr
->icon_title_font
) {
2451 wFreeFont(scr
->icon_title_font
);
2454 scr
->icon_title_font
= font
;
2457 XSetFont(dpy
, scr
->icon_title_gc
, font
->font
->fid
);
2460 return REFRESH_ICON_FONT
;
2465 setClipTitleFont(WScreen
*scr
, WDefaultEntry
*entry
, WFont
*font
, void *foo
)
2467 if (scr
->clip_title_font
) {
2468 wFreeFont(scr
->clip_title_font
);
2471 scr
->clip_title_font
= font
;
2474 XSetFont(dpy
, scr
->clip_title_gc
, font
->font
->fid
);
2477 return REFRESH_ICON_FONT
;
2482 setDisplayFont(WScreen
*scr
, WDefaultEntry
*entry
, WFont
*font
, void *foo
)
2484 if (scr
->info_text_font
) {
2485 wFreeFont(scr
->info_text_font
);
2488 scr
->info_text_font
= font
;
2491 XSetFont(dpy
, scr
->info_text_gc
, font
->font
->fid
);
2492 XSetFont(dpy
, scr
->line_gc
, font
->font
->fid
);
2495 /* This test works because the scr structure is initially zeroed out
2496 and None = 0. Any other time, the window should be valid. */
2497 if (scr
->geometry_display
!= None
) {
2498 wGetGeometryWindowSize(scr
, &scr
->geometry_display_width
,
2499 &scr
->geometry_display_height
);
2500 XResizeWindow(dpy
, scr
->geometry_display
,
2501 scr
->geometry_display_width
, scr
->geometry_display_height
);
2509 setHightlight(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, void *foo
)
2511 if (scr
->select_pixel
!=scr
->white_pixel
&&
2512 scr
->select_pixel
!=scr
->black_pixel
) {
2513 wFreeColor(scr
, scr
->select_pixel
);
2516 scr
->select_pixel
= color
->pixel
;
2518 return REFRESH_MENU_COLOR
;
2523 setHightlightText(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, void *foo
)
2525 if (scr
->select_text_pixel
!=scr
->white_pixel
&&
2526 scr
->select_text_pixel
!=scr
->black_pixel
) {
2527 wFreeColor(scr
, scr
->select_text_pixel
);
2530 scr
->select_text_pixel
= color
->pixel
;
2532 return REFRESH_MENU_COLOR
;
2537 setClipTitleColor(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, long index
)
2539 if (scr
->clip_title_pixel
[index
]!=scr
->white_pixel
&&
2540 scr
->clip_title_pixel
[index
]!=scr
->black_pixel
) {
2541 wFreeColor(scr
, scr
->clip_title_pixel
[index
]);
2543 scr
->clip_title_pixel
[index
] = color
->pixel
;
2545 #ifdef GRADIENT_CLIP_ARROW
2546 if (index
== CLIP_NORMAL
) {
2548 RColor color1
, color2
;
2549 int pt
= CLIP_BUTTON_SIZE
*wPreferences
.icon_size
/64;
2550 int as
= pt
- 15; /* 15 = 5+5+5 */
2552 FREE_PIXMAP(scr
->clip_arrow_gradient
);
2554 color1
.red
= (color
->red
>> 8)*6/10;
2555 color1
.green
= (color
->green
>> 8)*6/10;
2556 color1
.blue
= (color
->blue
>> 8)*6/10;
2558 color2
.red
= WMIN((color
->red
>> 8)*20/10, 255);
2559 color2
.green
= WMIN((color
->green
>> 8)*20/10, 255);
2560 color2
.blue
= WMIN((color
->blue
>> 8)*20/10, 255);
2562 image
= RRenderGradient(as
+1, as
+1, &color1
, &color2
, RDiagonalGradient
);
2563 RConvertImage(scr
->rcontext
, image
, &scr
->clip_arrow_gradient
);
2564 RDestroyImage(image
);
2566 #endif /* GRADIENT_CLIP_ARROW */
2568 return REFRESH_ICON_TITLE_COLOR
;
2573 setWTitleColor(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, long index
)
2575 if (scr
->window_title_pixel
[index
]!=scr
->white_pixel
&&
2576 scr
->window_title_pixel
[index
]!=scr
->black_pixel
) {
2577 wFreeColor(scr
, scr
->window_title_pixel
[index
]);
2580 scr
->window_title_pixel
[index
] = color
->pixel
;
2582 if (index
== WS_UNFOCUSED
)
2583 XSetForeground(dpy
, scr
->info_text_gc
, color
->pixel
);
2585 return REFRESH_WINDOW_TITLE_COLOR
;
2590 setMenuTitleColor(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, long index
)
2592 #ifdef TITLE_TEXT_SHADOW
2593 if (index
== WS_SMENU
){
2594 if (scr
->menu_title_pixel
[WS_SMENU
]!=scr
->white_pixel
&&
2595 scr
->menu_title_pixel
[WS_SMENU
]!=scr
->black_pixel
) {
2596 wFreeColor(scr
, scr
->menu_title_pixel
[WS_SMENU
]);
2598 scr
->menu_title_pixel
[WS_SMENU
] = color
->pixel
;
2601 if (scr
->menu_title_pixel
[0]!=scr
->white_pixel
&&
2602 scr
->menu_title_pixel
[0]!=scr
->black_pixel
) {
2603 wFreeColor(scr
, scr
->menu_title_pixel
[0]);
2605 scr
->menu_title_pixel
[0] = color
->pixel
;
2607 #else /* !TITLE_TEXT_SHADOW */
2608 if (scr
->menu_title_pixel
[0]!=scr
->white_pixel
&&
2609 scr
->menu_title_pixel
[0]!=scr
->black_pixel
) {
2610 wFreeColor(scr
, scr
->menu_title_pixel
[0]);
2613 scr
->menu_title_pixel
[0] = color
->pixel
;
2614 #endif /* !TITLE_TEXT_SHADOW */
2615 XSetForeground(dpy
, scr
->menu_title_gc
, color
->pixel
);
2617 return REFRESH_MENU_TITLE_COLOR
;
2622 setMenuTextColor(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, void *foo
)
2625 #define gcm (GCForeground|GCBackground|GCFillStyle)
2627 if (scr
->mtext_pixel
!=scr
->white_pixel
&&
2628 scr
->mtext_pixel
!=scr
->black_pixel
) {
2629 wFreeColor(scr
, scr
->mtext_pixel
);
2632 scr
->mtext_pixel
= color
->pixel
;
2634 XSetForeground(dpy
, scr
->menu_entry_gc
, color
->pixel
);
2637 if (scr
->dtext_pixel
== scr
->mtext_pixel
) {
2638 gcv
.foreground
= scr
->white_pixel
;
2639 gcv
.background
= scr
->black_pixel
;
2640 gcv
.fill_style
= FillStippled
;
2642 gcv
.foreground
= scr
->dtext_pixel
;
2643 gcv
.fill_style
= FillSolid
;
2645 XChangeGC(dpy
, scr
->disabled_menu_entry_gc
, gcm
, &gcv
);
2647 return REFRESH_MENU_COLOR
;
2653 setMenuDisabledColor(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, void *foo
)
2656 #define gcm (GCForeground|GCBackground|GCFillStyle)
2658 if (scr
->dtext_pixel
!=scr
->white_pixel
&&
2659 scr
->dtext_pixel
!=scr
->black_pixel
) {
2660 wFreeColor(scr
, scr
->dtext_pixel
);
2663 scr
->dtext_pixel
= color
->pixel
;
2665 if (scr
->dtext_pixel
== scr
->mtext_pixel
) {
2666 gcv
.foreground
= scr
->white_pixel
;
2667 gcv
.background
= scr
->black_pixel
;
2668 gcv
.fill_style
= FillStippled
;
2670 gcv
.foreground
= scr
->dtext_pixel
;
2671 gcv
.fill_style
= FillSolid
;
2673 XChangeGC(dpy
, scr
->disabled_menu_entry_gc
, gcm
, &gcv
);
2675 return REFRESH_MENU_COLOR
;
2680 setIconTitleColor(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, void *foo
)
2682 XSetForeground(dpy
, scr
->icon_title_gc
, color
->pixel
);
2684 return REFRESH_ICON_TITLE_COLOR
;
2689 setIconTitleBack(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, void *foo
)
2691 if (scr
->icon_title_texture
) {
2692 wTextureDestroy(scr
, (WTexture
*)scr
->icon_title_texture
);
2694 XQueryColor (dpy
, scr
->w_colormap
, color
);
2695 scr
->icon_title_texture
= wTextureMakeSolid(scr
, color
);
2697 return REFRESH_ICON_TITLE_BACK
;
2702 trackDeadProcess(pid_t pid
, unsigned char status
, WScreen
*scr
)
2704 close(scr
->helper_fd
);
2706 scr
->helper_pid
= 0;
2707 scr
->flags
.backimage_helper_launched
= 0;
2712 setWorkspaceSpecificBack(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
,
2719 if (scr
->flags
.backimage_helper_launched
) {
2720 if (PLGetNumberOfElements(value
)==0) {
2721 SendHelperMessage(scr
, 'C', 0, NULL
);
2722 SendHelperMessage(scr
, 'K', 0, NULL
);
2731 if (PLGetNumberOfElements(value
) == 0)
2734 if (pipe(filedes
) < 0) {
2735 wsyserror("pipe() failed:can't set workspace specific background image");
2743 wsyserror("fork() failed:can't set workspace specific background image");
2744 if (close(filedes
[0]) < 0)
2745 wsyserror("could not close pipe");
2746 if (close(filedes
[1]) < 0)
2747 wsyserror("could not close pipe");
2749 } else if (pid
== 0) {
2750 SetupEnvironment(scr
);
2753 wsyserror("could not close pipe");
2754 if (dup(filedes
[0]) < 0) {
2755 wsyserror("dup() failed:can't set workspace specific background image");
2757 execlp("wmsetbg", "wmsetbg", "-helper", "-d", NULL
);
2758 wsyserror("could not execute wmsetbg");
2762 if (fcntl(filedes
[0], F_SETFD
, FD_CLOEXEC
) < 0) {
2763 wsyserror("error setting close-on-exec flag");
2765 if (fcntl(filedes
[1], F_SETFD
, FD_CLOEXEC
) < 0) {
2766 wsyserror("error setting close-on-exec flag");
2769 scr
->helper_fd
= filedes
[1];
2770 scr
->helper_pid
= pid
;
2771 scr
->flags
.backimage_helper_launched
= 1;
2773 wAddDeathHandler(pid
, (WDeathHandler
*)trackDeadProcess
, scr
);
2775 SendHelperMessage(scr
, 'P', -1, wPreferences
.pixmap_path
);
2779 for (i
= 0; i
< PLGetNumberOfElements(value
); i
++) {
2780 val
= PLGetArrayElement(value
, i
);
2781 if (val
&& PLIsArray(val
) && PLGetNumberOfElements(val
)>0) {
2782 str
= PLGetDescription(val
);
2784 SendHelperMessage(scr
, 'S', i
+1, str
);
2788 SendHelperMessage(scr
, 'U', i
+1, NULL
);
2799 setWorkspaceBack(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
,
2802 if (scr
->flags
.backimage_helper_launched
) {
2805 if (PLGetNumberOfElements(value
)==0) {
2806 SendHelperMessage(scr
, 'U', 0, NULL
);
2808 /* set the default workspace background to this one */
2809 str
= PLGetDescription(value
);
2811 SendHelperMessage(scr
, 'S', 0, str
);
2813 SendHelperMessage(scr
, 'C', scr
->current_workspace
+1, NULL
);
2815 SendHelperMessage(scr
, 'U', 0, NULL
);
2822 SetupEnvironment(scr
);
2823 text
= PLGetDescription(value
);
2824 command
= wmalloc(strlen(text
)+40);
2825 sprintf(command
, "wmsetbg -d -p '%s' &", text
);
2837 setWidgetColor(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
2839 if (scr
->widget_texture
) {
2840 wTextureDestroy(scr
, (WTexture
*)scr
->widget_texture
);
2842 scr
->widget_texture
= *(WTexSolid
**)texture
;
2844 if (scr
->geometry_display
!= None
)
2845 XSetWindowBackground(dpy
, scr
->geometry_display
,
2846 scr
->widget_texture
->normal
.pixel
);
2853 setFTitleBack(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
2855 if (scr
->window_title_texture
[WS_FOCUSED
]) {
2856 wTextureDestroy(scr
, scr
->window_title_texture
[WS_FOCUSED
]);
2858 scr
->window_title_texture
[WS_FOCUSED
] = *texture
;
2860 return REFRESH_WINDOW_TEXTURES
;
2865 setPTitleBack(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
2867 if (scr
->window_title_texture
[WS_PFOCUSED
]) {
2868 wTextureDestroy(scr
, scr
->window_title_texture
[WS_PFOCUSED
]);
2870 scr
->window_title_texture
[WS_PFOCUSED
] = *texture
;
2872 return REFRESH_WINDOW_TEXTURES
;
2877 setUTitleBack(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
2879 if (scr
->window_title_texture
[WS_UNFOCUSED
]) {
2880 wTextureDestroy(scr
, scr
->window_title_texture
[WS_UNFOCUSED
]);
2882 scr
->window_title_texture
[WS_UNFOCUSED
] = *texture
;
2884 return REFRESH_WINDOW_TEXTURES
;
2889 setResizebarBack(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
2891 if (scr
->resizebar_texture
[0]) {
2892 wTextureDestroy(scr
, scr
->resizebar_texture
[0]);
2894 scr
->resizebar_texture
[0] = *texture
;
2896 return REFRESH_WINDOW_TEXTURES
;
2901 setMenuTitleBack(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
2903 if (scr
->menu_title_texture
[0]) {
2904 wTextureDestroy(scr
, scr
->menu_title_texture
[0]);
2906 scr
->menu_title_texture
[0] = *texture
;
2908 return REFRESH_MENU_TITLE_TEXTURE
;
2913 setMenuTextBack(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
2915 if (scr
->menu_item_texture
) {
2916 wTextureDestroy(scr
, scr
->menu_item_texture
);
2917 wTextureDestroy(scr
, (WTexture
*)scr
->menu_item_auxtexture
);
2919 scr
->menu_item_texture
= *texture
;
2921 scr
->menu_item_auxtexture
2922 = wTextureMakeSolid(scr
, &scr
->menu_item_texture
->any
.color
);
2924 return REFRESH_MENU_TEXTURE
;
2929 setKeyGrab(WScreen
*scr
, WDefaultEntry
*entry
, WShortKey
*shortcut
, long index
)
2932 wKeyBindings
[index
] = *shortcut
;
2934 wwin
= scr
->focused_window
;
2936 while (wwin
!=NULL
) {
2937 XUngrabKey(dpy
, AnyKey
, AnyModifier
, wwin
->frame
->core
->window
);
2939 if (!WFLAGP(wwin
, no_bind_keys
)) {
2940 wWindowSetKeyGrabs(wwin
);
2950 setIconPosition(WScreen
*scr
, WDefaultEntry
*entry
, void *bar
, void *foo
)
2952 wArrangeIcons(scr
, True
);
2959 updateUsableArea(WScreen
*scr
, WDefaultEntry
*entry
, void *bar
, void *foo
)
2961 wScreenUpdateUsableArea(scr
);
2968 setMenuStyle(WScreen
*scr
, WDefaultEntry
*entry
, int *value
, void *foo
)
2970 return REFRESH_MENU_TEXTURE
;
2976 setButtonImages(WScreen *scr, WDefaultEntry *entry, int *value, void *foo)
2978 return REFRESH_BUTTON_IMAGES;
2984 * Need access to the double click variables, so that all widgets in
2985 * wmaker panels will have the same dbl-click values.
2986 * TODO: figure a better way of dealing with it.
2991 setDoubleClick(WScreen
*scr
, WDefaultEntry
*entry
, int *value
, void *foo
)
2993 extern _WINGsConfiguration WINGsConfiguration
;
2998 WINGsConfiguration
.doubleClickDelay
= *value
;