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"
71 #include "properties.h"
75 * Our own proplist reader parser. This one will not accept any
76 * syntax errors and is more descriptive in the error messages.
77 * It also doesn't seem to crash.
79 extern proplist_t
ReadProplistFromFile(char *file
);
84 extern WDDomain
*WDWindowMaker
;
85 extern WDDomain
*WDWindowAttributes
;
86 extern WDDomain
*WDRootMenu
;
88 extern int wScreenCount
;
90 extern Atom _XA_WINDOWMAKER_ICON_SIZE
;
91 extern Atom _XA_WINDOWMAKER_ICON_TILE
;
94 extern proplist_t wDomainName;
95 extern proplist_t wAttributeDomainName;
97 extern WPreferences wPreferences
;
99 extern WShortKey wKeyBindings
[WKBD_LAST
];
109 proplist_t plvalue
; /* default value */
113 /* used to map strings to integers */
118 } WOptionEnumeration
;
121 /* type converters */
122 static int getBool();
124 static int getCoord();
126 /* this is not used yet */
127 static int getString();
129 static int getPathList();
130 static int getEnum();
131 static int getTexture();
132 #ifdef DRAWSTRING_PLUGIN
133 static int getTextRenderer();
135 static int getWSBackground();
136 static int getWSSpecificBackground();
137 static int getFont();
138 static int getColor();
139 static int getKeybind();
140 static int getModMask();
142 static int getRImage();
146 /* value setting functions */
147 static int setJustify();
148 static int setClearance();
149 static int setIfDockPresent();
150 static int setStickyIcons();
152 static int setPositive();
154 static int setWidgetColor();
155 static int setIconTile();
156 static int setWinTitleFont();
157 static int setMenuTitleFont();
158 static int setMenuTextFont();
159 static int setIconTitleFont();
160 static int setIconTitleColor();
161 static int setIconTitleBack();
162 static int setLargeDisplayFont();
163 static int setWTitleColor();
164 static int setFTitleBack();
165 static int setPTitleBack();
166 static int setUTitleBack();
167 static int setResizebarBack();
168 static int setWorkspaceBack();
169 static int setWorkspaceSpecificBack();
170 static int setMenuTitleColor();
171 static int setMenuTextColor();
172 static int setMenuDisabledColor();
173 static int setMenuTitleBack();
174 static int setMenuTextBack();
175 static int setHightlight();
176 static int setHightlightText();
177 static int setKeyGrab();
178 static int setDoubleClick();
179 static int setIconPosition();
181 static int setClipTitleFont();
182 static int setClipTitleColor();
184 static int setMenuStyle();
185 static int setMultiByte();
187 static int updateUsableArea();
192 * Tables to convert strings to enumeration values.
193 * Values stored are char
197 /* WARNING: sum of length of all value strings must not exceed
199 #define TOTAL_VALUES_LENGTH 80
204 #define REFRESH_WINDOW_TEXTURES (1<<0)
205 #define REFRESH_MENU_TEXTURE (1<<1)
206 #define REFRESH_MENU_FONT (1<<2)
207 #define REFRESH_MENU_COLOR (1<<3)
208 #define REFRESH_MENU_TITLE_TEXTURE (1<<4)
209 #define REFRESH_MENU_TITLE_FONT (1<<5)
210 #define REFRESH_MENU_TITLE_COLOR (1<<6)
211 #define REFRESH_WINDOW_TITLE_COLOR (1<<7)
212 #define REFRESH_WINDOW_FONT (1<<8)
213 #define REFRESH_ICON_TILE (1<<9)
214 #define REFRESH_ICON_FONT (1<<10)
215 #define REFRESH_WORKSPACE_BACK (1<<11)
217 #define REFRESH_BUTTON_IMAGES (1<<12)
219 #define REFRESH_ICON_TITLE_COLOR (1<<13)
220 #define REFRESH_ICON_TITLE_BACK (1<<14)
224 static WOptionEnumeration seFocusModes
[] = {
225 {"Manual", WKF_CLICK
, 0}, {"ClickToFocus", WKF_CLICK
, 1},
226 {"Auto", WKF_POINTER
, 0}, {"FocusFollowMouse", WKF_POINTER
, 1},
227 {"Sloppy", WKF_SLOPPY
, 0}, {"SemiAuto", WKF_SLOPPY
, 1},
231 static WOptionEnumeration seColormapModes
[] = {
232 {"Manual", WKF_CLICK
, 0}, {"ClickToFocus", WKF_CLICK
, 1},
233 {"Auto", WKF_POINTER
, 0}, {"FocusFollowMouse", WKF_POINTER
, 1},
237 static WOptionEnumeration sePlacements
[] = {
238 {"Auto", WPM_AUTO
, 0},
239 {"Smart", WPM_SMART
, 0},
240 {"Cascade", WPM_CASCADE
, 0},
241 {"Random", WPM_RANDOM
, 0},
242 {"Manual", WPM_MANUAL
, 0},
246 static WOptionEnumeration seGeomDisplays
[] = {
247 {"Center", WDIS_CENTER
, 0},
248 {"Corner", WDIS_TOPLEFT
, 0},
249 {"Floating", WDIS_FRAME_CENTER
, 0},
250 {"Line", WDIS_NEW
, 0},
254 static WOptionEnumeration seSpeeds
[] = {
255 {"UltraFast", SPEED_ULTRAFAST
, 0},
256 {"Fast", SPEED_FAST
, 0},
257 {"Medium", SPEED_MEDIUM
, 0},
258 {"Slow", SPEED_SLOW
, 0},
259 {"UltraSlow", SPEED_ULTRASLOW
, 0},
263 static WOptionEnumeration seMouseButtons
[] = {
265 {"Left", Button1
, 0}, {"Button1", Button1
, 1},
266 {"Middle", Button2
, 0}, {"Button2", Button2
, 1},
267 {"Right", Button3
, 0}, {"Button3", Button3
, 1},
268 {"Button4", Button4
, 0},
269 {"Button5", Button5
, 0},
273 static WOptionEnumeration seIconificationStyles
[] = {
274 {"Zoom", WIS_ZOOM
, 0},
275 {"Twist", WIS_TWIST
, 0},
276 {"Flip", WIS_FLIP
, 0},
277 {"None", WIS_NONE
, 0},
278 {"random", WIS_RANDOM
, 0},
282 static WOptionEnumeration seJustifications
[] = {
283 {"Left", WTJ_LEFT
, 0},
284 {"Center", WTJ_CENTER
, 0},
285 {"Right", WTJ_RIGHT
, 0},
289 static WOptionEnumeration seIconPositions
[] = {
290 {"blv", IY_BOTTOM
|IY_LEFT
|IY_VERT
, 0},
291 {"blh", IY_BOTTOM
|IY_LEFT
|IY_HORIZ
, 0},
292 {"brv", IY_BOTTOM
|IY_RIGHT
|IY_VERT
, 0},
293 {"brh", IY_BOTTOM
|IY_RIGHT
|IY_HORIZ
, 0},
294 {"tlv", IY_TOP
|IY_LEFT
|IY_VERT
, 0},
295 {"tlh", IY_TOP
|IY_LEFT
|IY_HORIZ
, 0},
296 {"trv", IY_TOP
|IY_RIGHT
|IY_VERT
, 0},
297 {"trh", IY_TOP
|IY_RIGHT
|IY_HORIZ
, 0},
301 static WOptionEnumeration seMenuStyles
[] = {
302 {"normal", MS_NORMAL
, 0},
303 {"singletexture", MS_SINGLE_TEXTURE
, 0},
304 {"flat", MS_FLAT
, 0},
309 static WOptionEnumeration seDisplayPositions
[] = {
310 {"none", WD_NONE
, 0},
311 {"center", WD_CENTER
, 0},
313 {"bottom", WD_BOTTOM
, 0},
314 {"topleft", WD_TOPLEFT
, 0},
315 {"topright", WD_TOPRIGHT
, 0},
316 {"bottomleft", WD_BOTTOMLEFT
, 0},
317 {"bottomright", WD_BOTTOMRIGHT
, 0}
322 * ALL entries in the tables bellow, NEED to have a default value
323 * defined, and this value needs to be correct.
326 /* these options will only affect the window manager on startup
328 * static defaults can't access the screen data, because it is
329 * created after these defaults are read
331 WDefaultEntry staticOptionList
[] = {
333 {"ColormapSize", "4", NULL
,
334 &wPreferences
.cmap_size
, getInt
, NULL
336 {"DisableDithering", "NO", NULL
,
337 &wPreferences
.no_dithering
, getBool
, NULL
339 /* static by laziness */
340 {"IconSize", "64", NULL
,
341 &wPreferences
.icon_size
, getInt
, NULL
343 {"ModifierKey", "Mod1", NULL
,
344 &wPreferences
.modifier_mask
, getModMask
, NULL
346 {"DisableWSMouseActions", "NO", NULL
,
347 &wPreferences
.disable_root_mouse
, getBool
, NULL
349 {"FocusMode", "manual", seFocusModes
,
350 &wPreferences
.focus_mode
, getEnum
, NULL
351 }, /* have a problem when switching from manual to sloppy without restart */
352 {"NewStyle", "NO", NULL
,
353 &wPreferences
.new_style
, getBool
, NULL
355 {"DisableDock", "NO", (void*) WM_DOCK
,
356 NULL
, getBool
, setIfDockPresent
358 {"DisableClip", "NO", (void*) WM_CLIP
,
359 NULL
, getBool
, setIfDockPresent
361 {"DisableMiniwindows", "NO", NULL
,
362 &wPreferences
.disable_miniwindows
, getBool
, NULL
364 {"MultiByteText", "NO", NULL
,
365 &wPreferences
.multi_byte_text
, getBool
, setMultiByte
371 WDefaultEntry optionList
[] = {
372 /* dynamic options */
373 {"IconPosition", "blh", seIconPositions
,
374 &wPreferences
.icon_yard
, getEnum
, setIconPosition
376 {"IconificationStyle", "Zoom", seIconificationStyles
,
377 &wPreferences
.iconification_style
, getEnum
, NULL
379 {"SelectWindowsMouseButton", "Left", seMouseButtons
,
380 &wPreferences
.select_button
, getEnum
, NULL
382 {"WindowListMouseButton", "Middle", seMouseButtons
,
383 &wPreferences
.windowl_button
, getEnum
, NULL
385 {"ApplicationMenuMouseButton", "Right", seMouseButtons
,
386 &wPreferences
.menu_button
, getEnum
, NULL
388 {"PixmapPath", DEF_PIXMAP_PATHS
, NULL
,
389 &wPreferences
.pixmap_path
, getPathList
, NULL
391 {"IconPath", DEF_ICON_PATHS
, NULL
,
392 &wPreferences
.icon_path
, getPathList
, NULL
394 {"ColormapMode", "auto", seColormapModes
,
395 &wPreferences
.colormap_mode
, getEnum
, NULL
397 {"AutoFocus", "NO", NULL
,
398 &wPreferences
.auto_focus
, getBool
, NULL
400 {"RaiseDelay", "0", NULL
,
401 &wPreferences
.raise_delay
, getInt
, NULL
403 {"CirculateRaise", "NO", NULL
,
404 &wPreferences
.circ_raise
, getBool
, NULL
406 {"Superfluous", "NO", NULL
,
407 &wPreferences
.superfluous
, getBool
, NULL
409 {"AdvanceToNewWorkspace", "NO", NULL
,
410 &wPreferences
.ws_advance
, getBool
, NULL
412 {"CycleWorkspaces", "NO", NULL
,
413 &wPreferences
.ws_cycle
, getBool
, NULL
415 {"WorkspaceNameDisplayPosition", "center", seDisplayPositions
,
416 &wPreferences
.workspace_name_display_position
, getEnum
, NULL
418 #ifdef VIRTUAL_DESKTOP
419 {"VirtualEdgeThickness", "1", NULL
,
420 &wPreferences
.vedge_thickness
, getInt
, NULL
422 {"VirtualEdgeHorizonScrollSpeed", "1", NULL
,
423 &wPreferences
.vedge_hscrollspeed
, getInt
, NULL
425 {"VirtualEdgeVerticalScrollSpeed", "1", NULL
,
426 &wPreferences
.vedge_vscrollspeed
, getInt
, NULL
428 {"VirtualEdgeWidth", "2000", NULL
,
429 &wPreferences
.vedge_width
, getInt
, NULL
431 {"VirtualEdgeHeight", "2000", NULL
,
432 &wPreferences
.vedge_height
, getInt
, NULL
435 {"StickyIcons", "NO", NULL
,
436 &wPreferences
.sticky_icons
, getBool
, setStickyIcons
438 {"SaveSessionOnExit", "NO", NULL
,
439 &wPreferences
.save_session_on_exit
, getBool
, NULL
441 {"WrapMenus", "NO", NULL
,
442 &wPreferences
.wrap_menus
, getBool
, NULL
444 {"ScrollableMenus", "NO", NULL
,
445 &wPreferences
.scrollable_menus
, getBool
, NULL
447 {"MenuScrollSpeed", "medium", seSpeeds
,
448 &wPreferences
.menu_scroll_speed
, getEnum
, NULL
450 {"IconSlideSpeed", "medium", seSpeeds
,
451 &wPreferences
.icon_slide_speed
, getEnum
, NULL
453 {"ShadeSpeed", "medium", seSpeeds
,
454 &wPreferences
.shade_speed
, getEnum
, NULL
456 {"DoubleClickTime", "250", (void*) &wPreferences
.dblclick_time
,
457 &wPreferences
.dblclick_time
, getInt
, setDoubleClick
,
459 {"AlignSubmenus", "NO", NULL
,
460 &wPreferences
.align_menus
, getBool
, NULL
462 {"OpenTransientOnOwnerWorkspace", "NO", NULL
,
463 &wPreferences
.open_transients_with_parent
, getBool
, NULL
465 {"WindowPlacement", "auto", sePlacements
,
466 &wPreferences
.window_placement
, getEnum
, NULL
468 {"IgnoreFocusClick","NO", NULL
,
469 &wPreferences
.ignore_focus_click
, getBool
, NULL
471 {"UseSaveUnders", "NO", NULL
,
472 &wPreferences
.use_saveunders
, getBool
, NULL
474 {"OpaqueMove", "NO", NULL
,
475 &wPreferences
.opaque_move
, getBool
, NULL
477 {"DisableSound", "NO", NULL
,
478 &wPreferences
.no_sound
, getBool
, NULL
480 {"DisableAnimations", "NO", NULL
,
481 &wPreferences
.no_animations
, getBool
, NULL
483 {"DontLinkWorkspaces","NO", NULL
,
484 &wPreferences
.no_autowrap
, getBool
, NULL
486 {"AutoArrangeIcons", "NO", NULL
,
487 &wPreferences
.auto_arrange_icons
, getBool
, NULL
489 {"NoWindowOverDock", "NO", NULL
,
490 &wPreferences
.no_window_over_dock
, getBool
, updateUsableArea
492 {"NoWindowOverIcons", "NO", NULL
,
493 &wPreferences
.no_window_over_icons
, getBool
, updateUsableArea
495 {"WindowPlaceOrigin", "(0, 0)", NULL
,
496 &wPreferences
.window_place_origin
, getCoord
, NULL
498 {"ResizeDisplay", "corner", seGeomDisplays
,
499 &wPreferences
.size_display
, getEnum
, NULL
501 {"MoveDisplay", "corner", seGeomDisplays
,
502 &wPreferences
.move_display
, getEnum
, NULL
504 {"DontConfirmKill", "NO", NULL
,
505 &wPreferences
.dont_confirm_kill
, getBool
,NULL
507 {"WindowTitleBalloons", "NO", NULL
,
508 &wPreferences
.window_balloon
, getBool
, NULL
510 {"MiniwindowTitleBalloons", "NO", NULL
,
511 &wPreferences
.miniwin_balloon
,getBool
, NULL
513 {"AppIconBalloons", "NO", NULL
,
514 &wPreferences
.appicon_balloon
,getBool
, NULL
516 {"HelpBalloons", "NO", NULL
,
517 &wPreferences
.help_balloon
, getBool
, NULL
519 {"EdgeResistance", "30", NULL
,
520 &wPreferences
.edge_resistance
,getInt
, NULL
522 {"Attraction", "NO", NULL
,
523 &wPreferences
.attract
, getBool
, NULL
525 {"DisableBlinking", "NO", NULL
,
526 &wPreferences
.dont_blink
, getBool
, NULL
529 {"MenuStyle", "normal", seMenuStyles
,
530 &wPreferences
.menu_style
, getEnum
, setMenuStyle
532 {"WidgetColor", "(solid, gray)", NULL
,
533 NULL
, getTexture
, setWidgetColor
,
535 {"WorkspaceSpecificBack","()", NULL
,
536 NULL
, getWSSpecificBackground
, setWorkspaceSpecificBack
538 /* WorkspaceBack must come after WorkspaceSpecificBack or
539 * WorkspaceBack wont know WorkspaceSpecificBack was also
540 * specified and 2 copies of wmsetbg will be launched */
541 {"WorkspaceBack", "(solid, black)", NULL
,
542 NULL
, getWSBackground
,setWorkspaceBack
544 {"SmoothWorkspaceBack", "NO", NULL
,
547 {"IconBack", "(solid, gray)", NULL
,
548 NULL
, getTexture
, setIconTile
550 {"TitleJustify", "center", seJustifications
,
551 &wPreferences
.title_justification
, getEnum
, setJustify
553 {"WindowTitleFont", DEF_TITLE_FONT
, NULL
,
554 NULL
, getFont
, setWinTitleFont
,
556 {"WindowTitleExtendSpace", DEF_WINDOW_TITLE_EXTEND_SPACE
, NULL
,
557 &wPreferences
.window_title_clearance
, getInt
, setClearance
559 {"MenuTitleExtendSpace", DEF_MENU_TITLE_EXTEND_SPACE
, NULL
,
560 &wPreferences
.menu_title_clearance
, getInt
, setClearance
562 {"MenuTextExtendSpace", DEF_MENU_TEXT_EXTEND_SPACE
, NULL
,
563 &wPreferences
.menu_text_clearance
, getInt
, setClearance
565 {"MenuTitleFont", DEF_MENU_TITLE_FONT
, NULL
,
566 NULL
, getFont
, setMenuTitleFont
568 {"MenuTextFont", DEF_MENU_ENTRY_FONT
, NULL
,
569 NULL
, getFont
, setMenuTextFont
571 {"IconTitleFont", DEF_ICON_TITLE_FONT
, NULL
,
572 NULL
, getFont
, setIconTitleFont
574 {"ClipTitleFont", DEF_CLIP_TITLE_FONT
, NULL
,
575 NULL
, getFont
, setClipTitleFont
577 {"LargeDisplayFont",DEF_WORKSPACE_NAME_FONT
, NULL
,
578 NULL
, getFont
, setLargeDisplayFont
580 {"HighlightColor", "white", NULL
,
581 NULL
, getColor
, setHightlight
583 {"HighlightTextColor", "black", NULL
,
584 NULL
, getColor
, setHightlightText
586 {"ClipTitleColor", "black", (void*)CLIP_NORMAL
,
587 NULL
, getColor
, setClipTitleColor
589 {"CClipTitleColor", "\"#454045\"", (void*)CLIP_COLLAPSED
,
590 NULL
, getColor
, setClipTitleColor
592 #ifdef DRAWSTRING_PLUGIN
593 {"FTitleColor", "white", (void*)WS_FOCUSED
,
594 NULL
, getTextRenderer
, setWTitleColor
596 {"PTitleColor", "white", (void*)WS_PFOCUSED
,
597 NULL
, getTextRenderer
, setWTitleColor
599 {"UTitleColor", "black", (void*)WS_UNFOCUSED
,
600 NULL
, getTextRenderer
, setWTitleColor
603 {"FTitleColor", "white", (void*)WS_FOCUSED
,
604 NULL
, getColor
, setWTitleColor
606 {"PTitleColor", "white", (void*)WS_PFOCUSED
,
607 NULL
, getColor
, setWTitleColor
609 {"UTitleColor", "black", (void*)WS_UNFOCUSED
,
610 NULL
, getColor
, setWTitleColor
613 {"FTitleBack", "(solid, black)", NULL
,
614 NULL
, getTexture
, setFTitleBack
616 {"PTitleBack", "(solid, \"#616161\")", NULL
,
617 NULL
, getTexture
, setPTitleBack
619 {"UTitleBack", "(solid, gray)", NULL
,
620 NULL
, getTexture
, setUTitleBack
622 {"ResizebarBack", "(solid, gray)", NULL
,
623 NULL
, getTexture
, setResizebarBack
625 #ifdef DRAWSTRING_PLUGIN
626 {"MenuTitleColor", "white", NULL
,
627 NULL
, getTextRenderer
, setMenuTitleColor
630 {"MenuTitleColor", "white", NULL
,
631 NULL
, getColor
, setMenuTitleColor
634 {"MenuTextColor", "black", NULL
,
635 NULL
, getColor
, setMenuTextColor
637 {"MenuDisabledColor", "\"#616161\"", NULL
,
638 NULL
, getColor
, setMenuDisabledColor
640 {"MenuTitleBack", "(solid, black)", NULL
,
641 NULL
, getTexture
, setMenuTitleBack
643 {"MenuTextBack", "(solid, gray)", NULL
,
644 NULL
, getTexture
, setMenuTextBack
646 {"IconTitleColor", "white", NULL
,
647 NULL
, getColor
, setIconTitleColor
649 {"IconTitleBack", "black", NULL
,
650 NULL
, getColor
, setIconTitleBack
654 {"RootMenuKey", "None", (void*)WKBD_ROOTMENU
,
655 NULL
, getKeybind
, setKeyGrab
657 {"WindowListKey", "None", (void*)WKBD_WINDOWLIST
,
658 NULL
, getKeybind
, setKeyGrab
661 {"WindowMenuKey", "None", (void*)WKBD_WINDOWMENU
,
662 NULL
, getKeybind
, setKeyGrab
664 {"ClipLowerKey", "None", (void*)WKBD_CLIPLOWER
,
665 NULL
, getKeybind
, setKeyGrab
667 {"ClipRaiseKey", "None", (void*)WKBD_CLIPRAISE
,
668 NULL
, getKeybind
, setKeyGrab
670 {"ClipRaiseLowerKey", "None", (void*)WKBD_CLIPRAISELOWER
,
671 NULL
, getKeybind
, setKeyGrab
673 {"MiniaturizeKey", "None", (void*)WKBD_MINIATURIZE
,
674 NULL
, getKeybind
, setKeyGrab
676 {"HideKey", "None", (void*)WKBD_HIDE
,
677 NULL
, getKeybind
, setKeyGrab
679 {"MoveResizeKey", "None", (void*)WKBD_MOVERESIZE
,
680 NULL
, getKeybind
, setKeyGrab
682 {"CloseKey", "None", (void*)WKBD_CLOSE
,
683 NULL
, getKeybind
, setKeyGrab
685 {"MaximizeKey", "None", (void*)WKBD_MAXIMIZE
,
686 NULL
, getKeybind
, setKeyGrab
688 {"VMaximizeKey", "None", (void*)WKBD_VMAXIMIZE
,
689 NULL
, getKeybind
, setKeyGrab
691 {"RaiseKey", "\"Meta+Up\"", (void*)WKBD_RAISE
,
692 NULL
, getKeybind
, setKeyGrab
694 {"LowerKey", "\"Meta+Down\"", (void*)WKBD_LOWER
,
695 NULL
, getKeybind
, setKeyGrab
697 {"RaiseLowerKey", "None", (void*)WKBD_RAISELOWER
,
698 NULL
, getKeybind
, setKeyGrab
700 {"ShadeKey", "None", (void*)WKBD_SHADE
,
701 NULL
, getKeybind
, setKeyGrab
703 {"SelectKey", "None", (void*)WKBD_SELECT
,
704 NULL
, getKeybind
, setKeyGrab
706 {"FocusNextKey", "None", (void*)WKBD_FOCUSNEXT
,
707 NULL
, getKeybind
, setKeyGrab
709 {"FocusPrevKey", "None", (void*)WKBD_FOCUSPREV
,
710 NULL
, getKeybind
, setKeyGrab
712 {"NextWorkspaceKey", "None", (void*)WKBD_NEXTWORKSPACE
,
713 NULL
, getKeybind
, setKeyGrab
715 {"PrevWorkspaceKey", "None", (void*)WKBD_PREVWORKSPACE
,
716 NULL
, getKeybind
, setKeyGrab
718 {"NextWorkspaceLayerKey", "None", (void*)WKBD_NEXTWSLAYER
,
719 NULL
, getKeybind
, setKeyGrab
721 {"PrevWorkspaceLayerKey", "None", (void*)WKBD_PREVWSLAYER
,
722 NULL
, getKeybind
, setKeyGrab
724 {"Workspace1Key", "None", (void*)WKBD_WORKSPACE1
,
725 NULL
, getKeybind
, setKeyGrab
727 {"Workspace2Key", "None", (void*)WKBD_WORKSPACE2
,
728 NULL
, getKeybind
, setKeyGrab
730 {"Workspace3Key", "None", (void*)WKBD_WORKSPACE3
,
731 NULL
, getKeybind
, setKeyGrab
733 {"Workspace4Key", "None", (void*)WKBD_WORKSPACE4
,
734 NULL
, getKeybind
, setKeyGrab
736 {"Workspace5Key", "None", (void*)WKBD_WORKSPACE5
,
737 NULL
, getKeybind
, setKeyGrab
739 {"Workspace6Key", "None", (void*)WKBD_WORKSPACE6
,
740 NULL
, getKeybind
, setKeyGrab
742 {"Workspace7Key", "None", (void*)WKBD_WORKSPACE7
,
743 NULL
, getKeybind
, setKeyGrab
745 {"Workspace8Key", "None", (void*)WKBD_WORKSPACE8
,
746 NULL
, getKeybind
, setKeyGrab
748 {"Workspace9Key", "None", (void*)WKBD_WORKSPACE9
,
749 NULL
, getKeybind
, setKeyGrab
751 {"Workspace10Key", "None", (void*)WKBD_WORKSPACE10
,
752 NULL
, getKeybind
, setKeyGrab
754 {"WindowShortcut1Key","None", (void*)WKBD_WINDOW1
,
755 NULL
, getKeybind
, setKeyGrab
757 {"WindowShortcut2Key","None", (void*)WKBD_WINDOW2
,
758 NULL
, getKeybind
, setKeyGrab
760 {"WindowShortcut3Key","None", (void*)WKBD_WINDOW3
,
761 NULL
, getKeybind
, setKeyGrab
763 {"WindowShortcut4Key","None", (void*)WKBD_WINDOW4
,
764 NULL
, getKeybind
, setKeyGrab
766 #ifdef EXTEND_WINDOWSHORTCUT
767 ,{"WindowShortcut5Key","None", (void*)WKBD_WINDOW5
,
768 NULL
, getKeybind
, setKeyGrab
770 {"WindowShortcut6Key","None", (void*)WKBD_WINDOW6
,
771 NULL
, getKeybind
, setKeyGrab
773 {"WindowShortcut7Key","None", (void*)WKBD_WINDOW7
,
774 NULL
, getKeybind
, setKeyGrab
776 {"WindowShortcut8Key","None", (void*)WKBD_WINDOW8
,
777 NULL
, getKeybind
, setKeyGrab
779 {"WindowShortcut9Key","None", (void*)WKBD_WINDOW9
,
780 NULL
, getKeybind
, setKeyGrab
782 {"WindowShortcut10Key","None", (void*)WKBD_WINDOW10
,
783 NULL
, getKeybind
, setKeyGrab
785 #endif /* EXTEND_WINDOWSHORTCUT */
787 #ifdef KEEP_XKB_LOCK_STATUS
788 ,{"ToggleKbdModeKey", "None", (void*)WKBD_TOGGLE
,
789 NULL
, getKeybind
, setKeyGrab
791 {"KbdModeLock", "NO", NULL
,
792 &wPreferences
.modelock
, getBool
, NULL
794 #endif /* KEEP_XKB_LOCK_STATUS */
799 static void rereadDefaults(void);
806 /* must defer the update because accessing X data from a
807 * signal handler can mess up Xlib */
816 WDefaultEntry
*entry
;
818 PLSetStringCmpHook(StringCompareHook
);
820 for (i
=0; i
<sizeof(optionList
)/sizeof(WDefaultEntry
); i
++) {
821 entry
= &optionList
[i
];
823 entry
->plkey
= PLMakeString(entry
->key
);
824 if (entry
->default_value
)
825 entry
->plvalue
= PLGetProplistWithDescription(entry
->default_value
);
827 entry
->plvalue
= NULL
;
830 for (i
=0; i
<sizeof(staticOptionList
)/sizeof(WDefaultEntry
); i
++) {
831 entry
= &staticOptionList
[i
];
833 entry
->plkey
= PLMakeString(entry
->key
);
834 if (entry
->default_value
)
835 entry
->plvalue
= PLGetProplistWithDescription(entry
->default_value
);
837 entry
->plvalue
= NULL
;
841 wDomainName = PLMakeString(WMDOMAIN_NAME);
842 wAttributeDomainName = PLMakeString(WMATTRIBUTE_DOMAIN_NAME);
844 PLRegister(wDomainName, rereadDefaults);
845 PLRegister(wAttributeDomainName, rereadDefaults);
854 wDefaultsInit(int screen_number
)
856 static int defaults_inited
= 0;
859 if (!defaults_inited
) {
863 dict
= PLGetDomain(wDomainName
);
865 wwarning(_("could not read domain \"%s\" from defaults database"),
866 PLGetString(wDomainName
));
875 wDefaultsDestroyDomain(WDDomain
*domain
)
877 if (domain
->dictionary
)
878 PLRelease(domain
->dictionary
);
885 wDefaultsInitDomain(char *domain
, Bool requireDictionary
)
889 static int inited
= 0;
892 proplist_t shared_dict
=NULL
;
899 db
= wmalloc(sizeof(WDDomain
));
900 memset(db
, 0, sizeof(WDDomain
));
901 db
->domain_name
= domain
;
902 db
->path
= wdefaultspathfordomain(domain
);
905 if (the_path
&& stat(the_path
, &stbuf
)>=0) {
906 db
->dictionary
= ReadProplistFromFile(the_path
);
907 if (db
->dictionary
) {
908 if (requireDictionary
&& !PLIsDictionary(db
->dictionary
)) {
909 PLRelease(db
->dictionary
);
910 db
->dictionary
= NULL
;
911 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
914 db
->timestamp
= stbuf
.st_mtime
;
916 wwarning(_("could not load domain %s from user defaults database"),
921 /* global system dictionary */
922 sprintf(path
, "%s/WindowMaker/%s", SYSCONFDIR
, domain
);
923 if (stat(path
, &stbuf
)>=0) {
924 shared_dict
= ReadProplistFromFile(path
);
926 if (requireDictionary
&& !PLIsDictionary(shared_dict
)) {
927 wwarning(_("Domain %s (%s) of global defaults database is corrupted!"),
929 PLRelease(shared_dict
);
932 if (db
->dictionary
&& PLIsDictionary(shared_dict
) &&
933 PLIsDictionary(db
->dictionary
)) {
934 PLMergeDictionaries(shared_dict
, db
->dictionary
);
935 PLRelease(db
->dictionary
);
936 db
->dictionary
= shared_dict
;
937 if (stbuf
.st_mtime
> db
->timestamp
)
938 db
->timestamp
= stbuf
.st_mtime
;
939 } else if (!db
->dictionary
) {
940 db
->dictionary
= shared_dict
;
941 if (stbuf
.st_mtime
> db
->timestamp
)
942 db
->timestamp
= stbuf
.st_mtime
;
946 wwarning(_("could not load domain %s from global defaults database (%s)"),
951 /* set to save it in user's directory, no matter from where it was read */
952 if (db
->dictionary
) {
953 proplist_t tmp
= PLMakeString(db
->path
);
955 PLSetFilename(db
->dictionary
, tmp
);
964 wReadStaticDefaults(proplist_t dict
)
967 WDefaultEntry
*entry
;
972 for (i
=0; i
<sizeof(staticOptionList
)/sizeof(WDefaultEntry
); i
++) {
973 entry
= &staticOptionList
[i
];
976 plvalue
= PLGetDictionaryEntry(dict
, entry
->plkey
);
981 /* no default in the DB. Use builtin default */
982 plvalue
= entry
->plvalue
;
987 (*entry
->convert
)(NULL
, entry
, plvalue
, entry
->addr
, &tdata
);
989 (*entry
->update
)(NULL
, entry
, tdata
, entry
->extra_data
);
997 wDefaultsCheckDomains(void *foo
)
1003 char path
[PATH_MAX
];
1006 puts("Checking domains...");
1008 if (stat(WDWindowMaker
->path
, &stbuf
)>=0
1009 && WDWindowMaker
->timestamp
< stbuf
.st_mtime
) {
1010 proplist_t shared_dict
= NULL
;
1012 puts("Checking WindowMaker domain");
1014 WDWindowMaker
->timestamp
= stbuf
.st_mtime
;
1016 /* global dictionary */
1017 sprintf(path
, "%s/WindowMaker/WindowMaker", SYSCONFDIR
);
1018 if (stat(path
, &stbuf
)>=0) {
1019 shared_dict
= ReadProplistFromFile(path
);
1020 if (shared_dict
&& !PLIsDictionary(shared_dict
)) {
1021 wwarning(_("Domain %s (%s) of global defaults database is corrupted!"),
1022 "WindowMaker", path
);
1023 PLRelease(shared_dict
);
1025 } else if (!shared_dict
) {
1026 wwarning(_("could not load domain %s from global defaults database"),
1030 /* user dictionary */
1031 dict
= ReadProplistFromFile(WDWindowMaker
->path
);
1033 if (!PLIsDictionary(dict
)) {
1036 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
1037 "WindowMaker", WDWindowMaker
->path
);
1040 PLSetFilename(shared_dict
, PLGetFilename(dict
));
1041 PLMergeDictionaries(shared_dict
, dict
);
1046 for (i
=0; i
<wScreenCount
; i
++) {
1047 scr
= wScreenWithNumber(i
);
1049 wReadDefaults(scr
, dict
);
1051 if (WDWindowMaker
->dictionary
) {
1052 PLRelease(WDWindowMaker
->dictionary
);
1054 WDWindowMaker
->dictionary
= dict
;
1057 wwarning(_("could not load domain %s from user defaults database"),
1061 PLRelease(shared_dict
);
1065 if (stat(WDWindowAttributes
->path
, &stbuf
)>=0
1066 && WDWindowAttributes
->timestamp
< stbuf
.st_mtime
) {
1068 puts("Checking WMWindowAttributes domain");
1070 dict
= ReadProplistFromFile(WDWindowAttributes
->path
);
1072 if (!PLIsDictionary(dict
)) {
1075 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
1076 "WMWindowAttributes", WDWindowAttributes
->path
);
1078 if (WDWindowAttributes
->dictionary
)
1079 PLRelease(WDWindowAttributes
->dictionary
);
1080 WDWindowAttributes
->dictionary
= dict
;
1081 for (i
=0; i
<wScreenCount
; i
++) {
1082 scr
= wScreenWithNumber(i
);
1084 wDefaultUpdateIcons(scr
);
1088 wwarning(_("could not load domain %s from user defaults database"),
1089 "WMWindowAttributes");
1091 WDWindowAttributes
->timestamp
= stbuf
.st_mtime
;
1095 if (stat(WDRootMenu
->path
, &stbuf
)>=0
1096 && WDRootMenu
->timestamp
< stbuf
.st_mtime
) {
1097 dict
= ReadProplistFromFile(WDRootMenu
->path
);
1099 puts("Checking WMRootMenu domain");
1102 if (!PLIsArray(dict
) && !PLIsString(dict
)) {
1105 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
1106 "WMRootMenu", WDRootMenu
->path
);
1108 if (WDRootMenu
->dictionary
) {
1109 PLRelease(WDRootMenu
->dictionary
);
1111 WDRootMenu
->dictionary
= dict
;
1114 wwarning(_("could not load domain %s from user defaults database"),
1117 WDRootMenu
->timestamp
= stbuf
.st_mtime
;
1122 WMAddTimerHandler(DEFAULTS_CHECK_INTERVAL
, wDefaultsCheckDomains
, foo
);
1127 wReadDefaults(WScreen
*scr
, proplist_t new_dict
)
1129 proplist_t plvalue
, old_value
;
1130 WDefaultEntry
*entry
;
1132 int update_workspace_back
= 0; /* kluge :/ */
1135 proplist_t old_dict
= (WDWindowMaker
->dictionary
!=new_dict
1136 ? WDWindowMaker
->dictionary
: NULL
);
1142 for (i
=0; i
<sizeof(optionList
)/sizeof(WDefaultEntry
); i
++) {
1143 entry
= &optionList
[i
];
1146 plvalue
= PLGetDictionaryEntry(new_dict
, entry
->plkey
);
1153 old_value
= PLGetDictionaryEntry(old_dict
, entry
->plkey
);
1156 if (!plvalue
&& !old_value
) {
1157 /* no default in the DB. Use builtin default */
1158 plvalue
= entry
->plvalue
;
1159 if (plvalue
&& new_dict
) {
1160 PLInsertDictionaryEntry(new_dict
, entry
->plkey
, plvalue
);
1163 } else if (!plvalue
) {
1164 /* value was deleted from DB. Keep current value */
1166 } else if (!old_value
) {
1167 /* set value for the 1st time */
1168 } else if (!PLIsEqual(plvalue
, old_value
)) {
1169 /* value has changed */
1172 if (strcmp(entry
->key
, "WorkspaceBack") == 0
1173 && update_workspace_back
1174 && scr
->flags
.backimage_helper_launched
) {
1176 /* value was not changed since last time */
1183 printf("Updating %s to %s\n", entry
->key
,
1184 PLGetDescription(plvalue
));
1187 if ((*entry
->convert
)(scr
, entry
, plvalue
, entry
->addr
, &tdata
)) {
1189 * If the WorkspaceSpecificBack data has been changed
1190 * so that the helper will be launched now, we must be
1191 * sure to send the default background texture config
1194 if (strcmp(entry
->key
, "WorkspaceSpecificBack") == 0
1195 && !scr
->flags
.backimage_helper_launched
) {
1196 update_workspace_back
= 1;
1198 if (entry
->update
) {
1200 (*entry
->update
)(scr
, entry
, tdata
, entry
->extra_data
);
1206 if (needs_refresh
!=0 && !scr
->flags
.startup
) {
1210 if (needs_refresh
& REFRESH_MENU_TITLE_TEXTURE
)
1211 foo
|= WTextureSettings
;
1212 if (needs_refresh
& REFRESH_MENU_TITLE_FONT
)
1213 foo
|= WFontSettings
;
1214 if (needs_refresh
& REFRESH_MENU_TITLE_COLOR
)
1215 foo
|= WColorSettings
;
1217 WMPostNotificationName(WNMenuTitleAppearanceSettingsChanged
, NULL
,
1221 if (needs_refresh
& REFRESH_MENU_TEXTURE
)
1222 foo
|= WTextureSettings
;
1223 if (needs_refresh
& REFRESH_MENU_FONT
)
1224 foo
|= WFontSettings
;
1225 if (needs_refresh
& REFRESH_MENU_COLOR
)
1226 foo
|= WColorSettings
;
1228 WMPostNotificationName(WNMenuAppearanceSettingsChanged
, NULL
,
1232 if (needs_refresh
& REFRESH_WINDOW_FONT
) {
1233 foo
|= WFontSettings
;
1235 if (needs_refresh
& REFRESH_WINDOW_TEXTURES
) {
1236 foo
|= WTextureSettings
;
1238 if (needs_refresh
& REFRESH_WINDOW_TITLE_COLOR
) {
1239 foo
|= WColorSettings
;
1242 WMPostNotificationName(WNWindowAppearanceSettingsChanged
, NULL
,
1245 if (!(needs_refresh
& REFRESH_ICON_TILE
)) {
1247 if (needs_refresh
& REFRESH_ICON_FONT
) {
1248 foo
|= WFontSettings
;
1250 if (needs_refresh
& REFRESH_ICON_TITLE_COLOR
) {
1251 foo
|= WTextureSettings
;
1253 if (needs_refresh
& REFRESH_ICON_TITLE_BACK
) {
1254 foo
|= WTextureSettings
;
1257 WMPostNotificationName(WNIconAppearanceSettingsChanged
, NULL
,
1260 if (needs_refresh
& REFRESH_ICON_TILE
)
1261 WMPostNotificationName(WNIconTileSettingsChanged
, NULL
, NULL
);
1267 wDefaultUpdateIcons(WScreen
*scr
)
1269 WAppIcon
*aicon
= scr
->app_icon_list
;
1270 WWindow
*wwin
= scr
->focused_window
;
1274 file
= wDefaultGetIconFile(scr
, aicon
->wm_instance
, aicon
->wm_class
,
1276 if ((file
&& aicon
->icon
->file
&& strcmp(file
, aicon
->icon
->file
)!=0)
1277 || (file
&& !aicon
->icon
->file
)) {
1280 if (aicon
->icon
->file
)
1281 free(aicon
->icon
->file
);
1282 aicon
->icon
->file
= wstrdup(file
);
1284 new_image
= wDefaultGetImage(scr
, aicon
->wm_instance
,
1287 wIconChangeImage(aicon
->icon
, new_image
);
1288 wAppIconPaint(aicon
);
1291 aicon
= aicon
->next
;
1294 if (!wPreferences
.flags
.noclip
)
1295 wClipIconPaint(scr
->clip_icon
);
1298 if (wwin
->icon
&& wwin
->flags
.miniaturized
) {
1299 file
= wDefaultGetIconFile(scr
, wwin
->wm_instance
, wwin
->wm_class
,
1301 if ((file
&& wwin
->icon
->file
&& strcmp(file
, wwin
->icon
->file
)!=0)
1302 || (file
&& !wwin
->icon
->file
)) {
1305 if (wwin
->icon
->file
)
1306 free(wwin
->icon
->file
);
1307 wwin
->icon
->file
= wstrdup(file
);
1309 new_image
= wDefaultGetImage(scr
, wwin
->wm_instance
,
1312 wIconChangeImage(wwin
->icon
, new_image
);
1320 /* --------------------------- Local ----------------------- */
1322 #define GET_STRING_OR_DEFAULT(x, var) if (!PLIsString(value)) { \
1323 wwarning(_("Wrong option format for key \"%s\". Should be %s."), \
1325 wwarning(_("using default \"%s\" instead"), entry->default_value); \
1326 var = entry->default_value;\
1327 } else var = PLGetString(value)\
1334 string2index(proplist_t key
, proplist_t val
, proplist_t def
,
1335 WOptionEnumeration
*values
)
1338 WOptionEnumeration
*v
;
1339 char buffer
[TOTAL_VALUES_LENGTH
];
1341 if (PLIsString(val
) && (str
= PLGetString(val
))) {
1342 for (v
=values
; v
->string
!=NULL
; v
++) {
1343 if (strcasecmp(v
->string
, str
)==0)
1349 for (v
=values
; v
->string
!=NULL
; v
++) {
1352 strcat(buffer
, ", ");
1353 strcat(buffer
, v
->string
);
1356 wwarning(_("wrong option value for key \"%s\". Should be one of %s"),
1357 PLGetString(key
), buffer
);
1360 return string2index(key
, val
, NULL
, values
);
1370 * value - is the value in the defaults DB
1371 * addr - is the address to store the data
1372 * ret - is the address to store a pointer to a temporary buffer. ret
1373 * must not be freed and is used by the set functions
1376 getBool(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
1383 GET_STRING_OR_DEFAULT("Boolean", val
);
1386 if ((val
[1]=='\0' && (val
[0]=='y' || val
[0]=='Y'))
1387 || strcasecmp(val
, "YES")==0) {
1390 } else if ((val
[1]=='\0' && (val
[0]=='n' || val
[0]=='N'))
1391 || strcasecmp(val
, "NO")==0) {
1395 if (sscanf(val
, "%i", &i
)==1) {
1401 wwarning(_("can't convert \"%s\" to boolean for key \"%s\""),
1403 if (second_pass
==0) {
1404 val
= PLGetString(entry
->plvalue
);
1406 wwarning(_("using default \"%s\" instead"), val
);
1417 *(char*)addr
= data
;
1425 getInt(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
1432 GET_STRING_OR_DEFAULT("Integer", val
);
1434 if (sscanf(val
, "%i", &data
)!=1) {
1435 wwarning(_("can't convert \"%s\" to integer for key \"%s\""),
1437 val
= PLGetString(entry
->plvalue
);
1438 wwarning(_("using default \"%s\" instead"), val
);
1439 if (sscanf(val
, "%i", &data
)!=1) {
1455 getCoord(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
1459 char *val_x
, *val_y
;
1460 int nelem
, changed
=0;
1461 proplist_t elem_x
, elem_y
;
1464 if (!PLIsArray(value
)) {
1465 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1466 entry
->key
, "Coordinate");
1468 value
= entry
->plvalue
;
1470 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1476 nelem
= PLGetNumberOfElements(value
);
1478 wwarning(_("Incorrect number of elements in array for key \"%s\"."),
1481 value
= entry
->plvalue
;
1483 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1489 elem_x
= PLGetArrayElement(value
, 0);
1490 elem_y
= PLGetArrayElement(value
, 1);
1492 if (!elem_x
|| !elem_y
|| !PLIsString(elem_x
) || !PLIsString(elem_y
)) {
1493 wwarning(_("Wrong value for key \"%s\". Should be Coordinate."),
1496 value
= entry
->plvalue
;
1498 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1504 val_x
= PLGetString(elem_x
);
1505 val_y
= PLGetString(elem_y
);
1507 if (sscanf(val_x
, "%i", &data
.x
)!=1 || sscanf(val_y
, "%i", &data
.y
)!=1) {
1508 wwarning(_("can't convert array to integers for \"%s\"."), entry
->key
);
1510 value
= entry
->plvalue
;
1512 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1520 else if (data
.x
> scr
->scr_width
/3)
1521 data
.x
= scr
->scr_width
/3;
1524 else if (data
.y
> scr
->scr_height
/3)
1525 data
.y
= scr
->scr_height
/3;
1531 *(WCoord
*)addr
= data
;
1539 /* This function is not used at the moment. */
1541 getString(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
1546 GET_STRING_OR_DEFAULT("String", data
);
1549 data
= PLGetString(entry
->plvalue
);
1558 *(char**)addr
= wstrdup(data
);
1566 getPathList(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
1576 if (!PLIsArray(value
)) {
1577 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1578 entry
->key
, "an array of paths");
1580 value
= entry
->plvalue
;
1582 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1589 count
= PLGetNumberOfElements(value
);
1592 value
= entry
->plvalue
;
1594 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1601 for (i
=0; i
<count
; i
++) {
1602 d
= PLGetArrayElement(value
, i
);
1603 if (!d
|| !PLIsString(d
)) {
1607 len
+= strlen(PLGetString(d
))+1;
1610 ptr
= data
= wmalloc(len
+1);
1612 for (i
=0; i
<count
; i
++) {
1613 d
= PLGetArrayElement(value
, i
);
1614 if (!d
|| !PLIsString(d
)) {
1617 strcpy(ptr
, PLGetString(d
));
1618 ptr
+= strlen(PLGetString(d
));
1622 ptr
--; *(ptr
--) = 0;
1624 if (*(char**)addr
!=NULL
) {
1625 free(*(char**)addr
);
1627 *(char**)addr
= data
;
1634 getEnum(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
1637 static signed char data
;
1639 data
= string2index(entry
->plkey
, value
, entry
->default_value
,
1640 (WOptionEnumeration
*)entry
->extra_data
);
1648 *(signed char*)addr
= data
;
1657 * (hgradient <color> <color>)
1658 * (vgradient <color> <color>)
1659 * (dgradient <color> <color>)
1660 * (mhgradient <color> <color> ...)
1661 * (mvgradient <color> <color> ...)
1662 * (tpixmap <file> <color>)
1663 * (spixmap <file> <color>)
1664 * (cpixmap <file> <color>)
1665 * (thgradient <file> <opaqueness> <color> <color>)
1666 * (tvgradient <file> <opaqueness> <color> <color>)
1667 * (tdgradient <file> <opaqueness> <color> <color>)
1668 * (function <lib> <function> ...)
1672 parse_texture(WScreen
*scr
, proplist_t pl
)
1677 WTexture
*texture
=NULL
;
1679 nelem
= PLGetNumberOfElements(pl
);
1684 elem
= PLGetArrayElement(pl
, 0);
1685 if (!elem
|| !PLIsString(elem
))
1687 val
= PLGetString(elem
);
1690 if (strcasecmp(val
, "solid")==0) {
1698 elem
= PLGetArrayElement(pl
, 1);
1699 if (!elem
|| !PLIsString(elem
))
1701 val
= PLGetString(elem
);
1703 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &color
)) {
1704 wwarning(_("\"%s\" is not a valid color name"), val
);
1708 texture
= (WTexture
*)wTextureMakeSolid(scr
, &color
);
1709 } else if (strcasecmp(val
, "dgradient")==0
1710 || strcasecmp(val
, "vgradient")==0
1711 || strcasecmp(val
, "hgradient")==0) {
1712 RColor color1
, color2
;
1717 wwarning(_("bad number of arguments in gradient specification"));
1721 if (val
[0]=='d' || val
[0]=='D')
1722 type
= WTEX_DGRADIENT
;
1723 else if (val
[0]=='h' || val
[0]=='H')
1724 type
= WTEX_HGRADIENT
;
1726 type
= WTEX_VGRADIENT
;
1729 /* get from color */
1730 elem
= PLGetArrayElement(pl
, 1);
1731 if (!elem
|| !PLIsString(elem
))
1733 val
= PLGetString(elem
);
1735 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1736 wwarning(_("\"%s\" is not a valid color name"), val
);
1740 color1
.red
= xcolor
.red
>> 8;
1741 color1
.green
= xcolor
.green
>> 8;
1742 color1
.blue
= xcolor
.blue
>> 8;
1745 elem
= PLGetArrayElement(pl
, 2);
1746 if (!elem
|| !PLIsString(elem
)) {
1749 val
= PLGetString(elem
);
1751 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1752 wwarning(_("\"%s\" is not a valid color name"), val
);
1756 color2
.red
= xcolor
.red
>> 8;
1757 color2
.green
= xcolor
.green
>> 8;
1758 color2
.blue
= xcolor
.blue
>> 8;
1760 texture
= (WTexture
*)wTextureMakeGradient(scr
, type
, &color1
, &color2
);
1762 } else if (strcasecmp(val
, "mhgradient")==0
1763 || strcasecmp(val
, "mvgradient")==0
1764 || strcasecmp(val
, "mdgradient")==0) {
1771 wwarning(_("too few arguments in multicolor gradient specification"));
1775 if (val
[1]=='h' || val
[1]=='H')
1776 type
= WTEX_MHGRADIENT
;
1777 else if (val
[1]=='v' || val
[1]=='V')
1778 type
= WTEX_MVGRADIENT
;
1780 type
= WTEX_MDGRADIENT
;
1784 colors
= wmalloc(sizeof(RColor
*)*(count
+1));
1786 for (i
=0; i
<count
; i
++) {
1787 elem
= PLGetArrayElement(pl
, i
+1);
1788 if (!elem
|| !PLIsString(elem
)) {
1789 for (--i
; i
>=0; --i
) {
1795 val
= PLGetString(elem
);
1797 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &color
)) {
1798 wwarning(_("\"%s\" is not a valid color name"), val
);
1799 for (--i
; i
>=0; --i
) {
1805 colors
[i
] = wmalloc(sizeof(RColor
));
1806 colors
[i
]->red
= color
.red
>> 8;
1807 colors
[i
]->green
= color
.green
>> 8;
1808 colors
[i
]->blue
= color
.blue
>> 8;
1813 texture
= (WTexture
*)wTextureMakeMGradient(scr
, type
, colors
);
1814 } else if (strcasecmp(val
, "spixmap")==0 ||
1815 strcasecmp(val
, "cpixmap")==0 ||
1816 strcasecmp(val
, "tpixmap")==0) {
1823 if (val
[0] == 's' || val
[0] == 'S')
1825 else if (val
[0] == 'c' || val
[0] == 'C')
1831 elem
= PLGetArrayElement(pl
, 2);
1832 if (!elem
|| !PLIsString(elem
)) {
1835 val
= PLGetString(elem
);
1837 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &color
)) {
1838 wwarning(_("\"%s\" is not a valid color name"), val
);
1843 elem
= PLGetArrayElement(pl
, 1);
1844 if (!elem
|| !PLIsString(elem
))
1846 val
= PLGetString(elem
);
1848 texture
= (WTexture
*)wTextureMakePixmap(scr
, type
, val
, &color
);
1849 } else if (strcasecmp(val
, "thgradient")==0
1850 || strcasecmp(val
, "tvgradient")==0
1851 || strcasecmp(val
, "tdgradient")==0) {
1852 RColor color1
, color2
;
1857 if (val
[1]=='h' || val
[1]=='H')
1858 style
= WTEX_THGRADIENT
;
1859 else if (val
[1]=='v' || val
[1]=='V')
1860 style
= WTEX_TVGRADIENT
;
1862 style
= WTEX_TDGRADIENT
;
1865 wwarning(_("bad number of arguments in textured gradient specification"));
1869 /* get from color */
1870 elem
= PLGetArrayElement(pl
, 3);
1871 if (!elem
|| !PLIsString(elem
))
1873 val
= PLGetString(elem
);
1875 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1876 wwarning(_("\"%s\" is not a valid color name"), val
);
1880 color1
.red
= xcolor
.red
>> 8;
1881 color1
.green
= xcolor
.green
>> 8;
1882 color1
.blue
= xcolor
.blue
>> 8;
1885 elem
= PLGetArrayElement(pl
, 4);
1886 if (!elem
|| !PLIsString(elem
)) {
1889 val
= PLGetString(elem
);
1891 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1892 wwarning(_("\"%s\" is not a valid color name"), val
);
1896 color2
.red
= xcolor
.red
>> 8;
1897 color2
.green
= xcolor
.green
>> 8;
1898 color2
.blue
= xcolor
.blue
>> 8;
1901 elem
= PLGetArrayElement(pl
, 2);
1902 if (!elem
|| !PLIsString(elem
))
1905 val
= PLGetString(elem
);
1907 if (!val
|| (opacity
= atoi(val
)) < 0 || opacity
> 255) {
1908 wwarning(_("bad opacity value for tgradient texture \"%s\". Should be [0..255]"), val
);
1913 elem
= PLGetArrayElement(pl
, 1);
1914 if (!elem
|| !PLIsString(elem
))
1916 val
= PLGetString(elem
);
1918 texture
= (WTexture
*)wTextureMakeTGradient(scr
, style
, &color1
, &color2
,
1921 #ifdef TEXTURE_PLUGIN
1922 else if (strcasecmp(val
, "function")==0) {
1923 WTexFunction
*function
;
1924 void (*initFunc
) (Display
*, Colormap
);
1925 char *lib
, *func
, **argv
;
1931 /* get the library name */
1932 elem
= PLGetArrayElement(pl
, 1);
1933 if (!elem
|| !PLIsString(elem
)) {
1936 lib
= PLGetString(elem
);
1938 /* get the function name */
1939 elem
= PLGetArrayElement(pl
, 2);
1940 if (!elem
|| !PLIsString(elem
)) {
1943 func
= PLGetString(elem
);
1946 argv
= (char **)wmalloc(argc
* sizeof(char *));
1948 /* get the parameters */
1949 argv
[0] = wstrdup(func
);
1950 for (i
= 0; i
< argc
- 1; i
++) {
1951 elem
= PLGetArrayElement(pl
, 3 + i
);
1952 if (!elem
|| !PLIsString(elem
)) {
1957 argv
[i
+1] = wstrdup(PLGetString(elem
));
1960 function
= wTextureMakeFunction(scr
, lib
, func
, argc
, argv
);
1964 initFunc
= dlsym(function
->handle
, "initWindowMaker");
1966 initFunc(dpy
, scr
->w_colormap
);
1968 wwarning(_("could not initialize library %s"), lib
);
1971 wwarning(_("could not find function %s::%s"), lib
, func
);
1973 #endif /* HAVE_DLFCN_H */
1974 texture
= (WTexture
*)function
;
1976 #endif /* TEXTURE_PLUGIN */
1978 wwarning(_("invalid texture type %s"), val
);
1987 getTexture(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
1990 static WTexture
*texture
;
1994 if (!PLIsArray(value
)) {
1995 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1996 entry
->key
, "Texture");
1998 value
= entry
->plvalue
;
2000 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
2006 if (strcmp(entry
->key
, "WidgetColor")==0 && !changed
) {
2009 pl
= PLGetArrayElement(value
, 0);
2010 if (!pl
|| !PLIsString(pl
) || !PLGetString(pl
)
2011 || strcasecmp(PLGetString(pl
), "solid")!=0) {
2012 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
2013 entry
->key
, "Solid Texture");
2015 value
= entry
->plvalue
;
2017 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
2022 texture
= parse_texture(scr
, value
);
2025 wwarning(_("Error in texture specification for key \"%s\""),
2028 value
= entry
->plvalue
;
2030 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
2040 *(WTexture
**)addr
= texture
;
2047 #ifdef DRAWSTRING_PLUGIN
2049 getTextRenderer(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
,
2050 void *addr
, void **ret
)
2053 char *val
, *lib
, *func
, **argv
;
2056 if (strcmp(entry
->key
, "FTitleColor")==0) {
2057 wPluginDestroyFunction(scr
->drawstring_func
[changed
= W_STRING_FTITLE
]);
2058 scr
->drawstring_func
[W_STRING_FTITLE
] = NULL
;
2059 } else if (strcmp(entry
->key
, "UTitleColor")==0) {
2060 wPluginDestroyFunction(scr
->drawstring_func
[changed
= W_STRING_UTITLE
]);
2061 scr
->drawstring_func
[W_STRING_UTITLE
] = NULL
;
2062 } else if (strcmp(entry
->key
, "PTitleColor")==0) {
2063 wPluginDestroyFunction(scr
->drawstring_func
[changed
= W_STRING_PTITLE
]);
2064 scr
->drawstring_func
[W_STRING_PTITLE
] = NULL
;
2065 } else if (strcmp(entry
->key
, "MenuTitleColor")==0) {
2066 wPluginDestroyFunction(scr
->drawstring_func
[changed
= W_STRING_MTITLE
]);
2067 scr
->drawstring_func
[W_STRING_MTITLE
] = NULL
;
2068 } else if (strcmp(entry
->key
, "MenuPluginColor")==0) {
2069 wPluginDestroyFunction(scr
->drawstring_func
[changed
= W_STRING_MTEXT
]);
2070 scr
->drawstring_func
[W_STRING_MTEXT
] = NULL
;
2073 if (PLIsArray(value
)) {
2074 if ((argc
= PLGetNumberOfElements(value
)) < 4) return False
;
2076 argv
= (char **)wmalloc(argc
* sizeof(char *));
2078 elem
= PLGetArrayElement(value
,0);
2079 if (!elem
|| !PLIsString(elem
)) return False
;
2080 val
= PLGetString(elem
);
2081 if (strcasecmp(val
, "function")==0) {
2082 elem
= PLGetArrayElement(value
, 1); /* library name */
2083 if (!elem
|| !PLIsString(elem
)) return False
;
2084 lib
= PLGetString(elem
);
2085 elem
= PLGetArrayElement(value
, 2); /* function name */
2086 if (!elem
|| !PLIsString(elem
)) return False
;
2087 func
= PLGetString(elem
);
2088 scr
->drawstring_func
[changed
] = wPluginCreateFunction (W_FUNCTION_DRAWSTRING
,
2089 lib
, "initDrawString", func
, NULL
, value
,
2090 wPluginPackInitData(3, dpy
, scr
->w_colormap
,"-DATA-"));
2093 return getColor(scr
, entry
, PLGetArrayElement(value
,3), addr
, ret
);
2094 } else if (PLIsString(value
)) {
2095 return getColor(scr
, entry
, value
, addr
, ret
);
2100 #endif /* DRAWSTRING_PLUGIN */
2105 getWSBackground(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
,
2106 void *addr
, void **ret
)
2114 if (!PLIsArray(value
)) {
2115 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
2116 "WorkspaceBack", "Texture or None");
2118 value
= entry
->plvalue
;
2120 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
2126 /* only do basic error checking and verify for None texture */
2128 nelem
= PLGetNumberOfElements(value
);
2130 elem
= PLGetArrayElement(value
, 0);
2131 if (!elem
|| !PLIsString(elem
)) {
2132 wwarning(_("Wrong type for workspace background. Should be a texture type."));
2134 value
= entry
->plvalue
;
2136 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
2141 val
= PLGetString(elem
);
2143 if (strcasecmp(val
, "None")==0)
2146 *ret
= PLRetain(value
);
2153 getWSSpecificBackground(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
,
2154 void *addr
, void **ret
)
2161 if (!PLIsArray(value
)) {
2162 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
2163 "WorkspaceSpecificBack", "an array of textures");
2165 value
= entry
->plvalue
;
2167 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
2173 /* only do basic error checking and verify for None texture */
2175 nelem
= PLGetNumberOfElements(value
);
2178 elem
= PLGetArrayElement(value
, nelem
);
2179 if (!elem
|| !PLIsArray(elem
)) {
2180 wwarning(_("Wrong type for background of workspace %i. Should be a texture."),
2186 *ret
= PLRetain(value
);
2190 * Kluge to force wmsetbg helper to set the default background.
2191 * If the WorkspaceSpecificBack is changed once wmaker has started,
2192 * the WorkspaceBack won't be sent to the helper, unless the user
2193 * changes it's value too. So, we must force this by removing the
2194 * value from the defaults DB.
2196 if (!scr
->flags
.backimage_helper_launched
&& !scr
->flags
.startup
) {
2197 proplist_t key
= PLMakeString("WorkspaceBack");
2199 PLRemoveDictionaryEntry(WDWindowMaker
->dictionary
, key
);
2209 getFont(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
2212 static WMFont
*font
;
2215 GET_STRING_OR_DEFAULT("Font", val
);
2217 font
= WMCreateFont(scr
->wmscreen
, val
);
2219 font
= WMCreateFont(scr
->wmscreen
, "fixed");
2222 wfatal(_("could not load any usable font!!!"));
2229 /* can't assign font value outside update function */
2230 wassertrv(addr
== NULL
, True
);
2237 getColor(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
2240 static XColor color
;
2244 GET_STRING_OR_DEFAULT("Color", val
);
2248 if (!wGetColor(scr
, val
, &color
)) {
2249 wwarning(_("could not get color for key \"%s\""),
2251 if (second_pass
==0) {
2252 val
= PLGetString(entry
->plvalue
);
2254 wwarning(_("using default \"%s\" instead"), val
);
2266 *(unsigned long*)addr = pixel;
2275 getKeybind(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
2278 static WShortKey shortcut
;
2285 GET_STRING_OR_DEFAULT("Key spec", val
);
2287 if (!val
|| strcasecmp(val
, "NONE")==0) {
2288 shortcut
.keycode
= 0;
2289 shortcut
.modifier
= 0;
2300 shortcut
.modifier
= 0;
2301 while ((k
= strchr(b
, '+'))!=NULL
) {
2305 mod
= wXModifierFromKey(b
);
2307 wwarning(_("%s:invalid key modifier \"%s\""), entry
->key
, b
);
2310 shortcut
.modifier
|= mod
;
2316 ksym
= XStringToKeysym(b
);
2318 if (ksym
==NoSymbol
) {
2319 wwarning(_("%s:invalid kbd shortcut specification \"%s\""), entry
->key
,
2324 shortcut
.keycode
= XKeysymToKeycode(dpy
, ksym
);
2325 if (shortcut
.keycode
==0) {
2326 wwarning(_("%s:invalid key in shortcut \"%s\""), entry
->key
, val
);
2338 getModMask(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
2341 static unsigned int mask
;
2344 GET_STRING_OR_DEFAULT("Modifier Key", str
);
2349 mask
= wXModifierFromKey(str
);
2351 wwarning(_("%s: modifier key %s is not valid"), entry
->key
, str
);
2357 *(unsigned int*)addr
= mask
;
2368 getRImages(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
,
2369 void *addr
, void **ret
)
2377 GET_STRING_OR_DEFAULT("Image File Path", str
);
2381 image
= RLoadImage(scr
->rcontext
, str
, 0);
2383 wwarning(_("could not load image in option %s: %s"), entry
->key
,
2384 RMessageForError(RErrorCode
));
2388 if (*(RImage
**)addr
) {
2389 RDestroyImage(*(RImage
**)addr
);
2392 *(RImage
**)addr
= image
;
2394 assert(ret
== NULL
);
2397 *(RImage**)ret = image;
2405 /* ---------------- value setting functions --------------- */
2407 setJustify(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
2409 return REFRESH_WINDOW_TITLE_COLOR
;
2413 setClearance(WScreen
*scr
, WDefaultEntry
*entry
, void *bar
, void *foo
)
2415 return REFRESH_WINDOW_FONT
|REFRESH_BUTTON_IMAGES
|REFRESH_MENU_TITLE_FONT
|REFRESH_MENU_FONT
;
2419 setIfDockPresent(WScreen
*scr
, WDefaultEntry
*entry
, int *flag
, long which
)
2423 wPreferences
.flags
.nodock
= wPreferences
.flags
.nodock
|| *flag
;
2426 wPreferences
.flags
.noclip
= wPreferences
.flags
.noclip
|| *flag
;
2436 setStickyIcons(WScreen
*scr
, WDefaultEntry
*entry
, void *bar
, void *foo
)
2438 if (scr
->workspaces
) {
2439 wWorkspaceForceChange(scr
, scr
->current_workspace
);
2440 wArrangeIcons(scr
, False
);
2447 setPositive(WScreen
*scr
, WDefaultEntry
*entry
, int *value
, void *foo
)
2459 setIconTile(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
2465 img
= wTextureRenderImage(*texture
, wPreferences
.icon_size
,
2466 wPreferences
.icon_size
,
2467 ((*texture
)->any
.type
& WREL_BORDER_MASK
)
2468 ? WREL_ICON
: WREL_FLAT
);
2470 wwarning(_("could not render texture for icon background"));
2472 wTextureDestroy(scr
, *texture
);
2475 RConvertImage(scr
->rcontext
, img
, &pixmap
);
2477 if (scr
->icon_tile
) {
2479 RDestroyImage(scr
->icon_tile
);
2480 XFreePixmap(dpy
, scr
->icon_tile_pixmap
);
2483 scr
->icon_tile
= img
;
2486 /* put the icon in the noticeboard hint */
2487 PropSetIconTileHint(scr
, img
);
2490 if (!wPreferences
.flags
.noclip
) {
2491 if (scr
->clip_tile
) {
2492 RDestroyImage(scr
->clip_tile
);
2494 scr
->clip_tile
= wClipMakeTile(scr
, img
);
2497 scr
->icon_tile_pixmap
= pixmap
;
2499 if (scr
->def_icon_pixmap
) {
2500 XFreePixmap(dpy
, scr
->def_icon_pixmap
);
2501 scr
->def_icon_pixmap
= None
;
2503 if (scr
->def_ticon_pixmap
) {
2504 XFreePixmap(dpy
, scr
->def_ticon_pixmap
);
2505 scr
->def_ticon_pixmap
= None
;
2508 if (scr
->icon_back_texture
) {
2509 wTextureDestroy(scr
, (WTexture
*)scr
->icon_back_texture
);
2511 scr
->icon_back_texture
= wTextureMakeSolid(scr
, &((*texture
)->any
.color
));
2513 if (scr
->clip_balloon
)
2514 XSetWindowBackground(dpy
, scr
->clip_balloon
,
2515 (*texture
)->any
.color
.pixel
);
2518 * Free the texture as nobody else will use it, nor refer to it.
2521 wTextureDestroy(scr
, *texture
);
2523 return (reset
? REFRESH_ICON_TILE
: 0);
2529 setWinTitleFont(WScreen
*scr
, WDefaultEntry
*entry
, WMFont
*font
, void *foo
)
2531 if (scr
->title_font
) {
2532 WMReleaseFont(scr
->title_font
);
2534 scr
->title_font
= font
;
2536 return REFRESH_WINDOW_FONT
|REFRESH_BUTTON_IMAGES
;
2541 setMenuTitleFont(WScreen
*scr
, WDefaultEntry
*entry
, WMFont
*font
, void *foo
)
2543 if (scr
->menu_title_font
) {
2544 WMReleaseFont(scr
->menu_title_font
);
2547 scr
->menu_title_font
= font
;
2549 return REFRESH_MENU_TITLE_FONT
;
2554 setMenuTextFont(WScreen
*scr
, WDefaultEntry
*entry
, WMFont
*font
, void *foo
)
2556 if (scr
->menu_entry_font
) {
2557 WMReleaseFont(scr
->menu_entry_font
);
2559 scr
->menu_entry_font
= font
;
2561 return REFRESH_MENU_FONT
;
2567 setIconTitleFont(WScreen
*scr
, WDefaultEntry
*entry
, WMFont
*font
, void *foo
)
2569 if (scr
->icon_title_font
) {
2570 WMReleaseFont(scr
->icon_title_font
);
2573 scr
->icon_title_font
= font
;
2575 return REFRESH_ICON_FONT
;
2580 setClipTitleFont(WScreen
*scr
, WDefaultEntry
*entry
, WMFont
*font
, void *foo
)
2582 if (scr
->clip_title_font
) {
2583 WMReleaseFont(scr
->clip_title_font
);
2586 scr
->clip_title_font
= font
;
2588 return REFRESH_ICON_FONT
;
2593 setLargeDisplayFont(WScreen
*scr
, WDefaultEntry
*entry
, WMFont
*font
, void *foo
)
2595 if (scr
->workspace_name_font
) {
2596 WMReleaseFont(scr
->workspace_name_font
);
2599 scr
->workspace_name_font
= font
;
2606 setHightlight(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, void *foo
)
2608 if (scr
->select_pixel
!=scr
->white_pixel
&&
2609 scr
->select_pixel
!=scr
->black_pixel
) {
2610 wFreeColor(scr
, scr
->select_pixel
);
2613 scr
->select_pixel
= color
->pixel
;
2615 return REFRESH_MENU_COLOR
;
2620 setHightlightText(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, void *foo
)
2622 if (scr
->select_text_pixel
!=scr
->white_pixel
&&
2623 scr
->select_text_pixel
!=scr
->black_pixel
) {
2624 wFreeColor(scr
, scr
->select_text_pixel
);
2627 scr
->select_text_pixel
= color
->pixel
;
2629 return REFRESH_MENU_COLOR
;
2634 setClipTitleColor(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, long index
)
2636 if (scr
->clip_title_pixel
[index
]!=scr
->white_pixel
&&
2637 scr
->clip_title_pixel
[index
]!=scr
->black_pixel
) {
2638 wFreeColor(scr
, scr
->clip_title_pixel
[index
]);
2640 scr
->clip_title_pixel
[index
] = color
->pixel
;
2642 #ifdef GRADIENT_CLIP_ARROW
2643 if (index
== CLIP_NORMAL
) {
2645 RColor color1
, color2
;
2646 int pt
= CLIP_BUTTON_SIZE
*wPreferences
.icon_size
/64;
2647 int as
= pt
- 15; /* 15 = 5+5+5 */
2649 FREE_PIXMAP(scr
->clip_arrow_gradient
);
2651 color1
.red
= (color
->red
>> 8)*6/10;
2652 color1
.green
= (color
->green
>> 8)*6/10;
2653 color1
.blue
= (color
->blue
>> 8)*6/10;
2655 color2
.red
= WMIN((color
->red
>> 8)*20/10, 255);
2656 color2
.green
= WMIN((color
->green
>> 8)*20/10, 255);
2657 color2
.blue
= WMIN((color
->blue
>> 8)*20/10, 255);
2659 image
= RRenderGradient(as
+1, as
+1, &color1
, &color2
, RDiagonalGradient
);
2660 RConvertImage(scr
->rcontext
, image
, &scr
->clip_arrow_gradient
);
2661 RDestroyImage(image
);
2663 #endif /* GRADIENT_CLIP_ARROW */
2665 return REFRESH_ICON_TITLE_COLOR
;
2670 setWTitleColor(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, long index
)
2672 if (scr
->window_title_pixel
[index
]!=scr
->white_pixel
&&
2673 scr
->window_title_pixel
[index
]!=scr
->black_pixel
) {
2674 wFreeColor(scr
, scr
->window_title_pixel
[index
]);
2677 scr
->window_title_pixel
[index
] = color
->pixel
;
2679 if (index
== WS_UNFOCUSED
)
2680 XSetForeground(dpy
, scr
->info_text_gc
, color
->pixel
);
2682 return REFRESH_WINDOW_TITLE_COLOR
;
2687 setMenuTitleColor(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, long index
)
2689 if (scr
->menu_title_pixel
[0]!=scr
->white_pixel
&&
2690 scr
->menu_title_pixel
[0]!=scr
->black_pixel
) {
2691 #ifdef DRAWSTRING_PLUGIN
2692 if(!scr
->drawstring_func
[W_STRING_MTITLE
])
2694 wFreeColor(scr
, scr
->menu_title_pixel
[0]);
2697 scr
->menu_title_pixel
[0] = color
->pixel
;
2698 XSetForeground(dpy
, scr
->menu_title_gc
, color
->pixel
);
2700 return REFRESH_MENU_TITLE_COLOR
;
2705 setMenuTextColor(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, void *foo
)
2708 #define gcm (GCForeground|GCBackground|GCFillStyle)
2710 if (scr
->mtext_pixel
!=scr
->white_pixel
&&
2711 scr
->mtext_pixel
!=scr
->black_pixel
) {
2712 wFreeColor(scr
, scr
->mtext_pixel
);
2715 scr
->mtext_pixel
= color
->pixel
;
2717 XSetForeground(dpy
, scr
->menu_entry_gc
, color
->pixel
);
2720 if (scr
->dtext_pixel
== scr
->mtext_pixel
) {
2721 gcv
.foreground
= scr
->white_pixel
;
2722 gcv
.background
= scr
->black_pixel
;
2723 gcv
.fill_style
= FillStippled
;
2725 gcv
.foreground
= scr
->dtext_pixel
;
2726 gcv
.fill_style
= FillSolid
;
2728 XChangeGC(dpy
, scr
->disabled_menu_entry_gc
, gcm
, &gcv
);
2730 return REFRESH_MENU_COLOR
;
2736 setMenuDisabledColor(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, void *foo
)
2739 #define gcm (GCForeground|GCBackground|GCFillStyle)
2741 if (scr
->dtext_pixel
!=scr
->white_pixel
&&
2742 scr
->dtext_pixel
!=scr
->black_pixel
) {
2743 wFreeColor(scr
, scr
->dtext_pixel
);
2746 scr
->dtext_pixel
= color
->pixel
;
2748 if (scr
->dtext_pixel
== scr
->mtext_pixel
) {
2749 gcv
.foreground
= scr
->white_pixel
;
2750 gcv
.background
= scr
->black_pixel
;
2751 gcv
.fill_style
= FillStippled
;
2753 gcv
.foreground
= scr
->dtext_pixel
;
2754 gcv
.fill_style
= FillSolid
;
2756 XChangeGC(dpy
, scr
->disabled_menu_entry_gc
, gcm
, &gcv
);
2758 return REFRESH_MENU_COLOR
;
2763 setIconTitleColor(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, void *foo
)
2765 XSetForeground(dpy
, scr
->icon_title_gc
, color
->pixel
);
2767 return REFRESH_ICON_TITLE_COLOR
;
2772 setIconTitleBack(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, void *foo
)
2774 if (scr
->icon_title_texture
) {
2775 wTextureDestroy(scr
, (WTexture
*)scr
->icon_title_texture
);
2777 XQueryColor (dpy
, scr
->w_colormap
, color
);
2778 scr
->icon_title_texture
= wTextureMakeSolid(scr
, color
);
2780 return REFRESH_ICON_TITLE_BACK
;
2785 trackDeadProcess(pid_t pid
, unsigned char status
, WScreen
*scr
)
2787 close(scr
->helper_fd
);
2789 scr
->helper_pid
= 0;
2790 scr
->flags
.backimage_helper_launched
= 0;
2795 setWorkspaceSpecificBack(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
,
2802 if (scr
->flags
.backimage_helper_launched
) {
2803 if (PLGetNumberOfElements(value
)==0) {
2804 SendHelperMessage(scr
, 'C', 0, NULL
);
2805 SendHelperMessage(scr
, 'K', 0, NULL
);
2814 if (PLGetNumberOfElements(value
) == 0)
2817 if (pipe(filedes
) < 0) {
2818 wsyserror("pipe() failed:can't set workspace specific background image");
2826 wsyserror("fork() failed:can't set workspace specific background image");
2827 if (close(filedes
[0]) < 0)
2828 wsyserror("could not close pipe");
2829 if (close(filedes
[1]) < 0)
2830 wsyserror("could not close pipe");
2832 } else if (pid
== 0) {
2833 SetupEnvironment(scr
);
2836 wsyserror("could not close pipe");
2837 if (dup(filedes
[0]) < 0) {
2838 wsyserror("dup() failed:can't set workspace specific background image");
2840 if (wPreferences
.smooth_workspace_back
)
2841 execlp("wmsetbg", "wmsetbg", "-helper", "-S", "-d", NULL
);
2843 execlp("wmsetbg", "wmsetbg", "-helper", "-d", NULL
);
2844 wsyserror("could not execute wmsetbg");
2848 if (fcntl(filedes
[0], F_SETFD
, FD_CLOEXEC
) < 0) {
2849 wsyserror("error setting close-on-exec flag");
2851 if (fcntl(filedes
[1], F_SETFD
, FD_CLOEXEC
) < 0) {
2852 wsyserror("error setting close-on-exec flag");
2855 scr
->helper_fd
= filedes
[1];
2856 scr
->helper_pid
= pid
;
2857 scr
->flags
.backimage_helper_launched
= 1;
2859 wAddDeathHandler(pid
, (WDeathHandler
*)trackDeadProcess
, scr
);
2861 SendHelperMessage(scr
, 'P', -1, wPreferences
.pixmap_path
);
2866 for (i
= 0; i
< PLGetNumberOfElements(value
); i
++) {
2867 val
= PLGetArrayElement(value
, i
);
2868 if (val
&& PLIsArray(val
) && PLGetNumberOfElements(val
)>0) {
2869 str
= PLGetDescription(val
);
2871 SendHelperMessage(scr
, 'S', i
+1, str
);
2875 SendHelperMessage(scr
, 'U', i
+1, NULL
);
2886 setWorkspaceBack(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
,
2889 if (scr
->flags
.backimage_helper_launched
) {
2892 if (PLGetNumberOfElements(value
)==0) {
2893 SendHelperMessage(scr
, 'U', 0, NULL
);
2895 /* set the default workspace background to this one */
2896 str
= PLGetDescription(value
);
2898 SendHelperMessage(scr
, 'S', 0, str
);
2900 SendHelperMessage(scr
, 'C', scr
->current_workspace
+1, NULL
);
2902 SendHelperMessage(scr
, 'U', 0, NULL
);
2909 SetupEnvironment(scr
);
2910 text
= PLGetDescription(value
);
2911 command
= wmalloc(strlen(text
)+40);
2912 if (wPreferences
.smooth_workspace_back
)
2913 sprintf(command
, "wmsetbg -d -S -p '%s' &", text
);
2915 sprintf(command
, "wmsetbg -d -p '%s' &", text
);
2927 setWidgetColor(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
2929 if (scr
->widget_texture
) {
2930 wTextureDestroy(scr
, (WTexture
*)scr
->widget_texture
);
2932 scr
->widget_texture
= *(WTexSolid
**)texture
;
2939 setFTitleBack(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
2941 if (scr
->window_title_texture
[WS_FOCUSED
]) {
2942 wTextureDestroy(scr
, scr
->window_title_texture
[WS_FOCUSED
]);
2944 scr
->window_title_texture
[WS_FOCUSED
] = *texture
;
2946 return REFRESH_WINDOW_TEXTURES
;
2951 setPTitleBack(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
2953 if (scr
->window_title_texture
[WS_PFOCUSED
]) {
2954 wTextureDestroy(scr
, scr
->window_title_texture
[WS_PFOCUSED
]);
2956 scr
->window_title_texture
[WS_PFOCUSED
] = *texture
;
2958 return REFRESH_WINDOW_TEXTURES
;
2963 setUTitleBack(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
2965 if (scr
->window_title_texture
[WS_UNFOCUSED
]) {
2966 wTextureDestroy(scr
, scr
->window_title_texture
[WS_UNFOCUSED
]);
2968 scr
->window_title_texture
[WS_UNFOCUSED
] = *texture
;
2970 return REFRESH_WINDOW_TEXTURES
;
2975 setResizebarBack(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
2977 if (scr
->resizebar_texture
[0]) {
2978 wTextureDestroy(scr
, scr
->resizebar_texture
[0]);
2980 scr
->resizebar_texture
[0] = *texture
;
2982 return REFRESH_WINDOW_TEXTURES
;
2987 setMenuTitleBack(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
2989 if (scr
->menu_title_texture
[0]) {
2990 wTextureDestroy(scr
, scr
->menu_title_texture
[0]);
2992 scr
->menu_title_texture
[0] = *texture
;
2994 return REFRESH_MENU_TITLE_TEXTURE
;
2999 setMenuTextBack(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
3001 if (scr
->menu_item_texture
) {
3002 wTextureDestroy(scr
, scr
->menu_item_texture
);
3003 wTextureDestroy(scr
, (WTexture
*)scr
->menu_item_auxtexture
);
3005 scr
->menu_item_texture
= *texture
;
3007 scr
->menu_item_auxtexture
3008 = wTextureMakeSolid(scr
, &scr
->menu_item_texture
->any
.color
);
3010 return REFRESH_MENU_TEXTURE
;
3015 setKeyGrab(WScreen
*scr
, WDefaultEntry
*entry
, WShortKey
*shortcut
, long index
)
3018 wKeyBindings
[index
] = *shortcut
;
3020 wwin
= scr
->focused_window
;
3022 while (wwin
!=NULL
) {
3023 XUngrabKey(dpy
, AnyKey
, AnyModifier
, wwin
->frame
->core
->window
);
3025 if (!WFLAGP(wwin
, no_bind_keys
)) {
3026 wWindowSetKeyGrabs(wwin
);
3036 setIconPosition(WScreen
*scr
, WDefaultEntry
*entry
, void *bar
, void *foo
)
3038 wArrangeIcons(scr
, True
);
3045 updateUsableArea(WScreen
*scr
, WDefaultEntry
*entry
, void *bar
, void *foo
)
3047 wScreenUpdateUsableArea(scr
);
3054 setMenuStyle(WScreen
*scr
, WDefaultEntry
*entry
, int *value
, void *foo
)
3056 return REFRESH_MENU_TEXTURE
;
3062 setButtonImages(WScreen *scr, WDefaultEntry *entry, int *value, void *foo)
3064 return REFRESH_BUTTON_IMAGES;
3070 * Need access to the double click variables, so that all widgets in
3071 * wmaker panels will have the same dbl-click values.
3072 * TODO: figure a better way of dealing with it.
3077 setDoubleClick(WScreen
*scr
, WDefaultEntry
*entry
, int *value
, void *foo
)
3079 extern _WINGsConfiguration WINGsConfiguration
;
3084 WINGsConfiguration
.doubleClickDelay
= *value
;
3092 setMultiByte(WScreen
*scr
, WDefaultEntry
*entry
, int *value
, void *foo
)
3094 extern _WINGsConfiguration WINGsConfiguration
;
3096 WINGsConfiguration
.useMultiByte
= *value
;