1 /* defaults.c - manage configuration through defaults db
3 * Window Maker window manager
5 * Copyright (c) 1997, 1998 Alfredo K. Kojima
6 * Copyright (c) 1998 Dan Pascu
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
32 #include <sys/types.h>
45 #define PATH_MAX DEFAULT_PATH_MAX
49 #include <X11/Xutil.h>
50 #include <X11/keysym.h>
55 #include "WindowMaker.h"
61 #include "resources.h"
64 #include "xmodifier.h"
69 #include "workspace.h"
73 * Our own proplist reader parser. This one will not accept any
74 * syntax errors and is more descriptive in the error messages.
75 * It also doesn't seem to crash.
77 extern proplist_t
ReadProplistFromFile(char *file
);
82 extern WDDomain
*WDWindowMaker
;
83 extern WDDomain
*WDWindowAttributes
;
84 extern WDDomain
*WDRootMenu
;
86 extern int wScreenCount
;
89 extern proplist_t wDomainName;
90 extern proplist_t wAttributeDomainName;
92 extern WPreferences wPreferences
;
94 extern WShortKey wKeyBindings
[WKBD_LAST
];
104 proplist_t plvalue
; /* default value */
108 /* used to map strings to integers */
113 } WOptionEnumeration
;
116 /* type converters */
117 static int getBool();
119 static int getCoord();
121 /* this is not used yet */
122 static int getString();
124 static int getPathList();
125 static int getEnum();
126 static int getTexture();
127 static int getWSBackground();
128 static int getWSSpecificBackground();
129 static int getFont();
130 static int getColor();
131 static int getKeybind();
132 static int getModMask();
134 static int getRImage();
138 /* value setting functions */
139 static int setJustify();
140 static int setIfDockPresent();
141 static int setStickyIcons();
143 static int setPositive();
145 static int setWidgetColor();
146 static int setIconTile();
147 static int setWinTitleFont();
148 static int setMenuTitleFont();
149 static int setMenuTextFont();
150 static int setIconTitleFont();
151 static int setIconTitleColor();
152 static int setIconTitleBack();
153 static int setDisplayFont();
154 static int setLargeDisplayFont();
155 static int setWTitleColor();
156 static int setFTitleBack();
157 static int setPTitleBack();
158 static int setUTitleBack();
159 static int setResizebarBack();
160 static int setWorkspaceBack();
161 static int setWorkspaceSpecificBack();
162 static int setMenuTitleColor();
163 static int setMenuTextColor();
164 static int setMenuDisabledColor();
165 static int setMenuTitleBack();
166 static int setMenuTextBack();
167 static int setHightlight();
168 static int setHightlightText();
169 static int setKeyGrab();
170 static int setDoubleClick();
171 static int setIconPosition();
173 static int setClipTitleFont();
174 static int setClipTitleColor();
176 static int setMenuStyle();
177 static int setMultiByte();
179 static int updateUsableArea();
184 * Tables to convert strings to enumeration values.
185 * Values stored are char
189 /* WARNING: sum of length of all value strings must not exceed
191 #define TOTAL_VALUES_LENGTH 80
196 #define REFRESH_WINDOW_TEXTURES (1<<0)
197 #define REFRESH_MENU_TEXTURE (1<<1)
198 #define REFRESH_MENU_FONT (1<<2)
199 #define REFRESH_MENU_COLOR (1<<3)
200 #define REFRESH_MENU_TITLE_TEXTURE (1<<4)
201 #define REFRESH_MENU_TITLE_FONT (1<<5)
202 #define REFRESH_MENU_TITLE_COLOR (1<<6)
203 #define REFRESH_WINDOW_TITLE_COLOR (1<<7)
204 #define REFRESH_WINDOW_FONT (1<<8)
205 #define REFRESH_ICON_TILE (1<<9)
206 #define REFRESH_ICON_FONT (1<<10)
207 #define REFRESH_WORKSPACE_BACK (1<<11)
209 #define REFRESH_BUTTON_IMAGES (1<<12)
211 #define REFRESH_ICON_TITLE_COLOR (1<<13)
212 #define REFRESH_ICON_TITLE_BACK (1<<14)
216 static WOptionEnumeration seFocusModes
[] = {
217 {"Manual", WKF_CLICK
, 0}, {"ClickToFocus", WKF_CLICK
, 1},
218 {"Auto", WKF_POINTER
, 0}, {"FocusFollowMouse", WKF_POINTER
, 1},
219 {"Sloppy", WKF_SLOPPY
, 0}, {"SemiAuto", WKF_SLOPPY
, 1},
223 static WOptionEnumeration seColormapModes
[] = {
224 {"Manual", WKF_CLICK
, 0}, {"ClickToFocus", WKF_CLICK
, 1},
225 {"Auto", WKF_POINTER
, 0}, {"FocusFollowMouse", WKF_POINTER
, 1},
229 static WOptionEnumeration sePlacements
[] = {
230 {"Auto", WPM_SMART
, 0}, {"Smart", WPM_SMART
, 1},
231 {"Cascade", WPM_CASCADE
, 0},
232 {"Random", WPM_RANDOM
, 0},
233 {"Manual", WPM_MANUAL
, 0},
237 static WOptionEnumeration seGeomDisplays
[] = {
238 {"Center", WDIS_CENTER
, 0},
239 {"Corner", WDIS_TOPLEFT
, 0},
240 {"Floating", WDIS_FRAME_CENTER
, 0},
241 {"Line", WDIS_NEW
, 0},
245 static WOptionEnumeration seSpeeds
[] = {
246 {"UltraFast", SPEED_ULTRAFAST
, 0},
247 {"Fast", SPEED_FAST
, 0},
248 {"Medium", SPEED_MEDIUM
, 0},
249 {"Slow", SPEED_SLOW
, 0},
250 {"UltraSlow", SPEED_ULTRASLOW
, 0},
254 static WOptionEnumeration seMouseButtons
[] = {
255 {"Left", Button1
, 0}, {"Button1", Button1
, 1},
256 {"Middle", Button2
, 0}, {"Button2", Button2
, 1},
257 {"Right", Button3
, 0}, {"Button3", Button3
, 1},
258 {"Button4", Button4
, 0},
259 {"Button5", Button5
, 0},
263 static WOptionEnumeration seIconificationStyles
[] = {
264 {"Zoom", WIS_ZOOM
, 0},
265 {"Twist", WIS_TWIST
, 0},
266 {"Flip", WIS_FLIP
, 0},
267 {"None", WIS_NONE
, 0},
268 {"random", WIS_RANDOM
, 0},
272 static WOptionEnumeration seJustifications
[] = {
273 {"Left", WTJ_LEFT
, 0},
274 {"Center", WTJ_CENTER
, 0},
275 {"Right", WTJ_RIGHT
, 0},
279 static WOptionEnumeration seIconPositions
[] = {
280 {"blv", IY_BOTTOM
|IY_LEFT
|IY_VERT
, 0},
281 {"blh", IY_BOTTOM
|IY_LEFT
|IY_HORIZ
, 0},
282 {"brv", IY_BOTTOM
|IY_RIGHT
|IY_VERT
, 0},
283 {"brh", IY_BOTTOM
|IY_RIGHT
|IY_HORIZ
, 0},
284 {"tlv", IY_TOP
|IY_LEFT
|IY_VERT
, 0},
285 {"tlh", IY_TOP
|IY_LEFT
|IY_HORIZ
, 0},
286 {"trv", IY_TOP
|IY_RIGHT
|IY_VERT
, 0},
287 {"trh", IY_TOP
|IY_RIGHT
|IY_HORIZ
, 0},
291 static WOptionEnumeration seMenuStyles
[] = {
292 {"normal", MS_NORMAL
, 0},
293 {"singletexture", MS_SINGLE_TEXTURE
, 0},
294 {"flat", MS_FLAT
, 0},
299 static WOptionEnumeration seDisplayPositions
[] = {
300 {"none", WD_NONE
, 0},
301 {"center", WD_CENTER
, 0},
303 {"bottom", WD_BOTTOM
, 0},
304 {"topleft", WD_TOPLEFT
, 0},
305 {"topright", WD_TOPRIGHT
, 0},
306 {"bottomleft", WD_BOTTOMLEFT
, 0},
307 {"bottomright", WD_BOTTOMRIGHT
, 0}
312 * ALL entries in the tables bellow, NEED to have a default value
313 * defined, and this value needs to be correct.
316 /* these options will only affect the window manager on startup
318 * static defaults can't access the screen data, because it is
319 * created after these defaults are read
321 WDefaultEntry staticOptionList
[] = {
323 {"DisableDithering", "NO", NULL
,
324 &wPreferences
.no_dithering
, getBool
, NULL
326 {"ColormapSize", "4", NULL
,
327 &wPreferences
.cmap_size
, getInt
, NULL
329 /* static by laziness */
330 {"IconSize", "64", NULL
,
331 &wPreferences
.icon_size
, getInt
, NULL
333 {"ModifierKey", "Mod1", NULL
,
334 &wPreferences
.modifier_mask
, getModMask
, NULL
336 {"DisableWSMouseActions", "NO", NULL
,
337 &wPreferences
.disable_root_mouse
, getBool
, NULL
339 {"FocusMode", "manual", seFocusModes
,
340 &wPreferences
.focus_mode
, getEnum
, NULL
341 }, /* have a problem when switching from manual to sloppy without restart */
342 {"NewStyle", "NO", NULL
,
343 &wPreferences
.new_style
, getBool
, NULL
345 {"DisableDock", "NO", (void*) WM_DOCK
,
346 NULL
, getBool
, setIfDockPresent
348 {"DisableClip", "NO", (void*) WM_CLIP
,
349 NULL
, getBool
, setIfDockPresent
351 {"DisableMiniwindows", "NO", NULL
,
352 &wPreferences
.disable_miniwindows
, getBool
, NULL
354 {"MultiByteText", "NO", NULL
,
355 &wPreferences
.multi_byte_text
, getBool
, setMultiByte
361 WDefaultEntry optionList
[] = {
362 /* dynamic options */
363 {"IconPosition", "blh", seIconPositions
,
364 &wPreferences
.icon_yard
, getEnum
, setIconPosition
366 {"IconificationStyle", "Zoom", seIconificationStyles
,
367 &wPreferences
.iconification_style
, getEnum
, NULL
369 {"SelectWindowsMouseButton", "Left", seMouseButtons
,
370 &wPreferences
.select_button
, getEnum
, NULL
372 {"WindowListMouseButton", "Middle", seMouseButtons
,
373 &wPreferences
.windowl_button
, getEnum
, NULL
375 {"ApplicationMenuMouseButton", "Right", seMouseButtons
,
376 &wPreferences
.menu_button
, getEnum
, NULL
378 {"PixmapPath", DEF_PIXMAP_PATHS
, NULL
,
379 &wPreferences
.pixmap_path
, getPathList
, NULL
381 {"IconPath", DEF_ICON_PATHS
, NULL
,
382 &wPreferences
.icon_path
, getPathList
, NULL
384 {"ColormapMode", "auto", seColormapModes
,
385 &wPreferences
.colormap_mode
, getEnum
, NULL
387 {"AutoFocus", "NO", NULL
,
388 &wPreferences
.auto_focus
, getBool
, NULL
390 {"RaiseDelay", "0", NULL
,
391 &wPreferences
.raise_delay
, getInt
, NULL
393 {"CirculateRaise", "NO", NULL
,
394 &wPreferences
.circ_raise
, getBool
, NULL
396 {"Superfluous", "NO", NULL
,
397 &wPreferences
.superfluous
, getBool
, NULL
399 {"AdvanceToNewWorkspace", "NO", NULL
,
400 &wPreferences
.ws_advance
, getBool
, NULL
402 {"CycleWorkspaces", "NO", NULL
,
403 &wPreferences
.ws_cycle
, getBool
, NULL
405 {"WorkspaceNameDisplayPosition", "center", seDisplayPositions
,
406 &wPreferences
.workspace_name_display_position
, getEnum
, NULL
408 {"StickyIcons", "NO", NULL
,
409 &wPreferences
.sticky_icons
, getBool
, setStickyIcons
411 {"SaveSessionOnExit", "NO", NULL
,
412 &wPreferences
.save_session_on_exit
, getBool
, NULL
414 {"WrapMenus", "NO", NULL
,
415 &wPreferences
.wrap_menus
, getBool
, NULL
417 {"ScrollableMenus", "NO", NULL
,
418 &wPreferences
.scrollable_menus
, getBool
, NULL
420 {"MenuScrollSpeed", "medium", seSpeeds
,
421 &wPreferences
.menu_scroll_speed
, getEnum
, NULL
423 {"IconSlideSpeed", "medium", seSpeeds
,
424 &wPreferences
.icon_slide_speed
, getEnum
, NULL
426 {"ShadeSpeed", "medium", seSpeeds
,
427 &wPreferences
.shade_speed
, getEnum
, NULL
429 {"DoubleClickTime", "250", (void*) &wPreferences
.dblclick_time
,
430 &wPreferences
.dblclick_time
, getInt
, setDoubleClick
,
432 {"AlignSubmenus", "NO", NULL
,
433 &wPreferences
.align_menus
, getBool
, NULL
435 {"OpenTransientOnOwnerWorkspace", "NO", NULL
,
436 &wPreferences
.open_transients_with_parent
, getBool
, NULL
438 {"WindowPlacement", "auto", sePlacements
,
439 &wPreferences
.window_placement
, getEnum
, NULL
441 {"IgnoreFocusClick","NO", NULL
,
442 &wPreferences
.ignore_focus_click
, getBool
, NULL
444 {"UseSaveUnders", "NO", NULL
,
445 &wPreferences
.use_saveunders
, getBool
, NULL
447 {"OpaqueMove", "NO", NULL
,
448 &wPreferences
.opaque_move
, getBool
, NULL
450 {"DisableSound", "NO", NULL
,
451 &wPreferences
.no_sound
, getBool
, NULL
453 {"DisableAnimations", "NO", NULL
,
454 &wPreferences
.no_animations
, getBool
, NULL
456 {"DontLinkWorkspaces","NO", NULL
,
457 &wPreferences
.no_autowrap
, getBool
, NULL
459 {"AutoArrangeIcons", "NO", NULL
,
460 &wPreferences
.auto_arrange_icons
, getBool
, NULL
462 {"NoWindowOverDock", "NO", NULL
,
463 &wPreferences
.no_window_over_dock
, getBool
, updateUsableArea
465 {"NoWindowOverIcons", "NO", NULL
,
466 &wPreferences
.no_window_over_icons
, getBool
, updateUsableArea
468 {"WindowPlaceOrigin", "(0, 0)", NULL
,
469 &wPreferences
.window_place_origin
, getCoord
, NULL
471 {"ResizeDisplay", "corner", seGeomDisplays
,
472 &wPreferences
.size_display
, getEnum
, NULL
474 {"MoveDisplay", "corner", seGeomDisplays
,
475 &wPreferences
.move_display
, getEnum
, NULL
477 {"DontConfirmKill", "NO", NULL
,
478 &wPreferences
.dont_confirm_kill
, getBool
,NULL
480 {"WindowTitleBalloons", "NO", NULL
,
481 &wPreferences
.window_balloon
, getBool
, NULL
483 {"MiniwindowTitleBalloons", "NO", NULL
,
484 &wPreferences
.miniwin_balloon
,getBool
, NULL
486 {"AppIconBalloons", "NO", NULL
,
487 &wPreferences
.appicon_balloon
,getBool
, NULL
489 {"HelpBalloons", "NO", NULL
,
490 &wPreferences
.help_balloon
, getBool
, NULL
492 {"EdgeResistance", "30", NULL
,
493 &wPreferences
.edge_resistance
,getInt
, NULL
495 {"Attraction", "NO", NULL
,
496 &wPreferences
.attract
, getBool
, NULL
498 {"DisableBlinking", "NO", NULL
,
499 &wPreferences
.dont_blink
, getBool
, NULL
501 #ifdef WEENDOZE_CYCLE
502 {"WindozeCycling","NO", NULL
,
503 &wPreferences
.windoze_cycling
, getBool
, NULL
505 {"PopupSwitchMenu","YES", NULL
,
506 &wPreferences
.popup_switchmenu
, getBool
, NULL
508 #endif /* WEENDOZE_CYCLE */
510 {"MenuStyle", "normal", seMenuStyles
,
511 &wPreferences
.menu_style
, getEnum
, setMenuStyle
513 {"WidgetColor", "(solid, gray)", NULL
,
514 NULL
, getTexture
, setWidgetColor
,
516 {"WorkspaceSpecificBack","()", NULL
,
517 NULL
, getWSSpecificBackground
, setWorkspaceSpecificBack
519 /* WorkspaceBack must come after WorkspaceSpecificBack or
520 * WorkspaceBack wont know WorkspaceSpecificBack was also
521 * specified and 2 copies of wmsetbg will be launched */
522 {"WorkspaceBack", "(solid, black)", NULL
,
523 NULL
, getWSBackground
,setWorkspaceBack
525 {"SmoothWorkspaceBack", "NO", NULL
,
528 {"IconBack", "(solid, gray)", NULL
,
529 NULL
, getTexture
, setIconTile
531 {"TitleJustify", "center", seJustifications
,
532 &wPreferences
.title_justification
, getEnum
, setJustify
534 {"WindowTitleFont", DEF_TITLE_FONT
, NULL
,
535 NULL
, getFont
, setWinTitleFont
,
537 {"MenuTitleFont", DEF_MENU_TITLE_FONT
, NULL
,
538 NULL
, getFont
, setMenuTitleFont
540 {"MenuTextFont", DEF_MENU_ENTRY_FONT
, NULL
,
541 NULL
, getFont
, setMenuTextFont
543 {"IconTitleFont", DEF_ICON_TITLE_FONT
, NULL
,
544 NULL
, getFont
, setIconTitleFont
546 {"ClipTitleFont", DEF_CLIP_TITLE_FONT
, NULL
,
547 NULL
, getFont
, setClipTitleFont
549 {"DisplayFont", DEF_INFO_TEXT_FONT
, NULL
,
550 NULL
, getFont
, setDisplayFont
552 {"LargeDisplayFont",DEF_WORKSPACE_NAME_FONT
, NULL
,
553 NULL
, getFont
, setLargeDisplayFont
555 {"HighlightColor", "white", NULL
,
556 NULL
, getColor
, setHightlight
558 {"HighlightTextColor", "black", NULL
,
559 NULL
, getColor
, setHightlightText
561 {"ClipTitleColor", "black", (void*)CLIP_NORMAL
,
562 NULL
, getColor
, setClipTitleColor
564 {"CClipTitleColor", "\"#454045\"", (void*)CLIP_COLLAPSED
,
565 NULL
, getColor
, setClipTitleColor
567 {"FTitleColor", "white", (void*)WS_FOCUSED
,
568 NULL
, getColor
, setWTitleColor
570 {"PTitleColor", "white", (void*)WS_PFOCUSED
,
571 NULL
, getColor
, setWTitleColor
573 {"UTitleColor", "black", (void*)WS_UNFOCUSED
,
574 NULL
, getColor
, setWTitleColor
576 {"FTitleBack", "(solid, black)", NULL
,
577 NULL
, getTexture
, setFTitleBack
579 {"PTitleBack", "(solid, \"#616161\")", NULL
,
580 NULL
, getTexture
, setPTitleBack
582 {"UTitleBack", "(solid, gray)", NULL
,
583 NULL
, getTexture
, setUTitleBack
585 {"ResizebarBack", "(solid, gray)", NULL
,
586 NULL
, getTexture
, setResizebarBack
588 {"MenuTitleColor", "white", NULL
,
589 NULL
, getColor
, setMenuTitleColor
591 {"MenuTextColor", "black", NULL
,
592 NULL
, getColor
, setMenuTextColor
594 {"MenuDisabledColor", "\"#616161\"", NULL
,
595 NULL
, getColor
, setMenuDisabledColor
597 {"MenuTitleBack", "(solid, black)", NULL
,
598 NULL
, getTexture
, setMenuTitleBack
600 {"MenuTextBack", "(solid, gray)", NULL
,
601 NULL
, getTexture
, setMenuTextBack
603 {"IconTitleColor", "white", NULL
,
604 NULL
, getColor
, setIconTitleColor
606 {"IconTitleBack", "black", NULL
,
607 NULL
, getColor
, setIconTitleBack
611 {"RootMenuKey", "None", (void*)WKBD_ROOTMENU
,
612 NULL
, getKeybind
, setKeyGrab
614 {"WindowListKey", "None", (void*)WKBD_WINDOWLIST
,
615 NULL
, getKeybind
, setKeyGrab
618 {"WindowMenuKey", "None", (void*)WKBD_WINDOWMENU
,
619 NULL
, getKeybind
, setKeyGrab
621 {"ClipLowerKey", "None", (void*)WKBD_CLIPLOWER
,
622 NULL
, getKeybind
, setKeyGrab
624 {"ClipRaiseKey", "None", (void*)WKBD_CLIPRAISE
,
625 NULL
, getKeybind
, setKeyGrab
627 {"ClipRaiseLowerKey", "None", (void*)WKBD_CLIPRAISELOWER
,
628 NULL
, getKeybind
, setKeyGrab
630 {"MiniaturizeKey", "None", (void*)WKBD_MINIATURIZE
,
631 NULL
, getKeybind
, setKeyGrab
633 {"HideKey", "None", (void*)WKBD_HIDE
,
634 NULL
, getKeybind
, setKeyGrab
636 {"MoveResizeKey", "None", (void*)WKBD_MOVERESIZE
,
637 NULL
, getKeybind
, setKeyGrab
639 {"CloseKey", "None", (void*)WKBD_CLOSE
,
640 NULL
, getKeybind
, setKeyGrab
642 {"MaximizeKey", "None", (void*)WKBD_MAXIMIZE
,
643 NULL
, getKeybind
, setKeyGrab
645 {"VMaximizeKey", "None", (void*)WKBD_VMAXIMIZE
,
646 NULL
, getKeybind
, setKeyGrab
648 {"RaiseKey", "Meta+Up", (void*)WKBD_RAISE
,
649 NULL
, getKeybind
, setKeyGrab
651 {"LowerKey", "Meta+Down", (void*)WKBD_LOWER
,
652 NULL
, getKeybind
, setKeyGrab
654 {"RaiseLowerKey", "None", (void*)WKBD_RAISELOWER
,
655 NULL
, getKeybind
, setKeyGrab
657 {"ShadeKey", "None", (void*)WKBD_SHADE
,
658 NULL
, getKeybind
, setKeyGrab
660 {"SelectKey", "None", (void*)WKBD_SELECT
,
661 NULL
, getKeybind
, setKeyGrab
663 {"FocusNextKey", "None", (void*)WKBD_FOCUSNEXT
,
664 NULL
, getKeybind
, setKeyGrab
666 {"FocusPrevKey", "None", (void*)WKBD_FOCUSPREV
,
667 NULL
, getKeybind
, setKeyGrab
669 {"NextWorkspaceKey", "None", (void*)WKBD_NEXTWORKSPACE
,
670 NULL
, getKeybind
, setKeyGrab
672 {"PrevWorkspaceKey", "None", (void*)WKBD_PREVWORKSPACE
,
673 NULL
, getKeybind
, setKeyGrab
675 {"NextWorkspaceLayerKey", "None", (void*)WKBD_NEXTWSLAYER
,
676 NULL
, getKeybind
, setKeyGrab
678 {"PrevWorkspaceLayerKey", "None", (void*)WKBD_PREVWSLAYER
,
679 NULL
, getKeybind
, setKeyGrab
681 {"Workspace1Key", "None", (void*)WKBD_WORKSPACE1
,
682 NULL
, getKeybind
, setKeyGrab
684 {"Workspace2Key", "None", (void*)WKBD_WORKSPACE2
,
685 NULL
, getKeybind
, setKeyGrab
687 {"Workspace3Key", "None", (void*)WKBD_WORKSPACE3
,
688 NULL
, getKeybind
, setKeyGrab
690 {"Workspace4Key", "None", (void*)WKBD_WORKSPACE4
,
691 NULL
, getKeybind
, setKeyGrab
693 {"Workspace5Key", "None", (void*)WKBD_WORKSPACE5
,
694 NULL
, getKeybind
, setKeyGrab
696 {"Workspace6Key", "None", (void*)WKBD_WORKSPACE6
,
697 NULL
, getKeybind
, setKeyGrab
699 {"Workspace7Key", "None", (void*)WKBD_WORKSPACE7
,
700 NULL
, getKeybind
, setKeyGrab
702 {"Workspace8Key", "None", (void*)WKBD_WORKSPACE8
,
703 NULL
, getKeybind
, setKeyGrab
705 {"Workspace9Key", "None", (void*)WKBD_WORKSPACE9
,
706 NULL
, getKeybind
, setKeyGrab
708 {"Workspace10Key", "None", (void*)WKBD_WORKSPACE10
,
709 NULL
, getKeybind
, setKeyGrab
711 {"WindowShortcut1Key","None", (void*)WKBD_WINDOW1
,
712 NULL
, getKeybind
, setKeyGrab
714 {"WindowShortcut2Key","None", (void*)WKBD_WINDOW2
,
715 NULL
, getKeybind
, setKeyGrab
717 {"WindowShortcut3Key","None", (void*)WKBD_WINDOW3
,
718 NULL
, getKeybind
, setKeyGrab
720 {"WindowShortcut4Key","None", (void*)WKBD_WINDOW4
,
721 NULL
, getKeybind
, setKeyGrab
723 #ifdef EXTEND_WINDOWSHORTCUT
724 ,{"WindowShortcut5Key","None", (void*)WKBD_WINDOW5
,
725 NULL
, getKeybind
, setKeyGrab
727 {"WindowShortcut6Key","None", (void*)WKBD_WINDOW6
,
728 NULL
, getKeybind
, setKeyGrab
730 {"WindowShortcut7Key","None", (void*)WKBD_WINDOW7
,
731 NULL
, getKeybind
, setKeyGrab
733 {"WindowShortcut8Key","None", (void*)WKBD_WINDOW8
,
734 NULL
, getKeybind
, setKeyGrab
736 {"WindowShortcut9Key","None", (void*)WKBD_WINDOW9
,
737 NULL
, getKeybind
, setKeyGrab
739 {"WindowShortcut10Key","None", (void*)WKBD_WINDOW10
,
740 NULL
, getKeybind
, setKeyGrab
742 #endif /* EXTEND_WINDOWSHORTCUT */
744 #ifdef KEEP_XKB_LOCK_STATUS
745 ,{"ToggleKbdModeKey", "None", (void*)WKBD_TOGGLE
,
746 NULL
, getKeybind
, setKeyGrab
748 {"KbdModeLock", "NO", NULL
,
749 &wPreferences
.modelock
, getBool
, NULL
751 #endif /* KEEP_XKB_LOCK_STATUS */
752 #ifdef TITLE_TEXT_SHADOW
753 ,{"FShadowColor", "black", (void*)WS_SFOCUSED
,
754 NULL
, getColor
, setWTitleColor
756 {"PShadowColor", "black", (void*)WS_SPFOCUSED
,
757 NULL
, getColor
, setWTitleColor
759 {"UShadowColor", "grey50", (void*)WS_SUNFOCUSED
,
760 NULL
, getColor
, setWTitleColor
762 {"MShadowColor", "black", (void*)WS_SMENU
,
763 NULL
, getColor
, setMenuTitleColor
765 {"Shadow", "Yes", NULL
,
766 &wPreferences
.title_shadow
, getBool
, setJustify
768 #endif /* TITLE_TEXT_SHADOW */
773 static void rereadDefaults(void);
780 /* must defer the update because accessing X data from a
781 * signal handler can mess up Xlib */
790 WDefaultEntry
*entry
;
792 PLSetStringCmpHook(StringCompareHook
);
794 for (i
=0; i
<sizeof(optionList
)/sizeof(WDefaultEntry
); i
++) {
795 entry
= &optionList
[i
];
797 entry
->plkey
= PLMakeString(entry
->key
);
798 if (entry
->default_value
)
799 entry
->plvalue
= PLGetProplistWithDescription(entry
->default_value
);
801 entry
->plvalue
= NULL
;
804 for (i
=0; i
<sizeof(staticOptionList
)/sizeof(WDefaultEntry
); i
++) {
805 entry
= &staticOptionList
[i
];
807 entry
->plkey
= PLMakeString(entry
->key
);
808 if (entry
->default_value
)
809 entry
->plvalue
= PLGetProplistWithDescription(entry
->default_value
);
811 entry
->plvalue
= NULL
;
815 wDomainName = PLMakeString(WMDOMAIN_NAME);
816 wAttributeDomainName = PLMakeString(WMATTRIBUTE_DOMAIN_NAME);
818 PLRegister(wDomainName, rereadDefaults);
819 PLRegister(wAttributeDomainName, rereadDefaults);
828 wDefaultsInit(int screen_number
)
830 static int defaults_inited
= 0;
833 if (!defaults_inited
) {
837 dict
= PLGetDomain(wDomainName
);
839 wwarning(_("could not read domain \"%s\" from defaults database"),
840 PLGetString(wDomainName
));
849 wDefaultsDestroyDomain(WDDomain
*domain
)
851 if (domain
->dictionary
)
852 PLRelease(domain
->dictionary
);
859 wDefaultsInitDomain(char *domain
, Bool requireDictionary
)
863 static int inited
= 0;
866 proplist_t shared_dict
=NULL
;
873 db
= wmalloc(sizeof(WDDomain
));
874 memset(db
, 0, sizeof(WDDomain
));
875 db
->domain_name
= domain
;
876 db
->path
= wdefaultspathfordomain(domain
);
879 if (the_path
&& stat(the_path
, &stbuf
)>=0) {
880 db
->dictionary
= ReadProplistFromFile(the_path
);
881 if (db
->dictionary
) {
882 if (requireDictionary
&& !PLIsDictionary(db
->dictionary
)) {
883 PLRelease(db
->dictionary
);
884 db
->dictionary
= NULL
;
885 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
888 db
->timestamp
= stbuf
.st_mtime
;
890 wwarning(_("could not load domain %s from user defaults database"),
895 /* global system dictionary */
896 sprintf(path
, "%s/%s", SYSCONFDIR
, domain
);
897 if (stat(path
, &stbuf
)>=0) {
898 shared_dict
= ReadProplistFromFile(path
);
900 if (requireDictionary
&& !PLIsDictionary(shared_dict
)) {
901 wwarning(_("Domain %s (%s) of global defaults database is corrupted!"),
903 PLRelease(shared_dict
);
906 if (db
->dictionary
&& PLIsDictionary(shared_dict
) &&
907 PLIsDictionary(db
->dictionary
)) {
908 PLMergeDictionaries(shared_dict
, db
->dictionary
);
909 PLRelease(db
->dictionary
);
910 db
->dictionary
= shared_dict
;
911 if (stbuf
.st_mtime
> db
->timestamp
)
912 db
->timestamp
= stbuf
.st_mtime
;
913 } else if (!db
->dictionary
) {
914 db
->dictionary
= shared_dict
;
915 if (stbuf
.st_mtime
> db
->timestamp
)
916 db
->timestamp
= stbuf
.st_mtime
;
920 wwarning(_("could not load domain %s from global defaults database"),
925 /* set to save it in user's directory, no matter from where it was read */
926 if (db
->dictionary
) {
927 proplist_t tmp
= PLMakeString(db
->path
);
929 PLSetFilename(db
->dictionary
, tmp
);
938 wReadStaticDefaults(proplist_t dict
)
941 WDefaultEntry
*entry
;
946 for (i
=0; i
<sizeof(staticOptionList
)/sizeof(WDefaultEntry
); i
++) {
947 entry
= &staticOptionList
[i
];
950 plvalue
= PLGetDictionaryEntry(dict
, entry
->plkey
);
955 /* no default in the DB. Use builtin default */
956 plvalue
= entry
->plvalue
;
961 (*entry
->convert
)(NULL
, entry
, plvalue
, entry
->addr
, &tdata
);
963 (*entry
->update
)(NULL
, entry
, tdata
, entry
->extra_data
);
971 wDefaultsCheckDomains(void *foo
)
980 puts("Checking domains...");
982 if (stat(WDWindowMaker
->path
, &stbuf
)>=0
983 && WDWindowMaker
->timestamp
< stbuf
.st_mtime
) {
984 proplist_t shared_dict
= NULL
;
986 puts("Checking WindowMaker domain");
988 WDWindowMaker
->timestamp
= stbuf
.st_mtime
;
990 /* global dictionary */
991 sprintf(path
, "%s/WindowMaker", SYSCONFDIR
);
992 if (stat(path
, &stbuf
)>=0) {
993 shared_dict
= ReadProplistFromFile(path
);
994 if (shared_dict
&& !PLIsDictionary(shared_dict
)) {
995 wwarning(_("Domain %s (%s) of global defaults database is corrupted!"),
996 "WindowMaker", path
);
997 PLRelease(shared_dict
);
999 } else if (!shared_dict
) {
1000 wwarning(_("could not load domain %s from global defaults database"),
1004 /* user dictionary */
1005 dict
= ReadProplistFromFile(WDWindowMaker
->path
);
1007 if (!PLIsDictionary(dict
)) {
1010 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
1011 "WindowMaker", WDWindowMaker
->path
);
1014 PLSetFilename(shared_dict
, PLGetFilename(dict
));
1015 PLMergeDictionaries(shared_dict
, dict
);
1020 for (i
=0; i
<wScreenCount
; i
++) {
1021 scr
= wScreenWithNumber(i
);
1023 wReadDefaults(scr
, dict
);
1025 if (WDWindowMaker
->dictionary
) {
1026 PLRelease(WDWindowMaker
->dictionary
);
1028 WDWindowMaker
->dictionary
= dict
;
1031 wwarning(_("could not load domain %s from user defaults database"),
1035 PLRelease(shared_dict
);
1039 if (stat(WDWindowAttributes
->path
, &stbuf
)>=0
1040 && WDWindowAttributes
->timestamp
< stbuf
.st_mtime
) {
1042 puts("Checking WMWindowAttributes domain");
1044 dict
= ReadProplistFromFile(WDWindowAttributes
->path
);
1046 if (!PLIsDictionary(dict
)) {
1049 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
1050 "WMWindowAttributes", WDWindowAttributes
->path
);
1052 if (WDWindowAttributes
->dictionary
)
1053 PLRelease(WDWindowAttributes
->dictionary
);
1054 WDWindowAttributes
->dictionary
= dict
;
1055 for (i
=0; i
<wScreenCount
; i
++) {
1056 scr
= wScreenWithNumber(i
);
1058 wDefaultUpdateIcons(scr
);
1062 wwarning(_("could not load domain %s from user defaults database"),
1063 "WMWindowAttributes");
1065 WDWindowAttributes
->timestamp
= stbuf
.st_mtime
;
1069 if (stat(WDRootMenu
->path
, &stbuf
)>=0
1070 && WDRootMenu
->timestamp
< stbuf
.st_mtime
) {
1071 dict
= ReadProplistFromFile(WDRootMenu
->path
);
1073 puts("Checking WMRootMenu domain");
1076 if (!PLIsArray(dict
) && !PLIsString(dict
)) {
1079 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
1080 "WMRootMenu", WDRootMenu
->path
);
1082 if (WDRootMenu
->dictionary
) {
1083 PLRelease(WDRootMenu
->dictionary
);
1085 WDRootMenu
->dictionary
= dict
;
1088 wwarning(_("could not load domain %s from user defaults database"),
1091 WDRootMenu
->timestamp
= stbuf
.st_mtime
;
1096 WMAddTimerHandler(DEFAULTS_CHECK_INTERVAL
, wDefaultsCheckDomains
, foo
);
1101 wReadDefaults(WScreen
*scr
, proplist_t new_dict
)
1103 proplist_t plvalue
, old_value
;
1104 WDefaultEntry
*entry
;
1108 proplist_t old_dict
= (WDWindowMaker
->dictionary
!=new_dict
1109 ? WDWindowMaker
->dictionary
: NULL
);
1115 for (i
=0; i
<sizeof(optionList
)/sizeof(WDefaultEntry
); i
++) {
1116 entry
= &optionList
[i
];
1119 plvalue
= PLGetDictionaryEntry(new_dict
, entry
->plkey
);
1126 old_value
= PLGetDictionaryEntry(old_dict
, entry
->plkey
);
1129 if (!plvalue
&& !old_value
) {
1130 /* no default in the DB. Use builtin default */
1131 plvalue
= entry
->plvalue
;
1132 if (plvalue
&& new_dict
) {
1133 PLInsertDictionaryEntry(new_dict
, entry
->plkey
, plvalue
);
1136 } else if (!plvalue
) {
1137 /* value was deleted from DB. Keep current value */
1139 } else if (!old_value
) {
1140 /* set value for the 1st time */
1141 } else if (!PLIsEqual(plvalue
, old_value
)) {
1142 /* value has changed */
1144 /* value was not changed since last time */
1150 printf("Updating %s to %s\n", entry
->key
, PLGetDescription(plvalue
));
1153 if ((*entry
->convert
)(scr
, entry
, plvalue
, entry
->addr
, &tdata
)) {
1154 if (entry
->update
) {
1156 (*entry
->update
)(scr
, entry
, tdata
, entry
->extra_data
);
1162 if (needs_refresh
!=0 && !scr
->flags
.startup
) {
1166 if (needs_refresh
& REFRESH_MENU_TITLE_TEXTURE
)
1167 foo
|= WTextureSettings
;
1168 if (needs_refresh
& REFRESH_MENU_TITLE_FONT
)
1169 foo
|= WFontSettings
;
1170 if (needs_refresh
& REFRESH_MENU_TITLE_COLOR
)
1171 foo
|= WColorSettings
;
1173 WMPostNotificationName(WNMenuTitleAppearanceSettingsChanged
, NULL
,
1177 if (needs_refresh
& REFRESH_MENU_TEXTURE
)
1178 foo
|= WTextureSettings
;
1179 if (needs_refresh
& REFRESH_MENU_FONT
)
1180 foo
|= WFontSettings
;
1181 if (needs_refresh
& REFRESH_MENU_COLOR
)
1182 foo
|= WColorSettings
;
1184 WMPostNotificationName(WNMenuAppearanceSettingsChanged
, NULL
,
1188 if (needs_refresh
& REFRESH_WINDOW_FONT
) {
1189 foo
|= WFontSettings
;
1191 if (needs_refresh
& REFRESH_WINDOW_TEXTURES
) {
1192 foo
|= WTextureSettings
;
1194 if (needs_refresh
& REFRESH_WINDOW_TITLE_COLOR
) {
1195 foo
|= WColorSettings
;
1198 WMPostNotificationName(WNWindowAppearanceSettingsChanged
, NULL
,
1201 if (!(needs_refresh
& REFRESH_ICON_TILE
)) {
1203 if (needs_refresh
& REFRESH_ICON_FONT
) {
1204 foo
|= WFontSettings
;
1206 if (needs_refresh
& REFRESH_ICON_TITLE_COLOR
) {
1207 foo
|= WTextureSettings
;
1209 if (needs_refresh
& REFRESH_ICON_TITLE_BACK
) {
1210 foo
|= WTextureSettings
;
1213 WMPostNotificationName(WNIconAppearanceSettingsChanged
, NULL
,
1216 if (needs_refresh
& REFRESH_ICON_TILE
)
1217 WMPostNotificationName(WNIconTileSettingsChanged
, NULL
, NULL
);
1223 wDefaultUpdateIcons(WScreen
*scr
)
1225 WAppIcon
*aicon
= scr
->app_icon_list
;
1226 WWindow
*wwin
= scr
->focused_window
;
1230 file
= wDefaultGetIconFile(scr
, aicon
->wm_instance
, aicon
->wm_class
,
1232 if ((file
&& aicon
->icon
->file
&& strcmp(file
, aicon
->icon
->file
)!=0)
1233 || (file
&& !aicon
->icon
->file
)) {
1236 if (aicon
->icon
->file
)
1237 free(aicon
->icon
->file
);
1238 aicon
->icon
->file
= wstrdup(file
);
1240 new_image
= wDefaultGetImage(scr
, aicon
->wm_instance
,
1243 wIconChangeImage(aicon
->icon
, new_image
);
1244 wAppIconPaint(aicon
);
1247 aicon
= aicon
->next
;
1250 if (!wPreferences
.flags
.noclip
)
1251 wClipIconPaint(scr
->clip_icon
);
1254 if (wwin
->icon
&& wwin
->flags
.miniaturized
) {
1255 file
= wDefaultGetIconFile(scr
, wwin
->wm_instance
, wwin
->wm_class
,
1257 if ((file
&& wwin
->icon
->file
&& strcmp(file
, wwin
->icon
->file
)!=0)
1258 || (file
&& !wwin
->icon
->file
)) {
1261 if (wwin
->icon
->file
)
1262 free(wwin
->icon
->file
);
1263 wwin
->icon
->file
= wstrdup(file
);
1265 new_image
= wDefaultGetImage(scr
, wwin
->wm_instance
,
1268 wIconChangeImage(wwin
->icon
, new_image
);
1276 /* --------------------------- Local ----------------------- */
1278 #define STRINGP(x) if (!PLIsString(value)) { \
1279 wwarning(_("Wrong option format for key \"%s\". Should be %s."), \
1286 string2index(proplist_t key
, proplist_t val
, proplist_t def
,
1287 WOptionEnumeration
*values
)
1290 WOptionEnumeration
*v
;
1291 char buffer
[TOTAL_VALUES_LENGTH
];
1293 if (PLIsString(val
) && (str
= PLGetString(val
))) {
1294 for (v
=values
; v
->string
!=NULL
; v
++) {
1295 if (strcasecmp(v
->string
, str
)==0)
1301 for (v
=values
; v
->string
!=NULL
; v
++) {
1304 strcat(buffer
, ", ");
1305 strcat(buffer
, v
->string
);
1308 wwarning(_("wrong option value for key \"%s\". Should be one of %s"),
1309 PLGetString(key
), buffer
);
1312 return string2index(key
, val
, NULL
, values
);
1322 * value - is the value in the defaults DB
1323 * addr - is the address to store the data
1324 * ret - is the address to store a pointer to a temporary buffer. ret
1325 * must not be freed and is used by the set functions
1328 getBool(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
1337 val
= PLGetString(value
);
1340 if ((val
[1]=='\0' && (val
[0]=='y' || val
[0]=='Y'))
1341 || strcasecmp(val
, "YES")==0) {
1344 } else if ((val
[1]=='\0' && (val
[0]=='n' || val
[0]=='N'))
1345 || strcasecmp(val
, "NO")==0) {
1349 if (sscanf(val
, "%i", &i
)==1) {
1355 wwarning(_("can't convert \"%s\" to boolean for key \"%s\""),
1357 if (second_pass
==0) {
1358 val
= PLGetString(entry
->plvalue
);
1360 wwarning(_("using default \"%s\" instead"), val
);
1371 *(char*)addr
= data
;
1379 getInt(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
1388 val
= PLGetString(value
);
1390 if (sscanf(val
, "%i", &data
)!=1) {
1391 wwarning(_("can't convert \"%s\" to integer for key \"%s\""),
1393 val
= PLGetString(entry
->plvalue
);
1394 wwarning(_("using default \"%s\" instead"), val
);
1395 if (sscanf(val
, "%i", &data
)!=1) {
1411 getCoord(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
1415 char *val_x
, *val_y
;
1416 int nelem
, changed
=0;
1417 proplist_t elem_x
, elem_y
;
1420 if (!PLIsArray(value
)) {
1421 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1422 entry
->key
, "Coordinate");
1424 value
= entry
->plvalue
;
1426 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1432 nelem
= PLGetNumberOfElements(value
);
1434 wwarning(_("Incorrect number of elements in array for key \"%s\"."),
1437 value
= entry
->plvalue
;
1439 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1445 elem_x
= PLGetArrayElement(value
, 0);
1446 elem_y
= PLGetArrayElement(value
, 1);
1448 if (!elem_x
|| !elem_y
|| !PLIsString(elem_x
) || !PLIsString(elem_y
)) {
1449 wwarning(_("Wrong value for key \"%s\". Should be Coordinate."),
1452 value
= entry
->plvalue
;
1454 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1460 val_x
= PLGetString(elem_x
);
1461 val_y
= PLGetString(elem_y
);
1463 if (sscanf(val_x
, "%i", &data
.x
)!=1 || sscanf(val_y
, "%i", &data
.y
)!=1) {
1464 wwarning(_("can't convert array to integers for \"%s\"."), entry
->key
);
1466 value
= entry
->plvalue
;
1468 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1476 else if (data
.x
> scr
->scr_width
/3)
1477 data
.x
= scr
->scr_width
/3;
1480 else if (data
.y
> scr
->scr_height
/3)
1481 data
.y
= scr
->scr_height
/3;
1487 *(WCoord
*)addr
= data
;
1495 /* This function is not used at the moment. */
1497 getString(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
1504 data
= PLGetString(value
);
1507 data
= PLGetString(entry
->plvalue
);
1516 *(char**)addr
= wstrdup(data
);
1524 getPathList(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
1534 if (!PLIsArray(value
)) {
1535 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1536 entry
->key
, "an array of paths");
1538 value
= entry
->plvalue
;
1540 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1547 count
= PLGetNumberOfElements(value
);
1550 value
= entry
->plvalue
;
1552 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1559 for (i
=0; i
<count
; i
++) {
1560 d
= PLGetArrayElement(value
, i
);
1561 if (!d
|| !PLIsString(d
)) {
1565 len
+= strlen(PLGetString(d
))+1;
1568 ptr
= data
= wmalloc(len
+1);
1570 for (i
=0; i
<count
; i
++) {
1571 d
= PLGetArrayElement(value
, i
);
1572 if (!d
|| !PLIsString(d
)) {
1575 strcpy(ptr
, PLGetString(d
));
1576 ptr
+= strlen(PLGetString(d
));
1580 ptr
--; *(ptr
--) = 0;
1582 if (*(char**)addr
!=NULL
) {
1583 free(*(char**)addr
);
1585 *(char**)addr
= data
;
1592 getEnum(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
1595 static signed char data
;
1597 data
= string2index(entry
->plkey
, value
, entry
->default_value
,
1598 (WOptionEnumeration
*)entry
->extra_data
);
1606 *(signed char*)addr
= data
;
1615 * (hgradient <color> <color>)
1616 * (vgradient <color> <color>)
1617 * (dgradient <color> <color>)
1618 * (mhgradient <color> <color> ...)
1619 * (mvgradient <color> <color> ...)
1620 * (tpixmap <file> <color>)
1621 * (spixmap <file> <color>)
1622 * (cpixmap <file> <color>)
1623 * (thgradient <file> <opaqueness> <color> <color>)
1624 * (tvgradient <file> <opaqueness> <color> <color>)
1625 * (tdgradient <file> <opaqueness> <color> <color>)
1626 * (function <lib> <function> ...)
1630 parse_texture(WScreen
*scr
, proplist_t pl
)
1635 WTexture
*texture
=NULL
;
1637 nelem
= PLGetNumberOfElements(pl
);
1642 elem
= PLGetArrayElement(pl
, 0);
1643 if (!elem
|| !PLIsString(elem
))
1645 val
= PLGetString(elem
);
1648 if (strcasecmp(val
, "solid")==0) {
1656 elem
= PLGetArrayElement(pl
, 1);
1657 if (!elem
|| !PLIsString(elem
))
1659 val
= PLGetString(elem
);
1661 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &color
)) {
1662 wwarning(_("\"%s\" is not a valid color name"), val
);
1666 texture
= (WTexture
*)wTextureMakeSolid(scr
, &color
);
1667 } else if (strcasecmp(val
, "dgradient")==0
1668 || strcasecmp(val
, "vgradient")==0
1669 || strcasecmp(val
, "hgradient")==0) {
1670 RColor color1
, color2
;
1675 wwarning(_("bad number of arguments in gradient specification"));
1679 if (val
[0]=='d' || val
[0]=='D')
1680 type
= WTEX_DGRADIENT
;
1681 else if (val
[0]=='h' || val
[0]=='H')
1682 type
= WTEX_HGRADIENT
;
1684 type
= WTEX_VGRADIENT
;
1687 /* get from color */
1688 elem
= PLGetArrayElement(pl
, 1);
1689 if (!elem
|| !PLIsString(elem
))
1691 val
= PLGetString(elem
);
1693 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1694 wwarning(_("\"%s\" is not a valid color name"), val
);
1698 color1
.red
= xcolor
.red
>> 8;
1699 color1
.green
= xcolor
.green
>> 8;
1700 color1
.blue
= xcolor
.blue
>> 8;
1703 elem
= PLGetArrayElement(pl
, 2);
1704 if (!elem
|| !PLIsString(elem
)) {
1707 val
= PLGetString(elem
);
1709 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1710 wwarning(_("\"%s\" is not a valid color name"), val
);
1714 color2
.red
= xcolor
.red
>> 8;
1715 color2
.green
= xcolor
.green
>> 8;
1716 color2
.blue
= xcolor
.blue
>> 8;
1718 texture
= (WTexture
*)wTextureMakeGradient(scr
, type
, &color1
, &color2
);
1720 } else if (strcasecmp(val
, "mhgradient")==0
1721 || strcasecmp(val
, "mvgradient")==0
1722 || strcasecmp(val
, "mdgradient")==0) {
1729 wwarning(_("too few arguments in multicolor gradient specification"));
1733 if (val
[1]=='h' || val
[1]=='H')
1734 type
= WTEX_MHGRADIENT
;
1735 else if (val
[1]=='v' || val
[1]=='V')
1736 type
= WTEX_MVGRADIENT
;
1738 type
= WTEX_MDGRADIENT
;
1742 colors
= wmalloc(sizeof(RColor
*)*(count
+1));
1744 for (i
=0; i
<count
; i
++) {
1745 elem
= PLGetArrayElement(pl
, i
+1);
1746 if (!elem
|| !PLIsString(elem
)) {
1747 for (--i
; i
>=0; --i
) {
1753 val
= PLGetString(elem
);
1755 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &color
)) {
1756 wwarning(_("\"%s\" is not a valid color name"), val
);
1757 for (--i
; i
>=0; --i
) {
1763 colors
[i
] = wmalloc(sizeof(RColor
));
1764 colors
[i
]->red
= color
.red
>> 8;
1765 colors
[i
]->green
= color
.green
>> 8;
1766 colors
[i
]->blue
= color
.blue
>> 8;
1771 texture
= (WTexture
*)wTextureMakeMGradient(scr
, type
, colors
);
1772 } else if (strcasecmp(val
, "spixmap")==0 ||
1773 strcasecmp(val
, "cpixmap")==0 ||
1774 strcasecmp(val
, "tpixmap")==0) {
1781 if (val
[0] == 's' || val
[0] == 'S')
1783 else if (val
[0] == 'c' || val
[0] == 'C')
1789 elem
= PLGetArrayElement(pl
, 2);
1790 if (!elem
|| !PLIsString(elem
)) {
1793 val
= PLGetString(elem
);
1795 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &color
)) {
1796 wwarning(_("\"%s\" is not a valid color name"), val
);
1801 elem
= PLGetArrayElement(pl
, 1);
1802 if (!elem
|| !PLIsString(elem
))
1804 val
= PLGetString(elem
);
1806 texture
= (WTexture
*)wTextureMakePixmap(scr
, type
, val
, &color
);
1807 } else if (strcasecmp(val
, "thgradient")==0
1808 || strcasecmp(val
, "tvgradient")==0
1809 || strcasecmp(val
, "tdgradient")==0) {
1810 RColor color1
, color2
;
1815 if (val
[1]=='h' || val
[1]=='H')
1816 style
= WTEX_THGRADIENT
;
1817 else if (val
[1]=='v' || val
[1]=='V')
1818 style
= WTEX_TVGRADIENT
;
1820 style
= WTEX_TDGRADIENT
;
1823 wwarning(_("bad number of arguments in textured gradient specification"));
1827 /* get from color */
1828 elem
= PLGetArrayElement(pl
, 3);
1829 if (!elem
|| !PLIsString(elem
))
1831 val
= PLGetString(elem
);
1833 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1834 wwarning(_("\"%s\" is not a valid color name"), val
);
1838 color1
.red
= xcolor
.red
>> 8;
1839 color1
.green
= xcolor
.green
>> 8;
1840 color1
.blue
= xcolor
.blue
>> 8;
1843 elem
= PLGetArrayElement(pl
, 4);
1844 if (!elem
|| !PLIsString(elem
)) {
1847 val
= PLGetString(elem
);
1849 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1850 wwarning(_("\"%s\" is not a valid color name"), val
);
1854 color2
.red
= xcolor
.red
>> 8;
1855 color2
.green
= xcolor
.green
>> 8;
1856 color2
.blue
= xcolor
.blue
>> 8;
1859 elem
= PLGetArrayElement(pl
, 2);
1860 if (!elem
|| !PLIsString(elem
))
1863 val
= PLGetString(elem
);
1865 if (!val
|| (opacity
= atoi(val
)) < 0 || opacity
> 255) {
1866 wwarning(_("bad opacity value for tgradient texture \"%s\". Should be [0..255]"), val
);
1871 elem
= PLGetArrayElement(pl
, 1);
1872 if (!elem
|| !PLIsString(elem
))
1874 val
= PLGetString(elem
);
1876 texture
= (WTexture
*)wTextureMakeTGradient(scr
, style
, &color1
, &color2
,
1879 #ifdef TEXTURE_PLUGIN
1880 else if (strcasecmp(val
, "function")==0) {
1881 WTexFunction
*function
;
1882 void (*initFunc
) (Display
*, Colormap
);
1883 char *lib
, *func
, **argv
;
1889 /* get the library name */
1890 elem
= PLGetArrayElement(pl
, 1);
1891 if (!elem
|| !PLIsString(elem
)) {
1894 lib
= PLGetString(elem
);
1896 /* get the function name */
1897 elem
= PLGetArrayElement(pl
, 2);
1898 if (!elem
|| !PLIsString(elem
)) {
1901 func
= PLGetString(elem
);
1904 argv
= (char **)wmalloc(argc
* sizeof(char *));
1906 /* get the parameters */
1907 argv
[0] = wstrdup(func
);
1908 for (i
= 0; i
< argc
- 1; i
++) {
1909 elem
= PLGetArrayElement(pl
, 3 + i
);
1910 if (!elem
|| !PLIsString(elem
)) {
1915 argv
[i
+1] = wstrdup(PLGetString(elem
));
1918 function
= wTextureMakeFunction(scr
, lib
, func
, argc
, argv
);
1922 initFunc
= dlsym(function
->handle
, "initWindowMaker");
1924 initFunc(dpy
, scr
->w_colormap
);
1926 wwarning(_("could not initialize library %s"), lib
);
1929 wwarning(_("could not find function %s::%s"), lib
, func
);
1931 #endif /* HAVE_DLFCN_H */
1932 texture
= (WTexture
*)function
;
1934 #endif /* TEXTURE_PLUGIN */
1936 wwarning(_("invalid texture type %s"), val
);
1945 getTexture(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
1948 static WTexture
*texture
;
1952 if (!PLIsArray(value
)) {
1953 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1954 entry
->key
, "Texture");
1956 value
= entry
->plvalue
;
1958 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1964 if (strcmp(entry
->key
, "WidgetColor")==0 && !changed
) {
1967 pl
= PLGetArrayElement(value
, 0);
1968 if (!pl
|| !PLIsString(pl
) || !PLGetString(pl
)
1969 || strcasecmp(PLGetString(pl
), "solid")!=0) {
1970 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1971 entry
->key
, "Solid Texture");
1973 value
= entry
->plvalue
;
1975 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1980 texture
= parse_texture(scr
, value
);
1983 wwarning(_("Error in texture specification for key \"%s\""),
1986 value
= entry
->plvalue
;
1988 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1998 *(WTexture
**)addr
= texture
;
2006 getWSBackground(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
,
2007 void *addr
, void **ret
)
2015 if (!PLIsArray(value
)) {
2016 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
2017 "WorkspaceBack", "Texture or None");
2019 value
= entry
->plvalue
;
2021 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
2027 /* only do basic error checking and verify for None texture */
2029 nelem
= PLGetNumberOfElements(value
);
2031 elem
= PLGetArrayElement(value
, 0);
2032 if (!elem
|| !PLIsString(elem
)) {
2033 wwarning(_("Wrong type for workspace background. Should be a texture type."));
2035 value
= entry
->plvalue
;
2037 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
2042 val
= PLGetString(elem
);
2044 if (strcasecmp(val
, "None")==0)
2047 *ret
= PLRetain(value
);
2054 getWSSpecificBackground(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
,
2055 void *addr
, void **ret
)
2062 if (!PLIsArray(value
)) {
2063 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
2064 "WorkspaceSpecificBack", "an array of textures");
2066 value
= entry
->plvalue
;
2068 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
2074 /* only do basic error checking and verify for None texture */
2076 nelem
= PLGetNumberOfElements(value
);
2079 elem
= PLGetArrayElement(value
, nelem
);
2080 if (!elem
|| !PLIsArray(elem
)) {
2081 wwarning(_("Wrong type for background of workspace %i. Should be a texture."),
2087 *ret
= PLRetain(value
);
2091 * Kluge to force wmsetbg helper to set the default background.
2092 * If the WorkspaceSpecificBack is changed once wmaker has started,
2093 * the WorkspaceBack won't be sent to the helper, unless the user
2094 * changes it's value too. So, we must force this by removing the
2095 * value from the defaults DB.
2097 if (!scr
->flags
.backimage_helper_launched
&& !scr
->flags
.startup
) {
2098 proplist_t key
= PLMakeString("WorkspaceBack");
2100 PLRemoveDictionaryEntry(WDWindowMaker
->dictionary
, key
);
2110 getFont(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
2113 static WMFont
*font
;
2118 val
= PLGetString(value
);
2120 font
= WMCreateFont(scr
->wmscreen
, val
);
2122 font
= WMCreateFont(scr
->wmscreen
, "fixed");
2125 wfatal(_("could not load any usable font!!!"));
2132 /* can't assign font value outside update function */
2133 wassertrv(addr
== NULL
, True
);
2140 getColor(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
2143 static XColor color
;
2149 val
= PLGetString(value
);
2152 if (!wGetColor(scr
, val
, &color
)) {
2153 wwarning(_("could not get color for key \"%s\""),
2155 if (second_pass
==0) {
2156 val
= PLGetString(entry
->plvalue
);
2158 wwarning(_("using default \"%s\" instead"), val
);
2170 *(unsigned long*)addr = pixel;
2179 getKeybind(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
2182 static WShortKey shortcut
;
2189 STRINGP("Key spec");
2191 val
= PLGetString(value
);
2193 if (!val
|| strcasecmp(val
, "NONE")==0) {
2194 shortcut
.keycode
= 0;
2195 shortcut
.modifier
= 0;
2206 shortcut
.modifier
= 0;
2207 while ((k
= strchr(b
, '+'))!=NULL
) {
2211 mod
= wXModifierFromKey(b
);
2213 wwarning(_("%s:invalid key modifier \"%s\""), entry
->key
, b
);
2216 shortcut
.modifier
|= mod
;
2222 ksym
= XStringToKeysym(b
);
2224 if (ksym
==NoSymbol
) {
2225 wwarning(_("%s:invalid kbd shortcut specification \"%s\""), entry
->key
,
2230 shortcut
.keycode
= XKeysymToKeycode(dpy
, ksym
);
2231 if (shortcut
.keycode
==0) {
2232 wwarning(_("%s:invalid key in shortcut \"%s\""), entry
->key
, val
);
2244 getModMask(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
2247 static unsigned int mask
;
2250 STRINGP("Modifier Key");
2252 str
= PLGetString(value
);
2256 mask
= wXModifierFromKey(str
);
2258 wwarning(_("%s: modifier key %s is not valid"), entry
->key
, str
);
2264 *(unsigned int*)addr
= mask
;
2275 getRImages(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
,
2276 void *addr
, void **ret
)
2284 STRINGP("Image File Path");
2286 str
= PLGetString(value
);
2290 image
= RLoadImage(scr
->rcontext
, str
, 0);
2292 wwarning(_("could not load image in option %s: %s"), entry
->key
,
2293 RMessageForError(RErrorCode
));
2297 if (*(RImage
**)addr
) {
2298 RDestroyImage(*(RImage
**)addr
);
2301 *(RImage
**)addr
= image
;
2303 assert(ret
== NULL
);
2306 *(RImage**)ret = image;
2314 /* ---------------- value setting functions --------------- */
2316 setJustify(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
2318 return REFRESH_WINDOW_TITLE_COLOR
;
2323 setIfDockPresent(WScreen
*scr
, WDefaultEntry
*entry
, int *flag
, long which
)
2327 wPreferences
.flags
.nodock
= wPreferences
.flags
.nodock
|| *flag
;
2330 wPreferences
.flags
.noclip
= wPreferences
.flags
.noclip
|| *flag
;
2340 setStickyIcons(WScreen
*scr
, WDefaultEntry
*entry
, void *bar
, void *foo
)
2342 if (scr
->workspaces
) {
2343 wWorkspaceForceChange(scr
, scr
->current_workspace
);
2344 wArrangeIcons(scr
, False
);
2351 setPositive(WScreen
*scr
, WDefaultEntry
*entry
, int *value
, void *foo
)
2363 setIconTile(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
2369 img
= wTextureRenderImage(*texture
, wPreferences
.icon_size
,
2370 wPreferences
.icon_size
,
2371 ((*texture
)->any
.type
& WREL_BORDER_MASK
)
2372 ? WREL_ICON
: WREL_FLAT
);
2374 wwarning(_("could not render texture for icon background"));
2376 wTextureDestroy(scr
, *texture
);
2379 RConvertImage(scr
->rcontext
, img
, &pixmap
);
2381 if (scr
->icon_tile
) {
2383 RDestroyImage(scr
->icon_tile
);
2384 XFreePixmap(dpy
, scr
->icon_tile_pixmap
);
2387 scr
->icon_tile
= img
;
2389 if (!wPreferences
.flags
.noclip
) {
2390 if (scr
->clip_tile
) {
2391 RDestroyImage(scr
->clip_tile
);
2393 scr
->clip_tile
= wClipMakeTile(scr
, img
);
2396 scr
->icon_tile_pixmap
= pixmap
;
2398 if (scr
->def_icon_pixmap
) {
2399 XFreePixmap(dpy
, scr
->def_icon_pixmap
);
2400 scr
->def_icon_pixmap
= None
;
2402 if (scr
->def_ticon_pixmap
) {
2403 XFreePixmap(dpy
, scr
->def_ticon_pixmap
);
2404 scr
->def_ticon_pixmap
= None
;
2407 if (scr
->icon_back_texture
) {
2408 wTextureDestroy(scr
, (WTexture
*)scr
->icon_back_texture
);
2410 scr
->icon_back_texture
= wTextureMakeSolid(scr
, &((*texture
)->any
.color
));
2412 if (scr
->clip_balloon
)
2413 XSetWindowBackground(dpy
, scr
->clip_balloon
,
2414 (*texture
)->any
.color
.pixel
);
2417 * Free the texture as nobody else will use it, nor refer to it.
2420 wTextureDestroy(scr
, *texture
);
2422 return (reset
? REFRESH_ICON_TILE
: 0);
2428 setWinTitleFont(WScreen
*scr
, WDefaultEntry
*entry
, WMFont
*font
, void *foo
)
2430 if (scr
->title_font
) {
2431 WMReleaseFont(scr
->title_font
);
2433 scr
->title_font
= font
;
2435 return REFRESH_WINDOW_FONT
|REFRESH_BUTTON_IMAGES
;
2440 setMenuTitleFont(WScreen
*scr
, WDefaultEntry
*entry
, WMFont
*font
, void *foo
)
2442 if (scr
->menu_title_font
) {
2443 WMReleaseFont(scr
->menu_title_font
);
2446 scr
->menu_title_font
= font
;
2448 return REFRESH_MENU_TITLE_FONT
;
2453 setMenuTextFont(WScreen
*scr
, WDefaultEntry
*entry
, WMFont
*font
, void *foo
)
2455 if (scr
->menu_entry_font
) {
2456 WMReleaseFont(scr
->menu_entry_font
);
2458 scr
->menu_entry_font
= font
;
2460 return REFRESH_MENU_FONT
;
2466 setIconTitleFont(WScreen
*scr
, WDefaultEntry
*entry
, WMFont
*font
, void *foo
)
2468 if (scr
->icon_title_font
) {
2469 WMReleaseFont(scr
->icon_title_font
);
2472 scr
->icon_title_font
= font
;
2474 return REFRESH_ICON_FONT
;
2479 setClipTitleFont(WScreen
*scr
, WDefaultEntry
*entry
, WMFont
*font
, void *foo
)
2481 if (scr
->clip_title_font
) {
2482 WMReleaseFont(scr
->clip_title_font
);
2485 scr
->clip_title_font
= font
;
2487 return REFRESH_ICON_FONT
;
2492 setDisplayFont(WScreen
*scr
, WDefaultEntry
*entry
, WMFont
*font
, void *foo
)
2494 if (scr
->info_text_font
) {
2495 WMReleaseFont(scr
->info_text_font
);
2498 scr
->info_text_font
= font
;
2500 /* This test works because the scr structure is initially zeroed out
2501 and None = 0. Any other time, the window should be valid. */
2502 if (scr
->geometry_display
!= None
) {
2503 wGetGeometryWindowSize(scr
, &scr
->geometry_display_width
,
2504 &scr
->geometry_display_height
);
2505 XResizeWindow(dpy
, scr
->geometry_display
,
2506 scr
->geometry_display_width
, scr
->geometry_display_height
);
2514 setLargeDisplayFont(WScreen
*scr
, WDefaultEntry
*entry
, WMFont
*font
, void *foo
)
2516 if (scr
->workspace_name_font
) {
2517 WMReleaseFont(scr
->workspace_name_font
);
2520 scr
->workspace_name_font
= font
;
2527 setHightlight(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, void *foo
)
2529 if (scr
->select_pixel
!=scr
->white_pixel
&&
2530 scr
->select_pixel
!=scr
->black_pixel
) {
2531 wFreeColor(scr
, scr
->select_pixel
);
2534 scr
->select_pixel
= color
->pixel
;
2536 return REFRESH_MENU_COLOR
;
2541 setHightlightText(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, void *foo
)
2543 if (scr
->select_text_pixel
!=scr
->white_pixel
&&
2544 scr
->select_text_pixel
!=scr
->black_pixel
) {
2545 wFreeColor(scr
, scr
->select_text_pixel
);
2548 scr
->select_text_pixel
= color
->pixel
;
2550 return REFRESH_MENU_COLOR
;
2555 setClipTitleColor(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, long index
)
2557 if (scr
->clip_title_pixel
[index
]!=scr
->white_pixel
&&
2558 scr
->clip_title_pixel
[index
]!=scr
->black_pixel
) {
2559 wFreeColor(scr
, scr
->clip_title_pixel
[index
]);
2561 scr
->clip_title_pixel
[index
] = color
->pixel
;
2563 #ifdef GRADIENT_CLIP_ARROW
2564 if (index
== CLIP_NORMAL
) {
2566 RColor color1
, color2
;
2567 int pt
= CLIP_BUTTON_SIZE
*wPreferences
.icon_size
/64;
2568 int as
= pt
- 15; /* 15 = 5+5+5 */
2570 FREE_PIXMAP(scr
->clip_arrow_gradient
);
2572 color1
.red
= (color
->red
>> 8)*6/10;
2573 color1
.green
= (color
->green
>> 8)*6/10;
2574 color1
.blue
= (color
->blue
>> 8)*6/10;
2576 color2
.red
= WMIN((color
->red
>> 8)*20/10, 255);
2577 color2
.green
= WMIN((color
->green
>> 8)*20/10, 255);
2578 color2
.blue
= WMIN((color
->blue
>> 8)*20/10, 255);
2580 image
= RRenderGradient(as
+1, as
+1, &color1
, &color2
, RDiagonalGradient
);
2581 RConvertImage(scr
->rcontext
, image
, &scr
->clip_arrow_gradient
);
2582 RDestroyImage(image
);
2584 #endif /* GRADIENT_CLIP_ARROW */
2586 return REFRESH_ICON_TITLE_COLOR
;
2591 setWTitleColor(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, long index
)
2593 if (scr
->window_title_pixel
[index
]!=scr
->white_pixel
&&
2594 scr
->window_title_pixel
[index
]!=scr
->black_pixel
) {
2595 wFreeColor(scr
, scr
->window_title_pixel
[index
]);
2598 scr
->window_title_pixel
[index
] = color
->pixel
;
2600 if (index
== WS_UNFOCUSED
)
2601 XSetForeground(dpy
, scr
->info_text_gc
, color
->pixel
);
2603 return REFRESH_WINDOW_TITLE_COLOR
;
2608 setMenuTitleColor(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, long index
)
2610 #ifdef TITLE_TEXT_SHADOW
2611 if (index
== WS_SMENU
){
2612 if (scr
->menu_title_pixel
[WS_SMENU
]!=scr
->white_pixel
&&
2613 scr
->menu_title_pixel
[WS_SMENU
]!=scr
->black_pixel
) {
2614 wFreeColor(scr
, scr
->menu_title_pixel
[WS_SMENU
]);
2616 scr
->menu_title_pixel
[WS_SMENU
] = color
->pixel
;
2619 if (scr
->menu_title_pixel
[0]!=scr
->white_pixel
&&
2620 scr
->menu_title_pixel
[0]!=scr
->black_pixel
) {
2621 wFreeColor(scr
, scr
->menu_title_pixel
[0]);
2623 scr
->menu_title_pixel
[0] = color
->pixel
;
2625 #else /* !TITLE_TEXT_SHADOW */
2626 if (scr
->menu_title_pixel
[0]!=scr
->white_pixel
&&
2627 scr
->menu_title_pixel
[0]!=scr
->black_pixel
) {
2628 wFreeColor(scr
, scr
->menu_title_pixel
[0]);
2631 scr
->menu_title_pixel
[0] = color
->pixel
;
2632 #endif /* !TITLE_TEXT_SHADOW */
2633 XSetForeground(dpy
, scr
->menu_title_gc
, color
->pixel
);
2635 return REFRESH_MENU_TITLE_COLOR
;
2640 setMenuTextColor(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, void *foo
)
2643 #define gcm (GCForeground|GCBackground|GCFillStyle)
2645 if (scr
->mtext_pixel
!=scr
->white_pixel
&&
2646 scr
->mtext_pixel
!=scr
->black_pixel
) {
2647 wFreeColor(scr
, scr
->mtext_pixel
);
2650 scr
->mtext_pixel
= color
->pixel
;
2652 XSetForeground(dpy
, scr
->menu_entry_gc
, color
->pixel
);
2655 if (scr
->dtext_pixel
== scr
->mtext_pixel
) {
2656 gcv
.foreground
= scr
->white_pixel
;
2657 gcv
.background
= scr
->black_pixel
;
2658 gcv
.fill_style
= FillStippled
;
2660 gcv
.foreground
= scr
->dtext_pixel
;
2661 gcv
.fill_style
= FillSolid
;
2663 XChangeGC(dpy
, scr
->disabled_menu_entry_gc
, gcm
, &gcv
);
2665 return REFRESH_MENU_COLOR
;
2671 setMenuDisabledColor(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, void *foo
)
2674 #define gcm (GCForeground|GCBackground|GCFillStyle)
2676 if (scr
->dtext_pixel
!=scr
->white_pixel
&&
2677 scr
->dtext_pixel
!=scr
->black_pixel
) {
2678 wFreeColor(scr
, scr
->dtext_pixel
);
2681 scr
->dtext_pixel
= color
->pixel
;
2683 if (scr
->dtext_pixel
== scr
->mtext_pixel
) {
2684 gcv
.foreground
= scr
->white_pixel
;
2685 gcv
.background
= scr
->black_pixel
;
2686 gcv
.fill_style
= FillStippled
;
2688 gcv
.foreground
= scr
->dtext_pixel
;
2689 gcv
.fill_style
= FillSolid
;
2691 XChangeGC(dpy
, scr
->disabled_menu_entry_gc
, gcm
, &gcv
);
2693 return REFRESH_MENU_COLOR
;
2698 setIconTitleColor(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, void *foo
)
2700 XSetForeground(dpy
, scr
->icon_title_gc
, color
->pixel
);
2702 return REFRESH_ICON_TITLE_COLOR
;
2707 setIconTitleBack(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, void *foo
)
2709 if (scr
->icon_title_texture
) {
2710 wTextureDestroy(scr
, (WTexture
*)scr
->icon_title_texture
);
2712 XQueryColor (dpy
, scr
->w_colormap
, color
);
2713 scr
->icon_title_texture
= wTextureMakeSolid(scr
, color
);
2715 return REFRESH_ICON_TITLE_BACK
;
2720 trackDeadProcess(pid_t pid
, unsigned char status
, WScreen
*scr
)
2722 close(scr
->helper_fd
);
2724 scr
->helper_pid
= 0;
2725 scr
->flags
.backimage_helper_launched
= 0;
2730 setWorkspaceSpecificBack(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
,
2737 if (scr
->flags
.backimage_helper_launched
) {
2738 if (PLGetNumberOfElements(value
)==0) {
2739 SendHelperMessage(scr
, 'C', 0, NULL
);
2740 SendHelperMessage(scr
, 'K', 0, NULL
);
2749 if (PLGetNumberOfElements(value
) == 0)
2752 if (pipe(filedes
) < 0) {
2753 wsyserror("pipe() failed:can't set workspace specific background image");
2761 wsyserror("fork() failed:can't set workspace specific background image");
2762 if (close(filedes
[0]) < 0)
2763 wsyserror("could not close pipe");
2764 if (close(filedes
[1]) < 0)
2765 wsyserror("could not close pipe");
2767 } else if (pid
== 0) {
2768 SetupEnvironment(scr
);
2771 wsyserror("could not close pipe");
2772 if (dup(filedes
[0]) < 0) {
2773 wsyserror("dup() failed:can't set workspace specific background image");
2775 if (wPreferences
.smooth_workspace_back
)
2776 execlp("wmsetbg", "wmsetbg", "-helper", "-S", "-d", NULL
);
2778 execlp("wmsetbg", "wmsetbg", "-helper", "-d", NULL
);
2779 wsyserror("could not execute wmsetbg");
2783 if (fcntl(filedes
[0], F_SETFD
, FD_CLOEXEC
) < 0) {
2784 wsyserror("error setting close-on-exec flag");
2786 if (fcntl(filedes
[1], F_SETFD
, FD_CLOEXEC
) < 0) {
2787 wsyserror("error setting close-on-exec flag");
2790 scr
->helper_fd
= filedes
[1];
2791 scr
->helper_pid
= pid
;
2792 scr
->flags
.backimage_helper_launched
= 1;
2794 wAddDeathHandler(pid
, (WDeathHandler
*)trackDeadProcess
, scr
);
2796 SendHelperMessage(scr
, 'P', -1, wPreferences
.pixmap_path
);
2800 for (i
= 0; i
< PLGetNumberOfElements(value
); i
++) {
2801 val
= PLGetArrayElement(value
, i
);
2802 if (val
&& PLIsArray(val
) && PLGetNumberOfElements(val
)>0) {
2803 str
= PLGetDescription(val
);
2805 SendHelperMessage(scr
, 'S', i
+1, str
);
2809 SendHelperMessage(scr
, 'U', i
+1, NULL
);
2820 setWorkspaceBack(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
,
2823 if (scr
->flags
.backimage_helper_launched
) {
2826 if (PLGetNumberOfElements(value
)==0) {
2827 SendHelperMessage(scr
, 'U', 0, NULL
);
2829 /* set the default workspace background to this one */
2830 str
= PLGetDescription(value
);
2832 SendHelperMessage(scr
, 'S', 0, str
);
2834 SendHelperMessage(scr
, 'C', scr
->current_workspace
+1, NULL
);
2836 SendHelperMessage(scr
, 'U', 0, NULL
);
2843 SetupEnvironment(scr
);
2844 text
= PLGetDescription(value
);
2845 command
= wmalloc(strlen(text
)+40);
2846 if (wPreferences
.smooth_workspace_back
)
2847 sprintf(command
, "wmsetbg -d -S -p '%s' &", text
);
2849 sprintf(command
, "wmsetbg -d -p '%s' &", text
);
2861 setWidgetColor(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
2863 if (scr
->widget_texture
) {
2864 wTextureDestroy(scr
, (WTexture
*)scr
->widget_texture
);
2866 scr
->widget_texture
= *(WTexSolid
**)texture
;
2868 if (scr
->geometry_display
!= None
)
2869 XSetWindowBackground(dpy
, scr
->geometry_display
,
2870 scr
->widget_texture
->normal
.pixel
);
2877 setFTitleBack(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
2879 if (scr
->window_title_texture
[WS_FOCUSED
]) {
2880 wTextureDestroy(scr
, scr
->window_title_texture
[WS_FOCUSED
]);
2882 scr
->window_title_texture
[WS_FOCUSED
] = *texture
;
2884 return REFRESH_WINDOW_TEXTURES
;
2889 setPTitleBack(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
2891 if (scr
->window_title_texture
[WS_PFOCUSED
]) {
2892 wTextureDestroy(scr
, scr
->window_title_texture
[WS_PFOCUSED
]);
2894 scr
->window_title_texture
[WS_PFOCUSED
] = *texture
;
2896 return REFRESH_WINDOW_TEXTURES
;
2901 setUTitleBack(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
2903 if (scr
->window_title_texture
[WS_UNFOCUSED
]) {
2904 wTextureDestroy(scr
, scr
->window_title_texture
[WS_UNFOCUSED
]);
2906 scr
->window_title_texture
[WS_UNFOCUSED
] = *texture
;
2908 return REFRESH_WINDOW_TEXTURES
;
2913 setResizebarBack(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
2915 if (scr
->resizebar_texture
[0]) {
2916 wTextureDestroy(scr
, scr
->resizebar_texture
[0]);
2918 scr
->resizebar_texture
[0] = *texture
;
2920 return REFRESH_WINDOW_TEXTURES
;
2925 setMenuTitleBack(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
2927 if (scr
->menu_title_texture
[0]) {
2928 wTextureDestroy(scr
, scr
->menu_title_texture
[0]);
2930 scr
->menu_title_texture
[0] = *texture
;
2932 return REFRESH_MENU_TITLE_TEXTURE
;
2937 setMenuTextBack(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
2939 if (scr
->menu_item_texture
) {
2940 wTextureDestroy(scr
, scr
->menu_item_texture
);
2941 wTextureDestroy(scr
, (WTexture
*)scr
->menu_item_auxtexture
);
2943 scr
->menu_item_texture
= *texture
;
2945 scr
->menu_item_auxtexture
2946 = wTextureMakeSolid(scr
, &scr
->menu_item_texture
->any
.color
);
2948 return REFRESH_MENU_TEXTURE
;
2953 setKeyGrab(WScreen
*scr
, WDefaultEntry
*entry
, WShortKey
*shortcut
, long index
)
2956 wKeyBindings
[index
] = *shortcut
;
2958 wwin
= scr
->focused_window
;
2960 while (wwin
!=NULL
) {
2961 XUngrabKey(dpy
, AnyKey
, AnyModifier
, wwin
->frame
->core
->window
);
2963 if (!WFLAGP(wwin
, no_bind_keys
)) {
2964 wWindowSetKeyGrabs(wwin
);
2974 setIconPosition(WScreen
*scr
, WDefaultEntry
*entry
, void *bar
, void *foo
)
2976 wArrangeIcons(scr
, True
);
2983 updateUsableArea(WScreen
*scr
, WDefaultEntry
*entry
, void *bar
, void *foo
)
2985 wScreenUpdateUsableArea(scr
);
2992 setMenuStyle(WScreen
*scr
, WDefaultEntry
*entry
, int *value
, void *foo
)
2994 return REFRESH_MENU_TEXTURE
;
3000 setButtonImages(WScreen *scr, WDefaultEntry *entry, int *value, void *foo)
3002 return REFRESH_BUTTON_IMAGES;
3008 * Need access to the double click variables, so that all widgets in
3009 * wmaker panels will have the same dbl-click values.
3010 * TODO: figure a better way of dealing with it.
3015 setDoubleClick(WScreen
*scr
, WDefaultEntry
*entry
, int *value
, void *foo
)
3017 extern _WINGsConfiguration WINGsConfiguration
;
3022 WINGsConfiguration
.doubleClickDelay
= *value
;
3030 setMultiByte(WScreen
*scr
, WDefaultEntry
*entry
, int *value
, void *foo
)
3032 extern _WINGsConfiguration WINGsConfiguration
;
3034 WINGsConfiguration
.useMultiByte
= *value
;