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 setClearance();
145 static int setIfDockPresent();
146 static int setStickyIcons();
148 static int setPositive();
150 static int setWidgetColor();
151 static int setIconTile();
152 static int setWinTitleFont();
153 static int setMenuTitleFont();
154 static int setMenuTextFont();
155 static int setIconTitleFont();
156 static int setIconTitleColor();
157 static int setIconTitleBack();
158 static int setDisplayFont();
159 static int setLargeDisplayFont();
160 static int setWTitleColor();
161 static int setFTitleBack();
162 static int setPTitleBack();
163 static int setUTitleBack();
164 static int setResizebarBack();
165 static int setWorkspaceBack();
166 static int setWorkspaceSpecificBack();
167 static int setMenuTitleColor();
168 static int setMenuTextColor();
169 static int setMenuDisabledColor();
170 static int setMenuTitleBack();
171 static int setMenuTextBack();
172 static int setHightlight();
173 static int setHightlightText();
174 static int setKeyGrab();
175 static int setDoubleClick();
176 static int setIconPosition();
178 static int setClipTitleFont();
179 static int setClipTitleColor();
181 static int setMenuStyle();
182 static int setMultiByte();
184 static int updateUsableArea();
189 * Tables to convert strings to enumeration values.
190 * Values stored are char
194 /* WARNING: sum of length of all value strings must not exceed
196 #define TOTAL_VALUES_LENGTH 80
201 #define REFRESH_WINDOW_TEXTURES (1<<0)
202 #define REFRESH_MENU_TEXTURE (1<<1)
203 #define REFRESH_MENU_FONT (1<<2)
204 #define REFRESH_MENU_COLOR (1<<3)
205 #define REFRESH_MENU_TITLE_TEXTURE (1<<4)
206 #define REFRESH_MENU_TITLE_FONT (1<<5)
207 #define REFRESH_MENU_TITLE_COLOR (1<<6)
208 #define REFRESH_WINDOW_TITLE_COLOR (1<<7)
209 #define REFRESH_WINDOW_FONT (1<<8)
210 #define REFRESH_ICON_TILE (1<<9)
211 #define REFRESH_ICON_FONT (1<<10)
212 #define REFRESH_WORKSPACE_BACK (1<<11)
214 #define REFRESH_BUTTON_IMAGES (1<<12)
216 #define REFRESH_ICON_TITLE_COLOR (1<<13)
217 #define REFRESH_ICON_TITLE_BACK (1<<14)
221 static WOptionEnumeration seFocusModes
[] = {
222 {"Manual", WKF_CLICK
, 0}, {"ClickToFocus", WKF_CLICK
, 1},
223 {"Auto", WKF_POINTER
, 0}, {"FocusFollowMouse", WKF_POINTER
, 1},
224 {"Sloppy", WKF_SLOPPY
, 0}, {"SemiAuto", WKF_SLOPPY
, 1},
228 static WOptionEnumeration seColormapModes
[] = {
229 {"Manual", WKF_CLICK
, 0}, {"ClickToFocus", WKF_CLICK
, 1},
230 {"Auto", WKF_POINTER
, 0}, {"FocusFollowMouse", WKF_POINTER
, 1},
234 static WOptionEnumeration sePlacements
[] = {
235 {"Auto", WPM_AUTO
, 0},
236 {"Smart", WPM_SMART
, 0},
237 {"Cascade", WPM_CASCADE
, 0},
238 {"Random", WPM_RANDOM
, 0},
239 {"Manual", WPM_MANUAL
, 0},
243 static WOptionEnumeration seGeomDisplays
[] = {
244 {"Center", WDIS_CENTER
, 0},
245 {"Corner", WDIS_TOPLEFT
, 0},
246 {"Floating", WDIS_FRAME_CENTER
, 0},
247 {"Line", WDIS_NEW
, 0},
251 static WOptionEnumeration seSpeeds
[] = {
252 {"UltraFast", SPEED_ULTRAFAST
, 0},
253 {"Fast", SPEED_FAST
, 0},
254 {"Medium", SPEED_MEDIUM
, 0},
255 {"Slow", SPEED_SLOW
, 0},
256 {"UltraSlow", SPEED_ULTRASLOW
, 0},
260 static WOptionEnumeration seMouseButtons
[] = {
262 {"Left", Button1
, 0}, {"Button1", Button1
, 1},
263 {"Middle", Button2
, 0}, {"Button2", Button2
, 1},
264 {"Right", Button3
, 0}, {"Button3", Button3
, 1},
265 {"Button4", Button4
, 0},
266 {"Button5", Button5
, 0},
270 static WOptionEnumeration seIconificationStyles
[] = {
271 {"Zoom", WIS_ZOOM
, 0},
272 {"Twist", WIS_TWIST
, 0},
273 {"Flip", WIS_FLIP
, 0},
274 {"None", WIS_NONE
, 0},
275 {"random", WIS_RANDOM
, 0},
279 static WOptionEnumeration seJustifications
[] = {
280 {"Left", WTJ_LEFT
, 0},
281 {"Center", WTJ_CENTER
, 0},
282 {"Right", WTJ_RIGHT
, 0},
286 static WOptionEnumeration seIconPositions
[] = {
287 {"blv", IY_BOTTOM
|IY_LEFT
|IY_VERT
, 0},
288 {"blh", IY_BOTTOM
|IY_LEFT
|IY_HORIZ
, 0},
289 {"brv", IY_BOTTOM
|IY_RIGHT
|IY_VERT
, 0},
290 {"brh", IY_BOTTOM
|IY_RIGHT
|IY_HORIZ
, 0},
291 {"tlv", IY_TOP
|IY_LEFT
|IY_VERT
, 0},
292 {"tlh", IY_TOP
|IY_LEFT
|IY_HORIZ
, 0},
293 {"trv", IY_TOP
|IY_RIGHT
|IY_VERT
, 0},
294 {"trh", IY_TOP
|IY_RIGHT
|IY_HORIZ
, 0},
298 static WOptionEnumeration seMenuStyles
[] = {
299 {"normal", MS_NORMAL
, 0},
300 {"singletexture", MS_SINGLE_TEXTURE
, 0},
301 {"flat", MS_FLAT
, 0},
306 static WOptionEnumeration seDisplayPositions
[] = {
307 {"none", WD_NONE
, 0},
308 {"center", WD_CENTER
, 0},
310 {"bottom", WD_BOTTOM
, 0},
311 {"topleft", WD_TOPLEFT
, 0},
312 {"topright", WD_TOPRIGHT
, 0},
313 {"bottomleft", WD_BOTTOMLEFT
, 0},
314 {"bottomright", WD_BOTTOMRIGHT
, 0}
319 * ALL entries in the tables bellow, NEED to have a default value
320 * defined, and this value needs to be correct.
323 /* these options will only affect the window manager on startup
325 * static defaults can't access the screen data, because it is
326 * created after these defaults are read
328 WDefaultEntry staticOptionList
[] = {
330 {"DisableDithering", "NO", NULL
,
331 &wPreferences
.no_dithering
, getBool
, NULL
333 {"ColormapSize", "4", NULL
,
334 &wPreferences
.cmap_size
, getInt
, NULL
336 /* static by laziness */
337 {"IconSize", "64", NULL
,
338 &wPreferences
.icon_size
, getInt
, NULL
340 {"ModifierKey", "Mod1", NULL
,
341 &wPreferences
.modifier_mask
, getModMask
, NULL
343 {"DisableWSMouseActions", "NO", NULL
,
344 &wPreferences
.disable_root_mouse
, getBool
, NULL
346 {"FocusMode", "manual", seFocusModes
,
347 &wPreferences
.focus_mode
, getEnum
, NULL
348 }, /* have a problem when switching from manual to sloppy without restart */
349 {"NewStyle", "NO", NULL
,
350 &wPreferences
.new_style
, getBool
, NULL
352 {"DisableDock", "NO", (void*) WM_DOCK
,
353 NULL
, getBool
, setIfDockPresent
355 {"DisableClip", "NO", (void*) WM_CLIP
,
356 NULL
, getBool
, setIfDockPresent
358 {"DisableMiniwindows", "NO", NULL
,
359 &wPreferences
.disable_miniwindows
, getBool
, NULL
361 {"MultiByteText", "NO", NULL
,
362 &wPreferences
.multi_byte_text
, getBool
, setMultiByte
368 WDefaultEntry optionList
[] = {
369 /* dynamic options */
370 {"IconPosition", "blh", seIconPositions
,
371 &wPreferences
.icon_yard
, getEnum
, setIconPosition
373 {"IconificationStyle", "Zoom", seIconificationStyles
,
374 &wPreferences
.iconification_style
, getEnum
, NULL
376 {"SelectWindowsMouseButton", "Left", seMouseButtons
,
377 &wPreferences
.select_button
, getEnum
, NULL
379 {"WindowListMouseButton", "Middle", seMouseButtons
,
380 &wPreferences
.windowl_button
, getEnum
, NULL
382 {"ApplicationMenuMouseButton", "Right", seMouseButtons
,
383 &wPreferences
.menu_button
, getEnum
, NULL
385 {"PixmapPath", DEF_PIXMAP_PATHS
, NULL
,
386 &wPreferences
.pixmap_path
, getPathList
, NULL
388 {"IconPath", DEF_ICON_PATHS
, NULL
,
389 &wPreferences
.icon_path
, getPathList
, NULL
391 {"ColormapMode", "auto", seColormapModes
,
392 &wPreferences
.colormap_mode
, getEnum
, NULL
394 {"AutoFocus", "NO", NULL
,
395 &wPreferences
.auto_focus
, getBool
, NULL
397 {"RaiseDelay", "0", NULL
,
398 &wPreferences
.raise_delay
, getInt
, NULL
400 {"CirculateRaise", "NO", NULL
,
401 &wPreferences
.circ_raise
, getBool
, NULL
403 {"Superfluous", "NO", NULL
,
404 &wPreferences
.superfluous
, getBool
, NULL
406 {"AdvanceToNewWorkspace", "NO", NULL
,
407 &wPreferences
.ws_advance
, getBool
, NULL
409 {"CycleWorkspaces", "NO", NULL
,
410 &wPreferences
.ws_cycle
, getBool
, NULL
412 {"WorkspaceNameDisplayPosition", "center", seDisplayPositions
,
413 &wPreferences
.workspace_name_display_position
, getEnum
, NULL
415 #ifdef VIRTUAL_DESKTOP
416 {"VirtualEdgeThickness", "1", NULL
,
417 &wPreferences
.vedge_thickness
, getInt
, NULL
419 {"VirtualEdgeHorizonScrollSpeed", "1", NULL
,
420 &wPreferences
.vedge_hscrollspeed
, getInt
, NULL
422 {"VirtualEdgeVerticalScrollSpeed", "1", NULL
,
423 &wPreferences
.vedge_vscrollspeed
, getInt
, NULL
425 {"VirtualEdgeWidth", "2000", NULL
,
426 &wPreferences
.vedge_width
, getInt
, NULL
428 {"VirtualEdgeHeight", "2000", NULL
,
429 &wPreferences
.vedge_height
, getInt
, NULL
432 {"StickyIcons", "NO", NULL
,
433 &wPreferences
.sticky_icons
, getBool
, setStickyIcons
435 {"SaveSessionOnExit", "NO", NULL
,
436 &wPreferences
.save_session_on_exit
, getBool
, NULL
438 {"WrapMenus", "NO", NULL
,
439 &wPreferences
.wrap_menus
, getBool
, NULL
441 {"ScrollableMenus", "NO", NULL
,
442 &wPreferences
.scrollable_menus
, getBool
, NULL
444 {"MenuScrollSpeed", "medium", seSpeeds
,
445 &wPreferences
.menu_scroll_speed
, getEnum
, NULL
447 {"IconSlideSpeed", "medium", seSpeeds
,
448 &wPreferences
.icon_slide_speed
, getEnum
, NULL
450 {"ShadeSpeed", "medium", seSpeeds
,
451 &wPreferences
.shade_speed
, getEnum
, NULL
453 {"DoubleClickTime", "250", (void*) &wPreferences
.dblclick_time
,
454 &wPreferences
.dblclick_time
, getInt
, setDoubleClick
,
456 {"AlignSubmenus", "NO", NULL
,
457 &wPreferences
.align_menus
, getBool
, NULL
459 {"OpenTransientOnOwnerWorkspace", "NO", NULL
,
460 &wPreferences
.open_transients_with_parent
, getBool
, NULL
462 {"WindowPlacement", "auto", sePlacements
,
463 &wPreferences
.window_placement
, getEnum
, NULL
465 {"IgnoreFocusClick","NO", NULL
,
466 &wPreferences
.ignore_focus_click
, getBool
, NULL
468 {"UseSaveUnders", "NO", NULL
,
469 &wPreferences
.use_saveunders
, getBool
, NULL
471 {"OpaqueMove", "NO", NULL
,
472 &wPreferences
.opaque_move
, getBool
, NULL
474 {"DisableSound", "NO", NULL
,
475 &wPreferences
.no_sound
, getBool
, NULL
477 {"DisableAnimations", "NO", NULL
,
478 &wPreferences
.no_animations
, getBool
, NULL
480 {"DontLinkWorkspaces","NO", NULL
,
481 &wPreferences
.no_autowrap
, getBool
, NULL
483 {"AutoArrangeIcons", "NO", NULL
,
484 &wPreferences
.auto_arrange_icons
, getBool
, NULL
486 {"NoWindowOverDock", "NO", NULL
,
487 &wPreferences
.no_window_over_dock
, getBool
, updateUsableArea
489 {"NoWindowOverIcons", "NO", NULL
,
490 &wPreferences
.no_window_over_icons
, getBool
, updateUsableArea
492 {"WindowPlaceOrigin", "(0, 0)", NULL
,
493 &wPreferences
.window_place_origin
, getCoord
, NULL
495 {"ResizeDisplay", "corner", seGeomDisplays
,
496 &wPreferences
.size_display
, getEnum
, NULL
498 {"MoveDisplay", "corner", seGeomDisplays
,
499 &wPreferences
.move_display
, getEnum
, NULL
501 {"DontConfirmKill", "NO", NULL
,
502 &wPreferences
.dont_confirm_kill
, getBool
,NULL
504 {"WindowTitleBalloons", "NO", NULL
,
505 &wPreferences
.window_balloon
, getBool
, NULL
507 {"MiniwindowTitleBalloons", "NO", NULL
,
508 &wPreferences
.miniwin_balloon
,getBool
, NULL
510 {"AppIconBalloons", "NO", NULL
,
511 &wPreferences
.appicon_balloon
,getBool
, NULL
513 {"HelpBalloons", "NO", NULL
,
514 &wPreferences
.help_balloon
, getBool
, NULL
516 {"EdgeResistance", "30", NULL
,
517 &wPreferences
.edge_resistance
,getInt
, NULL
519 {"Attraction", "NO", NULL
,
520 &wPreferences
.attract
, getBool
, NULL
522 {"DisableBlinking", "NO", NULL
,
523 &wPreferences
.dont_blink
, getBool
, NULL
525 #ifdef WEENDOZE_CYCLE
526 {"WindozeCycling","NO", NULL
,
527 &wPreferences
.windoze_cycling
, getBool
, NULL
529 {"PopupSwitchMenu","YES", NULL
,
530 &wPreferences
.popup_switchmenu
, getBool
, NULL
532 #endif /* WEENDOZE_CYCLE */
534 {"MenuStyle", "normal", seMenuStyles
,
535 &wPreferences
.menu_style
, getEnum
, setMenuStyle
537 {"WidgetColor", "(solid, gray)", NULL
,
538 NULL
, getTexture
, setWidgetColor
,
540 {"WorkspaceSpecificBack","()", NULL
,
541 NULL
, getWSSpecificBackground
, setWorkspaceSpecificBack
543 /* WorkspaceBack must come after WorkspaceSpecificBack or
544 * WorkspaceBack wont know WorkspaceSpecificBack was also
545 * specified and 2 copies of wmsetbg will be launched */
546 {"WorkspaceBack", "(solid, black)", NULL
,
547 NULL
, getWSBackground
,setWorkspaceBack
549 {"SmoothWorkspaceBack", "NO", NULL
,
552 {"IconBack", "(solid, gray)", NULL
,
553 NULL
, getTexture
, setIconTile
555 {"TitleJustify", "center", seJustifications
,
556 &wPreferences
.title_justification
, getEnum
, setJustify
558 {"WindowTitleFont", DEF_TITLE_FONT
, NULL
,
559 NULL
, getFont
, setWinTitleFont
,
561 {"WindowTitleClearance", DEF_TITLE_CLEARANCE
, NULL
,
562 &wPreferences
.title_clearance
, getInt
, setClearance
564 {"MenuTitleFont", DEF_MENU_TITLE_FONT
, NULL
,
565 NULL
, getFont
, setMenuTitleFont
567 {"MenuTextFont", DEF_MENU_ENTRY_FONT
, NULL
,
568 NULL
, getFont
, setMenuTextFont
570 {"IconTitleFont", DEF_ICON_TITLE_FONT
, NULL
,
571 NULL
, getFont
, setIconTitleFont
573 {"ClipTitleFont", DEF_CLIP_TITLE_FONT
, NULL
,
574 NULL
, getFont
, setClipTitleFont
576 {"DisplayFont", DEF_INFO_TEXT_FONT
, NULL
,
577 NULL
, getFont
, setDisplayFont
579 {"LargeDisplayFont",DEF_WORKSPACE_NAME_FONT
, NULL
,
580 NULL
, getFont
, setLargeDisplayFont
582 {"HighlightColor", "white", NULL
,
583 NULL
, getColor
, setHightlight
585 {"HighlightTextColor", "black", NULL
,
586 NULL
, getColor
, setHightlightText
588 {"ClipTitleColor", "black", (void*)CLIP_NORMAL
,
589 NULL
, getColor
, setClipTitleColor
591 {"CClipTitleColor", "\"#454045\"", (void*)CLIP_COLLAPSED
,
592 NULL
, getColor
, setClipTitleColor
594 #ifdef DRAWSTRING_PLUGIN
595 {"FTitleColor", "white", (void*)WS_FOCUSED
,
596 NULL
, getTextRenderer
, setWTitleColor
598 {"PTitleColor", "white", (void*)WS_PFOCUSED
,
599 NULL
, getTextRenderer
, setWTitleColor
601 {"UTitleColor", "black", (void*)WS_UNFOCUSED
,
602 NULL
, getTextRenderer
, setWTitleColor
605 {"FTitleColor", "white", (void*)WS_FOCUSED
,
606 NULL
, getColor
, setWTitleColor
608 {"PTitleColor", "white", (void*)WS_PFOCUSED
,
609 NULL
, getColor
, setWTitleColor
611 {"UTitleColor", "black", (void*)WS_UNFOCUSED
,
612 NULL
, getColor
, setWTitleColor
615 {"FTitleBack", "(solid, black)", NULL
,
616 NULL
, getTexture
, setFTitleBack
618 {"PTitleBack", "(solid, \"#616161\")", NULL
,
619 NULL
, getTexture
, setPTitleBack
621 {"UTitleBack", "(solid, gray)", NULL
,
622 NULL
, getTexture
, setUTitleBack
624 {"ResizebarBack", "(solid, gray)", NULL
,
625 NULL
, getTexture
, setResizebarBack
627 #ifdef DRAWSTRING_PLUGIN
628 {"MenuTitleColor", "white", NULL
,
629 NULL
, getTextRenderer
, setMenuTitleColor
632 {"MenuTitleColor", "white", NULL
,
633 NULL
, getColor
, setMenuTitleColor
636 {"MenuTextColor", "black", NULL
,
637 NULL
, getColor
, setMenuTextColor
639 {"MenuDisabledColor", "\"#616161\"", NULL
,
640 NULL
, getColor
, setMenuDisabledColor
642 {"MenuTitleBack", "(solid, black)", NULL
,
643 NULL
, getTexture
, setMenuTitleBack
645 {"MenuTextBack", "(solid, gray)", NULL
,
646 NULL
, getTexture
, setMenuTextBack
648 {"IconTitleColor", "white", NULL
,
649 NULL
, getColor
, setIconTitleColor
651 {"IconTitleBack", "black", NULL
,
652 NULL
, getColor
, setIconTitleBack
656 {"RootMenuKey", "None", (void*)WKBD_ROOTMENU
,
657 NULL
, getKeybind
, setKeyGrab
659 {"WindowListKey", "None", (void*)WKBD_WINDOWLIST
,
660 NULL
, getKeybind
, setKeyGrab
663 {"WindowMenuKey", "None", (void*)WKBD_WINDOWMENU
,
664 NULL
, getKeybind
, setKeyGrab
666 {"ClipLowerKey", "None", (void*)WKBD_CLIPLOWER
,
667 NULL
, getKeybind
, setKeyGrab
669 {"ClipRaiseKey", "None", (void*)WKBD_CLIPRAISE
,
670 NULL
, getKeybind
, setKeyGrab
672 {"ClipRaiseLowerKey", "None", (void*)WKBD_CLIPRAISELOWER
,
673 NULL
, getKeybind
, setKeyGrab
675 {"MiniaturizeKey", "None", (void*)WKBD_MINIATURIZE
,
676 NULL
, getKeybind
, setKeyGrab
678 {"HideKey", "None", (void*)WKBD_HIDE
,
679 NULL
, getKeybind
, setKeyGrab
681 {"MoveResizeKey", "None", (void*)WKBD_MOVERESIZE
,
682 NULL
, getKeybind
, setKeyGrab
684 {"CloseKey", "None", (void*)WKBD_CLOSE
,
685 NULL
, getKeybind
, setKeyGrab
687 {"MaximizeKey", "None", (void*)WKBD_MAXIMIZE
,
688 NULL
, getKeybind
, setKeyGrab
690 {"VMaximizeKey", "None", (void*)WKBD_VMAXIMIZE
,
691 NULL
, getKeybind
, setKeyGrab
693 {"RaiseKey", "\"Meta+Up\"", (void*)WKBD_RAISE
,
694 NULL
, getKeybind
, setKeyGrab
696 {"LowerKey", "\"Meta+Down\"", (void*)WKBD_LOWER
,
697 NULL
, getKeybind
, setKeyGrab
699 {"RaiseLowerKey", "None", (void*)WKBD_RAISELOWER
,
700 NULL
, getKeybind
, setKeyGrab
702 {"ShadeKey", "None", (void*)WKBD_SHADE
,
703 NULL
, getKeybind
, setKeyGrab
705 {"SelectKey", "None", (void*)WKBD_SELECT
,
706 NULL
, getKeybind
, setKeyGrab
708 {"FocusNextKey", "None", (void*)WKBD_FOCUSNEXT
,
709 NULL
, getKeybind
, setKeyGrab
711 {"FocusPrevKey", "None", (void*)WKBD_FOCUSPREV
,
712 NULL
, getKeybind
, setKeyGrab
714 {"NextWorkspaceKey", "None", (void*)WKBD_NEXTWORKSPACE
,
715 NULL
, getKeybind
, setKeyGrab
717 {"PrevWorkspaceKey", "None", (void*)WKBD_PREVWORKSPACE
,
718 NULL
, getKeybind
, setKeyGrab
720 {"NextWorkspaceLayerKey", "None", (void*)WKBD_NEXTWSLAYER
,
721 NULL
, getKeybind
, setKeyGrab
723 {"PrevWorkspaceLayerKey", "None", (void*)WKBD_PREVWSLAYER
,
724 NULL
, getKeybind
, setKeyGrab
726 {"Workspace1Key", "None", (void*)WKBD_WORKSPACE1
,
727 NULL
, getKeybind
, setKeyGrab
729 {"Workspace2Key", "None", (void*)WKBD_WORKSPACE2
,
730 NULL
, getKeybind
, setKeyGrab
732 {"Workspace3Key", "None", (void*)WKBD_WORKSPACE3
,
733 NULL
, getKeybind
, setKeyGrab
735 {"Workspace4Key", "None", (void*)WKBD_WORKSPACE4
,
736 NULL
, getKeybind
, setKeyGrab
738 {"Workspace5Key", "None", (void*)WKBD_WORKSPACE5
,
739 NULL
, getKeybind
, setKeyGrab
741 {"Workspace6Key", "None", (void*)WKBD_WORKSPACE6
,
742 NULL
, getKeybind
, setKeyGrab
744 {"Workspace7Key", "None", (void*)WKBD_WORKSPACE7
,
745 NULL
, getKeybind
, setKeyGrab
747 {"Workspace8Key", "None", (void*)WKBD_WORKSPACE8
,
748 NULL
, getKeybind
, setKeyGrab
750 {"Workspace9Key", "None", (void*)WKBD_WORKSPACE9
,
751 NULL
, getKeybind
, setKeyGrab
753 {"Workspace10Key", "None", (void*)WKBD_WORKSPACE10
,
754 NULL
, getKeybind
, setKeyGrab
756 {"WindowShortcut1Key","None", (void*)WKBD_WINDOW1
,
757 NULL
, getKeybind
, setKeyGrab
759 {"WindowShortcut2Key","None", (void*)WKBD_WINDOW2
,
760 NULL
, getKeybind
, setKeyGrab
762 {"WindowShortcut3Key","None", (void*)WKBD_WINDOW3
,
763 NULL
, getKeybind
, setKeyGrab
765 {"WindowShortcut4Key","None", (void*)WKBD_WINDOW4
,
766 NULL
, getKeybind
, setKeyGrab
768 #ifdef EXTEND_WINDOWSHORTCUT
769 ,{"WindowShortcut5Key","None", (void*)WKBD_WINDOW5
,
770 NULL
, getKeybind
, setKeyGrab
772 {"WindowShortcut6Key","None", (void*)WKBD_WINDOW6
,
773 NULL
, getKeybind
, setKeyGrab
775 {"WindowShortcut7Key","None", (void*)WKBD_WINDOW7
,
776 NULL
, getKeybind
, setKeyGrab
778 {"WindowShortcut8Key","None", (void*)WKBD_WINDOW8
,
779 NULL
, getKeybind
, setKeyGrab
781 {"WindowShortcut9Key","None", (void*)WKBD_WINDOW9
,
782 NULL
, getKeybind
, setKeyGrab
784 {"WindowShortcut10Key","None", (void*)WKBD_WINDOW10
,
785 NULL
, getKeybind
, setKeyGrab
787 #endif /* EXTEND_WINDOWSHORTCUT */
789 #ifdef KEEP_XKB_LOCK_STATUS
790 ,{"ToggleKbdModeKey", "None", (void*)WKBD_TOGGLE
,
791 NULL
, getKeybind
, setKeyGrab
793 {"KbdModeLock", "NO", NULL
,
794 &wPreferences
.modelock
, getBool
, NULL
796 #endif /* KEEP_XKB_LOCK_STATUS */
801 static void rereadDefaults(void);
808 /* must defer the update because accessing X data from a
809 * signal handler can mess up Xlib */
818 WDefaultEntry
*entry
;
820 PLSetStringCmpHook(StringCompareHook
);
822 for (i
=0; i
<sizeof(optionList
)/sizeof(WDefaultEntry
); i
++) {
823 entry
= &optionList
[i
];
825 entry
->plkey
= PLMakeString(entry
->key
);
826 if (entry
->default_value
)
827 entry
->plvalue
= PLGetProplistWithDescription(entry
->default_value
);
829 entry
->plvalue
= NULL
;
832 for (i
=0; i
<sizeof(staticOptionList
)/sizeof(WDefaultEntry
); i
++) {
833 entry
= &staticOptionList
[i
];
835 entry
->plkey
= PLMakeString(entry
->key
);
836 if (entry
->default_value
)
837 entry
->plvalue
= PLGetProplistWithDescription(entry
->default_value
);
839 entry
->plvalue
= NULL
;
843 wDomainName = PLMakeString(WMDOMAIN_NAME);
844 wAttributeDomainName = PLMakeString(WMATTRIBUTE_DOMAIN_NAME);
846 PLRegister(wDomainName, rereadDefaults);
847 PLRegister(wAttributeDomainName, rereadDefaults);
856 wDefaultsInit(int screen_number
)
858 static int defaults_inited
= 0;
861 if (!defaults_inited
) {
865 dict
= PLGetDomain(wDomainName
);
867 wwarning(_("could not read domain \"%s\" from defaults database"),
868 PLGetString(wDomainName
));
877 wDefaultsDestroyDomain(WDDomain
*domain
)
879 if (domain
->dictionary
)
880 PLRelease(domain
->dictionary
);
887 wDefaultsInitDomain(char *domain
, Bool requireDictionary
)
891 static int inited
= 0;
894 proplist_t shared_dict
=NULL
;
901 db
= wmalloc(sizeof(WDDomain
));
902 memset(db
, 0, sizeof(WDDomain
));
903 db
->domain_name
= domain
;
904 db
->path
= wdefaultspathfordomain(domain
);
907 if (the_path
&& stat(the_path
, &stbuf
)>=0) {
908 db
->dictionary
= ReadProplistFromFile(the_path
);
909 if (db
->dictionary
) {
910 if (requireDictionary
&& !PLIsDictionary(db
->dictionary
)) {
911 PLRelease(db
->dictionary
);
912 db
->dictionary
= NULL
;
913 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
916 db
->timestamp
= stbuf
.st_mtime
;
918 wwarning(_("could not load domain %s from user defaults database"),
923 /* global system dictionary */
924 sprintf(path
, "%s/WindowMaker/%s", SYSCONFDIR
, domain
);
925 if (stat(path
, &stbuf
)>=0) {
926 shared_dict
= ReadProplistFromFile(path
);
928 if (requireDictionary
&& !PLIsDictionary(shared_dict
)) {
929 wwarning(_("Domain %s (%s) of global defaults database is corrupted!"),
931 PLRelease(shared_dict
);
934 if (db
->dictionary
&& PLIsDictionary(shared_dict
) &&
935 PLIsDictionary(db
->dictionary
)) {
936 PLMergeDictionaries(shared_dict
, db
->dictionary
);
937 PLRelease(db
->dictionary
);
938 db
->dictionary
= shared_dict
;
939 if (stbuf
.st_mtime
> db
->timestamp
)
940 db
->timestamp
= stbuf
.st_mtime
;
941 } else if (!db
->dictionary
) {
942 db
->dictionary
= shared_dict
;
943 if (stbuf
.st_mtime
> db
->timestamp
)
944 db
->timestamp
= stbuf
.st_mtime
;
948 wwarning(_("could not load domain %s from global defaults database (%s)"),
953 /* set to save it in user's directory, no matter from where it was read */
954 if (db
->dictionary
) {
955 proplist_t tmp
= PLMakeString(db
->path
);
957 PLSetFilename(db
->dictionary
, tmp
);
966 wReadStaticDefaults(proplist_t dict
)
969 WDefaultEntry
*entry
;
974 for (i
=0; i
<sizeof(staticOptionList
)/sizeof(WDefaultEntry
); i
++) {
975 entry
= &staticOptionList
[i
];
978 plvalue
= PLGetDictionaryEntry(dict
, entry
->plkey
);
983 /* no default in the DB. Use builtin default */
984 plvalue
= entry
->plvalue
;
989 (*entry
->convert
)(NULL
, entry
, plvalue
, entry
->addr
, &tdata
);
991 (*entry
->update
)(NULL
, entry
, tdata
, entry
->extra_data
);
999 wDefaultsCheckDomains(void *foo
)
1005 char path
[PATH_MAX
];
1008 puts("Checking domains...");
1010 if (stat(WDWindowMaker
->path
, &stbuf
)>=0
1011 && WDWindowMaker
->timestamp
< stbuf
.st_mtime
) {
1012 proplist_t shared_dict
= NULL
;
1014 puts("Checking WindowMaker domain");
1016 WDWindowMaker
->timestamp
= stbuf
.st_mtime
;
1018 /* global dictionary */
1019 sprintf(path
, "%s/WindowMaker/WindowMaker", SYSCONFDIR
);
1020 if (stat(path
, &stbuf
)>=0) {
1021 shared_dict
= ReadProplistFromFile(path
);
1022 if (shared_dict
&& !PLIsDictionary(shared_dict
)) {
1023 wwarning(_("Domain %s (%s) of global defaults database is corrupted!"),
1024 "WindowMaker", path
);
1025 PLRelease(shared_dict
);
1027 } else if (!shared_dict
) {
1028 wwarning(_("could not load domain %s from global defaults database"),
1032 /* user dictionary */
1033 dict
= ReadProplistFromFile(WDWindowMaker
->path
);
1035 if (!PLIsDictionary(dict
)) {
1038 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
1039 "WindowMaker", WDWindowMaker
->path
);
1042 PLSetFilename(shared_dict
, PLGetFilename(dict
));
1043 PLMergeDictionaries(shared_dict
, dict
);
1048 for (i
=0; i
<wScreenCount
; i
++) {
1049 scr
= wScreenWithNumber(i
);
1051 wReadDefaults(scr
, dict
);
1053 if (WDWindowMaker
->dictionary
) {
1054 PLRelease(WDWindowMaker
->dictionary
);
1056 WDWindowMaker
->dictionary
= dict
;
1059 wwarning(_("could not load domain %s from user defaults database"),
1063 PLRelease(shared_dict
);
1067 if (stat(WDWindowAttributes
->path
, &stbuf
)>=0
1068 && WDWindowAttributes
->timestamp
< stbuf
.st_mtime
) {
1070 puts("Checking WMWindowAttributes domain");
1072 dict
= ReadProplistFromFile(WDWindowAttributes
->path
);
1074 if (!PLIsDictionary(dict
)) {
1077 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
1078 "WMWindowAttributes", WDWindowAttributes
->path
);
1080 if (WDWindowAttributes
->dictionary
)
1081 PLRelease(WDWindowAttributes
->dictionary
);
1082 WDWindowAttributes
->dictionary
= dict
;
1083 for (i
=0; i
<wScreenCount
; i
++) {
1084 scr
= wScreenWithNumber(i
);
1086 wDefaultUpdateIcons(scr
);
1090 wwarning(_("could not load domain %s from user defaults database"),
1091 "WMWindowAttributes");
1093 WDWindowAttributes
->timestamp
= stbuf
.st_mtime
;
1097 if (stat(WDRootMenu
->path
, &stbuf
)>=0
1098 && WDRootMenu
->timestamp
< stbuf
.st_mtime
) {
1099 dict
= ReadProplistFromFile(WDRootMenu
->path
);
1101 puts("Checking WMRootMenu domain");
1104 if (!PLIsArray(dict
) && !PLIsString(dict
)) {
1107 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
1108 "WMRootMenu", WDRootMenu
->path
);
1110 if (WDRootMenu
->dictionary
) {
1111 PLRelease(WDRootMenu
->dictionary
);
1113 WDRootMenu
->dictionary
= dict
;
1116 wwarning(_("could not load domain %s from user defaults database"),
1119 WDRootMenu
->timestamp
= stbuf
.st_mtime
;
1124 WMAddTimerHandler(DEFAULTS_CHECK_INTERVAL
, wDefaultsCheckDomains
, foo
);
1129 wReadDefaults(WScreen
*scr
, proplist_t new_dict
)
1131 proplist_t plvalue
, old_value
;
1132 WDefaultEntry
*entry
;
1134 int update_workspace_back
= 0; /* kluge :/ */
1137 proplist_t old_dict
= (WDWindowMaker
->dictionary
!=new_dict
1138 ? WDWindowMaker
->dictionary
: NULL
);
1144 for (i
=0; i
<sizeof(optionList
)/sizeof(WDefaultEntry
); i
++) {
1145 entry
= &optionList
[i
];
1148 plvalue
= PLGetDictionaryEntry(new_dict
, entry
->plkey
);
1155 old_value
= PLGetDictionaryEntry(old_dict
, entry
->plkey
);
1158 if (!plvalue
&& !old_value
) {
1159 /* no default in the DB. Use builtin default */
1160 plvalue
= entry
->plvalue
;
1161 if (plvalue
&& new_dict
) {
1162 PLInsertDictionaryEntry(new_dict
, entry
->plkey
, plvalue
);
1165 } else if (!plvalue
) {
1166 /* value was deleted from DB. Keep current value */
1168 } else if (!old_value
) {
1169 /* set value for the 1st time */
1170 } else if (!PLIsEqual(plvalue
, old_value
)) {
1171 /* value has changed */
1174 if (strcmp(entry
->key
, "WorkspaceBack") == 0
1175 && update_workspace_back
1176 && scr
->flags
.backimage_helper_launched
) {
1178 /* value was not changed since last time */
1185 printf("Updating %s to %s\n", entry
->key
,
1186 PLGetDescription(plvalue
));
1189 if ((*entry
->convert
)(scr
, entry
, plvalue
, entry
->addr
, &tdata
)) {
1191 * If the WorkspaceSpecificBack data has been changed
1192 * so that the helper will be launched now, we must be
1193 * sure to send the default background texture config
1196 if (strcmp(entry
->key
, "WorkspaceSpecificBack") == 0
1197 && !scr
->flags
.backimage_helper_launched
) {
1198 update_workspace_back
= 1;
1200 if (entry
->update
) {
1202 (*entry
->update
)(scr
, entry
, tdata
, entry
->extra_data
);
1208 if (needs_refresh
!=0 && !scr
->flags
.startup
) {
1212 if (needs_refresh
& REFRESH_MENU_TITLE_TEXTURE
)
1213 foo
|= WTextureSettings
;
1214 if (needs_refresh
& REFRESH_MENU_TITLE_FONT
)
1215 foo
|= WFontSettings
;
1216 if (needs_refresh
& REFRESH_MENU_TITLE_COLOR
)
1217 foo
|= WColorSettings
;
1219 WMPostNotificationName(WNMenuTitleAppearanceSettingsChanged
, NULL
,
1223 if (needs_refresh
& REFRESH_MENU_TEXTURE
)
1224 foo
|= WTextureSettings
;
1225 if (needs_refresh
& REFRESH_MENU_FONT
)
1226 foo
|= WFontSettings
;
1227 if (needs_refresh
& REFRESH_MENU_COLOR
)
1228 foo
|= WColorSettings
;
1230 WMPostNotificationName(WNMenuAppearanceSettingsChanged
, NULL
,
1234 if (needs_refresh
& REFRESH_WINDOW_FONT
) {
1235 foo
|= WFontSettings
;
1237 if (needs_refresh
& REFRESH_WINDOW_TEXTURES
) {
1238 foo
|= WTextureSettings
;
1240 if (needs_refresh
& REFRESH_WINDOW_TITLE_COLOR
) {
1241 foo
|= WColorSettings
;
1244 WMPostNotificationName(WNWindowAppearanceSettingsChanged
, NULL
,
1247 if (!(needs_refresh
& REFRESH_ICON_TILE
)) {
1249 if (needs_refresh
& REFRESH_ICON_FONT
) {
1250 foo
|= WFontSettings
;
1252 if (needs_refresh
& REFRESH_ICON_TITLE_COLOR
) {
1253 foo
|= WTextureSettings
;
1255 if (needs_refresh
& REFRESH_ICON_TITLE_BACK
) {
1256 foo
|= WTextureSettings
;
1259 WMPostNotificationName(WNIconAppearanceSettingsChanged
, NULL
,
1262 if (needs_refresh
& REFRESH_ICON_TILE
)
1263 WMPostNotificationName(WNIconTileSettingsChanged
, NULL
, NULL
);
1269 wDefaultUpdateIcons(WScreen
*scr
)
1271 WAppIcon
*aicon
= scr
->app_icon_list
;
1272 WWindow
*wwin
= scr
->focused_window
;
1276 file
= wDefaultGetIconFile(scr
, aicon
->wm_instance
, aicon
->wm_class
,
1278 if ((file
&& aicon
->icon
->file
&& strcmp(file
, aicon
->icon
->file
)!=0)
1279 || (file
&& !aicon
->icon
->file
)) {
1282 if (aicon
->icon
->file
)
1283 free(aicon
->icon
->file
);
1284 aicon
->icon
->file
= wstrdup(file
);
1286 new_image
= wDefaultGetImage(scr
, aicon
->wm_instance
,
1289 wIconChangeImage(aicon
->icon
, new_image
);
1290 wAppIconPaint(aicon
);
1293 aicon
= aicon
->next
;
1296 if (!wPreferences
.flags
.noclip
)
1297 wClipIconPaint(scr
->clip_icon
);
1300 if (wwin
->icon
&& wwin
->flags
.miniaturized
) {
1301 file
= wDefaultGetIconFile(scr
, wwin
->wm_instance
, wwin
->wm_class
,
1303 if ((file
&& wwin
->icon
->file
&& strcmp(file
, wwin
->icon
->file
)!=0)
1304 || (file
&& !wwin
->icon
->file
)) {
1307 if (wwin
->icon
->file
)
1308 free(wwin
->icon
->file
);
1309 wwin
->icon
->file
= wstrdup(file
);
1311 new_image
= wDefaultGetImage(scr
, wwin
->wm_instance
,
1314 wIconChangeImage(wwin
->icon
, new_image
);
1322 /* --------------------------- Local ----------------------- */
1324 #define GET_STRING_OR_DEFAULT(x, var) if (!PLIsString(value)) { \
1325 wwarning(_("Wrong option format for key \"%s\". Should be %s."), \
1327 wwarning(_("using default \"%s\" instead"), entry->default_value); \
1328 var = entry->default_value;\
1329 } else var = PLGetString(value)\
1336 string2index(proplist_t key
, proplist_t val
, proplist_t def
,
1337 WOptionEnumeration
*values
)
1340 WOptionEnumeration
*v
;
1341 char buffer
[TOTAL_VALUES_LENGTH
];
1343 if (PLIsString(val
) && (str
= PLGetString(val
))) {
1344 for (v
=values
; v
->string
!=NULL
; v
++) {
1345 if (strcasecmp(v
->string
, str
)==0)
1351 for (v
=values
; v
->string
!=NULL
; v
++) {
1354 strcat(buffer
, ", ");
1355 strcat(buffer
, v
->string
);
1358 wwarning(_("wrong option value for key \"%s\". Should be one of %s"),
1359 PLGetString(key
), buffer
);
1362 return string2index(key
, val
, NULL
, values
);
1372 * value - is the value in the defaults DB
1373 * addr - is the address to store the data
1374 * ret - is the address to store a pointer to a temporary buffer. ret
1375 * must not be freed and is used by the set functions
1378 getBool(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
1385 GET_STRING_OR_DEFAULT("Boolean", val
);
1388 if ((val
[1]=='\0' && (val
[0]=='y' || val
[0]=='Y'))
1389 || strcasecmp(val
, "YES")==0) {
1392 } else if ((val
[1]=='\0' && (val
[0]=='n' || val
[0]=='N'))
1393 || strcasecmp(val
, "NO")==0) {
1397 if (sscanf(val
, "%i", &i
)==1) {
1403 wwarning(_("can't convert \"%s\" to boolean for key \"%s\""),
1405 if (second_pass
==0) {
1406 val
= PLGetString(entry
->plvalue
);
1408 wwarning(_("using default \"%s\" instead"), val
);
1419 *(char*)addr
= data
;
1427 getInt(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
1434 GET_STRING_OR_DEFAULT("Integer", val
);
1436 if (sscanf(val
, "%i", &data
)!=1) {
1437 wwarning(_("can't convert \"%s\" to integer for key \"%s\""),
1439 val
= PLGetString(entry
->plvalue
);
1440 wwarning(_("using default \"%s\" instead"), val
);
1441 if (sscanf(val
, "%i", &data
)!=1) {
1457 getCoord(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
1461 char *val_x
, *val_y
;
1462 int nelem
, changed
=0;
1463 proplist_t elem_x
, elem_y
;
1466 if (!PLIsArray(value
)) {
1467 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1468 entry
->key
, "Coordinate");
1470 value
= entry
->plvalue
;
1472 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1478 nelem
= PLGetNumberOfElements(value
);
1480 wwarning(_("Incorrect number of elements in array for key \"%s\"."),
1483 value
= entry
->plvalue
;
1485 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1491 elem_x
= PLGetArrayElement(value
, 0);
1492 elem_y
= PLGetArrayElement(value
, 1);
1494 if (!elem_x
|| !elem_y
|| !PLIsString(elem_x
) || !PLIsString(elem_y
)) {
1495 wwarning(_("Wrong value for key \"%s\". Should be Coordinate."),
1498 value
= entry
->plvalue
;
1500 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1506 val_x
= PLGetString(elem_x
);
1507 val_y
= PLGetString(elem_y
);
1509 if (sscanf(val_x
, "%i", &data
.x
)!=1 || sscanf(val_y
, "%i", &data
.y
)!=1) {
1510 wwarning(_("can't convert array to integers for \"%s\"."), entry
->key
);
1512 value
= entry
->plvalue
;
1514 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1522 else if (data
.x
> scr
->scr_width
/3)
1523 data
.x
= scr
->scr_width
/3;
1526 else if (data
.y
> scr
->scr_height
/3)
1527 data
.y
= scr
->scr_height
/3;
1533 *(WCoord
*)addr
= data
;
1541 /* This function is not used at the moment. */
1543 getString(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
1548 GET_STRING_OR_DEFAULT("String", data
);
1551 data
= PLGetString(entry
->plvalue
);
1560 *(char**)addr
= wstrdup(data
);
1568 getPathList(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
1578 if (!PLIsArray(value
)) {
1579 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1580 entry
->key
, "an array of paths");
1582 value
= entry
->plvalue
;
1584 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1591 count
= PLGetNumberOfElements(value
);
1594 value
= entry
->plvalue
;
1596 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1603 for (i
=0; i
<count
; i
++) {
1604 d
= PLGetArrayElement(value
, i
);
1605 if (!d
|| !PLIsString(d
)) {
1609 len
+= strlen(PLGetString(d
))+1;
1612 ptr
= data
= wmalloc(len
+1);
1614 for (i
=0; i
<count
; i
++) {
1615 d
= PLGetArrayElement(value
, i
);
1616 if (!d
|| !PLIsString(d
)) {
1619 strcpy(ptr
, PLGetString(d
));
1620 ptr
+= strlen(PLGetString(d
));
1624 ptr
--; *(ptr
--) = 0;
1626 if (*(char**)addr
!=NULL
) {
1627 free(*(char**)addr
);
1629 *(char**)addr
= data
;
1636 getEnum(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
1639 static signed char data
;
1641 data
= string2index(entry
->plkey
, value
, entry
->default_value
,
1642 (WOptionEnumeration
*)entry
->extra_data
);
1650 *(signed char*)addr
= data
;
1659 * (hgradient <color> <color>)
1660 * (vgradient <color> <color>)
1661 * (dgradient <color> <color>)
1662 * (mhgradient <color> <color> ...)
1663 * (mvgradient <color> <color> ...)
1664 * (tpixmap <file> <color>)
1665 * (spixmap <file> <color>)
1666 * (cpixmap <file> <color>)
1667 * (thgradient <file> <opaqueness> <color> <color>)
1668 * (tvgradient <file> <opaqueness> <color> <color>)
1669 * (tdgradient <file> <opaqueness> <color> <color>)
1670 * (function <lib> <function> ...)
1674 parse_texture(WScreen
*scr
, proplist_t pl
)
1679 WTexture
*texture
=NULL
;
1681 nelem
= PLGetNumberOfElements(pl
);
1686 elem
= PLGetArrayElement(pl
, 0);
1687 if (!elem
|| !PLIsString(elem
))
1689 val
= PLGetString(elem
);
1692 if (strcasecmp(val
, "solid")==0) {
1700 elem
= PLGetArrayElement(pl
, 1);
1701 if (!elem
|| !PLIsString(elem
))
1703 val
= PLGetString(elem
);
1705 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &color
)) {
1706 wwarning(_("\"%s\" is not a valid color name"), val
);
1710 texture
= (WTexture
*)wTextureMakeSolid(scr
, &color
);
1711 } else if (strcasecmp(val
, "dgradient")==0
1712 || strcasecmp(val
, "vgradient")==0
1713 || strcasecmp(val
, "hgradient")==0) {
1714 RColor color1
, color2
;
1719 wwarning(_("bad number of arguments in gradient specification"));
1723 if (val
[0]=='d' || val
[0]=='D')
1724 type
= WTEX_DGRADIENT
;
1725 else if (val
[0]=='h' || val
[0]=='H')
1726 type
= WTEX_HGRADIENT
;
1728 type
= WTEX_VGRADIENT
;
1731 /* get from color */
1732 elem
= PLGetArrayElement(pl
, 1);
1733 if (!elem
|| !PLIsString(elem
))
1735 val
= PLGetString(elem
);
1737 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1738 wwarning(_("\"%s\" is not a valid color name"), val
);
1742 color1
.red
= xcolor
.red
>> 8;
1743 color1
.green
= xcolor
.green
>> 8;
1744 color1
.blue
= xcolor
.blue
>> 8;
1747 elem
= PLGetArrayElement(pl
, 2);
1748 if (!elem
|| !PLIsString(elem
)) {
1751 val
= PLGetString(elem
);
1753 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1754 wwarning(_("\"%s\" is not a valid color name"), val
);
1758 color2
.red
= xcolor
.red
>> 8;
1759 color2
.green
= xcolor
.green
>> 8;
1760 color2
.blue
= xcolor
.blue
>> 8;
1762 texture
= (WTexture
*)wTextureMakeGradient(scr
, type
, &color1
, &color2
);
1764 } else if (strcasecmp(val
, "mhgradient")==0
1765 || strcasecmp(val
, "mvgradient")==0
1766 || strcasecmp(val
, "mdgradient")==0) {
1773 wwarning(_("too few arguments in multicolor gradient specification"));
1777 if (val
[1]=='h' || val
[1]=='H')
1778 type
= WTEX_MHGRADIENT
;
1779 else if (val
[1]=='v' || val
[1]=='V')
1780 type
= WTEX_MVGRADIENT
;
1782 type
= WTEX_MDGRADIENT
;
1786 colors
= wmalloc(sizeof(RColor
*)*(count
+1));
1788 for (i
=0; i
<count
; i
++) {
1789 elem
= PLGetArrayElement(pl
, i
+1);
1790 if (!elem
|| !PLIsString(elem
)) {
1791 for (--i
; i
>=0; --i
) {
1797 val
= PLGetString(elem
);
1799 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &color
)) {
1800 wwarning(_("\"%s\" is not a valid color name"), val
);
1801 for (--i
; i
>=0; --i
) {
1807 colors
[i
] = wmalloc(sizeof(RColor
));
1808 colors
[i
]->red
= color
.red
>> 8;
1809 colors
[i
]->green
= color
.green
>> 8;
1810 colors
[i
]->blue
= color
.blue
>> 8;
1815 texture
= (WTexture
*)wTextureMakeMGradient(scr
, type
, colors
);
1816 } else if (strcasecmp(val
, "spixmap")==0 ||
1817 strcasecmp(val
, "cpixmap")==0 ||
1818 strcasecmp(val
, "tpixmap")==0) {
1825 if (val
[0] == 's' || val
[0] == 'S')
1827 else if (val
[0] == 'c' || val
[0] == 'C')
1833 elem
= PLGetArrayElement(pl
, 2);
1834 if (!elem
|| !PLIsString(elem
)) {
1837 val
= PLGetString(elem
);
1839 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &color
)) {
1840 wwarning(_("\"%s\" is not a valid color name"), val
);
1845 elem
= PLGetArrayElement(pl
, 1);
1846 if (!elem
|| !PLIsString(elem
))
1848 val
= PLGetString(elem
);
1850 texture
= (WTexture
*)wTextureMakePixmap(scr
, type
, val
, &color
);
1851 } else if (strcasecmp(val
, "thgradient")==0
1852 || strcasecmp(val
, "tvgradient")==0
1853 || strcasecmp(val
, "tdgradient")==0) {
1854 RColor color1
, color2
;
1859 if (val
[1]=='h' || val
[1]=='H')
1860 style
= WTEX_THGRADIENT
;
1861 else if (val
[1]=='v' || val
[1]=='V')
1862 style
= WTEX_TVGRADIENT
;
1864 style
= WTEX_TDGRADIENT
;
1867 wwarning(_("bad number of arguments in textured gradient specification"));
1871 /* get from color */
1872 elem
= PLGetArrayElement(pl
, 3);
1873 if (!elem
|| !PLIsString(elem
))
1875 val
= PLGetString(elem
);
1877 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1878 wwarning(_("\"%s\" is not a valid color name"), val
);
1882 color1
.red
= xcolor
.red
>> 8;
1883 color1
.green
= xcolor
.green
>> 8;
1884 color1
.blue
= xcolor
.blue
>> 8;
1887 elem
= PLGetArrayElement(pl
, 4);
1888 if (!elem
|| !PLIsString(elem
)) {
1891 val
= PLGetString(elem
);
1893 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1894 wwarning(_("\"%s\" is not a valid color name"), val
);
1898 color2
.red
= xcolor
.red
>> 8;
1899 color2
.green
= xcolor
.green
>> 8;
1900 color2
.blue
= xcolor
.blue
>> 8;
1903 elem
= PLGetArrayElement(pl
, 2);
1904 if (!elem
|| !PLIsString(elem
))
1907 val
= PLGetString(elem
);
1909 if (!val
|| (opacity
= atoi(val
)) < 0 || opacity
> 255) {
1910 wwarning(_("bad opacity value for tgradient texture \"%s\". Should be [0..255]"), val
);
1915 elem
= PLGetArrayElement(pl
, 1);
1916 if (!elem
|| !PLIsString(elem
))
1918 val
= PLGetString(elem
);
1920 texture
= (WTexture
*)wTextureMakeTGradient(scr
, style
, &color1
, &color2
,
1923 #ifdef TEXTURE_PLUGIN
1924 else if (strcasecmp(val
, "function")==0) {
1925 WTexFunction
*function
;
1926 void (*initFunc
) (Display
*, Colormap
);
1927 char *lib
, *func
, **argv
;
1933 /* get the library name */
1934 elem
= PLGetArrayElement(pl
, 1);
1935 if (!elem
|| !PLIsString(elem
)) {
1938 lib
= PLGetString(elem
);
1940 /* get the function name */
1941 elem
= PLGetArrayElement(pl
, 2);
1942 if (!elem
|| !PLIsString(elem
)) {
1945 func
= PLGetString(elem
);
1948 argv
= (char **)wmalloc(argc
* sizeof(char *));
1950 /* get the parameters */
1951 argv
[0] = wstrdup(func
);
1952 for (i
= 0; i
< argc
- 1; i
++) {
1953 elem
= PLGetArrayElement(pl
, 3 + i
);
1954 if (!elem
|| !PLIsString(elem
)) {
1959 argv
[i
+1] = wstrdup(PLGetString(elem
));
1962 function
= wTextureMakeFunction(scr
, lib
, func
, argc
, argv
);
1966 initFunc
= dlsym(function
->handle
, "initWindowMaker");
1968 initFunc(dpy
, scr
->w_colormap
);
1970 wwarning(_("could not initialize library %s"), lib
);
1973 wwarning(_("could not find function %s::%s"), lib
, func
);
1975 #endif /* HAVE_DLFCN_H */
1976 texture
= (WTexture
*)function
;
1978 #endif /* TEXTURE_PLUGIN */
1980 wwarning(_("invalid texture type %s"), val
);
1989 getTexture(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
1992 static WTexture
*texture
;
1996 if (!PLIsArray(value
)) {
1997 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1998 entry
->key
, "Texture");
2000 value
= entry
->plvalue
;
2002 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
2008 if (strcmp(entry
->key
, "WidgetColor")==0 && !changed
) {
2011 pl
= PLGetArrayElement(value
, 0);
2012 if (!pl
|| !PLIsString(pl
) || !PLGetString(pl
)
2013 || strcasecmp(PLGetString(pl
), "solid")!=0) {
2014 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
2015 entry
->key
, "Solid Texture");
2017 value
= entry
->plvalue
;
2019 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
2024 texture
= parse_texture(scr
, value
);
2027 wwarning(_("Error in texture specification for key \"%s\""),
2030 value
= entry
->plvalue
;
2032 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
2042 *(WTexture
**)addr
= texture
;
2049 #ifdef DRAWSTRING_PLUGIN
2051 getTextRenderer(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
,
2052 void *addr
, void **ret
)
2055 char *val
, *lib
, *func
, **argv
;
2058 if (strcmp(entry
->key
, "FTitleColor")==0) {
2059 wPluginDestroyFunction(scr
->drawstring_func
[changed
= W_STRING_FTITLE
]);
2060 scr
->drawstring_func
[W_STRING_FTITLE
] = NULL
;
2061 } else if (strcmp(entry
->key
, "UTitleColor")==0) {
2062 wPluginDestroyFunction(scr
->drawstring_func
[changed
= W_STRING_UTITLE
]);
2063 scr
->drawstring_func
[W_STRING_UTITLE
] = NULL
;
2064 } else if (strcmp(entry
->key
, "PTitleColor")==0) {
2065 wPluginDestroyFunction(scr
->drawstring_func
[changed
= W_STRING_PTITLE
]);
2066 scr
->drawstring_func
[W_STRING_PTITLE
] = NULL
;
2067 } else if (strcmp(entry
->key
, "MenuTitleColor")==0) {
2068 wPluginDestroyFunction(scr
->drawstring_func
[changed
= W_STRING_MTITLE
]);
2069 scr
->drawstring_func
[W_STRING_MTITLE
] = NULL
;
2070 } else if (strcmp(entry
->key
, "MenuPluginColor")==0) {
2071 wPluginDestroyFunction(scr
->drawstring_func
[changed
= W_STRING_MTEXT
]);
2072 scr
->drawstring_func
[W_STRING_MTEXT
] = NULL
;
2075 if (PLIsArray(value
)) {
2076 if ((argc
= PLGetNumberOfElements(value
)) < 4) return False
;
2078 argv
= (char **)wmalloc(argc
* sizeof(char *));
2080 elem
= PLGetArrayElement(value
,0);
2081 if (!elem
|| !PLIsString(elem
)) return False
;
2082 val
= PLGetString(elem
);
2083 if (strcasecmp(val
, "function")==0) {
2084 elem
= PLGetArrayElement(value
, 1); /* library name */
2085 if (!elem
|| !PLIsString(elem
)) return False
;
2086 lib
= PLGetString(elem
);
2087 elem
= PLGetArrayElement(value
, 2); /* function name */
2088 if (!elem
|| !PLIsString(elem
)) return False
;
2089 func
= PLGetString(elem
);
2090 scr
->drawstring_func
[changed
] = wPluginCreateFunction (W_FUNCTION_DRAWSTRING
,
2091 lib
, "initDrawString", func
, NULL
, value
,
2092 wPluginPackInitData(3, dpy
, scr
->w_colormap
,"-DATA-"));
2095 return getColor(scr
, entry
, PLGetArrayElement(value
,3), addr
, ret
);
2096 } else if (PLIsString(value
)) {
2097 return getColor(scr
, entry
, value
, addr
, ret
);
2102 #endif /* DRAWSTRING_PLUGIN */
2107 getWSBackground(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
,
2108 void *addr
, void **ret
)
2116 if (!PLIsArray(value
)) {
2117 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
2118 "WorkspaceBack", "Texture or None");
2120 value
= entry
->plvalue
;
2122 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
2128 /* only do basic error checking and verify for None texture */
2130 nelem
= PLGetNumberOfElements(value
);
2132 elem
= PLGetArrayElement(value
, 0);
2133 if (!elem
|| !PLIsString(elem
)) {
2134 wwarning(_("Wrong type for workspace background. Should be a texture type."));
2136 value
= entry
->plvalue
;
2138 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
2143 val
= PLGetString(elem
);
2145 if (strcasecmp(val
, "None")==0)
2148 *ret
= PLRetain(value
);
2155 getWSSpecificBackground(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
,
2156 void *addr
, void **ret
)
2163 if (!PLIsArray(value
)) {
2164 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
2165 "WorkspaceSpecificBack", "an array of textures");
2167 value
= entry
->plvalue
;
2169 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
2175 /* only do basic error checking and verify for None texture */
2177 nelem
= PLGetNumberOfElements(value
);
2180 elem
= PLGetArrayElement(value
, nelem
);
2181 if (!elem
|| !PLIsArray(elem
)) {
2182 wwarning(_("Wrong type for background of workspace %i. Should be a texture."),
2188 *ret
= PLRetain(value
);
2192 * Kluge to force wmsetbg helper to set the default background.
2193 * If the WorkspaceSpecificBack is changed once wmaker has started,
2194 * the WorkspaceBack won't be sent to the helper, unless the user
2195 * changes it's value too. So, we must force this by removing the
2196 * value from the defaults DB.
2198 if (!scr
->flags
.backimage_helper_launched
&& !scr
->flags
.startup
) {
2199 proplist_t key
= PLMakeString("WorkspaceBack");
2201 PLRemoveDictionaryEntry(WDWindowMaker
->dictionary
, key
);
2211 getFont(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
2214 static WMFont
*font
;
2217 GET_STRING_OR_DEFAULT("Font", val
);
2219 font
= WMCreateFont(scr
->wmscreen
, val
);
2221 font
= WMCreateFont(scr
->wmscreen
, "fixed");
2224 wfatal(_("could not load any usable font!!!"));
2231 /* can't assign font value outside update function */
2232 wassertrv(addr
== NULL
, True
);
2239 getColor(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
2242 static XColor color
;
2246 GET_STRING_OR_DEFAULT("Color", val
);
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 GET_STRING_OR_DEFAULT("Key spec", val
);
2289 if (!val
|| strcasecmp(val
, "NONE")==0) {
2290 shortcut
.keycode
= 0;
2291 shortcut
.modifier
= 0;
2302 shortcut
.modifier
= 0;
2303 while ((k
= strchr(b
, '+'))!=NULL
) {
2307 mod
= wXModifierFromKey(b
);
2309 wwarning(_("%s:invalid key modifier \"%s\""), entry
->key
, b
);
2312 shortcut
.modifier
|= mod
;
2318 ksym
= XStringToKeysym(b
);
2320 if (ksym
==NoSymbol
) {
2321 wwarning(_("%s:invalid kbd shortcut specification \"%s\""), entry
->key
,
2326 shortcut
.keycode
= XKeysymToKeycode(dpy
, ksym
);
2327 if (shortcut
.keycode
==0) {
2328 wwarning(_("%s:invalid key in shortcut \"%s\""), entry
->key
, val
);
2340 getModMask(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
, void *addr
,
2343 static unsigned int mask
;
2346 GET_STRING_OR_DEFAULT("Modifier Key", str
);
2351 mask
= wXModifierFromKey(str
);
2353 wwarning(_("%s: modifier key %s is not valid"), entry
->key
, str
);
2359 *(unsigned int*)addr
= mask
;
2370 getRImages(WScreen
*scr
, WDefaultEntry
*entry
, proplist_t value
,
2371 void *addr
, void **ret
)
2379 GET_STRING_OR_DEFAULT("Image File Path", str
);
2383 image
= RLoadImage(scr
->rcontext
, str
, 0);
2385 wwarning(_("could not load image in option %s: %s"), entry
->key
,
2386 RMessageForError(RErrorCode
));
2390 if (*(RImage
**)addr
) {
2391 RDestroyImage(*(RImage
**)addr
);
2394 *(RImage
**)addr
= image
;
2396 assert(ret
== NULL
);
2399 *(RImage**)ret = image;
2407 /* ---------------- value setting functions --------------- */
2409 setJustify(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
2411 return REFRESH_WINDOW_TITLE_COLOR
;
2415 setClearance(WScreen
*scr
, WDefaultEntry
*entry
, void *bar
, void *foo
)
2417 return REFRESH_WINDOW_FONT
|REFRESH_BUTTON_IMAGES
|REFRESH_MENU_TITLE_FONT
;
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
;