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 setResizebarBack();
158 static int setWorkspaceBack();
159 static int setWorkspaceSpecificBack();
160 static int setMenuTitleColor();
161 static int setMenuTextColor();
162 static int setMenuDisabledColor();
163 static int setMenuTitleBack();
164 static int setMenuTextBack();
165 static int setHightlight();
166 static int setHightlightText();
167 static int setKeyGrab();
168 static int setDoubleClick();
169 static int setIconPosition();
171 static int setClipTitleFont();
172 static int setClipTitleColor();
174 static int setMenuStyle();
177 static int updateUsableArea();
182 * Tables to convert strings to enumeration values.
183 * Values stored are char
187 /* WARNING: sum of length of all value strings must not exceed
189 #define TOTAL_VALUES_LENGTH 80
194 #define REFRESH_WINDOW_TEXTURES (1<<0)
195 #define REFRESH_MENU_TEXTURE (1<<1)
196 #define REFRESH_MENU_FONT (1<<2)
197 #define REFRESH_MENU_COLOR (1<<3)
198 #define REFRESH_MENU_TITLE_TEXTURE (1<<4)
199 #define REFRESH_MENU_TITLE_FONT (1<<5)
200 #define REFRESH_MENU_TITLE_COLOR (1<<6)
201 #define REFRESH_WINDOW_TITLE_COLOR (1<<7)
202 #define REFRESH_WINDOW_FONT (1<<8)
203 #define REFRESH_ICON_TILE (1<<9)
204 #define REFRESH_ICON_FONT (1<<10)
205 #define REFRESH_WORKSPACE_BACK (1<<11)
207 #define REFRESH_BUTTON_IMAGES (1<<12)
209 #define REFRESH_ICON_TITLE_COLOR (1<<13)
210 #define REFRESH_ICON_TITLE_BACK (1<<14)
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 {"ResizebarBack", "(solid, gray)", NULL
,
554 NULL
, getTexture
, setResizebarBack
556 {"MenuTitleColor", "white", NULL
,
557 NULL
, getColor
, setMenuTitleColor
559 {"MenuTextColor", "black", NULL
,
560 NULL
, getColor
, setMenuTextColor
562 {"MenuDisabledColor", "\"#616161\"", NULL
,
563 NULL
, getColor
, setMenuDisabledColor
565 {"MenuTitleBack", "(solid, black)", NULL
,
566 NULL
, getTexture
, setMenuTitleBack
568 {"MenuTextBack", "(solid, gray)", NULL
,
569 NULL
, getTexture
, setMenuTextBack
571 {"IconTitleColor", "white", NULL
,
572 NULL
, getColor
, setIconTitleColor
574 {"IconTitleBack", "black", NULL
,
575 NULL
, getColor
, setIconTitleBack
579 {"RootMenuKey", "None", (void*)WKBD_ROOTMENU
,
580 NULL
, getKeybind
, setKeyGrab
582 {"WindowListKey", "None", (void*)WKBD_WINDOWLIST
,
583 NULL
, getKeybind
, setKeyGrab
586 {"WindowMenuKey", "None", (void*)WKBD_WINDOWMENU
,
587 NULL
, getKeybind
, setKeyGrab
589 {"ClipLowerKey", "None", (void*)WKBD_CLIPLOWER
,
590 NULL
, getKeybind
, setKeyGrab
592 {"ClipRaiseKey", "None", (void*)WKBD_CLIPRAISE
,
593 NULL
, getKeybind
, setKeyGrab
595 {"ClipRaiseLowerKey", "None", (void*)WKBD_CLIPRAISELOWER
,
596 NULL
, getKeybind
, setKeyGrab
598 {"MiniaturizeKey", "None", (void*)WKBD_MINIATURIZE
,
599 NULL
, getKeybind
, setKeyGrab
601 {"HideKey", "None", (void*)WKBD_HIDE
,
602 NULL
, getKeybind
, setKeyGrab
604 {"MoveResizeKey", "None", (void*)WKBD_MOVERESIZE
,
605 NULL
, getKeybind
, setKeyGrab
607 {"CloseKey", "None", (void*)WKBD_CLOSE
,
608 NULL
, getKeybind
, setKeyGrab
610 {"MaximizeKey", "None", (void*)WKBD_MAXIMIZE
,
611 NULL
, getKeybind
, setKeyGrab
613 {"VMaximizeKey", "None", (void*)WKBD_VMAXIMIZE
,
614 NULL
, getKeybind
, setKeyGrab
616 {"RaiseKey", "Meta+Up", (void*)WKBD_RAISE
,
617 NULL
, getKeybind
, setKeyGrab
619 {"LowerKey", "Meta+Down", (void*)WKBD_LOWER
,
620 NULL
, getKeybind
, setKeyGrab
622 {"RaiseLowerKey", "None", (void*)WKBD_RAISELOWER
,
623 NULL
, getKeybind
, setKeyGrab
625 {"ShadeKey", "None", (void*)WKBD_SHADE
,
626 NULL
, getKeybind
, setKeyGrab
628 {"SelectKey", "None", (void*)WKBD_SELECT
,
629 NULL
, getKeybind
, setKeyGrab
631 {"FocusNextKey", "None", (void*)WKBD_FOCUSNEXT
,
632 NULL
, getKeybind
, setKeyGrab
634 {"FocusPrevKey", "None", (void*)WKBD_FOCUSPREV
,
635 NULL
, getKeybind
, setKeyGrab
637 {"NextWorkspaceKey", "None", (void*)WKBD_NEXTWORKSPACE
,
638 NULL
, getKeybind
, setKeyGrab
640 {"PrevWorkspaceKey", "None", (void*)WKBD_PREVWORKSPACE
,
641 NULL
, getKeybind
, setKeyGrab
643 {"NextWorkspaceLayerKey", "None", (void*)WKBD_NEXTWSLAYER
,
644 NULL
, getKeybind
, setKeyGrab
646 {"PrevWorkspaceLayerKey", "None", (void*)WKBD_PREVWSLAYER
,
647 NULL
, getKeybind
, setKeyGrab
649 {"Workspace1Key", "None", (void*)WKBD_WORKSPACE1
,
650 NULL
, getKeybind
, setKeyGrab
652 {"Workspace2Key", "None", (void*)WKBD_WORKSPACE2
,
653 NULL
, getKeybind
, setKeyGrab
655 {"Workspace3Key", "None", (void*)WKBD_WORKSPACE3
,
656 NULL
, getKeybind
, setKeyGrab
658 {"Workspace4Key", "None", (void*)WKBD_WORKSPACE4
,
659 NULL
, getKeybind
, setKeyGrab
661 {"Workspace5Key", "None", (void*)WKBD_WORKSPACE5
,
662 NULL
, getKeybind
, setKeyGrab
664 {"Workspace6Key", "None", (void*)WKBD_WORKSPACE6
,
665 NULL
, getKeybind
, setKeyGrab
667 {"Workspace7Key", "None", (void*)WKBD_WORKSPACE7
,
668 NULL
, getKeybind
, setKeyGrab
670 {"Workspace8Key", "None", (void*)WKBD_WORKSPACE8
,
671 NULL
, getKeybind
, setKeyGrab
673 {"Workspace9Key", "None", (void*)WKBD_WORKSPACE9
,
674 NULL
, getKeybind
, setKeyGrab
676 {"Workspace10Key", "None", (void*)WKBD_WORKSPACE10
,
677 NULL
, getKeybind
, setKeyGrab
679 {"WindowShortcut1Key","None", (void*)WKBD_WINDOW1
,
680 NULL
, getKeybind
, setKeyGrab
682 {"WindowShortcut2Key","None", (void*)WKBD_WINDOW2
,
683 NULL
, getKeybind
, setKeyGrab
685 {"WindowShortcut3Key","None", (void*)WKBD_WINDOW3
,
686 NULL
, getKeybind
, setKeyGrab
688 {"WindowShortcut4Key","None", (void*)WKBD_WINDOW4
,
689 NULL
, getKeybind
, setKeyGrab
691 #ifdef EXTEND_WINDOWSHORTCUT
692 ,{"WindowShortcut5Key","None", (void*)WKBD_WINDOW5
,
693 NULL
, getKeybind
, setKeyGrab
695 {"WindowShortcut6Key","None", (void*)WKBD_WINDOW6
,
696 NULL
, getKeybind
, setKeyGrab
698 {"WindowShortcut7Key","None", (void*)WKBD_WINDOW7
,
699 NULL
, getKeybind
, setKeyGrab
701 {"WindowShortcut8Key","None", (void*)WKBD_WINDOW8
,
702 NULL
, getKeybind
, setKeyGrab
704 {"WindowShortcut9Key","None", (void*)WKBD_WINDOW9
,
705 NULL
, getKeybind
, setKeyGrab
707 {"WindowShortcut10Key","None", (void*)WKBD_WINDOW10
,
708 NULL
, getKeybind
, setKeyGrab
710 #endif /* EXTEND_WINDOWSHORTCUT */
712 #ifdef KEEP_XKB_LOCK_STATUS
713 ,{"ToggleKbdModeKey", "None", (void*)WKBD_TOGGLE
,
714 NULL
, getKeybind
, setKeyGrab
716 {"KbdModeLock", "NO", NULL
,
717 &wPreferences
.modelock
, getBool
, NULL
719 #endif /* KEEP_XKB_LOCK_STATUS */
720 #ifdef TITLE_TEXT_SHADOW
721 ,{"FShadowColor", "black", (void*)WS_SFOCUSED
,
722 NULL
, getColor
, setWTitleColor
724 {"PShadowColor", "black", (void*)WS_SPFOCUSED
,
725 NULL
, getColor
, setWTitleColor
727 {"UShadowColor", "grey50", (void*)WS_SUNFOCUSED
,
728 NULL
, getColor
, setWTitleColor
730 {"MShadowColor", "black", (void*)WS_SMENU
,
731 NULL
, getColor
, setMenuTitleColor
733 {"Shadow", "Yes", NULL
,
734 &wPreferences
.title_shadow
, getBool
, setJustify
736 #endif /* TITLE_TEXT_SHADOW */
741 static void rereadDefaults(void);
748 /* must defer the update because accessing X data from a
749 * signal handler can mess up Xlib */
758 WDefaultEntry
*entry
;
760 PLSetStringCmpHook(StringCompareHook
);
762 for (i
=0; i
<sizeof(optionList
)/sizeof(WDefaultEntry
); i
++) {
763 entry
= &optionList
[i
];
765 entry
->plkey
= PLMakeString(entry
->key
);
766 if (entry
->default_value
)
767 entry
->plvalue
= PLGetProplistWithDescription(entry
->default_value
);
769 entry
->plvalue
= NULL
;
772 for (i
=0; i
<sizeof(staticOptionList
)/sizeof(WDefaultEntry
); i
++) {
773 entry
= &staticOptionList
[i
];
775 entry
->plkey
= PLMakeString(entry
->key
);
776 if (entry
->default_value
)
777 entry
->plvalue
= PLGetProplistWithDescription(entry
->default_value
);
779 entry
->plvalue
= NULL
;
783 wDomainName = PLMakeString(WMDOMAIN_NAME);
784 wAttributeDomainName = PLMakeString(WMATTRIBUTE_DOMAIN_NAME);
786 PLRegister(wDomainName, rereadDefaults);
787 PLRegister(wAttributeDomainName, rereadDefaults);
796 wDefaultsInit(int screen_number
)
798 static int defaults_inited
= 0;
801 if (!defaults_inited
) {
805 dict
= PLGetDomain(wDomainName
);
807 wwarning(_("could not read domain \"%s\" from defaults database"),
808 PLGetString(wDomainName
));
817 wDefaultsDestroyDomain(WDDomain
*domain
)
819 if (domain
->dictionary
)
820 PLRelease(domain
->dictionary
);
827 wDefaultsInitDomain(char *domain
, Bool requireDictionary
)
831 static int inited
= 0;
834 proplist_t shared_dict
=NULL
;
841 db
= wmalloc(sizeof(WDDomain
));
842 memset(db
, 0, sizeof(WDDomain
));
843 db
->domain_name
= domain
;
844 db
->path
= wdefaultspathfordomain(domain
);
847 if (the_path
&& stat(the_path
, &stbuf
)>=0) {
848 db
->dictionary
= ReadProplistFromFile(the_path
);
849 if (db
->dictionary
) {
850 if (requireDictionary
&& !PLIsDictionary(db
->dictionary
)) {
851 PLRelease(db
->dictionary
);
852 db
->dictionary
= NULL
;
853 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
856 db
->timestamp
= stbuf
.st_mtime
;
858 wwarning(_("could not load domain %s from user defaults database"),
863 /* global system dictionary */
864 sprintf(path
, "%s/%s", SYSCONFDIR
, domain
);
865 if (stat(path
, &stbuf
)>=0) {
866 shared_dict
= ReadProplistFromFile(path
);
868 if (requireDictionary
&& !PLIsDictionary(shared_dict
)) {
869 wwarning(_("Domain %s (%s) of global defaults database is corrupted!"),
871 PLRelease(shared_dict
);
874 if (db
->dictionary
&& PLIsDictionary(shared_dict
) &&
875 PLIsDictionary(db
->dictionary
)) {
876 PLMergeDictionaries(shared_dict
, db
->dictionary
);
877 PLRelease(db
->dictionary
);
878 db
->dictionary
= shared_dict
;
879 if (stbuf
.st_mtime
> db
->timestamp
)
880 db
->timestamp
= stbuf
.st_mtime
;
881 } else if (!db
->dictionary
) {
882 db
->dictionary
= shared_dict
;
883 if (stbuf
.st_mtime
> db
->timestamp
)
884 db
->timestamp
= stbuf
.st_mtime
;
888 wwarning(_("could not load domain %s from global defaults database"),
893 /* set to save it in user's directory, no matter from where it was read */
894 if (db
->dictionary
) {
895 proplist_t tmp
= PLMakeString(db
->path
);
897 PLSetFilename(db
->dictionary
, tmp
);
906 wReadStaticDefaults(proplist_t dict
)
909 WDefaultEntry
*entry
;
914 for (i
=0; i
<sizeof(staticOptionList
)/sizeof(WDefaultEntry
); i
++) {
915 entry
= &staticOptionList
[i
];
918 plvalue
= PLGetDictionaryEntry(dict
, entry
->plkey
);
923 /* no default in the DB. Use builtin default */
924 plvalue
= entry
->plvalue
;
929 (*entry
->convert
)(NULL
, entry
, plvalue
, entry
->addr
, &tdata
);
931 (*entry
->update
)(NULL
, entry
, tdata
, entry
->extra_data
);
939 wDefaultsCheckDomains(void *foo
)
948 puts("Checking domains...");
950 if (stat(WDWindowMaker
->path
, &stbuf
)>=0
951 && WDWindowMaker
->timestamp
< stbuf
.st_mtime
) {
952 proplist_t shared_dict
= NULL
;
954 puts("Checking WindowMaker domain");
956 WDWindowMaker
->timestamp
= stbuf
.st_mtime
;
958 /* global dictionary */
959 sprintf(path
, "%s/WindowMaker", SYSCONFDIR
);
960 if (stat(path
, &stbuf
)>=0) {
961 shared_dict
= ReadProplistFromFile(path
);
962 if (shared_dict
&& !PLIsDictionary(shared_dict
)) {
963 wwarning(_("Domain %s (%s) of global defaults database is corrupted!"),
964 "WindowMaker", path
);
965 PLRelease(shared_dict
);
967 } else if (!shared_dict
) {
968 wwarning(_("could not load domain %s from global defaults database"),
972 /* user dictionary */
973 dict
= ReadProplistFromFile(WDWindowMaker
->path
);
975 if (!PLIsDictionary(dict
)) {
978 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
979 "WindowMaker", WDWindowMaker
->path
);
982 PLSetFilename(shared_dict
, PLGetFilename(dict
));
983 PLMergeDictionaries(shared_dict
, dict
);
988 for (i
=0; i
<wScreenCount
; i
++) {
989 scr
= wScreenWithNumber(i
);
991 wReadDefaults(scr
, dict
);
993 if (WDWindowMaker
->dictionary
) {
994 PLRelease(WDWindowMaker
->dictionary
);
996 WDWindowMaker
->dictionary
= dict
;
999 wwarning(_("could not load domain %s from user defaults database"),
1003 PLRelease(shared_dict
);
1007 if (stat(WDWindowAttributes
->path
, &stbuf
)>=0
1008 && WDWindowAttributes
->timestamp
< stbuf
.st_mtime
) {
1010 puts("Checking WMWindowAttributes domain");
1012 dict
= ReadProplistFromFile(WDWindowAttributes
->path
);
1014 if (!PLIsDictionary(dict
)) {
1017 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
1018 "WMWindowAttributes", WDWindowAttributes
->path
);
1020 if (WDWindowAttributes
->dictionary
)
1021 PLRelease(WDWindowAttributes
->dictionary
);
1022 WDWindowAttributes
->dictionary
= dict
;
1023 for (i
=0; i
<wScreenCount
; i
++) {
1024 scr
= wScreenWithNumber(i
);
1026 wDefaultUpdateIcons(scr
);
1030 wwarning(_("could not load domain %s from user defaults database"),
1031 "WMWindowAttributes");
1033 WDWindowAttributes
->timestamp
= stbuf
.st_mtime
;
1037 if (stat(WDRootMenu
->path
, &stbuf
)>=0
1038 && WDRootMenu
->timestamp
< stbuf
.st_mtime
) {
1039 dict
= ReadProplistFromFile(WDRootMenu
->path
);
1041 puts("Checking WMRootMenu domain");
1044 if (!PLIsArray(dict
) && !PLIsString(dict
)) {
1047 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
1048 "WMRootMenu", WDRootMenu
->path
);
1050 if (WDRootMenu
->dictionary
) {
1051 PLRelease(WDRootMenu
->dictionary
);
1053 WDRootMenu
->dictionary
= dict
;
1056 wwarning(_("could not load domain %s from user defaults database"),
1059 WDRootMenu
->timestamp
= stbuf
.st_mtime
;
1064 WMAddTimerHandler(DEFAULTS_CHECK_INTERVAL
, wDefaultsCheckDomains
, foo
);
1069 wReadDefaults(WScreen
*scr
, proplist_t new_dict
)
1071 proplist_t plvalue
, old_value
;
1072 WDefaultEntry
*entry
;
1076 proplist_t old_dict
= (WDWindowMaker
->dictionary
!=new_dict
1077 ? WDWindowMaker
->dictionary
: NULL
);
1083 for (i
=0; i
<sizeof(optionList
)/sizeof(WDefaultEntry
); i
++) {
1084 entry
= &optionList
[i
];
1087 plvalue
= PLGetDictionaryEntry(new_dict
, entry
->plkey
);
1094 old_value
= PLGetDictionaryEntry(old_dict
, entry
->plkey
);
1097 if (!plvalue
&& !old_value
) {
1098 /* no default in the DB. Use builtin default */
1099 plvalue
= entry
->plvalue
;
1100 if (plvalue
&& new_dict
) {
1101 PLInsertDictionaryEntry(new_dict
, entry
->plkey
, plvalue
);
1104 } else if (!plvalue
) {
1105 /* value was deleted from DB. Keep current value */
1107 } else if (!old_value
) {
1108 /* set value for the 1st time */
1109 } else if (!PLIsEqual(plvalue
, old_value
)) {
1110 /* value has changed */
1112 /* value was not changed since last time */
1118 printf("Updating %s to %s\n", entry
->key
, PLGetDescription(plvalue
));
1121 if ((*entry
->convert
)(scr
, entry
, plvalue
, entry
->addr
, &tdata
)) {
1122 if (entry
->update
) {
1124 (*entry
->update
)(scr
, entry
, tdata
, entry
->extra_data
);
1130 if (needs_refresh
!=0 && !scr
->flags
.startup
) {
1134 if (needs_refresh
& REFRESH_MENU_TITLE_TEXTURE
)
1135 foo
|= WTextureSettings
;
1136 if (needs_refresh
& REFRESH_MENU_TITLE_FONT
)
1137 foo
|= WFontSettings
;
1138 if (needs_refresh
& REFRESH_MENU_TITLE_COLOR
)
1139 foo
|= WColorSettings
;
1141 WMPostNotificationName(WNMenuTitleAppearanceSettingsChanged
, NULL
,
1145 if (needs_refresh
& REFRESH_MENU_TEXTURE
)
1146 foo
|= WTextureSettings
;
1147 if (needs_refresh
& REFRESH_MENU_FONT
)
1148 foo
|= WFontSettings
;
1149 if (needs_refresh
& REFRESH_MENU_COLOR
)
1150 foo
|= WColorSettings
;
1152 WMPostNotificationName(WNMenuAppearanceSettingsChanged
, NULL
,
1156 if (needs_refresh
& REFRESH_WINDOW_FONT
) {
1157 foo
|= WFontSettings
;
1159 if (needs_refresh
& REFRESH_WINDOW_TEXTURES
) {
1160 foo
|= WTextureSettings
;
1162 if (needs_refresh
& REFRESH_WINDOW_TITLE_COLOR
) {
1163 foo
|= WColorSettings
;
1166 WMPostNotificationName(WNWindowAppearanceSettingsChanged
, NULL
,
1169 if (!(needs_refresh
& REFRESH_ICON_TILE
)) {
1171 if (needs_refresh
& REFRESH_ICON_FONT
) {
1172 foo
|= WFontSettings
;
1174 if (needs_refresh
& REFRESH_ICON_TITLE_COLOR
) {
1175 foo
|= WTextureSettings
;
1177 if (needs_refresh
& REFRESH_ICON_TITLE_BACK
) {
1178 foo
|= WTextureSettings
;
1181 WMPostNotificationName(WNIconAppearanceSettingsChanged
, NULL
,
1184 if (needs_refresh
& REFRESH_ICON_TILE
)
1185 WMPostNotificationName(WNIconTileSettingsChanged
, NULL
, NULL
);
1191 wDefaultUpdateIcons(WScreen
*scr
)
1193 WAppIcon
*aicon
= scr
->app_icon_list
;
1194 WWindow
*wwin
= scr
->focused_window
;
1198 file
= wDefaultGetIconFile(scr
, aicon
->wm_instance
, aicon
->wm_class
,
1200 if ((file
&& aicon
->icon
->file
&& strcmp(file
, aicon
->icon
->file
)!=0)
1201 || (file
&& !aicon
->icon
->file
)) {
1204 if (aicon
->icon
->file
)
1205 free(aicon
->icon
->file
);
1206 aicon
->icon
->file
= wstrdup(file
);
1208 new_image
= wDefaultGetImage(scr
, aicon
->wm_instance
,
1211 wIconChangeImage(aicon
->icon
, new_image
);
1212 wAppIconPaint(aicon
);
1215 aicon
= aicon
->next
;
1218 if (!wPreferences
.flags
.noclip
)
1219 wClipIconPaint(scr
->clip_icon
);
1222 if (wwin
->icon
&& wwin
->flags
.miniaturized
) {
1223 file
= wDefaultGetIconFile(scr
, wwin
->wm_instance
, wwin
->wm_class
,
1225 if ((file
&& wwin
->icon
->file
&& strcmp(file
, wwin
->icon
->file
)!=0)
1226 || (file
&& !wwin
->icon
->file
)) {
1229 if (wwin
->icon
->file
)
1230 free(wwin
->icon
->file
);
1231 wwin
->icon
->file
= wstrdup(file
);
1233 new_image
= wDefaultGetImage(scr
, wwin
->wm_instance
,
1236 wIconChangeImage(wwin
->icon
, new_image
);
1244 /* --------------------------- Local ----------------------- */
1246 #define STRINGP(x) if (!PLIsString(value)) { \
1247 wwarning(_("Wrong option format for key \"%s\". Should be %s."), \
1254 string2index(proplist_t key
, proplist_t val
, proplist_t def
,
1255 WOptionEnumeration
*values
)
1258 WOptionEnumeration
*v
;
1259 char buffer
[TOTAL_VALUES_LENGTH
];
1261 if (PLIsString(val
) && (str
= PLGetString(val
))) {
1262 for (v
=values
; v
->string
!=NULL
; v
++) {
1263 if (strcasecmp(v
->string
, str
)==0)
1269 for (v
=values
; v
->string
!=NULL
; v
++) {
1272 strcat(buffer
, ", ");
1273 strcat(buffer
, v
->string
);
1276 wwarning(_("wrong option value for key \"%s\". Should be one of %s"),
1277 PLGetString(key
), buffer
);
1280 return string2index(key
, val
, NULL
, values
);
1290 * value - is the value in the defaults DB
1291 * addr - is the address to store the data
1292 * ret - is the address to store a pointer to a temporary buffer. ret
1293 * must not be freed and is used by the set functions
1296 getBool(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
1305 val
= PLGetString(value
);
1308 if ((val
[1]=='\0' && (val
[0]=='y' || val
[0]=='Y'))
1309 || strcasecmp(val
, "YES")==0) {
1312 } else if ((val
[1]=='\0' && (val
[0]=='n' || val
[0]=='N'))
1313 || strcasecmp(val
, "NO")==0) {
1317 if (sscanf(val
, "%i", &i
)==1) {
1323 wwarning(_("can't convert \"%s\" to boolean for key \"%s\""),
1325 if (second_pass
==0) {
1326 val
= PLGetString(entry
->plvalue
);
1328 wwarning(_("using default \"%s\" instead"), val
);
1339 *(char*)addr
= data
;
1347 getInt(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
1356 val
= PLGetString(value
);
1358 if (sscanf(val
, "%i", &data
)!=1) {
1359 wwarning(_("can't convert \"%s\" to integer for key \"%s\""),
1361 val
= PLGetString(entry
->plvalue
);
1362 wwarning(_("using default \"%s\" instead"), val
);
1363 if (sscanf(val
, "%i", &data
)!=1) {
1379 getCoord(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
1383 char *val_x
, *val_y
;
1384 int nelem
, changed
=0;
1385 proplist_t elem_x
, elem_y
;
1388 if (!PLIsArray(value
)) {
1389 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1390 entry
->key
, "Coordinate");
1392 value
= entry
->plvalue
;
1394 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1400 nelem
= PLGetNumberOfElements(value
);
1402 wwarning(_("Incorrect number of elements in array for key \"%s\"."),
1405 value
= entry
->plvalue
;
1407 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1413 elem_x
= PLGetArrayElement(value
, 0);
1414 elem_y
= PLGetArrayElement(value
, 1);
1416 if (!elem_x
|| !elem_y
|| !PLIsString(elem_x
) || !PLIsString(elem_y
)) {
1417 wwarning(_("Wrong value for key \"%s\". Should be Coordinate."),
1420 value
= entry
->plvalue
;
1422 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1428 val_x
= PLGetString(elem_x
);
1429 val_y
= PLGetString(elem_y
);
1431 if (sscanf(val_x
, "%i", &data
.x
)!=1 || sscanf(val_y
, "%i", &data
.y
)!=1) {
1432 wwarning(_("can't convert array to integers for \"%s\"."), entry
->key
);
1434 value
= entry
->plvalue
;
1436 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1444 else if (data
.x
> scr
->scr_width
/3)
1445 data
.x
= scr
->scr_width
/3;
1448 else if (data
.y
> scr
->scr_height
/3)
1449 data
.y
= scr
->scr_height
/3;
1455 *(WCoord
*)addr
= data
;
1463 /* This function is not used at the moment. */
1465 getString(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
1472 data
= PLGetString(value
);
1475 data
= PLGetString(entry
->plvalue
);
1484 *(char**)addr
= wstrdup(data
);
1492 getPathList(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
1502 if (!PLIsArray(value
)) {
1503 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1504 entry
->key
, "an array of paths");
1506 value
= entry
->plvalue
;
1508 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1515 count
= PLGetNumberOfElements(value
);
1518 value
= entry
->plvalue
;
1520 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1527 for (i
=0; i
<count
; i
++) {
1528 d
= PLGetArrayElement(value
, i
);
1529 if (!d
|| !PLIsString(d
)) {
1533 len
+= strlen(PLGetString(d
))+1;
1536 ptr
= data
= wmalloc(len
+1);
1538 for (i
=0; i
<count
; i
++) {
1539 d
= PLGetArrayElement(value
, i
);
1540 if (!d
|| !PLIsString(d
)) {
1543 strcpy(ptr
, PLGetString(d
));
1544 ptr
+= strlen(PLGetString(d
));
1548 ptr
--; *(ptr
--) = 0;
1550 if (*(char**)addr
!=NULL
) {
1551 free(*(char**)addr
);
1553 *(char**)addr
= data
;
1560 getEnum(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
1563 static signed char data
;
1565 data
= string2index(entry
->plkey
, value
, entry
->default_value
,
1566 (WOptionEnumeration
*)entry
->extra_data
);
1574 *(signed char*)addr
= data
;
1583 * (hgradient <color> <color>)
1584 * (vgradient <color> <color>)
1585 * (dgradient <color> <color>)
1586 * (mhgradient <color> <color> ...)
1587 * (mvgradient <color> <color> ...)
1588 * (tpixmap <file> <color>)
1589 * (spixmap <file> <color>)
1590 * (cpixmap <file> <color>)
1591 * (thgradient <file> <opaqueness> <color> <color>)
1592 * (tvgradient <file> <opaqueness> <color> <color>)
1593 * (tdgradient <file> <opaqueness> <color> <color>)
1594 * (function <lib> <function> ...)
1598 parse_texture(WScreen
*scr
, proplist_t pl
)
1603 WTexture
*texture
=NULL
;
1605 nelem
= PLGetNumberOfElements(pl
);
1610 elem
= PLGetArrayElement(pl
, 0);
1611 if (!elem
|| !PLIsString(elem
))
1613 val
= PLGetString(elem
);
1616 if (strcasecmp(val
, "solid")==0) {
1624 elem
= PLGetArrayElement(pl
, 1);
1625 if (!elem
|| !PLIsString(elem
))
1627 val
= PLGetString(elem
);
1629 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &color
)) {
1630 wwarning(_("\"%s\" is not a valid color name"), val
);
1634 texture
= (WTexture
*)wTextureMakeSolid(scr
, &color
);
1635 } else if (strcasecmp(val
, "dgradient")==0
1636 || strcasecmp(val
, "vgradient")==0
1637 || strcasecmp(val
, "hgradient")==0) {
1638 RColor color1
, color2
;
1643 wwarning(_("bad number of arguments in gradient specification"));
1647 if (val
[0]=='d' || val
[0]=='D')
1648 type
= WTEX_DGRADIENT
;
1649 else if (val
[0]=='h' || val
[0]=='H')
1650 type
= WTEX_HGRADIENT
;
1652 type
= WTEX_VGRADIENT
;
1655 /* get from color */
1656 elem
= PLGetArrayElement(pl
, 1);
1657 if (!elem
|| !PLIsString(elem
))
1659 val
= PLGetString(elem
);
1661 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1662 wwarning(_("\"%s\" is not a valid color name"), val
);
1666 color1
.red
= xcolor
.red
>> 8;
1667 color1
.green
= xcolor
.green
>> 8;
1668 color1
.blue
= xcolor
.blue
>> 8;
1671 elem
= PLGetArrayElement(pl
, 2);
1672 if (!elem
|| !PLIsString(elem
)) {
1675 val
= PLGetString(elem
);
1677 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1678 wwarning(_("\"%s\" is not a valid color name"), val
);
1682 color2
.red
= xcolor
.red
>> 8;
1683 color2
.green
= xcolor
.green
>> 8;
1684 color2
.blue
= xcolor
.blue
>> 8;
1686 texture
= (WTexture
*)wTextureMakeGradient(scr
, type
, &color1
, &color2
);
1688 } else if (strcasecmp(val
, "mhgradient")==0
1689 || strcasecmp(val
, "mvgradient")==0
1690 || strcasecmp(val
, "mdgradient")==0) {
1697 wwarning(_("too few arguments in multicolor gradient specification"));
1701 if (val
[1]=='h' || val
[1]=='H')
1702 type
= WTEX_MHGRADIENT
;
1703 else if (val
[1]=='v' || val
[1]=='V')
1704 type
= WTEX_MVGRADIENT
;
1706 type
= WTEX_MDGRADIENT
;
1710 colors
= wmalloc(sizeof(RColor
*)*(count
+1));
1712 for (i
=0; i
<count
; i
++) {
1713 elem
= PLGetArrayElement(pl
, i
+1);
1714 if (!elem
|| !PLIsString(elem
)) {
1715 for (--i
; i
>=0; --i
) {
1721 val
= PLGetString(elem
);
1723 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &color
)) {
1724 wwarning(_("\"%s\" is not a valid color name"), val
);
1725 for (--i
; i
>=0; --i
) {
1731 colors
[i
] = wmalloc(sizeof(RColor
));
1732 colors
[i
]->red
= color
.red
>> 8;
1733 colors
[i
]->green
= color
.green
>> 8;
1734 colors
[i
]->blue
= color
.blue
>> 8;
1739 texture
= (WTexture
*)wTextureMakeMGradient(scr
, type
, colors
);
1740 } else if (strcasecmp(val
, "spixmap")==0 ||
1741 strcasecmp(val
, "cpixmap")==0 ||
1742 strcasecmp(val
, "tpixmap")==0) {
1749 if (val
[0] == 's' || val
[0] == 'S')
1751 else if (val
[0] == 'c' || val
[0] == 'C')
1757 elem
= PLGetArrayElement(pl
, 2);
1758 if (!elem
|| !PLIsString(elem
)) {
1761 val
= PLGetString(elem
);
1763 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &color
)) {
1764 wwarning(_("\"%s\" is not a valid color name"), val
);
1769 elem
= PLGetArrayElement(pl
, 1);
1770 if (!elem
|| !PLIsString(elem
))
1772 val
= PLGetString(elem
);
1774 texture
= (WTexture
*)wTextureMakePixmap(scr
, type
, val
, &color
);
1775 } else if (strcasecmp(val
, "thgradient")==0
1776 || strcasecmp(val
, "tvgradient")==0
1777 || strcasecmp(val
, "tdgradient")==0) {
1778 RColor color1
, color2
;
1783 if (val
[1]=='h' || val
[1]=='H')
1784 style
= WTEX_THGRADIENT
;
1785 else if (val
[1]=='v' || val
[1]=='V')
1786 style
= WTEX_TVGRADIENT
;
1788 style
= WTEX_TDGRADIENT
;
1791 wwarning(_("bad number of arguments in textured gradient specification"));
1795 /* get from color */
1796 elem
= PLGetArrayElement(pl
, 3);
1797 if (!elem
|| !PLIsString(elem
))
1799 val
= PLGetString(elem
);
1801 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1802 wwarning(_("\"%s\" is not a valid color name"), val
);
1806 color1
.red
= xcolor
.red
>> 8;
1807 color1
.green
= xcolor
.green
>> 8;
1808 color1
.blue
= xcolor
.blue
>> 8;
1811 elem
= PLGetArrayElement(pl
, 4);
1812 if (!elem
|| !PLIsString(elem
)) {
1815 val
= PLGetString(elem
);
1817 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1818 wwarning(_("\"%s\" is not a valid color name"), val
);
1822 color2
.red
= xcolor
.red
>> 8;
1823 color2
.green
= xcolor
.green
>> 8;
1824 color2
.blue
= xcolor
.blue
>> 8;
1827 elem
= PLGetArrayElement(pl
, 2);
1828 if (!elem
|| !PLIsString(elem
))
1831 val
= PLGetString(elem
);
1833 if (!val
|| (opacity
= atoi(val
)) < 0 || opacity
> 255) {
1834 wwarning(_("bad opacity value for tgradient texture \"%s\". Should be [0..255]"), val
);
1839 elem
= PLGetArrayElement(pl
, 1);
1840 if (!elem
|| !PLIsString(elem
))
1842 val
= PLGetString(elem
);
1844 texture
= (WTexture
*)wTextureMakeTGradient(scr
, style
, &color1
, &color2
,
1847 #ifdef TEXTURE_PLUGIN
1848 else if (strcasecmp(val
, "function")==0) {
1849 WTexFunction
*function
;
1850 void (*initFunc
) (Display
*, Colormap
);
1851 char *lib
, *func
, **argv
;
1857 /* get the library name */
1858 elem
= PLGetArrayElement(pl
, 1);
1859 if (!elem
|| !PLIsString(elem
)) {
1862 lib
= PLGetString(elem
);
1864 /* get the function name */
1865 elem
= PLGetArrayElement(pl
, 2);
1866 if (!elem
|| !PLIsString(elem
)) {
1869 func
= PLGetString(elem
);
1872 argv
= (char **)wmalloc(argc
* sizeof(char *));
1874 /* get the parameters */
1875 argv
[0] = wstrdup(func
);
1876 for (i
= 0; i
< argc
- 1; i
++) {
1877 elem
= PLGetArrayElement(pl
, 3 + i
);
1878 if (!elem
|| !PLIsString(elem
)) {
1883 argv
[i
+1] = wstrdup(PLGetString(elem
));
1886 function
= wTextureMakeFunction(scr
, lib
, func
, argc
, argv
);
1890 initFunc
= dlsym(function
->handle
, "initWindowMaker");
1892 initFunc(dpy
, scr
->w_colormap
);
1894 wwarning(_("could not initialize library %s"), lib
);
1897 wwarning(_("could not find function %s::%s"), lib
, func
);
1899 #endif /* HAVE_DLFCN_H */
1900 texture
= (WTexture
*)function
;
1902 #endif /* TEXTURE_PLUGIN */
1904 wwarning(_("invalid texture type %s"), val
);
1913 getTexture(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
1916 static WTexture
*texture
;
1920 if (!PLIsArray(value
)) {
1921 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1922 entry
->key
, "Texture");
1924 value
= entry
->plvalue
;
1926 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1932 if (strcmp(entry
->key
, "WidgetColor")==0 && !changed
) {
1935 pl
= PLGetArrayElement(value
, 0);
1936 if (!pl
|| !PLIsString(pl
) || !PLGetString(pl
)
1937 || strcasecmp(PLGetString(pl
), "solid")!=0) {
1938 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1939 entry
->key
, "Solid Texture");
1941 value
= entry
->plvalue
;
1943 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1948 texture
= parse_texture(scr
, value
);
1951 wwarning(_("Error in texture specification for key \"%s\""),
1954 value
= entry
->plvalue
;
1956 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1966 *(WTexture
**)addr
= texture
;
1974 getWSBackground(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
,
1975 void *addr
, void **ret
)
1983 if (!PLIsArray(value
)) {
1984 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1985 "WorkspaceBack", "Texture or None");
1987 value
= entry
->plvalue
;
1989 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1995 /* only do basic error checking and verify for None texture */
1997 nelem
= PLGetNumberOfElements(value
);
1999 elem
= PLGetArrayElement(value
, 0);
2000 if (!elem
|| !PLIsString(elem
)) {
2001 wwarning(_("Wrong type for workspace background. Should be a texture type."));
2003 value
= entry
->plvalue
;
2005 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
2010 val
= PLGetString(elem
);
2012 if (strcasecmp(val
, "None")==0)
2015 *ret
= PLRetain(value
);
2022 getWSSpecificBackground(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
,
2023 void *addr
, void **ret
)
2030 if (!PLIsArray(value
)) {
2031 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
2032 "WorkspaceSpecificBack", "an array of textures");
2034 value
= entry
->plvalue
;
2036 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
2042 /* only do basic error checking and verify for None texture */
2044 nelem
= PLGetNumberOfElements(value
);
2047 elem
= PLGetArrayElement(value
, nelem
);
2048 if (!elem
|| !PLIsArray(elem
)) {
2049 wwarning(_("Wrong type for background of workspace %i. Should be a texture."),
2055 *ret
= PLRetain(value
);
2059 * Kluge to force wmsetbg helper to set the default background.
2060 * If the WorkspaceSpecificBack is changed once wmaker has started,
2061 * the WorkspaceBack won't be sent to the helper, unless the user
2062 * changes it's value too. So, we must force this by removing the
2063 * value from the defaults DB.
2065 if (!scr
->flags
.backimage_helper_launched
&& !scr
->flags
.startup
) {
2066 proplist_t key
= PLMakeString("WorkspaceBack");
2068 PLRemoveDictionaryEntry(WDWindowMaker
->dictionary
, key
);
2078 getFont(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
2086 val
= PLGetString(value
);
2088 font
= wLoadFont(val
);
2090 wfatal(_("could not load any usable font!!!"));
2097 /* can't assign font value outside update function */
2098 wassertrv(addr
== NULL
, True
);
2105 getColor(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
2108 static XColor color
;
2114 val
= PLGetString(value
);
2117 if (!wGetColor(scr
, val
, &color
)) {
2118 wwarning(_("could not get color for key \"%s\""),
2120 if (second_pass
==0) {
2121 val
= PLGetString(entry
->plvalue
);
2123 wwarning(_("using default \"%s\" instead"), val
);
2135 *(unsigned long*)addr = pixel;
2144 getKeybind(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
2147 static WShortKey shortcut
;
2154 STRINGP("Key spec");
2156 val
= PLGetString(value
);
2158 if (!val
|| strcasecmp(val
, "NONE")==0) {
2159 shortcut
.keycode
= 0;
2160 shortcut
.modifier
= 0;
2171 shortcut
.modifier
= 0;
2172 while ((k
= strchr(b
, '+'))!=NULL
) {
2176 mod
= wXModifierFromKey(b
);
2178 wwarning(_("%s:invalid key modifier \"%s\""), entry
->key
, b
);
2181 shortcut
.modifier
|= mod
;
2187 ksym
= XStringToKeysym(b
);
2189 if (ksym
==NoSymbol
) {
2190 wwarning(_("%s:invalid kbd shortcut specification \"%s\""), entry
->key
,
2195 shortcut
.keycode
= XKeysymToKeycode(dpy
, ksym
);
2196 if (shortcut
.keycode
==0) {
2197 wwarning(_("%s:invalid key in shortcut \"%s\""), entry
->key
, val
);
2209 getModMask(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
2212 static unsigned int mask
;
2215 STRINGP("Modifier Key");
2217 str
= PLGetString(value
);
2221 mask
= wXModifierFromKey(str
);
2223 wwarning(_("%s: modifier key %s is not valid"), entry
->key
, str
);
2229 *(unsigned int*)addr
= mask
;
2240 getRImages(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
,
2241 void *addr
, void **ret
)
2249 STRINGP("Image File Path");
2251 str
= PLGetString(value
);
2255 image
= RLoadImage(scr
->rcontext
, str
, 0);
2257 wwarning(_("could not load image in option %s: %s"), entry
->key
,
2258 RMessageForError(RErrorCode
));
2262 if (*(RImage
**)addr
) {
2263 RDestroyImage(*(RImage
**)addr
);
2266 *(RImage
**)addr
= image
;
2268 assert(ret
== NULL
);
2271 *(RImage**)ret = image;
2279 /* ---------------- value setting functions --------------- */
2281 setJustify(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
2283 return REFRESH_WINDOW_TITLE_COLOR
;
2288 setIfDockPresent(WScreen
*scr
, WDefaultEntry
*entry
, int *flag
, long which
)
2292 wPreferences
.flags
.nodock
= wPreferences
.flags
.nodock
|| *flag
;
2295 wPreferences
.flags
.noclip
= wPreferences
.flags
.noclip
|| *flag
;
2305 setStickyIcons(WScreen
*scr
, WDefaultEntry
*entry
, void *bar
, void *foo
)
2307 if (scr
->workspaces
) {
2308 wWorkspaceForceChange(scr
, scr
->current_workspace
);
2309 wArrangeIcons(scr
, False
);
2316 setPositive(WScreen
*scr
, WDefaultEntry
*entry
, int *value
, void *foo
)
2328 setIconTile(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
2334 img
= wTextureRenderImage(*texture
, wPreferences
.icon_size
,
2335 wPreferences
.icon_size
,
2336 ((*texture
)->any
.type
& WREL_BORDER_MASK
)
2337 ? WREL_ICON
: WREL_FLAT
);
2339 wwarning(_("could not render texture for icon background"));
2341 wTextureDestroy(scr
, *texture
);
2344 RConvertImage(scr
->rcontext
, img
, &pixmap
);
2346 if (scr
->icon_tile
) {
2348 RDestroyImage(scr
->icon_tile
);
2349 XFreePixmap(dpy
, scr
->icon_tile_pixmap
);
2352 scr
->icon_tile
= img
;
2354 if (!wPreferences
.flags
.noclip
) {
2355 if (scr
->clip_tile
) {
2356 RDestroyImage(scr
->clip_tile
);
2358 scr
->clip_tile
= wClipMakeTile(scr
, img
);
2361 scr
->icon_tile_pixmap
= pixmap
;
2363 if (scr
->def_icon_pixmap
) {
2364 XFreePixmap(dpy
, scr
->def_icon_pixmap
);
2365 scr
->def_icon_pixmap
= None
;
2367 if (scr
->def_ticon_pixmap
) {
2368 XFreePixmap(dpy
, scr
->def_ticon_pixmap
);
2369 scr
->def_ticon_pixmap
= None
;
2372 if (scr
->icon_back_texture
) {
2373 wTextureDestroy(scr
, (WTexture
*)scr
->icon_back_texture
);
2375 scr
->icon_back_texture
= wTextureMakeSolid(scr
, &((*texture
)->any
.color
));
2377 if (scr
->clip_balloon
)
2378 XSetWindowBackground(dpy
, scr
->clip_balloon
,
2379 (*texture
)->any
.color
.pixel
);
2382 * Free the texture as nobody else will use it, nor refer to it.
2385 wTextureDestroy(scr
, *texture
);
2387 return (reset
? REFRESH_ICON_TILE
: 0);
2393 setWinTitleFont(WScreen
*scr
, WDefaultEntry
*entry
, WFont
*font
, void *foo
)
2395 if (scr
->title_font
) {
2396 wFreeFont(scr
->title_font
);
2399 scr
->title_font
= font
;
2402 XSetFont(dpy
, scr
->window_title_gc
, font
->font
->fid
);
2405 return REFRESH_WINDOW_FONT
|REFRESH_BUTTON_IMAGES
;
2410 setMenuTitleFont(WScreen
*scr
, WDefaultEntry
*entry
, WFont
*font
, void *foo
)
2412 if (scr
->menu_title_font
) {
2413 wFreeFont(scr
->menu_title_font
);
2416 scr
->menu_title_font
= font
;
2419 XSetFont(dpy
, scr
->menu_title_gc
, font
->font
->fid
);
2422 return REFRESH_MENU_TITLE_FONT
;
2427 setMenuTextFont(WScreen
*scr
, WDefaultEntry
*entry
, WFont
*font
, void *foo
)
2429 if (scr
->menu_entry_font
) {
2430 wFreeFont(scr
->menu_entry_font
);
2433 scr
->menu_entry_font
= font
;
2436 XSetFont(dpy
, scr
->menu_entry_gc
, font
->font
->fid
);
2437 XSetFont(dpy
, scr
->disabled_menu_entry_gc
, font
->font
->fid
);
2438 XSetFont(dpy
, scr
->select_menu_gc
, font
->font
->fid
);
2441 return REFRESH_MENU_FONT
;
2447 setIconTitleFont(WScreen
*scr
, WDefaultEntry
*entry
, WFont
*font
, void *foo
)
2449 if (scr
->icon_title_font
) {
2450 wFreeFont(scr
->icon_title_font
);
2453 scr
->icon_title_font
= font
;
2456 XSetFont(dpy
, scr
->icon_title_gc
, font
->font
->fid
);
2459 return REFRESH_ICON_FONT
;
2464 setClipTitleFont(WScreen
*scr
, WDefaultEntry
*entry
, WFont
*font
, void *foo
)
2466 if (scr
->clip_title_font
) {
2467 wFreeFont(scr
->clip_title_font
);
2470 scr
->clip_title_font
= font
;
2473 XSetFont(dpy
, scr
->clip_title_gc
, font
->font
->fid
);
2476 return REFRESH_ICON_FONT
;
2481 setDisplayFont(WScreen
*scr
, WDefaultEntry
*entry
, WFont
*font
, void *foo
)
2483 if (scr
->info_text_font
) {
2484 wFreeFont(scr
->info_text_font
);
2487 scr
->info_text_font
= font
;
2490 XSetFont(dpy
, scr
->info_text_gc
, font
->font
->fid
);
2491 XSetFont(dpy
, scr
->line_gc
, font
->font
->fid
);
2494 /* This test works because the scr structure is initially zeroed out
2495 and None = 0. Any other time, the window should be valid. */
2496 if (scr
->geometry_display
!= None
) {
2497 wGetGeometryWindowSize(scr
, &scr
->geometry_display_width
,
2498 &scr
->geometry_display_height
);
2499 XResizeWindow(dpy
, scr
->geometry_display
,
2500 scr
->geometry_display_width
, scr
->geometry_display_height
);
2508 setHightlight(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, void *foo
)
2510 if (scr
->select_pixel
!=scr
->white_pixel
&&
2511 scr
->select_pixel
!=scr
->black_pixel
) {
2512 wFreeColor(scr
, scr
->select_pixel
);
2515 scr
->select_pixel
= color
->pixel
;
2517 return REFRESH_MENU_COLOR
;
2522 setHightlightText(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, void *foo
)
2524 if (scr
->select_text_pixel
!=scr
->white_pixel
&&
2525 scr
->select_text_pixel
!=scr
->black_pixel
) {
2526 wFreeColor(scr
, scr
->select_text_pixel
);
2529 scr
->select_text_pixel
= color
->pixel
;
2531 return REFRESH_MENU_COLOR
;
2536 setClipTitleColor(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, long index
)
2538 if (scr
->clip_title_pixel
[index
]!=scr
->white_pixel
&&
2539 scr
->clip_title_pixel
[index
]!=scr
->black_pixel
) {
2540 wFreeColor(scr
, scr
->clip_title_pixel
[index
]);
2542 scr
->clip_title_pixel
[index
] = color
->pixel
;
2544 if (index
== CLIP_NORMAL
) {
2546 RColor color1
, color2
;
2547 int pt
= CLIP_BUTTON_SIZE
*wPreferences
.icon_size
/64;
2548 int as
= pt
- 15; /* 15 = 5+5+5 */
2550 FREE_PIXMAP(scr
->clip_arrow_gradient
);
2552 color1
.red
= (color
->red
>> 8)*6/10;
2553 color1
.green
= (color
->green
>> 8)*6/10;
2554 color1
.blue
= (color
->blue
>> 8)*6/10;
2556 color2
.red
= WMIN((color
->red
>> 8)*20/10, 255);
2557 color2
.green
= WMIN((color
->green
>> 8)*20/10, 255);
2558 color2
.blue
= WMIN((color
->blue
>> 8)*20/10, 255);
2560 image
= RRenderGradient(as
+1, as
+1, &color1
, &color2
, RDiagonalGradient
);
2561 RConvertImage(scr
->rcontext
, image
, &scr
->clip_arrow_gradient
);
2562 RDestroyImage(image
);
2564 return REFRESH_ICON_TITLE_COLOR
;
2569 setWTitleColor(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, long index
)
2571 if (scr
->window_title_pixel
[index
]!=scr
->white_pixel
&&
2572 scr
->window_title_pixel
[index
]!=scr
->black_pixel
) {
2573 wFreeColor(scr
, scr
->window_title_pixel
[index
]);
2576 scr
->window_title_pixel
[index
] = color
->pixel
;
2578 if (index
== WS_UNFOCUSED
)
2579 XSetForeground(dpy
, scr
->info_text_gc
, color
->pixel
);
2581 return REFRESH_WINDOW_TITLE_COLOR
;
2586 setMenuTitleColor(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, long index
)
2588 #ifdef TITLE_TEXT_SHADOW
2589 if (index
== WS_SMENU
){
2590 if (scr
->menu_title_pixel
[WS_SMENU
]!=scr
->white_pixel
&&
2591 scr
->menu_title_pixel
[WS_SMENU
]!=scr
->black_pixel
) {
2592 wFreeColor(scr
, scr
->menu_title_pixel
[WS_SMENU
]);
2594 scr
->menu_title_pixel
[WS_SMENU
] = color
->pixel
;
2597 if (scr
->menu_title_pixel
[0]!=scr
->white_pixel
&&
2598 scr
->menu_title_pixel
[0]!=scr
->black_pixel
) {
2599 wFreeColor(scr
, scr
->menu_title_pixel
[0]);
2601 scr
->menu_title_pixel
[0] = color
->pixel
;
2603 #else /* !TITLE_TEXT_SHADOW */
2604 if (scr
->menu_title_pixel
[0]!=scr
->white_pixel
&&
2605 scr
->menu_title_pixel
[0]!=scr
->black_pixel
) {
2606 wFreeColor(scr
, scr
->menu_title_pixel
[0]);
2609 scr
->menu_title_pixel
[0] = color
->pixel
;
2610 #endif /* !TITLE_TEXT_SHADOW */
2611 XSetForeground(dpy
, scr
->menu_title_gc
, color
->pixel
);
2613 return REFRESH_MENU_TITLE_COLOR
;
2618 setMenuTextColor(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, void *foo
)
2621 #define gcm (GCForeground|GCBackground|GCFillStyle)
2623 if (scr
->mtext_pixel
!=scr
->white_pixel
&&
2624 scr
->mtext_pixel
!=scr
->black_pixel
) {
2625 wFreeColor(scr
, scr
->mtext_pixel
);
2628 scr
->mtext_pixel
= color
->pixel
;
2630 XSetForeground(dpy
, scr
->menu_entry_gc
, color
->pixel
);
2633 if (scr
->dtext_pixel
== scr
->mtext_pixel
) {
2634 gcv
.foreground
= scr
->white_pixel
;
2635 gcv
.background
= scr
->black_pixel
;
2636 gcv
.fill_style
= FillStippled
;
2638 gcv
.foreground
= scr
->dtext_pixel
;
2639 gcv
.fill_style
= FillSolid
;
2641 XChangeGC(dpy
, scr
->disabled_menu_entry_gc
, gcm
, &gcv
);
2643 return REFRESH_MENU_COLOR
;
2649 setMenuDisabledColor(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, void *foo
)
2652 #define gcm (GCForeground|GCBackground|GCFillStyle)
2654 if (scr
->dtext_pixel
!=scr
->white_pixel
&&
2655 scr
->dtext_pixel
!=scr
->black_pixel
) {
2656 wFreeColor(scr
, scr
->dtext_pixel
);
2659 scr
->dtext_pixel
= color
->pixel
;
2661 if (scr
->dtext_pixel
== scr
->mtext_pixel
) {
2662 gcv
.foreground
= scr
->white_pixel
;
2663 gcv
.background
= scr
->black_pixel
;
2664 gcv
.fill_style
= FillStippled
;
2666 gcv
.foreground
= scr
->dtext_pixel
;
2667 gcv
.fill_style
= FillSolid
;
2669 XChangeGC(dpy
, scr
->disabled_menu_entry_gc
, gcm
, &gcv
);
2671 return REFRESH_MENU_COLOR
;
2676 setIconTitleColor(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, void *foo
)
2678 XSetForeground(dpy
, scr
->icon_title_gc
, color
->pixel
);
2680 return REFRESH_ICON_TITLE_COLOR
;
2685 setIconTitleBack(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, void *foo
)
2687 if (scr
->icon_title_texture
) {
2688 wTextureDestroy(scr
, (WTexture
*)scr
->icon_title_texture
);
2690 XQueryColor (dpy
, scr
->w_colormap
, color
);
2691 scr
->icon_title_texture
= wTextureMakeSolid(scr
, color
);
2693 return REFRESH_ICON_TITLE_BACK
;
2698 trackDeadProcess(pid_t pid
, unsigned char status
, WScreen
*scr
)
2700 close(scr
->helper_fd
);
2702 scr
->helper_pid
= 0;
2703 scr
->flags
.backimage_helper_launched
= 0;
2708 setWorkspaceSpecificBack(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
,
2715 if (scr
->flags
.backimage_helper_launched
) {
2716 if (PLGetNumberOfElements(value
)==0) {
2717 SendHelperMessage(scr
, 'C', 0, NULL
);
2718 SendHelperMessage(scr
, 'K', 0, NULL
);
2727 if (PLGetNumberOfElements(value
) == 0)
2730 if (pipe(filedes
) < 0) {
2731 wsyserror("pipe() failed:can't set workspace specific background image");
2739 wsyserror("fork() failed:can't set workspace specific background image");
2740 if (close(filedes
[0]) < 0)
2741 wsyserror("could not close pipe");
2742 if (close(filedes
[1]) < 0)
2743 wsyserror("could not close pipe");
2745 } else if (pid
== 0) {
2746 SetupEnvironment(scr
);
2749 wsyserror("could not close pipe");
2750 if (dup(filedes
[0]) < 0) {
2751 wsyserror("dup() failed:can't set workspace specific background image");
2753 execlp("wmsetbg", "wmsetbg", "-helper", "-d", NULL
);
2754 wsyserror("could not execute wmsetbg");
2758 if (fcntl(filedes
[0], F_SETFD
, FD_CLOEXEC
) < 0) {
2759 wsyserror("error setting close-on-exec flag");
2761 if (fcntl(filedes
[1], F_SETFD
, FD_CLOEXEC
) < 0) {
2762 wsyserror("error setting close-on-exec flag");
2765 scr
->helper_fd
= filedes
[1];
2766 scr
->helper_pid
= pid
;
2767 scr
->flags
.backimage_helper_launched
= 1;
2769 wAddDeathHandler(pid
, (WDeathHandler
*)trackDeadProcess
, scr
);
2771 SendHelperMessage(scr
, 'P', -1, wPreferences
.pixmap_path
);
2775 for (i
= 0; i
< PLGetNumberOfElements(value
); i
++) {
2776 val
= PLGetArrayElement(value
, i
);
2777 if (val
&& PLIsArray(val
) && PLGetNumberOfElements(val
)>0) {
2778 str
= PLGetDescription(val
);
2780 SendHelperMessage(scr
, 'S', i
+1, str
);
2784 SendHelperMessage(scr
, 'U', i
+1, NULL
);
2795 setWorkspaceBack(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
,
2798 if (scr
->flags
.backimage_helper_launched
) {
2801 if (PLGetNumberOfElements(value
)==0) {
2802 SendHelperMessage(scr
, 'U', 0, NULL
);
2804 /* set the default workspace background to this one */
2805 str
= PLGetDescription(value
);
2807 SendHelperMessage(scr
, 'S', 0, str
);
2809 SendHelperMessage(scr
, 'C', scr
->current_workspace
+1, NULL
);
2811 SendHelperMessage(scr
, 'U', 0, NULL
);
2818 SetupEnvironment(scr
);
2819 text
= PLGetDescription(value
);
2820 command
= wmalloc(strlen(text
)+40);
2821 sprintf(command
, "wmsetbg -d -p '%s' &", text
);
2833 setWidgetColor(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
2835 if (scr
->widget_texture
) {
2836 wTextureDestroy(scr
, (WTexture
*)scr
->widget_texture
);
2838 scr
->widget_texture
= *(WTexSolid
**)texture
;
2840 if (scr
->geometry_display
!= None
)
2841 XSetWindowBackground(dpy
, scr
->geometry_display
,
2842 scr
->widget_texture
->normal
.pixel
);
2849 setFTitleBack(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
2851 if (scr
->window_title_texture
[WS_FOCUSED
]) {
2852 wTextureDestroy(scr
, scr
->window_title_texture
[WS_FOCUSED
]);
2854 scr
->window_title_texture
[WS_FOCUSED
] = *texture
;
2856 return REFRESH_WINDOW_TEXTURES
;
2861 setPTitleBack(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
2863 if (scr
->window_title_texture
[WS_PFOCUSED
]) {
2864 wTextureDestroy(scr
, scr
->window_title_texture
[WS_PFOCUSED
]);
2866 scr
->window_title_texture
[WS_PFOCUSED
] = *texture
;
2868 return REFRESH_WINDOW_TEXTURES
;
2873 setUTitleBack(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
2875 if (scr
->window_title_texture
[WS_UNFOCUSED
]) {
2876 wTextureDestroy(scr
, scr
->window_title_texture
[WS_UNFOCUSED
]);
2878 scr
->window_title_texture
[WS_UNFOCUSED
] = *texture
;
2880 return REFRESH_WINDOW_TEXTURES
;
2885 setResizebarBack(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
2887 if (scr
->resizebar_texture
[0]) {
2888 wTextureDestroy(scr
, scr
->resizebar_texture
[0]);
2890 scr
->resizebar_texture
[0] = *texture
;
2892 return REFRESH_WINDOW_TEXTURES
;
2897 setMenuTitleBack(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
2899 if (scr
->menu_title_texture
[0]) {
2900 wTextureDestroy(scr
, scr
->menu_title_texture
[0]);
2902 scr
->menu_title_texture
[0] = *texture
;
2904 return REFRESH_MENU_TITLE_TEXTURE
;
2909 setMenuTextBack(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
2911 if (scr
->menu_item_texture
) {
2912 wTextureDestroy(scr
, scr
->menu_item_texture
);
2913 wTextureDestroy(scr
, (WTexture
*)scr
->menu_item_auxtexture
);
2915 scr
->menu_item_texture
= *texture
;
2917 scr
->menu_item_auxtexture
2918 = wTextureMakeSolid(scr
, &scr
->menu_item_texture
->any
.color
);
2920 return REFRESH_MENU_TEXTURE
;
2925 setKeyGrab(WScreen
*scr
, WDefaultEntry
*entry
, WShortKey
*shortcut
, long index
)
2928 wKeyBindings
[index
] = *shortcut
;
2930 wwin
= scr
->focused_window
;
2932 while (wwin
!=NULL
) {
2933 XUngrabKey(dpy
, AnyKey
, AnyModifier
, wwin
->frame
->core
->window
);
2935 if (!WFLAGP(wwin
, no_bind_keys
)) {
2936 wWindowSetKeyGrabs(wwin
);
2946 setIconPosition(WScreen
*scr
, WDefaultEntry
*entry
, void *bar
, void *foo
)
2948 wArrangeIcons(scr
, True
);
2955 updateUsableArea(WScreen
*scr
, WDefaultEntry
*entry
, void *bar
, void *foo
)
2957 wScreenUpdateUsableArea(scr
);
2964 setMenuStyle(WScreen
*scr
, WDefaultEntry
*entry
, int *value
, void *foo
)
2966 return REFRESH_MENU_TEXTURE
;
2972 setButtonImages(WScreen *scr, WDefaultEntry *entry, int *value, void *foo)
2974 return REFRESH_BUTTON_IMAGES;
2980 * Need access to the double click variables, so that all widgets in
2981 * wmaker panels will have the same dbl-click values.
2982 * TODO: figure a better way of dealing with it.
2987 setDoubleClick(WScreen
*scr
, WDefaultEntry
*entry
, int *value
, void *foo
)
2989 extern _WINGsConfiguration WINGsConfiguration
;
2994 WINGsConfiguration
.doubleClickDelay
= *value
;