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>
36 #define PATH_MAX DEFAULT_PATH_MAX
40 #include <X11/Xutil.h>
41 #include <X11/keysym.h>
46 #include "WindowMaker.h"
52 #include "resources.h"
55 #include "xmodifier.h"
60 #include "workspace.h"
64 * Our own proplist reader parser. This one will not accept any
65 * syntax errors and is more descriptive in the error messages.
66 * It also doesn't seem to crash.
68 extern proplist_t
ReadProplistFromFile(char *file
);
73 extern WDDomain
*WDWindowMaker
;
74 extern WDDomain
*WDWindowAttributes
;
75 extern WDDomain
*WDRootMenu
;
77 extern int wScreenCount
;
80 extern proplist_t wDomainName;
81 extern proplist_t wAttributeDomainName;
83 extern WPreferences wPreferences
;
85 extern WShortKey wKeyBindings
[WKBD_LAST
];
99 /* used to map strings to integers */
104 } WOptionEnumeration
;
108 /* type converters */
109 static int getBool();
111 static int getCoord();
113 /* this is not used yet */
114 static int getString();
116 static int getPathList();
117 static int getEnum();
118 static int getTexture();
119 static int getWSBackground();
120 static int getFont();
121 static int getColor();
122 static int getKeybind();
123 static int getModMask();
126 /* value setting functions */
127 static int setJustify();
128 static int setIfDockPresent();
129 static int setStickyIcons();
131 static int setPositive();
133 static int setWidgetColor();
134 static int setIconTile();
135 static int setWinTitleFont();
136 static int setMenuTitleFont();
137 static int setMenuTextFont();
138 static int setIconTitleFont();
139 static int setDisplayFont();
140 static int setWTitleColor();
141 static int setFTitleBack();
142 static int setPTitleBack();
143 static int setUTitleBack();
144 static int setWorkspaceBack();
145 static int setMenuTitleColor();
146 static int setMenuTextColor();
147 static int setMenuDisabledColor();
148 static int setMenuTitleBack();
149 static int setMenuTextBack();
150 static int setHightlight();
151 static int setHightlightText();
152 static int setKeyGrab();
153 static int setDoubleClick();
154 static int setIconPosition();
156 static int setClipTitleFont();
157 static int setClipTitleColor();
162 * Tables to convert strings to enumeration values.
163 * Values stored are char
167 /* WARNING: sum of length of all value strings must not exceed
169 #define TOTAL_VALUES_LENGTH 80
173 static WOptionEnumeration seFocusModes
[] = {
174 {"Manual", WKF_CLICK
, 0}, {"ClickToFocus", WKF_CLICK
, 1},
175 {"Auto", WKF_POINTER
, 0}, {"FocusFollowMouse", WKF_POINTER
, 1},
176 {"Sloppy", WKF_SLOPPY
, 0}, {"SemiAuto", WKF_SLOPPY
, 1},
180 static WOptionEnumeration seColormapModes
[] = {
181 {"Manual", WKF_CLICK
, 0}, {"ClickToFocus", WKF_CLICK
, 1},
182 {"Auto", WKF_POINTER
, 0}, {"FocusFollowMouse", WKF_POINTER
, 1},
186 static WOptionEnumeration sePlacements
[] = {
187 {"Auto", WPM_SMART
, 0}, {"Smart", WPM_SMART
, 1},
188 {"Cascade", WPM_CASCADE
, 0},
189 {"Random", WPM_RANDOM
, 0},
190 {"Manual", WPM_MANUAL
, 0},
194 static WOptionEnumeration seGeomDisplays
[] = {
195 {"Center", WDIS_CENTER
, 0},
196 {"Corner", WDIS_TOPLEFT
, 0},
197 {"Floating", WDIS_FRAME_CENTER
, 0},
198 {"Line", WDIS_NEW
, 0},
202 static WOptionEnumeration seSpeeds
[] = {
203 {"UltraFast", SPEED_ULTRAFAST
, 0},
204 {"Fast", SPEED_FAST
, 0},
205 {"Medium", SPEED_MEDIUM
, 0},
206 {"Slow", SPEED_SLOW
, 0},
207 {"UltraSlow", SPEED_ULTRASLOW
, 0},
211 static WOptionEnumeration seMouseButtons
[] = {
212 {"Left", Button1
, 0}, {"Button1", Button1
, 1},
213 {"Middle", Button2
, 0}, {"Button2", Button2
, 1},
214 {"Right", Button3
, 0}, {"Button3", Button3
, 1},
215 {"Button4", Button4
, 0},
216 {"Button5", Button5
, 0},
220 static WOptionEnumeration seIconificationStyles
[] = {
221 {"Zoom", WIS_ZOOM
, 0},
222 {"Twist", WIS_TWIST
, 0},
223 {"Flip", WIS_FLIP
, 0},
224 {"None", WIS_NONE
, 0},
228 static WOptionEnumeration seJustifications
[] = {
229 {"Left", WTJ_LEFT
, 0},
230 {"Center", WTJ_CENTER
, 0},
231 {"Right", WTJ_RIGHT
, 0},
235 static WOptionEnumeration seIconPositions
[] = {
236 {"blv", IY_BOTTOM
|IY_LEFT
|IY_VERT
, 0},
237 {"blh", IY_BOTTOM
|IY_LEFT
|IY_HORIZ
, 0},
238 {"brv", IY_BOTTOM
|IY_RIGHT
|IY_VERT
, 0},
239 {"brh", IY_BOTTOM
|IY_RIGHT
|IY_HORIZ
, 0},
240 {"tlv", IY_TOP
|IY_LEFT
|IY_VERT
, 0},
241 {"tlh", IY_TOP
|IY_LEFT
|IY_HORIZ
, 0},
242 {"trv", IY_TOP
|IY_RIGHT
|IY_VERT
, 0},
243 {"trh", IY_TOP
|IY_RIGHT
|IY_HORIZ
, 0},
250 * All entries in the tables bellow, NEED to have a default value
251 * defined, and this value needs to be correct.
254 /* these options will only affect the window manager on startup
256 * static defaults can't access the screen data, because it is
257 * created after these defaults are read
259 WDefaultEntry staticOptionList
[] = {
261 {"DisableDithering", "NO", NULL
,
262 &wPreferences
.no_dithering
, getBool
, NULL
264 {"ColormapSize", "4", NULL
,
265 &wPreferences
.cmap_size
, getInt
, NULL
267 /* static by laziness */
268 {"IconSize", "64", NULL
,
269 &wPreferences
.icon_size
, getInt
, NULL
271 {"ModifierKey", "Mod1", NULL
,
272 &wPreferences
.modifier_mask
, getModMask
, NULL
274 {"DisableWSMouseActions", "NO", NULL
,
275 &wPreferences
.disable_root_mouse
, getBool
, NULL
277 {"FocusMode", "manual", seFocusModes
,
278 &wPreferences
.focus_mode
, getEnum
, NULL
279 }, /* have a problem when switching from manual to sloppy without restart */
280 {"NewStyle", "NO", NULL
,
281 &wPreferences
.new_style
, getBool
, NULL
283 {"DisableDock", "NO", (void*) WM_DOCK
,
284 NULL
, getBool
, setIfDockPresent
286 {"DisableClip", "NO", (void*) WM_CLIP
,
287 NULL
, getBool
, setIfDockPresent
293 WDefaultEntry optionList
[] = {
294 /* dynamic options */
295 {"IconPosition", "blh", seIconPositions
,
296 &wPreferences
.icon_yard
, getEnum
, setIconPosition
298 {"IconificationStyle", "Zoom", seIconificationStyles
,
299 &wPreferences
.iconification_style
, getEnum
, NULL
301 {"SelectWindowsMouseButton", "Left", seMouseButtons
,
302 &wPreferences
.select_button
, getEnum
, NULL
304 {"WindowListMouseButton", "Middle", seMouseButtons
,
305 &wPreferences
.windowl_button
, getEnum
, NULL
307 {"ApplicationMenuMouseButton", "Right", seMouseButtons
,
308 &wPreferences
.menu_button
, getEnum
, NULL
310 {"PixmapPath", DEF_PIXMAP_PATHS
, NULL
,
311 &wPreferences
.pixmap_path
, getPathList
, NULL
313 {"IconPath", DEF_ICON_PATHS
, NULL
,
314 &wPreferences
.icon_path
, getPathList
, NULL
316 {"ColormapMode", "auto", seColormapModes
,
317 &wPreferences
.colormap_mode
, getEnum
, NULL
319 {"AutoFocus", "NO", NULL
,
320 &wPreferences
.auto_focus
, getBool
, NULL
322 {"RaiseDelay", "0", NULL
,
323 &wPreferences
.raise_delay
, getInt
, NULL
325 {"CirculateRaise", "NO", NULL
,
326 &wPreferences
.circ_raise
, getBool
, NULL
328 {"Superfluous", "NO", NULL
,
329 &wPreferences
.superfluous
, getBool
, NULL
331 {"AdvanceToNewWorkspace", "NO", NULL
,
332 &wPreferences
.ws_advance
, getBool
, NULL
334 {"CycleWorkspaces", "NO", NULL
,
335 &wPreferences
.ws_cycle
, getBool
, NULL
337 {"StickyIcons", "NO", NULL
,
338 &wPreferences
.sticky_icons
, getBool
, setStickyIcons
340 {"SaveSessionOnExit", "NO", NULL
,
341 &wPreferences
.save_session_on_exit
, getBool
, NULL
343 {"WrapMenus", "NO", NULL
,
344 &wPreferences
.wrap_menus
, getBool
, NULL
346 {"ScrollableMenus", "NO", NULL
,
347 &wPreferences
.scrollable_menus
, getBool
, NULL
349 {"MenuScrollSpeed", "medium", seSpeeds
,
350 &wPreferences
.menu_scroll_speed
, getEnum
, NULL
352 {"IconSlideSpeed", "medium", seSpeeds
,
353 &wPreferences
.icon_slide_speed
, getEnum
, NULL
355 {"ShadeSpeed", "medium", seSpeeds
,
356 &wPreferences
.shade_speed
, getEnum
, NULL
358 {"DoubleClickTime", "250", (void*) &wPreferences
.dblclick_time
,
359 &wPreferences
.dblclick_time
, getInt
, setDoubleClick
,
361 {"AlignSubmenus", "NO", NULL
,
362 &wPreferences
.align_menus
, getBool
, NULL
364 {"OnTopTransients", "NO", NULL
,
365 &wPreferences
.on_top_transients
, getBool
, NULL
367 {"WindowPlacement", "auto", sePlacements
,
368 &wPreferences
.window_placement
, getEnum
, NULL
370 {"IgnoreFocusClick","NO", NULL
,
371 &wPreferences
.ignore_focus_click
, getBool
, NULL
373 {"UseSaveUnders", "NO", NULL
,
374 &wPreferences
.use_saveunders
, getBool
, NULL
376 {"OpaqueMove", "NO", NULL
,
377 &wPreferences
.opaque_move
, getBool
, NULL
379 {"DisableSound", "NO", NULL
,
380 &wPreferences
.no_sound
, getBool
, NULL
382 {"DisableAnimations", "NO", NULL
,
383 &wPreferences
.no_animations
, getBool
, NULL
385 {"DontLinkWorkspaces","NO", NULL
,
386 &wPreferences
.no_autowrap
, getBool
, NULL
388 {"EdgeResistance", "0", NULL
,
389 &wPreferences
.edge_resistance
,getInt
, NULL
391 {"AutoArrangeIcons", "NO", NULL
,
392 &wPreferences
.auto_arrange_icons
, getBool
, NULL
395 {"NoWindowUnderDock", "NO", NULL,
396 &wPreferences.no_window_under_dock, getBool, NULL
399 {"NoWindowOverIcons", "NO", NULL
,
400 &wPreferences
.no_window_over_icons
, getBool
, NULL
402 {"WindowPlaceOrigin", "(0, 0)", NULL
,
403 &wPreferences
.window_place_origin
, getCoord
, NULL
405 {"ResizeDisplay", "corner", seGeomDisplays
,
406 &wPreferences
.size_display
, getEnum
, NULL
408 {"MoveDisplay", "corner", seGeomDisplays
,
409 &wPreferences
.move_display
, getEnum
, NULL
411 {"DontConfirmKill", "NO", NULL
,
412 &wPreferences
.dont_confirm_kill
, getBool
,NULL
414 {"WindowTitleBalloons", "NO", NULL
,
415 &wPreferences
.window_balloon
, getBool
, NULL
417 {"MiniwindowTitleBalloons", "NO", NULL
,
418 &wPreferences
.miniwin_balloon
,getBool
, NULL
420 {"AppIconBalloons", "NO", NULL
,
421 &wPreferences
.appicon_balloon
,getBool
, NULL
423 {"DisableBlinking", "NO", NULL
,
424 &wPreferences
.dont_blink
, getBool
, NULL
427 {"WidgetColor", "(solid, gray)", NULL
,
428 NULL
, getTexture
, setWidgetColor
,
430 {"WorkspaceBack", "(solid, black)", NULL
,
431 NULL
, getWSBackground
,setWorkspaceBack
433 {"IconBack", "(solid, gray)", NULL
,
434 NULL
, getTexture
, setIconTile
436 {"TitleJustify", "center", seJustifications
,
437 &wPreferences
.title_justification
, getEnum
, setJustify
439 {"WindowTitleFont", DEF_TITLE_FONT
, NULL
,
440 NULL
, getFont
, setWinTitleFont
442 {"MenuTitleFont", DEF_MENU_TITLE_FONT
, NULL
,
443 NULL
, getFont
, setMenuTitleFont
445 {"MenuTextFont", DEF_MENU_ENTRY_FONT
, NULL
,
446 NULL
, getFont
, setMenuTextFont
448 {"IconTitleFont", DEF_ICON_TITLE_FONT
, NULL
,
449 NULL
, getFont
, setIconTitleFont
451 {"ClipTitleFont", DEF_CLIP_TITLE_FONT
, NULL
,
452 NULL
, getFont
, setClipTitleFont
454 {"DisplayFont", DEF_INFO_TEXT_FONT
, NULL
,
455 NULL
, getFont
, setDisplayFont
457 {"HighlightColor", "white", NULL
,
458 NULL
, getColor
, setHightlight
460 {"HighlightTextColor", "black", NULL
,
461 NULL
, getColor
, setHightlightText
463 {"ClipTitleColor", "black", (void*)CLIP_NORMAL
,
464 NULL
, getColor
, setClipTitleColor
466 {"CClipTitleColor", "\"#454045\"", (void*)CLIP_COLLAPSED
,
467 NULL
, getColor
, setClipTitleColor
469 {"FTitleColor", "white", (void*)WS_FOCUSED
,
470 NULL
, getColor
, setWTitleColor
472 {"PTitleColor", "white", (void*)WS_PFOCUSED
,
473 NULL
, getColor
, setWTitleColor
475 {"UTitleColor", "black", (void*)WS_UNFOCUSED
,
476 NULL
, getColor
, setWTitleColor
478 {"FTitleBack", "(solid, black)", NULL
,
479 NULL
, getTexture
, setFTitleBack
481 {"PTitleBack", "(solid, \"#616161\")", NULL
,
482 NULL
, getTexture
, setPTitleBack
484 {"UTitleBack", "(solid, gray)", NULL
,
485 NULL
, getTexture
, setUTitleBack
487 {"MenuTitleColor", "white", NULL
,
488 NULL
, getColor
, setMenuTitleColor
490 {"MenuTextColor", "black", NULL
,
491 NULL
, getColor
, setMenuTextColor
493 {"MenuDisabledColor", "\"#616161\"", NULL
,
494 NULL
, getColor
, setMenuDisabledColor
496 {"MenuTitleBack", "(solid, black)", NULL
,
497 NULL
, getTexture
, setMenuTitleBack
499 {"MenuTextBack", "(solid, gray)", NULL
,
500 NULL
, getTexture
, setMenuTextBack
504 {"RootMenuKey", "None", (void*)WKBD_ROOTMENU
,
505 NULL
, getKeybind
, setKeyGrab
507 {"WindowListKey", "None", (void*)WKBD_WINDOWLIST
,
508 NULL
, getKeybind
, setKeyGrab
510 {"WindowMenuKey", "None", (void*)WKBD_WINDOWMENU
,
511 NULL
, getKeybind
, setKeyGrab
513 {"ClipLowerKey", "None", (void*)WKBD_CLIPLOWER
,
514 NULL
, getKeybind
, setKeyGrab
516 {"ClipRaiseKey", "None", (void*)WKBD_CLIPRAISE
,
517 NULL
, getKeybind
, setKeyGrab
519 {"ClipRaiseLowerKey", "None", (void*)WKBD_CLIPRAISELOWER
,
520 NULL
, getKeybind
, setKeyGrab
522 {"MiniaturizeKey", "None", (void*)WKBD_MINIATURIZE
,
523 NULL
, getKeybind
, setKeyGrab
525 {"HideKey", "None", (void*)WKBD_HIDE
,
526 NULL
, getKeybind
, setKeyGrab
528 {"CloseKey", "None", (void*)WKBD_CLOSE
,
529 NULL
, getKeybind
, setKeyGrab
531 {"MaximizeKey", "None", (void*)WKBD_MAXIMIZE
,
532 NULL
, getKeybind
, setKeyGrab
534 {"VMaximizeKey", "None", (void*)WKBD_VMAXIMIZE
,
535 NULL
, getKeybind
, setKeyGrab
537 {"RaiseKey", "Meta+Up", (void*)WKBD_RAISE
,
538 NULL
, getKeybind
, setKeyGrab
540 {"LowerKey", "Meta+Down", (void*)WKBD_LOWER
,
541 NULL
, getKeybind
, setKeyGrab
543 {"RaiseLowerKey", "None", (void*)WKBD_RAISELOWER
,
544 NULL
, getKeybind
, setKeyGrab
546 {"ShadeKey", "None", (void*)WKBD_SHADE
,
547 NULL
, getKeybind
, setKeyGrab
549 {"SelectKey", "None", (void*)WKBD_SELECT
,
550 NULL
, getKeybind
, setKeyGrab
552 {"FocusNextKey", "None", (void*)WKBD_FOCUSNEXT
,
553 NULL
, getKeybind
, setKeyGrab
555 {"FocusPrevKey", "None", (void*)WKBD_FOCUSPREV
,
556 NULL
, getKeybind
, setKeyGrab
558 {"NextWorkspaceKey", "None", (void*)WKBD_NEXTWORKSPACE
,
559 NULL
, getKeybind
, setKeyGrab
561 {"PrevWorkspaceKey", "None", (void*)WKBD_PREVWORKSPACE
,
562 NULL
, getKeybind
, setKeyGrab
564 {"NextWorkspaceLayerKey", "None", (void*)WKBD_NEXTWSLAYER
,
565 NULL
, getKeybind
, setKeyGrab
567 {"PrevWorkspaceLayerKey", "None", (void*)WKBD_PREVWSLAYER
,
568 NULL
, getKeybind
, setKeyGrab
570 {"Workspace1Key", "None", (void*)WKBD_WORKSPACE1
,
571 NULL
, getKeybind
, setKeyGrab
573 {"Workspace2Key", "None", (void*)WKBD_WORKSPACE2
,
574 NULL
, getKeybind
, setKeyGrab
576 {"Workspace3Key", "None", (void*)WKBD_WORKSPACE3
,
577 NULL
, getKeybind
, setKeyGrab
579 {"Workspace4Key", "None", (void*)WKBD_WORKSPACE4
,
580 NULL
, getKeybind
, setKeyGrab
582 {"Workspace5Key", "None", (void*)WKBD_WORKSPACE5
,
583 NULL
, getKeybind
, setKeyGrab
585 {"Workspace6Key", "None", (void*)WKBD_WORKSPACE6
,
586 NULL
, getKeybind
, setKeyGrab
588 {"Workspace7Key", "None", (void*)WKBD_WORKSPACE7
,
589 NULL
, getKeybind
, setKeyGrab
591 {"Workspace8Key", "None", (void*)WKBD_WORKSPACE8
,
592 NULL
, getKeybind
, setKeyGrab
594 {"Workspace9Key", "None", (void*)WKBD_WORKSPACE9
,
595 NULL
, getKeybind
, setKeyGrab
597 {"Workspace10Key", "None", (void*)WKBD_WORKSPACE10
,
598 NULL
, getKeybind
, setKeyGrab
600 {"WindowShortcut1Key","None", (void*)WKBD_WINDOW1
,
601 NULL
, getKeybind
, setKeyGrab
603 {"WindowShortcut2Key","None", (void*)WKBD_WINDOW2
,
604 NULL
, getKeybind
, setKeyGrab
606 {"WindowShortcut3Key","None", (void*)WKBD_WINDOW3
,
607 NULL
, getKeybind
, setKeyGrab
609 {"WindowShortcut4Key","None", (void*)WKBD_WINDOW4
,
610 NULL
, getKeybind
, setKeyGrab
612 #ifdef KEEP_XKB_LOCK_STATUS
613 {"ToggleKbdModeKey", "None", (void*)WKBD_TOGGLE
,
614 NULL
, getKeybind
, setKeyGrab
616 {"KbdModeLock", "NO", NULL
,
617 &wPreferences
.modelock
, getBool
, NULL
619 #endif /* KEEP_XKB_LOCK_STATUS */
624 static void rereadDefaults(void);
631 /* must defer the update because accessing X data from a
632 * signal handler can mess up Xlib */
641 WDefaultEntry
*entry
;
643 PLSetStringCmpHook(StringCompareHook
);
645 for (i
=0; i
<sizeof(optionList
)/sizeof(WDefaultEntry
); i
++) {
646 entry
= &optionList
[i
];
648 entry
->plkey
= PLMakeString(entry
->key
);
649 if (entry
->default_value
)
650 entry
->plvalue
= PLGetProplistWithDescription(entry
->default_value
);
652 entry
->plvalue
= NULL
;
655 for (i
=0; i
<sizeof(staticOptionList
)/sizeof(WDefaultEntry
); i
++) {
656 entry
= &staticOptionList
[i
];
658 entry
->plkey
= PLMakeString(entry
->key
);
659 if (entry
->default_value
)
660 entry
->plvalue
= PLGetProplistWithDescription(entry
->default_value
);
662 entry
->plvalue
= NULL
;
666 wDomainName = PLMakeString(WMDOMAIN_NAME);
667 wAttributeDomainName = PLMakeString(WMATTRIBUTE_DOMAIN_NAME);
669 PLRegister(wDomainName, rereadDefaults);
670 PLRegister(wAttributeDomainName, rereadDefaults);
679 wDefaultsInit(int screen_number
)
681 static int defaults_inited
= 0;
684 if (!defaults_inited
) {
688 dict
= PLGetDomain(wDomainName
);
690 wwarning(_("could not read domain \"%s\" from defaults database"),
691 PLGetString(wDomainName
));
700 wDefaultsDestroyDomain(WDDomain
*domain
)
702 if (domain
->dictionary
)
703 PLRelease(domain
->dictionary
);
710 wDefaultsInitDomain(char *domain
, Bool requireDictionary
)
714 static int inited
= 0;
717 proplist_t shared_dict
=NULL
;
724 db
= wmalloc(sizeof(WDDomain
));
725 memset(db
, 0, sizeof(WDDomain
));
726 db
->domain_name
= domain
;
727 db
->path
= wdefaultspathfordomain(domain
);
730 if (the_path
&& stat(the_path
, &stbuf
)>=0) {
731 db
->dictionary
= ReadProplistFromFile(the_path
);
732 if (db
->dictionary
) {
733 if (requireDictionary
&& !PLIsDictionary(db
->dictionary
)) {
734 PLRelease(db
->dictionary
);
735 db
->dictionary
= NULL
;
736 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
739 db
->timestamp
= stbuf
.st_mtime
;
741 wwarning(_("could not load domain %s from user defaults database"),
746 /* global system dictionary */
747 sprintf(path
, "%s/%s/%s", PKGDATADIR
, DEFAULTS_DIR
, domain
);
748 if (stat(path
, &stbuf
)>=0) {
749 shared_dict
= ReadProplistFromFile(path
);
751 if (requireDictionary
&& !PLIsDictionary(shared_dict
)) {
752 wwarning(_("Domain %s (%s) of global defaults database is corrupted!"),
754 PLRelease(shared_dict
);
757 if (db
->dictionary
&& PLIsDictionary(shared_dict
) &&
758 PLIsDictionary(db
->dictionary
)) {
759 PLMergeDictionaries(shared_dict
, db
->dictionary
);
760 PLRelease(db
->dictionary
);
761 db
->dictionary
= shared_dict
;
762 if (stbuf
.st_mtime
> db
->timestamp
)
763 db
->timestamp
= stbuf
.st_mtime
;
764 } else if (!db
->dictionary
) {
765 db
->dictionary
= shared_dict
;
766 if (stbuf
.st_mtime
> db
->timestamp
)
767 db
->timestamp
= stbuf
.st_mtime
;
771 wwarning(_("could not load domain %s from global defaults database"),
776 /* set to save it in user's directory, no matter from where it was read */
777 if (db
->dictionary
) {
778 proplist_t tmp
= PLMakeString(db
->path
);
780 PLSetFilename(db
->dictionary
, tmp
);
789 wReadStaticDefaults(proplist_t dict
)
792 WDefaultEntry
*entry
;
797 for (i
=0; i
<sizeof(staticOptionList
)/sizeof(WDefaultEntry
); i
++) {
798 entry
= &staticOptionList
[i
];
801 plvalue
= PLGetDictionaryEntry(dict
, entry
->plkey
);
806 /* no default in the DB. Use builtin default */
807 plvalue
= entry
->plvalue
;
812 (*entry
->convert
)(NULL
, entry
, plvalue
, entry
->addr
, &tdata
);
814 (*entry
->update
)(NULL
, entry
, tdata
, entry
->extra_data
);
821 wDefaultsCheckDomains(void *foo
)
830 puts("Checking domains...");
832 if (stat(WDWindowMaker
->path
, &stbuf
)>=0
833 && WDWindowMaker
->timestamp
< stbuf
.st_mtime
) {
834 proplist_t shared_dict
= NULL
;
836 puts("Checking WindowMaker domain");
838 WDWindowMaker
->timestamp
= stbuf
.st_mtime
;
840 /* global dictionary */
841 sprintf(path
, "%s/%s/WindowMaker", PKGDATADIR
, DEFAULTS_DIR
);
842 if (stat(path
, &stbuf
)>=0) {
843 shared_dict
= ReadProplistFromFile(path
);
844 if (shared_dict
&& !PLIsDictionary(shared_dict
)) {
845 wwarning(_("Domain %s (%s) of global defaults database is corrupted!"),
846 "WindowMaker", path
);
847 PLRelease(shared_dict
);
849 } else if (!shared_dict
) {
850 wwarning(_("could not load domain %s from global defaults database"),
854 /* user dictionary */
855 dict
= ReadProplistFromFile(WDWindowMaker
->path
);
857 if (!PLIsDictionary(dict
)) {
860 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
861 "WindowMaker", WDWindowMaker
->path
);
864 PLSetFilename(shared_dict
, PLGetFilename(dict
));
865 PLMergeDictionaries(shared_dict
, dict
);
870 for (i
=0; i
<wScreenCount
; i
++) {
871 scr
= wScreenWithNumber(i
);
873 wReadDefaults(scr
, dict
);
875 if (WDWindowMaker
->dictionary
) {
876 PLRelease(WDWindowMaker
->dictionary
);
878 WDWindowMaker
->dictionary
= dict
;
881 wwarning(_("could not load domain %s from user defaults database"),
885 PLRelease(shared_dict
);
889 if (stat(WDWindowAttributes
->path
, &stbuf
)>=0
890 && WDWindowAttributes
->timestamp
< stbuf
.st_mtime
) {
892 puts("Checking WMWindowAttributes domain");
894 dict
= ReadProplistFromFile(WDWindowAttributes
->path
);
896 if (!PLIsDictionary(dict
)) {
899 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
900 "WMWindowAttributes", WDWindowAttributes
->path
);
902 if (WDWindowAttributes
->dictionary
)
903 PLRelease(WDWindowAttributes
->dictionary
);
904 WDWindowAttributes
->dictionary
= dict
;
905 for (i
=0; i
<wScreenCount
; i
++) {
906 scr
= wScreenWithNumber(i
);
908 wDefaultUpdateIcons(scr
);
912 wwarning(_("could not load domain %s from user defaults database"),
913 "WMWindowAttributes");
915 WDWindowAttributes
->timestamp
= stbuf
.st_mtime
;
919 if (stat(WDRootMenu
->path
, &stbuf
)>=0
920 && WDRootMenu
->timestamp
< stbuf
.st_mtime
) {
921 dict
= ReadProplistFromFile(WDRootMenu
->path
);
923 puts("Checking WMRootMenu domain");
926 if (!PLIsArray(dict
) && !PLIsString(dict
)) {
929 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
930 "WMRootMenu", WDRootMenu
->path
);
932 if (WDRootMenu
->dictionary
) {
933 PLRelease(WDRootMenu
->dictionary
);
935 WDRootMenu
->dictionary
= dict
;
938 wwarning(_("could not load domain %s from user defaults database"),
941 WDRootMenu
->timestamp
= stbuf
.st_mtime
;
944 WMAddTimerHandler(DEFAULTS_CHECK_INTERVAL
, wDefaultsCheckDomains
, foo
);
949 #define REFRESH_WINDOW_TEXTURES (1<<0)
950 #define REFRESH_MENU_TEXTURES (1<<1)
951 #define REFRESH_WINDOW_FONT (1<<2)
952 #define REFRESH_MENU_TITLE_FONT (1<<3)
953 #define REFRESH_MENU_FONT (1<<4)
954 #define REFRESH_FORE_COLOR (1<<5)
955 #define REFRESH_ICON_TILE (1<<6)
956 #define REFRESH_ICON_FONT (1<<7)
957 #define REFRESH_WORKSPACE_BACK (1<<8)
960 refreshMenus(WScreen
*scr
, int flags
)
964 menu
= scr
->root_menu
;
966 wMenuRefresh(!menu
->flags
.brother
? menu
: menu
->brother
, flags
);
968 menu
= scr
->workspace_menu
;
970 wMenuRefresh(!menu
->flags
.brother
? menu
: menu
->brother
, flags
);
972 menu
= scr
->switch_menu
;
974 wMenuRefresh(!menu
->flags
.brother
? menu
: menu
->brother
, flags
);
976 menu
= scr
->window_menu
;
978 wMenuRefresh(!menu
->flags
.brother
? menu
: menu
->brother
, flags
);
980 menu
= scr
->icon_menu
;
982 wMenuRefresh(!menu
->flags
.brother
? menu
: menu
->brother
, flags
);
985 menu
= scr
->dock
->menu
;
987 wMenuRefresh(!menu
->flags
.brother
? menu
: menu
->brother
, flags
);
989 menu
= scr
->clip_menu
;
991 wMenuRefresh(!menu
->flags
.brother
? menu
: menu
->brother
, flags
);
993 menu
= scr
->clip_submenu
;
995 wMenuRefresh(!menu
->flags
.brother
? menu
: menu
->brother
, flags
);
997 menu
= scr
->clip_options
;
999 wMenuRefresh(!menu
->flags
.brother
? menu
: menu
->brother
, flags
);
1004 refreshAppIcons(WScreen
*scr
, int flags
)
1006 WAppIcon
*aicon
= scr
->app_icon_list
;
1010 aicon
->icon
->force_paint
= 1;
1012 aicon
= aicon
->next
;
1018 refreshWindows(WScreen
*scr
, int flags
)
1022 wwin
= scr
->focused_window
;
1024 if (flags
& REFRESH_WINDOW_FONT
) {
1025 wWindowConfigureBorders(wwin
);
1027 if ((flags
& (REFRESH_ICON_TILE
|REFRESH_WINDOW_TEXTURES
)) &&
1028 wwin
->flags
.miniaturized
&& wwin
->icon
) {
1029 wwin
->icon
->force_paint
= 1;
1031 if (flags
& REFRESH_WINDOW_TEXTURES
) {
1032 wwin
->frame
->flags
.need_texture_remake
= 1;
1040 wReadDefaults(WScreen
*scr
, proplist_t new_dict
)
1042 proplist_t plvalue
, old_value
;
1043 WDefaultEntry
*entry
;
1044 int i
, changed
, must_update
;
1047 proplist_t old_dict
= (WDWindowMaker
->dictionary
!=new_dict
1048 ? WDWindowMaker
->dictionary
: NULL
);
1055 for (i
=0; i
<sizeof(optionList
)/sizeof(WDefaultEntry
); i
++) {
1056 entry
= &optionList
[i
];
1059 plvalue
= PLGetDictionaryEntry(new_dict
, entry
->plkey
);
1066 old_value
= PLGetDictionaryEntry(old_dict
, entry
->plkey
);
1069 if (!plvalue
&& !old_value
) {
1070 /* no default in the DB. Use builtin default */
1071 plvalue
= entry
->plvalue
;
1072 if (plvalue
&& new_dict
) {
1073 PLInsertDictionaryEntry(new_dict
, entry
->plkey
, plvalue
);
1077 } else if (!plvalue
) {
1078 /* value was deleted from DB. Keep current value */
1080 } else if (!old_value
) {
1081 /* set value for the 1st time */
1083 } else if (!PLIsEqual(plvalue
, old_value
)) {
1084 /* value has changed */
1087 /* value was not changed since last time */
1093 printf("Updating %s to %s\n", entry
->key
, PLGetDescription(plvalue
));
1096 if ((*entry
->convert
)(scr
, entry
, plvalue
, entry
->addr
, &tdata
)) {
1097 if (entry
->update
) {
1099 (*entry
->update
)(scr
, entry
, tdata
, entry
->extra_data
);
1105 if (needs_refresh
!=0) {
1109 if (needs_refresh
& REFRESH_MENU_TEXTURES
)
1110 foo
|= MR_TEXT_BACK
;
1111 if (needs_refresh
& REFRESH_MENU_FONT
)
1113 if (needs_refresh
& REFRESH_MENU_TITLE_FONT
)
1114 foo
|= MR_TITLE_TEXT
;
1117 refreshMenus(scr
, foo
);
1119 if (needs_refresh
& (REFRESH_WINDOW_TEXTURES
|REFRESH_WINDOW_FONT
|
1121 refreshWindows(scr
, needs_refresh
);
1123 if (needs_refresh
& REFRESH_ICON_TILE
)
1124 refreshAppIcons(scr
, needs_refresh
);
1127 if (needs_refresh
& REFRESH_WORKSPACE_BACK
) {
1128 WWorkspaceTexture
*wsback
;
1130 /* update the background for the workspace */
1131 if (scr
->current_workspace
< scr
->wspaceTextureCount
1132 && scr
->wspaceTextures
[scr
->current_workspace
]) {
1133 wsback
= scr
->wspaceTextures
[scr
->current_workspace
];
1135 wsback
= scr
->defaultTexure
;
1138 if (wsback
->pixmap
!=None
) {
1139 XSetWindowBackgroundPixmap(dpy
, scr
->root_win
,
1142 XSetWindowBackground(dpy
, scr
->root_win
, wsback
->solid
);
1144 XClearWindow(dpy
, scr
->root_win
);
1148 #endif /* !EXPERIMENTAL */
1149 wRefreshDesktop(scr
);
1155 wDefaultUpdateIcons(WScreen
*scr
)
1157 WAppIcon
*aicon
= scr
->app_icon_list
;
1158 WWindow
*wwin
= scr
->focused_window
;
1162 file
= wDefaultGetIconFile(scr
, aicon
->wm_instance
, aicon
->wm_class
,
1164 if ((file
&& aicon
->icon
->file
&& strcmp(file
, aicon
->icon
->file
)!=0)
1165 || (file
&& !aicon
->icon
->file
)) {
1168 if (aicon
->icon
->file
)
1169 free(aicon
->icon
->file
);
1170 aicon
->icon
->file
= wstrdup(file
);
1172 new_image
= wDefaultGetImage(scr
, aicon
->wm_instance
,
1175 wIconChangeImage(aicon
->icon
, new_image
);
1176 wAppIconPaint(aicon
);
1179 aicon
= aicon
->next
;
1182 if (!wPreferences
.flags
.noclip
)
1183 wClipIconPaint(scr
->clip_icon
);
1186 if (wwin
->icon
&& wwin
->flags
.miniaturized
) {
1187 file
= wDefaultGetIconFile(scr
, wwin
->wm_instance
, wwin
->wm_class
,
1189 if ((file
&& wwin
->icon
->file
&& strcmp(file
, wwin
->icon
->file
)!=0)
1190 || (file
&& !wwin
->icon
->file
)) {
1193 if (wwin
->icon
->file
)
1194 free(wwin
->icon
->file
);
1195 wwin
->icon
->file
= wstrdup(file
);
1197 new_image
= wDefaultGetImage(scr
, wwin
->wm_instance
,
1200 wIconChangeImage(wwin
->icon
, new_image
);
1208 /* --------------------------- Local ----------------------- */
1210 #define STRINGP(x) if (!PLIsString(value)) { \
1211 wwarning(_("Wrong option format for key \"%s\". Should be %s."), \
1212 PLGetString(entry->plkey), x); \
1218 string2index(proplist_t key
, proplist_t val
, proplist_t def
,
1219 WOptionEnumeration
*values
)
1222 WOptionEnumeration
*v
;
1223 char buffer
[TOTAL_VALUES_LENGTH
];
1225 if (PLIsString(val
) && (str
= PLGetString(val
))) {
1226 for (v
=values
; v
->string
!=NULL
; v
++) {
1227 if (strcasecmp(v
->string
, str
)==0)
1233 for (v
=values
; v
->string
!=NULL
; v
++) {
1236 strcat(buffer
, ", ");
1237 strcat(buffer
, v
->string
);
1240 wwarning(_("wrong option value for key \"%s\". Should be one of %s"),
1241 PLGetString(key
), buffer
);
1244 return string2index(key
, val
, NULL
, values
);
1254 * value - is the value in the defaults DB
1255 * addr - is the address to store the data
1256 * ret - is the address to store a pointer to a temporary buffer. ret
1257 * must not be freed and is used by the set functions
1260 getBool(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
1269 val
= PLGetString(value
);
1272 if ((val
[1]=='\0' && (val
[0]=='y' || val
[0]=='Y'))
1273 || strcasecmp(val
, "YES")==0) {
1276 } else if ((val
[1]=='\0' && (val
[0]=='n' || val
[0]=='N'))
1277 || strcasecmp(val
, "NO")==0) {
1281 if (sscanf(val
, "%i", &i
)==1) {
1287 wwarning(_("can't convert \"%s\" to boolean for key \"%s\""),
1288 val
, PLGetString(entry
->plkey
));
1289 if (second_pass
==0) {
1290 val
= PLGetString(entry
->plvalue
);
1292 wwarning(_("using default \"%s\" instead"), val
);
1303 *(char*)addr
= data
;
1311 getInt(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
1320 val
= PLGetString(value
);
1322 if (sscanf(val
, "%i", &data
)!=1) {
1323 wwarning(_("can't convert \"%s\" to integer for key \"%s\""),
1324 val
, PLGetString(entry
->plkey
));
1325 val
= PLGetString(entry
->plvalue
);
1326 wwarning(_("using default \"%s\" instead"), val
);
1327 if (sscanf(val
, "%i", &data
)!=1) {
1343 getCoord(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
1347 char *val_x
, *val_y
;
1348 int nelem
, changed
=0;
1349 proplist_t elem_x
, elem_y
;
1352 if (!PLIsArray(value
)) {
1353 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1354 PLGetString(entry
->plkey
), "Coordinate");
1356 value
= entry
->plvalue
;
1358 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1364 nelem
= PLGetNumberOfElements(value
);
1366 wwarning(_("Incorrect number of elements in array for key \"%s\"."),
1367 PLGetString(entry
->plkey
));
1369 value
= entry
->plvalue
;
1371 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1377 elem_x
= PLGetArrayElement(value
, 0);
1378 elem_y
= PLGetArrayElement(value
, 1);
1380 if (!elem_x
|| !elem_y
|| !PLIsString(elem_x
) || !PLIsString(elem_y
)) {
1381 wwarning(_("Wrong value for key \"%s\". Should be Coordinate."),
1382 PLGetString(entry
->plkey
));
1384 value
= entry
->plvalue
;
1386 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1392 val_x
= PLGetString(elem_x
);
1393 val_y
= PLGetString(elem_y
);
1395 if (sscanf(val_x
, "%i", &data
.x
)!=1 || sscanf(val_y
, "%i", &data
.y
)!=1) {
1396 wwarning(_("can't convert array to integers for \"%s\"."),
1397 PLGetString(entry
->plkey
));
1399 value
= entry
->plvalue
;
1401 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1409 else if (data
.x
> scr
->scr_width
/3)
1410 data
.x
= scr
->scr_width
/3;
1413 else if (data
.y
> scr
->scr_height
/3)
1414 data
.y
= scr
->scr_height
/3;
1420 *(WCoord
*)addr
= data
;
1428 /* This function is not used at the moment. */
1430 getString(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
1437 data
= PLGetString(value
);
1440 data
= PLGetString(entry
->plvalue
);
1449 *(char**)addr
= wstrdup(data
);
1457 getPathList(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
1466 if (!PLIsArray(value
)) {
1467 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1468 PLGetString(entry
->plkey
), "an array of paths");
1470 value
= entry
->plvalue
;
1472 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1479 count
= PLGetNumberOfElements(value
);
1482 value
= entry
->plvalue
;
1484 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1490 data
= wmalloc(sizeof(char*)*(count
+1));
1491 for (i
=0; i
<count
; i
++) {
1492 d
= PLGetArrayElement(value
, i
);
1493 if (!d
|| !PLIsString(d
)) {
1496 data
[i
] = wstrdup(PLGetString(d
));
1500 if (*(char***)addr
!=NULL
) {
1501 char **tmp
= *(char***)addr
;
1502 for (i
=0; tmp
[i
]!=NULL
; i
++) {
1507 *(char***)addr
= data
;
1514 getEnum(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
1519 data
= string2index(entry
->key
, value
, entry
->default_value
,
1520 (WOptionEnumeration
*)entry
->extra_data
);
1528 *(char*)addr
= data
;
1537 * (hgradient <color> <color>)
1538 * (vgradient <color> <color>)
1539 * (dgradient <color> <color>)
1540 * (mhgradient <color> <color> ...)
1541 * (mvgradient <color> <color> ...)
1542 * (tpixmap <file> <color>)
1543 * (spixmap <file> <color>)
1544 * (cpixmap <file> <color>)
1548 parse_texture(WScreen
*scr
, proplist_t pl
)
1553 WTexture
*texture
=NULL
;
1555 nelem
= PLGetNumberOfElements(pl
);
1560 elem
= PLGetArrayElement(pl
, 0);
1561 if (!elem
|| !PLIsString(elem
))
1563 val
= PLGetString(elem
);
1566 if (strcasecmp(val
, "solid")==0) {
1574 elem
= PLGetArrayElement(pl
, 1);
1575 if (!elem
|| !PLIsString(elem
))
1577 val
= PLGetString(elem
);
1579 if (!XParseColor(dpy
, scr
->colormap
, val
, &color
)) {
1580 wwarning(_("\"%s\" is not a valid color name"), val
);
1584 texture
= (WTexture
*)wTextureMakeSolid(scr
, &color
);
1585 } else if (strcasecmp(val
, "dgradient")==0
1586 || strcasecmp(val
, "vgradient")==0
1587 || strcasecmp(val
, "hgradient")==0) {
1588 XColor color1
, color2
;
1592 wwarning(_("bad number of arguments in gradient specification"));
1596 if (val
[0]=='d' || val
[0]=='D')
1597 type
= WTEX_DGRADIENT
;
1598 else if (val
[0]=='h' || val
[0]=='H')
1599 type
= WTEX_HGRADIENT
;
1601 type
= WTEX_VGRADIENT
;
1604 /* get from color */
1605 elem
= PLGetArrayElement(pl
, 1);
1606 if (!elem
|| !PLIsString(elem
))
1608 val
= PLGetString(elem
);
1610 if (!XParseColor(dpy
, scr
->colormap
, val
, &color1
)) {
1611 wwarning(_("\"%s\" is not a valid color name"), val
);
1616 elem
= PLGetArrayElement(pl
, 2);
1617 if (!elem
|| !PLIsString(elem
)) {
1620 val
= PLGetString(elem
);
1622 if (!XParseColor(dpy
, scr
->colormap
, val
, &color2
)) {
1623 wwarning(_("\"%s\" is not a valid color name"), val
);
1627 texture
= (WTexture
*)wTextureMakeGradient(scr
, type
, &color1
, &color2
);
1629 } else if (strcasecmp(val
, "mhgradient")==0
1630 || strcasecmp(val
, "mvgradient")==0
1631 || strcasecmp(val
, "mdgradient")==0) {
1638 wwarning(_("too few arguments in multicolor gradient specification"));
1642 if (val
[1]=='h' || val
[1]=='H')
1643 type
= WTEX_MHGRADIENT
;
1644 else if (val
[1]=='v' || val
[1]=='V')
1645 type
= WTEX_MVGRADIENT
;
1647 type
= WTEX_MDGRADIENT
;
1651 colors
= wmalloc(sizeof(RColor
*)*(count
+1));
1653 for (i
=0; i
<count
; i
++) {
1654 elem
= PLGetArrayElement(pl
, i
+1);
1655 if (!elem
|| !PLIsString(elem
)) {
1656 for (--i
; i
>=0; --i
) {
1662 val
= PLGetString(elem
);
1664 if (!XParseColor(dpy
, scr
->colormap
, val
, &color
)) {
1665 wwarning(_("\"%s\" is not a valid color name"), val
);
1666 for (--i
; i
>=0; --i
) {
1672 colors
[i
] = wmalloc(sizeof(RColor
));
1673 colors
[i
]->red
= color
.red
>> 8;
1674 colors
[i
]->green
= color
.green
>> 8;
1675 colors
[i
]->blue
= color
.blue
>> 8;
1680 texture
= (WTexture
*)wTextureMakeMGradient(scr
, type
, colors
);
1681 } else if (strcasecmp(val
, "spixmap")==0 ||
1682 strcasecmp(val
, "cpixmap")==0 ||
1683 strcasecmp(val
, "tpixmap")==0) {
1690 if (val
[0] == 's' || val
[0] == 'S')
1692 else if (val
[0] == 'c' || val
[0] == 'C')
1698 elem
= PLGetArrayElement(pl
, 2);
1699 if (!elem
|| !PLIsString(elem
)) {
1702 val
= PLGetString(elem
);
1704 if (!XParseColor(dpy
, scr
->colormap
, val
, &color
)) {
1705 wwarning(_("\"%s\" is not a valid color name"), val
);
1710 elem
= PLGetArrayElement(pl
, 1);
1711 if (!elem
|| !PLIsString(elem
))
1713 val
= PLGetString(elem
);
1715 texture
= (WTexture
*)wTextureMakePixmap(scr
, type
, val
, &color
);
1726 getTexture(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
1729 static WTexture
*texture
;
1733 if (!PLIsArray(value
)) {
1734 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1735 PLGetString(entry
->plkey
), "Texture");
1737 value
= entry
->plvalue
;
1739 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1745 texture
= parse_texture(scr
, value
);
1748 wwarning(_("Error in texture specification for key \"%s\""),
1749 PLGetString(entry
->plkey
));
1751 value
= entry
->plvalue
;
1753 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1763 *(WTexture
**)addr
= texture
;
1772 getWSBackground(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
,
1773 void *addr
, void **ret
)
1778 static WTexture
*texture
=NULL
;
1783 entry
->extra_data
= NULL
;
1785 if (!PLIsArray(value
)) {
1786 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1787 "WorkspaceBack", "Texture");
1789 value
= entry
->plvalue
;
1791 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1797 nelem
= PLGetNumberOfElements(value
);
1799 wwarning(_("Too few elements in array for key \"WorkspaceBack\"."));
1801 value
= entry
->plvalue
;
1803 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1809 elem
= PLGetArrayElement(value
, 0);
1810 if (!elem
|| !PLIsString(elem
)) {
1811 wwarning(_("Wrong type for workspace background. Should be Texture."));
1813 value
= entry
->plvalue
;
1815 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1820 val
= PLGetString(elem
);
1822 if (strcasecmp(val
, "None")==0)
1825 if (strcasecmp(val
, "spixmap")!=0 && strcasecmp(val
, "tpixmap")!=0
1826 && strcasecmp(val
, "cpixmap")!=0) {
1827 texture
= parse_texture(scr
, value
);
1829 /* spixmap || tpixmap || cpixmap */
1834 wwarning(_("Too few elements in array for key \"WorkspaceBack\"."));
1836 value
= entry
->plvalue
;
1838 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1859 elem
= PLGetArrayElement(value
, 2);
1860 if (!elem
|| !PLIsString(elem
)) {
1861 wwarning(_("Cannot get color entry for key \"WorkspaceBack\"."));
1863 value
= entry
->plvalue
;
1865 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1870 val
= PLGetString(elem
);
1872 if (!XParseColor(dpy
, scr
->colormap
, val
, &color
)) {
1873 wwarning(_("key \"WorkspaceBack\" has invalid color \"%s\""),
1876 value
= entry
->plvalue
;
1878 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1885 elem
= PLGetArrayElement(value
, 1);
1886 if (!elem
|| !PLIsString(elem
)) {
1887 wwarning(_("Cannot get file entry for key \"WorkspaceBack\"."));
1889 value
= entry
->plvalue
;
1891 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1897 val
= PLGetString(elem
);
1898 file
= FindImage(wPreferences
.pixmap_path
, val
);
1900 wwarning(_("could not find background image \"%s\""), val
);
1904 /* create a dummy texture.
1905 * use free() to free this texture.
1907 texture
= wmalloc(sizeof(WTexture
));
1908 memset(texture
, 0, sizeof(WTexture
));
1909 texture
->type
= WTEX_PIXMAP
;
1910 texture
->subtype
= style
;
1911 texture
->normal
= color
;
1917 wwarning(_("Error in texture specification for key \"WorkspaceBack\""));
1919 value
= entry
->plvalue
;
1921 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1931 *(WTexture
**)addr
= texture
;
1933 /* we use the extra_data field to pass the filename string
1934 * to the background setting function. We can't pass it with
1935 * WTexture because it holds a RImage, not a file name.
1936 * It also would be dirtier to cast the RImage to char* to make it
1937 * hold the file name. The extra_data must be freed by the
1940 entry
->extra_data
= file
;
1944 #else /* !EXPERIMENTAL */
1946 getWSBackground(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
,
1947 void *addr
, void **ret
)
1952 static WTexture
*texture
=NULL
;
1956 if (!PLIsArray(value
)) {
1957 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1958 "WorkspaceBack", "Texture");
1960 value
= entry
->plvalue
;
1962 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1968 nelem
= PLGetNumberOfElements(value
);
1970 wwarning(_("Too few elements in array for key \"WorkspaceBack\"."));
1972 value
= entry
->plvalue
;
1974 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1980 elem
= PLGetArrayElement(value
, 0);
1981 if (!elem
|| !PLIsString(elem
)) {
1982 wwarning(_("Wrong type for workspace background. Should be Texture."));
1984 value
= entry
->plvalue
;
1986 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1991 val
= PLGetString(elem
);
1993 if (strcasecmp(val
, "None")==0)
1996 if (strcasecmp(val
, "spixmap")!=0 && strcasecmp(val
, "tpixmap")!=0
1997 && strcasecmp(val
, "cpixmap")!=0) {
1998 texture
= parse_texture(scr
, value
);
2001 /* spixmap || tpixmap || cpixmap */
2003 char *file
, cpc
[30], *style
= "-s";
2004 char *program
= "wmsetbg";
2008 wwarning(_("Too few elements in array for key \"WorkspaceBack\"."));
2010 value
= entry
->plvalue
;
2012 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
2018 if (val
[0] == 't' || val
[0] == 'T')
2020 else if (val
[0] == 'c' || val
[0] == 'C')
2023 sprintf(cpc
, "%i", wPreferences
.cmap_size
);
2026 elem
= PLGetArrayElement(value
, 2);
2027 if (!elem
|| !PLIsString(elem
)) {
2028 wwarning(_("Cannot get color entry for key \"WorkspaceBack\"."));
2030 value
= entry
->plvalue
;
2032 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
2037 val
= PLGetString(elem
);
2039 if (!XParseColor(dpy
, scr
->colormap
, val
, &color
)) {
2040 wwarning(_("key \"WorkspaceBack\" has invalid color \"%s\""),
2043 value
= entry
->plvalue
;
2045 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
2051 back
= wstrdup(val
);
2054 elem
= PLGetArrayElement(value
, 1);
2055 if (!elem
|| !PLIsString(elem
)) {
2056 wwarning(_("Cannot get file entry for key \"WorkspaceBack\"."));
2058 value
= entry
->plvalue
;
2060 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
2066 val
= PLGetString(elem
);
2068 file
= FindImage(wPreferences
.pixmap_path
, val
);
2071 SetupEnvironment(scr
);
2073 close(ConnectionNumber(dpy
));
2075 execlp(program
, program
, style
, "-c", cpc
, "-b", back
, file
, NULL
);
2076 wwarning(_("could not run \"%s\""), program
);
2081 wwarning(_("could not find background image \"%s\""), val
);
2086 /* This is to let WindowMaker put a color in the background
2087 * until the pixmap is loaded, if the image is big and loads slow.
2088 * It assumes that the color will be set before the image is set
2089 * by the child. Is this true for very small images?
2091 texture
= (WTexture
*)wTextureMakeSolid(scr
, &color
);
2095 wwarning(_("Error in texture specification for key \"WorkspaceBack\""));
2097 value
= entry
->plvalue
;
2099 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
2109 *(WTexture
**)addr
= texture
;
2113 #endif /* !EXPERIMENTAL */
2117 getFont(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
2125 val
= PLGetString(value
);
2127 font
= wLoadFont(val
);
2129 wwarning(_("could not load any usable font"));
2137 wwarning("BUG:can't assign font value outside update function");
2145 getColor(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
2148 static unsigned long pixel
;
2155 val
= PLGetString(value
);
2158 if (!wGetColor(scr
, val
, &color
)) {
2159 wwarning(_("could not get color for key \"%s\""),
2160 PLGetString(entry
->plkey
));
2161 if (second_pass
==0) {
2162 val
= PLGetString(entry
->plvalue
);
2164 wwarning(_("using default \"%s\" instead"), val
);
2170 pixel
= color
.pixel
;
2176 *(unsigned long*)addr
= pixel
;
2184 getKeybind(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
2187 static WShortKey shortcut
;
2194 STRINGP("Key spec");
2196 val
= PLGetString(value
);
2198 if (!val
|| strcasecmp(val
, "NONE")==0) {
2199 shortcut
.keycode
= 0;
2200 shortcut
.modifier
= 0;
2211 shortcut
.modifier
= 0;
2212 while ((k
= strchr(b
, '+'))!=NULL
) {
2216 mod
= wXModifierFromKey(b
);
2218 wwarning(_("%s:invalid key modifier \"%s\""), entry
->key
, val
);
2221 shortcut
.modifier
|= mod
;
2227 ksym
= XStringToKeysym(b
);
2229 if (ksym
==NoSymbol
) {
2230 wwarning(_("%s:invalid kbd shortcut specification \"%s\""), entry
->key
,
2235 shortcut
.keycode
= XKeysymToKeycode(dpy
, ksym
);
2236 if (shortcut
.keycode
==0) {
2237 wwarning(_("%s:invalid key in shortcut \"%s\""), entry
->key
, val
);
2249 getModMask(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
2255 STRINGP("Modifier Key");
2257 str
= PLGetString(value
);
2261 mask
= wXModifierFromKey(str
);
2263 wwarning(_("%s: modifier key %s is not valid"), entry
->key
, str
);
2269 *(unsigned int*)addr
= mask
;
2279 /* ---------------- value setting functions --------------- */
2281 setJustify(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
2283 return REFRESH_FORE_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
;
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_FORE_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_FORE_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
]);
2543 scr
->clip_title_pixel
[index
] = color
->pixel
;
2545 return REFRESH_FORE_COLOR
;
2550 setWTitleColor(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, long index
)
2552 if (scr
->window_title_pixel
[index
]!=scr
->white_pixel
&&
2553 scr
->window_title_pixel
[index
]!=scr
->black_pixel
) {
2554 wFreeColor(scr
, scr
->window_title_pixel
[index
]);
2557 scr
->window_title_pixel
[index
] = color
->pixel
;
2559 if (index
== WS_FOCUSED
)
2560 XSetForeground(dpy
, scr
->icon_title_gc
, color
->pixel
);
2561 else if (index
== WS_UNFOCUSED
)
2562 XSetForeground(dpy
, scr
->info_text_gc
, color
->pixel
);
2564 return REFRESH_FORE_COLOR
;
2569 setMenuTitleColor(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, void *foo
)
2571 if (scr
->menu_title_pixel
[0]!=scr
->white_pixel
&&
2572 scr
->menu_title_pixel
[0]!=scr
->black_pixel
) {
2573 wFreeColor(scr
, scr
->menu_title_pixel
[0]);
2576 scr
->menu_title_pixel
[0] = color
->pixel
;
2578 XSetForeground(dpy
, scr
->menu_title_gc
, color
->pixel
);
2580 return REFRESH_FORE_COLOR
;
2585 setMenuTextColor(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, void *foo
)
2588 #define gcm (GCForeground|GCBackground|GCFillStyle)
2590 if (scr
->mtext_pixel
!=scr
->white_pixel
&&
2591 scr
->mtext_pixel
!=scr
->black_pixel
) {
2592 wFreeColor(scr
, scr
->mtext_pixel
);
2595 scr
->mtext_pixel
= color
->pixel
;
2597 XSetForeground(dpy
, scr
->menu_entry_gc
, color
->pixel
);
2600 if (scr
->dtext_pixel
== scr
->mtext_pixel
) {
2601 gcv
.foreground
= scr
->white_pixel
;
2602 gcv
.background
= scr
->black_pixel
;
2603 gcv
.fill_style
= FillStippled
;
2605 gcv
.foreground
= scr
->dtext_pixel
;
2606 gcv
.fill_style
= FillSolid
;
2608 XChangeGC(dpy
, scr
->disabled_menu_entry_gc
, gcm
, &gcv
);
2610 return REFRESH_FORE_COLOR
;
2616 setMenuDisabledColor(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, void *foo
)
2619 #define gcm (GCForeground|GCBackground|GCFillStyle)
2621 if (scr
->dtext_pixel
!=scr
->white_pixel
&&
2622 scr
->dtext_pixel
!=scr
->black_pixel
) {
2623 wFreeColor(scr
, scr
->dtext_pixel
);
2626 scr
->dtext_pixel
= color
->pixel
;
2628 if (scr
->dtext_pixel
== scr
->mtext_pixel
) {
2629 gcv
.foreground
= scr
->white_pixel
;
2630 gcv
.background
= scr
->black_pixel
;
2631 gcv
.fill_style
= FillStippled
;
2633 gcv
.foreground
= scr
->dtext_pixel
;
2634 gcv
.fill_style
= FillSolid
;
2636 XChangeGC(dpy
, scr
->disabled_menu_entry_gc
, gcm
, &gcv
);
2638 return REFRESH_FORE_COLOR
;
2645 * Implementation of workspace specific backgrounds.
2647 * WorkspaceBack is used as the default background.
2648 * WorkspaceSpecificBack supplies an array with the textures for
2650 * WorkspaceSpecificBack = (ws1texture, ws2texture, "", ws4texture);
2651 * "" means that workspace3 should use the default texture.
2653 * struct WWorkspaceTexture {
2654 * Pixmap pixmap; // the pixmap for non-solid textures.
2655 * //None means the texture is solid
2656 * WPixel color; // color for solid texture
2657 * proplist_t texture; // for checking updates
2661 * All textures are rendered by wmsetbg. When it exits with status 0
2662 * it outputs the pixmap ID.
2663 * wmaker will monitor the fd and when it becomes available it reads the
2664 * pixmap ID and uses it in the texture. The data read from the fd
2665 * is the pixmap ID and the pid of the wmsetbg process, separated by
2666 * a space (the pid is to allow paralel wmsetbg processes).
2668 * The workspace background cant be set if the pid field of the
2669 * texture is 0. Otherwise, the texture is still being rendered
2672 * If the workspace background is changed before wmsetbg finishes
2673 * the rendering, wmsetbg must be killed.
2676 * Workspace specific textures are generated only when switching to
2677 * that workspace, unless #define SLOW_CONFIGURATION_UPDATE.
2683 trackDeadProcess(pid_t pid
, unsigned char status
, WScreen
*scr
)
2685 WWorkspaceTexture
*wsback
;
2686 int setBackground
= 0;
2688 /* find out to which wsback, this process belongs to */
2691 if (status
!= 123) {
2692 /* something went wrong during rendering */
2693 XFreePixmap(dpy
, wsback
->pixmap
);
2694 wsback
->pixmap
= None
;
2695 wwarning(_("background texture rendering was unsuccessfull"));
2698 if (setBackground
) {
2703 makeWorkspaceTexture(WScreen
*scr
, WTexture
*texture
, char *file
, char *option
)
2705 WWorkspaceTexture
*wsback
;
2707 wsback
= wmalloc(sizeof(WWorkspaceTexture
));
2710 wsback
->solid
= (*texture
)->any
.color
.pixel
;
2712 if (texture
->any
.type
==WTEX_SOLID
) {
2713 wsback
->pixmap
= None
;
2714 } else if (texture
->any
.type
== WTEX_PIXMAP
) {
2716 if (texture
->pixmap
.subtype
== WTP_TILE
) {
2719 /* render ourseves */
2720 image
= RLoadImage(scr
->rcontext
, file
, 0);
2722 wwarning(_("could not load image %s for option %s:%s\n"),
2723 file
, option
, RErrorString
);
2724 wsback
->pixmap
= None
;
2728 /* create a empty pixmap... */
2730 int style
= texture
->pixmap
.subtype
;
2732 pixmap
= XCreatePixmap(dpy
, scr
->root_win
, scr
->scr_width
,
2733 scr
->scr_height
, scr
->depth
);
2735 /* ...and let wmsetbg render it */
2738 wsyserror(_("could not spawn texture rendering subprocess for option"));
2739 } else if (pid
== 0) {
2742 SetupEnvironment(scr
);
2744 close(ConnectionNumber(dpy
));
2746 colorn
= wmalloc(32);
2747 sprintf(colorn
, "\"#%2x%2x%2x\"",
2748 texture
->any
.color
.red
,
2749 texture
->any
.color
.green
,
2750 texture
->any
.color
.blue
);
2752 sprintf(pix
, "%x", pixmap
);
2753 execlp("wmsetbg", "wmsetbg", (style
==WTP_SCALE
? "-s":"-e"),
2754 "-b", colorn
, "-x", pix
, file
);
2757 wsback
->pixmap
= pixmap
;
2758 /* must add a death handler to detect when wmsetbg has
2759 * exited (with exit status 123) and refresh the background.
2767 switch (texture
->any
.type
) {
2768 case WTEX_HGRADIENT
:
2769 case WTEX_MHGRADIENT
:
2774 case WTEX_VGRADIENT
:
2775 case WTEX_MVGRADIENT
:
2777 h
= scr
->scr_height
;
2780 case WTEX_DGRADIENT
:
2781 case WTEX_MDGRADIENT
:
2783 h
= scr
->scr_height
;
2790 img
= wTextureRenderImage(texture
, w
, h
, WREL_FLAT
);
2792 wwarning(_("could not render texture for workspace background"));
2796 RConvertImage(scr
->rcontext
, img
, &pixmap
);
2798 wsback
->pixmap
= pixmap
;
2806 setWorkspaceBack(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
,
2812 if (scr
->defaultTexture
) {
2813 if (scr
->defaultTexture
->pixmap
)
2814 XFreePixmap(dpy
, scr
->defaultTexture
->pixmap
);
2815 free(scr
->defaultTexture
);
2819 scr
->defaultTexture
= NULL
;
2825 scr
->defaultTexture
= makeWorkspaceTexture(scr
, *texture
, file
);
2828 wTextureDestroy(scr
, *texture
);
2830 /* free the file name that was passed from the getWSBackground()
2831 * function and placed in entry->extra_data */
2834 entry
->extra_data
= NULL
;
2836 return REFRESH_WORKSPACE_BACK
;
2838 #else /* !EXPERIMENTAL */
2840 setWorkspaceBack(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
,
2847 if ((*texture
)->any
.type
==WTEX_SOLID
) {
2848 XSetWindowBackground(dpy
, scr
->root_win
, (*texture
)->solid
.normal
.pixel
);
2849 XClearWindow(dpy
, scr
->root_win
);
2853 switch ((*texture
)->any
.type
) {
2854 case WTEX_HGRADIENT
:
2855 case WTEX_MHGRADIENT
:
2860 case WTEX_VGRADIENT
:
2861 case WTEX_MVGRADIENT
:
2863 h
= scr
->scr_height
;
2866 case WTEX_DGRADIENT
:
2867 case WTEX_MDGRADIENT
:
2869 h
= scr
->scr_height
;
2874 wTextureDestroy(scr
, *texture
);
2878 img
= wTextureRenderImage(*texture
, w
, h
, WREL_FLAT
);
2880 wwarning(_("could not render texture for workspace background"));
2882 wTextureDestroy(scr
, *texture
);
2885 RConvertImage(scr
->rcontext
, img
, &pixmap
);
2887 XSetWindowBackgroundPixmap(dpy
, scr
->root_win
, pixmap
);
2888 XClearWindow(dpy
, scr
->root_win
);
2892 * Free the texture as nobody else will use it, nor refer to it.
2895 wTextureDestroy(scr
, *texture
);
2899 #endif /* !EXPERIMENTAL */
2902 setWidgetColor(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
2904 if (scr
->widget_texture
) {
2905 wTextureDestroy(scr
, (WTexture
*)scr
->widget_texture
);
2907 scr
->widget_texture
= *(WTexSolid
**)texture
;
2914 setFTitleBack(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
2916 if (scr
->window_title_texture
[WS_FOCUSED
]) {
2917 wTextureDestroy(scr
, scr
->window_title_texture
[WS_FOCUSED
]);
2919 scr
->window_title_texture
[WS_FOCUSED
] = *texture
;
2921 if (scr
->icon_title_texture
) {
2922 wTextureDestroy(scr
, (WTexture
*)scr
->icon_title_texture
);
2924 scr
->icon_title_texture
2925 = wTextureMakeSolid(scr
, &scr
->window_title_texture
[WS_FOCUSED
]->any
.color
);
2927 return REFRESH_WINDOW_TEXTURES
;
2932 setPTitleBack(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
2934 if (scr
->window_title_texture
[WS_PFOCUSED
]) {
2935 wTextureDestroy(scr
, scr
->window_title_texture
[WS_PFOCUSED
]);
2937 scr
->window_title_texture
[WS_PFOCUSED
] = *texture
;
2939 return REFRESH_WINDOW_TEXTURES
;
2944 setUTitleBack(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
2946 if (scr
->window_title_texture
[WS_UNFOCUSED
]) {
2947 wTextureDestroy(scr
, scr
->window_title_texture
[WS_UNFOCUSED
]);
2949 scr
->window_title_texture
[WS_UNFOCUSED
] = *texture
;
2951 if (scr
->resizebar_texture
[0]) {
2952 wTextureDestroy(scr
, (WTexture
*)scr
->resizebar_texture
[0]);
2954 scr
->resizebar_texture
[0]
2955 = wTextureMakeSolid(scr
, &scr
->window_title_texture
[WS_UNFOCUSED
]->any
.color
);
2957 if (scr
->geometry_display
!= None
)
2958 XSetWindowBackground(dpy
, scr
->geometry_display
,
2959 scr
->resizebar_texture
[0]->normal
.pixel
);
2961 return REFRESH_WINDOW_TEXTURES
;
2966 setMenuTitleBack(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
2968 if (scr
->menu_title_texture
[0]) {
2969 wTextureDestroy(scr
, scr
->menu_title_texture
[0]);
2971 scr
->menu_title_texture
[0] = *texture
;
2973 return REFRESH_MENU_TEXTURES
;
2978 setMenuTextBack(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
2980 if (scr
->menu_item_texture
) {
2981 wTextureDestroy(scr
, scr
->menu_item_texture
);
2982 wTextureDestroy(scr
, (WTexture
*)scr
->menu_item_auxtexture
);
2984 scr
->menu_item_texture
= *texture
;
2986 scr
->menu_item_auxtexture
2987 = wTextureMakeSolid(scr
, &scr
->menu_item_texture
->any
.color
);
2989 return REFRESH_MENU_TEXTURES
;
2994 setKeyGrab(WScreen
*scr
, WDefaultEntry
*entry
, WShortKey
*shortcut
, long index
)
2997 wKeyBindings
[index
] = *shortcut
;
2999 wwin
= scr
->focused_window
;
3001 while (wwin
!=NULL
) {
3002 XUngrabKey(dpy
, AnyKey
, AnyModifier
, wwin
->frame
->core
->window
);
3004 if (!wwin
->window_flags
.no_bind_keys
) {
3005 wWindowSetKeyGrabs(wwin
);
3015 setIconPosition(WScreen
*scr
, WDefaultEntry
*entry
, void *bar
, void *foo
)
3017 wArrangeIcons(scr
, True
);
3026 * Need access to the double click variables, so that all widgets in
3027 * wmaker panels will have the same dbl-click values.
3028 * TODO: figure a better way of dealing with it.
3033 setDoubleClick(WScreen
*scr
, WDefaultEntry
*entry
, int *value
, void *foo
)
3035 extern _WINGsConfiguration WINGsConfiguration
;
3040 WINGsConfiguration
.doubleClickDelay
= *value
;