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,
33 #include <sys/types.h>
46 #define PATH_MAX DEFAULT_PATH_MAX
50 #include <X11/Xutil.h>
51 #include <X11/keysym.h>
56 #include "WindowMaker.h"
62 #include "resources.h"
65 #include "xmodifier.h"
70 #include "workspace.h"
74 * Our own proplist reader parser. This one will not accept any
75 * syntax errors and is more descriptive in the error messages.
76 * It also doesn't seem to crash.
78 extern proplist_t
ReadProplistFromFile(char *file
);
83 extern WDDomain
*WDWindowMaker
;
84 extern WDDomain
*WDWindowAttributes
;
85 extern WDDomain
*WDRootMenu
;
87 extern int wScreenCount
;
90 extern proplist_t wDomainName;
91 extern proplist_t wAttributeDomainName;
93 extern WPreferences wPreferences
;
95 extern WShortKey wKeyBindings
[WKBD_LAST
];
105 proplist_t plvalue
; /* default value */
109 /* used to map strings to integers */
114 } WOptionEnumeration
;
117 /* type converters */
118 static int getBool();
120 static int getCoord();
122 /* this is not used yet */
123 static int getString();
125 static int getPathList();
126 static int getEnum();
127 static int getTexture();
128 #ifdef DRAWSTRING_PLUGIN
129 static int getTextRenderer();
131 static int getWSBackground();
132 static int getWSSpecificBackground();
133 static int getFont();
134 static int getColor();
135 static int getKeybind();
136 static int getModMask();
138 static int getRImage();
142 /* value setting functions */
143 static int setJustify();
144 static int setIfDockPresent();
145 static int setStickyIcons();
147 static int setPositive();
149 static int setWidgetColor();
150 static int setIconTile();
151 static int setWinTitleFont();
152 static int setMenuTitleFont();
153 static int setMenuTextFont();
154 static int setIconTitleFont();
155 static int setIconTitleColor();
156 static int setIconTitleBack();
157 static int setDisplayFont();
158 static int setLargeDisplayFont();
159 static int setWTitleColor();
160 static int setFTitleBack();
161 static int setPTitleBack();
162 static int setUTitleBack();
163 static int setResizebarBack();
164 static int setWorkspaceBack();
165 static int setWorkspaceSpecificBack();
166 static int setMenuTitleColor();
167 static int setMenuTextColor();
168 static int setMenuDisabledColor();
169 static int setMenuTitleBack();
170 static int setMenuTextBack();
171 static int setHightlight();
172 static int setHightlightText();
173 static int setKeyGrab();
174 static int setDoubleClick();
175 static int setIconPosition();
177 static int setClipTitleFont();
178 static int setClipTitleColor();
180 static int setMenuStyle();
181 static int setMultiByte();
183 static int updateUsableArea();
188 * Tables to convert strings to enumeration values.
189 * Values stored are char
193 /* WARNING: sum of length of all value strings must not exceed
195 #define TOTAL_VALUES_LENGTH 80
200 #define REFRESH_WINDOW_TEXTURES (1<<0)
201 #define REFRESH_MENU_TEXTURE (1<<1)
202 #define REFRESH_MENU_FONT (1<<2)
203 #define REFRESH_MENU_COLOR (1<<3)
204 #define REFRESH_MENU_TITLE_TEXTURE (1<<4)
205 #define REFRESH_MENU_TITLE_FONT (1<<5)
206 #define REFRESH_MENU_TITLE_COLOR (1<<6)
207 #define REFRESH_WINDOW_TITLE_COLOR (1<<7)
208 #define REFRESH_WINDOW_FONT (1<<8)
209 #define REFRESH_ICON_TILE (1<<9)
210 #define REFRESH_ICON_FONT (1<<10)
211 #define REFRESH_WORKSPACE_BACK (1<<11)
213 #define REFRESH_BUTTON_IMAGES (1<<12)
215 #define REFRESH_ICON_TITLE_COLOR (1<<13)
216 #define REFRESH_ICON_TITLE_BACK (1<<14)
220 static WOptionEnumeration seFocusModes
[] = {
221 {"Manual", WKF_CLICK
, 0}, {"ClickToFocus", WKF_CLICK
, 1},
222 {"Auto", WKF_POINTER
, 0}, {"FocusFollowMouse", WKF_POINTER
, 1},
223 {"Sloppy", WKF_SLOPPY
, 0}, {"SemiAuto", WKF_SLOPPY
, 1},
227 static WOptionEnumeration seColormapModes
[] = {
228 {"Manual", WKF_CLICK
, 0}, {"ClickToFocus", WKF_CLICK
, 1},
229 {"Auto", WKF_POINTER
, 0}, {"FocusFollowMouse", WKF_POINTER
, 1},
233 static WOptionEnumeration sePlacements
[] = {
234 {"Auto", WPM_AUTO
, 0}, {"Smart", WPM_SMART
, 0},
235 {"Cascade", WPM_CASCADE
, 0},
236 {"Random", WPM_RANDOM
, 0},
237 {"Manual", WPM_MANUAL
, 0},
241 static WOptionEnumeration seGeomDisplays
[] = {
242 {"Center", WDIS_CENTER
, 0},
243 {"Corner", WDIS_TOPLEFT
, 0},
244 {"Floating", WDIS_FRAME_CENTER
, 0},
245 {"Line", WDIS_NEW
, 0},
249 static WOptionEnumeration seSpeeds
[] = {
250 {"UltraFast", SPEED_ULTRAFAST
, 0},
251 {"Fast", SPEED_FAST
, 0},
252 {"Medium", SPEED_MEDIUM
, 0},
253 {"Slow", SPEED_SLOW
, 0},
254 {"UltraSlow", SPEED_ULTRASLOW
, 0},
258 static WOptionEnumeration seMouseButtons
[] = {
260 {"Left", Button1
, 0}, {"Button1", Button1
, 1},
261 {"Middle", Button2
, 0}, {"Button2", Button2
, 1},
262 {"Right", Button3
, 0}, {"Button3", Button3
, 1},
263 {"Button4", Button4
, 0},
264 {"Button5", Button5
, 0},
268 static WOptionEnumeration seIconificationStyles
[] = {
269 {"Zoom", WIS_ZOOM
, 0},
270 {"Twist", WIS_TWIST
, 0},
271 {"Flip", WIS_FLIP
, 0},
272 {"None", WIS_NONE
, 0},
273 {"random", WIS_RANDOM
, 0},
277 static WOptionEnumeration seJustifications
[] = {
278 {"Left", WTJ_LEFT
, 0},
279 {"Center", WTJ_CENTER
, 0},
280 {"Right", WTJ_RIGHT
, 0},
284 static WOptionEnumeration seIconPositions
[] = {
285 {"blv", IY_BOTTOM
|IY_LEFT
|IY_VERT
, 0},
286 {"blh", IY_BOTTOM
|IY_LEFT
|IY_HORIZ
, 0},
287 {"brv", IY_BOTTOM
|IY_RIGHT
|IY_VERT
, 0},
288 {"brh", IY_BOTTOM
|IY_RIGHT
|IY_HORIZ
, 0},
289 {"tlv", IY_TOP
|IY_LEFT
|IY_VERT
, 0},
290 {"tlh", IY_TOP
|IY_LEFT
|IY_HORIZ
, 0},
291 {"trv", IY_TOP
|IY_RIGHT
|IY_VERT
, 0},
292 {"trh", IY_TOP
|IY_RIGHT
|IY_HORIZ
, 0},
296 static WOptionEnumeration seMenuStyles
[] = {
297 {"normal", MS_NORMAL
, 0},
298 {"singletexture", MS_SINGLE_TEXTURE
, 0},
299 {"flat", MS_FLAT
, 0},
304 static WOptionEnumeration seDisplayPositions
[] = {
305 {"none", WD_NONE
, 0},
306 {"center", WD_CENTER
, 0},
308 {"bottom", WD_BOTTOM
, 0},
309 {"topleft", WD_TOPLEFT
, 0},
310 {"topright", WD_TOPRIGHT
, 0},
311 {"bottomleft", WD_BOTTOMLEFT
, 0},
312 {"bottomright", WD_BOTTOMRIGHT
, 0}
317 * ALL entries in the tables bellow, NEED to have a default value
318 * defined, and this value needs to be correct.
321 /* these options will only affect the window manager on startup
323 * static defaults can't access the screen data, because it is
324 * created after these defaults are read
326 WDefaultEntry staticOptionList
[] = {
328 {"DisableDithering", "NO", NULL
,
329 &wPreferences
.no_dithering
, getBool
, NULL
331 {"ColormapSize", "4", NULL
,
332 &wPreferences
.cmap_size
, getInt
, NULL
334 /* static by laziness */
335 {"IconSize", "64", NULL
,
336 &wPreferences
.icon_size
, getInt
, NULL
338 {"ModifierKey", "Mod1", NULL
,
339 &wPreferences
.modifier_mask
, getModMask
, NULL
341 {"DisableWSMouseActions", "NO", NULL
,
342 &wPreferences
.disable_root_mouse
, getBool
, NULL
344 {"FocusMode", "manual", seFocusModes
,
345 &wPreferences
.focus_mode
, getEnum
, NULL
346 }, /* have a problem when switching from manual to sloppy without restart */
347 {"NewStyle", "NO", NULL
,
348 &wPreferences
.new_style
, getBool
, NULL
350 {"DisableDock", "NO", (void*) WM_DOCK
,
351 NULL
, getBool
, setIfDockPresent
353 {"DisableClip", "NO", (void*) WM_CLIP
,
354 NULL
, getBool
, setIfDockPresent
356 {"DisableMiniwindows", "NO", NULL
,
357 &wPreferences
.disable_miniwindows
, getBool
, NULL
359 {"MultiByteText", "NO", NULL
,
360 &wPreferences
.multi_byte_text
, getBool
, setMultiByte
366 WDefaultEntry optionList
[] = {
367 /* dynamic options */
368 {"IconPosition", "blh", seIconPositions
,
369 &wPreferences
.icon_yard
, getEnum
, setIconPosition
371 {"IconificationStyle", "Zoom", seIconificationStyles
,
372 &wPreferences
.iconification_style
, getEnum
, NULL
374 {"SelectWindowsMouseButton", "Left", seMouseButtons
,
375 &wPreferences
.select_button
, getEnum
, NULL
377 {"WindowListMouseButton", "Middle", seMouseButtons
,
378 &wPreferences
.windowl_button
, getEnum
, NULL
380 {"ApplicationMenuMouseButton", "Right", seMouseButtons
,
381 &wPreferences
.menu_button
, getEnum
, NULL
383 {"PixmapPath", DEF_PIXMAP_PATHS
, NULL
,
384 &wPreferences
.pixmap_path
, getPathList
, NULL
386 {"IconPath", DEF_ICON_PATHS
, NULL
,
387 &wPreferences
.icon_path
, getPathList
, NULL
389 {"ColormapMode", "auto", seColormapModes
,
390 &wPreferences
.colormap_mode
, getEnum
, NULL
392 {"AutoFocus", "NO", NULL
,
393 &wPreferences
.auto_focus
, getBool
, NULL
395 {"RaiseDelay", "0", NULL
,
396 &wPreferences
.raise_delay
, getInt
, NULL
398 {"CirculateRaise", "NO", NULL
,
399 &wPreferences
.circ_raise
, getBool
, NULL
401 {"Superfluous", "NO", NULL
,
402 &wPreferences
.superfluous
, getBool
, NULL
404 {"AdvanceToNewWorkspace", "NO", NULL
,
405 &wPreferences
.ws_advance
, getBool
, NULL
407 {"CycleWorkspaces", "NO", NULL
,
408 &wPreferences
.ws_cycle
, getBool
, NULL
410 {"WorkspaceNameDisplayPosition", "center", seDisplayPositions
,
411 &wPreferences
.workspace_name_display_position
, getEnum
, NULL
413 {"StickyIcons", "NO", NULL
,
414 &wPreferences
.sticky_icons
, getBool
, setStickyIcons
416 {"SaveSessionOnExit", "NO", NULL
,
417 &wPreferences
.save_session_on_exit
, getBool
, NULL
419 {"WrapMenus", "NO", NULL
,
420 &wPreferences
.wrap_menus
, getBool
, NULL
422 {"ScrollableMenus", "NO", NULL
,
423 &wPreferences
.scrollable_menus
, getBool
, NULL
425 {"MenuScrollSpeed", "medium", seSpeeds
,
426 &wPreferences
.menu_scroll_speed
, getEnum
, NULL
428 {"IconSlideSpeed", "medium", seSpeeds
,
429 &wPreferences
.icon_slide_speed
, getEnum
, NULL
431 {"ShadeSpeed", "medium", seSpeeds
,
432 &wPreferences
.shade_speed
, getEnum
, NULL
434 {"DoubleClickTime", "250", (void*) &wPreferences
.dblclick_time
,
435 &wPreferences
.dblclick_time
, getInt
, setDoubleClick
,
437 {"AlignSubmenus", "NO", NULL
,
438 &wPreferences
.align_menus
, getBool
, NULL
440 {"OpenTransientOnOwnerWorkspace", "NO", NULL
,
441 &wPreferences
.open_transients_with_parent
, getBool
, NULL
443 {"WindowPlacement", "auto", sePlacements
,
444 &wPreferences
.window_placement
, getEnum
, NULL
446 {"IgnoreFocusClick","NO", NULL
,
447 &wPreferences
.ignore_focus_click
, getBool
, NULL
449 {"UseSaveUnders", "NO", NULL
,
450 &wPreferences
.use_saveunders
, getBool
, NULL
452 {"OpaqueMove", "NO", NULL
,
453 &wPreferences
.opaque_move
, getBool
, NULL
455 {"DisableSound", "NO", NULL
,
456 &wPreferences
.no_sound
, getBool
, NULL
458 {"DisableAnimations", "NO", NULL
,
459 &wPreferences
.no_animations
, getBool
, NULL
461 {"DontLinkWorkspaces","NO", NULL
,
462 &wPreferences
.no_autowrap
, getBool
, NULL
464 {"AutoArrangeIcons", "NO", NULL
,
465 &wPreferences
.auto_arrange_icons
, getBool
, NULL
467 {"NoWindowOverDock", "NO", NULL
,
468 &wPreferences
.no_window_over_dock
, getBool
, updateUsableArea
470 {"NoWindowOverIcons", "NO", NULL
,
471 &wPreferences
.no_window_over_icons
, getBool
, updateUsableArea
473 {"WindowPlaceOrigin", "(0, 0)", NULL
,
474 &wPreferences
.window_place_origin
, getCoord
, NULL
476 {"ResizeDisplay", "corner", seGeomDisplays
,
477 &wPreferences
.size_display
, getEnum
, NULL
479 {"MoveDisplay", "corner", seGeomDisplays
,
480 &wPreferences
.move_display
, getEnum
, NULL
482 {"DontConfirmKill", "NO", NULL
,
483 &wPreferences
.dont_confirm_kill
, getBool
,NULL
485 {"WindowTitleBalloons", "NO", NULL
,
486 &wPreferences
.window_balloon
, getBool
, NULL
488 {"MiniwindowTitleBalloons", "NO", NULL
,
489 &wPreferences
.miniwin_balloon
,getBool
, NULL
491 {"AppIconBalloons", "NO", NULL
,
492 &wPreferences
.appicon_balloon
,getBool
, NULL
494 {"HelpBalloons", "NO", NULL
,
495 &wPreferences
.help_balloon
, getBool
, NULL
497 {"EdgeResistance", "30", NULL
,
498 &wPreferences
.edge_resistance
,getInt
, NULL
500 {"Attraction", "NO", NULL
,
501 &wPreferences
.attract
, getBool
, NULL
503 {"DisableBlinking", "NO", NULL
,
504 &wPreferences
.dont_blink
, getBool
, NULL
506 #ifdef WEENDOZE_CYCLE
507 {"WindozeCycling","NO", NULL
,
508 &wPreferences
.windoze_cycling
, getBool
, NULL
510 {"PopupSwitchMenu","YES", NULL
,
511 &wPreferences
.popup_switchmenu
, getBool
, NULL
513 #endif /* WEENDOZE_CYCLE */
515 {"MenuStyle", "normal", seMenuStyles
,
516 &wPreferences
.menu_style
, getEnum
, setMenuStyle
518 {"WidgetColor", "(solid, gray)", NULL
,
519 NULL
, getTexture
, setWidgetColor
,
521 {"WorkspaceSpecificBack","()", NULL
,
522 NULL
, getWSSpecificBackground
, setWorkspaceSpecificBack
524 /* WorkspaceBack must come after WorkspaceSpecificBack or
525 * WorkspaceBack wont know WorkspaceSpecificBack was also
526 * specified and 2 copies of wmsetbg will be launched */
527 {"WorkspaceBack", "(solid, black)", NULL
,
528 NULL
, getWSBackground
,setWorkspaceBack
530 {"SmoothWorkspaceBack", "NO", NULL
,
533 {"IconBack", "(solid, gray)", NULL
,
534 NULL
, getTexture
, setIconTile
536 {"TitleJustify", "center", seJustifications
,
537 &wPreferences
.title_justification
, getEnum
, setJustify
539 {"WindowTitleFont", DEF_TITLE_FONT
, NULL
,
540 NULL
, getFont
, setWinTitleFont
,
542 {"MenuTitleFont", DEF_MENU_TITLE_FONT
, NULL
,
543 NULL
, getFont
, setMenuTitleFont
545 {"MenuTextFont", DEF_MENU_ENTRY_FONT
, NULL
,
546 NULL
, getFont
, setMenuTextFont
548 {"IconTitleFont", DEF_ICON_TITLE_FONT
, NULL
,
549 NULL
, getFont
, setIconTitleFont
551 {"ClipTitleFont", DEF_CLIP_TITLE_FONT
, NULL
,
552 NULL
, getFont
, setClipTitleFont
554 {"DisplayFont", DEF_INFO_TEXT_FONT
, NULL
,
555 NULL
, getFont
, setDisplayFont
557 {"LargeDisplayFont",DEF_WORKSPACE_NAME_FONT
, NULL
,
558 NULL
, getFont
, setLargeDisplayFont
560 {"HighlightColor", "white", NULL
,
561 NULL
, getColor
, setHightlight
563 {"HighlightTextColor", "black", NULL
,
564 NULL
, getColor
, setHightlightText
566 {"ClipTitleColor", "black", (void*)CLIP_NORMAL
,
567 NULL
, getColor
, setClipTitleColor
569 {"CClipTitleColor", "\"#454045\"", (void*)CLIP_COLLAPSED
,
570 NULL
, getColor
, setClipTitleColor
572 #ifdef DRAWSTRING_PLUGIN
573 {"FTitleColor", "white", (void*)WS_FOCUSED
,
574 NULL
, getTextRenderer
, setWTitleColor
576 {"PTitleColor", "white", (void*)WS_PFOCUSED
,
577 NULL
, getTextRenderer
, setWTitleColor
579 {"UTitleColor", "black", (void*)WS_UNFOCUSED
,
580 NULL
, getTextRenderer
, setWTitleColor
583 {"FTitleColor", "white", (void*)WS_FOCUSED
,
584 NULL
, getColor
, setWTitleColor
586 {"PTitleColor", "white", (void*)WS_PFOCUSED
,
587 NULL
, getColor
, setWTitleColor
589 {"UTitleColor", "black", (void*)WS_UNFOCUSED
,
590 NULL
, getColor
, setWTitleColor
593 {"FTitleBack", "(solid, black)", NULL
,
594 NULL
, getTexture
, setFTitleBack
596 {"PTitleBack", "(solid, \"#616161\")", NULL
,
597 NULL
, getTexture
, setPTitleBack
599 {"UTitleBack", "(solid, gray)", NULL
,
600 NULL
, getTexture
, setUTitleBack
602 {"ResizebarBack", "(solid, gray)", NULL
,
603 NULL
, getTexture
, setResizebarBack
605 #ifdef DRAWSTRING_PLUGIN
606 {"MenuTitleColor", "white", NULL
,
607 NULL
, getTextRenderer
, setMenuTitleColor
610 {"MenuTitleColor", "white", NULL
,
611 NULL
, getColor
, setMenuTitleColor
614 {"MenuTextColor", "black", NULL
,
615 NULL
, getColor
, setMenuTextColor
617 {"MenuDisabledColor", "\"#616161\"", NULL
,
618 NULL
, getColor
, setMenuDisabledColor
620 {"MenuTitleBack", "(solid, black)", NULL
,
621 NULL
, getTexture
, setMenuTitleBack
623 {"MenuTextBack", "(solid, gray)", NULL
,
624 NULL
, getTexture
, setMenuTextBack
626 {"IconTitleColor", "white", NULL
,
627 NULL
, getColor
, setIconTitleColor
629 {"IconTitleBack", "black", NULL
,
630 NULL
, getColor
, setIconTitleBack
634 {"RootMenuKey", "None", (void*)WKBD_ROOTMENU
,
635 NULL
, getKeybind
, setKeyGrab
637 {"WindowListKey", "None", (void*)WKBD_WINDOWLIST
,
638 NULL
, getKeybind
, setKeyGrab
641 {"WindowMenuKey", "None", (void*)WKBD_WINDOWMENU
,
642 NULL
, getKeybind
, setKeyGrab
644 {"ClipLowerKey", "None", (void*)WKBD_CLIPLOWER
,
645 NULL
, getKeybind
, setKeyGrab
647 {"ClipRaiseKey", "None", (void*)WKBD_CLIPRAISE
,
648 NULL
, getKeybind
, setKeyGrab
650 {"ClipRaiseLowerKey", "None", (void*)WKBD_CLIPRAISELOWER
,
651 NULL
, getKeybind
, setKeyGrab
653 {"MiniaturizeKey", "None", (void*)WKBD_MINIATURIZE
,
654 NULL
, getKeybind
, setKeyGrab
656 {"HideKey", "None", (void*)WKBD_HIDE
,
657 NULL
, getKeybind
, setKeyGrab
659 {"MoveResizeKey", "None", (void*)WKBD_MOVERESIZE
,
660 NULL
, getKeybind
, setKeyGrab
662 {"CloseKey", "None", (void*)WKBD_CLOSE
,
663 NULL
, getKeybind
, setKeyGrab
665 {"MaximizeKey", "None", (void*)WKBD_MAXIMIZE
,
666 NULL
, getKeybind
, setKeyGrab
668 {"VMaximizeKey", "None", (void*)WKBD_VMAXIMIZE
,
669 NULL
, getKeybind
, setKeyGrab
671 {"RaiseKey", "\"Meta+Up\"", (void*)WKBD_RAISE
,
672 NULL
, getKeybind
, setKeyGrab
674 {"LowerKey", "\"Meta+Down\"", (void*)WKBD_LOWER
,
675 NULL
, getKeybind
, setKeyGrab
677 {"RaiseLowerKey", "None", (void*)WKBD_RAISELOWER
,
678 NULL
, getKeybind
, setKeyGrab
680 {"ShadeKey", "None", (void*)WKBD_SHADE
,
681 NULL
, getKeybind
, setKeyGrab
683 {"SelectKey", "None", (void*)WKBD_SELECT
,
684 NULL
, getKeybind
, setKeyGrab
686 {"FocusNextKey", "None", (void*)WKBD_FOCUSNEXT
,
687 NULL
, getKeybind
, setKeyGrab
689 {"FocusPrevKey", "None", (void*)WKBD_FOCUSPREV
,
690 NULL
, getKeybind
, setKeyGrab
692 {"NextWorkspaceKey", "None", (void*)WKBD_NEXTWORKSPACE
,
693 NULL
, getKeybind
, setKeyGrab
695 {"PrevWorkspaceKey", "None", (void*)WKBD_PREVWORKSPACE
,
696 NULL
, getKeybind
, setKeyGrab
698 {"NextWorkspaceLayerKey", "None", (void*)WKBD_NEXTWSLAYER
,
699 NULL
, getKeybind
, setKeyGrab
701 {"PrevWorkspaceLayerKey", "None", (void*)WKBD_PREVWSLAYER
,
702 NULL
, getKeybind
, setKeyGrab
704 {"Workspace1Key", "None", (void*)WKBD_WORKSPACE1
,
705 NULL
, getKeybind
, setKeyGrab
707 {"Workspace2Key", "None", (void*)WKBD_WORKSPACE2
,
708 NULL
, getKeybind
, setKeyGrab
710 {"Workspace3Key", "None", (void*)WKBD_WORKSPACE3
,
711 NULL
, getKeybind
, setKeyGrab
713 {"Workspace4Key", "None", (void*)WKBD_WORKSPACE4
,
714 NULL
, getKeybind
, setKeyGrab
716 {"Workspace5Key", "None", (void*)WKBD_WORKSPACE5
,
717 NULL
, getKeybind
, setKeyGrab
719 {"Workspace6Key", "None", (void*)WKBD_WORKSPACE6
,
720 NULL
, getKeybind
, setKeyGrab
722 {"Workspace7Key", "None", (void*)WKBD_WORKSPACE7
,
723 NULL
, getKeybind
, setKeyGrab
725 {"Workspace8Key", "None", (void*)WKBD_WORKSPACE8
,
726 NULL
, getKeybind
, setKeyGrab
728 {"Workspace9Key", "None", (void*)WKBD_WORKSPACE9
,
729 NULL
, getKeybind
, setKeyGrab
731 {"Workspace10Key", "None", (void*)WKBD_WORKSPACE10
,
732 NULL
, getKeybind
, setKeyGrab
734 {"WindowShortcut1Key","None", (void*)WKBD_WINDOW1
,
735 NULL
, getKeybind
, setKeyGrab
737 {"WindowShortcut2Key","None", (void*)WKBD_WINDOW2
,
738 NULL
, getKeybind
, setKeyGrab
740 {"WindowShortcut3Key","None", (void*)WKBD_WINDOW3
,
741 NULL
, getKeybind
, setKeyGrab
743 {"WindowShortcut4Key","None", (void*)WKBD_WINDOW4
,
744 NULL
, getKeybind
, setKeyGrab
746 #ifdef EXTEND_WINDOWSHORTCUT
747 ,{"WindowShortcut5Key","None", (void*)WKBD_WINDOW5
,
748 NULL
, getKeybind
, setKeyGrab
750 {"WindowShortcut6Key","None", (void*)WKBD_WINDOW6
,
751 NULL
, getKeybind
, setKeyGrab
753 {"WindowShortcut7Key","None", (void*)WKBD_WINDOW7
,
754 NULL
, getKeybind
, setKeyGrab
756 {"WindowShortcut8Key","None", (void*)WKBD_WINDOW8
,
757 NULL
, getKeybind
, setKeyGrab
759 {"WindowShortcut9Key","None", (void*)WKBD_WINDOW9
,
760 NULL
, getKeybind
, setKeyGrab
762 {"WindowShortcut10Key","None", (void*)WKBD_WINDOW10
,
763 NULL
, getKeybind
, setKeyGrab
765 #endif /* EXTEND_WINDOWSHORTCUT */
767 #ifdef KEEP_XKB_LOCK_STATUS
768 ,{"ToggleKbdModeKey", "None", (void*)WKBD_TOGGLE
,
769 NULL
, getKeybind
, setKeyGrab
771 {"KbdModeLock", "NO", NULL
,
772 &wPreferences
.modelock
, getBool
, NULL
774 #endif /* KEEP_XKB_LOCK_STATUS */
779 static void rereadDefaults(void);
786 /* must defer the update because accessing X data from a
787 * signal handler can mess up Xlib */
796 WDefaultEntry
*entry
;
798 PLSetStringCmpHook(StringCompareHook
);
800 for (i
=0; i
<sizeof(optionList
)/sizeof(WDefaultEntry
); i
++) {
801 entry
= &optionList
[i
];
803 entry
->plkey
= PLMakeString(entry
->key
);
804 if (entry
->default_value
)
805 entry
->plvalue
= PLGetProplistWithDescription(entry
->default_value
);
807 entry
->plvalue
= NULL
;
810 for (i
=0; i
<sizeof(staticOptionList
)/sizeof(WDefaultEntry
); i
++) {
811 entry
= &staticOptionList
[i
];
813 entry
->plkey
= PLMakeString(entry
->key
);
814 if (entry
->default_value
)
815 entry
->plvalue
= PLGetProplistWithDescription(entry
->default_value
);
817 entry
->plvalue
= NULL
;
821 wDomainName = PLMakeString(WMDOMAIN_NAME);
822 wAttributeDomainName = PLMakeString(WMATTRIBUTE_DOMAIN_NAME);
824 PLRegister(wDomainName, rereadDefaults);
825 PLRegister(wAttributeDomainName, rereadDefaults);
834 wDefaultsInit(int screen_number
)
836 static int defaults_inited
= 0;
839 if (!defaults_inited
) {
843 dict
= PLGetDomain(wDomainName
);
845 wwarning(_("could not read domain \"%s\" from defaults database"),
846 PLGetString(wDomainName
));
855 wDefaultsDestroyDomain(WDDomain
*domain
)
857 if (domain
->dictionary
)
858 PLRelease(domain
->dictionary
);
865 wDefaultsInitDomain(char *domain
, Bool requireDictionary
)
869 static int inited
= 0;
872 proplist_t shared_dict
=NULL
;
879 db
= wmalloc(sizeof(WDDomain
));
880 memset(db
, 0, sizeof(WDDomain
));
881 db
->domain_name
= domain
;
882 db
->path
= wdefaultspathfordomain(domain
);
885 if (the_path
&& stat(the_path
, &stbuf
)>=0) {
886 db
->dictionary
= ReadProplistFromFile(the_path
);
887 if (db
->dictionary
) {
888 if (requireDictionary
&& !PLIsDictionary(db
->dictionary
)) {
889 PLRelease(db
->dictionary
);
890 db
->dictionary
= NULL
;
891 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
894 db
->timestamp
= stbuf
.st_mtime
;
896 wwarning(_("could not load domain %s from user defaults database"),
901 /* global system dictionary */
902 sprintf(path
, "%s/WindowMaker/%s", SYSCONFDIR
, domain
);
903 if (stat(path
, &stbuf
)>=0) {
904 shared_dict
= ReadProplistFromFile(path
);
906 if (requireDictionary
&& !PLIsDictionary(shared_dict
)) {
907 wwarning(_("Domain %s (%s) of global defaults database is corrupted!"),
909 PLRelease(shared_dict
);
912 if (db
->dictionary
&& PLIsDictionary(shared_dict
) &&
913 PLIsDictionary(db
->dictionary
)) {
914 PLMergeDictionaries(shared_dict
, db
->dictionary
);
915 PLRelease(db
->dictionary
);
916 db
->dictionary
= shared_dict
;
917 if (stbuf
.st_mtime
> db
->timestamp
)
918 db
->timestamp
= stbuf
.st_mtime
;
919 } else if (!db
->dictionary
) {
920 db
->dictionary
= shared_dict
;
921 if (stbuf
.st_mtime
> db
->timestamp
)
922 db
->timestamp
= stbuf
.st_mtime
;
926 wwarning(_("could not load domain %s from global defaults database (%s)"),
931 /* set to save it in user's directory, no matter from where it was read */
932 if (db
->dictionary
) {
933 proplist_t tmp
= PLMakeString(db
->path
);
935 PLSetFilename(db
->dictionary
, tmp
);
944 wReadStaticDefaults(proplist_t dict
)
947 WDefaultEntry
*entry
;
952 for (i
=0; i
<sizeof(staticOptionList
)/sizeof(WDefaultEntry
); i
++) {
953 entry
= &staticOptionList
[i
];
956 plvalue
= PLGetDictionaryEntry(dict
, entry
->plkey
);
961 /* no default in the DB. Use builtin default */
962 plvalue
= entry
->plvalue
;
967 (*entry
->convert
)(NULL
, entry
, plvalue
, entry
->addr
, &tdata
);
969 (*entry
->update
)(NULL
, entry
, tdata
, entry
->extra_data
);
977 wDefaultsCheckDomains(void *foo
)
986 puts("Checking domains...");
988 if (stat(WDWindowMaker
->path
, &stbuf
)>=0
989 && WDWindowMaker
->timestamp
< stbuf
.st_mtime
) {
990 proplist_t shared_dict
= NULL
;
992 puts("Checking WindowMaker domain");
994 WDWindowMaker
->timestamp
= stbuf
.st_mtime
;
996 /* global dictionary */
997 sprintf(path
, "%s/WindowMaker/WindowMaker", SYSCONFDIR
);
998 if (stat(path
, &stbuf
)>=0) {
999 shared_dict
= ReadProplistFromFile(path
);
1000 if (shared_dict
&& !PLIsDictionary(shared_dict
)) {
1001 wwarning(_("Domain %s (%s) of global defaults database is corrupted!"),
1002 "WindowMaker", path
);
1003 PLRelease(shared_dict
);
1005 } else if (!shared_dict
) {
1006 wwarning(_("could not load domain %s from global defaults database"),
1010 /* user dictionary */
1011 dict
= ReadProplistFromFile(WDWindowMaker
->path
);
1013 if (!PLIsDictionary(dict
)) {
1016 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
1017 "WindowMaker", WDWindowMaker
->path
);
1020 PLSetFilename(shared_dict
, PLGetFilename(dict
));
1021 PLMergeDictionaries(shared_dict
, dict
);
1026 for (i
=0; i
<wScreenCount
; i
++) {
1027 scr
= wScreenWithNumber(i
);
1029 wReadDefaults(scr
, dict
);
1031 if (WDWindowMaker
->dictionary
) {
1032 PLRelease(WDWindowMaker
->dictionary
);
1034 WDWindowMaker
->dictionary
= dict
;
1037 wwarning(_("could not load domain %s from user defaults database"),
1041 PLRelease(shared_dict
);
1045 if (stat(WDWindowAttributes
->path
, &stbuf
)>=0
1046 && WDWindowAttributes
->timestamp
< stbuf
.st_mtime
) {
1048 puts("Checking WMWindowAttributes domain");
1050 dict
= ReadProplistFromFile(WDWindowAttributes
->path
);
1052 if (!PLIsDictionary(dict
)) {
1055 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
1056 "WMWindowAttributes", WDWindowAttributes
->path
);
1058 if (WDWindowAttributes
->dictionary
)
1059 PLRelease(WDWindowAttributes
->dictionary
);
1060 WDWindowAttributes
->dictionary
= dict
;
1061 for (i
=0; i
<wScreenCount
; i
++) {
1062 scr
= wScreenWithNumber(i
);
1064 wDefaultUpdateIcons(scr
);
1068 wwarning(_("could not load domain %s from user defaults database"),
1069 "WMWindowAttributes");
1071 WDWindowAttributes
->timestamp
= stbuf
.st_mtime
;
1075 if (stat(WDRootMenu
->path
, &stbuf
)>=0
1076 && WDRootMenu
->timestamp
< stbuf
.st_mtime
) {
1077 dict
= ReadProplistFromFile(WDRootMenu
->path
);
1079 puts("Checking WMRootMenu domain");
1082 if (!PLIsArray(dict
) && !PLIsString(dict
)) {
1085 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
1086 "WMRootMenu", WDRootMenu
->path
);
1088 if (WDRootMenu
->dictionary
) {
1089 PLRelease(WDRootMenu
->dictionary
);
1091 WDRootMenu
->dictionary
= dict
;
1094 wwarning(_("could not load domain %s from user defaults database"),
1097 WDRootMenu
->timestamp
= stbuf
.st_mtime
;
1102 WMAddTimerHandler(DEFAULTS_CHECK_INTERVAL
, wDefaultsCheckDomains
, foo
);
1107 wReadDefaults(WScreen
*scr
, proplist_t new_dict
)
1109 proplist_t plvalue
, old_value
;
1110 WDefaultEntry
*entry
;
1112 int update_workspace_back
= 0; /* kluge :/ */
1115 proplist_t old_dict
= (WDWindowMaker
->dictionary
!=new_dict
1116 ? WDWindowMaker
->dictionary
: NULL
);
1122 for (i
=0; i
<sizeof(optionList
)/sizeof(WDefaultEntry
); i
++) {
1123 entry
= &optionList
[i
];
1126 plvalue
= PLGetDictionaryEntry(new_dict
, entry
->plkey
);
1133 old_value
= PLGetDictionaryEntry(old_dict
, entry
->plkey
);
1136 if (!plvalue
&& !old_value
) {
1137 /* no default in the DB. Use builtin default */
1138 plvalue
= entry
->plvalue
;
1139 if (plvalue
&& new_dict
) {
1140 PLInsertDictionaryEntry(new_dict
, entry
->plkey
, plvalue
);
1143 } else if (!plvalue
) {
1144 /* value was deleted from DB. Keep current value */
1146 } else if (!old_value
) {
1147 /* set value for the 1st time */
1148 } else if (!PLIsEqual(plvalue
, old_value
)) {
1149 /* value has changed */
1152 if (strcmp(entry
->key
, "WorkspaceBack") == 0
1153 && update_workspace_back
1154 && scr
->flags
.backimage_helper_launched
) {
1156 /* value was not changed since last time */
1163 printf("Updating %s to %s\n", entry
->key
,
1164 PLGetDescription(plvalue
));
1167 if ((*entry
->convert
)(scr
, entry
, plvalue
, entry
->addr
, &tdata
)) {
1169 * If the WorkspaceSpecificBack data has been changed
1170 * so that the helper will be launched now, we must be
1171 * sure to send the default background texture config
1174 if (strcmp(entry
->key
, "WorkspaceSpecificBack") == 0
1175 && !scr
->flags
.backimage_helper_launched
) {
1176 update_workspace_back
= 1;
1178 if (entry
->update
) {
1180 (*entry
->update
)(scr
, entry
, tdata
, entry
->extra_data
);
1186 if (needs_refresh
!=0 && !scr
->flags
.startup
) {
1190 if (needs_refresh
& REFRESH_MENU_TITLE_TEXTURE
)
1191 foo
|= WTextureSettings
;
1192 if (needs_refresh
& REFRESH_MENU_TITLE_FONT
)
1193 foo
|= WFontSettings
;
1194 if (needs_refresh
& REFRESH_MENU_TITLE_COLOR
)
1195 foo
|= WColorSettings
;
1197 WMPostNotificationName(WNMenuTitleAppearanceSettingsChanged
, NULL
,
1201 if (needs_refresh
& REFRESH_MENU_TEXTURE
)
1202 foo
|= WTextureSettings
;
1203 if (needs_refresh
& REFRESH_MENU_FONT
)
1204 foo
|= WFontSettings
;
1205 if (needs_refresh
& REFRESH_MENU_COLOR
)
1206 foo
|= WColorSettings
;
1208 WMPostNotificationName(WNMenuAppearanceSettingsChanged
, NULL
,
1212 if (needs_refresh
& REFRESH_WINDOW_FONT
) {
1213 foo
|= WFontSettings
;
1215 if (needs_refresh
& REFRESH_WINDOW_TEXTURES
) {
1216 foo
|= WTextureSettings
;
1218 if (needs_refresh
& REFRESH_WINDOW_TITLE_COLOR
) {
1219 foo
|= WColorSettings
;
1222 WMPostNotificationName(WNWindowAppearanceSettingsChanged
, NULL
,
1225 if (!(needs_refresh
& REFRESH_ICON_TILE
)) {
1227 if (needs_refresh
& REFRESH_ICON_FONT
) {
1228 foo
|= WFontSettings
;
1230 if (needs_refresh
& REFRESH_ICON_TITLE_COLOR
) {
1231 foo
|= WTextureSettings
;
1233 if (needs_refresh
& REFRESH_ICON_TITLE_BACK
) {
1234 foo
|= WTextureSettings
;
1237 WMPostNotificationName(WNIconAppearanceSettingsChanged
, NULL
,
1240 if (needs_refresh
& REFRESH_ICON_TILE
)
1241 WMPostNotificationName(WNIconTileSettingsChanged
, NULL
, NULL
);
1247 wDefaultUpdateIcons(WScreen
*scr
)
1249 WAppIcon
*aicon
= scr
->app_icon_list
;
1250 WWindow
*wwin
= scr
->focused_window
;
1254 file
= wDefaultGetIconFile(scr
, aicon
->wm_instance
, aicon
->wm_class
,
1256 if ((file
&& aicon
->icon
->file
&& strcmp(file
, aicon
->icon
->file
)!=0)
1257 || (file
&& !aicon
->icon
->file
)) {
1260 if (aicon
->icon
->file
)
1261 free(aicon
->icon
->file
);
1262 aicon
->icon
->file
= wstrdup(file
);
1264 new_image
= wDefaultGetImage(scr
, aicon
->wm_instance
,
1267 wIconChangeImage(aicon
->icon
, new_image
);
1268 wAppIconPaint(aicon
);
1271 aicon
= aicon
->next
;
1274 if (!wPreferences
.flags
.noclip
)
1275 wClipIconPaint(scr
->clip_icon
);
1278 if (wwin
->icon
&& wwin
->flags
.miniaturized
) {
1279 file
= wDefaultGetIconFile(scr
, wwin
->wm_instance
, wwin
->wm_class
,
1281 if ((file
&& wwin
->icon
->file
&& strcmp(file
, wwin
->icon
->file
)!=0)
1282 || (file
&& !wwin
->icon
->file
)) {
1285 if (wwin
->icon
->file
)
1286 free(wwin
->icon
->file
);
1287 wwin
->icon
->file
= wstrdup(file
);
1289 new_image
= wDefaultGetImage(scr
, wwin
->wm_instance
,
1292 wIconChangeImage(wwin
->icon
, new_image
);
1300 /* --------------------------- Local ----------------------- */
1302 #define STRINGP(x) if (!PLIsString(value)) { \
1303 wwarning(_("Wrong option format for key \"%s\". Should be %s."), \
1310 string2index(proplist_t key
, proplist_t val
, proplist_t def
,
1311 WOptionEnumeration
*values
)
1314 WOptionEnumeration
*v
;
1315 char buffer
[TOTAL_VALUES_LENGTH
];
1317 if (PLIsString(val
) && (str
= PLGetString(val
))) {
1318 for (v
=values
; v
->string
!=NULL
; v
++) {
1319 if (strcasecmp(v
->string
, str
)==0)
1325 for (v
=values
; v
->string
!=NULL
; v
++) {
1328 strcat(buffer
, ", ");
1329 strcat(buffer
, v
->string
);
1332 wwarning(_("wrong option value for key \"%s\". Should be one of %s"),
1333 PLGetString(key
), buffer
);
1336 return string2index(key
, val
, NULL
, values
);
1346 * value - is the value in the defaults DB
1347 * addr - is the address to store the data
1348 * ret - is the address to store a pointer to a temporary buffer. ret
1349 * must not be freed and is used by the set functions
1352 getBool(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
1361 val
= PLGetString(value
);
1364 if ((val
[1]=='\0' && (val
[0]=='y' || val
[0]=='Y'))
1365 || strcasecmp(val
, "YES")==0) {
1368 } else if ((val
[1]=='\0' && (val
[0]=='n' || val
[0]=='N'))
1369 || strcasecmp(val
, "NO")==0) {
1373 if (sscanf(val
, "%i", &i
)==1) {
1379 wwarning(_("can't convert \"%s\" to boolean for key \"%s\""),
1381 if (second_pass
==0) {
1382 val
= PLGetString(entry
->plvalue
);
1384 wwarning(_("using default \"%s\" instead"), val
);
1395 *(char*)addr
= data
;
1403 getInt(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
1412 val
= PLGetString(value
);
1414 if (sscanf(val
, "%i", &data
)!=1) {
1415 wwarning(_("can't convert \"%s\" to integer for key \"%s\""),
1417 val
= PLGetString(entry
->plvalue
);
1418 wwarning(_("using default \"%s\" instead"), val
);
1419 if (sscanf(val
, "%i", &data
)!=1) {
1435 getCoord(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
1439 char *val_x
, *val_y
;
1440 int nelem
, changed
=0;
1441 proplist_t elem_x
, elem_y
;
1444 if (!PLIsArray(value
)) {
1445 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1446 entry
->key
, "Coordinate");
1448 value
= entry
->plvalue
;
1450 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1456 nelem
= PLGetNumberOfElements(value
);
1458 wwarning(_("Incorrect number of elements in array for key \"%s\"."),
1461 value
= entry
->plvalue
;
1463 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1469 elem_x
= PLGetArrayElement(value
, 0);
1470 elem_y
= PLGetArrayElement(value
, 1);
1472 if (!elem_x
|| !elem_y
|| !PLIsString(elem_x
) || !PLIsString(elem_y
)) {
1473 wwarning(_("Wrong value for key \"%s\". Should be Coordinate."),
1476 value
= entry
->plvalue
;
1478 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1484 val_x
= PLGetString(elem_x
);
1485 val_y
= PLGetString(elem_y
);
1487 if (sscanf(val_x
, "%i", &data
.x
)!=1 || sscanf(val_y
, "%i", &data
.y
)!=1) {
1488 wwarning(_("can't convert array to integers for \"%s\"."), entry
->key
);
1490 value
= entry
->plvalue
;
1492 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1500 else if (data
.x
> scr
->scr_width
/3)
1501 data
.x
= scr
->scr_width
/3;
1504 else if (data
.y
> scr
->scr_height
/3)
1505 data
.y
= scr
->scr_height
/3;
1511 *(WCoord
*)addr
= data
;
1519 /* This function is not used at the moment. */
1521 getString(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
1528 data
= PLGetString(value
);
1531 data
= PLGetString(entry
->plvalue
);
1540 *(char**)addr
= wstrdup(data
);
1548 getPathList(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
1558 if (!PLIsArray(value
)) {
1559 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1560 entry
->key
, "an array of paths");
1562 value
= entry
->plvalue
;
1564 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1571 count
= PLGetNumberOfElements(value
);
1574 value
= entry
->plvalue
;
1576 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1583 for (i
=0; i
<count
; i
++) {
1584 d
= PLGetArrayElement(value
, i
);
1585 if (!d
|| !PLIsString(d
)) {
1589 len
+= strlen(PLGetString(d
))+1;
1592 ptr
= data
= wmalloc(len
+1);
1594 for (i
=0; i
<count
; i
++) {
1595 d
= PLGetArrayElement(value
, i
);
1596 if (!d
|| !PLIsString(d
)) {
1599 strcpy(ptr
, PLGetString(d
));
1600 ptr
+= strlen(PLGetString(d
));
1604 ptr
--; *(ptr
--) = 0;
1606 if (*(char**)addr
!=NULL
) {
1607 free(*(char**)addr
);
1609 *(char**)addr
= data
;
1616 getEnum(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
1619 static signed char data
;
1621 data
= string2index(entry
->plkey
, value
, entry
->default_value
,
1622 (WOptionEnumeration
*)entry
->extra_data
);
1630 *(signed char*)addr
= data
;
1639 * (hgradient <color> <color>)
1640 * (vgradient <color> <color>)
1641 * (dgradient <color> <color>)
1642 * (mhgradient <color> <color> ...)
1643 * (mvgradient <color> <color> ...)
1644 * (tpixmap <file> <color>)
1645 * (spixmap <file> <color>)
1646 * (cpixmap <file> <color>)
1647 * (thgradient <file> <opaqueness> <color> <color>)
1648 * (tvgradient <file> <opaqueness> <color> <color>)
1649 * (tdgradient <file> <opaqueness> <color> <color>)
1650 * (function <lib> <function> ...)
1654 parse_texture(WScreen
*scr
, proplist_t pl
)
1659 WTexture
*texture
=NULL
;
1661 nelem
= PLGetNumberOfElements(pl
);
1666 elem
= PLGetArrayElement(pl
, 0);
1667 if (!elem
|| !PLIsString(elem
))
1669 val
= PLGetString(elem
);
1672 if (strcasecmp(val
, "solid")==0) {
1680 elem
= PLGetArrayElement(pl
, 1);
1681 if (!elem
|| !PLIsString(elem
))
1683 val
= PLGetString(elem
);
1685 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &color
)) {
1686 wwarning(_("\"%s\" is not a valid color name"), val
);
1690 texture
= (WTexture
*)wTextureMakeSolid(scr
, &color
);
1691 } else if (strcasecmp(val
, "dgradient")==0
1692 || strcasecmp(val
, "vgradient")==0
1693 || strcasecmp(val
, "hgradient")==0) {
1694 RColor color1
, color2
;
1699 wwarning(_("bad number of arguments in gradient specification"));
1703 if (val
[0]=='d' || val
[0]=='D')
1704 type
= WTEX_DGRADIENT
;
1705 else if (val
[0]=='h' || val
[0]=='H')
1706 type
= WTEX_HGRADIENT
;
1708 type
= WTEX_VGRADIENT
;
1711 /* get from color */
1712 elem
= PLGetArrayElement(pl
, 1);
1713 if (!elem
|| !PLIsString(elem
))
1715 val
= PLGetString(elem
);
1717 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1718 wwarning(_("\"%s\" is not a valid color name"), val
);
1722 color1
.red
= xcolor
.red
>> 8;
1723 color1
.green
= xcolor
.green
>> 8;
1724 color1
.blue
= xcolor
.blue
>> 8;
1727 elem
= PLGetArrayElement(pl
, 2);
1728 if (!elem
|| !PLIsString(elem
)) {
1731 val
= PLGetString(elem
);
1733 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1734 wwarning(_("\"%s\" is not a valid color name"), val
);
1738 color2
.red
= xcolor
.red
>> 8;
1739 color2
.green
= xcolor
.green
>> 8;
1740 color2
.blue
= xcolor
.blue
>> 8;
1742 texture
= (WTexture
*)wTextureMakeGradient(scr
, type
, &color1
, &color2
);
1744 } else if (strcasecmp(val
, "mhgradient")==0
1745 || strcasecmp(val
, "mvgradient")==0
1746 || strcasecmp(val
, "mdgradient")==0) {
1753 wwarning(_("too few arguments in multicolor gradient specification"));
1757 if (val
[1]=='h' || val
[1]=='H')
1758 type
= WTEX_MHGRADIENT
;
1759 else if (val
[1]=='v' || val
[1]=='V')
1760 type
= WTEX_MVGRADIENT
;
1762 type
= WTEX_MDGRADIENT
;
1766 colors
= wmalloc(sizeof(RColor
*)*(count
+1));
1768 for (i
=0; i
<count
; i
++) {
1769 elem
= PLGetArrayElement(pl
, i
+1);
1770 if (!elem
|| !PLIsString(elem
)) {
1771 for (--i
; i
>=0; --i
) {
1777 val
= PLGetString(elem
);
1779 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &color
)) {
1780 wwarning(_("\"%s\" is not a valid color name"), val
);
1781 for (--i
; i
>=0; --i
) {
1787 colors
[i
] = wmalloc(sizeof(RColor
));
1788 colors
[i
]->red
= color
.red
>> 8;
1789 colors
[i
]->green
= color
.green
>> 8;
1790 colors
[i
]->blue
= color
.blue
>> 8;
1795 texture
= (WTexture
*)wTextureMakeMGradient(scr
, type
, colors
);
1796 } else if (strcasecmp(val
, "spixmap")==0 ||
1797 strcasecmp(val
, "cpixmap")==0 ||
1798 strcasecmp(val
, "tpixmap")==0) {
1805 if (val
[0] == 's' || val
[0] == 'S')
1807 else if (val
[0] == 'c' || val
[0] == 'C')
1813 elem
= PLGetArrayElement(pl
, 2);
1814 if (!elem
|| !PLIsString(elem
)) {
1817 val
= PLGetString(elem
);
1819 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &color
)) {
1820 wwarning(_("\"%s\" is not a valid color name"), val
);
1825 elem
= PLGetArrayElement(pl
, 1);
1826 if (!elem
|| !PLIsString(elem
))
1828 val
= PLGetString(elem
);
1830 texture
= (WTexture
*)wTextureMakePixmap(scr
, type
, val
, &color
);
1831 } else if (strcasecmp(val
, "thgradient")==0
1832 || strcasecmp(val
, "tvgradient")==0
1833 || strcasecmp(val
, "tdgradient")==0) {
1834 RColor color1
, color2
;
1839 if (val
[1]=='h' || val
[1]=='H')
1840 style
= WTEX_THGRADIENT
;
1841 else if (val
[1]=='v' || val
[1]=='V')
1842 style
= WTEX_TVGRADIENT
;
1844 style
= WTEX_TDGRADIENT
;
1847 wwarning(_("bad number of arguments in textured gradient specification"));
1851 /* get from color */
1852 elem
= PLGetArrayElement(pl
, 3);
1853 if (!elem
|| !PLIsString(elem
))
1855 val
= PLGetString(elem
);
1857 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1858 wwarning(_("\"%s\" is not a valid color name"), val
);
1862 color1
.red
= xcolor
.red
>> 8;
1863 color1
.green
= xcolor
.green
>> 8;
1864 color1
.blue
= xcolor
.blue
>> 8;
1867 elem
= PLGetArrayElement(pl
, 4);
1868 if (!elem
|| !PLIsString(elem
)) {
1871 val
= PLGetString(elem
);
1873 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1874 wwarning(_("\"%s\" is not a valid color name"), val
);
1878 color2
.red
= xcolor
.red
>> 8;
1879 color2
.green
= xcolor
.green
>> 8;
1880 color2
.blue
= xcolor
.blue
>> 8;
1883 elem
= PLGetArrayElement(pl
, 2);
1884 if (!elem
|| !PLIsString(elem
))
1887 val
= PLGetString(elem
);
1889 if (!val
|| (opacity
= atoi(val
)) < 0 || opacity
> 255) {
1890 wwarning(_("bad opacity value for tgradient texture \"%s\". Should be [0..255]"), val
);
1895 elem
= PLGetArrayElement(pl
, 1);
1896 if (!elem
|| !PLIsString(elem
))
1898 val
= PLGetString(elem
);
1900 texture
= (WTexture
*)wTextureMakeTGradient(scr
, style
, &color1
, &color2
,
1903 #ifdef TEXTURE_PLUGIN
1904 else if (strcasecmp(val
, "function")==0) {
1905 WTexFunction
*function
;
1906 void (*initFunc
) (Display
*, Colormap
);
1907 char *lib
, *func
, **argv
;
1913 /* get the library name */
1914 elem
= PLGetArrayElement(pl
, 1);
1915 if (!elem
|| !PLIsString(elem
)) {
1918 lib
= PLGetString(elem
);
1920 /* get the function name */
1921 elem
= PLGetArrayElement(pl
, 2);
1922 if (!elem
|| !PLIsString(elem
)) {
1925 func
= PLGetString(elem
);
1928 argv
= (char **)wmalloc(argc
* sizeof(char *));
1930 /* get the parameters */
1931 argv
[0] = wstrdup(func
);
1932 for (i
= 0; i
< argc
- 1; i
++) {
1933 elem
= PLGetArrayElement(pl
, 3 + i
);
1934 if (!elem
|| !PLIsString(elem
)) {
1939 argv
[i
+1] = wstrdup(PLGetString(elem
));
1942 function
= wTextureMakeFunction(scr
, lib
, func
, argc
, argv
);
1946 initFunc
= dlsym(function
->handle
, "initWindowMaker");
1948 initFunc(dpy
, scr
->w_colormap
);
1950 wwarning(_("could not initialize library %s"), lib
);
1953 wwarning(_("could not find function %s::%s"), lib
, func
);
1955 #endif /* HAVE_DLFCN_H */
1956 texture
= (WTexture
*)function
;
1958 #endif /* TEXTURE_PLUGIN */
1960 wwarning(_("invalid texture type %s"), val
);
1969 getTexture(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
1972 static WTexture
*texture
;
1976 if (!PLIsArray(value
)) {
1977 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1978 entry
->key
, "Texture");
1980 value
= entry
->plvalue
;
1982 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1988 if (strcmp(entry
->key
, "WidgetColor")==0 && !changed
) {
1991 pl
= PLGetArrayElement(value
, 0);
1992 if (!pl
|| !PLIsString(pl
) || !PLGetString(pl
)
1993 || strcasecmp(PLGetString(pl
), "solid")!=0) {
1994 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1995 entry
->key
, "Solid Texture");
1997 value
= entry
->plvalue
;
1999 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
2004 texture
= parse_texture(scr
, value
);
2007 wwarning(_("Error in texture specification for key \"%s\""),
2010 value
= entry
->plvalue
;
2012 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
2022 *(WTexture
**)addr
= texture
;
2029 #ifdef DRAWSTRING_PLUGIN
2031 getTextRenderer(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
,
2032 void *addr
, void **ret
)
2035 char *val
, *lib
, *func
, **argv
;
2038 if (strcmp(entry
->key
, "FTitleColor")==0) {
2039 wPluginDestroyFunction(scr
->drawstring_func
[changed
= W_STRING_FTITLE
]);
2040 scr
->drawstring_func
[W_STRING_FTITLE
] = NULL
;
2041 } else if (strcmp(entry
->key
, "UTitleColor")==0) {
2042 wPluginDestroyFunction(scr
->drawstring_func
[changed
= W_STRING_UTITLE
]);
2043 scr
->drawstring_func
[W_STRING_UTITLE
] = NULL
;
2044 } else if (strcmp(entry
->key
, "PTitleColor")==0) {
2045 wPluginDestroyFunction(scr
->drawstring_func
[changed
= W_STRING_PTITLE
]);
2046 scr
->drawstring_func
[W_STRING_PTITLE
] = NULL
;
2047 } else if (strcmp(entry
->key
, "MenuTitleColor")==0) {
2048 wPluginDestroyFunction(scr
->drawstring_func
[changed
= W_STRING_MTITLE
]);
2049 scr
->drawstring_func
[W_STRING_MTITLE
] = NULL
;
2050 } else if (strcmp(entry
->key
, "MenuPluginColor")==0) {
2051 wPluginDestroyFunction(scr
->drawstring_func
[changed
= W_STRING_MTEXT
]);
2052 scr
->drawstring_func
[W_STRING_MTEXT
] = NULL
;
2055 if (PLIsArray(value
)) {
2056 if ((argc
= PLGetNumberOfElements(value
)) < 4) return False
;
2058 argv
= (char **)wmalloc(argc
* sizeof(char *));
2060 elem
= PLGetArrayElement(value
,0);
2061 if (!elem
|| !PLIsString(elem
)) return False
;
2062 val
= PLGetString(elem
);
2063 if (strcasecmp(val
, "function")==0) {
2064 elem
= PLGetArrayElement(value
, 1); /* library name */
2065 if (!elem
|| !PLIsString(elem
)) return False
;
2066 lib
= PLGetString(elem
);
2067 elem
= PLGetArrayElement(value
, 2); /* function name */
2068 if (!elem
|| !PLIsString(elem
)) return False
;
2069 func
= PLGetString(elem
);
2070 scr
->drawstring_func
[changed
] = wPluginCreateFunction (W_FUNCTION_DRAWSTRING
,
2071 lib
, "initDrawString", func
, NULL
, value
,
2072 wPluginPackInitData(3, dpy
, scr
->w_colormap
,"-DATA-"));
2075 return getColor(scr
, entry
, PLGetArrayElement(value
,3), addr
, ret
);
2076 } else if (PLIsString(value
)) {
2077 return getColor(scr
, entry
, value
, addr
, ret
);
2082 #endif /* DRAWSTRING_PLUGIN */
2087 getWSBackground(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
,
2088 void *addr
, void **ret
)
2096 if (!PLIsArray(value
)) {
2097 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
2098 "WorkspaceBack", "Texture or None");
2100 value
= entry
->plvalue
;
2102 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
2108 /* only do basic error checking and verify for None texture */
2110 nelem
= PLGetNumberOfElements(value
);
2112 elem
= PLGetArrayElement(value
, 0);
2113 if (!elem
|| !PLIsString(elem
)) {
2114 wwarning(_("Wrong type for workspace background. Should be a texture type."));
2116 value
= entry
->plvalue
;
2118 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
2123 val
= PLGetString(elem
);
2125 if (strcasecmp(val
, "None")==0)
2128 *ret
= PLRetain(value
);
2135 getWSSpecificBackground(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
,
2136 void *addr
, void **ret
)
2143 if (!PLIsArray(value
)) {
2144 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
2145 "WorkspaceSpecificBack", "an array of textures");
2147 value
= entry
->plvalue
;
2149 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
2155 /* only do basic error checking and verify for None texture */
2157 nelem
= PLGetNumberOfElements(value
);
2160 elem
= PLGetArrayElement(value
, nelem
);
2161 if (!elem
|| !PLIsArray(elem
)) {
2162 wwarning(_("Wrong type for background of workspace %i. Should be a texture."),
2168 *ret
= PLRetain(value
);
2172 * Kluge to force wmsetbg helper to set the default background.
2173 * If the WorkspaceSpecificBack is changed once wmaker has started,
2174 * the WorkspaceBack won't be sent to the helper, unless the user
2175 * changes it's value too. So, we must force this by removing the
2176 * value from the defaults DB.
2178 if (!scr
->flags
.backimage_helper_launched
&& !scr
->flags
.startup
) {
2179 proplist_t key
= PLMakeString("WorkspaceBack");
2181 PLRemoveDictionaryEntry(WDWindowMaker
->dictionary
, key
);
2191 getFont(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
2194 static WMFont
*font
;
2199 val
= PLGetString(value
);
2201 font
= WMCreateFont(scr
->wmscreen
, val
);
2203 font
= WMCreateFont(scr
->wmscreen
, "fixed");
2206 wfatal(_("could not load any usable font!!!"));
2213 /* can't assign font value outside update function */
2214 wassertrv(addr
== NULL
, True
);
2221 getColor(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
2224 static XColor color
;
2230 val
= PLGetString(value
);
2233 if (!wGetColor(scr
, val
, &color
)) {
2234 wwarning(_("could not get color for key \"%s\""),
2236 if (second_pass
==0) {
2237 val
= PLGetString(entry
->plvalue
);
2239 wwarning(_("using default \"%s\" instead"), val
);
2251 *(unsigned long*)addr = pixel;
2260 getKeybind(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
2263 static WShortKey shortcut
;
2270 STRINGP("Key spec");
2272 val
= PLGetString(value
);
2274 if (!val
|| strcasecmp(val
, "NONE")==0) {
2275 shortcut
.keycode
= 0;
2276 shortcut
.modifier
= 0;
2287 shortcut
.modifier
= 0;
2288 while ((k
= strchr(b
, '+'))!=NULL
) {
2292 mod
= wXModifierFromKey(b
);
2294 wwarning(_("%s:invalid key modifier \"%s\""), entry
->key
, b
);
2297 shortcut
.modifier
|= mod
;
2303 ksym
= XStringToKeysym(b
);
2305 if (ksym
==NoSymbol
) {
2306 wwarning(_("%s:invalid kbd shortcut specification \"%s\""), entry
->key
,
2311 shortcut
.keycode
= XKeysymToKeycode(dpy
, ksym
);
2312 if (shortcut
.keycode
==0) {
2313 wwarning(_("%s:invalid key in shortcut \"%s\""), entry
->key
, val
);
2325 getModMask(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
2328 static unsigned int mask
;
2331 STRINGP("Modifier Key");
2333 str
= PLGetString(value
);
2337 mask
= wXModifierFromKey(str
);
2339 wwarning(_("%s: modifier key %s is not valid"), entry
->key
, str
);
2345 *(unsigned int*)addr
= mask
;
2356 getRImages(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
,
2357 void *addr
, void **ret
)
2365 STRINGP("Image File Path");
2367 str
= PLGetString(value
);
2371 image
= RLoadImage(scr
->rcontext
, str
, 0);
2373 wwarning(_("could not load image in option %s: %s"), entry
->key
,
2374 RMessageForError(RErrorCode
));
2378 if (*(RImage
**)addr
) {
2379 RDestroyImage(*(RImage
**)addr
);
2382 *(RImage
**)addr
= image
;
2384 assert(ret
== NULL
);
2387 *(RImage**)ret = image;
2395 /* ---------------- value setting functions --------------- */
2397 setJustify(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
2399 return REFRESH_WINDOW_TITLE_COLOR
;
2404 setIfDockPresent(WScreen
*scr
, WDefaultEntry
*entry
, int *flag
, long which
)
2408 wPreferences
.flags
.nodock
= wPreferences
.flags
.nodock
|| *flag
;
2411 wPreferences
.flags
.noclip
= wPreferences
.flags
.noclip
|| *flag
;
2421 setStickyIcons(WScreen
*scr
, WDefaultEntry
*entry
, void *bar
, void *foo
)
2423 if (scr
->workspaces
) {
2424 wWorkspaceForceChange(scr
, scr
->current_workspace
);
2425 wArrangeIcons(scr
, False
);
2432 setPositive(WScreen
*scr
, WDefaultEntry
*entry
, int *value
, void *foo
)
2444 setIconTile(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
2450 img
= wTextureRenderImage(*texture
, wPreferences
.icon_size
,
2451 wPreferences
.icon_size
,
2452 ((*texture
)->any
.type
& WREL_BORDER_MASK
)
2453 ? WREL_ICON
: WREL_FLAT
);
2455 wwarning(_("could not render texture for icon background"));
2457 wTextureDestroy(scr
, *texture
);
2460 RConvertImage(scr
->rcontext
, img
, &pixmap
);
2462 if (scr
->icon_tile
) {
2464 RDestroyImage(scr
->icon_tile
);
2465 XFreePixmap(dpy
, scr
->icon_tile_pixmap
);
2468 scr
->icon_tile
= img
;
2470 if (!wPreferences
.flags
.noclip
) {
2471 if (scr
->clip_tile
) {
2472 RDestroyImage(scr
->clip_tile
);
2474 scr
->clip_tile
= wClipMakeTile(scr
, img
);
2477 scr
->icon_tile_pixmap
= pixmap
;
2479 if (scr
->def_icon_pixmap
) {
2480 XFreePixmap(dpy
, scr
->def_icon_pixmap
);
2481 scr
->def_icon_pixmap
= None
;
2483 if (scr
->def_ticon_pixmap
) {
2484 XFreePixmap(dpy
, scr
->def_ticon_pixmap
);
2485 scr
->def_ticon_pixmap
= None
;
2488 if (scr
->icon_back_texture
) {
2489 wTextureDestroy(scr
, (WTexture
*)scr
->icon_back_texture
);
2491 scr
->icon_back_texture
= wTextureMakeSolid(scr
, &((*texture
)->any
.color
));
2493 if (scr
->clip_balloon
)
2494 XSetWindowBackground(dpy
, scr
->clip_balloon
,
2495 (*texture
)->any
.color
.pixel
);
2498 * Free the texture as nobody else will use it, nor refer to it.
2501 wTextureDestroy(scr
, *texture
);
2503 return (reset
? REFRESH_ICON_TILE
: 0);
2509 setWinTitleFont(WScreen
*scr
, WDefaultEntry
*entry
, WMFont
*font
, void *foo
)
2511 if (scr
->title_font
) {
2512 WMReleaseFont(scr
->title_font
);
2514 scr
->title_font
= font
;
2516 return REFRESH_WINDOW_FONT
|REFRESH_BUTTON_IMAGES
;
2521 setMenuTitleFont(WScreen
*scr
, WDefaultEntry
*entry
, WMFont
*font
, void *foo
)
2523 if (scr
->menu_title_font
) {
2524 WMReleaseFont(scr
->menu_title_font
);
2527 scr
->menu_title_font
= font
;
2529 return REFRESH_MENU_TITLE_FONT
;
2534 setMenuTextFont(WScreen
*scr
, WDefaultEntry
*entry
, WMFont
*font
, void *foo
)
2536 if (scr
->menu_entry_font
) {
2537 WMReleaseFont(scr
->menu_entry_font
);
2539 scr
->menu_entry_font
= font
;
2541 return REFRESH_MENU_FONT
;
2547 setIconTitleFont(WScreen
*scr
, WDefaultEntry
*entry
, WMFont
*font
, void *foo
)
2549 if (scr
->icon_title_font
) {
2550 WMReleaseFont(scr
->icon_title_font
);
2553 scr
->icon_title_font
= font
;
2555 return REFRESH_ICON_FONT
;
2560 setClipTitleFont(WScreen
*scr
, WDefaultEntry
*entry
, WMFont
*font
, void *foo
)
2562 if (scr
->clip_title_font
) {
2563 WMReleaseFont(scr
->clip_title_font
);
2566 scr
->clip_title_font
= font
;
2568 return REFRESH_ICON_FONT
;
2573 setDisplayFont(WScreen
*scr
, WDefaultEntry
*entry
, WMFont
*font
, void *foo
)
2575 if (scr
->info_text_font
) {
2576 WMReleaseFont(scr
->info_text_font
);
2579 scr
->info_text_font
= font
;
2581 /* This test works because the scr structure is initially zeroed out
2582 and None = 0. Any other time, the window should be valid. */
2583 if (scr
->geometry_display
!= None
) {
2584 wGetGeometryWindowSize(scr
, &scr
->geometry_display_width
,
2585 &scr
->geometry_display_height
);
2586 XResizeWindow(dpy
, scr
->geometry_display
,
2587 scr
->geometry_display_width
, scr
->geometry_display_height
);
2595 setLargeDisplayFont(WScreen
*scr
, WDefaultEntry
*entry
, WMFont
*font
, void *foo
)
2597 if (scr
->workspace_name_font
) {
2598 WMReleaseFont(scr
->workspace_name_font
);
2601 scr
->workspace_name_font
= font
;
2608 setHightlight(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, void *foo
)
2610 if (scr
->select_pixel
!=scr
->white_pixel
&&
2611 scr
->select_pixel
!=scr
->black_pixel
) {
2612 wFreeColor(scr
, scr
->select_pixel
);
2615 scr
->select_pixel
= color
->pixel
;
2617 return REFRESH_MENU_COLOR
;
2622 setHightlightText(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, void *foo
)
2624 if (scr
->select_text_pixel
!=scr
->white_pixel
&&
2625 scr
->select_text_pixel
!=scr
->black_pixel
) {
2626 wFreeColor(scr
, scr
->select_text_pixel
);
2629 scr
->select_text_pixel
= color
->pixel
;
2631 return REFRESH_MENU_COLOR
;
2636 setClipTitleColor(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, long index
)
2638 if (scr
->clip_title_pixel
[index
]!=scr
->white_pixel
&&
2639 scr
->clip_title_pixel
[index
]!=scr
->black_pixel
) {
2640 wFreeColor(scr
, scr
->clip_title_pixel
[index
]);
2642 scr
->clip_title_pixel
[index
] = color
->pixel
;
2644 #ifdef GRADIENT_CLIP_ARROW
2645 if (index
== CLIP_NORMAL
) {
2647 RColor color1
, color2
;
2648 int pt
= CLIP_BUTTON_SIZE
*wPreferences
.icon_size
/64;
2649 int as
= pt
- 15; /* 15 = 5+5+5 */
2651 FREE_PIXMAP(scr
->clip_arrow_gradient
);
2653 color1
.red
= (color
->red
>> 8)*6/10;
2654 color1
.green
= (color
->green
>> 8)*6/10;
2655 color1
.blue
= (color
->blue
>> 8)*6/10;
2657 color2
.red
= WMIN((color
->red
>> 8)*20/10, 255);
2658 color2
.green
= WMIN((color
->green
>> 8)*20/10, 255);
2659 color2
.blue
= WMIN((color
->blue
>> 8)*20/10, 255);
2661 image
= RRenderGradient(as
+1, as
+1, &color1
, &color2
, RDiagonalGradient
);
2662 RConvertImage(scr
->rcontext
, image
, &scr
->clip_arrow_gradient
);
2663 RDestroyImage(image
);
2665 #endif /* GRADIENT_CLIP_ARROW */
2667 return REFRESH_ICON_TITLE_COLOR
;
2672 setWTitleColor(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, long index
)
2674 if (scr
->window_title_pixel
[index
]!=scr
->white_pixel
&&
2675 scr
->window_title_pixel
[index
]!=scr
->black_pixel
) {
2676 wFreeColor(scr
, scr
->window_title_pixel
[index
]);
2679 scr
->window_title_pixel
[index
] = color
->pixel
;
2681 if (index
== WS_UNFOCUSED
)
2682 XSetForeground(dpy
, scr
->info_text_gc
, color
->pixel
);
2684 return REFRESH_WINDOW_TITLE_COLOR
;
2689 setMenuTitleColor(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, long index
)
2691 if (scr
->menu_title_pixel
[0]!=scr
->white_pixel
&&
2692 scr
->menu_title_pixel
[0]!=scr
->black_pixel
) {
2693 #ifdef DRAWSTRING_PLUGIN
2694 if(!scr
->drawstring_func
[W_STRING_MTITLE
])
2696 wFreeColor(scr
, scr
->menu_title_pixel
[0]);
2699 scr
->menu_title_pixel
[0] = color
->pixel
;
2700 XSetForeground(dpy
, scr
->menu_title_gc
, color
->pixel
);
2702 return REFRESH_MENU_TITLE_COLOR
;
2707 setMenuTextColor(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, void *foo
)
2710 #define gcm (GCForeground|GCBackground|GCFillStyle)
2712 if (scr
->mtext_pixel
!=scr
->white_pixel
&&
2713 scr
->mtext_pixel
!=scr
->black_pixel
) {
2714 wFreeColor(scr
, scr
->mtext_pixel
);
2717 scr
->mtext_pixel
= color
->pixel
;
2719 XSetForeground(dpy
, scr
->menu_entry_gc
, color
->pixel
);
2722 if (scr
->dtext_pixel
== scr
->mtext_pixel
) {
2723 gcv
.foreground
= scr
->white_pixel
;
2724 gcv
.background
= scr
->black_pixel
;
2725 gcv
.fill_style
= FillStippled
;
2727 gcv
.foreground
= scr
->dtext_pixel
;
2728 gcv
.fill_style
= FillSolid
;
2730 XChangeGC(dpy
, scr
->disabled_menu_entry_gc
, gcm
, &gcv
);
2732 return REFRESH_MENU_COLOR
;
2738 setMenuDisabledColor(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, void *foo
)
2741 #define gcm (GCForeground|GCBackground|GCFillStyle)
2743 if (scr
->dtext_pixel
!=scr
->white_pixel
&&
2744 scr
->dtext_pixel
!=scr
->black_pixel
) {
2745 wFreeColor(scr
, scr
->dtext_pixel
);
2748 scr
->dtext_pixel
= color
->pixel
;
2750 if (scr
->dtext_pixel
== scr
->mtext_pixel
) {
2751 gcv
.foreground
= scr
->white_pixel
;
2752 gcv
.background
= scr
->black_pixel
;
2753 gcv
.fill_style
= FillStippled
;
2755 gcv
.foreground
= scr
->dtext_pixel
;
2756 gcv
.fill_style
= FillSolid
;
2758 XChangeGC(dpy
, scr
->disabled_menu_entry_gc
, gcm
, &gcv
);
2760 return REFRESH_MENU_COLOR
;
2765 setIconTitleColor(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, void *foo
)
2767 XSetForeground(dpy
, scr
->icon_title_gc
, color
->pixel
);
2769 return REFRESH_ICON_TITLE_COLOR
;
2774 setIconTitleBack(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, void *foo
)
2776 if (scr
->icon_title_texture
) {
2777 wTextureDestroy(scr
, (WTexture
*)scr
->icon_title_texture
);
2779 XQueryColor (dpy
, scr
->w_colormap
, color
);
2780 scr
->icon_title_texture
= wTextureMakeSolid(scr
, color
);
2782 return REFRESH_ICON_TITLE_BACK
;
2787 trackDeadProcess(pid_t pid
, unsigned char status
, WScreen
*scr
)
2789 close(scr
->helper_fd
);
2791 scr
->helper_pid
= 0;
2792 scr
->flags
.backimage_helper_launched
= 0;
2797 setWorkspaceSpecificBack(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
,
2804 if (scr
->flags
.backimage_helper_launched
) {
2805 if (PLGetNumberOfElements(value
)==0) {
2806 SendHelperMessage(scr
, 'C', 0, NULL
);
2807 SendHelperMessage(scr
, 'K', 0, NULL
);
2816 if (PLGetNumberOfElements(value
) == 0)
2819 if (pipe(filedes
) < 0) {
2820 wsyserror("pipe() failed:can't set workspace specific background image");
2828 wsyserror("fork() failed:can't set workspace specific background image");
2829 if (close(filedes
[0]) < 0)
2830 wsyserror("could not close pipe");
2831 if (close(filedes
[1]) < 0)
2832 wsyserror("could not close pipe");
2834 } else if (pid
== 0) {
2835 SetupEnvironment(scr
);
2838 wsyserror("could not close pipe");
2839 if (dup(filedes
[0]) < 0) {
2840 wsyserror("dup() failed:can't set workspace specific background image");
2842 if (wPreferences
.smooth_workspace_back
)
2843 execlp("wmsetbg", "wmsetbg", "-helper", "-S", "-d", NULL
);
2845 execlp("wmsetbg", "wmsetbg", "-helper", "-d", NULL
);
2846 wsyserror("could not execute wmsetbg");
2850 if (fcntl(filedes
[0], F_SETFD
, FD_CLOEXEC
) < 0) {
2851 wsyserror("error setting close-on-exec flag");
2853 if (fcntl(filedes
[1], F_SETFD
, FD_CLOEXEC
) < 0) {
2854 wsyserror("error setting close-on-exec flag");
2857 scr
->helper_fd
= filedes
[1];
2858 scr
->helper_pid
= pid
;
2859 scr
->flags
.backimage_helper_launched
= 1;
2861 wAddDeathHandler(pid
, (WDeathHandler
*)trackDeadProcess
, scr
);
2863 SendHelperMessage(scr
, 'P', -1, wPreferences
.pixmap_path
);
2868 for (i
= 0; i
< PLGetNumberOfElements(value
); i
++) {
2869 val
= PLGetArrayElement(value
, i
);
2870 if (val
&& PLIsArray(val
) && PLGetNumberOfElements(val
)>0) {
2871 str
= PLGetDescription(val
);
2873 SendHelperMessage(scr
, 'S', i
+1, str
);
2877 SendHelperMessage(scr
, 'U', i
+1, NULL
);
2888 setWorkspaceBack(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
,
2891 if (scr
->flags
.backimage_helper_launched
) {
2894 if (PLGetNumberOfElements(value
)==0) {
2895 SendHelperMessage(scr
, 'U', 0, NULL
);
2897 /* set the default workspace background to this one */
2898 str
= PLGetDescription(value
);
2900 SendHelperMessage(scr
, 'S', 0, str
);
2902 SendHelperMessage(scr
, 'C', scr
->current_workspace
+1, NULL
);
2904 SendHelperMessage(scr
, 'U', 0, NULL
);
2911 SetupEnvironment(scr
);
2912 text
= PLGetDescription(value
);
2913 command
= wmalloc(strlen(text
)+40);
2914 if (wPreferences
.smooth_workspace_back
)
2915 sprintf(command
, "wmsetbg -d -S -p '%s' &", text
);
2917 sprintf(command
, "wmsetbg -d -p '%s' &", text
);
2929 setWidgetColor(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
2931 if (scr
->widget_texture
) {
2932 wTextureDestroy(scr
, (WTexture
*)scr
->widget_texture
);
2934 scr
->widget_texture
= *(WTexSolid
**)texture
;
2936 if (scr
->geometry_display
!= None
)
2937 XSetWindowBackground(dpy
, scr
->geometry_display
,
2938 scr
->widget_texture
->normal
.pixel
);
2945 setFTitleBack(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
2947 if (scr
->window_title_texture
[WS_FOCUSED
]) {
2948 wTextureDestroy(scr
, scr
->window_title_texture
[WS_FOCUSED
]);
2950 scr
->window_title_texture
[WS_FOCUSED
] = *texture
;
2952 return REFRESH_WINDOW_TEXTURES
;
2957 setPTitleBack(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
2959 if (scr
->window_title_texture
[WS_PFOCUSED
]) {
2960 wTextureDestroy(scr
, scr
->window_title_texture
[WS_PFOCUSED
]);
2962 scr
->window_title_texture
[WS_PFOCUSED
] = *texture
;
2964 return REFRESH_WINDOW_TEXTURES
;
2969 setUTitleBack(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
2971 if (scr
->window_title_texture
[WS_UNFOCUSED
]) {
2972 wTextureDestroy(scr
, scr
->window_title_texture
[WS_UNFOCUSED
]);
2974 scr
->window_title_texture
[WS_UNFOCUSED
] = *texture
;
2976 return REFRESH_WINDOW_TEXTURES
;
2981 setResizebarBack(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
2983 if (scr
->resizebar_texture
[0]) {
2984 wTextureDestroy(scr
, scr
->resizebar_texture
[0]);
2986 scr
->resizebar_texture
[0] = *texture
;
2988 return REFRESH_WINDOW_TEXTURES
;
2993 setMenuTitleBack(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
2995 if (scr
->menu_title_texture
[0]) {
2996 wTextureDestroy(scr
, scr
->menu_title_texture
[0]);
2998 scr
->menu_title_texture
[0] = *texture
;
3000 return REFRESH_MENU_TITLE_TEXTURE
;
3005 setMenuTextBack(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
3007 if (scr
->menu_item_texture
) {
3008 wTextureDestroy(scr
, scr
->menu_item_texture
);
3009 wTextureDestroy(scr
, (WTexture
*)scr
->menu_item_auxtexture
);
3011 scr
->menu_item_texture
= *texture
;
3013 scr
->menu_item_auxtexture
3014 = wTextureMakeSolid(scr
, &scr
->menu_item_texture
->any
.color
);
3016 return REFRESH_MENU_TEXTURE
;
3021 setKeyGrab(WScreen
*scr
, WDefaultEntry
*entry
, WShortKey
*shortcut
, long index
)
3024 wKeyBindings
[index
] = *shortcut
;
3026 wwin
= scr
->focused_window
;
3028 while (wwin
!=NULL
) {
3029 XUngrabKey(dpy
, AnyKey
, AnyModifier
, wwin
->frame
->core
->window
);
3031 if (!WFLAGP(wwin
, no_bind_keys
)) {
3032 wWindowSetKeyGrabs(wwin
);
3042 setIconPosition(WScreen
*scr
, WDefaultEntry
*entry
, void *bar
, void *foo
)
3044 wArrangeIcons(scr
, True
);
3051 updateUsableArea(WScreen
*scr
, WDefaultEntry
*entry
, void *bar
, void *foo
)
3053 wScreenUpdateUsableArea(scr
);
3060 setMenuStyle(WScreen
*scr
, WDefaultEntry
*entry
, int *value
, void *foo
)
3062 return REFRESH_MENU_TEXTURE
;
3068 setButtonImages(WScreen *scr, WDefaultEntry *entry, int *value, void *foo)
3070 return REFRESH_BUTTON_IMAGES;
3076 * Need access to the double click variables, so that all widgets in
3077 * wmaker panels will have the same dbl-click values.
3078 * TODO: figure a better way of dealing with it.
3083 setDoubleClick(WScreen
*scr
, WDefaultEntry
*entry
, int *value
, void *foo
)
3085 extern _WINGsConfiguration WINGsConfiguration
;
3090 WINGsConfiguration
.doubleClickDelay
= *value
;
3098 setMultiByte(WScreen
*scr
, WDefaultEntry
*entry
, int *value
, void *foo
)
3100 extern _WINGsConfiguration WINGsConfiguration
;
3102 WINGsConfiguration
.useMultiByte
= *value
;