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,
33 #include <sys/types.h>
46 #define PATH_MAX DEFAULT_PATH_MAX
50 #include <X11/Xutil.h>
51 #include <X11/keysym.h>
55 #include "WindowMaker.h"
61 #include "resources.h"
64 #include "xmodifier.h"
69 #include "workspace.h"
70 #include "properties.h"
72 #define MAX_SHORTCUT_LENGTH 32
76 extern WDDomain
*WDWindowMaker
;
77 extern WDDomain
*WDWindowAttributes
;
78 extern WDDomain
*WDRootMenu
;
80 extern int wScreenCount
;
82 extern Atom _XA_WINDOWMAKER_ICON_SIZE
;
83 extern Atom _XA_WINDOWMAKER_ICON_TILE
;
86 extern WMPropList *wDomainName;
87 extern WMPropList *wAttributeDomainName;
89 extern WPreferences wPreferences
;
91 extern WShortKey wKeyBindings
[WKBD_LAST
];
101 WMPropList
*plvalue
; /* default value */
105 /* used to map strings to integers */
110 } WOptionEnumeration
;
113 /* type converters */
114 static int getBool();
116 static int getCoord();
118 /* this is not used yet */
119 static int getString();
121 static int getPathList();
122 static int getEnum();
123 static int getTexture();
124 static int getWSBackground();
125 static int getWSSpecificBackground();
126 static int getFont();
127 static int getColor();
128 static int getKeybind();
129 static int getModMask();
131 static int getRImage();
133 static int getPropList();
135 /* value setting functions */
136 static int setJustify();
137 static int setClearance();
138 static int setIfDockPresent();
139 static int setStickyIcons();
141 static int setPositive();
143 static int setWidgetColor();
144 static int setIconTile();
145 static int setWinTitleFont();
146 static int setMenuTitleFont();
147 static int setMenuTextFont();
148 static int setIconTitleFont();
149 static int setIconTitleColor();
150 static int setIconTitleBack();
151 static int setLargeDisplayFont();
152 static int setWTitleColor();
153 static int setFTitleBack();
154 static int setPTitleBack();
155 static int setUTitleBack();
156 static int setResizebarBack();
157 static int setWorkspaceBack();
158 static int setWorkspaceSpecificBack();
159 #ifdef VIRTUAL_DESKTOP
160 static int setVirtualDeskEnable();
162 static int setMenuTitleColor();
163 static int setMenuTextColor();
164 static int setMenuDisabledColor();
165 static int setMenuTitleBack();
166 static int setMenuTextBack();
167 static int setHightlight();
168 static int setHightlightText();
169 static int setKeyGrab();
170 static int setDoubleClick();
171 static int setIconPosition();
173 static int setClipTitleFont();
174 static int setClipTitleColor();
176 static int setMenuStyle();
177 static int setSwPOptions();
178 static int updateUsableArea();
181 extern Cursor wCursor
[WCUR_LAST
];
182 static int getCursor();
183 static int setCursor();
187 * Tables to convert strings to enumeration values.
188 * Values stored are char
192 /* WARNING: sum of length of all value strings must not exceed
194 #define TOTAL_VALUES_LENGTH 80
199 #define REFRESH_WINDOW_TEXTURES (1<<0)
200 #define REFRESH_MENU_TEXTURE (1<<1)
201 #define REFRESH_MENU_FONT (1<<2)
202 #define REFRESH_MENU_COLOR (1<<3)
203 #define REFRESH_MENU_TITLE_TEXTURE (1<<4)
204 #define REFRESH_MENU_TITLE_FONT (1<<5)
205 #define REFRESH_MENU_TITLE_COLOR (1<<6)
206 #define REFRESH_WINDOW_TITLE_COLOR (1<<7)
207 #define REFRESH_WINDOW_FONT (1<<8)
208 #define REFRESH_ICON_TILE (1<<9)
209 #define REFRESH_ICON_FONT (1<<10)
210 #define REFRESH_WORKSPACE_BACK (1<<11)
212 #define REFRESH_BUTTON_IMAGES (1<<12)
214 #define REFRESH_ICON_TITLE_COLOR (1<<13)
215 #define REFRESH_ICON_TITLE_BACK (1<<14)
219 static WOptionEnumeration seFocusModes
[] = {
220 {"Manual", WKF_CLICK
, 0}, {"ClickToFocus", WKF_CLICK
, 1},
221 {"Sloppy", WKF_SLOPPY
, 0}, {"SemiAuto", WKF_SLOPPY
, 1}, {"Auto", WKF_SLOPPY
, 1},
225 static WOptionEnumeration seColormapModes
[] = {
226 {"Manual", WCM_CLICK
, 0}, {"ClickToFocus", WCM_CLICK
, 1},
227 {"Auto", WCM_POINTER
, 0}, {"FocusFollowMouse", WCM_POINTER
, 1},
231 static WOptionEnumeration sePlacements
[] = {
232 {"Auto", WPM_AUTO
, 0},
233 {"Smart", WPM_SMART
, 0},
234 {"Cascade", WPM_CASCADE
, 0},
235 {"Random", WPM_RANDOM
, 0},
236 {"Manual", WPM_MANUAL
, 0},
240 static WOptionEnumeration seGeomDisplays
[] = {
241 {"None", WDIS_NONE
, 0},
242 {"Center", WDIS_CENTER
, 0},
243 {"Corner", WDIS_TOPLEFT
, 0},
244 {"Floating", WDIS_FRAME_CENTER
, 0},
245 {"Line", WDIS_NEW
, 0},
249 static WOptionEnumeration seSpeeds
[] = {
250 {"UltraFast", SPEED_ULTRAFAST
, 0},
251 {"Fast", SPEED_FAST
, 0},
252 {"Medium", SPEED_MEDIUM
, 0},
253 {"Slow", SPEED_SLOW
, 0},
254 {"UltraSlow", SPEED_ULTRASLOW
, 0},
258 static WOptionEnumeration seMouseButtonActions
[] = {
259 {"None", WA_NONE
, 0},
260 {"SelectWindows", WA_SELECT_WINDOWS
, 0},
261 {"OpenApplicationsMenu", WA_OPEN_APPMENU
, 0},
262 {"OpenWindowListMenu", WA_OPEN_WINLISTMENU
, 0},
266 static WOptionEnumeration seMouseWheelActions
[] = {
267 {"None", WA_NONE
, 0},
268 {"SwitchWorkspaces", WA_SWITCH_WORKSPACES
, 0},
272 static WOptionEnumeration seIconificationStyles
[] = {
273 {"Zoom", WIS_ZOOM
, 0},
274 {"Twist", WIS_TWIST
, 0},
275 {"Flip", WIS_FLIP
, 0},
276 {"None", WIS_NONE
, 0},
277 {"random", WIS_RANDOM
, 0},
281 static WOptionEnumeration seJustifications
[] = {
282 {"Left", WTJ_LEFT
, 0},
283 {"Center", WTJ_CENTER
, 0},
284 {"Right", WTJ_RIGHT
, 0},
288 static WOptionEnumeration seIconPositions
[] = {
289 {"blv", IY_BOTTOM
|IY_LEFT
|IY_VERT
, 0},
290 {"blh", IY_BOTTOM
|IY_LEFT
|IY_HORIZ
, 0},
291 {"brv", IY_BOTTOM
|IY_RIGHT
|IY_VERT
, 0},
292 {"brh", IY_BOTTOM
|IY_RIGHT
|IY_HORIZ
, 0},
293 {"tlv", IY_TOP
|IY_LEFT
|IY_VERT
, 0},
294 {"tlh", IY_TOP
|IY_LEFT
|IY_HORIZ
, 0},
295 {"trv", IY_TOP
|IY_RIGHT
|IY_VERT
, 0},
296 {"trh", IY_TOP
|IY_RIGHT
|IY_HORIZ
, 0},
300 static WOptionEnumeration seMenuStyles
[] = {
301 {"normal", MS_NORMAL
, 0},
302 {"singletexture", MS_SINGLE_TEXTURE
, 0},
303 {"flat", MS_FLAT
, 0},
308 static WOptionEnumeration seDisplayPositions
[] = {
309 {"none", WD_NONE
, 0},
310 {"center", WD_CENTER
, 0},
312 {"bottom", WD_BOTTOM
, 0},
313 {"topleft", WD_TOPLEFT
, 0},
314 {"topright", WD_TOPRIGHT
, 0},
315 {"bottomleft", WD_BOTTOMLEFT
, 0},
316 {"bottomright", WD_BOTTOMRIGHT
, 0},
320 static WOptionEnumeration seWorkspaceBorder
[] = {
321 {"None", WB_NONE
, 0},
322 {"LeftRight", WB_LEFTRIGHT
, 0},
323 {"TopBottom", WB_TOPBOTTOM
, 0},
324 {"AllDirections", WB_ALLDIRS
, 0},
330 * ALL entries in the tables bellow, NEED to have a default value
331 * defined, and this value needs to be correct.
334 /* these options will only affect the window manager on startup
336 * static defaults can't access the screen data, because it is
337 * created after these defaults are read
339 WDefaultEntry staticOptionList
[] = {
341 {"ColormapSize", "4", NULL
,
342 &wPreferences
.cmap_size
, getInt
, NULL
344 {"DisableDithering", "NO", NULL
,
345 &wPreferences
.no_dithering
, getBool
, NULL
347 /* static by laziness */
348 {"IconSize", "64", NULL
,
349 &wPreferences
.icon_size
, getInt
, NULL
351 {"ModifierKey", "Mod1", NULL
,
352 &wPreferences
.modifier_mask
, getModMask
, NULL
354 {"DisableWSMouseActions", "NO", NULL
,
355 &wPreferences
.disable_root_mouse
, getBool
, NULL
357 {"FocusMode", "manual", seFocusModes
,
358 &wPreferences
.focus_mode
, getEnum
, NULL
359 }, /* have a problem when switching from manual to sloppy without restart */
360 {"NewStyle", "NO", NULL
,
361 &wPreferences
.new_style
, getBool
, NULL
363 {"DisableDock", "NO", (void*) WM_DOCK
,
364 NULL
, getBool
, setIfDockPresent
366 {"DisableClip", "NO", (void*) WM_CLIP
,
367 NULL
, getBool
, setIfDockPresent
369 {"DisableMiniwindows", "NO", NULL
,
370 &wPreferences
.disable_miniwindows
, getBool
, NULL
376 WDefaultEntry optionList
[] = {
377 /* dynamic options */
378 {"IconPosition", "blh", seIconPositions
,
379 &wPreferences
.icon_yard
, getEnum
, setIconPosition
381 {"IconificationStyle", "Zoom", seIconificationStyles
,
382 &wPreferences
.iconification_style
, getEnum
, NULL
384 {"MouseLeftButtonAction", "SelectWindows", seMouseButtonActions
,
385 &wPreferences
.mouse_button1
, getEnum
, NULL
387 {"MouseMiddleButtonAction", "OpenWindowListMenu", seMouseButtonActions
,
388 &wPreferences
.mouse_button2
, getEnum
, NULL
390 {"MouseRightButtonAction", "OpenApplicationsMenu", seMouseButtonActions
,
391 &wPreferences
.mouse_button3
, getEnum
, NULL
393 {"MouseWheelAction", "None", seMouseWheelActions
,
394 &wPreferences
.mouse_wheel
, getEnum
, NULL
396 {"PixmapPath", DEF_PIXMAP_PATHS
, NULL
,
397 &wPreferences
.pixmap_path
, getPathList
, NULL
399 {"IconPath", DEF_ICON_PATHS
, NULL
,
400 &wPreferences
.icon_path
, getPathList
, NULL
402 {"ColormapMode", "auto", seColormapModes
,
403 &wPreferences
.colormap_mode
, getEnum
, NULL
405 {"AutoFocus", "NO", NULL
,
406 &wPreferences
.auto_focus
, getBool
, NULL
408 {"RaiseDelay", "0", NULL
,
409 &wPreferences
.raise_delay
, getInt
, NULL
411 {"CirculateRaise", "NO", NULL
,
412 &wPreferences
.circ_raise
, getBool
, NULL
414 {"Superfluous", "NO", NULL
,
415 &wPreferences
.superfluous
, getBool
, NULL
417 {"AdvanceToNewWorkspace", "NO", NULL
,
418 &wPreferences
.ws_advance
, getBool
, NULL
420 {"CycleWorkspaces", "NO", NULL
,
421 &wPreferences
.ws_cycle
, getBool
, NULL
423 {"WorkspaceNameDisplayPosition", "center", seDisplayPositions
,
424 &wPreferences
.workspace_name_display_position
, getEnum
, NULL
426 {"WorkspaceBorder", "None", seWorkspaceBorder
,
427 &wPreferences
.workspace_border_position
, getEnum
, updateUsableArea
429 {"WorkspaceBorderSize", "0", NULL
,
430 &wPreferences
.workspace_border_size
, getInt
, updateUsableArea
432 #ifdef VIRTUAL_DESKTOP
433 {"EnableVirtualDesktop", "NO", NULL
,
434 &wPreferences
.vdesk_enable
, getBool
, setVirtualDeskEnable
436 {"VirtualEdgeExtendSpace", "0", NULL
,
437 &wPreferences
.vedge_bordersize
, getInt
, NULL
439 {"VirtualEdgeHorizonScrollSpeed", "30", NULL
,
440 &wPreferences
.vedge_hscrollspeed
, getInt
, NULL
442 {"VirtualEdgeVerticalScrollSpeed", "30", NULL
,
443 &wPreferences
.vedge_vscrollspeed
, getInt
, NULL
445 {"VirtualEdgeResistance", "30", NULL
,
446 &wPreferences
.vedge_resistance
, getInt
, NULL
448 {"VirtualEdgeAttraction", "30", NULL
,
449 &wPreferences
.vedge_attraction
, getInt
, NULL
451 {"VirtualEdgeLeftKey", "None", (void*)WKBD_VDESK_LEFT
,
452 NULL
, getKeybind
, setKeyGrab
454 {"VirtualEdgeRightKey", "None", (void*)WKBD_VDESK_RIGHT
,
455 NULL
, getKeybind
, setKeyGrab
457 {"VirtualEdgeUpKey", "None", (void*)WKBD_VDESK_UP
,
458 NULL
, getKeybind
, setKeyGrab
460 {"VirtualEdgeDownKey", "None", (void*)WKBD_VDESK_DOWN
,
461 NULL
, getKeybind
, setKeyGrab
464 {"StickyIcons", "NO", NULL
,
465 &wPreferences
.sticky_icons
, getBool
, setStickyIcons
467 {"SaveSessionOnExit", "NO", NULL
,
468 &wPreferences
.save_session_on_exit
, getBool
, NULL
470 {"WrapMenus", "NO", NULL
,
471 &wPreferences
.wrap_menus
, getBool
, NULL
473 {"ScrollableMenus", "NO", NULL
,
474 &wPreferences
.scrollable_menus
, getBool
, NULL
476 {"MenuScrollSpeed", "medium", seSpeeds
,
477 &wPreferences
.menu_scroll_speed
, getEnum
, NULL
479 {"IconSlideSpeed", "medium", seSpeeds
,
480 &wPreferences
.icon_slide_speed
, getEnum
, NULL
482 {"ShadeSpeed", "medium", seSpeeds
,
483 &wPreferences
.shade_speed
, getEnum
, NULL
485 {"DoubleClickTime", "250", (void*) &wPreferences
.dblclick_time
,
486 &wPreferences
.dblclick_time
, getInt
, setDoubleClick
,
488 {"AlignSubmenus", "NO", NULL
,
489 &wPreferences
.align_menus
, getBool
, NULL
491 {"OpenTransientOnOwnerWorkspace", "NO", NULL
,
492 &wPreferences
.open_transients_with_parent
, getBool
, NULL
494 {"WindowPlacement", "auto", sePlacements
,
495 &wPreferences
.window_placement
, getEnum
, NULL
497 {"IgnoreFocusClick","NO", NULL
,
498 &wPreferences
.ignore_focus_click
, getBool
, NULL
500 {"UseSaveUnders", "NO", NULL
,
501 &wPreferences
.use_saveunders
, getBool
, NULL
503 {"OpaqueMove", "NO", NULL
,
504 &wPreferences
.opaque_move
, getBool
, NULL
506 {"DisableSound", "NO", NULL
,
507 &wPreferences
.no_sound
, getBool
, NULL
509 {"DisableAnimations", "NO", NULL
,
510 &wPreferences
.no_animations
, getBool
, NULL
512 {"DontLinkWorkspaces","NO", NULL
,
513 &wPreferences
.no_autowrap
, getBool
, NULL
515 {"AutoArrangeIcons", "NO", NULL
,
516 &wPreferences
.auto_arrange_icons
, getBool
, NULL
518 {"NoWindowOverDock", "NO", NULL
,
519 &wPreferences
.no_window_over_dock
, getBool
, updateUsableArea
521 {"NoWindowOverIcons", "NO", NULL
,
522 &wPreferences
.no_window_over_icons
, getBool
, updateUsableArea
524 {"WindowPlaceOrigin", "(0, 0)", NULL
,
525 &wPreferences
.window_place_origin
, getCoord
, NULL
527 {"ResizeDisplay", "corner", seGeomDisplays
,
528 &wPreferences
.size_display
, getEnum
, NULL
530 {"MoveDisplay", "corner", seGeomDisplays
,
531 &wPreferences
.move_display
, getEnum
, NULL
533 {"DontConfirmKill", "NO", NULL
,
534 &wPreferences
.dont_confirm_kill
, getBool
,NULL
536 {"WindowTitleBalloons", "NO", NULL
,
537 &wPreferences
.window_balloon
, getBool
, NULL
539 {"MiniwindowTitleBalloons", "NO", NULL
,
540 &wPreferences
.miniwin_balloon
,getBool
, NULL
542 {"AppIconBalloons", "NO", NULL
,
543 &wPreferences
.appicon_balloon
,getBool
, NULL
545 {"HelpBalloons", "NO", NULL
,
546 &wPreferences
.help_balloon
, getBool
, NULL
548 {"EdgeResistance", "30", NULL
,
549 &wPreferences
.edge_resistance
,getInt
, NULL
551 {"Attraction", "NO", NULL
,
552 &wPreferences
.attract
, getBool
, NULL
554 {"DisableBlinking", "NO", NULL
,
555 &wPreferences
.dont_blink
, getBool
, NULL
558 {"MenuStyle", "normal", seMenuStyles
,
559 &wPreferences
.menu_style
, getEnum
, setMenuStyle
561 {"WidgetColor", "(solid, gray)", NULL
,
562 NULL
, getTexture
, setWidgetColor
,
564 {"WorkspaceSpecificBack","()", NULL
,
565 NULL
, getWSSpecificBackground
, setWorkspaceSpecificBack
567 /* WorkspaceBack must come after WorkspaceSpecificBack or
568 * WorkspaceBack wont know WorkspaceSpecificBack was also
569 * specified and 2 copies of wmsetbg will be launched */
570 {"WorkspaceBack", "(solid, black)", NULL
,
571 NULL
, getWSBackground
,setWorkspaceBack
573 {"SmoothWorkspaceBack", "NO", NULL
,
576 {"IconBack", "(solid, gray)", NULL
,
577 NULL
, getTexture
, setIconTile
579 {"TitleJustify", "center", seJustifications
,
580 &wPreferences
.title_justification
, getEnum
, setJustify
582 {"WindowTitleFont", DEF_TITLE_FONT
, NULL
,
583 NULL
, getFont
, setWinTitleFont
,
585 {"WindowTitleExtendSpace", DEF_WINDOW_TITLE_EXTEND_SPACE
, NULL
,
586 &wPreferences
.window_title_clearance
, getInt
, setClearance
588 {"MenuTitleExtendSpace", DEF_MENU_TITLE_EXTEND_SPACE
, NULL
,
589 &wPreferences
.menu_title_clearance
, getInt
, setClearance
591 {"MenuTextExtendSpace", DEF_MENU_TEXT_EXTEND_SPACE
, NULL
,
592 &wPreferences
.menu_text_clearance
, getInt
, setClearance
594 {"MenuTitleFont", DEF_MENU_TITLE_FONT
, NULL
,
595 NULL
, getFont
, setMenuTitleFont
597 {"MenuTextFont", DEF_MENU_ENTRY_FONT
, NULL
,
598 NULL
, getFont
, setMenuTextFont
600 {"IconTitleFont", DEF_ICON_TITLE_FONT
, NULL
,
601 NULL
, getFont
, setIconTitleFont
603 {"ClipTitleFont", DEF_CLIP_TITLE_FONT
, NULL
,
604 NULL
, getFont
, setClipTitleFont
606 {"LargeDisplayFont",DEF_WORKSPACE_NAME_FONT
, NULL
,
607 NULL
, getFont
, setLargeDisplayFont
609 {"HighlightColor", "white", NULL
,
610 NULL
, getColor
, setHightlight
612 {"HighlightTextColor", "black", NULL
,
613 NULL
, getColor
, setHightlightText
615 {"ClipTitleColor", "black", (void*)CLIP_NORMAL
,
616 NULL
, getColor
, setClipTitleColor
618 {"CClipTitleColor", "\"#454045\"", (void*)CLIP_COLLAPSED
,
619 NULL
, getColor
, setClipTitleColor
621 {"FTitleColor", "white", (void*)WS_FOCUSED
,
622 NULL
, getColor
, setWTitleColor
624 {"PTitleColor", "white", (void*)WS_PFOCUSED
,
625 NULL
, getColor
, setWTitleColor
627 {"UTitleColor", "black", (void*)WS_UNFOCUSED
,
628 NULL
, getColor
, setWTitleColor
630 {"FTitleBack", "(solid, black)", NULL
,
631 NULL
, getTexture
, setFTitleBack
633 {"PTitleBack", "(solid, \"#616161\")", NULL
,
634 NULL
, getTexture
, setPTitleBack
636 {"UTitleBack", "(solid, gray)", NULL
,
637 NULL
, getTexture
, setUTitleBack
639 {"ResizebarBack", "(solid, gray)", NULL
,
640 NULL
, getTexture
, setResizebarBack
642 {"MenuTitleColor", "white", NULL
,
643 NULL
, getColor
, setMenuTitleColor
645 {"MenuTextColor", "black", NULL
,
646 NULL
, getColor
, setMenuTextColor
648 {"MenuDisabledColor", "\"#616161\"", NULL
,
649 NULL
, getColor
, setMenuDisabledColor
651 {"MenuTitleBack", "(solid, black)", NULL
,
652 NULL
, getTexture
, setMenuTitleBack
654 {"MenuTextBack", "(solid, gray)", NULL
,
655 NULL
, getTexture
, setMenuTextBack
657 {"IconTitleColor", "white", NULL
,
658 NULL
, getColor
, setIconTitleColor
660 {"IconTitleBack", "black", NULL
,
661 NULL
, getColor
, setIconTitleBack
663 {"SwitchPanelImages", "(swtile.png, swback.png, 30, 40)", &wPreferences
,
664 NULL
, getPropList
, setSwPOptions
668 {"RootMenuKey", "None", (void*)WKBD_ROOTMENU
,
669 NULL
, getKeybind
, setKeyGrab
671 {"WindowListKey", "None", (void*)WKBD_WINDOWLIST
,
672 NULL
, getKeybind
, setKeyGrab
675 {"WindowMenuKey", "None", (void*)WKBD_WINDOWMENU
,
676 NULL
, getKeybind
, setKeyGrab
678 {"ClipLowerKey", "None", (void*)WKBD_CLIPLOWER
,
679 NULL
, getKeybind
, setKeyGrab
681 {"ClipRaiseKey", "None", (void*)WKBD_CLIPRAISE
,
682 NULL
, getKeybind
, setKeyGrab
684 {"ClipRaiseLowerKey", "None", (void*)WKBD_CLIPRAISELOWER
,
685 NULL
, getKeybind
, setKeyGrab
687 {"MiniaturizeKey", "None", (void*)WKBD_MINIATURIZE
,
688 NULL
, getKeybind
, setKeyGrab
690 {"HideKey", "None", (void*)WKBD_HIDE
,
691 NULL
, getKeybind
, setKeyGrab
693 {"HideOthersKey", "None", (void*)WKBD_HIDE_OTHERS
,
694 NULL
, getKeybind
, setKeyGrab
696 {"MoveResizeKey", "None", (void*)WKBD_MOVERESIZE
,
697 NULL
, getKeybind
, setKeyGrab
699 {"CloseKey", "None", (void*)WKBD_CLOSE
,
700 NULL
, getKeybind
, setKeyGrab
702 {"MaximizeKey", "None", (void*)WKBD_MAXIMIZE
,
703 NULL
, getKeybind
, setKeyGrab
705 {"VMaximizeKey", "None", (void*)WKBD_VMAXIMIZE
,
706 NULL
, getKeybind
, setKeyGrab
708 {"HMaximizeKey", "None", (void*)WKBD_HMAXIMIZE
,
709 NULL
, getKeybind
, setKeyGrab
711 {"RaiseKey", "\"Meta+Up\"", (void*)WKBD_RAISE
,
712 NULL
, getKeybind
, setKeyGrab
714 {"LowerKey", "\"Meta+Down\"", (void*)WKBD_LOWER
,
715 NULL
, getKeybind
, setKeyGrab
717 {"RaiseLowerKey", "None", (void*)WKBD_RAISELOWER
,
718 NULL
, getKeybind
, setKeyGrab
720 {"ShadeKey", "None", (void*)WKBD_SHADE
,
721 NULL
, getKeybind
, setKeyGrab
723 {"SelectKey", "None", (void*)WKBD_SELECT
,
724 NULL
, getKeybind
, setKeyGrab
726 {"FocusNextKey", "None", (void*)WKBD_FOCUSNEXT
,
727 NULL
, getKeybind
, setKeyGrab
729 {"FocusPrevKey", "None", (void*)WKBD_FOCUSPREV
,
730 NULL
, getKeybind
, setKeyGrab
732 {"NextWorkspaceKey", "None", (void*)WKBD_NEXTWORKSPACE
,
733 NULL
, getKeybind
, setKeyGrab
735 {"PrevWorkspaceKey", "None", (void*)WKBD_PREVWORKSPACE
,
736 NULL
, getKeybind
, setKeyGrab
738 {"NextWorkspaceLayerKey", "None", (void*)WKBD_NEXTWSLAYER
,
739 NULL
, getKeybind
, setKeyGrab
741 {"PrevWorkspaceLayerKey", "None", (void*)WKBD_PREVWSLAYER
,
742 NULL
, getKeybind
, setKeyGrab
744 {"Workspace1Key", "None", (void*)WKBD_WORKSPACE1
,
745 NULL
, getKeybind
, setKeyGrab
747 {"Workspace2Key", "None", (void*)WKBD_WORKSPACE2
,
748 NULL
, getKeybind
, setKeyGrab
750 {"Workspace3Key", "None", (void*)WKBD_WORKSPACE3
,
751 NULL
, getKeybind
, setKeyGrab
753 {"Workspace4Key", "None", (void*)WKBD_WORKSPACE4
,
754 NULL
, getKeybind
, setKeyGrab
756 {"Workspace5Key", "None", (void*)WKBD_WORKSPACE5
,
757 NULL
, getKeybind
, setKeyGrab
759 {"Workspace6Key", "None", (void*)WKBD_WORKSPACE6
,
760 NULL
, getKeybind
, setKeyGrab
762 {"Workspace7Key", "None", (void*)WKBD_WORKSPACE7
,
763 NULL
, getKeybind
, setKeyGrab
765 {"Workspace8Key", "None", (void*)WKBD_WORKSPACE8
,
766 NULL
, getKeybind
, setKeyGrab
768 {"Workspace9Key", "None", (void*)WKBD_WORKSPACE9
,
769 NULL
, getKeybind
, setKeyGrab
771 {"Workspace10Key", "None", (void*)WKBD_WORKSPACE10
,
772 NULL
, getKeybind
, setKeyGrab
774 {"WindowShortcut1Key","None", (void*)WKBD_WINDOW1
,
775 NULL
, getKeybind
, setKeyGrab
777 {"WindowShortcut2Key","None", (void*)WKBD_WINDOW2
,
778 NULL
, getKeybind
, setKeyGrab
780 {"WindowShortcut3Key","None", (void*)WKBD_WINDOW3
,
781 NULL
, getKeybind
, setKeyGrab
783 {"WindowShortcut4Key","None", (void*)WKBD_WINDOW4
,
784 NULL
, getKeybind
, setKeyGrab
786 ,{"WindowShortcut5Key","None", (void*)WKBD_WINDOW5
,
787 NULL
, getKeybind
, setKeyGrab
789 {"WindowShortcut6Key","None", (void*)WKBD_WINDOW6
,
790 NULL
, getKeybind
, setKeyGrab
792 {"WindowShortcut7Key","None", (void*)WKBD_WINDOW7
,
793 NULL
, getKeybind
, setKeyGrab
795 {"WindowShortcut8Key","None", (void*)WKBD_WINDOW8
,
796 NULL
, getKeybind
, setKeyGrab
798 {"WindowShortcut9Key","None", (void*)WKBD_WINDOW9
,
799 NULL
, getKeybind
, setKeyGrab
801 {"WindowShortcut10Key","None", (void*)WKBD_WINDOW10
,
802 NULL
, getKeybind
, setKeyGrab
804 {"ScreenSwitchKey", "None", (void*)WKBD_SWITCH_SCREEN
,
805 NULL
, getKeybind
, setKeyGrab
808 #ifdef KEEP_XKB_LOCK_STATUS
809 {"ToggleKbdModeKey", "None", (void*)WKBD_TOGGLE
,
810 NULL
, getKeybind
, setKeyGrab
812 {"KbdModeLock", "NO", NULL
,
813 &wPreferences
.modelock
, getBool
, NULL
815 #endif /* KEEP_XKB_LOCK_STATUS */
817 {"NormalCursor", "(builtin, left_ptr)", (void*)WCUR_ROOT
,
818 NULL
, getCursor
, setCursor
820 {"ArrowCursor", "(builtin, top_left_arrow)", (void*)WCUR_ARROW
,
821 NULL
, getCursor
, setCursor
823 {"MoveCursor", "(builtin, fleur)", (void*)WCUR_MOVE
,
824 NULL
, getCursor
, setCursor
826 {"ResizeCursor", "(builtin, sizing)", (void*)WCUR_RESIZE
,
827 NULL
, getCursor
, setCursor
829 {"TopLeftResizeCursor", "(builtin, top_left_corner)",
830 (void*)WCUR_TOPLEFTRESIZE
,
831 NULL
, getCursor
, setCursor
833 {"TopRightResizeCursor", "(builtin, top_right_corner)",
834 (void*)WCUR_TOPRIGHTRESIZE
,
835 NULL
, getCursor
, setCursor
837 {"BottomLeftResizeCursor", "(builtin, bottom_left_corner)",
838 (void*)WCUR_BOTTOMLEFTRESIZE
,
839 NULL
, getCursor
, setCursor
841 {"BottomRightResizeCursor", "(builtin, bottom_right_corner)",
842 (void*)WCUR_BOTTOMRIGHTRESIZE
,
843 NULL
, getCursor
, setCursor
845 {"VerticalResizeCursor", "(builtin, sb_v_double_arrow)",
846 (void*)WCUR_VERTICALRESIZE
,
847 NULL
, getCursor
, setCursor
849 {"HorizontalResizeCursor", "(builtin, sb_h_double_arrow)",
850 (void*)WCUR_HORIZONRESIZE
,
851 NULL
, getCursor
, setCursor
853 {"WaitCursor", "(builtin, watch)", (void*)WCUR_WAIT
,
854 NULL
, getCursor
, setCursor
856 {"QuestionCursor", "(builtin, question_arrow)", (void*)WCUR_QUESTION
,
857 NULL
, getCursor
, setCursor
859 {"TextCursor", "(builtin, xterm)", (void*)WCUR_TEXT
,
860 NULL
, getCursor
, setCursor
862 {"SelectCursor", "(builtin, cross)", (void*)WCUR_SELECT
,
863 NULL
, getCursor
, setCursor
869 static void rereadDefaults(void);
876 /* must defer the update because accessing X data from a
877 * signal handler can mess up Xlib */
886 WDefaultEntry
*entry
;
888 WMPLSetCaseSensitive(False
);
890 for (i
=0; i
<sizeof(optionList
)/sizeof(WDefaultEntry
); i
++) {
891 entry
= &optionList
[i
];
893 entry
->plkey
= WMCreatePLString(entry
->key
);
894 if (entry
->default_value
)
895 entry
->plvalue
= WMCreatePropListFromDescription(entry
->default_value
);
897 entry
->plvalue
= NULL
;
900 for (i
=0; i
<sizeof(staticOptionList
)/sizeof(WDefaultEntry
); i
++) {
901 entry
= &staticOptionList
[i
];
903 entry
->plkey
= WMCreatePLString(entry
->key
);
904 if (entry
->default_value
)
905 entry
->plvalue
= WMCreatePropListFromDescription(entry
->default_value
);
907 entry
->plvalue
= NULL
;
911 wDomainName = WMCreatePLString(WMDOMAIN_NAME);
912 wAttributeDomainName = WMCreatePLString(WMATTRIBUTE_DOMAIN_NAME);
914 PLRegister(wDomainName, rereadDefaults);
915 PLRegister(wAttributeDomainName, rereadDefaults);
921 readGlobalDomain(char *domainName
, Bool requireDictionary
)
923 WMPropList
*globalDict
= NULL
;
927 snprintf(path
, sizeof(path
), "%s/WindowMaker/%s", SYSCONFDIR
, domainName
);
928 if (stat(path
, &stbuf
)>=0) {
929 globalDict
= WMReadPropListFromFile(path
);
930 if (globalDict
&& requireDictionary
&& !WMIsPLDictionary(globalDict
)) {
931 wwarning(_("Domain %s (%s) of global defaults database is corrupted!"),
933 WMReleasePropList(globalDict
);
935 } else if (!globalDict
) {
936 wwarning(_("could not load domain %s from global defaults database"),
945 #if defined(GLOBAL_PREAMBLE_MENU_FILE) || defined(GLOBAL_EPILOGUE_MENU_FILE)
947 prependMenu(WMPropList
*destarr
, WMPropList
*array
)
952 for (i
=0; i
<WMGetPropListItemCount(array
); i
++) {
953 item
= WMGetFromPLArray(array
, i
);
955 WMInsertInPLArray(destarr
, i
+1, item
);
961 appendMenu(WMPropList
*destarr
, WMPropList
*array
)
966 for (i
=0; i
<WMGetPropListItemCount(array
); i
++) {
967 item
= WMGetFromPLArray(array
, i
);
969 WMAddToPLArray(destarr
, item
);
975 /* Fixup paths for cached pixmaps from .AppInfo to Library/WindowMaker/... */
977 fixupCachedPixmapsPaths(WMPropList
*dict
)
979 WMPropList
*allApps
, *app
, *props
, *iconkey
, *icon
, *newicon
;
980 char *path
, *fixedpath
, *ptr
, *search
;
982 Bool changed
= False
;
984 search
= "/.AppInfo/WindowMaker/";
985 slen
= strlen(search
);
987 iconkey
= WMCreatePLString("Icon");
988 allApps
= WMGetPLDictionaryKeys(dict
);
990 for (i
=0; i
< WMGetPropListItemCount(allApps
); i
++) {
991 app
= WMGetFromPLArray(allApps
, i
);
992 props
= WMGetFromPLDictionary(dict
, app
);
995 icon
= WMGetFromPLDictionary(props
, iconkey
);
996 if (icon
&& WMIsPLString(icon
)) {
997 path
= WMGetFromPLString(icon
);
998 ptr
= strstr(path
, search
);
1002 fixedpath
= wmalloc(strlen(path
)+32);
1003 strncpy(fixedpath
, path
, len
);
1005 strcat(fixedpath
, "/Library/WindowMaker/CachedPixmaps/");
1006 strcat(fixedpath
, ptr
+slen
);
1007 newicon
= WMCreatePLString(fixedpath
);
1008 WMPutInPLDictionary(props
, iconkey
, newicon
);
1009 WMReleasePropList(newicon
);
1015 WMReleasePropList(allApps
);
1016 WMReleasePropList(iconkey
);
1023 wDefaultsMergeGlobalMenus(WDDomain
*menuDomain
)
1025 WMPropList
*menu
= menuDomain
->dictionary
;
1026 WMPropList
*submenu
;
1028 if (!menu
|| !WMIsPLArray(menu
))
1031 #ifdef GLOBAL_PREAMBLE_MENU_FILE
1032 submenu
= WMReadPropListFromFile(SYSCONFDIR
"/WindowMaker/"GLOBAL_PREAMBLE_MENU_FILE
);
1034 if (submenu
&& !WMIsPLArray(submenu
)) {
1035 wwarning(_("invalid global menu file %s"),
1036 GLOBAL_PREAMBLE_MENU_FILE
);
1037 WMReleasePropList(submenu
);
1041 prependMenu(menu
, submenu
);
1042 WMReleasePropList(submenu
);
1046 #ifdef GLOBAL_EPILOGUE_MENU_FILE
1047 submenu
= WMReadPropListFromFile(SYSCONFDIR
"/WindowMaker/"GLOBAL_EPILOGUE_MENU_FILE
);
1049 if (submenu
&& !WMIsPLArray(submenu
)) {
1050 wwarning(_("invalid global menu file %s"),
1051 GLOBAL_EPILOGUE_MENU_FILE
);
1052 WMReleasePropList(submenu
);
1056 appendMenu(menu
, submenu
);
1057 WMReleasePropList(submenu
);
1061 menuDomain
->dictionary
= menu
;
1067 wDefaultsInit(int screen_number
)
1069 static int defaults_inited
= 0;
1072 if (!defaults_inited
) {
1076 dict
= PLGetDomain(wDomainName
);
1078 wwarning(_("could not read domain \"%s\" from defaults database"),
1079 WMGetFromPLString(wDomainName
));
1088 wDefaultsDestroyDomain(WDDomain
*domain
)
1090 if (domain
->dictionary
)
1091 WMReleasePropList(domain
->dictionary
);
1092 wfree(domain
->path
);
1098 wDefaultsInitDomain(char *domain
, Bool requireDictionary
)
1102 static int inited
= 0;
1103 char path
[PATH_MAX
];
1105 WMPropList
*shared_dict
=NULL
;
1112 db
= wmalloc(sizeof(WDDomain
));
1113 memset(db
, 0, sizeof(WDDomain
));
1114 db
->domain_name
= domain
;
1115 db
->path
= wdefaultspathfordomain(domain
);
1116 the_path
= db
->path
;
1118 if (the_path
&& stat(the_path
, &stbuf
)>=0) {
1119 db
->dictionary
= WMReadPropListFromFile(the_path
);
1120 if (db
->dictionary
) {
1121 if (requireDictionary
&& !WMIsPLDictionary(db
->dictionary
)) {
1122 WMReleasePropList(db
->dictionary
);
1123 db
->dictionary
= NULL
;
1124 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
1127 if (strcmp(domain
, "WMWindowAttributes")==0 && db
->dictionary
) {
1128 if (fixupCachedPixmapsPaths(db
->dictionary
)) {
1129 WMWritePropListToFile(db
->dictionary
, db
->path
, True
);
1130 /* re-read the timestamp. if this fails take current time */
1131 if (stat(db
->path
, &stbuf
)<0) {
1132 stbuf
.st_mtime
= time(NULL
);
1136 db
->timestamp
= stbuf
.st_mtime
;
1138 wwarning(_("could not load domain %s from user defaults database"),
1143 /* global system dictionary */
1144 snprintf(path
, sizeof(path
), "%s/WindowMaker/%s", SYSCONFDIR
, domain
);
1145 if (stat(path
, &stbuf
)>=0) {
1146 shared_dict
= WMReadPropListFromFile(path
);
1148 if (requireDictionary
&& !WMIsPLDictionary(shared_dict
)) {
1149 wwarning(_("Domain %s (%s) of global defaults database is corrupted!"),
1151 WMReleasePropList(shared_dict
);
1154 if (db
->dictionary
&& WMIsPLDictionary(shared_dict
) &&
1155 WMIsPLDictionary(db
->dictionary
)) {
1156 WMMergePLDictionaries(shared_dict
, db
->dictionary
, True
);
1157 WMReleasePropList(db
->dictionary
);
1158 db
->dictionary
= shared_dict
;
1159 if (stbuf
.st_mtime
> db
->timestamp
)
1160 db
->timestamp
= stbuf
.st_mtime
;
1161 } else if (!db
->dictionary
) {
1162 db
->dictionary
= shared_dict
;
1163 if (stbuf
.st_mtime
> db
->timestamp
)
1164 db
->timestamp
= stbuf
.st_mtime
;
1168 wwarning(_("could not load domain %s from global defaults database (%s)"),
1178 wReadStaticDefaults(WMPropList
*dict
)
1180 WMPropList
*plvalue
;
1181 WDefaultEntry
*entry
;
1186 for (i
=0; i
<sizeof(staticOptionList
)/sizeof(WDefaultEntry
); i
++) {
1187 entry
= &staticOptionList
[i
];
1190 plvalue
= WMGetFromPLDictionary(dict
, entry
->plkey
);
1195 /* no default in the DB. Use builtin default */
1196 plvalue
= entry
->plvalue
;
1201 (*entry
->convert
)(NULL
, entry
, plvalue
, entry
->addr
, &tdata
);
1202 if (entry
->update
) {
1203 (*entry
->update
)(NULL
, entry
, tdata
, entry
->extra_data
);
1212 wDefaultsCheckDomains(void)
1216 WMPropList
*shared_dict
= NULL
;
1221 puts("Checking domains...");
1223 if (stat(WDWindowMaker
->path
, &stbuf
)>=0
1224 && WDWindowMaker
->timestamp
< stbuf
.st_mtime
) {
1226 puts("Checking WindowMaker domain");
1228 WDWindowMaker
->timestamp
= stbuf
.st_mtime
;
1230 /* global dictionary */
1231 shared_dict
= readGlobalDomain("WindowMaker", True
);
1232 /* user dictionary */
1233 dict
= WMReadPropListFromFile(WDWindowMaker
->path
);
1235 if (!WMIsPLDictionary(dict
)) {
1236 WMReleasePropList(dict
);
1238 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
1239 "WindowMaker", WDWindowMaker
->path
);
1242 WMMergePLDictionaries(shared_dict
, dict
, True
);
1243 WMReleasePropList(dict
);
1247 for (i
=0; i
<wScreenCount
; i
++) {
1248 scr
= wScreenWithNumber(i
);
1250 wReadDefaults(scr
, dict
);
1252 if (WDWindowMaker
->dictionary
) {
1253 WMReleasePropList(WDWindowMaker
->dictionary
);
1255 WDWindowMaker
->dictionary
= dict
;
1258 wwarning(_("could not load domain %s from user defaults database"),
1262 WMReleasePropList(shared_dict
);
1266 if (stat(WDWindowAttributes
->path
, &stbuf
)>=0
1267 && WDWindowAttributes
->timestamp
< stbuf
.st_mtime
) {
1269 puts("Checking WMWindowAttributes domain");
1271 /* global dictionary */
1272 shared_dict
= readGlobalDomain("WMWindowAttributes", True
);
1273 /* user dictionary */
1274 dict
= WMReadPropListFromFile(WDWindowAttributes
->path
);
1276 if (!WMIsPLDictionary(dict
)) {
1277 WMReleasePropList(dict
);
1279 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
1280 "WMWindowAttributes", WDWindowAttributes
->path
);
1283 WMMergePLDictionaries(shared_dict
, dict
, True
);
1284 WMReleasePropList(dict
);
1288 if (WDWindowAttributes
->dictionary
) {
1289 WMReleasePropList(WDWindowAttributes
->dictionary
);
1291 WDWindowAttributes
->dictionary
= dict
;
1292 for (i
=0; i
<wScreenCount
; i
++) {
1293 scr
= wScreenWithNumber(i
);
1297 wDefaultUpdateIcons(scr
);
1299 /* Update the panel image if changed */
1300 /* Don't worry. If the image is the same these
1301 * functions will have no performance impact. */
1302 image
= wDefaultGetImage(scr
, "Logo", "WMPanel");
1305 wwarning(_("could not load logo image for panels: %s"),
1306 RMessageForError(RErrorCode
));
1308 WMSetApplicationIconImage(scr
->wmscreen
, image
);
1309 RReleaseImage(image
);
1315 wwarning(_("could not load domain %s from user defaults database"),
1316 "WMWindowAttributes");
1318 WDWindowAttributes
->timestamp
= stbuf
.st_mtime
;
1320 WMReleasePropList(shared_dict
);
1325 if (stat(WDRootMenu
->path
, &stbuf
)>=0
1326 && WDRootMenu
->timestamp
< stbuf
.st_mtime
) {
1327 dict
= WMReadPropListFromFile(WDRootMenu
->path
);
1329 puts("Checking WMRootMenu domain");
1332 if (!WMIsPLArray(dict
) && !WMIsPLString(dict
)) {
1333 WMReleasePropList(dict
);
1335 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
1336 "WMRootMenu", WDRootMenu
->path
);
1338 if (WDRootMenu
->dictionary
) {
1339 WMReleasePropList(WDRootMenu
->dictionary
);
1341 WDRootMenu
->dictionary
= dict
;
1342 wDefaultsMergeGlobalMenus(WDRootMenu
);
1345 wwarning(_("could not load domain %s from user defaults database"),
1348 WDRootMenu
->timestamp
= stbuf
.st_mtime
;
1356 wReadDefaults(WScreen
*scr
, WMPropList
*new_dict
)
1358 WMPropList
*plvalue
, *old_value
;
1359 WDefaultEntry
*entry
;
1360 unsigned int i
, must_update
;
1361 int update_workspace_back
= 0; /* kluge :/ */
1362 unsigned int needs_refresh
;
1364 WMPropList
*old_dict
= (WDWindowMaker
->dictionary
!=new_dict
1365 ? WDWindowMaker
->dictionary
: NULL
);
1371 for (i
=0; i
<sizeof(optionList
)/sizeof(WDefaultEntry
); i
++) {
1372 entry
= &optionList
[i
];
1375 plvalue
= WMGetFromPLDictionary(new_dict
, entry
->plkey
);
1382 old_value
= WMGetFromPLDictionary(old_dict
, entry
->plkey
);
1385 if (!plvalue
&& !old_value
) {
1386 /* no default in the DB. Use builtin default */
1387 plvalue
= entry
->plvalue
;
1388 if (plvalue
&& new_dict
) {
1389 WMPutInPLDictionary(new_dict
, entry
->plkey
, plvalue
);
1392 } else if (!plvalue
) {
1393 /* value was deleted from DB. Keep current value */
1395 } else if (!old_value
) {
1396 /* set value for the 1st time */
1397 } else if (!WMIsPropListEqualTo(plvalue
, old_value
)) {
1398 /* value has changed */
1401 if (strcmp(entry
->key
, "WorkspaceBack") == 0
1402 && update_workspace_back
1403 && scr
->flags
.backimage_helper_launched
) {
1405 /* value was not changed since last time */
1412 printf("Updating %s to %s\n", entry
->key
,
1413 WMGetPropListDescription(plvalue
, False
));
1416 if ((*entry
->convert
)(scr
, entry
, plvalue
, entry
->addr
, &tdata
)) {
1418 * If the WorkspaceSpecificBack data has been changed
1419 * so that the helper will be launched now, we must be
1420 * sure to send the default background texture config
1423 if (strcmp(entry
->key
, "WorkspaceSpecificBack") == 0
1424 && !scr
->flags
.backimage_helper_launched
) {
1425 update_workspace_back
= 1;
1427 if (entry
->update
) {
1429 (*entry
->update
)(scr
, entry
, tdata
, entry
->extra_data
);
1435 if (needs_refresh
!=0 && !scr
->flags
.startup
) {
1439 if (needs_refresh
& REFRESH_MENU_TITLE_TEXTURE
)
1440 foo
|= WTextureSettings
;
1441 if (needs_refresh
& REFRESH_MENU_TITLE_FONT
)
1442 foo
|= WFontSettings
;
1443 if (needs_refresh
& REFRESH_MENU_TITLE_COLOR
)
1444 foo
|= WColorSettings
;
1446 WMPostNotificationName(WNMenuTitleAppearanceSettingsChanged
, NULL
,
1447 (void*)(uintptr_t)foo
);
1450 if (needs_refresh
& REFRESH_MENU_TEXTURE
)
1451 foo
|= WTextureSettings
;
1452 if (needs_refresh
& REFRESH_MENU_FONT
)
1453 foo
|= WFontSettings
;
1454 if (needs_refresh
& REFRESH_MENU_COLOR
)
1455 foo
|= WColorSettings
;
1457 WMPostNotificationName(WNMenuAppearanceSettingsChanged
, NULL
,
1458 (void*)(uintptr_t)foo
);
1461 if (needs_refresh
& REFRESH_WINDOW_FONT
) {
1462 foo
|= WFontSettings
;
1464 if (needs_refresh
& REFRESH_WINDOW_TEXTURES
) {
1465 foo
|= WTextureSettings
;
1467 if (needs_refresh
& REFRESH_WINDOW_TITLE_COLOR
) {
1468 foo
|= WColorSettings
;
1471 WMPostNotificationName(WNWindowAppearanceSettingsChanged
, NULL
,
1472 (void*)(uintptr_t)foo
);
1474 if (!(needs_refresh
& REFRESH_ICON_TILE
)) {
1476 if (needs_refresh
& REFRESH_ICON_FONT
) {
1477 foo
|= WFontSettings
;
1479 if (needs_refresh
& REFRESH_ICON_TITLE_COLOR
) {
1480 foo
|= WTextureSettings
;
1482 if (needs_refresh
& REFRESH_ICON_TITLE_BACK
) {
1483 foo
|= WTextureSettings
;
1486 WMPostNotificationName(WNIconAppearanceSettingsChanged
, NULL
,
1487 (void*)(uintptr_t)foo
);
1489 if (needs_refresh
& REFRESH_ICON_TILE
)
1490 WMPostNotificationName(WNIconTileSettingsChanged
, NULL
, NULL
);
1496 wDefaultUpdateIcons(WScreen
*scr
)
1498 WAppIcon
*aicon
= scr
->app_icon_list
;
1499 WWindow
*wwin
= scr
->focused_window
;
1503 file
= wDefaultGetIconFile(scr
, aicon
->wm_instance
, aicon
->wm_class
,
1505 if ((file
&& aicon
->icon
->file
&& strcmp(file
, aicon
->icon
->file
)!=0)
1506 || (file
&& !aicon
->icon
->file
)) {
1509 if (aicon
->icon
->file
)
1510 wfree(aicon
->icon
->file
);
1511 aicon
->icon
->file
= wstrdup(file
);
1513 new_image
= wDefaultGetImage(scr
, aicon
->wm_instance
,
1516 wIconChangeImage(aicon
->icon
, new_image
);
1517 wAppIconPaint(aicon
);
1520 aicon
= aicon
->next
;
1523 if (!wPreferences
.flags
.noclip
)
1524 wClipIconPaint(scr
->clip_icon
);
1527 if (wwin
->icon
&& wwin
->flags
.miniaturized
) {
1528 file
= wDefaultGetIconFile(scr
, wwin
->wm_instance
, wwin
->wm_class
,
1530 if ((file
&& wwin
->icon
->file
&& strcmp(file
, wwin
->icon
->file
)!=0)
1531 || (file
&& !wwin
->icon
->file
)) {
1534 if (wwin
->icon
->file
)
1535 wfree(wwin
->icon
->file
);
1536 wwin
->icon
->file
= wstrdup(file
);
1538 new_image
= wDefaultGetImage(scr
, wwin
->wm_instance
,
1541 wIconChangeImage(wwin
->icon
, new_image
);
1549 /* --------------------------- Local ----------------------- */
1551 #define GET_STRING_OR_DEFAULT(x, var) if (!WMIsPLString(value)) { \
1552 wwarning(_("Wrong option format for key \"%s\". Should be %s."), \
1554 wwarning(_("using default \"%s\" instead"), entry->default_value); \
1555 var = entry->default_value;\
1556 } else var = WMGetFromPLString(value)\
1563 string2index(WMPropList
*key
, WMPropList
*val
, char *def
,
1564 WOptionEnumeration
*values
)
1567 WOptionEnumeration
*v
;
1568 char buffer
[TOTAL_VALUES_LENGTH
];
1570 if (WMIsPLString(val
) && (str
= WMGetFromPLString(val
))) {
1571 for (v
=values
; v
->string
!=NULL
; v
++) {
1572 if (strcasecmp(v
->string
, str
)==0)
1578 for (v
=values
; v
->string
!=NULL
; v
++) {
1581 strcat(buffer
, ", ");
1582 strcat(buffer
, v
->string
);
1585 wwarning(_("wrong option value for key \"%s\". Should be one of %s"),
1586 WMGetFromPLString(key
), buffer
);
1589 return string2index(key
, val
, NULL
, values
);
1599 * value - is the value in the defaults DB
1600 * addr - is the address to store the data
1601 * ret - is the address to store a pointer to a temporary buffer. ret
1602 * must not be freed and is used by the set functions
1605 getBool(WScreen
*scr
, WDefaultEntry
*entry
, WMPropList
*value
, void *addr
,
1612 GET_STRING_OR_DEFAULT("Boolean", val
);
1615 if ((val
[1]=='\0' && (val
[0]=='y' || val
[0]=='Y'))
1616 || strcasecmp(val
, "YES")==0) {
1619 } else if ((val
[1]=='\0' && (val
[0]=='n' || val
[0]=='N'))
1620 || strcasecmp(val
, "NO")==0) {
1624 if (sscanf(val
, "%i", &i
)==1) {
1630 wwarning(_("can't convert \"%s\" to boolean for key \"%s\""),
1632 if (second_pass
==0) {
1633 val
= WMGetFromPLString(entry
->plvalue
);
1635 wwarning(_("using default \"%s\" instead"), val
);
1645 *(char*)addr
= data
;
1652 getInt(WScreen
*scr
, WDefaultEntry
*entry
, WMPropList
*value
, void *addr
,
1659 GET_STRING_OR_DEFAULT("Integer", val
);
1661 if (sscanf(val
, "%i", &data
)!=1) {
1662 wwarning(_("can't convert \"%s\" to integer for key \"%s\""),
1664 val
= WMGetFromPLString(entry
->plvalue
);
1665 wwarning(_("using default \"%s\" instead"), val
);
1666 if (sscanf(val
, "%i", &data
)!=1) {
1681 getCoord(WScreen
*scr
, WDefaultEntry
*entry
, WMPropList
*value
, void *addr
,
1685 char *val_x
, *val_y
;
1686 int nelem
, changed
=0;
1687 WMPropList
*elem_x
, *elem_y
;
1690 if (!WMIsPLArray(value
)) {
1691 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1692 entry
->key
, "Coordinate");
1694 value
= entry
->plvalue
;
1696 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1702 nelem
= WMGetPropListItemCount(value
);
1704 wwarning(_("Incorrect number of elements in array for key \"%s\"."),
1707 value
= entry
->plvalue
;
1709 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1715 elem_x
= WMGetFromPLArray(value
, 0);
1716 elem_y
= WMGetFromPLArray(value
, 1);
1718 if (!elem_x
|| !elem_y
|| !WMIsPLString(elem_x
) || !WMIsPLString(elem_y
)) {
1719 wwarning(_("Wrong value for key \"%s\". Should be Coordinate."),
1722 value
= entry
->plvalue
;
1724 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1730 val_x
= WMGetFromPLString(elem_x
);
1731 val_y
= WMGetFromPLString(elem_y
);
1733 if (sscanf(val_x
, "%i", &data
.x
)!=1 || sscanf(val_y
, "%i", &data
.y
)!=1) {
1734 wwarning(_("can't convert array to integers for \"%s\"."), entry
->key
);
1736 value
= entry
->plvalue
;
1738 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1746 else if (data
.x
> scr
->scr_width
/3)
1747 data
.x
= scr
->scr_width
/3;
1750 else if (data
.y
> scr
->scr_height
/3)
1751 data
.y
= scr
->scr_height
/3;
1756 *(WCoord
*)addr
= data
;
1763 getPropList(WScreen
*scr
, WDefaultEntry
*entry
, WMPropList
*value
, void *addr
,
1766 WMRetainPropList(value
);
1774 /* This function is not used at the moment. */
1776 getString(WScreen
*scr
, WDefaultEntry
*entry
, WMPropList
*value
, void *addr
,
1781 GET_STRING_OR_DEFAULT("String", data
);
1784 data
= WMGetFromPLString(entry
->plvalue
);
1792 *(char**)addr
= wstrdup(data
);
1800 getPathList(WScreen
*scr
, WDefaultEntry
*entry
, WMPropList
*value
, void *addr
,
1810 if (!WMIsPLArray(value
)) {
1811 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1812 entry
->key
, "an array of paths");
1814 value
= entry
->plvalue
;
1816 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1823 count
= WMGetPropListItemCount(value
);
1826 value
= entry
->plvalue
;
1828 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1835 for (i
=0; i
<count
; i
++) {
1836 d
= WMGetFromPLArray(value
, i
);
1837 if (!d
|| !WMIsPLString(d
)) {
1841 len
+= strlen(WMGetFromPLString(d
))+1;
1844 ptr
= data
= wmalloc(len
+1);
1846 for (i
=0; i
<count
; i
++) {
1847 d
= WMGetFromPLArray(value
, i
);
1848 if (!d
|| !WMIsPLString(d
)) {
1851 strcpy(ptr
, WMGetFromPLString(d
));
1852 ptr
+= strlen(WMGetFromPLString(d
));
1856 ptr
--; *(ptr
--) = 0;
1858 if (*(char**)addr
!=NULL
) {
1859 wfree(*(char**)addr
);
1861 *(char**)addr
= data
;
1868 getEnum(WScreen
*scr
, WDefaultEntry
*entry
, WMPropList
*value
, void *addr
,
1871 static signed char data
;
1873 data
= string2index(entry
->plkey
, value
, entry
->default_value
,
1874 (WOptionEnumeration
*)entry
->extra_data
);
1881 *(signed char*)addr
= data
;
1890 * (hgradient <color> <color>)
1891 * (vgradient <color> <color>)
1892 * (dgradient <color> <color>)
1893 * (mhgradient <color> <color> ...)
1894 * (mvgradient <color> <color> ...)
1895 * (mdgradient <color> <color> ...)
1896 * (igradient <color1> <color1> <thickness1> <color2> <color2> <thickness2>)
1897 * (tpixmap <file> <color>)
1898 * (spixmap <file> <color>)
1899 * (cpixmap <file> <color>)
1900 * (thgradient <file> <opaqueness> <color> <color>)
1901 * (tvgradient <file> <opaqueness> <color> <color>)
1902 * (tdgradient <file> <opaqueness> <color> <color>)
1903 * (function <lib> <function> ...)
1907 parse_texture(WScreen
*scr
, WMPropList
*pl
)
1912 WTexture
*texture
=NULL
;
1914 nelem
= WMGetPropListItemCount(pl
);
1919 elem
= WMGetFromPLArray(pl
, 0);
1920 if (!elem
|| !WMIsPLString(elem
))
1922 val
= WMGetFromPLString(elem
);
1925 if (strcasecmp(val
, "solid")==0) {
1933 elem
= WMGetFromPLArray(pl
, 1);
1934 if (!elem
|| !WMIsPLString(elem
))
1936 val
= WMGetFromPLString(elem
);
1938 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &color
)) {
1939 wwarning(_("\"%s\" is not a valid color name"), val
);
1943 texture
= (WTexture
*)wTextureMakeSolid(scr
, &color
);
1944 } else if (strcasecmp(val
, "dgradient")==0
1945 || strcasecmp(val
, "vgradient")==0
1946 || strcasecmp(val
, "hgradient")==0) {
1947 RColor color1
, color2
;
1952 wwarning(_("bad number of arguments in gradient specification"));
1956 if (val
[0]=='d' || val
[0]=='D')
1957 type
= WTEX_DGRADIENT
;
1958 else if (val
[0]=='h' || val
[0]=='H')
1959 type
= WTEX_HGRADIENT
;
1961 type
= WTEX_VGRADIENT
;
1964 /* get from color */
1965 elem
= WMGetFromPLArray(pl
, 1);
1966 if (!elem
|| !WMIsPLString(elem
))
1968 val
= WMGetFromPLString(elem
);
1970 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1971 wwarning(_("\"%s\" is not a valid color name"), val
);
1975 color1
.red
= xcolor
.red
>> 8;
1976 color1
.green
= xcolor
.green
>> 8;
1977 color1
.blue
= xcolor
.blue
>> 8;
1980 elem
= WMGetFromPLArray(pl
, 2);
1981 if (!elem
|| !WMIsPLString(elem
)) {
1984 val
= WMGetFromPLString(elem
);
1986 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1987 wwarning(_("\"%s\" is not a valid color name"), val
);
1991 color2
.red
= xcolor
.red
>> 8;
1992 color2
.green
= xcolor
.green
>> 8;
1993 color2
.blue
= xcolor
.blue
>> 8;
1995 texture
= (WTexture
*)wTextureMakeGradient(scr
, type
, &color1
, &color2
);
1997 } else if (strcasecmp(val
, "igradient")==0) {
1998 RColor colors1
[2], colors2
[2];
2004 wwarning(_("bad number of arguments in gradient specification"));
2008 /* get from color */
2009 for (i
= 0; i
< 2; i
++) {
2010 elem
= WMGetFromPLArray(pl
, 1+i
);
2011 if (!elem
|| !WMIsPLString(elem
))
2013 val
= WMGetFromPLString(elem
);
2015 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
2016 wwarning(_("\"%s\" is not a valid color name"), val
);
2019 colors1
[i
].alpha
= 255;
2020 colors1
[i
].red
= xcolor
.red
>> 8;
2021 colors1
[i
].green
= xcolor
.green
>> 8;
2022 colors1
[i
].blue
= xcolor
.blue
>> 8;
2024 elem
= WMGetFromPLArray(pl
, 3);
2025 if (!elem
|| !WMIsPLString(elem
))
2027 val
= WMGetFromPLString(elem
);
2031 /* get from color */
2032 for (i
= 0; i
< 2; i
++) {
2033 elem
= WMGetFromPLArray(pl
, 4+i
);
2034 if (!elem
|| !WMIsPLString(elem
))
2036 val
= WMGetFromPLString(elem
);
2038 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
2039 wwarning(_("\"%s\" is not a valid color name"), val
);
2042 colors2
[i
].alpha
= 255;
2043 colors2
[i
].red
= xcolor
.red
>> 8;
2044 colors2
[i
].green
= xcolor
.green
>> 8;
2045 colors2
[i
].blue
= xcolor
.blue
>> 8;
2047 elem
= WMGetFromPLArray(pl
, 6);
2048 if (!elem
|| !WMIsPLString(elem
))
2050 val
= WMGetFromPLString(elem
);
2053 texture
= (WTexture
*)wTextureMakeIGradient(scr
, th1
, colors1
,
2056 } else if (strcasecmp(val
, "mhgradient")==0
2057 || strcasecmp(val
, "mvgradient")==0
2058 || strcasecmp(val
, "mdgradient")==0) {
2065 wwarning(_("too few arguments in multicolor gradient specification"));
2069 if (val
[1]=='h' || val
[1]=='H')
2070 type
= WTEX_MHGRADIENT
;
2071 else if (val
[1]=='v' || val
[1]=='V')
2072 type
= WTEX_MVGRADIENT
;
2074 type
= WTEX_MDGRADIENT
;
2078 colors
= wmalloc(sizeof(RColor
*)*(count
+1));
2080 for (i
=0; i
<count
; i
++) {
2081 elem
= WMGetFromPLArray(pl
, i
+1);
2082 if (!elem
|| !WMIsPLString(elem
)) {
2083 for (--i
; i
>=0; --i
) {
2089 val
= WMGetFromPLString(elem
);
2091 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &color
)) {
2092 wwarning(_("\"%s\" is not a valid color name"), val
);
2093 for (--i
; i
>=0; --i
) {
2099 colors
[i
] = wmalloc(sizeof(RColor
));
2100 colors
[i
]->red
= color
.red
>> 8;
2101 colors
[i
]->green
= color
.green
>> 8;
2102 colors
[i
]->blue
= color
.blue
>> 8;
2107 texture
= (WTexture
*)wTextureMakeMGradient(scr
, type
, colors
);
2108 } else if (strcasecmp(val
, "spixmap")==0 ||
2109 strcasecmp(val
, "cpixmap")==0 ||
2110 strcasecmp(val
, "tpixmap")==0) {
2117 if (val
[0] == 's' || val
[0] == 'S')
2119 else if (val
[0] == 'c' || val
[0] == 'C')
2125 elem
= WMGetFromPLArray(pl
, 2);
2126 if (!elem
|| !WMIsPLString(elem
)) {
2129 val
= WMGetFromPLString(elem
);
2131 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &color
)) {
2132 wwarning(_("\"%s\" is not a valid color name"), val
);
2137 elem
= WMGetFromPLArray(pl
, 1);
2138 if (!elem
|| !WMIsPLString(elem
))
2140 val
= WMGetFromPLString(elem
);
2142 texture
= (WTexture
*)wTextureMakePixmap(scr
, type
, val
, &color
);
2143 } else if (strcasecmp(val
, "thgradient")==0
2144 || strcasecmp(val
, "tvgradient")==0
2145 || strcasecmp(val
, "tdgradient")==0) {
2146 RColor color1
, color2
;
2151 if (val
[1]=='h' || val
[1]=='H')
2152 style
= WTEX_THGRADIENT
;
2153 else if (val
[1]=='v' || val
[1]=='V')
2154 style
= WTEX_TVGRADIENT
;
2156 style
= WTEX_TDGRADIENT
;
2159 wwarning(_("bad number of arguments in textured gradient specification"));
2163 /* get from color */
2164 elem
= WMGetFromPLArray(pl
, 3);
2165 if (!elem
|| !WMIsPLString(elem
))
2167 val
= WMGetFromPLString(elem
);
2169 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
2170 wwarning(_("\"%s\" is not a valid color name"), val
);
2174 color1
.red
= xcolor
.red
>> 8;
2175 color1
.green
= xcolor
.green
>> 8;
2176 color1
.blue
= xcolor
.blue
>> 8;
2179 elem
= WMGetFromPLArray(pl
, 4);
2180 if (!elem
|| !WMIsPLString(elem
)) {
2183 val
= WMGetFromPLString(elem
);
2185 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
2186 wwarning(_("\"%s\" is not a valid color name"), val
);
2190 color2
.red
= xcolor
.red
>> 8;
2191 color2
.green
= xcolor
.green
>> 8;
2192 color2
.blue
= xcolor
.blue
>> 8;
2195 elem
= WMGetFromPLArray(pl
, 2);
2196 if (!elem
|| !WMIsPLString(elem
))
2199 val
= WMGetFromPLString(elem
);
2201 if (!val
|| (opacity
= atoi(val
)) < 0 || opacity
> 255) {
2202 wwarning(_("bad opacity value for tgradient texture \"%s\". Should be [0..255]"), val
);
2207 elem
= WMGetFromPLArray(pl
, 1);
2208 if (!elem
|| !WMIsPLString(elem
))
2210 val
= WMGetFromPLString(elem
);
2212 texture
= (WTexture
*)wTextureMakeTGradient(scr
, style
, &color1
, &color2
,
2215 #ifdef TEXTURE_PLUGIN
2216 else if (strcasecmp(val
, "function")==0) {
2217 WTexFunction
*function
;
2218 void (*initFunc
) (Display
*, Colormap
);
2219 char *lib
, *func
, **argv
;
2225 /* get the library name */
2226 elem
= WMGetFromPLArray(pl
, 1);
2227 if (!elem
|| !WMIsPLString(elem
)) {
2230 lib
= WMGetFromPLString(elem
);
2232 /* get the function name */
2233 elem
= WMGetFromPLArray(pl
, 2);
2234 if (!elem
|| !WMIsPLString(elem
)) {
2237 func
= WMGetFromPLString(elem
);
2240 argv
= (char **)wmalloc(argc
* sizeof(char *));
2242 /* get the parameters */
2243 argv
[0] = wstrdup(func
);
2244 for (i
= 0; i
< argc
- 1; i
++) {
2245 elem
= WMGetFromPLArray(pl
, 3 + i
);
2246 if (!elem
|| !WMIsPLString(elem
)) {
2251 argv
[i
+1] = wstrdup(WMGetFromPLString(elem
));
2254 function
= wTextureMakeFunction(scr
, lib
, func
, argc
, argv
);
2258 initFunc
= dlsym(function
->handle
, "initWindowMaker");
2260 initFunc(dpy
, scr
->w_colormap
);
2262 wwarning(_("could not initialize library %s"), lib
);
2265 wwarning(_("could not find function %s::%s"), lib
, func
);
2267 #endif /* HAVE_DLFCN_H */
2268 texture
= (WTexture
*)function
;
2270 #endif /* TEXTURE_PLUGIN */
2272 wwarning(_("invalid texture type %s"), val
);
2281 getTexture(WScreen
*scr
, WDefaultEntry
*entry
, WMPropList
*value
, void *addr
,
2284 static WTexture
*texture
;
2288 if (!WMIsPLArray(value
)) {
2289 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
2290 entry
->key
, "Texture");
2292 value
= entry
->plvalue
;
2294 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
2300 if (strcmp(entry
->key
, "WidgetColor")==0 && !changed
) {
2303 pl
= WMGetFromPLArray(value
, 0);
2304 if (!pl
|| !WMIsPLString(pl
) || !WMGetFromPLString(pl
)
2305 || strcasecmp(WMGetFromPLString(pl
), "solid")!=0) {
2306 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
2307 entry
->key
, "Solid Texture");
2309 value
= entry
->plvalue
;
2311 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
2316 texture
= parse_texture(scr
, value
);
2319 wwarning(_("Error in texture specification for key \"%s\""),
2322 value
= entry
->plvalue
;
2324 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
2334 *(WTexture
**)addr
= texture
;
2341 getWSBackground(WScreen
*scr
, WDefaultEntry
*entry
, WMPropList
*value
,
2342 void *addr
, void **ret
)
2350 if (!WMIsPLArray(value
)) {
2351 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
2352 "WorkspaceBack", "Texture or None");
2354 value
= entry
->plvalue
;
2356 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
2362 /* only do basic error checking and verify for None texture */
2364 nelem
= WMGetPropListItemCount(value
);
2366 elem
= WMGetFromPLArray(value
, 0);
2367 if (!elem
|| !WMIsPLString(elem
)) {
2368 wwarning(_("Wrong type for workspace background. Should be a texture type."));
2370 value
= entry
->plvalue
;
2372 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
2377 val
= WMGetFromPLString(elem
);
2379 if (strcasecmp(val
, "None")==0)
2382 *ret
= WMRetainPropList(value
);
2389 getWSSpecificBackground(WScreen
*scr
, WDefaultEntry
*entry
, WMPropList
*value
,
2390 void *addr
, void **ret
)
2397 if (!WMIsPLArray(value
)) {
2398 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
2399 "WorkspaceSpecificBack", "an array of textures");
2401 value
= entry
->plvalue
;
2403 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
2409 /* only do basic error checking and verify for None texture */
2411 nelem
= WMGetPropListItemCount(value
);
2414 elem
= WMGetFromPLArray(value
, nelem
);
2415 if (!elem
|| !WMIsPLArray(elem
)) {
2416 wwarning(_("Wrong type for background of workspace %i. Should be a texture."),
2422 *ret
= WMRetainPropList(value
);
2426 * Kluge to force wmsetbg helper to set the default background.
2427 * If the WorkspaceSpecificBack is changed once wmaker has started,
2428 * the WorkspaceBack won't be sent to the helper, unless the user
2429 * changes it's value too. So, we must force this by removing the
2430 * value from the defaults DB.
2432 if (!scr
->flags
.backimage_helper_launched
&& !scr
->flags
.startup
) {
2433 WMPropList
*key
= WMCreatePLString("WorkspaceBack");
2435 WMRemoveFromPLDictionary(WDWindowMaker
->dictionary
, key
);
2437 WMReleasePropList(key
);
2445 getFont(WScreen
*scr
, WDefaultEntry
*entry
, WMPropList
*value
, void *addr
,
2448 static WMFont
*font
;
2451 GET_STRING_OR_DEFAULT("Font", val
);
2453 font
= WMCreateFont(scr
->wmscreen
, val
);
2455 font
= WMCreateFont(scr
->wmscreen
, "fixed");
2458 wfatal(_("could not load any usable font!!!"));
2465 /* can't assign font value outside update function */
2466 wassertrv(addr
== NULL
, True
);
2473 getColor(WScreen
*scr
, WDefaultEntry
*entry
, WMPropList
*value
, void *addr
,
2476 static XColor color
;
2480 GET_STRING_OR_DEFAULT("Color", val
);
2484 if (!wGetColor(scr
, val
, &color
)) {
2485 wwarning(_("could not get color for key \"%s\""),
2487 if (second_pass
==0) {
2488 val
= WMGetFromPLString(entry
->plvalue
);
2490 wwarning(_("using default \"%s\" instead"), val
);
2502 *(unsigned long*)addr = pixel;
2511 getKeybind(WScreen
*scr
, WDefaultEntry
*entry
, WMPropList
*value
, void *addr
,
2514 static WShortKey shortcut
;
2518 char buf
[MAX_SHORTCUT_LENGTH
], *b
;
2521 GET_STRING_OR_DEFAULT("Key spec", val
);
2523 if (!val
|| strcasecmp(val
, "NONE")==0) {
2524 shortcut
.keycode
= 0;
2525 shortcut
.modifier
= 0;
2531 strncpy(buf
, val
, MAX_SHORTCUT_LENGTH
);
2536 shortcut
.modifier
= 0;
2537 while ((k
= strchr(b
, '+'))!=NULL
) {
2541 mod
= wXModifierFromKey(b
);
2543 wwarning(_("%s: invalid key modifier \"%s\""), entry
->key
, b
);
2546 shortcut
.modifier
|= mod
;
2552 ksym
= XStringToKeysym(b
);
2554 if (ksym
==NoSymbol
) {
2555 wwarning(_("%s:invalid kbd shortcut specification \"%s\""), entry
->key
,
2560 shortcut
.keycode
= XKeysymToKeycode(dpy
, ksym
);
2561 if (shortcut
.keycode
==0) {
2562 wwarning(_("%s:invalid key in shortcut \"%s\""), entry
->key
, val
);
2574 getModMask(WScreen
*scr
, WDefaultEntry
*entry
, WMPropList
*value
, void *addr
,
2577 static unsigned int mask
;
2580 GET_STRING_OR_DEFAULT("Modifier Key", str
);
2585 mask
= wXModifierFromKey(str
);
2587 wwarning(_("%s: modifier key %s is not valid"), entry
->key
, str
);
2593 *(unsigned int*)addr
= mask
;
2604 getRImages(WScreen
*scr
, WDefaultEntry
*entry
, WMPropList
*value
,
2605 void *addr
, void **ret
)
2613 GET_STRING_OR_DEFAULT("Image File Path", str
);
2617 image
= RLoadImage(scr
->rcontext
, str
, 0);
2619 wwarning(_("could not load image in option %s: %s"), entry
->key
,
2620 RMessageForError(RErrorCode
));
2624 if (*(RImage
**)addr
) {
2625 RReleaseImage(*(RImage
**)addr
);
2628 *(RImage
**)addr
= image
;
2630 assert(ret
== NULL
);
2633 *(RImage**)ret = image;
2640 # include <X11/cursorfont.h>
2647 #define CURSOR_ID_NONE (XC_num_glyphs)
2649 static WCursorLookup cursor_table
[] =
2651 { "X_cursor", XC_X_cursor
},
2652 { "arrow", XC_arrow
},
2653 { "based_arrow_down", XC_based_arrow_down
},
2654 { "based_arrow_up", XC_based_arrow_up
},
2655 { "boat", XC_boat
},
2656 { "bogosity", XC_bogosity
},
2657 { "bottom_left_corner", XC_bottom_left_corner
},
2658 { "bottom_right_corner", XC_bottom_right_corner
},
2659 { "bottom_side", XC_bottom_side
},
2660 { "bottom_tee", XC_bottom_tee
},
2661 { "box_spiral", XC_box_spiral
},
2662 { "center_ptr", XC_center_ptr
},
2663 { "circle", XC_circle
},
2664 { "clock", XC_clock
},
2665 { "coffee_mug", XC_coffee_mug
},
2666 { "cross", XC_cross
},
2667 { "cross_reverse", XC_cross_reverse
},
2668 { "crosshair", XC_crosshair
},
2669 { "diamond_cross", XC_diamond_cross
},
2671 { "dotbox", XC_dotbox
},
2672 { "double_arrow", XC_double_arrow
},
2673 { "draft_large", XC_draft_large
},
2674 { "draft_small", XC_draft_small
},
2675 { "draped_box", XC_draped_box
},
2676 { "exchange", XC_exchange
},
2677 { "fleur", XC_fleur
},
2678 { "gobbler", XC_gobbler
},
2679 { "gumby", XC_gumby
},
2680 { "hand1", XC_hand1
},
2681 { "hand2", XC_hand2
},
2682 { "heart", XC_heart
},
2683 { "icon", XC_icon
},
2684 { "iron_cross", XC_iron_cross
},
2685 { "left_ptr", XC_left_ptr
},
2686 { "left_side", XC_left_side
},
2687 { "left_tee", XC_left_tee
},
2688 { "leftbutton", XC_leftbutton
},
2689 { "ll_angle", XC_ll_angle
},
2690 { "lr_angle", XC_lr_angle
},
2692 { "middlebutton", XC_middlebutton
},
2693 { "mouse", XC_mouse
},
2694 { "pencil", XC_pencil
},
2695 { "pirate", XC_pirate
},
2696 { "plus", XC_plus
},
2697 { "question_arrow", XC_question_arrow
},
2698 { "right_ptr", XC_right_ptr
},
2699 { "right_side", XC_right_side
},
2700 { "right_tee", XC_right_tee
},
2701 { "rightbutton", XC_rightbutton
},
2702 { "rtl_logo", XC_rtl_logo
},
2703 { "sailboat", XC_sailboat
},
2704 { "sb_down_arrow", XC_sb_down_arrow
},
2705 { "sb_h_double_arrow", XC_sb_h_double_arrow
},
2706 { "sb_left_arrow", XC_sb_left_arrow
},
2707 { "sb_right_arrow", XC_sb_right_arrow
},
2708 { "sb_up_arrow", XC_sb_up_arrow
},
2709 { "sb_v_double_arrow", XC_sb_v_double_arrow
},
2710 { "shuttle", XC_shuttle
},
2711 { "sizing", XC_sizing
},
2712 { "spider", XC_spider
},
2713 { "spraycan", XC_spraycan
},
2714 { "star", XC_star
},
2715 { "target", XC_target
},
2716 { "tcross", XC_tcross
},
2717 { "top_left_arrow", XC_top_left_arrow
},
2718 { "top_left_corner", XC_top_left_corner
},
2719 { "top_right_corner", XC_top_right_corner
},
2720 { "top_side", XC_top_side
},
2721 { "top_tee", XC_top_tee
},
2722 { "trek", XC_trek
},
2723 { "ul_angle", XC_ul_angle
},
2724 { "umbrella", XC_umbrella
},
2725 { "ur_angle", XC_ur_angle
},
2726 { "watch", XC_watch
},
2727 { "xterm", XC_xterm
},
2728 { NULL
, CURSOR_ID_NONE
}
2732 check_bitmap_status(int status
, char *filename
, Pixmap bitmap
)
2735 case BitmapOpenFailed
:
2736 wwarning(_("failed to open bitmap file \"%s\""), filename
);
2738 case BitmapFileInvalid
:
2739 wwarning(_("\"%s\" is not a valid bitmap file"), filename
);
2741 case BitmapNoMemory
:
2742 wwarning(_("out of memory reading bitmap file \"%s\""), filename
);
2745 XFreePixmap(dpy
, bitmap
);
2752 * (builtin, <cursor_name>)
2753 * (bitmap, <cursor_bitmap>, <cursor_mask>)
2756 parse_cursor(WScreen
*scr
, WMPropList
*pl
, Cursor
*cursor
)
2763 nelem
= WMGetPropListItemCount(pl
);
2767 elem
= WMGetFromPLArray(pl
, 0);
2768 if (!elem
|| !WMIsPLString(elem
)) {
2771 val
= WMGetFromPLString(elem
);
2773 if (0 == strcasecmp(val
, "none")) {
2776 } else if (0 == strcasecmp(val
, "builtin")) {
2778 int cursor_id
= CURSOR_ID_NONE
;
2781 wwarning(_("bad number of arguments in cursor specification"));
2784 elem
= WMGetFromPLArray(pl
, 1);
2785 if (!elem
|| !WMIsPLString(elem
)) {
2788 val
= WMGetFromPLString(elem
);
2790 for (i
= 0; NULL
!= cursor_table
[i
].name
; i
++) {
2791 if (0 == strcasecmp(val
, cursor_table
[i
].name
)) {
2792 cursor_id
= cursor_table
[i
].id
;
2796 if (CURSOR_ID_NONE
== cursor_id
) {
2797 wwarning(_("unknown builtin cursor name \"%s\""), val
);
2799 *cursor
= XCreateFontCursor(dpy
, cursor_id
);
2802 } else if (0 == strcasecmp(val
, "bitmap")) {
2814 wwarning(_("bad number of arguments in cursor specification"));
2817 elem
= WMGetFromPLArray(pl
, 1);
2818 if (!elem
|| !WMIsPLString(elem
)) {
2821 val
= WMGetFromPLString(elem
);
2822 bitmap_name
= FindImage(wPreferences
.pixmap_path
, val
);
2824 wwarning(_("could not find cursor bitmap file \"%s\""), val
);
2827 elem
= WMGetFromPLArray(pl
, 2);
2828 if (!elem
|| !WMIsPLString(elem
)) {
2832 val
= WMGetFromPLString(elem
);
2833 mask_name
= FindImage(wPreferences
.pixmap_path
, val
);
2836 wwarning(_("could not find cursor bitmap file \"%s\""), val
);
2839 mask_status
= XReadBitmapFile(dpy
, scr
->w_win
, mask_name
, &w
, &h
,
2841 bitmap_status
= XReadBitmapFile(dpy
, scr
->w_win
, bitmap_name
, &w
, &h
,
2843 if ((BitmapSuccess
== bitmap_status
) &&
2844 (BitmapSuccess
== mask_status
)) {
2845 fg
.pixel
= scr
->black_pixel
;
2846 bg
.pixel
= scr
->white_pixel
;
2847 XQueryColor(dpy
, scr
->w_colormap
, &fg
);
2848 XQueryColor(dpy
, scr
->w_colormap
, &bg
);
2849 *cursor
= XCreatePixmapCursor(dpy
, bitmap
, mask
, &fg
, &bg
, x
, y
);
2852 check_bitmap_status(bitmap_status
, bitmap_name
, bitmap
);
2853 check_bitmap_status(mask_status
, mask_name
, mask
);
2862 getCursor(WScreen
*scr
, WDefaultEntry
*entry
, WMPropList
*value
, void *addr
,
2865 static Cursor cursor
;
2870 if (!WMIsPLArray(value
)) {
2871 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
2872 entry
->key
, "cursor specification");
2874 value
= entry
->plvalue
;
2876 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
2881 status
= parse_cursor(scr
, value
, &cursor
);
2883 wwarning(_("Error in cursor specification for key \"%s\""), entry
->key
);
2885 value
= entry
->plvalue
;
2887 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
2896 *(Cursor
*)addr
= cursor
;
2900 #undef CURSOR_ID_NONE
2903 /* ---------------- value setting functions --------------- */
2905 setJustify(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
2907 return REFRESH_WINDOW_TITLE_COLOR
;
2911 setClearance(WScreen
*scr
, WDefaultEntry
*entry
, void *bar
, void *foo
)
2913 return REFRESH_WINDOW_FONT
|REFRESH_BUTTON_IMAGES
|REFRESH_MENU_TITLE_FONT
|REFRESH_MENU_FONT
;
2917 setIfDockPresent(WScreen
*scr
, WDefaultEntry
*entry
, char *flag
, long which
)
2921 wPreferences
.flags
.nodock
= wPreferences
.flags
.nodock
|| *flag
;
2924 wPreferences
.flags
.noclip
= wPreferences
.flags
.noclip
|| *flag
;
2934 setStickyIcons(WScreen
*scr
, WDefaultEntry
*entry
, void *bar
, void *foo
)
2936 if (scr
->workspaces
) {
2937 wWorkspaceForceChange(scr
, scr
->current_workspace
);
2938 wArrangeIcons(scr
, False
);
2945 setPositive(WScreen
*scr
, WDefaultEntry
*entry
, int *value
, void *foo
)
2957 setIconTile(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
2963 img
= wTextureRenderImage(*texture
, wPreferences
.icon_size
,
2964 wPreferences
.icon_size
,
2965 ((*texture
)->any
.type
& WREL_BORDER_MASK
)
2966 ? WREL_ICON
: WREL_FLAT
);
2968 wwarning(_("could not render texture for icon background"));
2970 wTextureDestroy(scr
, *texture
);
2973 RConvertImage(scr
->rcontext
, img
, &pixmap
);
2975 if (scr
->icon_tile
) {
2977 RReleaseImage(scr
->icon_tile
);
2978 XFreePixmap(dpy
, scr
->icon_tile_pixmap
);
2981 scr
->icon_tile
= img
;
2984 /* put the icon in the noticeboard hint */
2985 PropSetIconTileHint(scr
, img
);
2988 if (!wPreferences
.flags
.noclip
) {
2989 if (scr
->clip_tile
) {
2990 RReleaseImage(scr
->clip_tile
);
2992 scr
->clip_tile
= wClipMakeTile(scr
, img
);
2995 scr
->icon_tile_pixmap
= pixmap
;
2997 if (scr
->def_icon_pixmap
) {
2998 XFreePixmap(dpy
, scr
->def_icon_pixmap
);
2999 scr
->def_icon_pixmap
= None
;
3001 if (scr
->def_ticon_pixmap
) {
3002 XFreePixmap(dpy
, scr
->def_ticon_pixmap
);
3003 scr
->def_ticon_pixmap
= None
;
3006 if (scr
->icon_back_texture
) {
3007 wTextureDestroy(scr
, (WTexture
*)scr
->icon_back_texture
);
3009 scr
->icon_back_texture
= wTextureMakeSolid(scr
, &((*texture
)->any
.color
));
3011 if (scr
->clip_balloon
)
3012 XSetWindowBackground(dpy
, scr
->clip_balloon
,
3013 (*texture
)->any
.color
.pixel
);
3016 * Free the texture as nobody else will use it, nor refer to it.
3019 wTextureDestroy(scr
, *texture
);
3021 return (reset
? REFRESH_ICON_TILE
: 0);
3027 setWinTitleFont(WScreen
*scr
, WDefaultEntry
*entry
, WMFont
*font
, void *foo
)
3029 if (scr
->title_font
) {
3030 WMReleaseFont(scr
->title_font
);
3032 scr
->title_font
= font
;
3034 return REFRESH_WINDOW_FONT
|REFRESH_BUTTON_IMAGES
;
3039 setMenuTitleFont(WScreen
*scr
, WDefaultEntry
*entry
, WMFont
*font
, void *foo
)
3041 if (scr
->menu_title_font
) {
3042 WMReleaseFont(scr
->menu_title_font
);
3045 scr
->menu_title_font
= font
;
3047 return REFRESH_MENU_TITLE_FONT
;
3052 setMenuTextFont(WScreen
*scr
, WDefaultEntry
*entry
, WMFont
*font
, void *foo
)
3054 if (scr
->menu_entry_font
) {
3055 WMReleaseFont(scr
->menu_entry_font
);
3057 scr
->menu_entry_font
= font
;
3059 return REFRESH_MENU_FONT
;
3065 setIconTitleFont(WScreen
*scr
, WDefaultEntry
*entry
, WMFont
*font
, void *foo
)
3067 if (scr
->icon_title_font
) {
3068 WMReleaseFont(scr
->icon_title_font
);
3071 scr
->icon_title_font
= font
;
3073 return REFRESH_ICON_FONT
;
3078 setClipTitleFont(WScreen
*scr
, WDefaultEntry
*entry
, WMFont
*font
, void *foo
)
3080 if (scr
->clip_title_font
) {
3081 WMReleaseFont(scr
->clip_title_font
);
3084 scr
->clip_title_font
= font
;
3086 return REFRESH_ICON_FONT
;
3091 setLargeDisplayFont(WScreen
*scr
, WDefaultEntry
*entry
, WMFont
*font
, void *foo
)
3093 if (scr
->workspace_name_font
) {
3094 WMReleaseFont(scr
->workspace_name_font
);
3097 scr
->workspace_name_font
= font
;
3104 setHightlight(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, void *foo
)
3106 if (scr
->select_color
)
3107 WMReleaseColor(scr
->select_color
);
3110 WMCreateRGBColor(scr
->wmscreen
, color
->red
, color
->green
,
3113 wFreeColor(scr
, color
->pixel
);
3115 return REFRESH_MENU_COLOR
;
3120 setHightlightText(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, void *foo
)
3122 if (scr
->select_text_color
)
3123 WMReleaseColor(scr
->select_text_color
);
3125 scr
->select_text_color
=
3126 WMCreateRGBColor(scr
->wmscreen
, color
->red
, color
->green
,
3129 wFreeColor(scr
, color
->pixel
);
3131 return REFRESH_MENU_COLOR
;
3136 setClipTitleColor(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, long widx
)
3138 if (scr
->clip_title_color
[widx
])
3139 WMReleaseColor(scr
->clip_title_color
[widx
]);
3140 scr
->clip_title_color
[widx
] = WMCreateRGBColor(scr
->wmscreen
, color
->red
,
3141 color
->green
, color
->blue
,
3143 #ifdef GRADIENT_CLIP_ARROW
3144 if (widx
== CLIP_NORMAL
) {
3146 RColor color1
, color2
;
3147 int pt
= CLIP_BUTTON_SIZE
*wPreferences
.icon_size
/64;
3148 int as
= pt
- 15; /* 15 = 5+5+5 */
3150 FREE_PIXMAP(scr
->clip_arrow_gradient
);
3152 color1
.red
= (color
->red
>> 8)*6/10;
3153 color1
.green
= (color
->green
>> 8)*6/10;
3154 color1
.blue
= (color
->blue
>> 8)*6/10;
3156 color2
.red
= WMIN((color
->red
>> 8)*20/10, 255);
3157 color2
.green
= WMIN((color
->green
>> 8)*20/10, 255);
3158 color2
.blue
= WMIN((color
->blue
>> 8)*20/10, 255);
3160 image
= RRenderGradient(as
+1, as
+1, &color1
, &color2
, RDiagonalGradient
);
3161 RConvertImage(scr
->rcontext
, image
, &scr
->clip_arrow_gradient
);
3162 RReleaseImage(image
);
3164 #endif /* GRADIENT_CLIP_ARROW */
3166 wFreeColor(scr
, color
->pixel
);
3168 return REFRESH_ICON_TITLE_COLOR
;
3173 setWTitleColor(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, long widx
)
3175 if (scr
->window_title_color
[widx
])
3176 WMReleaseColor(scr
->window_title_color
[widx
]);
3178 scr
->window_title_color
[widx
] =
3179 WMCreateRGBColor(scr
->wmscreen
, color
->red
, color
->green
, color
->blue
,
3182 wFreeColor(scr
, color
->pixel
);
3184 return REFRESH_WINDOW_TITLE_COLOR
;
3189 setMenuTitleColor(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, long widx
)
3191 if (scr
->menu_title_color
[0])
3192 WMReleaseColor(scr
->menu_title_color
[0]);
3194 scr
->menu_title_color
[0] =
3195 WMCreateRGBColor(scr
->wmscreen
, color
->red
, color
->green
,
3198 wFreeColor(scr
, color
->pixel
);
3200 return REFRESH_MENU_TITLE_COLOR
;
3205 setMenuTextColor(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, void *foo
)
3207 if (scr
->mtext_color
)
3208 WMReleaseColor(scr
->mtext_color
);
3210 scr
->mtext_color
= WMCreateRGBColor(scr
->wmscreen
, color
->red
,
3211 color
->green
, color
->blue
, True
);
3213 if (WMColorPixel(scr
->dtext_color
) == WMColorPixel(scr
->mtext_color
)) {
3214 WMSetColorAlpha(scr
->dtext_color
, 0x7fff);
3216 WMSetColorAlpha(scr
->dtext_color
, 0xffff);
3219 wFreeColor(scr
, color
->pixel
);
3221 return REFRESH_MENU_COLOR
;
3226 setMenuDisabledColor(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, void *foo
)
3228 if (scr
->dtext_color
)
3229 WMReleaseColor(scr
->dtext_color
);
3231 scr
->dtext_color
= WMCreateRGBColor(scr
->wmscreen
, color
->red
,
3232 color
->green
, color
->blue
, True
);
3234 if (WMColorPixel(scr
->dtext_color
) == WMColorPixel(scr
->mtext_color
)) {
3235 WMSetColorAlpha(scr
->dtext_color
, 0x7fff);
3237 WMSetColorAlpha(scr
->dtext_color
, 0xffff);
3240 wFreeColor(scr
, color
->pixel
);
3242 return REFRESH_MENU_COLOR
;
3247 setIconTitleColor(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, void *foo
)
3249 if (scr
->icon_title_color
)
3250 WMReleaseColor(scr
->icon_title_color
);
3251 scr
->icon_title_color
= WMCreateRGBColor(scr
->wmscreen
, color
->red
,
3252 color
->green
, color
->blue
,
3255 wFreeColor(scr
, color
->pixel
);
3257 return REFRESH_ICON_TITLE_COLOR
;
3262 setIconTitleBack(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, void *foo
)
3264 if (scr
->icon_title_texture
) {
3265 wTextureDestroy(scr
, (WTexture
*)scr
->icon_title_texture
);
3267 scr
->icon_title_texture
= wTextureMakeSolid(scr
, color
);
3269 return REFRESH_ICON_TITLE_BACK
;
3274 trackDeadProcess(pid_t pid
, unsigned char status
, WScreen
*scr
)
3276 close(scr
->helper_fd
);
3278 scr
->helper_pid
= 0;
3279 scr
->flags
.backimage_helper_launched
= 0;
3284 setWorkspaceSpecificBack(WScreen
*scr
, WDefaultEntry
*entry
, WMPropList
*value
,
3291 if (scr
->flags
.backimage_helper_launched
) {
3292 if (WMGetPropListItemCount(value
)==0) {
3293 SendHelperMessage(scr
, 'C', 0, NULL
);
3294 SendHelperMessage(scr
, 'K', 0, NULL
);
3296 WMReleasePropList(value
);
3303 if (WMGetPropListItemCount(value
) == 0)
3306 if (pipe(filedes
) < 0) {
3307 wsyserror("pipe() failed:can't set workspace specific background image");
3309 WMReleasePropList(value
);
3315 wsyserror("fork() failed:can't set workspace specific background image");
3316 if (close(filedes
[0]) < 0)
3317 wsyserror("could not close pipe");
3318 if (close(filedes
[1]) < 0)
3319 wsyserror("could not close pipe");
3321 } else if (pid
== 0) {
3324 SetupEnvironment(scr
);
3327 wsyserror("could not close pipe");
3328 if (dup(filedes
[0]) < 0) {
3329 wsyserror("dup() failed:can't set workspace specific background image");
3331 dither
= wPreferences
.no_dithering
? "-m" : "-d";
3332 if (wPreferences
.smooth_workspace_back
)
3333 execlp("wmsetbg", "wmsetbg", "-helper", "-S", dither
, NULL
);
3335 execlp("wmsetbg", "wmsetbg", "-helper", dither
, NULL
);
3336 wsyserror("could not execute wmsetbg");
3340 if (fcntl(filedes
[0], F_SETFD
, FD_CLOEXEC
) < 0) {
3341 wsyserror("error setting close-on-exec flag");
3343 if (fcntl(filedes
[1], F_SETFD
, FD_CLOEXEC
) < 0) {
3344 wsyserror("error setting close-on-exec flag");
3347 scr
->helper_fd
= filedes
[1];
3348 scr
->helper_pid
= pid
;
3349 scr
->flags
.backimage_helper_launched
= 1;
3351 wAddDeathHandler(pid
, (WDeathHandler
*)trackDeadProcess
, scr
);
3353 SendHelperMessage(scr
, 'P', -1, wPreferences
.pixmap_path
);
3358 for (i
= 0; i
< WMGetPropListItemCount(value
); i
++) {
3359 val
= WMGetFromPLArray(value
, i
);
3360 if (val
&& WMIsPLArray(val
) && WMGetPropListItemCount(val
)>0) {
3361 str
= WMGetPropListDescription(val
, False
);
3363 SendHelperMessage(scr
, 'S', i
+1, str
);
3367 SendHelperMessage(scr
, 'U', i
+1, NULL
);
3372 WMReleasePropList(value
);
3378 setWorkspaceBack(WScreen
*scr
, WDefaultEntry
*entry
, WMPropList
*value
,
3381 if (scr
->flags
.backimage_helper_launched
) {
3384 if (WMGetPropListItemCount(value
)==0) {
3385 SendHelperMessage(scr
, 'U', 0, NULL
);
3387 /* set the default workspace background to this one */
3388 str
= WMGetPropListDescription(value
, False
);
3390 SendHelperMessage(scr
, 'S', 0, str
);
3392 SendHelperMessage(scr
, 'C', scr
->current_workspace
+1, NULL
);
3394 SendHelperMessage(scr
, 'U', 0, NULL
);
3397 } else if (WMGetPropListItemCount(value
) > 0) {
3403 SetupEnvironment(scr
);
3404 text
= WMGetPropListDescription(value
, False
);
3405 len
= strlen(text
)+40;
3406 command
= wmalloc(len
);
3407 dither
= wPreferences
.no_dithering
? "-m" : "-d";
3408 if (wPreferences
.smooth_workspace_back
)
3409 snprintf(command
, len
, "wmsetbg %s -S -p '%s' &", dither
, text
);
3411 snprintf(command
, len
, "wmsetbg %s -p '%s' &", dither
, text
);
3416 WMReleasePropList(value
);
3422 #ifdef VIRTUAL_DESKTOP
3424 setVirtualDeskEnable(WScreen
*scr
, WDefaultEntry
*entry
, void *foo
, void *bar
)
3426 wWorkspaceUpdateEdge(scr
);
3433 setWidgetColor(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
3435 if (scr
->widget_texture
) {
3436 wTextureDestroy(scr
, (WTexture
*)scr
->widget_texture
);
3438 scr
->widget_texture
= *(WTexSolid
**)texture
;
3445 setFTitleBack(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
3447 if (scr
->window_title_texture
[WS_FOCUSED
]) {
3448 wTextureDestroy(scr
, scr
->window_title_texture
[WS_FOCUSED
]);
3450 scr
->window_title_texture
[WS_FOCUSED
] = *texture
;
3452 return REFRESH_WINDOW_TEXTURES
;
3457 setPTitleBack(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
3459 if (scr
->window_title_texture
[WS_PFOCUSED
]) {
3460 wTextureDestroy(scr
, scr
->window_title_texture
[WS_PFOCUSED
]);
3462 scr
->window_title_texture
[WS_PFOCUSED
] = *texture
;
3464 return REFRESH_WINDOW_TEXTURES
;
3469 setUTitleBack(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
3471 if (scr
->window_title_texture
[WS_UNFOCUSED
]) {
3472 wTextureDestroy(scr
, scr
->window_title_texture
[WS_UNFOCUSED
]);
3474 scr
->window_title_texture
[WS_UNFOCUSED
] = *texture
;
3476 return REFRESH_WINDOW_TEXTURES
;
3481 setResizebarBack(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
3483 if (scr
->resizebar_texture
[0]) {
3484 wTextureDestroy(scr
, scr
->resizebar_texture
[0]);
3486 scr
->resizebar_texture
[0] = *texture
;
3488 return REFRESH_WINDOW_TEXTURES
;
3493 setMenuTitleBack(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
3495 if (scr
->menu_title_texture
[0]) {
3496 wTextureDestroy(scr
, scr
->menu_title_texture
[0]);
3498 scr
->menu_title_texture
[0] = *texture
;
3500 return REFRESH_MENU_TITLE_TEXTURE
;
3505 setMenuTextBack(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
3507 if (scr
->menu_item_texture
) {
3508 wTextureDestroy(scr
, scr
->menu_item_texture
);
3509 wTextureDestroy(scr
, (WTexture
*)scr
->menu_item_auxtexture
);
3511 scr
->menu_item_texture
= *texture
;
3513 scr
->menu_item_auxtexture
3514 = wTextureMakeSolid(scr
, &scr
->menu_item_texture
->any
.color
);
3516 return REFRESH_MENU_TEXTURE
;
3521 setKeyGrab(WScreen
*scr
, WDefaultEntry
*entry
, WShortKey
*shortcut
, long widx
)
3524 wKeyBindings
[widx
] = *shortcut
;
3526 wwin
= scr
->focused_window
;
3528 while (wwin
!=NULL
) {
3529 XUngrabKey(dpy
, AnyKey
, AnyModifier
, wwin
->frame
->core
->window
);
3531 if (!WFLAGP(wwin
, no_bind_keys
)) {
3532 wWindowSetKeyGrabs(wwin
);
3542 setIconPosition(WScreen
*scr
, WDefaultEntry
*entry
, void *bar
, void *foo
)
3544 wScreenUpdateUsableArea(scr
);
3545 wArrangeIcons(scr
, True
);
3552 updateUsableArea(WScreen
*scr
, WDefaultEntry
*entry
, void *bar
, void *foo
)
3554 wScreenUpdateUsableArea(scr
);
3561 setMenuStyle(WScreen
*scr
, WDefaultEntry
*entry
, int *value
, void *foo
)
3563 return REFRESH_MENU_TEXTURE
;
3567 static RImage
*chopOffImage(RImage
*image
, int x
, int y
, int w
, int h
)
3569 RImage
*img
= RCreateImage(w
, h
, image
->format
== RRGBAFormat
);
3571 RCopyArea(img
, image
, x
, y
, w
, h
, 0, 0);
3577 setSwPOptions(WScreen
*scr
, WDefaultEntry
*entry
, WMPropList
*array
, void *foo
)
3581 int cwidth
, cheight
;
3582 WPreferences
*prefs
= (WPreferences
*)foo
;
3584 if (!WMIsPLArray(array
) || WMGetPropListItemCount(array
)==0) {
3585 if (prefs
->swtileImage
) RReleaseImage(prefs
->swtileImage
);
3586 prefs
->swtileImage
= NULL
;
3588 WMReleasePropList(array
);
3592 switch (WMGetPropListItemCount(array
))
3595 if (!WMIsPLString(WMGetFromPLArray(array
, 1))) {
3596 wwarning(_("Invalid arguments for option \"%s\""),
3600 path
= FindImage(wPreferences
.pixmap_path
, WMGetFromPLString(WMGetFromPLArray(array
, 1)));
3603 wwarning(_("Could not find image \"%s\" for option \"%s\""),
3604 WMGetFromPLString(WMGetFromPLArray(array
, 1)),
3607 bgimage
= RLoadImage(scr
->rcontext
, path
, 0);
3609 wwarning(_("Could not load image \"%s\" for option \"%s\""),
3615 cwidth
= atoi(WMGetFromPLString(WMGetFromPLArray(array
, 2)));
3616 cheight
= atoi(WMGetFromPLString(WMGetFromPLArray(array
, 3)));
3618 if (cwidth
<= 0 || cheight
<= 0 ||
3619 cwidth
>= bgimage
->width
- 2 ||
3620 cheight
>= bgimage
->height
- 2)
3621 wwarning(_("Invalid split sizes for SwitchPanel back image."));
3624 int swidth
, theight
;
3625 for (i
= 0; i
< 9; i
++) {
3626 if (prefs
->swbackImage
[i
])
3627 RReleaseImage(prefs
->swbackImage
[i
]);
3628 prefs
->swbackImage
[i
]= NULL
;
3630 swidth
= (bgimage
->width
- cwidth
) / 2;
3631 theight
= (bgimage
->height
- cheight
) / 2;
3633 prefs
->swbackImage
[0]= chopOffImage(bgimage
, 0, 0,
3635 prefs
->swbackImage
[1]= chopOffImage(bgimage
, swidth
, 0,
3637 prefs
->swbackImage
[2]= chopOffImage(bgimage
, swidth
+cwidth
, 0,
3640 prefs
->swbackImage
[3]= chopOffImage(bgimage
, 0, theight
,
3642 prefs
->swbackImage
[4]= chopOffImage(bgimage
, swidth
, theight
,
3644 prefs
->swbackImage
[5]= chopOffImage(bgimage
, swidth
+cwidth
, theight
,
3647 prefs
->swbackImage
[6]= chopOffImage(bgimage
, 0, theight
+cheight
,
3649 prefs
->swbackImage
[7]= chopOffImage(bgimage
, swidth
, theight
+cheight
,
3651 prefs
->swbackImage
[8]= chopOffImage(bgimage
, swidth
+cwidth
, theight
+cheight
,
3654 // check if anything failed
3655 for (i
= 0; i
< 9; i
++) {
3656 if (!prefs
->swbackImage
[i
]) {
3658 RReleaseImage(prefs
->swbackImage
[i
]);
3659 prefs
->swbackImage
[i
]= NULL
;
3665 RReleaseImage(bgimage
);
3670 if (!WMIsPLString(WMGetFromPLArray(array
, 0))) {
3671 wwarning(_("Invalid arguments for option \"%s\""),
3675 path
= FindImage(wPreferences
.pixmap_path
, WMGetFromPLString(WMGetFromPLArray(array
, 0)));
3678 wwarning(_("Could not find image \"%s\" for option \"%s\""),
3679 WMGetFromPLString(WMGetFromPLArray(array
, 0)),
3682 if (prefs
->swtileImage
) RReleaseImage(prefs
->swtileImage
);
3684 prefs
->swtileImage
= RLoadImage(scr
->rcontext
, path
, 0);
3685 if (!prefs
->swtileImage
) {
3686 wwarning(_("Could not load image \"%s\" for option \"%s\""),
3694 wwarning(_("Invalid number of arguments for option \"%s\""),
3699 WMReleasePropList(array
);
3707 setButtonImages(WScreen *scr, WDefaultEntry *entry, int *value, void *foo)
3709 return REFRESH_BUTTON_IMAGES;
3715 * Need access to the double click variables, so that all widgets in
3716 * wmaker panels will have the same dbl-click values.
3717 * TODO: figure a better way of dealing with it.
3719 #include <WINGs/WINGsP.h>
3722 setDoubleClick(WScreen
*scr
, WDefaultEntry
*entry
, int *value
, void *foo
)
3724 extern _WINGsConfiguration WINGsConfiguration
;
3729 WINGsConfiguration
.doubleClickDelay
= *value
;
3736 setCursor(WScreen
*scr
, WDefaultEntry
*entry
, Cursor
*cursor
, long widx
)
3738 if (wCursor
[widx
] != None
) {
3739 XFreeCursor(dpy
, wCursor
[widx
]);
3742 wCursor
[widx
] = *cursor
;
3744 if (widx
== WCUR_ROOT
&& *cursor
!= None
) {
3745 XDefineCursor(dpy
, scr
->root_win
, *cursor
);