1 /* defaults.c - manage configuration through defaults db
3 * WindowMaker 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
];
100 /* type converters */
101 static int getBool();
103 static int getCoord();
105 /* this is not used yet */
106 static int getString();
108 static int getPathList();
109 static int getFocusMode();
110 static int getPlacement();
111 static int getGeomDisp();
112 static int getTexture();
113 static int getWSBackground();
114 static int getJust();
115 static int getFont();
116 static int getColor();
117 static int getKeybind();
118 static int getModMask();
119 static int getSpeed();
120 static int getMButton();
121 static int getIconPosition();
122 static int getIconificationStyle();
124 /* value setting functions */
125 static int setJustify();
126 static int setIfDockPresent();
127 static int setStickyIcons();
129 static int setPositive();
131 static int setWidgetColor();
132 static int setIconTile();
133 static int setWinTitleFont();
134 static int setMenuTitleFont();
135 static int setMenuTextFont();
136 static int setIconTitleFont();
137 static int setDisplayFont();
138 static int setWTitleColor();
139 static int setFTitleBack();
140 static int setPTitleBack();
141 static int setUTitleBack();
142 static int setWorkspaceBack();
143 static int setMenuTitleColor();
144 static int setMenuTextColor();
145 static int setMenuDisabledColor();
146 static int setMenuTitleBack();
147 static int setMenuTextBack();
148 static int setHightlight();
149 static int setHightlightText();
150 static int setKeyGrab();
151 static int setDoubleClick();
152 static int setIconPosition();
154 static int setClipTitleFont();
155 static int setClipTitleColor();
160 * All entries in the tables bellow, NEED to have a default value
161 * defined, and this value needs to be correct.
164 /* these options will only affect the window manager on startup
166 * static defaults can't access the screen data, because it is
167 * created after these defaults are read
169 WDefaultEntry staticOptionList
[] = {
171 {"DisableDithering", "NO", NULL
,
172 &wPreferences
.no_dithering
, getBool
, NULL
174 {"ColormapSize", "4", NULL
,
175 &wPreferences
.cmap_size
, getInt
, NULL
177 /* static by laziness */
178 {"IconSize", "64", NULL
,
179 &wPreferences
.icon_size
, getInt
, NULL
181 {"ModifierKey", "Mod1", NULL
,
182 &wPreferences
.modifier_mask
, getModMask
, NULL
184 {"DisableWSMouseActions", "NO", NULL
,
185 &wPreferences
.disable_root_mouse
, getBool
, NULL
187 {"FocusMode", "manual", (void*)False
,
188 &wPreferences
.focus_mode
, getFocusMode
, NULL
189 }, /* have a problem when switching from manual to sloppy without restart */
190 {"NewStyle", "NO", NULL
,
191 &wPreferences
.new_style
, getBool
, NULL
193 {"DisableDock", "NO", (void*) WM_DOCK
,
194 NULL
, getBool
, setIfDockPresent
196 {"DisableClip", "NO", (void*) WM_CLIP
,
197 NULL
, getBool
, setIfDockPresent
203 WDefaultEntry optionList
[] = {
204 /* dynamic options */
205 {"IconPosition", "blh", NULL
,
206 &wPreferences
.icon_yard
, getIconPosition
, setIconPosition
208 {"IconificationStyle", "Zoom", NULL
,
209 &wPreferences
.iconification_style
, getIconificationStyle
, NULL
211 {"SelectWindowsMouseButton", "Left", NULL
,
212 &wPreferences
.select_button
, getMButton
, NULL
214 {"WindowListMouseButton", "Middle", NULL
,
215 &wPreferences
.windowl_button
, getMButton
, NULL
217 {"ApplicationMenuMouseButton", "Right", NULL
,
218 &wPreferences
.menu_button
, getMButton
, NULL
220 {"PixmapPath", DEF_PIXMAP_PATHS
, NULL
,
221 &wPreferences
.pixmap_path
, getPathList
, NULL
223 {"IconPath", DEF_ICON_PATHS
, NULL
,
224 &wPreferences
.icon_path
, getPathList
, NULL
226 {"ColormapMode", "auto", (void*)True
,
227 &wPreferences
.colormap_mode
, getFocusMode
, NULL
229 {"AutoFocus", "NO", NULL
,
230 &wPreferences
.auto_focus
, getBool
, NULL
232 {"RaiseDelay", "0", NULL
,
233 &wPreferences
.raise_delay
, getInt
, NULL
235 {"CirculateRaise", "NO", NULL
,
236 &wPreferences
.circ_raise
, getBool
, NULL
238 {"Superfluous", "NO", NULL
,
239 &wPreferences
.superfluous
, getBool
, NULL
241 {"AdvanceToNewWorkspace", "NO", NULL
,
242 &wPreferences
.ws_advance
, getBool
, NULL
244 {"CycleWorkspaces", "NO", NULL
,
245 &wPreferences
.ws_cycle
, getBool
, NULL
247 {"StickyIcons", "NO", NULL
,
248 &wPreferences
.sticky_icons
, getBool
, setStickyIcons
250 {"SaveSessionOnExit", "NO", NULL
,
251 &wPreferences
.save_session_on_exit
, getBool
, NULL
253 {"WrapMenus", "NO", NULL
,
254 &wPreferences
.wrap_menus
, getBool
, NULL
256 {"ScrollableMenus", "NO", NULL
,
257 &wPreferences
.scrollable_menus
, getBool
, NULL
259 {"MenuScrollSpeed", "medium", NULL
,
260 &wPreferences
.menu_scroll_speed
, getSpeed
, NULL
262 {"IconSlideSpeed", "medium", NULL
,
263 &wPreferences
.icon_slide_speed
, getSpeed
, NULL
265 {"ShadeSpeed", "medium", NULL
,
266 &wPreferences
.shade_speed
, getSpeed
, NULL
268 {"DoubleClickTime", "250", (void*) &wPreferences
.dblclick_time
,
269 &wPreferences
.dblclick_time
, getInt
, setDoubleClick
,
271 {"AlignSubmenus", "NO", NULL
,
272 &wPreferences
.align_menus
, getBool
, NULL
274 {"OnTopTransients", "NO", NULL
,
275 &wPreferences
.on_top_transients
, getBool
, NULL
277 {"WindowPlacement", "auto", NULL
,
278 &wPreferences
.window_placement
, getPlacement
, NULL
280 {"IgnoreFocusClick","NO", NULL
,
281 &wPreferences
.ignore_focus_click
, getBool
, NULL
283 {"UseSaveUnders", "NO", NULL
,
284 &wPreferences
.use_saveunders
, getBool
, NULL
286 {"OpaqueMove", "NO", NULL
,
287 &wPreferences
.opaque_move
, getBool
, NULL
289 {"DisableSound", "NO", NULL
,
290 &wPreferences
.no_sound
, getBool
, NULL
292 {"DisableAnimations", "NO", NULL
,
293 &wPreferences
.no_animations
, getBool
, NULL
295 {"DontLinkWorkspaces","NO", NULL
,
296 &wPreferences
.no_autowrap
, getBool
, NULL
298 {"EdgeResistance", "0", NULL
,
299 &wPreferences
.edge_resistance
,getInt
, NULL
301 {"AutoArrangeIcons", "NO", NULL
,
302 &wPreferences
.auto_arrange_icons
, getBool
, NULL
304 {"NoWindowUnderDock", "NO", NULL
,
305 &wPreferences
.no_window_under_dock
, getBool
, NULL
307 {"NoWindowOverIcons", "NO", NULL
,
308 &wPreferences
.no_window_over_icons
, getBool
, NULL
310 {"WindowPlaceOrigin", "(0, 0)", NULL
,
311 &wPreferences
.window_place_origin
, getCoord
, NULL
313 {"ResizeDisplay", "corner", NULL
,
314 &wPreferences
.size_display
, getGeomDisp
, NULL
316 {"MoveDisplay", "corner", NULL
,
317 &wPreferences
.move_display
, getGeomDisp
, NULL
319 {"DontConfirmKill", "NO", NULL
,
320 &wPreferences
.dont_confirm_kill
, getBool
,NULL
322 {"WindowTitleBalloons", "NO", NULL
,
323 &wPreferences
.window_balloon
, getBool
, NULL
325 {"MiniwindowTitleBalloons", "NO", NULL
,
326 &wPreferences
.miniwin_balloon
,getBool
, NULL
328 {"AppIconBalloons", "NO", NULL
,
329 &wPreferences
.appicon_balloon
,getBool
, NULL
331 {"DisableBlinking", "NO", NULL
,
332 &wPreferences
.dont_blink
, getBool
, NULL
335 {"WidgetColor", "(solid, gray)", NULL
,
336 NULL
, getTexture
, setWidgetColor
,
338 {"WorkspaceBack", "(solid, black)", NULL
,
339 NULL
, getWSBackground
,setWorkspaceBack
341 {"IconBack", "(solid, gray)", NULL
,
342 NULL
, getTexture
, setIconTile
344 {"TitleJustify", "center", NULL
,
345 &wPreferences
.title_justification
, getJust
, setJustify
347 {"WindowTitleFont", DEF_TITLE_FONT
, NULL
,
348 NULL
, getFont
, setWinTitleFont
350 {"MenuTitleFont", DEF_MENU_TITLE_FONT
, NULL
,
351 NULL
, getFont
, setMenuTitleFont
353 {"MenuTextFont", DEF_MENU_ENTRY_FONT
, NULL
,
354 NULL
, getFont
, setMenuTextFont
356 {"IconTitleFont", DEF_ICON_TITLE_FONT
, NULL
,
357 NULL
, getFont
, setIconTitleFont
359 {"ClipTitleFont", DEF_CLIP_TITLE_FONT
, NULL
,
360 NULL
, getFont
, setClipTitleFont
362 {"DisplayFont", DEF_INFO_TEXT_FONT
, NULL
,
363 NULL
, getFont
, setDisplayFont
365 {"HighlightColor", "white", NULL
,
366 NULL
, getColor
, setHightlight
368 {"HighlightTextColor", "black", NULL
,
369 NULL
, getColor
, setHightlightText
371 {"ClipTitleColor", "black", (void*)CLIP_NORMAL
,
372 NULL
, getColor
, setClipTitleColor
374 {"CClipTitleColor", "\"#454045\"", (void*)CLIP_COLLAPSED
,
375 NULL
, getColor
, setClipTitleColor
377 {"FTitleColor", "white", (void*)WS_FOCUSED
,
378 NULL
, getColor
, setWTitleColor
380 {"PTitleColor", "white", (void*)WS_PFOCUSED
,
381 NULL
, getColor
, setWTitleColor
383 {"UTitleColor", "black", (void*)WS_UNFOCUSED
,
384 NULL
, getColor
, setWTitleColor
386 {"FTitleBack", "(solid, black)", NULL
,
387 NULL
, getTexture
, setFTitleBack
389 {"PTitleBack", "(solid, \"#616161\")", NULL
,
390 NULL
, getTexture
, setPTitleBack
392 {"UTitleBack", "(solid, gray)", NULL
,
393 NULL
, getTexture
, setUTitleBack
395 {"MenuTitleColor", "white", NULL
,
396 NULL
, getColor
, setMenuTitleColor
398 {"MenuTextColor", "black", NULL
,
399 NULL
, getColor
, setMenuTextColor
401 {"MenuDisabledColor", "\"#616161\"", NULL
,
402 NULL
, getColor
, setMenuDisabledColor
404 {"MenuTitleBack", "(solid, black)", NULL
,
405 NULL
, getTexture
, setMenuTitleBack
407 {"MenuTextBack", "(solid, gray)", NULL
,
408 NULL
, getTexture
, setMenuTextBack
412 {"RootMenuKey", "None", (void*)WKBD_ROOTMENU
,
413 NULL
, getKeybind
, setKeyGrab
415 {"WindowListKey", "None", (void*)WKBD_WINDOWLIST
,
416 NULL
, getKeybind
, setKeyGrab
418 {"WindowMenuKey", "None", (void*)WKBD_WINDOWMENU
,
419 NULL
, getKeybind
, setKeyGrab
421 {"ClipLowerKey", "None", (void*)WKBD_CLIPLOWER
,
422 NULL
, getKeybind
, setKeyGrab
424 {"ClipRaiseKey", "None", (void*)WKBD_CLIPRAISE
,
425 NULL
, getKeybind
, setKeyGrab
427 {"ClipRaiseLowerKey", "None", (void*)WKBD_CLIPRAISELOWER
,
428 NULL
, getKeybind
, setKeyGrab
430 {"MiniaturizeKey", "None", (void*)WKBD_MINIATURIZE
,
431 NULL
, getKeybind
, setKeyGrab
433 {"HideKey", "None", (void*)WKBD_HIDE
,
434 NULL
, getKeybind
, setKeyGrab
436 {"CloseKey", "None", (void*)WKBD_CLOSE
,
437 NULL
, getKeybind
, setKeyGrab
439 {"MaximizeKey", "None", (void*)WKBD_MAXIMIZE
,
440 NULL
, getKeybind
, setKeyGrab
442 {"VMaximizeKey", "None", (void*)WKBD_VMAXIMIZE
,
443 NULL
, getKeybind
, setKeyGrab
445 {"RaiseKey", "Meta+Up", (void*)WKBD_RAISE
,
446 NULL
, getKeybind
, setKeyGrab
448 {"LowerKey", "Meta+Down", (void*)WKBD_LOWER
,
449 NULL
, getKeybind
, setKeyGrab
451 {"RaiseLowerKey", "None", (void*)WKBD_RAISELOWER
,
452 NULL
, getKeybind
, setKeyGrab
454 {"ShadeKey", "None", (void*)WKBD_SHADE
,
455 NULL
, getKeybind
, setKeyGrab
457 {"SelectKey", "None", (void*)WKBD_SELECT
,
458 NULL
, getKeybind
, setKeyGrab
460 {"FocusNextKey", "None", (void*)WKBD_FOCUSNEXT
,
461 NULL
, getKeybind
, setKeyGrab
463 {"FocusPrevKey", "None", (void*)WKBD_FOCUSPREV
,
464 NULL
, getKeybind
, setKeyGrab
466 {"NextWorkspaceKey", "None", (void*)WKBD_NEXTWORKSPACE
,
467 NULL
, getKeybind
, setKeyGrab
469 {"PrevWorkspaceKey", "None", (void*)WKBD_PREVWORKSPACE
,
470 NULL
, getKeybind
, setKeyGrab
472 {"NextWorkspaceLayerKey", "None", (void*)WKBD_NEXTWSLAYER
,
473 NULL
, getKeybind
, setKeyGrab
475 {"PrevWorkspaceLayerKey", "None", (void*)WKBD_PREVWSLAYER
,
476 NULL
, getKeybind
, setKeyGrab
478 {"Workspace1Key", "None", (void*)WKBD_WORKSPACE1
,
479 NULL
, getKeybind
, setKeyGrab
481 {"Workspace2Key", "None", (void*)WKBD_WORKSPACE2
,
482 NULL
, getKeybind
, setKeyGrab
484 {"Workspace3Key", "None", (void*)WKBD_WORKSPACE3
,
485 NULL
, getKeybind
, setKeyGrab
487 {"Workspace4Key", "None", (void*)WKBD_WORKSPACE4
,
488 NULL
, getKeybind
, setKeyGrab
490 {"Workspace5Key", "None", (void*)WKBD_WORKSPACE5
,
491 NULL
, getKeybind
, setKeyGrab
493 {"Workspace6Key", "None", (void*)WKBD_WORKSPACE6
,
494 NULL
, getKeybind
, setKeyGrab
496 {"Workspace7Key", "None", (void*)WKBD_WORKSPACE7
,
497 NULL
, getKeybind
, setKeyGrab
499 {"Workspace8Key", "None", (void*)WKBD_WORKSPACE8
,
500 NULL
, getKeybind
, setKeyGrab
502 {"Workspace9Key", "None", (void*)WKBD_WORKSPACE9
,
503 NULL
, getKeybind
, setKeyGrab
505 {"Workspace10Key", "None", (void*)WKBD_WORKSPACE10
,
506 NULL
, getKeybind
, setKeyGrab
513 static proplist_t DCenter
, DCorner
, DFloating
, DLine
;
514 static proplist_t JLeft
, JCenter
, JRight
;
517 static void rereadDefaults(void);
524 /* must defer the update because accessing X data from a
525 * signal handler can mess up Xlib */
534 WDefaultEntry
*entry
;
536 PLSetStringCmpHook(StringCompareHook
);
538 DCenter
= PLMakeString("Center");
539 DCorner
= PLMakeString("Corner");
540 DFloating
= PLMakeString("Floating");
541 DLine
= PLMakeString("Line");
543 JLeft
= PLMakeString("Left");
544 JCenter
= PLMakeString("Center");
545 JRight
= PLMakeString("Right");
547 for (i
=0; i
<sizeof(optionList
)/sizeof(WDefaultEntry
); i
++) {
548 entry
= &optionList
[i
];
550 entry
->plkey
= PLMakeString(entry
->key
);
551 if (entry
->default_value
)
552 entry
->plvalue
= PLGetProplistWithDescription(entry
->default_value
);
554 entry
->plvalue
= NULL
;
557 for (i
=0; i
<sizeof(staticOptionList
)/sizeof(WDefaultEntry
); i
++) {
558 entry
= &staticOptionList
[i
];
560 entry
->plkey
= PLMakeString(entry
->key
);
561 if (entry
->default_value
)
562 entry
->plvalue
= PLGetProplistWithDescription(entry
->default_value
);
564 entry
->plvalue
= NULL
;
568 wDomainName = PLMakeString(WMDOMAIN_NAME);
569 wAttributeDomainName = PLMakeString(WMATTRIBUTE_DOMAIN_NAME);
571 PLRegister(wDomainName, rereadDefaults);
572 PLRegister(wAttributeDomainName, rereadDefaults);
581 wDefaultsInit(int screen_number
)
583 static int defaults_inited
= 0;
586 if (!defaults_inited
) {
590 dict
= PLGetDomain(wDomainName
);
592 wwarning(_("could not read domain \"%s\" from defaults database"),
593 PLGetString(wDomainName
));
602 wDefaultsDestroyDomain(WDDomain
*domain
)
604 if (domain
->dictionary
)
605 PLRelease(domain
->dictionary
);
612 wDefaultsInitDomain(char *domain
, Bool requireDictionary
)
616 static int inited
= 0;
619 proplist_t shared_dict
=NULL
;
626 db
= wmalloc(sizeof(WDDomain
));
627 memset(db
, 0, sizeof(WDDomain
));
628 db
->domain_name
= domain
;
629 db
->path
= wdefaultspathfordomain(domain
);
632 if (the_path
&& stat(the_path
, &stbuf
)>=0) {
633 db
->dictionary
= ReadProplistFromFile(the_path
);
634 if (db
->dictionary
) {
635 if (requireDictionary
&& !PLIsDictionary(db
->dictionary
)) {
636 PLRelease(db
->dictionary
);
637 db
->dictionary
= NULL
;
638 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
641 db
->timestamp
= stbuf
.st_mtime
;
643 wwarning(_("could not load domain %s from user defaults database"),
648 /* global system dictionary */
649 sprintf(path
, "%s/%s/%s", PKGDATADIR
, DEFAULTS_DIR
, domain
);
650 if (stat(path
, &stbuf
)>=0) {
651 shared_dict
= ReadProplistFromFile(path
);
653 if (requireDictionary
&& !PLIsDictionary(shared_dict
)) {
654 wwarning(_("Domain %s (%s) of global defaults database is corrupted!"),
656 PLRelease(shared_dict
);
659 if (db
->dictionary
&& PLIsDictionary(shared_dict
) &&
660 PLIsDictionary(db
->dictionary
)) {
661 PLMergeDictionaries(shared_dict
, db
->dictionary
);
662 PLRelease(db
->dictionary
);
663 db
->dictionary
= shared_dict
;
664 if (stbuf
.st_mtime
> db
->timestamp
)
665 db
->timestamp
= stbuf
.st_mtime
;
666 } else if (!db
->dictionary
) {
667 db
->dictionary
= shared_dict
;
668 if (stbuf
.st_mtime
> db
->timestamp
)
669 db
->timestamp
= stbuf
.st_mtime
;
673 wwarning(_("could not load domain %s from global defaults database"),
678 /* set to save it in user's directory, no matter from where it was read */
679 if (db
->dictionary
) {
680 proplist_t tmp
= PLMakeString(db
->path
);
682 PLSetFilename(db
->dictionary
, tmp
);
691 wReadStaticDefaults(proplist_t dict
)
694 WDefaultEntry
*entry
;
699 for (i
=0; i
<sizeof(staticOptionList
)/sizeof(WDefaultEntry
); i
++) {
700 entry
= &staticOptionList
[i
];
703 plvalue
= PLGetDictionaryEntry(dict
, entry
->plkey
);
708 /* no default in the DB. Use builtin default */
709 plvalue
= entry
->plvalue
;
714 (*entry
->convert
)(NULL
, entry
, plvalue
, entry
->addr
, &tdata
);
716 (*entry
->update
)(NULL
, entry
, tdata
, entry
->extra_data
);
723 wDefaultsCheckDomains(void *foo
)
732 puts("Checking domains...");
734 if (stat(WDWindowMaker
->path
, &stbuf
)>=0
735 && WDWindowMaker
->timestamp
< stbuf
.st_mtime
) {
736 proplist_t shared_dict
= NULL
;
738 puts("Checking WindowMaker domain");
740 WDWindowMaker
->timestamp
= stbuf
.st_mtime
;
742 /* global dictionary */
743 sprintf(path
, "%s/%s/WindowMaker", PKGDATADIR
, DEFAULTS_DIR
);
744 if (stat(path
, &stbuf
)>=0) {
745 shared_dict
= ReadProplistFromFile(path
);
746 if (shared_dict
&& !PLIsDictionary(shared_dict
)) {
747 wwarning(_("Domain %s (%s) of global defaults database is corrupted!"),
748 "WindowMaker", path
);
749 PLRelease(shared_dict
);
751 } else if (!shared_dict
) {
752 wwarning(_("could not load domain %s from global defaults database"),
756 /* user dictionary */
757 dict
= ReadProplistFromFile(WDWindowMaker
->path
);
759 if (!PLIsDictionary(dict
)) {
762 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
763 "WindowMaker", WDWindowMaker
->path
);
766 PLSetFilename(shared_dict
, PLGetFilename(dict
));
767 PLMergeDictionaries(shared_dict
, dict
);
772 for (i
=0; i
<wScreenCount
; i
++) {
773 scr
= wScreenWithNumber(i
);
775 wReadDefaults(scr
, dict
);
777 if (WDWindowMaker
->dictionary
) {
778 PLRelease(WDWindowMaker
->dictionary
);
780 WDWindowMaker
->dictionary
= dict
;
783 wwarning(_("could not load domain %s from user defaults database"),
787 PLRelease(shared_dict
);
791 if (stat(WDWindowAttributes
->path
, &stbuf
)>=0
792 && WDWindowAttributes
->timestamp
< stbuf
.st_mtime
) {
794 puts("Checking WMWindowAttributes domain");
796 dict
= ReadProplistFromFile(WDWindowAttributes
->path
);
798 if (!PLIsDictionary(dict
)) {
801 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
802 "WMWindowAttributes", WDWindowAttributes
->path
);
804 if (WDWindowAttributes
->dictionary
)
805 PLRelease(WDWindowAttributes
->dictionary
);
806 WDWindowAttributes
->dictionary
= dict
;
807 for (i
=0; i
<wScreenCount
; i
++) {
808 scr
= wScreenWithNumber(i
);
810 wDefaultUpdateIcons(scr
);
814 wwarning(_("could not load domain %s from user defaults database"),
815 "WMWindowAttributes");
817 WDWindowAttributes
->timestamp
= stbuf
.st_mtime
;
821 if (stat(WDRootMenu
->path
, &stbuf
)>=0
822 && WDRootMenu
->timestamp
< stbuf
.st_mtime
) {
823 dict
= ReadProplistFromFile(WDRootMenu
->path
);
825 puts("Checking WMRootMenu domain");
828 if (!PLIsArray(dict
) && !PLIsString(dict
)) {
831 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
832 "WMRootMenu", WDRootMenu
->path
);
834 if (WDRootMenu
->dictionary
) {
835 PLRelease(WDRootMenu
->dictionary
);
837 WDRootMenu
->dictionary
= dict
;
840 wwarning(_("could not load domain %s from user defaults database"),
843 WDRootMenu
->timestamp
= stbuf
.st_mtime
;
846 WMAddTimerHandler(DEFAULTS_CHECK_INTERVAL
, wDefaultsCheckDomains
, foo
);
851 #define REFRESH_WINDOW_TEXTURES (1<<0)
852 #define REFRESH_MENU_TEXTURES (1<<1)
853 #define REFRESH_WINDOW_FONT (1<<2)
854 #define REFRESH_MENU_TITLE_FONT (1<<3)
855 #define REFRESH_MENU_FONT (1<<4)
856 #define REFRESH_FORE_COLOR (1<<5)
857 #define REFRESH_ICON_TILE (1<<6)
858 #define REFRESH_ICON_FONT (1<<7)
859 #define REFRESH_WORKSPACE_BACK (1<<8)
862 refreshMenus(WScreen
*scr
, int flags
)
866 menu
= scr
->root_menu
;
868 wMenuRefresh(!menu
->flags
.brother
? menu
: menu
->brother
, flags
);
870 menu
= scr
->workspace_menu
;
872 wMenuRefresh(!menu
->flags
.brother
? menu
: menu
->brother
, flags
);
874 menu
= scr
->switch_menu
;
876 wMenuRefresh(!menu
->flags
.brother
? menu
: menu
->brother
, flags
);
878 menu
= scr
->window_menu
;
880 wMenuRefresh(!menu
->flags
.brother
? menu
: menu
->brother
, flags
);
882 menu
= scr
->icon_menu
;
884 wMenuRefresh(!menu
->flags
.brother
? menu
: menu
->brother
, flags
);
887 menu
= scr
->dock
->menu
;
889 wMenuRefresh(!menu
->flags
.brother
? menu
: menu
->brother
, flags
);
891 menu
= scr
->clip_menu
;
893 wMenuRefresh(!menu
->flags
.brother
? menu
: menu
->brother
, flags
);
895 menu
= scr
->clip_submenu
;
897 wMenuRefresh(!menu
->flags
.brother
? menu
: menu
->brother
, flags
);
899 menu
= scr
->clip_options
;
901 wMenuRefresh(!menu
->flags
.brother
? menu
: menu
->brother
, flags
);
906 refreshAppIcons(WScreen
*scr
, int flags
)
908 WAppIcon
*aicon
= scr
->app_icon_list
;
912 aicon
->icon
->force_paint
= 1;
920 refreshWindows(WScreen
*scr
, int flags
)
924 wwin
= scr
->focused_window
;
926 if (flags
& REFRESH_WINDOW_FONT
) {
927 wWindowConfigureBorders(wwin
);
929 if ((flags
& (REFRESH_ICON_TILE
|REFRESH_WINDOW_TEXTURES
)) &&
930 wwin
->flags
.miniaturized
&& wwin
->icon
) {
931 wwin
->icon
->force_paint
= 1;
933 if (flags
& REFRESH_WINDOW_TEXTURES
) {
934 wwin
->frame
->flags
.need_texture_remake
= 1;
942 wReadDefaults(WScreen
*scr
, proplist_t new_dict
)
944 proplist_t plvalue
, old_value
;
945 WDefaultEntry
*entry
;
946 int i
, changed
, must_update
;
949 proplist_t old_dict
= (WDWindowMaker
->dictionary
!=new_dict
950 ? WDWindowMaker
->dictionary
: NULL
);
957 for (i
=0; i
<sizeof(optionList
)/sizeof(WDefaultEntry
); i
++) {
958 entry
= &optionList
[i
];
961 plvalue
= PLGetDictionaryEntry(new_dict
, entry
->plkey
);
968 old_value
= PLGetDictionaryEntry(old_dict
, entry
->plkey
);
971 if (!plvalue
&& !old_value
) {
972 /* no default in the DB. Use builtin default */
973 plvalue
= entry
->plvalue
;
974 if (plvalue
&& new_dict
) {
975 PLInsertDictionaryEntry(new_dict
, entry
->plkey
, plvalue
);
979 } else if (!plvalue
) {
980 /* value was deleted from DB. Keep current value */
982 } else if (!old_value
) {
983 /* set value for the 1st time */
985 } else if (!PLIsEqual(plvalue
, old_value
)) {
986 /* value has changed */
989 /* value was not changed since last time */
995 printf("Updating %s to %s\n", entry
->key
, PLGetDescription(plvalue
));
998 if ((*entry
->convert
)(scr
, entry
, plvalue
, entry
->addr
, &tdata
)) {
1001 (*entry
->update
)(scr
, entry
, tdata
, entry
->extra_data
);
1007 if (needs_refresh
!=0) {
1011 if (needs_refresh
& REFRESH_MENU_TEXTURES
)
1012 foo
|= MR_TEXT_BACK
;
1013 if (needs_refresh
& REFRESH_MENU_FONT
)
1015 if (needs_refresh
& REFRESH_MENU_TITLE_FONT
)
1016 foo
|= MR_TITLE_TEXT
;
1019 refreshMenus(scr
, foo
);
1021 if (needs_refresh
& (REFRESH_WINDOW_TEXTURES
|REFRESH_WINDOW_FONT
|
1023 refreshWindows(scr
, needs_refresh
);
1025 if (needs_refresh
& REFRESH_ICON_TILE
)
1026 refreshAppIcons(scr
, needs_refresh
);
1029 if (needs_refresh
& REFRESH_WORKSPACE_BACK
) {
1030 WWorkspaceTexture
*wsback
;
1032 /* update the background for the workspace */
1033 if (scr
->current_workspace
< scr
->wspaceTextureCount
1034 && scr
->wspaceTextures
[scr
->current_workspace
]) {
1035 wsback
= scr
->wspaceTextures
[scr
->current_workspace
];
1037 wsback
= scr
->defaultTexure
;
1040 if (wsback
->pixmap
!=None
) {
1041 XSetWindowBackgroundPixmap(dpy
, scr
->root_win
,
1044 XSetWindowBackground(dpy
, scr
->root_win
, wsback
->solid
);
1046 XClearWindow(dpy
, scr
->root_win
);
1050 #endif /* !EXPERIMENTAL */
1051 wRefreshDesktop(scr
);
1057 wDefaultUpdateIcons(WScreen
*scr
)
1059 WAppIcon
*aicon
= scr
->app_icon_list
;
1060 WWindow
*wwin
= scr
->focused_window
;
1064 file
= wDefaultGetIconFile(scr
, aicon
->wm_instance
, aicon
->wm_class
,
1066 if ((file
&& aicon
->icon
->file
&& strcmp(file
, aicon
->icon
->file
)!=0)
1067 || (file
&& !aicon
->icon
->file
)) {
1070 if (aicon
->icon
->file
)
1071 free(aicon
->icon
->file
);
1072 aicon
->icon
->file
= wstrdup(file
);
1074 new_image
= wDefaultGetImage(scr
, aicon
->wm_instance
,
1077 wIconChangeImage(aicon
->icon
, new_image
);
1078 wAppIconPaint(aicon
);
1081 aicon
= aicon
->next
;
1084 if (!wPreferences
.flags
.noclip
)
1085 wClipIconPaint(scr
->clip_icon
);
1088 if (wwin
->icon
&& wwin
->flags
.miniaturized
) {
1089 file
= wDefaultGetIconFile(scr
, wwin
->wm_instance
, wwin
->wm_class
,
1091 if ((file
&& wwin
->icon
->file
&& strcmp(file
, wwin
->icon
->file
)!=0)
1092 || (file
&& !wwin
->icon
->file
)) {
1095 if (wwin
->icon
->file
)
1096 free(wwin
->icon
->file
);
1097 wwin
->icon
->file
= wstrdup(file
);
1099 new_image
= wDefaultGetImage(scr
, wwin
->wm_instance
,
1102 wIconChangeImage(wwin
->icon
, new_image
);
1110 /* --------------------------- Local ----------------------- */
1112 #define STRINGP(x) if (!PLIsString(value)) { \
1113 wwarning(_("Wrong option format for key \"%s\". Should be %s."), \
1114 PLGetString(entry->plkey), x); \
1118 * value - is the value in the defaults DB
1119 * addr - is the address to store the data
1120 * ret - is the address to store a pointer to a temporary buffer. ret
1121 * must not be freed and is used by the set functions
1124 getBool(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
1133 val
= PLGetString(value
);
1136 if ((val
[1]=='\0' && (val
[0]=='y' || val
[0]=='Y'))
1137 || strcasecmp(val
, "YES")==0) {
1140 } else if ((val
[1]=='\0' && (val
[0]=='n' || val
[0]=='N'))
1141 || strcasecmp(val
, "NO")==0) {
1145 if (sscanf(val
, "%i", &i
)==1) {
1151 wwarning(_("can't convert \"%s\" to boolean for key \"%s\""),
1152 val
, PLGetString(entry
->plkey
));
1153 if (second_pass
==0) {
1154 val
= PLGetString(entry
->plvalue
);
1156 wwarning(_("using default \"%s\" instead"), val
);
1167 *(char*)addr
= data
;
1175 getInt(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
1184 val
= PLGetString(value
);
1186 if (sscanf(val
, "%i", &data
)!=1) {
1187 wwarning(_("can't convert \"%s\" to integer for key \"%s\""),
1188 val
, PLGetString(entry
->plkey
));
1189 val
= PLGetString(entry
->plvalue
);
1190 wwarning(_("using default \"%s\" instead"), val
);
1191 if (sscanf(val
, "%i", &data
)!=1) {
1207 getCoord(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
1211 char *val_x
, *val_y
;
1212 int nelem
, changed
=0;
1213 proplist_t elem_x
, elem_y
;
1216 if (!PLIsArray(value
)) {
1217 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1218 PLGetString(entry
->plkey
), "Coordinate");
1220 value
= entry
->plvalue
;
1222 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1228 nelem
= PLGetNumberOfElements(value
);
1230 wwarning(_("Incorrect number of elements in array for key \"%s\"."),
1231 PLGetString(entry
->plkey
));
1233 value
= entry
->plvalue
;
1235 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1241 elem_x
= PLGetArrayElement(value
, 0);
1242 elem_y
= PLGetArrayElement(value
, 1);
1244 if (!elem_x
|| !elem_y
|| !PLIsString(elem_x
) || !PLIsString(elem_y
)) {
1245 wwarning(_("Wrong value for key \"%s\". Should be Coordinate."),
1246 PLGetString(entry
->plkey
));
1248 value
= entry
->plvalue
;
1250 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1256 val_x
= PLGetString(elem_x
);
1257 val_y
= PLGetString(elem_y
);
1259 if (sscanf(val_x
, "%i", &data
.x
)!=1 || sscanf(val_y
, "%i", &data
.y
)!=1) {
1260 wwarning(_("can't convert array to integers for \"%s\"."),
1261 PLGetString(entry
->plkey
));
1263 value
= entry
->plvalue
;
1265 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1273 else if (data
.x
> scr
->scr_width
/3)
1274 data
.x
= scr
->scr_width
/3;
1277 else if (data
.y
> scr
->scr_height
/3)
1278 data
.y
= scr
->scr_height
/3;
1284 *(WCoord
*)addr
= data
;
1292 /* This function is not used at the moment. */
1294 getString(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
1301 data
= PLGetString(value
);
1304 data
= PLGetString(entry
->plvalue
);
1313 *(char**)addr
= wstrdup(data
);
1321 getPathList(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
1330 if (!PLIsArray(value
)) {
1331 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1332 PLGetString(entry
->plkey
), "an array of paths");
1334 value
= entry
->plvalue
;
1336 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1343 count
= PLGetNumberOfElements(value
);
1346 value
= entry
->plvalue
;
1348 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1354 data
= wmalloc(sizeof(char*)*(count
+1));
1355 for (i
=0; i
<count
; i
++) {
1356 d
= PLGetArrayElement(value
, i
);
1357 if (!d
|| !PLIsString(d
)) {
1360 data
[i
] = wstrdup(PLGetString(d
));
1364 if (*(char***)addr
!=NULL
) {
1365 char **tmp
= *(char***)addr
;
1366 for (i
=0; tmp
[i
]!=NULL
; i
++) {
1371 *(char***)addr
= data
;
1378 getFocusMode(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
1385 STRINGP("one of Manual, Auto or Sloppy");
1387 val
= PLGetString(value
);
1390 if (strcasecmp(val
, "manual")==0 || strcasecmp(val
, "clicktofocus")==0)
1392 else if (strcasecmp(val
, "auto")==0 || strcasecmp(val
, "focusfollowsmouse")==0)
1394 else if ((strcasecmp(val
, "semiauto")==0 || strcasecmp(val
, "sloppy")==0)
1395 && !(int)entry
->extra_data
)
1398 if (!(int)entry
->extra_data
)
1399 wwarning(_("Invalid focus mode \"%s\". Should be Manual, "
1400 "Auto or Sloppy."), PLGetString(value
));
1402 wwarning(_("Invalid colormap focus mode \"%s\". Should be Manual or "
1403 "Auto."), PLGetString(value
));
1404 if (second_pass
==0) {
1405 val
= PLGetString(entry
->plvalue
);
1407 wwarning(_("using default \"%s\" instead"), val
);
1417 *(char*)addr
= data
;
1424 getPlacement(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
1431 STRINGP("one of Auto, Cascade, Random or Manual");
1433 val
= PLGetString(value
);
1436 if (strcasecmp(val
, "auto")==0 || strcasecmp(val
, "smart")==0)
1438 else if (strcasecmp(val
, "cascade")==0)
1440 else if (strcasecmp(val
, "manual")==0)
1442 else if (strcasecmp(val
, "random")==0)
1445 wwarning(_("Invalid window placement mode \"%s\". "
1446 "Should be Auto, Cascade, Random or Manual."),
1447 PLGetString(value
));
1448 if (second_pass
==0) {
1449 val
= PLGetString(entry
->plvalue
);
1451 wwarning(_("using default \"%s\" instead"), val
);
1461 *(char*)addr
= data
;
1469 getGeomDisp(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
1475 STRINGP("one of Center, Corner, Floating or Line");
1478 if(PLIsEqual(value
, DCenter
))
1480 else if(PLIsEqual(value
, DCorner
))
1481 data
= WDIS_TOPLEFT
;
1482 else if(PLIsEqual(value
, DFloating
))
1483 data
= WDIS_FRAME_CENTER
;
1484 else if(PLIsEqual(value
, DLine
))
1487 wwarning(_("Invalid geometry display type \"%s\". Should "
1488 "be Center, Corner, Floating or Line."),
1489 PLGetString(value
));
1491 value
= entry
->plvalue
;
1493 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1503 *(char*)addr
= data
;
1510 getSpeed(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
1517 STRINGP("one of UltraFast, Fast, Medium, Slow or UltraSlow");
1519 val
= PLGetString(value
);
1523 if (strcasecmp(val
, "ultrafast")==0)
1524 data
= SPEED_ULTRAFAST
;
1525 else if (strcasecmp(val
, "fast")==0)
1527 else if (strcasecmp(val
, "medium")==0)
1528 data
= SPEED_MEDIUM
;
1529 else if (strcasecmp(val
, "slow")==0)
1531 else if (strcasecmp(val
, "ultraslow")==0)
1532 data
= SPEED_ULTRASLOW
;
1534 wwarning(_("Invalid speed \"%s\". Should be UltraFast, Fast, "
1535 "Medium, Slow or UltraSlow."), PLGetString(value
));
1536 if (second_pass
==0) {
1537 val
= PLGetString(entry
->plvalue
);
1539 wwarning(_("using default \"%s\" instead"), val
);
1556 getMButton(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
1563 STRINGP("one of Left, Middle, Right or Button1 through Button5");
1565 val
= PLGetString(value
);
1568 if (strcasecmp(val
, "left")==0 || strcasecmp(val
, "button1")==0)
1570 else if (strcasecmp(val
, "middle")==0 || strcasecmp(val
, "button2")==0)
1572 else if (strcasecmp(val
, "right")==0 || strcasecmp(val
, "button3")==0)
1574 else if (strcasecmp(val
, "button4")==0)
1576 else if (strcasecmp(val
, "button5")==0)
1579 wwarning(_("Invalid mouse button \"%s\". "
1580 "Should be Left, Middle, Right or Button1 through Button5"),
1581 PLGetString(value
));
1582 if (second_pass
==0) {
1583 val
= PLGetString(entry
->plvalue
);
1585 wwarning(_("using default \"%s\" instead"), val
);
1595 *(char*)addr
= data
;
1602 getIconificationStyle(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
,
1603 void *addr
, void **ret
)
1609 STRINGP("one of Zoom, Twist, Flip or None");
1611 val
= PLGetString(value
);
1614 if (strcasecmp(val
, "zoom")==0)
1616 else if (strcasecmp(val
, "twist")==0)
1618 else if (strcasecmp(val
, "flip")==0)
1620 else if (strcasecmp(val
, "none")==0)
1623 wwarning(_("Invalid iconification style \"%s\". "
1624 "Should be Zoom, Twist, Flip or None"),
1625 PLGetString(value
));
1626 if (second_pass
==0) {
1627 val
= PLGetString(entry
->plvalue
);
1629 wwarning(_("using default \"%s\" instead"), val
);
1639 *(char*)addr
= data
;
1649 * (hgradient <color> <color>)
1650 * (vgradient <color> <color>)
1651 * (dgradient <color> <color>)
1652 * (mhgradient <color> <color> ...)
1653 * (mvgradient <color> <color> ...)
1654 * (tpixmap <file> <color>)
1655 * (spixmap <file> <color>)
1656 * (cpixmap <file> <color>)
1660 parse_texture(WScreen
*scr
, proplist_t pl
)
1665 WTexture
*texture
=NULL
;
1667 nelem
= PLGetNumberOfElements(pl
);
1672 elem
= PLGetArrayElement(pl
, 0);
1673 if (!elem
|| !PLIsString(elem
))
1675 val
= PLGetString(elem
);
1678 if (strcasecmp(val
, "solid")==0) {
1686 elem
= PLGetArrayElement(pl
, 1);
1687 if (!elem
|| !PLIsString(elem
))
1689 val
= PLGetString(elem
);
1691 if (!XParseColor(dpy
, scr
->colormap
, val
, &color
)) {
1692 wwarning(_("\"%s\" is not a valid color name"), val
);
1696 texture
= (WTexture
*)wTextureMakeSolid(scr
, &color
);
1697 } else if (strcasecmp(val
, "dgradient")==0
1698 || strcasecmp(val
, "vgradient")==0
1699 || strcasecmp(val
, "hgradient")==0) {
1700 XColor color1
, color2
;
1704 wwarning(_("bad number of arguments in gradient specification"));
1708 if (val
[0]=='d' || val
[0]=='D')
1709 type
= WTEX_DGRADIENT
;
1710 else if (val
[0]=='h' || val
[0]=='H')
1711 type
= WTEX_HGRADIENT
;
1713 type
= WTEX_VGRADIENT
;
1716 /* get from color */
1717 elem
= PLGetArrayElement(pl
, 1);
1718 if (!elem
|| !PLIsString(elem
))
1720 val
= PLGetString(elem
);
1722 if (!XParseColor(dpy
, scr
->colormap
, val
, &color1
)) {
1723 wwarning(_("\"%s\" is not a valid color name"), val
);
1728 elem
= PLGetArrayElement(pl
, 2);
1729 if (!elem
|| !PLIsString(elem
)) {
1732 val
= PLGetString(elem
);
1734 if (!XParseColor(dpy
, scr
->colormap
, val
, &color2
)) {
1735 wwarning(_("\"%s\" is not a valid color name"), val
);
1739 texture
= (WTexture
*)wTextureMakeGradient(scr
, type
, &color1
, &color2
);
1741 } else if (strcasecmp(val
, "mhgradient")==0
1742 || strcasecmp(val
, "mvgradient")==0
1743 || strcasecmp(val
, "mdgradient")==0) {
1750 wwarning(_("too few arguments in multicolor gradient specification"));
1754 if (val
[1]=='h' || val
[1]=='H')
1755 type
= WTEX_MHGRADIENT
;
1756 else if (val
[1]=='v' || val
[1]=='V')
1757 type
= WTEX_MVGRADIENT
;
1759 type
= WTEX_MDGRADIENT
;
1763 colors
= wmalloc(sizeof(RColor
*)*(count
+1));
1765 for (i
=0; i
<count
; i
++) {
1766 elem
= PLGetArrayElement(pl
, i
+1);
1767 if (!elem
|| !PLIsString(elem
)) {
1768 for ( ; i
>=0; --i
) {
1774 val
= PLGetString(elem
);
1776 if (!XParseColor(dpy
, scr
->colormap
, val
, &color
)) {
1777 wwarning(_("\"%s\" is not a valid color name"), val
);
1778 for ( ; i
>=0; --i
) {
1784 colors
[i
] = wmalloc(sizeof(RColor
));
1785 colors
[i
]->red
= color
.red
>> 8;
1786 colors
[i
]->green
= color
.green
>> 8;
1787 colors
[i
]->blue
= color
.blue
>> 8;
1792 texture
= (WTexture
*)wTextureMakeMGradient(scr
, type
, colors
);
1793 } else if (strcasecmp(val
, "spixmap")==0 ||
1794 strcasecmp(val
, "cpixmap")==0 ||
1795 strcasecmp(val
, "tpixmap")==0) {
1802 if (val
[0] == 's' || val
[0] == 'S')
1804 else if (val
[0] == 'c' || val
[0] == 'C')
1810 elem
= PLGetArrayElement(pl
, 2);
1811 if (!elem
|| !PLIsString(elem
)) {
1814 val
= PLGetString(elem
);
1816 if (!XParseColor(dpy
, scr
->colormap
, val
, &color
)) {
1817 wwarning(_("\"%s\" is not a valid color name"), val
);
1822 elem
= PLGetArrayElement(pl
, 1);
1823 if (!elem
|| !PLIsString(elem
))
1825 val
= PLGetString(elem
);
1827 texture
= (WTexture
*)wTextureMakePixmap(scr
, type
, val
, &color
);
1838 getTexture(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
1841 static WTexture
*texture
;
1845 if (!PLIsArray(value
)) {
1846 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1847 PLGetString(entry
->plkey
), "Texture");
1849 value
= entry
->plvalue
;
1851 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1857 texture
= parse_texture(scr
, value
);
1860 wwarning(_("Error in texture specification for key \"%s\""),
1861 PLGetString(entry
->plkey
));
1863 value
= entry
->plvalue
;
1865 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1875 *(WTexture
**)addr
= texture
;
1884 getWSBackground(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
,
1885 void *addr
, void **ret
)
1890 static WTexture
*texture
=NULL
;
1895 entry
->extra_data
= NULL
;
1897 if (!PLIsArray(value
)) {
1898 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1899 "WorkspaceBack", "Texture");
1901 value
= entry
->plvalue
;
1903 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1909 nelem
= PLGetNumberOfElements(value
);
1911 wwarning(_("Too few elements in array for key \"WorkspaceBack\"."));
1913 value
= entry
->plvalue
;
1915 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1921 elem
= PLGetArrayElement(value
, 0);
1922 if (!elem
|| !PLIsString(elem
)) {
1923 wwarning(_("Wrong type for workspace background. Should be Texture."));
1925 value
= entry
->plvalue
;
1927 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1932 val
= PLGetString(elem
);
1934 if (strcasecmp(val
, "None")==0)
1937 if (strcasecmp(val
, "spixmap")!=0 && strcasecmp(val
, "tpixmap")!=0
1938 && strcasecmp(val
, "cpixmap")!=0) {
1939 texture
= parse_texture(scr
, value
);
1941 /* spixmap || tpixmap || cpixmap */
1946 wwarning(_("Too few elements in array for key \"WorkspaceBack\"."));
1948 value
= entry
->plvalue
;
1950 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1971 elem
= PLGetArrayElement(value
, 2);
1972 if (!elem
|| !PLIsString(elem
)) {
1973 wwarning(_("Cannot get color entry for key \"WorkspaceBack\"."));
1975 value
= entry
->plvalue
;
1977 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1982 val
= PLGetString(elem
);
1984 if (!XParseColor(dpy
, scr
->colormap
, val
, &color
)) {
1985 wwarning(_("key \"WorkspaceBack\" has invalid color \"%s\""),
1988 value
= entry
->plvalue
;
1990 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1997 elem
= PLGetArrayElement(value
, 1);
1998 if (!elem
|| !PLIsString(elem
)) {
1999 wwarning(_("Cannot get file entry for key \"WorkspaceBack\"."));
2001 value
= entry
->plvalue
;
2003 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
2009 val
= PLGetString(elem
);
2010 file
= FindImage(wPreferences
.pixmap_path
, val
);
2012 wwarning(_("could not find background image \"%s\""), val
);
2016 /* create a dummy texture.
2017 * use free() to free this texture.
2019 texture
= wmalloc(sizeof(WTexture
));
2020 memset(texture
, 0, sizeof(WTexture
));
2021 texture
->type
= WTEX_PIXMAP
;
2022 texture
->subtype
= style
;
2023 texture
->normal
= color
;
2029 wwarning(_("Error in texture specification for key \"WorkspaceBack\""));
2031 value
= entry
->plvalue
;
2033 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
2043 *(WTexture
**)addr
= texture
;
2045 /* we use the extra_data field to pass the filename string
2046 * to the background setting function. We can't pass it with
2047 * WTexture because it holds a RImage, not a file name.
2048 * It also would be dirtier to cast the RImage to char* to make it
2049 * hold the file name. The extra_data must be freed by the
2052 entry
->extra_data
= file
;
2056 #else /* !EXPERIMENTAL */
2058 getWSBackground(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
,
2059 void *addr
, void **ret
)
2064 static WTexture
*texture
=NULL
;
2068 if (!PLIsArray(value
)) {
2069 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
2070 "WorkspaceBack", "Texture");
2072 value
= entry
->plvalue
;
2074 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
2080 nelem
= PLGetNumberOfElements(value
);
2082 wwarning(_("Too few elements in array for key \"WorkspaceBack\"."));
2084 value
= entry
->plvalue
;
2086 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
2092 elem
= PLGetArrayElement(value
, 0);
2093 if (!elem
|| !PLIsString(elem
)) {
2094 wwarning(_("Wrong type for workspace background. Should be Texture."));
2096 value
= entry
->plvalue
;
2098 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
2103 val
= PLGetString(elem
);
2105 if (strcasecmp(val
, "None")==0)
2108 if (strcasecmp(val
, "spixmap")!=0 && strcasecmp(val
, "tpixmap")!=0
2109 && strcasecmp(val
, "cpixmap")!=0) {
2110 texture
= parse_texture(scr
, value
);
2113 /* spixmap || tpixmap || cpixmap */
2115 char *file
, cpc
[30], *style
= "-s";
2116 char *program
= "wmsetbg";
2120 wwarning(_("Too few elements in array for key \"WorkspaceBack\"."));
2122 value
= entry
->plvalue
;
2124 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
2130 if (val
[0] == 't' || val
[0] == 'T')
2132 else if (val
[0] == 'c' || val
[0] == 'C')
2135 sprintf(cpc
, "%i", wPreferences
.cmap_size
);
2138 elem
= PLGetArrayElement(value
, 2);
2139 if (!elem
|| !PLIsString(elem
)) {
2140 wwarning(_("Cannot get color entry for key \"WorkspaceBack\"."));
2142 value
= entry
->plvalue
;
2144 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
2149 val
= PLGetString(elem
);
2151 if (!XParseColor(dpy
, scr
->colormap
, val
, &color
)) {
2152 wwarning(_("key \"WorkspaceBack\" has invalid color \"%s\""),
2155 value
= entry
->plvalue
;
2157 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
2163 back
= wstrdup(val
);
2166 elem
= PLGetArrayElement(value
, 1);
2167 if (!elem
|| !PLIsString(elem
)) {
2168 wwarning(_("Cannot get file entry for key \"WorkspaceBack\"."));
2170 value
= entry
->plvalue
;
2172 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
2178 val
= PLGetString(elem
);
2180 file
= FindImage(wPreferences
.pixmap_path
, val
);
2183 SetupEnvironment(scr
);
2185 close(ConnectionNumber(dpy
));
2187 execlp(program
, program
, style
, "-c", cpc
, "-b", back
, file
, NULL
);
2188 wwarning(_("could not run \"%s\""), program
);
2193 wwarning(_("could not find background image \"%s\""), val
);
2198 /* This is to let WindowMaker put a color in the background
2199 * until the pixmap is loaded, if the image is big and loads slow.
2200 * It assumes that the color will be set before the image is set
2201 * by the child. Is this true for very small images?
2203 texture
= (WTexture
*)wTextureMakeSolid(scr
, &color
);
2207 wwarning(_("Error in texture specification for key \"WorkspaceBack\""));
2209 value
= entry
->plvalue
;
2211 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
2221 *(WTexture
**)addr
= texture
;
2225 #endif /* !EXPERIMENTAL */
2228 getJust(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
2234 STRINGP("one of Left, Center or Right");
2237 if(PLIsEqual(value
, JLeft
))
2239 else if(PLIsEqual(value
, JRight
))
2241 else if(PLIsEqual(value
, JCenter
))
2244 wwarning(_("Invalid justification type \"%s\". Should be "
2245 "Left, Center or Right"), PLGetString(value
));
2247 value
= entry
->plvalue
;
2249 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
2259 *(char*)addr
= data
;
2266 getFont(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
2274 val
= PLGetString(value
);
2276 font
= wLoadFont(val
);
2278 wwarning(_("could not load any usable font"));
2286 wwarning("BUG:can't assign font value outside update function");
2294 getColor(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
2297 static unsigned long pixel
;
2304 val
= PLGetString(value
);
2307 if (!wGetColor(scr
, val
, &color
)) {
2308 wwarning(_("could not get color for key \"%s\""),
2309 PLGetString(entry
->plkey
));
2310 if (second_pass
==0) {
2311 val
= PLGetString(entry
->plvalue
);
2313 wwarning(_("using default \"%s\" instead"), val
);
2319 pixel
= color
.pixel
;
2325 *(unsigned long*)addr
= pixel
;
2333 getKeybind(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
2336 static WShortKey shortcut
;
2343 STRINGP("Key spec");
2345 val
= PLGetString(value
);
2347 if (!val
|| strcasecmp(val
, "NONE")==0) {
2348 shortcut
.keycode
= 0;
2349 shortcut
.modifier
= 0;
2360 shortcut
.modifier
= 0;
2361 while ((k
= strchr(b
, '+'))!=NULL
) {
2365 mod
= wXModifierFromKey(b
);
2367 wwarning(_("%s:invalid key modifier \"%s\""), entry
->key
, val
);
2370 shortcut
.modifier
|= mod
;
2376 ksym
= XStringToKeysym(b
);
2378 if (ksym
==NoSymbol
) {
2379 wwarning(_("%s:invalid kbd shortcut specification \"%s\""), entry
->key
,
2384 shortcut
.keycode
= XKeysymToKeycode(dpy
, ksym
);
2385 if (shortcut
.keycode
==0) {
2386 wwarning(_("%s:invalid key in shortcut \"%s\""), entry
->key
, val
);
2398 getModMask(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
2404 STRINGP("Modifier Key");
2406 str
= PLGetString(value
);
2410 mask
= wXModifierFromKey(str
);
2412 wwarning(_("%s: modifier key %s is not valid"), entry
->key
, str
);
2418 *(unsigned int*)addr
= mask
;
2429 getIconPosition(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
2436 STRINGP("one of blv, blh, brv, brh, tlv, tlh, trv, trh");
2438 val
= PLGetString(value
);
2441 if (strlen(val
)==3) {
2442 if (val
[0]=='T' || val
[0]=='t') {
2447 if (val
[1]=='R' || val
[1]=='r') {
2452 if (val
[2]=='V' || val
[2]=='v') {
2458 wwarning(_("Invalid icon Position \"%s\". "
2459 "Should be one of blv, blh, brv, brh, tlv, tlh, trv, trh"),
2460 PLGetString(value
));
2461 if (second_pass
==0) {
2462 val
= PLGetString(entry
->plvalue
);
2464 wwarning(_("using default \"%s\" instead"), val
);
2480 /* ---------------- value setting functions --------------- */
2482 setJustify(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
2484 return REFRESH_FORE_COLOR
;
2489 setIfDockPresent(WScreen
*scr
, WDefaultEntry
*entry
, int *flag
, long which
)
2493 wPreferences
.flags
.nodock
= wPreferences
.flags
.nodock
|| *flag
;
2496 wPreferences
.flags
.noclip
= wPreferences
.flags
.noclip
|| *flag
;
2506 setStickyIcons(WScreen
*scr
, WDefaultEntry
*entry
, void *bar
, void *foo
)
2508 if (scr
->workspaces
) {
2509 wWorkspaceForceChange(scr
, scr
->current_workspace
);
2510 wArrangeIcons(scr
, False
);
2517 setPositive(WScreen
*scr
, WDefaultEntry
*entry
, int *value
, void *foo
)
2529 setIconTile(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
2535 img
= wTextureRenderImage(*texture
, wPreferences
.icon_size
,
2536 wPreferences
.icon_size
,
2537 ((*texture
)->any
.type
& WREL_BORDER_MASK
)
2538 ? WREL_ICON
: WREL_FLAT
);
2540 wwarning(_("could not render texture for icon background"));
2542 wTextureDestroy(scr
, *texture
);
2545 RConvertImage(scr
->rcontext
, img
, &pixmap
);
2547 if (scr
->icon_tile
) {
2549 RDestroyImage(scr
->icon_tile
);
2550 XFreePixmap(dpy
, scr
->icon_tile_pixmap
);
2553 scr
->icon_tile
= img
;
2555 if (!wPreferences
.flags
.noclip
) {
2556 if (scr
->clip_tile
) {
2557 RDestroyImage(scr
->clip_tile
);
2559 scr
->clip_tile
= wClipMakeTile(scr
, img
);
2562 scr
->icon_tile_pixmap
= pixmap
;
2564 if (scr
->def_icon_pixmap
) {
2565 XFreePixmap(dpy
, scr
->def_icon_pixmap
);
2566 scr
->def_icon_pixmap
= None
;
2568 if (scr
->def_ticon_pixmap
) {
2569 XFreePixmap(dpy
, scr
->def_ticon_pixmap
);
2570 scr
->def_ticon_pixmap
= None
;
2573 if (scr
->icon_back_texture
) {
2574 wTextureDestroy(scr
, (WTexture
*)scr
->icon_back_texture
);
2576 scr
->icon_back_texture
= wTextureMakeSolid(scr
, &((*texture
)->any
.color
));
2578 if (scr
->clip_balloon
)
2579 XSetWindowBackground(dpy
, scr
->clip_balloon
,
2580 (*texture
)->any
.color
.pixel
);
2583 * Free the texture as nobody else will use it, nor refer to it.
2586 wTextureDestroy(scr
, *texture
);
2588 return (reset
? REFRESH_ICON_TILE
: 0);
2594 setWinTitleFont(WScreen
*scr
, WDefaultEntry
*entry
, WFont
*font
, void *foo
)
2596 if (scr
->title_font
) {
2597 wFreeFont(scr
->title_font
);
2600 scr
->title_font
= font
;
2603 XSetFont(dpy
, scr
->window_title_gc
, font
->font
->fid
);
2606 return REFRESH_WINDOW_FONT
;
2611 setMenuTitleFont(WScreen
*scr
, WDefaultEntry
*entry
, WFont
*font
, void *foo
)
2613 if (scr
->menu_title_font
) {
2614 wFreeFont(scr
->menu_title_font
);
2617 scr
->menu_title_font
= font
;
2620 XSetFont(dpy
, scr
->menu_title_gc
, font
->font
->fid
);
2623 return REFRESH_MENU_TITLE_FONT
;
2628 setMenuTextFont(WScreen
*scr
, WDefaultEntry
*entry
, WFont
*font
, void *foo
)
2630 if (scr
->menu_entry_font
) {
2631 wFreeFont(scr
->menu_entry_font
);
2634 scr
->menu_entry_font
= font
;
2637 XSetFont(dpy
, scr
->menu_entry_gc
, font
->font
->fid
);
2638 XSetFont(dpy
, scr
->disabled_menu_entry_gc
, font
->font
->fid
);
2639 XSetFont(dpy
, scr
->select_menu_gc
, font
->font
->fid
);
2642 return REFRESH_MENU_FONT
;
2648 setIconTitleFont(WScreen
*scr
, WDefaultEntry
*entry
, WFont
*font
, void *foo
)
2650 if (scr
->icon_title_font
) {
2651 wFreeFont(scr
->icon_title_font
);
2654 scr
->icon_title_font
= font
;
2657 XSetFont(dpy
, scr
->icon_title_gc
, font
->font
->fid
);
2660 return REFRESH_ICON_FONT
;
2665 setClipTitleFont(WScreen
*scr
, WDefaultEntry
*entry
, WFont
*font
, void *foo
)
2667 if (scr
->clip_title_font
) {
2668 wFreeFont(scr
->clip_title_font
);
2671 scr
->clip_title_font
= font
;
2674 XSetFont(dpy
, scr
->clip_title_gc
, font
->font
->fid
);
2677 return REFRESH_ICON_FONT
;
2682 setDisplayFont(WScreen
*scr
, WDefaultEntry
*entry
, WFont
*font
, void *foo
)
2684 if (scr
->info_text_font
) {
2685 wFreeFont(scr
->info_text_font
);
2688 scr
->info_text_font
= font
;
2691 XSetFont(dpy
, scr
->info_text_gc
, font
->font
->fid
);
2692 XSetFont(dpy
, scr
->line_gc
, font
->font
->fid
);
2695 /* This test works because the scr structure is initially zeroed out
2696 and None = 0. Any other time, the window should be valid. */
2697 if (scr
->geometry_display
!= None
) {
2698 wGetGeometryWindowSize(scr
, &scr
->geometry_display_width
,
2699 &scr
->geometry_display_height
);
2700 XResizeWindow(dpy
, scr
->geometry_display
,
2701 scr
->geometry_display_width
, scr
->geometry_display_height
);
2709 setHightlight(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, void *foo
)
2711 if (scr
->select_pixel
!=scr
->white_pixel
&&
2712 scr
->select_pixel
!=scr
->black_pixel
) {
2713 wFreeColor(scr
, scr
->select_pixel
);
2716 scr
->select_pixel
= color
->pixel
;
2718 return REFRESH_FORE_COLOR
;
2723 setHightlightText(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, void *foo
)
2725 if (scr
->select_text_pixel
!=scr
->white_pixel
&&
2726 scr
->select_text_pixel
!=scr
->black_pixel
) {
2727 wFreeColor(scr
, scr
->select_text_pixel
);
2730 scr
->select_text_pixel
= color
->pixel
;
2732 return REFRESH_FORE_COLOR
;
2737 setClipTitleColor(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, long index
)
2739 if (scr
->clip_title_pixel
[index
]!=scr
->white_pixel
&&
2740 scr
->clip_title_pixel
[index
]!=scr
->black_pixel
) {
2741 wFreeColor(scr
, scr
->clip_title_pixel
[index
]);
2744 scr
->clip_title_pixel
[index
] = color
->pixel
;
2746 return REFRESH_FORE_COLOR
;
2751 setWTitleColor(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, long index
)
2753 if (scr
->window_title_pixel
[index
]!=scr
->white_pixel
&&
2754 scr
->window_title_pixel
[index
]!=scr
->black_pixel
) {
2755 wFreeColor(scr
, scr
->window_title_pixel
[index
]);
2758 scr
->window_title_pixel
[index
] = color
->pixel
;
2760 if (index
== WS_FOCUSED
)
2761 XSetForeground(dpy
, scr
->icon_title_gc
, color
->pixel
);
2762 else if (index
== WS_UNFOCUSED
)
2763 XSetForeground(dpy
, scr
->info_text_gc
, color
->pixel
);
2765 return REFRESH_FORE_COLOR
;
2770 setMenuTitleColor(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, void *foo
)
2772 if (scr
->menu_title_pixel
[0]!=scr
->white_pixel
&&
2773 scr
->menu_title_pixel
[0]!=scr
->black_pixel
) {
2774 wFreeColor(scr
, scr
->menu_title_pixel
[0]);
2777 scr
->menu_title_pixel
[0] = color
->pixel
;
2779 XSetForeground(dpy
, scr
->menu_title_gc
, color
->pixel
);
2781 return REFRESH_FORE_COLOR
;
2786 setMenuTextColor(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, void *foo
)
2789 #define gcm (GCForeground|GCBackground|GCFillStyle)
2791 if (scr
->mtext_pixel
!=scr
->white_pixel
&&
2792 scr
->mtext_pixel
!=scr
->black_pixel
) {
2793 wFreeColor(scr
, scr
->mtext_pixel
);
2796 scr
->mtext_pixel
= color
->pixel
;
2798 XSetForeground(dpy
, scr
->menu_entry_gc
, color
->pixel
);
2801 if (scr
->dtext_pixel
== scr
->mtext_pixel
) {
2802 gcv
.foreground
= scr
->white_pixel
;
2803 gcv
.background
= scr
->black_pixel
;
2804 gcv
.fill_style
= FillStippled
;
2806 gcv
.foreground
= scr
->dtext_pixel
;
2807 gcv
.fill_style
= FillSolid
;
2809 XChangeGC(dpy
, scr
->disabled_menu_entry_gc
, gcm
, &gcv
);
2811 return REFRESH_FORE_COLOR
;
2817 setMenuDisabledColor(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, void *foo
)
2820 #define gcm (GCForeground|GCBackground|GCFillStyle)
2822 if (scr
->dtext_pixel
!=scr
->white_pixel
&&
2823 scr
->dtext_pixel
!=scr
->black_pixel
) {
2824 wFreeColor(scr
, scr
->dtext_pixel
);
2827 scr
->dtext_pixel
= color
->pixel
;
2829 if (scr
->dtext_pixel
== scr
->mtext_pixel
) {
2830 gcv
.foreground
= scr
->white_pixel
;
2831 gcv
.background
= scr
->black_pixel
;
2832 gcv
.fill_style
= FillStippled
;
2834 gcv
.foreground
= scr
->dtext_pixel
;
2835 gcv
.fill_style
= FillSolid
;
2837 XChangeGC(dpy
, scr
->disabled_menu_entry_gc
, gcm
, &gcv
);
2839 return REFRESH_FORE_COLOR
;
2846 * Implementation of workspace specific backgrounds.
2848 * WorkspaceBack is used as the default background.
2849 * WorkspaceSpecificBack supplies an array with the textures for
2851 * WorkspaceSpecificBack = (ws1texture, ws2texture, "", ws4texture);
2852 * "" means that workspace3 should use the default texture.
2854 * struct WWorkspaceTexture {
2855 * Pixmap pixmap; // the pixmap for non-solid textures.
2856 * //None means the texture is solid
2857 * WPixel color; // color for solid texture
2858 * proplist_t texture; // for checking updates
2861 * spixmap and cpixmap textures are rendered by wmsetbg in a buffer
2862 * supplied by wmaker (-x drawable-XID).
2863 * All other textures are rendered by wmaker itself. This is to
2864 * prevent wmaker from blocking when rendering large pixmaps.
2865 * tpixmap must be rendered by wmaker because we dont know the size
2866 * of the image before loading the image. We supply the pixmap
2867 * to wmsetbg, instead of letting wmsetbg create it for 2 reasons:
2868 * 1 - Xlib will free the pixmap when wmsetbg exits
2869 * 2 - it would require wmaker to figure when wmsetbg finished
2870 * rendering (complicated synchronization...).
2872 * The workspace background cant be set if the pid field of the
2873 * texture is 0. Otherwise, the texture is still being rendered
2876 * If the workspace background is changed before wmsetbg finishes
2877 * the rendering, wmsetbg must be killed.
2880 * Workspace specific textures are generated only when switching to
2881 * that workspace, unless #define SLOW_CONFIGURATION_UPDATE.
2887 trackDeadProcess(pid_t pid
, unsigned char status
, WScreen
*scr
)
2889 WWorkspaceTexture
*wsback
;
2890 int setBackground
= 0;
2892 /* find out to which wsback, this process belongs to */
2895 if (status
!= 123) {
2896 /* something went wrong during rendering */
2897 XFreePixmap(dpy
, wsback
->pixmap
);
2898 wsback
->pixmap
= None
;
2899 wwarning(_("background texture rendering was unsuccessfull"));
2902 if (setBackground
) {
2907 makeWorkspaceTexture(WScreen
*scr
, WTexture
*texture
, char *file
, char *option
)
2909 WWorkspaceTexture
*wsback
;
2911 wsback
= wmalloc(sizeof(WWorkspaceTexture
));
2914 wsback
->solid
= (*texture
)->any
.color
.pixel
;
2916 if (texture
->any
.type
==WTEX_SOLID
) {
2917 wsback
->pixmap
= None
;
2918 } else if (texture
->any
.type
== WTEX_PIXMAP
) {
2920 if (texture
->pixmap
.subtype
== WTP_TILE
) {
2923 /* render ourseves */
2924 image
= RLoadImage(scr
->rcontext
, file
, 0);
2926 wwarning(_("could not load image %s for option %s:%s\n"),
2927 file
, option
, RErrorString
);
2928 wsback
->pixmap
= None
;
2932 /* create a empty pixmap... */
2934 int style
= texture
->pixmap
.subtype
;
2936 pixmap
= XCreatePixmap(dpy
, scr
->root_win
, scr
->scr_width
,
2937 scr
->scr_height
, scr
->depth
);
2939 /* ...and let wmsetbg render it */
2942 wsyserror(_("could not spawn texture rendering subprocess for option"));
2943 } else if (pid
== 0) {
2946 SetupEnvironment(scr
);
2948 close(ConnectionNumber(dpy
));
2950 colorn
= wmalloc(32);
2951 sprintf(colorn
, "\"#%2x%2x%2x\"",
2952 texture
->any
.color
.red
,
2953 texture
->any
.color
.green
,
2954 texture
->any
.color
.blue
);
2956 sprintf(pix
, "%x", pixmap
);
2957 execlp("wmsetbg", "wmsetbg", (style
==WTP_SCALE
? "-s":"-e"),
2958 "-b", colorn
, "-x", pix
, file
);
2961 wsback
->pixmap
= pixmap
;
2962 /* must add a death handler to detect when wmsetbg has
2963 * exited (with exit status 123) and refresh the background.
2971 switch (texture
->any
.type
) {
2972 case WTEX_HGRADIENT
:
2973 case WTEX_MHGRADIENT
:
2978 case WTEX_VGRADIENT
:
2979 case WTEX_MVGRADIENT
:
2981 h
= scr
->scr_height
;
2984 case WTEX_DGRADIENT
:
2985 case WTEX_MDGRADIENT
:
2987 h
= scr
->scr_height
;
2994 img
= wTextureRenderImage(texture
, w
, h
, WREL_FLAT
);
2996 wwarning(_("could not render texture for workspace background"));
3000 RConvertImage(scr
->rcontext
, img
, &pixmap
);
3002 wsback
->pixmap
= pixmap
;
3010 setWorkspaceBack(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
,
3016 if (scr
->defaultTexture
) {
3017 if (scr
->defaultTexture
->pixmap
)
3018 XFreePixmap(dpy
, scr
->defaultTexture
->pixmap
);
3019 free(scr
->defaultTexture
);
3023 scr
->defaultTexture
= NULL
;
3029 scr
->defaultTexture
= makeWorkspaceTexture(scr
, *texture
, file
);
3032 wTextureDestroy(scr
, *texture
);
3034 /* free the file name that was passed from the getWSBackground()
3035 * function and placed in entry->extra_data */
3038 entry
->extra_data
= NULL
;
3040 return REFRESH_WORKSPACE_BACK
;
3042 #else /* !EXPERIMENTAL */
3044 setWorkspaceBack(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
,
3051 if ((*texture
)->any
.type
==WTEX_SOLID
) {
3052 XSetWindowBackground(dpy
, scr
->root_win
, (*texture
)->solid
.normal
.pixel
);
3053 XClearWindow(dpy
, scr
->root_win
);
3057 switch ((*texture
)->any
.type
) {
3058 case WTEX_HGRADIENT
:
3059 case WTEX_MHGRADIENT
:
3064 case WTEX_VGRADIENT
:
3065 case WTEX_MVGRADIENT
:
3067 h
= scr
->scr_height
;
3070 case WTEX_DGRADIENT
:
3071 case WTEX_MDGRADIENT
:
3073 h
= scr
->scr_height
;
3078 wTextureDestroy(scr
, *texture
);
3082 img
= wTextureRenderImage(*texture
, w
, h
, WREL_FLAT
);
3084 wwarning(_("could not render texture for workspace background"));
3086 wTextureDestroy(scr
, *texture
);
3089 RConvertImage(scr
->rcontext
, img
, &pixmap
);
3091 XSetWindowBackgroundPixmap(dpy
, scr
->root_win
, pixmap
);
3092 XClearWindow(dpy
, scr
->root_win
);
3096 * Free the texture as nobody else will use it, nor refer to it.
3099 wTextureDestroy(scr
, *texture
);
3103 #endif /* !EXPERIMENTAL */
3106 setWidgetColor(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
3108 if (scr
->widget_texture
) {
3109 wTextureDestroy(scr
, (WTexture
*)scr
->widget_texture
);
3111 scr
->widget_texture
= *(WTexSolid
**)texture
;
3118 setFTitleBack(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
3120 if (scr
->window_title_texture
[WS_FOCUSED
]) {
3121 wTextureDestroy(scr
, scr
->window_title_texture
[WS_FOCUSED
]);
3123 scr
->window_title_texture
[WS_FOCUSED
] = *texture
;
3125 if (scr
->icon_title_texture
) {
3126 wTextureDestroy(scr
, (WTexture
*)scr
->icon_title_texture
);
3128 scr
->icon_title_texture
3129 = wTextureMakeSolid(scr
, &scr
->window_title_texture
[WS_FOCUSED
]->any
.color
);
3131 return REFRESH_WINDOW_TEXTURES
;
3136 setPTitleBack(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
3138 if (scr
->window_title_texture
[WS_PFOCUSED
]) {
3139 wTextureDestroy(scr
, scr
->window_title_texture
[WS_PFOCUSED
]);
3141 scr
->window_title_texture
[WS_PFOCUSED
] = *texture
;
3143 return REFRESH_WINDOW_TEXTURES
;
3148 setUTitleBack(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
3150 if (scr
->window_title_texture
[WS_UNFOCUSED
]) {
3151 wTextureDestroy(scr
, scr
->window_title_texture
[WS_UNFOCUSED
]);
3153 scr
->window_title_texture
[WS_UNFOCUSED
] = *texture
;
3155 if (scr
->resizebar_texture
[0]) {
3156 wTextureDestroy(scr
, (WTexture
*)scr
->resizebar_texture
[0]);
3158 scr
->resizebar_texture
[0]
3159 = wTextureMakeSolid(scr
, &scr
->window_title_texture
[WS_UNFOCUSED
]->any
.color
);
3161 if (scr
->geometry_display
!= None
)
3162 XSetWindowBackground(dpy
, scr
->geometry_display
,
3163 scr
->resizebar_texture
[0]->normal
.pixel
);
3165 return REFRESH_WINDOW_TEXTURES
;
3170 setMenuTitleBack(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
3172 if (scr
->menu_title_texture
[0]) {
3173 wTextureDestroy(scr
, scr
->menu_title_texture
[0]);
3175 scr
->menu_title_texture
[0] = *texture
;
3177 return REFRESH_MENU_TEXTURES
;
3182 setMenuTextBack(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
3184 if (scr
->menu_item_texture
) {
3185 wTextureDestroy(scr
, scr
->menu_item_texture
);
3186 wTextureDestroy(scr
, (WTexture
*)scr
->menu_item_auxtexture
);
3188 scr
->menu_item_texture
= *texture
;
3190 scr
->menu_item_auxtexture
3191 = wTextureMakeSolid(scr
, &scr
->menu_item_texture
->any
.color
);
3193 return REFRESH_MENU_TEXTURES
;
3198 setKeyGrab(WScreen
*scr
, WDefaultEntry
*entry
, WShortKey
*shortcut
, long index
)
3201 wKeyBindings
[index
] = *shortcut
;
3203 wwin
= scr
->focused_window
;
3205 while (wwin
!=NULL
) {
3206 XUngrabKey(dpy
, AnyKey
, AnyModifier
, wwin
->frame
->core
->window
);
3208 if (!wwin
->window_flags
.no_bind_keys
) {
3209 wWindowSetKeyGrabs(wwin
);
3219 setIconPosition(WScreen
*scr
, WDefaultEntry
*entry
, void *bar
, void *foo
)
3221 wArrangeIcons(scr
, True
);
3230 * Need access to the double click variables, so that all widgets in
3231 * wmaker panels will have the same dbl-click values.
3232 * TODO: figure a better way of dealing with it.
3237 setDoubleClick(WScreen
*scr
, WDefaultEntry
*entry
, int *value
, void *foo
)
3239 extern _WINGsConfiguration WINGsConfiguration
;
3244 WINGsConfiguration
.doubleClickDelay
= *value
;