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();
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},
300 * ALL entries in the tables bellow, NEED to have a default value
301 * defined, and this value needs to be correct.
304 /* these options will only affect the window manager on startup
306 * static defaults can't access the screen data, because it is
307 * created after these defaults are read
309 WDefaultEntry staticOptionList
[] = {
311 {"DisableDithering", "NO", NULL
,
312 &wPreferences
.no_dithering
, getBool
, NULL
314 {"ColormapSize", "4", NULL
,
315 &wPreferences
.cmap_size
, getInt
, NULL
317 /* static by laziness */
318 {"IconSize", "64", NULL
,
319 &wPreferences
.icon_size
, getInt
, NULL
321 {"ModifierKey", "Mod1", NULL
,
322 &wPreferences
.modifier_mask
, getModMask
, NULL
324 {"DisableWSMouseActions", "NO", NULL
,
325 &wPreferences
.disable_root_mouse
, getBool
, NULL
327 {"FocusMode", "manual", seFocusModes
,
328 &wPreferences
.focus_mode
, getEnum
, NULL
329 }, /* have a problem when switching from manual to sloppy without restart */
330 {"NewStyle", "NO", NULL
,
331 &wPreferences
.new_style
, getBool
, NULL
333 {"DisableDock", "NO", (void*) WM_DOCK
,
334 NULL
, getBool
, setIfDockPresent
336 {"DisableClip", "NO", (void*) WM_CLIP
,
337 NULL
, getBool
, setIfDockPresent
339 {"DisableMiniwindows", "NO", NULL
,
340 &wPreferences
.disable_miniwindows
, getBool
, NULL
346 WDefaultEntry optionList
[] = {
347 /* dynamic options */
348 {"IconPosition", "blh", seIconPositions
,
349 &wPreferences
.icon_yard
, getEnum
, setIconPosition
351 {"IconificationStyle", "Zoom", seIconificationStyles
,
352 &wPreferences
.iconification_style
, getEnum
, NULL
354 {"SelectWindowsMouseButton", "Left", seMouseButtons
,
355 &wPreferences
.select_button
, getEnum
, NULL
357 {"WindowListMouseButton", "Middle", seMouseButtons
,
358 &wPreferences
.windowl_button
, getEnum
, NULL
360 {"ApplicationMenuMouseButton", "Right", seMouseButtons
,
361 &wPreferences
.menu_button
, getEnum
, NULL
363 {"PixmapPath", DEF_PIXMAP_PATHS
, NULL
,
364 &wPreferences
.pixmap_path
, getPathList
, NULL
366 {"IconPath", DEF_ICON_PATHS
, NULL
,
367 &wPreferences
.icon_path
, getPathList
, NULL
369 {"ColormapMode", "auto", seColormapModes
,
370 &wPreferences
.colormap_mode
, getEnum
, NULL
372 {"AutoFocus", "NO", NULL
,
373 &wPreferences
.auto_focus
, getBool
, NULL
375 {"RaiseDelay", "0", NULL
,
376 &wPreferences
.raise_delay
, getInt
, NULL
378 {"CirculateRaise", "NO", NULL
,
379 &wPreferences
.circ_raise
, getBool
, NULL
381 {"Superfluous", "NO", NULL
,
382 &wPreferences
.superfluous
, getBool
, NULL
384 {"AdvanceToNewWorkspace", "NO", NULL
,
385 &wPreferences
.ws_advance
, getBool
, NULL
387 {"CycleWorkspaces", "NO", NULL
,
388 &wPreferences
.ws_cycle
, getBool
, NULL
390 {"IAmAnnoyingAndDontWantWorkspaceNameDisplay", "NO",NULL
,
391 &wPreferences
.no_workspace_name_display
, getBool
, NULL
393 {"StickyIcons", "NO", NULL
,
394 &wPreferences
.sticky_icons
, getBool
, setStickyIcons
396 {"SaveSessionOnExit", "NO", NULL
,
397 &wPreferences
.save_session_on_exit
, getBool
, NULL
399 {"WrapMenus", "NO", NULL
,
400 &wPreferences
.wrap_menus
, getBool
, NULL
402 {"ScrollableMenus", "NO", NULL
,
403 &wPreferences
.scrollable_menus
, getBool
, NULL
405 {"MenuScrollSpeed", "medium", seSpeeds
,
406 &wPreferences
.menu_scroll_speed
, getEnum
, NULL
408 {"IconSlideSpeed", "medium", seSpeeds
,
409 &wPreferences
.icon_slide_speed
, getEnum
, NULL
411 {"ShadeSpeed", "medium", seSpeeds
,
412 &wPreferences
.shade_speed
, getEnum
, NULL
414 {"DoubleClickTime", "250", (void*) &wPreferences
.dblclick_time
,
415 &wPreferences
.dblclick_time
, getInt
, setDoubleClick
,
417 {"AlignSubmenus", "NO", NULL
,
418 &wPreferences
.align_menus
, getBool
, NULL
420 {"OpenTransientOnOwnerWorkspace", "NO", NULL
,
421 &wPreferences
.open_transients_with_parent
, getBool
, NULL
423 {"WindowPlacement", "auto", sePlacements
,
424 &wPreferences
.window_placement
, getEnum
, NULL
426 {"IgnoreFocusClick","NO", NULL
,
427 &wPreferences
.ignore_focus_click
, getBool
, NULL
429 {"UseSaveUnders", "NO", NULL
,
430 &wPreferences
.use_saveunders
, getBool
, NULL
432 {"OpaqueMove", "NO", NULL
,
433 &wPreferences
.opaque_move
, getBool
, NULL
435 {"DisableSound", "NO", NULL
,
436 &wPreferences
.no_sound
, getBool
, NULL
438 {"DisableAnimations", "NO", NULL
,
439 &wPreferences
.no_animations
, getBool
, NULL
441 {"DontLinkWorkspaces","NO", NULL
,
442 &wPreferences
.no_autowrap
, getBool
, NULL
444 {"AutoArrangeIcons", "NO", NULL
,
445 &wPreferences
.auto_arrange_icons
, getBool
, NULL
447 {"NoWindowOverDock", "NO", NULL
,
448 &wPreferences
.no_window_over_dock
, getBool
, updateUsableArea
450 {"NoWindowOverIcons", "NO", NULL
,
451 &wPreferences
.no_window_over_icons
, getBool
, updateUsableArea
453 {"WindowPlaceOrigin", "(0, 0)", NULL
,
454 &wPreferences
.window_place_origin
, getCoord
, NULL
456 {"ResizeDisplay", "corner", seGeomDisplays
,
457 &wPreferences
.size_display
, getEnum
, NULL
459 {"MoveDisplay", "corner", seGeomDisplays
,
460 &wPreferences
.move_display
, getEnum
, NULL
462 {"DontConfirmKill", "NO", NULL
,
463 &wPreferences
.dont_confirm_kill
, getBool
,NULL
465 {"WindowTitleBalloons", "NO", NULL
,
466 &wPreferences
.window_balloon
, getBool
, NULL
468 {"MiniwindowTitleBalloons", "NO", NULL
,
469 &wPreferences
.miniwin_balloon
,getBool
, NULL
471 {"AppIconBalloons", "NO", NULL
,
472 &wPreferences
.appicon_balloon
,getBool
, NULL
474 {"EdgeResistance", "30", NULL
,
475 &wPreferences
.edge_resistance
,getInt
, NULL
477 {"DisableBlinking", "NO", NULL
,
478 &wPreferences
.dont_blink
, getBool
, NULL
480 #ifdef WEENDOZE_CYCLE
481 {"WindozeCycling","NO", NULL
,
482 &wPreferences
.windoze_cycling
, getBool
, NULL
484 {"PopupSwitchMenu","YES", NULL
,
485 &wPreferences
.popup_switchmenu
, getBool
, NULL
487 #endif /* WEENDOZE_CYCLE */
489 {"MenuStyle", "normal", seMenuStyles
,
490 &wPreferences
.menu_style
, getEnum
, setMenuStyle
492 {"WidgetColor", "(solid, gray)", NULL
,
493 NULL
, getTexture
, setWidgetColor
,
495 {"WorkspaceSpecificBack","()", NULL
,
496 NULL
, getWSSpecificBackground
, setWorkspaceSpecificBack
498 /* WorkspaceBack must come after WorkspaceSpecificBack or
499 * WorkspaceBack wont know WorkspaceSpecificBack was also
500 * specified and 2 copies of wmsetbg will be launched */
501 {"WorkspaceBack", "(solid, black)", NULL
,
502 NULL
, getWSBackground
,setWorkspaceBack
504 {"IconBack", "(solid, gray)", NULL
,
505 NULL
, getTexture
, setIconTile
507 {"TitleJustify", "center", seJustifications
,
508 &wPreferences
.title_justification
, getEnum
, setJustify
510 {"WindowTitleFont", DEF_TITLE_FONT
, NULL
,
511 NULL
, getFont
, setWinTitleFont
,
513 {"MenuTitleFont", DEF_MENU_TITLE_FONT
, NULL
,
514 NULL
, getFont
, setMenuTitleFont
516 {"MenuTextFont", DEF_MENU_ENTRY_FONT
, NULL
,
517 NULL
, getFont
, setMenuTextFont
519 {"IconTitleFont", DEF_ICON_TITLE_FONT
, NULL
,
520 NULL
, getFont
, setIconTitleFont
522 {"ClipTitleFont", DEF_CLIP_TITLE_FONT
, NULL
,
523 NULL
, getFont
, setClipTitleFont
525 {"DisplayFont", DEF_INFO_TEXT_FONT
, NULL
,
526 NULL
, getFont
, setDisplayFont
528 {"LargeDisplayFont",DEF_WORKSPACE_NAME_FONT
, NULL
,
529 NULL
, getFont
, setLargeDisplayFont
531 {"HighlightColor", "white", NULL
,
532 NULL
, getColor
, setHightlight
534 {"HighlightTextColor", "black", NULL
,
535 NULL
, getColor
, setHightlightText
537 {"ClipTitleColor", "black", (void*)CLIP_NORMAL
,
538 NULL
, getColor
, setClipTitleColor
540 {"CClipTitleColor", "\"#454045\"", (void*)CLIP_COLLAPSED
,
541 NULL
, getColor
, setClipTitleColor
543 {"FTitleColor", "white", (void*)WS_FOCUSED
,
544 NULL
, getColor
, setWTitleColor
546 {"PTitleColor", "white", (void*)WS_PFOCUSED
,
547 NULL
, getColor
, setWTitleColor
549 {"UTitleColor", "black", (void*)WS_UNFOCUSED
,
550 NULL
, getColor
, setWTitleColor
552 {"FTitleBack", "(solid, black)", NULL
,
553 NULL
, getTexture
, setFTitleBack
555 {"PTitleBack", "(solid, \"#616161\")", NULL
,
556 NULL
, getTexture
, setPTitleBack
558 {"UTitleBack", "(solid, gray)", NULL
,
559 NULL
, getTexture
, setUTitleBack
561 {"ResizebarBack", "(solid, gray)", NULL
,
562 NULL
, getTexture
, setResizebarBack
564 {"MenuTitleColor", "white", NULL
,
565 NULL
, getColor
, setMenuTitleColor
567 {"MenuTextColor", "black", NULL
,
568 NULL
, getColor
, setMenuTextColor
570 {"MenuDisabledColor", "\"#616161\"", NULL
,
571 NULL
, getColor
, setMenuDisabledColor
573 {"MenuTitleBack", "(solid, black)", NULL
,
574 NULL
, getTexture
, setMenuTitleBack
576 {"MenuTextBack", "(solid, gray)", NULL
,
577 NULL
, getTexture
, setMenuTextBack
579 {"IconTitleColor", "white", NULL
,
580 NULL
, getColor
, setIconTitleColor
582 {"IconTitleBack", "black", NULL
,
583 NULL
, getColor
, setIconTitleBack
587 {"RootMenuKey", "None", (void*)WKBD_ROOTMENU
,
588 NULL
, getKeybind
, setKeyGrab
590 {"WindowListKey", "None", (void*)WKBD_WINDOWLIST
,
591 NULL
, getKeybind
, setKeyGrab
594 {"WindowMenuKey", "None", (void*)WKBD_WINDOWMENU
,
595 NULL
, getKeybind
, setKeyGrab
597 {"ClipLowerKey", "None", (void*)WKBD_CLIPLOWER
,
598 NULL
, getKeybind
, setKeyGrab
600 {"ClipRaiseKey", "None", (void*)WKBD_CLIPRAISE
,
601 NULL
, getKeybind
, setKeyGrab
603 {"ClipRaiseLowerKey", "None", (void*)WKBD_CLIPRAISELOWER
,
604 NULL
, getKeybind
, setKeyGrab
606 {"MiniaturizeKey", "None", (void*)WKBD_MINIATURIZE
,
607 NULL
, getKeybind
, setKeyGrab
609 {"HideKey", "None", (void*)WKBD_HIDE
,
610 NULL
, getKeybind
, setKeyGrab
612 {"MoveResizeKey", "None", (void*)WKBD_MOVERESIZE
,
613 NULL
, getKeybind
, setKeyGrab
615 {"CloseKey", "None", (void*)WKBD_CLOSE
,
616 NULL
, getKeybind
, setKeyGrab
618 {"MaximizeKey", "None", (void*)WKBD_MAXIMIZE
,
619 NULL
, getKeybind
, setKeyGrab
621 {"VMaximizeKey", "None", (void*)WKBD_VMAXIMIZE
,
622 NULL
, getKeybind
, setKeyGrab
624 {"RaiseKey", "Meta+Up", (void*)WKBD_RAISE
,
625 NULL
, getKeybind
, setKeyGrab
627 {"LowerKey", "Meta+Down", (void*)WKBD_LOWER
,
628 NULL
, getKeybind
, setKeyGrab
630 {"RaiseLowerKey", "None", (void*)WKBD_RAISELOWER
,
631 NULL
, getKeybind
, setKeyGrab
633 {"ShadeKey", "None", (void*)WKBD_SHADE
,
634 NULL
, getKeybind
, setKeyGrab
636 {"SelectKey", "None", (void*)WKBD_SELECT
,
637 NULL
, getKeybind
, setKeyGrab
639 {"FocusNextKey", "None", (void*)WKBD_FOCUSNEXT
,
640 NULL
, getKeybind
, setKeyGrab
642 {"FocusPrevKey", "None", (void*)WKBD_FOCUSPREV
,
643 NULL
, getKeybind
, setKeyGrab
645 {"NextWorkspaceKey", "None", (void*)WKBD_NEXTWORKSPACE
,
646 NULL
, getKeybind
, setKeyGrab
648 {"PrevWorkspaceKey", "None", (void*)WKBD_PREVWORKSPACE
,
649 NULL
, getKeybind
, setKeyGrab
651 {"NextWorkspaceLayerKey", "None", (void*)WKBD_NEXTWSLAYER
,
652 NULL
, getKeybind
, setKeyGrab
654 {"PrevWorkspaceLayerKey", "None", (void*)WKBD_PREVWSLAYER
,
655 NULL
, getKeybind
, setKeyGrab
657 {"Workspace1Key", "None", (void*)WKBD_WORKSPACE1
,
658 NULL
, getKeybind
, setKeyGrab
660 {"Workspace2Key", "None", (void*)WKBD_WORKSPACE2
,
661 NULL
, getKeybind
, setKeyGrab
663 {"Workspace3Key", "None", (void*)WKBD_WORKSPACE3
,
664 NULL
, getKeybind
, setKeyGrab
666 {"Workspace4Key", "None", (void*)WKBD_WORKSPACE4
,
667 NULL
, getKeybind
, setKeyGrab
669 {"Workspace5Key", "None", (void*)WKBD_WORKSPACE5
,
670 NULL
, getKeybind
, setKeyGrab
672 {"Workspace6Key", "None", (void*)WKBD_WORKSPACE6
,
673 NULL
, getKeybind
, setKeyGrab
675 {"Workspace7Key", "None", (void*)WKBD_WORKSPACE7
,
676 NULL
, getKeybind
, setKeyGrab
678 {"Workspace8Key", "None", (void*)WKBD_WORKSPACE8
,
679 NULL
, getKeybind
, setKeyGrab
681 {"Workspace9Key", "None", (void*)WKBD_WORKSPACE9
,
682 NULL
, getKeybind
, setKeyGrab
684 {"Workspace10Key", "None", (void*)WKBD_WORKSPACE10
,
685 NULL
, getKeybind
, setKeyGrab
687 {"WindowShortcut1Key","None", (void*)WKBD_WINDOW1
,
688 NULL
, getKeybind
, setKeyGrab
690 {"WindowShortcut2Key","None", (void*)WKBD_WINDOW2
,
691 NULL
, getKeybind
, setKeyGrab
693 {"WindowShortcut3Key","None", (void*)WKBD_WINDOW3
,
694 NULL
, getKeybind
, setKeyGrab
696 {"WindowShortcut4Key","None", (void*)WKBD_WINDOW4
,
697 NULL
, getKeybind
, setKeyGrab
699 #ifdef EXTEND_WINDOWSHORTCUT
700 ,{"WindowShortcut5Key","None", (void*)WKBD_WINDOW5
,
701 NULL
, getKeybind
, setKeyGrab
703 {"WindowShortcut6Key","None", (void*)WKBD_WINDOW6
,
704 NULL
, getKeybind
, setKeyGrab
706 {"WindowShortcut7Key","None", (void*)WKBD_WINDOW7
,
707 NULL
, getKeybind
, setKeyGrab
709 {"WindowShortcut8Key","None", (void*)WKBD_WINDOW8
,
710 NULL
, getKeybind
, setKeyGrab
712 {"WindowShortcut9Key","None", (void*)WKBD_WINDOW9
,
713 NULL
, getKeybind
, setKeyGrab
715 {"WindowShortcut10Key","None", (void*)WKBD_WINDOW10
,
716 NULL
, getKeybind
, setKeyGrab
718 #endif /* EXTEND_WINDOWSHORTCUT */
720 #ifdef KEEP_XKB_LOCK_STATUS
721 ,{"ToggleKbdModeKey", "None", (void*)WKBD_TOGGLE
,
722 NULL
, getKeybind
, setKeyGrab
724 {"KbdModeLock", "NO", NULL
,
725 &wPreferences
.modelock
, getBool
, NULL
727 #endif /* KEEP_XKB_LOCK_STATUS */
728 #ifdef TITLE_TEXT_SHADOW
729 ,{"FShadowColor", "black", (void*)WS_SFOCUSED
,
730 NULL
, getColor
, setWTitleColor
732 {"PShadowColor", "black", (void*)WS_SPFOCUSED
,
733 NULL
, getColor
, setWTitleColor
735 {"UShadowColor", "grey50", (void*)WS_SUNFOCUSED
,
736 NULL
, getColor
, setWTitleColor
738 {"MShadowColor", "black", (void*)WS_SMENU
,
739 NULL
, getColor
, setMenuTitleColor
741 {"Shadow", "Yes", NULL
,
742 &wPreferences
.title_shadow
, getBool
, setJustify
744 #endif /* TITLE_TEXT_SHADOW */
749 static void rereadDefaults(void);
756 /* must defer the update because accessing X data from a
757 * signal handler can mess up Xlib */
766 WDefaultEntry
*entry
;
768 PLSetStringCmpHook(StringCompareHook
);
770 for (i
=0; i
<sizeof(optionList
)/sizeof(WDefaultEntry
); i
++) {
771 entry
= &optionList
[i
];
773 entry
->plkey
= PLMakeString(entry
->key
);
774 if (entry
->default_value
)
775 entry
->plvalue
= PLGetProplistWithDescription(entry
->default_value
);
777 entry
->plvalue
= NULL
;
780 for (i
=0; i
<sizeof(staticOptionList
)/sizeof(WDefaultEntry
); i
++) {
781 entry
= &staticOptionList
[i
];
783 entry
->plkey
= PLMakeString(entry
->key
);
784 if (entry
->default_value
)
785 entry
->plvalue
= PLGetProplistWithDescription(entry
->default_value
);
787 entry
->plvalue
= NULL
;
791 wDomainName = PLMakeString(WMDOMAIN_NAME);
792 wAttributeDomainName = PLMakeString(WMATTRIBUTE_DOMAIN_NAME);
794 PLRegister(wDomainName, rereadDefaults);
795 PLRegister(wAttributeDomainName, rereadDefaults);
804 wDefaultsInit(int screen_number
)
806 static int defaults_inited
= 0;
809 if (!defaults_inited
) {
813 dict
= PLGetDomain(wDomainName
);
815 wwarning(_("could not read domain \"%s\" from defaults database"),
816 PLGetString(wDomainName
));
825 wDefaultsDestroyDomain(WDDomain
*domain
)
827 if (domain
->dictionary
)
828 PLRelease(domain
->dictionary
);
835 wDefaultsInitDomain(char *domain
, Bool requireDictionary
)
839 static int inited
= 0;
842 proplist_t shared_dict
=NULL
;
849 db
= wmalloc(sizeof(WDDomain
));
850 memset(db
, 0, sizeof(WDDomain
));
851 db
->domain_name
= domain
;
852 db
->path
= wdefaultspathfordomain(domain
);
855 if (the_path
&& stat(the_path
, &stbuf
)>=0) {
856 db
->dictionary
= ReadProplistFromFile(the_path
);
857 if (db
->dictionary
) {
858 if (requireDictionary
&& !PLIsDictionary(db
->dictionary
)) {
859 PLRelease(db
->dictionary
);
860 db
->dictionary
= NULL
;
861 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
864 db
->timestamp
= stbuf
.st_mtime
;
866 wwarning(_("could not load domain %s from user defaults database"),
871 /* global system dictionary */
872 sprintf(path
, "%s/%s", SYSCONFDIR
, domain
);
873 if (stat(path
, &stbuf
)>=0) {
874 shared_dict
= ReadProplistFromFile(path
);
876 if (requireDictionary
&& !PLIsDictionary(shared_dict
)) {
877 wwarning(_("Domain %s (%s) of global defaults database is corrupted!"),
879 PLRelease(shared_dict
);
882 if (db
->dictionary
&& PLIsDictionary(shared_dict
) &&
883 PLIsDictionary(db
->dictionary
)) {
884 PLMergeDictionaries(shared_dict
, db
->dictionary
);
885 PLRelease(db
->dictionary
);
886 db
->dictionary
= shared_dict
;
887 if (stbuf
.st_mtime
> db
->timestamp
)
888 db
->timestamp
= stbuf
.st_mtime
;
889 } else if (!db
->dictionary
) {
890 db
->dictionary
= shared_dict
;
891 if (stbuf
.st_mtime
> db
->timestamp
)
892 db
->timestamp
= stbuf
.st_mtime
;
896 wwarning(_("could not load domain %s from global defaults database"),
901 /* set to save it in user's directory, no matter from where it was read */
902 if (db
->dictionary
) {
903 proplist_t tmp
= PLMakeString(db
->path
);
905 PLSetFilename(db
->dictionary
, tmp
);
914 wReadStaticDefaults(proplist_t dict
)
917 WDefaultEntry
*entry
;
922 for (i
=0; i
<sizeof(staticOptionList
)/sizeof(WDefaultEntry
); i
++) {
923 entry
= &staticOptionList
[i
];
926 plvalue
= PLGetDictionaryEntry(dict
, entry
->plkey
);
931 /* no default in the DB. Use builtin default */
932 plvalue
= entry
->plvalue
;
937 (*entry
->convert
)(NULL
, entry
, plvalue
, entry
->addr
, &tdata
);
939 (*entry
->update
)(NULL
, entry
, tdata
, entry
->extra_data
);
947 wDefaultsCheckDomains(void *foo
)
956 puts("Checking domains...");
958 if (stat(WDWindowMaker
->path
, &stbuf
)>=0
959 && WDWindowMaker
->timestamp
< stbuf
.st_mtime
) {
960 proplist_t shared_dict
= NULL
;
962 puts("Checking WindowMaker domain");
964 WDWindowMaker
->timestamp
= stbuf
.st_mtime
;
966 /* global dictionary */
967 sprintf(path
, "%s/WindowMaker", SYSCONFDIR
);
968 if (stat(path
, &stbuf
)>=0) {
969 shared_dict
= ReadProplistFromFile(path
);
970 if (shared_dict
&& !PLIsDictionary(shared_dict
)) {
971 wwarning(_("Domain %s (%s) of global defaults database is corrupted!"),
972 "WindowMaker", path
);
973 PLRelease(shared_dict
);
975 } else if (!shared_dict
) {
976 wwarning(_("could not load domain %s from global defaults database"),
980 /* user dictionary */
981 dict
= ReadProplistFromFile(WDWindowMaker
->path
);
983 if (!PLIsDictionary(dict
)) {
986 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
987 "WindowMaker", WDWindowMaker
->path
);
990 PLSetFilename(shared_dict
, PLGetFilename(dict
));
991 PLMergeDictionaries(shared_dict
, dict
);
996 for (i
=0; i
<wScreenCount
; i
++) {
997 scr
= wScreenWithNumber(i
);
999 wReadDefaults(scr
, dict
);
1001 if (WDWindowMaker
->dictionary
) {
1002 PLRelease(WDWindowMaker
->dictionary
);
1004 WDWindowMaker
->dictionary
= dict
;
1007 wwarning(_("could not load domain %s from user defaults database"),
1011 PLRelease(shared_dict
);
1015 if (stat(WDWindowAttributes
->path
, &stbuf
)>=0
1016 && WDWindowAttributes
->timestamp
< stbuf
.st_mtime
) {
1018 puts("Checking WMWindowAttributes domain");
1020 dict
= ReadProplistFromFile(WDWindowAttributes
->path
);
1022 if (!PLIsDictionary(dict
)) {
1025 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
1026 "WMWindowAttributes", WDWindowAttributes
->path
);
1028 if (WDWindowAttributes
->dictionary
)
1029 PLRelease(WDWindowAttributes
->dictionary
);
1030 WDWindowAttributes
->dictionary
= dict
;
1031 for (i
=0; i
<wScreenCount
; i
++) {
1032 scr
= wScreenWithNumber(i
);
1034 wDefaultUpdateIcons(scr
);
1038 wwarning(_("could not load domain %s from user defaults database"),
1039 "WMWindowAttributes");
1041 WDWindowAttributes
->timestamp
= stbuf
.st_mtime
;
1045 if (stat(WDRootMenu
->path
, &stbuf
)>=0
1046 && WDRootMenu
->timestamp
< stbuf
.st_mtime
) {
1047 dict
= ReadProplistFromFile(WDRootMenu
->path
);
1049 puts("Checking WMRootMenu domain");
1052 if (!PLIsArray(dict
) && !PLIsString(dict
)) {
1055 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
1056 "WMRootMenu", WDRootMenu
->path
);
1058 if (WDRootMenu
->dictionary
) {
1059 PLRelease(WDRootMenu
->dictionary
);
1061 WDRootMenu
->dictionary
= dict
;
1064 wwarning(_("could not load domain %s from user defaults database"),
1067 WDRootMenu
->timestamp
= stbuf
.st_mtime
;
1072 WMAddTimerHandler(DEFAULTS_CHECK_INTERVAL
, wDefaultsCheckDomains
, foo
);
1077 wReadDefaults(WScreen
*scr
, proplist_t new_dict
)
1079 proplist_t plvalue
, old_value
;
1080 WDefaultEntry
*entry
;
1084 proplist_t old_dict
= (WDWindowMaker
->dictionary
!=new_dict
1085 ? WDWindowMaker
->dictionary
: NULL
);
1091 for (i
=0; i
<sizeof(optionList
)/sizeof(WDefaultEntry
); i
++) {
1092 entry
= &optionList
[i
];
1095 plvalue
= PLGetDictionaryEntry(new_dict
, entry
->plkey
);
1102 old_value
= PLGetDictionaryEntry(old_dict
, entry
->plkey
);
1105 if (!plvalue
&& !old_value
) {
1106 /* no default in the DB. Use builtin default */
1107 plvalue
= entry
->plvalue
;
1108 if (plvalue
&& new_dict
) {
1109 PLInsertDictionaryEntry(new_dict
, entry
->plkey
, plvalue
);
1112 } else if (!plvalue
) {
1113 /* value was deleted from DB. Keep current value */
1115 } else if (!old_value
) {
1116 /* set value for the 1st time */
1117 } else if (!PLIsEqual(plvalue
, old_value
)) {
1118 /* value has changed */
1120 /* value was not changed since last time */
1126 printf("Updating %s to %s\n", entry
->key
, PLGetDescription(plvalue
));
1129 if ((*entry
->convert
)(scr
, entry
, plvalue
, entry
->addr
, &tdata
)) {
1130 if (entry
->update
) {
1132 (*entry
->update
)(scr
, entry
, tdata
, entry
->extra_data
);
1138 if (needs_refresh
!=0 && !scr
->flags
.startup
) {
1142 if (needs_refresh
& REFRESH_MENU_TITLE_TEXTURE
)
1143 foo
|= WTextureSettings
;
1144 if (needs_refresh
& REFRESH_MENU_TITLE_FONT
)
1145 foo
|= WFontSettings
;
1146 if (needs_refresh
& REFRESH_MENU_TITLE_COLOR
)
1147 foo
|= WColorSettings
;
1149 WMPostNotificationName(WNMenuTitleAppearanceSettingsChanged
, NULL
,
1153 if (needs_refresh
& REFRESH_MENU_TEXTURE
)
1154 foo
|= WTextureSettings
;
1155 if (needs_refresh
& REFRESH_MENU_FONT
)
1156 foo
|= WFontSettings
;
1157 if (needs_refresh
& REFRESH_MENU_COLOR
)
1158 foo
|= WColorSettings
;
1160 WMPostNotificationName(WNMenuAppearanceSettingsChanged
, NULL
,
1164 if (needs_refresh
& REFRESH_WINDOW_FONT
) {
1165 foo
|= WFontSettings
;
1167 if (needs_refresh
& REFRESH_WINDOW_TEXTURES
) {
1168 foo
|= WTextureSettings
;
1170 if (needs_refresh
& REFRESH_WINDOW_TITLE_COLOR
) {
1171 foo
|= WColorSettings
;
1174 WMPostNotificationName(WNWindowAppearanceSettingsChanged
, NULL
,
1177 if (!(needs_refresh
& REFRESH_ICON_TILE
)) {
1179 if (needs_refresh
& REFRESH_ICON_FONT
) {
1180 foo
|= WFontSettings
;
1182 if (needs_refresh
& REFRESH_ICON_TITLE_COLOR
) {
1183 foo
|= WTextureSettings
;
1185 if (needs_refresh
& REFRESH_ICON_TITLE_BACK
) {
1186 foo
|= WTextureSettings
;
1189 WMPostNotificationName(WNIconAppearanceSettingsChanged
, NULL
,
1192 if (needs_refresh
& REFRESH_ICON_TILE
)
1193 WMPostNotificationName(WNIconTileSettingsChanged
, NULL
, NULL
);
1199 wDefaultUpdateIcons(WScreen
*scr
)
1201 WAppIcon
*aicon
= scr
->app_icon_list
;
1202 WWindow
*wwin
= scr
->focused_window
;
1206 file
= wDefaultGetIconFile(scr
, aicon
->wm_instance
, aicon
->wm_class
,
1208 if ((file
&& aicon
->icon
->file
&& strcmp(file
, aicon
->icon
->file
)!=0)
1209 || (file
&& !aicon
->icon
->file
)) {
1212 if (aicon
->icon
->file
)
1213 free(aicon
->icon
->file
);
1214 aicon
->icon
->file
= wstrdup(file
);
1216 new_image
= wDefaultGetImage(scr
, aicon
->wm_instance
,
1219 wIconChangeImage(aicon
->icon
, new_image
);
1220 wAppIconPaint(aicon
);
1223 aicon
= aicon
->next
;
1226 if (!wPreferences
.flags
.noclip
)
1227 wClipIconPaint(scr
->clip_icon
);
1230 if (wwin
->icon
&& wwin
->flags
.miniaturized
) {
1231 file
= wDefaultGetIconFile(scr
, wwin
->wm_instance
, wwin
->wm_class
,
1233 if ((file
&& wwin
->icon
->file
&& strcmp(file
, wwin
->icon
->file
)!=0)
1234 || (file
&& !wwin
->icon
->file
)) {
1237 if (wwin
->icon
->file
)
1238 free(wwin
->icon
->file
);
1239 wwin
->icon
->file
= wstrdup(file
);
1241 new_image
= wDefaultGetImage(scr
, wwin
->wm_instance
,
1244 wIconChangeImage(wwin
->icon
, new_image
);
1252 /* --------------------------- Local ----------------------- */
1254 #define STRINGP(x) if (!PLIsString(value)) { \
1255 wwarning(_("Wrong option format for key \"%s\". Should be %s."), \
1262 string2index(proplist_t key
, proplist_t val
, proplist_t def
,
1263 WOptionEnumeration
*values
)
1266 WOptionEnumeration
*v
;
1267 char buffer
[TOTAL_VALUES_LENGTH
];
1269 if (PLIsString(val
) && (str
= PLGetString(val
))) {
1270 for (v
=values
; v
->string
!=NULL
; v
++) {
1271 if (strcasecmp(v
->string
, str
)==0)
1277 for (v
=values
; v
->string
!=NULL
; v
++) {
1280 strcat(buffer
, ", ");
1281 strcat(buffer
, v
->string
);
1284 wwarning(_("wrong option value for key \"%s\". Should be one of %s"),
1285 PLGetString(key
), buffer
);
1288 return string2index(key
, val
, NULL
, values
);
1298 * value - is the value in the defaults DB
1299 * addr - is the address to store the data
1300 * ret - is the address to store a pointer to a temporary buffer. ret
1301 * must not be freed and is used by the set functions
1304 getBool(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
1313 val
= PLGetString(value
);
1316 if ((val
[1]=='\0' && (val
[0]=='y' || val
[0]=='Y'))
1317 || strcasecmp(val
, "YES")==0) {
1320 } else if ((val
[1]=='\0' && (val
[0]=='n' || val
[0]=='N'))
1321 || strcasecmp(val
, "NO")==0) {
1325 if (sscanf(val
, "%i", &i
)==1) {
1331 wwarning(_("can't convert \"%s\" to boolean for key \"%s\""),
1333 if (second_pass
==0) {
1334 val
= PLGetString(entry
->plvalue
);
1336 wwarning(_("using default \"%s\" instead"), val
);
1347 *(char*)addr
= data
;
1355 getInt(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
1364 val
= PLGetString(value
);
1366 if (sscanf(val
, "%i", &data
)!=1) {
1367 wwarning(_("can't convert \"%s\" to integer for key \"%s\""),
1369 val
= PLGetString(entry
->plvalue
);
1370 wwarning(_("using default \"%s\" instead"), val
);
1371 if (sscanf(val
, "%i", &data
)!=1) {
1387 getCoord(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
1391 char *val_x
, *val_y
;
1392 int nelem
, changed
=0;
1393 proplist_t elem_x
, elem_y
;
1396 if (!PLIsArray(value
)) {
1397 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1398 entry
->key
, "Coordinate");
1400 value
= entry
->plvalue
;
1402 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1408 nelem
= PLGetNumberOfElements(value
);
1410 wwarning(_("Incorrect number of elements in array for key \"%s\"."),
1413 value
= entry
->plvalue
;
1415 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1421 elem_x
= PLGetArrayElement(value
, 0);
1422 elem_y
= PLGetArrayElement(value
, 1);
1424 if (!elem_x
|| !elem_y
|| !PLIsString(elem_x
) || !PLIsString(elem_y
)) {
1425 wwarning(_("Wrong value for key \"%s\". Should be Coordinate."),
1428 value
= entry
->plvalue
;
1430 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1436 val_x
= PLGetString(elem_x
);
1437 val_y
= PLGetString(elem_y
);
1439 if (sscanf(val_x
, "%i", &data
.x
)!=1 || sscanf(val_y
, "%i", &data
.y
)!=1) {
1440 wwarning(_("can't convert array to integers for \"%s\"."), entry
->key
);
1442 value
= entry
->plvalue
;
1444 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1452 else if (data
.x
> scr
->scr_width
/3)
1453 data
.x
= scr
->scr_width
/3;
1456 else if (data
.y
> scr
->scr_height
/3)
1457 data
.y
= scr
->scr_height
/3;
1463 *(WCoord
*)addr
= data
;
1471 /* This function is not used at the moment. */
1473 getString(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
1480 data
= PLGetString(value
);
1483 data
= PLGetString(entry
->plvalue
);
1492 *(char**)addr
= wstrdup(data
);
1500 getPathList(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
1510 if (!PLIsArray(value
)) {
1511 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1512 entry
->key
, "an array of paths");
1514 value
= entry
->plvalue
;
1516 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1523 count
= PLGetNumberOfElements(value
);
1526 value
= entry
->plvalue
;
1528 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1535 for (i
=0; i
<count
; i
++) {
1536 d
= PLGetArrayElement(value
, i
);
1537 if (!d
|| !PLIsString(d
)) {
1541 len
+= strlen(PLGetString(d
))+1;
1544 ptr
= data
= wmalloc(len
+1);
1546 for (i
=0; i
<count
; i
++) {
1547 d
= PLGetArrayElement(value
, i
);
1548 if (!d
|| !PLIsString(d
)) {
1551 strcpy(ptr
, PLGetString(d
));
1552 ptr
+= strlen(PLGetString(d
));
1556 ptr
--; *(ptr
--) = 0;
1558 if (*(char**)addr
!=NULL
) {
1559 free(*(char**)addr
);
1561 *(char**)addr
= data
;
1568 getEnum(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
1571 static signed char data
;
1573 data
= string2index(entry
->plkey
, value
, entry
->default_value
,
1574 (WOptionEnumeration
*)entry
->extra_data
);
1582 *(signed char*)addr
= data
;
1591 * (hgradient <color> <color>)
1592 * (vgradient <color> <color>)
1593 * (dgradient <color> <color>)
1594 * (mhgradient <color> <color> ...)
1595 * (mvgradient <color> <color> ...)
1596 * (tpixmap <file> <color>)
1597 * (spixmap <file> <color>)
1598 * (cpixmap <file> <color>)
1599 * (thgradient <file> <opaqueness> <color> <color>)
1600 * (tvgradient <file> <opaqueness> <color> <color>)
1601 * (tdgradient <file> <opaqueness> <color> <color>)
1602 * (function <lib> <function> ...)
1606 parse_texture(WScreen
*scr
, proplist_t pl
)
1611 WTexture
*texture
=NULL
;
1613 nelem
= PLGetNumberOfElements(pl
);
1618 elem
= PLGetArrayElement(pl
, 0);
1619 if (!elem
|| !PLIsString(elem
))
1621 val
= PLGetString(elem
);
1624 if (strcasecmp(val
, "solid")==0) {
1632 elem
= PLGetArrayElement(pl
, 1);
1633 if (!elem
|| !PLIsString(elem
))
1635 val
= PLGetString(elem
);
1637 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &color
)) {
1638 wwarning(_("\"%s\" is not a valid color name"), val
);
1642 texture
= (WTexture
*)wTextureMakeSolid(scr
, &color
);
1643 } else if (strcasecmp(val
, "dgradient")==0
1644 || strcasecmp(val
, "vgradient")==0
1645 || strcasecmp(val
, "hgradient")==0) {
1646 RColor color1
, color2
;
1651 wwarning(_("bad number of arguments in gradient specification"));
1655 if (val
[0]=='d' || val
[0]=='D')
1656 type
= WTEX_DGRADIENT
;
1657 else if (val
[0]=='h' || val
[0]=='H')
1658 type
= WTEX_HGRADIENT
;
1660 type
= WTEX_VGRADIENT
;
1663 /* get from color */
1664 elem
= PLGetArrayElement(pl
, 1);
1665 if (!elem
|| !PLIsString(elem
))
1667 val
= PLGetString(elem
);
1669 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1670 wwarning(_("\"%s\" is not a valid color name"), val
);
1674 color1
.red
= xcolor
.red
>> 8;
1675 color1
.green
= xcolor
.green
>> 8;
1676 color1
.blue
= xcolor
.blue
>> 8;
1679 elem
= PLGetArrayElement(pl
, 2);
1680 if (!elem
|| !PLIsString(elem
)) {
1683 val
= PLGetString(elem
);
1685 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1686 wwarning(_("\"%s\" is not a valid color name"), val
);
1690 color2
.red
= xcolor
.red
>> 8;
1691 color2
.green
= xcolor
.green
>> 8;
1692 color2
.blue
= xcolor
.blue
>> 8;
1694 texture
= (WTexture
*)wTextureMakeGradient(scr
, type
, &color1
, &color2
);
1696 } else if (strcasecmp(val
, "mhgradient")==0
1697 || strcasecmp(val
, "mvgradient")==0
1698 || strcasecmp(val
, "mdgradient")==0) {
1705 wwarning(_("too few arguments in multicolor gradient specification"));
1709 if (val
[1]=='h' || val
[1]=='H')
1710 type
= WTEX_MHGRADIENT
;
1711 else if (val
[1]=='v' || val
[1]=='V')
1712 type
= WTEX_MVGRADIENT
;
1714 type
= WTEX_MDGRADIENT
;
1718 colors
= wmalloc(sizeof(RColor
*)*(count
+1));
1720 for (i
=0; i
<count
; i
++) {
1721 elem
= PLGetArrayElement(pl
, i
+1);
1722 if (!elem
|| !PLIsString(elem
)) {
1723 for (--i
; i
>=0; --i
) {
1729 val
= PLGetString(elem
);
1731 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &color
)) {
1732 wwarning(_("\"%s\" is not a valid color name"), val
);
1733 for (--i
; i
>=0; --i
) {
1739 colors
[i
] = wmalloc(sizeof(RColor
));
1740 colors
[i
]->red
= color
.red
>> 8;
1741 colors
[i
]->green
= color
.green
>> 8;
1742 colors
[i
]->blue
= color
.blue
>> 8;
1747 texture
= (WTexture
*)wTextureMakeMGradient(scr
, type
, colors
);
1748 } else if (strcasecmp(val
, "spixmap")==0 ||
1749 strcasecmp(val
, "cpixmap")==0 ||
1750 strcasecmp(val
, "tpixmap")==0) {
1757 if (val
[0] == 's' || val
[0] == 'S')
1759 else if (val
[0] == 'c' || val
[0] == 'C')
1765 elem
= PLGetArrayElement(pl
, 2);
1766 if (!elem
|| !PLIsString(elem
)) {
1769 val
= PLGetString(elem
);
1771 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &color
)) {
1772 wwarning(_("\"%s\" is not a valid color name"), val
);
1777 elem
= PLGetArrayElement(pl
, 1);
1778 if (!elem
|| !PLIsString(elem
))
1780 val
= PLGetString(elem
);
1782 texture
= (WTexture
*)wTextureMakePixmap(scr
, type
, val
, &color
);
1783 } else if (strcasecmp(val
, "thgradient")==0
1784 || strcasecmp(val
, "tvgradient")==0
1785 || strcasecmp(val
, "tdgradient")==0) {
1786 RColor color1
, color2
;
1791 if (val
[1]=='h' || val
[1]=='H')
1792 style
= WTEX_THGRADIENT
;
1793 else if (val
[1]=='v' || val
[1]=='V')
1794 style
= WTEX_TVGRADIENT
;
1796 style
= WTEX_TDGRADIENT
;
1799 wwarning(_("bad number of arguments in textured gradient specification"));
1803 /* get from color */
1804 elem
= PLGetArrayElement(pl
, 3);
1805 if (!elem
|| !PLIsString(elem
))
1807 val
= PLGetString(elem
);
1809 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1810 wwarning(_("\"%s\" is not a valid color name"), val
);
1814 color1
.red
= xcolor
.red
>> 8;
1815 color1
.green
= xcolor
.green
>> 8;
1816 color1
.blue
= xcolor
.blue
>> 8;
1819 elem
= PLGetArrayElement(pl
, 4);
1820 if (!elem
|| !PLIsString(elem
)) {
1823 val
= PLGetString(elem
);
1825 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1826 wwarning(_("\"%s\" is not a valid color name"), val
);
1830 color2
.red
= xcolor
.red
>> 8;
1831 color2
.green
= xcolor
.green
>> 8;
1832 color2
.blue
= xcolor
.blue
>> 8;
1835 elem
= PLGetArrayElement(pl
, 2);
1836 if (!elem
|| !PLIsString(elem
))
1839 val
= PLGetString(elem
);
1841 if (!val
|| (opacity
= atoi(val
)) < 0 || opacity
> 255) {
1842 wwarning(_("bad opacity value for tgradient texture \"%s\". Should be [0..255]"), val
);
1847 elem
= PLGetArrayElement(pl
, 1);
1848 if (!elem
|| !PLIsString(elem
))
1850 val
= PLGetString(elem
);
1852 texture
= (WTexture
*)wTextureMakeTGradient(scr
, style
, &color1
, &color2
,
1855 #ifdef TEXTURE_PLUGIN
1856 else if (strcasecmp(val
, "function")==0) {
1857 WTexFunction
*function
;
1858 void (*initFunc
) (Display
*, Colormap
);
1859 char *lib
, *func
, **argv
;
1865 /* get the library name */
1866 elem
= PLGetArrayElement(pl
, 1);
1867 if (!elem
|| !PLIsString(elem
)) {
1870 lib
= PLGetString(elem
);
1872 /* get the function name */
1873 elem
= PLGetArrayElement(pl
, 2);
1874 if (!elem
|| !PLIsString(elem
)) {
1877 func
= PLGetString(elem
);
1880 argv
= (char **)wmalloc(argc
* sizeof(char *));
1882 /* get the parameters */
1883 argv
[0] = wstrdup(func
);
1884 for (i
= 0; i
< argc
- 1; i
++) {
1885 elem
= PLGetArrayElement(pl
, 3 + i
);
1886 if (!elem
|| !PLIsString(elem
)) {
1891 argv
[i
+1] = wstrdup(PLGetString(elem
));
1894 function
= wTextureMakeFunction(scr
, lib
, func
, argc
, argv
);
1898 initFunc
= dlsym(function
->handle
, "initWindowMaker");
1900 initFunc(dpy
, scr
->w_colormap
);
1902 wwarning(_("could not initialize library %s"), lib
);
1905 wwarning(_("could not find function %s::%s"), lib
, func
);
1907 #endif /* HAVE_DLFCN_H */
1908 texture
= (WTexture
*)function
;
1910 #endif /* TEXTURE_PLUGIN */
1912 wwarning(_("invalid texture type %s"), val
);
1921 getTexture(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
1924 static WTexture
*texture
;
1928 if (!PLIsArray(value
)) {
1929 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1930 entry
->key
, "Texture");
1932 value
= entry
->plvalue
;
1934 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1940 if (strcmp(entry
->key
, "WidgetColor")==0 && !changed
) {
1943 pl
= PLGetArrayElement(value
, 0);
1944 if (!pl
|| !PLIsString(pl
) || !PLGetString(pl
)
1945 || strcasecmp(PLGetString(pl
), "solid")!=0) {
1946 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1947 entry
->key
, "Solid Texture");
1949 value
= entry
->plvalue
;
1951 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1956 texture
= parse_texture(scr
, value
);
1959 wwarning(_("Error in texture specification for key \"%s\""),
1962 value
= entry
->plvalue
;
1964 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1974 *(WTexture
**)addr
= texture
;
1982 getWSBackground(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
,
1983 void *addr
, void **ret
)
1991 if (!PLIsArray(value
)) {
1992 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1993 "WorkspaceBack", "Texture or None");
1995 value
= entry
->plvalue
;
1997 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
2003 /* only do basic error checking and verify for None texture */
2005 nelem
= PLGetNumberOfElements(value
);
2007 elem
= PLGetArrayElement(value
, 0);
2008 if (!elem
|| !PLIsString(elem
)) {
2009 wwarning(_("Wrong type for workspace background. Should be a texture type."));
2011 value
= entry
->plvalue
;
2013 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
2018 val
= PLGetString(elem
);
2020 if (strcasecmp(val
, "None")==0)
2023 *ret
= PLRetain(value
);
2030 getWSSpecificBackground(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
,
2031 void *addr
, void **ret
)
2038 if (!PLIsArray(value
)) {
2039 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
2040 "WorkspaceSpecificBack", "an array of textures");
2042 value
= entry
->plvalue
;
2044 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
2050 /* only do basic error checking and verify for None texture */
2052 nelem
= PLGetNumberOfElements(value
);
2055 elem
= PLGetArrayElement(value
, nelem
);
2056 if (!elem
|| !PLIsArray(elem
)) {
2057 wwarning(_("Wrong type for background of workspace %i. Should be a texture."),
2063 *ret
= PLRetain(value
);
2067 * Kluge to force wmsetbg helper to set the default background.
2068 * If the WorkspaceSpecificBack is changed once wmaker has started,
2069 * the WorkspaceBack won't be sent to the helper, unless the user
2070 * changes it's value too. So, we must force this by removing the
2071 * value from the defaults DB.
2073 if (!scr
->flags
.backimage_helper_launched
&& !scr
->flags
.startup
) {
2074 proplist_t key
= PLMakeString("WorkspaceBack");
2076 PLRemoveDictionaryEntry(WDWindowMaker
->dictionary
, key
);
2086 getFont(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
2094 val
= PLGetString(value
);
2096 font
= wLoadFont(val
);
2098 wfatal(_("could not load any usable font!!!"));
2105 /* can't assign font value outside update function */
2106 wassertrv(addr
== NULL
, True
);
2113 getColor(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
2116 static XColor color
;
2122 val
= PLGetString(value
);
2125 if (!wGetColor(scr
, val
, &color
)) {
2126 wwarning(_("could not get color for key \"%s\""),
2128 if (second_pass
==0) {
2129 val
= PLGetString(entry
->plvalue
);
2131 wwarning(_("using default \"%s\" instead"), val
);
2143 *(unsigned long*)addr = pixel;
2152 getKeybind(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
2155 static WShortKey shortcut
;
2162 STRINGP("Key spec");
2164 val
= PLGetString(value
);
2166 if (!val
|| strcasecmp(val
, "NONE")==0) {
2167 shortcut
.keycode
= 0;
2168 shortcut
.modifier
= 0;
2179 shortcut
.modifier
= 0;
2180 while ((k
= strchr(b
, '+'))!=NULL
) {
2184 mod
= wXModifierFromKey(b
);
2186 wwarning(_("%s:invalid key modifier \"%s\""), entry
->key
, b
);
2189 shortcut
.modifier
|= mod
;
2195 ksym
= XStringToKeysym(b
);
2197 if (ksym
==NoSymbol
) {
2198 wwarning(_("%s:invalid kbd shortcut specification \"%s\""), entry
->key
,
2203 shortcut
.keycode
= XKeysymToKeycode(dpy
, ksym
);
2204 if (shortcut
.keycode
==0) {
2205 wwarning(_("%s:invalid key in shortcut \"%s\""), entry
->key
, val
);
2217 getModMask(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
2220 static unsigned int mask
;
2223 STRINGP("Modifier Key");
2225 str
= PLGetString(value
);
2229 mask
= wXModifierFromKey(str
);
2231 wwarning(_("%s: modifier key %s is not valid"), entry
->key
, str
);
2237 *(unsigned int*)addr
= mask
;
2248 getRImages(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
,
2249 void *addr
, void **ret
)
2257 STRINGP("Image File Path");
2259 str
= PLGetString(value
);
2263 image
= RLoadImage(scr
->rcontext
, str
, 0);
2265 wwarning(_("could not load image in option %s: %s"), entry
->key
,
2266 RMessageForError(RErrorCode
));
2270 if (*(RImage
**)addr
) {
2271 RDestroyImage(*(RImage
**)addr
);
2274 *(RImage
**)addr
= image
;
2276 assert(ret
== NULL
);
2279 *(RImage**)ret = image;
2287 /* ---------------- value setting functions --------------- */
2289 setJustify(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
2291 return REFRESH_WINDOW_TITLE_COLOR
;
2296 setIfDockPresent(WScreen
*scr
, WDefaultEntry
*entry
, int *flag
, long which
)
2300 wPreferences
.flags
.nodock
= wPreferences
.flags
.nodock
|| *flag
;
2303 wPreferences
.flags
.noclip
= wPreferences
.flags
.noclip
|| *flag
;
2313 setStickyIcons(WScreen
*scr
, WDefaultEntry
*entry
, void *bar
, void *foo
)
2315 if (scr
->workspaces
) {
2316 wWorkspaceForceChange(scr
, scr
->current_workspace
);
2317 wArrangeIcons(scr
, False
);
2324 setPositive(WScreen
*scr
, WDefaultEntry
*entry
, int *value
, void *foo
)
2336 setIconTile(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
2342 img
= wTextureRenderImage(*texture
, wPreferences
.icon_size
,
2343 wPreferences
.icon_size
,
2344 ((*texture
)->any
.type
& WREL_BORDER_MASK
)
2345 ? WREL_ICON
: WREL_FLAT
);
2347 wwarning(_("could not render texture for icon background"));
2349 wTextureDestroy(scr
, *texture
);
2352 RConvertImage(scr
->rcontext
, img
, &pixmap
);
2354 if (scr
->icon_tile
) {
2356 RDestroyImage(scr
->icon_tile
);
2357 XFreePixmap(dpy
, scr
->icon_tile_pixmap
);
2360 scr
->icon_tile
= img
;
2362 if (!wPreferences
.flags
.noclip
) {
2363 if (scr
->clip_tile
) {
2364 RDestroyImage(scr
->clip_tile
);
2366 scr
->clip_tile
= wClipMakeTile(scr
, img
);
2369 scr
->icon_tile_pixmap
= pixmap
;
2371 if (scr
->def_icon_pixmap
) {
2372 XFreePixmap(dpy
, scr
->def_icon_pixmap
);
2373 scr
->def_icon_pixmap
= None
;
2375 if (scr
->def_ticon_pixmap
) {
2376 XFreePixmap(dpy
, scr
->def_ticon_pixmap
);
2377 scr
->def_ticon_pixmap
= None
;
2380 if (scr
->icon_back_texture
) {
2381 wTextureDestroy(scr
, (WTexture
*)scr
->icon_back_texture
);
2383 scr
->icon_back_texture
= wTextureMakeSolid(scr
, &((*texture
)->any
.color
));
2385 if (scr
->clip_balloon
)
2386 XSetWindowBackground(dpy
, scr
->clip_balloon
,
2387 (*texture
)->any
.color
.pixel
);
2390 * Free the texture as nobody else will use it, nor refer to it.
2393 wTextureDestroy(scr
, *texture
);
2395 return (reset
? REFRESH_ICON_TILE
: 0);
2401 setWinTitleFont(WScreen
*scr
, WDefaultEntry
*entry
, WFont
*font
, void *foo
)
2403 if (scr
->title_font
) {
2404 wFreeFont(scr
->title_font
);
2407 scr
->title_font
= font
;
2410 XSetFont(dpy
, scr
->window_title_gc
, font
->font
->fid
);
2413 return REFRESH_WINDOW_FONT
|REFRESH_BUTTON_IMAGES
;
2418 setMenuTitleFont(WScreen
*scr
, WDefaultEntry
*entry
, WFont
*font
, void *foo
)
2420 if (scr
->menu_title_font
) {
2421 wFreeFont(scr
->menu_title_font
);
2424 scr
->menu_title_font
= font
;
2427 XSetFont(dpy
, scr
->menu_title_gc
, font
->font
->fid
);
2430 return REFRESH_MENU_TITLE_FONT
;
2435 setMenuTextFont(WScreen
*scr
, WDefaultEntry
*entry
, WFont
*font
, void *foo
)
2437 if (scr
->menu_entry_font
) {
2438 wFreeFont(scr
->menu_entry_font
);
2441 scr
->menu_entry_font
= font
;
2444 XSetFont(dpy
, scr
->menu_entry_gc
, font
->font
->fid
);
2445 XSetFont(dpy
, scr
->disabled_menu_entry_gc
, font
->font
->fid
);
2446 XSetFont(dpy
, scr
->select_menu_gc
, font
->font
->fid
);
2449 return REFRESH_MENU_FONT
;
2455 setIconTitleFont(WScreen
*scr
, WDefaultEntry
*entry
, WFont
*font
, void *foo
)
2457 if (scr
->icon_title_font
) {
2458 wFreeFont(scr
->icon_title_font
);
2461 scr
->icon_title_font
= font
;
2464 XSetFont(dpy
, scr
->icon_title_gc
, font
->font
->fid
);
2467 return REFRESH_ICON_FONT
;
2472 setClipTitleFont(WScreen
*scr
, WDefaultEntry
*entry
, WFont
*font
, void *foo
)
2474 if (scr
->clip_title_font
) {
2475 wFreeFont(scr
->clip_title_font
);
2478 scr
->clip_title_font
= font
;
2481 XSetFont(dpy
, scr
->clip_title_gc
, font
->font
->fid
);
2484 return REFRESH_ICON_FONT
;
2489 setDisplayFont(WScreen
*scr
, WDefaultEntry
*entry
, WFont
*font
, void *foo
)
2491 if (scr
->info_text_font
) {
2492 wFreeFont(scr
->info_text_font
);
2495 scr
->info_text_font
= font
;
2498 XSetFont(dpy
, scr
->info_text_gc
, font
->font
->fid
);
2499 XSetFont(dpy
, scr
->line_gc
, font
->font
->fid
);
2502 /* This test works because the scr structure is initially zeroed out
2503 and None = 0. Any other time, the window should be valid. */
2504 if (scr
->geometry_display
!= None
) {
2505 wGetGeometryWindowSize(scr
, &scr
->geometry_display_width
,
2506 &scr
->geometry_display_height
);
2507 XResizeWindow(dpy
, scr
->geometry_display
,
2508 scr
->geometry_display_width
, scr
->geometry_display_height
);
2516 setLargeDisplayFont(WScreen
*scr
, WDefaultEntry
*entry
, WFont
*font
, void *foo
)
2518 if (scr
->workspace_name_font
) {
2519 wFreeFont(scr
->workspace_name_font
);
2522 scr
->workspace_name_font
= font
;
2529 setHightlight(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, void *foo
)
2531 if (scr
->select_pixel
!=scr
->white_pixel
&&
2532 scr
->select_pixel
!=scr
->black_pixel
) {
2533 wFreeColor(scr
, scr
->select_pixel
);
2536 scr
->select_pixel
= color
->pixel
;
2538 return REFRESH_MENU_COLOR
;
2543 setHightlightText(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, void *foo
)
2545 if (scr
->select_text_pixel
!=scr
->white_pixel
&&
2546 scr
->select_text_pixel
!=scr
->black_pixel
) {
2547 wFreeColor(scr
, scr
->select_text_pixel
);
2550 scr
->select_text_pixel
= color
->pixel
;
2552 return REFRESH_MENU_COLOR
;
2557 setClipTitleColor(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, long index
)
2559 if (scr
->clip_title_pixel
[index
]!=scr
->white_pixel
&&
2560 scr
->clip_title_pixel
[index
]!=scr
->black_pixel
) {
2561 wFreeColor(scr
, scr
->clip_title_pixel
[index
]);
2563 scr
->clip_title_pixel
[index
] = color
->pixel
;
2565 #ifdef GRADIENT_CLIP_ARROW
2566 if (index
== CLIP_NORMAL
) {
2568 RColor color1
, color2
;
2569 int pt
= CLIP_BUTTON_SIZE
*wPreferences
.icon_size
/64;
2570 int as
= pt
- 15; /* 15 = 5+5+5 */
2572 FREE_PIXMAP(scr
->clip_arrow_gradient
);
2574 color1
.red
= (color
->red
>> 8)*6/10;
2575 color1
.green
= (color
->green
>> 8)*6/10;
2576 color1
.blue
= (color
->blue
>> 8)*6/10;
2578 color2
.red
= WMIN((color
->red
>> 8)*20/10, 255);
2579 color2
.green
= WMIN((color
->green
>> 8)*20/10, 255);
2580 color2
.blue
= WMIN((color
->blue
>> 8)*20/10, 255);
2582 image
= RRenderGradient(as
+1, as
+1, &color1
, &color2
, RDiagonalGradient
);
2583 RConvertImage(scr
->rcontext
, image
, &scr
->clip_arrow_gradient
);
2584 RDestroyImage(image
);
2586 #endif /* GRADIENT_CLIP_ARROW */
2588 return REFRESH_ICON_TITLE_COLOR
;
2593 setWTitleColor(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, long index
)
2595 if (scr
->window_title_pixel
[index
]!=scr
->white_pixel
&&
2596 scr
->window_title_pixel
[index
]!=scr
->black_pixel
) {
2597 wFreeColor(scr
, scr
->window_title_pixel
[index
]);
2600 scr
->window_title_pixel
[index
] = color
->pixel
;
2602 if (index
== WS_UNFOCUSED
)
2603 XSetForeground(dpy
, scr
->info_text_gc
, color
->pixel
);
2605 return REFRESH_WINDOW_TITLE_COLOR
;
2610 setMenuTitleColor(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, long index
)
2612 #ifdef TITLE_TEXT_SHADOW
2613 if (index
== WS_SMENU
){
2614 if (scr
->menu_title_pixel
[WS_SMENU
]!=scr
->white_pixel
&&
2615 scr
->menu_title_pixel
[WS_SMENU
]!=scr
->black_pixel
) {
2616 wFreeColor(scr
, scr
->menu_title_pixel
[WS_SMENU
]);
2618 scr
->menu_title_pixel
[WS_SMENU
] = color
->pixel
;
2621 if (scr
->menu_title_pixel
[0]!=scr
->white_pixel
&&
2622 scr
->menu_title_pixel
[0]!=scr
->black_pixel
) {
2623 wFreeColor(scr
, scr
->menu_title_pixel
[0]);
2625 scr
->menu_title_pixel
[0] = color
->pixel
;
2627 #else /* !TITLE_TEXT_SHADOW */
2628 if (scr
->menu_title_pixel
[0]!=scr
->white_pixel
&&
2629 scr
->menu_title_pixel
[0]!=scr
->black_pixel
) {
2630 wFreeColor(scr
, scr
->menu_title_pixel
[0]);
2633 scr
->menu_title_pixel
[0] = color
->pixel
;
2634 #endif /* !TITLE_TEXT_SHADOW */
2635 XSetForeground(dpy
, scr
->menu_title_gc
, color
->pixel
);
2637 return REFRESH_MENU_TITLE_COLOR
;
2642 setMenuTextColor(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, void *foo
)
2645 #define gcm (GCForeground|GCBackground|GCFillStyle)
2647 if (scr
->mtext_pixel
!=scr
->white_pixel
&&
2648 scr
->mtext_pixel
!=scr
->black_pixel
) {
2649 wFreeColor(scr
, scr
->mtext_pixel
);
2652 scr
->mtext_pixel
= color
->pixel
;
2654 XSetForeground(dpy
, scr
->menu_entry_gc
, color
->pixel
);
2657 if (scr
->dtext_pixel
== scr
->mtext_pixel
) {
2658 gcv
.foreground
= scr
->white_pixel
;
2659 gcv
.background
= scr
->black_pixel
;
2660 gcv
.fill_style
= FillStippled
;
2662 gcv
.foreground
= scr
->dtext_pixel
;
2663 gcv
.fill_style
= FillSolid
;
2665 XChangeGC(dpy
, scr
->disabled_menu_entry_gc
, gcm
, &gcv
);
2667 return REFRESH_MENU_COLOR
;
2673 setMenuDisabledColor(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, void *foo
)
2676 #define gcm (GCForeground|GCBackground|GCFillStyle)
2678 if (scr
->dtext_pixel
!=scr
->white_pixel
&&
2679 scr
->dtext_pixel
!=scr
->black_pixel
) {
2680 wFreeColor(scr
, scr
->dtext_pixel
);
2683 scr
->dtext_pixel
= color
->pixel
;
2685 if (scr
->dtext_pixel
== scr
->mtext_pixel
) {
2686 gcv
.foreground
= scr
->white_pixel
;
2687 gcv
.background
= scr
->black_pixel
;
2688 gcv
.fill_style
= FillStippled
;
2690 gcv
.foreground
= scr
->dtext_pixel
;
2691 gcv
.fill_style
= FillSolid
;
2693 XChangeGC(dpy
, scr
->disabled_menu_entry_gc
, gcm
, &gcv
);
2695 return REFRESH_MENU_COLOR
;
2700 setIconTitleColor(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, void *foo
)
2702 XSetForeground(dpy
, scr
->icon_title_gc
, color
->pixel
);
2704 return REFRESH_ICON_TITLE_COLOR
;
2709 setIconTitleBack(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, void *foo
)
2711 if (scr
->icon_title_texture
) {
2712 wTextureDestroy(scr
, (WTexture
*)scr
->icon_title_texture
);
2714 XQueryColor (dpy
, scr
->w_colormap
, color
);
2715 scr
->icon_title_texture
= wTextureMakeSolid(scr
, color
);
2717 return REFRESH_ICON_TITLE_BACK
;
2722 trackDeadProcess(pid_t pid
, unsigned char status
, WScreen
*scr
)
2724 close(scr
->helper_fd
);
2726 scr
->helper_pid
= 0;
2727 scr
->flags
.backimage_helper_launched
= 0;
2732 setWorkspaceSpecificBack(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
,
2739 if (scr
->flags
.backimage_helper_launched
) {
2740 if (PLGetNumberOfElements(value
)==0) {
2741 SendHelperMessage(scr
, 'C', 0, NULL
);
2742 SendHelperMessage(scr
, 'K', 0, NULL
);
2751 if (PLGetNumberOfElements(value
) == 0)
2754 if (pipe(filedes
) < 0) {
2755 wsyserror("pipe() failed:can't set workspace specific background image");
2763 wsyserror("fork() failed:can't set workspace specific background image");
2764 if (close(filedes
[0]) < 0)
2765 wsyserror("could not close pipe");
2766 if (close(filedes
[1]) < 0)
2767 wsyserror("could not close pipe");
2769 } else if (pid
== 0) {
2770 SetupEnvironment(scr
);
2773 wsyserror("could not close pipe");
2774 if (dup(filedes
[0]) < 0) {
2775 wsyserror("dup() failed:can't set workspace specific background image");
2777 execlp("wmsetbg", "wmsetbg", "-helper", "-d", NULL
);
2778 wsyserror("could not execute wmsetbg");
2782 if (fcntl(filedes
[0], F_SETFD
, FD_CLOEXEC
) < 0) {
2783 wsyserror("error setting close-on-exec flag");
2785 if (fcntl(filedes
[1], F_SETFD
, FD_CLOEXEC
) < 0) {
2786 wsyserror("error setting close-on-exec flag");
2789 scr
->helper_fd
= filedes
[1];
2790 scr
->helper_pid
= pid
;
2791 scr
->flags
.backimage_helper_launched
= 1;
2793 wAddDeathHandler(pid
, (WDeathHandler
*)trackDeadProcess
, scr
);
2795 SendHelperMessage(scr
, 'P', -1, wPreferences
.pixmap_path
);
2799 for (i
= 0; i
< PLGetNumberOfElements(value
); i
++) {
2800 val
= PLGetArrayElement(value
, i
);
2801 if (val
&& PLIsArray(val
) && PLGetNumberOfElements(val
)>0) {
2802 str
= PLGetDescription(val
);
2804 SendHelperMessage(scr
, 'S', i
+1, str
);
2808 SendHelperMessage(scr
, 'U', i
+1, NULL
);
2819 setWorkspaceBack(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
,
2822 if (scr
->flags
.backimage_helper_launched
) {
2825 if (PLGetNumberOfElements(value
)==0) {
2826 SendHelperMessage(scr
, 'U', 0, NULL
);
2828 /* set the default workspace background to this one */
2829 str
= PLGetDescription(value
);
2831 SendHelperMessage(scr
, 'S', 0, str
);
2833 SendHelperMessage(scr
, 'C', scr
->current_workspace
+1, NULL
);
2835 SendHelperMessage(scr
, 'U', 0, NULL
);
2842 SetupEnvironment(scr
);
2843 text
= PLGetDescription(value
);
2844 command
= wmalloc(strlen(text
)+40);
2845 sprintf(command
, "wmsetbg -d -p '%s' &", text
);
2857 setWidgetColor(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
2859 if (scr
->widget_texture
) {
2860 wTextureDestroy(scr
, (WTexture
*)scr
->widget_texture
);
2862 scr
->widget_texture
= *(WTexSolid
**)texture
;
2864 if (scr
->geometry_display
!= None
)
2865 XSetWindowBackground(dpy
, scr
->geometry_display
,
2866 scr
->widget_texture
->normal
.pixel
);
2873 setFTitleBack(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
2875 if (scr
->window_title_texture
[WS_FOCUSED
]) {
2876 wTextureDestroy(scr
, scr
->window_title_texture
[WS_FOCUSED
]);
2878 scr
->window_title_texture
[WS_FOCUSED
] = *texture
;
2880 return REFRESH_WINDOW_TEXTURES
;
2885 setPTitleBack(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
2887 if (scr
->window_title_texture
[WS_PFOCUSED
]) {
2888 wTextureDestroy(scr
, scr
->window_title_texture
[WS_PFOCUSED
]);
2890 scr
->window_title_texture
[WS_PFOCUSED
] = *texture
;
2892 return REFRESH_WINDOW_TEXTURES
;
2897 setUTitleBack(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
2899 if (scr
->window_title_texture
[WS_UNFOCUSED
]) {
2900 wTextureDestroy(scr
, scr
->window_title_texture
[WS_UNFOCUSED
]);
2902 scr
->window_title_texture
[WS_UNFOCUSED
] = *texture
;
2904 return REFRESH_WINDOW_TEXTURES
;
2909 setResizebarBack(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
2911 if (scr
->resizebar_texture
[0]) {
2912 wTextureDestroy(scr
, scr
->resizebar_texture
[0]);
2914 scr
->resizebar_texture
[0] = *texture
;
2916 return REFRESH_WINDOW_TEXTURES
;
2921 setMenuTitleBack(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
2923 if (scr
->menu_title_texture
[0]) {
2924 wTextureDestroy(scr
, scr
->menu_title_texture
[0]);
2926 scr
->menu_title_texture
[0] = *texture
;
2928 return REFRESH_MENU_TITLE_TEXTURE
;
2933 setMenuTextBack(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
2935 if (scr
->menu_item_texture
) {
2936 wTextureDestroy(scr
, scr
->menu_item_texture
);
2937 wTextureDestroy(scr
, (WTexture
*)scr
->menu_item_auxtexture
);
2939 scr
->menu_item_texture
= *texture
;
2941 scr
->menu_item_auxtexture
2942 = wTextureMakeSolid(scr
, &scr
->menu_item_texture
->any
.color
);
2944 return REFRESH_MENU_TEXTURE
;
2949 setKeyGrab(WScreen
*scr
, WDefaultEntry
*entry
, WShortKey
*shortcut
, long index
)
2952 wKeyBindings
[index
] = *shortcut
;
2954 wwin
= scr
->focused_window
;
2956 while (wwin
!=NULL
) {
2957 XUngrabKey(dpy
, AnyKey
, AnyModifier
, wwin
->frame
->core
->window
);
2959 if (!WFLAGP(wwin
, no_bind_keys
)) {
2960 wWindowSetKeyGrabs(wwin
);
2970 setIconPosition(WScreen
*scr
, WDefaultEntry
*entry
, void *bar
, void *foo
)
2972 wArrangeIcons(scr
, True
);
2979 updateUsableArea(WScreen
*scr
, WDefaultEntry
*entry
, void *bar
, void *foo
)
2981 wScreenUpdateUsableArea(scr
);
2988 setMenuStyle(WScreen
*scr
, WDefaultEntry
*entry
, int *value
, void *foo
)
2990 return REFRESH_MENU_TEXTURE
;
2996 setButtonImages(WScreen *scr, WDefaultEntry *entry, int *value, void *foo)
2998 return REFRESH_BUTTON_IMAGES;
3004 * Need access to the double click variables, so that all widgets in
3005 * wmaker panels will have the same dbl-click values.
3006 * TODO: figure a better way of dealing with it.
3011 setDoubleClick(WScreen
*scr
, WDefaultEntry
*entry
, int *value
, void *foo
)
3013 extern _WINGsConfiguration WINGsConfiguration
;
3018 WINGsConfiguration
.doubleClickDelay
= *value
;