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_SMART
, 0}, {"Smart", WPM_SMART
, 1},
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
[] = {
259 {"Left", Button1
, 0}, {"Button1", Button1
, 1},
260 {"Middle", Button2
, 0}, {"Button2", Button2
, 1},
261 {"Right", Button3
, 0}, {"Button3", Button3
, 1},
262 {"Button4", Button4
, 0},
263 {"Button5", Button5
, 0},
267 static WOptionEnumeration seIconificationStyles
[] = {
268 {"Zoom", WIS_ZOOM
, 0},
269 {"Twist", WIS_TWIST
, 0},
270 {"Flip", WIS_FLIP
, 0},
271 {"None", WIS_NONE
, 0},
272 {"random", WIS_RANDOM
, 0},
276 static WOptionEnumeration seJustifications
[] = {
277 {"Left", WTJ_LEFT
, 0},
278 {"Center", WTJ_CENTER
, 0},
279 {"Right", WTJ_RIGHT
, 0},
283 static WOptionEnumeration seIconPositions
[] = {
284 {"blv", IY_BOTTOM
|IY_LEFT
|IY_VERT
, 0},
285 {"blh", IY_BOTTOM
|IY_LEFT
|IY_HORIZ
, 0},
286 {"brv", IY_BOTTOM
|IY_RIGHT
|IY_VERT
, 0},
287 {"brh", IY_BOTTOM
|IY_RIGHT
|IY_HORIZ
, 0},
288 {"tlv", IY_TOP
|IY_LEFT
|IY_VERT
, 0},
289 {"tlh", IY_TOP
|IY_LEFT
|IY_HORIZ
, 0},
290 {"trv", IY_TOP
|IY_RIGHT
|IY_VERT
, 0},
291 {"trh", IY_TOP
|IY_RIGHT
|IY_HORIZ
, 0},
295 static WOptionEnumeration seMenuStyles
[] = {
296 {"normal", MS_NORMAL
, 0},
297 {"singletexture", MS_SINGLE_TEXTURE
, 0},
298 {"flat", MS_FLAT
, 0},
303 static WOptionEnumeration seDisplayPositions
[] = {
304 {"none", WD_NONE
, 0},
305 {"center", WD_CENTER
, 0},
307 {"bottom", WD_BOTTOM
, 0},
308 {"topleft", WD_TOPLEFT
, 0},
309 {"topright", WD_TOPRIGHT
, 0},
310 {"bottomleft", WD_BOTTOMLEFT
, 0},
311 {"bottomright", WD_BOTTOMRIGHT
, 0}
316 * ALL entries in the tables bellow, NEED to have a default value
317 * defined, and this value needs to be correct.
320 /* these options will only affect the window manager on startup
322 * static defaults can't access the screen data, because it is
323 * created after these defaults are read
325 WDefaultEntry staticOptionList
[] = {
327 {"DisableDithering", "NO", NULL
,
328 &wPreferences
.no_dithering
, getBool
, NULL
330 {"ColormapSize", "4", NULL
,
331 &wPreferences
.cmap_size
, getInt
, NULL
333 /* static by laziness */
334 {"IconSize", "64", NULL
,
335 &wPreferences
.icon_size
, getInt
, NULL
337 {"ModifierKey", "Mod1", NULL
,
338 &wPreferences
.modifier_mask
, getModMask
, NULL
340 {"DisableWSMouseActions", "NO", NULL
,
341 &wPreferences
.disable_root_mouse
, getBool
, NULL
343 {"FocusMode", "manual", seFocusModes
,
344 &wPreferences
.focus_mode
, getEnum
, NULL
345 }, /* have a problem when switching from manual to sloppy without restart */
346 {"NewStyle", "NO", NULL
,
347 &wPreferences
.new_style
, getBool
, NULL
349 {"DisableDock", "NO", (void*) WM_DOCK
,
350 NULL
, getBool
, setIfDockPresent
352 {"DisableClip", "NO", (void*) WM_CLIP
,
353 NULL
, getBool
, setIfDockPresent
355 {"DisableMiniwindows", "NO", NULL
,
356 &wPreferences
.disable_miniwindows
, getBool
, NULL
358 {"MultiByteText", "NO", NULL
,
359 &wPreferences
.multi_byte_text
, getBool
, setMultiByte
365 WDefaultEntry optionList
[] = {
366 /* dynamic options */
367 {"IconPosition", "blh", seIconPositions
,
368 &wPreferences
.icon_yard
, getEnum
, setIconPosition
370 {"IconificationStyle", "Zoom", seIconificationStyles
,
371 &wPreferences
.iconification_style
, getEnum
, NULL
373 {"SelectWindowsMouseButton", "Left", seMouseButtons
,
374 &wPreferences
.select_button
, getEnum
, NULL
376 {"WindowListMouseButton", "Middle", seMouseButtons
,
377 &wPreferences
.windowl_button
, getEnum
, NULL
379 {"ApplicationMenuMouseButton", "Right", seMouseButtons
,
380 &wPreferences
.menu_button
, getEnum
, NULL
382 {"PixmapPath", DEF_PIXMAP_PATHS
, NULL
,
383 &wPreferences
.pixmap_path
, getPathList
, NULL
385 {"IconPath", DEF_ICON_PATHS
, NULL
,
386 &wPreferences
.icon_path
, getPathList
, NULL
388 {"ColormapMode", "auto", seColormapModes
,
389 &wPreferences
.colormap_mode
, getEnum
, NULL
391 {"AutoFocus", "NO", NULL
,
392 &wPreferences
.auto_focus
, getBool
, NULL
394 {"RaiseDelay", "0", NULL
,
395 &wPreferences
.raise_delay
, getInt
, NULL
397 {"CirculateRaise", "NO", NULL
,
398 &wPreferences
.circ_raise
, getBool
, NULL
400 {"Superfluous", "NO", NULL
,
401 &wPreferences
.superfluous
, getBool
, NULL
403 {"AdvanceToNewWorkspace", "NO", NULL
,
404 &wPreferences
.ws_advance
, getBool
, NULL
406 {"CycleWorkspaces", "NO", NULL
,
407 &wPreferences
.ws_cycle
, getBool
, NULL
409 {"WorkspaceNameDisplayPosition", "center", seDisplayPositions
,
410 &wPreferences
.workspace_name_display_position
, getEnum
, NULL
412 {"StickyIcons", "NO", NULL
,
413 &wPreferences
.sticky_icons
, getBool
, setStickyIcons
415 {"SaveSessionOnExit", "NO", NULL
,
416 &wPreferences
.save_session_on_exit
, getBool
, NULL
418 {"WrapMenus", "NO", NULL
,
419 &wPreferences
.wrap_menus
, getBool
, NULL
421 {"ScrollableMenus", "NO", NULL
,
422 &wPreferences
.scrollable_menus
, getBool
, NULL
424 {"MenuScrollSpeed", "medium", seSpeeds
,
425 &wPreferences
.menu_scroll_speed
, getEnum
, NULL
427 {"IconSlideSpeed", "medium", seSpeeds
,
428 &wPreferences
.icon_slide_speed
, getEnum
, NULL
430 {"ShadeSpeed", "medium", seSpeeds
,
431 &wPreferences
.shade_speed
, getEnum
, NULL
433 {"DoubleClickTime", "250", (void*) &wPreferences
.dblclick_time
,
434 &wPreferences
.dblclick_time
, getInt
, setDoubleClick
,
436 {"AlignSubmenus", "NO", NULL
,
437 &wPreferences
.align_menus
, getBool
, NULL
439 {"OpenTransientOnOwnerWorkspace", "NO", NULL
,
440 &wPreferences
.open_transients_with_parent
, getBool
, NULL
442 {"WindowPlacement", "auto", sePlacements
,
443 &wPreferences
.window_placement
, getEnum
, NULL
445 {"IgnoreFocusClick","NO", NULL
,
446 &wPreferences
.ignore_focus_click
, getBool
, NULL
448 {"UseSaveUnders", "NO", NULL
,
449 &wPreferences
.use_saveunders
, getBool
, NULL
451 {"OpaqueMove", "NO", NULL
,
452 &wPreferences
.opaque_move
, getBool
, NULL
454 {"DisableSound", "NO", NULL
,
455 &wPreferences
.no_sound
, getBool
, NULL
457 {"DisableAnimations", "NO", NULL
,
458 &wPreferences
.no_animations
, getBool
, NULL
460 {"DontLinkWorkspaces","NO", NULL
,
461 &wPreferences
.no_autowrap
, getBool
, NULL
463 {"AutoArrangeIcons", "NO", NULL
,
464 &wPreferences
.auto_arrange_icons
, getBool
, NULL
466 {"NoWindowOverDock", "NO", NULL
,
467 &wPreferences
.no_window_over_dock
, getBool
, updateUsableArea
469 {"NoWindowOverIcons", "NO", NULL
,
470 &wPreferences
.no_window_over_icons
, getBool
, updateUsableArea
472 {"WindowPlaceOrigin", "(0, 0)", NULL
,
473 &wPreferences
.window_place_origin
, getCoord
, NULL
475 {"ResizeDisplay", "corner", seGeomDisplays
,
476 &wPreferences
.size_display
, getEnum
, NULL
478 {"MoveDisplay", "corner", seGeomDisplays
,
479 &wPreferences
.move_display
, getEnum
, NULL
481 {"DontConfirmKill", "NO", NULL
,
482 &wPreferences
.dont_confirm_kill
, getBool
,NULL
484 {"WindowTitleBalloons", "NO", NULL
,
485 &wPreferences
.window_balloon
, getBool
, NULL
487 {"MiniwindowTitleBalloons", "NO", NULL
,
488 &wPreferences
.miniwin_balloon
,getBool
, NULL
490 {"AppIconBalloons", "NO", NULL
,
491 &wPreferences
.appicon_balloon
,getBool
, NULL
493 {"HelpBalloons", "NO", NULL
,
494 &wPreferences
.help_balloon
, getBool
, NULL
496 {"EdgeResistance", "30", NULL
,
497 &wPreferences
.edge_resistance
,getInt
, NULL
499 {"Attraction", "NO", NULL
,
500 &wPreferences
.attract
, getBool
, NULL
502 {"DisableBlinking", "NO", NULL
,
503 &wPreferences
.dont_blink
, getBool
, NULL
505 #ifdef WEENDOZE_CYCLE
506 {"WindozeCycling","NO", NULL
,
507 &wPreferences
.windoze_cycling
, getBool
, NULL
509 {"PopupSwitchMenu","YES", NULL
,
510 &wPreferences
.popup_switchmenu
, getBool
, NULL
512 #endif /* WEENDOZE_CYCLE */
514 {"MenuStyle", "normal", seMenuStyles
,
515 &wPreferences
.menu_style
, getEnum
, setMenuStyle
517 {"WidgetColor", "(solid, gray)", NULL
,
518 NULL
, getTexture
, setWidgetColor
,
520 {"WorkspaceSpecificBack","()", NULL
,
521 NULL
, getWSSpecificBackground
, setWorkspaceSpecificBack
523 /* WorkspaceBack must come after WorkspaceSpecificBack or
524 * WorkspaceBack wont know WorkspaceSpecificBack was also
525 * specified and 2 copies of wmsetbg will be launched */
526 {"WorkspaceBack", "(solid, black)", NULL
,
527 NULL
, getWSBackground
,setWorkspaceBack
529 {"SmoothWorkspaceBack", "NO", NULL
,
532 {"IconBack", "(solid, gray)", NULL
,
533 NULL
, getTexture
, setIconTile
535 {"TitleJustify", "center", seJustifications
,
536 &wPreferences
.title_justification
, getEnum
, setJustify
538 {"WindowTitleFont", DEF_TITLE_FONT
, NULL
,
539 NULL
, getFont
, setWinTitleFont
,
541 {"MenuTitleFont", DEF_MENU_TITLE_FONT
, NULL
,
542 NULL
, getFont
, setMenuTitleFont
544 {"MenuTextFont", DEF_MENU_ENTRY_FONT
, NULL
,
545 NULL
, getFont
, setMenuTextFont
547 {"IconTitleFont", DEF_ICON_TITLE_FONT
, NULL
,
548 NULL
, getFont
, setIconTitleFont
550 {"ClipTitleFont", DEF_CLIP_TITLE_FONT
, NULL
,
551 NULL
, getFont
, setClipTitleFont
553 {"DisplayFont", DEF_INFO_TEXT_FONT
, NULL
,
554 NULL
, getFont
, setDisplayFont
556 {"LargeDisplayFont",DEF_WORKSPACE_NAME_FONT
, NULL
,
557 NULL
, getFont
, setLargeDisplayFont
559 {"HighlightColor", "white", NULL
,
560 NULL
, getColor
, setHightlight
562 {"HighlightTextColor", "black", NULL
,
563 NULL
, getColor
, setHightlightText
565 {"ClipTitleColor", "black", (void*)CLIP_NORMAL
,
566 NULL
, getColor
, setClipTitleColor
568 {"CClipTitleColor", "\"#454045\"", (void*)CLIP_COLLAPSED
,
569 NULL
, getColor
, setClipTitleColor
571 #ifdef DRAWSTRING_PLUGIN
572 {"FTitleColor", "white", (void*)WS_FOCUSED
,
573 NULL
, getTextRenderer
, setWTitleColor
575 {"PTitleColor", "white", (void*)WS_PFOCUSED
,
576 NULL
, getTextRenderer
, setWTitleColor
578 {"UTitleColor", "black", (void*)WS_UNFOCUSED
,
579 NULL
, getTextRenderer
, setWTitleColor
582 {"FTitleColor", "white", (void*)WS_FOCUSED
,
583 NULL
, getColor
, setWTitleColor
585 {"PTitleColor", "white", (void*)WS_PFOCUSED
,
586 NULL
, getColor
, setWTitleColor
588 {"UTitleColor", "black", (void*)WS_UNFOCUSED
,
589 NULL
, getColor
, setWTitleColor
592 {"FTitleBack", "(solid, black)", NULL
,
593 NULL
, getTexture
, setFTitleBack
595 {"PTitleBack", "(solid, \"#616161\")", NULL
,
596 NULL
, getTexture
, setPTitleBack
598 {"UTitleBack", "(solid, gray)", NULL
,
599 NULL
, getTexture
, setUTitleBack
601 {"ResizebarBack", "(solid, gray)", NULL
,
602 NULL
, getTexture
, setResizebarBack
604 #ifdef DRAWSTRING_PLUGIN
605 {"MenuTitleColor", "white", NULL
,
606 NULL
, getTextRenderer
, setMenuTitleColor
609 {"MenuTitleColor", "white", NULL
,
610 NULL
, getColor
, setMenuTitleColor
613 {"MenuTextColor", "black", NULL
,
614 NULL
, getColor
, setMenuTextColor
616 {"MenuDisabledColor", "\"#616161\"", NULL
,
617 NULL
, getColor
, setMenuDisabledColor
619 {"MenuTitleBack", "(solid, black)", NULL
,
620 NULL
, getTexture
, setMenuTitleBack
622 {"MenuTextBack", "(solid, gray)", NULL
,
623 NULL
, getTexture
, setMenuTextBack
625 {"IconTitleColor", "white", NULL
,
626 NULL
, getColor
, setIconTitleColor
628 {"IconTitleBack", "black", NULL
,
629 NULL
, getColor
, setIconTitleBack
633 {"RootMenuKey", "None", (void*)WKBD_ROOTMENU
,
634 NULL
, getKeybind
, setKeyGrab
636 {"WindowListKey", "None", (void*)WKBD_WINDOWLIST
,
637 NULL
, getKeybind
, setKeyGrab
640 {"WindowMenuKey", "None", (void*)WKBD_WINDOWMENU
,
641 NULL
, getKeybind
, setKeyGrab
643 {"ClipLowerKey", "None", (void*)WKBD_CLIPLOWER
,
644 NULL
, getKeybind
, setKeyGrab
646 {"ClipRaiseKey", "None", (void*)WKBD_CLIPRAISE
,
647 NULL
, getKeybind
, setKeyGrab
649 {"ClipRaiseLowerKey", "None", (void*)WKBD_CLIPRAISELOWER
,
650 NULL
, getKeybind
, setKeyGrab
652 {"MiniaturizeKey", "None", (void*)WKBD_MINIATURIZE
,
653 NULL
, getKeybind
, setKeyGrab
655 {"HideKey", "None", (void*)WKBD_HIDE
,
656 NULL
, getKeybind
, setKeyGrab
658 {"MoveResizeKey", "None", (void*)WKBD_MOVERESIZE
,
659 NULL
, getKeybind
, setKeyGrab
661 {"CloseKey", "None", (void*)WKBD_CLOSE
,
662 NULL
, getKeybind
, setKeyGrab
664 {"MaximizeKey", "None", (void*)WKBD_MAXIMIZE
,
665 NULL
, getKeybind
, setKeyGrab
667 {"VMaximizeKey", "None", (void*)WKBD_VMAXIMIZE
,
668 NULL
, getKeybind
, setKeyGrab
670 {"RaiseKey", "Meta+Up", (void*)WKBD_RAISE
,
671 NULL
, getKeybind
, setKeyGrab
673 {"LowerKey", "Meta+Down", (void*)WKBD_LOWER
,
674 NULL
, getKeybind
, setKeyGrab
676 {"RaiseLowerKey", "None", (void*)WKBD_RAISELOWER
,
677 NULL
, getKeybind
, setKeyGrab
679 {"ShadeKey", "None", (void*)WKBD_SHADE
,
680 NULL
, getKeybind
, setKeyGrab
682 {"SelectKey", "None", (void*)WKBD_SELECT
,
683 NULL
, getKeybind
, setKeyGrab
685 {"FocusNextKey", "None", (void*)WKBD_FOCUSNEXT
,
686 NULL
, getKeybind
, setKeyGrab
688 {"FocusPrevKey", "None", (void*)WKBD_FOCUSPREV
,
689 NULL
, getKeybind
, setKeyGrab
691 {"NextWorkspaceKey", "None", (void*)WKBD_NEXTWORKSPACE
,
692 NULL
, getKeybind
, setKeyGrab
694 {"PrevWorkspaceKey", "None", (void*)WKBD_PREVWORKSPACE
,
695 NULL
, getKeybind
, setKeyGrab
697 {"NextWorkspaceLayerKey", "None", (void*)WKBD_NEXTWSLAYER
,
698 NULL
, getKeybind
, setKeyGrab
700 {"PrevWorkspaceLayerKey", "None", (void*)WKBD_PREVWSLAYER
,
701 NULL
, getKeybind
, setKeyGrab
703 {"Workspace1Key", "None", (void*)WKBD_WORKSPACE1
,
704 NULL
, getKeybind
, setKeyGrab
706 {"Workspace2Key", "None", (void*)WKBD_WORKSPACE2
,
707 NULL
, getKeybind
, setKeyGrab
709 {"Workspace3Key", "None", (void*)WKBD_WORKSPACE3
,
710 NULL
, getKeybind
, setKeyGrab
712 {"Workspace4Key", "None", (void*)WKBD_WORKSPACE4
,
713 NULL
, getKeybind
, setKeyGrab
715 {"Workspace5Key", "None", (void*)WKBD_WORKSPACE5
,
716 NULL
, getKeybind
, setKeyGrab
718 {"Workspace6Key", "None", (void*)WKBD_WORKSPACE6
,
719 NULL
, getKeybind
, setKeyGrab
721 {"Workspace7Key", "None", (void*)WKBD_WORKSPACE7
,
722 NULL
, getKeybind
, setKeyGrab
724 {"Workspace8Key", "None", (void*)WKBD_WORKSPACE8
,
725 NULL
, getKeybind
, setKeyGrab
727 {"Workspace9Key", "None", (void*)WKBD_WORKSPACE9
,
728 NULL
, getKeybind
, setKeyGrab
730 {"Workspace10Key", "None", (void*)WKBD_WORKSPACE10
,
731 NULL
, getKeybind
, setKeyGrab
733 {"WindowShortcut1Key","None", (void*)WKBD_WINDOW1
,
734 NULL
, getKeybind
, setKeyGrab
736 {"WindowShortcut2Key","None", (void*)WKBD_WINDOW2
,
737 NULL
, getKeybind
, setKeyGrab
739 {"WindowShortcut3Key","None", (void*)WKBD_WINDOW3
,
740 NULL
, getKeybind
, setKeyGrab
742 {"WindowShortcut4Key","None", (void*)WKBD_WINDOW4
,
743 NULL
, getKeybind
, setKeyGrab
745 #ifdef EXTEND_WINDOWSHORTCUT
746 ,{"WindowShortcut5Key","None", (void*)WKBD_WINDOW5
,
747 NULL
, getKeybind
, setKeyGrab
749 {"WindowShortcut6Key","None", (void*)WKBD_WINDOW6
,
750 NULL
, getKeybind
, setKeyGrab
752 {"WindowShortcut7Key","None", (void*)WKBD_WINDOW7
,
753 NULL
, getKeybind
, setKeyGrab
755 {"WindowShortcut8Key","None", (void*)WKBD_WINDOW8
,
756 NULL
, getKeybind
, setKeyGrab
758 {"WindowShortcut9Key","None", (void*)WKBD_WINDOW9
,
759 NULL
, getKeybind
, setKeyGrab
761 {"WindowShortcut10Key","None", (void*)WKBD_WINDOW10
,
762 NULL
, getKeybind
, setKeyGrab
764 #endif /* EXTEND_WINDOWSHORTCUT */
766 #ifdef KEEP_XKB_LOCK_STATUS
767 ,{"ToggleKbdModeKey", "None", (void*)WKBD_TOGGLE
,
768 NULL
, getKeybind
, setKeyGrab
770 {"KbdModeLock", "NO", NULL
,
771 &wPreferences
.modelock
, getBool
, NULL
773 #endif /* KEEP_XKB_LOCK_STATUS */
778 static void rereadDefaults(void);
785 /* must defer the update because accessing X data from a
786 * signal handler can mess up Xlib */
795 WDefaultEntry
*entry
;
797 PLSetStringCmpHook(StringCompareHook
);
799 for (i
=0; i
<sizeof(optionList
)/sizeof(WDefaultEntry
); i
++) {
800 entry
= &optionList
[i
];
802 entry
->plkey
= PLMakeString(entry
->key
);
803 if (entry
->default_value
)
804 entry
->plvalue
= PLGetProplistWithDescription(entry
->default_value
);
806 entry
->plvalue
= NULL
;
809 for (i
=0; i
<sizeof(staticOptionList
)/sizeof(WDefaultEntry
); i
++) {
810 entry
= &staticOptionList
[i
];
812 entry
->plkey
= PLMakeString(entry
->key
);
813 if (entry
->default_value
)
814 entry
->plvalue
= PLGetProplistWithDescription(entry
->default_value
);
816 entry
->plvalue
= NULL
;
820 wDomainName = PLMakeString(WMDOMAIN_NAME);
821 wAttributeDomainName = PLMakeString(WMATTRIBUTE_DOMAIN_NAME);
823 PLRegister(wDomainName, rereadDefaults);
824 PLRegister(wAttributeDomainName, rereadDefaults);
833 wDefaultsInit(int screen_number
)
835 static int defaults_inited
= 0;
838 if (!defaults_inited
) {
842 dict
= PLGetDomain(wDomainName
);
844 wwarning(_("could not read domain \"%s\" from defaults database"),
845 PLGetString(wDomainName
));
854 wDefaultsDestroyDomain(WDDomain
*domain
)
856 if (domain
->dictionary
)
857 PLRelease(domain
->dictionary
);
864 wDefaultsInitDomain(char *domain
, Bool requireDictionary
)
868 static int inited
= 0;
871 proplist_t shared_dict
=NULL
;
878 db
= wmalloc(sizeof(WDDomain
));
879 memset(db
, 0, sizeof(WDDomain
));
880 db
->domain_name
= domain
;
881 db
->path
= wdefaultspathfordomain(domain
);
884 if (the_path
&& stat(the_path
, &stbuf
)>=0) {
885 db
->dictionary
= ReadProplistFromFile(the_path
);
886 if (db
->dictionary
) {
887 if (requireDictionary
&& !PLIsDictionary(db
->dictionary
)) {
888 PLRelease(db
->dictionary
);
889 db
->dictionary
= NULL
;
890 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
893 db
->timestamp
= stbuf
.st_mtime
;
895 wwarning(_("could not load domain %s from user defaults database"),
900 /* global system dictionary */
901 sprintf(path
, "%s/%s", SYSCONFDIR
, domain
);
902 if (stat(path
, &stbuf
)>=0) {
903 shared_dict
= ReadProplistFromFile(path
);
905 if (requireDictionary
&& !PLIsDictionary(shared_dict
)) {
906 wwarning(_("Domain %s (%s) of global defaults database is corrupted!"),
908 PLRelease(shared_dict
);
911 if (db
->dictionary
&& PLIsDictionary(shared_dict
) &&
912 PLIsDictionary(db
->dictionary
)) {
913 PLMergeDictionaries(shared_dict
, db
->dictionary
);
914 PLRelease(db
->dictionary
);
915 db
->dictionary
= shared_dict
;
916 if (stbuf
.st_mtime
> db
->timestamp
)
917 db
->timestamp
= stbuf
.st_mtime
;
918 } else if (!db
->dictionary
) {
919 db
->dictionary
= shared_dict
;
920 if (stbuf
.st_mtime
> db
->timestamp
)
921 db
->timestamp
= stbuf
.st_mtime
;
925 wwarning(_("could not load domain %s from global defaults database"),
930 /* set to save it in user's directory, no matter from where it was read */
931 if (db
->dictionary
) {
932 proplist_t tmp
= PLMakeString(db
->path
);
934 PLSetFilename(db
->dictionary
, tmp
);
943 wReadStaticDefaults(proplist_t dict
)
946 WDefaultEntry
*entry
;
951 for (i
=0; i
<sizeof(staticOptionList
)/sizeof(WDefaultEntry
); i
++) {
952 entry
= &staticOptionList
[i
];
955 plvalue
= PLGetDictionaryEntry(dict
, entry
->plkey
);
960 /* no default in the DB. Use builtin default */
961 plvalue
= entry
->plvalue
;
966 (*entry
->convert
)(NULL
, entry
, plvalue
, entry
->addr
, &tdata
);
968 (*entry
->update
)(NULL
, entry
, tdata
, entry
->extra_data
);
976 wDefaultsCheckDomains(void *foo
)
985 puts("Checking domains...");
987 if (stat(WDWindowMaker
->path
, &stbuf
)>=0
988 && WDWindowMaker
->timestamp
< stbuf
.st_mtime
) {
989 proplist_t shared_dict
= NULL
;
991 puts("Checking WindowMaker domain");
993 WDWindowMaker
->timestamp
= stbuf
.st_mtime
;
995 /* global dictionary */
996 sprintf(path
, "%s/WindowMaker", SYSCONFDIR
);
997 if (stat(path
, &stbuf
)>=0) {
998 shared_dict
= ReadProplistFromFile(path
);
999 if (shared_dict
&& !PLIsDictionary(shared_dict
)) {
1000 wwarning(_("Domain %s (%s) of global defaults database is corrupted!"),
1001 "WindowMaker", path
);
1002 PLRelease(shared_dict
);
1004 } else if (!shared_dict
) {
1005 wwarning(_("could not load domain %s from global defaults database"),
1009 /* user dictionary */
1010 dict
= ReadProplistFromFile(WDWindowMaker
->path
);
1012 if (!PLIsDictionary(dict
)) {
1015 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
1016 "WindowMaker", WDWindowMaker
->path
);
1019 PLSetFilename(shared_dict
, PLGetFilename(dict
));
1020 PLMergeDictionaries(shared_dict
, dict
);
1025 for (i
=0; i
<wScreenCount
; i
++) {
1026 scr
= wScreenWithNumber(i
);
1028 wReadDefaults(scr
, dict
);
1030 if (WDWindowMaker
->dictionary
) {
1031 PLRelease(WDWindowMaker
->dictionary
);
1033 WDWindowMaker
->dictionary
= dict
;
1036 wwarning(_("could not load domain %s from user defaults database"),
1040 PLRelease(shared_dict
);
1044 if (stat(WDWindowAttributes
->path
, &stbuf
)>=0
1045 && WDWindowAttributes
->timestamp
< stbuf
.st_mtime
) {
1047 puts("Checking WMWindowAttributes domain");
1049 dict
= ReadProplistFromFile(WDWindowAttributes
->path
);
1051 if (!PLIsDictionary(dict
)) {
1054 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
1055 "WMWindowAttributes", WDWindowAttributes
->path
);
1057 if (WDWindowAttributes
->dictionary
)
1058 PLRelease(WDWindowAttributes
->dictionary
);
1059 WDWindowAttributes
->dictionary
= dict
;
1060 for (i
=0; i
<wScreenCount
; i
++) {
1061 scr
= wScreenWithNumber(i
);
1063 wDefaultUpdateIcons(scr
);
1067 wwarning(_("could not load domain %s from user defaults database"),
1068 "WMWindowAttributes");
1070 WDWindowAttributes
->timestamp
= stbuf
.st_mtime
;
1074 if (stat(WDRootMenu
->path
, &stbuf
)>=0
1075 && WDRootMenu
->timestamp
< stbuf
.st_mtime
) {
1076 dict
= ReadProplistFromFile(WDRootMenu
->path
);
1078 puts("Checking WMRootMenu domain");
1081 if (!PLIsArray(dict
) && !PLIsString(dict
)) {
1084 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
1085 "WMRootMenu", WDRootMenu
->path
);
1087 if (WDRootMenu
->dictionary
) {
1088 PLRelease(WDRootMenu
->dictionary
);
1090 WDRootMenu
->dictionary
= dict
;
1093 wwarning(_("could not load domain %s from user defaults database"),
1096 WDRootMenu
->timestamp
= stbuf
.st_mtime
;
1101 WMAddTimerHandler(DEFAULTS_CHECK_INTERVAL
, wDefaultsCheckDomains
, foo
);
1106 wReadDefaults(WScreen
*scr
, proplist_t new_dict
)
1108 proplist_t plvalue
, old_value
;
1109 WDefaultEntry
*entry
;
1113 proplist_t old_dict
= (WDWindowMaker
->dictionary
!=new_dict
1114 ? WDWindowMaker
->dictionary
: NULL
);
1120 for (i
=0; i
<sizeof(optionList
)/sizeof(WDefaultEntry
); i
++) {
1121 entry
= &optionList
[i
];
1124 plvalue
= PLGetDictionaryEntry(new_dict
, entry
->plkey
);
1131 old_value
= PLGetDictionaryEntry(old_dict
, entry
->plkey
);
1134 if (!plvalue
&& !old_value
) {
1135 /* no default in the DB. Use builtin default */
1136 plvalue
= entry
->plvalue
;
1137 if (plvalue
&& new_dict
) {
1138 PLInsertDictionaryEntry(new_dict
, entry
->plkey
, plvalue
);
1141 } else if (!plvalue
) {
1142 /* value was deleted from DB. Keep current value */
1144 } else if (!old_value
) {
1145 /* set value for the 1st time */
1146 } else if (!PLIsEqual(plvalue
, old_value
)) {
1147 /* value has changed */
1149 /* value was not changed since last time */
1155 printf("Updating %s to %s\n", entry
->key
, PLGetDescription(plvalue
));
1158 if ((*entry
->convert
)(scr
, entry
, plvalue
, entry
->addr
, &tdata
)) {
1159 if (entry
->update
) {
1161 (*entry
->update
)(scr
, entry
, tdata
, entry
->extra_data
);
1167 if (needs_refresh
!=0 && !scr
->flags
.startup
) {
1171 if (needs_refresh
& REFRESH_MENU_TITLE_TEXTURE
)
1172 foo
|= WTextureSettings
;
1173 if (needs_refresh
& REFRESH_MENU_TITLE_FONT
)
1174 foo
|= WFontSettings
;
1175 if (needs_refresh
& REFRESH_MENU_TITLE_COLOR
)
1176 foo
|= WColorSettings
;
1178 WMPostNotificationName(WNMenuTitleAppearanceSettingsChanged
, NULL
,
1182 if (needs_refresh
& REFRESH_MENU_TEXTURE
)
1183 foo
|= WTextureSettings
;
1184 if (needs_refresh
& REFRESH_MENU_FONT
)
1185 foo
|= WFontSettings
;
1186 if (needs_refresh
& REFRESH_MENU_COLOR
)
1187 foo
|= WColorSettings
;
1189 WMPostNotificationName(WNMenuAppearanceSettingsChanged
, NULL
,
1193 if (needs_refresh
& REFRESH_WINDOW_FONT
) {
1194 foo
|= WFontSettings
;
1196 if (needs_refresh
& REFRESH_WINDOW_TEXTURES
) {
1197 foo
|= WTextureSettings
;
1199 if (needs_refresh
& REFRESH_WINDOW_TITLE_COLOR
) {
1200 foo
|= WColorSettings
;
1203 WMPostNotificationName(WNWindowAppearanceSettingsChanged
, NULL
,
1206 if (!(needs_refresh
& REFRESH_ICON_TILE
)) {
1208 if (needs_refresh
& REFRESH_ICON_FONT
) {
1209 foo
|= WFontSettings
;
1211 if (needs_refresh
& REFRESH_ICON_TITLE_COLOR
) {
1212 foo
|= WTextureSettings
;
1214 if (needs_refresh
& REFRESH_ICON_TITLE_BACK
) {
1215 foo
|= WTextureSettings
;
1218 WMPostNotificationName(WNIconAppearanceSettingsChanged
, NULL
,
1221 if (needs_refresh
& REFRESH_ICON_TILE
)
1222 WMPostNotificationName(WNIconTileSettingsChanged
, NULL
, NULL
);
1228 wDefaultUpdateIcons(WScreen
*scr
)
1230 WAppIcon
*aicon
= scr
->app_icon_list
;
1231 WWindow
*wwin
= scr
->focused_window
;
1235 file
= wDefaultGetIconFile(scr
, aicon
->wm_instance
, aicon
->wm_class
,
1237 if ((file
&& aicon
->icon
->file
&& strcmp(file
, aicon
->icon
->file
)!=0)
1238 || (file
&& !aicon
->icon
->file
)) {
1241 if (aicon
->icon
->file
)
1242 free(aicon
->icon
->file
);
1243 aicon
->icon
->file
= wstrdup(file
);
1245 new_image
= wDefaultGetImage(scr
, aicon
->wm_instance
,
1248 wIconChangeImage(aicon
->icon
, new_image
);
1249 wAppIconPaint(aicon
);
1252 aicon
= aicon
->next
;
1255 if (!wPreferences
.flags
.noclip
)
1256 wClipIconPaint(scr
->clip_icon
);
1259 if (wwin
->icon
&& wwin
->flags
.miniaturized
) {
1260 file
= wDefaultGetIconFile(scr
, wwin
->wm_instance
, wwin
->wm_class
,
1262 if ((file
&& wwin
->icon
->file
&& strcmp(file
, wwin
->icon
->file
)!=0)
1263 || (file
&& !wwin
->icon
->file
)) {
1266 if (wwin
->icon
->file
)
1267 free(wwin
->icon
->file
);
1268 wwin
->icon
->file
= wstrdup(file
);
1270 new_image
= wDefaultGetImage(scr
, wwin
->wm_instance
,
1273 wIconChangeImage(wwin
->icon
, new_image
);
1281 /* --------------------------- Local ----------------------- */
1283 #define STRINGP(x) if (!PLIsString(value)) { \
1284 wwarning(_("Wrong option format for key \"%s\". Should be %s."), \
1291 string2index(proplist_t key
, proplist_t val
, proplist_t def
,
1292 WOptionEnumeration
*values
)
1295 WOptionEnumeration
*v
;
1296 char buffer
[TOTAL_VALUES_LENGTH
];
1298 if (PLIsString(val
) && (str
= PLGetString(val
))) {
1299 for (v
=values
; v
->string
!=NULL
; v
++) {
1300 if (strcasecmp(v
->string
, str
)==0)
1306 for (v
=values
; v
->string
!=NULL
; v
++) {
1309 strcat(buffer
, ", ");
1310 strcat(buffer
, v
->string
);
1313 wwarning(_("wrong option value for key \"%s\". Should be one of %s"),
1314 PLGetString(key
), buffer
);
1317 return string2index(key
, val
, NULL
, values
);
1327 * value - is the value in the defaults DB
1328 * addr - is the address to store the data
1329 * ret - is the address to store a pointer to a temporary buffer. ret
1330 * must not be freed and is used by the set functions
1333 getBool(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
1342 val
= PLGetString(value
);
1345 if ((val
[1]=='\0' && (val
[0]=='y' || val
[0]=='Y'))
1346 || strcasecmp(val
, "YES")==0) {
1349 } else if ((val
[1]=='\0' && (val
[0]=='n' || val
[0]=='N'))
1350 || strcasecmp(val
, "NO")==0) {
1354 if (sscanf(val
, "%i", &i
)==1) {
1360 wwarning(_("can't convert \"%s\" to boolean for key \"%s\""),
1362 if (second_pass
==0) {
1363 val
= PLGetString(entry
->plvalue
);
1365 wwarning(_("using default \"%s\" instead"), val
);
1376 *(char*)addr
= data
;
1384 getInt(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
1393 val
= PLGetString(value
);
1395 if (sscanf(val
, "%i", &data
)!=1) {
1396 wwarning(_("can't convert \"%s\" to integer for key \"%s\""),
1398 val
= PLGetString(entry
->plvalue
);
1399 wwarning(_("using default \"%s\" instead"), val
);
1400 if (sscanf(val
, "%i", &data
)!=1) {
1416 getCoord(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
1420 char *val_x
, *val_y
;
1421 int nelem
, changed
=0;
1422 proplist_t elem_x
, elem_y
;
1425 if (!PLIsArray(value
)) {
1426 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1427 entry
->key
, "Coordinate");
1429 value
= entry
->plvalue
;
1431 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1437 nelem
= PLGetNumberOfElements(value
);
1439 wwarning(_("Incorrect number of elements in array for key \"%s\"."),
1442 value
= entry
->plvalue
;
1444 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1450 elem_x
= PLGetArrayElement(value
, 0);
1451 elem_y
= PLGetArrayElement(value
, 1);
1453 if (!elem_x
|| !elem_y
|| !PLIsString(elem_x
) || !PLIsString(elem_y
)) {
1454 wwarning(_("Wrong value for key \"%s\". Should be Coordinate."),
1457 value
= entry
->plvalue
;
1459 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1465 val_x
= PLGetString(elem_x
);
1466 val_y
= PLGetString(elem_y
);
1468 if (sscanf(val_x
, "%i", &data
.x
)!=1 || sscanf(val_y
, "%i", &data
.y
)!=1) {
1469 wwarning(_("can't convert array to integers for \"%s\"."), entry
->key
);
1471 value
= entry
->plvalue
;
1473 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1481 else if (data
.x
> scr
->scr_width
/3)
1482 data
.x
= scr
->scr_width
/3;
1485 else if (data
.y
> scr
->scr_height
/3)
1486 data
.y
= scr
->scr_height
/3;
1492 *(WCoord
*)addr
= data
;
1500 /* This function is not used at the moment. */
1502 getString(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
1509 data
= PLGetString(value
);
1512 data
= PLGetString(entry
->plvalue
);
1521 *(char**)addr
= wstrdup(data
);
1529 getPathList(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
1539 if (!PLIsArray(value
)) {
1540 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1541 entry
->key
, "an array of paths");
1543 value
= entry
->plvalue
;
1545 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1552 count
= PLGetNumberOfElements(value
);
1555 value
= entry
->plvalue
;
1557 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1564 for (i
=0; i
<count
; i
++) {
1565 d
= PLGetArrayElement(value
, i
);
1566 if (!d
|| !PLIsString(d
)) {
1570 len
+= strlen(PLGetString(d
))+1;
1573 ptr
= data
= wmalloc(len
+1);
1575 for (i
=0; i
<count
; i
++) {
1576 d
= PLGetArrayElement(value
, i
);
1577 if (!d
|| !PLIsString(d
)) {
1580 strcpy(ptr
, PLGetString(d
));
1581 ptr
+= strlen(PLGetString(d
));
1585 ptr
--; *(ptr
--) = 0;
1587 if (*(char**)addr
!=NULL
) {
1588 free(*(char**)addr
);
1590 *(char**)addr
= data
;
1597 getEnum(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
1600 static signed char data
;
1602 data
= string2index(entry
->plkey
, value
, entry
->default_value
,
1603 (WOptionEnumeration
*)entry
->extra_data
);
1611 *(signed char*)addr
= data
;
1620 * (hgradient <color> <color>)
1621 * (vgradient <color> <color>)
1622 * (dgradient <color> <color>)
1623 * (mhgradient <color> <color> ...)
1624 * (mvgradient <color> <color> ...)
1625 * (tpixmap <file> <color>)
1626 * (spixmap <file> <color>)
1627 * (cpixmap <file> <color>)
1628 * (thgradient <file> <opaqueness> <color> <color>)
1629 * (tvgradient <file> <opaqueness> <color> <color>)
1630 * (tdgradient <file> <opaqueness> <color> <color>)
1631 * (function <lib> <function> ...)
1635 parse_texture(WScreen
*scr
, proplist_t pl
)
1640 WTexture
*texture
=NULL
;
1642 nelem
= PLGetNumberOfElements(pl
);
1647 elem
= PLGetArrayElement(pl
, 0);
1648 if (!elem
|| !PLIsString(elem
))
1650 val
= PLGetString(elem
);
1653 if (strcasecmp(val
, "solid")==0) {
1661 elem
= PLGetArrayElement(pl
, 1);
1662 if (!elem
|| !PLIsString(elem
))
1664 val
= PLGetString(elem
);
1666 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &color
)) {
1667 wwarning(_("\"%s\" is not a valid color name"), val
);
1671 texture
= (WTexture
*)wTextureMakeSolid(scr
, &color
);
1672 } else if (strcasecmp(val
, "dgradient")==0
1673 || strcasecmp(val
, "vgradient")==0
1674 || strcasecmp(val
, "hgradient")==0) {
1675 RColor color1
, color2
;
1680 wwarning(_("bad number of arguments in gradient specification"));
1684 if (val
[0]=='d' || val
[0]=='D')
1685 type
= WTEX_DGRADIENT
;
1686 else if (val
[0]=='h' || val
[0]=='H')
1687 type
= WTEX_HGRADIENT
;
1689 type
= WTEX_VGRADIENT
;
1692 /* get from color */
1693 elem
= PLGetArrayElement(pl
, 1);
1694 if (!elem
|| !PLIsString(elem
))
1696 val
= PLGetString(elem
);
1698 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1699 wwarning(_("\"%s\" is not a valid color name"), val
);
1703 color1
.red
= xcolor
.red
>> 8;
1704 color1
.green
= xcolor
.green
>> 8;
1705 color1
.blue
= xcolor
.blue
>> 8;
1708 elem
= PLGetArrayElement(pl
, 2);
1709 if (!elem
|| !PLIsString(elem
)) {
1712 val
= PLGetString(elem
);
1714 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1715 wwarning(_("\"%s\" is not a valid color name"), val
);
1719 color2
.red
= xcolor
.red
>> 8;
1720 color2
.green
= xcolor
.green
>> 8;
1721 color2
.blue
= xcolor
.blue
>> 8;
1723 texture
= (WTexture
*)wTextureMakeGradient(scr
, type
, &color1
, &color2
);
1725 } else if (strcasecmp(val
, "mhgradient")==0
1726 || strcasecmp(val
, "mvgradient")==0
1727 || strcasecmp(val
, "mdgradient")==0) {
1734 wwarning(_("too few arguments in multicolor gradient specification"));
1738 if (val
[1]=='h' || val
[1]=='H')
1739 type
= WTEX_MHGRADIENT
;
1740 else if (val
[1]=='v' || val
[1]=='V')
1741 type
= WTEX_MVGRADIENT
;
1743 type
= WTEX_MDGRADIENT
;
1747 colors
= wmalloc(sizeof(RColor
*)*(count
+1));
1749 for (i
=0; i
<count
; i
++) {
1750 elem
= PLGetArrayElement(pl
, i
+1);
1751 if (!elem
|| !PLIsString(elem
)) {
1752 for (--i
; i
>=0; --i
) {
1758 val
= PLGetString(elem
);
1760 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &color
)) {
1761 wwarning(_("\"%s\" is not a valid color name"), val
);
1762 for (--i
; i
>=0; --i
) {
1768 colors
[i
] = wmalloc(sizeof(RColor
));
1769 colors
[i
]->red
= color
.red
>> 8;
1770 colors
[i
]->green
= color
.green
>> 8;
1771 colors
[i
]->blue
= color
.blue
>> 8;
1776 texture
= (WTexture
*)wTextureMakeMGradient(scr
, type
, colors
);
1777 } else if (strcasecmp(val
, "spixmap")==0 ||
1778 strcasecmp(val
, "cpixmap")==0 ||
1779 strcasecmp(val
, "tpixmap")==0) {
1786 if (val
[0] == 's' || val
[0] == 'S')
1788 else if (val
[0] == 'c' || val
[0] == 'C')
1794 elem
= PLGetArrayElement(pl
, 2);
1795 if (!elem
|| !PLIsString(elem
)) {
1798 val
= PLGetString(elem
);
1800 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &color
)) {
1801 wwarning(_("\"%s\" is not a valid color name"), val
);
1806 elem
= PLGetArrayElement(pl
, 1);
1807 if (!elem
|| !PLIsString(elem
))
1809 val
= PLGetString(elem
);
1811 texture
= (WTexture
*)wTextureMakePixmap(scr
, type
, val
, &color
);
1812 } else if (strcasecmp(val
, "thgradient")==0
1813 || strcasecmp(val
, "tvgradient")==0
1814 || strcasecmp(val
, "tdgradient")==0) {
1815 RColor color1
, color2
;
1820 if (val
[1]=='h' || val
[1]=='H')
1821 style
= WTEX_THGRADIENT
;
1822 else if (val
[1]=='v' || val
[1]=='V')
1823 style
= WTEX_TVGRADIENT
;
1825 style
= WTEX_TDGRADIENT
;
1828 wwarning(_("bad number of arguments in textured gradient specification"));
1832 /* get from color */
1833 elem
= PLGetArrayElement(pl
, 3);
1834 if (!elem
|| !PLIsString(elem
))
1836 val
= PLGetString(elem
);
1838 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1839 wwarning(_("\"%s\" is not a valid color name"), val
);
1843 color1
.red
= xcolor
.red
>> 8;
1844 color1
.green
= xcolor
.green
>> 8;
1845 color1
.blue
= xcolor
.blue
>> 8;
1848 elem
= PLGetArrayElement(pl
, 4);
1849 if (!elem
|| !PLIsString(elem
)) {
1852 val
= PLGetString(elem
);
1854 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1855 wwarning(_("\"%s\" is not a valid color name"), val
);
1859 color2
.red
= xcolor
.red
>> 8;
1860 color2
.green
= xcolor
.green
>> 8;
1861 color2
.blue
= xcolor
.blue
>> 8;
1864 elem
= PLGetArrayElement(pl
, 2);
1865 if (!elem
|| !PLIsString(elem
))
1868 val
= PLGetString(elem
);
1870 if (!val
|| (opacity
= atoi(val
)) < 0 || opacity
> 255) {
1871 wwarning(_("bad opacity value for tgradient texture \"%s\". Should be [0..255]"), val
);
1876 elem
= PLGetArrayElement(pl
, 1);
1877 if (!elem
|| !PLIsString(elem
))
1879 val
= PLGetString(elem
);
1881 texture
= (WTexture
*)wTextureMakeTGradient(scr
, style
, &color1
, &color2
,
1884 #ifdef TEXTURE_PLUGIN
1885 else if (strcasecmp(val
, "function")==0) {
1886 WTexFunction
*function
;
1887 void (*initFunc
) (Display
*, Colormap
);
1888 char *lib
, *func
, **argv
;
1894 /* get the library name */
1895 elem
= PLGetArrayElement(pl
, 1);
1896 if (!elem
|| !PLIsString(elem
)) {
1899 lib
= PLGetString(elem
);
1901 /* get the function name */
1902 elem
= PLGetArrayElement(pl
, 2);
1903 if (!elem
|| !PLIsString(elem
)) {
1906 func
= PLGetString(elem
);
1909 argv
= (char **)wmalloc(argc
* sizeof(char *));
1911 /* get the parameters */
1912 argv
[0] = wstrdup(func
);
1913 for (i
= 0; i
< argc
- 1; i
++) {
1914 elem
= PLGetArrayElement(pl
, 3 + i
);
1915 if (!elem
|| !PLIsString(elem
)) {
1920 argv
[i
+1] = wstrdup(PLGetString(elem
));
1923 function
= wTextureMakeFunction(scr
, lib
, func
, argc
, argv
);
1927 initFunc
= dlsym(function
->handle
, "initWindowMaker");
1929 initFunc(dpy
, scr
->w_colormap
);
1931 wwarning(_("could not initialize library %s"), lib
);
1934 wwarning(_("could not find function %s::%s"), lib
, func
);
1936 #endif /* HAVE_DLFCN_H */
1937 texture
= (WTexture
*)function
;
1939 #endif /* TEXTURE_PLUGIN */
1941 wwarning(_("invalid texture type %s"), val
);
1950 getTexture(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
1953 static WTexture
*texture
;
1957 if (!PLIsArray(value
)) {
1958 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1959 entry
->key
, "Texture");
1961 value
= entry
->plvalue
;
1963 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1969 if (strcmp(entry
->key
, "WidgetColor")==0 && !changed
) {
1972 pl
= PLGetArrayElement(value
, 0);
1973 if (!pl
|| !PLIsString(pl
) || !PLGetString(pl
)
1974 || strcasecmp(PLGetString(pl
), "solid")!=0) {
1975 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1976 entry
->key
, "Solid Texture");
1978 value
= entry
->plvalue
;
1980 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1985 texture
= parse_texture(scr
, value
);
1988 wwarning(_("Error in texture specification for key \"%s\""),
1991 value
= entry
->plvalue
;
1993 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
2003 *(WTexture
**)addr
= texture
;
2010 #ifdef DRAWSTRING_PLUGIN
2012 getTextRenderer(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
,
2013 void *addr
, void **ret
)
2016 char *val
, *lib
, *func
, **argv
;
2017 int argc
, i
, changed
;
2019 if (strcmp(entry
->key
, "FTitleColor")==0) {
2020 wPluginDestroyFunction(scr
->drawstring_func
[changed
= W_STRING_FTITLE
]);
2021 scr
->drawstring_func
[W_STRING_FTITLE
] = NULL
;
2022 } else if (strcmp(entry
->key
, "UTitleColor")==0) {
2023 wPluginDestroyFunction(scr
->drawstring_func
[changed
= W_STRING_UTITLE
]);
2024 scr
->drawstring_func
[W_STRING_UTITLE
] = NULL
;
2025 } else if (strcmp(entry
->key
, "PTitleColor")==0) {
2026 wPluginDestroyFunction(scr
->drawstring_func
[changed
= W_STRING_PTITLE
]);
2027 scr
->drawstring_func
[W_STRING_PTITLE
] = NULL
;
2028 } else if (strcmp(entry
->key
, "MenuTitleColor")==0) {
2029 wPluginDestroyFunction(scr
->drawstring_func
[changed
= W_STRING_MTITLE
]);
2030 scr
->drawstring_func
[W_STRING_MTITLE
] = NULL
;
2031 } else if (strcmp(entry
->key
, "MenuPluginColor")==0) {
2032 wPluginDestroyFunction(scr
->drawstring_func
[changed
= W_STRING_MTEXT
]);
2033 scr
->drawstring_func
[W_STRING_MTEXT
] = NULL
;
2036 if (PLIsArray(value
)) {
2037 if ((argc
= PLGetNumberOfElements(value
)) < 4) return False
;
2039 argv
= (char **)wmalloc(argc
* sizeof(char *));
2041 elem
= PLGetArrayElement(value
,0);
2042 if (!elem
|| !PLIsString(elem
)) return False
;
2043 val
= PLGetString(elem
);
2044 if (strcasecmp(val
, "function")==0) {
2045 elem
= PLGetArrayElement(value
, 1); /* library name */
2046 if (!elem
|| !PLIsString(elem
)) return False
;
2047 lib
= PLGetString(elem
);
2048 elem
= PLGetArrayElement(value
, 2); /* function name */
2049 if (!elem
|| !PLIsString(elem
)) return False
;
2050 func
= PLGetString(elem
);
2051 scr
->drawstring_func
[changed
] = wPluginCreateFunction (W_FUNCTION_DRAWSTRING
,
2052 lib
, "initDrawString", func
, NULL
, value
,
2053 wPluginPackInitData(3, dpy
, scr
->w_colormap
,"-DATA-"));
2056 return getColor(scr
, entry
, PLGetArrayElement(value
,3), addr
, ret
);
2057 } else if (PLIsString(value
)) {
2058 return getColor(scr
, entry
, value
, addr
, ret
);
2061 #endif /* DRAWSTRING_PLUGIN */
2066 getWSBackground(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
,
2067 void *addr
, void **ret
)
2075 if (!PLIsArray(value
)) {
2076 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
2077 "WorkspaceBack", "Texture or None");
2079 value
= entry
->plvalue
;
2081 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
2087 /* only do basic error checking and verify for None texture */
2089 nelem
= PLGetNumberOfElements(value
);
2091 elem
= PLGetArrayElement(value
, 0);
2092 if (!elem
|| !PLIsString(elem
)) {
2093 wwarning(_("Wrong type for workspace background. Should be a texture type."));
2095 value
= entry
->plvalue
;
2097 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
2102 val
= PLGetString(elem
);
2104 if (strcasecmp(val
, "None")==0)
2107 *ret
= PLRetain(value
);
2114 getWSSpecificBackground(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
,
2115 void *addr
, void **ret
)
2122 if (!PLIsArray(value
)) {
2123 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
2124 "WorkspaceSpecificBack", "an array of textures");
2126 value
= entry
->plvalue
;
2128 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
2134 /* only do basic error checking and verify for None texture */
2136 nelem
= PLGetNumberOfElements(value
);
2139 elem
= PLGetArrayElement(value
, nelem
);
2140 if (!elem
|| !PLIsArray(elem
)) {
2141 wwarning(_("Wrong type for background of workspace %i. Should be a texture."),
2147 *ret
= PLRetain(value
);
2151 * Kluge to force wmsetbg helper to set the default background.
2152 * If the WorkspaceSpecificBack is changed once wmaker has started,
2153 * the WorkspaceBack won't be sent to the helper, unless the user
2154 * changes it's value too. So, we must force this by removing the
2155 * value from the defaults DB.
2157 if (!scr
->flags
.backimage_helper_launched
&& !scr
->flags
.startup
) {
2158 proplist_t key
= PLMakeString("WorkspaceBack");
2160 PLRemoveDictionaryEntry(WDWindowMaker
->dictionary
, key
);
2170 getFont(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
2173 static WMFont
*font
;
2178 val
= PLGetString(value
);
2180 font
= WMCreateFont(scr
->wmscreen
, val
);
2182 font
= WMCreateFont(scr
->wmscreen
, "fixed");
2185 wfatal(_("could not load any usable font!!!"));
2192 /* can't assign font value outside update function */
2193 wassertrv(addr
== NULL
, True
);
2200 getColor(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
2203 static XColor color
;
2209 val
= PLGetString(value
);
2212 if (!wGetColor(scr
, val
, &color
)) {
2213 wwarning(_("could not get color for key \"%s\""),
2215 if (second_pass
==0) {
2216 val
= PLGetString(entry
->plvalue
);
2218 wwarning(_("using default \"%s\" instead"), val
);
2230 *(unsigned long*)addr = pixel;
2239 getKeybind(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
2242 static WShortKey shortcut
;
2249 STRINGP("Key spec");
2251 val
= PLGetString(value
);
2253 if (!val
|| strcasecmp(val
, "NONE")==0) {
2254 shortcut
.keycode
= 0;
2255 shortcut
.modifier
= 0;
2266 shortcut
.modifier
= 0;
2267 while ((k
= strchr(b
, '+'))!=NULL
) {
2271 mod
= wXModifierFromKey(b
);
2273 wwarning(_("%s:invalid key modifier \"%s\""), entry
->key
, b
);
2276 shortcut
.modifier
|= mod
;
2282 ksym
= XStringToKeysym(b
);
2284 if (ksym
==NoSymbol
) {
2285 wwarning(_("%s:invalid kbd shortcut specification \"%s\""), entry
->key
,
2290 shortcut
.keycode
= XKeysymToKeycode(dpy
, ksym
);
2291 if (shortcut
.keycode
==0) {
2292 wwarning(_("%s:invalid key in shortcut \"%s\""), entry
->key
, val
);
2304 getModMask(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
2307 static unsigned int mask
;
2310 STRINGP("Modifier Key");
2312 str
= PLGetString(value
);
2316 mask
= wXModifierFromKey(str
);
2318 wwarning(_("%s: modifier key %s is not valid"), entry
->key
, str
);
2324 *(unsigned int*)addr
= mask
;
2335 getRImages(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
,
2336 void *addr
, void **ret
)
2344 STRINGP("Image File Path");
2346 str
= PLGetString(value
);
2350 image
= RLoadImage(scr
->rcontext
, str
, 0);
2352 wwarning(_("could not load image in option %s: %s"), entry
->key
,
2353 RMessageForError(RErrorCode
));
2357 if (*(RImage
**)addr
) {
2358 RDestroyImage(*(RImage
**)addr
);
2361 *(RImage
**)addr
= image
;
2363 assert(ret
== NULL
);
2366 *(RImage**)ret = image;
2374 /* ---------------- value setting functions --------------- */
2376 setJustify(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
2378 return REFRESH_WINDOW_TITLE_COLOR
;
2383 setIfDockPresent(WScreen
*scr
, WDefaultEntry
*entry
, int *flag
, long which
)
2387 wPreferences
.flags
.nodock
= wPreferences
.flags
.nodock
|| *flag
;
2390 wPreferences
.flags
.noclip
= wPreferences
.flags
.noclip
|| *flag
;
2400 setStickyIcons(WScreen
*scr
, WDefaultEntry
*entry
, void *bar
, void *foo
)
2402 if (scr
->workspaces
) {
2403 wWorkspaceForceChange(scr
, scr
->current_workspace
);
2404 wArrangeIcons(scr
, False
);
2411 setPositive(WScreen
*scr
, WDefaultEntry
*entry
, int *value
, void *foo
)
2423 setIconTile(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
2429 img
= wTextureRenderImage(*texture
, wPreferences
.icon_size
,
2430 wPreferences
.icon_size
,
2431 ((*texture
)->any
.type
& WREL_BORDER_MASK
)
2432 ? WREL_ICON
: WREL_FLAT
);
2434 wwarning(_("could not render texture for icon background"));
2436 wTextureDestroy(scr
, *texture
);
2439 RConvertImage(scr
->rcontext
, img
, &pixmap
);
2441 if (scr
->icon_tile
) {
2443 RDestroyImage(scr
->icon_tile
);
2444 XFreePixmap(dpy
, scr
->icon_tile_pixmap
);
2447 scr
->icon_tile
= img
;
2449 if (!wPreferences
.flags
.noclip
) {
2450 if (scr
->clip_tile
) {
2451 RDestroyImage(scr
->clip_tile
);
2453 scr
->clip_tile
= wClipMakeTile(scr
, img
);
2456 scr
->icon_tile_pixmap
= pixmap
;
2458 if (scr
->def_icon_pixmap
) {
2459 XFreePixmap(dpy
, scr
->def_icon_pixmap
);
2460 scr
->def_icon_pixmap
= None
;
2462 if (scr
->def_ticon_pixmap
) {
2463 XFreePixmap(dpy
, scr
->def_ticon_pixmap
);
2464 scr
->def_ticon_pixmap
= None
;
2467 if (scr
->icon_back_texture
) {
2468 wTextureDestroy(scr
, (WTexture
*)scr
->icon_back_texture
);
2470 scr
->icon_back_texture
= wTextureMakeSolid(scr
, &((*texture
)->any
.color
));
2472 if (scr
->clip_balloon
)
2473 XSetWindowBackground(dpy
, scr
->clip_balloon
,
2474 (*texture
)->any
.color
.pixel
);
2477 * Free the texture as nobody else will use it, nor refer to it.
2480 wTextureDestroy(scr
, *texture
);
2482 return (reset
? REFRESH_ICON_TILE
: 0);
2488 setWinTitleFont(WScreen
*scr
, WDefaultEntry
*entry
, WMFont
*font
, void *foo
)
2490 if (scr
->title_font
) {
2491 WMReleaseFont(scr
->title_font
);
2493 scr
->title_font
= font
;
2495 return REFRESH_WINDOW_FONT
|REFRESH_BUTTON_IMAGES
;
2500 setMenuTitleFont(WScreen
*scr
, WDefaultEntry
*entry
, WMFont
*font
, void *foo
)
2502 if (scr
->menu_title_font
) {
2503 WMReleaseFont(scr
->menu_title_font
);
2506 scr
->menu_title_font
= font
;
2508 return REFRESH_MENU_TITLE_FONT
;
2513 setMenuTextFont(WScreen
*scr
, WDefaultEntry
*entry
, WMFont
*font
, void *foo
)
2515 if (scr
->menu_entry_font
) {
2516 WMReleaseFont(scr
->menu_entry_font
);
2518 scr
->menu_entry_font
= font
;
2520 return REFRESH_MENU_FONT
;
2526 setIconTitleFont(WScreen
*scr
, WDefaultEntry
*entry
, WMFont
*font
, void *foo
)
2528 if (scr
->icon_title_font
) {
2529 WMReleaseFont(scr
->icon_title_font
);
2532 scr
->icon_title_font
= font
;
2534 return REFRESH_ICON_FONT
;
2539 setClipTitleFont(WScreen
*scr
, WDefaultEntry
*entry
, WMFont
*font
, void *foo
)
2541 if (scr
->clip_title_font
) {
2542 WMReleaseFont(scr
->clip_title_font
);
2545 scr
->clip_title_font
= font
;
2547 return REFRESH_ICON_FONT
;
2552 setDisplayFont(WScreen
*scr
, WDefaultEntry
*entry
, WMFont
*font
, void *foo
)
2554 if (scr
->info_text_font
) {
2555 WMReleaseFont(scr
->info_text_font
);
2558 scr
->info_text_font
= font
;
2560 /* This test works because the scr structure is initially zeroed out
2561 and None = 0. Any other time, the window should be valid. */
2562 if (scr
->geometry_display
!= None
) {
2563 wGetGeometryWindowSize(scr
, &scr
->geometry_display_width
,
2564 &scr
->geometry_display_height
);
2565 XResizeWindow(dpy
, scr
->geometry_display
,
2566 scr
->geometry_display_width
, scr
->geometry_display_height
);
2574 setLargeDisplayFont(WScreen
*scr
, WDefaultEntry
*entry
, WMFont
*font
, void *foo
)
2576 if (scr
->workspace_name_font
) {
2577 WMReleaseFont(scr
->workspace_name_font
);
2580 scr
->workspace_name_font
= font
;
2587 setHightlight(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, void *foo
)
2589 if (scr
->select_pixel
!=scr
->white_pixel
&&
2590 scr
->select_pixel
!=scr
->black_pixel
) {
2591 wFreeColor(scr
, scr
->select_pixel
);
2594 scr
->select_pixel
= color
->pixel
;
2596 return REFRESH_MENU_COLOR
;
2601 setHightlightText(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, void *foo
)
2603 if (scr
->select_text_pixel
!=scr
->white_pixel
&&
2604 scr
->select_text_pixel
!=scr
->black_pixel
) {
2605 wFreeColor(scr
, scr
->select_text_pixel
);
2608 scr
->select_text_pixel
= color
->pixel
;
2610 return REFRESH_MENU_COLOR
;
2615 setClipTitleColor(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, long index
)
2617 if (scr
->clip_title_pixel
[index
]!=scr
->white_pixel
&&
2618 scr
->clip_title_pixel
[index
]!=scr
->black_pixel
) {
2619 wFreeColor(scr
, scr
->clip_title_pixel
[index
]);
2621 scr
->clip_title_pixel
[index
] = color
->pixel
;
2623 #ifdef GRADIENT_CLIP_ARROW
2624 if (index
== CLIP_NORMAL
) {
2626 RColor color1
, color2
;
2627 int pt
= CLIP_BUTTON_SIZE
*wPreferences
.icon_size
/64;
2628 int as
= pt
- 15; /* 15 = 5+5+5 */
2630 FREE_PIXMAP(scr
->clip_arrow_gradient
);
2632 color1
.red
= (color
->red
>> 8)*6/10;
2633 color1
.green
= (color
->green
>> 8)*6/10;
2634 color1
.blue
= (color
->blue
>> 8)*6/10;
2636 color2
.red
= WMIN((color
->red
>> 8)*20/10, 255);
2637 color2
.green
= WMIN((color
->green
>> 8)*20/10, 255);
2638 color2
.blue
= WMIN((color
->blue
>> 8)*20/10, 255);
2640 image
= RRenderGradient(as
+1, as
+1, &color1
, &color2
, RDiagonalGradient
);
2641 RConvertImage(scr
->rcontext
, image
, &scr
->clip_arrow_gradient
);
2642 RDestroyImage(image
);
2644 #endif /* GRADIENT_CLIP_ARROW */
2646 return REFRESH_ICON_TITLE_COLOR
;
2651 setWTitleColor(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, long index
)
2653 if (scr
->window_title_pixel
[index
]!=scr
->white_pixel
&&
2654 scr
->window_title_pixel
[index
]!=scr
->black_pixel
) {
2655 wFreeColor(scr
, scr
->window_title_pixel
[index
]);
2658 scr
->window_title_pixel
[index
] = color
->pixel
;
2660 if (index
== WS_UNFOCUSED
)
2661 XSetForeground(dpy
, scr
->info_text_gc
, color
->pixel
);
2663 return REFRESH_WINDOW_TITLE_COLOR
;
2668 setMenuTitleColor(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, long index
)
2670 if (scr
->menu_title_pixel
[0]!=scr
->white_pixel
&&
2671 scr
->menu_title_pixel
[0]!=scr
->black_pixel
) {
2672 #ifdef DRAWSTRING_PLUGIN
2673 if(!scr
->drawstring_func
[W_STRING_MTITLE
])
2675 wFreeColor(scr
, scr
->menu_title_pixel
[0]);
2678 scr
->menu_title_pixel
[0] = color
->pixel
;
2679 XSetForeground(dpy
, scr
->menu_title_gc
, color
->pixel
);
2681 return REFRESH_MENU_TITLE_COLOR
;
2686 setMenuTextColor(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, void *foo
)
2689 #define gcm (GCForeground|GCBackground|GCFillStyle)
2691 if (scr
->mtext_pixel
!=scr
->white_pixel
&&
2692 scr
->mtext_pixel
!=scr
->black_pixel
) {
2693 wFreeColor(scr
, scr
->mtext_pixel
);
2696 scr
->mtext_pixel
= color
->pixel
;
2698 XSetForeground(dpy
, scr
->menu_entry_gc
, color
->pixel
);
2701 if (scr
->dtext_pixel
== scr
->mtext_pixel
) {
2702 gcv
.foreground
= scr
->white_pixel
;
2703 gcv
.background
= scr
->black_pixel
;
2704 gcv
.fill_style
= FillStippled
;
2706 gcv
.foreground
= scr
->dtext_pixel
;
2707 gcv
.fill_style
= FillSolid
;
2709 XChangeGC(dpy
, scr
->disabled_menu_entry_gc
, gcm
, &gcv
);
2711 return REFRESH_MENU_COLOR
;
2717 setMenuDisabledColor(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, void *foo
)
2720 #define gcm (GCForeground|GCBackground|GCFillStyle)
2722 if (scr
->dtext_pixel
!=scr
->white_pixel
&&
2723 scr
->dtext_pixel
!=scr
->black_pixel
) {
2724 wFreeColor(scr
, scr
->dtext_pixel
);
2727 scr
->dtext_pixel
= color
->pixel
;
2729 if (scr
->dtext_pixel
== scr
->mtext_pixel
) {
2730 gcv
.foreground
= scr
->white_pixel
;
2731 gcv
.background
= scr
->black_pixel
;
2732 gcv
.fill_style
= FillStippled
;
2734 gcv
.foreground
= scr
->dtext_pixel
;
2735 gcv
.fill_style
= FillSolid
;
2737 XChangeGC(dpy
, scr
->disabled_menu_entry_gc
, gcm
, &gcv
);
2739 return REFRESH_MENU_COLOR
;
2744 setIconTitleColor(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, void *foo
)
2746 XSetForeground(dpy
, scr
->icon_title_gc
, color
->pixel
);
2748 return REFRESH_ICON_TITLE_COLOR
;
2753 setIconTitleBack(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, void *foo
)
2755 if (scr
->icon_title_texture
) {
2756 wTextureDestroy(scr
, (WTexture
*)scr
->icon_title_texture
);
2758 XQueryColor (dpy
, scr
->w_colormap
, color
);
2759 scr
->icon_title_texture
= wTextureMakeSolid(scr
, color
);
2761 return REFRESH_ICON_TITLE_BACK
;
2766 trackDeadProcess(pid_t pid
, unsigned char status
, WScreen
*scr
)
2768 close(scr
->helper_fd
);
2770 scr
->helper_pid
= 0;
2771 scr
->flags
.backimage_helper_launched
= 0;
2776 setWorkspaceSpecificBack(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
,
2783 if (scr
->flags
.backimage_helper_launched
) {
2784 if (PLGetNumberOfElements(value
)==0) {
2785 SendHelperMessage(scr
, 'C', 0, NULL
);
2786 SendHelperMessage(scr
, 'K', 0, NULL
);
2795 if (PLGetNumberOfElements(value
) == 0)
2798 if (pipe(filedes
) < 0) {
2799 wsyserror("pipe() failed:can't set workspace specific background image");
2807 wsyserror("fork() failed:can't set workspace specific background image");
2808 if (close(filedes
[0]) < 0)
2809 wsyserror("could not close pipe");
2810 if (close(filedes
[1]) < 0)
2811 wsyserror("could not close pipe");
2813 } else if (pid
== 0) {
2814 SetupEnvironment(scr
);
2817 wsyserror("could not close pipe");
2818 if (dup(filedes
[0]) < 0) {
2819 wsyserror("dup() failed:can't set workspace specific background image");
2821 if (wPreferences
.smooth_workspace_back
)
2822 execlp("wmsetbg", "wmsetbg", "-helper", "-S", "-d", NULL
);
2824 execlp("wmsetbg", "wmsetbg", "-helper", "-d", NULL
);
2825 wsyserror("could not execute wmsetbg");
2829 if (fcntl(filedes
[0], F_SETFD
, FD_CLOEXEC
) < 0) {
2830 wsyserror("error setting close-on-exec flag");
2832 if (fcntl(filedes
[1], F_SETFD
, FD_CLOEXEC
) < 0) {
2833 wsyserror("error setting close-on-exec flag");
2836 scr
->helper_fd
= filedes
[1];
2837 scr
->helper_pid
= pid
;
2838 scr
->flags
.backimage_helper_launched
= 1;
2840 wAddDeathHandler(pid
, (WDeathHandler
*)trackDeadProcess
, scr
);
2842 SendHelperMessage(scr
, 'P', -1, wPreferences
.pixmap_path
);
2846 for (i
= 0; i
< PLGetNumberOfElements(value
); i
++) {
2847 val
= PLGetArrayElement(value
, i
);
2848 if (val
&& PLIsArray(val
) && PLGetNumberOfElements(val
)>0) {
2849 str
= PLGetDescription(val
);
2851 SendHelperMessage(scr
, 'S', i
+1, str
);
2855 SendHelperMessage(scr
, 'U', i
+1, NULL
);
2866 setWorkspaceBack(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
,
2869 if (scr
->flags
.backimage_helper_launched
) {
2872 if (PLGetNumberOfElements(value
)==0) {
2873 SendHelperMessage(scr
, 'U', 0, NULL
);
2875 /* set the default workspace background to this one */
2876 str
= PLGetDescription(value
);
2878 SendHelperMessage(scr
, 'S', 0, str
);
2880 SendHelperMessage(scr
, 'C', scr
->current_workspace
+1, NULL
);
2882 SendHelperMessage(scr
, 'U', 0, NULL
);
2889 SetupEnvironment(scr
);
2890 text
= PLGetDescription(value
);
2891 command
= wmalloc(strlen(text
)+40);
2892 if (wPreferences
.smooth_workspace_back
)
2893 sprintf(command
, "wmsetbg -d -S -p '%s' &", text
);
2895 sprintf(command
, "wmsetbg -d -p '%s' &", text
);
2907 setWidgetColor(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
2909 if (scr
->widget_texture
) {
2910 wTextureDestroy(scr
, (WTexture
*)scr
->widget_texture
);
2912 scr
->widget_texture
= *(WTexSolid
**)texture
;
2914 if (scr
->geometry_display
!= None
)
2915 XSetWindowBackground(dpy
, scr
->geometry_display
,
2916 scr
->widget_texture
->normal
.pixel
);
2923 setFTitleBack(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
2925 if (scr
->window_title_texture
[WS_FOCUSED
]) {
2926 wTextureDestroy(scr
, scr
->window_title_texture
[WS_FOCUSED
]);
2928 scr
->window_title_texture
[WS_FOCUSED
] = *texture
;
2930 return REFRESH_WINDOW_TEXTURES
;
2935 setPTitleBack(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
2937 if (scr
->window_title_texture
[WS_PFOCUSED
]) {
2938 wTextureDestroy(scr
, scr
->window_title_texture
[WS_PFOCUSED
]);
2940 scr
->window_title_texture
[WS_PFOCUSED
] = *texture
;
2942 return REFRESH_WINDOW_TEXTURES
;
2947 setUTitleBack(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
2949 if (scr
->window_title_texture
[WS_UNFOCUSED
]) {
2950 wTextureDestroy(scr
, scr
->window_title_texture
[WS_UNFOCUSED
]);
2952 scr
->window_title_texture
[WS_UNFOCUSED
] = *texture
;
2954 return REFRESH_WINDOW_TEXTURES
;
2959 setResizebarBack(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
2961 if (scr
->resizebar_texture
[0]) {
2962 wTextureDestroy(scr
, scr
->resizebar_texture
[0]);
2964 scr
->resizebar_texture
[0] = *texture
;
2966 return REFRESH_WINDOW_TEXTURES
;
2971 setMenuTitleBack(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
2973 if (scr
->menu_title_texture
[0]) {
2974 wTextureDestroy(scr
, scr
->menu_title_texture
[0]);
2976 scr
->menu_title_texture
[0] = *texture
;
2978 return REFRESH_MENU_TITLE_TEXTURE
;
2983 setMenuTextBack(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
2985 if (scr
->menu_item_texture
) {
2986 wTextureDestroy(scr
, scr
->menu_item_texture
);
2987 wTextureDestroy(scr
, (WTexture
*)scr
->menu_item_auxtexture
);
2989 scr
->menu_item_texture
= *texture
;
2991 scr
->menu_item_auxtexture
2992 = wTextureMakeSolid(scr
, &scr
->menu_item_texture
->any
.color
);
2994 return REFRESH_MENU_TEXTURE
;
2999 setKeyGrab(WScreen
*scr
, WDefaultEntry
*entry
, WShortKey
*shortcut
, long index
)
3002 wKeyBindings
[index
] = *shortcut
;
3004 wwin
= scr
->focused_window
;
3006 while (wwin
!=NULL
) {
3007 XUngrabKey(dpy
, AnyKey
, AnyModifier
, wwin
->frame
->core
->window
);
3009 if (!WFLAGP(wwin
, no_bind_keys
)) {
3010 wWindowSetKeyGrabs(wwin
);
3020 setIconPosition(WScreen
*scr
, WDefaultEntry
*entry
, void *bar
, void *foo
)
3022 wArrangeIcons(scr
, True
);
3029 updateUsableArea(WScreen
*scr
, WDefaultEntry
*entry
, void *bar
, void *foo
)
3031 wScreenUpdateUsableArea(scr
);
3038 setMenuStyle(WScreen
*scr
, WDefaultEntry
*entry
, int *value
, void *foo
)
3040 return REFRESH_MENU_TEXTURE
;
3046 setButtonImages(WScreen *scr, WDefaultEntry *entry, int *value, void *foo)
3048 return REFRESH_BUTTON_IMAGES;
3054 * Need access to the double click variables, so that all widgets in
3055 * wmaker panels will have the same dbl-click values.
3056 * TODO: figure a better way of dealing with it.
3061 setDoubleClick(WScreen
*scr
, WDefaultEntry
*entry
, int *value
, void *foo
)
3063 extern _WINGsConfiguration WINGsConfiguration
;
3068 WINGsConfiguration
.doubleClickDelay
= *value
;
3076 setMultiByte(WScreen
*scr
, WDefaultEntry
*entry
, int *value
, void *foo
)
3078 extern _WINGsConfiguration WINGsConfiguration
;
3080 WINGsConfiguration
.useMultiByte
= *value
;