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
;
115 /* type converters */
116 static int getBool();
118 static int getCoord();
120 /* this is not used yet */
121 static int getString();
123 static int getPathList();
124 static int getEnum();
125 static int getTexture();
126 static int getWSBackground();
127 static int getWSSpecificBackground();
128 static int getFont();
129 static int getColor();
130 static int getKeybind();
131 static int getModMask();
133 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();
173 static int setMenuStyle();
176 static int updateUsableArea();
181 * Tables to convert strings to enumeration values.
182 * Values stored are char
186 /* WARNING: sum of length of all value strings must not exceed
188 #define TOTAL_VALUES_LENGTH 80
193 #define REFRESH_WINDOW_TEXTURES (1<<0)
194 #define REFRESH_MENU_TEXTURE (1<<1)
195 #define REFRESH_MENU_FONT (1<<2)
196 #define REFRESH_MENU_COLOR (1<<3)
197 #define REFRESH_MENU_TITLE_TEXTURE (1<<4)
198 #define REFRESH_MENU_TITLE_FONT (1<<5)
199 #define REFRESH_MENU_TITLE_COLOR (1<<6)
200 #define REFRESH_WINDOW_TITLE_COLOR (1<<7)
201 #define REFRESH_WINDOW_FONT (1<<8)
202 #define REFRESH_FORE_COLOR (1<<9)
203 #define REFRESH_ICON_TILE (1<<10)
204 #define REFRESH_ICON_FONT (1<<11)
205 #define REFRESH_WORKSPACE_BACK (1<<12)
207 #define REFRESH_BUTTON_IMAGES (1<<13)
209 #define REFRESH_ICON_TITLE_COLOR (1<<14)
210 #define REFRESH_ICON_TITLE_BACK (1<<15)
214 static WOptionEnumeration seFocusModes
[] = {
215 {"Manual", WKF_CLICK
, 0}, {"ClickToFocus", WKF_CLICK
, 1},
216 {"Auto", WKF_POINTER
, 0}, {"FocusFollowMouse", WKF_POINTER
, 1},
217 {"Sloppy", WKF_SLOPPY
, 0}, {"SemiAuto", WKF_SLOPPY
, 1},
221 static WOptionEnumeration seColormapModes
[] = {
222 {"Manual", WKF_CLICK
, 0}, {"ClickToFocus", WKF_CLICK
, 1},
223 {"Auto", WKF_POINTER
, 0}, {"FocusFollowMouse", WKF_POINTER
, 1},
227 static WOptionEnumeration sePlacements
[] = {
228 {"Auto", WPM_SMART
, 0}, {"Smart", WPM_SMART
, 1},
229 {"Cascade", WPM_CASCADE
, 0},
230 {"Random", WPM_RANDOM
, 0},
231 {"Manual", WPM_MANUAL
, 0},
235 static WOptionEnumeration seGeomDisplays
[] = {
236 {"Center", WDIS_CENTER
, 0},
237 {"Corner", WDIS_TOPLEFT
, 0},
238 {"Floating", WDIS_FRAME_CENTER
, 0},
239 {"Line", WDIS_NEW
, 0},
243 static WOptionEnumeration seSpeeds
[] = {
244 {"UltraFast", SPEED_ULTRAFAST
, 0},
245 {"Fast", SPEED_FAST
, 0},
246 {"Medium", SPEED_MEDIUM
, 0},
247 {"Slow", SPEED_SLOW
, 0},
248 {"UltraSlow", SPEED_ULTRASLOW
, 0},
252 static WOptionEnumeration seMouseButtons
[] = {
253 {"Left", Button1
, 0}, {"Button1", Button1
, 1},
254 {"Middle", Button2
, 0}, {"Button2", Button2
, 1},
255 {"Right", Button3
, 0}, {"Button3", Button3
, 1},
256 {"Button4", Button4
, 0},
257 {"Button5", Button5
, 0},
261 static WOptionEnumeration seIconificationStyles
[] = {
262 {"Zoom", WIS_ZOOM
, 0},
263 {"Twist", WIS_TWIST
, 0},
264 {"Flip", WIS_FLIP
, 0},
265 {"None", WIS_NONE
, 0},
266 {"random", WIS_RANDOM
, 0},
270 static WOptionEnumeration seJustifications
[] = {
271 {"Left", WTJ_LEFT
, 0},
272 {"Center", WTJ_CENTER
, 0},
273 {"Right", WTJ_RIGHT
, 0},
277 static WOptionEnumeration seIconPositions
[] = {
278 {"blv", IY_BOTTOM
|IY_LEFT
|IY_VERT
, 0},
279 {"blh", IY_BOTTOM
|IY_LEFT
|IY_HORIZ
, 0},
280 {"brv", IY_BOTTOM
|IY_RIGHT
|IY_VERT
, 0},
281 {"brh", IY_BOTTOM
|IY_RIGHT
|IY_HORIZ
, 0},
282 {"tlv", IY_TOP
|IY_LEFT
|IY_VERT
, 0},
283 {"tlh", IY_TOP
|IY_LEFT
|IY_HORIZ
, 0},
284 {"trv", IY_TOP
|IY_RIGHT
|IY_VERT
, 0},
285 {"trh", IY_TOP
|IY_RIGHT
|IY_HORIZ
, 0},
289 static WOptionEnumeration seMenuStyles
[] = {
290 {"normal", MS_NORMAL
, 0},
291 {"singletexture", MS_SINGLE_TEXTURE
, 0},
292 {"flat", MS_FLAT
, 0},
298 * ALL entries in the tables bellow, NEED to have a default value
299 * defined, and this value needs to be correct.
302 /* these options will only affect the window manager on startup
304 * static defaults can't access the screen data, because it is
305 * created after these defaults are read
307 WDefaultEntry staticOptionList
[] = {
309 {"DisableDithering", "NO", NULL
,
310 &wPreferences
.no_dithering
, getBool
, NULL
312 {"ColormapSize", "4", NULL
,
313 &wPreferences
.cmap_size
, getInt
, NULL
315 /* static by laziness */
316 {"IconSize", "64", NULL
,
317 &wPreferences
.icon_size
, getInt
, NULL
319 {"ModifierKey", "Mod1", NULL
,
320 &wPreferences
.modifier_mask
, getModMask
, NULL
322 {"DisableWSMouseActions", "NO", NULL
,
323 &wPreferences
.disable_root_mouse
, getBool
, NULL
325 {"FocusMode", "manual", seFocusModes
,
326 &wPreferences
.focus_mode
, getEnum
, NULL
327 }, /* have a problem when switching from manual to sloppy without restart */
328 {"NewStyle", "NO", NULL
,
329 &wPreferences
.new_style
, getBool
, NULL
331 {"DisableDock", "NO", (void*) WM_DOCK
,
332 NULL
, getBool
, setIfDockPresent
334 {"DisableClip", "NO", (void*) WM_CLIP
,
335 NULL
, getBool
, setIfDockPresent
337 {"DisableMiniwindows", "NO", NULL
,
338 &wPreferences
.disable_miniwindows
, getBool
, NULL
344 WDefaultEntry optionList
[] = {
345 /* dynamic options */
346 {"IconPosition", "blh", seIconPositions
,
347 &wPreferences
.icon_yard
, getEnum
, setIconPosition
349 {"IconificationStyle", "Zoom", seIconificationStyles
,
350 &wPreferences
.iconification_style
, getEnum
, NULL
352 {"SelectWindowsMouseButton", "Left", seMouseButtons
,
353 &wPreferences
.select_button
, getEnum
, NULL
355 {"WindowListMouseButton", "Middle", seMouseButtons
,
356 &wPreferences
.windowl_button
, getEnum
, NULL
358 {"ApplicationMenuMouseButton", "Right", seMouseButtons
,
359 &wPreferences
.menu_button
, getEnum
, NULL
361 {"PixmapPath", DEF_PIXMAP_PATHS
, NULL
,
362 &wPreferences
.pixmap_path
, getPathList
, NULL
364 {"IconPath", DEF_ICON_PATHS
, NULL
,
365 &wPreferences
.icon_path
, getPathList
, NULL
367 {"ColormapMode", "auto", seColormapModes
,
368 &wPreferences
.colormap_mode
, getEnum
, NULL
370 {"AutoFocus", "NO", NULL
,
371 &wPreferences
.auto_focus
, getBool
, NULL
373 {"RaiseDelay", "0", NULL
,
374 &wPreferences
.raise_delay
, getInt
, NULL
376 {"CirculateRaise", "NO", NULL
,
377 &wPreferences
.circ_raise
, getBool
, NULL
379 {"Superfluous", "NO", NULL
,
380 &wPreferences
.superfluous
, getBool
, NULL
382 {"AdvanceToNewWorkspace", "NO", NULL
,
383 &wPreferences
.ws_advance
, getBool
, NULL
385 {"CycleWorkspaces", "NO", NULL
,
386 &wPreferences
.ws_cycle
, getBool
, NULL
388 {"StickyIcons", "NO", NULL
,
389 &wPreferences
.sticky_icons
, getBool
, setStickyIcons
391 {"SaveSessionOnExit", "NO", NULL
,
392 &wPreferences
.save_session_on_exit
, getBool
, NULL
394 {"WrapMenus", "NO", NULL
,
395 &wPreferences
.wrap_menus
, getBool
, NULL
397 {"ScrollableMenus", "NO", NULL
,
398 &wPreferences
.scrollable_menus
, getBool
, NULL
400 {"MenuScrollSpeed", "medium", seSpeeds
,
401 &wPreferences
.menu_scroll_speed
, getEnum
, NULL
403 {"IconSlideSpeed", "medium", seSpeeds
,
404 &wPreferences
.icon_slide_speed
, getEnum
, NULL
406 {"ShadeSpeed", "medium", seSpeeds
,
407 &wPreferences
.shade_speed
, getEnum
, NULL
409 {"DoubleClickTime", "250", (void*) &wPreferences
.dblclick_time
,
410 &wPreferences
.dblclick_time
, getInt
, setDoubleClick
,
412 {"AlignSubmenus", "NO", NULL
,
413 &wPreferences
.align_menus
, getBool
, NULL
415 {"OpenTransientOnOwnerWorkspace", "NO", NULL
,
416 &wPreferences
.open_transients_with_parent
, getBool
, NULL
418 {"WindowPlacement", "auto", sePlacements
,
419 &wPreferences
.window_placement
, getEnum
, NULL
421 {"IgnoreFocusClick","NO", NULL
,
422 &wPreferences
.ignore_focus_click
, getBool
, NULL
424 {"UseSaveUnders", "NO", NULL
,
425 &wPreferences
.use_saveunders
, getBool
, NULL
427 {"OpaqueMove", "NO", NULL
,
428 &wPreferences
.opaque_move
, getBool
, NULL
430 {"DisableSound", "NO", NULL
,
431 &wPreferences
.no_sound
, getBool
, NULL
433 {"DisableAnimations", "NO", NULL
,
434 &wPreferences
.no_animations
, getBool
, NULL
436 {"DontLinkWorkspaces","NO", NULL
,
437 &wPreferences
.no_autowrap
, getBool
, NULL
439 {"AutoArrangeIcons", "NO", NULL
,
440 &wPreferences
.auto_arrange_icons
, getBool
, NULL
442 {"NoWindowOverDock", "NO", NULL
,
443 &wPreferences
.no_window_over_dock
, getBool
, updateUsableArea
445 {"NoWindowOverIcons", "NO", NULL
,
446 &wPreferences
.no_window_over_icons
, getBool
, updateUsableArea
448 {"WindowPlaceOrigin", "(0, 0)", NULL
,
449 &wPreferences
.window_place_origin
, getCoord
, NULL
451 {"ResizeDisplay", "corner", seGeomDisplays
,
452 &wPreferences
.size_display
, getEnum
, NULL
454 {"MoveDisplay", "corner", seGeomDisplays
,
455 &wPreferences
.move_display
, getEnum
, NULL
457 {"DontConfirmKill", "NO", NULL
,
458 &wPreferences
.dont_confirm_kill
, getBool
,NULL
460 {"WindowTitleBalloons", "NO", NULL
,
461 &wPreferences
.window_balloon
, getBool
, NULL
463 {"MiniwindowTitleBalloons", "NO", NULL
,
464 &wPreferences
.miniwin_balloon
,getBool
, NULL
466 {"AppIconBalloons", "NO", NULL
,
467 &wPreferences
.appicon_balloon
,getBool
, NULL
469 {"EdgeResistance", "30", NULL
,
470 &wPreferences
.edge_resistance
,getInt
, NULL
472 {"DisableBlinking", "NO", NULL
,
473 &wPreferences
.dont_blink
, getBool
, NULL
475 #ifdef WEENDOZE_CYCLE
476 {"WindozeCycling","NO", NULL
,
477 &wPreferences
.windoze_cycling
, getBool
, NULL
479 {"PopupSwitchMenu","YES", NULL
,
480 &wPreferences
.popup_switchmenu
, getBool
, NULL
482 #endif /* WEENDOZE_CYCLE */
484 {"MenuStyle", "normal", seMenuStyles
,
485 &wPreferences
.menu_style
, getEnum
, setMenuStyle
487 {"WidgetColor", "(solid, gray)", NULL
,
488 NULL
, getTexture
, setWidgetColor
,
490 {"WorkspaceSpecificBack","()", NULL
,
491 NULL
, getWSSpecificBackground
, setWorkspaceSpecificBack
493 /* WorkspaceBack must come after WorkspaceSpecificBack or
494 * WorkspaceBack wont know WorkspaceSpecificBack was also
495 * specified and 2 copies of wmsetbg will be launched */
496 {"WorkspaceBack", "(solid, black)", NULL
,
497 NULL
, getWSBackground
,setWorkspaceBack
499 {"IconBack", "(solid, gray)", NULL
,
500 NULL
, getTexture
, setIconTile
502 {"TitleJustify", "center", seJustifications
,
503 &wPreferences
.title_justification
, getEnum
, setJustify
505 {"WindowTitleFont", DEF_TITLE_FONT
, NULL
,
506 NULL
, getFont
, setWinTitleFont
,
508 {"MenuTitleFont", DEF_MENU_TITLE_FONT
, NULL
,
509 NULL
, getFont
, setMenuTitleFont
511 {"MenuTextFont", DEF_MENU_ENTRY_FONT
, NULL
,
512 NULL
, getFont
, setMenuTextFont
514 {"IconTitleFont", DEF_ICON_TITLE_FONT
, NULL
,
515 NULL
, getFont
, setIconTitleFont
517 {"ClipTitleFont", DEF_CLIP_TITLE_FONT
, NULL
,
518 NULL
, getFont
, setClipTitleFont
520 {"DisplayFont", DEF_INFO_TEXT_FONT
, NULL
,
521 NULL
, getFont
, setDisplayFont
523 {"HighlightColor", "white", NULL
,
524 NULL
, getColor
, setHightlight
526 {"HighlightTextColor", "black", NULL
,
527 NULL
, getColor
, setHightlightText
529 {"ClipTitleColor", "black", (void*)CLIP_NORMAL
,
530 NULL
, getColor
, setClipTitleColor
532 {"CClipTitleColor", "\"#454045\"", (void*)CLIP_COLLAPSED
,
533 NULL
, getColor
, setClipTitleColor
535 {"FTitleColor", "white", (void*)WS_FOCUSED
,
536 NULL
, getColor
, setWTitleColor
538 {"PTitleColor", "white", (void*)WS_PFOCUSED
,
539 NULL
, getColor
, setWTitleColor
541 {"UTitleColor", "black", (void*)WS_UNFOCUSED
,
542 NULL
, getColor
, setWTitleColor
544 {"FTitleBack", "(solid, black)", NULL
,
545 NULL
, getTexture
, setFTitleBack
547 {"PTitleBack", "(solid, \"#616161\")", NULL
,
548 NULL
, getTexture
, setPTitleBack
550 {"UTitleBack", "(solid, gray)", NULL
,
551 NULL
, getTexture
, setUTitleBack
553 {"MenuTitleColor", "white", NULL
,
554 NULL
, getColor
, setMenuTitleColor
556 {"MenuTextColor", "black", NULL
,
557 NULL
, getColor
, setMenuTextColor
559 {"MenuDisabledColor", "\"#616161\"", NULL
,
560 NULL
, getColor
, setMenuDisabledColor
562 {"MenuTitleBack", "(solid, black)", NULL
,
563 NULL
, getTexture
, setMenuTitleBack
565 {"MenuTextBack", "(solid, gray)", NULL
,
566 NULL
, getTexture
, setMenuTextBack
568 {"IconTitleColor", "white", NULL
,
569 NULL
, getColor
, setIconTitleColor
571 {"IconTitleBack", "black", NULL
,
572 NULL
, getColor
, setIconTitleBack
576 {"RootMenuKey", "None", (void*)WKBD_ROOTMENU
,
577 NULL
, getKeybind
, setKeyGrab
579 {"WindowListKey", "None", (void*)WKBD_WINDOWLIST
,
580 NULL
, getKeybind
, setKeyGrab
583 {"WindowMenuKey", "None", (void*)WKBD_WINDOWMENU
,
584 NULL
, getKeybind
, setKeyGrab
586 {"ClipLowerKey", "None", (void*)WKBD_CLIPLOWER
,
587 NULL
, getKeybind
, setKeyGrab
589 {"ClipRaiseKey", "None", (void*)WKBD_CLIPRAISE
,
590 NULL
, getKeybind
, setKeyGrab
592 {"ClipRaiseLowerKey", "None", (void*)WKBD_CLIPRAISELOWER
,
593 NULL
, getKeybind
, setKeyGrab
595 {"MiniaturizeKey", "None", (void*)WKBD_MINIATURIZE
,
596 NULL
, getKeybind
, setKeyGrab
598 {"HideKey", "None", (void*)WKBD_HIDE
,
599 NULL
, getKeybind
, setKeyGrab
601 {"MoveResizeKey", "None", (void*)WKBD_MOVERESIZE
,
602 NULL
, getKeybind
, setKeyGrab
604 {"CloseKey", "None", (void*)WKBD_CLOSE
,
605 NULL
, getKeybind
, setKeyGrab
607 {"MaximizeKey", "None", (void*)WKBD_MAXIMIZE
,
608 NULL
, getKeybind
, setKeyGrab
610 {"VMaximizeKey", "None", (void*)WKBD_VMAXIMIZE
,
611 NULL
, getKeybind
, setKeyGrab
613 {"RaiseKey", "Meta+Up", (void*)WKBD_RAISE
,
614 NULL
, getKeybind
, setKeyGrab
616 {"LowerKey", "Meta+Down", (void*)WKBD_LOWER
,
617 NULL
, getKeybind
, setKeyGrab
619 {"RaiseLowerKey", "None", (void*)WKBD_RAISELOWER
,
620 NULL
, getKeybind
, setKeyGrab
622 {"ShadeKey", "None", (void*)WKBD_SHADE
,
623 NULL
, getKeybind
, setKeyGrab
625 {"SelectKey", "None", (void*)WKBD_SELECT
,
626 NULL
, getKeybind
, setKeyGrab
628 {"FocusNextKey", "None", (void*)WKBD_FOCUSNEXT
,
629 NULL
, getKeybind
, setKeyGrab
631 {"FocusPrevKey", "None", (void*)WKBD_FOCUSPREV
,
632 NULL
, getKeybind
, setKeyGrab
634 {"NextWorkspaceKey", "None", (void*)WKBD_NEXTWORKSPACE
,
635 NULL
, getKeybind
, setKeyGrab
637 {"PrevWorkspaceKey", "None", (void*)WKBD_PREVWORKSPACE
,
638 NULL
, getKeybind
, setKeyGrab
640 {"NextWorkspaceLayerKey", "None", (void*)WKBD_NEXTWSLAYER
,
641 NULL
, getKeybind
, setKeyGrab
643 {"PrevWorkspaceLayerKey", "None", (void*)WKBD_PREVWSLAYER
,
644 NULL
, getKeybind
, setKeyGrab
646 {"Workspace1Key", "None", (void*)WKBD_WORKSPACE1
,
647 NULL
, getKeybind
, setKeyGrab
649 {"Workspace2Key", "None", (void*)WKBD_WORKSPACE2
,
650 NULL
, getKeybind
, setKeyGrab
652 {"Workspace3Key", "None", (void*)WKBD_WORKSPACE3
,
653 NULL
, getKeybind
, setKeyGrab
655 {"Workspace4Key", "None", (void*)WKBD_WORKSPACE4
,
656 NULL
, getKeybind
, setKeyGrab
658 {"Workspace5Key", "None", (void*)WKBD_WORKSPACE5
,
659 NULL
, getKeybind
, setKeyGrab
661 {"Workspace6Key", "None", (void*)WKBD_WORKSPACE6
,
662 NULL
, getKeybind
, setKeyGrab
664 {"Workspace7Key", "None", (void*)WKBD_WORKSPACE7
,
665 NULL
, getKeybind
, setKeyGrab
667 {"Workspace8Key", "None", (void*)WKBD_WORKSPACE8
,
668 NULL
, getKeybind
, setKeyGrab
670 {"Workspace9Key", "None", (void*)WKBD_WORKSPACE9
,
671 NULL
, getKeybind
, setKeyGrab
673 {"Workspace10Key", "None", (void*)WKBD_WORKSPACE10
,
674 NULL
, getKeybind
, setKeyGrab
676 {"WindowShortcut1Key","None", (void*)WKBD_WINDOW1
,
677 NULL
, getKeybind
, setKeyGrab
679 {"WindowShortcut2Key","None", (void*)WKBD_WINDOW2
,
680 NULL
, getKeybind
, setKeyGrab
682 {"WindowShortcut3Key","None", (void*)WKBD_WINDOW3
,
683 NULL
, getKeybind
, setKeyGrab
685 {"WindowShortcut4Key","None", (void*)WKBD_WINDOW4
,
686 NULL
, getKeybind
, setKeyGrab
688 #ifdef EXTEND_WINDOWSHORTCUT
689 ,{"WindowShortcut5Key","None", (void*)WKBD_WINDOW5
,
690 NULL
, getKeybind
, setKeyGrab
692 {"WindowShortcut6Key","None", (void*)WKBD_WINDOW6
,
693 NULL
, getKeybind
, setKeyGrab
695 {"WindowShortcut7Key","None", (void*)WKBD_WINDOW7
,
696 NULL
, getKeybind
, setKeyGrab
698 {"WindowShortcut8Key","None", (void*)WKBD_WINDOW8
,
699 NULL
, getKeybind
, setKeyGrab
701 {"WindowShortcut9Key","None", (void*)WKBD_WINDOW9
,
702 NULL
, getKeybind
, setKeyGrab
704 {"WindowShortcut10Key","None", (void*)WKBD_WINDOW10
,
705 NULL
, getKeybind
, setKeyGrab
707 #endif /* EXTEND_WINDOWSHORTCUT */
709 #ifdef KEEP_XKB_LOCK_STATUS
710 ,{"ToggleKbdModeKey", "None", (void*)WKBD_TOGGLE
,
711 NULL
, getKeybind
, setKeyGrab
713 {"KbdModeLock", "NO", NULL
,
714 &wPreferences
.modelock
, getBool
, NULL
716 #endif /* KEEP_XKB_LOCK_STATUS */
717 #ifdef TITLE_TEXT_SHADOW
718 ,{"FShadowColor", "black", (void*)WS_SFOCUSED
,
719 NULL
, getColor
, setWTitleColor
721 {"PShadowColor", "black", (void*)WS_SPFOCUSED
,
722 NULL
, getColor
, setWTitleColor
724 {"UShadowColor", "grey50", (void*)WS_SUNFOCUSED
,
725 NULL
, getColor
, setWTitleColor
727 {"MShadowColor", "black", (void*)WS_SMENU
,
728 NULL
, getColor
, setMenuTitleColor
730 {"Shadow", "Yes", NULL
,
731 &wPreferences
.title_shadow
, getBool
, setJustify
733 #endif /* TITLE_TEXT_SHADOW */
738 static void rereadDefaults(void);
745 /* must defer the update because accessing X data from a
746 * signal handler can mess up Xlib */
755 WDefaultEntry
*entry
;
757 PLSetStringCmpHook(StringCompareHook
);
759 for (i
=0; i
<sizeof(optionList
)/sizeof(WDefaultEntry
); i
++) {
760 entry
= &optionList
[i
];
762 entry
->plkey
= PLMakeString(entry
->key
);
763 if (entry
->default_value
)
764 entry
->plvalue
= PLGetProplistWithDescription(entry
->default_value
);
766 entry
->plvalue
= NULL
;
769 for (i
=0; i
<sizeof(staticOptionList
)/sizeof(WDefaultEntry
); i
++) {
770 entry
= &staticOptionList
[i
];
772 entry
->plkey
= PLMakeString(entry
->key
);
773 if (entry
->default_value
)
774 entry
->plvalue
= PLGetProplistWithDescription(entry
->default_value
);
776 entry
->plvalue
= NULL
;
780 wDomainName = PLMakeString(WMDOMAIN_NAME);
781 wAttributeDomainName = PLMakeString(WMATTRIBUTE_DOMAIN_NAME);
783 PLRegister(wDomainName, rereadDefaults);
784 PLRegister(wAttributeDomainName, rereadDefaults);
793 wDefaultsInit(int screen_number
)
795 static int defaults_inited
= 0;
798 if (!defaults_inited
) {
802 dict
= PLGetDomain(wDomainName
);
804 wwarning(_("could not read domain \"%s\" from defaults database"),
805 PLGetString(wDomainName
));
814 wDefaultsDestroyDomain(WDDomain
*domain
)
816 if (domain
->dictionary
)
817 PLRelease(domain
->dictionary
);
824 wDefaultsInitDomain(char *domain
, Bool requireDictionary
)
828 static int inited
= 0;
831 proplist_t shared_dict
=NULL
;
838 db
= wmalloc(sizeof(WDDomain
));
839 memset(db
, 0, sizeof(WDDomain
));
840 db
->domain_name
= domain
;
841 db
->path
= wdefaultspathfordomain(domain
);
844 if (the_path
&& stat(the_path
, &stbuf
)>=0) {
845 db
->dictionary
= ReadProplistFromFile(the_path
);
846 if (db
->dictionary
) {
847 if (requireDictionary
&& !PLIsDictionary(db
->dictionary
)) {
848 PLRelease(db
->dictionary
);
849 db
->dictionary
= NULL
;
850 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
853 db
->timestamp
= stbuf
.st_mtime
;
855 wwarning(_("could not load domain %s from user defaults database"),
860 /* global system dictionary */
861 sprintf(path
, "%s/%s", SYSCONFDIR
, domain
);
862 if (stat(path
, &stbuf
)>=0) {
863 shared_dict
= ReadProplistFromFile(path
);
865 if (requireDictionary
&& !PLIsDictionary(shared_dict
)) {
866 wwarning(_("Domain %s (%s) of global defaults database is corrupted!"),
868 PLRelease(shared_dict
);
871 if (db
->dictionary
&& PLIsDictionary(shared_dict
) &&
872 PLIsDictionary(db
->dictionary
)) {
873 PLMergeDictionaries(shared_dict
, db
->dictionary
);
874 PLRelease(db
->dictionary
);
875 db
->dictionary
= shared_dict
;
876 if (stbuf
.st_mtime
> db
->timestamp
)
877 db
->timestamp
= stbuf
.st_mtime
;
878 } else if (!db
->dictionary
) {
879 db
->dictionary
= shared_dict
;
880 if (stbuf
.st_mtime
> db
->timestamp
)
881 db
->timestamp
= stbuf
.st_mtime
;
885 wwarning(_("could not load domain %s from global defaults database"),
890 /* set to save it in user's directory, no matter from where it was read */
891 if (db
->dictionary
) {
892 proplist_t tmp
= PLMakeString(db
->path
);
894 PLSetFilename(db
->dictionary
, tmp
);
903 wReadStaticDefaults(proplist_t dict
)
906 WDefaultEntry
*entry
;
911 for (i
=0; i
<sizeof(staticOptionList
)/sizeof(WDefaultEntry
); i
++) {
912 entry
= &staticOptionList
[i
];
915 plvalue
= PLGetDictionaryEntry(dict
, entry
->plkey
);
920 /* no default in the DB. Use builtin default */
921 plvalue
= entry
->plvalue
;
926 (*entry
->convert
)(NULL
, entry
, plvalue
, entry
->addr
, &tdata
);
928 (*entry
->update
)(NULL
, entry
, tdata
, entry
->extra_data
);
936 wDefaultsCheckDomains(void *foo
)
945 puts("Checking domains...");
947 if (stat(WDWindowMaker
->path
, &stbuf
)>=0
948 && WDWindowMaker
->timestamp
< stbuf
.st_mtime
) {
949 proplist_t shared_dict
= NULL
;
951 puts("Checking WindowMaker domain");
953 WDWindowMaker
->timestamp
= stbuf
.st_mtime
;
955 /* global dictionary */
956 sprintf(path
, "%s/WindowMaker", SYSCONFDIR
);
957 if (stat(path
, &stbuf
)>=0) {
958 shared_dict
= ReadProplistFromFile(path
);
959 if (shared_dict
&& !PLIsDictionary(shared_dict
)) {
960 wwarning(_("Domain %s (%s) of global defaults database is corrupted!"),
961 "WindowMaker", path
);
962 PLRelease(shared_dict
);
964 } else if (!shared_dict
) {
965 wwarning(_("could not load domain %s from global defaults database"),
969 /* user dictionary */
970 dict
= ReadProplistFromFile(WDWindowMaker
->path
);
972 if (!PLIsDictionary(dict
)) {
975 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
976 "WindowMaker", WDWindowMaker
->path
);
979 PLSetFilename(shared_dict
, PLGetFilename(dict
));
980 PLMergeDictionaries(shared_dict
, dict
);
985 for (i
=0; i
<wScreenCount
; i
++) {
986 scr
= wScreenWithNumber(i
);
988 wReadDefaults(scr
, dict
);
990 if (WDWindowMaker
->dictionary
) {
991 PLRelease(WDWindowMaker
->dictionary
);
993 WDWindowMaker
->dictionary
= dict
;
996 wwarning(_("could not load domain %s from user defaults database"),
1000 PLRelease(shared_dict
);
1004 if (stat(WDWindowAttributes
->path
, &stbuf
)>=0
1005 && WDWindowAttributes
->timestamp
< stbuf
.st_mtime
) {
1007 puts("Checking WMWindowAttributes domain");
1009 dict
= ReadProplistFromFile(WDWindowAttributes
->path
);
1011 if (!PLIsDictionary(dict
)) {
1014 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
1015 "WMWindowAttributes", WDWindowAttributes
->path
);
1017 if (WDWindowAttributes
->dictionary
)
1018 PLRelease(WDWindowAttributes
->dictionary
);
1019 WDWindowAttributes
->dictionary
= dict
;
1020 for (i
=0; i
<wScreenCount
; i
++) {
1021 scr
= wScreenWithNumber(i
);
1023 wDefaultUpdateIcons(scr
);
1027 wwarning(_("could not load domain %s from user defaults database"),
1028 "WMWindowAttributes");
1030 WDWindowAttributes
->timestamp
= stbuf
.st_mtime
;
1034 if (stat(WDRootMenu
->path
, &stbuf
)>=0
1035 && WDRootMenu
->timestamp
< stbuf
.st_mtime
) {
1036 dict
= ReadProplistFromFile(WDRootMenu
->path
);
1038 puts("Checking WMRootMenu domain");
1041 if (!PLIsArray(dict
) && !PLIsString(dict
)) {
1044 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
1045 "WMRootMenu", WDRootMenu
->path
);
1047 if (WDRootMenu
->dictionary
) {
1048 PLRelease(WDRootMenu
->dictionary
);
1050 WDRootMenu
->dictionary
= dict
;
1053 wwarning(_("could not load domain %s from user defaults database"),
1056 WDRootMenu
->timestamp
= stbuf
.st_mtime
;
1061 WMAddTimerHandler(DEFAULTS_CHECK_INTERVAL
, wDefaultsCheckDomains
, foo
);
1066 wReadDefaults(WScreen
*scr
, proplist_t new_dict
)
1068 proplist_t plvalue
, old_value
;
1069 WDefaultEntry
*entry
;
1073 proplist_t old_dict
= (WDWindowMaker
->dictionary
!=new_dict
1074 ? WDWindowMaker
->dictionary
: NULL
);
1080 for (i
=0; i
<sizeof(optionList
)/sizeof(WDefaultEntry
); i
++) {
1081 entry
= &optionList
[i
];
1084 plvalue
= PLGetDictionaryEntry(new_dict
, entry
->plkey
);
1091 old_value
= PLGetDictionaryEntry(old_dict
, entry
->plkey
);
1094 if (!plvalue
&& !old_value
) {
1095 /* no default in the DB. Use builtin default */
1096 plvalue
= entry
->plvalue
;
1097 if (plvalue
&& new_dict
) {
1098 PLInsertDictionaryEntry(new_dict
, entry
->plkey
, plvalue
);
1101 } else if (!plvalue
) {
1102 /* value was deleted from DB. Keep current value */
1104 } else if (!old_value
) {
1105 /* set value for the 1st time */
1106 } else if (!PLIsEqual(plvalue
, old_value
)) {
1107 /* value has changed */
1109 /* value was not changed since last time */
1115 printf("Updating %s to %s\n", entry
->key
, PLGetDescription(plvalue
));
1118 if ((*entry
->convert
)(scr
, entry
, plvalue
, entry
->addr
, &tdata
)) {
1119 if (entry
->update
) {
1121 (*entry
->update
)(scr
, entry
, tdata
, entry
->extra_data
);
1127 if (needs_refresh
!=0 && !scr
->flags
.startup
) {
1131 if (needs_refresh
& REFRESH_MENU_TITLE_TEXTURE
)
1132 foo
|= WTextureSettings
;
1133 if (needs_refresh
& REFRESH_MENU_TITLE_FONT
)
1134 foo
|= WFontSettings
;
1135 if (needs_refresh
& REFRESH_MENU_TITLE_COLOR
)
1136 foo
|= WColorSettings
;
1138 WMPostNotificationName(WNMenuTitleAppearanceSettingsChanged
, NULL
,
1142 if (needs_refresh
& REFRESH_MENU_TEXTURE
)
1143 foo
|= WTextureSettings
;
1144 if (needs_refresh
& REFRESH_MENU_FONT
)
1145 foo
|= WFontSettings
;
1146 if (needs_refresh
& REFRESH_MENU_COLOR
)
1147 foo
|= WColorSettings
;
1149 WMPostNotificationName(WNMenuAppearanceSettingsChanged
, NULL
,
1153 if (needs_refresh
& REFRESH_WINDOW_FONT
) {
1154 foo
|= WFontSettings
;
1156 if (needs_refresh
& REFRESH_WINDOW_TEXTURES
) {
1157 foo
|= WTextureSettings
;
1159 if (needs_refresh
& REFRESH_WINDOW_TITLE_COLOR
) {
1160 foo
|= WColorSettings
;
1163 WMPostNotificationName(WNWindowAppearanceSettingsChanged
, NULL
,
1166 if (!(needs_refresh
& REFRESH_ICON_TILE
)) {
1168 if (needs_refresh
& REFRESH_ICON_FONT
) {
1169 foo
|= WFontSettings
;
1171 if (needs_refresh
& REFRESH_ICON_TITLE_COLOR
) {
1172 foo
|= WTextureSettings
;
1174 if (needs_refresh
& REFRESH_ICON_TITLE_BACK
) {
1175 foo
|= WTextureSettings
;
1178 WMPostNotificationName(WNIconAppearanceSettingsChanged
, NULL
,
1181 if (needs_refresh
& REFRESH_ICON_TILE
)
1182 WMPostNotificationName(WNIconTileSettingsChanged
, NULL
, NULL
);
1188 wDefaultUpdateIcons(WScreen
*scr
)
1190 WAppIcon
*aicon
= scr
->app_icon_list
;
1191 WWindow
*wwin
= scr
->focused_window
;
1195 file
= wDefaultGetIconFile(scr
, aicon
->wm_instance
, aicon
->wm_class
,
1197 if ((file
&& aicon
->icon
->file
&& strcmp(file
, aicon
->icon
->file
)!=0)
1198 || (file
&& !aicon
->icon
->file
)) {
1201 if (aicon
->icon
->file
)
1202 free(aicon
->icon
->file
);
1203 aicon
->icon
->file
= wstrdup(file
);
1205 new_image
= wDefaultGetImage(scr
, aicon
->wm_instance
,
1208 wIconChangeImage(aicon
->icon
, new_image
);
1209 wAppIconPaint(aicon
);
1212 aicon
= aicon
->next
;
1215 if (!wPreferences
.flags
.noclip
)
1216 wClipIconPaint(scr
->clip_icon
);
1219 if (wwin
->icon
&& wwin
->flags
.miniaturized
) {
1220 file
= wDefaultGetIconFile(scr
, wwin
->wm_instance
, wwin
->wm_class
,
1222 if ((file
&& wwin
->icon
->file
&& strcmp(file
, wwin
->icon
->file
)!=0)
1223 || (file
&& !wwin
->icon
->file
)) {
1226 if (wwin
->icon
->file
)
1227 free(wwin
->icon
->file
);
1228 wwin
->icon
->file
= wstrdup(file
);
1230 new_image
= wDefaultGetImage(scr
, wwin
->wm_instance
,
1233 wIconChangeImage(wwin
->icon
, new_image
);
1241 /* --------------------------- Local ----------------------- */
1243 #define STRINGP(x) if (!PLIsString(value)) { \
1244 wwarning(_("Wrong option format for key \"%s\". Should be %s."), \
1251 string2index(proplist_t key
, proplist_t val
, proplist_t def
,
1252 WOptionEnumeration
*values
)
1255 WOptionEnumeration
*v
;
1256 char buffer
[TOTAL_VALUES_LENGTH
];
1258 if (PLIsString(val
) && (str
= PLGetString(val
))) {
1259 for (v
=values
; v
->string
!=NULL
; v
++) {
1260 if (strcasecmp(v
->string
, str
)==0)
1266 for (v
=values
; v
->string
!=NULL
; v
++) {
1269 strcat(buffer
, ", ");
1270 strcat(buffer
, v
->string
);
1273 wwarning(_("wrong option value for key \"%s\". Should be one of %s"),
1274 PLGetString(key
), buffer
);
1277 return string2index(key
, val
, NULL
, values
);
1287 * value - is the value in the defaults DB
1288 * addr - is the address to store the data
1289 * ret - is the address to store a pointer to a temporary buffer. ret
1290 * must not be freed and is used by the set functions
1293 getBool(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
1302 val
= PLGetString(value
);
1305 if ((val
[1]=='\0' && (val
[0]=='y' || val
[0]=='Y'))
1306 || strcasecmp(val
, "YES")==0) {
1309 } else if ((val
[1]=='\0' && (val
[0]=='n' || val
[0]=='N'))
1310 || strcasecmp(val
, "NO")==0) {
1314 if (sscanf(val
, "%i", &i
)==1) {
1320 wwarning(_("can't convert \"%s\" to boolean for key \"%s\""),
1322 if (second_pass
==0) {
1323 val
= PLGetString(entry
->plvalue
);
1325 wwarning(_("using default \"%s\" instead"), val
);
1336 *(char*)addr
= data
;
1344 getInt(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
1353 val
= PLGetString(value
);
1355 if (sscanf(val
, "%i", &data
)!=1) {
1356 wwarning(_("can't convert \"%s\" to integer for key \"%s\""),
1358 val
= PLGetString(entry
->plvalue
);
1359 wwarning(_("using default \"%s\" instead"), val
);
1360 if (sscanf(val
, "%i", &data
)!=1) {
1376 getCoord(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
1380 char *val_x
, *val_y
;
1381 int nelem
, changed
=0;
1382 proplist_t elem_x
, elem_y
;
1385 if (!PLIsArray(value
)) {
1386 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1387 entry
->key
, "Coordinate");
1389 value
= entry
->plvalue
;
1391 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1397 nelem
= PLGetNumberOfElements(value
);
1399 wwarning(_("Incorrect number of elements in array for key \"%s\"."),
1402 value
= entry
->plvalue
;
1404 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1410 elem_x
= PLGetArrayElement(value
, 0);
1411 elem_y
= PLGetArrayElement(value
, 1);
1413 if (!elem_x
|| !elem_y
|| !PLIsString(elem_x
) || !PLIsString(elem_y
)) {
1414 wwarning(_("Wrong value for key \"%s\". Should be Coordinate."),
1417 value
= entry
->plvalue
;
1419 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1425 val_x
= PLGetString(elem_x
);
1426 val_y
= PLGetString(elem_y
);
1428 if (sscanf(val_x
, "%i", &data
.x
)!=1 || sscanf(val_y
, "%i", &data
.y
)!=1) {
1429 wwarning(_("can't convert array to integers for \"%s\"."), entry
->key
);
1431 value
= entry
->plvalue
;
1433 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1441 else if (data
.x
> scr
->scr_width
/3)
1442 data
.x
= scr
->scr_width
/3;
1445 else if (data
.y
> scr
->scr_height
/3)
1446 data
.y
= scr
->scr_height
/3;
1452 *(WCoord
*)addr
= data
;
1460 /* This function is not used at the moment. */
1462 getString(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
1469 data
= PLGetString(value
);
1472 data
= PLGetString(entry
->plvalue
);
1481 *(char**)addr
= wstrdup(data
);
1489 getPathList(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
1499 if (!PLIsArray(value
)) {
1500 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1501 entry
->key
, "an array of paths");
1503 value
= entry
->plvalue
;
1505 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1512 count
= PLGetNumberOfElements(value
);
1515 value
= entry
->plvalue
;
1517 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1524 for (i
=0; i
<count
; i
++) {
1525 d
= PLGetArrayElement(value
, i
);
1526 if (!d
|| !PLIsString(d
)) {
1530 len
+= strlen(PLGetString(d
))+1;
1533 ptr
= data
= wmalloc(len
+1);
1535 for (i
=0; i
<count
; i
++) {
1536 d
= PLGetArrayElement(value
, i
);
1537 if (!d
|| !PLIsString(d
)) {
1540 strcpy(ptr
, PLGetString(d
));
1541 ptr
+= strlen(PLGetString(d
));
1545 ptr
--; *(ptr
--) = 0;
1547 if (*(char**)addr
!=NULL
) {
1548 free(*(char**)addr
);
1550 *(char**)addr
= data
;
1557 getEnum(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
1560 static signed char data
;
1562 data
= string2index(entry
->plkey
, value
, entry
->default_value
,
1563 (WOptionEnumeration
*)entry
->extra_data
);
1571 *(signed char*)addr
= data
;
1580 * (hgradient <color> <color>)
1581 * (vgradient <color> <color>)
1582 * (dgradient <color> <color>)
1583 * (mhgradient <color> <color> ...)
1584 * (mvgradient <color> <color> ...)
1585 * (tpixmap <file> <color>)
1586 * (spixmap <file> <color>)
1587 * (cpixmap <file> <color>)
1588 * (thgradient <file> <opaqueness> <color> <color>)
1589 * (tvgradient <file> <opaqueness> <color> <color>)
1590 * (tdgradient <file> <opaqueness> <color> <color>)
1591 * (function <lib> <function> ...)
1595 parse_texture(WScreen
*scr
, proplist_t pl
)
1600 WTexture
*texture
=NULL
;
1602 nelem
= PLGetNumberOfElements(pl
);
1607 elem
= PLGetArrayElement(pl
, 0);
1608 if (!elem
|| !PLIsString(elem
))
1610 val
= PLGetString(elem
);
1613 if (strcasecmp(val
, "solid")==0) {
1621 elem
= PLGetArrayElement(pl
, 1);
1622 if (!elem
|| !PLIsString(elem
))
1624 val
= PLGetString(elem
);
1626 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &color
)) {
1627 wwarning(_("\"%s\" is not a valid color name"), val
);
1631 texture
= (WTexture
*)wTextureMakeSolid(scr
, &color
);
1632 } else if (strcasecmp(val
, "dgradient")==0
1633 || strcasecmp(val
, "vgradient")==0
1634 || strcasecmp(val
, "hgradient")==0) {
1635 RColor color1
, color2
;
1640 wwarning(_("bad number of arguments in gradient specification"));
1644 if (val
[0]=='d' || val
[0]=='D')
1645 type
= WTEX_DGRADIENT
;
1646 else if (val
[0]=='h' || val
[0]=='H')
1647 type
= WTEX_HGRADIENT
;
1649 type
= WTEX_VGRADIENT
;
1652 /* get from color */
1653 elem
= PLGetArrayElement(pl
, 1);
1654 if (!elem
|| !PLIsString(elem
))
1656 val
= PLGetString(elem
);
1658 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1659 wwarning(_("\"%s\" is not a valid color name"), val
);
1663 color1
.red
= xcolor
.red
>> 8;
1664 color1
.green
= xcolor
.green
>> 8;
1665 color1
.blue
= xcolor
.blue
>> 8;
1668 elem
= PLGetArrayElement(pl
, 2);
1669 if (!elem
|| !PLIsString(elem
)) {
1672 val
= PLGetString(elem
);
1674 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1675 wwarning(_("\"%s\" is not a valid color name"), val
);
1679 color2
.red
= xcolor
.red
>> 8;
1680 color2
.green
= xcolor
.green
>> 8;
1681 color2
.blue
= xcolor
.blue
>> 8;
1683 texture
= (WTexture
*)wTextureMakeGradient(scr
, type
, &color1
, &color2
);
1685 } else if (strcasecmp(val
, "mhgradient")==0
1686 || strcasecmp(val
, "mvgradient")==0
1687 || strcasecmp(val
, "mdgradient")==0) {
1694 wwarning(_("too few arguments in multicolor gradient specification"));
1698 if (val
[1]=='h' || val
[1]=='H')
1699 type
= WTEX_MHGRADIENT
;
1700 else if (val
[1]=='v' || val
[1]=='V')
1701 type
= WTEX_MVGRADIENT
;
1703 type
= WTEX_MDGRADIENT
;
1707 colors
= wmalloc(sizeof(RColor
*)*(count
+1));
1709 for (i
=0; i
<count
; i
++) {
1710 elem
= PLGetArrayElement(pl
, i
+1);
1711 if (!elem
|| !PLIsString(elem
)) {
1712 for (--i
; i
>=0; --i
) {
1718 val
= PLGetString(elem
);
1720 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &color
)) {
1721 wwarning(_("\"%s\" is not a valid color name"), val
);
1722 for (--i
; i
>=0; --i
) {
1728 colors
[i
] = wmalloc(sizeof(RColor
));
1729 colors
[i
]->red
= color
.red
>> 8;
1730 colors
[i
]->green
= color
.green
>> 8;
1731 colors
[i
]->blue
= color
.blue
>> 8;
1736 texture
= (WTexture
*)wTextureMakeMGradient(scr
, type
, colors
);
1737 } else if (strcasecmp(val
, "spixmap")==0 ||
1738 strcasecmp(val
, "cpixmap")==0 ||
1739 strcasecmp(val
, "tpixmap")==0) {
1746 if (val
[0] == 's' || val
[0] == 'S')
1748 else if (val
[0] == 'c' || val
[0] == 'C')
1754 elem
= PLGetArrayElement(pl
, 2);
1755 if (!elem
|| !PLIsString(elem
)) {
1758 val
= PLGetString(elem
);
1760 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &color
)) {
1761 wwarning(_("\"%s\" is not a valid color name"), val
);
1766 elem
= PLGetArrayElement(pl
, 1);
1767 if (!elem
|| !PLIsString(elem
))
1769 val
= PLGetString(elem
);
1771 texture
= (WTexture
*)wTextureMakePixmap(scr
, type
, val
, &color
);
1772 } else if (strcasecmp(val
, "thgradient")==0
1773 || strcasecmp(val
, "tvgradient")==0
1774 || strcasecmp(val
, "tdgradient")==0) {
1775 RColor color1
, color2
;
1780 if (val
[1]=='h' || val
[1]=='H')
1781 style
= WTEX_THGRADIENT
;
1782 else if (val
[1]=='v' || val
[1]=='V')
1783 style
= WTEX_TVGRADIENT
;
1785 style
= WTEX_TDGRADIENT
;
1788 wwarning(_("bad number of arguments in textured gradient specification"));
1792 /* get from color */
1793 elem
= PLGetArrayElement(pl
, 3);
1794 if (!elem
|| !PLIsString(elem
))
1796 val
= PLGetString(elem
);
1798 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1799 wwarning(_("\"%s\" is not a valid color name"), val
);
1803 color1
.red
= xcolor
.red
>> 8;
1804 color1
.green
= xcolor
.green
>> 8;
1805 color1
.blue
= xcolor
.blue
>> 8;
1808 elem
= PLGetArrayElement(pl
, 4);
1809 if (!elem
|| !PLIsString(elem
)) {
1812 val
= PLGetString(elem
);
1814 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1815 wwarning(_("\"%s\" is not a valid color name"), val
);
1819 color2
.red
= xcolor
.red
>> 8;
1820 color2
.green
= xcolor
.green
>> 8;
1821 color2
.blue
= xcolor
.blue
>> 8;
1824 elem
= PLGetArrayElement(pl
, 2);
1825 if (!elem
|| !PLIsString(elem
))
1828 val
= PLGetString(elem
);
1830 if (!val
|| (opacity
= atoi(val
)) < 0 || opacity
> 255) {
1831 wwarning(_("bad opacity value for tgradient texture \"%s\". Should be [0..255]"), val
);
1836 elem
= PLGetArrayElement(pl
, 1);
1837 if (!elem
|| !PLIsString(elem
))
1839 val
= PLGetString(elem
);
1841 texture
= (WTexture
*)wTextureMakeTGradient(scr
, style
, &color1
, &color2
,
1844 #ifdef TEXTURE_PLUGIN
1845 else if (strcasecmp(val
, "function")==0) {
1846 WTexFunction
*function
;
1847 void (*initFunc
) (Display
*, Colormap
);
1848 char *lib
, *func
, **argv
;
1854 /* get the library name */
1855 elem
= PLGetArrayElement(pl
, 1);
1856 if (!elem
|| !PLIsString(elem
)) {
1859 lib
= PLGetString(elem
);
1861 /* get the function name */
1862 elem
= PLGetArrayElement(pl
, 2);
1863 if (!elem
|| !PLIsString(elem
)) {
1866 func
= PLGetString(elem
);
1869 argv
= (char **)wmalloc(argc
* sizeof(char *));
1871 /* get the parameters */
1872 argv
[0] = wstrdup(func
);
1873 for (i
= 0; i
< argc
- 1; i
++) {
1874 elem
= PLGetArrayElement(pl
, 3 + i
);
1875 if (!elem
|| !PLIsString(elem
)) {
1880 argv
[i
+1] = wstrdup(PLGetString(elem
));
1883 function
= wTextureMakeFunction(scr
, lib
, func
, argc
, argv
);
1887 initFunc
= dlsym(function
->handle
, "initWindowMaker");
1889 initFunc(dpy
, scr
->w_colormap
);
1891 wwarning(_("could not initialize library %s"), lib
);
1894 wwarning(_("could not find function %s::%s"), lib
, func
);
1896 #endif /* HAVE_DLFCN_H */
1897 texture
= (WTexture
*)function
;
1899 #endif /* TEXTURE_PLUGIN */
1901 wwarning(_("invalid texture type %s"), val
);
1910 getTexture(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
1913 static WTexture
*texture
;
1917 if (!PLIsArray(value
)) {
1918 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1919 entry
->key
, "Texture");
1921 value
= entry
->plvalue
;
1923 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1929 if (strcmp(entry
->key
, "WidgetColor")==0 && !changed
) {
1932 pl
= PLGetArrayElement(value
, 0);
1933 if (!pl
|| !PLIsString(pl
) || !PLGetString(pl
)
1934 || strcasecmp(PLGetString(pl
), "solid")!=0) {
1935 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1936 entry
->key
, "Solid Texture");
1938 value
= entry
->plvalue
;
1940 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1945 texture
= parse_texture(scr
, value
);
1948 wwarning(_("Error in texture specification for key \"%s\""),
1951 value
= entry
->plvalue
;
1953 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1963 *(WTexture
**)addr
= texture
;
1971 getWSBackground(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
,
1972 void *addr
, void **ret
)
1980 if (!PLIsArray(value
)) {
1981 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1982 "WorkspaceBack", "Texture or None");
1984 value
= entry
->plvalue
;
1986 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1992 /* only do basic error checking and verify for None texture */
1994 nelem
= PLGetNumberOfElements(value
);
1996 elem
= PLGetArrayElement(value
, 0);
1997 if (!elem
|| !PLIsString(elem
)) {
1998 wwarning(_("Wrong type for workspace background. Should be a texture type."));
2000 value
= entry
->plvalue
;
2002 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
2007 val
= PLGetString(elem
);
2009 if (strcasecmp(val
, "None")==0)
2012 *ret
= PLRetain(value
);
2019 getWSSpecificBackground(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
,
2020 void *addr
, void **ret
)
2027 if (!PLIsArray(value
)) {
2028 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
2029 "WorkspaceSpecificBack", "an array of textures");
2031 value
= entry
->plvalue
;
2033 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
2039 /* only do basic error checking and verify for None texture */
2041 nelem
= PLGetNumberOfElements(value
);
2044 elem
= PLGetArrayElement(value
, nelem
);
2045 if (!elem
|| !PLIsArray(elem
)) {
2046 wwarning(_("Wrong type for background of workspace %i. Should be a texture."),
2052 *ret
= PLRetain(value
);
2056 * Kluge to force wmsetbg helper to set the default background.
2057 * If the WorkspaceSpecificBack is changed once wmaker has started,
2058 * the WorkspaceBack won't be sent to the helper, unless the user
2059 * changes it's value too. So, we must force this by removing the
2060 * value from the defaults DB.
2062 if (!scr
->flags
.backimage_helper_launched
&& !scr
->flags
.startup
) {
2063 proplist_t key
= PLMakeString("WorkspaceBack");
2065 PLRemoveDictionaryEntry(WDWindowMaker
->dictionary
, key
);
2075 getFont(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
2083 val
= PLGetString(value
);
2085 font
= wLoadFont(val
);
2087 wfatal(_("could not load any usable font!!!"));
2094 /* can't assign font value outside update function */
2095 wassertrv(addr
== NULL
, True
);
2102 getColor(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
2105 static unsigned long pixel
;
2112 val
= PLGetString(value
);
2115 if (!wGetColor(scr
, val
, &color
)) {
2116 wwarning(_("could not get color for key \"%s\""),
2118 if (second_pass
==0) {
2119 val
= PLGetString(entry
->plvalue
);
2121 wwarning(_("using default \"%s\" instead"), val
);
2127 pixel
= color
.pixel
;
2133 *(unsigned long*)addr
= pixel
;
2141 getKeybind(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
2144 static WShortKey shortcut
;
2151 STRINGP("Key spec");
2153 val
= PLGetString(value
);
2155 if (!val
|| strcasecmp(val
, "NONE")==0) {
2156 shortcut
.keycode
= 0;
2157 shortcut
.modifier
= 0;
2168 shortcut
.modifier
= 0;
2169 while ((k
= strchr(b
, '+'))!=NULL
) {
2173 mod
= wXModifierFromKey(b
);
2175 wwarning(_("%s:invalid key modifier \"%s\""), entry
->key
, b
);
2178 shortcut
.modifier
|= mod
;
2184 ksym
= XStringToKeysym(b
);
2186 if (ksym
==NoSymbol
) {
2187 wwarning(_("%s:invalid kbd shortcut specification \"%s\""), entry
->key
,
2192 shortcut
.keycode
= XKeysymToKeycode(dpy
, ksym
);
2193 if (shortcut
.keycode
==0) {
2194 wwarning(_("%s:invalid key in shortcut \"%s\""), entry
->key
, val
);
2206 getModMask(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
2209 static unsigned int mask
;
2212 STRINGP("Modifier Key");
2214 str
= PLGetString(value
);
2218 mask
= wXModifierFromKey(str
);
2220 wwarning(_("%s: modifier key %s is not valid"), entry
->key
, str
);
2226 *(unsigned int*)addr
= mask
;
2237 getRImages(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
,
2238 void *addr
, void **ret
)
2246 STRINGP("Image File Path");
2248 str
= PLGetString(value
);
2252 image
= RLoadImage(scr
->rcontext
, str
, 0);
2254 wwarning(_("could not load image in option %s: %s"), entry
->key
,
2255 RMessageForError(RErrorCode
));
2259 if (*(RImage
**)addr
) {
2260 RDestroyImage(*(RImage
**)addr
);
2263 *(RImage
**)addr
= image
;
2265 assert(ret
== NULL
);
2268 *(RImage**)ret = image;
2276 /* ---------------- value setting functions --------------- */
2278 setJustify(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
2280 return REFRESH_FORE_COLOR
;
2285 setIfDockPresent(WScreen
*scr
, WDefaultEntry
*entry
, int *flag
, long which
)
2289 wPreferences
.flags
.nodock
= wPreferences
.flags
.nodock
|| *flag
;
2292 wPreferences
.flags
.noclip
= wPreferences
.flags
.noclip
|| *flag
;
2302 setStickyIcons(WScreen
*scr
, WDefaultEntry
*entry
, void *bar
, void *foo
)
2304 if (scr
->workspaces
) {
2305 wWorkspaceForceChange(scr
, scr
->current_workspace
);
2306 wArrangeIcons(scr
, False
);
2313 setPositive(WScreen
*scr
, WDefaultEntry
*entry
, int *value
, void *foo
)
2325 setIconTile(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
2331 img
= wTextureRenderImage(*texture
, wPreferences
.icon_size
,
2332 wPreferences
.icon_size
,
2333 ((*texture
)->any
.type
& WREL_BORDER_MASK
)
2334 ? WREL_ICON
: WREL_FLAT
);
2336 wwarning(_("could not render texture for icon background"));
2338 wTextureDestroy(scr
, *texture
);
2341 RConvertImage(scr
->rcontext
, img
, &pixmap
);
2343 if (scr
->icon_tile
) {
2345 RDestroyImage(scr
->icon_tile
);
2346 XFreePixmap(dpy
, scr
->icon_tile_pixmap
);
2349 scr
->icon_tile
= img
;
2351 if (!wPreferences
.flags
.noclip
) {
2352 if (scr
->clip_tile
) {
2353 RDestroyImage(scr
->clip_tile
);
2355 scr
->clip_tile
= wClipMakeTile(scr
, img
);
2358 scr
->icon_tile_pixmap
= pixmap
;
2360 if (scr
->def_icon_pixmap
) {
2361 XFreePixmap(dpy
, scr
->def_icon_pixmap
);
2362 scr
->def_icon_pixmap
= None
;
2364 if (scr
->def_ticon_pixmap
) {
2365 XFreePixmap(dpy
, scr
->def_ticon_pixmap
);
2366 scr
->def_ticon_pixmap
= None
;
2369 if (scr
->icon_back_texture
) {
2370 wTextureDestroy(scr
, (WTexture
*)scr
->icon_back_texture
);
2372 scr
->icon_back_texture
= wTextureMakeSolid(scr
, &((*texture
)->any
.color
));
2374 if (scr
->clip_balloon
)
2375 XSetWindowBackground(dpy
, scr
->clip_balloon
,
2376 (*texture
)->any
.color
.pixel
);
2379 * Free the texture as nobody else will use it, nor refer to it.
2382 wTextureDestroy(scr
, *texture
);
2384 return (reset
? REFRESH_ICON_TILE
: 0);
2390 setWinTitleFont(WScreen
*scr
, WDefaultEntry
*entry
, WFont
*font
, void *foo
)
2392 if (scr
->title_font
) {
2393 wFreeFont(scr
->title_font
);
2396 scr
->title_font
= font
;
2399 XSetFont(dpy
, scr
->window_title_gc
, font
->font
->fid
);
2402 return REFRESH_WINDOW_FONT
|REFRESH_BUTTON_IMAGES
;
2407 setMenuTitleFont(WScreen
*scr
, WDefaultEntry
*entry
, WFont
*font
, void *foo
)
2409 if (scr
->menu_title_font
) {
2410 wFreeFont(scr
->menu_title_font
);
2413 scr
->menu_title_font
= font
;
2416 XSetFont(dpy
, scr
->menu_title_gc
, font
->font
->fid
);
2419 return REFRESH_MENU_TITLE_FONT
;
2424 setMenuTextFont(WScreen
*scr
, WDefaultEntry
*entry
, WFont
*font
, void *foo
)
2426 if (scr
->menu_entry_font
) {
2427 wFreeFont(scr
->menu_entry_font
);
2430 scr
->menu_entry_font
= font
;
2433 XSetFont(dpy
, scr
->menu_entry_gc
, font
->font
->fid
);
2434 XSetFont(dpy
, scr
->disabled_menu_entry_gc
, font
->font
->fid
);
2435 XSetFont(dpy
, scr
->select_menu_gc
, font
->font
->fid
);
2438 return REFRESH_MENU_FONT
;
2444 setIconTitleFont(WScreen
*scr
, WDefaultEntry
*entry
, WFont
*font
, void *foo
)
2446 if (scr
->icon_title_font
) {
2447 wFreeFont(scr
->icon_title_font
);
2450 scr
->icon_title_font
= font
;
2453 XSetFont(dpy
, scr
->icon_title_gc
, font
->font
->fid
);
2456 return REFRESH_ICON_FONT
;
2461 setClipTitleFont(WScreen
*scr
, WDefaultEntry
*entry
, WFont
*font
, void *foo
)
2463 if (scr
->clip_title_font
) {
2464 wFreeFont(scr
->clip_title_font
);
2467 scr
->clip_title_font
= font
;
2470 XSetFont(dpy
, scr
->clip_title_gc
, font
->font
->fid
);
2473 return REFRESH_ICON_FONT
;
2478 setDisplayFont(WScreen
*scr
, WDefaultEntry
*entry
, WFont
*font
, void *foo
)
2480 if (scr
->info_text_font
) {
2481 wFreeFont(scr
->info_text_font
);
2484 scr
->info_text_font
= font
;
2487 XSetFont(dpy
, scr
->info_text_gc
, font
->font
->fid
);
2488 XSetFont(dpy
, scr
->line_gc
, font
->font
->fid
);
2491 /* This test works because the scr structure is initially zeroed out
2492 and None = 0. Any other time, the window should be valid. */
2493 if (scr
->geometry_display
!= None
) {
2494 wGetGeometryWindowSize(scr
, &scr
->geometry_display_width
,
2495 &scr
->geometry_display_height
);
2496 XResizeWindow(dpy
, scr
->geometry_display
,
2497 scr
->geometry_display_width
, scr
->geometry_display_height
);
2505 setHightlight(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, void *foo
)
2507 if (scr
->select_pixel
!=scr
->white_pixel
&&
2508 scr
->select_pixel
!=scr
->black_pixel
) {
2509 wFreeColor(scr
, scr
->select_pixel
);
2512 scr
->select_pixel
= color
->pixel
;
2514 return REFRESH_FORE_COLOR
;
2519 setHightlightText(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, void *foo
)
2521 if (scr
->select_text_pixel
!=scr
->white_pixel
&&
2522 scr
->select_text_pixel
!=scr
->black_pixel
) {
2523 wFreeColor(scr
, scr
->select_text_pixel
);
2526 scr
->select_text_pixel
= color
->pixel
;
2528 return REFRESH_FORE_COLOR
;
2533 setClipTitleColor(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, long index
)
2535 if (scr
->clip_title_pixel
[index
]!=scr
->white_pixel
&&
2536 scr
->clip_title_pixel
[index
]!=scr
->black_pixel
) {
2537 wFreeColor(scr
, scr
->clip_title_pixel
[index
]);
2540 scr
->clip_title_pixel
[index
] = color
->pixel
;
2542 return REFRESH_FORE_COLOR
;
2547 setWTitleColor(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, long index
)
2549 if (scr
->window_title_pixel
[index
]!=scr
->white_pixel
&&
2550 scr
->window_title_pixel
[index
]!=scr
->black_pixel
) {
2551 wFreeColor(scr
, scr
->window_title_pixel
[index
]);
2554 scr
->window_title_pixel
[index
] = color
->pixel
;
2556 if (index
== WS_UNFOCUSED
)
2557 XSetForeground(dpy
, scr
->info_text_gc
, color
->pixel
);
2559 return REFRESH_WINDOW_TITLE_COLOR
;
2564 setMenuTitleColor(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, long index
)
2566 #ifdef TITLE_TEXT_SHADOW
2567 if (index
== WS_SMENU
){
2568 if (scr
->menu_title_pixel
[WS_SMENU
]!=scr
->white_pixel
&&
2569 scr
->menu_title_pixel
[WS_SMENU
]!=scr
->black_pixel
) {
2570 wFreeColor(scr
, scr
->menu_title_pixel
[WS_SMENU
]);
2572 scr
->menu_title_pixel
[WS_SMENU
] = color
->pixel
;
2575 if (scr
->menu_title_pixel
[0]!=scr
->white_pixel
&&
2576 scr
->menu_title_pixel
[0]!=scr
->black_pixel
) {
2577 wFreeColor(scr
, scr
->menu_title_pixel
[0]);
2579 scr
->menu_title_pixel
[0] = color
->pixel
;
2581 #else /* !TITLE_TEXT_SHADOW */
2582 if (scr
->menu_title_pixel
[0]!=scr
->white_pixel
&&
2583 scr
->menu_title_pixel
[0]!=scr
->black_pixel
) {
2584 wFreeColor(scr
, scr
->menu_title_pixel
[0]);
2587 scr
->menu_title_pixel
[0] = color
->pixel
;
2588 #endif /* !TITLE_TEXT_SHADOW */
2589 XSetForeground(dpy
, scr
->menu_title_gc
, color
->pixel
);
2591 return REFRESH_MENU_TITLE_COLOR
;
2596 setMenuTextColor(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, void *foo
)
2599 #define gcm (GCForeground|GCBackground|GCFillStyle)
2601 if (scr
->mtext_pixel
!=scr
->white_pixel
&&
2602 scr
->mtext_pixel
!=scr
->black_pixel
) {
2603 wFreeColor(scr
, scr
->mtext_pixel
);
2606 scr
->mtext_pixel
= color
->pixel
;
2608 XSetForeground(dpy
, scr
->menu_entry_gc
, color
->pixel
);
2611 if (scr
->dtext_pixel
== scr
->mtext_pixel
) {
2612 gcv
.foreground
= scr
->white_pixel
;
2613 gcv
.background
= scr
->black_pixel
;
2614 gcv
.fill_style
= FillStippled
;
2616 gcv
.foreground
= scr
->dtext_pixel
;
2617 gcv
.fill_style
= FillSolid
;
2619 XChangeGC(dpy
, scr
->disabled_menu_entry_gc
, gcm
, &gcv
);
2621 return REFRESH_MENU_COLOR
;
2627 setMenuDisabledColor(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, void *foo
)
2630 #define gcm (GCForeground|GCBackground|GCFillStyle)
2632 if (scr
->dtext_pixel
!=scr
->white_pixel
&&
2633 scr
->dtext_pixel
!=scr
->black_pixel
) {
2634 wFreeColor(scr
, scr
->dtext_pixel
);
2637 scr
->dtext_pixel
= color
->pixel
;
2639 if (scr
->dtext_pixel
== scr
->mtext_pixel
) {
2640 gcv
.foreground
= scr
->white_pixel
;
2641 gcv
.background
= scr
->black_pixel
;
2642 gcv
.fill_style
= FillStippled
;
2644 gcv
.foreground
= scr
->dtext_pixel
;
2645 gcv
.fill_style
= FillSolid
;
2647 XChangeGC(dpy
, scr
->disabled_menu_entry_gc
, gcm
, &gcv
);
2649 return REFRESH_FORE_COLOR
;
2654 setIconTitleColor(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, void *foo
)
2656 XSetForeground(dpy
, scr
->icon_title_gc
, color
->pixel
);
2658 return REFRESH_ICON_TITLE_COLOR
;
2663 setIconTitleBack(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, void *foo
)
2665 if (scr
->icon_title_texture
) {
2666 wTextureDestroy(scr
, (WTexture
*)scr
->icon_title_texture
);
2668 XQueryColor (dpy
, scr
->w_colormap
, color
);
2669 scr
->icon_title_texture
= wTextureMakeSolid(scr
, color
);
2671 return REFRESH_ICON_TITLE_BACK
;
2676 trackDeadProcess(pid_t pid
, unsigned char status
, WScreen
*scr
)
2678 close(scr
->helper_fd
);
2680 scr
->helper_pid
= 0;
2681 scr
->flags
.backimage_helper_launched
= 0;
2686 setWorkspaceSpecificBack(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
,
2693 if (scr
->flags
.backimage_helper_launched
) {
2694 if (PLGetNumberOfElements(value
)==0) {
2695 SendHelperMessage(scr
, 'C', 0, NULL
);
2696 SendHelperMessage(scr
, 'K', 0, NULL
);
2705 if (PLGetNumberOfElements(value
) == 0)
2708 if (pipe(filedes
) < 0) {
2709 wsyserror("pipe() failed:can't set workspace specific background image");
2717 wsyserror("fork() failed:can't set workspace specific background image");
2718 if (close(filedes
[0]) < 0)
2719 wsyserror("could not close pipe");
2720 if (close(filedes
[1]) < 0)
2721 wsyserror("could not close pipe");
2723 } else if (pid
== 0) {
2724 SetupEnvironment(scr
);
2727 wsyserror("could not close pipe");
2728 if (dup(filedes
[0]) < 0) {
2729 wsyserror("dup() failed:can't set workspace specific background image");
2731 execlp("wmsetbg", "wmsetbg", "-helper", "-d", NULL
);
2732 wsyserror("could not execute wmsetbg");
2736 if (fcntl(filedes
[0], F_SETFD
, FD_CLOEXEC
) < 0) {
2737 wsyserror("error setting close-on-exec flag");
2739 if (fcntl(filedes
[1], F_SETFD
, FD_CLOEXEC
) < 0) {
2740 wsyserror("error setting close-on-exec flag");
2743 scr
->helper_fd
= filedes
[1];
2744 scr
->helper_pid
= pid
;
2745 scr
->flags
.backimage_helper_launched
= 1;
2747 wAddDeathHandler(pid
, (WDeathHandler
*)trackDeadProcess
, scr
);
2749 SendHelperMessage(scr
, 'P', -1, wPreferences
.pixmap_path
);
2753 for (i
= 0; i
< PLGetNumberOfElements(value
); i
++) {
2754 val
= PLGetArrayElement(value
, i
);
2755 if (val
&& PLIsArray(val
) && PLGetNumberOfElements(val
)>0) {
2756 str
= PLGetDescription(val
);
2758 SendHelperMessage(scr
, 'S', i
+1, str
);
2762 SendHelperMessage(scr
, 'U', i
+1, NULL
);
2773 setWorkspaceBack(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
,
2776 if (scr
->flags
.backimage_helper_launched
) {
2779 if (PLGetNumberOfElements(value
)==0) {
2780 SendHelperMessage(scr
, 'U', 0, NULL
);
2782 /* set the default workspace background to this one */
2783 str
= PLGetDescription(value
);
2785 SendHelperMessage(scr
, 'S', 0, str
);
2787 SendHelperMessage(scr
, 'C', scr
->current_workspace
+1, NULL
);
2789 SendHelperMessage(scr
, 'U', 0, NULL
);
2796 SetupEnvironment(scr
);
2797 text
= PLGetDescription(value
);
2798 command
= wmalloc(strlen(text
)+40);
2799 sprintf(command
, "wmsetbg -d -p '%s' &", text
);
2811 setWidgetColor(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
2813 if (scr
->widget_texture
) {
2814 wTextureDestroy(scr
, (WTexture
*)scr
->widget_texture
);
2816 scr
->widget_texture
= *(WTexSolid
**)texture
;
2823 setFTitleBack(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
2825 if (scr
->window_title_texture
[WS_FOCUSED
]) {
2826 wTextureDestroy(scr
, scr
->window_title_texture
[WS_FOCUSED
]);
2828 scr
->window_title_texture
[WS_FOCUSED
] = *texture
;
2830 return REFRESH_WINDOW_TEXTURES
;
2835 setPTitleBack(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
2837 if (scr
->window_title_texture
[WS_PFOCUSED
]) {
2838 wTextureDestroy(scr
, scr
->window_title_texture
[WS_PFOCUSED
]);
2840 scr
->window_title_texture
[WS_PFOCUSED
] = *texture
;
2842 return REFRESH_WINDOW_TEXTURES
;
2847 setUTitleBack(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
2849 if (scr
->window_title_texture
[WS_UNFOCUSED
]) {
2850 wTextureDestroy(scr
, scr
->window_title_texture
[WS_UNFOCUSED
]);
2852 scr
->window_title_texture
[WS_UNFOCUSED
] = *texture
;
2854 if (scr
->resizebar_texture
[0]) {
2855 wTextureDestroy(scr
, (WTexture
*)scr
->resizebar_texture
[0]);
2857 scr
->resizebar_texture
[0]
2858 = wTextureMakeSolid(scr
, &scr
->window_title_texture
[WS_UNFOCUSED
]->any
.color
);
2860 if (scr
->geometry_display
!= None
)
2861 XSetWindowBackground(dpy
, scr
->geometry_display
,
2862 scr
->resizebar_texture
[0]->normal
.pixel
);
2864 return REFRESH_WINDOW_TEXTURES
;
2869 setMenuTitleBack(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
2871 if (scr
->menu_title_texture
[0]) {
2872 wTextureDestroy(scr
, scr
->menu_title_texture
[0]);
2874 scr
->menu_title_texture
[0] = *texture
;
2876 return REFRESH_MENU_TITLE_TEXTURE
;
2881 setMenuTextBack(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
2883 if (scr
->menu_item_texture
) {
2884 wTextureDestroy(scr
, scr
->menu_item_texture
);
2885 wTextureDestroy(scr
, (WTexture
*)scr
->menu_item_auxtexture
);
2887 scr
->menu_item_texture
= *texture
;
2889 scr
->menu_item_auxtexture
2890 = wTextureMakeSolid(scr
, &scr
->menu_item_texture
->any
.color
);
2892 return REFRESH_MENU_TEXTURE
;
2897 setKeyGrab(WScreen
*scr
, WDefaultEntry
*entry
, WShortKey
*shortcut
, long index
)
2900 wKeyBindings
[index
] = *shortcut
;
2902 wwin
= scr
->focused_window
;
2904 while (wwin
!=NULL
) {
2905 XUngrabKey(dpy
, AnyKey
, AnyModifier
, wwin
->frame
->core
->window
);
2907 if (!WFLAGP(wwin
, no_bind_keys
)) {
2908 wWindowSetKeyGrabs(wwin
);
2918 setIconPosition(WScreen
*scr
, WDefaultEntry
*entry
, void *bar
, void *foo
)
2920 wArrangeIcons(scr
, True
);
2927 updateUsableArea(WScreen
*scr
, WDefaultEntry
*entry
, void *bar
, void *foo
)
2929 wScreenUpdateUsableArea(scr
);
2936 setMenuStyle(WScreen
*scr
, WDefaultEntry
*entry
, int *value
, void *foo
)
2938 return REFRESH_MENU_TEXTURE
;
2944 setButtonImages(WScreen *scr, WDefaultEntry *entry, int *value, void *foo)
2946 return REFRESH_BUTTON_IMAGES;
2952 * Need access to the double click variables, so that all widgets in
2953 * wmaker panels will have the same dbl-click values.
2954 * TODO: figure a better way of dealing with it.
2959 setDoubleClick(WScreen
*scr
, WDefaultEntry
*entry
, int *value
, void *foo
)
2961 extern _WINGsConfiguration WINGsConfiguration
;
2966 WINGsConfiguration
.doubleClickDelay
= *value
;