1 /* defaults.c - manage configuration through defaults db
3 * Window Maker window manager
5 * Copyright (c) 1997, 1998 Alfredo K. Kojima
6 * Copyright (c) 1998 Dan Pascu
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
33 #include <sys/types.h>
46 #define PATH_MAX DEFAULT_PATH_MAX
50 #include <X11/Xutil.h>
51 #include <X11/keysym.h>
56 #include "WindowMaker.h"
62 #include "resources.h"
65 #include "xmodifier.h"
70 #include "workspace.h"
74 * Our own proplist reader parser. This one will not accept any
75 * syntax errors and is more descriptive in the error messages.
76 * It also doesn't seem to crash.
78 extern proplist_t
ReadProplistFromFile(char *file
);
83 extern WDDomain
*WDWindowMaker
;
84 extern WDDomain
*WDWindowAttributes
;
85 extern WDDomain
*WDRootMenu
;
87 extern int wScreenCount
;
90 extern proplist_t wDomainName;
91 extern proplist_t wAttributeDomainName;
93 extern WPreferences wPreferences
;
95 extern WShortKey wKeyBindings
[WKBD_LAST
];
105 proplist_t plvalue
; /* default value */
109 /* used to map strings to integers */
114 } WOptionEnumeration
;
117 /* type converters */
118 static int getBool();
120 static int getCoord();
122 /* this is not used yet */
123 static int getString();
125 static int getPathList();
126 static int getEnum();
127 static int getTexture();
128 #ifdef DRAWSTRING_PLUGIN
129 static int getTextRenderer();
131 static int getWSBackground();
132 static int getWSSpecificBackground();
133 static int getFont();
134 static int getColor();
135 static int getKeybind();
136 static int getModMask();
138 static int getRImage();
142 /* value setting functions */
143 static int setJustify();
144 static int setIfDockPresent();
145 static int setStickyIcons();
147 static int setPositive();
149 static int setWidgetColor();
150 static int setIconTile();
151 static int setWinTitleFont();
152 static int setMenuTitleFont();
153 static int setMenuTextFont();
154 static int setIconTitleFont();
155 static int setIconTitleColor();
156 static int setIconTitleBack();
157 static int setDisplayFont();
158 static int setLargeDisplayFont();
159 static int setWTitleColor();
160 static int setFTitleBack();
161 static int setPTitleBack();
162 static int setUTitleBack();
163 static int setResizebarBack();
164 static int setWorkspaceBack();
165 static int setWorkspaceSpecificBack();
166 static int setMenuTitleColor();
167 static int setMenuTextColor();
168 static int setMenuDisabledColor();
169 static int setMenuTitleBack();
170 static int setMenuTextBack();
171 static int setHightlight();
172 static int setHightlightText();
173 static int setKeyGrab();
174 static int setDoubleClick();
175 static int setIconPosition();
177 static int setClipTitleFont();
178 static int setClipTitleColor();
180 static int setMenuStyle();
181 static int setMultiByte();
183 static int updateUsableArea();
188 * Tables to convert strings to enumeration values.
189 * Values stored are char
193 /* WARNING: sum of length of all value strings must not exceed
195 #define TOTAL_VALUES_LENGTH 80
200 #define REFRESH_WINDOW_TEXTURES (1<<0)
201 #define REFRESH_MENU_TEXTURE (1<<1)
202 #define REFRESH_MENU_FONT (1<<2)
203 #define REFRESH_MENU_COLOR (1<<3)
204 #define REFRESH_MENU_TITLE_TEXTURE (1<<4)
205 #define REFRESH_MENU_TITLE_FONT (1<<5)
206 #define REFRESH_MENU_TITLE_COLOR (1<<6)
207 #define REFRESH_WINDOW_TITLE_COLOR (1<<7)
208 #define REFRESH_WINDOW_FONT (1<<8)
209 #define REFRESH_ICON_TILE (1<<9)
210 #define REFRESH_ICON_FONT (1<<10)
211 #define REFRESH_WORKSPACE_BACK (1<<11)
213 #define REFRESH_BUTTON_IMAGES (1<<12)
215 #define REFRESH_ICON_TITLE_COLOR (1<<13)
216 #define REFRESH_ICON_TITLE_BACK (1<<14)
220 static WOptionEnumeration seFocusModes
[] = {
221 {"Manual", WKF_CLICK
, 0}, {"ClickToFocus", WKF_CLICK
, 1},
222 {"Auto", WKF_POINTER
, 0}, {"FocusFollowMouse", WKF_POINTER
, 1},
223 {"Sloppy", WKF_SLOPPY
, 0}, {"SemiAuto", WKF_SLOPPY
, 1},
227 static WOptionEnumeration seColormapModes
[] = {
228 {"Manual", WKF_CLICK
, 0}, {"ClickToFocus", WKF_CLICK
, 1},
229 {"Auto", WKF_POINTER
, 0}, {"FocusFollowMouse", WKF_POINTER
, 1},
233 static WOptionEnumeration sePlacements
[] = {
234 {"Auto", WPM_AUTO
, 0},
235 {"Smart", WPM_SMART
, 0},
236 {"Cascade", WPM_CASCADE
, 0},
237 {"Random", WPM_RANDOM
, 0},
238 {"Manual", WPM_MANUAL
, 0},
242 static WOptionEnumeration seGeomDisplays
[] = {
243 {"Center", WDIS_CENTER
, 0},
244 {"Corner", WDIS_TOPLEFT
, 0},
245 {"Floating", WDIS_FRAME_CENTER
, 0},
246 {"Line", WDIS_NEW
, 0},
250 static WOptionEnumeration seSpeeds
[] = {
251 {"UltraFast", SPEED_ULTRAFAST
, 0},
252 {"Fast", SPEED_FAST
, 0},
253 {"Medium", SPEED_MEDIUM
, 0},
254 {"Slow", SPEED_SLOW
, 0},
255 {"UltraSlow", SPEED_ULTRASLOW
, 0},
259 static WOptionEnumeration seMouseButtons
[] = {
261 {"Left", Button1
, 0}, {"Button1", Button1
, 1},
262 {"Middle", Button2
, 0}, {"Button2", Button2
, 1},
263 {"Right", Button3
, 0}, {"Button3", Button3
, 1},
264 {"Button4", Button4
, 0},
265 {"Button5", Button5
, 0},
269 static WOptionEnumeration seIconificationStyles
[] = {
270 {"Zoom", WIS_ZOOM
, 0},
271 {"Twist", WIS_TWIST
, 0},
272 {"Flip", WIS_FLIP
, 0},
273 {"None", WIS_NONE
, 0},
274 {"random", WIS_RANDOM
, 0},
278 static WOptionEnumeration seJustifications
[] = {
279 {"Left", WTJ_LEFT
, 0},
280 {"Center", WTJ_CENTER
, 0},
281 {"Right", WTJ_RIGHT
, 0},
285 static WOptionEnumeration seIconPositions
[] = {
286 {"blv", IY_BOTTOM
|IY_LEFT
|IY_VERT
, 0},
287 {"blh", IY_BOTTOM
|IY_LEFT
|IY_HORIZ
, 0},
288 {"brv", IY_BOTTOM
|IY_RIGHT
|IY_VERT
, 0},
289 {"brh", IY_BOTTOM
|IY_RIGHT
|IY_HORIZ
, 0},
290 {"tlv", IY_TOP
|IY_LEFT
|IY_VERT
, 0},
291 {"tlh", IY_TOP
|IY_LEFT
|IY_HORIZ
, 0},
292 {"trv", IY_TOP
|IY_RIGHT
|IY_VERT
, 0},
293 {"trh", IY_TOP
|IY_RIGHT
|IY_HORIZ
, 0},
297 static WOptionEnumeration seMenuStyles
[] = {
298 {"normal", MS_NORMAL
, 0},
299 {"singletexture", MS_SINGLE_TEXTURE
, 0},
300 {"flat", MS_FLAT
, 0},
305 static WOptionEnumeration seDisplayPositions
[] = {
306 {"none", WD_NONE
, 0},
307 {"center", WD_CENTER
, 0},
309 {"bottom", WD_BOTTOM
, 0},
310 {"topleft", WD_TOPLEFT
, 0},
311 {"topright", WD_TOPRIGHT
, 0},
312 {"bottomleft", WD_BOTTOMLEFT
, 0},
313 {"bottomright", WD_BOTTOMRIGHT
, 0}
318 * ALL entries in the tables bellow, NEED to have a default value
319 * defined, and this value needs to be correct.
322 /* these options will only affect the window manager on startup
324 * static defaults can't access the screen data, because it is
325 * created after these defaults are read
327 WDefaultEntry staticOptionList
[] = {
329 {"DisableDithering", "NO", NULL
,
330 &wPreferences
.no_dithering
, getBool
, NULL
332 {"ColormapSize", "4", NULL
,
333 &wPreferences
.cmap_size
, getInt
, NULL
335 /* static by laziness */
336 {"IconSize", "64", NULL
,
337 &wPreferences
.icon_size
, getInt
, NULL
339 {"ModifierKey", "Mod1", NULL
,
340 &wPreferences
.modifier_mask
, getModMask
, NULL
342 {"DisableWSMouseActions", "NO", NULL
,
343 &wPreferences
.disable_root_mouse
, getBool
, NULL
345 {"FocusMode", "manual", seFocusModes
,
346 &wPreferences
.focus_mode
, getEnum
, NULL
347 }, /* have a problem when switching from manual to sloppy without restart */
348 {"NewStyle", "NO", NULL
,
349 &wPreferences
.new_style
, getBool
, NULL
351 {"DisableDock", "NO", (void*) WM_DOCK
,
352 NULL
, getBool
, setIfDockPresent
354 {"DisableClip", "NO", (void*) WM_CLIP
,
355 NULL
, getBool
, setIfDockPresent
357 {"DisableMiniwindows", "NO", NULL
,
358 &wPreferences
.disable_miniwindows
, getBool
, NULL
360 {"MultiByteText", "NO", NULL
,
361 &wPreferences
.multi_byte_text
, getBool
, setMultiByte
367 WDefaultEntry optionList
[] = {
368 /* dynamic options */
369 {"IconPosition", "blh", seIconPositions
,
370 &wPreferences
.icon_yard
, getEnum
, setIconPosition
372 {"IconificationStyle", "Zoom", seIconificationStyles
,
373 &wPreferences
.iconification_style
, getEnum
, NULL
375 {"SelectWindowsMouseButton", "Left", seMouseButtons
,
376 &wPreferences
.select_button
, getEnum
, NULL
378 {"WindowListMouseButton", "Middle", seMouseButtons
,
379 &wPreferences
.windowl_button
, getEnum
, NULL
381 {"ApplicationMenuMouseButton", "Right", seMouseButtons
,
382 &wPreferences
.menu_button
, getEnum
, NULL
384 {"PixmapPath", DEF_PIXMAP_PATHS
, NULL
,
385 &wPreferences
.pixmap_path
, getPathList
, NULL
387 {"IconPath", DEF_ICON_PATHS
, NULL
,
388 &wPreferences
.icon_path
, getPathList
, NULL
390 {"ColormapMode", "auto", seColormapModes
,
391 &wPreferences
.colormap_mode
, getEnum
, NULL
393 {"AutoFocus", "NO", NULL
,
394 &wPreferences
.auto_focus
, getBool
, NULL
396 {"RaiseDelay", "0", NULL
,
397 &wPreferences
.raise_delay
, getInt
, NULL
399 {"CirculateRaise", "NO", NULL
,
400 &wPreferences
.circ_raise
, getBool
, NULL
402 {"Superfluous", "NO", NULL
,
403 &wPreferences
.superfluous
, getBool
, NULL
405 {"AdvanceToNewWorkspace", "NO", NULL
,
406 &wPreferences
.ws_advance
, getBool
, NULL
408 {"CycleWorkspaces", "NO", NULL
,
409 &wPreferences
.ws_cycle
, getBool
, NULL
411 {"WorkspaceNameDisplayPosition", "center", seDisplayPositions
,
412 &wPreferences
.workspace_name_display_position
, getEnum
, NULL
414 #ifdef VIRTUAL_DESKTOP
415 {"VirtualEdgeThickness", "1", NULL
,
416 &wPreferences
.vedge_thickness
, getInt
, NULL
418 {"VirtualEdgeHorizonScrollSpeed", "1", NULL
,
419 &wPreferences
.vedge_hscrollspeed
, getInt
, NULL
421 {"VirtualEdgeVerticalScrollSpeed", "1", NULL
,
422 &wPreferences
.vedge_vscrollspeed
, getInt
, NULL
424 {"VirtualEdgeWidth", "2000", NULL
,
425 &wPreferences
.vedge_width
, getInt
, NULL
427 {"VirtualEdgeHeight", "2000", NULL
,
428 &wPreferences
.vedge_height
, getInt
, NULL
431 {"StickyIcons", "NO", NULL
,
432 &wPreferences
.sticky_icons
, getBool
, setStickyIcons
434 {"SaveSessionOnExit", "NO", NULL
,
435 &wPreferences
.save_session_on_exit
, getBool
, NULL
437 {"WrapMenus", "NO", NULL
,
438 &wPreferences
.wrap_menus
, getBool
, NULL
440 {"ScrollableMenus", "NO", NULL
,
441 &wPreferences
.scrollable_menus
, getBool
, NULL
443 {"MenuScrollSpeed", "medium", seSpeeds
,
444 &wPreferences
.menu_scroll_speed
, getEnum
, NULL
446 {"IconSlideSpeed", "medium", seSpeeds
,
447 &wPreferences
.icon_slide_speed
, getEnum
, NULL
449 {"ShadeSpeed", "medium", seSpeeds
,
450 &wPreferences
.shade_speed
, getEnum
, NULL
452 {"DoubleClickTime", "250", (void*) &wPreferences
.dblclick_time
,
453 &wPreferences
.dblclick_time
, getInt
, setDoubleClick
,
455 {"AlignSubmenus", "NO", NULL
,
456 &wPreferences
.align_menus
, getBool
, NULL
458 {"OpenTransientOnOwnerWorkspace", "NO", NULL
,
459 &wPreferences
.open_transients_with_parent
, getBool
, NULL
461 {"WindowPlacement", "auto", sePlacements
,
462 &wPreferences
.window_placement
, getEnum
, NULL
464 {"IgnoreFocusClick","NO", NULL
,
465 &wPreferences
.ignore_focus_click
, getBool
, NULL
467 {"UseSaveUnders", "NO", NULL
,
468 &wPreferences
.use_saveunders
, getBool
, NULL
470 {"OpaqueMove", "NO", NULL
,
471 &wPreferences
.opaque_move
, getBool
, NULL
473 {"DisableSound", "NO", NULL
,
474 &wPreferences
.no_sound
, getBool
, NULL
476 {"DisableAnimations", "NO", NULL
,
477 &wPreferences
.no_animations
, getBool
, NULL
479 {"DontLinkWorkspaces","NO", NULL
,
480 &wPreferences
.no_autowrap
, getBool
, NULL
482 {"AutoArrangeIcons", "NO", NULL
,
483 &wPreferences
.auto_arrange_icons
, getBool
, NULL
485 {"NoWindowOverDock", "NO", NULL
,
486 &wPreferences
.no_window_over_dock
, getBool
, updateUsableArea
488 {"NoWindowOverIcons", "NO", NULL
,
489 &wPreferences
.no_window_over_icons
, getBool
, updateUsableArea
491 {"WindowPlaceOrigin", "(0, 0)", NULL
,
492 &wPreferences
.window_place_origin
, getCoord
, NULL
494 {"ResizeDisplay", "corner", seGeomDisplays
,
495 &wPreferences
.size_display
, getEnum
, NULL
497 {"MoveDisplay", "corner", seGeomDisplays
,
498 &wPreferences
.move_display
, getEnum
, NULL
500 {"DontConfirmKill", "NO", NULL
,
501 &wPreferences
.dont_confirm_kill
, getBool
,NULL
503 {"WindowTitleBalloons", "NO", NULL
,
504 &wPreferences
.window_balloon
, getBool
, NULL
506 {"MiniwindowTitleBalloons", "NO", NULL
,
507 &wPreferences
.miniwin_balloon
,getBool
, NULL
509 {"AppIconBalloons", "NO", NULL
,
510 &wPreferences
.appicon_balloon
,getBool
, NULL
512 {"HelpBalloons", "NO", NULL
,
513 &wPreferences
.help_balloon
, getBool
, NULL
515 {"EdgeResistance", "30", NULL
,
516 &wPreferences
.edge_resistance
,getInt
, NULL
518 {"Attraction", "NO", NULL
,
519 &wPreferences
.attract
, getBool
, NULL
521 {"DisableBlinking", "NO", NULL
,
522 &wPreferences
.dont_blink
, getBool
, NULL
524 #ifdef WEENDOZE_CYCLE
525 {"WindozeCycling","NO", NULL
,
526 &wPreferences
.windoze_cycling
, getBool
, NULL
528 {"PopupSwitchMenu","YES", NULL
,
529 &wPreferences
.popup_switchmenu
, getBool
, NULL
531 #endif /* WEENDOZE_CYCLE */
533 {"MenuStyle", "normal", seMenuStyles
,
534 &wPreferences
.menu_style
, getEnum
, setMenuStyle
536 {"WidgetColor", "(solid, gray)", NULL
,
537 NULL
, getTexture
, setWidgetColor
,
539 {"WorkspaceSpecificBack","()", NULL
,
540 NULL
, getWSSpecificBackground
, setWorkspaceSpecificBack
542 /* WorkspaceBack must come after WorkspaceSpecificBack or
543 * WorkspaceBack wont know WorkspaceSpecificBack was also
544 * specified and 2 copies of wmsetbg will be launched */
545 {"WorkspaceBack", "(solid, black)", NULL
,
546 NULL
, getWSBackground
,setWorkspaceBack
548 {"SmoothWorkspaceBack", "NO", NULL
,
551 {"IconBack", "(solid, gray)", NULL
,
552 NULL
, getTexture
, setIconTile
554 {"TitleJustify", "center", seJustifications
,
555 &wPreferences
.title_justification
, getEnum
, setJustify
557 {"WindowTitleFont", DEF_TITLE_FONT
, NULL
,
558 NULL
, getFont
, setWinTitleFont
,
560 {"MenuTitleFont", DEF_MENU_TITLE_FONT
, NULL
,
561 NULL
, getFont
, setMenuTitleFont
563 {"MenuTextFont", DEF_MENU_ENTRY_FONT
, NULL
,
564 NULL
, getFont
, setMenuTextFont
566 {"IconTitleFont", DEF_ICON_TITLE_FONT
, NULL
,
567 NULL
, getFont
, setIconTitleFont
569 {"ClipTitleFont", DEF_CLIP_TITLE_FONT
, NULL
,
570 NULL
, getFont
, setClipTitleFont
572 {"DisplayFont", DEF_INFO_TEXT_FONT
, NULL
,
573 NULL
, getFont
, setDisplayFont
575 {"LargeDisplayFont",DEF_WORKSPACE_NAME_FONT
, NULL
,
576 NULL
, getFont
, setLargeDisplayFont
578 {"HighlightColor", "white", NULL
,
579 NULL
, getColor
, setHightlight
581 {"HighlightTextColor", "black", NULL
,
582 NULL
, getColor
, setHightlightText
584 {"ClipTitleColor", "black", (void*)CLIP_NORMAL
,
585 NULL
, getColor
, setClipTitleColor
587 {"CClipTitleColor", "\"#454045\"", (void*)CLIP_COLLAPSED
,
588 NULL
, getColor
, setClipTitleColor
590 #ifdef DRAWSTRING_PLUGIN
591 {"FTitleColor", "white", (void*)WS_FOCUSED
,
592 NULL
, getTextRenderer
, setWTitleColor
594 {"PTitleColor", "white", (void*)WS_PFOCUSED
,
595 NULL
, getTextRenderer
, setWTitleColor
597 {"UTitleColor", "black", (void*)WS_UNFOCUSED
,
598 NULL
, getTextRenderer
, setWTitleColor
601 {"FTitleColor", "white", (void*)WS_FOCUSED
,
602 NULL
, getColor
, setWTitleColor
604 {"PTitleColor", "white", (void*)WS_PFOCUSED
,
605 NULL
, getColor
, setWTitleColor
607 {"UTitleColor", "black", (void*)WS_UNFOCUSED
,
608 NULL
, getColor
, setWTitleColor
611 {"FTitleBack", "(solid, black)", NULL
,
612 NULL
, getTexture
, setFTitleBack
614 {"PTitleBack", "(solid, \"#616161\")", NULL
,
615 NULL
, getTexture
, setPTitleBack
617 {"UTitleBack", "(solid, gray)", NULL
,
618 NULL
, getTexture
, setUTitleBack
620 {"ResizebarBack", "(solid, gray)", NULL
,
621 NULL
, getTexture
, setResizebarBack
623 #ifdef DRAWSTRING_PLUGIN
624 {"MenuTitleColor", "white", NULL
,
625 NULL
, getTextRenderer
, setMenuTitleColor
628 {"MenuTitleColor", "white", NULL
,
629 NULL
, getColor
, setMenuTitleColor
632 {"MenuTextColor", "black", NULL
,
633 NULL
, getColor
, setMenuTextColor
635 {"MenuDisabledColor", "\"#616161\"", NULL
,
636 NULL
, getColor
, setMenuDisabledColor
638 {"MenuTitleBack", "(solid, black)", NULL
,
639 NULL
, getTexture
, setMenuTitleBack
641 {"MenuTextBack", "(solid, gray)", NULL
,
642 NULL
, getTexture
, setMenuTextBack
644 {"IconTitleColor", "white", NULL
,
645 NULL
, getColor
, setIconTitleColor
647 {"IconTitleBack", "black", NULL
,
648 NULL
, getColor
, setIconTitleBack
652 {"RootMenuKey", "None", (void*)WKBD_ROOTMENU
,
653 NULL
, getKeybind
, setKeyGrab
655 {"WindowListKey", "None", (void*)WKBD_WINDOWLIST
,
656 NULL
, getKeybind
, setKeyGrab
659 {"WindowMenuKey", "None", (void*)WKBD_WINDOWMENU
,
660 NULL
, getKeybind
, setKeyGrab
662 {"ClipLowerKey", "None", (void*)WKBD_CLIPLOWER
,
663 NULL
, getKeybind
, setKeyGrab
665 {"ClipRaiseKey", "None", (void*)WKBD_CLIPRAISE
,
666 NULL
, getKeybind
, setKeyGrab
668 {"ClipRaiseLowerKey", "None", (void*)WKBD_CLIPRAISELOWER
,
669 NULL
, getKeybind
, setKeyGrab
671 {"MiniaturizeKey", "None", (void*)WKBD_MINIATURIZE
,
672 NULL
, getKeybind
, setKeyGrab
674 {"HideKey", "None", (void*)WKBD_HIDE
,
675 NULL
, getKeybind
, setKeyGrab
677 {"MoveResizeKey", "None", (void*)WKBD_MOVERESIZE
,
678 NULL
, getKeybind
, setKeyGrab
680 {"CloseKey", "None", (void*)WKBD_CLOSE
,
681 NULL
, getKeybind
, setKeyGrab
683 {"MaximizeKey", "None", (void*)WKBD_MAXIMIZE
,
684 NULL
, getKeybind
, setKeyGrab
686 {"VMaximizeKey", "None", (void*)WKBD_VMAXIMIZE
,
687 NULL
, getKeybind
, setKeyGrab
689 {"RaiseKey", "\"Meta+Up\"", (void*)WKBD_RAISE
,
690 NULL
, getKeybind
, setKeyGrab
692 {"LowerKey", "\"Meta+Down\"", (void*)WKBD_LOWER
,
693 NULL
, getKeybind
, setKeyGrab
695 {"RaiseLowerKey", "None", (void*)WKBD_RAISELOWER
,
696 NULL
, getKeybind
, setKeyGrab
698 {"ShadeKey", "None", (void*)WKBD_SHADE
,
699 NULL
, getKeybind
, setKeyGrab
701 {"SelectKey", "None", (void*)WKBD_SELECT
,
702 NULL
, getKeybind
, setKeyGrab
704 {"FocusNextKey", "None", (void*)WKBD_FOCUSNEXT
,
705 NULL
, getKeybind
, setKeyGrab
707 {"FocusPrevKey", "None", (void*)WKBD_FOCUSPREV
,
708 NULL
, getKeybind
, setKeyGrab
710 {"NextWorkspaceKey", "None", (void*)WKBD_NEXTWORKSPACE
,
711 NULL
, getKeybind
, setKeyGrab
713 {"PrevWorkspaceKey", "None", (void*)WKBD_PREVWORKSPACE
,
714 NULL
, getKeybind
, setKeyGrab
716 {"NextWorkspaceLayerKey", "None", (void*)WKBD_NEXTWSLAYER
,
717 NULL
, getKeybind
, setKeyGrab
719 {"PrevWorkspaceLayerKey", "None", (void*)WKBD_PREVWSLAYER
,
720 NULL
, getKeybind
, setKeyGrab
722 {"Workspace1Key", "None", (void*)WKBD_WORKSPACE1
,
723 NULL
, getKeybind
, setKeyGrab
725 {"Workspace2Key", "None", (void*)WKBD_WORKSPACE2
,
726 NULL
, getKeybind
, setKeyGrab
728 {"Workspace3Key", "None", (void*)WKBD_WORKSPACE3
,
729 NULL
, getKeybind
, setKeyGrab
731 {"Workspace4Key", "None", (void*)WKBD_WORKSPACE4
,
732 NULL
, getKeybind
, setKeyGrab
734 {"Workspace5Key", "None", (void*)WKBD_WORKSPACE5
,
735 NULL
, getKeybind
, setKeyGrab
737 {"Workspace6Key", "None", (void*)WKBD_WORKSPACE6
,
738 NULL
, getKeybind
, setKeyGrab
740 {"Workspace7Key", "None", (void*)WKBD_WORKSPACE7
,
741 NULL
, getKeybind
, setKeyGrab
743 {"Workspace8Key", "None", (void*)WKBD_WORKSPACE8
,
744 NULL
, getKeybind
, setKeyGrab
746 {"Workspace9Key", "None", (void*)WKBD_WORKSPACE9
,
747 NULL
, getKeybind
, setKeyGrab
749 {"Workspace10Key", "None", (void*)WKBD_WORKSPACE10
,
750 NULL
, getKeybind
, setKeyGrab
752 {"WindowShortcut1Key","None", (void*)WKBD_WINDOW1
,
753 NULL
, getKeybind
, setKeyGrab
755 {"WindowShortcut2Key","None", (void*)WKBD_WINDOW2
,
756 NULL
, getKeybind
, setKeyGrab
758 {"WindowShortcut3Key","None", (void*)WKBD_WINDOW3
,
759 NULL
, getKeybind
, setKeyGrab
761 {"WindowShortcut4Key","None", (void*)WKBD_WINDOW4
,
762 NULL
, getKeybind
, setKeyGrab
764 #ifdef EXTEND_WINDOWSHORTCUT
765 ,{"WindowShortcut5Key","None", (void*)WKBD_WINDOW5
,
766 NULL
, getKeybind
, setKeyGrab
768 {"WindowShortcut6Key","None", (void*)WKBD_WINDOW6
,
769 NULL
, getKeybind
, setKeyGrab
771 {"WindowShortcut7Key","None", (void*)WKBD_WINDOW7
,
772 NULL
, getKeybind
, setKeyGrab
774 {"WindowShortcut8Key","None", (void*)WKBD_WINDOW8
,
775 NULL
, getKeybind
, setKeyGrab
777 {"WindowShortcut9Key","None", (void*)WKBD_WINDOW9
,
778 NULL
, getKeybind
, setKeyGrab
780 {"WindowShortcut10Key","None", (void*)WKBD_WINDOW10
,
781 NULL
, getKeybind
, setKeyGrab
783 #endif /* EXTEND_WINDOWSHORTCUT */
785 #ifdef KEEP_XKB_LOCK_STATUS
786 ,{"ToggleKbdModeKey", "None", (void*)WKBD_TOGGLE
,
787 NULL
, getKeybind
, setKeyGrab
789 {"KbdModeLock", "NO", NULL
,
790 &wPreferences
.modelock
, getBool
, NULL
792 #endif /* KEEP_XKB_LOCK_STATUS */
797 static void rereadDefaults(void);
804 /* must defer the update because accessing X data from a
805 * signal handler can mess up Xlib */
814 WDefaultEntry
*entry
;
816 PLSetStringCmpHook(StringCompareHook
);
818 for (i
=0; i
<sizeof(optionList
)/sizeof(WDefaultEntry
); i
++) {
819 entry
= &optionList
[i
];
821 entry
->plkey
= PLMakeString(entry
->key
);
822 if (entry
->default_value
)
823 entry
->plvalue
= PLGetProplistWithDescription(entry
->default_value
);
825 entry
->plvalue
= NULL
;
828 for (i
=0; i
<sizeof(staticOptionList
)/sizeof(WDefaultEntry
); i
++) {
829 entry
= &staticOptionList
[i
];
831 entry
->plkey
= PLMakeString(entry
->key
);
832 if (entry
->default_value
)
833 entry
->plvalue
= PLGetProplistWithDescription(entry
->default_value
);
835 entry
->plvalue
= NULL
;
839 wDomainName = PLMakeString(WMDOMAIN_NAME);
840 wAttributeDomainName = PLMakeString(WMATTRIBUTE_DOMAIN_NAME);
842 PLRegister(wDomainName, rereadDefaults);
843 PLRegister(wAttributeDomainName, rereadDefaults);
852 wDefaultsInit(int screen_number
)
854 static int defaults_inited
= 0;
857 if (!defaults_inited
) {
861 dict
= PLGetDomain(wDomainName
);
863 wwarning(_("could not read domain \"%s\" from defaults database"),
864 PLGetString(wDomainName
));
873 wDefaultsDestroyDomain(WDDomain
*domain
)
875 if (domain
->dictionary
)
876 PLRelease(domain
->dictionary
);
883 wDefaultsInitDomain(char *domain
, Bool requireDictionary
)
887 static int inited
= 0;
890 proplist_t shared_dict
=NULL
;
897 db
= wmalloc(sizeof(WDDomain
));
898 memset(db
, 0, sizeof(WDDomain
));
899 db
->domain_name
= domain
;
900 db
->path
= wdefaultspathfordomain(domain
);
903 if (the_path
&& stat(the_path
, &stbuf
)>=0) {
904 db
->dictionary
= ReadProplistFromFile(the_path
);
905 if (db
->dictionary
) {
906 if (requireDictionary
&& !PLIsDictionary(db
->dictionary
)) {
907 PLRelease(db
->dictionary
);
908 db
->dictionary
= NULL
;
909 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
912 db
->timestamp
= stbuf
.st_mtime
;
914 wwarning(_("could not load domain %s from user defaults database"),
919 /* global system dictionary */
920 sprintf(path
, "%s/WindowMaker/%s", SYSCONFDIR
, domain
);
921 if (stat(path
, &stbuf
)>=0) {
922 shared_dict
= ReadProplistFromFile(path
);
924 if (requireDictionary
&& !PLIsDictionary(shared_dict
)) {
925 wwarning(_("Domain %s (%s) of global defaults database is corrupted!"),
927 PLRelease(shared_dict
);
930 if (db
->dictionary
&& PLIsDictionary(shared_dict
) &&
931 PLIsDictionary(db
->dictionary
)) {
932 PLMergeDictionaries(shared_dict
, db
->dictionary
);
933 PLRelease(db
->dictionary
);
934 db
->dictionary
= shared_dict
;
935 if (stbuf
.st_mtime
> db
->timestamp
)
936 db
->timestamp
= stbuf
.st_mtime
;
937 } else if (!db
->dictionary
) {
938 db
->dictionary
= shared_dict
;
939 if (stbuf
.st_mtime
> db
->timestamp
)
940 db
->timestamp
= stbuf
.st_mtime
;
944 wwarning(_("could not load domain %s from global defaults database (%s)"),
949 /* set to save it in user's directory, no matter from where it was read */
950 if (db
->dictionary
) {
951 proplist_t tmp
= PLMakeString(db
->path
);
953 PLSetFilename(db
->dictionary
, tmp
);
962 wReadStaticDefaults(proplist_t dict
)
965 WDefaultEntry
*entry
;
970 for (i
=0; i
<sizeof(staticOptionList
)/sizeof(WDefaultEntry
); i
++) {
971 entry
= &staticOptionList
[i
];
974 plvalue
= PLGetDictionaryEntry(dict
, entry
->plkey
);
979 /* no default in the DB. Use builtin default */
980 plvalue
= entry
->plvalue
;
985 (*entry
->convert
)(NULL
, entry
, plvalue
, entry
->addr
, &tdata
);
987 (*entry
->update
)(NULL
, entry
, tdata
, entry
->extra_data
);
995 wDefaultsCheckDomains(void *foo
)
1001 char path
[PATH_MAX
];
1004 puts("Checking domains...");
1006 if (stat(WDWindowMaker
->path
, &stbuf
)>=0
1007 && WDWindowMaker
->timestamp
< stbuf
.st_mtime
) {
1008 proplist_t shared_dict
= NULL
;
1010 puts("Checking WindowMaker domain");
1012 WDWindowMaker
->timestamp
= stbuf
.st_mtime
;
1014 /* global dictionary */
1015 sprintf(path
, "%s/WindowMaker/WindowMaker", SYSCONFDIR
);
1016 if (stat(path
, &stbuf
)>=0) {
1017 shared_dict
= ReadProplistFromFile(path
);
1018 if (shared_dict
&& !PLIsDictionary(shared_dict
)) {
1019 wwarning(_("Domain %s (%s) of global defaults database is corrupted!"),
1020 "WindowMaker", path
);
1021 PLRelease(shared_dict
);
1023 } else if (!shared_dict
) {
1024 wwarning(_("could not load domain %s from global defaults database"),
1028 /* user dictionary */
1029 dict
= ReadProplistFromFile(WDWindowMaker
->path
);
1031 if (!PLIsDictionary(dict
)) {
1034 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
1035 "WindowMaker", WDWindowMaker
->path
);
1038 PLSetFilename(shared_dict
, PLGetFilename(dict
));
1039 PLMergeDictionaries(shared_dict
, dict
);
1044 for (i
=0; i
<wScreenCount
; i
++) {
1045 scr
= wScreenWithNumber(i
);
1047 wReadDefaults(scr
, dict
);
1049 if (WDWindowMaker
->dictionary
) {
1050 PLRelease(WDWindowMaker
->dictionary
);
1052 WDWindowMaker
->dictionary
= dict
;
1055 wwarning(_("could not load domain %s from user defaults database"),
1059 PLRelease(shared_dict
);
1063 if (stat(WDWindowAttributes
->path
, &stbuf
)>=0
1064 && WDWindowAttributes
->timestamp
< stbuf
.st_mtime
) {
1066 puts("Checking WMWindowAttributes domain");
1068 dict
= ReadProplistFromFile(WDWindowAttributes
->path
);
1070 if (!PLIsDictionary(dict
)) {
1073 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
1074 "WMWindowAttributes", WDWindowAttributes
->path
);
1076 if (WDWindowAttributes
->dictionary
)
1077 PLRelease(WDWindowAttributes
->dictionary
);
1078 WDWindowAttributes
->dictionary
= dict
;
1079 for (i
=0; i
<wScreenCount
; i
++) {
1080 scr
= wScreenWithNumber(i
);
1082 wDefaultUpdateIcons(scr
);
1086 wwarning(_("could not load domain %s from user defaults database"),
1087 "WMWindowAttributes");
1089 WDWindowAttributes
->timestamp
= stbuf
.st_mtime
;
1093 if (stat(WDRootMenu
->path
, &stbuf
)>=0
1094 && WDRootMenu
->timestamp
< stbuf
.st_mtime
) {
1095 dict
= ReadProplistFromFile(WDRootMenu
->path
);
1097 puts("Checking WMRootMenu domain");
1100 if (!PLIsArray(dict
) && !PLIsString(dict
)) {
1103 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
1104 "WMRootMenu", WDRootMenu
->path
);
1106 if (WDRootMenu
->dictionary
) {
1107 PLRelease(WDRootMenu
->dictionary
);
1109 WDRootMenu
->dictionary
= dict
;
1112 wwarning(_("could not load domain %s from user defaults database"),
1115 WDRootMenu
->timestamp
= stbuf
.st_mtime
;
1120 WMAddTimerHandler(DEFAULTS_CHECK_INTERVAL
, wDefaultsCheckDomains
, foo
);
1125 wReadDefaults(WScreen
*scr
, proplist_t new_dict
)
1127 proplist_t plvalue
, old_value
;
1128 WDefaultEntry
*entry
;
1130 int update_workspace_back
= 0; /* kluge :/ */
1133 proplist_t old_dict
= (WDWindowMaker
->dictionary
!=new_dict
1134 ? WDWindowMaker
->dictionary
: NULL
);
1140 for (i
=0; i
<sizeof(optionList
)/sizeof(WDefaultEntry
); i
++) {
1141 entry
= &optionList
[i
];
1144 plvalue
= PLGetDictionaryEntry(new_dict
, entry
->plkey
);
1151 old_value
= PLGetDictionaryEntry(old_dict
, entry
->plkey
);
1154 if (!plvalue
&& !old_value
) {
1155 /* no default in the DB. Use builtin default */
1156 plvalue
= entry
->plvalue
;
1157 if (plvalue
&& new_dict
) {
1158 PLInsertDictionaryEntry(new_dict
, entry
->plkey
, plvalue
);
1161 } else if (!plvalue
) {
1162 /* value was deleted from DB. Keep current value */
1164 } else if (!old_value
) {
1165 /* set value for the 1st time */
1166 } else if (!PLIsEqual(plvalue
, old_value
)) {
1167 /* value has changed */
1170 if (strcmp(entry
->key
, "WorkspaceBack") == 0
1171 && update_workspace_back
1172 && scr
->flags
.backimage_helper_launched
) {
1174 /* value was not changed since last time */
1181 printf("Updating %s to %s\n", entry
->key
,
1182 PLGetDescription(plvalue
));
1185 if ((*entry
->convert
)(scr
, entry
, plvalue
, entry
->addr
, &tdata
)) {
1187 * If the WorkspaceSpecificBack data has been changed
1188 * so that the helper will be launched now, we must be
1189 * sure to send the default background texture config
1192 if (strcmp(entry
->key
, "WorkspaceSpecificBack") == 0
1193 && !scr
->flags
.backimage_helper_launched
) {
1194 update_workspace_back
= 1;
1196 if (entry
->update
) {
1198 (*entry
->update
)(scr
, entry
, tdata
, entry
->extra_data
);
1204 if (needs_refresh
!=0 && !scr
->flags
.startup
) {
1208 if (needs_refresh
& REFRESH_MENU_TITLE_TEXTURE
)
1209 foo
|= WTextureSettings
;
1210 if (needs_refresh
& REFRESH_MENU_TITLE_FONT
)
1211 foo
|= WFontSettings
;
1212 if (needs_refresh
& REFRESH_MENU_TITLE_COLOR
)
1213 foo
|= WColorSettings
;
1215 WMPostNotificationName(WNMenuTitleAppearanceSettingsChanged
, NULL
,
1219 if (needs_refresh
& REFRESH_MENU_TEXTURE
)
1220 foo
|= WTextureSettings
;
1221 if (needs_refresh
& REFRESH_MENU_FONT
)
1222 foo
|= WFontSettings
;
1223 if (needs_refresh
& REFRESH_MENU_COLOR
)
1224 foo
|= WColorSettings
;
1226 WMPostNotificationName(WNMenuAppearanceSettingsChanged
, NULL
,
1230 if (needs_refresh
& REFRESH_WINDOW_FONT
) {
1231 foo
|= WFontSettings
;
1233 if (needs_refresh
& REFRESH_WINDOW_TEXTURES
) {
1234 foo
|= WTextureSettings
;
1236 if (needs_refresh
& REFRESH_WINDOW_TITLE_COLOR
) {
1237 foo
|= WColorSettings
;
1240 WMPostNotificationName(WNWindowAppearanceSettingsChanged
, NULL
,
1243 if (!(needs_refresh
& REFRESH_ICON_TILE
)) {
1245 if (needs_refresh
& REFRESH_ICON_FONT
) {
1246 foo
|= WFontSettings
;
1248 if (needs_refresh
& REFRESH_ICON_TITLE_COLOR
) {
1249 foo
|= WTextureSettings
;
1251 if (needs_refresh
& REFRESH_ICON_TITLE_BACK
) {
1252 foo
|= WTextureSettings
;
1255 WMPostNotificationName(WNIconAppearanceSettingsChanged
, NULL
,
1258 if (needs_refresh
& REFRESH_ICON_TILE
)
1259 WMPostNotificationName(WNIconTileSettingsChanged
, NULL
, NULL
);
1265 wDefaultUpdateIcons(WScreen
*scr
)
1267 WAppIcon
*aicon
= scr
->app_icon_list
;
1268 WWindow
*wwin
= scr
->focused_window
;
1272 file
= wDefaultGetIconFile(scr
, aicon
->wm_instance
, aicon
->wm_class
,
1274 if ((file
&& aicon
->icon
->file
&& strcmp(file
, aicon
->icon
->file
)!=0)
1275 || (file
&& !aicon
->icon
->file
)) {
1278 if (aicon
->icon
->file
)
1279 free(aicon
->icon
->file
);
1280 aicon
->icon
->file
= wstrdup(file
);
1282 new_image
= wDefaultGetImage(scr
, aicon
->wm_instance
,
1285 wIconChangeImage(aicon
->icon
, new_image
);
1286 wAppIconPaint(aicon
);
1289 aicon
= aicon
->next
;
1292 if (!wPreferences
.flags
.noclip
)
1293 wClipIconPaint(scr
->clip_icon
);
1296 if (wwin
->icon
&& wwin
->flags
.miniaturized
) {
1297 file
= wDefaultGetIconFile(scr
, wwin
->wm_instance
, wwin
->wm_class
,
1299 if ((file
&& wwin
->icon
->file
&& strcmp(file
, wwin
->icon
->file
)!=0)
1300 || (file
&& !wwin
->icon
->file
)) {
1303 if (wwin
->icon
->file
)
1304 free(wwin
->icon
->file
);
1305 wwin
->icon
->file
= wstrdup(file
);
1307 new_image
= wDefaultGetImage(scr
, wwin
->wm_instance
,
1310 wIconChangeImage(wwin
->icon
, new_image
);
1318 /* --------------------------- Local ----------------------- */
1320 #define GET_STRING_OR_DEFAULT(x, var) if (!PLIsString(value)) { \
1321 wwarning(_("Wrong option format for key \"%s\". Should be %s."), \
1323 wwarning(_("using default \"%s\" instead"), entry->default_value); \
1324 var = entry->default_value;\
1325 } else var = PLGetString(value)\
1332 string2index(proplist_t key
, proplist_t val
, proplist_t def
,
1333 WOptionEnumeration
*values
)
1336 WOptionEnumeration
*v
;
1337 char buffer
[TOTAL_VALUES_LENGTH
];
1339 if (PLIsString(val
) && (str
= PLGetString(val
))) {
1340 for (v
=values
; v
->string
!=NULL
; v
++) {
1341 if (strcasecmp(v
->string
, str
)==0)
1347 for (v
=values
; v
->string
!=NULL
; v
++) {
1350 strcat(buffer
, ", ");
1351 strcat(buffer
, v
->string
);
1354 wwarning(_("wrong option value for key \"%s\". Should be one of %s"),
1355 PLGetString(key
), buffer
);
1358 return string2index(key
, val
, NULL
, values
);
1368 * value - is the value in the defaults DB
1369 * addr - is the address to store the data
1370 * ret - is the address to store a pointer to a temporary buffer. ret
1371 * must not be freed and is used by the set functions
1374 getBool(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
1381 GET_STRING_OR_DEFAULT("Boolean", val
);
1384 if ((val
[1]=='\0' && (val
[0]=='y' || val
[0]=='Y'))
1385 || strcasecmp(val
, "YES")==0) {
1388 } else if ((val
[1]=='\0' && (val
[0]=='n' || val
[0]=='N'))
1389 || strcasecmp(val
, "NO")==0) {
1393 if (sscanf(val
, "%i", &i
)==1) {
1399 wwarning(_("can't convert \"%s\" to boolean for key \"%s\""),
1401 if (second_pass
==0) {
1402 val
= PLGetString(entry
->plvalue
);
1404 wwarning(_("using default \"%s\" instead"), val
);
1415 *(char*)addr
= data
;
1423 getInt(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
1430 GET_STRING_OR_DEFAULT("Integer", val
);
1432 if (sscanf(val
, "%i", &data
)!=1) {
1433 wwarning(_("can't convert \"%s\" to integer for key \"%s\""),
1435 val
= PLGetString(entry
->plvalue
);
1436 wwarning(_("using default \"%s\" instead"), val
);
1437 if (sscanf(val
, "%i", &data
)!=1) {
1453 getCoord(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
1457 char *val_x
, *val_y
;
1458 int nelem
, changed
=0;
1459 proplist_t elem_x
, elem_y
;
1462 if (!PLIsArray(value
)) {
1463 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1464 entry
->key
, "Coordinate");
1466 value
= entry
->plvalue
;
1468 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1474 nelem
= PLGetNumberOfElements(value
);
1476 wwarning(_("Incorrect number of elements in array for key \"%s\"."),
1479 value
= entry
->plvalue
;
1481 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1487 elem_x
= PLGetArrayElement(value
, 0);
1488 elem_y
= PLGetArrayElement(value
, 1);
1490 if (!elem_x
|| !elem_y
|| !PLIsString(elem_x
) || !PLIsString(elem_y
)) {
1491 wwarning(_("Wrong value for key \"%s\". Should be Coordinate."),
1494 value
= entry
->plvalue
;
1496 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1502 val_x
= PLGetString(elem_x
);
1503 val_y
= PLGetString(elem_y
);
1505 if (sscanf(val_x
, "%i", &data
.x
)!=1 || sscanf(val_y
, "%i", &data
.y
)!=1) {
1506 wwarning(_("can't convert array to integers for \"%s\"."), entry
->key
);
1508 value
= entry
->plvalue
;
1510 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1518 else if (data
.x
> scr
->scr_width
/3)
1519 data
.x
= scr
->scr_width
/3;
1522 else if (data
.y
> scr
->scr_height
/3)
1523 data
.y
= scr
->scr_height
/3;
1529 *(WCoord
*)addr
= data
;
1537 /* This function is not used at the moment. */
1539 getString(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
1544 GET_STRING_OR_DEFAULT("String", data
);
1547 data
= PLGetString(entry
->plvalue
);
1556 *(char**)addr
= wstrdup(data
);
1564 getPathList(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
1574 if (!PLIsArray(value
)) {
1575 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1576 entry
->key
, "an array of paths");
1578 value
= entry
->plvalue
;
1580 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1587 count
= PLGetNumberOfElements(value
);
1590 value
= entry
->plvalue
;
1592 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1599 for (i
=0; i
<count
; i
++) {
1600 d
= PLGetArrayElement(value
, i
);
1601 if (!d
|| !PLIsString(d
)) {
1605 len
+= strlen(PLGetString(d
))+1;
1608 ptr
= data
= wmalloc(len
+1);
1610 for (i
=0; i
<count
; i
++) {
1611 d
= PLGetArrayElement(value
, i
);
1612 if (!d
|| !PLIsString(d
)) {
1615 strcpy(ptr
, PLGetString(d
));
1616 ptr
+= strlen(PLGetString(d
));
1620 ptr
--; *(ptr
--) = 0;
1622 if (*(char**)addr
!=NULL
) {
1623 free(*(char**)addr
);
1625 *(char**)addr
= data
;
1632 getEnum(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
1635 static signed char data
;
1637 data
= string2index(entry
->plkey
, value
, entry
->default_value
,
1638 (WOptionEnumeration
*)entry
->extra_data
);
1646 *(signed char*)addr
= data
;
1655 * (hgradient <color> <color>)
1656 * (vgradient <color> <color>)
1657 * (dgradient <color> <color>)
1658 * (mhgradient <color> <color> ...)
1659 * (mvgradient <color> <color> ...)
1660 * (tpixmap <file> <color>)
1661 * (spixmap <file> <color>)
1662 * (cpixmap <file> <color>)
1663 * (thgradient <file> <opaqueness> <color> <color>)
1664 * (tvgradient <file> <opaqueness> <color> <color>)
1665 * (tdgradient <file> <opaqueness> <color> <color>)
1666 * (function <lib> <function> ...)
1670 parse_texture(WScreen
*scr
, proplist_t pl
)
1675 WTexture
*texture
=NULL
;
1677 nelem
= PLGetNumberOfElements(pl
);
1682 elem
= PLGetArrayElement(pl
, 0);
1683 if (!elem
|| !PLIsString(elem
))
1685 val
= PLGetString(elem
);
1688 if (strcasecmp(val
, "solid")==0) {
1696 elem
= PLGetArrayElement(pl
, 1);
1697 if (!elem
|| !PLIsString(elem
))
1699 val
= PLGetString(elem
);
1701 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &color
)) {
1702 wwarning(_("\"%s\" is not a valid color name"), val
);
1706 texture
= (WTexture
*)wTextureMakeSolid(scr
, &color
);
1707 } else if (strcasecmp(val
, "dgradient")==0
1708 || strcasecmp(val
, "vgradient")==0
1709 || strcasecmp(val
, "hgradient")==0) {
1710 RColor color1
, color2
;
1715 wwarning(_("bad number of arguments in gradient specification"));
1719 if (val
[0]=='d' || val
[0]=='D')
1720 type
= WTEX_DGRADIENT
;
1721 else if (val
[0]=='h' || val
[0]=='H')
1722 type
= WTEX_HGRADIENT
;
1724 type
= WTEX_VGRADIENT
;
1727 /* get from color */
1728 elem
= PLGetArrayElement(pl
, 1);
1729 if (!elem
|| !PLIsString(elem
))
1731 val
= PLGetString(elem
);
1733 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1734 wwarning(_("\"%s\" is not a valid color name"), val
);
1738 color1
.red
= xcolor
.red
>> 8;
1739 color1
.green
= xcolor
.green
>> 8;
1740 color1
.blue
= xcolor
.blue
>> 8;
1743 elem
= PLGetArrayElement(pl
, 2);
1744 if (!elem
|| !PLIsString(elem
)) {
1747 val
= PLGetString(elem
);
1749 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1750 wwarning(_("\"%s\" is not a valid color name"), val
);
1754 color2
.red
= xcolor
.red
>> 8;
1755 color2
.green
= xcolor
.green
>> 8;
1756 color2
.blue
= xcolor
.blue
>> 8;
1758 texture
= (WTexture
*)wTextureMakeGradient(scr
, type
, &color1
, &color2
);
1760 } else if (strcasecmp(val
, "mhgradient")==0
1761 || strcasecmp(val
, "mvgradient")==0
1762 || strcasecmp(val
, "mdgradient")==0) {
1769 wwarning(_("too few arguments in multicolor gradient specification"));
1773 if (val
[1]=='h' || val
[1]=='H')
1774 type
= WTEX_MHGRADIENT
;
1775 else if (val
[1]=='v' || val
[1]=='V')
1776 type
= WTEX_MVGRADIENT
;
1778 type
= WTEX_MDGRADIENT
;
1782 colors
= wmalloc(sizeof(RColor
*)*(count
+1));
1784 for (i
=0; i
<count
; i
++) {
1785 elem
= PLGetArrayElement(pl
, i
+1);
1786 if (!elem
|| !PLIsString(elem
)) {
1787 for (--i
; i
>=0; --i
) {
1793 val
= PLGetString(elem
);
1795 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &color
)) {
1796 wwarning(_("\"%s\" is not a valid color name"), val
);
1797 for (--i
; i
>=0; --i
) {
1803 colors
[i
] = wmalloc(sizeof(RColor
));
1804 colors
[i
]->red
= color
.red
>> 8;
1805 colors
[i
]->green
= color
.green
>> 8;
1806 colors
[i
]->blue
= color
.blue
>> 8;
1811 texture
= (WTexture
*)wTextureMakeMGradient(scr
, type
, colors
);
1812 } else if (strcasecmp(val
, "spixmap")==0 ||
1813 strcasecmp(val
, "cpixmap")==0 ||
1814 strcasecmp(val
, "tpixmap")==0) {
1821 if (val
[0] == 's' || val
[0] == 'S')
1823 else if (val
[0] == 'c' || val
[0] == 'C')
1829 elem
= PLGetArrayElement(pl
, 2);
1830 if (!elem
|| !PLIsString(elem
)) {
1833 val
= PLGetString(elem
);
1835 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &color
)) {
1836 wwarning(_("\"%s\" is not a valid color name"), val
);
1841 elem
= PLGetArrayElement(pl
, 1);
1842 if (!elem
|| !PLIsString(elem
))
1844 val
= PLGetString(elem
);
1846 texture
= (WTexture
*)wTextureMakePixmap(scr
, type
, val
, &color
);
1847 } else if (strcasecmp(val
, "thgradient")==0
1848 || strcasecmp(val
, "tvgradient")==0
1849 || strcasecmp(val
, "tdgradient")==0) {
1850 RColor color1
, color2
;
1855 if (val
[1]=='h' || val
[1]=='H')
1856 style
= WTEX_THGRADIENT
;
1857 else if (val
[1]=='v' || val
[1]=='V')
1858 style
= WTEX_TVGRADIENT
;
1860 style
= WTEX_TDGRADIENT
;
1863 wwarning(_("bad number of arguments in textured gradient specification"));
1867 /* get from color */
1868 elem
= PLGetArrayElement(pl
, 3);
1869 if (!elem
|| !PLIsString(elem
))
1871 val
= PLGetString(elem
);
1873 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1874 wwarning(_("\"%s\" is not a valid color name"), val
);
1878 color1
.red
= xcolor
.red
>> 8;
1879 color1
.green
= xcolor
.green
>> 8;
1880 color1
.blue
= xcolor
.blue
>> 8;
1883 elem
= PLGetArrayElement(pl
, 4);
1884 if (!elem
|| !PLIsString(elem
)) {
1887 val
= PLGetString(elem
);
1889 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1890 wwarning(_("\"%s\" is not a valid color name"), val
);
1894 color2
.red
= xcolor
.red
>> 8;
1895 color2
.green
= xcolor
.green
>> 8;
1896 color2
.blue
= xcolor
.blue
>> 8;
1899 elem
= PLGetArrayElement(pl
, 2);
1900 if (!elem
|| !PLIsString(elem
))
1903 val
= PLGetString(elem
);
1905 if (!val
|| (opacity
= atoi(val
)) < 0 || opacity
> 255) {
1906 wwarning(_("bad opacity value for tgradient texture \"%s\". Should be [0..255]"), val
);
1911 elem
= PLGetArrayElement(pl
, 1);
1912 if (!elem
|| !PLIsString(elem
))
1914 val
= PLGetString(elem
);
1916 texture
= (WTexture
*)wTextureMakeTGradient(scr
, style
, &color1
, &color2
,
1919 #ifdef TEXTURE_PLUGIN
1920 else if (strcasecmp(val
, "function")==0) {
1921 WTexFunction
*function
;
1922 void (*initFunc
) (Display
*, Colormap
);
1923 char *lib
, *func
, **argv
;
1929 /* get the library name */
1930 elem
= PLGetArrayElement(pl
, 1);
1931 if (!elem
|| !PLIsString(elem
)) {
1934 lib
= PLGetString(elem
);
1936 /* get the function name */
1937 elem
= PLGetArrayElement(pl
, 2);
1938 if (!elem
|| !PLIsString(elem
)) {
1941 func
= PLGetString(elem
);
1944 argv
= (char **)wmalloc(argc
* sizeof(char *));
1946 /* get the parameters */
1947 argv
[0] = wstrdup(func
);
1948 for (i
= 0; i
< argc
- 1; i
++) {
1949 elem
= PLGetArrayElement(pl
, 3 + i
);
1950 if (!elem
|| !PLIsString(elem
)) {
1955 argv
[i
+1] = wstrdup(PLGetString(elem
));
1958 function
= wTextureMakeFunction(scr
, lib
, func
, argc
, argv
);
1962 initFunc
= dlsym(function
->handle
, "initWindowMaker");
1964 initFunc(dpy
, scr
->w_colormap
);
1966 wwarning(_("could not initialize library %s"), lib
);
1969 wwarning(_("could not find function %s::%s"), lib
, func
);
1971 #endif /* HAVE_DLFCN_H */
1972 texture
= (WTexture
*)function
;
1974 #endif /* TEXTURE_PLUGIN */
1976 wwarning(_("invalid texture type %s"), val
);
1985 getTexture(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
1988 static WTexture
*texture
;
1992 if (!PLIsArray(value
)) {
1993 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1994 entry
->key
, "Texture");
1996 value
= entry
->plvalue
;
1998 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
2004 if (strcmp(entry
->key
, "WidgetColor")==0 && !changed
) {
2007 pl
= PLGetArrayElement(value
, 0);
2008 if (!pl
|| !PLIsString(pl
) || !PLGetString(pl
)
2009 || strcasecmp(PLGetString(pl
), "solid")!=0) {
2010 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
2011 entry
->key
, "Solid Texture");
2013 value
= entry
->plvalue
;
2015 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
2020 texture
= parse_texture(scr
, value
);
2023 wwarning(_("Error in texture specification for key \"%s\""),
2026 value
= entry
->plvalue
;
2028 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
2038 *(WTexture
**)addr
= texture
;
2045 #ifdef DRAWSTRING_PLUGIN
2047 getTextRenderer(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
,
2048 void *addr
, void **ret
)
2051 char *val
, *lib
, *func
, **argv
;
2054 if (strcmp(entry
->key
, "FTitleColor")==0) {
2055 wPluginDestroyFunction(scr
->drawstring_func
[changed
= W_STRING_FTITLE
]);
2056 scr
->drawstring_func
[W_STRING_FTITLE
] = NULL
;
2057 } else if (strcmp(entry
->key
, "UTitleColor")==0) {
2058 wPluginDestroyFunction(scr
->drawstring_func
[changed
= W_STRING_UTITLE
]);
2059 scr
->drawstring_func
[W_STRING_UTITLE
] = NULL
;
2060 } else if (strcmp(entry
->key
, "PTitleColor")==0) {
2061 wPluginDestroyFunction(scr
->drawstring_func
[changed
= W_STRING_PTITLE
]);
2062 scr
->drawstring_func
[W_STRING_PTITLE
] = NULL
;
2063 } else if (strcmp(entry
->key
, "MenuTitleColor")==0) {
2064 wPluginDestroyFunction(scr
->drawstring_func
[changed
= W_STRING_MTITLE
]);
2065 scr
->drawstring_func
[W_STRING_MTITLE
] = NULL
;
2066 } else if (strcmp(entry
->key
, "MenuPluginColor")==0) {
2067 wPluginDestroyFunction(scr
->drawstring_func
[changed
= W_STRING_MTEXT
]);
2068 scr
->drawstring_func
[W_STRING_MTEXT
] = NULL
;
2071 if (PLIsArray(value
)) {
2072 if ((argc
= PLGetNumberOfElements(value
)) < 4) return False
;
2074 argv
= (char **)wmalloc(argc
* sizeof(char *));
2076 elem
= PLGetArrayElement(value
,0);
2077 if (!elem
|| !PLIsString(elem
)) return False
;
2078 val
= PLGetString(elem
);
2079 if (strcasecmp(val
, "function")==0) {
2080 elem
= PLGetArrayElement(value
, 1); /* library name */
2081 if (!elem
|| !PLIsString(elem
)) return False
;
2082 lib
= PLGetString(elem
);
2083 elem
= PLGetArrayElement(value
, 2); /* function name */
2084 if (!elem
|| !PLIsString(elem
)) return False
;
2085 func
= PLGetString(elem
);
2086 scr
->drawstring_func
[changed
] = wPluginCreateFunction (W_FUNCTION_DRAWSTRING
,
2087 lib
, "initDrawString", func
, NULL
, value
,
2088 wPluginPackInitData(3, dpy
, scr
->w_colormap
,"-DATA-"));
2091 return getColor(scr
, entry
, PLGetArrayElement(value
,3), addr
, ret
);
2092 } else if (PLIsString(value
)) {
2093 return getColor(scr
, entry
, value
, addr
, ret
);
2098 #endif /* DRAWSTRING_PLUGIN */
2103 getWSBackground(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
,
2104 void *addr
, void **ret
)
2112 if (!PLIsArray(value
)) {
2113 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
2114 "WorkspaceBack", "Texture or None");
2116 value
= entry
->plvalue
;
2118 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
2124 /* only do basic error checking and verify for None texture */
2126 nelem
= PLGetNumberOfElements(value
);
2128 elem
= PLGetArrayElement(value
, 0);
2129 if (!elem
|| !PLIsString(elem
)) {
2130 wwarning(_("Wrong type for workspace background. Should be a texture type."));
2132 value
= entry
->plvalue
;
2134 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
2139 val
= PLGetString(elem
);
2141 if (strcasecmp(val
, "None")==0)
2144 *ret
= PLRetain(value
);
2151 getWSSpecificBackground(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
,
2152 void *addr
, void **ret
)
2159 if (!PLIsArray(value
)) {
2160 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
2161 "WorkspaceSpecificBack", "an array of textures");
2163 value
= entry
->plvalue
;
2165 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
2171 /* only do basic error checking and verify for None texture */
2173 nelem
= PLGetNumberOfElements(value
);
2176 elem
= PLGetArrayElement(value
, nelem
);
2177 if (!elem
|| !PLIsArray(elem
)) {
2178 wwarning(_("Wrong type for background of workspace %i. Should be a texture."),
2184 *ret
= PLRetain(value
);
2188 * Kluge to force wmsetbg helper to set the default background.
2189 * If the WorkspaceSpecificBack is changed once wmaker has started,
2190 * the WorkspaceBack won't be sent to the helper, unless the user
2191 * changes it's value too. So, we must force this by removing the
2192 * value from the defaults DB.
2194 if (!scr
->flags
.backimage_helper_launched
&& !scr
->flags
.startup
) {
2195 proplist_t key
= PLMakeString("WorkspaceBack");
2197 PLRemoveDictionaryEntry(WDWindowMaker
->dictionary
, key
);
2207 getFont(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
2210 static WMFont
*font
;
2213 GET_STRING_OR_DEFAULT("Font", val
);
2215 font
= WMCreateFont(scr
->wmscreen
, val
);
2217 font
= WMCreateFont(scr
->wmscreen
, "fixed");
2220 wfatal(_("could not load any usable font!!!"));
2227 /* can't assign font value outside update function */
2228 wassertrv(addr
== NULL
, True
);
2235 getColor(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
2238 static XColor color
;
2242 GET_STRING_OR_DEFAULT("Color", val
);
2246 if (!wGetColor(scr
, val
, &color
)) {
2247 wwarning(_("could not get color for key \"%s\""),
2249 if (second_pass
==0) {
2250 val
= PLGetString(entry
->plvalue
);
2252 wwarning(_("using default \"%s\" instead"), val
);
2264 *(unsigned long*)addr = pixel;
2273 getKeybind(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
2276 static WShortKey shortcut
;
2283 GET_STRING_OR_DEFAULT("Key spec", val
);
2285 if (!val
|| strcasecmp(val
, "NONE")==0) {
2286 shortcut
.keycode
= 0;
2287 shortcut
.modifier
= 0;
2298 shortcut
.modifier
= 0;
2299 while ((k
= strchr(b
, '+'))!=NULL
) {
2303 mod
= wXModifierFromKey(b
);
2305 wwarning(_("%s:invalid key modifier \"%s\""), entry
->key
, b
);
2308 shortcut
.modifier
|= mod
;
2314 ksym
= XStringToKeysym(b
);
2316 if (ksym
==NoSymbol
) {
2317 wwarning(_("%s:invalid kbd shortcut specification \"%s\""), entry
->key
,
2322 shortcut
.keycode
= XKeysymToKeycode(dpy
, ksym
);
2323 if (shortcut
.keycode
==0) {
2324 wwarning(_("%s:invalid key in shortcut \"%s\""), entry
->key
, val
);
2336 getModMask(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
2339 static unsigned int mask
;
2342 GET_STRING_OR_DEFAULT("Modifier Key", str
);
2347 mask
= wXModifierFromKey(str
);
2349 wwarning(_("%s: modifier key %s is not valid"), entry
->key
, str
);
2355 *(unsigned int*)addr
= mask
;
2366 getRImages(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
,
2367 void *addr
, void **ret
)
2375 GET_STRING_OR_DEFAULT("Image File Path", str
);
2379 image
= RLoadImage(scr
->rcontext
, str
, 0);
2381 wwarning(_("could not load image in option %s: %s"), entry
->key
,
2382 RMessageForError(RErrorCode
));
2386 if (*(RImage
**)addr
) {
2387 RDestroyImage(*(RImage
**)addr
);
2390 *(RImage
**)addr
= image
;
2392 assert(ret
== NULL
);
2395 *(RImage**)ret = image;
2403 /* ---------------- value setting functions --------------- */
2405 setJustify(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
2407 return REFRESH_WINDOW_TITLE_COLOR
;
2412 setIfDockPresent(WScreen
*scr
, WDefaultEntry
*entry
, int *flag
, long which
)
2416 wPreferences
.flags
.nodock
= wPreferences
.flags
.nodock
|| *flag
;
2419 wPreferences
.flags
.noclip
= wPreferences
.flags
.noclip
|| *flag
;
2429 setStickyIcons(WScreen
*scr
, WDefaultEntry
*entry
, void *bar
, void *foo
)
2431 if (scr
->workspaces
) {
2432 wWorkspaceForceChange(scr
, scr
->current_workspace
);
2433 wArrangeIcons(scr
, False
);
2440 setPositive(WScreen
*scr
, WDefaultEntry
*entry
, int *value
, void *foo
)
2452 setIconTile(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
2458 img
= wTextureRenderImage(*texture
, wPreferences
.icon_size
,
2459 wPreferences
.icon_size
,
2460 ((*texture
)->any
.type
& WREL_BORDER_MASK
)
2461 ? WREL_ICON
: WREL_FLAT
);
2463 wwarning(_("could not render texture for icon background"));
2465 wTextureDestroy(scr
, *texture
);
2468 RConvertImage(scr
->rcontext
, img
, &pixmap
);
2470 if (scr
->icon_tile
) {
2472 RDestroyImage(scr
->icon_tile
);
2473 XFreePixmap(dpy
, scr
->icon_tile_pixmap
);
2476 scr
->icon_tile
= img
;
2478 if (!wPreferences
.flags
.noclip
) {
2479 if (scr
->clip_tile
) {
2480 RDestroyImage(scr
->clip_tile
);
2482 scr
->clip_tile
= wClipMakeTile(scr
, img
);
2485 scr
->icon_tile_pixmap
= pixmap
;
2487 if (scr
->def_icon_pixmap
) {
2488 XFreePixmap(dpy
, scr
->def_icon_pixmap
);
2489 scr
->def_icon_pixmap
= None
;
2491 if (scr
->def_ticon_pixmap
) {
2492 XFreePixmap(dpy
, scr
->def_ticon_pixmap
);
2493 scr
->def_ticon_pixmap
= None
;
2496 if (scr
->icon_back_texture
) {
2497 wTextureDestroy(scr
, (WTexture
*)scr
->icon_back_texture
);
2499 scr
->icon_back_texture
= wTextureMakeSolid(scr
, &((*texture
)->any
.color
));
2501 if (scr
->clip_balloon
)
2502 XSetWindowBackground(dpy
, scr
->clip_balloon
,
2503 (*texture
)->any
.color
.pixel
);
2506 * Free the texture as nobody else will use it, nor refer to it.
2509 wTextureDestroy(scr
, *texture
);
2511 return (reset
? REFRESH_ICON_TILE
: 0);
2517 setWinTitleFont(WScreen
*scr
, WDefaultEntry
*entry
, WMFont
*font
, void *foo
)
2519 if (scr
->title_font
) {
2520 WMReleaseFont(scr
->title_font
);
2522 scr
->title_font
= font
;
2524 return REFRESH_WINDOW_FONT
|REFRESH_BUTTON_IMAGES
;
2529 setMenuTitleFont(WScreen
*scr
, WDefaultEntry
*entry
, WMFont
*font
, void *foo
)
2531 if (scr
->menu_title_font
) {
2532 WMReleaseFont(scr
->menu_title_font
);
2535 scr
->menu_title_font
= font
;
2537 return REFRESH_MENU_TITLE_FONT
;
2542 setMenuTextFont(WScreen
*scr
, WDefaultEntry
*entry
, WMFont
*font
, void *foo
)
2544 if (scr
->menu_entry_font
) {
2545 WMReleaseFont(scr
->menu_entry_font
);
2547 scr
->menu_entry_font
= font
;
2549 return REFRESH_MENU_FONT
;
2555 setIconTitleFont(WScreen
*scr
, WDefaultEntry
*entry
, WMFont
*font
, void *foo
)
2557 if (scr
->icon_title_font
) {
2558 WMReleaseFont(scr
->icon_title_font
);
2561 scr
->icon_title_font
= font
;
2563 return REFRESH_ICON_FONT
;
2568 setClipTitleFont(WScreen
*scr
, WDefaultEntry
*entry
, WMFont
*font
, void *foo
)
2570 if (scr
->clip_title_font
) {
2571 WMReleaseFont(scr
->clip_title_font
);
2574 scr
->clip_title_font
= font
;
2576 return REFRESH_ICON_FONT
;
2581 setDisplayFont(WScreen
*scr
, WDefaultEntry
*entry
, WMFont
*font
, void *foo
)
2583 if (scr
->info_text_font
) {
2584 WMReleaseFont(scr
->info_text_font
);
2587 scr
->info_text_font
= font
;
2589 /* This test works because the scr structure is initially zeroed out
2590 and None = 0. Any other time, the window should be valid. */
2591 if (scr
->geometry_display
!= None
) {
2592 wGetGeometryWindowSize(scr
, &scr
->geometry_display_width
,
2593 &scr
->geometry_display_height
);
2594 XResizeWindow(dpy
, scr
->geometry_display
,
2595 scr
->geometry_display_width
, scr
->geometry_display_height
);
2603 setLargeDisplayFont(WScreen
*scr
, WDefaultEntry
*entry
, WMFont
*font
, void *foo
)
2605 if (scr
->workspace_name_font
) {
2606 WMReleaseFont(scr
->workspace_name_font
);
2609 scr
->workspace_name_font
= font
;
2616 setHightlight(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, void *foo
)
2618 if (scr
->select_pixel
!=scr
->white_pixel
&&
2619 scr
->select_pixel
!=scr
->black_pixel
) {
2620 wFreeColor(scr
, scr
->select_pixel
);
2623 scr
->select_pixel
= color
->pixel
;
2625 return REFRESH_MENU_COLOR
;
2630 setHightlightText(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, void *foo
)
2632 if (scr
->select_text_pixel
!=scr
->white_pixel
&&
2633 scr
->select_text_pixel
!=scr
->black_pixel
) {
2634 wFreeColor(scr
, scr
->select_text_pixel
);
2637 scr
->select_text_pixel
= color
->pixel
;
2639 return REFRESH_MENU_COLOR
;
2644 setClipTitleColor(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, long index
)
2646 if (scr
->clip_title_pixel
[index
]!=scr
->white_pixel
&&
2647 scr
->clip_title_pixel
[index
]!=scr
->black_pixel
) {
2648 wFreeColor(scr
, scr
->clip_title_pixel
[index
]);
2650 scr
->clip_title_pixel
[index
] = color
->pixel
;
2652 #ifdef GRADIENT_CLIP_ARROW
2653 if (index
== CLIP_NORMAL
) {
2655 RColor color1
, color2
;
2656 int pt
= CLIP_BUTTON_SIZE
*wPreferences
.icon_size
/64;
2657 int as
= pt
- 15; /* 15 = 5+5+5 */
2659 FREE_PIXMAP(scr
->clip_arrow_gradient
);
2661 color1
.red
= (color
->red
>> 8)*6/10;
2662 color1
.green
= (color
->green
>> 8)*6/10;
2663 color1
.blue
= (color
->blue
>> 8)*6/10;
2665 color2
.red
= WMIN((color
->red
>> 8)*20/10, 255);
2666 color2
.green
= WMIN((color
->green
>> 8)*20/10, 255);
2667 color2
.blue
= WMIN((color
->blue
>> 8)*20/10, 255);
2669 image
= RRenderGradient(as
+1, as
+1, &color1
, &color2
, RDiagonalGradient
);
2670 RConvertImage(scr
->rcontext
, image
, &scr
->clip_arrow_gradient
);
2671 RDestroyImage(image
);
2673 #endif /* GRADIENT_CLIP_ARROW */
2675 return REFRESH_ICON_TITLE_COLOR
;
2680 setWTitleColor(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, long index
)
2682 if (scr
->window_title_pixel
[index
]!=scr
->white_pixel
&&
2683 scr
->window_title_pixel
[index
]!=scr
->black_pixel
) {
2684 wFreeColor(scr
, scr
->window_title_pixel
[index
]);
2687 scr
->window_title_pixel
[index
] = color
->pixel
;
2689 if (index
== WS_UNFOCUSED
)
2690 XSetForeground(dpy
, scr
->info_text_gc
, color
->pixel
);
2692 return REFRESH_WINDOW_TITLE_COLOR
;
2697 setMenuTitleColor(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, long index
)
2699 if (scr
->menu_title_pixel
[0]!=scr
->white_pixel
&&
2700 scr
->menu_title_pixel
[0]!=scr
->black_pixel
) {
2701 #ifdef DRAWSTRING_PLUGIN
2702 if(!scr
->drawstring_func
[W_STRING_MTITLE
])
2704 wFreeColor(scr
, scr
->menu_title_pixel
[0]);
2707 scr
->menu_title_pixel
[0] = color
->pixel
;
2708 XSetForeground(dpy
, scr
->menu_title_gc
, color
->pixel
);
2710 return REFRESH_MENU_TITLE_COLOR
;
2715 setMenuTextColor(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, void *foo
)
2718 #define gcm (GCForeground|GCBackground|GCFillStyle)
2720 if (scr
->mtext_pixel
!=scr
->white_pixel
&&
2721 scr
->mtext_pixel
!=scr
->black_pixel
) {
2722 wFreeColor(scr
, scr
->mtext_pixel
);
2725 scr
->mtext_pixel
= color
->pixel
;
2727 XSetForeground(dpy
, scr
->menu_entry_gc
, color
->pixel
);
2730 if (scr
->dtext_pixel
== scr
->mtext_pixel
) {
2731 gcv
.foreground
= scr
->white_pixel
;
2732 gcv
.background
= scr
->black_pixel
;
2733 gcv
.fill_style
= FillStippled
;
2735 gcv
.foreground
= scr
->dtext_pixel
;
2736 gcv
.fill_style
= FillSolid
;
2738 XChangeGC(dpy
, scr
->disabled_menu_entry_gc
, gcm
, &gcv
);
2740 return REFRESH_MENU_COLOR
;
2746 setMenuDisabledColor(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, void *foo
)
2749 #define gcm (GCForeground|GCBackground|GCFillStyle)
2751 if (scr
->dtext_pixel
!=scr
->white_pixel
&&
2752 scr
->dtext_pixel
!=scr
->black_pixel
) {
2753 wFreeColor(scr
, scr
->dtext_pixel
);
2756 scr
->dtext_pixel
= color
->pixel
;
2758 if (scr
->dtext_pixel
== scr
->mtext_pixel
) {
2759 gcv
.foreground
= scr
->white_pixel
;
2760 gcv
.background
= scr
->black_pixel
;
2761 gcv
.fill_style
= FillStippled
;
2763 gcv
.foreground
= scr
->dtext_pixel
;
2764 gcv
.fill_style
= FillSolid
;
2766 XChangeGC(dpy
, scr
->disabled_menu_entry_gc
, gcm
, &gcv
);
2768 return REFRESH_MENU_COLOR
;
2773 setIconTitleColor(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, void *foo
)
2775 XSetForeground(dpy
, scr
->icon_title_gc
, color
->pixel
);
2777 return REFRESH_ICON_TITLE_COLOR
;
2782 setIconTitleBack(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, void *foo
)
2784 if (scr
->icon_title_texture
) {
2785 wTextureDestroy(scr
, (WTexture
*)scr
->icon_title_texture
);
2787 XQueryColor (dpy
, scr
->w_colormap
, color
);
2788 scr
->icon_title_texture
= wTextureMakeSolid(scr
, color
);
2790 return REFRESH_ICON_TITLE_BACK
;
2795 trackDeadProcess(pid_t pid
, unsigned char status
, WScreen
*scr
)
2797 close(scr
->helper_fd
);
2799 scr
->helper_pid
= 0;
2800 scr
->flags
.backimage_helper_launched
= 0;
2805 setWorkspaceSpecificBack(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
,
2812 if (scr
->flags
.backimage_helper_launched
) {
2813 if (PLGetNumberOfElements(value
)==0) {
2814 SendHelperMessage(scr
, 'C', 0, NULL
);
2815 SendHelperMessage(scr
, 'K', 0, NULL
);
2824 if (PLGetNumberOfElements(value
) == 0)
2827 if (pipe(filedes
) < 0) {
2828 wsyserror("pipe() failed:can't set workspace specific background image");
2836 wsyserror("fork() failed:can't set workspace specific background image");
2837 if (close(filedes
[0]) < 0)
2838 wsyserror("could not close pipe");
2839 if (close(filedes
[1]) < 0)
2840 wsyserror("could not close pipe");
2842 } else if (pid
== 0) {
2843 SetupEnvironment(scr
);
2846 wsyserror("could not close pipe");
2847 if (dup(filedes
[0]) < 0) {
2848 wsyserror("dup() failed:can't set workspace specific background image");
2850 if (wPreferences
.smooth_workspace_back
)
2851 execlp("wmsetbg", "wmsetbg", "-helper", "-S", "-d", NULL
);
2853 execlp("wmsetbg", "wmsetbg", "-helper", "-d", NULL
);
2854 wsyserror("could not execute wmsetbg");
2858 if (fcntl(filedes
[0], F_SETFD
, FD_CLOEXEC
) < 0) {
2859 wsyserror("error setting close-on-exec flag");
2861 if (fcntl(filedes
[1], F_SETFD
, FD_CLOEXEC
) < 0) {
2862 wsyserror("error setting close-on-exec flag");
2865 scr
->helper_fd
= filedes
[1];
2866 scr
->helper_pid
= pid
;
2867 scr
->flags
.backimage_helper_launched
= 1;
2869 wAddDeathHandler(pid
, (WDeathHandler
*)trackDeadProcess
, scr
);
2871 SendHelperMessage(scr
, 'P', -1, wPreferences
.pixmap_path
);
2876 for (i
= 0; i
< PLGetNumberOfElements(value
); i
++) {
2877 val
= PLGetArrayElement(value
, i
);
2878 if (val
&& PLIsArray(val
) && PLGetNumberOfElements(val
)>0) {
2879 str
= PLGetDescription(val
);
2881 SendHelperMessage(scr
, 'S', i
+1, str
);
2885 SendHelperMessage(scr
, 'U', i
+1, NULL
);
2896 setWorkspaceBack(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
,
2899 if (scr
->flags
.backimage_helper_launched
) {
2902 if (PLGetNumberOfElements(value
)==0) {
2903 SendHelperMessage(scr
, 'U', 0, NULL
);
2905 /* set the default workspace background to this one */
2906 str
= PLGetDescription(value
);
2908 SendHelperMessage(scr
, 'S', 0, str
);
2910 SendHelperMessage(scr
, 'C', scr
->current_workspace
+1, NULL
);
2912 SendHelperMessage(scr
, 'U', 0, NULL
);
2919 SetupEnvironment(scr
);
2920 text
= PLGetDescription(value
);
2921 command
= wmalloc(strlen(text
)+40);
2922 if (wPreferences
.smooth_workspace_back
)
2923 sprintf(command
, "wmsetbg -d -S -p '%s' &", text
);
2925 sprintf(command
, "wmsetbg -d -p '%s' &", text
);
2937 setWidgetColor(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
2939 if (scr
->widget_texture
) {
2940 wTextureDestroy(scr
, (WTexture
*)scr
->widget_texture
);
2942 scr
->widget_texture
= *(WTexSolid
**)texture
;
2944 if (scr
->geometry_display
!= None
)
2945 XSetWindowBackground(dpy
, scr
->geometry_display
,
2946 scr
->widget_texture
->normal
.pixel
);
2953 setFTitleBack(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
2955 if (scr
->window_title_texture
[WS_FOCUSED
]) {
2956 wTextureDestroy(scr
, scr
->window_title_texture
[WS_FOCUSED
]);
2958 scr
->window_title_texture
[WS_FOCUSED
] = *texture
;
2960 return REFRESH_WINDOW_TEXTURES
;
2965 setPTitleBack(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
2967 if (scr
->window_title_texture
[WS_PFOCUSED
]) {
2968 wTextureDestroy(scr
, scr
->window_title_texture
[WS_PFOCUSED
]);
2970 scr
->window_title_texture
[WS_PFOCUSED
] = *texture
;
2972 return REFRESH_WINDOW_TEXTURES
;
2977 setUTitleBack(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
2979 if (scr
->window_title_texture
[WS_UNFOCUSED
]) {
2980 wTextureDestroy(scr
, scr
->window_title_texture
[WS_UNFOCUSED
]);
2982 scr
->window_title_texture
[WS_UNFOCUSED
] = *texture
;
2984 return REFRESH_WINDOW_TEXTURES
;
2989 setResizebarBack(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
2991 if (scr
->resizebar_texture
[0]) {
2992 wTextureDestroy(scr
, scr
->resizebar_texture
[0]);
2994 scr
->resizebar_texture
[0] = *texture
;
2996 return REFRESH_WINDOW_TEXTURES
;
3001 setMenuTitleBack(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
3003 if (scr
->menu_title_texture
[0]) {
3004 wTextureDestroy(scr
, scr
->menu_title_texture
[0]);
3006 scr
->menu_title_texture
[0] = *texture
;
3008 return REFRESH_MENU_TITLE_TEXTURE
;
3013 setMenuTextBack(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
3015 if (scr
->menu_item_texture
) {
3016 wTextureDestroy(scr
, scr
->menu_item_texture
);
3017 wTextureDestroy(scr
, (WTexture
*)scr
->menu_item_auxtexture
);
3019 scr
->menu_item_texture
= *texture
;
3021 scr
->menu_item_auxtexture
3022 = wTextureMakeSolid(scr
, &scr
->menu_item_texture
->any
.color
);
3024 return REFRESH_MENU_TEXTURE
;
3029 setKeyGrab(WScreen
*scr
, WDefaultEntry
*entry
, WShortKey
*shortcut
, long index
)
3032 wKeyBindings
[index
] = *shortcut
;
3034 wwin
= scr
->focused_window
;
3036 while (wwin
!=NULL
) {
3037 XUngrabKey(dpy
, AnyKey
, AnyModifier
, wwin
->frame
->core
->window
);
3039 if (!WFLAGP(wwin
, no_bind_keys
)) {
3040 wWindowSetKeyGrabs(wwin
);
3050 setIconPosition(WScreen
*scr
, WDefaultEntry
*entry
, void *bar
, void *foo
)
3052 wArrangeIcons(scr
, True
);
3059 updateUsableArea(WScreen
*scr
, WDefaultEntry
*entry
, void *bar
, void *foo
)
3061 wScreenUpdateUsableArea(scr
);
3068 setMenuStyle(WScreen
*scr
, WDefaultEntry
*entry
, int *value
, void *foo
)
3070 return REFRESH_MENU_TEXTURE
;
3076 setButtonImages(WScreen *scr, WDefaultEntry *entry, int *value, void *foo)
3078 return REFRESH_BUTTON_IMAGES;
3084 * Need access to the double click variables, so that all widgets in
3085 * wmaker panels will have the same dbl-click values.
3086 * TODO: figure a better way of dealing with it.
3091 setDoubleClick(WScreen
*scr
, WDefaultEntry
*entry
, int *value
, void *foo
)
3093 extern _WINGsConfiguration WINGsConfiguration
;
3098 WINGsConfiguration
.doubleClickDelay
= *value
;
3106 setMultiByte(WScreen
*scr
, WDefaultEntry
*entry
, int *value
, void *foo
)
3108 extern _WINGsConfiguration WINGsConfiguration
;
3110 WINGsConfiguration
.useMultiByte
= *value
;