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 setLargeDisplayFont();
158 static int setWTitleColor();
159 static int setFTitleBack();
160 static int setPTitleBack();
161 static int setUTitleBack();
162 static int setResizebarBack();
163 static int setWorkspaceBack();
164 static int setWorkspaceSpecificBack();
165 static int setMenuTitleColor();
166 static int setMenuTextColor();
167 static int setMenuDisabledColor();
168 static int setMenuTitleBack();
169 static int setMenuTextBack();
170 static int setHightlight();
171 static int setHightlightText();
172 static int setKeyGrab();
173 static int setDoubleClick();
174 static int setIconPosition();
176 static int setClipTitleFont();
177 static int setClipTitleColor();
179 static int setMenuStyle();
180 static int setMultiByte();
182 static int updateUsableArea();
187 * Tables to convert strings to enumeration values.
188 * Values stored are char
192 /* WARNING: sum of length of all value strings must not exceed
194 #define TOTAL_VALUES_LENGTH 80
199 #define REFRESH_WINDOW_TEXTURES (1<<0)
200 #define REFRESH_MENU_TEXTURE (1<<1)
201 #define REFRESH_MENU_FONT (1<<2)
202 #define REFRESH_MENU_COLOR (1<<3)
203 #define REFRESH_MENU_TITLE_TEXTURE (1<<4)
204 #define REFRESH_MENU_TITLE_FONT (1<<5)
205 #define REFRESH_MENU_TITLE_COLOR (1<<6)
206 #define REFRESH_WINDOW_TITLE_COLOR (1<<7)
207 #define REFRESH_WINDOW_FONT (1<<8)
208 #define REFRESH_ICON_TILE (1<<9)
209 #define REFRESH_ICON_FONT (1<<10)
210 #define REFRESH_WORKSPACE_BACK (1<<11)
212 #define REFRESH_BUTTON_IMAGES (1<<12)
214 #define REFRESH_ICON_TITLE_COLOR (1<<13)
215 #define REFRESH_ICON_TITLE_BACK (1<<14)
219 static WOptionEnumeration seFocusModes
[] = {
220 {"Manual", WKF_CLICK
, 0}, {"ClickToFocus", WKF_CLICK
, 1},
221 {"Auto", WKF_POINTER
, 0}, {"FocusFollowMouse", WKF_POINTER
, 1},
222 {"Sloppy", WKF_SLOPPY
, 0}, {"SemiAuto", WKF_SLOPPY
, 1},
226 static WOptionEnumeration seColormapModes
[] = {
227 {"Manual", WKF_CLICK
, 0}, {"ClickToFocus", WKF_CLICK
, 1},
228 {"Auto", WKF_POINTER
, 0}, {"FocusFollowMouse", WKF_POINTER
, 1},
232 static WOptionEnumeration sePlacements
[] = {
233 {"Auto", WPM_AUTO
, 0}, {"Smart", WPM_SMART
, 0},
234 {"Cascade", WPM_CASCADE
, 0},
235 {"Random", WPM_RANDOM
, 0},
236 {"Manual", WPM_MANUAL
, 0},
240 static WOptionEnumeration seGeomDisplays
[] = {
241 {"Center", WDIS_CENTER
, 0},
242 {"Corner", WDIS_TOPLEFT
, 0},
243 {"Floating", WDIS_FRAME_CENTER
, 0},
244 {"Line", WDIS_NEW
, 0},
248 static WOptionEnumeration seSpeeds
[] = {
249 {"UltraFast", SPEED_ULTRAFAST
, 0},
250 {"Fast", SPEED_FAST
, 0},
251 {"Medium", SPEED_MEDIUM
, 0},
252 {"Slow", SPEED_SLOW
, 0},
253 {"UltraSlow", SPEED_ULTRASLOW
, 0},
257 static WOptionEnumeration seMouseButtons
[] = {
259 {"Left", Button1
, 0}, {"Button1", Button1
, 1},
260 {"Middle", Button2
, 0}, {"Button2", Button2
, 1},
261 {"Right", Button3
, 0}, {"Button3", Button3
, 1},
262 {"Button4", Button4
, 0},
263 {"Button5", Button5
, 0},
267 static WOptionEnumeration seIconificationStyles
[] = {
268 {"Zoom", WIS_ZOOM
, 0},
269 {"Twist", WIS_TWIST
, 0},
270 {"Flip", WIS_FLIP
, 0},
271 {"None", WIS_NONE
, 0},
272 {"random", WIS_RANDOM
, 0},
276 static WOptionEnumeration seJustifications
[] = {
277 {"Left", WTJ_LEFT
, 0},
278 {"Center", WTJ_CENTER
, 0},
279 {"Right", WTJ_RIGHT
, 0},
283 static WOptionEnumeration seIconPositions
[] = {
284 {"blv", IY_BOTTOM
|IY_LEFT
|IY_VERT
, 0},
285 {"blh", IY_BOTTOM
|IY_LEFT
|IY_HORIZ
, 0},
286 {"brv", IY_BOTTOM
|IY_RIGHT
|IY_VERT
, 0},
287 {"brh", IY_BOTTOM
|IY_RIGHT
|IY_HORIZ
, 0},
288 {"tlv", IY_TOP
|IY_LEFT
|IY_VERT
, 0},
289 {"tlh", IY_TOP
|IY_LEFT
|IY_HORIZ
, 0},
290 {"trv", IY_TOP
|IY_RIGHT
|IY_VERT
, 0},
291 {"trh", IY_TOP
|IY_RIGHT
|IY_HORIZ
, 0},
295 static WOptionEnumeration seMenuStyles
[] = {
296 {"normal", MS_NORMAL
, 0},
297 {"singletexture", MS_SINGLE_TEXTURE
, 0},
298 {"flat", MS_FLAT
, 0},
303 static WOptionEnumeration seDisplayPositions
[] = {
304 {"none", WD_NONE
, 0},
305 {"center", WD_CENTER
, 0},
307 {"bottom", WD_BOTTOM
, 0},
308 {"topleft", WD_TOPLEFT
, 0},
309 {"topright", WD_TOPRIGHT
, 0},
310 {"bottomleft", WD_BOTTOMLEFT
, 0},
311 {"bottomright", WD_BOTTOMRIGHT
, 0}
316 * ALL entries in the tables bellow, NEED to have a default value
317 * defined, and this value needs to be correct.
320 /* these options will only affect the window manager on startup
322 * static defaults can't access the screen data, because it is
323 * created after these defaults are read
325 WDefaultEntry staticOptionList
[] = {
327 {"DisableDithering", "NO", NULL
,
328 &wPreferences
.no_dithering
, getBool
, NULL
330 {"ColormapSize", "4", NULL
,
331 &wPreferences
.cmap_size
, getInt
, NULL
333 /* static by laziness */
334 {"IconSize", "64", NULL
,
335 &wPreferences
.icon_size
, getInt
, NULL
337 {"ModifierKey", "Mod1", NULL
,
338 &wPreferences
.modifier_mask
, getModMask
, NULL
340 {"DisableWSMouseActions", "NO", NULL
,
341 &wPreferences
.disable_root_mouse
, getBool
, NULL
343 {"FocusMode", "manual", seFocusModes
,
344 &wPreferences
.focus_mode
, getEnum
, NULL
345 }, /* have a problem when switching from manual to sloppy without restart */
346 {"NewStyle", "NO", NULL
,
347 &wPreferences
.new_style
, getBool
, NULL
349 {"DisableDock", "NO", (void*) WM_DOCK
,
350 NULL
, getBool
, setIfDockPresent
352 {"DisableClip", "NO", (void*) WM_CLIP
,
353 NULL
, getBool
, setIfDockPresent
355 {"DisableMiniwindows", "NO", NULL
,
356 &wPreferences
.disable_miniwindows
, getBool
, NULL
358 {"MultiByteText", "NO", NULL
,
359 &wPreferences
.multi_byte_text
, getBool
, setMultiByte
365 WDefaultEntry optionList
[] = {
366 /* dynamic options */
367 {"IconPosition", "blh", seIconPositions
,
368 &wPreferences
.icon_yard
, getEnum
, setIconPosition
370 {"IconificationStyle", "Zoom", seIconificationStyles
,
371 &wPreferences
.iconification_style
, getEnum
, NULL
373 {"SelectWindowsMouseButton", "Left", seMouseButtons
,
374 &wPreferences
.select_button
, getEnum
, NULL
376 {"WindowListMouseButton", "Middle", seMouseButtons
,
377 &wPreferences
.windowl_button
, getEnum
, NULL
379 {"ApplicationMenuMouseButton", "Right", seMouseButtons
,
380 &wPreferences
.menu_button
, getEnum
, NULL
382 {"PixmapPath", DEF_PIXMAP_PATHS
, NULL
,
383 &wPreferences
.pixmap_path
, getPathList
, NULL
385 {"IconPath", DEF_ICON_PATHS
, NULL
,
386 &wPreferences
.icon_path
, getPathList
, NULL
388 {"ColormapMode", "auto", seColormapModes
,
389 &wPreferences
.colormap_mode
, getEnum
, NULL
391 {"AutoFocus", "NO", NULL
,
392 &wPreferences
.auto_focus
, getBool
, NULL
394 {"RaiseDelay", "0", NULL
,
395 &wPreferences
.raise_delay
, getInt
, NULL
397 {"CirculateRaise", "NO", NULL
,
398 &wPreferences
.circ_raise
, getBool
, NULL
400 {"Superfluous", "NO", NULL
,
401 &wPreferences
.superfluous
, getBool
, NULL
403 {"AdvanceToNewWorkspace", "NO", NULL
,
404 &wPreferences
.ws_advance
, getBool
, NULL
406 {"CycleWorkspaces", "NO", NULL
,
407 &wPreferences
.ws_cycle
, getBool
, NULL
409 {"WorkspaceNameDisplayPosition", "center", seDisplayPositions
,
410 &wPreferences
.workspace_name_display_position
, getEnum
, NULL
412 #ifdef VIRTUAL_DESKTOP
413 {"VirtualEdgeThickness", "1", NULL
,
414 &wPreferences
.vedge_thickness
, getInt
, NULL
416 {"VirtualEdgeHorizonScrollSpeed", "1", NULL
,
417 &wPreferences
.vedge_hscrollspeed
, getInt
, NULL
419 {"VirtualEdgeVerticalScrollSpeed", "1", NULL
,
420 &wPreferences
.vedge_vscrollspeed
, getInt
, NULL
422 {"VirtualEdgeWidth", "2000", NULL
,
423 &wPreferences
.vedge_width
, getInt
, NULL
425 {"VirtualEdgeHeight", "2000", NULL
,
426 &wPreferences
.vedge_height
, getInt
, NULL
429 {"StickyIcons", "NO", NULL
,
430 &wPreferences
.sticky_icons
, getBool
, setStickyIcons
432 {"SaveSessionOnExit", "NO", NULL
,
433 &wPreferences
.save_session_on_exit
, getBool
, NULL
435 {"WrapMenus", "NO", NULL
,
436 &wPreferences
.wrap_menus
, getBool
, NULL
438 {"ScrollableMenus", "NO", NULL
,
439 &wPreferences
.scrollable_menus
, getBool
, NULL
441 {"MenuScrollSpeed", "medium", seSpeeds
,
442 &wPreferences
.menu_scroll_speed
, getEnum
, NULL
444 {"IconSlideSpeed", "medium", seSpeeds
,
445 &wPreferences
.icon_slide_speed
, getEnum
, NULL
447 {"ShadeSpeed", "medium", seSpeeds
,
448 &wPreferences
.shade_speed
, getEnum
, NULL
450 {"DoubleClickTime", "250", (void*) &wPreferences
.dblclick_time
,
451 &wPreferences
.dblclick_time
, getInt
, setDoubleClick
,
453 {"AlignSubmenus", "NO", NULL
,
454 &wPreferences
.align_menus
, getBool
, NULL
456 {"OpenTransientOnOwnerWorkspace", "NO", NULL
,
457 &wPreferences
.open_transients_with_parent
, getBool
, NULL
459 {"WindowPlacement", "auto", sePlacements
,
460 &wPreferences
.window_placement
, getEnum
, NULL
462 {"IgnoreFocusClick","NO", NULL
,
463 &wPreferences
.ignore_focus_click
, getBool
, NULL
465 {"UseSaveUnders", "NO", NULL
,
466 &wPreferences
.use_saveunders
, getBool
, NULL
468 {"OpaqueMove", "NO", NULL
,
469 &wPreferences
.opaque_move
, getBool
, NULL
471 {"DisableSound", "NO", NULL
,
472 &wPreferences
.no_sound
, getBool
, NULL
474 {"DisableAnimations", "NO", NULL
,
475 &wPreferences
.no_animations
, getBool
, NULL
477 {"DontLinkWorkspaces","NO", NULL
,
478 &wPreferences
.no_autowrap
, getBool
, NULL
480 {"AutoArrangeIcons", "NO", NULL
,
481 &wPreferences
.auto_arrange_icons
, getBool
, NULL
483 {"NoWindowOverDock", "NO", NULL
,
484 &wPreferences
.no_window_over_dock
, getBool
, updateUsableArea
486 {"NoWindowOverIcons", "NO", NULL
,
487 &wPreferences
.no_window_over_icons
, getBool
, updateUsableArea
489 {"WindowPlaceOrigin", "(0, 0)", NULL
,
490 &wPreferences
.window_place_origin
, getCoord
, NULL
492 {"ResizeDisplay", "corner", seGeomDisplays
,
493 &wPreferences
.size_display
, getEnum
, NULL
495 {"MoveDisplay", "corner", seGeomDisplays
,
496 &wPreferences
.move_display
, getEnum
, NULL
498 {"DontConfirmKill", "NO", NULL
,
499 &wPreferences
.dont_confirm_kill
, getBool
,NULL
501 {"WindowTitleBalloons", "NO", NULL
,
502 &wPreferences
.window_balloon
, getBool
, NULL
504 {"MiniwindowTitleBalloons", "NO", NULL
,
505 &wPreferences
.miniwin_balloon
,getBool
, NULL
507 {"AppIconBalloons", "NO", NULL
,
508 &wPreferences
.appicon_balloon
,getBool
, NULL
510 {"HelpBalloons", "NO", NULL
,
511 &wPreferences
.help_balloon
, getBool
, NULL
513 {"EdgeResistance", "30", NULL
,
514 &wPreferences
.edge_resistance
,getInt
, NULL
516 {"Attraction", "NO", NULL
,
517 &wPreferences
.attract
, getBool
, NULL
519 {"DisableBlinking", "NO", NULL
,
520 &wPreferences
.dont_blink
, getBool
, NULL
522 #ifdef WEENDOZE_CYCLE
523 {"WindozeCycling","NO", NULL
,
524 &wPreferences
.windoze_cycling
, getBool
, NULL
526 {"PopupSwitchMenu","YES", NULL
,
527 &wPreferences
.popup_switchmenu
, getBool
, NULL
529 #endif /* WEENDOZE_CYCLE */
531 {"MenuStyle", "normal", seMenuStyles
,
532 &wPreferences
.menu_style
, getEnum
, setMenuStyle
534 {"WidgetColor", "(solid, gray)", NULL
,
535 NULL
, getTexture
, setWidgetColor
,
537 {"WorkspaceSpecificBack","()", NULL
,
538 NULL
, getWSSpecificBackground
, setWorkspaceSpecificBack
540 /* WorkspaceBack must come after WorkspaceSpecificBack or
541 * WorkspaceBack wont know WorkspaceSpecificBack was also
542 * specified and 2 copies of wmsetbg will be launched */
543 {"WorkspaceBack", "(solid, black)", NULL
,
544 NULL
, getWSBackground
,setWorkspaceBack
546 {"SmoothWorkspaceBack", "NO", NULL
,
549 {"IconBack", "(solid, gray)", NULL
,
550 NULL
, getTexture
, setIconTile
552 {"TitleJustify", "center", seJustifications
,
553 &wPreferences
.title_justification
, getEnum
, setJustify
555 {"WindowTitleFont", DEF_TITLE_FONT
, NULL
,
556 NULL
, getFont
, setWinTitleFont
,
558 {"MenuTitleFont", DEF_MENU_TITLE_FONT
, NULL
,
559 NULL
, getFont
, setMenuTitleFont
561 {"MenuTextFont", DEF_MENU_ENTRY_FONT
, NULL
,
562 NULL
, getFont
, setMenuTextFont
564 {"IconTitleFont", DEF_ICON_TITLE_FONT
, NULL
,
565 NULL
, getFont
, setIconTitleFont
567 {"ClipTitleFont", DEF_CLIP_TITLE_FONT
, NULL
,
568 NULL
, getFont
, setClipTitleFont
570 {"LargeDisplayFont",DEF_WORKSPACE_NAME_FONT
, NULL
,
571 NULL
, getFont
, setLargeDisplayFont
573 {"HighlightColor", "white", NULL
,
574 NULL
, getColor
, setHightlight
576 {"HighlightTextColor", "black", NULL
,
577 NULL
, getColor
, setHightlightText
579 {"ClipTitleColor", "black", (void*)CLIP_NORMAL
,
580 NULL
, getColor
, setClipTitleColor
582 {"CClipTitleColor", "\"#454045\"", (void*)CLIP_COLLAPSED
,
583 NULL
, getColor
, setClipTitleColor
585 #ifdef DRAWSTRING_PLUGIN
586 {"FTitleColor", "white", (void*)WS_FOCUSED
,
587 NULL
, getTextRenderer
, setWTitleColor
589 {"PTitleColor", "white", (void*)WS_PFOCUSED
,
590 NULL
, getTextRenderer
, setWTitleColor
592 {"UTitleColor", "black", (void*)WS_UNFOCUSED
,
593 NULL
, getTextRenderer
, setWTitleColor
596 {"FTitleColor", "white", (void*)WS_FOCUSED
,
597 NULL
, getColor
, setWTitleColor
599 {"PTitleColor", "white", (void*)WS_PFOCUSED
,
600 NULL
, getColor
, setWTitleColor
602 {"UTitleColor", "black", (void*)WS_UNFOCUSED
,
603 NULL
, getColor
, setWTitleColor
606 {"FTitleBack", "(solid, black)", NULL
,
607 NULL
, getTexture
, setFTitleBack
609 {"PTitleBack", "(solid, \"#616161\")", NULL
,
610 NULL
, getTexture
, setPTitleBack
612 {"UTitleBack", "(solid, gray)", NULL
,
613 NULL
, getTexture
, setUTitleBack
615 {"ResizebarBack", "(solid, gray)", NULL
,
616 NULL
, getTexture
, setResizebarBack
618 #ifdef DRAWSTRING_PLUGIN
619 {"MenuTitleColor", "white", NULL
,
620 NULL
, getTextRenderer
, setMenuTitleColor
623 {"MenuTitleColor", "white", NULL
,
624 NULL
, getColor
, setMenuTitleColor
627 {"MenuTextColor", "black", NULL
,
628 NULL
, getColor
, setMenuTextColor
630 {"MenuDisabledColor", "\"#616161\"", NULL
,
631 NULL
, getColor
, setMenuDisabledColor
633 {"MenuTitleBack", "(solid, black)", NULL
,
634 NULL
, getTexture
, setMenuTitleBack
636 {"MenuTextBack", "(solid, gray)", NULL
,
637 NULL
, getTexture
, setMenuTextBack
639 {"IconTitleColor", "white", NULL
,
640 NULL
, getColor
, setIconTitleColor
642 {"IconTitleBack", "black", NULL
,
643 NULL
, getColor
, setIconTitleBack
647 {"RootMenuKey", "None", (void*)WKBD_ROOTMENU
,
648 NULL
, getKeybind
, setKeyGrab
650 {"WindowListKey", "None", (void*)WKBD_WINDOWLIST
,
651 NULL
, getKeybind
, setKeyGrab
654 {"WindowMenuKey", "None", (void*)WKBD_WINDOWMENU
,
655 NULL
, getKeybind
, setKeyGrab
657 {"ClipLowerKey", "None", (void*)WKBD_CLIPLOWER
,
658 NULL
, getKeybind
, setKeyGrab
660 {"ClipRaiseKey", "None", (void*)WKBD_CLIPRAISE
,
661 NULL
, getKeybind
, setKeyGrab
663 {"ClipRaiseLowerKey", "None", (void*)WKBD_CLIPRAISELOWER
,
664 NULL
, getKeybind
, setKeyGrab
666 {"MiniaturizeKey", "None", (void*)WKBD_MINIATURIZE
,
667 NULL
, getKeybind
, setKeyGrab
669 {"HideKey", "None", (void*)WKBD_HIDE
,
670 NULL
, getKeybind
, setKeyGrab
672 {"MoveResizeKey", "None", (void*)WKBD_MOVERESIZE
,
673 NULL
, getKeybind
, setKeyGrab
675 {"CloseKey", "None", (void*)WKBD_CLOSE
,
676 NULL
, getKeybind
, setKeyGrab
678 {"MaximizeKey", "None", (void*)WKBD_MAXIMIZE
,
679 NULL
, getKeybind
, setKeyGrab
681 {"VMaximizeKey", "None", (void*)WKBD_VMAXIMIZE
,
682 NULL
, getKeybind
, setKeyGrab
684 {"RaiseKey", "\"Meta+Up\"", (void*)WKBD_RAISE
,
685 NULL
, getKeybind
, setKeyGrab
687 {"LowerKey", "\"Meta+Down\"", (void*)WKBD_LOWER
,
688 NULL
, getKeybind
, setKeyGrab
690 {"RaiseLowerKey", "None", (void*)WKBD_RAISELOWER
,
691 NULL
, getKeybind
, setKeyGrab
693 {"ShadeKey", "None", (void*)WKBD_SHADE
,
694 NULL
, getKeybind
, setKeyGrab
696 {"SelectKey", "None", (void*)WKBD_SELECT
,
697 NULL
, getKeybind
, setKeyGrab
699 {"FocusNextKey", "None", (void*)WKBD_FOCUSNEXT
,
700 NULL
, getKeybind
, setKeyGrab
702 {"FocusPrevKey", "None", (void*)WKBD_FOCUSPREV
,
703 NULL
, getKeybind
, setKeyGrab
705 {"NextWorkspaceKey", "None", (void*)WKBD_NEXTWORKSPACE
,
706 NULL
, getKeybind
, setKeyGrab
708 {"PrevWorkspaceKey", "None", (void*)WKBD_PREVWORKSPACE
,
709 NULL
, getKeybind
, setKeyGrab
711 {"NextWorkspaceLayerKey", "None", (void*)WKBD_NEXTWSLAYER
,
712 NULL
, getKeybind
, setKeyGrab
714 {"PrevWorkspaceLayerKey", "None", (void*)WKBD_PREVWSLAYER
,
715 NULL
, getKeybind
, setKeyGrab
717 {"Workspace1Key", "None", (void*)WKBD_WORKSPACE1
,
718 NULL
, getKeybind
, setKeyGrab
720 {"Workspace2Key", "None", (void*)WKBD_WORKSPACE2
,
721 NULL
, getKeybind
, setKeyGrab
723 {"Workspace3Key", "None", (void*)WKBD_WORKSPACE3
,
724 NULL
, getKeybind
, setKeyGrab
726 {"Workspace4Key", "None", (void*)WKBD_WORKSPACE4
,
727 NULL
, getKeybind
, setKeyGrab
729 {"Workspace5Key", "None", (void*)WKBD_WORKSPACE5
,
730 NULL
, getKeybind
, setKeyGrab
732 {"Workspace6Key", "None", (void*)WKBD_WORKSPACE6
,
733 NULL
, getKeybind
, setKeyGrab
735 {"Workspace7Key", "None", (void*)WKBD_WORKSPACE7
,
736 NULL
, getKeybind
, setKeyGrab
738 {"Workspace8Key", "None", (void*)WKBD_WORKSPACE8
,
739 NULL
, getKeybind
, setKeyGrab
741 {"Workspace9Key", "None", (void*)WKBD_WORKSPACE9
,
742 NULL
, getKeybind
, setKeyGrab
744 {"Workspace10Key", "None", (void*)WKBD_WORKSPACE10
,
745 NULL
, getKeybind
, setKeyGrab
747 {"WindowShortcut1Key","None", (void*)WKBD_WINDOW1
,
748 NULL
, getKeybind
, setKeyGrab
750 {"WindowShortcut2Key","None", (void*)WKBD_WINDOW2
,
751 NULL
, getKeybind
, setKeyGrab
753 {"WindowShortcut3Key","None", (void*)WKBD_WINDOW3
,
754 NULL
, getKeybind
, setKeyGrab
756 {"WindowShortcut4Key","None", (void*)WKBD_WINDOW4
,
757 NULL
, getKeybind
, setKeyGrab
759 #ifdef EXTEND_WINDOWSHORTCUT
760 ,{"WindowShortcut5Key","None", (void*)WKBD_WINDOW5
,
761 NULL
, getKeybind
, setKeyGrab
763 {"WindowShortcut6Key","None", (void*)WKBD_WINDOW6
,
764 NULL
, getKeybind
, setKeyGrab
766 {"WindowShortcut7Key","None", (void*)WKBD_WINDOW7
,
767 NULL
, getKeybind
, setKeyGrab
769 {"WindowShortcut8Key","None", (void*)WKBD_WINDOW8
,
770 NULL
, getKeybind
, setKeyGrab
772 {"WindowShortcut9Key","None", (void*)WKBD_WINDOW9
,
773 NULL
, getKeybind
, setKeyGrab
775 {"WindowShortcut10Key","None", (void*)WKBD_WINDOW10
,
776 NULL
, getKeybind
, setKeyGrab
778 #endif /* EXTEND_WINDOWSHORTCUT */
780 #ifdef KEEP_XKB_LOCK_STATUS
781 ,{"ToggleKbdModeKey", "None", (void*)WKBD_TOGGLE
,
782 NULL
, getKeybind
, setKeyGrab
784 {"KbdModeLock", "NO", NULL
,
785 &wPreferences
.modelock
, getBool
, NULL
787 #endif /* KEEP_XKB_LOCK_STATUS */
792 static void rereadDefaults(void);
799 /* must defer the update because accessing X data from a
800 * signal handler can mess up Xlib */
809 WDefaultEntry
*entry
;
811 PLSetStringCmpHook(StringCompareHook
);
813 for (i
=0; i
<sizeof(optionList
)/sizeof(WDefaultEntry
); i
++) {
814 entry
= &optionList
[i
];
816 entry
->plkey
= PLMakeString(entry
->key
);
817 if (entry
->default_value
)
818 entry
->plvalue
= PLGetProplistWithDescription(entry
->default_value
);
820 entry
->plvalue
= NULL
;
823 for (i
=0; i
<sizeof(staticOptionList
)/sizeof(WDefaultEntry
); i
++) {
824 entry
= &staticOptionList
[i
];
826 entry
->plkey
= PLMakeString(entry
->key
);
827 if (entry
->default_value
)
828 entry
->plvalue
= PLGetProplistWithDescription(entry
->default_value
);
830 entry
->plvalue
= NULL
;
834 wDomainName = PLMakeString(WMDOMAIN_NAME);
835 wAttributeDomainName = PLMakeString(WMATTRIBUTE_DOMAIN_NAME);
837 PLRegister(wDomainName, rereadDefaults);
838 PLRegister(wAttributeDomainName, rereadDefaults);
847 wDefaultsInit(int screen_number
)
849 static int defaults_inited
= 0;
852 if (!defaults_inited
) {
856 dict
= PLGetDomain(wDomainName
);
858 wwarning(_("could not read domain \"%s\" from defaults database"),
859 PLGetString(wDomainName
));
868 wDefaultsDestroyDomain(WDDomain
*domain
)
870 if (domain
->dictionary
)
871 PLRelease(domain
->dictionary
);
878 wDefaultsInitDomain(char *domain
, Bool requireDictionary
)
882 static int inited
= 0;
885 proplist_t shared_dict
=NULL
;
892 db
= wmalloc(sizeof(WDDomain
));
893 memset(db
, 0, sizeof(WDDomain
));
894 db
->domain_name
= domain
;
895 db
->path
= wdefaultspathfordomain(domain
);
898 if (the_path
&& stat(the_path
, &stbuf
)>=0) {
899 db
->dictionary
= ReadProplistFromFile(the_path
);
900 if (db
->dictionary
) {
901 if (requireDictionary
&& !PLIsDictionary(db
->dictionary
)) {
902 PLRelease(db
->dictionary
);
903 db
->dictionary
= NULL
;
904 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
907 db
->timestamp
= stbuf
.st_mtime
;
909 wwarning(_("could not load domain %s from user defaults database"),
914 /* global system dictionary */
915 sprintf(path
, "%s/WindowMaker/%s", SYSCONFDIR
, domain
);
916 if (stat(path
, &stbuf
)>=0) {
917 shared_dict
= ReadProplistFromFile(path
);
919 if (requireDictionary
&& !PLIsDictionary(shared_dict
)) {
920 wwarning(_("Domain %s (%s) of global defaults database is corrupted!"),
922 PLRelease(shared_dict
);
925 if (db
->dictionary
&& PLIsDictionary(shared_dict
) &&
926 PLIsDictionary(db
->dictionary
)) {
927 PLMergeDictionaries(shared_dict
, db
->dictionary
);
928 PLRelease(db
->dictionary
);
929 db
->dictionary
= shared_dict
;
930 if (stbuf
.st_mtime
> db
->timestamp
)
931 db
->timestamp
= stbuf
.st_mtime
;
932 } else if (!db
->dictionary
) {
933 db
->dictionary
= shared_dict
;
934 if (stbuf
.st_mtime
> db
->timestamp
)
935 db
->timestamp
= stbuf
.st_mtime
;
939 wwarning(_("could not load domain %s from global defaults database (%s)"),
944 /* set to save it in user's directory, no matter from where it was read */
945 if (db
->dictionary
) {
946 proplist_t tmp
= PLMakeString(db
->path
);
948 PLSetFilename(db
->dictionary
, tmp
);
957 wReadStaticDefaults(proplist_t dict
)
960 WDefaultEntry
*entry
;
965 for (i
=0; i
<sizeof(staticOptionList
)/sizeof(WDefaultEntry
); i
++) {
966 entry
= &staticOptionList
[i
];
969 plvalue
= PLGetDictionaryEntry(dict
, entry
->plkey
);
974 /* no default in the DB. Use builtin default */
975 plvalue
= entry
->plvalue
;
980 (*entry
->convert
)(NULL
, entry
, plvalue
, entry
->addr
, &tdata
);
982 (*entry
->update
)(NULL
, entry
, tdata
, entry
->extra_data
);
990 wDefaultsCheckDomains(void *foo
)
999 puts("Checking domains...");
1001 if (stat(WDWindowMaker
->path
, &stbuf
)>=0
1002 && WDWindowMaker
->timestamp
< stbuf
.st_mtime
) {
1003 proplist_t shared_dict
= NULL
;
1005 puts("Checking WindowMaker domain");
1007 WDWindowMaker
->timestamp
= stbuf
.st_mtime
;
1009 /* global dictionary */
1010 sprintf(path
, "%s/WindowMaker/WindowMaker", SYSCONFDIR
);
1011 if (stat(path
, &stbuf
)>=0) {
1012 shared_dict
= ReadProplistFromFile(path
);
1013 if (shared_dict
&& !PLIsDictionary(shared_dict
)) {
1014 wwarning(_("Domain %s (%s) of global defaults database is corrupted!"),
1015 "WindowMaker", path
);
1016 PLRelease(shared_dict
);
1018 } else if (!shared_dict
) {
1019 wwarning(_("could not load domain %s from global defaults database"),
1023 /* user dictionary */
1024 dict
= ReadProplistFromFile(WDWindowMaker
->path
);
1026 if (!PLIsDictionary(dict
)) {
1029 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
1030 "WindowMaker", WDWindowMaker
->path
);
1033 PLSetFilename(shared_dict
, PLGetFilename(dict
));
1034 PLMergeDictionaries(shared_dict
, dict
);
1039 for (i
=0; i
<wScreenCount
; i
++) {
1040 scr
= wScreenWithNumber(i
);
1042 wReadDefaults(scr
, dict
);
1044 if (WDWindowMaker
->dictionary
) {
1045 PLRelease(WDWindowMaker
->dictionary
);
1047 WDWindowMaker
->dictionary
= dict
;
1050 wwarning(_("could not load domain %s from user defaults database"),
1054 PLRelease(shared_dict
);
1058 if (stat(WDWindowAttributes
->path
, &stbuf
)>=0
1059 && WDWindowAttributes
->timestamp
< stbuf
.st_mtime
) {
1061 puts("Checking WMWindowAttributes domain");
1063 dict
= ReadProplistFromFile(WDWindowAttributes
->path
);
1065 if (!PLIsDictionary(dict
)) {
1068 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
1069 "WMWindowAttributes", WDWindowAttributes
->path
);
1071 if (WDWindowAttributes
->dictionary
)
1072 PLRelease(WDWindowAttributes
->dictionary
);
1073 WDWindowAttributes
->dictionary
= dict
;
1074 for (i
=0; i
<wScreenCount
; i
++) {
1075 scr
= wScreenWithNumber(i
);
1077 wDefaultUpdateIcons(scr
);
1081 wwarning(_("could not load domain %s from user defaults database"),
1082 "WMWindowAttributes");
1084 WDWindowAttributes
->timestamp
= stbuf
.st_mtime
;
1088 if (stat(WDRootMenu
->path
, &stbuf
)>=0
1089 && WDRootMenu
->timestamp
< stbuf
.st_mtime
) {
1090 dict
= ReadProplistFromFile(WDRootMenu
->path
);
1092 puts("Checking WMRootMenu domain");
1095 if (!PLIsArray(dict
) && !PLIsString(dict
)) {
1098 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
1099 "WMRootMenu", WDRootMenu
->path
);
1101 if (WDRootMenu
->dictionary
) {
1102 PLRelease(WDRootMenu
->dictionary
);
1104 WDRootMenu
->dictionary
= dict
;
1107 wwarning(_("could not load domain %s from user defaults database"),
1110 WDRootMenu
->timestamp
= stbuf
.st_mtime
;
1115 WMAddTimerHandler(DEFAULTS_CHECK_INTERVAL
, wDefaultsCheckDomains
, foo
);
1120 wReadDefaults(WScreen
*scr
, proplist_t new_dict
)
1122 proplist_t plvalue
, old_value
;
1123 WDefaultEntry
*entry
;
1125 int update_workspace_back
= 0; /* kluge :/ */
1128 proplist_t old_dict
= (WDWindowMaker
->dictionary
!=new_dict
1129 ? WDWindowMaker
->dictionary
: NULL
);
1135 for (i
=0; i
<sizeof(optionList
)/sizeof(WDefaultEntry
); i
++) {
1136 entry
= &optionList
[i
];
1139 plvalue
= PLGetDictionaryEntry(new_dict
, entry
->plkey
);
1146 old_value
= PLGetDictionaryEntry(old_dict
, entry
->plkey
);
1149 if (!plvalue
&& !old_value
) {
1150 /* no default in the DB. Use builtin default */
1151 plvalue
= entry
->plvalue
;
1152 if (plvalue
&& new_dict
) {
1153 PLInsertDictionaryEntry(new_dict
, entry
->plkey
, plvalue
);
1156 } else if (!plvalue
) {
1157 /* value was deleted from DB. Keep current value */
1159 } else if (!old_value
) {
1160 /* set value for the 1st time */
1161 } else if (!PLIsEqual(plvalue
, old_value
)) {
1162 /* value has changed */
1165 if (strcmp(entry
->key
, "WorkspaceBack") == 0
1166 && update_workspace_back
1167 && scr
->flags
.backimage_helper_launched
) {
1169 /* value was not changed since last time */
1176 printf("Updating %s to %s\n", entry
->key
,
1177 PLGetDescription(plvalue
));
1180 if ((*entry
->convert
)(scr
, entry
, plvalue
, entry
->addr
, &tdata
)) {
1182 * If the WorkspaceSpecificBack data has been changed
1183 * so that the helper will be launched now, we must be
1184 * sure to send the default background texture config
1187 if (strcmp(entry
->key
, "WorkspaceSpecificBack") == 0
1188 && !scr
->flags
.backimage_helper_launched
) {
1189 update_workspace_back
= 1;
1191 if (entry
->update
) {
1193 (*entry
->update
)(scr
, entry
, tdata
, entry
->extra_data
);
1199 if (needs_refresh
!=0 && !scr
->flags
.startup
) {
1203 if (needs_refresh
& REFRESH_MENU_TITLE_TEXTURE
)
1204 foo
|= WTextureSettings
;
1205 if (needs_refresh
& REFRESH_MENU_TITLE_FONT
)
1206 foo
|= WFontSettings
;
1207 if (needs_refresh
& REFRESH_MENU_TITLE_COLOR
)
1208 foo
|= WColorSettings
;
1210 WMPostNotificationName(WNMenuTitleAppearanceSettingsChanged
, NULL
,
1214 if (needs_refresh
& REFRESH_MENU_TEXTURE
)
1215 foo
|= WTextureSettings
;
1216 if (needs_refresh
& REFRESH_MENU_FONT
)
1217 foo
|= WFontSettings
;
1218 if (needs_refresh
& REFRESH_MENU_COLOR
)
1219 foo
|= WColorSettings
;
1221 WMPostNotificationName(WNMenuAppearanceSettingsChanged
, NULL
,
1225 if (needs_refresh
& REFRESH_WINDOW_FONT
) {
1226 foo
|= WFontSettings
;
1228 if (needs_refresh
& REFRESH_WINDOW_TEXTURES
) {
1229 foo
|= WTextureSettings
;
1231 if (needs_refresh
& REFRESH_WINDOW_TITLE_COLOR
) {
1232 foo
|= WColorSettings
;
1235 WMPostNotificationName(WNWindowAppearanceSettingsChanged
, NULL
,
1238 if (!(needs_refresh
& REFRESH_ICON_TILE
)) {
1240 if (needs_refresh
& REFRESH_ICON_FONT
) {
1241 foo
|= WFontSettings
;
1243 if (needs_refresh
& REFRESH_ICON_TITLE_COLOR
) {
1244 foo
|= WTextureSettings
;
1246 if (needs_refresh
& REFRESH_ICON_TITLE_BACK
) {
1247 foo
|= WTextureSettings
;
1250 WMPostNotificationName(WNIconAppearanceSettingsChanged
, NULL
,
1253 if (needs_refresh
& REFRESH_ICON_TILE
)
1254 WMPostNotificationName(WNIconTileSettingsChanged
, NULL
, NULL
);
1260 wDefaultUpdateIcons(WScreen
*scr
)
1262 WAppIcon
*aicon
= scr
->app_icon_list
;
1263 WWindow
*wwin
= scr
->focused_window
;
1267 file
= wDefaultGetIconFile(scr
, aicon
->wm_instance
, aicon
->wm_class
,
1269 if ((file
&& aicon
->icon
->file
&& strcmp(file
, aicon
->icon
->file
)!=0)
1270 || (file
&& !aicon
->icon
->file
)) {
1273 if (aicon
->icon
->file
)
1274 free(aicon
->icon
->file
);
1275 aicon
->icon
->file
= wstrdup(file
);
1277 new_image
= wDefaultGetImage(scr
, aicon
->wm_instance
,
1280 wIconChangeImage(aicon
->icon
, new_image
);
1281 wAppIconPaint(aicon
);
1284 aicon
= aicon
->next
;
1287 if (!wPreferences
.flags
.noclip
)
1288 wClipIconPaint(scr
->clip_icon
);
1291 if (wwin
->icon
&& wwin
->flags
.miniaturized
) {
1292 file
= wDefaultGetIconFile(scr
, wwin
->wm_instance
, wwin
->wm_class
,
1294 if ((file
&& wwin
->icon
->file
&& strcmp(file
, wwin
->icon
->file
)!=0)
1295 || (file
&& !wwin
->icon
->file
)) {
1298 if (wwin
->icon
->file
)
1299 free(wwin
->icon
->file
);
1300 wwin
->icon
->file
= wstrdup(file
);
1302 new_image
= wDefaultGetImage(scr
, wwin
->wm_instance
,
1305 wIconChangeImage(wwin
->icon
, new_image
);
1313 /* --------------------------- Local ----------------------- */
1315 #define GET_STRING_OR_DEFAULT(x, var) if (!PLIsString(value)) { \
1316 wwarning(_("Wrong option format for key \"%s\". Should be %s."), \
1318 wwarning(_("using default \"%s\" instead"), entry->default_value); \
1319 var = entry->default_value;\
1320 } else var = PLGetString(value)\
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
,
1376 GET_STRING_OR_DEFAULT("Boolean", val
);
1379 if ((val
[1]=='\0' && (val
[0]=='y' || val
[0]=='Y'))
1380 || strcasecmp(val
, "YES")==0) {
1383 } else if ((val
[1]=='\0' && (val
[0]=='n' || val
[0]=='N'))
1384 || strcasecmp(val
, "NO")==0) {
1388 if (sscanf(val
, "%i", &i
)==1) {
1394 wwarning(_("can't convert \"%s\" to boolean for key \"%s\""),
1396 if (second_pass
==0) {
1397 val
= PLGetString(entry
->plvalue
);
1399 wwarning(_("using default \"%s\" instead"), val
);
1410 *(char*)addr
= data
;
1418 getInt(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
1425 GET_STRING_OR_DEFAULT("Integer", val
);
1427 if (sscanf(val
, "%i", &data
)!=1) {
1428 wwarning(_("can't convert \"%s\" to integer for key \"%s\""),
1430 val
= PLGetString(entry
->plvalue
);
1431 wwarning(_("using default \"%s\" instead"), val
);
1432 if (sscanf(val
, "%i", &data
)!=1) {
1448 getCoord(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
1452 char *val_x
, *val_y
;
1453 int nelem
, changed
=0;
1454 proplist_t elem_x
, elem_y
;
1457 if (!PLIsArray(value
)) {
1458 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1459 entry
->key
, "Coordinate");
1461 value
= entry
->plvalue
;
1463 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1469 nelem
= PLGetNumberOfElements(value
);
1471 wwarning(_("Incorrect number of elements in array for key \"%s\"."),
1474 value
= entry
->plvalue
;
1476 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1482 elem_x
= PLGetArrayElement(value
, 0);
1483 elem_y
= PLGetArrayElement(value
, 1);
1485 if (!elem_x
|| !elem_y
|| !PLIsString(elem_x
) || !PLIsString(elem_y
)) {
1486 wwarning(_("Wrong value for key \"%s\". Should be Coordinate."),
1489 value
= entry
->plvalue
;
1491 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1497 val_x
= PLGetString(elem_x
);
1498 val_y
= PLGetString(elem_y
);
1500 if (sscanf(val_x
, "%i", &data
.x
)!=1 || sscanf(val_y
, "%i", &data
.y
)!=1) {
1501 wwarning(_("can't convert array to integers for \"%s\"."), entry
->key
);
1503 value
= entry
->plvalue
;
1505 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1513 else if (data
.x
> scr
->scr_width
/3)
1514 data
.x
= scr
->scr_width
/3;
1517 else if (data
.y
> scr
->scr_height
/3)
1518 data
.y
= scr
->scr_height
/3;
1524 *(WCoord
*)addr
= data
;
1532 /* This function is not used at the moment. */
1534 getString(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
1539 GET_STRING_OR_DEFAULT("String", data
);
1542 data
= PLGetString(entry
->plvalue
);
1551 *(char**)addr
= wstrdup(data
);
1559 getPathList(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
1569 if (!PLIsArray(value
)) {
1570 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1571 entry
->key
, "an array of paths");
1573 value
= entry
->plvalue
;
1575 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1582 count
= PLGetNumberOfElements(value
);
1585 value
= entry
->plvalue
;
1587 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1594 for (i
=0; i
<count
; i
++) {
1595 d
= PLGetArrayElement(value
, i
);
1596 if (!d
|| !PLIsString(d
)) {
1600 len
+= strlen(PLGetString(d
))+1;
1603 ptr
= data
= wmalloc(len
+1);
1605 for (i
=0; i
<count
; i
++) {
1606 d
= PLGetArrayElement(value
, i
);
1607 if (!d
|| !PLIsString(d
)) {
1610 strcpy(ptr
, PLGetString(d
));
1611 ptr
+= strlen(PLGetString(d
));
1615 ptr
--; *(ptr
--) = 0;
1617 if (*(char**)addr
!=NULL
) {
1618 free(*(char**)addr
);
1620 *(char**)addr
= data
;
1627 getEnum(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
1630 static signed char data
;
1632 data
= string2index(entry
->plkey
, value
, entry
->default_value
,
1633 (WOptionEnumeration
*)entry
->extra_data
);
1641 *(signed char*)addr
= data
;
1650 * (hgradient <color> <color>)
1651 * (vgradient <color> <color>)
1652 * (dgradient <color> <color>)
1653 * (mhgradient <color> <color> ...)
1654 * (mvgradient <color> <color> ...)
1655 * (tpixmap <file> <color>)
1656 * (spixmap <file> <color>)
1657 * (cpixmap <file> <color>)
1658 * (thgradient <file> <opaqueness> <color> <color>)
1659 * (tvgradient <file> <opaqueness> <color> <color>)
1660 * (tdgradient <file> <opaqueness> <color> <color>)
1661 * (function <lib> <function> ...)
1665 parse_texture(WScreen
*scr
, proplist_t pl
)
1670 WTexture
*texture
=NULL
;
1672 nelem
= PLGetNumberOfElements(pl
);
1677 elem
= PLGetArrayElement(pl
, 0);
1678 if (!elem
|| !PLIsString(elem
))
1680 val
= PLGetString(elem
);
1683 if (strcasecmp(val
, "solid")==0) {
1691 elem
= PLGetArrayElement(pl
, 1);
1692 if (!elem
|| !PLIsString(elem
))
1694 val
= PLGetString(elem
);
1696 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &color
)) {
1697 wwarning(_("\"%s\" is not a valid color name"), val
);
1701 texture
= (WTexture
*)wTextureMakeSolid(scr
, &color
);
1702 } else if (strcasecmp(val
, "dgradient")==0
1703 || strcasecmp(val
, "vgradient")==0
1704 || strcasecmp(val
, "hgradient")==0) {
1705 RColor color1
, color2
;
1710 wwarning(_("bad number of arguments in gradient specification"));
1714 if (val
[0]=='d' || val
[0]=='D')
1715 type
= WTEX_DGRADIENT
;
1716 else if (val
[0]=='h' || val
[0]=='H')
1717 type
= WTEX_HGRADIENT
;
1719 type
= WTEX_VGRADIENT
;
1722 /* get from color */
1723 elem
= PLGetArrayElement(pl
, 1);
1724 if (!elem
|| !PLIsString(elem
))
1726 val
= PLGetString(elem
);
1728 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1729 wwarning(_("\"%s\" is not a valid color name"), val
);
1733 color1
.red
= xcolor
.red
>> 8;
1734 color1
.green
= xcolor
.green
>> 8;
1735 color1
.blue
= xcolor
.blue
>> 8;
1738 elem
= PLGetArrayElement(pl
, 2);
1739 if (!elem
|| !PLIsString(elem
)) {
1742 val
= PLGetString(elem
);
1744 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1745 wwarning(_("\"%s\" is not a valid color name"), val
);
1749 color2
.red
= xcolor
.red
>> 8;
1750 color2
.green
= xcolor
.green
>> 8;
1751 color2
.blue
= xcolor
.blue
>> 8;
1753 texture
= (WTexture
*)wTextureMakeGradient(scr
, type
, &color1
, &color2
);
1755 } else if (strcasecmp(val
, "mhgradient")==0
1756 || strcasecmp(val
, "mvgradient")==0
1757 || strcasecmp(val
, "mdgradient")==0) {
1764 wwarning(_("too few arguments in multicolor gradient specification"));
1768 if (val
[1]=='h' || val
[1]=='H')
1769 type
= WTEX_MHGRADIENT
;
1770 else if (val
[1]=='v' || val
[1]=='V')
1771 type
= WTEX_MVGRADIENT
;
1773 type
= WTEX_MDGRADIENT
;
1777 colors
= wmalloc(sizeof(RColor
*)*(count
+1));
1779 for (i
=0; i
<count
; i
++) {
1780 elem
= PLGetArrayElement(pl
, i
+1);
1781 if (!elem
|| !PLIsString(elem
)) {
1782 for (--i
; i
>=0; --i
) {
1788 val
= PLGetString(elem
);
1790 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &color
)) {
1791 wwarning(_("\"%s\" is not a valid color name"), val
);
1792 for (--i
; i
>=0; --i
) {
1798 colors
[i
] = wmalloc(sizeof(RColor
));
1799 colors
[i
]->red
= color
.red
>> 8;
1800 colors
[i
]->green
= color
.green
>> 8;
1801 colors
[i
]->blue
= color
.blue
>> 8;
1806 texture
= (WTexture
*)wTextureMakeMGradient(scr
, type
, colors
);
1807 } else if (strcasecmp(val
, "spixmap")==0 ||
1808 strcasecmp(val
, "cpixmap")==0 ||
1809 strcasecmp(val
, "tpixmap")==0) {
1816 if (val
[0] == 's' || val
[0] == 'S')
1818 else if (val
[0] == 'c' || val
[0] == 'C')
1824 elem
= PLGetArrayElement(pl
, 2);
1825 if (!elem
|| !PLIsString(elem
)) {
1828 val
= PLGetString(elem
);
1830 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &color
)) {
1831 wwarning(_("\"%s\" is not a valid color name"), val
);
1836 elem
= PLGetArrayElement(pl
, 1);
1837 if (!elem
|| !PLIsString(elem
))
1839 val
= PLGetString(elem
);
1841 texture
= (WTexture
*)wTextureMakePixmap(scr
, type
, val
, &color
);
1842 } else if (strcasecmp(val
, "thgradient")==0
1843 || strcasecmp(val
, "tvgradient")==0
1844 || strcasecmp(val
, "tdgradient")==0) {
1845 RColor color1
, color2
;
1850 if (val
[1]=='h' || val
[1]=='H')
1851 style
= WTEX_THGRADIENT
;
1852 else if (val
[1]=='v' || val
[1]=='V')
1853 style
= WTEX_TVGRADIENT
;
1855 style
= WTEX_TDGRADIENT
;
1858 wwarning(_("bad number of arguments in textured gradient specification"));
1862 /* get from color */
1863 elem
= PLGetArrayElement(pl
, 3);
1864 if (!elem
|| !PLIsString(elem
))
1866 val
= PLGetString(elem
);
1868 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1869 wwarning(_("\"%s\" is not a valid color name"), val
);
1873 color1
.red
= xcolor
.red
>> 8;
1874 color1
.green
= xcolor
.green
>> 8;
1875 color1
.blue
= xcolor
.blue
>> 8;
1878 elem
= PLGetArrayElement(pl
, 4);
1879 if (!elem
|| !PLIsString(elem
)) {
1882 val
= PLGetString(elem
);
1884 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1885 wwarning(_("\"%s\" is not a valid color name"), val
);
1889 color2
.red
= xcolor
.red
>> 8;
1890 color2
.green
= xcolor
.green
>> 8;
1891 color2
.blue
= xcolor
.blue
>> 8;
1894 elem
= PLGetArrayElement(pl
, 2);
1895 if (!elem
|| !PLIsString(elem
))
1898 val
= PLGetString(elem
);
1900 if (!val
|| (opacity
= atoi(val
)) < 0 || opacity
> 255) {
1901 wwarning(_("bad opacity value for tgradient texture \"%s\". Should be [0..255]"), val
);
1906 elem
= PLGetArrayElement(pl
, 1);
1907 if (!elem
|| !PLIsString(elem
))
1909 val
= PLGetString(elem
);
1911 texture
= (WTexture
*)wTextureMakeTGradient(scr
, style
, &color1
, &color2
,
1914 #ifdef TEXTURE_PLUGIN
1915 else if (strcasecmp(val
, "function")==0) {
1916 WTexFunction
*function
;
1917 void (*initFunc
) (Display
*, Colormap
);
1918 char *lib
, *func
, **argv
;
1924 /* get the library name */
1925 elem
= PLGetArrayElement(pl
, 1);
1926 if (!elem
|| !PLIsString(elem
)) {
1929 lib
= PLGetString(elem
);
1931 /* get the function name */
1932 elem
= PLGetArrayElement(pl
, 2);
1933 if (!elem
|| !PLIsString(elem
)) {
1936 func
= PLGetString(elem
);
1939 argv
= (char **)wmalloc(argc
* sizeof(char *));
1941 /* get the parameters */
1942 argv
[0] = wstrdup(func
);
1943 for (i
= 0; i
< argc
- 1; i
++) {
1944 elem
= PLGetArrayElement(pl
, 3 + i
);
1945 if (!elem
|| !PLIsString(elem
)) {
1950 argv
[i
+1] = wstrdup(PLGetString(elem
));
1953 function
= wTextureMakeFunction(scr
, lib
, func
, argc
, argv
);
1957 initFunc
= dlsym(function
->handle
, "initWindowMaker");
1959 initFunc(dpy
, scr
->w_colormap
);
1961 wwarning(_("could not initialize library %s"), lib
);
1964 wwarning(_("could not find function %s::%s"), lib
, func
);
1966 #endif /* HAVE_DLFCN_H */
1967 texture
= (WTexture
*)function
;
1969 #endif /* TEXTURE_PLUGIN */
1971 wwarning(_("invalid texture type %s"), val
);
1980 getTexture(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
1983 static WTexture
*texture
;
1987 if (!PLIsArray(value
)) {
1988 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1989 entry
->key
, "Texture");
1991 value
= entry
->plvalue
;
1993 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1999 if (strcmp(entry
->key
, "WidgetColor")==0 && !changed
) {
2002 pl
= PLGetArrayElement(value
, 0);
2003 if (!pl
|| !PLIsString(pl
) || !PLGetString(pl
)
2004 || strcasecmp(PLGetString(pl
), "solid")!=0) {
2005 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
2006 entry
->key
, "Solid Texture");
2008 value
= entry
->plvalue
;
2010 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
2015 texture
= parse_texture(scr
, value
);
2018 wwarning(_("Error in texture specification for key \"%s\""),
2021 value
= entry
->plvalue
;
2023 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
2033 *(WTexture
**)addr
= texture
;
2040 #ifdef DRAWSTRING_PLUGIN
2042 getTextRenderer(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
,
2043 void *addr
, void **ret
)
2046 char *val
, *lib
, *func
, **argv
;
2049 if (strcmp(entry
->key
, "FTitleColor")==0) {
2050 wPluginDestroyFunction(scr
->drawstring_func
[changed
= W_STRING_FTITLE
]);
2051 scr
->drawstring_func
[W_STRING_FTITLE
] = NULL
;
2052 } else if (strcmp(entry
->key
, "UTitleColor")==0) {
2053 wPluginDestroyFunction(scr
->drawstring_func
[changed
= W_STRING_UTITLE
]);
2054 scr
->drawstring_func
[W_STRING_UTITLE
] = NULL
;
2055 } else if (strcmp(entry
->key
, "PTitleColor")==0) {
2056 wPluginDestroyFunction(scr
->drawstring_func
[changed
= W_STRING_PTITLE
]);
2057 scr
->drawstring_func
[W_STRING_PTITLE
] = NULL
;
2058 } else if (strcmp(entry
->key
, "MenuTitleColor")==0) {
2059 wPluginDestroyFunction(scr
->drawstring_func
[changed
= W_STRING_MTITLE
]);
2060 scr
->drawstring_func
[W_STRING_MTITLE
] = NULL
;
2061 } else if (strcmp(entry
->key
, "MenuPluginColor")==0) {
2062 wPluginDestroyFunction(scr
->drawstring_func
[changed
= W_STRING_MTEXT
]);
2063 scr
->drawstring_func
[W_STRING_MTEXT
] = NULL
;
2066 if (PLIsArray(value
)) {
2067 if ((argc
= PLGetNumberOfElements(value
)) < 4) return False
;
2069 argv
= (char **)wmalloc(argc
* sizeof(char *));
2071 elem
= PLGetArrayElement(value
,0);
2072 if (!elem
|| !PLIsString(elem
)) return False
;
2073 val
= PLGetString(elem
);
2074 if (strcasecmp(val
, "function")==0) {
2075 elem
= PLGetArrayElement(value
, 1); /* library name */
2076 if (!elem
|| !PLIsString(elem
)) return False
;
2077 lib
= PLGetString(elem
);
2078 elem
= PLGetArrayElement(value
, 2); /* function name */
2079 if (!elem
|| !PLIsString(elem
)) return False
;
2080 func
= PLGetString(elem
);
2081 scr
->drawstring_func
[changed
] = wPluginCreateFunction (W_FUNCTION_DRAWSTRING
,
2082 lib
, "initDrawString", func
, NULL
, value
,
2083 wPluginPackInitData(3, dpy
, scr
->w_colormap
,"-DATA-"));
2086 return getColor(scr
, entry
, PLGetArrayElement(value
,3), addr
, ret
);
2087 } else if (PLIsString(value
)) {
2088 return getColor(scr
, entry
, value
, addr
, ret
);
2093 #endif /* DRAWSTRING_PLUGIN */
2098 getWSBackground(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
,
2099 void *addr
, void **ret
)
2107 if (!PLIsArray(value
)) {
2108 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
2109 "WorkspaceBack", "Texture or None");
2111 value
= entry
->plvalue
;
2113 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
2119 /* only do basic error checking and verify for None texture */
2121 nelem
= PLGetNumberOfElements(value
);
2123 elem
= PLGetArrayElement(value
, 0);
2124 if (!elem
|| !PLIsString(elem
)) {
2125 wwarning(_("Wrong type for workspace background. Should be a texture type."));
2127 value
= entry
->plvalue
;
2129 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
2134 val
= PLGetString(elem
);
2136 if (strcasecmp(val
, "None")==0)
2139 *ret
= PLRetain(value
);
2146 getWSSpecificBackground(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
,
2147 void *addr
, void **ret
)
2154 if (!PLIsArray(value
)) {
2155 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
2156 "WorkspaceSpecificBack", "an array of textures");
2158 value
= entry
->plvalue
;
2160 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
2166 /* only do basic error checking and verify for None texture */
2168 nelem
= PLGetNumberOfElements(value
);
2171 elem
= PLGetArrayElement(value
, nelem
);
2172 if (!elem
|| !PLIsArray(elem
)) {
2173 wwarning(_("Wrong type for background of workspace %i. Should be a texture."),
2179 *ret
= PLRetain(value
);
2183 * Kluge to force wmsetbg helper to set the default background.
2184 * If the WorkspaceSpecificBack is changed once wmaker has started,
2185 * the WorkspaceBack won't be sent to the helper, unless the user
2186 * changes it's value too. So, we must force this by removing the
2187 * value from the defaults DB.
2189 if (!scr
->flags
.backimage_helper_launched
&& !scr
->flags
.startup
) {
2190 proplist_t key
= PLMakeString("WorkspaceBack");
2192 PLRemoveDictionaryEntry(WDWindowMaker
->dictionary
, key
);
2202 getFont(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
2205 static WMFont
*font
;
2208 GET_STRING_OR_DEFAULT("Font", val
);
2210 font
= WMCreateFont(scr
->wmscreen
, val
);
2212 font
= WMCreateFont(scr
->wmscreen
, "fixed");
2215 wfatal(_("could not load any usable font!!!"));
2222 /* can't assign font value outside update function */
2223 wassertrv(addr
== NULL
, True
);
2230 getColor(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
2233 static XColor color
;
2237 GET_STRING_OR_DEFAULT("Color", val
);
2241 if (!wGetColor(scr
, val
, &color
)) {
2242 wwarning(_("could not get color for key \"%s\""),
2244 if (second_pass
==0) {
2245 val
= PLGetString(entry
->plvalue
);
2247 wwarning(_("using default \"%s\" instead"), val
);
2259 *(unsigned long*)addr = pixel;
2268 getKeybind(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
2271 static WShortKey shortcut
;
2278 GET_STRING_OR_DEFAULT("Key spec", val
);
2280 if (!val
|| strcasecmp(val
, "NONE")==0) {
2281 shortcut
.keycode
= 0;
2282 shortcut
.modifier
= 0;
2293 shortcut
.modifier
= 0;
2294 while ((k
= strchr(b
, '+'))!=NULL
) {
2298 mod
= wXModifierFromKey(b
);
2300 wwarning(_("%s:invalid key modifier \"%s\""), entry
->key
, b
);
2303 shortcut
.modifier
|= mod
;
2309 ksym
= XStringToKeysym(b
);
2311 if (ksym
==NoSymbol
) {
2312 wwarning(_("%s:invalid kbd shortcut specification \"%s\""), entry
->key
,
2317 shortcut
.keycode
= XKeysymToKeycode(dpy
, ksym
);
2318 if (shortcut
.keycode
==0) {
2319 wwarning(_("%s:invalid key in shortcut \"%s\""), entry
->key
, val
);
2331 getModMask(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
2334 static unsigned int mask
;
2337 GET_STRING_OR_DEFAULT("Modifier Key", str
);
2342 mask
= wXModifierFromKey(str
);
2344 wwarning(_("%s: modifier key %s is not valid"), entry
->key
, str
);
2350 *(unsigned int*)addr
= mask
;
2361 getRImages(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
,
2362 void *addr
, void **ret
)
2370 GET_STRING_OR_DEFAULT("Image File Path", str
);
2374 image
= RLoadImage(scr
->rcontext
, str
, 0);
2376 wwarning(_("could not load image in option %s: %s"), entry
->key
,
2377 RMessageForError(RErrorCode
));
2381 if (*(RImage
**)addr
) {
2382 RDestroyImage(*(RImage
**)addr
);
2385 *(RImage
**)addr
= image
;
2387 assert(ret
== NULL
);
2390 *(RImage**)ret = image;
2398 /* ---------------- value setting functions --------------- */
2400 setJustify(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
2402 return REFRESH_WINDOW_TITLE_COLOR
;
2407 setIfDockPresent(WScreen
*scr
, WDefaultEntry
*entry
, int *flag
, long which
)
2411 wPreferences
.flags
.nodock
= wPreferences
.flags
.nodock
|| *flag
;
2414 wPreferences
.flags
.noclip
= wPreferences
.flags
.noclip
|| *flag
;
2424 setStickyIcons(WScreen
*scr
, WDefaultEntry
*entry
, void *bar
, void *foo
)
2426 if (scr
->workspaces
) {
2427 wWorkspaceForceChange(scr
, scr
->current_workspace
);
2428 wArrangeIcons(scr
, False
);
2435 setPositive(WScreen
*scr
, WDefaultEntry
*entry
, int *value
, void *foo
)
2447 setIconTile(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
2453 img
= wTextureRenderImage(*texture
, wPreferences
.icon_size
,
2454 wPreferences
.icon_size
,
2455 ((*texture
)->any
.type
& WREL_BORDER_MASK
)
2456 ? WREL_ICON
: WREL_FLAT
);
2458 wwarning(_("could not render texture for icon background"));
2460 wTextureDestroy(scr
, *texture
);
2463 RConvertImage(scr
->rcontext
, img
, &pixmap
);
2465 if (scr
->icon_tile
) {
2467 RDestroyImage(scr
->icon_tile
);
2468 XFreePixmap(dpy
, scr
->icon_tile_pixmap
);
2471 scr
->icon_tile
= img
;
2473 if (!wPreferences
.flags
.noclip
) {
2474 if (scr
->clip_tile
) {
2475 RDestroyImage(scr
->clip_tile
);
2477 scr
->clip_tile
= wClipMakeTile(scr
, img
);
2480 scr
->icon_tile_pixmap
= pixmap
;
2482 if (scr
->def_icon_pixmap
) {
2483 XFreePixmap(dpy
, scr
->def_icon_pixmap
);
2484 scr
->def_icon_pixmap
= None
;
2486 if (scr
->def_ticon_pixmap
) {
2487 XFreePixmap(dpy
, scr
->def_ticon_pixmap
);
2488 scr
->def_ticon_pixmap
= None
;
2491 if (scr
->icon_back_texture
) {
2492 wTextureDestroy(scr
, (WTexture
*)scr
->icon_back_texture
);
2494 scr
->icon_back_texture
= wTextureMakeSolid(scr
, &((*texture
)->any
.color
));
2496 if (scr
->clip_balloon
)
2497 XSetWindowBackground(dpy
, scr
->clip_balloon
,
2498 (*texture
)->any
.color
.pixel
);
2501 * Free the texture as nobody else will use it, nor refer to it.
2504 wTextureDestroy(scr
, *texture
);
2506 return (reset
? REFRESH_ICON_TILE
: 0);
2512 setWinTitleFont(WScreen
*scr
, WDefaultEntry
*entry
, WMFont
*font
, void *foo
)
2514 if (scr
->title_font
) {
2515 WMReleaseFont(scr
->title_font
);
2517 scr
->title_font
= font
;
2519 return REFRESH_WINDOW_FONT
|REFRESH_BUTTON_IMAGES
;
2524 setMenuTitleFont(WScreen
*scr
, WDefaultEntry
*entry
, WMFont
*font
, void *foo
)
2526 if (scr
->menu_title_font
) {
2527 WMReleaseFont(scr
->menu_title_font
);
2530 scr
->menu_title_font
= font
;
2532 return REFRESH_MENU_TITLE_FONT
;
2537 setMenuTextFont(WScreen
*scr
, WDefaultEntry
*entry
, WMFont
*font
, void *foo
)
2539 if (scr
->menu_entry_font
) {
2540 WMReleaseFont(scr
->menu_entry_font
);
2542 scr
->menu_entry_font
= font
;
2544 return REFRESH_MENU_FONT
;
2550 setIconTitleFont(WScreen
*scr
, WDefaultEntry
*entry
, WMFont
*font
, void *foo
)
2552 if (scr
->icon_title_font
) {
2553 WMReleaseFont(scr
->icon_title_font
);
2556 scr
->icon_title_font
= font
;
2558 return REFRESH_ICON_FONT
;
2563 setClipTitleFont(WScreen
*scr
, WDefaultEntry
*entry
, WMFont
*font
, void *foo
)
2565 if (scr
->clip_title_font
) {
2566 WMReleaseFont(scr
->clip_title_font
);
2569 scr
->clip_title_font
= font
;
2571 return REFRESH_ICON_FONT
;
2576 setLargeDisplayFont(WScreen
*scr
, WDefaultEntry
*entry
, WMFont
*font
, void *foo
)
2578 if (scr
->workspace_name_font
) {
2579 WMReleaseFont(scr
->workspace_name_font
);
2582 scr
->workspace_name_font
= font
;
2589 setHightlight(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, void *foo
)
2591 if (scr
->select_pixel
!=scr
->white_pixel
&&
2592 scr
->select_pixel
!=scr
->black_pixel
) {
2593 wFreeColor(scr
, scr
->select_pixel
);
2596 scr
->select_pixel
= color
->pixel
;
2598 return REFRESH_MENU_COLOR
;
2603 setHightlightText(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, void *foo
)
2605 if (scr
->select_text_pixel
!=scr
->white_pixel
&&
2606 scr
->select_text_pixel
!=scr
->black_pixel
) {
2607 wFreeColor(scr
, scr
->select_text_pixel
);
2610 scr
->select_text_pixel
= color
->pixel
;
2612 return REFRESH_MENU_COLOR
;
2617 setClipTitleColor(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, long index
)
2619 if (scr
->clip_title_pixel
[index
]!=scr
->white_pixel
&&
2620 scr
->clip_title_pixel
[index
]!=scr
->black_pixel
) {
2621 wFreeColor(scr
, scr
->clip_title_pixel
[index
]);
2623 scr
->clip_title_pixel
[index
] = color
->pixel
;
2625 #ifdef GRADIENT_CLIP_ARROW
2626 if (index
== CLIP_NORMAL
) {
2628 RColor color1
, color2
;
2629 int pt
= CLIP_BUTTON_SIZE
*wPreferences
.icon_size
/64;
2630 int as
= pt
- 15; /* 15 = 5+5+5 */
2632 FREE_PIXMAP(scr
->clip_arrow_gradient
);
2634 color1
.red
= (color
->red
>> 8)*6/10;
2635 color1
.green
= (color
->green
>> 8)*6/10;
2636 color1
.blue
= (color
->blue
>> 8)*6/10;
2638 color2
.red
= WMIN((color
->red
>> 8)*20/10, 255);
2639 color2
.green
= WMIN((color
->green
>> 8)*20/10, 255);
2640 color2
.blue
= WMIN((color
->blue
>> 8)*20/10, 255);
2642 image
= RRenderGradient(as
+1, as
+1, &color1
, &color2
, RDiagonalGradient
);
2643 RConvertImage(scr
->rcontext
, image
, &scr
->clip_arrow_gradient
);
2644 RDestroyImage(image
);
2646 #endif /* GRADIENT_CLIP_ARROW */
2648 return REFRESH_ICON_TITLE_COLOR
;
2653 setWTitleColor(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, long index
)
2655 if (scr
->window_title_pixel
[index
]!=scr
->white_pixel
&&
2656 scr
->window_title_pixel
[index
]!=scr
->black_pixel
) {
2657 wFreeColor(scr
, scr
->window_title_pixel
[index
]);
2660 scr
->window_title_pixel
[index
] = color
->pixel
;
2662 if (index
== WS_UNFOCUSED
)
2663 XSetForeground(dpy
, scr
->info_text_gc
, color
->pixel
);
2665 return REFRESH_WINDOW_TITLE_COLOR
;
2670 setMenuTitleColor(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, long index
)
2672 if (scr
->menu_title_pixel
[0]!=scr
->white_pixel
&&
2673 scr
->menu_title_pixel
[0]!=scr
->black_pixel
) {
2674 #ifdef DRAWSTRING_PLUGIN
2675 if(!scr
->drawstring_func
[W_STRING_MTITLE
])
2677 wFreeColor(scr
, scr
->menu_title_pixel
[0]);
2680 scr
->menu_title_pixel
[0] = color
->pixel
;
2681 XSetForeground(dpy
, scr
->menu_title_gc
, color
->pixel
);
2683 return REFRESH_MENU_TITLE_COLOR
;
2688 setMenuTextColor(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, void *foo
)
2691 #define gcm (GCForeground|GCBackground|GCFillStyle)
2693 if (scr
->mtext_pixel
!=scr
->white_pixel
&&
2694 scr
->mtext_pixel
!=scr
->black_pixel
) {
2695 wFreeColor(scr
, scr
->mtext_pixel
);
2698 scr
->mtext_pixel
= color
->pixel
;
2700 XSetForeground(dpy
, scr
->menu_entry_gc
, color
->pixel
);
2703 if (scr
->dtext_pixel
== scr
->mtext_pixel
) {
2704 gcv
.foreground
= scr
->white_pixel
;
2705 gcv
.background
= scr
->black_pixel
;
2706 gcv
.fill_style
= FillStippled
;
2708 gcv
.foreground
= scr
->dtext_pixel
;
2709 gcv
.fill_style
= FillSolid
;
2711 XChangeGC(dpy
, scr
->disabled_menu_entry_gc
, gcm
, &gcv
);
2713 return REFRESH_MENU_COLOR
;
2719 setMenuDisabledColor(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, void *foo
)
2722 #define gcm (GCForeground|GCBackground|GCFillStyle)
2724 if (scr
->dtext_pixel
!=scr
->white_pixel
&&
2725 scr
->dtext_pixel
!=scr
->black_pixel
) {
2726 wFreeColor(scr
, scr
->dtext_pixel
);
2729 scr
->dtext_pixel
= color
->pixel
;
2731 if (scr
->dtext_pixel
== scr
->mtext_pixel
) {
2732 gcv
.foreground
= scr
->white_pixel
;
2733 gcv
.background
= scr
->black_pixel
;
2734 gcv
.fill_style
= FillStippled
;
2736 gcv
.foreground
= scr
->dtext_pixel
;
2737 gcv
.fill_style
= FillSolid
;
2739 XChangeGC(dpy
, scr
->disabled_menu_entry_gc
, gcm
, &gcv
);
2741 return REFRESH_MENU_COLOR
;
2746 setIconTitleColor(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, void *foo
)
2748 XSetForeground(dpy
, scr
->icon_title_gc
, color
->pixel
);
2750 return REFRESH_ICON_TITLE_COLOR
;
2755 setIconTitleBack(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, void *foo
)
2757 if (scr
->icon_title_texture
) {
2758 wTextureDestroy(scr
, (WTexture
*)scr
->icon_title_texture
);
2760 XQueryColor (dpy
, scr
->w_colormap
, color
);
2761 scr
->icon_title_texture
= wTextureMakeSolid(scr
, color
);
2763 return REFRESH_ICON_TITLE_BACK
;
2768 trackDeadProcess(pid_t pid
, unsigned char status
, WScreen
*scr
)
2770 close(scr
->helper_fd
);
2772 scr
->helper_pid
= 0;
2773 scr
->flags
.backimage_helper_launched
= 0;
2778 setWorkspaceSpecificBack(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
,
2785 if (scr
->flags
.backimage_helper_launched
) {
2786 if (PLGetNumberOfElements(value
)==0) {
2787 SendHelperMessage(scr
, 'C', 0, NULL
);
2788 SendHelperMessage(scr
, 'K', 0, NULL
);
2797 if (PLGetNumberOfElements(value
) == 0)
2800 if (pipe(filedes
) < 0) {
2801 wsyserror("pipe() failed:can't set workspace specific background image");
2809 wsyserror("fork() failed:can't set workspace specific background image");
2810 if (close(filedes
[0]) < 0)
2811 wsyserror("could not close pipe");
2812 if (close(filedes
[1]) < 0)
2813 wsyserror("could not close pipe");
2815 } else if (pid
== 0) {
2816 SetupEnvironment(scr
);
2819 wsyserror("could not close pipe");
2820 if (dup(filedes
[0]) < 0) {
2821 wsyserror("dup() failed:can't set workspace specific background image");
2823 if (wPreferences
.smooth_workspace_back
)
2824 execlp("wmsetbg", "wmsetbg", "-helper", "-S", "-d", NULL
);
2826 execlp("wmsetbg", "wmsetbg", "-helper", "-d", NULL
);
2827 wsyserror("could not execute wmsetbg");
2831 if (fcntl(filedes
[0], F_SETFD
, FD_CLOEXEC
) < 0) {
2832 wsyserror("error setting close-on-exec flag");
2834 if (fcntl(filedes
[1], F_SETFD
, FD_CLOEXEC
) < 0) {
2835 wsyserror("error setting close-on-exec flag");
2838 scr
->helper_fd
= filedes
[1];
2839 scr
->helper_pid
= pid
;
2840 scr
->flags
.backimage_helper_launched
= 1;
2842 wAddDeathHandler(pid
, (WDeathHandler
*)trackDeadProcess
, scr
);
2844 SendHelperMessage(scr
, 'P', -1, wPreferences
.pixmap_path
);
2849 for (i
= 0; i
< PLGetNumberOfElements(value
); i
++) {
2850 val
= PLGetArrayElement(value
, i
);
2851 if (val
&& PLIsArray(val
) && PLGetNumberOfElements(val
)>0) {
2852 str
= PLGetDescription(val
);
2854 SendHelperMessage(scr
, 'S', i
+1, str
);
2858 SendHelperMessage(scr
, 'U', i
+1, NULL
);
2869 setWorkspaceBack(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
,
2872 if (scr
->flags
.backimage_helper_launched
) {
2875 if (PLGetNumberOfElements(value
)==0) {
2876 SendHelperMessage(scr
, 'U', 0, NULL
);
2878 /* set the default workspace background to this one */
2879 str
= PLGetDescription(value
);
2881 SendHelperMessage(scr
, 'S', 0, str
);
2883 SendHelperMessage(scr
, 'C', scr
->current_workspace
+1, NULL
);
2885 SendHelperMessage(scr
, 'U', 0, NULL
);
2892 SetupEnvironment(scr
);
2893 text
= PLGetDescription(value
);
2894 command
= wmalloc(strlen(text
)+40);
2895 if (wPreferences
.smooth_workspace_back
)
2896 sprintf(command
, "wmsetbg -d -S -p '%s' &", text
);
2898 sprintf(command
, "wmsetbg -d -p '%s' &", text
);
2910 setWidgetColor(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
2912 if (scr
->widget_texture
) {
2913 wTextureDestroy(scr
, (WTexture
*)scr
->widget_texture
);
2915 scr
->widget_texture
= *(WTexSolid
**)texture
;
2922 setFTitleBack(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
2924 if (scr
->window_title_texture
[WS_FOCUSED
]) {
2925 wTextureDestroy(scr
, scr
->window_title_texture
[WS_FOCUSED
]);
2927 scr
->window_title_texture
[WS_FOCUSED
] = *texture
;
2929 return REFRESH_WINDOW_TEXTURES
;
2934 setPTitleBack(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
2936 if (scr
->window_title_texture
[WS_PFOCUSED
]) {
2937 wTextureDestroy(scr
, scr
->window_title_texture
[WS_PFOCUSED
]);
2939 scr
->window_title_texture
[WS_PFOCUSED
] = *texture
;
2941 return REFRESH_WINDOW_TEXTURES
;
2946 setUTitleBack(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
2948 if (scr
->window_title_texture
[WS_UNFOCUSED
]) {
2949 wTextureDestroy(scr
, scr
->window_title_texture
[WS_UNFOCUSED
]);
2951 scr
->window_title_texture
[WS_UNFOCUSED
] = *texture
;
2953 return REFRESH_WINDOW_TEXTURES
;
2958 setResizebarBack(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
2960 if (scr
->resizebar_texture
[0]) {
2961 wTextureDestroy(scr
, scr
->resizebar_texture
[0]);
2963 scr
->resizebar_texture
[0] = *texture
;
2965 return REFRESH_WINDOW_TEXTURES
;
2970 setMenuTitleBack(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
2972 if (scr
->menu_title_texture
[0]) {
2973 wTextureDestroy(scr
, scr
->menu_title_texture
[0]);
2975 scr
->menu_title_texture
[0] = *texture
;
2977 return REFRESH_MENU_TITLE_TEXTURE
;
2982 setMenuTextBack(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
2984 if (scr
->menu_item_texture
) {
2985 wTextureDestroy(scr
, scr
->menu_item_texture
);
2986 wTextureDestroy(scr
, (WTexture
*)scr
->menu_item_auxtexture
);
2988 scr
->menu_item_texture
= *texture
;
2990 scr
->menu_item_auxtexture
2991 = wTextureMakeSolid(scr
, &scr
->menu_item_texture
->any
.color
);
2993 return REFRESH_MENU_TEXTURE
;
2998 setKeyGrab(WScreen
*scr
, WDefaultEntry
*entry
, WShortKey
*shortcut
, long index
)
3001 wKeyBindings
[index
] = *shortcut
;
3003 wwin
= scr
->focused_window
;
3005 while (wwin
!=NULL
) {
3006 XUngrabKey(dpy
, AnyKey
, AnyModifier
, wwin
->frame
->core
->window
);
3008 if (!WFLAGP(wwin
, no_bind_keys
)) {
3009 wWindowSetKeyGrabs(wwin
);
3019 setIconPosition(WScreen
*scr
, WDefaultEntry
*entry
, void *bar
, void *foo
)
3021 wArrangeIcons(scr
, True
);
3028 updateUsableArea(WScreen
*scr
, WDefaultEntry
*entry
, void *bar
, void *foo
)
3030 wScreenUpdateUsableArea(scr
);
3037 setMenuStyle(WScreen
*scr
, WDefaultEntry
*entry
, int *value
, void *foo
)
3039 return REFRESH_MENU_TEXTURE
;
3045 setButtonImages(WScreen *scr, WDefaultEntry *entry, int *value, void *foo)
3047 return REFRESH_BUTTON_IMAGES;
3053 * Need access to the double click variables, so that all widgets in
3054 * wmaker panels will have the same dbl-click values.
3055 * TODO: figure a better way of dealing with it.
3060 setDoubleClick(WScreen
*scr
, WDefaultEntry
*entry
, int *value
, void *foo
)
3062 extern _WINGsConfiguration WINGsConfiguration
;
3067 WINGsConfiguration
.doubleClickDelay
= *value
;
3075 setMultiByte(WScreen
*scr
, WDefaultEntry
*entry
, int *value
, void *foo
)
3077 extern _WINGsConfiguration WINGsConfiguration
;
3079 WINGsConfiguration
.useMultiByte
= *value
;