1 /* defaults.c - manage configuration through defaults db
3 * Window Maker window manager
5 * Copyright (c) 1997-2003 Alfredo K. Kojima
6 * Copyright (c) 1998-2003 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,
32 #include <sys/types.h>
45 #define PATH_MAX DEFAULT_PATH_MAX
49 #include <X11/Xutil.h>
50 #include <X11/keysym.h>
54 #include "WindowMaker.h"
60 #include "resources.h"
63 #include "xmodifier.h"
68 #include "workspace.h"
69 #include "properties.h"
75 extern WDDomain
*WDWindowMaker
;
76 extern WDDomain
*WDWindowAttributes
;
77 extern WDDomain
*WDRootMenu
;
79 extern int wScreenCount
;
81 extern Atom _XA_WINDOWMAKER_ICON_SIZE
;
82 extern Atom _XA_WINDOWMAKER_ICON_TILE
;
85 extern WMPropList *wDomainName;
86 extern WMPropList *wAttributeDomainName;
88 extern WPreferences wPreferences
;
90 extern WShortKey wKeyBindings
[WKBD_LAST
];
100 WMPropList
*plvalue
; /* default value */
104 /* used to map strings to integers */
109 } WOptionEnumeration
;
112 /* type converters */
113 static int getBool();
115 static int getCoord();
117 /* this is not used yet */
118 static int getString();
120 static int getPathList();
121 static int getEnum();
122 static int getTexture();
123 static int getWSBackground();
124 static int getWSSpecificBackground();
125 static int getFont();
126 static int getColor();
127 static int getKeybind();
128 static int getModMask();
130 static int getRImage();
132 static int getPropList();
134 /* value setting functions */
135 static int setJustify();
136 static int setClearance();
137 static int setIfDockPresent();
138 static int setStickyIcons();
140 static int setPositive();
142 static int setWidgetColor();
143 static int setIconTile();
144 static int setWinTitleFont();
145 static int setMenuTitleFont();
146 static int setMenuTextFont();
147 static int setIconTitleFont();
148 static int setIconTitleColor();
149 static int setIconTitleBack();
150 static int setLargeDisplayFont();
151 static int setWTitleColor();
152 static int setFTitleBack();
153 static int setPTitleBack();
154 static int setUTitleBack();
155 static int setResizebarBack();
156 static int setWorkspaceBack();
157 static int setWorkspaceSpecificBack();
158 #ifdef VIRTUAL_DESKTOP
159 static int setVirtualDeskEnable();
161 static int setMenuTitleColor();
162 static int setMenuTextColor();
163 static int setMenuDisabledColor();
164 static int setMenuTitleBack();
165 static int setMenuTextBack();
166 static int setHightlight();
167 static int setHightlightText();
168 static int setKeyGrab();
169 static int setDoubleClick();
170 static int setIconPosition();
172 static int setClipTitleFont();
173 static int setClipTitleColor();
175 static int setMenuStyle();
176 static int setSwPOptions();
177 static int updateUsableArea();
180 extern Cursor wCursor
[WCUR_LAST
];
181 static int getCursor();
182 static int setCursor();
186 * Tables to convert strings to enumeration values.
187 * Values stored are char
191 /* WARNING: sum of length of all value strings must not exceed
193 #define TOTAL_VALUES_LENGTH 80
198 #define REFRESH_WINDOW_TEXTURES (1<<0)
199 #define REFRESH_MENU_TEXTURE (1<<1)
200 #define REFRESH_MENU_FONT (1<<2)
201 #define REFRESH_MENU_COLOR (1<<3)
202 #define REFRESH_MENU_TITLE_TEXTURE (1<<4)
203 #define REFRESH_MENU_TITLE_FONT (1<<5)
204 #define REFRESH_MENU_TITLE_COLOR (1<<6)
205 #define REFRESH_WINDOW_TITLE_COLOR (1<<7)
206 #define REFRESH_WINDOW_FONT (1<<8)
207 #define REFRESH_ICON_TILE (1<<9)
208 #define REFRESH_ICON_FONT (1<<10)
209 #define REFRESH_WORKSPACE_BACK (1<<11)
211 #define REFRESH_BUTTON_IMAGES (1<<12)
213 #define REFRESH_ICON_TITLE_COLOR (1<<13)
214 #define REFRESH_ICON_TITLE_BACK (1<<14)
218 static WOptionEnumeration seFocusModes
[] = {
219 {"Manual", WKF_CLICK
, 0}, {"ClickToFocus", WKF_CLICK
, 1},
220 {"Sloppy", WKF_SLOPPY
, 0}, {"SemiAuto", WKF_SLOPPY
, 1}, {"Auto", WKF_SLOPPY
, 1},
224 static WOptionEnumeration seColormapModes
[] = {
225 {"Manual", WCM_CLICK
, 0}, {"ClickToFocus", WCM_CLICK
, 1},
226 {"Auto", WCM_POINTER
, 0}, {"FocusFollowMouse", WCM_POINTER
, 1},
230 static WOptionEnumeration sePlacements
[] = {
231 {"Auto", WPM_AUTO
, 0},
232 {"Smart", WPM_SMART
, 0},
233 {"Cascade", WPM_CASCADE
, 0},
234 {"Random", WPM_RANDOM
, 0},
235 {"Manual", WPM_MANUAL
, 0},
239 static WOptionEnumeration seGeomDisplays
[] = {
240 {"None", WDIS_NONE
, 0},
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 seMouseButtonActions
[] = {
258 {"None", WA_NONE
, 0},
259 {"SelectWindows", WA_SELECT_WINDOWS
, 0},
260 {"OpenApplicationsMenu", WA_OPEN_APPMENU
, 0},
261 {"OpenWindowListMenu", WA_OPEN_WINLISTMENU
, 0},
265 static WOptionEnumeration seMouseWheelActions
[] = {
266 {"None", WA_NONE
, 0},
267 {"SwitchWorkspaces", WA_SWITCH_WORKSPACES
, 0},
271 static WOptionEnumeration seIconificationStyles
[] = {
272 {"Zoom", WIS_ZOOM
, 0},
273 {"Twist", WIS_TWIST
, 0},
274 {"Flip", WIS_FLIP
, 0},
275 {"None", WIS_NONE
, 0},
276 {"random", WIS_RANDOM
, 0},
280 static WOptionEnumeration seJustifications
[] = {
281 {"Left", WTJ_LEFT
, 0},
282 {"Center", WTJ_CENTER
, 0},
283 {"Right", WTJ_RIGHT
, 0},
287 static WOptionEnumeration seIconPositions
[] = {
288 {"blv", IY_BOTTOM
|IY_LEFT
|IY_VERT
, 0},
289 {"blh", IY_BOTTOM
|IY_LEFT
|IY_HORIZ
, 0},
290 {"brv", IY_BOTTOM
|IY_RIGHT
|IY_VERT
, 0},
291 {"brh", IY_BOTTOM
|IY_RIGHT
|IY_HORIZ
, 0},
292 {"tlv", IY_TOP
|IY_LEFT
|IY_VERT
, 0},
293 {"tlh", IY_TOP
|IY_LEFT
|IY_HORIZ
, 0},
294 {"trv", IY_TOP
|IY_RIGHT
|IY_VERT
, 0},
295 {"trh", IY_TOP
|IY_RIGHT
|IY_HORIZ
, 0},
299 static WOptionEnumeration seMenuStyles
[] = {
300 {"normal", MS_NORMAL
, 0},
301 {"singletexture", MS_SINGLE_TEXTURE
, 0},
302 {"flat", MS_FLAT
, 0},
307 static WOptionEnumeration seDisplayPositions
[] = {
308 {"none", WD_NONE
, 0},
309 {"center", WD_CENTER
, 0},
311 {"bottom", WD_BOTTOM
, 0},
312 {"topleft", WD_TOPLEFT
, 0},
313 {"topright", WD_TOPRIGHT
, 0},
314 {"bottomleft", WD_BOTTOMLEFT
, 0},
315 {"bottomright", WD_BOTTOMRIGHT
, 0},
319 static WOptionEnumeration seWorkspaceBorder
[] = {
320 {"None", WB_NONE
, 0},
321 {"LeftRight", WB_LEFTRIGHT
, 0},
322 {"TopBottom", WB_TOPBOTTOM
, 0},
323 {"AllDirections", WB_ALLDIRS
, 0},
329 * ALL entries in the tables bellow, NEED to have a default value
330 * defined, and this value needs to be correct.
333 /* these options will only affect the window manager on startup
335 * static defaults can't access the screen data, because it is
336 * created after these defaults are read
338 WDefaultEntry staticOptionList
[] = {
340 {"ColormapSize", "4", NULL
,
341 &wPreferences
.cmap_size
, getInt
, NULL
343 {"DisableDithering", "NO", NULL
,
344 &wPreferences
.no_dithering
, getBool
, NULL
346 /* static by laziness */
347 {"IconSize", "64", NULL
,
348 &wPreferences
.icon_size
, getInt
, NULL
350 {"ModifierKey", "Mod1", NULL
,
351 &wPreferences
.modifier_mask
, getModMask
, NULL
353 {"DisableWSMouseActions", "NO", NULL
,
354 &wPreferences
.disable_root_mouse
, getBool
, NULL
356 {"FocusMode", "manual", seFocusModes
,
357 &wPreferences
.focus_mode
, getEnum
, NULL
358 }, /* have a problem when switching from manual to sloppy without restart */
359 {"NewStyle", "NO", NULL
,
360 &wPreferences
.new_style
, getBool
, NULL
362 {"DisableDock", "NO", (void*) WM_DOCK
,
363 NULL
, getBool
, setIfDockPresent
365 {"DisableClip", "NO", (void*) WM_CLIP
,
366 NULL
, getBool
, setIfDockPresent
368 {"DisableMiniwindows", "NO", NULL
,
369 &wPreferences
.disable_miniwindows
, getBool
, NULL
375 WDefaultEntry optionList
[] = {
376 /* dynamic options */
377 {"IconPosition", "blh", seIconPositions
,
378 &wPreferences
.icon_yard
, getEnum
, setIconPosition
380 {"IconificationStyle", "Zoom", seIconificationStyles
,
381 &wPreferences
.iconification_style
, getEnum
, NULL
383 {"MouseLeftButtonAction", "SelectWindows", seMouseButtonActions
,
384 &wPreferences
.mouse_button1
, getEnum
, NULL
386 {"MouseMiddleButtonAction", "OpenWindowListMenu", seMouseButtonActions
,
387 &wPreferences
.mouse_button2
, getEnum
, NULL
389 {"MouseRightButtonAction", "OpenApplicationsMenu", seMouseButtonActions
,
390 &wPreferences
.mouse_button3
, getEnum
, NULL
392 {"MouseWheelAction", "None", seMouseWheelActions
,
393 &wPreferences
.mouse_wheel
, getEnum
, NULL
395 {"PixmapPath", DEF_PIXMAP_PATHS
, NULL
,
396 &wPreferences
.pixmap_path
, getPathList
, NULL
398 {"IconPath", DEF_ICON_PATHS
, NULL
,
399 &wPreferences
.icon_path
, getPathList
, NULL
401 {"ColormapMode", "auto", seColormapModes
,
402 &wPreferences
.colormap_mode
, getEnum
, NULL
404 {"AutoFocus", "NO", NULL
,
405 &wPreferences
.auto_focus
, getBool
, NULL
407 {"RaiseDelay", "0", NULL
,
408 &wPreferences
.raise_delay
, getInt
, NULL
410 {"CirculateRaise", "NO", NULL
,
411 &wPreferences
.circ_raise
, getBool
, NULL
413 {"Superfluous", "NO", NULL
,
414 &wPreferences
.superfluous
, getBool
, NULL
416 {"AdvanceToNewWorkspace", "NO", NULL
,
417 &wPreferences
.ws_advance
, getBool
, NULL
419 {"CycleWorkspaces", "NO", NULL
,
420 &wPreferences
.ws_cycle
, getBool
, NULL
422 {"WorkspaceNameDisplayPosition", "center", seDisplayPositions
,
423 &wPreferences
.workspace_name_display_position
, getEnum
, NULL
425 {"WorkspaceBorder", "None", seWorkspaceBorder
,
426 &wPreferences
.workspace_border_position
, getEnum
, updateUsableArea
428 {"WorkspaceBorderSize", "0", NULL
,
429 &wPreferences
.workspace_border_size
, getInt
, updateUsableArea
431 #ifdef VIRTUAL_DESKTOP
432 {"EnableVirtualDesktop", "NO", NULL
,
433 &wPreferences
.vdesk_enable
, getBool
, setVirtualDeskEnable
435 {"VirtualEdgeExtendSpace", "0", NULL
,
436 &wPreferences
.vedge_bordersize
, getInt
, NULL
438 {"VirtualEdgeHorizonScrollSpeed", "30", NULL
,
439 &wPreferences
.vedge_hscrollspeed
, getInt
, NULL
441 {"VirtualEdgeVerticalScrollSpeed", "30", NULL
,
442 &wPreferences
.vedge_vscrollspeed
, getInt
, NULL
444 {"VirtualEdgeResistance", "30", NULL
,
445 &wPreferences
.vedge_resistance
, getInt
, NULL
447 {"VirtualEdgeAttraction", "30", NULL
,
448 &wPreferences
.vedge_attraction
, getInt
, NULL
450 {"VirtualEdgeLeftKey", "None", (void*)WKBD_VDESK_LEFT
,
451 NULL
, getKeybind
, setKeyGrab
453 {"VirtualEdgeRightKey", "None", (void*)WKBD_VDESK_RIGHT
,
454 NULL
, getKeybind
, setKeyGrab
456 {"VirtualEdgeUpKey", "None", (void*)WKBD_VDESK_UP
,
457 NULL
, getKeybind
, setKeyGrab
459 {"VirtualEdgeDownKey", "None", (void*)WKBD_VDESK_DOWN
,
460 NULL
, getKeybind
, setKeyGrab
463 {"StickyIcons", "NO", NULL
,
464 &wPreferences
.sticky_icons
, getBool
, setStickyIcons
466 {"SaveSessionOnExit", "NO", NULL
,
467 &wPreferences
.save_session_on_exit
, getBool
, NULL
469 {"WrapMenus", "NO", NULL
,
470 &wPreferences
.wrap_menus
, getBool
, NULL
472 {"ScrollableMenus", "NO", NULL
,
473 &wPreferences
.scrollable_menus
, getBool
, NULL
475 {"MenuScrollSpeed", "medium", seSpeeds
,
476 &wPreferences
.menu_scroll_speed
, getEnum
, NULL
478 {"IconSlideSpeed", "medium", seSpeeds
,
479 &wPreferences
.icon_slide_speed
, getEnum
, NULL
481 {"ShadeSpeed", "medium", seSpeeds
,
482 &wPreferences
.shade_speed
, getEnum
, NULL
484 {"DoubleClickTime", "250", (void*) &wPreferences
.dblclick_time
,
485 &wPreferences
.dblclick_time
, getInt
, setDoubleClick
,
487 {"AlignSubmenus", "NO", NULL
,
488 &wPreferences
.align_menus
, getBool
, NULL
490 {"OpenTransientOnOwnerWorkspace", "NO", NULL
,
491 &wPreferences
.open_transients_with_parent
, getBool
, NULL
493 {"WindowPlacement", "auto", sePlacements
,
494 &wPreferences
.window_placement
, getEnum
, NULL
496 {"IgnoreFocusClick","NO", NULL
,
497 &wPreferences
.ignore_focus_click
, getBool
, NULL
499 {"UseSaveUnders", "NO", NULL
,
500 &wPreferences
.use_saveunders
, getBool
, NULL
502 {"OpaqueMove", "NO", NULL
,
503 &wPreferences
.opaque_move
, getBool
, NULL
505 {"DisableSound", "NO", NULL
,
506 &wPreferences
.no_sound
, getBool
, NULL
508 {"DisableAnimations", "NO", NULL
,
509 &wPreferences
.no_animations
, getBool
, NULL
511 {"DontLinkWorkspaces","NO", NULL
,
512 &wPreferences
.no_autowrap
, getBool
, NULL
514 {"AutoArrangeIcons", "NO", NULL
,
515 &wPreferences
.auto_arrange_icons
, getBool
, NULL
517 {"NoWindowOverDock", "NO", NULL
,
518 &wPreferences
.no_window_over_dock
, getBool
, updateUsableArea
520 {"NoWindowOverIcons", "NO", NULL
,
521 &wPreferences
.no_window_over_icons
, getBool
, updateUsableArea
523 {"WindowPlaceOrigin", "(0, 0)", NULL
,
524 &wPreferences
.window_place_origin
, getCoord
, NULL
526 {"ResizeDisplay", "corner", seGeomDisplays
,
527 &wPreferences
.size_display
, getEnum
, NULL
529 {"MoveDisplay", "corner", seGeomDisplays
,
530 &wPreferences
.move_display
, getEnum
, NULL
532 {"DontConfirmKill", "NO", NULL
,
533 &wPreferences
.dont_confirm_kill
, getBool
,NULL
535 {"WindowTitleBalloons", "NO", NULL
,
536 &wPreferences
.window_balloon
, getBool
, NULL
538 {"MiniwindowTitleBalloons", "NO", NULL
,
539 &wPreferences
.miniwin_balloon
,getBool
, NULL
541 {"AppIconBalloons", "NO", NULL
,
542 &wPreferences
.appicon_balloon
,getBool
, NULL
544 {"HelpBalloons", "NO", NULL
,
545 &wPreferences
.help_balloon
, getBool
, NULL
547 {"EdgeResistance", "30", NULL
,
548 &wPreferences
.edge_resistance
,getInt
, NULL
550 {"Attraction", "NO", NULL
,
551 &wPreferences
.attract
, getBool
, NULL
553 {"DisableBlinking", "NO", NULL
,
554 &wPreferences
.dont_blink
, getBool
, NULL
557 {"MenuStyle", "normal", seMenuStyles
,
558 &wPreferences
.menu_style
, getEnum
, setMenuStyle
560 {"WidgetColor", "(solid, gray)", NULL
,
561 NULL
, getTexture
, setWidgetColor
,
563 {"WorkspaceSpecificBack","()", NULL
,
564 NULL
, getWSSpecificBackground
, setWorkspaceSpecificBack
566 /* WorkspaceBack must come after WorkspaceSpecificBack or
567 * WorkspaceBack wont know WorkspaceSpecificBack was also
568 * specified and 2 copies of wmsetbg will be launched */
569 {"WorkspaceBack", "(solid, black)", NULL
,
570 NULL
, getWSBackground
,setWorkspaceBack
572 {"SmoothWorkspaceBack", "NO", NULL
,
575 {"IconBack", "(solid, gray)", NULL
,
576 NULL
, getTexture
, setIconTile
578 {"TitleJustify", "center", seJustifications
,
579 &wPreferences
.title_justification
, getEnum
, setJustify
581 {"WindowTitleFont", DEF_TITLE_FONT
, NULL
,
582 NULL
, getFont
, setWinTitleFont
,
584 {"WindowTitleExtendSpace", DEF_WINDOW_TITLE_EXTEND_SPACE
, NULL
,
585 &wPreferences
.window_title_clearance
, getInt
, setClearance
587 {"MenuTitleExtendSpace", DEF_MENU_TITLE_EXTEND_SPACE
, NULL
,
588 &wPreferences
.menu_title_clearance
, getInt
, setClearance
590 {"MenuTextExtendSpace", DEF_MENU_TEXT_EXTEND_SPACE
, NULL
,
591 &wPreferences
.menu_text_clearance
, getInt
, setClearance
593 {"MenuTitleFont", DEF_MENU_TITLE_FONT
, NULL
,
594 NULL
, getFont
, setMenuTitleFont
596 {"MenuTextFont", DEF_MENU_ENTRY_FONT
, NULL
,
597 NULL
, getFont
, setMenuTextFont
599 {"IconTitleFont", DEF_ICON_TITLE_FONT
, NULL
,
600 NULL
, getFont
, setIconTitleFont
602 {"ClipTitleFont", DEF_CLIP_TITLE_FONT
, NULL
,
603 NULL
, getFont
, setClipTitleFont
605 {"LargeDisplayFont",DEF_WORKSPACE_NAME_FONT
, NULL
,
606 NULL
, getFont
, setLargeDisplayFont
608 {"HighlightColor", "white", NULL
,
609 NULL
, getColor
, setHightlight
611 {"HighlightTextColor", "black", NULL
,
612 NULL
, getColor
, setHightlightText
614 {"ClipTitleColor", "black", (void*)CLIP_NORMAL
,
615 NULL
, getColor
, setClipTitleColor
617 {"CClipTitleColor", "\"#454045\"", (void*)CLIP_COLLAPSED
,
618 NULL
, getColor
, setClipTitleColor
620 {"FTitleColor", "white", (void*)WS_FOCUSED
,
621 NULL
, getColor
, setWTitleColor
623 {"PTitleColor", "white", (void*)WS_PFOCUSED
,
624 NULL
, getColor
, setWTitleColor
626 {"UTitleColor", "black", (void*)WS_UNFOCUSED
,
627 NULL
, getColor
, setWTitleColor
629 {"FTitleBack", "(solid, black)", NULL
,
630 NULL
, getTexture
, setFTitleBack
632 {"PTitleBack", "(solid, \"#616161\")", NULL
,
633 NULL
, getTexture
, setPTitleBack
635 {"UTitleBack", "(solid, gray)", NULL
,
636 NULL
, getTexture
, setUTitleBack
638 {"ResizebarBack", "(solid, gray)", NULL
,
639 NULL
, getTexture
, setResizebarBack
641 {"MenuTitleColor", "white", NULL
,
642 NULL
, getColor
, setMenuTitleColor
644 {"MenuTextColor", "black", NULL
,
645 NULL
, getColor
, setMenuTextColor
647 {"MenuDisabledColor", "\"#616161\"", NULL
,
648 NULL
, getColor
, setMenuDisabledColor
650 {"MenuTitleBack", "(solid, black)", NULL
,
651 NULL
, getTexture
, setMenuTitleBack
653 {"MenuTextBack", "(solid, gray)", NULL
,
654 NULL
, getTexture
, setMenuTextBack
656 {"IconTitleColor", "white", NULL
,
657 NULL
, getColor
, setIconTitleColor
659 {"IconTitleBack", "black", NULL
,
660 NULL
, getColor
, setIconTitleBack
662 {"SwitchPanelImages", "(swtile.png, swback.png, 30, 40)", &wPreferences
,
663 NULL
, getPropList
, setSwPOptions
667 {"RootMenuKey", "None", (void*)WKBD_ROOTMENU
,
668 NULL
, getKeybind
, setKeyGrab
670 {"WindowListKey", "None", (void*)WKBD_WINDOWLIST
,
671 NULL
, getKeybind
, setKeyGrab
674 {"WindowMenuKey", "None", (void*)WKBD_WINDOWMENU
,
675 NULL
, getKeybind
, setKeyGrab
677 {"ClipLowerKey", "None", (void*)WKBD_CLIPLOWER
,
678 NULL
, getKeybind
, setKeyGrab
680 {"ClipRaiseKey", "None", (void*)WKBD_CLIPRAISE
,
681 NULL
, getKeybind
, setKeyGrab
683 {"ClipRaiseLowerKey", "None", (void*)WKBD_CLIPRAISELOWER
,
684 NULL
, getKeybind
, setKeyGrab
686 {"MiniaturizeKey", "None", (void*)WKBD_MINIATURIZE
,
687 NULL
, getKeybind
, setKeyGrab
689 {"HideKey", "None", (void*)WKBD_HIDE
,
690 NULL
, getKeybind
, setKeyGrab
692 {"HideOthersKey", "None", (void*)WKBD_HIDE_OTHERS
,
693 NULL
, getKeybind
, setKeyGrab
695 {"MoveResizeKey", "None", (void*)WKBD_MOVERESIZE
,
696 NULL
, getKeybind
, setKeyGrab
698 {"CloseKey", "None", (void*)WKBD_CLOSE
,
699 NULL
, getKeybind
, setKeyGrab
701 {"MaximizeKey", "None", (void*)WKBD_MAXIMIZE
,
702 NULL
, getKeybind
, setKeyGrab
704 {"VMaximizeKey", "None", (void*)WKBD_VMAXIMIZE
,
705 NULL
, getKeybind
, setKeyGrab
707 {"HMaximizeKey", "None", (void*)WKBD_HMAXIMIZE
,
708 NULL
, getKeybind
, setKeyGrab
710 {"RaiseKey", "\"Meta+Up\"", (void*)WKBD_RAISE
,
711 NULL
, getKeybind
, setKeyGrab
713 {"LowerKey", "\"Meta+Down\"", (void*)WKBD_LOWER
,
714 NULL
, getKeybind
, setKeyGrab
716 {"RaiseLowerKey", "None", (void*)WKBD_RAISELOWER
,
717 NULL
, getKeybind
, setKeyGrab
719 {"ShadeKey", "None", (void*)WKBD_SHADE
,
720 NULL
, getKeybind
, setKeyGrab
722 {"SelectKey", "None", (void*)WKBD_SELECT
,
723 NULL
, getKeybind
, setKeyGrab
725 {"FocusNextKey", "None", (void*)WKBD_FOCUSNEXT
,
726 NULL
, getKeybind
, setKeyGrab
728 {"FocusPrevKey", "None", (void*)WKBD_FOCUSPREV
,
729 NULL
, getKeybind
, setKeyGrab
731 {"NextWorkspaceKey", "None", (void*)WKBD_NEXTWORKSPACE
,
732 NULL
, getKeybind
, setKeyGrab
734 {"PrevWorkspaceKey", "None", (void*)WKBD_PREVWORKSPACE
,
735 NULL
, getKeybind
, setKeyGrab
737 {"NextWorkspaceLayerKey", "None", (void*)WKBD_NEXTWSLAYER
,
738 NULL
, getKeybind
, setKeyGrab
740 {"PrevWorkspaceLayerKey", "None", (void*)WKBD_PREVWSLAYER
,
741 NULL
, getKeybind
, setKeyGrab
743 {"Workspace1Key", "None", (void*)WKBD_WORKSPACE1
,
744 NULL
, getKeybind
, setKeyGrab
746 {"Workspace2Key", "None", (void*)WKBD_WORKSPACE2
,
747 NULL
, getKeybind
, setKeyGrab
749 {"Workspace3Key", "None", (void*)WKBD_WORKSPACE3
,
750 NULL
, getKeybind
, setKeyGrab
752 {"Workspace4Key", "None", (void*)WKBD_WORKSPACE4
,
753 NULL
, getKeybind
, setKeyGrab
755 {"Workspace5Key", "None", (void*)WKBD_WORKSPACE5
,
756 NULL
, getKeybind
, setKeyGrab
758 {"Workspace6Key", "None", (void*)WKBD_WORKSPACE6
,
759 NULL
, getKeybind
, setKeyGrab
761 {"Workspace7Key", "None", (void*)WKBD_WORKSPACE7
,
762 NULL
, getKeybind
, setKeyGrab
764 {"Workspace8Key", "None", (void*)WKBD_WORKSPACE8
,
765 NULL
, getKeybind
, setKeyGrab
767 {"Workspace9Key", "None", (void*)WKBD_WORKSPACE9
,
768 NULL
, getKeybind
, setKeyGrab
770 {"Workspace10Key", "None", (void*)WKBD_WORKSPACE10
,
771 NULL
, getKeybind
, setKeyGrab
773 {"WindowShortcut1Key","None", (void*)WKBD_WINDOW1
,
774 NULL
, getKeybind
, setKeyGrab
776 {"WindowShortcut2Key","None", (void*)WKBD_WINDOW2
,
777 NULL
, getKeybind
, setKeyGrab
779 {"WindowShortcut3Key","None", (void*)WKBD_WINDOW3
,
780 NULL
, getKeybind
, setKeyGrab
782 {"WindowShortcut4Key","None", (void*)WKBD_WINDOW4
,
783 NULL
, getKeybind
, setKeyGrab
785 ,{"WindowShortcut5Key","None", (void*)WKBD_WINDOW5
,
786 NULL
, getKeybind
, setKeyGrab
788 {"WindowShortcut6Key","None", (void*)WKBD_WINDOW6
,
789 NULL
, getKeybind
, setKeyGrab
791 {"WindowShortcut7Key","None", (void*)WKBD_WINDOW7
,
792 NULL
, getKeybind
, setKeyGrab
794 {"WindowShortcut8Key","None", (void*)WKBD_WINDOW8
,
795 NULL
, getKeybind
, setKeyGrab
797 {"WindowShortcut9Key","None", (void*)WKBD_WINDOW9
,
798 NULL
, getKeybind
, setKeyGrab
800 {"WindowShortcut10Key","None", (void*)WKBD_WINDOW10
,
801 NULL
, getKeybind
, setKeyGrab
803 {"ScreenSwitchKey", "None", (void*)WKBD_SWITCH_SCREEN
,
804 NULL
, getKeybind
, setKeyGrab
807 #ifdef KEEP_XKB_LOCK_STATUS
808 {"ToggleKbdModeKey", "None", (void*)WKBD_TOGGLE
,
809 NULL
, getKeybind
, setKeyGrab
811 {"KbdModeLock", "NO", NULL
,
812 &wPreferences
.modelock
, getBool
, NULL
814 #endif /* KEEP_XKB_LOCK_STATUS */
816 {"NormalCursor", "(builtin, left_ptr)", (void*)WCUR_ROOT
,
817 NULL
, getCursor
, setCursor
819 {"ArrowCursor", "(builtin, top_left_arrow)", (void*)WCUR_ARROW
,
820 NULL
, getCursor
, setCursor
822 {"MoveCursor", "(builtin, fleur)", (void*)WCUR_MOVE
,
823 NULL
, getCursor
, setCursor
825 {"ResizeCursor", "(builtin, sizing)", (void*)WCUR_RESIZE
,
826 NULL
, getCursor
, setCursor
828 {"TopLeftResizeCursor", "(builtin, top_left_corner)",
829 (void*)WCUR_TOPLEFTRESIZE
,
830 NULL
, getCursor
, setCursor
832 {"TopRightResizeCursor", "(builtin, top_right_corner)",
833 (void*)WCUR_TOPRIGHTRESIZE
,
834 NULL
, getCursor
, setCursor
836 {"BottomLeftResizeCursor", "(builtin, bottom_left_corner)",
837 (void*)WCUR_BOTTOMLEFTRESIZE
,
838 NULL
, getCursor
, setCursor
840 {"BottomRightResizeCursor", "(builtin, bottom_right_corner)",
841 (void*)WCUR_BOTTOMRIGHTRESIZE
,
842 NULL
, getCursor
, setCursor
844 {"VerticalResizeCursor", "(builtin, sb_v_double_arrow)",
845 (void*)WCUR_VERTICALRESIZE
,
846 NULL
, getCursor
, setCursor
848 {"HorizontalResizeCursor", "(builtin, sb_h_double_arrow)",
849 (void*)WCUR_HORIZONRESIZE
,
850 NULL
, getCursor
, setCursor
852 {"WaitCursor", "(builtin, watch)", (void*)WCUR_WAIT
,
853 NULL
, getCursor
, setCursor
855 {"QuestionCursor", "(builtin, question_arrow)", (void*)WCUR_QUESTION
,
856 NULL
, getCursor
, setCursor
858 {"TextCursor", "(builtin, xterm)", (void*)WCUR_TEXT
,
859 NULL
, getCursor
, setCursor
861 {"SelectCursor", "(builtin, cross)", (void*)WCUR_SELECT
,
862 NULL
, getCursor
, setCursor
868 static void rereadDefaults(void);
875 /* must defer the update because accessing X data from a
876 * signal handler can mess up Xlib */
885 WDefaultEntry
*entry
;
887 WMPLSetCaseSensitive(False
);
889 for (i
=0; i
<sizeof(optionList
)/sizeof(WDefaultEntry
); i
++) {
890 entry
= &optionList
[i
];
892 entry
->plkey
= WMCreatePLString(entry
->key
);
893 if (entry
->default_value
)
894 entry
->plvalue
= WMCreatePropListFromDescription(entry
->default_value
);
896 entry
->plvalue
= NULL
;
899 for (i
=0; i
<sizeof(staticOptionList
)/sizeof(WDefaultEntry
); i
++) {
900 entry
= &staticOptionList
[i
];
902 entry
->plkey
= WMCreatePLString(entry
->key
);
903 if (entry
->default_value
)
904 entry
->plvalue
= WMCreatePropListFromDescription(entry
->default_value
);
906 entry
->plvalue
= NULL
;
910 wDomainName = WMCreatePLString(WMDOMAIN_NAME);
911 wAttributeDomainName = WMCreatePLString(WMATTRIBUTE_DOMAIN_NAME);
913 PLRegister(wDomainName, rereadDefaults);
914 PLRegister(wAttributeDomainName, rereadDefaults);
920 readGlobalDomain(char *domainName
, Bool requireDictionary
)
922 WMPropList
*globalDict
= NULL
;
926 snprintf(path
, sizeof(path
), "%s/WindowMaker/%s", SYSCONFDIR
, domainName
);
927 if (stat(path
, &stbuf
)>=0) {
928 globalDict
= WMReadPropListFromFile(path
);
929 if (globalDict
&& requireDictionary
&& !WMIsPLDictionary(globalDict
)) {
930 wwarning(_("Domain %s (%s) of global defaults database is corrupted!"),
932 WMReleasePropList(globalDict
);
934 } else if (!globalDict
) {
935 wwarning(_("could not load domain %s from global defaults database"),
944 #if defined(GLOBAL_PREAMBLE_MENU_FILE) || defined(GLOBAL_EPILOGUE_MENU_FILE)
946 prependMenu(WMPropList
*destarr
, WMPropList
*array
)
951 for (i
=0; i
<WMGetPropListItemCount(array
); i
++) {
952 item
= WMGetFromPLArray(array
, i
);
954 WMInsertInPLArray(destarr
, i
+1, item
);
960 appendMenu(WMPropList
*destarr
, WMPropList
*array
)
965 for (i
=0; i
<WMGetPropListItemCount(array
); i
++) {
966 item
= WMGetFromPLArray(array
, i
);
968 WMAddToPLArray(destarr
, item
);
974 /* Fixup paths for cached pixmaps from .AppInfo to Library/WindowMaker/... */
976 fixupCachedPixmapsPaths(WMPropList
*dict
)
978 WMPropList
*allApps
, *app
, *props
, *iconkey
, *icon
, *newicon
;
979 char *path
, *fixedpath
, *ptr
, *search
, *replace
;
981 Bool changed
= False
;
983 search
= "/.AppInfo/WindowMaker/";
984 slen
= strlen(search
);
986 iconkey
= WMCreatePLString("Icon");
987 allApps
= WMGetPLDictionaryKeys(dict
);
989 for (i
=0; i
< WMGetPropListItemCount(allApps
); i
++) {
990 app
= WMGetFromPLArray(allApps
, i
);
991 props
= WMGetFromPLDictionary(dict
, app
);
994 icon
= WMGetFromPLDictionary(props
, iconkey
);
995 if (icon
&& WMIsPLString(icon
)) {
996 path
= WMGetFromPLString(icon
);
997 ptr
= strstr(path
, search
);
1001 fixedpath
= wmalloc(strlen(path
)+32);
1002 strncpy(fixedpath
, path
, len
);
1004 strcat(fixedpath
, "/Library/WindowMaker/CachedPixmaps/");
1005 strcat(fixedpath
, ptr
+slen
);
1006 newicon
= WMCreatePLString(fixedpath
);
1007 WMPutInPLDictionary(props
, iconkey
, newicon
);
1008 WMReleasePropList(newicon
);
1014 WMReleasePropList(allApps
);
1015 WMReleasePropList(iconkey
);
1022 wDefaultsMergeGlobalMenus(WDDomain
*menuDomain
)
1024 WMPropList
*menu
= menuDomain
->dictionary
;
1025 WMPropList
*submenu
;
1027 if (!menu
|| !WMIsPLArray(menu
))
1030 #ifdef GLOBAL_PREAMBLE_MENU_FILE
1031 submenu
= WMReadPropListFromFile(SYSCONFDIR
"/WindowMaker/"GLOBAL_PREAMBLE_MENU_FILE
);
1033 if (submenu
&& !WMIsPLArray(submenu
)) {
1034 wwarning(_("invalid global menu file %s"),
1035 GLOBAL_PREAMBLE_MENU_FILE
);
1036 WMReleasePropList(submenu
);
1040 prependMenu(menu
, submenu
);
1041 WMReleasePropList(submenu
);
1045 #ifdef GLOBAL_EPILOGUE_MENU_FILE
1046 submenu
= WMReadPropListFromFile(SYSCONFDIR
"/WindowMaker/"GLOBAL_EPILOGUE_MENU_FILE
);
1048 if (submenu
&& !WMIsPLArray(submenu
)) {
1049 wwarning(_("invalid global menu file %s"),
1050 GLOBAL_EPILOGUE_MENU_FILE
);
1051 WMReleasePropList(submenu
);
1055 appendMenu(menu
, submenu
);
1056 WMReleasePropList(submenu
);
1060 menuDomain
->dictionary
= menu
;
1066 wDefaultsInit(int screen_number
)
1068 static int defaults_inited
= 0;
1071 if (!defaults_inited
) {
1075 dict
= PLGetDomain(wDomainName
);
1077 wwarning(_("could not read domain \"%s\" from defaults database"),
1078 WMGetFromPLString(wDomainName
));
1087 wDefaultsDestroyDomain(WDDomain
*domain
)
1089 if (domain
->dictionary
)
1090 WMReleasePropList(domain
->dictionary
);
1091 wfree(domain
->path
);
1097 wDefaultsInitDomain(char *domain
, Bool requireDictionary
)
1101 static int inited
= 0;
1102 char path
[PATH_MAX
];
1104 WMPropList
*shared_dict
=NULL
;
1111 db
= wmalloc(sizeof(WDDomain
));
1112 memset(db
, 0, sizeof(WDDomain
));
1113 db
->domain_name
= domain
;
1114 db
->path
= wdefaultspathfordomain(domain
);
1115 the_path
= db
->path
;
1117 if (the_path
&& stat(the_path
, &stbuf
)>=0) {
1118 db
->dictionary
= WMReadPropListFromFile(the_path
);
1119 if (db
->dictionary
) {
1120 if (requireDictionary
&& !WMIsPLDictionary(db
->dictionary
)) {
1121 WMReleasePropList(db
->dictionary
);
1122 db
->dictionary
= NULL
;
1123 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
1126 if (strcmp(domain
, "WMWindowAttributes")==0 && db
->dictionary
) {
1127 if (fixupCachedPixmapsPaths(db
->dictionary
)) {
1128 WMWritePropListToFile(db
->dictionary
, db
->path
, True
);
1129 /* re-read the timestamp. if this fails take current time */
1130 if (stat(db
->path
, &stbuf
)<0) {
1131 stbuf
.st_mtime
= time(NULL
);
1135 db
->timestamp
= stbuf
.st_mtime
;
1137 wwarning(_("could not load domain %s from user defaults database"),
1142 /* global system dictionary */
1143 snprintf(path
, sizeof(path
), "%s/WindowMaker/%s", SYSCONFDIR
, domain
);
1144 if (stat(path
, &stbuf
)>=0) {
1145 shared_dict
= WMReadPropListFromFile(path
);
1147 if (requireDictionary
&& !WMIsPLDictionary(shared_dict
)) {
1148 wwarning(_("Domain %s (%s) of global defaults database is corrupted!"),
1150 WMReleasePropList(shared_dict
);
1153 if (db
->dictionary
&& WMIsPLDictionary(shared_dict
) &&
1154 WMIsPLDictionary(db
->dictionary
)) {
1155 WMMergePLDictionaries(shared_dict
, db
->dictionary
, True
);
1156 WMReleasePropList(db
->dictionary
);
1157 db
->dictionary
= shared_dict
;
1158 if (stbuf
.st_mtime
> db
->timestamp
)
1159 db
->timestamp
= stbuf
.st_mtime
;
1160 } else if (!db
->dictionary
) {
1161 db
->dictionary
= shared_dict
;
1162 if (stbuf
.st_mtime
> db
->timestamp
)
1163 db
->timestamp
= stbuf
.st_mtime
;
1167 wwarning(_("could not load domain %s from global defaults database (%s)"),
1177 wReadStaticDefaults(WMPropList
*dict
)
1179 WMPropList
*plvalue
;
1180 WDefaultEntry
*entry
;
1185 for (i
=0; i
<sizeof(staticOptionList
)/sizeof(WDefaultEntry
); i
++) {
1186 entry
= &staticOptionList
[i
];
1189 plvalue
= WMGetFromPLDictionary(dict
, entry
->plkey
);
1194 /* no default in the DB. Use builtin default */
1195 plvalue
= entry
->plvalue
;
1200 (*entry
->convert
)(NULL
, entry
, plvalue
, entry
->addr
, &tdata
);
1201 if (entry
->update
) {
1202 (*entry
->update
)(NULL
, entry
, tdata
, entry
->extra_data
);
1211 wDefaultsCheckDomains(void *foo
)
1215 WMPropList
*shared_dict
= NULL
;
1220 puts("Checking domains...");
1222 if (stat(WDWindowMaker
->path
, &stbuf
)>=0
1223 && WDWindowMaker
->timestamp
< stbuf
.st_mtime
) {
1225 puts("Checking WindowMaker domain");
1227 WDWindowMaker
->timestamp
= stbuf
.st_mtime
;
1229 /* global dictionary */
1230 shared_dict
= readGlobalDomain("WindowMaker", True
);
1231 /* user dictionary */
1232 dict
= WMReadPropListFromFile(WDWindowMaker
->path
);
1234 if (!WMIsPLDictionary(dict
)) {
1235 WMReleasePropList(dict
);
1237 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
1238 "WindowMaker", WDWindowMaker
->path
);
1241 WMMergePLDictionaries(shared_dict
, dict
, True
);
1242 WMReleasePropList(dict
);
1246 for (i
=0; i
<wScreenCount
; i
++) {
1247 scr
= wScreenWithNumber(i
);
1249 wReadDefaults(scr
, dict
);
1251 if (WDWindowMaker
->dictionary
) {
1252 WMReleasePropList(WDWindowMaker
->dictionary
);
1254 WDWindowMaker
->dictionary
= dict
;
1257 wwarning(_("could not load domain %s from user defaults database"),
1261 WMReleasePropList(shared_dict
);
1265 if (stat(WDWindowAttributes
->path
, &stbuf
)>=0
1266 && WDWindowAttributes
->timestamp
< stbuf
.st_mtime
) {
1268 puts("Checking WMWindowAttributes domain");
1270 /* global dictionary */
1271 shared_dict
= readGlobalDomain("WMWindowAttributes", True
);
1272 /* user dictionary */
1273 dict
= WMReadPropListFromFile(WDWindowAttributes
->path
);
1275 if (!WMIsPLDictionary(dict
)) {
1276 WMReleasePropList(dict
);
1278 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
1279 "WMWindowAttributes", WDWindowAttributes
->path
);
1282 WMMergePLDictionaries(shared_dict
, dict
, True
);
1283 WMReleasePropList(dict
);
1287 if (WDWindowAttributes
->dictionary
) {
1288 WMReleasePropList(WDWindowAttributes
->dictionary
);
1290 WDWindowAttributes
->dictionary
= dict
;
1291 for (i
=0; i
<wScreenCount
; i
++) {
1292 scr
= wScreenWithNumber(i
);
1296 wDefaultUpdateIcons(scr
);
1298 /* Update the panel image if changed */
1299 /* Don't worry. If the image is the same these
1300 * functions will have no performance impact. */
1301 image
= wDefaultGetImage(scr
, "Logo", "WMPanel");
1304 wwarning(_("could not load logo image for panels: %s"),
1305 RMessageForError(RErrorCode
));
1307 WMSetApplicationIconImage(scr
->wmscreen
, image
);
1308 RReleaseImage(image
);
1314 wwarning(_("could not load domain %s from user defaults database"),
1315 "WMWindowAttributes");
1317 WDWindowAttributes
->timestamp
= stbuf
.st_mtime
;
1319 WMReleasePropList(shared_dict
);
1324 if (stat(WDRootMenu
->path
, &stbuf
)>=0
1325 && WDRootMenu
->timestamp
< stbuf
.st_mtime
) {
1326 dict
= WMReadPropListFromFile(WDRootMenu
->path
);
1328 puts("Checking WMRootMenu domain");
1331 if (!WMIsPLArray(dict
) && !WMIsPLString(dict
)) {
1332 WMReleasePropList(dict
);
1334 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
1335 "WMRootMenu", WDRootMenu
->path
);
1337 if (WDRootMenu
->dictionary
) {
1338 WMReleasePropList(WDRootMenu
->dictionary
);
1340 WDRootMenu
->dictionary
= dict
;
1341 wDefaultsMergeGlobalMenus(WDRootMenu
);
1344 wwarning(_("could not load domain %s from user defaults database"),
1347 WDRootMenu
->timestamp
= stbuf
.st_mtime
;
1352 WMAddTimerHandler(DEFAULTS_CHECK_INTERVAL
, wDefaultsCheckDomains
, foo
);
1357 wReadDefaults(WScreen
*scr
, WMPropList
*new_dict
)
1359 WMPropList
*plvalue
, *old_value
;
1360 WDefaultEntry
*entry
;
1362 int update_workspace_back
= 0; /* kluge :/ */
1365 WMPropList
*old_dict
= (WDWindowMaker
->dictionary
!=new_dict
1366 ? WDWindowMaker
->dictionary
: NULL
);
1372 for (i
=0; i
<sizeof(optionList
)/sizeof(WDefaultEntry
); i
++) {
1373 entry
= &optionList
[i
];
1376 plvalue
= WMGetFromPLDictionary(new_dict
, entry
->plkey
);
1383 old_value
= WMGetFromPLDictionary(old_dict
, entry
->plkey
);
1386 if (!plvalue
&& !old_value
) {
1387 /* no default in the DB. Use builtin default */
1388 plvalue
= entry
->plvalue
;
1389 if (plvalue
&& new_dict
) {
1390 WMPutInPLDictionary(new_dict
, entry
->plkey
, plvalue
);
1393 } else if (!plvalue
) {
1394 /* value was deleted from DB. Keep current value */
1396 } else if (!old_value
) {
1397 /* set value for the 1st time */
1398 } else if (!WMIsPropListEqualTo(plvalue
, old_value
)) {
1399 /* value has changed */
1402 if (strcmp(entry
->key
, "WorkspaceBack") == 0
1403 && update_workspace_back
1404 && scr
->flags
.backimage_helper_launched
) {
1406 /* value was not changed since last time */
1413 printf("Updating %s to %s\n", entry
->key
,
1414 WMGetPropListDescription(plvalue
, False
));
1417 if ((*entry
->convert
)(scr
, entry
, plvalue
, entry
->addr
, &tdata
)) {
1419 * If the WorkspaceSpecificBack data has been changed
1420 * so that the helper will be launched now, we must be
1421 * sure to send the default background texture config
1424 if (strcmp(entry
->key
, "WorkspaceSpecificBack") == 0
1425 && !scr
->flags
.backimage_helper_launched
) {
1426 update_workspace_back
= 1;
1428 if (entry
->update
) {
1430 (*entry
->update
)(scr
, entry
, tdata
, entry
->extra_data
);
1436 if (needs_refresh
!=0 && !scr
->flags
.startup
) {
1440 if (needs_refresh
& REFRESH_MENU_TITLE_TEXTURE
)
1441 foo
|= WTextureSettings
;
1442 if (needs_refresh
& REFRESH_MENU_TITLE_FONT
)
1443 foo
|= WFontSettings
;
1444 if (needs_refresh
& REFRESH_MENU_TITLE_COLOR
)
1445 foo
|= WColorSettings
;
1447 WMPostNotificationName(WNMenuTitleAppearanceSettingsChanged
, NULL
,
1451 if (needs_refresh
& REFRESH_MENU_TEXTURE
)
1452 foo
|= WTextureSettings
;
1453 if (needs_refresh
& REFRESH_MENU_FONT
)
1454 foo
|= WFontSettings
;
1455 if (needs_refresh
& REFRESH_MENU_COLOR
)
1456 foo
|= WColorSettings
;
1458 WMPostNotificationName(WNMenuAppearanceSettingsChanged
, NULL
,
1462 if (needs_refresh
& REFRESH_WINDOW_FONT
) {
1463 foo
|= WFontSettings
;
1465 if (needs_refresh
& REFRESH_WINDOW_TEXTURES
) {
1466 foo
|= WTextureSettings
;
1468 if (needs_refresh
& REFRESH_WINDOW_TITLE_COLOR
) {
1469 foo
|= WColorSettings
;
1472 WMPostNotificationName(WNWindowAppearanceSettingsChanged
, NULL
,
1475 if (!(needs_refresh
& REFRESH_ICON_TILE
)) {
1477 if (needs_refresh
& REFRESH_ICON_FONT
) {
1478 foo
|= WFontSettings
;
1480 if (needs_refresh
& REFRESH_ICON_TITLE_COLOR
) {
1481 foo
|= WTextureSettings
;
1483 if (needs_refresh
& REFRESH_ICON_TITLE_BACK
) {
1484 foo
|= WTextureSettings
;
1487 WMPostNotificationName(WNIconAppearanceSettingsChanged
, NULL
,
1490 if (needs_refresh
& REFRESH_ICON_TILE
)
1491 WMPostNotificationName(WNIconTileSettingsChanged
, NULL
, NULL
);
1497 wDefaultUpdateIcons(WScreen
*scr
)
1499 WAppIcon
*aicon
= scr
->app_icon_list
;
1500 WWindow
*wwin
= scr
->focused_window
;
1504 file
= wDefaultGetIconFile(scr
, aicon
->wm_instance
, aicon
->wm_class
,
1506 if ((file
&& aicon
->icon
->file
&& strcmp(file
, aicon
->icon
->file
)!=0)
1507 || (file
&& !aicon
->icon
->file
)) {
1510 if (aicon
->icon
->file
)
1511 wfree(aicon
->icon
->file
);
1512 aicon
->icon
->file
= wstrdup(file
);
1514 new_image
= wDefaultGetImage(scr
, aicon
->wm_instance
,
1517 wIconChangeImage(aicon
->icon
, new_image
);
1518 wAppIconPaint(aicon
);
1521 aicon
= aicon
->next
;
1524 if (!wPreferences
.flags
.noclip
)
1525 wClipIconPaint(scr
->clip_icon
);
1528 if (wwin
->icon
&& wwin
->flags
.miniaturized
) {
1529 file
= wDefaultGetIconFile(scr
, wwin
->wm_instance
, wwin
->wm_class
,
1531 if ((file
&& wwin
->icon
->file
&& strcmp(file
, wwin
->icon
->file
)!=0)
1532 || (file
&& !wwin
->icon
->file
)) {
1535 if (wwin
->icon
->file
)
1536 wfree(wwin
->icon
->file
);
1537 wwin
->icon
->file
= wstrdup(file
);
1539 new_image
= wDefaultGetImage(scr
, wwin
->wm_instance
,
1542 wIconChangeImage(wwin
->icon
, new_image
);
1550 /* --------------------------- Local ----------------------- */
1552 #define GET_STRING_OR_DEFAULT(x, var) if (!WMIsPLString(value)) { \
1553 wwarning(_("Wrong option format for key \"%s\". Should be %s."), \
1555 wwarning(_("using default \"%s\" instead"), entry->default_value); \
1556 var = entry->default_value;\
1557 } else var = WMGetFromPLString(value)\
1564 string2index(WMPropList
*key
, WMPropList
*val
, char *def
,
1565 WOptionEnumeration
*values
)
1568 WOptionEnumeration
*v
;
1569 char buffer
[TOTAL_VALUES_LENGTH
];
1571 if (WMIsPLString(val
) && (str
= WMGetFromPLString(val
))) {
1572 for (v
=values
; v
->string
!=NULL
; v
++) {
1573 if (strcasecmp(v
->string
, str
)==0)
1579 for (v
=values
; v
->string
!=NULL
; v
++) {
1582 strcat(buffer
, ", ");
1583 strcat(buffer
, v
->string
);
1586 wwarning(_("wrong option value for key \"%s\". Should be one of %s"),
1587 WMGetFromPLString(key
), buffer
);
1590 return string2index(key
, val
, NULL
, values
);
1600 * value - is the value in the defaults DB
1601 * addr - is the address to store the data
1602 * ret - is the address to store a pointer to a temporary buffer. ret
1603 * must not be freed and is used by the set functions
1606 getBool(WScreen
*scr
, WDefaultEntry
*entry
, WMPropList
*value
, void *addr
,
1613 GET_STRING_OR_DEFAULT("Boolean", val
);
1616 if ((val
[1]=='\0' && (val
[0]=='y' || val
[0]=='Y'))
1617 || strcasecmp(val
, "YES")==0) {
1620 } else if ((val
[1]=='\0' && (val
[0]=='n' || val
[0]=='N'))
1621 || strcasecmp(val
, "NO")==0) {
1625 if (sscanf(val
, "%i", &i
)==1) {
1631 wwarning(_("can't convert \"%s\" to boolean for key \"%s\""),
1633 if (second_pass
==0) {
1634 val
= WMGetFromPLString(entry
->plvalue
);
1636 wwarning(_("using default \"%s\" instead"), val
);
1646 *(char*)addr
= data
;
1653 getInt(WScreen
*scr
, WDefaultEntry
*entry
, WMPropList
*value
, void *addr
,
1660 GET_STRING_OR_DEFAULT("Integer", val
);
1662 if (sscanf(val
, "%i", &data
)!=1) {
1663 wwarning(_("can't convert \"%s\" to integer for key \"%s\""),
1665 val
= WMGetFromPLString(entry
->plvalue
);
1666 wwarning(_("using default \"%s\" instead"), val
);
1667 if (sscanf(val
, "%i", &data
)!=1) {
1682 getCoord(WScreen
*scr
, WDefaultEntry
*entry
, WMPropList
*value
, void *addr
,
1686 char *val_x
, *val_y
;
1687 int nelem
, changed
=0;
1688 WMPropList
*elem_x
, *elem_y
;
1691 if (!WMIsPLArray(value
)) {
1692 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1693 entry
->key
, "Coordinate");
1695 value
= entry
->plvalue
;
1697 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1703 nelem
= WMGetPropListItemCount(value
);
1705 wwarning(_("Incorrect number of elements in array for key \"%s\"."),
1708 value
= entry
->plvalue
;
1710 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1716 elem_x
= WMGetFromPLArray(value
, 0);
1717 elem_y
= WMGetFromPLArray(value
, 1);
1719 if (!elem_x
|| !elem_y
|| !WMIsPLString(elem_x
) || !WMIsPLString(elem_y
)) {
1720 wwarning(_("Wrong value for key \"%s\". Should be Coordinate."),
1723 value
= entry
->plvalue
;
1725 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1731 val_x
= WMGetFromPLString(elem_x
);
1732 val_y
= WMGetFromPLString(elem_y
);
1734 if (sscanf(val_x
, "%i", &data
.x
)!=1 || sscanf(val_y
, "%i", &data
.y
)!=1) {
1735 wwarning(_("can't convert array to integers for \"%s\"."), entry
->key
);
1737 value
= entry
->plvalue
;
1739 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1747 else if (data
.x
> scr
->scr_width
/3)
1748 data
.x
= scr
->scr_width
/3;
1751 else if (data
.y
> scr
->scr_height
/3)
1752 data
.y
= scr
->scr_height
/3;
1757 *(WCoord
*)addr
= data
;
1764 getPropList(WScreen
*scr
, WDefaultEntry
*entry
, WMPropList
*value
, void *addr
,
1767 WMRetainPropList(value
);
1775 /* This function is not used at the moment. */
1777 getString(WScreen
*scr
, WDefaultEntry
*entry
, WMPropList
*value
, void *addr
,
1782 GET_STRING_OR_DEFAULT("String", data
);
1785 data
= WMGetFromPLString(entry
->plvalue
);
1793 *(char**)addr
= wstrdup(data
);
1801 getPathList(WScreen
*scr
, WDefaultEntry
*entry
, WMPropList
*value
, void *addr
,
1811 if (!WMIsPLArray(value
)) {
1812 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1813 entry
->key
, "an array of paths");
1815 value
= entry
->plvalue
;
1817 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1824 count
= WMGetPropListItemCount(value
);
1827 value
= entry
->plvalue
;
1829 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1836 for (i
=0; i
<count
; i
++) {
1837 d
= WMGetFromPLArray(value
, i
);
1838 if (!d
|| !WMIsPLString(d
)) {
1842 len
+= strlen(WMGetFromPLString(d
))+1;
1845 ptr
= data
= wmalloc(len
+1);
1847 for (i
=0; i
<count
; i
++) {
1848 d
= WMGetFromPLArray(value
, i
);
1849 if (!d
|| !WMIsPLString(d
)) {
1852 strcpy(ptr
, WMGetFromPLString(d
));
1853 ptr
+= strlen(WMGetFromPLString(d
));
1857 ptr
--; *(ptr
--) = 0;
1859 if (*(char**)addr
!=NULL
) {
1860 wfree(*(char**)addr
);
1862 *(char**)addr
= data
;
1869 getEnum(WScreen
*scr
, WDefaultEntry
*entry
, WMPropList
*value
, void *addr
,
1872 static signed char data
;
1874 data
= string2index(entry
->plkey
, value
, entry
->default_value
,
1875 (WOptionEnumeration
*)entry
->extra_data
);
1882 *(signed char*)addr
= data
;
1891 * (hgradient <color> <color>)
1892 * (vgradient <color> <color>)
1893 * (dgradient <color> <color>)
1894 * (mhgradient <color> <color> ...)
1895 * (mvgradient <color> <color> ...)
1896 * (mdgradient <color> <color> ...)
1897 * (igradient <color1> <color1> <thickness1> <color2> <color2> <thickness2>)
1898 * (tpixmap <file> <color>)
1899 * (spixmap <file> <color>)
1900 * (cpixmap <file> <color>)
1901 * (thgradient <file> <opaqueness> <color> <color>)
1902 * (tvgradient <file> <opaqueness> <color> <color>)
1903 * (tdgradient <file> <opaqueness> <color> <color>)
1904 * (function <lib> <function> ...)
1908 parse_texture(WScreen
*scr
, WMPropList
*pl
)
1913 WTexture
*texture
=NULL
;
1915 nelem
= WMGetPropListItemCount(pl
);
1920 elem
= WMGetFromPLArray(pl
, 0);
1921 if (!elem
|| !WMIsPLString(elem
))
1923 val
= WMGetFromPLString(elem
);
1926 if (strcasecmp(val
, "solid")==0) {
1934 elem
= WMGetFromPLArray(pl
, 1);
1935 if (!elem
|| !WMIsPLString(elem
))
1937 val
= WMGetFromPLString(elem
);
1939 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &color
)) {
1940 wwarning(_("\"%s\" is not a valid color name"), val
);
1944 texture
= (WTexture
*)wTextureMakeSolid(scr
, &color
);
1945 } else if (strcasecmp(val
, "dgradient")==0
1946 || strcasecmp(val
, "vgradient")==0
1947 || strcasecmp(val
, "hgradient")==0) {
1948 RColor color1
, color2
;
1953 wwarning(_("bad number of arguments in gradient specification"));
1957 if (val
[0]=='d' || val
[0]=='D')
1958 type
= WTEX_DGRADIENT
;
1959 else if (val
[0]=='h' || val
[0]=='H')
1960 type
= WTEX_HGRADIENT
;
1962 type
= WTEX_VGRADIENT
;
1965 /* get from color */
1966 elem
= WMGetFromPLArray(pl
, 1);
1967 if (!elem
|| !WMIsPLString(elem
))
1969 val
= WMGetFromPLString(elem
);
1971 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1972 wwarning(_("\"%s\" is not a valid color name"), val
);
1976 color1
.red
= xcolor
.red
>> 8;
1977 color1
.green
= xcolor
.green
>> 8;
1978 color1
.blue
= xcolor
.blue
>> 8;
1981 elem
= WMGetFromPLArray(pl
, 2);
1982 if (!elem
|| !WMIsPLString(elem
)) {
1985 val
= WMGetFromPLString(elem
);
1987 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1988 wwarning(_("\"%s\" is not a valid color name"), val
);
1992 color2
.red
= xcolor
.red
>> 8;
1993 color2
.green
= xcolor
.green
>> 8;
1994 color2
.blue
= xcolor
.blue
>> 8;
1996 texture
= (WTexture
*)wTextureMakeGradient(scr
, type
, &color1
, &color2
);
1998 } else if (strcasecmp(val
, "igradient")==0) {
1999 RColor colors1
[2], colors2
[2];
2005 wwarning(_("bad number of arguments in gradient specification"));
2009 /* get from color */
2010 for (i
= 0; i
< 2; i
++) {
2011 elem
= WMGetFromPLArray(pl
, 1+i
);
2012 if (!elem
|| !WMIsPLString(elem
))
2014 val
= WMGetFromPLString(elem
);
2016 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
2017 wwarning(_("\"%s\" is not a valid color name"), val
);
2020 colors1
[i
].alpha
= 255;
2021 colors1
[i
].red
= xcolor
.red
>> 8;
2022 colors1
[i
].green
= xcolor
.green
>> 8;
2023 colors1
[i
].blue
= xcolor
.blue
>> 8;
2025 elem
= WMGetFromPLArray(pl
, 3);
2026 if (!elem
|| !WMIsPLString(elem
))
2028 val
= WMGetFromPLString(elem
);
2032 /* get from color */
2033 for (i
= 0; i
< 2; i
++) {
2034 elem
= WMGetFromPLArray(pl
, 4+i
);
2035 if (!elem
|| !WMIsPLString(elem
))
2037 val
= WMGetFromPLString(elem
);
2039 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
2040 wwarning(_("\"%s\" is not a valid color name"), val
);
2043 colors2
[i
].alpha
= 255;
2044 colors2
[i
].red
= xcolor
.red
>> 8;
2045 colors2
[i
].green
= xcolor
.green
>> 8;
2046 colors2
[i
].blue
= xcolor
.blue
>> 8;
2048 elem
= WMGetFromPLArray(pl
, 6);
2049 if (!elem
|| !WMIsPLString(elem
))
2051 val
= WMGetFromPLString(elem
);
2054 texture
= (WTexture
*)wTextureMakeIGradient(scr
, th1
, colors1
,
2057 } else if (strcasecmp(val
, "mhgradient")==0
2058 || strcasecmp(val
, "mvgradient")==0
2059 || strcasecmp(val
, "mdgradient")==0) {
2066 wwarning(_("too few arguments in multicolor gradient specification"));
2070 if (val
[1]=='h' || val
[1]=='H')
2071 type
= WTEX_MHGRADIENT
;
2072 else if (val
[1]=='v' || val
[1]=='V')
2073 type
= WTEX_MVGRADIENT
;
2075 type
= WTEX_MDGRADIENT
;
2079 colors
= wmalloc(sizeof(RColor
*)*(count
+1));
2081 for (i
=0; i
<count
; i
++) {
2082 elem
= WMGetFromPLArray(pl
, i
+1);
2083 if (!elem
|| !WMIsPLString(elem
)) {
2084 for (--i
; i
>=0; --i
) {
2090 val
= WMGetFromPLString(elem
);
2092 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &color
)) {
2093 wwarning(_("\"%s\" is not a valid color name"), val
);
2094 for (--i
; i
>=0; --i
) {
2100 colors
[i
] = wmalloc(sizeof(RColor
));
2101 colors
[i
]->red
= color
.red
>> 8;
2102 colors
[i
]->green
= color
.green
>> 8;
2103 colors
[i
]->blue
= color
.blue
>> 8;
2108 texture
= (WTexture
*)wTextureMakeMGradient(scr
, type
, colors
);
2109 } else if (strcasecmp(val
, "spixmap")==0 ||
2110 strcasecmp(val
, "cpixmap")==0 ||
2111 strcasecmp(val
, "tpixmap")==0) {
2118 if (val
[0] == 's' || val
[0] == 'S')
2120 else if (val
[0] == 'c' || val
[0] == 'C')
2126 elem
= WMGetFromPLArray(pl
, 2);
2127 if (!elem
|| !WMIsPLString(elem
)) {
2130 val
= WMGetFromPLString(elem
);
2132 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &color
)) {
2133 wwarning(_("\"%s\" is not a valid color name"), val
);
2138 elem
= WMGetFromPLArray(pl
, 1);
2139 if (!elem
|| !WMIsPLString(elem
))
2141 val
= WMGetFromPLString(elem
);
2143 texture
= (WTexture
*)wTextureMakePixmap(scr
, type
, val
, &color
);
2144 } else if (strcasecmp(val
, "thgradient")==0
2145 || strcasecmp(val
, "tvgradient")==0
2146 || strcasecmp(val
, "tdgradient")==0) {
2147 RColor color1
, color2
;
2152 if (val
[1]=='h' || val
[1]=='H')
2153 style
= WTEX_THGRADIENT
;
2154 else if (val
[1]=='v' || val
[1]=='V')
2155 style
= WTEX_TVGRADIENT
;
2157 style
= WTEX_TDGRADIENT
;
2160 wwarning(_("bad number of arguments in textured gradient specification"));
2164 /* get from color */
2165 elem
= WMGetFromPLArray(pl
, 3);
2166 if (!elem
|| !WMIsPLString(elem
))
2168 val
= WMGetFromPLString(elem
);
2170 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
2171 wwarning(_("\"%s\" is not a valid color name"), val
);
2175 color1
.red
= xcolor
.red
>> 8;
2176 color1
.green
= xcolor
.green
>> 8;
2177 color1
.blue
= xcolor
.blue
>> 8;
2180 elem
= WMGetFromPLArray(pl
, 4);
2181 if (!elem
|| !WMIsPLString(elem
)) {
2184 val
= WMGetFromPLString(elem
);
2186 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
2187 wwarning(_("\"%s\" is not a valid color name"), val
);
2191 color2
.red
= xcolor
.red
>> 8;
2192 color2
.green
= xcolor
.green
>> 8;
2193 color2
.blue
= xcolor
.blue
>> 8;
2196 elem
= WMGetFromPLArray(pl
, 2);
2197 if (!elem
|| !WMIsPLString(elem
))
2200 val
= WMGetFromPLString(elem
);
2202 if (!val
|| (opacity
= atoi(val
)) < 0 || opacity
> 255) {
2203 wwarning(_("bad opacity value for tgradient texture \"%s\". Should be [0..255]"), val
);
2208 elem
= WMGetFromPLArray(pl
, 1);
2209 if (!elem
|| !WMIsPLString(elem
))
2211 val
= WMGetFromPLString(elem
);
2213 texture
= (WTexture
*)wTextureMakeTGradient(scr
, style
, &color1
, &color2
,
2216 #ifdef TEXTURE_PLUGIN
2217 else if (strcasecmp(val
, "function")==0) {
2218 WTexFunction
*function
;
2219 void (*initFunc
) (Display
*, Colormap
);
2220 char *lib
, *func
, **argv
;
2226 /* get the library name */
2227 elem
= WMGetFromPLArray(pl
, 1);
2228 if (!elem
|| !WMIsPLString(elem
)) {
2231 lib
= WMGetFromPLString(elem
);
2233 /* get the function name */
2234 elem
= WMGetFromPLArray(pl
, 2);
2235 if (!elem
|| !WMIsPLString(elem
)) {
2238 func
= WMGetFromPLString(elem
);
2241 argv
= (char **)wmalloc(argc
* sizeof(char *));
2243 /* get the parameters */
2244 argv
[0] = wstrdup(func
);
2245 for (i
= 0; i
< argc
- 1; i
++) {
2246 elem
= WMGetFromPLArray(pl
, 3 + i
);
2247 if (!elem
|| !WMIsPLString(elem
)) {
2252 argv
[i
+1] = wstrdup(WMGetFromPLString(elem
));
2255 function
= wTextureMakeFunction(scr
, lib
, func
, argc
, argv
);
2259 initFunc
= dlsym(function
->handle
, "initWindowMaker");
2261 initFunc(dpy
, scr
->w_colormap
);
2263 wwarning(_("could not initialize library %s"), lib
);
2266 wwarning(_("could not find function %s::%s"), lib
, func
);
2268 #endif /* HAVE_DLFCN_H */
2269 texture
= (WTexture
*)function
;
2271 #endif /* TEXTURE_PLUGIN */
2273 wwarning(_("invalid texture type %s"), val
);
2282 getTexture(WScreen
*scr
, WDefaultEntry
*entry
, WMPropList
*value
, void *addr
,
2285 static WTexture
*texture
;
2289 if (!WMIsPLArray(value
)) {
2290 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
2291 entry
->key
, "Texture");
2293 value
= entry
->plvalue
;
2295 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
2301 if (strcmp(entry
->key
, "WidgetColor")==0 && !changed
) {
2304 pl
= WMGetFromPLArray(value
, 0);
2305 if (!pl
|| !WMIsPLString(pl
) || !WMGetFromPLString(pl
)
2306 || strcasecmp(WMGetFromPLString(pl
), "solid")!=0) {
2307 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
2308 entry
->key
, "Solid Texture");
2310 value
= entry
->plvalue
;
2312 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
2317 texture
= parse_texture(scr
, value
);
2320 wwarning(_("Error in texture specification for key \"%s\""),
2323 value
= entry
->plvalue
;
2325 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
2335 *(WTexture
**)addr
= texture
;
2342 getWSBackground(WScreen
*scr
, WDefaultEntry
*entry
, WMPropList
*value
,
2343 void *addr
, void **ret
)
2351 if (!WMIsPLArray(value
)) {
2352 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
2353 "WorkspaceBack", "Texture or None");
2355 value
= entry
->plvalue
;
2357 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
2363 /* only do basic error checking and verify for None texture */
2365 nelem
= WMGetPropListItemCount(value
);
2367 elem
= WMGetFromPLArray(value
, 0);
2368 if (!elem
|| !WMIsPLString(elem
)) {
2369 wwarning(_("Wrong type for workspace background. Should be a texture type."));
2371 value
= entry
->plvalue
;
2373 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
2378 val
= WMGetFromPLString(elem
);
2380 if (strcasecmp(val
, "None")==0)
2383 *ret
= WMRetainPropList(value
);
2390 getWSSpecificBackground(WScreen
*scr
, WDefaultEntry
*entry
, WMPropList
*value
,
2391 void *addr
, void **ret
)
2398 if (!WMIsPLArray(value
)) {
2399 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
2400 "WorkspaceSpecificBack", "an array of textures");
2402 value
= entry
->plvalue
;
2404 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
2410 /* only do basic error checking and verify for None texture */
2412 nelem
= WMGetPropListItemCount(value
);
2415 elem
= WMGetFromPLArray(value
, nelem
);
2416 if (!elem
|| !WMIsPLArray(elem
)) {
2417 wwarning(_("Wrong type for background of workspace %i. Should be a texture."),
2423 *ret
= WMRetainPropList(value
);
2427 * Kluge to force wmsetbg helper to set the default background.
2428 * If the WorkspaceSpecificBack is changed once wmaker has started,
2429 * the WorkspaceBack won't be sent to the helper, unless the user
2430 * changes it's value too. So, we must force this by removing the
2431 * value from the defaults DB.
2433 if (!scr
->flags
.backimage_helper_launched
&& !scr
->flags
.startup
) {
2434 WMPropList
*key
= WMCreatePLString("WorkspaceBack");
2436 WMRemoveFromPLDictionary(WDWindowMaker
->dictionary
, key
);
2438 WMReleasePropList(key
);
2446 getFont(WScreen
*scr
, WDefaultEntry
*entry
, WMPropList
*value
, void *addr
,
2449 static WMFont
*font
;
2452 GET_STRING_OR_DEFAULT("Font", val
);
2454 font
= WMCreateFont(scr
->wmscreen
, val
);
2456 font
= WMCreateFont(scr
->wmscreen
, "fixed");
2459 wfatal(_("could not load any usable font!!!"));
2466 /* can't assign font value outside update function */
2467 wassertrv(addr
== NULL
, True
);
2474 getColor(WScreen
*scr
, WDefaultEntry
*entry
, WMPropList
*value
, void *addr
,
2477 static XColor color
;
2481 GET_STRING_OR_DEFAULT("Color", val
);
2485 if (!wGetColor(scr
, val
, &color
)) {
2486 wwarning(_("could not get color for key \"%s\""),
2488 if (second_pass
==0) {
2489 val
= WMGetFromPLString(entry
->plvalue
);
2491 wwarning(_("using default \"%s\" instead"), val
);
2503 *(unsigned long*)addr = pixel;
2512 getKeybind(WScreen
*scr
, WDefaultEntry
*entry
, WMPropList
*value
, void *addr
,
2515 static WShortKey shortcut
;
2522 GET_STRING_OR_DEFAULT("Key spec", val
);
2524 if (!val
|| strcasecmp(val
, "NONE")==0) {
2525 shortcut
.keycode
= 0;
2526 shortcut
.modifier
= 0;
2537 shortcut
.modifier
= 0;
2538 while ((k
= strchr(b
, '+'))!=NULL
) {
2542 mod
= wXModifierFromKey(b
);
2544 wwarning(_("%s: invalid key modifier \"%s\""), entry
->key
, b
);
2547 shortcut
.modifier
|= mod
;
2553 ksym
= XStringToKeysym(b
);
2555 if (ksym
==NoSymbol
) {
2556 wwarning(_("%s:invalid kbd shortcut specification \"%s\""), entry
->key
,
2561 shortcut
.keycode
= XKeysymToKeycode(dpy
, ksym
);
2562 if (shortcut
.keycode
==0) {
2563 wwarning(_("%s:invalid key in shortcut \"%s\""), entry
->key
, val
);
2575 getModMask(WScreen
*scr
, WDefaultEntry
*entry
, WMPropList
*value
, void *addr
,
2578 static unsigned int mask
;
2581 GET_STRING_OR_DEFAULT("Modifier Key", str
);
2586 mask
= wXModifierFromKey(str
);
2588 wwarning(_("%s: modifier key %s is not valid"), entry
->key
, str
);
2594 *(unsigned int*)addr
= mask
;
2605 getRImages(WScreen
*scr
, WDefaultEntry
*entry
, WMPropList
*value
,
2606 void *addr
, void **ret
)
2614 GET_STRING_OR_DEFAULT("Image File Path", str
);
2618 image
= RLoadImage(scr
->rcontext
, str
, 0);
2620 wwarning(_("could not load image in option %s: %s"), entry
->key
,
2621 RMessageForError(RErrorCode
));
2625 if (*(RImage
**)addr
) {
2626 RReleaseImage(*(RImage
**)addr
);
2629 *(RImage
**)addr
= image
;
2631 assert(ret
== NULL
);
2634 *(RImage**)ret = image;
2641 # include <X11/cursorfont.h>
2648 #define CURSOR_ID_NONE (XC_num_glyphs)
2650 static WCursorLookup cursor_table
[] =
2652 { "X_cursor", XC_X_cursor
},
2653 { "arrow", XC_arrow
},
2654 { "based_arrow_down", XC_based_arrow_down
},
2655 { "based_arrow_up", XC_based_arrow_up
},
2656 { "boat", XC_boat
},
2657 { "bogosity", XC_bogosity
},
2658 { "bottom_left_corner", XC_bottom_left_corner
},
2659 { "bottom_right_corner", XC_bottom_right_corner
},
2660 { "bottom_side", XC_bottom_side
},
2661 { "bottom_tee", XC_bottom_tee
},
2662 { "box_spiral", XC_box_spiral
},
2663 { "center_ptr", XC_center_ptr
},
2664 { "circle", XC_circle
},
2665 { "clock", XC_clock
},
2666 { "coffee_mug", XC_coffee_mug
},
2667 { "cross", XC_cross
},
2668 { "cross_reverse", XC_cross_reverse
},
2669 { "crosshair", XC_crosshair
},
2670 { "diamond_cross", XC_diamond_cross
},
2672 { "dotbox", XC_dotbox
},
2673 { "double_arrow", XC_double_arrow
},
2674 { "draft_large", XC_draft_large
},
2675 { "draft_small", XC_draft_small
},
2676 { "draped_box", XC_draped_box
},
2677 { "exchange", XC_exchange
},
2678 { "fleur", XC_fleur
},
2679 { "gobbler", XC_gobbler
},
2680 { "gumby", XC_gumby
},
2681 { "hand1", XC_hand1
},
2682 { "hand2", XC_hand2
},
2683 { "heart", XC_heart
},
2684 { "icon", XC_icon
},
2685 { "iron_cross", XC_iron_cross
},
2686 { "left_ptr", XC_left_ptr
},
2687 { "left_side", XC_left_side
},
2688 { "left_tee", XC_left_tee
},
2689 { "leftbutton", XC_leftbutton
},
2690 { "ll_angle", XC_ll_angle
},
2691 { "lr_angle", XC_lr_angle
},
2693 { "middlebutton", XC_middlebutton
},
2694 { "mouse", XC_mouse
},
2695 { "pencil", XC_pencil
},
2696 { "pirate", XC_pirate
},
2697 { "plus", XC_plus
},
2698 { "question_arrow", XC_question_arrow
},
2699 { "right_ptr", XC_right_ptr
},
2700 { "right_side", XC_right_side
},
2701 { "right_tee", XC_right_tee
},
2702 { "rightbutton", XC_rightbutton
},
2703 { "rtl_logo", XC_rtl_logo
},
2704 { "sailboat", XC_sailboat
},
2705 { "sb_down_arrow", XC_sb_down_arrow
},
2706 { "sb_h_double_arrow", XC_sb_h_double_arrow
},
2707 { "sb_left_arrow", XC_sb_left_arrow
},
2708 { "sb_right_arrow", XC_sb_right_arrow
},
2709 { "sb_up_arrow", XC_sb_up_arrow
},
2710 { "sb_v_double_arrow", XC_sb_v_double_arrow
},
2711 { "shuttle", XC_shuttle
},
2712 { "sizing", XC_sizing
},
2713 { "spider", XC_spider
},
2714 { "spraycan", XC_spraycan
},
2715 { "star", XC_star
},
2716 { "target", XC_target
},
2717 { "tcross", XC_tcross
},
2718 { "top_left_arrow", XC_top_left_arrow
},
2719 { "top_left_corner", XC_top_left_corner
},
2720 { "top_right_corner", XC_top_right_corner
},
2721 { "top_side", XC_top_side
},
2722 { "top_tee", XC_top_tee
},
2723 { "trek", XC_trek
},
2724 { "ul_angle", XC_ul_angle
},
2725 { "umbrella", XC_umbrella
},
2726 { "ur_angle", XC_ur_angle
},
2727 { "watch", XC_watch
},
2728 { "xterm", XC_xterm
},
2729 { NULL
, CURSOR_ID_NONE
}
2733 check_bitmap_status(int status
, char *filename
, Pixmap bitmap
)
2736 case BitmapOpenFailed
:
2737 wwarning(_("failed to open bitmap file \"%s\""), filename
);
2739 case BitmapFileInvalid
:
2740 wwarning(_("\"%s\" is not a valid bitmap file"), filename
);
2742 case BitmapNoMemory
:
2743 wwarning(_("out of memory reading bitmap file \"%s\""), filename
);
2746 XFreePixmap(dpy
, bitmap
);
2753 * (builtin, <cursor_name>)
2754 * (bitmap, <cursor_bitmap>, <cursor_mask>)
2757 parse_cursor(WScreen
*scr
, WMPropList
*pl
, Cursor
*cursor
)
2764 nelem
= WMGetPropListItemCount(pl
);
2768 elem
= WMGetFromPLArray(pl
, 0);
2769 if (!elem
|| !WMIsPLString(elem
)) {
2772 val
= WMGetFromPLString(elem
);
2774 if (0 == strcasecmp(val
, "none")) {
2777 } else if (0 == strcasecmp(val
, "builtin")) {
2779 int cursor_id
= CURSOR_ID_NONE
;
2782 wwarning(_("bad number of arguments in cursor specification"));
2785 elem
= WMGetFromPLArray(pl
, 1);
2786 if (!elem
|| !WMIsPLString(elem
)) {
2789 val
= WMGetFromPLString(elem
);
2791 for (i
= 0; NULL
!= cursor_table
[i
].name
; i
++) {
2792 if (0 == strcasecmp(val
, cursor_table
[i
].name
)) {
2793 cursor_id
= cursor_table
[i
].id
;
2797 if (CURSOR_ID_NONE
== cursor_id
) {
2798 wwarning(_("unknown builtin cursor name \"%s\""), val
);
2800 *cursor
= XCreateFontCursor(dpy
, cursor_id
);
2803 } else if (0 == strcasecmp(val
, "bitmap")) {
2815 wwarning(_("bad number of arguments in cursor specification"));
2818 elem
= WMGetFromPLArray(pl
, 1);
2819 if (!elem
|| !WMIsPLString(elem
)) {
2822 val
= WMGetFromPLString(elem
);
2823 bitmap_name
= FindImage(wPreferences
.pixmap_path
, val
);
2825 wwarning(_("could not find cursor bitmap file \"%s\""), val
);
2828 elem
= WMGetFromPLArray(pl
, 2);
2829 if (!elem
|| !WMIsPLString(elem
)) {
2833 val
= WMGetFromPLString(elem
);
2834 mask_name
= FindImage(wPreferences
.pixmap_path
, val
);
2837 wwarning(_("could not find cursor bitmap file \"%s\""), val
);
2840 mask_status
= XReadBitmapFile(dpy
, scr
->w_win
, mask_name
, &w
, &h
,
2842 bitmap_status
= XReadBitmapFile(dpy
, scr
->w_win
, bitmap_name
, &w
, &h
,
2844 if ((BitmapSuccess
== bitmap_status
) &&
2845 (BitmapSuccess
== mask_status
)) {
2846 fg
.pixel
= scr
->black_pixel
;
2847 bg
.pixel
= scr
->white_pixel
;
2848 XQueryColor(dpy
, scr
->w_colormap
, &fg
);
2849 XQueryColor(dpy
, scr
->w_colormap
, &bg
);
2850 *cursor
= XCreatePixmapCursor(dpy
, bitmap
, mask
, &fg
, &bg
, x
, y
);
2853 check_bitmap_status(bitmap_status
, bitmap_name
, bitmap
);
2854 check_bitmap_status(mask_status
, mask_name
, mask
);
2863 getCursor(WScreen
*scr
, WDefaultEntry
*entry
, WMPropList
*value
, void *addr
,
2866 static Cursor cursor
;
2871 if (!WMIsPLArray(value
)) {
2872 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
2873 entry
->key
, "cursor specification");
2875 value
= entry
->plvalue
;
2877 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
2882 status
= parse_cursor(scr
, value
, &cursor
);
2884 wwarning(_("Error in cursor specification for key \"%s\""), entry
->key
);
2886 value
= entry
->plvalue
;
2888 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
2897 *(Cursor
*)addr
= cursor
;
2901 #undef CURSOR_ID_NONE
2904 /* ---------------- value setting functions --------------- */
2906 setJustify(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
2908 return REFRESH_WINDOW_TITLE_COLOR
;
2912 setClearance(WScreen
*scr
, WDefaultEntry
*entry
, void *bar
, void *foo
)
2914 return REFRESH_WINDOW_FONT
|REFRESH_BUTTON_IMAGES
|REFRESH_MENU_TITLE_FONT
|REFRESH_MENU_FONT
;
2918 setIfDockPresent(WScreen
*scr
, WDefaultEntry
*entry
, char *flag
, long which
)
2922 wPreferences
.flags
.nodock
= wPreferences
.flags
.nodock
|| *flag
;
2925 wPreferences
.flags
.noclip
= wPreferences
.flags
.noclip
|| *flag
;
2935 setStickyIcons(WScreen
*scr
, WDefaultEntry
*entry
, void *bar
, void *foo
)
2937 if (scr
->workspaces
) {
2938 wWorkspaceForceChange(scr
, scr
->current_workspace
);
2939 wArrangeIcons(scr
, False
);
2946 setPositive(WScreen
*scr
, WDefaultEntry
*entry
, int *value
, void *foo
)
2958 setIconTile(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
2964 img
= wTextureRenderImage(*texture
, wPreferences
.icon_size
,
2965 wPreferences
.icon_size
,
2966 ((*texture
)->any
.type
& WREL_BORDER_MASK
)
2967 ? WREL_ICON
: WREL_FLAT
);
2969 wwarning(_("could not render texture for icon background"));
2971 wTextureDestroy(scr
, *texture
);
2974 RConvertImage(scr
->rcontext
, img
, &pixmap
);
2976 if (scr
->icon_tile
) {
2978 RReleaseImage(scr
->icon_tile
);
2979 XFreePixmap(dpy
, scr
->icon_tile_pixmap
);
2982 scr
->icon_tile
= img
;
2985 /* put the icon in the noticeboard hint */
2986 PropSetIconTileHint(scr
, img
);
2989 if (!wPreferences
.flags
.noclip
) {
2990 if (scr
->clip_tile
) {
2991 RReleaseImage(scr
->clip_tile
);
2993 scr
->clip_tile
= wClipMakeTile(scr
, img
);
2996 scr
->icon_tile_pixmap
= pixmap
;
2998 if (scr
->def_icon_pixmap
) {
2999 XFreePixmap(dpy
, scr
->def_icon_pixmap
);
3000 scr
->def_icon_pixmap
= None
;
3002 if (scr
->def_ticon_pixmap
) {
3003 XFreePixmap(dpy
, scr
->def_ticon_pixmap
);
3004 scr
->def_ticon_pixmap
= None
;
3007 if (scr
->icon_back_texture
) {
3008 wTextureDestroy(scr
, (WTexture
*)scr
->icon_back_texture
);
3010 scr
->icon_back_texture
= wTextureMakeSolid(scr
, &((*texture
)->any
.color
));
3012 if (scr
->clip_balloon
)
3013 XSetWindowBackground(dpy
, scr
->clip_balloon
,
3014 (*texture
)->any
.color
.pixel
);
3017 * Free the texture as nobody else will use it, nor refer to it.
3020 wTextureDestroy(scr
, *texture
);
3022 return (reset
? REFRESH_ICON_TILE
: 0);
3028 setWinTitleFont(WScreen
*scr
, WDefaultEntry
*entry
, WMFont
*font
, void *foo
)
3030 if (scr
->title_font
) {
3031 WMReleaseFont(scr
->title_font
);
3033 scr
->title_font
= font
;
3035 return REFRESH_WINDOW_FONT
|REFRESH_BUTTON_IMAGES
;
3040 setMenuTitleFont(WScreen
*scr
, WDefaultEntry
*entry
, WMFont
*font
, void *foo
)
3042 if (scr
->menu_title_font
) {
3043 WMReleaseFont(scr
->menu_title_font
);
3046 scr
->menu_title_font
= font
;
3048 return REFRESH_MENU_TITLE_FONT
;
3053 setMenuTextFont(WScreen
*scr
, WDefaultEntry
*entry
, WMFont
*font
, void *foo
)
3055 if (scr
->menu_entry_font
) {
3056 WMReleaseFont(scr
->menu_entry_font
);
3058 scr
->menu_entry_font
= font
;
3060 return REFRESH_MENU_FONT
;
3066 setIconTitleFont(WScreen
*scr
, WDefaultEntry
*entry
, WMFont
*font
, void *foo
)
3068 if (scr
->icon_title_font
) {
3069 WMReleaseFont(scr
->icon_title_font
);
3072 scr
->icon_title_font
= font
;
3074 return REFRESH_ICON_FONT
;
3079 setClipTitleFont(WScreen
*scr
, WDefaultEntry
*entry
, WMFont
*font
, void *foo
)
3081 if (scr
->clip_title_font
) {
3082 WMReleaseFont(scr
->clip_title_font
);
3085 scr
->clip_title_font
= font
;
3087 return REFRESH_ICON_FONT
;
3092 setLargeDisplayFont(WScreen
*scr
, WDefaultEntry
*entry
, WMFont
*font
, void *foo
)
3094 if (scr
->workspace_name_font
) {
3095 WMReleaseFont(scr
->workspace_name_font
);
3098 scr
->workspace_name_font
= font
;
3105 setHightlight(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, void *foo
)
3107 if (scr
->select_color
)
3108 WMReleaseColor(scr
->select_color
);
3111 WMCreateRGBColor(scr
->wmscreen
, color
->red
, color
->green
,
3114 wFreeColor(scr
, color
->pixel
);
3116 return REFRESH_MENU_COLOR
;
3121 setHightlightText(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, void *foo
)
3123 if (scr
->select_text_color
)
3124 WMReleaseColor(scr
->select_text_color
);
3126 scr
->select_text_color
=
3127 WMCreateRGBColor(scr
->wmscreen
, color
->red
, color
->green
,
3130 wFreeColor(scr
, color
->pixel
);
3132 return REFRESH_MENU_COLOR
;
3137 setClipTitleColor(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, long index
)
3139 if (scr
->clip_title_color
[index
])
3140 WMReleaseColor(scr
->clip_title_color
[index
]);
3141 scr
->clip_title_color
[index
] = WMCreateRGBColor(scr
->wmscreen
, color
->red
,
3142 color
->green
, color
->blue
,
3144 #ifdef GRADIENT_CLIP_ARROW
3145 if (index
== CLIP_NORMAL
) {
3147 RColor color1
, color2
;
3148 int pt
= CLIP_BUTTON_SIZE
*wPreferences
.icon_size
/64;
3149 int as
= pt
- 15; /* 15 = 5+5+5 */
3151 FREE_PIXMAP(scr
->clip_arrow_gradient
);
3153 color1
.red
= (color
->red
>> 8)*6/10;
3154 color1
.green
= (color
->green
>> 8)*6/10;
3155 color1
.blue
= (color
->blue
>> 8)*6/10;
3157 color2
.red
= WMIN((color
->red
>> 8)*20/10, 255);
3158 color2
.green
= WMIN((color
->green
>> 8)*20/10, 255);
3159 color2
.blue
= WMIN((color
->blue
>> 8)*20/10, 255);
3161 image
= RRenderGradient(as
+1, as
+1, &color1
, &color2
, RDiagonalGradient
);
3162 RConvertImage(scr
->rcontext
, image
, &scr
->clip_arrow_gradient
);
3163 RReleaseImage(image
);
3165 #endif /* GRADIENT_CLIP_ARROW */
3167 wFreeColor(scr
, color
->pixel
);
3169 return REFRESH_ICON_TITLE_COLOR
;
3174 setWTitleColor(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, long index
)
3176 if (scr
->window_title_color
[index
])
3177 WMReleaseColor(scr
->window_title_color
[index
]);
3179 scr
->window_title_color
[index
] =
3180 WMCreateRGBColor(scr
->wmscreen
, color
->red
, color
->green
, color
->blue
,
3183 wFreeColor(scr
, color
->pixel
);
3185 return REFRESH_WINDOW_TITLE_COLOR
;
3190 setMenuTitleColor(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, long index
)
3192 if (scr
->menu_title_color
[0])
3193 WMReleaseColor(scr
->menu_title_color
[0]);
3195 scr
->menu_title_color
[0] =
3196 WMCreateRGBColor(scr
->wmscreen
, color
->red
, color
->green
,
3199 wFreeColor(scr
, color
->pixel
);
3201 return REFRESH_MENU_TITLE_COLOR
;
3206 setMenuTextColor(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, void *foo
)
3208 if (scr
->mtext_color
)
3209 WMReleaseColor(scr
->mtext_color
);
3211 scr
->mtext_color
= WMCreateRGBColor(scr
->wmscreen
, color
->red
,
3212 color
->green
, color
->blue
, True
);
3214 if (WMColorPixel(scr
->dtext_color
) == WMColorPixel(scr
->mtext_color
)) {
3215 WMSetColorAlpha(scr
->dtext_color
, 0x7fff);
3217 WMSetColorAlpha(scr
->dtext_color
, 0xffff);
3220 wFreeColor(scr
, color
->pixel
);
3222 return REFRESH_MENU_COLOR
;
3227 setMenuDisabledColor(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, void *foo
)
3229 if (scr
->dtext_color
)
3230 WMReleaseColor(scr
->dtext_color
);
3232 scr
->dtext_color
= WMCreateRGBColor(scr
->wmscreen
, color
->red
,
3233 color
->green
, color
->blue
, True
);
3235 if (WMColorPixel(scr
->dtext_color
) == WMColorPixel(scr
->mtext_color
)) {
3236 WMSetColorAlpha(scr
->dtext_color
, 0x7fff);
3238 WMSetColorAlpha(scr
->dtext_color
, 0xffff);
3241 wFreeColor(scr
, color
->pixel
);
3243 return REFRESH_MENU_COLOR
;
3248 setIconTitleColor(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, void *foo
)
3250 if (scr
->icon_title_color
)
3251 WMReleaseColor(scr
->icon_title_color
);
3252 scr
->icon_title_color
= WMCreateRGBColor(scr
->wmscreen
, color
->red
,
3253 color
->green
, color
->blue
,
3256 wFreeColor(scr
, color
->pixel
);
3258 return REFRESH_ICON_TITLE_COLOR
;
3263 setIconTitleBack(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, void *foo
)
3265 if (scr
->icon_title_texture
) {
3266 wTextureDestroy(scr
, (WTexture
*)scr
->icon_title_texture
);
3268 scr
->icon_title_texture
= wTextureMakeSolid(scr
, color
);
3270 return REFRESH_ICON_TITLE_BACK
;
3275 trackDeadProcess(pid_t pid
, unsigned char status
, WScreen
*scr
)
3277 close(scr
->helper_fd
);
3279 scr
->helper_pid
= 0;
3280 scr
->flags
.backimage_helper_launched
= 0;
3285 setWorkspaceSpecificBack(WScreen
*scr
, WDefaultEntry
*entry
, WMPropList
*value
,
3292 if (scr
->flags
.backimage_helper_launched
) {
3293 if (WMGetPropListItemCount(value
)==0) {
3294 SendHelperMessage(scr
, 'C', 0, NULL
);
3295 SendHelperMessage(scr
, 'K', 0, NULL
);
3297 WMReleasePropList(value
);
3304 if (WMGetPropListItemCount(value
) == 0)
3307 if (pipe(filedes
) < 0) {
3308 wsyserror("pipe() failed:can't set workspace specific background image");
3310 WMReleasePropList(value
);
3316 wsyserror("fork() failed:can't set workspace specific background image");
3317 if (close(filedes
[0]) < 0)
3318 wsyserror("could not close pipe");
3319 if (close(filedes
[1]) < 0)
3320 wsyserror("could not close pipe");
3322 } else if (pid
== 0) {
3325 SetupEnvironment(scr
);
3328 wsyserror("could not close pipe");
3329 if (dup(filedes
[0]) < 0) {
3330 wsyserror("dup() failed:can't set workspace specific background image");
3332 dither
= wPreferences
.no_dithering
? "-m" : "-d";
3333 if (wPreferences
.smooth_workspace_back
)
3334 execlp("wmsetbg", "wmsetbg", "-helper", "-S", dither
, NULL
);
3336 execlp("wmsetbg", "wmsetbg", "-helper", dither
, NULL
);
3337 wsyserror("could not execute wmsetbg");
3341 if (fcntl(filedes
[0], F_SETFD
, FD_CLOEXEC
) < 0) {
3342 wsyserror("error setting close-on-exec flag");
3344 if (fcntl(filedes
[1], F_SETFD
, FD_CLOEXEC
) < 0) {
3345 wsyserror("error setting close-on-exec flag");
3348 scr
->helper_fd
= filedes
[1];
3349 scr
->helper_pid
= pid
;
3350 scr
->flags
.backimage_helper_launched
= 1;
3352 wAddDeathHandler(pid
, (WDeathHandler
*)trackDeadProcess
, scr
);
3354 SendHelperMessage(scr
, 'P', -1, wPreferences
.pixmap_path
);
3359 for (i
= 0; i
< WMGetPropListItemCount(value
); i
++) {
3360 val
= WMGetFromPLArray(value
, i
);
3361 if (val
&& WMIsPLArray(val
) && WMGetPropListItemCount(val
)>0) {
3362 str
= WMGetPropListDescription(val
, False
);
3364 SendHelperMessage(scr
, 'S', i
+1, str
);
3368 SendHelperMessage(scr
, 'U', i
+1, NULL
);
3373 WMReleasePropList(value
);
3379 setWorkspaceBack(WScreen
*scr
, WDefaultEntry
*entry
, WMPropList
*value
,
3382 if (scr
->flags
.backimage_helper_launched
) {
3385 if (WMGetPropListItemCount(value
)==0) {
3386 SendHelperMessage(scr
, 'U', 0, NULL
);
3388 /* set the default workspace background to this one */
3389 str
= WMGetPropListDescription(value
, False
);
3391 SendHelperMessage(scr
, 'S', 0, str
);
3393 SendHelperMessage(scr
, 'C', scr
->current_workspace
+1, NULL
);
3395 SendHelperMessage(scr
, 'U', 0, NULL
);
3398 } else if (WMGetPropListItemCount(value
) > 0) {
3404 SetupEnvironment(scr
);
3405 text
= WMGetPropListDescription(value
, False
);
3406 len
= strlen(text
)+40;
3407 command
= wmalloc(len
);
3408 dither
= wPreferences
.no_dithering
? "-m" : "-d";
3409 if (wPreferences
.smooth_workspace_back
)
3410 snprintf(command
, len
, "wmsetbg %s -S -p '%s' &", dither
, text
);
3412 snprintf(command
, len
, "wmsetbg %s -p '%s' &", dither
, text
);
3417 WMReleasePropList(value
);
3423 #ifdef VIRTUAL_DESKTOP
3425 setVirtualDeskEnable(WScreen
*scr
, WDefaultEntry
*entry
, void *foo
, void *bar
)
3427 wWorkspaceUpdateEdge(scr
);
3434 setWidgetColor(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
3436 if (scr
->widget_texture
) {
3437 wTextureDestroy(scr
, (WTexture
*)scr
->widget_texture
);
3439 scr
->widget_texture
= *(WTexSolid
**)texture
;
3446 setFTitleBack(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
3448 if (scr
->window_title_texture
[WS_FOCUSED
]) {
3449 wTextureDestroy(scr
, scr
->window_title_texture
[WS_FOCUSED
]);
3451 scr
->window_title_texture
[WS_FOCUSED
] = *texture
;
3453 return REFRESH_WINDOW_TEXTURES
;
3458 setPTitleBack(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
3460 if (scr
->window_title_texture
[WS_PFOCUSED
]) {
3461 wTextureDestroy(scr
, scr
->window_title_texture
[WS_PFOCUSED
]);
3463 scr
->window_title_texture
[WS_PFOCUSED
] = *texture
;
3465 return REFRESH_WINDOW_TEXTURES
;
3470 setUTitleBack(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
3472 if (scr
->window_title_texture
[WS_UNFOCUSED
]) {
3473 wTextureDestroy(scr
, scr
->window_title_texture
[WS_UNFOCUSED
]);
3475 scr
->window_title_texture
[WS_UNFOCUSED
] = *texture
;
3477 return REFRESH_WINDOW_TEXTURES
;
3482 setResizebarBack(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
3484 if (scr
->resizebar_texture
[0]) {
3485 wTextureDestroy(scr
, scr
->resizebar_texture
[0]);
3487 scr
->resizebar_texture
[0] = *texture
;
3489 return REFRESH_WINDOW_TEXTURES
;
3494 setMenuTitleBack(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
3496 if (scr
->menu_title_texture
[0]) {
3497 wTextureDestroy(scr
, scr
->menu_title_texture
[0]);
3499 scr
->menu_title_texture
[0] = *texture
;
3501 return REFRESH_MENU_TITLE_TEXTURE
;
3506 setMenuTextBack(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
3508 if (scr
->menu_item_texture
) {
3509 wTextureDestroy(scr
, scr
->menu_item_texture
);
3510 wTextureDestroy(scr
, (WTexture
*)scr
->menu_item_auxtexture
);
3512 scr
->menu_item_texture
= *texture
;
3514 scr
->menu_item_auxtexture
3515 = wTextureMakeSolid(scr
, &scr
->menu_item_texture
->any
.color
);
3517 return REFRESH_MENU_TEXTURE
;
3522 setKeyGrab(WScreen
*scr
, WDefaultEntry
*entry
, WShortKey
*shortcut
, long index
)
3525 wKeyBindings
[index
] = *shortcut
;
3527 wwin
= scr
->focused_window
;
3529 while (wwin
!=NULL
) {
3530 XUngrabKey(dpy
, AnyKey
, AnyModifier
, wwin
->frame
->core
->window
);
3532 if (!WFLAGP(wwin
, no_bind_keys
)) {
3533 wWindowSetKeyGrabs(wwin
);
3543 setIconPosition(WScreen
*scr
, WDefaultEntry
*entry
, void *bar
, void *foo
)
3545 wScreenUpdateUsableArea(scr
);
3546 wArrangeIcons(scr
, True
);
3553 updateUsableArea(WScreen
*scr
, WDefaultEntry
*entry
, void *bar
, void *foo
)
3555 wScreenUpdateUsableArea(scr
);
3562 setMenuStyle(WScreen
*scr
, WDefaultEntry
*entry
, int *value
, void *foo
)
3564 return REFRESH_MENU_TEXTURE
;
3568 static RImage
*chopOffImage(RImage
*image
, int x
, int y
, int w
, int h
)
3570 RImage
*img
= RCreateImage(w
, h
, image
->format
== RRGBAFormat
);
3572 RCopyArea(img
, image
, x
, y
, w
, h
, 0, 0);
3578 setSwPOptions(WScreen
*scr
, WDefaultEntry
*entry
, WMPropList
*array
, void *foo
)
3582 int cwidth
, cheight
;
3583 WPreferences
*prefs
= (WPreferences
*)foo
;
3585 if (!WMIsPLArray(array
) || WMGetPropListItemCount(array
)==0) {
3586 if (prefs
->swtileImage
) RReleaseImage(prefs
->swtileImage
);
3587 prefs
->swtileImage
= NULL
;
3589 WMReleasePropList(array
);
3593 switch (WMGetPropListItemCount(array
))
3596 if (!WMIsPLString(WMGetFromPLArray(array
, 1))) {
3597 wwarning(_("Invalid arguments for option \"%s\""),
3601 path
= FindImage(wPreferences
.pixmap_path
, WMGetFromPLString(WMGetFromPLArray(array
, 1)));
3604 wwarning(_("Could not find image \"%s\" for option \"%s\""),
3605 WMGetFromPLString(WMGetFromPLArray(array
, 1)),
3608 bgimage
= RLoadImage(scr
->rcontext
, path
, 0);
3610 wwarning(_("Could not load image \"%s\" for option \"%s\""),
3616 cwidth
= atoi(WMGetFromPLString(WMGetFromPLArray(array
, 2)));
3617 cheight
= atoi(WMGetFromPLString(WMGetFromPLArray(array
, 3)));
3619 if (cwidth
<= 0 || cheight
<= 0 ||
3620 cwidth
>= bgimage
->width
- 2 ||
3621 cheight
>= bgimage
->height
- 2)
3622 wwarning(_("Invalid split sizes for SwitchPanel back image."));
3625 int swidth
, theight
;
3626 for (i
= 0; i
< 9; i
++) {
3627 if (prefs
->swbackImage
[i
])
3628 RReleaseImage(prefs
->swbackImage
[i
]);
3629 prefs
->swbackImage
[i
]= NULL
;
3631 swidth
= (bgimage
->width
- cwidth
) / 2;
3632 theight
= (bgimage
->height
- cheight
) / 2;
3634 prefs
->swbackImage
[0]= chopOffImage(bgimage
, 0, 0,
3636 prefs
->swbackImage
[1]= chopOffImage(bgimage
, swidth
, 0,
3638 prefs
->swbackImage
[2]= chopOffImage(bgimage
, swidth
+cwidth
, 0,
3641 prefs
->swbackImage
[3]= chopOffImage(bgimage
, 0, theight
,
3643 prefs
->swbackImage
[4]= chopOffImage(bgimage
, swidth
, theight
,
3645 prefs
->swbackImage
[5]= chopOffImage(bgimage
, swidth
+cwidth
, theight
,
3648 prefs
->swbackImage
[6]= chopOffImage(bgimage
, 0, theight
+cheight
,
3650 prefs
->swbackImage
[7]= chopOffImage(bgimage
, swidth
, theight
+cheight
,
3652 prefs
->swbackImage
[8]= chopOffImage(bgimage
, swidth
+cwidth
, theight
+cheight
,
3655 // check if anything failed
3656 for (i
= 0; i
< 9; i
++) {
3657 if (!prefs
->swbackImage
[i
]) {
3659 RReleaseImage(prefs
->swbackImage
[i
]);
3660 prefs
->swbackImage
[i
]= NULL
;
3666 RReleaseImage(bgimage
);
3671 if (!WMIsPLString(WMGetFromPLArray(array
, 0))) {
3672 wwarning(_("Invalid arguments for option \"%s\""),
3676 path
= FindImage(wPreferences
.pixmap_path
, WMGetFromPLString(WMGetFromPLArray(array
, 0)));
3679 wwarning(_("Could not find image \"%s\" for option \"%s\""),
3680 WMGetFromPLString(WMGetFromPLArray(array
, 0)),
3683 if (prefs
->swtileImage
) RReleaseImage(prefs
->swtileImage
);
3685 prefs
->swtileImage
= RLoadImage(scr
->rcontext
, path
, 0);
3686 if (!prefs
->swtileImage
) {
3687 wwarning(_("Could not load image \"%s\" for option \"%s\""),
3695 wwarning(_("Invalid number of arguments for option \"%s\""),
3700 WMReleasePropList(array
);
3708 setButtonImages(WScreen *scr, WDefaultEntry *entry, int *value, void *foo)
3710 return REFRESH_BUTTON_IMAGES;
3716 * Need access to the double click variables, so that all widgets in
3717 * wmaker panels will have the same dbl-click values.
3718 * TODO: figure a better way of dealing with it.
3720 #include <WINGs/WINGsP.h>
3723 setDoubleClick(WScreen
*scr
, WDefaultEntry
*entry
, int *value
, void *foo
)
3725 extern _WINGsConfiguration WINGsConfiguration
;
3730 WINGsConfiguration
.doubleClickDelay
= *value
;
3737 setCursor(WScreen
*scr
, WDefaultEntry
*entry
, Cursor
*cursor
, long index
)
3739 if (wCursor
[index
] != None
) {
3740 XFreeCursor(dpy
, wCursor
[index
]);
3743 wCursor
[index
] = *cursor
;
3745 if (index
==WCUR_ROOT
&& *cursor
!=None
) {
3746 XDefineCursor(dpy
, scr
->root_win
, *cursor
);