1 /* defaults.c - manage configuration through defaults db
3 * Window Maker window manager
5 * Copyright (c) 1997, 1998 Alfredo K. Kojima
6 * Copyright (c) 1998 Dan Pascu
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
33 #include <sys/types.h>
46 #define PATH_MAX DEFAULT_PATH_MAX
50 #include <X11/Xutil.h>
51 #include <X11/keysym.h>
56 #include "WindowMaker.h"
62 #include "resources.h"
65 #include "xmodifier.h"
70 #include "workspace.h"
74 * Our own proplist reader parser. This one will not accept any
75 * syntax errors and is more descriptive in the error messages.
76 * It also doesn't seem to crash.
78 extern proplist_t
ReadProplistFromFile(char *file
);
83 extern WDDomain
*WDWindowMaker
;
84 extern WDDomain
*WDWindowAttributes
;
85 extern WDDomain
*WDRootMenu
;
87 extern int wScreenCount
;
90 extern proplist_t wDomainName;
91 extern proplist_t wAttributeDomainName;
93 extern WPreferences wPreferences
;
95 extern WShortKey wKeyBindings
[WKBD_LAST
];
105 proplist_t plvalue
; /* default value */
109 /* used to map strings to integers */
114 } WOptionEnumeration
;
117 /* type converters */
118 static int getBool();
120 static int getCoord();
122 /* this is not used yet */
123 static int getString();
125 static int getPathList();
126 static int getEnum();
127 static int getTexture();
128 #ifdef DRAWSTRING_PLUGIN
129 static int getTextRenderer();
131 static int getWSBackground();
132 static int getWSSpecificBackground();
133 static int getFont();
134 static int getColor();
135 static int getKeybind();
136 static int getModMask();
138 static int getRImage();
142 /* value setting functions */
143 static int setJustify();
144 static int setIfDockPresent();
145 static int setStickyIcons();
147 static int setPositive();
149 static int setWidgetColor();
150 static int setIconTile();
151 static int setWinTitleFont();
152 static int setMenuTitleFont();
153 static int setMenuTextFont();
154 static int setIconTitleFont();
155 static int setIconTitleColor();
156 static int setIconTitleBack();
157 static int setDisplayFont();
158 static int setLargeDisplayFont();
159 static int setWTitleColor();
160 static int setFTitleBack();
161 static int setPTitleBack();
162 static int setUTitleBack();
163 static int setResizebarBack();
164 static int setWorkspaceBack();
165 static int setWorkspaceSpecificBack();
166 static int setMenuTitleColor();
167 static int setMenuTextColor();
168 static int setMenuDisabledColor();
169 static int setMenuTitleBack();
170 static int setMenuTextBack();
171 static int setHightlight();
172 static int setHightlightText();
173 static int setKeyGrab();
174 static int setDoubleClick();
175 static int setIconPosition();
177 static int setClipTitleFont();
178 static int setClipTitleColor();
180 static int setMenuStyle();
181 static int setMultiByte();
183 static int updateUsableArea();
188 * Tables to convert strings to enumeration values.
189 * Values stored are char
193 /* WARNING: sum of length of all value strings must not exceed
195 #define TOTAL_VALUES_LENGTH 80
200 #define REFRESH_WINDOW_TEXTURES (1<<0)
201 #define REFRESH_MENU_TEXTURE (1<<1)
202 #define REFRESH_MENU_FONT (1<<2)
203 #define REFRESH_MENU_COLOR (1<<3)
204 #define REFRESH_MENU_TITLE_TEXTURE (1<<4)
205 #define REFRESH_MENU_TITLE_FONT (1<<5)
206 #define REFRESH_MENU_TITLE_COLOR (1<<6)
207 #define REFRESH_WINDOW_TITLE_COLOR (1<<7)
208 #define REFRESH_WINDOW_FONT (1<<8)
209 #define REFRESH_ICON_TILE (1<<9)
210 #define REFRESH_ICON_FONT (1<<10)
211 #define REFRESH_WORKSPACE_BACK (1<<11)
213 #define REFRESH_BUTTON_IMAGES (1<<12)
215 #define REFRESH_ICON_TITLE_COLOR (1<<13)
216 #define REFRESH_ICON_TITLE_BACK (1<<14)
220 static WOptionEnumeration seFocusModes
[] = {
221 {"Manual", WKF_CLICK
, 0}, {"ClickToFocus", WKF_CLICK
, 1},
222 {"Auto", WKF_POINTER
, 0}, {"FocusFollowMouse", WKF_POINTER
, 1},
223 {"Sloppy", WKF_SLOPPY
, 0}, {"SemiAuto", WKF_SLOPPY
, 1},
227 static WOptionEnumeration seColormapModes
[] = {
228 {"Manual", WKF_CLICK
, 0}, {"ClickToFocus", WKF_CLICK
, 1},
229 {"Auto", WKF_POINTER
, 0}, {"FocusFollowMouse", WKF_POINTER
, 1},
233 static WOptionEnumeration sePlacements
[] = {
234 {"Auto", WPM_AUTO
, 0}, {"Smart", WPM_SMART
, 0},
235 {"Cascade", WPM_CASCADE
, 0},
236 {"Random", WPM_RANDOM
, 0},
237 {"Manual", WPM_MANUAL
, 0},
241 static WOptionEnumeration seGeomDisplays
[] = {
242 {"Center", WDIS_CENTER
, 0},
243 {"Corner", WDIS_TOPLEFT
, 0},
244 {"Floating", WDIS_FRAME_CENTER
, 0},
245 {"Line", WDIS_NEW
, 0},
249 static WOptionEnumeration seSpeeds
[] = {
250 {"UltraFast", SPEED_ULTRAFAST
, 0},
251 {"Fast", SPEED_FAST
, 0},
252 {"Medium", SPEED_MEDIUM
, 0},
253 {"Slow", SPEED_SLOW
, 0},
254 {"UltraSlow", SPEED_ULTRASLOW
, 0},
258 static WOptionEnumeration seMouseButtons
[] = {
260 {"Left", Button1
, 0}, {"Button1", Button1
, 1},
261 {"Middle", Button2
, 0}, {"Button2", Button2
, 1},
262 {"Right", Button3
, 0}, {"Button3", Button3
, 1},
263 {"Button4", Button4
, 0},
264 {"Button5", Button5
, 0},
268 static WOptionEnumeration seIconificationStyles
[] = {
269 {"Zoom", WIS_ZOOM
, 0},
270 {"Twist", WIS_TWIST
, 0},
271 {"Flip", WIS_FLIP
, 0},
272 {"None", WIS_NONE
, 0},
273 {"random", WIS_RANDOM
, 0},
277 static WOptionEnumeration seJustifications
[] = {
278 {"Left", WTJ_LEFT
, 0},
279 {"Center", WTJ_CENTER
, 0},
280 {"Right", WTJ_RIGHT
, 0},
284 static WOptionEnumeration seIconPositions
[] = {
285 {"blv", IY_BOTTOM
|IY_LEFT
|IY_VERT
, 0},
286 {"blh", IY_BOTTOM
|IY_LEFT
|IY_HORIZ
, 0},
287 {"brv", IY_BOTTOM
|IY_RIGHT
|IY_VERT
, 0},
288 {"brh", IY_BOTTOM
|IY_RIGHT
|IY_HORIZ
, 0},
289 {"tlv", IY_TOP
|IY_LEFT
|IY_VERT
, 0},
290 {"tlh", IY_TOP
|IY_LEFT
|IY_HORIZ
, 0},
291 {"trv", IY_TOP
|IY_RIGHT
|IY_VERT
, 0},
292 {"trh", IY_TOP
|IY_RIGHT
|IY_HORIZ
, 0},
296 static WOptionEnumeration seMenuStyles
[] = {
297 {"normal", MS_NORMAL
, 0},
298 {"singletexture", MS_SINGLE_TEXTURE
, 0},
299 {"flat", MS_FLAT
, 0},
304 static WOptionEnumeration seDisplayPositions
[] = {
305 {"none", WD_NONE
, 0},
306 {"center", WD_CENTER
, 0},
308 {"bottom", WD_BOTTOM
, 0},
309 {"topleft", WD_TOPLEFT
, 0},
310 {"topright", WD_TOPRIGHT
, 0},
311 {"bottomleft", WD_BOTTOMLEFT
, 0},
312 {"bottomright", WD_BOTTOMRIGHT
, 0}
317 * ALL entries in the tables bellow, NEED to have a default value
318 * defined, and this value needs to be correct.
321 /* these options will only affect the window manager on startup
323 * static defaults can't access the screen data, because it is
324 * created after these defaults are read
326 WDefaultEntry staticOptionList
[] = {
328 {"DisableDithering", "NO", NULL
,
329 &wPreferences
.no_dithering
, getBool
, NULL
331 {"ColormapSize", "4", NULL
,
332 &wPreferences
.cmap_size
, getInt
, NULL
334 /* static by laziness */
335 {"IconSize", "64", NULL
,
336 &wPreferences
.icon_size
, getInt
, NULL
338 {"ModifierKey", "Mod1", NULL
,
339 &wPreferences
.modifier_mask
, getModMask
, NULL
341 {"DisableWSMouseActions", "NO", NULL
,
342 &wPreferences
.disable_root_mouse
, getBool
, NULL
344 {"FocusMode", "manual", seFocusModes
,
345 &wPreferences
.focus_mode
, getEnum
, NULL
346 }, /* have a problem when switching from manual to sloppy without restart */
347 {"NewStyle", "NO", NULL
,
348 &wPreferences
.new_style
, getBool
, NULL
350 {"DisableDock", "NO", (void*) WM_DOCK
,
351 NULL
, getBool
, setIfDockPresent
353 {"DisableClip", "NO", (void*) WM_CLIP
,
354 NULL
, getBool
, setIfDockPresent
356 {"DisableMiniwindows", "NO", NULL
,
357 &wPreferences
.disable_miniwindows
, getBool
, NULL
359 {"MultiByteText", "NO", NULL
,
360 &wPreferences
.multi_byte_text
, getBool
, setMultiByte
366 WDefaultEntry optionList
[] = {
367 /* dynamic options */
368 {"IconPosition", "blh", seIconPositions
,
369 &wPreferences
.icon_yard
, getEnum
, setIconPosition
371 {"IconificationStyle", "Zoom", seIconificationStyles
,
372 &wPreferences
.iconification_style
, getEnum
, NULL
374 {"SelectWindowsMouseButton", "Left", seMouseButtons
,
375 &wPreferences
.select_button
, getEnum
, NULL
377 {"WindowListMouseButton", "Middle", seMouseButtons
,
378 &wPreferences
.windowl_button
, getEnum
, NULL
380 {"ApplicationMenuMouseButton", "Right", seMouseButtons
,
381 &wPreferences
.menu_button
, getEnum
, NULL
383 {"PixmapPath", DEF_PIXMAP_PATHS
, NULL
,
384 &wPreferences
.pixmap_path
, getPathList
, NULL
386 {"IconPath", DEF_ICON_PATHS
, NULL
,
387 &wPreferences
.icon_path
, getPathList
, NULL
389 {"ColormapMode", "auto", seColormapModes
,
390 &wPreferences
.colormap_mode
, getEnum
, NULL
392 {"AutoFocus", "NO", NULL
,
393 &wPreferences
.auto_focus
, getBool
, NULL
395 {"RaiseDelay", "0", NULL
,
396 &wPreferences
.raise_delay
, getInt
, NULL
398 {"CirculateRaise", "NO", NULL
,
399 &wPreferences
.circ_raise
, getBool
, NULL
401 {"Superfluous", "NO", NULL
,
402 &wPreferences
.superfluous
, getBool
, NULL
404 {"AdvanceToNewWorkspace", "NO", NULL
,
405 &wPreferences
.ws_advance
, getBool
, NULL
407 {"CycleWorkspaces", "NO", NULL
,
408 &wPreferences
.ws_cycle
, getBool
, NULL
410 {"WorkspaceNameDisplayPosition", "center", seDisplayPositions
,
411 &wPreferences
.workspace_name_display_position
, getEnum
, NULL
413 #ifdef VIRTUAL_DESKTOP
414 {"VirtualEdgeThickness", "1", NULL
,
415 &wPreferences
.vedge_thickness
, getInt
, NULL
417 {"VirtualEdgeHorizonScrollSpeed", "1", NULL
,
418 &wPreferences
.vedge_hscrollspeed
, getInt
, NULL
420 {"VirtualEdgeVerticalScrollSpeed", "1", NULL
,
421 &wPreferences
.vedge_vscrollspeed
, getInt
, NULL
423 {"VirtualEdgeWidth", "2000", NULL
,
424 &wPreferences
.vedge_width
, getInt
, NULL
426 {"VirtualEdgeHeight", "2000", NULL
,
427 &wPreferences
.vedge_height
, getInt
, NULL
430 {"StickyIcons", "NO", NULL
,
431 &wPreferences
.sticky_icons
, getBool
, setStickyIcons
433 {"SaveSessionOnExit", "NO", NULL
,
434 &wPreferences
.save_session_on_exit
, getBool
, NULL
436 {"WrapMenus", "NO", NULL
,
437 &wPreferences
.wrap_menus
, getBool
, NULL
439 {"ScrollableMenus", "NO", NULL
,
440 &wPreferences
.scrollable_menus
, getBool
, NULL
442 {"MenuScrollSpeed", "medium", seSpeeds
,
443 &wPreferences
.menu_scroll_speed
, getEnum
, NULL
445 {"IconSlideSpeed", "medium", seSpeeds
,
446 &wPreferences
.icon_slide_speed
, getEnum
, NULL
448 {"ShadeSpeed", "medium", seSpeeds
,
449 &wPreferences
.shade_speed
, getEnum
, NULL
451 {"DoubleClickTime", "250", (void*) &wPreferences
.dblclick_time
,
452 &wPreferences
.dblclick_time
, getInt
, setDoubleClick
,
454 {"AlignSubmenus", "NO", NULL
,
455 &wPreferences
.align_menus
, getBool
, NULL
457 {"OpenTransientOnOwnerWorkspace", "NO", NULL
,
458 &wPreferences
.open_transients_with_parent
, getBool
, NULL
460 {"WindowPlacement", "auto", sePlacements
,
461 &wPreferences
.window_placement
, getEnum
, NULL
463 {"IgnoreFocusClick","NO", NULL
,
464 &wPreferences
.ignore_focus_click
, getBool
, NULL
466 {"UseSaveUnders", "NO", NULL
,
467 &wPreferences
.use_saveunders
, getBool
, NULL
469 {"OpaqueMove", "NO", NULL
,
470 &wPreferences
.opaque_move
, getBool
, NULL
472 {"DisableSound", "NO", NULL
,
473 &wPreferences
.no_sound
, getBool
, NULL
475 {"DisableAnimations", "NO", NULL
,
476 &wPreferences
.no_animations
, getBool
, NULL
478 {"DontLinkWorkspaces","NO", NULL
,
479 &wPreferences
.no_autowrap
, getBool
, NULL
481 {"AutoArrangeIcons", "NO", NULL
,
482 &wPreferences
.auto_arrange_icons
, getBool
, NULL
484 {"NoWindowOverDock", "NO", NULL
,
485 &wPreferences
.no_window_over_dock
, getBool
, updateUsableArea
487 {"NoWindowOverIcons", "NO", NULL
,
488 &wPreferences
.no_window_over_icons
, getBool
, updateUsableArea
490 {"WindowPlaceOrigin", "(0, 0)", NULL
,
491 &wPreferences
.window_place_origin
, getCoord
, NULL
493 {"ResizeDisplay", "corner", seGeomDisplays
,
494 &wPreferences
.size_display
, getEnum
, NULL
496 {"MoveDisplay", "corner", seGeomDisplays
,
497 &wPreferences
.move_display
, getEnum
, NULL
499 {"DontConfirmKill", "NO", NULL
,
500 &wPreferences
.dont_confirm_kill
, getBool
,NULL
502 {"WindowTitleBalloons", "NO", NULL
,
503 &wPreferences
.window_balloon
, getBool
, NULL
505 {"MiniwindowTitleBalloons", "NO", NULL
,
506 &wPreferences
.miniwin_balloon
,getBool
, NULL
508 {"AppIconBalloons", "NO", NULL
,
509 &wPreferences
.appicon_balloon
,getBool
, NULL
511 {"HelpBalloons", "NO", NULL
,
512 &wPreferences
.help_balloon
, getBool
, NULL
514 {"EdgeResistance", "30", NULL
,
515 &wPreferences
.edge_resistance
,getInt
, NULL
517 {"Attraction", "NO", NULL
,
518 &wPreferences
.attract
, getBool
, NULL
520 {"DisableBlinking", "NO", NULL
,
521 &wPreferences
.dont_blink
, getBool
, NULL
523 #ifdef WEENDOZE_CYCLE
524 {"WindozeCycling","NO", NULL
,
525 &wPreferences
.windoze_cycling
, getBool
, NULL
527 {"PopupSwitchMenu","YES", NULL
,
528 &wPreferences
.popup_switchmenu
, getBool
, NULL
530 #endif /* WEENDOZE_CYCLE */
532 {"MenuStyle", "normal", seMenuStyles
,
533 &wPreferences
.menu_style
, getEnum
, setMenuStyle
535 {"WidgetColor", "(solid, gray)", NULL
,
536 NULL
, getTexture
, setWidgetColor
,
538 {"WorkspaceSpecificBack","()", NULL
,
539 NULL
, getWSSpecificBackground
, setWorkspaceSpecificBack
541 /* WorkspaceBack must come after WorkspaceSpecificBack or
542 * WorkspaceBack wont know WorkspaceSpecificBack was also
543 * specified and 2 copies of wmsetbg will be launched */
544 {"WorkspaceBack", "(solid, black)", NULL
,
545 NULL
, getWSBackground
,setWorkspaceBack
547 {"SmoothWorkspaceBack", "NO", NULL
,
550 {"IconBack", "(solid, gray)", NULL
,
551 NULL
, getTexture
, setIconTile
553 {"TitleJustify", "center", seJustifications
,
554 &wPreferences
.title_justification
, getEnum
, setJustify
556 {"WindowTitleFont", DEF_TITLE_FONT
, NULL
,
557 NULL
, getFont
, setWinTitleFont
,
559 {"MenuTitleFont", DEF_MENU_TITLE_FONT
, NULL
,
560 NULL
, getFont
, setMenuTitleFont
562 {"MenuTextFont", DEF_MENU_ENTRY_FONT
, NULL
,
563 NULL
, getFont
, setMenuTextFont
565 {"IconTitleFont", DEF_ICON_TITLE_FONT
, NULL
,
566 NULL
, getFont
, setIconTitleFont
568 {"ClipTitleFont", DEF_CLIP_TITLE_FONT
, NULL
,
569 NULL
, getFont
, setClipTitleFont
571 {"DisplayFont", DEF_INFO_TEXT_FONT
, NULL
,
572 NULL
, getFont
, setDisplayFont
574 {"LargeDisplayFont",DEF_WORKSPACE_NAME_FONT
, NULL
,
575 NULL
, getFont
, setLargeDisplayFont
577 {"HighlightColor", "white", NULL
,
578 NULL
, getColor
, setHightlight
580 {"HighlightTextColor", "black", NULL
,
581 NULL
, getColor
, setHightlightText
583 {"ClipTitleColor", "black", (void*)CLIP_NORMAL
,
584 NULL
, getColor
, setClipTitleColor
586 {"CClipTitleColor", "\"#454045\"", (void*)CLIP_COLLAPSED
,
587 NULL
, getColor
, setClipTitleColor
589 #ifdef DRAWSTRING_PLUGIN
590 {"FTitleColor", "white", (void*)WS_FOCUSED
,
591 NULL
, getTextRenderer
, setWTitleColor
593 {"PTitleColor", "white", (void*)WS_PFOCUSED
,
594 NULL
, getTextRenderer
, setWTitleColor
596 {"UTitleColor", "black", (void*)WS_UNFOCUSED
,
597 NULL
, getTextRenderer
, setWTitleColor
600 {"FTitleColor", "white", (void*)WS_FOCUSED
,
601 NULL
, getColor
, setWTitleColor
603 {"PTitleColor", "white", (void*)WS_PFOCUSED
,
604 NULL
, getColor
, setWTitleColor
606 {"UTitleColor", "black", (void*)WS_UNFOCUSED
,
607 NULL
, getColor
, setWTitleColor
610 {"FTitleBack", "(solid, black)", NULL
,
611 NULL
, getTexture
, setFTitleBack
613 {"PTitleBack", "(solid, \"#616161\")", NULL
,
614 NULL
, getTexture
, setPTitleBack
616 {"UTitleBack", "(solid, gray)", NULL
,
617 NULL
, getTexture
, setUTitleBack
619 {"ResizebarBack", "(solid, gray)", NULL
,
620 NULL
, getTexture
, setResizebarBack
622 #ifdef DRAWSTRING_PLUGIN
623 {"MenuTitleColor", "white", NULL
,
624 NULL
, getTextRenderer
, setMenuTitleColor
627 {"MenuTitleColor", "white", NULL
,
628 NULL
, getColor
, setMenuTitleColor
631 {"MenuTextColor", "black", NULL
,
632 NULL
, getColor
, setMenuTextColor
634 {"MenuDisabledColor", "\"#616161\"", NULL
,
635 NULL
, getColor
, setMenuDisabledColor
637 {"MenuTitleBack", "(solid, black)", NULL
,
638 NULL
, getTexture
, setMenuTitleBack
640 {"MenuTextBack", "(solid, gray)", NULL
,
641 NULL
, getTexture
, setMenuTextBack
643 {"IconTitleColor", "white", NULL
,
644 NULL
, getColor
, setIconTitleColor
646 {"IconTitleBack", "black", NULL
,
647 NULL
, getColor
, setIconTitleBack
651 {"RootMenuKey", "None", (void*)WKBD_ROOTMENU
,
652 NULL
, getKeybind
, setKeyGrab
654 {"WindowListKey", "None", (void*)WKBD_WINDOWLIST
,
655 NULL
, getKeybind
, setKeyGrab
658 {"WindowMenuKey", "None", (void*)WKBD_WINDOWMENU
,
659 NULL
, getKeybind
, setKeyGrab
661 {"ClipLowerKey", "None", (void*)WKBD_CLIPLOWER
,
662 NULL
, getKeybind
, setKeyGrab
664 {"ClipRaiseKey", "None", (void*)WKBD_CLIPRAISE
,
665 NULL
, getKeybind
, setKeyGrab
667 {"ClipRaiseLowerKey", "None", (void*)WKBD_CLIPRAISELOWER
,
668 NULL
, getKeybind
, setKeyGrab
670 {"MiniaturizeKey", "None", (void*)WKBD_MINIATURIZE
,
671 NULL
, getKeybind
, setKeyGrab
673 {"HideKey", "None", (void*)WKBD_HIDE
,
674 NULL
, getKeybind
, setKeyGrab
676 {"MoveResizeKey", "None", (void*)WKBD_MOVERESIZE
,
677 NULL
, getKeybind
, setKeyGrab
679 {"CloseKey", "None", (void*)WKBD_CLOSE
,
680 NULL
, getKeybind
, setKeyGrab
682 {"MaximizeKey", "None", (void*)WKBD_MAXIMIZE
,
683 NULL
, getKeybind
, setKeyGrab
685 {"VMaximizeKey", "None", (void*)WKBD_VMAXIMIZE
,
686 NULL
, getKeybind
, setKeyGrab
688 {"RaiseKey", "\"Meta+Up\"", (void*)WKBD_RAISE
,
689 NULL
, getKeybind
, setKeyGrab
691 {"LowerKey", "\"Meta+Down\"", (void*)WKBD_LOWER
,
692 NULL
, getKeybind
, setKeyGrab
694 {"RaiseLowerKey", "None", (void*)WKBD_RAISELOWER
,
695 NULL
, getKeybind
, setKeyGrab
697 {"ShadeKey", "None", (void*)WKBD_SHADE
,
698 NULL
, getKeybind
, setKeyGrab
700 {"SelectKey", "None", (void*)WKBD_SELECT
,
701 NULL
, getKeybind
, setKeyGrab
703 {"FocusNextKey", "None", (void*)WKBD_FOCUSNEXT
,
704 NULL
, getKeybind
, setKeyGrab
706 {"FocusPrevKey", "None", (void*)WKBD_FOCUSPREV
,
707 NULL
, getKeybind
, setKeyGrab
709 {"NextWorkspaceKey", "None", (void*)WKBD_NEXTWORKSPACE
,
710 NULL
, getKeybind
, setKeyGrab
712 {"PrevWorkspaceKey", "None", (void*)WKBD_PREVWORKSPACE
,
713 NULL
, getKeybind
, setKeyGrab
715 {"NextWorkspaceLayerKey", "None", (void*)WKBD_NEXTWSLAYER
,
716 NULL
, getKeybind
, setKeyGrab
718 {"PrevWorkspaceLayerKey", "None", (void*)WKBD_PREVWSLAYER
,
719 NULL
, getKeybind
, setKeyGrab
721 {"Workspace1Key", "None", (void*)WKBD_WORKSPACE1
,
722 NULL
, getKeybind
, setKeyGrab
724 {"Workspace2Key", "None", (void*)WKBD_WORKSPACE2
,
725 NULL
, getKeybind
, setKeyGrab
727 {"Workspace3Key", "None", (void*)WKBD_WORKSPACE3
,
728 NULL
, getKeybind
, setKeyGrab
730 {"Workspace4Key", "None", (void*)WKBD_WORKSPACE4
,
731 NULL
, getKeybind
, setKeyGrab
733 {"Workspace5Key", "None", (void*)WKBD_WORKSPACE5
,
734 NULL
, getKeybind
, setKeyGrab
736 {"Workspace6Key", "None", (void*)WKBD_WORKSPACE6
,
737 NULL
, getKeybind
, setKeyGrab
739 {"Workspace7Key", "None", (void*)WKBD_WORKSPACE7
,
740 NULL
, getKeybind
, setKeyGrab
742 {"Workspace8Key", "None", (void*)WKBD_WORKSPACE8
,
743 NULL
, getKeybind
, setKeyGrab
745 {"Workspace9Key", "None", (void*)WKBD_WORKSPACE9
,
746 NULL
, getKeybind
, setKeyGrab
748 {"Workspace10Key", "None", (void*)WKBD_WORKSPACE10
,
749 NULL
, getKeybind
, setKeyGrab
751 {"WindowShortcut1Key","None", (void*)WKBD_WINDOW1
,
752 NULL
, getKeybind
, setKeyGrab
754 {"WindowShortcut2Key","None", (void*)WKBD_WINDOW2
,
755 NULL
, getKeybind
, setKeyGrab
757 {"WindowShortcut3Key","None", (void*)WKBD_WINDOW3
,
758 NULL
, getKeybind
, setKeyGrab
760 {"WindowShortcut4Key","None", (void*)WKBD_WINDOW4
,
761 NULL
, getKeybind
, setKeyGrab
763 #ifdef EXTEND_WINDOWSHORTCUT
764 ,{"WindowShortcut5Key","None", (void*)WKBD_WINDOW5
,
765 NULL
, getKeybind
, setKeyGrab
767 {"WindowShortcut6Key","None", (void*)WKBD_WINDOW6
,
768 NULL
, getKeybind
, setKeyGrab
770 {"WindowShortcut7Key","None", (void*)WKBD_WINDOW7
,
771 NULL
, getKeybind
, setKeyGrab
773 {"WindowShortcut8Key","None", (void*)WKBD_WINDOW8
,
774 NULL
, getKeybind
, setKeyGrab
776 {"WindowShortcut9Key","None", (void*)WKBD_WINDOW9
,
777 NULL
, getKeybind
, setKeyGrab
779 {"WindowShortcut10Key","None", (void*)WKBD_WINDOW10
,
780 NULL
, getKeybind
, setKeyGrab
782 #endif /* EXTEND_WINDOWSHORTCUT */
784 #ifdef KEEP_XKB_LOCK_STATUS
785 ,{"ToggleKbdModeKey", "None", (void*)WKBD_TOGGLE
,
786 NULL
, getKeybind
, setKeyGrab
788 {"KbdModeLock", "NO", NULL
,
789 &wPreferences
.modelock
, getBool
, NULL
791 #endif /* KEEP_XKB_LOCK_STATUS */
796 static void rereadDefaults(void);
803 /* must defer the update because accessing X data from a
804 * signal handler can mess up Xlib */
813 WDefaultEntry
*entry
;
815 PLSetStringCmpHook(StringCompareHook
);
817 for (i
=0; i
<sizeof(optionList
)/sizeof(WDefaultEntry
); i
++) {
818 entry
= &optionList
[i
];
820 entry
->plkey
= PLMakeString(entry
->key
);
821 if (entry
->default_value
)
822 entry
->plvalue
= PLGetProplistWithDescription(entry
->default_value
);
824 entry
->plvalue
= NULL
;
827 for (i
=0; i
<sizeof(staticOptionList
)/sizeof(WDefaultEntry
); i
++) {
828 entry
= &staticOptionList
[i
];
830 entry
->plkey
= PLMakeString(entry
->key
);
831 if (entry
->default_value
)
832 entry
->plvalue
= PLGetProplistWithDescription(entry
->default_value
);
834 entry
->plvalue
= NULL
;
838 wDomainName = PLMakeString(WMDOMAIN_NAME);
839 wAttributeDomainName = PLMakeString(WMATTRIBUTE_DOMAIN_NAME);
841 PLRegister(wDomainName, rereadDefaults);
842 PLRegister(wAttributeDomainName, rereadDefaults);
851 wDefaultsInit(int screen_number
)
853 static int defaults_inited
= 0;
856 if (!defaults_inited
) {
860 dict
= PLGetDomain(wDomainName
);
862 wwarning(_("could not read domain \"%s\" from defaults database"),
863 PLGetString(wDomainName
));
872 wDefaultsDestroyDomain(WDDomain
*domain
)
874 if (domain
->dictionary
)
875 PLRelease(domain
->dictionary
);
882 wDefaultsInitDomain(char *domain
, Bool requireDictionary
)
886 static int inited
= 0;
889 proplist_t shared_dict
=NULL
;
896 db
= wmalloc(sizeof(WDDomain
));
897 memset(db
, 0, sizeof(WDDomain
));
898 db
->domain_name
= domain
;
899 db
->path
= wdefaultspathfordomain(domain
);
902 if (the_path
&& stat(the_path
, &stbuf
)>=0) {
903 db
->dictionary
= ReadProplistFromFile(the_path
);
904 if (db
->dictionary
) {
905 if (requireDictionary
&& !PLIsDictionary(db
->dictionary
)) {
906 PLRelease(db
->dictionary
);
907 db
->dictionary
= NULL
;
908 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
911 db
->timestamp
= stbuf
.st_mtime
;
913 wwarning(_("could not load domain %s from user defaults database"),
918 /* global system dictionary */
919 sprintf(path
, "%s/WindowMaker/%s", SYSCONFDIR
, domain
);
920 if (stat(path
, &stbuf
)>=0) {
921 shared_dict
= ReadProplistFromFile(path
);
923 if (requireDictionary
&& !PLIsDictionary(shared_dict
)) {
924 wwarning(_("Domain %s (%s) of global defaults database is corrupted!"),
926 PLRelease(shared_dict
);
929 if (db
->dictionary
&& PLIsDictionary(shared_dict
) &&
930 PLIsDictionary(db
->dictionary
)) {
931 PLMergeDictionaries(shared_dict
, db
->dictionary
);
932 PLRelease(db
->dictionary
);
933 db
->dictionary
= shared_dict
;
934 if (stbuf
.st_mtime
> db
->timestamp
)
935 db
->timestamp
= stbuf
.st_mtime
;
936 } else if (!db
->dictionary
) {
937 db
->dictionary
= shared_dict
;
938 if (stbuf
.st_mtime
> db
->timestamp
)
939 db
->timestamp
= stbuf
.st_mtime
;
943 wwarning(_("could not load domain %s from global defaults database (%s)"),
948 /* set to save it in user's directory, no matter from where it was read */
949 if (db
->dictionary
) {
950 proplist_t tmp
= PLMakeString(db
->path
);
952 PLSetFilename(db
->dictionary
, tmp
);
961 wReadStaticDefaults(proplist_t dict
)
964 WDefaultEntry
*entry
;
969 for (i
=0; i
<sizeof(staticOptionList
)/sizeof(WDefaultEntry
); i
++) {
970 entry
= &staticOptionList
[i
];
973 plvalue
= PLGetDictionaryEntry(dict
, entry
->plkey
);
978 /* no default in the DB. Use builtin default */
979 plvalue
= entry
->plvalue
;
984 (*entry
->convert
)(NULL
, entry
, plvalue
, entry
->addr
, &tdata
);
986 (*entry
->update
)(NULL
, entry
, tdata
, entry
->extra_data
);
994 wDefaultsCheckDomains(void *foo
)
1000 char path
[PATH_MAX
];
1003 puts("Checking domains...");
1005 if (stat(WDWindowMaker
->path
, &stbuf
)>=0
1006 && WDWindowMaker
->timestamp
< stbuf
.st_mtime
) {
1007 proplist_t shared_dict
= NULL
;
1009 puts("Checking WindowMaker domain");
1011 WDWindowMaker
->timestamp
= stbuf
.st_mtime
;
1013 /* global dictionary */
1014 sprintf(path
, "%s/WindowMaker/WindowMaker", SYSCONFDIR
);
1015 if (stat(path
, &stbuf
)>=0) {
1016 shared_dict
= ReadProplistFromFile(path
);
1017 if (shared_dict
&& !PLIsDictionary(shared_dict
)) {
1018 wwarning(_("Domain %s (%s) of global defaults database is corrupted!"),
1019 "WindowMaker", path
);
1020 PLRelease(shared_dict
);
1022 } else if (!shared_dict
) {
1023 wwarning(_("could not load domain %s from global defaults database"),
1027 /* user dictionary */
1028 dict
= ReadProplistFromFile(WDWindowMaker
->path
);
1030 if (!PLIsDictionary(dict
)) {
1033 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
1034 "WindowMaker", WDWindowMaker
->path
);
1037 PLSetFilename(shared_dict
, PLGetFilename(dict
));
1038 PLMergeDictionaries(shared_dict
, dict
);
1043 for (i
=0; i
<wScreenCount
; i
++) {
1044 scr
= wScreenWithNumber(i
);
1046 wReadDefaults(scr
, dict
);
1048 if (WDWindowMaker
->dictionary
) {
1049 PLRelease(WDWindowMaker
->dictionary
);
1051 WDWindowMaker
->dictionary
= dict
;
1054 wwarning(_("could not load domain %s from user defaults database"),
1058 PLRelease(shared_dict
);
1062 if (stat(WDWindowAttributes
->path
, &stbuf
)>=0
1063 && WDWindowAttributes
->timestamp
< stbuf
.st_mtime
) {
1065 puts("Checking WMWindowAttributes domain");
1067 dict
= ReadProplistFromFile(WDWindowAttributes
->path
);
1069 if (!PLIsDictionary(dict
)) {
1072 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
1073 "WMWindowAttributes", WDWindowAttributes
->path
);
1075 if (WDWindowAttributes
->dictionary
)
1076 PLRelease(WDWindowAttributes
->dictionary
);
1077 WDWindowAttributes
->dictionary
= dict
;
1078 for (i
=0; i
<wScreenCount
; i
++) {
1079 scr
= wScreenWithNumber(i
);
1081 wDefaultUpdateIcons(scr
);
1085 wwarning(_("could not load domain %s from user defaults database"),
1086 "WMWindowAttributes");
1088 WDWindowAttributes
->timestamp
= stbuf
.st_mtime
;
1092 if (stat(WDRootMenu
->path
, &stbuf
)>=0
1093 && WDRootMenu
->timestamp
< stbuf
.st_mtime
) {
1094 dict
= ReadProplistFromFile(WDRootMenu
->path
);
1096 puts("Checking WMRootMenu domain");
1099 if (!PLIsArray(dict
) && !PLIsString(dict
)) {
1102 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
1103 "WMRootMenu", WDRootMenu
->path
);
1105 if (WDRootMenu
->dictionary
) {
1106 PLRelease(WDRootMenu
->dictionary
);
1108 WDRootMenu
->dictionary
= dict
;
1111 wwarning(_("could not load domain %s from user defaults database"),
1114 WDRootMenu
->timestamp
= stbuf
.st_mtime
;
1119 WMAddTimerHandler(DEFAULTS_CHECK_INTERVAL
, wDefaultsCheckDomains
, foo
);
1124 wReadDefaults(WScreen
*scr
, proplist_t new_dict
)
1126 proplist_t plvalue
, old_value
;
1127 WDefaultEntry
*entry
;
1129 int update_workspace_back
= 0; /* kluge :/ */
1132 proplist_t old_dict
= (WDWindowMaker
->dictionary
!=new_dict
1133 ? WDWindowMaker
->dictionary
: NULL
);
1139 for (i
=0; i
<sizeof(optionList
)/sizeof(WDefaultEntry
); i
++) {
1140 entry
= &optionList
[i
];
1143 plvalue
= PLGetDictionaryEntry(new_dict
, entry
->plkey
);
1150 old_value
= PLGetDictionaryEntry(old_dict
, entry
->plkey
);
1153 if (!plvalue
&& !old_value
) {
1154 /* no default in the DB. Use builtin default */
1155 plvalue
= entry
->plvalue
;
1156 if (plvalue
&& new_dict
) {
1157 PLInsertDictionaryEntry(new_dict
, entry
->plkey
, plvalue
);
1160 } else if (!plvalue
) {
1161 /* value was deleted from DB. Keep current value */
1163 } else if (!old_value
) {
1164 /* set value for the 1st time */
1165 } else if (!PLIsEqual(plvalue
, old_value
)) {
1166 /* value has changed */
1169 if (strcmp(entry
->key
, "WorkspaceBack") == 0
1170 && update_workspace_back
1171 && scr
->flags
.backimage_helper_launched
) {
1173 /* value was not changed since last time */
1180 printf("Updating %s to %s\n", entry
->key
,
1181 PLGetDescription(plvalue
));
1184 if ((*entry
->convert
)(scr
, entry
, plvalue
, entry
->addr
, &tdata
)) {
1186 * If the WorkspaceSpecificBack data has been changed
1187 * so that the helper will be launched now, we must be
1188 * sure to send the default background texture config
1191 if (strcmp(entry
->key
, "WorkspaceSpecificBack") == 0
1192 && !scr
->flags
.backimage_helper_launched
) {
1193 update_workspace_back
= 1;
1195 if (entry
->update
) {
1197 (*entry
->update
)(scr
, entry
, tdata
, entry
->extra_data
);
1203 if (needs_refresh
!=0 && !scr
->flags
.startup
) {
1207 if (needs_refresh
& REFRESH_MENU_TITLE_TEXTURE
)
1208 foo
|= WTextureSettings
;
1209 if (needs_refresh
& REFRESH_MENU_TITLE_FONT
)
1210 foo
|= WFontSettings
;
1211 if (needs_refresh
& REFRESH_MENU_TITLE_COLOR
)
1212 foo
|= WColorSettings
;
1214 WMPostNotificationName(WNMenuTitleAppearanceSettingsChanged
, NULL
,
1218 if (needs_refresh
& REFRESH_MENU_TEXTURE
)
1219 foo
|= WTextureSettings
;
1220 if (needs_refresh
& REFRESH_MENU_FONT
)
1221 foo
|= WFontSettings
;
1222 if (needs_refresh
& REFRESH_MENU_COLOR
)
1223 foo
|= WColorSettings
;
1225 WMPostNotificationName(WNMenuAppearanceSettingsChanged
, NULL
,
1229 if (needs_refresh
& REFRESH_WINDOW_FONT
) {
1230 foo
|= WFontSettings
;
1232 if (needs_refresh
& REFRESH_WINDOW_TEXTURES
) {
1233 foo
|= WTextureSettings
;
1235 if (needs_refresh
& REFRESH_WINDOW_TITLE_COLOR
) {
1236 foo
|= WColorSettings
;
1239 WMPostNotificationName(WNWindowAppearanceSettingsChanged
, NULL
,
1242 if (!(needs_refresh
& REFRESH_ICON_TILE
)) {
1244 if (needs_refresh
& REFRESH_ICON_FONT
) {
1245 foo
|= WFontSettings
;
1247 if (needs_refresh
& REFRESH_ICON_TITLE_COLOR
) {
1248 foo
|= WTextureSettings
;
1250 if (needs_refresh
& REFRESH_ICON_TITLE_BACK
) {
1251 foo
|= WTextureSettings
;
1254 WMPostNotificationName(WNIconAppearanceSettingsChanged
, NULL
,
1257 if (needs_refresh
& REFRESH_ICON_TILE
)
1258 WMPostNotificationName(WNIconTileSettingsChanged
, NULL
, NULL
);
1264 wDefaultUpdateIcons(WScreen
*scr
)
1266 WAppIcon
*aicon
= scr
->app_icon_list
;
1267 WWindow
*wwin
= scr
->focused_window
;
1271 file
= wDefaultGetIconFile(scr
, aicon
->wm_instance
, aicon
->wm_class
,
1273 if ((file
&& aicon
->icon
->file
&& strcmp(file
, aicon
->icon
->file
)!=0)
1274 || (file
&& !aicon
->icon
->file
)) {
1277 if (aicon
->icon
->file
)
1278 free(aicon
->icon
->file
);
1279 aicon
->icon
->file
= wstrdup(file
);
1281 new_image
= wDefaultGetImage(scr
, aicon
->wm_instance
,
1284 wIconChangeImage(aicon
->icon
, new_image
);
1285 wAppIconPaint(aicon
);
1288 aicon
= aicon
->next
;
1291 if (!wPreferences
.flags
.noclip
)
1292 wClipIconPaint(scr
->clip_icon
);
1295 if (wwin
->icon
&& wwin
->flags
.miniaturized
) {
1296 file
= wDefaultGetIconFile(scr
, wwin
->wm_instance
, wwin
->wm_class
,
1298 if ((file
&& wwin
->icon
->file
&& strcmp(file
, wwin
->icon
->file
)!=0)
1299 || (file
&& !wwin
->icon
->file
)) {
1302 if (wwin
->icon
->file
)
1303 free(wwin
->icon
->file
);
1304 wwin
->icon
->file
= wstrdup(file
);
1306 new_image
= wDefaultGetImage(scr
, wwin
->wm_instance
,
1309 wIconChangeImage(wwin
->icon
, new_image
);
1317 /* --------------------------- Local ----------------------- */
1319 #define STRINGP(x) if (!PLIsString(value)) { \
1320 wwarning(_("Wrong option format for key \"%s\". Should be %s."), \
1327 string2index(proplist_t key
, proplist_t val
, proplist_t def
,
1328 WOptionEnumeration
*values
)
1331 WOptionEnumeration
*v
;
1332 char buffer
[TOTAL_VALUES_LENGTH
];
1334 if (PLIsString(val
) && (str
= PLGetString(val
))) {
1335 for (v
=values
; v
->string
!=NULL
; v
++) {
1336 if (strcasecmp(v
->string
, str
)==0)
1342 for (v
=values
; v
->string
!=NULL
; v
++) {
1345 strcat(buffer
, ", ");
1346 strcat(buffer
, v
->string
);
1349 wwarning(_("wrong option value for key \"%s\". Should be one of %s"),
1350 PLGetString(key
), buffer
);
1353 return string2index(key
, val
, NULL
, values
);
1363 * value - is the value in the defaults DB
1364 * addr - is the address to store the data
1365 * ret - is the address to store a pointer to a temporary buffer. ret
1366 * must not be freed and is used by the set functions
1369 getBool(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
1378 val
= PLGetString(value
);
1381 if ((val
[1]=='\0' && (val
[0]=='y' || val
[0]=='Y'))
1382 || strcasecmp(val
, "YES")==0) {
1385 } else if ((val
[1]=='\0' && (val
[0]=='n' || val
[0]=='N'))
1386 || strcasecmp(val
, "NO")==0) {
1390 if (sscanf(val
, "%i", &i
)==1) {
1396 wwarning(_("can't convert \"%s\" to boolean for key \"%s\""),
1398 if (second_pass
==0) {
1399 val
= PLGetString(entry
->plvalue
);
1401 wwarning(_("using default \"%s\" instead"), val
);
1412 *(char*)addr
= data
;
1420 getInt(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
1429 val
= PLGetString(value
);
1431 if (sscanf(val
, "%i", &data
)!=1) {
1432 wwarning(_("can't convert \"%s\" to integer for key \"%s\""),
1434 val
= PLGetString(entry
->plvalue
);
1435 wwarning(_("using default \"%s\" instead"), val
);
1436 if (sscanf(val
, "%i", &data
)!=1) {
1452 getCoord(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
1456 char *val_x
, *val_y
;
1457 int nelem
, changed
=0;
1458 proplist_t elem_x
, elem_y
;
1461 if (!PLIsArray(value
)) {
1462 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1463 entry
->key
, "Coordinate");
1465 value
= entry
->plvalue
;
1467 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1473 nelem
= PLGetNumberOfElements(value
);
1475 wwarning(_("Incorrect number of elements in array for key \"%s\"."),
1478 value
= entry
->plvalue
;
1480 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1486 elem_x
= PLGetArrayElement(value
, 0);
1487 elem_y
= PLGetArrayElement(value
, 1);
1489 if (!elem_x
|| !elem_y
|| !PLIsString(elem_x
) || !PLIsString(elem_y
)) {
1490 wwarning(_("Wrong value for key \"%s\". Should be Coordinate."),
1493 value
= entry
->plvalue
;
1495 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1501 val_x
= PLGetString(elem_x
);
1502 val_y
= PLGetString(elem_y
);
1504 if (sscanf(val_x
, "%i", &data
.x
)!=1 || sscanf(val_y
, "%i", &data
.y
)!=1) {
1505 wwarning(_("can't convert array to integers for \"%s\"."), entry
->key
);
1507 value
= entry
->plvalue
;
1509 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1517 else if (data
.x
> scr
->scr_width
/3)
1518 data
.x
= scr
->scr_width
/3;
1521 else if (data
.y
> scr
->scr_height
/3)
1522 data
.y
= scr
->scr_height
/3;
1528 *(WCoord
*)addr
= data
;
1536 /* This function is not used at the moment. */
1538 getString(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
1545 data
= PLGetString(value
);
1548 data
= PLGetString(entry
->plvalue
);
1557 *(char**)addr
= wstrdup(data
);
1565 getPathList(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
1575 if (!PLIsArray(value
)) {
1576 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1577 entry
->key
, "an array of paths");
1579 value
= entry
->plvalue
;
1581 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1588 count
= PLGetNumberOfElements(value
);
1591 value
= entry
->plvalue
;
1593 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1600 for (i
=0; i
<count
; i
++) {
1601 d
= PLGetArrayElement(value
, i
);
1602 if (!d
|| !PLIsString(d
)) {
1606 len
+= strlen(PLGetString(d
))+1;
1609 ptr
= data
= wmalloc(len
+1);
1611 for (i
=0; i
<count
; i
++) {
1612 d
= PLGetArrayElement(value
, i
);
1613 if (!d
|| !PLIsString(d
)) {
1616 strcpy(ptr
, PLGetString(d
));
1617 ptr
+= strlen(PLGetString(d
));
1621 ptr
--; *(ptr
--) = 0;
1623 if (*(char**)addr
!=NULL
) {
1624 free(*(char**)addr
);
1626 *(char**)addr
= data
;
1633 getEnum(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
1636 static signed char data
;
1638 data
= string2index(entry
->plkey
, value
, entry
->default_value
,
1639 (WOptionEnumeration
*)entry
->extra_data
);
1647 *(signed char*)addr
= data
;
1656 * (hgradient <color> <color>)
1657 * (vgradient <color> <color>)
1658 * (dgradient <color> <color>)
1659 * (mhgradient <color> <color> ...)
1660 * (mvgradient <color> <color> ...)
1661 * (tpixmap <file> <color>)
1662 * (spixmap <file> <color>)
1663 * (cpixmap <file> <color>)
1664 * (thgradient <file> <opaqueness> <color> <color>)
1665 * (tvgradient <file> <opaqueness> <color> <color>)
1666 * (tdgradient <file> <opaqueness> <color> <color>)
1667 * (function <lib> <function> ...)
1671 parse_texture(WScreen
*scr
, proplist_t pl
)
1676 WTexture
*texture
=NULL
;
1678 nelem
= PLGetNumberOfElements(pl
);
1683 elem
= PLGetArrayElement(pl
, 0);
1684 if (!elem
|| !PLIsString(elem
))
1686 val
= PLGetString(elem
);
1689 if (strcasecmp(val
, "solid")==0) {
1697 elem
= PLGetArrayElement(pl
, 1);
1698 if (!elem
|| !PLIsString(elem
))
1700 val
= PLGetString(elem
);
1702 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &color
)) {
1703 wwarning(_("\"%s\" is not a valid color name"), val
);
1707 texture
= (WTexture
*)wTextureMakeSolid(scr
, &color
);
1708 } else if (strcasecmp(val
, "dgradient")==0
1709 || strcasecmp(val
, "vgradient")==0
1710 || strcasecmp(val
, "hgradient")==0) {
1711 RColor color1
, color2
;
1716 wwarning(_("bad number of arguments in gradient specification"));
1720 if (val
[0]=='d' || val
[0]=='D')
1721 type
= WTEX_DGRADIENT
;
1722 else if (val
[0]=='h' || val
[0]=='H')
1723 type
= WTEX_HGRADIENT
;
1725 type
= WTEX_VGRADIENT
;
1728 /* get from color */
1729 elem
= PLGetArrayElement(pl
, 1);
1730 if (!elem
|| !PLIsString(elem
))
1732 val
= PLGetString(elem
);
1734 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1735 wwarning(_("\"%s\" is not a valid color name"), val
);
1739 color1
.red
= xcolor
.red
>> 8;
1740 color1
.green
= xcolor
.green
>> 8;
1741 color1
.blue
= xcolor
.blue
>> 8;
1744 elem
= PLGetArrayElement(pl
, 2);
1745 if (!elem
|| !PLIsString(elem
)) {
1748 val
= PLGetString(elem
);
1750 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1751 wwarning(_("\"%s\" is not a valid color name"), val
);
1755 color2
.red
= xcolor
.red
>> 8;
1756 color2
.green
= xcolor
.green
>> 8;
1757 color2
.blue
= xcolor
.blue
>> 8;
1759 texture
= (WTexture
*)wTextureMakeGradient(scr
, type
, &color1
, &color2
);
1761 } else if (strcasecmp(val
, "mhgradient")==0
1762 || strcasecmp(val
, "mvgradient")==0
1763 || strcasecmp(val
, "mdgradient")==0) {
1770 wwarning(_("too few arguments in multicolor gradient specification"));
1774 if (val
[1]=='h' || val
[1]=='H')
1775 type
= WTEX_MHGRADIENT
;
1776 else if (val
[1]=='v' || val
[1]=='V')
1777 type
= WTEX_MVGRADIENT
;
1779 type
= WTEX_MDGRADIENT
;
1783 colors
= wmalloc(sizeof(RColor
*)*(count
+1));
1785 for (i
=0; i
<count
; i
++) {
1786 elem
= PLGetArrayElement(pl
, i
+1);
1787 if (!elem
|| !PLIsString(elem
)) {
1788 for (--i
; i
>=0; --i
) {
1794 val
= PLGetString(elem
);
1796 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &color
)) {
1797 wwarning(_("\"%s\" is not a valid color name"), val
);
1798 for (--i
; i
>=0; --i
) {
1804 colors
[i
] = wmalloc(sizeof(RColor
));
1805 colors
[i
]->red
= color
.red
>> 8;
1806 colors
[i
]->green
= color
.green
>> 8;
1807 colors
[i
]->blue
= color
.blue
>> 8;
1812 texture
= (WTexture
*)wTextureMakeMGradient(scr
, type
, colors
);
1813 } else if (strcasecmp(val
, "spixmap")==0 ||
1814 strcasecmp(val
, "cpixmap")==0 ||
1815 strcasecmp(val
, "tpixmap")==0) {
1822 if (val
[0] == 's' || val
[0] == 'S')
1824 else if (val
[0] == 'c' || val
[0] == 'C')
1830 elem
= PLGetArrayElement(pl
, 2);
1831 if (!elem
|| !PLIsString(elem
)) {
1834 val
= PLGetString(elem
);
1836 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &color
)) {
1837 wwarning(_("\"%s\" is not a valid color name"), val
);
1842 elem
= PLGetArrayElement(pl
, 1);
1843 if (!elem
|| !PLIsString(elem
))
1845 val
= PLGetString(elem
);
1847 texture
= (WTexture
*)wTextureMakePixmap(scr
, type
, val
, &color
);
1848 } else if (strcasecmp(val
, "thgradient")==0
1849 || strcasecmp(val
, "tvgradient")==0
1850 || strcasecmp(val
, "tdgradient")==0) {
1851 RColor color1
, color2
;
1856 if (val
[1]=='h' || val
[1]=='H')
1857 style
= WTEX_THGRADIENT
;
1858 else if (val
[1]=='v' || val
[1]=='V')
1859 style
= WTEX_TVGRADIENT
;
1861 style
= WTEX_TDGRADIENT
;
1864 wwarning(_("bad number of arguments in textured gradient specification"));
1868 /* get from color */
1869 elem
= PLGetArrayElement(pl
, 3);
1870 if (!elem
|| !PLIsString(elem
))
1872 val
= PLGetString(elem
);
1874 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1875 wwarning(_("\"%s\" is not a valid color name"), val
);
1879 color1
.red
= xcolor
.red
>> 8;
1880 color1
.green
= xcolor
.green
>> 8;
1881 color1
.blue
= xcolor
.blue
>> 8;
1884 elem
= PLGetArrayElement(pl
, 4);
1885 if (!elem
|| !PLIsString(elem
)) {
1888 val
= PLGetString(elem
);
1890 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1891 wwarning(_("\"%s\" is not a valid color name"), val
);
1895 color2
.red
= xcolor
.red
>> 8;
1896 color2
.green
= xcolor
.green
>> 8;
1897 color2
.blue
= xcolor
.blue
>> 8;
1900 elem
= PLGetArrayElement(pl
, 2);
1901 if (!elem
|| !PLIsString(elem
))
1904 val
= PLGetString(elem
);
1906 if (!val
|| (opacity
= atoi(val
)) < 0 || opacity
> 255) {
1907 wwarning(_("bad opacity value for tgradient texture \"%s\". Should be [0..255]"), val
);
1912 elem
= PLGetArrayElement(pl
, 1);
1913 if (!elem
|| !PLIsString(elem
))
1915 val
= PLGetString(elem
);
1917 texture
= (WTexture
*)wTextureMakeTGradient(scr
, style
, &color1
, &color2
,
1920 #ifdef TEXTURE_PLUGIN
1921 else if (strcasecmp(val
, "function")==0) {
1922 WTexFunction
*function
;
1923 void (*initFunc
) (Display
*, Colormap
);
1924 char *lib
, *func
, **argv
;
1930 /* get the library name */
1931 elem
= PLGetArrayElement(pl
, 1);
1932 if (!elem
|| !PLIsString(elem
)) {
1935 lib
= PLGetString(elem
);
1937 /* get the function name */
1938 elem
= PLGetArrayElement(pl
, 2);
1939 if (!elem
|| !PLIsString(elem
)) {
1942 func
= PLGetString(elem
);
1945 argv
= (char **)wmalloc(argc
* sizeof(char *));
1947 /* get the parameters */
1948 argv
[0] = wstrdup(func
);
1949 for (i
= 0; i
< argc
- 1; i
++) {
1950 elem
= PLGetArrayElement(pl
, 3 + i
);
1951 if (!elem
|| !PLIsString(elem
)) {
1956 argv
[i
+1] = wstrdup(PLGetString(elem
));
1959 function
= wTextureMakeFunction(scr
, lib
, func
, argc
, argv
);
1963 initFunc
= dlsym(function
->handle
, "initWindowMaker");
1965 initFunc(dpy
, scr
->w_colormap
);
1967 wwarning(_("could not initialize library %s"), lib
);
1970 wwarning(_("could not find function %s::%s"), lib
, func
);
1972 #endif /* HAVE_DLFCN_H */
1973 texture
= (WTexture
*)function
;
1975 #endif /* TEXTURE_PLUGIN */
1977 wwarning(_("invalid texture type %s"), val
);
1986 getTexture(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
1989 static WTexture
*texture
;
1993 if (!PLIsArray(value
)) {
1994 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1995 entry
->key
, "Texture");
1997 value
= entry
->plvalue
;
1999 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
2005 if (strcmp(entry
->key
, "WidgetColor")==0 && !changed
) {
2008 pl
= PLGetArrayElement(value
, 0);
2009 if (!pl
|| !PLIsString(pl
) || !PLGetString(pl
)
2010 || strcasecmp(PLGetString(pl
), "solid")!=0) {
2011 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
2012 entry
->key
, "Solid Texture");
2014 value
= entry
->plvalue
;
2016 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
2021 texture
= parse_texture(scr
, value
);
2024 wwarning(_("Error in texture specification for key \"%s\""),
2027 value
= entry
->plvalue
;
2029 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
2039 *(WTexture
**)addr
= texture
;
2046 #ifdef DRAWSTRING_PLUGIN
2048 getTextRenderer(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
,
2049 void *addr
, void **ret
)
2052 char *val
, *lib
, *func
, **argv
;
2055 if (strcmp(entry
->key
, "FTitleColor")==0) {
2056 wPluginDestroyFunction(scr
->drawstring_func
[changed
= W_STRING_FTITLE
]);
2057 scr
->drawstring_func
[W_STRING_FTITLE
] = NULL
;
2058 } else if (strcmp(entry
->key
, "UTitleColor")==0) {
2059 wPluginDestroyFunction(scr
->drawstring_func
[changed
= W_STRING_UTITLE
]);
2060 scr
->drawstring_func
[W_STRING_UTITLE
] = NULL
;
2061 } else if (strcmp(entry
->key
, "PTitleColor")==0) {
2062 wPluginDestroyFunction(scr
->drawstring_func
[changed
= W_STRING_PTITLE
]);
2063 scr
->drawstring_func
[W_STRING_PTITLE
] = NULL
;
2064 } else if (strcmp(entry
->key
, "MenuTitleColor")==0) {
2065 wPluginDestroyFunction(scr
->drawstring_func
[changed
= W_STRING_MTITLE
]);
2066 scr
->drawstring_func
[W_STRING_MTITLE
] = NULL
;
2067 } else if (strcmp(entry
->key
, "MenuPluginColor")==0) {
2068 wPluginDestroyFunction(scr
->drawstring_func
[changed
= W_STRING_MTEXT
]);
2069 scr
->drawstring_func
[W_STRING_MTEXT
] = NULL
;
2072 if (PLIsArray(value
)) {
2073 if ((argc
= PLGetNumberOfElements(value
)) < 4) return False
;
2075 argv
= (char **)wmalloc(argc
* sizeof(char *));
2077 elem
= PLGetArrayElement(value
,0);
2078 if (!elem
|| !PLIsString(elem
)) return False
;
2079 val
= PLGetString(elem
);
2080 if (strcasecmp(val
, "function")==0) {
2081 elem
= PLGetArrayElement(value
, 1); /* library name */
2082 if (!elem
|| !PLIsString(elem
)) return False
;
2083 lib
= PLGetString(elem
);
2084 elem
= PLGetArrayElement(value
, 2); /* function name */
2085 if (!elem
|| !PLIsString(elem
)) return False
;
2086 func
= PLGetString(elem
);
2087 scr
->drawstring_func
[changed
] = wPluginCreateFunction (W_FUNCTION_DRAWSTRING
,
2088 lib
, "initDrawString", func
, NULL
, value
,
2089 wPluginPackInitData(3, dpy
, scr
->w_colormap
,"-DATA-"));
2092 return getColor(scr
, entry
, PLGetArrayElement(value
,3), addr
, ret
);
2093 } else if (PLIsString(value
)) {
2094 return getColor(scr
, entry
, value
, addr
, ret
);
2099 #endif /* DRAWSTRING_PLUGIN */
2104 getWSBackground(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
,
2105 void *addr
, void **ret
)
2113 if (!PLIsArray(value
)) {
2114 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
2115 "WorkspaceBack", "Texture or None");
2117 value
= entry
->plvalue
;
2119 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
2125 /* only do basic error checking and verify for None texture */
2127 nelem
= PLGetNumberOfElements(value
);
2129 elem
= PLGetArrayElement(value
, 0);
2130 if (!elem
|| !PLIsString(elem
)) {
2131 wwarning(_("Wrong type for workspace background. Should be a texture type."));
2133 value
= entry
->plvalue
;
2135 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
2140 val
= PLGetString(elem
);
2142 if (strcasecmp(val
, "None")==0)
2145 *ret
= PLRetain(value
);
2152 getWSSpecificBackground(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
,
2153 void *addr
, void **ret
)
2160 if (!PLIsArray(value
)) {
2161 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
2162 "WorkspaceSpecificBack", "an array of textures");
2164 value
= entry
->plvalue
;
2166 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
2172 /* only do basic error checking and verify for None texture */
2174 nelem
= PLGetNumberOfElements(value
);
2177 elem
= PLGetArrayElement(value
, nelem
);
2178 if (!elem
|| !PLIsArray(elem
)) {
2179 wwarning(_("Wrong type for background of workspace %i. Should be a texture."),
2185 *ret
= PLRetain(value
);
2189 * Kluge to force wmsetbg helper to set the default background.
2190 * If the WorkspaceSpecificBack is changed once wmaker has started,
2191 * the WorkspaceBack won't be sent to the helper, unless the user
2192 * changes it's value too. So, we must force this by removing the
2193 * value from the defaults DB.
2195 if (!scr
->flags
.backimage_helper_launched
&& !scr
->flags
.startup
) {
2196 proplist_t key
= PLMakeString("WorkspaceBack");
2198 PLRemoveDictionaryEntry(WDWindowMaker
->dictionary
, key
);
2208 getFont(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
2211 static WMFont
*font
;
2216 val
= PLGetString(value
);
2218 font
= WMCreateFont(scr
->wmscreen
, val
);
2220 font
= WMCreateFont(scr
->wmscreen
, "fixed");
2223 wfatal(_("could not load any usable font!!!"));
2230 /* can't assign font value outside update function */
2231 wassertrv(addr
== NULL
, True
);
2238 getColor(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
2241 static XColor color
;
2247 val
= PLGetString(value
);
2250 if (!wGetColor(scr
, val
, &color
)) {
2251 wwarning(_("could not get color for key \"%s\""),
2253 if (second_pass
==0) {
2254 val
= PLGetString(entry
->plvalue
);
2256 wwarning(_("using default \"%s\" instead"), val
);
2268 *(unsigned long*)addr = pixel;
2277 getKeybind(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
2280 static WShortKey shortcut
;
2287 STRINGP("Key spec");
2289 val
= PLGetString(value
);
2291 if (!val
|| strcasecmp(val
, "NONE")==0) {
2292 shortcut
.keycode
= 0;
2293 shortcut
.modifier
= 0;
2304 shortcut
.modifier
= 0;
2305 while ((k
= strchr(b
, '+'))!=NULL
) {
2309 mod
= wXModifierFromKey(b
);
2311 wwarning(_("%s:invalid key modifier \"%s\""), entry
->key
, b
);
2314 shortcut
.modifier
|= mod
;
2320 ksym
= XStringToKeysym(b
);
2322 if (ksym
==NoSymbol
) {
2323 wwarning(_("%s:invalid kbd shortcut specification \"%s\""), entry
->key
,
2328 shortcut
.keycode
= XKeysymToKeycode(dpy
, ksym
);
2329 if (shortcut
.keycode
==0) {
2330 wwarning(_("%s:invalid key in shortcut \"%s\""), entry
->key
, val
);
2342 getModMask(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
2345 static unsigned int mask
;
2348 STRINGP("Modifier Key");
2350 str
= PLGetString(value
);
2354 mask
= wXModifierFromKey(str
);
2356 wwarning(_("%s: modifier key %s is not valid"), entry
->key
, str
);
2362 *(unsigned int*)addr
= mask
;
2373 getRImages(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
,
2374 void *addr
, void **ret
)
2382 STRINGP("Image File Path");
2384 str
= PLGetString(value
);
2388 image
= RLoadImage(scr
->rcontext
, str
, 0);
2390 wwarning(_("could not load image in option %s: %s"), entry
->key
,
2391 RMessageForError(RErrorCode
));
2395 if (*(RImage
**)addr
) {
2396 RDestroyImage(*(RImage
**)addr
);
2399 *(RImage
**)addr
= image
;
2401 assert(ret
== NULL
);
2404 *(RImage**)ret = image;
2412 /* ---------------- value setting functions --------------- */
2414 setJustify(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
2416 return REFRESH_WINDOW_TITLE_COLOR
;
2421 setIfDockPresent(WScreen
*scr
, WDefaultEntry
*entry
, int *flag
, long which
)
2425 wPreferences
.flags
.nodock
= wPreferences
.flags
.nodock
|| *flag
;
2428 wPreferences
.flags
.noclip
= wPreferences
.flags
.noclip
|| *flag
;
2438 setStickyIcons(WScreen
*scr
, WDefaultEntry
*entry
, void *bar
, void *foo
)
2440 if (scr
->workspaces
) {
2441 wWorkspaceForceChange(scr
, scr
->current_workspace
);
2442 wArrangeIcons(scr
, False
);
2449 setPositive(WScreen
*scr
, WDefaultEntry
*entry
, int *value
, void *foo
)
2461 setIconTile(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
2467 img
= wTextureRenderImage(*texture
, wPreferences
.icon_size
,
2468 wPreferences
.icon_size
,
2469 ((*texture
)->any
.type
& WREL_BORDER_MASK
)
2470 ? WREL_ICON
: WREL_FLAT
);
2472 wwarning(_("could not render texture for icon background"));
2474 wTextureDestroy(scr
, *texture
);
2477 RConvertImage(scr
->rcontext
, img
, &pixmap
);
2479 if (scr
->icon_tile
) {
2481 RDestroyImage(scr
->icon_tile
);
2482 XFreePixmap(dpy
, scr
->icon_tile_pixmap
);
2485 scr
->icon_tile
= img
;
2487 if (!wPreferences
.flags
.noclip
) {
2488 if (scr
->clip_tile
) {
2489 RDestroyImage(scr
->clip_tile
);
2491 scr
->clip_tile
= wClipMakeTile(scr
, img
);
2494 scr
->icon_tile_pixmap
= pixmap
;
2496 if (scr
->def_icon_pixmap
) {
2497 XFreePixmap(dpy
, scr
->def_icon_pixmap
);
2498 scr
->def_icon_pixmap
= None
;
2500 if (scr
->def_ticon_pixmap
) {
2501 XFreePixmap(dpy
, scr
->def_ticon_pixmap
);
2502 scr
->def_ticon_pixmap
= None
;
2505 if (scr
->icon_back_texture
) {
2506 wTextureDestroy(scr
, (WTexture
*)scr
->icon_back_texture
);
2508 scr
->icon_back_texture
= wTextureMakeSolid(scr
, &((*texture
)->any
.color
));
2510 if (scr
->clip_balloon
)
2511 XSetWindowBackground(dpy
, scr
->clip_balloon
,
2512 (*texture
)->any
.color
.pixel
);
2515 * Free the texture as nobody else will use it, nor refer to it.
2518 wTextureDestroy(scr
, *texture
);
2520 return (reset
? REFRESH_ICON_TILE
: 0);
2526 setWinTitleFont(WScreen
*scr
, WDefaultEntry
*entry
, WMFont
*font
, void *foo
)
2528 if (scr
->title_font
) {
2529 WMReleaseFont(scr
->title_font
);
2531 scr
->title_font
= font
;
2533 return REFRESH_WINDOW_FONT
|REFRESH_BUTTON_IMAGES
;
2538 setMenuTitleFont(WScreen
*scr
, WDefaultEntry
*entry
, WMFont
*font
, void *foo
)
2540 if (scr
->menu_title_font
) {
2541 WMReleaseFont(scr
->menu_title_font
);
2544 scr
->menu_title_font
= font
;
2546 return REFRESH_MENU_TITLE_FONT
;
2551 setMenuTextFont(WScreen
*scr
, WDefaultEntry
*entry
, WMFont
*font
, void *foo
)
2553 if (scr
->menu_entry_font
) {
2554 WMReleaseFont(scr
->menu_entry_font
);
2556 scr
->menu_entry_font
= font
;
2558 return REFRESH_MENU_FONT
;
2564 setIconTitleFont(WScreen
*scr
, WDefaultEntry
*entry
, WMFont
*font
, void *foo
)
2566 if (scr
->icon_title_font
) {
2567 WMReleaseFont(scr
->icon_title_font
);
2570 scr
->icon_title_font
= font
;
2572 return REFRESH_ICON_FONT
;
2577 setClipTitleFont(WScreen
*scr
, WDefaultEntry
*entry
, WMFont
*font
, void *foo
)
2579 if (scr
->clip_title_font
) {
2580 WMReleaseFont(scr
->clip_title_font
);
2583 scr
->clip_title_font
= font
;
2585 return REFRESH_ICON_FONT
;
2590 setDisplayFont(WScreen
*scr
, WDefaultEntry
*entry
, WMFont
*font
, void *foo
)
2592 if (scr
->info_text_font
) {
2593 WMReleaseFont(scr
->info_text_font
);
2596 scr
->info_text_font
= font
;
2598 /* This test works because the scr structure is initially zeroed out
2599 and None = 0. Any other time, the window should be valid. */
2600 if (scr
->geometry_display
!= None
) {
2601 wGetGeometryWindowSize(scr
, &scr
->geometry_display_width
,
2602 &scr
->geometry_display_height
);
2603 XResizeWindow(dpy
, scr
->geometry_display
,
2604 scr
->geometry_display_width
, scr
->geometry_display_height
);
2612 setLargeDisplayFont(WScreen
*scr
, WDefaultEntry
*entry
, WMFont
*font
, void *foo
)
2614 if (scr
->workspace_name_font
) {
2615 WMReleaseFont(scr
->workspace_name_font
);
2618 scr
->workspace_name_font
= font
;
2625 setHightlight(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, void *foo
)
2627 if (scr
->select_pixel
!=scr
->white_pixel
&&
2628 scr
->select_pixel
!=scr
->black_pixel
) {
2629 wFreeColor(scr
, scr
->select_pixel
);
2632 scr
->select_pixel
= color
->pixel
;
2634 return REFRESH_MENU_COLOR
;
2639 setHightlightText(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, void *foo
)
2641 if (scr
->select_text_pixel
!=scr
->white_pixel
&&
2642 scr
->select_text_pixel
!=scr
->black_pixel
) {
2643 wFreeColor(scr
, scr
->select_text_pixel
);
2646 scr
->select_text_pixel
= color
->pixel
;
2648 return REFRESH_MENU_COLOR
;
2653 setClipTitleColor(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, long index
)
2655 if (scr
->clip_title_pixel
[index
]!=scr
->white_pixel
&&
2656 scr
->clip_title_pixel
[index
]!=scr
->black_pixel
) {
2657 wFreeColor(scr
, scr
->clip_title_pixel
[index
]);
2659 scr
->clip_title_pixel
[index
] = color
->pixel
;
2661 #ifdef GRADIENT_CLIP_ARROW
2662 if (index
== CLIP_NORMAL
) {
2664 RColor color1
, color2
;
2665 int pt
= CLIP_BUTTON_SIZE
*wPreferences
.icon_size
/64;
2666 int as
= pt
- 15; /* 15 = 5+5+5 */
2668 FREE_PIXMAP(scr
->clip_arrow_gradient
);
2670 color1
.red
= (color
->red
>> 8)*6/10;
2671 color1
.green
= (color
->green
>> 8)*6/10;
2672 color1
.blue
= (color
->blue
>> 8)*6/10;
2674 color2
.red
= WMIN((color
->red
>> 8)*20/10, 255);
2675 color2
.green
= WMIN((color
->green
>> 8)*20/10, 255);
2676 color2
.blue
= WMIN((color
->blue
>> 8)*20/10, 255);
2678 image
= RRenderGradient(as
+1, as
+1, &color1
, &color2
, RDiagonalGradient
);
2679 RConvertImage(scr
->rcontext
, image
, &scr
->clip_arrow_gradient
);
2680 RDestroyImage(image
);
2682 #endif /* GRADIENT_CLIP_ARROW */
2684 return REFRESH_ICON_TITLE_COLOR
;
2689 setWTitleColor(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, long index
)
2691 if (scr
->window_title_pixel
[index
]!=scr
->white_pixel
&&
2692 scr
->window_title_pixel
[index
]!=scr
->black_pixel
) {
2693 wFreeColor(scr
, scr
->window_title_pixel
[index
]);
2696 scr
->window_title_pixel
[index
] = color
->pixel
;
2698 if (index
== WS_UNFOCUSED
)
2699 XSetForeground(dpy
, scr
->info_text_gc
, color
->pixel
);
2701 return REFRESH_WINDOW_TITLE_COLOR
;
2706 setMenuTitleColor(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, long index
)
2708 if (scr
->menu_title_pixel
[0]!=scr
->white_pixel
&&
2709 scr
->menu_title_pixel
[0]!=scr
->black_pixel
) {
2710 #ifdef DRAWSTRING_PLUGIN
2711 if(!scr
->drawstring_func
[W_STRING_MTITLE
])
2713 wFreeColor(scr
, scr
->menu_title_pixel
[0]);
2716 scr
->menu_title_pixel
[0] = color
->pixel
;
2717 XSetForeground(dpy
, scr
->menu_title_gc
, color
->pixel
);
2719 return REFRESH_MENU_TITLE_COLOR
;
2724 setMenuTextColor(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, void *foo
)
2727 #define gcm (GCForeground|GCBackground|GCFillStyle)
2729 if (scr
->mtext_pixel
!=scr
->white_pixel
&&
2730 scr
->mtext_pixel
!=scr
->black_pixel
) {
2731 wFreeColor(scr
, scr
->mtext_pixel
);
2734 scr
->mtext_pixel
= color
->pixel
;
2736 XSetForeground(dpy
, scr
->menu_entry_gc
, color
->pixel
);
2739 if (scr
->dtext_pixel
== scr
->mtext_pixel
) {
2740 gcv
.foreground
= scr
->white_pixel
;
2741 gcv
.background
= scr
->black_pixel
;
2742 gcv
.fill_style
= FillStippled
;
2744 gcv
.foreground
= scr
->dtext_pixel
;
2745 gcv
.fill_style
= FillSolid
;
2747 XChangeGC(dpy
, scr
->disabled_menu_entry_gc
, gcm
, &gcv
);
2749 return REFRESH_MENU_COLOR
;
2755 setMenuDisabledColor(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, void *foo
)
2758 #define gcm (GCForeground|GCBackground|GCFillStyle)
2760 if (scr
->dtext_pixel
!=scr
->white_pixel
&&
2761 scr
->dtext_pixel
!=scr
->black_pixel
) {
2762 wFreeColor(scr
, scr
->dtext_pixel
);
2765 scr
->dtext_pixel
= color
->pixel
;
2767 if (scr
->dtext_pixel
== scr
->mtext_pixel
) {
2768 gcv
.foreground
= scr
->white_pixel
;
2769 gcv
.background
= scr
->black_pixel
;
2770 gcv
.fill_style
= FillStippled
;
2772 gcv
.foreground
= scr
->dtext_pixel
;
2773 gcv
.fill_style
= FillSolid
;
2775 XChangeGC(dpy
, scr
->disabled_menu_entry_gc
, gcm
, &gcv
);
2777 return REFRESH_MENU_COLOR
;
2782 setIconTitleColor(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, void *foo
)
2784 XSetForeground(dpy
, scr
->icon_title_gc
, color
->pixel
);
2786 return REFRESH_ICON_TITLE_COLOR
;
2791 setIconTitleBack(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, void *foo
)
2793 if (scr
->icon_title_texture
) {
2794 wTextureDestroy(scr
, (WTexture
*)scr
->icon_title_texture
);
2796 XQueryColor (dpy
, scr
->w_colormap
, color
);
2797 scr
->icon_title_texture
= wTextureMakeSolid(scr
, color
);
2799 return REFRESH_ICON_TITLE_BACK
;
2804 trackDeadProcess(pid_t pid
, unsigned char status
, WScreen
*scr
)
2806 close(scr
->helper_fd
);
2808 scr
->helper_pid
= 0;
2809 scr
->flags
.backimage_helper_launched
= 0;
2814 setWorkspaceSpecificBack(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
,
2821 if (scr
->flags
.backimage_helper_launched
) {
2822 if (PLGetNumberOfElements(value
)==0) {
2823 SendHelperMessage(scr
, 'C', 0, NULL
);
2824 SendHelperMessage(scr
, 'K', 0, NULL
);
2833 if (PLGetNumberOfElements(value
) == 0)
2836 if (pipe(filedes
) < 0) {
2837 wsyserror("pipe() failed:can't set workspace specific background image");
2845 wsyserror("fork() failed:can't set workspace specific background image");
2846 if (close(filedes
[0]) < 0)
2847 wsyserror("could not close pipe");
2848 if (close(filedes
[1]) < 0)
2849 wsyserror("could not close pipe");
2851 } else if (pid
== 0) {
2852 SetupEnvironment(scr
);
2855 wsyserror("could not close pipe");
2856 if (dup(filedes
[0]) < 0) {
2857 wsyserror("dup() failed:can't set workspace specific background image");
2859 if (wPreferences
.smooth_workspace_back
)
2860 execlp("wmsetbg", "wmsetbg", "-helper", "-S", "-d", NULL
);
2862 execlp("wmsetbg", "wmsetbg", "-helper", "-d", NULL
);
2863 wsyserror("could not execute wmsetbg");
2867 if (fcntl(filedes
[0], F_SETFD
, FD_CLOEXEC
) < 0) {
2868 wsyserror("error setting close-on-exec flag");
2870 if (fcntl(filedes
[1], F_SETFD
, FD_CLOEXEC
) < 0) {
2871 wsyserror("error setting close-on-exec flag");
2874 scr
->helper_fd
= filedes
[1];
2875 scr
->helper_pid
= pid
;
2876 scr
->flags
.backimage_helper_launched
= 1;
2878 wAddDeathHandler(pid
, (WDeathHandler
*)trackDeadProcess
, scr
);
2880 SendHelperMessage(scr
, 'P', -1, wPreferences
.pixmap_path
);
2885 for (i
= 0; i
< PLGetNumberOfElements(value
); i
++) {
2886 val
= PLGetArrayElement(value
, i
);
2887 if (val
&& PLIsArray(val
) && PLGetNumberOfElements(val
)>0) {
2888 str
= PLGetDescription(val
);
2890 SendHelperMessage(scr
, 'S', i
+1, str
);
2894 SendHelperMessage(scr
, 'U', i
+1, NULL
);
2905 setWorkspaceBack(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
,
2908 if (scr
->flags
.backimage_helper_launched
) {
2911 if (PLGetNumberOfElements(value
)==0) {
2912 SendHelperMessage(scr
, 'U', 0, NULL
);
2914 /* set the default workspace background to this one */
2915 str
= PLGetDescription(value
);
2917 SendHelperMessage(scr
, 'S', 0, str
);
2919 SendHelperMessage(scr
, 'C', scr
->current_workspace
+1, NULL
);
2921 SendHelperMessage(scr
, 'U', 0, NULL
);
2928 SetupEnvironment(scr
);
2929 text
= PLGetDescription(value
);
2930 command
= wmalloc(strlen(text
)+40);
2931 if (wPreferences
.smooth_workspace_back
)
2932 sprintf(command
, "wmsetbg -d -S -p '%s' &", text
);
2934 sprintf(command
, "wmsetbg -d -p '%s' &", text
);
2946 setWidgetColor(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
2948 if (scr
->widget_texture
) {
2949 wTextureDestroy(scr
, (WTexture
*)scr
->widget_texture
);
2951 scr
->widget_texture
= *(WTexSolid
**)texture
;
2953 if (scr
->geometry_display
!= None
)
2954 XSetWindowBackground(dpy
, scr
->geometry_display
,
2955 scr
->widget_texture
->normal
.pixel
);
2962 setFTitleBack(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
2964 if (scr
->window_title_texture
[WS_FOCUSED
]) {
2965 wTextureDestroy(scr
, scr
->window_title_texture
[WS_FOCUSED
]);
2967 scr
->window_title_texture
[WS_FOCUSED
] = *texture
;
2969 return REFRESH_WINDOW_TEXTURES
;
2974 setPTitleBack(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
2976 if (scr
->window_title_texture
[WS_PFOCUSED
]) {
2977 wTextureDestroy(scr
, scr
->window_title_texture
[WS_PFOCUSED
]);
2979 scr
->window_title_texture
[WS_PFOCUSED
] = *texture
;
2981 return REFRESH_WINDOW_TEXTURES
;
2986 setUTitleBack(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
2988 if (scr
->window_title_texture
[WS_UNFOCUSED
]) {
2989 wTextureDestroy(scr
, scr
->window_title_texture
[WS_UNFOCUSED
]);
2991 scr
->window_title_texture
[WS_UNFOCUSED
] = *texture
;
2993 return REFRESH_WINDOW_TEXTURES
;
2998 setResizebarBack(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
3000 if (scr
->resizebar_texture
[0]) {
3001 wTextureDestroy(scr
, scr
->resizebar_texture
[0]);
3003 scr
->resizebar_texture
[0] = *texture
;
3005 return REFRESH_WINDOW_TEXTURES
;
3010 setMenuTitleBack(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
3012 if (scr
->menu_title_texture
[0]) {
3013 wTextureDestroy(scr
, scr
->menu_title_texture
[0]);
3015 scr
->menu_title_texture
[0] = *texture
;
3017 return REFRESH_MENU_TITLE_TEXTURE
;
3022 setMenuTextBack(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
3024 if (scr
->menu_item_texture
) {
3025 wTextureDestroy(scr
, scr
->menu_item_texture
);
3026 wTextureDestroy(scr
, (WTexture
*)scr
->menu_item_auxtexture
);
3028 scr
->menu_item_texture
= *texture
;
3030 scr
->menu_item_auxtexture
3031 = wTextureMakeSolid(scr
, &scr
->menu_item_texture
->any
.color
);
3033 return REFRESH_MENU_TEXTURE
;
3038 setKeyGrab(WScreen
*scr
, WDefaultEntry
*entry
, WShortKey
*shortcut
, long index
)
3041 wKeyBindings
[index
] = *shortcut
;
3043 wwin
= scr
->focused_window
;
3045 while (wwin
!=NULL
) {
3046 XUngrabKey(dpy
, AnyKey
, AnyModifier
, wwin
->frame
->core
->window
);
3048 if (!WFLAGP(wwin
, no_bind_keys
)) {
3049 wWindowSetKeyGrabs(wwin
);
3059 setIconPosition(WScreen
*scr
, WDefaultEntry
*entry
, void *bar
, void *foo
)
3061 wArrangeIcons(scr
, True
);
3068 updateUsableArea(WScreen
*scr
, WDefaultEntry
*entry
, void *bar
, void *foo
)
3070 wScreenUpdateUsableArea(scr
);
3077 setMenuStyle(WScreen
*scr
, WDefaultEntry
*entry
, int *value
, void *foo
)
3079 return REFRESH_MENU_TEXTURE
;
3085 setButtonImages(WScreen *scr, WDefaultEntry *entry, int *value, void *foo)
3087 return REFRESH_BUTTON_IMAGES;
3093 * Need access to the double click variables, so that all widgets in
3094 * wmaker panels will have the same dbl-click values.
3095 * TODO: figure a better way of dealing with it.
3100 setDoubleClick(WScreen
*scr
, WDefaultEntry
*entry
, int *value
, void *foo
)
3102 extern _WINGsConfiguration WINGsConfiguration
;
3107 WINGsConfiguration
.doubleClickDelay
= *value
;
3115 setMultiByte(WScreen
*scr
, WDefaultEntry
*entry
, int *value
, void *foo
)
3117 extern _WINGsConfiguration WINGsConfiguration
;
3119 WINGsConfiguration
.useMultiByte
= *value
;