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\")", &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
);
975 wDefaultsMergeGlobalMenus(WDDomain
*menuDomain
)
977 WMPropList
*menu
= menuDomain
->dictionary
;
980 if (!menu
|| !WMIsPLArray(menu
))
983 #ifdef GLOBAL_PREAMBLE_MENU_FILE
984 submenu
= WMReadPropListFromFile(SYSCONFDIR
"/WindowMaker/"GLOBAL_PREAMBLE_MENU_FILE
);
986 if (submenu
&& !WMIsPLArray(submenu
)) {
987 wwarning(_("invalid global menu file %s"),
988 GLOBAL_PREAMBLE_MENU_FILE
);
989 WMReleasePropList(submenu
);
993 prependMenu(menu
, submenu
);
994 WMReleasePropList(submenu
);
998 #ifdef GLOBAL_EPILOGUE_MENU_FILE
999 submenu
= WMReadPropListFromFile(SYSCONFDIR
"/WindowMaker/"GLOBAL_EPILOGUE_MENU_FILE
);
1001 if (submenu
&& !WMIsPLArray(submenu
)) {
1002 wwarning(_("invalid global menu file %s"),
1003 GLOBAL_EPILOGUE_MENU_FILE
);
1004 WMReleasePropList(submenu
);
1008 appendMenu(menu
, submenu
);
1009 WMReleasePropList(submenu
);
1013 menuDomain
->dictionary
= menu
;
1019 wDefaultsInit(int screen_number
)
1021 static int defaults_inited
= 0;
1024 if (!defaults_inited
) {
1028 dict
= PLGetDomain(wDomainName
);
1030 wwarning(_("could not read domain \"%s\" from defaults database"),
1031 WMGetFromPLString(wDomainName
));
1040 wDefaultsDestroyDomain(WDDomain
*domain
)
1042 if (domain
->dictionary
)
1043 WMReleasePropList(domain
->dictionary
);
1044 wfree(domain
->path
);
1050 wDefaultsInitDomain(char *domain
, Bool requireDictionary
)
1054 static int inited
= 0;
1055 char path
[PATH_MAX
];
1057 WMPropList
*shared_dict
=NULL
;
1064 db
= wmalloc(sizeof(WDDomain
));
1065 memset(db
, 0, sizeof(WDDomain
));
1066 db
->domain_name
= domain
;
1067 db
->path
= wdefaultspathfordomain(domain
);
1068 the_path
= db
->path
;
1070 if (the_path
&& stat(the_path
, &stbuf
)>=0) {
1071 db
->dictionary
= WMReadPropListFromFile(the_path
);
1072 if (db
->dictionary
) {
1073 if (requireDictionary
&& !WMIsPLDictionary(db
->dictionary
)) {
1074 WMReleasePropList(db
->dictionary
);
1075 db
->dictionary
= NULL
;
1076 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
1079 db
->timestamp
= stbuf
.st_mtime
;
1081 wwarning(_("could not load domain %s from user defaults database"),
1086 /* global system dictionary */
1087 snprintf(path
, sizeof(path
), "%s/WindowMaker/%s", SYSCONFDIR
, domain
);
1088 if (stat(path
, &stbuf
)>=0) {
1089 shared_dict
= WMReadPropListFromFile(path
);
1091 if (requireDictionary
&& !WMIsPLDictionary(shared_dict
)) {
1092 wwarning(_("Domain %s (%s) of global defaults database is corrupted!"),
1094 WMReleasePropList(shared_dict
);
1097 if (db
->dictionary
&& WMIsPLDictionary(shared_dict
) &&
1098 WMIsPLDictionary(db
->dictionary
)) {
1099 WMMergePLDictionaries(shared_dict
, db
->dictionary
, True
);
1100 WMReleasePropList(db
->dictionary
);
1101 db
->dictionary
= shared_dict
;
1102 if (stbuf
.st_mtime
> db
->timestamp
)
1103 db
->timestamp
= stbuf
.st_mtime
;
1104 } else if (!db
->dictionary
) {
1105 db
->dictionary
= shared_dict
;
1106 if (stbuf
.st_mtime
> db
->timestamp
)
1107 db
->timestamp
= stbuf
.st_mtime
;
1111 wwarning(_("could not load domain %s from global defaults database (%s)"),
1121 wReadStaticDefaults(WMPropList
*dict
)
1123 WMPropList
*plvalue
;
1124 WDefaultEntry
*entry
;
1129 for (i
=0; i
<sizeof(staticOptionList
)/sizeof(WDefaultEntry
); i
++) {
1130 entry
= &staticOptionList
[i
];
1133 plvalue
= WMGetFromPLDictionary(dict
, entry
->plkey
);
1138 /* no default in the DB. Use builtin default */
1139 plvalue
= entry
->plvalue
;
1144 (*entry
->convert
)(NULL
, entry
, plvalue
, entry
->addr
, &tdata
);
1145 if (entry
->update
) {
1146 (*entry
->update
)(NULL
, entry
, tdata
, entry
->extra_data
);
1155 wDefaultsCheckDomains(void *foo
)
1159 WMPropList
*shared_dict
= NULL
;
1164 puts("Checking domains...");
1166 if (stat(WDWindowMaker
->path
, &stbuf
)>=0
1167 && WDWindowMaker
->timestamp
< stbuf
.st_mtime
) {
1169 puts("Checking WindowMaker domain");
1171 WDWindowMaker
->timestamp
= stbuf
.st_mtime
;
1173 /* global dictionary */
1174 shared_dict
= readGlobalDomain("WindowMaker", True
);
1175 /* user dictionary */
1176 dict
= WMReadPropListFromFile(WDWindowMaker
->path
);
1178 if (!WMIsPLDictionary(dict
)) {
1179 WMReleasePropList(dict
);
1181 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
1182 "WindowMaker", WDWindowMaker
->path
);
1185 WMMergePLDictionaries(shared_dict
, dict
, True
);
1186 WMReleasePropList(dict
);
1190 for (i
=0; i
<wScreenCount
; i
++) {
1191 scr
= wScreenWithNumber(i
);
1193 wReadDefaults(scr
, dict
);
1195 if (WDWindowMaker
->dictionary
) {
1196 WMReleasePropList(WDWindowMaker
->dictionary
);
1198 WDWindowMaker
->dictionary
= dict
;
1201 wwarning(_("could not load domain %s from user defaults database"),
1205 WMReleasePropList(shared_dict
);
1209 if (stat(WDWindowAttributes
->path
, &stbuf
)>=0
1210 && WDWindowAttributes
->timestamp
< stbuf
.st_mtime
) {
1212 puts("Checking WMWindowAttributes domain");
1214 /* global dictionary */
1215 shared_dict
= readGlobalDomain("WMWindowAttributes", True
);
1216 /* user dictionary */
1217 dict
= WMReadPropListFromFile(WDWindowAttributes
->path
);
1219 if (!WMIsPLDictionary(dict
)) {
1220 WMReleasePropList(dict
);
1222 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
1223 "WMWindowAttributes", WDWindowAttributes
->path
);
1226 WMMergePLDictionaries(shared_dict
, dict
, True
);
1227 WMReleasePropList(dict
);
1231 if (WDWindowAttributes
->dictionary
) {
1232 WMReleasePropList(WDWindowAttributes
->dictionary
);
1234 WDWindowAttributes
->dictionary
= dict
;
1235 for (i
=0; i
<wScreenCount
; i
++) {
1236 scr
= wScreenWithNumber(i
);
1240 wDefaultUpdateIcons(scr
);
1242 /* Update the panel image if changed */
1243 /* Don't worry. If the image is the same these
1244 * functions will have no performance impact. */
1245 image
= wDefaultGetImage(scr
, "Logo", "WMPanel");
1248 wwarning(_("could not load logo image for panels: %s"),
1249 RMessageForError(RErrorCode
));
1251 WMSetApplicationIconImage(scr
->wmscreen
, image
);
1252 RReleaseImage(image
);
1258 wwarning(_("could not load domain %s from user defaults database"),
1259 "WMWindowAttributes");
1261 WDWindowAttributes
->timestamp
= stbuf
.st_mtime
;
1263 WMReleasePropList(shared_dict
);
1268 if (stat(WDRootMenu
->path
, &stbuf
)>=0
1269 && WDRootMenu
->timestamp
< stbuf
.st_mtime
) {
1270 dict
= WMReadPropListFromFile(WDRootMenu
->path
);
1272 puts("Checking WMRootMenu domain");
1275 if (!WMIsPLArray(dict
) && !WMIsPLString(dict
)) {
1276 WMReleasePropList(dict
);
1278 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
1279 "WMRootMenu", WDRootMenu
->path
);
1281 if (WDRootMenu
->dictionary
) {
1282 WMReleasePropList(WDRootMenu
->dictionary
);
1284 WDRootMenu
->dictionary
= dict
;
1285 wDefaultsMergeGlobalMenus(WDRootMenu
);
1288 wwarning(_("could not load domain %s from user defaults database"),
1291 WDRootMenu
->timestamp
= stbuf
.st_mtime
;
1296 WMAddTimerHandler(DEFAULTS_CHECK_INTERVAL
, wDefaultsCheckDomains
, foo
);
1301 wReadDefaults(WScreen
*scr
, WMPropList
*new_dict
)
1303 WMPropList
*plvalue
, *old_value
;
1304 WDefaultEntry
*entry
;
1306 int update_workspace_back
= 0; /* kluge :/ */
1309 WMPropList
*old_dict
= (WDWindowMaker
->dictionary
!=new_dict
1310 ? WDWindowMaker
->dictionary
: NULL
);
1316 for (i
=0; i
<sizeof(optionList
)/sizeof(WDefaultEntry
); i
++) {
1317 entry
= &optionList
[i
];
1320 plvalue
= WMGetFromPLDictionary(new_dict
, entry
->plkey
);
1327 old_value
= WMGetFromPLDictionary(old_dict
, entry
->plkey
);
1330 if (!plvalue
&& !old_value
) {
1331 /* no default in the DB. Use builtin default */
1332 plvalue
= entry
->plvalue
;
1333 if (plvalue
&& new_dict
) {
1334 WMPutInPLDictionary(new_dict
, entry
->plkey
, plvalue
);
1337 } else if (!plvalue
) {
1338 /* value was deleted from DB. Keep current value */
1340 } else if (!old_value
) {
1341 /* set value for the 1st time */
1342 } else if (!WMIsPropListEqualTo(plvalue
, old_value
)) {
1343 /* value has changed */
1346 if (strcmp(entry
->key
, "WorkspaceBack") == 0
1347 && update_workspace_back
1348 && scr
->flags
.backimage_helper_launched
) {
1350 /* value was not changed since last time */
1357 printf("Updating %s to %s\n", entry
->key
,
1358 WMGetPropListDescription(plvalue
, False
));
1361 if ((*entry
->convert
)(scr
, entry
, plvalue
, entry
->addr
, &tdata
)) {
1363 * If the WorkspaceSpecificBack data has been changed
1364 * so that the helper will be launched now, we must be
1365 * sure to send the default background texture config
1368 if (strcmp(entry
->key
, "WorkspaceSpecificBack") == 0
1369 && !scr
->flags
.backimage_helper_launched
) {
1370 update_workspace_back
= 1;
1372 if (entry
->update
) {
1374 (*entry
->update
)(scr
, entry
, tdata
, entry
->extra_data
);
1380 if (needs_refresh
!=0 && !scr
->flags
.startup
) {
1384 if (needs_refresh
& REFRESH_MENU_TITLE_TEXTURE
)
1385 foo
|= WTextureSettings
;
1386 if (needs_refresh
& REFRESH_MENU_TITLE_FONT
)
1387 foo
|= WFontSettings
;
1388 if (needs_refresh
& REFRESH_MENU_TITLE_COLOR
)
1389 foo
|= WColorSettings
;
1391 WMPostNotificationName(WNMenuTitleAppearanceSettingsChanged
, NULL
,
1395 if (needs_refresh
& REFRESH_MENU_TEXTURE
)
1396 foo
|= WTextureSettings
;
1397 if (needs_refresh
& REFRESH_MENU_FONT
)
1398 foo
|= WFontSettings
;
1399 if (needs_refresh
& REFRESH_MENU_COLOR
)
1400 foo
|= WColorSettings
;
1402 WMPostNotificationName(WNMenuAppearanceSettingsChanged
, NULL
,
1406 if (needs_refresh
& REFRESH_WINDOW_FONT
) {
1407 foo
|= WFontSettings
;
1409 if (needs_refresh
& REFRESH_WINDOW_TEXTURES
) {
1410 foo
|= WTextureSettings
;
1412 if (needs_refresh
& REFRESH_WINDOW_TITLE_COLOR
) {
1413 foo
|= WColorSettings
;
1416 WMPostNotificationName(WNWindowAppearanceSettingsChanged
, NULL
,
1419 if (!(needs_refresh
& REFRESH_ICON_TILE
)) {
1421 if (needs_refresh
& REFRESH_ICON_FONT
) {
1422 foo
|= WFontSettings
;
1424 if (needs_refresh
& REFRESH_ICON_TITLE_COLOR
) {
1425 foo
|= WTextureSettings
;
1427 if (needs_refresh
& REFRESH_ICON_TITLE_BACK
) {
1428 foo
|= WTextureSettings
;
1431 WMPostNotificationName(WNIconAppearanceSettingsChanged
, NULL
,
1434 if (needs_refresh
& REFRESH_ICON_TILE
)
1435 WMPostNotificationName(WNIconTileSettingsChanged
, NULL
, NULL
);
1441 wDefaultUpdateIcons(WScreen
*scr
)
1443 WAppIcon
*aicon
= scr
->app_icon_list
;
1444 WWindow
*wwin
= scr
->focused_window
;
1448 file
= wDefaultGetIconFile(scr
, aicon
->wm_instance
, aicon
->wm_class
,
1450 if ((file
&& aicon
->icon
->file
&& strcmp(file
, aicon
->icon
->file
)!=0)
1451 || (file
&& !aicon
->icon
->file
)) {
1454 if (aicon
->icon
->file
)
1455 wfree(aicon
->icon
->file
);
1456 aicon
->icon
->file
= wstrdup(file
);
1458 new_image
= wDefaultGetImage(scr
, aicon
->wm_instance
,
1461 wIconChangeImage(aicon
->icon
, new_image
);
1462 wAppIconPaint(aicon
);
1465 aicon
= aicon
->next
;
1468 if (!wPreferences
.flags
.noclip
)
1469 wClipIconPaint(scr
->clip_icon
);
1472 if (wwin
->icon
&& wwin
->flags
.miniaturized
) {
1473 file
= wDefaultGetIconFile(scr
, wwin
->wm_instance
, wwin
->wm_class
,
1475 if ((file
&& wwin
->icon
->file
&& strcmp(file
, wwin
->icon
->file
)!=0)
1476 || (file
&& !wwin
->icon
->file
)) {
1479 if (wwin
->icon
->file
)
1480 wfree(wwin
->icon
->file
);
1481 wwin
->icon
->file
= wstrdup(file
);
1483 new_image
= wDefaultGetImage(scr
, wwin
->wm_instance
,
1486 wIconChangeImage(wwin
->icon
, new_image
);
1494 /* --------------------------- Local ----------------------- */
1496 #define GET_STRING_OR_DEFAULT(x, var) if (!WMIsPLString(value)) { \
1497 wwarning(_("Wrong option format for key \"%s\". Should be %s."), \
1499 wwarning(_("using default \"%s\" instead"), entry->default_value); \
1500 var = entry->default_value;\
1501 } else var = WMGetFromPLString(value)\
1508 string2index(WMPropList
*key
, WMPropList
*val
, char *def
,
1509 WOptionEnumeration
*values
)
1512 WOptionEnumeration
*v
;
1513 char buffer
[TOTAL_VALUES_LENGTH
];
1515 if (WMIsPLString(val
) && (str
= WMGetFromPLString(val
))) {
1516 for (v
=values
; v
->string
!=NULL
; v
++) {
1517 if (strcasecmp(v
->string
, str
)==0)
1523 for (v
=values
; v
->string
!=NULL
; v
++) {
1526 strcat(buffer
, ", ");
1527 strcat(buffer
, v
->string
);
1530 wwarning(_("wrong option value for key \"%s\". Should be one of %s"),
1531 WMGetFromPLString(key
), buffer
);
1534 return string2index(key
, val
, NULL
, values
);
1544 * value - is the value in the defaults DB
1545 * addr - is the address to store the data
1546 * ret - is the address to store a pointer to a temporary buffer. ret
1547 * must not be freed and is used by the set functions
1550 getBool(WScreen
*scr
, WDefaultEntry
*entry
, WMPropList
*value
, void *addr
,
1557 GET_STRING_OR_DEFAULT("Boolean", val
);
1560 if ((val
[1]=='\0' && (val
[0]=='y' || val
[0]=='Y'))
1561 || strcasecmp(val
, "YES")==0) {
1564 } else if ((val
[1]=='\0' && (val
[0]=='n' || val
[0]=='N'))
1565 || strcasecmp(val
, "NO")==0) {
1569 if (sscanf(val
, "%i", &i
)==1) {
1575 wwarning(_("can't convert \"%s\" to boolean for key \"%s\""),
1577 if (second_pass
==0) {
1578 val
= WMGetFromPLString(entry
->plvalue
);
1580 wwarning(_("using default \"%s\" instead"), val
);
1590 *(char*)addr
= data
;
1597 getInt(WScreen
*scr
, WDefaultEntry
*entry
, WMPropList
*value
, void *addr
,
1604 GET_STRING_OR_DEFAULT("Integer", val
);
1606 if (sscanf(val
, "%i", &data
)!=1) {
1607 wwarning(_("can't convert \"%s\" to integer for key \"%s\""),
1609 val
= WMGetFromPLString(entry
->plvalue
);
1610 wwarning(_("using default \"%s\" instead"), val
);
1611 if (sscanf(val
, "%i", &data
)!=1) {
1626 getCoord(WScreen
*scr
, WDefaultEntry
*entry
, WMPropList
*value
, void *addr
,
1630 char *val_x
, *val_y
;
1631 int nelem
, changed
=0;
1632 WMPropList
*elem_x
, *elem_y
;
1635 if (!WMIsPLArray(value
)) {
1636 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1637 entry
->key
, "Coordinate");
1639 value
= entry
->plvalue
;
1641 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1647 nelem
= WMGetPropListItemCount(value
);
1649 wwarning(_("Incorrect number of elements in array for key \"%s\"."),
1652 value
= entry
->plvalue
;
1654 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1660 elem_x
= WMGetFromPLArray(value
, 0);
1661 elem_y
= WMGetFromPLArray(value
, 1);
1663 if (!elem_x
|| !elem_y
|| !WMIsPLString(elem_x
) || !WMIsPLString(elem_y
)) {
1664 wwarning(_("Wrong value for key \"%s\". Should be Coordinate."),
1667 value
= entry
->plvalue
;
1669 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1675 val_x
= WMGetFromPLString(elem_x
);
1676 val_y
= WMGetFromPLString(elem_y
);
1678 if (sscanf(val_x
, "%i", &data
.x
)!=1 || sscanf(val_y
, "%i", &data
.y
)!=1) {
1679 wwarning(_("can't convert array to integers for \"%s\"."), entry
->key
);
1681 value
= entry
->plvalue
;
1683 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1691 else if (data
.x
> scr
->scr_width
/3)
1692 data
.x
= scr
->scr_width
/3;
1695 else if (data
.y
> scr
->scr_height
/3)
1696 data
.y
= scr
->scr_height
/3;
1701 *(WCoord
*)addr
= data
;
1708 getPropList(WScreen
*scr
, WDefaultEntry
*entry
, WMPropList
*value
, void *addr
,
1711 WMRetainPropList(value
);
1719 /* This function is not used at the moment. */
1721 getString(WScreen
*scr
, WDefaultEntry
*entry
, WMPropList
*value
, void *addr
,
1726 GET_STRING_OR_DEFAULT("String", data
);
1729 data
= WMGetFromPLString(entry
->plvalue
);
1737 *(char**)addr
= wstrdup(data
);
1745 getPathList(WScreen
*scr
, WDefaultEntry
*entry
, WMPropList
*value
, void *addr
,
1755 if (!WMIsPLArray(value
)) {
1756 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1757 entry
->key
, "an array of paths");
1759 value
= entry
->plvalue
;
1761 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1768 count
= WMGetPropListItemCount(value
);
1771 value
= entry
->plvalue
;
1773 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1780 for (i
=0; i
<count
; i
++) {
1781 d
= WMGetFromPLArray(value
, i
);
1782 if (!d
|| !WMIsPLString(d
)) {
1786 len
+= strlen(WMGetFromPLString(d
))+1;
1789 ptr
= data
= wmalloc(len
+1);
1791 for (i
=0; i
<count
; i
++) {
1792 d
= WMGetFromPLArray(value
, i
);
1793 if (!d
|| !WMIsPLString(d
)) {
1796 strcpy(ptr
, WMGetFromPLString(d
));
1797 ptr
+= strlen(WMGetFromPLString(d
));
1801 ptr
--; *(ptr
--) = 0;
1803 if (*(char**)addr
!=NULL
) {
1804 wfree(*(char**)addr
);
1806 *(char**)addr
= data
;
1813 getEnum(WScreen
*scr
, WDefaultEntry
*entry
, WMPropList
*value
, void *addr
,
1816 static signed char data
;
1818 data
= string2index(entry
->plkey
, value
, entry
->default_value
,
1819 (WOptionEnumeration
*)entry
->extra_data
);
1826 *(signed char*)addr
= data
;
1835 * (hgradient <color> <color>)
1836 * (vgradient <color> <color>)
1837 * (dgradient <color> <color>)
1838 * (mhgradient <color> <color> ...)
1839 * (mvgradient <color> <color> ...)
1840 * (mdgradient <color> <color> ...)
1841 * (igradient <color1> <color1> <thickness1> <color2> <color2> <thickness2>)
1842 * (tpixmap <file> <color>)
1843 * (spixmap <file> <color>)
1844 * (cpixmap <file> <color>)
1845 * (thgradient <file> <opaqueness> <color> <color>)
1846 * (tvgradient <file> <opaqueness> <color> <color>)
1847 * (tdgradient <file> <opaqueness> <color> <color>)
1848 * (function <lib> <function> ...)
1852 parse_texture(WScreen
*scr
, WMPropList
*pl
)
1857 WTexture
*texture
=NULL
;
1859 nelem
= WMGetPropListItemCount(pl
);
1864 elem
= WMGetFromPLArray(pl
, 0);
1865 if (!elem
|| !WMIsPLString(elem
))
1867 val
= WMGetFromPLString(elem
);
1870 if (strcasecmp(val
, "solid")==0) {
1878 elem
= WMGetFromPLArray(pl
, 1);
1879 if (!elem
|| !WMIsPLString(elem
))
1881 val
= WMGetFromPLString(elem
);
1883 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &color
)) {
1884 wwarning(_("\"%s\" is not a valid color name"), val
);
1888 texture
= (WTexture
*)wTextureMakeSolid(scr
, &color
);
1889 } else if (strcasecmp(val
, "dgradient")==0
1890 || strcasecmp(val
, "vgradient")==0
1891 || strcasecmp(val
, "hgradient")==0) {
1892 RColor color1
, color2
;
1897 wwarning(_("bad number of arguments in gradient specification"));
1901 if (val
[0]=='d' || val
[0]=='D')
1902 type
= WTEX_DGRADIENT
;
1903 else if (val
[0]=='h' || val
[0]=='H')
1904 type
= WTEX_HGRADIENT
;
1906 type
= WTEX_VGRADIENT
;
1909 /* get from color */
1910 elem
= WMGetFromPLArray(pl
, 1);
1911 if (!elem
|| !WMIsPLString(elem
))
1913 val
= WMGetFromPLString(elem
);
1915 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1916 wwarning(_("\"%s\" is not a valid color name"), val
);
1920 color1
.red
= xcolor
.red
>> 8;
1921 color1
.green
= xcolor
.green
>> 8;
1922 color1
.blue
= xcolor
.blue
>> 8;
1925 elem
= WMGetFromPLArray(pl
, 2);
1926 if (!elem
|| !WMIsPLString(elem
)) {
1929 val
= WMGetFromPLString(elem
);
1931 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1932 wwarning(_("\"%s\" is not a valid color name"), val
);
1936 color2
.red
= xcolor
.red
>> 8;
1937 color2
.green
= xcolor
.green
>> 8;
1938 color2
.blue
= xcolor
.blue
>> 8;
1940 texture
= (WTexture
*)wTextureMakeGradient(scr
, type
, &color1
, &color2
);
1942 } else if (strcasecmp(val
, "igradient")==0) {
1943 RColor colors1
[2], colors2
[2];
1949 wwarning(_("bad number of arguments in gradient specification"));
1953 /* get from color */
1954 for (i
= 0; i
< 2; i
++) {
1955 elem
= WMGetFromPLArray(pl
, 1+i
);
1956 if (!elem
|| !WMIsPLString(elem
))
1958 val
= WMGetFromPLString(elem
);
1960 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1961 wwarning(_("\"%s\" is not a valid color name"), val
);
1964 colors1
[i
].alpha
= 255;
1965 colors1
[i
].red
= xcolor
.red
>> 8;
1966 colors1
[i
].green
= xcolor
.green
>> 8;
1967 colors1
[i
].blue
= xcolor
.blue
>> 8;
1969 elem
= WMGetFromPLArray(pl
, 3);
1970 if (!elem
|| !WMIsPLString(elem
))
1972 val
= WMGetFromPLString(elem
);
1976 /* get from color */
1977 for (i
= 0; i
< 2; i
++) {
1978 elem
= WMGetFromPLArray(pl
, 4+i
);
1979 if (!elem
|| !WMIsPLString(elem
))
1981 val
= WMGetFromPLString(elem
);
1983 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1984 wwarning(_("\"%s\" is not a valid color name"), val
);
1987 colors2
[i
].alpha
= 255;
1988 colors2
[i
].red
= xcolor
.red
>> 8;
1989 colors2
[i
].green
= xcolor
.green
>> 8;
1990 colors2
[i
].blue
= xcolor
.blue
>> 8;
1992 elem
= WMGetFromPLArray(pl
, 6);
1993 if (!elem
|| !WMIsPLString(elem
))
1995 val
= WMGetFromPLString(elem
);
1998 texture
= (WTexture
*)wTextureMakeIGradient(scr
, th1
, colors1
,
2001 } else if (strcasecmp(val
, "mhgradient")==0
2002 || strcasecmp(val
, "mvgradient")==0
2003 || strcasecmp(val
, "mdgradient")==0) {
2010 wwarning(_("too few arguments in multicolor gradient specification"));
2014 if (val
[1]=='h' || val
[1]=='H')
2015 type
= WTEX_MHGRADIENT
;
2016 else if (val
[1]=='v' || val
[1]=='V')
2017 type
= WTEX_MVGRADIENT
;
2019 type
= WTEX_MDGRADIENT
;
2023 colors
= wmalloc(sizeof(RColor
*)*(count
+1));
2025 for (i
=0; i
<count
; i
++) {
2026 elem
= WMGetFromPLArray(pl
, i
+1);
2027 if (!elem
|| !WMIsPLString(elem
)) {
2028 for (--i
; i
>=0; --i
) {
2034 val
= WMGetFromPLString(elem
);
2036 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &color
)) {
2037 wwarning(_("\"%s\" is not a valid color name"), val
);
2038 for (--i
; i
>=0; --i
) {
2044 colors
[i
] = wmalloc(sizeof(RColor
));
2045 colors
[i
]->red
= color
.red
>> 8;
2046 colors
[i
]->green
= color
.green
>> 8;
2047 colors
[i
]->blue
= color
.blue
>> 8;
2052 texture
= (WTexture
*)wTextureMakeMGradient(scr
, type
, colors
);
2053 } else if (strcasecmp(val
, "spixmap")==0 ||
2054 strcasecmp(val
, "cpixmap")==0 ||
2055 strcasecmp(val
, "tpixmap")==0) {
2062 if (val
[0] == 's' || val
[0] == 'S')
2064 else if (val
[0] == 'c' || val
[0] == 'C')
2070 elem
= WMGetFromPLArray(pl
, 2);
2071 if (!elem
|| !WMIsPLString(elem
)) {
2074 val
= WMGetFromPLString(elem
);
2076 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &color
)) {
2077 wwarning(_("\"%s\" is not a valid color name"), val
);
2082 elem
= WMGetFromPLArray(pl
, 1);
2083 if (!elem
|| !WMIsPLString(elem
))
2085 val
= WMGetFromPLString(elem
);
2087 texture
= (WTexture
*)wTextureMakePixmap(scr
, type
, val
, &color
);
2088 } else if (strcasecmp(val
, "thgradient")==0
2089 || strcasecmp(val
, "tvgradient")==0
2090 || strcasecmp(val
, "tdgradient")==0) {
2091 RColor color1
, color2
;
2096 if (val
[1]=='h' || val
[1]=='H')
2097 style
= WTEX_THGRADIENT
;
2098 else if (val
[1]=='v' || val
[1]=='V')
2099 style
= WTEX_TVGRADIENT
;
2101 style
= WTEX_TDGRADIENT
;
2104 wwarning(_("bad number of arguments in textured gradient specification"));
2108 /* get from color */
2109 elem
= WMGetFromPLArray(pl
, 3);
2110 if (!elem
|| !WMIsPLString(elem
))
2112 val
= WMGetFromPLString(elem
);
2114 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
2115 wwarning(_("\"%s\" is not a valid color name"), val
);
2119 color1
.red
= xcolor
.red
>> 8;
2120 color1
.green
= xcolor
.green
>> 8;
2121 color1
.blue
= xcolor
.blue
>> 8;
2124 elem
= WMGetFromPLArray(pl
, 4);
2125 if (!elem
|| !WMIsPLString(elem
)) {
2128 val
= WMGetFromPLString(elem
);
2130 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
2131 wwarning(_("\"%s\" is not a valid color name"), val
);
2135 color2
.red
= xcolor
.red
>> 8;
2136 color2
.green
= xcolor
.green
>> 8;
2137 color2
.blue
= xcolor
.blue
>> 8;
2140 elem
= WMGetFromPLArray(pl
, 2);
2141 if (!elem
|| !WMIsPLString(elem
))
2144 val
= WMGetFromPLString(elem
);
2146 if (!val
|| (opacity
= atoi(val
)) < 0 || opacity
> 255) {
2147 wwarning(_("bad opacity value for tgradient texture \"%s\". Should be [0..255]"), val
);
2152 elem
= WMGetFromPLArray(pl
, 1);
2153 if (!elem
|| !WMIsPLString(elem
))
2155 val
= WMGetFromPLString(elem
);
2157 texture
= (WTexture
*)wTextureMakeTGradient(scr
, style
, &color1
, &color2
,
2160 #ifdef TEXTURE_PLUGIN
2161 else if (strcasecmp(val
, "function")==0) {
2162 WTexFunction
*function
;
2163 void (*initFunc
) (Display
*, Colormap
);
2164 char *lib
, *func
, **argv
;
2170 /* get the library name */
2171 elem
= WMGetFromPLArray(pl
, 1);
2172 if (!elem
|| !WMIsPLString(elem
)) {
2175 lib
= WMGetFromPLString(elem
);
2177 /* get the function name */
2178 elem
= WMGetFromPLArray(pl
, 2);
2179 if (!elem
|| !WMIsPLString(elem
)) {
2182 func
= WMGetFromPLString(elem
);
2185 argv
= (char **)wmalloc(argc
* sizeof(char *));
2187 /* get the parameters */
2188 argv
[0] = wstrdup(func
);
2189 for (i
= 0; i
< argc
- 1; i
++) {
2190 elem
= WMGetFromPLArray(pl
, 3 + i
);
2191 if (!elem
|| !WMIsPLString(elem
)) {
2196 argv
[i
+1] = wstrdup(WMGetFromPLString(elem
));
2199 function
= wTextureMakeFunction(scr
, lib
, func
, argc
, argv
);
2203 initFunc
= dlsym(function
->handle
, "initWindowMaker");
2205 initFunc(dpy
, scr
->w_colormap
);
2207 wwarning(_("could not initialize library %s"), lib
);
2210 wwarning(_("could not find function %s::%s"), lib
, func
);
2212 #endif /* HAVE_DLFCN_H */
2213 texture
= (WTexture
*)function
;
2215 #endif /* TEXTURE_PLUGIN */
2217 wwarning(_("invalid texture type %s"), val
);
2226 getTexture(WScreen
*scr
, WDefaultEntry
*entry
, WMPropList
*value
, void *addr
,
2229 static WTexture
*texture
;
2233 if (!WMIsPLArray(value
)) {
2234 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
2235 entry
->key
, "Texture");
2237 value
= entry
->plvalue
;
2239 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
2245 if (strcmp(entry
->key
, "WidgetColor")==0 && !changed
) {
2248 pl
= WMGetFromPLArray(value
, 0);
2249 if (!pl
|| !WMIsPLString(pl
) || !WMGetFromPLString(pl
)
2250 || strcasecmp(WMGetFromPLString(pl
), "solid")!=0) {
2251 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
2252 entry
->key
, "Solid Texture");
2254 value
= entry
->plvalue
;
2256 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
2261 texture
= parse_texture(scr
, value
);
2264 wwarning(_("Error in texture specification for key \"%s\""),
2267 value
= entry
->plvalue
;
2269 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
2279 *(WTexture
**)addr
= texture
;
2286 getWSBackground(WScreen
*scr
, WDefaultEntry
*entry
, WMPropList
*value
,
2287 void *addr
, void **ret
)
2295 if (!WMIsPLArray(value
)) {
2296 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
2297 "WorkspaceBack", "Texture or None");
2299 value
= entry
->plvalue
;
2301 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
2307 /* only do basic error checking and verify for None texture */
2309 nelem
= WMGetPropListItemCount(value
);
2311 elem
= WMGetFromPLArray(value
, 0);
2312 if (!elem
|| !WMIsPLString(elem
)) {
2313 wwarning(_("Wrong type for workspace background. Should be a texture type."));
2315 value
= entry
->plvalue
;
2317 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
2322 val
= WMGetFromPLString(elem
);
2324 if (strcasecmp(val
, "None")==0)
2327 *ret
= WMRetainPropList(value
);
2334 getWSSpecificBackground(WScreen
*scr
, WDefaultEntry
*entry
, WMPropList
*value
,
2335 void *addr
, void **ret
)
2342 if (!WMIsPLArray(value
)) {
2343 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
2344 "WorkspaceSpecificBack", "an array of textures");
2346 value
= entry
->plvalue
;
2348 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
2354 /* only do basic error checking and verify for None texture */
2356 nelem
= WMGetPropListItemCount(value
);
2359 elem
= WMGetFromPLArray(value
, nelem
);
2360 if (!elem
|| !WMIsPLArray(elem
)) {
2361 wwarning(_("Wrong type for background of workspace %i. Should be a texture."),
2367 *ret
= WMRetainPropList(value
);
2371 * Kluge to force wmsetbg helper to set the default background.
2372 * If the WorkspaceSpecificBack is changed once wmaker has started,
2373 * the WorkspaceBack won't be sent to the helper, unless the user
2374 * changes it's value too. So, we must force this by removing the
2375 * value from the defaults DB.
2377 if (!scr
->flags
.backimage_helper_launched
&& !scr
->flags
.startup
) {
2378 WMPropList
*key
= WMCreatePLString("WorkspaceBack");
2380 WMRemoveFromPLDictionary(WDWindowMaker
->dictionary
, key
);
2382 WMReleasePropList(key
);
2390 getFont(WScreen
*scr
, WDefaultEntry
*entry
, WMPropList
*value
, void *addr
,
2393 static WMFont
*font
;
2396 GET_STRING_OR_DEFAULT("Font", val
);
2398 font
= WMCreateFont(scr
->wmscreen
, val
);
2400 font
= WMCreateFont(scr
->wmscreen
, "fixed");
2403 wfatal(_("could not load any usable font!!!"));
2410 /* can't assign font value outside update function */
2411 wassertrv(addr
== NULL
, True
);
2418 getColor(WScreen
*scr
, WDefaultEntry
*entry
, WMPropList
*value
, void *addr
,
2421 static XColor color
;
2425 GET_STRING_OR_DEFAULT("Color", val
);
2429 if (!wGetColor(scr
, val
, &color
)) {
2430 wwarning(_("could not get color for key \"%s\""),
2432 if (second_pass
==0) {
2433 val
= WMGetFromPLString(entry
->plvalue
);
2435 wwarning(_("using default \"%s\" instead"), val
);
2447 *(unsigned long*)addr = pixel;
2456 getKeybind(WScreen
*scr
, WDefaultEntry
*entry
, WMPropList
*value
, void *addr
,
2459 static WShortKey shortcut
;
2466 GET_STRING_OR_DEFAULT("Key spec", val
);
2468 if (!val
|| strcasecmp(val
, "NONE")==0) {
2469 shortcut
.keycode
= 0;
2470 shortcut
.modifier
= 0;
2481 shortcut
.modifier
= 0;
2482 while ((k
= strchr(b
, '+'))!=NULL
) {
2486 mod
= wXModifierFromKey(b
);
2488 wwarning(_("%s:invalid key modifier \"%s\""), entry
->key
, b
);
2491 shortcut
.modifier
|= mod
;
2497 ksym
= XStringToKeysym(b
);
2499 if (ksym
==NoSymbol
) {
2500 wwarning(_("%s:invalid kbd shortcut specification \"%s\""), entry
->key
,
2505 shortcut
.keycode
= XKeysymToKeycode(dpy
, ksym
);
2506 if (shortcut
.keycode
==0) {
2507 wwarning(_("%s:invalid key in shortcut \"%s\""), entry
->key
, val
);
2519 getModMask(WScreen
*scr
, WDefaultEntry
*entry
, WMPropList
*value
, void *addr
,
2522 static unsigned int mask
;
2525 GET_STRING_OR_DEFAULT("Modifier Key", str
);
2530 mask
= wXModifierFromKey(str
);
2532 wwarning(_("%s: modifier key %s is not valid"), entry
->key
, str
);
2538 *(unsigned int*)addr
= mask
;
2549 getRImages(WScreen
*scr
, WDefaultEntry
*entry
, WMPropList
*value
,
2550 void *addr
, void **ret
)
2558 GET_STRING_OR_DEFAULT("Image File Path", str
);
2562 image
= RLoadImage(scr
->rcontext
, str
, 0);
2564 wwarning(_("could not load image in option %s: %s"), entry
->key
,
2565 RMessageForError(RErrorCode
));
2569 if (*(RImage
**)addr
) {
2570 RReleaseImage(*(RImage
**)addr
);
2573 *(RImage
**)addr
= image
;
2575 assert(ret
== NULL
);
2578 *(RImage**)ret = image;
2585 # include <X11/cursorfont.h>
2592 #define CURSOR_ID_NONE (XC_num_glyphs)
2594 static WCursorLookup cursor_table
[] =
2596 { "X_cursor", XC_X_cursor
},
2597 { "arrow", XC_arrow
},
2598 { "based_arrow_down", XC_based_arrow_down
},
2599 { "based_arrow_up", XC_based_arrow_up
},
2600 { "boat", XC_boat
},
2601 { "bogosity", XC_bogosity
},
2602 { "bottom_left_corner", XC_bottom_left_corner
},
2603 { "bottom_right_corner", XC_bottom_right_corner
},
2604 { "bottom_side", XC_bottom_side
},
2605 { "bottom_tee", XC_bottom_tee
},
2606 { "box_spiral", XC_box_spiral
},
2607 { "center_ptr", XC_center_ptr
},
2608 { "circle", XC_circle
},
2609 { "clock", XC_clock
},
2610 { "coffee_mug", XC_coffee_mug
},
2611 { "cross", XC_cross
},
2612 { "cross_reverse", XC_cross_reverse
},
2613 { "crosshair", XC_crosshair
},
2614 { "diamond_cross", XC_diamond_cross
},
2616 { "dotbox", XC_dotbox
},
2617 { "double_arrow", XC_double_arrow
},
2618 { "draft_large", XC_draft_large
},
2619 { "draft_small", XC_draft_small
},
2620 { "draped_box", XC_draped_box
},
2621 { "exchange", XC_exchange
},
2622 { "fleur", XC_fleur
},
2623 { "gobbler", XC_gobbler
},
2624 { "gumby", XC_gumby
},
2625 { "hand1", XC_hand1
},
2626 { "hand2", XC_hand2
},
2627 { "heart", XC_heart
},
2628 { "icon", XC_icon
},
2629 { "iron_cross", XC_iron_cross
},
2630 { "left_ptr", XC_left_ptr
},
2631 { "left_side", XC_left_side
},
2632 { "left_tee", XC_left_tee
},
2633 { "leftbutton", XC_leftbutton
},
2634 { "ll_angle", XC_ll_angle
},
2635 { "lr_angle", XC_lr_angle
},
2637 { "middlebutton", XC_middlebutton
},
2638 { "mouse", XC_mouse
},
2639 { "pencil", XC_pencil
},
2640 { "pirate", XC_pirate
},
2641 { "plus", XC_plus
},
2642 { "question_arrow", XC_question_arrow
},
2643 { "right_ptr", XC_right_ptr
},
2644 { "right_side", XC_right_side
},
2645 { "right_tee", XC_right_tee
},
2646 { "rightbutton", XC_rightbutton
},
2647 { "rtl_logo", XC_rtl_logo
},
2648 { "sailboat", XC_sailboat
},
2649 { "sb_down_arrow", XC_sb_down_arrow
},
2650 { "sb_h_double_arrow", XC_sb_h_double_arrow
},
2651 { "sb_left_arrow", XC_sb_left_arrow
},
2652 { "sb_right_arrow", XC_sb_right_arrow
},
2653 { "sb_up_arrow", XC_sb_up_arrow
},
2654 { "sb_v_double_arrow", XC_sb_v_double_arrow
},
2655 { "shuttle", XC_shuttle
},
2656 { "sizing", XC_sizing
},
2657 { "spider", XC_spider
},
2658 { "spraycan", XC_spraycan
},
2659 { "star", XC_star
},
2660 { "target", XC_target
},
2661 { "tcross", XC_tcross
},
2662 { "top_left_arrow", XC_top_left_arrow
},
2663 { "top_left_corner", XC_top_left_corner
},
2664 { "top_right_corner", XC_top_right_corner
},
2665 { "top_side", XC_top_side
},
2666 { "top_tee", XC_top_tee
},
2667 { "trek", XC_trek
},
2668 { "ul_angle", XC_ul_angle
},
2669 { "umbrella", XC_umbrella
},
2670 { "ur_angle", XC_ur_angle
},
2671 { "watch", XC_watch
},
2672 { "xterm", XC_xterm
},
2673 { NULL
, CURSOR_ID_NONE
}
2677 check_bitmap_status(int status
, char *filename
, Pixmap bitmap
)
2680 case BitmapOpenFailed
:
2681 wwarning(_("failed to open bitmap file \"%s\""), filename
);
2683 case BitmapFileInvalid
:
2684 wwarning(_("\"%s\" is not a valid bitmap file"), filename
);
2686 case BitmapNoMemory
:
2687 wwarning(_("out of memory reading bitmap file \"%s\""), filename
);
2690 XFreePixmap(dpy
, bitmap
);
2697 * (builtin, <cursor_name>)
2698 * (bitmap, <cursor_bitmap>, <cursor_mask>)
2701 parse_cursor(WScreen
*scr
, WMPropList
*pl
, Cursor
*cursor
)
2708 nelem
= WMGetPropListItemCount(pl
);
2712 elem
= WMGetFromPLArray(pl
, 0);
2713 if (!elem
|| !WMIsPLString(elem
)) {
2716 val
= WMGetFromPLString(elem
);
2718 if (0 == strcasecmp(val
, "none")) {
2721 } else if (0 == strcasecmp(val
, "builtin")) {
2723 int cursor_id
= CURSOR_ID_NONE
;
2726 wwarning(_("bad number of arguments in cursor specification"));
2729 elem
= WMGetFromPLArray(pl
, 1);
2730 if (!elem
|| !WMIsPLString(elem
)) {
2733 val
= WMGetFromPLString(elem
);
2735 for (i
= 0; NULL
!= cursor_table
[i
].name
; i
++) {
2736 if (0 == strcasecmp(val
, cursor_table
[i
].name
)) {
2737 cursor_id
= cursor_table
[i
].id
;
2741 if (CURSOR_ID_NONE
== cursor_id
) {
2742 wwarning(_("unknown builtin cursor name \"%s\""), val
);
2744 *cursor
= XCreateFontCursor(dpy
, cursor_id
);
2747 } else if (0 == strcasecmp(val
, "bitmap")) {
2759 wwarning(_("bad number of arguments in cursor specification"));
2762 elem
= WMGetFromPLArray(pl
, 1);
2763 if (!elem
|| !WMIsPLString(elem
)) {
2766 val
= WMGetFromPLString(elem
);
2767 bitmap_name
= FindImage(wPreferences
.pixmap_path
, val
);
2769 wwarning(_("could not find cursor bitmap file \"%s\""), val
);
2772 elem
= WMGetFromPLArray(pl
, 2);
2773 if (!elem
|| !WMIsPLString(elem
)) {
2777 val
= WMGetFromPLString(elem
);
2778 mask_name
= FindImage(wPreferences
.pixmap_path
, val
);
2781 wwarning(_("could not find cursor bitmap file \"%s\""), val
);
2784 mask_status
= XReadBitmapFile(dpy
, scr
->w_win
, mask_name
, &w
, &h
,
2786 bitmap_status
= XReadBitmapFile(dpy
, scr
->w_win
, bitmap_name
, &w
, &h
,
2788 if ((BitmapSuccess
== bitmap_status
) &&
2789 (BitmapSuccess
== mask_status
)) {
2790 fg
.pixel
= scr
->black_pixel
;
2791 bg
.pixel
= scr
->white_pixel
;
2792 XQueryColor(dpy
, scr
->w_colormap
, &fg
);
2793 XQueryColor(dpy
, scr
->w_colormap
, &bg
);
2794 *cursor
= XCreatePixmapCursor(dpy
, bitmap
, mask
, &fg
, &bg
, x
, y
);
2797 check_bitmap_status(bitmap_status
, bitmap_name
, bitmap
);
2798 check_bitmap_status(mask_status
, mask_name
, mask
);
2807 getCursor(WScreen
*scr
, WDefaultEntry
*entry
, WMPropList
*value
, void *addr
,
2810 static Cursor cursor
;
2815 if (!WMIsPLArray(value
)) {
2816 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
2817 entry
->key
, "cursor specification");
2819 value
= entry
->plvalue
;
2821 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
2826 status
= parse_cursor(scr
, value
, &cursor
);
2828 wwarning(_("Error in cursor specification for key \"%s\""), entry
->key
);
2830 value
= entry
->plvalue
;
2832 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
2841 *(Cursor
*)addr
= cursor
;
2845 #undef CURSOR_ID_NONE
2848 /* ---------------- value setting functions --------------- */
2850 setJustify(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
2852 return REFRESH_WINDOW_TITLE_COLOR
;
2856 setClearance(WScreen
*scr
, WDefaultEntry
*entry
, void *bar
, void *foo
)
2858 return REFRESH_WINDOW_FONT
|REFRESH_BUTTON_IMAGES
|REFRESH_MENU_TITLE_FONT
|REFRESH_MENU_FONT
;
2862 setIfDockPresent(WScreen
*scr
, WDefaultEntry
*entry
, char *flag
, long which
)
2866 wPreferences
.flags
.nodock
= wPreferences
.flags
.nodock
|| *flag
;
2869 wPreferences
.flags
.noclip
= wPreferences
.flags
.noclip
|| *flag
;
2879 setStickyIcons(WScreen
*scr
, WDefaultEntry
*entry
, void *bar
, void *foo
)
2881 if (scr
->workspaces
) {
2882 wWorkspaceForceChange(scr
, scr
->current_workspace
);
2883 wArrangeIcons(scr
, False
);
2890 setPositive(WScreen
*scr
, WDefaultEntry
*entry
, int *value
, void *foo
)
2902 setIconTile(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
2908 img
= wTextureRenderImage(*texture
, wPreferences
.icon_size
,
2909 wPreferences
.icon_size
,
2910 ((*texture
)->any
.type
& WREL_BORDER_MASK
)
2911 ? WREL_ICON
: WREL_FLAT
);
2913 wwarning(_("could not render texture for icon background"));
2915 wTextureDestroy(scr
, *texture
);
2918 RConvertImage(scr
->rcontext
, img
, &pixmap
);
2920 if (scr
->icon_tile
) {
2922 RReleaseImage(scr
->icon_tile
);
2923 XFreePixmap(dpy
, scr
->icon_tile_pixmap
);
2926 scr
->icon_tile
= img
;
2929 /* put the icon in the noticeboard hint */
2930 PropSetIconTileHint(scr
, img
);
2933 if (!wPreferences
.flags
.noclip
) {
2934 if (scr
->clip_tile
) {
2935 RReleaseImage(scr
->clip_tile
);
2937 scr
->clip_tile
= wClipMakeTile(scr
, img
);
2940 scr
->icon_tile_pixmap
= pixmap
;
2942 if (scr
->def_icon_pixmap
) {
2943 XFreePixmap(dpy
, scr
->def_icon_pixmap
);
2944 scr
->def_icon_pixmap
= None
;
2946 if (scr
->def_ticon_pixmap
) {
2947 XFreePixmap(dpy
, scr
->def_ticon_pixmap
);
2948 scr
->def_ticon_pixmap
= None
;
2951 if (scr
->icon_back_texture
) {
2952 wTextureDestroy(scr
, (WTexture
*)scr
->icon_back_texture
);
2954 scr
->icon_back_texture
= wTextureMakeSolid(scr
, &((*texture
)->any
.color
));
2956 if (scr
->clip_balloon
)
2957 XSetWindowBackground(dpy
, scr
->clip_balloon
,
2958 (*texture
)->any
.color
.pixel
);
2961 * Free the texture as nobody else will use it, nor refer to it.
2964 wTextureDestroy(scr
, *texture
);
2966 return (reset
? REFRESH_ICON_TILE
: 0);
2972 setWinTitleFont(WScreen
*scr
, WDefaultEntry
*entry
, WMFont
*font
, void *foo
)
2974 if (scr
->title_font
) {
2975 WMReleaseFont(scr
->title_font
);
2977 scr
->title_font
= font
;
2979 return REFRESH_WINDOW_FONT
|REFRESH_BUTTON_IMAGES
;
2984 setMenuTitleFont(WScreen
*scr
, WDefaultEntry
*entry
, WMFont
*font
, void *foo
)
2986 if (scr
->menu_title_font
) {
2987 WMReleaseFont(scr
->menu_title_font
);
2990 scr
->menu_title_font
= font
;
2992 return REFRESH_MENU_TITLE_FONT
;
2997 setMenuTextFont(WScreen
*scr
, WDefaultEntry
*entry
, WMFont
*font
, void *foo
)
2999 if (scr
->menu_entry_font
) {
3000 WMReleaseFont(scr
->menu_entry_font
);
3002 scr
->menu_entry_font
= font
;
3004 return REFRESH_MENU_FONT
;
3010 setIconTitleFont(WScreen
*scr
, WDefaultEntry
*entry
, WMFont
*font
, void *foo
)
3012 if (scr
->icon_title_font
) {
3013 WMReleaseFont(scr
->icon_title_font
);
3016 scr
->icon_title_font
= font
;
3018 return REFRESH_ICON_FONT
;
3023 setClipTitleFont(WScreen
*scr
, WDefaultEntry
*entry
, WMFont
*font
, void *foo
)
3025 if (scr
->clip_title_font
) {
3026 WMReleaseFont(scr
->clip_title_font
);
3029 scr
->clip_title_font
= font
;
3031 return REFRESH_ICON_FONT
;
3036 setLargeDisplayFont(WScreen
*scr
, WDefaultEntry
*entry
, WMFont
*font
, void *foo
)
3038 if (scr
->workspace_name_font
) {
3039 WMReleaseFont(scr
->workspace_name_font
);
3042 scr
->workspace_name_font
= font
;
3049 setHightlight(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, void *foo
)
3051 if (scr
->select_color
)
3052 WMReleaseColor(scr
->select_color
);
3055 WMCreateRGBColor(scr
->wmscreen
, color
->red
, color
->green
,
3058 wFreeColor(scr
, color
->pixel
);
3060 return REFRESH_MENU_COLOR
;
3065 setHightlightText(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, void *foo
)
3067 if (scr
->select_text_color
)
3068 WMReleaseColor(scr
->select_text_color
);
3070 scr
->select_text_color
=
3071 WMCreateRGBColor(scr
->wmscreen
, color
->red
, color
->green
,
3074 wFreeColor(scr
, color
->pixel
);
3076 return REFRESH_MENU_COLOR
;
3081 setClipTitleColor(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, long index
)
3083 if (scr
->clip_title_color
[index
])
3084 WMReleaseColor(scr
->clip_title_color
[index
]);
3085 scr
->clip_title_color
[index
] = WMCreateRGBColor(scr
->wmscreen
, color
->red
,
3086 color
->green
, color
->blue
,
3088 #ifdef GRADIENT_CLIP_ARROW
3089 if (index
== CLIP_NORMAL
) {
3091 RColor color1
, color2
;
3092 int pt
= CLIP_BUTTON_SIZE
*wPreferences
.icon_size
/64;
3093 int as
= pt
- 15; /* 15 = 5+5+5 */
3095 FREE_PIXMAP(scr
->clip_arrow_gradient
);
3097 color1
.red
= (color
->red
>> 8)*6/10;
3098 color1
.green
= (color
->green
>> 8)*6/10;
3099 color1
.blue
= (color
->blue
>> 8)*6/10;
3101 color2
.red
= WMIN((color
->red
>> 8)*20/10, 255);
3102 color2
.green
= WMIN((color
->green
>> 8)*20/10, 255);
3103 color2
.blue
= WMIN((color
->blue
>> 8)*20/10, 255);
3105 image
= RRenderGradient(as
+1, as
+1, &color1
, &color2
, RDiagonalGradient
);
3106 RConvertImage(scr
->rcontext
, image
, &scr
->clip_arrow_gradient
);
3107 RReleaseImage(image
);
3109 #endif /* GRADIENT_CLIP_ARROW */
3111 wFreeColor(scr
, color
->pixel
);
3113 return REFRESH_ICON_TITLE_COLOR
;
3118 setWTitleColor(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, long index
)
3120 if (scr
->window_title_color
[index
])
3121 WMReleaseColor(scr
->window_title_color
[index
]);
3123 scr
->window_title_color
[index
] =
3124 WMCreateRGBColor(scr
->wmscreen
, color
->red
, color
->green
, color
->blue
,
3127 wFreeColor(scr
, color
->pixel
);
3129 return REFRESH_WINDOW_TITLE_COLOR
;
3134 setMenuTitleColor(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, long index
)
3136 if (scr
->menu_title_color
[0])
3137 WMReleaseColor(scr
->menu_title_color
[0]);
3139 scr
->menu_title_color
[0] =
3140 WMCreateRGBColor(scr
->wmscreen
, color
->red
, color
->green
,
3143 wFreeColor(scr
, color
->pixel
);
3145 return REFRESH_MENU_TITLE_COLOR
;
3150 setMenuTextColor(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, void *foo
)
3152 if (scr
->mtext_color
)
3153 WMReleaseColor(scr
->mtext_color
);
3155 scr
->mtext_color
= WMCreateRGBColor(scr
->wmscreen
, color
->red
,
3156 color
->green
, color
->blue
, True
);
3158 if (WMColorPixel(scr
->dtext_color
) == WMColorPixel(scr
->mtext_color
)) {
3159 WMSetColorAlpha(scr
->dtext_color
, 0x7fff);
3161 WMSetColorAlpha(scr
->dtext_color
, 0xffff);
3164 wFreeColor(scr
, color
->pixel
);
3166 return REFRESH_MENU_COLOR
;
3171 setMenuDisabledColor(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, void *foo
)
3173 if (scr
->dtext_color
)
3174 WMReleaseColor(scr
->dtext_color
);
3176 scr
->dtext_color
= WMCreateRGBColor(scr
->wmscreen
, color
->red
,
3177 color
->green
, color
->blue
, True
);
3179 if (WMColorPixel(scr
->dtext_color
) == WMColorPixel(scr
->mtext_color
)) {
3180 WMSetColorAlpha(scr
->dtext_color
, 0x7fff);
3182 WMSetColorAlpha(scr
->dtext_color
, 0xffff);
3185 wFreeColor(scr
, color
->pixel
);
3187 return REFRESH_MENU_COLOR
;
3192 setIconTitleColor(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, void *foo
)
3194 if (scr
->icon_title_color
)
3195 WMReleaseColor(scr
->icon_title_color
);
3196 scr
->icon_title_color
= WMCreateRGBColor(scr
->wmscreen
, color
->red
,
3197 color
->green
, color
->blue
,
3200 wFreeColor(scr
, color
->pixel
);
3202 return REFRESH_ICON_TITLE_COLOR
;
3207 setIconTitleBack(WScreen
*scr
, WDefaultEntry
*entry
, XColor
*color
, void *foo
)
3209 if (scr
->icon_title_texture
) {
3210 wTextureDestroy(scr
, (WTexture
*)scr
->icon_title_texture
);
3212 scr
->icon_title_texture
= wTextureMakeSolid(scr
, color
);
3214 return REFRESH_ICON_TITLE_BACK
;
3219 trackDeadProcess(pid_t pid
, unsigned char status
, WScreen
*scr
)
3221 close(scr
->helper_fd
);
3223 scr
->helper_pid
= 0;
3224 scr
->flags
.backimage_helper_launched
= 0;
3229 setWorkspaceSpecificBack(WScreen
*scr
, WDefaultEntry
*entry
, WMPropList
*value
,
3236 if (scr
->flags
.backimage_helper_launched
) {
3237 if (WMGetPropListItemCount(value
)==0) {
3238 SendHelperMessage(scr
, 'C', 0, NULL
);
3239 SendHelperMessage(scr
, 'K', 0, NULL
);
3241 WMReleasePropList(value
);
3248 if (WMGetPropListItemCount(value
) == 0)
3251 if (pipe(filedes
) < 0) {
3252 wsyserror("pipe() failed:can't set workspace specific background image");
3254 WMReleasePropList(value
);
3260 wsyserror("fork() failed:can't set workspace specific background image");
3261 if (close(filedes
[0]) < 0)
3262 wsyserror("could not close pipe");
3263 if (close(filedes
[1]) < 0)
3264 wsyserror("could not close pipe");
3266 } else if (pid
== 0) {
3269 SetupEnvironment(scr
);
3272 wsyserror("could not close pipe");
3273 if (dup(filedes
[0]) < 0) {
3274 wsyserror("dup() failed:can't set workspace specific background image");
3276 dither
= wPreferences
.no_dithering
? "-m" : "-d";
3277 if (wPreferences
.smooth_workspace_back
)
3278 execlp("wmsetbg", "wmsetbg", "-helper", "-S", dither
, NULL
);
3280 execlp("wmsetbg", "wmsetbg", "-helper", dither
, NULL
);
3281 wsyserror("could not execute wmsetbg");
3285 if (fcntl(filedes
[0], F_SETFD
, FD_CLOEXEC
) < 0) {
3286 wsyserror("error setting close-on-exec flag");
3288 if (fcntl(filedes
[1], F_SETFD
, FD_CLOEXEC
) < 0) {
3289 wsyserror("error setting close-on-exec flag");
3292 scr
->helper_fd
= filedes
[1];
3293 scr
->helper_pid
= pid
;
3294 scr
->flags
.backimage_helper_launched
= 1;
3296 wAddDeathHandler(pid
, (WDeathHandler
*)trackDeadProcess
, scr
);
3298 SendHelperMessage(scr
, 'P', -1, wPreferences
.pixmap_path
);
3303 for (i
= 0; i
< WMGetPropListItemCount(value
); i
++) {
3304 val
= WMGetFromPLArray(value
, i
);
3305 if (val
&& WMIsPLArray(val
) && WMGetPropListItemCount(val
)>0) {
3306 str
= WMGetPropListDescription(val
, False
);
3308 SendHelperMessage(scr
, 'S', i
+1, str
);
3312 SendHelperMessage(scr
, 'U', i
+1, NULL
);
3317 WMReleasePropList(value
);
3323 setWorkspaceBack(WScreen
*scr
, WDefaultEntry
*entry
, WMPropList
*value
,
3326 if (scr
->flags
.backimage_helper_launched
) {
3329 if (WMGetPropListItemCount(value
)==0) {
3330 SendHelperMessage(scr
, 'U', 0, NULL
);
3332 /* set the default workspace background to this one */
3333 str
= WMGetPropListDescription(value
, False
);
3335 SendHelperMessage(scr
, 'S', 0, str
);
3337 SendHelperMessage(scr
, 'C', scr
->current_workspace
+1, NULL
);
3339 SendHelperMessage(scr
, 'U', 0, NULL
);
3342 } else if (WMGetPropListItemCount(value
) > 0) {
3348 SetupEnvironment(scr
);
3349 text
= WMGetPropListDescription(value
, False
);
3350 len
= strlen(text
)+40;
3351 command
= wmalloc(len
);
3352 dither
= wPreferences
.no_dithering
? "-m" : "-d";
3353 if (wPreferences
.smooth_workspace_back
)
3354 snprintf(command
, len
, "wmsetbg %s -S -p '%s' &", dither
, text
);
3356 snprintf(command
, len
, "wmsetbg %s -p '%s' &", dither
, text
);
3361 WMReleasePropList(value
);
3367 #ifdef VIRTUAL_DESKTOP
3369 setVirtualDeskEnable(WScreen
*scr
, WDefaultEntry
*entry
, void *foo
, void *bar
)
3371 wWorkspaceUpdateEdge(scr
);
3378 setWidgetColor(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
3380 if (scr
->widget_texture
) {
3381 wTextureDestroy(scr
, (WTexture
*)scr
->widget_texture
);
3383 scr
->widget_texture
= *(WTexSolid
**)texture
;
3390 setFTitleBack(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
3392 if (scr
->window_title_texture
[WS_FOCUSED
]) {
3393 wTextureDestroy(scr
, scr
->window_title_texture
[WS_FOCUSED
]);
3395 scr
->window_title_texture
[WS_FOCUSED
] = *texture
;
3397 return REFRESH_WINDOW_TEXTURES
;
3402 setPTitleBack(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
3404 if (scr
->window_title_texture
[WS_PFOCUSED
]) {
3405 wTextureDestroy(scr
, scr
->window_title_texture
[WS_PFOCUSED
]);
3407 scr
->window_title_texture
[WS_PFOCUSED
] = *texture
;
3409 return REFRESH_WINDOW_TEXTURES
;
3414 setUTitleBack(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
3416 if (scr
->window_title_texture
[WS_UNFOCUSED
]) {
3417 wTextureDestroy(scr
, scr
->window_title_texture
[WS_UNFOCUSED
]);
3419 scr
->window_title_texture
[WS_UNFOCUSED
] = *texture
;
3421 return REFRESH_WINDOW_TEXTURES
;
3426 setResizebarBack(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
3428 if (scr
->resizebar_texture
[0]) {
3429 wTextureDestroy(scr
, scr
->resizebar_texture
[0]);
3431 scr
->resizebar_texture
[0] = *texture
;
3433 return REFRESH_WINDOW_TEXTURES
;
3438 setMenuTitleBack(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
3440 if (scr
->menu_title_texture
[0]) {
3441 wTextureDestroy(scr
, scr
->menu_title_texture
[0]);
3443 scr
->menu_title_texture
[0] = *texture
;
3445 return REFRESH_MENU_TITLE_TEXTURE
;
3450 setMenuTextBack(WScreen
*scr
, WDefaultEntry
*entry
, WTexture
**texture
, void *foo
)
3452 if (scr
->menu_item_texture
) {
3453 wTextureDestroy(scr
, scr
->menu_item_texture
);
3454 wTextureDestroy(scr
, (WTexture
*)scr
->menu_item_auxtexture
);
3456 scr
->menu_item_texture
= *texture
;
3458 scr
->menu_item_auxtexture
3459 = wTextureMakeSolid(scr
, &scr
->menu_item_texture
->any
.color
);
3461 return REFRESH_MENU_TEXTURE
;
3466 setKeyGrab(WScreen
*scr
, WDefaultEntry
*entry
, WShortKey
*shortcut
, long index
)
3469 wKeyBindings
[index
] = *shortcut
;
3471 wwin
= scr
->focused_window
;
3473 while (wwin
!=NULL
) {
3474 XUngrabKey(dpy
, AnyKey
, AnyModifier
, wwin
->frame
->core
->window
);
3476 if (!WFLAGP(wwin
, no_bind_keys
)) {
3477 wWindowSetKeyGrabs(wwin
);
3487 setIconPosition(WScreen
*scr
, WDefaultEntry
*entry
, void *bar
, void *foo
)
3489 wScreenUpdateUsableArea(scr
);
3490 wArrangeIcons(scr
, True
);
3497 updateUsableArea(WScreen
*scr
, WDefaultEntry
*entry
, void *bar
, void *foo
)
3499 wScreenUpdateUsableArea(scr
);
3506 setMenuStyle(WScreen
*scr
, WDefaultEntry
*entry
, int *value
, void *foo
)
3508 return REFRESH_MENU_TEXTURE
;
3512 static RImage
*chopOffImage(RImage
*image
, int x
, int y
, int w
, int h
)
3514 RImage
*img
= RCreateImage(w
, h
, image
->format
== RRGBAFormat
);
3516 RCopyArea(img
, image
, x
, y
, w
, h
, 0, 0);
3522 setSwPOptions(WScreen
*scr
, WDefaultEntry
*entry
, WMPropList
*array
, void *foo
)
3526 int cwidth
, cheight
;
3527 WPreferences
*prefs
= (WPreferences
*)foo
;
3529 if (!WMIsPLArray(array
) || WMGetPropListItemCount(array
)==0) {
3530 if (prefs
->swtileImage
) RReleaseImage(prefs
->swtileImage
);
3531 prefs
->swtileImage
= NULL
;
3533 WMReleasePropList(array
);
3537 switch (WMGetPropListItemCount(array
))
3540 if (!WMIsPLString(WMGetFromPLArray(array
, 1))) {
3541 wwarning(_("Invalid arguments for option \"%s\""),
3545 path
= FindImage(wPreferences
.pixmap_path
, WMGetFromPLString(WMGetFromPLArray(array
, 1)));
3548 wwarning(_("Could not find image \"%s\" for option \"%s\""),
3549 WMGetFromPLString(WMGetFromPLArray(array
, 1)),
3552 bgimage
= RLoadImage(scr
->rcontext
, path
, 0);
3554 wwarning(_("Could not load image \"%s\" for option \"%s\""),
3560 cwidth
= atoi(WMGetFromPLString(WMGetFromPLArray(array
, 2)));
3561 cheight
= atoi(WMGetFromPLString(WMGetFromPLArray(array
, 3)));
3563 if (cwidth
<= 0 || cheight
<= 0 ||
3564 cwidth
>= bgimage
->width
- 2 ||
3565 cheight
>= bgimage
->height
- 2)
3566 wwarning(_("Invalid split sizes for SwitchPanel back image."));
3569 int swidth
, theight
;
3570 for (i
= 0; i
< 9; i
++) {
3571 if (prefs
->swbackImage
[i
])
3572 RReleaseImage(prefs
->swbackImage
[i
]);
3573 prefs
->swbackImage
[i
]= NULL
;
3575 swidth
= (bgimage
->width
- cwidth
) / 2;
3576 theight
= (bgimage
->height
- cheight
) / 2;
3578 prefs
->swbackImage
[0]= chopOffImage(bgimage
, 0, 0,
3580 prefs
->swbackImage
[1]= chopOffImage(bgimage
, swidth
, 0,
3582 prefs
->swbackImage
[2]= chopOffImage(bgimage
, swidth
+cwidth
, 0,
3585 prefs
->swbackImage
[3]= chopOffImage(bgimage
, 0, theight
,
3587 prefs
->swbackImage
[4]= chopOffImage(bgimage
, swidth
, theight
,
3589 prefs
->swbackImage
[5]= chopOffImage(bgimage
, swidth
+cwidth
, theight
,
3592 prefs
->swbackImage
[6]= chopOffImage(bgimage
, 0, theight
+cheight
,
3594 prefs
->swbackImage
[7]= chopOffImage(bgimage
, swidth
, theight
+cheight
,
3596 prefs
->swbackImage
[8]= chopOffImage(bgimage
, swidth
+cwidth
, theight
+cheight
,
3599 // check if anything failed
3600 for (i
= 0; i
< 9; i
++) {
3601 if (!prefs
->swbackImage
[i
]) {
3603 RReleaseImage(prefs
->swbackImage
[i
]);
3604 prefs
->swbackImage
[i
]= NULL
;
3610 RReleaseImage(bgimage
);
3615 if (!WMIsPLString(WMGetFromPLArray(array
, 0))) {
3616 wwarning(_("Invalid arguments for option \"%s\""),
3620 path
= FindImage(wPreferences
.pixmap_path
, WMGetFromPLString(WMGetFromPLArray(array
, 0)));
3623 wwarning(_("Could not find image \"%s\" for option \"%s\""),
3624 WMGetFromPLString(WMGetFromPLArray(array
, 0)),
3627 if (prefs
->swtileImage
) RReleaseImage(prefs
->swtileImage
);
3629 prefs
->swtileImage
= RLoadImage(scr
->rcontext
, path
, 0);
3630 if (!prefs
->swtileImage
) {
3631 wwarning(_("Could not load image \"%s\" for option \"%s\""),
3639 wwarning(_("Invalid number of arguments for option \"%s\""),
3644 WMReleasePropList(array
);
3652 setButtonImages(WScreen *scr, WDefaultEntry *entry, int *value, void *foo)
3654 return REFRESH_BUTTON_IMAGES;
3660 * Need access to the double click variables, so that all widgets in
3661 * wmaker panels will have the same dbl-click values.
3662 * TODO: figure a better way of dealing with it.
3664 #include <WINGs/WINGsP.h>
3667 setDoubleClick(WScreen
*scr
, WDefaultEntry
*entry
, int *value
, void *foo
)
3669 extern _WINGsConfiguration WINGsConfiguration
;
3674 WINGsConfiguration
.doubleClickDelay
= *value
;
3681 setCursor(WScreen
*scr
, WDefaultEntry
*entry
, Cursor
*cursor
, long index
)
3683 if (wCursor
[index
] != None
) {
3684 XFreeCursor(dpy
, wCursor
[index
]);
3687 wCursor
[index
] = *cursor
;
3689 if (index
==WCUR_ROOT
&& *cursor
!=None
) {
3690 XDefineCursor(dpy
, scr
->root_win
, *cursor
);