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>
40 #define PATH_MAX DEFAULT_PATH_MAX
44 #include <X11/Xutil.h>
45 #include <X11/keysym.h>
49 #include "WindowMaker.h"
54 #include "resources.h"
57 #include "xmodifier.h"
62 #include "workspace.h"
63 #include "properties.h"
65 #define MAX_SHORTCUT_LENGTH 32
67 #ifndef GLOBAL_DEFAULTS_SUBDIR
68 #define GLOBAL_DEFAULTS_SUBDIR "WindowMaker"
72 extern WDDomain
*WDWindowMaker
;
73 extern WDDomain
*WDWindowAttributes
;
74 extern WDDomain
*WDRootMenu
;
75 extern int wScreenCount
;
76 extern WPreferences wPreferences
;
77 extern WShortKey wKeyBindings
[WKBD_LAST
];
87 WMPropList
*plvalue
; /* default value */
90 /* used to map strings to integers */
100 static int getCoord();
101 static int getPathList();
102 static int getEnum();
103 static int getTexture();
104 static int getWSBackground();
105 static int getWSSpecificBackground();
106 static int getFont();
107 static int getColor();
108 static int getKeybind();
109 static int getModMask();
110 static int getPropList();
112 /* value setting functions */
113 static int setJustify();
114 static int setClearance();
115 static int setIfDockPresent();
116 static int setStickyIcons();
117 static int setWidgetColor();
118 static int setIconTile();
119 static int setWinTitleFont();
120 static int setMenuTitleFont();
121 static int setMenuTextFont();
122 static int setIconTitleFont();
123 static int setIconTitleColor();
124 static int setIconTitleBack();
125 static int setLargeDisplayFont();
126 static int setWTitleColor();
127 static int setFTitleBack();
128 static int setPTitleBack();
129 static int setUTitleBack();
130 static int setResizebarBack();
131 static int setWorkspaceBack();
132 static int setWorkspaceSpecificBack();
133 static int setMenuTitleColor();
134 static int setMenuTextColor();
135 static int setMenuDisabledColor();
136 static int setMenuTitleBack();
137 static int setMenuTextBack();
138 static int setHightlight();
139 static int setHightlightText();
140 static int setKeyGrab();
141 static int setDoubleClick();
142 static int setIconPosition();
144 static int setClipTitleFont();
145 static int setClipTitleColor();
147 static int setMenuStyle();
148 static int setSwPOptions();
149 static int updateUsableArea();
151 extern Cursor wCursor
[WCUR_LAST
];
152 static int getCursor();
153 static int setCursor();
156 * Tables to convert strings to enumeration values.
157 * Values stored are char
160 /* WARNING: sum of length of all value strings must not exceed
162 #define TOTAL_VALUES_LENGTH 80
164 #define REFRESH_WINDOW_TEXTURES (1<<0)
165 #define REFRESH_MENU_TEXTURE (1<<1)
166 #define REFRESH_MENU_FONT (1<<2)
167 #define REFRESH_MENU_COLOR (1<<3)
168 #define REFRESH_MENU_TITLE_TEXTURE (1<<4)
169 #define REFRESH_MENU_TITLE_FONT (1<<5)
170 #define REFRESH_MENU_TITLE_COLOR (1<<6)
171 #define REFRESH_WINDOW_TITLE_COLOR (1<<7)
172 #define REFRESH_WINDOW_FONT (1<<8)
173 #define REFRESH_ICON_TILE (1<<9)
174 #define REFRESH_ICON_FONT (1<<10)
175 #define REFRESH_WORKSPACE_BACK (1<<11)
177 #define REFRESH_BUTTON_IMAGES (1<<12)
179 #define REFRESH_ICON_TITLE_COLOR (1<<13)
180 #define REFRESH_ICON_TITLE_BACK (1<<14)
182 static WOptionEnumeration seFocusModes
[] = {
183 {"Manual", WKF_CLICK
, 0}, {"ClickToFocus", WKF_CLICK
, 1},
184 {"Sloppy", WKF_SLOPPY
, 0}, {"SemiAuto", WKF_SLOPPY
, 1}, {"Auto", WKF_SLOPPY
, 1},
188 static WOptionEnumeration seTitlebarModes
[] = {
189 {"new", TS_NEW
, 0}, {"old", TS_OLD
, 0},
190 {"next", TS_NEXT
, 0}, {NULL
, 0, 0}
193 static WOptionEnumeration seColormapModes
[] = {
194 {"Manual", WCM_CLICK
, 0}, {"ClickToFocus", WCM_CLICK
, 1},
195 {"Auto", WCM_POINTER
, 0}, {"FocusFollowMouse", WCM_POINTER
, 1},
199 static WOptionEnumeration sePlacements
[] = {
200 {"Auto", WPM_AUTO
, 0},
201 {"Smart", WPM_SMART
, 0},
202 {"Cascade", WPM_CASCADE
, 0},
203 {"Random", WPM_RANDOM
, 0},
204 {"Manual", WPM_MANUAL
, 0},
208 static WOptionEnumeration seGeomDisplays
[] = {
209 {"None", WDIS_NONE
, 0},
210 {"Center", WDIS_CENTER
, 0},
211 {"Corner", WDIS_TOPLEFT
, 0},
212 {"Floating", WDIS_FRAME_CENTER
, 0},
213 {"Line", WDIS_NEW
, 0},
217 static WOptionEnumeration seSpeeds
[] = {
218 {"UltraFast", SPEED_ULTRAFAST
, 0},
219 {"Fast", SPEED_FAST
, 0},
220 {"Medium", SPEED_MEDIUM
, 0},
221 {"Slow", SPEED_SLOW
, 0},
222 {"UltraSlow", SPEED_ULTRASLOW
, 0},
226 static WOptionEnumeration seMouseButtonActions
[] = {
227 {"None", WA_NONE
, 0},
228 {"SelectWindows", WA_SELECT_WINDOWS
, 0},
229 {"OpenApplicationsMenu", WA_OPEN_APPMENU
, 0},
230 {"OpenWindowListMenu", WA_OPEN_WINLISTMENU
, 0},
234 static WOptionEnumeration seMouseWheelActions
[] = {
235 {"None", WA_NONE
, 0},
236 {"SwitchWorkspaces", WA_SWITCH_WORKSPACES
, 0},
240 static WOptionEnumeration seIconificationStyles
[] = {
241 {"Zoom", WIS_ZOOM
, 0},
242 {"Twist", WIS_TWIST
, 0},
243 {"Flip", WIS_FLIP
, 0},
244 {"None", WIS_NONE
, 0},
245 {"random", WIS_RANDOM
, 0},
249 static WOptionEnumeration seJustifications
[] = {
250 {"Left", WTJ_LEFT
, 0},
251 {"Center", WTJ_CENTER
, 0},
252 {"Right", WTJ_RIGHT
, 0},
256 static WOptionEnumeration seIconPositions
[] = {
257 {"blv", IY_BOTTOM
| IY_LEFT
| IY_VERT
, 0},
258 {"blh", IY_BOTTOM
| IY_LEFT
| IY_HORIZ
, 0},
259 {"brv", IY_BOTTOM
| IY_RIGHT
| IY_VERT
, 0},
260 {"brh", IY_BOTTOM
| IY_RIGHT
| IY_HORIZ
, 0},
261 {"tlv", IY_TOP
| IY_LEFT
| IY_VERT
, 0},
262 {"tlh", IY_TOP
| IY_LEFT
| IY_HORIZ
, 0},
263 {"trv", IY_TOP
| IY_RIGHT
| IY_VERT
, 0},
264 {"trh", IY_TOP
| IY_RIGHT
| IY_HORIZ
, 0},
268 static WOptionEnumeration seMenuStyles
[] = {
269 {"normal", MS_NORMAL
, 0},
270 {"singletexture", MS_SINGLE_TEXTURE
, 0},
271 {"flat", MS_FLAT
, 0},
275 static WOptionEnumeration seDisplayPositions
[] = {
276 {"none", WD_NONE
, 0},
277 {"center", WD_CENTER
, 0},
279 {"bottom", WD_BOTTOM
, 0},
280 {"topleft", WD_TOPLEFT
, 0},
281 {"topright", WD_TOPRIGHT
, 0},
282 {"bottomleft", WD_BOTTOMLEFT
, 0},
283 {"bottomright", WD_BOTTOMRIGHT
, 0},
287 static WOptionEnumeration seWorkspaceBorder
[] = {
288 {"None", WB_NONE
, 0},
289 {"LeftRight", WB_LEFTRIGHT
, 0},
290 {"TopBottom", WB_TOPBOTTOM
, 0},
291 {"AllDirections", WB_ALLDIRS
, 0},
296 * ALL entries in the tables bellow, NEED to have a default value
297 * defined, and this value needs to be correct.
300 /* these options will only affect the window manager on startup
302 * static defaults can't access the screen data, because it is
303 * created after these defaults are read
305 WDefaultEntry staticOptionList
[] = {
307 {"ColormapSize", "4", NULL
,
308 &wPreferences
.cmap_size
, getInt
, NULL
, NULL
, NULL
},
309 {"DisableDithering", "NO", NULL
,
310 &wPreferences
.no_dithering
, getBool
, NULL
, NULL
, NULL
},
311 {"IconSize", "64", NULL
,
312 &wPreferences
.icon_size
, getInt
, NULL
, NULL
, NULL
},
313 {"ModifierKey", "Mod1", NULL
,
314 &wPreferences
.modifier_mask
, getModMask
, NULL
, NULL
, NULL
},
315 {"DisableWSMouseActions", "NO", NULL
,
316 &wPreferences
.disable_root_mouse
, getBool
, NULL
, NULL
, NULL
},
317 {"FocusMode", "manual", seFocusModes
, /* have a problem when switching from */
318 &wPreferences
.focus_mode
, getEnum
, NULL
, NULL
, NULL
}, /* manual to sloppy without restart */
319 {"NewStyle", "new", seTitlebarModes
,
320 &wPreferences
.new_style
, getEnum
, NULL
, NULL
, NULL
},
321 {"DisableDock", "NO", (void *)WM_DOCK
,
322 NULL
, getBool
, setIfDockPresent
, NULL
, NULL
},
323 {"DisableClip", "NO", (void *)WM_CLIP
,
324 NULL
, getBool
, setIfDockPresent
, NULL
, NULL
},
325 {"DisableMiniwindows", "NO", NULL
,
326 &wPreferences
.disable_miniwindows
, getBool
, NULL
, NULL
, NULL
}
329 WDefaultEntry optionList
[] = {
331 /* dynamic options */
333 {"IconPosition", "blh", seIconPositions
,
334 &wPreferences
.icon_yard
, getEnum
, setIconPosition
, NULL
, NULL
},
335 {"IconificationStyle", "Zoom", seIconificationStyles
,
336 &wPreferences
.iconification_style
, getEnum
, NULL
, NULL
, NULL
},
337 {"MouseLeftButtonAction", "SelectWindows", seMouseButtonActions
,
338 &wPreferences
.mouse_button1
, getEnum
, NULL
, NULL
, NULL
},
339 {"MouseMiddleButtonAction", "OpenWindowListMenu", seMouseButtonActions
,
340 &wPreferences
.mouse_button2
, getEnum
, NULL
, NULL
, NULL
},
341 {"MouseRightButtonAction", "OpenApplicationsMenu", seMouseButtonActions
,
342 &wPreferences
.mouse_button3
, getEnum
, NULL
, NULL
, NULL
},
343 {"MouseWheelAction", "None", seMouseWheelActions
,
344 &wPreferences
.mouse_wheel
, getEnum
, NULL
, NULL
, NULL
},
345 {"PixmapPath", DEF_PIXMAP_PATHS
, NULL
,
346 &wPreferences
.pixmap_path
, getPathList
, NULL
, NULL
, NULL
},
347 {"IconPath", DEF_ICON_PATHS
, NULL
,
348 &wPreferences
.icon_path
, getPathList
, NULL
, NULL
, NULL
},
349 {"ColormapMode", "auto", seColormapModes
,
350 &wPreferences
.colormap_mode
, getEnum
, NULL
, NULL
, NULL
},
351 {"AutoFocus", "NO", NULL
,
352 &wPreferences
.auto_focus
, getBool
, NULL
, NULL
, NULL
},
353 {"RaiseDelay", "0", NULL
,
354 &wPreferences
.raise_delay
, getInt
, NULL
, NULL
, NULL
},
355 {"CirculateRaise", "NO", NULL
,
356 &wPreferences
.circ_raise
, getBool
, NULL
, NULL
, NULL
},
357 {"Superfluous", "NO", NULL
,
358 &wPreferences
.superfluous
, getBool
, NULL
, NULL
, NULL
},
359 {"AdvanceToNewWorkspace", "NO", NULL
,
360 &wPreferences
.ws_advance
, getBool
, NULL
, NULL
, NULL
},
361 {"CycleWorkspaces", "NO", NULL
,
362 &wPreferences
.ws_cycle
, getBool
, NULL
, NULL
, NULL
},
363 {"WorkspaceNameDisplayPosition", "center", seDisplayPositions
,
364 &wPreferences
.workspace_name_display_position
, getEnum
, NULL
, NULL
, NULL
},
365 {"WorkspaceBorder", "None", seWorkspaceBorder
,
366 &wPreferences
.workspace_border_position
, getEnum
, updateUsableArea
, NULL
, NULL
},
367 {"WorkspaceBorderSize", "0", NULL
,
368 &wPreferences
.workspace_border_size
, getInt
, updateUsableArea
, NULL
, NULL
},
369 {"StickyIcons", "NO", NULL
,
370 &wPreferences
.sticky_icons
, getBool
, setStickyIcons
, NULL
, NULL
},
371 {"SaveSessionOnExit", "NO", NULL
,
372 &wPreferences
.save_session_on_exit
, getBool
, NULL
, NULL
, NULL
},
373 {"WrapMenus", "NO", NULL
,
374 &wPreferences
.wrap_menus
, getBool
, NULL
, NULL
, NULL
},
375 {"ScrollableMenus", "NO", NULL
,
376 &wPreferences
.scrollable_menus
, getBool
, NULL
, NULL
, NULL
},
377 {"MenuScrollSpeed", "medium", seSpeeds
,
378 &wPreferences
.menu_scroll_speed
, getEnum
, NULL
, NULL
, NULL
},
379 {"IconSlideSpeed", "medium", seSpeeds
,
380 &wPreferences
.icon_slide_speed
, getEnum
, NULL
, NULL
, NULL
},
381 {"ShadeSpeed", "medium", seSpeeds
,
382 &wPreferences
.shade_speed
, getEnum
, NULL
, NULL
, NULL
},
383 {"DoubleClickTime", "250", (void *)&wPreferences
.dblclick_time
,
384 &wPreferences
.dblclick_time
, getInt
, setDoubleClick
, NULL
, NULL
},
385 {"AlignSubmenus", "NO", NULL
,
386 &wPreferences
.align_menus
, getBool
, NULL
, NULL
, NULL
},
387 {"OpenTransientOnOwnerWorkspace", "NO", NULL
,
388 &wPreferences
.open_transients_with_parent
, getBool
, NULL
, NULL
, NULL
},
389 {"WindowPlacement", "auto", sePlacements
,
390 &wPreferences
.window_placement
, getEnum
, NULL
, NULL
, NULL
},
391 {"IgnoreFocusClick", "NO", NULL
,
392 &wPreferences
.ignore_focus_click
, getBool
, NULL
, NULL
, NULL
},
393 {"UseSaveUnders", "NO", NULL
,
394 &wPreferences
.use_saveunders
, getBool
, NULL
, NULL
, NULL
},
395 {"OpaqueMove", "NO", NULL
,
396 &wPreferences
.opaque_move
, getBool
, NULL
, NULL
, NULL
},
397 {"DisableAnimations", "NO", NULL
,
398 &wPreferences
.no_animations
, getBool
, NULL
, NULL
, NULL
},
399 {"DontLinkWorkspaces", "NO", NULL
,
400 &wPreferences
.no_autowrap
, getBool
, NULL
, NULL
, NULL
},
401 {"AutoArrangeIcons", "NO", NULL
,
402 &wPreferences
.auto_arrange_icons
, getBool
, NULL
, NULL
, NULL
},
403 {"NoWindowOverDock", "NO", NULL
,
404 &wPreferences
.no_window_over_dock
, getBool
, updateUsableArea
, NULL
, NULL
},
405 {"NoWindowOverIcons", "NO", NULL
,
406 &wPreferences
.no_window_over_icons
, getBool
, updateUsableArea
, NULL
, NULL
},
407 {"WindowPlaceOrigin", "(0, 0)", NULL
,
408 &wPreferences
.window_place_origin
, getCoord
, NULL
, NULL
, NULL
},
409 {"ResizeDisplay", "corner", seGeomDisplays
,
410 &wPreferences
.size_display
, getEnum
, NULL
, NULL
, NULL
},
411 {"MoveDisplay", "corner", seGeomDisplays
,
412 &wPreferences
.move_display
, getEnum
, NULL
, NULL
, NULL
},
413 {"DontConfirmKill", "NO", NULL
,
414 &wPreferences
.dont_confirm_kill
, getBool
, NULL
, NULL
, NULL
},
415 {"WindowTitleBalloons", "NO", NULL
,
416 &wPreferences
.window_balloon
, getBool
, NULL
, NULL
, NULL
},
417 {"MiniwindowTitleBalloons", "NO", NULL
,
418 &wPreferences
.miniwin_balloon
, getBool
, NULL
, NULL
, NULL
},
419 {"AppIconBalloons", "NO", NULL
,
420 &wPreferences
.appicon_balloon
, getBool
, NULL
, NULL
, NULL
},
421 {"HelpBalloons", "NO", NULL
,
422 &wPreferences
.help_balloon
, getBool
, NULL
, NULL
, NULL
},
423 {"EdgeResistance", "30", NULL
,
424 &wPreferences
.edge_resistance
, getInt
, NULL
, NULL
, NULL
},
425 {"ResizeIncrement", "32", NULL
,
426 &wPreferences
.resize_increment
, getInt
, NULL
, NULL
, NULL
},
427 {"Attraction", "NO", NULL
,
428 &wPreferences
.attract
, getBool
, NULL
, NULL
, NULL
},
429 {"DisableBlinking", "NO", NULL
,
430 &wPreferences
.dont_blink
, getBool
, NULL
, NULL
, NULL
},
431 {"SingleClickLaunch", "NO", NULL
,
432 &wPreferences
.single_click
, getBool
, NULL
, NULL
, NULL
},
436 {"MenuStyle", "normal", seMenuStyles
,
437 &wPreferences
.menu_style
, getEnum
, setMenuStyle
, NULL
, NULL
},
438 {"WidgetColor", "(solid, gray)", NULL
,
439 NULL
, getTexture
, setWidgetColor
, NULL
, NULL
},
440 {"WorkspaceSpecificBack", "()", NULL
,
441 NULL
, getWSSpecificBackground
, setWorkspaceSpecificBack
, NULL
, NULL
},
442 /* WorkspaceBack must come after WorkspaceSpecificBack or
443 * WorkspaceBack wont know WorkspaceSpecificBack was also
444 * specified and 2 copies of wmsetbg will be launched */
445 {"WorkspaceBack", "(solid, black)", NULL
,
446 NULL
, getWSBackground
, setWorkspaceBack
, NULL
, NULL
},
447 {"SmoothWorkspaceBack", "NO", NULL
,
448 NULL
, getBool
, NULL
, NULL
, NULL
},
449 {"IconBack", "(solid, gray)", NULL
,
450 NULL
, getTexture
, setIconTile
, NULL
, NULL
},
451 {"TitleJustify", "center", seJustifications
,
452 &wPreferences
.title_justification
, getEnum
, setJustify
, NULL
, NULL
},
453 {"WindowTitleFont", DEF_TITLE_FONT
, NULL
,
454 NULL
, getFont
, setWinTitleFont
, NULL
, NULL
},
455 {"WindowTitleExtendSpace", DEF_WINDOW_TITLE_EXTEND_SPACE
, NULL
,
456 &wPreferences
.window_title_clearance
, getInt
, setClearance
, NULL
, NULL
},
457 {"MenuTitleExtendSpace", DEF_MENU_TITLE_EXTEND_SPACE
, NULL
,
458 &wPreferences
.menu_title_clearance
, getInt
, setClearance
, NULL
, NULL
},
459 {"MenuTextExtendSpace", DEF_MENU_TEXT_EXTEND_SPACE
, NULL
,
460 &wPreferences
.menu_text_clearance
, getInt
, setClearance
, NULL
, NULL
},
461 {"MenuTitleFont", DEF_MENU_TITLE_FONT
, NULL
,
462 NULL
, getFont
, setMenuTitleFont
, NULL
, NULL
},
463 {"MenuTextFont", DEF_MENU_ENTRY_FONT
, NULL
,
464 NULL
, getFont
, setMenuTextFont
, NULL
, NULL
},
465 {"IconTitleFont", DEF_ICON_TITLE_FONT
, NULL
,
466 NULL
, getFont
, setIconTitleFont
, NULL
, NULL
},
467 {"ClipTitleFont", DEF_CLIP_TITLE_FONT
, NULL
,
468 NULL
, getFont
, setClipTitleFont
, NULL
, NULL
},
469 {"LargeDisplayFont", DEF_WORKSPACE_NAME_FONT
, NULL
,
470 NULL
, getFont
, setLargeDisplayFont
, NULL
, NULL
},
471 {"HighlightColor", "white", NULL
,
472 NULL
, getColor
, setHightlight
, NULL
, NULL
},
473 {"HighlightTextColor", "black", NULL
,
474 NULL
, getColor
, setHightlightText
, NULL
, NULL
},
475 {"ClipTitleColor", "black", (void *)CLIP_NORMAL
,
476 NULL
, getColor
, setClipTitleColor
, NULL
, NULL
},
477 {"CClipTitleColor", "\"#454045\"", (void *)CLIP_COLLAPSED
,
478 NULL
, getColor
, setClipTitleColor
, NULL
, NULL
},
479 {"FTitleColor", "white", (void *)WS_FOCUSED
,
480 NULL
, getColor
, setWTitleColor
, NULL
, NULL
},
481 {"PTitleColor", "white", (void *)WS_PFOCUSED
,
482 NULL
, getColor
, setWTitleColor
, NULL
, NULL
},
483 {"UTitleColor", "black", (void *)WS_UNFOCUSED
,
484 NULL
, getColor
, setWTitleColor
, NULL
, NULL
},
485 {"FTitleBack", "(solid, black)", NULL
,
486 NULL
, getTexture
, setFTitleBack
, NULL
, NULL
},
487 {"PTitleBack", "(solid, \"#616161\")", NULL
,
488 NULL
, getTexture
, setPTitleBack
, NULL
, NULL
},
489 {"UTitleBack", "(solid, gray)", NULL
,
490 NULL
, getTexture
, setUTitleBack
, NULL
, NULL
},
491 {"ResizebarBack", "(solid, gray)", NULL
,
492 NULL
, getTexture
, setResizebarBack
, NULL
, NULL
},
493 {"MenuTitleColor", "white", NULL
,
494 NULL
, getColor
, setMenuTitleColor
, NULL
, NULL
},
495 {"MenuTextColor", "black", NULL
,
496 NULL
, getColor
, setMenuTextColor
, NULL
, NULL
},
497 {"MenuDisabledColor", "\"#616161\"", NULL
,
498 NULL
, getColor
, setMenuDisabledColor
, NULL
, NULL
},
499 {"MenuTitleBack", "(solid, black)", NULL
,
500 NULL
, getTexture
, setMenuTitleBack
, NULL
, NULL
},
501 {"MenuTextBack", "(solid, gray)", NULL
,
502 NULL
, getTexture
, setMenuTextBack
, NULL
, NULL
},
503 {"IconTitleColor", "white", NULL
,
504 NULL
, getColor
, setIconTitleColor
, NULL
, NULL
},
505 {"IconTitleBack", "black", NULL
,
506 NULL
, getColor
, setIconTitleBack
, NULL
, NULL
},
507 {"SwitchPanelImages", "(swtile.png, swback.png, 30, 40)", &wPreferences
,
508 NULL
, getPropList
, setSwPOptions
, NULL
, NULL
},
512 {"RootMenuKey", "None", (void *)WKBD_ROOTMENU
,
513 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
514 {"WindowListKey", "None", (void *)WKBD_WINDOWLIST
,
515 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
516 {"WindowMenuKey", "None", (void *)WKBD_WINDOWMENU
,
517 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
518 {"DockRaiseLowerKey", "None", (void*)WKBD_DOCKRAISELOWER
,
519 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
520 {"ClipRaiseLowerKey", "None", (void *)WKBD_CLIPRAISELOWER
,
521 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
522 {"MiniaturizeKey", "None", (void *)WKBD_MINIATURIZE
,
523 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
524 {"MinimizeAllKey", "None", (void *)WKBD_MINIMIZEALL
,
525 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
526 {"HideKey", "None", (void *)WKBD_HIDE
,
527 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
528 {"HideOthersKey", "None", (void *)WKBD_HIDE_OTHERS
,
529 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
530 {"MoveResizeKey", "None", (void *)WKBD_MOVERESIZE
,
531 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
532 {"CloseKey", "None", (void *)WKBD_CLOSE
,
533 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
534 {"MaximizeKey", "None", (void *)WKBD_MAXIMIZE
,
535 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
536 {"VMaximizeKey", "None", (void *)WKBD_VMAXIMIZE
,
537 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
538 {"HMaximizeKey", "None", (void *)WKBD_HMAXIMIZE
,
539 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
540 {"LHMaximizeKey", "None", (void*)WKBD_LHMAXIMIZE
,
541 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
542 {"RHMaximizeKey", "None", (void*)WKBD_RHMAXIMIZE
,
543 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
544 {"MaximusKey", "None", (void*)WKBD_MAXIMUS
,
545 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
546 {"RaiseKey", "\"Meta+Up\"", (void *)WKBD_RAISE
,
547 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
548 {"LowerKey", "\"Meta+Down\"", (void *)WKBD_LOWER
,
549 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
550 {"RaiseLowerKey", "None", (void *)WKBD_RAISELOWER
,
551 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
552 {"ShadeKey", "None", (void *)WKBD_SHADE
,
553 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
554 {"SelectKey", "None", (void *)WKBD_SELECT
,
555 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
556 {"FocusNextKey", "None", (void *)WKBD_FOCUSNEXT
,
557 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
558 {"FocusPrevKey", "None", (void *)WKBD_FOCUSPREV
,
559 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
560 {"GroupNextKey", "None", (void *)WKBD_GROUPNEXT
,
561 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
562 {"GroupPrevKey", "None", (void *)WKBD_GROUPPREV
,
563 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
564 {"NextWorkspaceKey", "None", (void *)WKBD_NEXTWORKSPACE
,
565 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
566 {"PrevWorkspaceKey", "None", (void *)WKBD_PREVWORKSPACE
,
567 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
568 {"NextWorkspaceLayerKey", "None", (void *)WKBD_NEXTWSLAYER
,
569 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
570 {"PrevWorkspaceLayerKey", "None", (void *)WKBD_PREVWSLAYER
,
571 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
572 {"Workspace1Key", "None", (void *)WKBD_WORKSPACE1
,
573 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
574 {"Workspace2Key", "None", (void *)WKBD_WORKSPACE2
,
575 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
576 {"Workspace3Key", "None", (void *)WKBD_WORKSPACE3
,
577 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
578 {"Workspace4Key", "None", (void *)WKBD_WORKSPACE4
,
579 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
580 {"Workspace5Key", "None", (void *)WKBD_WORKSPACE5
,
581 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
582 {"Workspace6Key", "None", (void *)WKBD_WORKSPACE6
,
583 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
584 {"Workspace7Key", "None", (void *)WKBD_WORKSPACE7
,
585 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
586 {"Workspace8Key", "None", (void *)WKBD_WORKSPACE8
,
587 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
588 {"Workspace9Key", "None", (void *)WKBD_WORKSPACE9
,
589 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
590 {"Workspace10Key", "None", (void *)WKBD_WORKSPACE10
,
591 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
592 {"WindowShortcut1Key", "None", (void *)WKBD_WINDOW1
,
593 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
594 {"WindowShortcut2Key", "None", (void *)WKBD_WINDOW2
,
595 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
596 {"WindowShortcut3Key", "None", (void *)WKBD_WINDOW3
,
597 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
598 {"WindowShortcut4Key", "None", (void *)WKBD_WINDOW4
,
599 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
600 {"WindowShortcut5Key", "None", (void *)WKBD_WINDOW5
,
601 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
602 {"WindowShortcut6Key", "None", (void *)WKBD_WINDOW6
,
603 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
604 {"WindowShortcut7Key", "None", (void *)WKBD_WINDOW7
,
605 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
606 {"WindowShortcut8Key", "None", (void *)WKBD_WINDOW8
,
607 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
608 {"WindowShortcut9Key", "None", (void *)WKBD_WINDOW9
,
609 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
610 {"WindowShortcut10Key", "None", (void *)WKBD_WINDOW10
,
611 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
612 {"ScreenSwitchKey", "None", (void *)WKBD_SWITCH_SCREEN
,
613 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
615 #ifdef KEEP_XKB_LOCK_STATUS
616 {"ToggleKbdModeKey", "None", (void *)WKBD_TOGGLE
,
617 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
618 {"KbdModeLock", "NO", NULL
,
619 &wPreferences
.modelock
, getBool
, NULL
, NULL
, NULL
},
620 #endif /* KEEP_XKB_LOCK_STATUS */
622 {"NormalCursor", "(builtin, left_ptr)", (void *)WCUR_ROOT
,
623 NULL
, getCursor
, setCursor
, NULL
, NULL
},
624 {"ArrowCursor", "(builtin, top_left_arrow)", (void *)WCUR_ARROW
,
625 NULL
, getCursor
, setCursor
, NULL
, NULL
},
626 {"MoveCursor", "(builtin, fleur)", (void *)WCUR_MOVE
,
627 NULL
, getCursor
, setCursor
, NULL
, NULL
},
628 {"ResizeCursor", "(builtin, sizing)", (void *)WCUR_RESIZE
,
629 NULL
, getCursor
, setCursor
, NULL
, NULL
},
630 {"TopLeftResizeCursor", "(builtin, top_left_corner)", (void *)WCUR_TOPLEFTRESIZE
,
631 NULL
, getCursor
, setCursor
, NULL
, NULL
},
632 {"TopRightResizeCursor", "(builtin, top_right_corner)", (void *)WCUR_TOPRIGHTRESIZE
,
633 NULL
, getCursor
, setCursor
, NULL
, NULL
},
634 {"BottomLeftResizeCursor", "(builtin, bottom_left_corner)", (void *)WCUR_BOTTOMLEFTRESIZE
,
635 NULL
, getCursor
, setCursor
, NULL
, NULL
},
636 {"BottomRightResizeCursor", "(builtin, bottom_right_corner)", (void *)WCUR_BOTTOMRIGHTRESIZE
,
637 NULL
, getCursor
, setCursor
, NULL
, NULL
},
638 {"VerticalResizeCursor", "(builtin, sb_v_double_arrow)", (void *)WCUR_VERTICALRESIZE
,
639 NULL
, getCursor
, setCursor
, NULL
, NULL
},
640 {"HorizontalResizeCursor", "(builtin, sb_h_double_arrow)", (void *)WCUR_HORIZONRESIZE
,
641 NULL
, getCursor
, setCursor
, NULL
, NULL
},
642 {"WaitCursor", "(builtin, watch)", (void *)WCUR_WAIT
,
643 NULL
, getCursor
, setCursor
, NULL
, NULL
},
644 {"QuestionCursor", "(builtin, question_arrow)", (void *)WCUR_QUESTION
,
645 NULL
, getCursor
, setCursor
, NULL
, NULL
},
646 {"TextCursor", "(builtin, xterm)", (void *)WCUR_TEXT
,
647 NULL
, getCursor
, setCursor
, NULL
, NULL
},
648 {"SelectCursor", "(builtin, cross)", (void *)WCUR_SELECT
,
649 NULL
, getCursor
, setCursor
, NULL
, NULL
},
650 {"DialogHistoryLines", "500", NULL
,
651 &wPreferences
.history_lines
, getInt
, NULL
, NULL
, NULL
},
652 {"CycleActiveHeadOnly", "NO", NULL
,
653 &wPreferences
.cycle_active_head_only
, getBool
, NULL
, NULL
, NULL
}
656 static void initDefaults()
659 WDefaultEntry
*entry
;
661 WMPLSetCaseSensitive(False
);
663 for (i
= 0; i
< sizeof(optionList
) / sizeof(WDefaultEntry
); i
++) {
664 entry
= &optionList
[i
];
666 entry
->plkey
= WMCreatePLString(entry
->key
);
667 if (entry
->default_value
)
668 entry
->plvalue
= WMCreatePropListFromDescription(entry
->default_value
);
670 entry
->plvalue
= NULL
;
673 for (i
= 0; i
< sizeof(staticOptionList
) / sizeof(WDefaultEntry
); i
++) {
674 entry
= &staticOptionList
[i
];
676 entry
->plkey
= WMCreatePLString(entry
->key
);
677 if (entry
->default_value
)
678 entry
->plvalue
= WMCreatePropListFromDescription(entry
->default_value
);
680 entry
->plvalue
= NULL
;
684 static WMPropList
*readGlobalDomain(char *domainName
, Bool requireDictionary
)
686 WMPropList
*globalDict
= NULL
;
690 snprintf(path
, sizeof(path
), "%s/%s/%s", SYSCONFDIR
, GLOBAL_DEFAULTS_SUBDIR
, domainName
);
691 if (stat(path
, &stbuf
) >= 0) {
692 globalDict
= WMReadPropListFromFile(path
);
693 if (globalDict
&& requireDictionary
&& !WMIsPLDictionary(globalDict
)) {
694 wwarning(_("Domain %s (%s) of global defaults database is corrupted!"), domainName
, path
);
695 WMReleasePropList(globalDict
);
697 } else if (!globalDict
) {
698 wwarning(_("could not load domain %s from global defaults database"), domainName
);
705 #if defined(GLOBAL_PREAMBLE_MENU_FILE) || defined(GLOBAL_EPILOGUE_MENU_FILE)
706 static void prependMenu(WMPropList
* destarr
, WMPropList
* array
)
711 for (i
= 0; i
< WMGetPropListItemCount(array
); i
++) {
712 item
= WMGetFromPLArray(array
, i
);
714 WMInsertInPLArray(destarr
, i
+ 1, item
);
718 static void appendMenu(WMPropList
* destarr
, WMPropList
* array
)
723 for (i
= 0; i
< WMGetPropListItemCount(array
); i
++) {
724 item
= WMGetFromPLArray(array
, i
);
726 WMAddToPLArray(destarr
, item
);
731 void wDefaultsMergeGlobalMenus(WDDomain
* menuDomain
)
733 WMPropList
*menu
= menuDomain
->dictionary
;
736 if (!menu
|| !WMIsPLArray(menu
))
739 #ifdef GLOBAL_PREAMBLE_MENU_FILE
740 submenu
= WMReadPropListFromFile(SYSCONFDIR
"/" GLOBAL_DEFAULTS_SUBDIR
"/" GLOBAL_PREAMBLE_MENU_FILE
);
742 if (submenu
&& !WMIsPLArray(submenu
)) {
743 wwarning(_("invalid global menu file %s"), GLOBAL_PREAMBLE_MENU_FILE
);
744 WMReleasePropList(submenu
);
748 prependMenu(menu
, submenu
);
749 WMReleasePropList(submenu
);
753 #ifdef GLOBAL_EPILOGUE_MENU_FILE
754 submenu
= WMReadPropListFromFile(SYSCONFDIR
"/" GLOBAL_DEFAULTS_SUBDIR
"/" GLOBAL_EPILOGUE_MENU_FILE
);
756 if (submenu
&& !WMIsPLArray(submenu
)) {
757 wwarning(_("invalid global menu file %s"), GLOBAL_EPILOGUE_MENU_FILE
);
758 WMReleasePropList(submenu
);
762 appendMenu(menu
, submenu
);
763 WMReleasePropList(submenu
);
767 menuDomain
->dictionary
= menu
;
770 void wDefaultsDestroyDomain(WDDomain
* domain
)
772 if (domain
->dictionary
)
773 WMReleasePropList(domain
->dictionary
);
778 WDDomain
*wDefaultsInitDomain(char *domain
, Bool requireDictionary
)
782 static int inited
= 0;
785 WMPropList
*shared_dict
= NULL
;
792 db
= wmalloc(sizeof(WDDomain
));
793 memset(db
, 0, sizeof(WDDomain
));
794 db
->domain_name
= domain
;
795 db
->path
= wdefaultspathfordomain(domain
);
798 if (the_path
&& stat(the_path
, &stbuf
) >= 0) {
799 db
->dictionary
= WMReadPropListFromFile(the_path
);
800 if (db
->dictionary
) {
801 if (requireDictionary
&& !WMIsPLDictionary(db
->dictionary
)) {
802 WMReleasePropList(db
->dictionary
);
803 db
->dictionary
= NULL
;
804 wwarning(_("Domain %s (%s) of defaults database is corrupted!"), domain
, the_path
);
806 db
->timestamp
= stbuf
.st_mtime
;
808 wwarning(_("could not load domain %s from user defaults database"), domain
);
812 /* global system dictionary */
813 snprintf(path
, sizeof(path
), "%s/%s/%s", SYSCONFDIR
, GLOBAL_DEFAULTS_SUBDIR
, domain
);
814 if (stat(path
, &stbuf
) >= 0) {
815 shared_dict
= WMReadPropListFromFile(path
);
817 if (requireDictionary
&& !WMIsPLDictionary(shared_dict
)) {
818 wwarning(_("Domain %s (%s) of global defaults database is corrupted!"),
820 WMReleasePropList(shared_dict
);
823 if (db
->dictionary
&& WMIsPLDictionary(shared_dict
) &&
824 WMIsPLDictionary(db
->dictionary
)) {
825 WMMergePLDictionaries(shared_dict
, db
->dictionary
, True
);
826 WMReleasePropList(db
->dictionary
);
827 db
->dictionary
= shared_dict
;
828 if (stbuf
.st_mtime
> db
->timestamp
)
829 db
->timestamp
= stbuf
.st_mtime
;
830 } else if (!db
->dictionary
) {
831 db
->dictionary
= shared_dict
;
832 if (stbuf
.st_mtime
> db
->timestamp
)
833 db
->timestamp
= stbuf
.st_mtime
;
837 wwarning(_("could not load domain %s from global defaults database (%s)"), domain
, path
);
844 void wReadStaticDefaults(WMPropList
* dict
)
847 WDefaultEntry
*entry
;
851 for (i
= 0; i
< sizeof(staticOptionList
) / sizeof(WDefaultEntry
); i
++) {
852 entry
= &staticOptionList
[i
];
855 plvalue
= WMGetFromPLDictionary(dict
, entry
->plkey
);
860 /* no default in the DB. Use builtin default */
861 plvalue
= entry
->plvalue
;
866 (*entry
->convert
) (NULL
, entry
, plvalue
, entry
->addr
, &tdata
);
868 (*entry
->update
) (NULL
, entry
, tdata
, entry
->extra_data
);
874 void wDefaultsCheckDomains(void* arg
)
878 WMPropList
*shared_dict
= NULL
;
882 if (stat(WDWindowMaker
->path
, &stbuf
) >= 0 && WDWindowMaker
->timestamp
< stbuf
.st_mtime
) {
883 WDWindowMaker
->timestamp
= stbuf
.st_mtime
;
885 /* global dictionary */
886 shared_dict
= readGlobalDomain("WindowMaker", True
);
887 /* user dictionary */
888 dict
= WMReadPropListFromFile(WDWindowMaker
->path
);
890 if (!WMIsPLDictionary(dict
)) {
891 WMReleasePropList(dict
);
893 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
894 "WindowMaker", WDWindowMaker
->path
);
897 WMMergePLDictionaries(shared_dict
, dict
, True
);
898 WMReleasePropList(dict
);
902 for (i
= 0; i
< wScreenCount
; i
++) {
903 scr
= wScreenWithNumber(i
);
905 wReadDefaults(scr
, dict
);
907 if (WDWindowMaker
->dictionary
) {
908 WMReleasePropList(WDWindowMaker
->dictionary
);
910 WDWindowMaker
->dictionary
= dict
;
913 wwarning(_("could not load domain %s from user defaults database"), "WindowMaker");
916 WMReleasePropList(shared_dict
);
920 if (stat(WDWindowAttributes
->path
, &stbuf
) >= 0 && WDWindowAttributes
->timestamp
< stbuf
.st_mtime
) {
921 /* global dictionary */
922 shared_dict
= readGlobalDomain("WMWindowAttributes", True
);
923 /* user dictionary */
924 dict
= WMReadPropListFromFile(WDWindowAttributes
->path
);
926 if (!WMIsPLDictionary(dict
)) {
927 WMReleasePropList(dict
);
929 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
930 "WMWindowAttributes", WDWindowAttributes
->path
);
933 WMMergePLDictionaries(shared_dict
, dict
, True
);
934 WMReleasePropList(dict
);
938 if (WDWindowAttributes
->dictionary
) {
939 WMReleasePropList(WDWindowAttributes
->dictionary
);
941 WDWindowAttributes
->dictionary
= dict
;
942 for (i
= 0; i
< wScreenCount
; i
++) {
943 scr
= wScreenWithNumber(i
);
947 wDefaultUpdateIcons(scr
);
949 /* Update the panel image if changed */
950 /* Don't worry. If the image is the same these
951 * functions will have no performance impact. */
952 image
= wDefaultGetImage(scr
, "Logo", "WMPanel");
955 wwarning(_("could not load logo image for panels: %s"),
956 RMessageForError(RErrorCode
));
958 WMSetApplicationIconImage(scr
->wmscreen
, image
);
959 RReleaseImage(image
);
965 wwarning(_("could not load domain %s from user defaults database"), "WMWindowAttributes");
967 WDWindowAttributes
->timestamp
= stbuf
.st_mtime
;
969 WMReleasePropList(shared_dict
);
973 if (stat(WDRootMenu
->path
, &stbuf
) >= 0 && WDRootMenu
->timestamp
< stbuf
.st_mtime
) {
974 dict
= WMReadPropListFromFile(WDRootMenu
->path
);
976 if (!WMIsPLArray(dict
) && !WMIsPLString(dict
)) {
977 WMReleasePropList(dict
);
979 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
980 "WMRootMenu", WDRootMenu
->path
);
982 if (WDRootMenu
->dictionary
) {
983 WMReleasePropList(WDRootMenu
->dictionary
);
985 WDRootMenu
->dictionary
= dict
;
986 wDefaultsMergeGlobalMenus(WDRootMenu
);
989 wwarning(_("could not load domain %s from user defaults database"), "WMRootMenu");
991 WDRootMenu
->timestamp
= stbuf
.st_mtime
;
995 WMAddTimerHandler(DEFAULTS_CHECK_INTERVAL
, wDefaultsCheckDomains
, arg
);
999 void wReadDefaults(WScreen
* scr
, WMPropList
* new_dict
)
1001 WMPropList
*plvalue
, *old_value
;
1002 WDefaultEntry
*entry
;
1003 unsigned int i
, must_update
;
1004 int update_workspace_back
= 0; /* kluge :/ */
1005 unsigned int needs_refresh
;
1007 WMPropList
*old_dict
= (WDWindowMaker
->dictionary
!= new_dict
? WDWindowMaker
->dictionary
: NULL
);
1013 for (i
= 0; i
< sizeof(optionList
) / sizeof(WDefaultEntry
); i
++) {
1014 entry
= &optionList
[i
];
1017 plvalue
= WMGetFromPLDictionary(new_dict
, entry
->plkey
);
1024 old_value
= WMGetFromPLDictionary(old_dict
, entry
->plkey
);
1026 if (!plvalue
&& !old_value
) {
1027 /* no default in the DB. Use builtin default */
1028 plvalue
= entry
->plvalue
;
1029 if (plvalue
&& new_dict
) {
1030 WMPutInPLDictionary(new_dict
, entry
->plkey
, plvalue
);
1033 } else if (!plvalue
) {
1034 /* value was deleted from DB. Keep current value */
1036 } else if (!old_value
) {
1037 /* set value for the 1st time */
1038 } else if (!WMIsPropListEqualTo(plvalue
, old_value
)) {
1039 /* value has changed */
1042 if (strcmp(entry
->key
, "WorkspaceBack") == 0
1043 && update_workspace_back
&& scr
->flags
.backimage_helper_launched
) {
1045 /* value was not changed since last time */
1052 if ((*entry
->convert
) (scr
, entry
, plvalue
, entry
->addr
, &tdata
)) {
1054 * If the WorkspaceSpecificBack data has been changed
1055 * so that the helper will be launched now, we must be
1056 * sure to send the default background texture config
1059 if (strcmp(entry
->key
, "WorkspaceSpecificBack") == 0
1060 && !scr
->flags
.backimage_helper_launched
) {
1061 update_workspace_back
= 1;
1063 if (entry
->update
) {
1064 needs_refresh
|= (*entry
->update
) (scr
, entry
, tdata
, entry
->extra_data
);
1070 if (needs_refresh
!= 0 && !scr
->flags
.startup
) {
1074 if (needs_refresh
& REFRESH_MENU_TITLE_TEXTURE
)
1075 foo
|= WTextureSettings
;
1076 if (needs_refresh
& REFRESH_MENU_TITLE_FONT
)
1077 foo
|= WFontSettings
;
1078 if (needs_refresh
& REFRESH_MENU_TITLE_COLOR
)
1079 foo
|= WColorSettings
;
1081 WMPostNotificationName(WNMenuTitleAppearanceSettingsChanged
, NULL
,
1082 (void *)(uintptr_t) foo
);
1085 if (needs_refresh
& REFRESH_MENU_TEXTURE
)
1086 foo
|= WTextureSettings
;
1087 if (needs_refresh
& REFRESH_MENU_FONT
)
1088 foo
|= WFontSettings
;
1089 if (needs_refresh
& REFRESH_MENU_COLOR
)
1090 foo
|= WColorSettings
;
1092 WMPostNotificationName(WNMenuAppearanceSettingsChanged
, NULL
, (void *)(uintptr_t) foo
);
1095 if (needs_refresh
& REFRESH_WINDOW_FONT
) {
1096 foo
|= WFontSettings
;
1098 if (needs_refresh
& REFRESH_WINDOW_TEXTURES
) {
1099 foo
|= WTextureSettings
;
1101 if (needs_refresh
& REFRESH_WINDOW_TITLE_COLOR
) {
1102 foo
|= WColorSettings
;
1105 WMPostNotificationName(WNWindowAppearanceSettingsChanged
, NULL
, (void *)(uintptr_t) foo
);
1107 if (!(needs_refresh
& REFRESH_ICON_TILE
)) {
1109 if (needs_refresh
& REFRESH_ICON_FONT
) {
1110 foo
|= WFontSettings
;
1112 if (needs_refresh
& REFRESH_ICON_TITLE_COLOR
) {
1113 foo
|= WTextureSettings
;
1115 if (needs_refresh
& REFRESH_ICON_TITLE_BACK
) {
1116 foo
|= WTextureSettings
;
1119 WMPostNotificationName(WNIconAppearanceSettingsChanged
, NULL
,
1120 (void *)(uintptr_t) foo
);
1122 if (needs_refresh
& REFRESH_ICON_TILE
)
1123 WMPostNotificationName(WNIconTileSettingsChanged
, NULL
, NULL
);
1127 void wDefaultUpdateIcons(WScreen
* scr
)
1129 WAppIcon
*aicon
= scr
->app_icon_list
;
1130 WWindow
*wwin
= scr
->focused_window
;
1134 file
= wDefaultGetIconFile(scr
, aicon
->wm_instance
, aicon
->wm_class
, False
);
1135 if ((file
&& aicon
->icon
->file
&& strcmp(file
, aicon
->icon
->file
) != 0)
1136 || (file
&& !aicon
->icon
->file
)) {
1139 if (aicon
->icon
->file
)
1140 wfree(aicon
->icon
->file
);
1141 aicon
->icon
->file
= wstrdup(file
);
1143 new_image
= wDefaultGetImage(scr
, aicon
->wm_instance
, aicon
->wm_class
);
1145 wIconChangeImage(aicon
->icon
, new_image
);
1146 wAppIconPaint(aicon
);
1149 aicon
= aicon
->next
;
1152 if (!wPreferences
.flags
.noclip
)
1153 wClipIconPaint(scr
->clip_icon
);
1156 if (wwin
->icon
&& wwin
->flags
.miniaturized
) {
1157 file
= wDefaultGetIconFile(scr
, wwin
->wm_instance
, wwin
->wm_class
, False
);
1158 if ((file
&& wwin
->icon
->file
&& strcmp(file
, wwin
->icon
->file
) != 0)
1159 || (file
&& !wwin
->icon
->file
)) {
1162 if (wwin
->icon
->file
)
1163 wfree(wwin
->icon
->file
);
1164 wwin
->icon
->file
= wstrdup(file
);
1166 new_image
= wDefaultGetImage(scr
, wwin
->wm_instance
, wwin
->wm_class
);
1168 wIconChangeImage(wwin
->icon
, new_image
);
1175 /* --------------------------- Local ----------------------- */
1177 #define GET_STRING_OR_DEFAULT(x, var) if (!WMIsPLString(value)) { \
1178 wwarning(_("Wrong option format for key \"%s\". Should be %s."), \
1180 wwarning(_("using default \"%s\" instead"), entry->default_value); \
1181 var = entry->default_value;\
1182 } else var = WMGetFromPLString(value)\
1185 static int string2index(WMPropList * key, WMPropList * val, char *def, WOptionEnumeration * values)
1188 WOptionEnumeration
*v
;
1189 char buffer
[TOTAL_VALUES_LENGTH
];
1191 if (WMIsPLString(val
) && (str
= WMGetFromPLString(val
))) {
1192 for (v
= values
; v
->string
!= NULL
; v
++) {
1193 if (strcasecmp(v
->string
, str
) == 0)
1199 for (v
= values
; v
->string
!= NULL
; v
++) {
1202 strcat(buffer
, ", ");
1203 strcat(buffer
, v
->string
);
1206 wwarning(_("wrong option value for key \"%s\". Should be one of %s"), WMGetFromPLString(key
), buffer
);
1209 return string2index(key
, val
, NULL
, values
);
1216 * value - is the value in the defaults DB
1217 * addr - is the address to store the data
1218 * ret - is the address to store a pointer to a temporary buffer. ret
1219 * must not be freed and is used by the set functions
1221 static int getBool(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1225 int second_pass
= 0;
1227 GET_STRING_OR_DEFAULT("Boolean", val
);
1230 if ((val
[1] == '\0' && (val
[0] == 'y' || val
[0] == 'Y'))
1231 || strcasecmp(val
, "YES") == 0) {
1234 } else if ((val
[1] == '\0' && (val
[0] == 'n' || val
[0] == 'N'))
1235 || strcasecmp(val
, "NO") == 0) {
1239 if (sscanf(val
, "%i", &i
) == 1) {
1245 wwarning(_("can't convert \"%s\" to boolean for key \"%s\""), val
, entry
->key
);
1246 if (second_pass
== 0) {
1247 val
= WMGetFromPLString(entry
->plvalue
);
1249 wwarning(_("using default \"%s\" instead"), val
);
1259 *(char *)addr
= data
;
1264 static int getInt(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1269 GET_STRING_OR_DEFAULT("Integer", val
);
1271 if (sscanf(val
, "%i", &data
) != 1) {
1272 wwarning(_("can't convert \"%s\" to integer for key \"%s\""), val
, entry
->key
);
1273 val
= WMGetFromPLString(entry
->plvalue
);
1274 wwarning(_("using default \"%s\" instead"), val
);
1275 if (sscanf(val
, "%i", &data
) != 1) {
1283 *(int *)addr
= data
;
1288 static int getCoord(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1291 char *val_x
, *val_y
;
1292 int nelem
, changed
= 0;
1293 WMPropList
*elem_x
, *elem_y
;
1296 if (!WMIsPLArray(value
)) {
1297 wwarning(_("Wrong option format for key \"%s\". Should be %s."), entry
->key
, "Coordinate");
1299 value
= entry
->plvalue
;
1301 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1307 nelem
= WMGetPropListItemCount(value
);
1309 wwarning(_("Incorrect number of elements in array for key \"%s\"."), entry
->key
);
1311 value
= entry
->plvalue
;
1313 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1319 elem_x
= WMGetFromPLArray(value
, 0);
1320 elem_y
= WMGetFromPLArray(value
, 1);
1322 if (!elem_x
|| !elem_y
|| !WMIsPLString(elem_x
) || !WMIsPLString(elem_y
)) {
1323 wwarning(_("Wrong value for key \"%s\". Should be Coordinate."), entry
->key
);
1325 value
= entry
->plvalue
;
1327 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1333 val_x
= WMGetFromPLString(elem_x
);
1334 val_y
= WMGetFromPLString(elem_y
);
1336 if (sscanf(val_x
, "%i", &data
.x
) != 1 || sscanf(val_y
, "%i", &data
.y
) != 1) {
1337 wwarning(_("can't convert array to integers for \"%s\"."), entry
->key
);
1339 value
= entry
->plvalue
;
1341 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1349 else if (data
.x
> scr
->scr_width
/ 3)
1350 data
.x
= scr
->scr_width
/ 3;
1353 else if (data
.y
> scr
->scr_height
/ 3)
1354 data
.y
= scr
->scr_height
/ 3;
1359 *(WCoord
*) addr
= data
;
1364 static int getPropList(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1366 WMRetainPropList(value
);
1373 static int getPathList(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1382 if (!WMIsPLArray(value
)) {
1383 wwarning(_("Wrong option format for key \"%s\". Should be %s."), entry
->key
, "an array of paths");
1385 value
= entry
->plvalue
;
1387 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1394 count
= WMGetPropListItemCount(value
);
1397 value
= entry
->plvalue
;
1399 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1406 for (i
= 0; i
< count
; i
++) {
1407 d
= WMGetFromPLArray(value
, i
);
1408 if (!d
|| !WMIsPLString(d
)) {
1412 len
+= strlen(WMGetFromPLString(d
)) + 1;
1415 ptr
= data
= wmalloc(len
+ 1);
1417 for (i
= 0; i
< count
; i
++) {
1418 d
= WMGetFromPLArray(value
, i
);
1419 if (!d
|| !WMIsPLString(d
)) {
1422 strcpy(ptr
, WMGetFromPLString(d
));
1423 ptr
+= strlen(WMGetFromPLString(d
));
1430 if (*(char **)addr
!= NULL
) {
1431 wfree(*(char **)addr
);
1433 *(char **)addr
= data
;
1438 static int getEnum(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1440 static signed char data
;
1442 data
= string2index(entry
->plkey
, value
, entry
->default_value
, (WOptionEnumeration
*) entry
->extra_data
);
1449 *(signed char *)addr
= data
;
1456 * (hgradient <color> <color>)
1457 * (vgradient <color> <color>)
1458 * (dgradient <color> <color>)
1459 * (mhgradient <color> <color> ...)
1460 * (mvgradient <color> <color> ...)
1461 * (mdgradient <color> <color> ...)
1462 * (igradient <color1> <color1> <thickness1> <color2> <color2> <thickness2>)
1463 * (tpixmap <file> <color>)
1464 * (spixmap <file> <color>)
1465 * (cpixmap <file> <color>)
1466 * (thgradient <file> <opaqueness> <color> <color>)
1467 * (tvgradient <file> <opaqueness> <color> <color>)
1468 * (tdgradient <file> <opaqueness> <color> <color>)
1469 * (function <lib> <function> ...)
1472 static WTexture
*parse_texture(WScreen
* scr
, WMPropList
* pl
)
1477 WTexture
*texture
= NULL
;
1479 nelem
= WMGetPropListItemCount(pl
);
1483 elem
= WMGetFromPLArray(pl
, 0);
1484 if (!elem
|| !WMIsPLString(elem
))
1486 val
= WMGetFromPLString(elem
);
1488 if (strcasecmp(val
, "solid") == 0) {
1496 elem
= WMGetFromPLArray(pl
, 1);
1497 if (!elem
|| !WMIsPLString(elem
))
1499 val
= WMGetFromPLString(elem
);
1501 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &color
)) {
1502 wwarning(_("\"%s\" is not a valid color name"), val
);
1506 texture
= (WTexture
*) wTextureMakeSolid(scr
, &color
);
1507 } else if (strcasecmp(val
, "dgradient") == 0
1508 || strcasecmp(val
, "vgradient") == 0 || strcasecmp(val
, "hgradient") == 0) {
1509 RColor color1
, color2
;
1514 wwarning(_("bad number of arguments in gradient specification"));
1518 if (val
[0] == 'd' || val
[0] == 'D')
1519 type
= WTEX_DGRADIENT
;
1520 else if (val
[0] == 'h' || val
[0] == 'H')
1521 type
= WTEX_HGRADIENT
;
1523 type
= WTEX_VGRADIENT
;
1525 /* get from color */
1526 elem
= WMGetFromPLArray(pl
, 1);
1527 if (!elem
|| !WMIsPLString(elem
))
1529 val
= WMGetFromPLString(elem
);
1531 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1532 wwarning(_("\"%s\" is not a valid color name"), val
);
1536 color1
.red
= xcolor
.red
>> 8;
1537 color1
.green
= xcolor
.green
>> 8;
1538 color1
.blue
= xcolor
.blue
>> 8;
1541 elem
= WMGetFromPLArray(pl
, 2);
1542 if (!elem
|| !WMIsPLString(elem
)) {
1545 val
= WMGetFromPLString(elem
);
1547 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1548 wwarning(_("\"%s\" is not a valid color name"), val
);
1552 color2
.red
= xcolor
.red
>> 8;
1553 color2
.green
= xcolor
.green
>> 8;
1554 color2
.blue
= xcolor
.blue
>> 8;
1556 texture
= (WTexture
*) wTextureMakeGradient(scr
, type
, &color1
, &color2
);
1558 } else if (strcasecmp(val
, "igradient") == 0) {
1559 RColor colors1
[2], colors2
[2];
1565 wwarning(_("bad number of arguments in gradient specification"));
1569 /* get from color */
1570 for (i
= 0; i
< 2; i
++) {
1571 elem
= WMGetFromPLArray(pl
, 1 + i
);
1572 if (!elem
|| !WMIsPLString(elem
))
1574 val
= WMGetFromPLString(elem
);
1576 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1577 wwarning(_("\"%s\" is not a valid color name"), val
);
1580 colors1
[i
].alpha
= 255;
1581 colors1
[i
].red
= xcolor
.red
>> 8;
1582 colors1
[i
].green
= xcolor
.green
>> 8;
1583 colors1
[i
].blue
= xcolor
.blue
>> 8;
1585 elem
= WMGetFromPLArray(pl
, 3);
1586 if (!elem
|| !WMIsPLString(elem
))
1588 val
= WMGetFromPLString(elem
);
1591 /* get from color */
1592 for (i
= 0; i
< 2; i
++) {
1593 elem
= WMGetFromPLArray(pl
, 4 + i
);
1594 if (!elem
|| !WMIsPLString(elem
))
1596 val
= WMGetFromPLString(elem
);
1598 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1599 wwarning(_("\"%s\" is not a valid color name"), val
);
1602 colors2
[i
].alpha
= 255;
1603 colors2
[i
].red
= xcolor
.red
>> 8;
1604 colors2
[i
].green
= xcolor
.green
>> 8;
1605 colors2
[i
].blue
= xcolor
.blue
>> 8;
1607 elem
= WMGetFromPLArray(pl
, 6);
1608 if (!elem
|| !WMIsPLString(elem
))
1610 val
= WMGetFromPLString(elem
);
1613 texture
= (WTexture
*) wTextureMakeIGradient(scr
, th1
, colors1
, th2
, colors2
);
1615 } else if (strcasecmp(val
, "mhgradient") == 0
1616 || strcasecmp(val
, "mvgradient") == 0 || strcasecmp(val
, "mdgradient") == 0) {
1623 wwarning(_("too few arguments in multicolor gradient specification"));
1627 if (val
[1] == 'h' || val
[1] == 'H')
1628 type
= WTEX_MHGRADIENT
;
1629 else if (val
[1] == 'v' || val
[1] == 'V')
1630 type
= WTEX_MVGRADIENT
;
1632 type
= WTEX_MDGRADIENT
;
1636 colors
= wmalloc(sizeof(RColor
*) * (count
+ 1));
1638 for (i
= 0; i
< count
; i
++) {
1639 elem
= WMGetFromPLArray(pl
, i
+ 1);
1640 if (!elem
|| !WMIsPLString(elem
)) {
1641 for (--i
; i
>= 0; --i
) {
1647 val
= WMGetFromPLString(elem
);
1649 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &color
)) {
1650 wwarning(_("\"%s\" is not a valid color name"), val
);
1651 for (--i
; i
>= 0; --i
) {
1657 colors
[i
] = wmalloc(sizeof(RColor
));
1658 colors
[i
]->red
= color
.red
>> 8;
1659 colors
[i
]->green
= color
.green
>> 8;
1660 colors
[i
]->blue
= color
.blue
>> 8;
1665 texture
= (WTexture
*) wTextureMakeMGradient(scr
, type
, colors
);
1666 } else if (strcasecmp(val
, "spixmap") == 0 ||
1667 strcasecmp(val
, "cpixmap") == 0 || strcasecmp(val
, "tpixmap") == 0) {
1674 if (val
[0] == 's' || val
[0] == 'S')
1676 else if (val
[0] == 'c' || val
[0] == 'C')
1682 elem
= WMGetFromPLArray(pl
, 2);
1683 if (!elem
|| !WMIsPLString(elem
)) {
1686 val
= WMGetFromPLString(elem
);
1688 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &color
)) {
1689 wwarning(_("\"%s\" is not a valid color name"), val
);
1694 elem
= WMGetFromPLArray(pl
, 1);
1695 if (!elem
|| !WMIsPLString(elem
))
1697 val
= WMGetFromPLString(elem
);
1699 texture
= (WTexture
*) wTextureMakePixmap(scr
, type
, val
, &color
);
1700 } else if (strcasecmp(val
, "thgradient") == 0
1701 || strcasecmp(val
, "tvgradient") == 0 || strcasecmp(val
, "tdgradient") == 0) {
1702 RColor color1
, color2
;
1707 if (val
[1] == 'h' || val
[1] == 'H')
1708 style
= WTEX_THGRADIENT
;
1709 else if (val
[1] == 'v' || val
[1] == 'V')
1710 style
= WTEX_TVGRADIENT
;
1712 style
= WTEX_TDGRADIENT
;
1715 wwarning(_("bad number of arguments in textured gradient specification"));
1719 /* get from color */
1720 elem
= WMGetFromPLArray(pl
, 3);
1721 if (!elem
|| !WMIsPLString(elem
))
1723 val
= WMGetFromPLString(elem
);
1725 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1726 wwarning(_("\"%s\" is not a valid color name"), val
);
1730 color1
.red
= xcolor
.red
>> 8;
1731 color1
.green
= xcolor
.green
>> 8;
1732 color1
.blue
= xcolor
.blue
>> 8;
1735 elem
= WMGetFromPLArray(pl
, 4);
1736 if (!elem
|| !WMIsPLString(elem
)) {
1739 val
= WMGetFromPLString(elem
);
1741 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1742 wwarning(_("\"%s\" is not a valid color name"), val
);
1746 color2
.red
= xcolor
.red
>> 8;
1747 color2
.green
= xcolor
.green
>> 8;
1748 color2
.blue
= xcolor
.blue
>> 8;
1751 elem
= WMGetFromPLArray(pl
, 2);
1752 if (!elem
|| !WMIsPLString(elem
))
1755 val
= WMGetFromPLString(elem
);
1757 if (!val
|| (opacity
= atoi(val
)) < 0 || opacity
> 255) {
1758 wwarning(_("bad opacity value for tgradient texture \"%s\". Should be [0..255]"), val
);
1763 elem
= WMGetFromPLArray(pl
, 1);
1764 if (!elem
|| !WMIsPLString(elem
))
1766 val
= WMGetFromPLString(elem
);
1768 texture
= (WTexture
*) wTextureMakeTGradient(scr
, style
, &color1
, &color2
, val
, opacity
);
1769 } else if (strcasecmp(val
, "function") == 0) {
1770 /* Leave this in to handle the unlikely case of
1771 * someone actually having function textures configured */
1772 wwarning("function texture support has been removed");
1775 wwarning(_("invalid texture type %s"), val
);
1781 static int getTexture(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1783 static WTexture
*texture
;
1787 if (!WMIsPLArray(value
)) {
1788 wwarning(_("Wrong option format for key \"%s\". Should be %s."), entry
->key
, "Texture");
1790 value
= entry
->plvalue
;
1792 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1798 if (strcmp(entry
->key
, "WidgetColor") == 0 && !changed
) {
1801 pl
= WMGetFromPLArray(value
, 0);
1802 if (!pl
|| !WMIsPLString(pl
) || !WMGetFromPLString(pl
)
1803 || strcasecmp(WMGetFromPLString(pl
), "solid") != 0) {
1804 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1805 entry
->key
, "Solid Texture");
1807 value
= entry
->plvalue
;
1809 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1814 texture
= parse_texture(scr
, value
);
1817 wwarning(_("Error in texture specification for key \"%s\""), entry
->key
);
1819 value
= entry
->plvalue
;
1821 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1831 *(WTexture
**) addr
= texture
;
1836 static int getWSBackground(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1844 if (!WMIsPLArray(value
)) {
1845 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1846 "WorkspaceBack", "Texture or None");
1848 value
= entry
->plvalue
;
1850 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1856 /* only do basic error checking and verify for None texture */
1858 nelem
= WMGetPropListItemCount(value
);
1860 elem
= WMGetFromPLArray(value
, 0);
1861 if (!elem
|| !WMIsPLString(elem
)) {
1862 wwarning(_("Wrong type for workspace background. Should be a texture type."));
1864 value
= entry
->plvalue
;
1866 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1871 val
= WMGetFromPLString(elem
);
1873 if (strcasecmp(val
, "None") == 0)
1876 *ret
= WMRetainPropList(value
);
1882 getWSSpecificBackground(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1889 if (!WMIsPLArray(value
)) {
1890 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1891 "WorkspaceSpecificBack", "an array of textures");
1893 value
= entry
->plvalue
;
1895 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1901 /* only do basic error checking and verify for None texture */
1903 nelem
= WMGetPropListItemCount(value
);
1906 elem
= WMGetFromPLArray(value
, nelem
);
1907 if (!elem
|| !WMIsPLArray(elem
)) {
1908 wwarning(_("Wrong type for background of workspace %i. Should be a texture."),
1914 *ret
= WMRetainPropList(value
);
1918 * Kluge to force wmsetbg helper to set the default background.
1919 * If the WorkspaceSpecificBack is changed once wmaker has started,
1920 * the WorkspaceBack won't be sent to the helper, unless the user
1921 * changes it's value too. So, we must force this by removing the
1922 * value from the defaults DB.
1924 if (!scr
->flags
.backimage_helper_launched
&& !scr
->flags
.startup
) {
1925 WMPropList
*key
= WMCreatePLString("WorkspaceBack");
1927 WMRemoveFromPLDictionary(WDWindowMaker
->dictionary
, key
);
1929 WMReleasePropList(key
);
1935 static int getFont(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1937 static WMFont
*font
;
1940 GET_STRING_OR_DEFAULT("Font", val
);
1942 font
= WMCreateFont(scr
->wmscreen
, val
);
1944 font
= WMCreateFont(scr
->wmscreen
, "fixed");
1947 wfatal(_("could not load any usable font!!!"));
1954 /* can't assign font value outside update function */
1955 wassertrv(addr
== NULL
, True
);
1960 static int getColor(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1962 static XColor color
;
1964 int second_pass
= 0;
1966 GET_STRING_OR_DEFAULT("Color", val
);
1969 if (!wGetColor(scr
, val
, &color
)) {
1970 wwarning(_("could not get color for key \"%s\""), entry
->key
);
1971 if (second_pass
== 0) {
1972 val
= WMGetFromPLString(entry
->plvalue
);
1974 wwarning(_("using default \"%s\" instead"), val
);
1983 assert(addr
== NULL
);
1986 *(unsigned long*)addr = pixel;
1992 static int getKeybind(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1994 static WShortKey shortcut
;
1998 char buf
[MAX_SHORTCUT_LENGTH
], *b
;
2000 GET_STRING_OR_DEFAULT("Key spec", val
);
2002 if (!val
|| strcasecmp(val
, "NONE") == 0) {
2003 shortcut
.keycode
= 0;
2004 shortcut
.modifier
= 0;
2010 strncpy(buf
, val
, MAX_SHORTCUT_LENGTH
);
2015 shortcut
.modifier
= 0;
2016 while ((k
= strchr(b
, '+')) != NULL
) {
2020 mod
= wXModifierFromKey(b
);
2022 wwarning(_("%s: invalid key modifier \"%s\""), entry
->key
, b
);
2025 shortcut
.modifier
|= mod
;
2031 ksym
= XStringToKeysym(b
);
2033 if (ksym
== NoSymbol
) {
2034 wwarning(_("%s:invalid kbd shortcut specification \"%s\""), entry
->key
, val
);
2038 shortcut
.keycode
= XKeysymToKeycode(dpy
, ksym
);
2039 if (shortcut
.keycode
== 0) {
2040 wwarning(_("%s:invalid key in shortcut \"%s\""), entry
->key
, val
);
2050 static int getModMask(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
2055 GET_STRING_OR_DEFAULT("Modifier Key", str
);
2060 mask
= wXModifierFromKey(str
);
2062 wwarning(_("%s: modifier key %s is not valid"), entry
->key
, str
);
2068 *(int *)addr
= mask
;
2076 # include <X11/cursorfont.h>
2082 #define CURSOR_ID_NONE (XC_num_glyphs)
2084 static WCursorLookup cursor_table
[] = {
2085 {"X_cursor", XC_X_cursor
},
2086 {"arrow", XC_arrow
},
2087 {"based_arrow_down", XC_based_arrow_down
},
2088 {"based_arrow_up", XC_based_arrow_up
},
2090 {"bogosity", XC_bogosity
},
2091 {"bottom_left_corner", XC_bottom_left_corner
},
2092 {"bottom_right_corner", XC_bottom_right_corner
},
2093 {"bottom_side", XC_bottom_side
},
2094 {"bottom_tee", XC_bottom_tee
},
2095 {"box_spiral", XC_box_spiral
},
2096 {"center_ptr", XC_center_ptr
},
2097 {"circle", XC_circle
},
2098 {"clock", XC_clock
},
2099 {"coffee_mug", XC_coffee_mug
},
2100 {"cross", XC_cross
},
2101 {"cross_reverse", XC_cross_reverse
},
2102 {"crosshair", XC_crosshair
},
2103 {"diamond_cross", XC_diamond_cross
},
2105 {"dotbox", XC_dotbox
},
2106 {"double_arrow", XC_double_arrow
},
2107 {"draft_large", XC_draft_large
},
2108 {"draft_small", XC_draft_small
},
2109 {"draped_box", XC_draped_box
},
2110 {"exchange", XC_exchange
},
2111 {"fleur", XC_fleur
},
2112 {"gobbler", XC_gobbler
},
2113 {"gumby", XC_gumby
},
2114 {"hand1", XC_hand1
},
2115 {"hand2", XC_hand2
},
2116 {"heart", XC_heart
},
2118 {"iron_cross", XC_iron_cross
},
2119 {"left_ptr", XC_left_ptr
},
2120 {"left_side", XC_left_side
},
2121 {"left_tee", XC_left_tee
},
2122 {"leftbutton", XC_leftbutton
},
2123 {"ll_angle", XC_ll_angle
},
2124 {"lr_angle", XC_lr_angle
},
2126 {"middlebutton", XC_middlebutton
},
2127 {"mouse", XC_mouse
},
2128 {"pencil", XC_pencil
},
2129 {"pirate", XC_pirate
},
2131 {"question_arrow", XC_question_arrow
},
2132 {"right_ptr", XC_right_ptr
},
2133 {"right_side", XC_right_side
},
2134 {"right_tee", XC_right_tee
},
2135 {"rightbutton", XC_rightbutton
},
2136 {"rtl_logo", XC_rtl_logo
},
2137 {"sailboat", XC_sailboat
},
2138 {"sb_down_arrow", XC_sb_down_arrow
},
2139 {"sb_h_double_arrow", XC_sb_h_double_arrow
},
2140 {"sb_left_arrow", XC_sb_left_arrow
},
2141 {"sb_right_arrow", XC_sb_right_arrow
},
2142 {"sb_up_arrow", XC_sb_up_arrow
},
2143 {"sb_v_double_arrow", XC_sb_v_double_arrow
},
2144 {"shuttle", XC_shuttle
},
2145 {"sizing", XC_sizing
},
2146 {"spider", XC_spider
},
2147 {"spraycan", XC_spraycan
},
2149 {"target", XC_target
},
2150 {"tcross", XC_tcross
},
2151 {"top_left_arrow", XC_top_left_arrow
},
2152 {"top_left_corner", XC_top_left_corner
},
2153 {"top_right_corner", XC_top_right_corner
},
2154 {"top_side", XC_top_side
},
2155 {"top_tee", XC_top_tee
},
2157 {"ul_angle", XC_ul_angle
},
2158 {"umbrella", XC_umbrella
},
2159 {"ur_angle", XC_ur_angle
},
2160 {"watch", XC_watch
},
2161 {"xterm", XC_xterm
},
2162 {NULL
, CURSOR_ID_NONE
}
2165 static void check_bitmap_status(int status
, char *filename
, Pixmap bitmap
)
2168 case BitmapOpenFailed
:
2169 wwarning(_("failed to open bitmap file \"%s\""), filename
);
2171 case BitmapFileInvalid
:
2172 wwarning(_("\"%s\" is not a valid bitmap file"), filename
);
2174 case BitmapNoMemory
:
2175 wwarning(_("out of memory reading bitmap file \"%s\""), filename
);
2178 XFreePixmap(dpy
, bitmap
);
2185 * (builtin, <cursor_name>)
2186 * (bitmap, <cursor_bitmap>, <cursor_mask>)
2188 static int parse_cursor(WScreen
* scr
, WMPropList
* pl
, Cursor
* cursor
)
2195 nelem
= WMGetPropListItemCount(pl
);
2199 elem
= WMGetFromPLArray(pl
, 0);
2200 if (!elem
|| !WMIsPLString(elem
)) {
2203 val
= WMGetFromPLString(elem
);
2205 if (strcasecmp(val
, "none") == 0) {
2208 } else if (strcasecmp(val
, "builtin") == 0) {
2210 int cursor_id
= CURSOR_ID_NONE
;
2213 wwarning(_("bad number of arguments in cursor specification"));
2216 elem
= WMGetFromPLArray(pl
, 1);
2217 if (!elem
|| !WMIsPLString(elem
)) {
2220 val
= WMGetFromPLString(elem
);
2222 for (i
= 0; cursor_table
[i
].name
!= NULL
; i
++) {
2223 if (strcasecmp(val
, cursor_table
[i
].name
) == 0) {
2224 cursor_id
= cursor_table
[i
].id
;
2228 if (CURSOR_ID_NONE
== cursor_id
) {
2229 wwarning(_("unknown builtin cursor name \"%s\""), val
);
2231 *cursor
= XCreateFontCursor(dpy
, cursor_id
);
2234 } else if (strcasecmp(val
, "bitmap") == 0) {
2246 wwarning(_("bad number of arguments in cursor specification"));
2249 elem
= WMGetFromPLArray(pl
, 1);
2250 if (!elem
|| !WMIsPLString(elem
)) {
2253 val
= WMGetFromPLString(elem
);
2254 bitmap_name
= FindImage(wPreferences
.pixmap_path
, val
);
2256 wwarning(_("could not find cursor bitmap file \"%s\""), val
);
2259 elem
= WMGetFromPLArray(pl
, 2);
2260 if (!elem
|| !WMIsPLString(elem
)) {
2264 val
= WMGetFromPLString(elem
);
2265 mask_name
= FindImage(wPreferences
.pixmap_path
, val
);
2268 wwarning(_("could not find cursor bitmap file \"%s\""), val
);
2271 mask_status
= XReadBitmapFile(dpy
, scr
->w_win
, mask_name
, &w
, &h
, &mask
, &x
, &y
);
2272 bitmap_status
= XReadBitmapFile(dpy
, scr
->w_win
, bitmap_name
, &w
, &h
, &bitmap
, &x
, &y
);
2273 if ((BitmapSuccess
== bitmap_status
) && (BitmapSuccess
== mask_status
)) {
2274 fg
.pixel
= scr
->black_pixel
;
2275 bg
.pixel
= scr
->white_pixel
;
2276 XQueryColor(dpy
, scr
->w_colormap
, &fg
);
2277 XQueryColor(dpy
, scr
->w_colormap
, &bg
);
2278 *cursor
= XCreatePixmapCursor(dpy
, bitmap
, mask
, &fg
, &bg
, x
, y
);
2281 check_bitmap_status(bitmap_status
, bitmap_name
, bitmap
);
2282 check_bitmap_status(mask_status
, mask_name
, mask
);
2289 static int getCursor(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
2291 static Cursor cursor
;
2296 if (!WMIsPLArray(value
)) {
2297 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
2298 entry
->key
, "cursor specification");
2300 value
= entry
->plvalue
;
2302 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
2307 status
= parse_cursor(scr
, value
, &cursor
);
2309 wwarning(_("Error in cursor specification for key \"%s\""), entry
->key
);
2311 value
= entry
->plvalue
;
2313 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
2322 *(Cursor
*) addr
= cursor
;
2327 #undef CURSOR_ID_NONE
2329 /* ---------------- value setting functions --------------- */
2330 static int setJustify(WScreen
* scr
, WDefaultEntry
* entry
, WTexture
** texture
, void *foo
)
2332 return REFRESH_WINDOW_TITLE_COLOR
;
2335 static int setClearance(WScreen
* scr
, WDefaultEntry
* entry
, void *bar
, void *foo
)
2337 return REFRESH_WINDOW_FONT
| REFRESH_BUTTON_IMAGES
| REFRESH_MENU_TITLE_FONT
| REFRESH_MENU_FONT
;
2340 static int setIfDockPresent(WScreen
* scr
, WDefaultEntry
* entry
, char *flag
, long which
)
2344 wPreferences
.flags
.nodock
= wPreferences
.flags
.nodock
|| *flag
;
2347 wPreferences
.flags
.noclip
= wPreferences
.flags
.noclip
|| *flag
;
2355 static int setStickyIcons(WScreen
* scr
, WDefaultEntry
* entry
, void *bar
, void *foo
)
2357 if (scr
->workspaces
) {
2358 wWorkspaceForceChange(scr
, scr
->current_workspace
);
2359 wArrangeIcons(scr
, False
);
2364 static int setIconTile(WScreen
* scr
, WDefaultEntry
* entry
, WTexture
** texture
, void *foo
)
2370 img
= wTextureRenderImage(*texture
, wPreferences
.icon_size
,
2371 wPreferences
.icon_size
, ((*texture
)->any
.type
& WREL_BORDER_MASK
)
2372 ? WREL_ICON
: WREL_FLAT
);
2374 wwarning(_("could not render texture for icon background"));
2376 wTextureDestroy(scr
, *texture
);
2379 RConvertImage(scr
->rcontext
, img
, &pixmap
);
2381 if (scr
->icon_tile
) {
2383 RReleaseImage(scr
->icon_tile
);
2384 XFreePixmap(dpy
, scr
->icon_tile_pixmap
);
2387 scr
->icon_tile
= img
;
2389 /* put the icon in the noticeboard hint */
2390 PropSetIconTileHint(scr
, img
);
2392 if (!wPreferences
.flags
.noclip
) {
2393 if (scr
->clip_tile
) {
2394 RReleaseImage(scr
->clip_tile
);
2396 scr
->clip_tile
= wClipMakeTile(scr
, img
);
2399 scr
->icon_tile_pixmap
= pixmap
;
2401 if (scr
->def_icon_pixmap
) {
2402 XFreePixmap(dpy
, scr
->def_icon_pixmap
);
2403 scr
->def_icon_pixmap
= None
;
2405 if (scr
->def_ticon_pixmap
) {
2406 XFreePixmap(dpy
, scr
->def_ticon_pixmap
);
2407 scr
->def_ticon_pixmap
= None
;
2410 if (scr
->icon_back_texture
) {
2411 wTextureDestroy(scr
, (WTexture
*) scr
->icon_back_texture
);
2413 scr
->icon_back_texture
= wTextureMakeSolid(scr
, &((*texture
)->any
.color
));
2415 if (scr
->clip_balloon
)
2416 XSetWindowBackground(dpy
, scr
->clip_balloon
, (*texture
)->any
.color
.pixel
);
2419 * Free the texture as nobody else will use it, nor refer to it.
2422 wTextureDestroy(scr
, *texture
);
2424 return (reset
? REFRESH_ICON_TILE
: 0);
2427 static int setWinTitleFont(WScreen
* scr
, WDefaultEntry
* entry
, WMFont
* font
, void *foo
)
2429 if (scr
->title_font
) {
2430 WMReleaseFont(scr
->title_font
);
2432 scr
->title_font
= font
;
2434 return REFRESH_WINDOW_FONT
| REFRESH_BUTTON_IMAGES
;
2437 static int setMenuTitleFont(WScreen
* scr
, WDefaultEntry
* entry
, WMFont
* font
, void *foo
)
2439 if (scr
->menu_title_font
) {
2440 WMReleaseFont(scr
->menu_title_font
);
2443 scr
->menu_title_font
= font
;
2445 return REFRESH_MENU_TITLE_FONT
;
2448 static int setMenuTextFont(WScreen
* scr
, WDefaultEntry
* entry
, WMFont
* font
, void *foo
)
2450 if (scr
->menu_entry_font
) {
2451 WMReleaseFont(scr
->menu_entry_font
);
2453 scr
->menu_entry_font
= font
;
2455 return REFRESH_MENU_FONT
;
2458 static int setIconTitleFont(WScreen
* scr
, WDefaultEntry
* entry
, WMFont
* font
, void *foo
)
2460 if (scr
->icon_title_font
) {
2461 WMReleaseFont(scr
->icon_title_font
);
2464 scr
->icon_title_font
= font
;
2466 return REFRESH_ICON_FONT
;
2469 static int setClipTitleFont(WScreen
* scr
, WDefaultEntry
* entry
, WMFont
* font
, void *foo
)
2471 if (scr
->clip_title_font
) {
2472 WMReleaseFont(scr
->clip_title_font
);
2475 scr
->clip_title_font
= font
;
2477 return REFRESH_ICON_FONT
;
2480 static int setLargeDisplayFont(WScreen
* scr
, WDefaultEntry
* entry
, WMFont
* font
, void *foo
)
2482 if (scr
->workspace_name_font
) {
2483 WMReleaseFont(scr
->workspace_name_font
);
2486 scr
->workspace_name_font
= font
;
2491 static int setHightlight(WScreen
* scr
, WDefaultEntry
* entry
, XColor
* color
, void *foo
)
2493 if (scr
->select_color
)
2494 WMReleaseColor(scr
->select_color
);
2496 scr
->select_color
= WMCreateRGBColor(scr
->wmscreen
, color
->red
, color
->green
, color
->blue
, True
);
2498 wFreeColor(scr
, color
->pixel
);
2500 return REFRESH_MENU_COLOR
;
2503 static int setHightlightText(WScreen
* scr
, WDefaultEntry
* entry
, XColor
* color
, void *foo
)
2505 if (scr
->select_text_color
)
2506 WMReleaseColor(scr
->select_text_color
);
2508 scr
->select_text_color
= WMCreateRGBColor(scr
->wmscreen
, color
->red
, color
->green
, color
->blue
, True
);
2510 wFreeColor(scr
, color
->pixel
);
2512 return REFRESH_MENU_COLOR
;
2515 static int setClipTitleColor(WScreen
* scr
, WDefaultEntry
* entry
, XColor
* color
, long widx
)
2517 if (scr
->clip_title_color
[widx
])
2518 WMReleaseColor(scr
->clip_title_color
[widx
]);
2519 scr
->clip_title_color
[widx
] = WMCreateRGBColor(scr
->wmscreen
, color
->red
, color
->green
, color
->blue
, True
);
2520 #ifdef GRADIENT_CLIP_ARROW
2521 if (widx
== CLIP_NORMAL
) {
2523 RColor color1
, color2
;
2524 int pt
= CLIP_BUTTON_SIZE
* wPreferences
.icon_size
/ 64;
2525 int as
= pt
- 15; /* 15 = 5+5+5 */
2527 FREE_PIXMAP(scr
->clip_arrow_gradient
);
2529 color1
.red
= (color
->red
>> 8) * 6 / 10;
2530 color1
.green
= (color
->green
>> 8) * 6 / 10;
2531 color1
.blue
= (color
->blue
>> 8) * 6 / 10;
2533 color2
.red
= WMIN((color
->red
>> 8) * 20 / 10, 255);
2534 color2
.green
= WMIN((color
->green
>> 8) * 20 / 10, 255);
2535 color2
.blue
= WMIN((color
->blue
>> 8) * 20 / 10, 255);
2537 image
= RRenderGradient(as
+ 1, as
+ 1, &color1
, &color2
, RDiagonalGradient
);
2538 RConvertImage(scr
->rcontext
, image
, &scr
->clip_arrow_gradient
);
2539 RReleaseImage(image
);
2541 #endif /* GRADIENT_CLIP_ARROW */
2543 wFreeColor(scr
, color
->pixel
);
2545 return REFRESH_ICON_TITLE_COLOR
;
2548 static int setWTitleColor(WScreen
* scr
, WDefaultEntry
* entry
, XColor
* color
, long widx
)
2550 if (scr
->window_title_color
[widx
])
2551 WMReleaseColor(scr
->window_title_color
[widx
]);
2553 scr
->window_title_color
[widx
] =
2554 WMCreateRGBColor(scr
->wmscreen
, color
->red
, color
->green
, color
->blue
, True
);
2556 wFreeColor(scr
, color
->pixel
);
2558 return REFRESH_WINDOW_TITLE_COLOR
;
2561 static int setMenuTitleColor(WScreen
* scr
, WDefaultEntry
* entry
, XColor
* color
, long widx
)
2563 if (scr
->menu_title_color
[0])
2564 WMReleaseColor(scr
->menu_title_color
[0]);
2566 scr
->menu_title_color
[0] = WMCreateRGBColor(scr
->wmscreen
, color
->red
, color
->green
, color
->blue
, True
);
2568 wFreeColor(scr
, color
->pixel
);
2570 return REFRESH_MENU_TITLE_COLOR
;
2573 static int setMenuTextColor(WScreen
* scr
, WDefaultEntry
* entry
, XColor
* color
, void *foo
)
2575 if (scr
->mtext_color
)
2576 WMReleaseColor(scr
->mtext_color
);
2578 scr
->mtext_color
= WMCreateRGBColor(scr
->wmscreen
, color
->red
, color
->green
, color
->blue
, True
);
2580 if (WMColorPixel(scr
->dtext_color
) == WMColorPixel(scr
->mtext_color
)) {
2581 WMSetColorAlpha(scr
->dtext_color
, 0x7fff);
2583 WMSetColorAlpha(scr
->dtext_color
, 0xffff);
2586 wFreeColor(scr
, color
->pixel
);
2588 return REFRESH_MENU_COLOR
;
2591 static int setMenuDisabledColor(WScreen
* scr
, WDefaultEntry
* entry
, XColor
* color
, void *foo
)
2593 if (scr
->dtext_color
)
2594 WMReleaseColor(scr
->dtext_color
);
2596 scr
->dtext_color
= WMCreateRGBColor(scr
->wmscreen
, color
->red
, color
->green
, color
->blue
, True
);
2598 if (WMColorPixel(scr
->dtext_color
) == WMColorPixel(scr
->mtext_color
)) {
2599 WMSetColorAlpha(scr
->dtext_color
, 0x7fff);
2601 WMSetColorAlpha(scr
->dtext_color
, 0xffff);
2604 wFreeColor(scr
, color
->pixel
);
2606 return REFRESH_MENU_COLOR
;
2609 static int setIconTitleColor(WScreen
* scr
, WDefaultEntry
* entry
, XColor
* color
, void *foo
)
2611 if (scr
->icon_title_color
)
2612 WMReleaseColor(scr
->icon_title_color
);
2613 scr
->icon_title_color
= WMCreateRGBColor(scr
->wmscreen
, color
->red
, color
->green
, color
->blue
, True
);
2615 wFreeColor(scr
, color
->pixel
);
2617 return REFRESH_ICON_TITLE_COLOR
;
2620 static int setIconTitleBack(WScreen
* scr
, WDefaultEntry
* entry
, XColor
* color
, void *foo
)
2622 if (scr
->icon_title_texture
) {
2623 wTextureDestroy(scr
, (WTexture
*) scr
->icon_title_texture
);
2625 scr
->icon_title_texture
= wTextureMakeSolid(scr
, color
);
2627 return REFRESH_ICON_TITLE_BACK
;
2630 static void trackDeadProcess(pid_t pid
, unsigned char status
, WScreen
* scr
)
2632 close(scr
->helper_fd
);
2634 scr
->helper_pid
= 0;
2635 scr
->flags
.backimage_helper_launched
= 0;
2638 static int setWorkspaceSpecificBack(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *bar
)
2644 if (scr
->flags
.backimage_helper_launched
) {
2645 if (WMGetPropListItemCount(value
) == 0) {
2646 SendHelperMessage(scr
, 'C', 0, NULL
);
2647 SendHelperMessage(scr
, 'K', 0, NULL
);
2649 WMReleasePropList(value
);
2656 if (WMGetPropListItemCount(value
) == 0)
2659 if (pipe(filedes
) < 0) {
2660 wsyserror("pipe() failed:can't set workspace specific background image");
2662 WMReleasePropList(value
);
2668 wsyserror("fork() failed:can't set workspace specific background image");
2669 if (close(filedes
[0]) < 0)
2670 wsyserror("could not close pipe");
2671 if (close(filedes
[1]) < 0)
2672 wsyserror("could not close pipe");
2674 } else if (pid
== 0) {
2677 SetupEnvironment(scr
);
2680 wsyserror("could not close pipe");
2681 if (dup(filedes
[0]) < 0) {
2682 wsyserror("dup() failed:can't set workspace specific background image");
2684 dither
= wPreferences
.no_dithering
? "-m" : "-d";
2685 if (wPreferences
.smooth_workspace_back
)
2686 execlp("wmsetbg", "wmsetbg", "-helper", "-S", dither
, NULL
);
2688 execlp("wmsetbg", "wmsetbg", "-helper", dither
, NULL
);
2689 wsyserror("could not execute wmsetbg");
2693 if (fcntl(filedes
[0], F_SETFD
, FD_CLOEXEC
) < 0) {
2694 wsyserror("error setting close-on-exec flag");
2696 if (fcntl(filedes
[1], F_SETFD
, FD_CLOEXEC
) < 0) {
2697 wsyserror("error setting close-on-exec flag");
2700 scr
->helper_fd
= filedes
[1];
2701 scr
->helper_pid
= pid
;
2702 scr
->flags
.backimage_helper_launched
= 1;
2704 wAddDeathHandler(pid
, (WDeathHandler
*) trackDeadProcess
, scr
);
2706 SendHelperMessage(scr
, 'P', -1, wPreferences
.pixmap_path
);
2711 for (i
= 0; i
< WMGetPropListItemCount(value
); i
++) {
2712 val
= WMGetFromPLArray(value
, i
);
2713 if (val
&& WMIsPLArray(val
) && WMGetPropListItemCount(val
) > 0) {
2714 str
= WMGetPropListDescription(val
, False
);
2716 SendHelperMessage(scr
, 'S', i
+ 1, str
);
2720 SendHelperMessage(scr
, 'U', i
+ 1, NULL
);
2725 WMReleasePropList(value
);
2729 static int setWorkspaceBack(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *bar
)
2731 if (scr
->flags
.backimage_helper_launched
) {
2734 if (WMGetPropListItemCount(value
) == 0) {
2735 SendHelperMessage(scr
, 'U', 0, NULL
);
2737 /* set the default workspace background to this one */
2738 str
= WMGetPropListDescription(value
, False
);
2740 SendHelperMessage(scr
, 'S', 0, str
);
2742 SendHelperMessage(scr
, 'C', scr
->current_workspace
+ 1, NULL
);
2744 SendHelperMessage(scr
, 'U', 0, NULL
);
2747 } else if (WMGetPropListItemCount(value
) > 0) {
2753 text
= WMGetPropListDescription(value
, False
);
2754 len
= strlen(text
) + 40;
2755 command
= wmalloc(len
);
2756 dither
= wPreferences
.no_dithering
? "-m" : "-d";
2757 if (wPreferences
.smooth_workspace_back
)
2758 snprintf(command
, len
, "wmsetbg %s -S -p '%s' &", dither
, text
);
2760 snprintf(command
, len
, "wmsetbg %s -p '%s' &", dither
, text
);
2762 ExecuteShellCommand(scr
, command
);
2765 WMReleasePropList(value
);
2770 static int setWidgetColor(WScreen
* scr
, WDefaultEntry
* entry
, WTexture
** texture
, void *foo
)
2772 if (scr
->widget_texture
) {
2773 wTextureDestroy(scr
, (WTexture
*) scr
->widget_texture
);
2775 scr
->widget_texture
= *(WTexSolid
**) texture
;
2780 static int setFTitleBack(WScreen
* scr
, WDefaultEntry
* entry
, WTexture
** texture
, void *foo
)
2782 if (scr
->window_title_texture
[WS_FOCUSED
]) {
2783 wTextureDestroy(scr
, scr
->window_title_texture
[WS_FOCUSED
]);
2785 scr
->window_title_texture
[WS_FOCUSED
] = *texture
;
2787 return REFRESH_WINDOW_TEXTURES
;
2790 static int setPTitleBack(WScreen
* scr
, WDefaultEntry
* entry
, WTexture
** texture
, void *foo
)
2792 if (scr
->window_title_texture
[WS_PFOCUSED
]) {
2793 wTextureDestroy(scr
, scr
->window_title_texture
[WS_PFOCUSED
]);
2795 scr
->window_title_texture
[WS_PFOCUSED
] = *texture
;
2797 return REFRESH_WINDOW_TEXTURES
;
2800 static int setUTitleBack(WScreen
* scr
, WDefaultEntry
* entry
, WTexture
** texture
, void *foo
)
2802 if (scr
->window_title_texture
[WS_UNFOCUSED
]) {
2803 wTextureDestroy(scr
, scr
->window_title_texture
[WS_UNFOCUSED
]);
2805 scr
->window_title_texture
[WS_UNFOCUSED
] = *texture
;
2807 return REFRESH_WINDOW_TEXTURES
;
2810 static int setResizebarBack(WScreen
* scr
, WDefaultEntry
* entry
, WTexture
** texture
, void *foo
)
2812 if (scr
->resizebar_texture
[0]) {
2813 wTextureDestroy(scr
, scr
->resizebar_texture
[0]);
2815 scr
->resizebar_texture
[0] = *texture
;
2817 return REFRESH_WINDOW_TEXTURES
;
2820 static int setMenuTitleBack(WScreen
* scr
, WDefaultEntry
* entry
, WTexture
** texture
, void *foo
)
2822 if (scr
->menu_title_texture
[0]) {
2823 wTextureDestroy(scr
, scr
->menu_title_texture
[0]);
2825 scr
->menu_title_texture
[0] = *texture
;
2827 return REFRESH_MENU_TITLE_TEXTURE
;
2830 static int setMenuTextBack(WScreen
* scr
, WDefaultEntry
* entry
, WTexture
** texture
, void *foo
)
2832 if (scr
->menu_item_texture
) {
2833 wTextureDestroy(scr
, scr
->menu_item_texture
);
2834 wTextureDestroy(scr
, (WTexture
*) scr
->menu_item_auxtexture
);
2836 scr
->menu_item_texture
= *texture
;
2838 scr
->menu_item_auxtexture
= wTextureMakeSolid(scr
, &scr
->menu_item_texture
->any
.color
);
2840 return REFRESH_MENU_TEXTURE
;
2843 static int setKeyGrab(WScreen
* scr
, WDefaultEntry
* entry
, WShortKey
* shortcut
, long widx
)
2846 wKeyBindings
[widx
] = *shortcut
;
2848 wwin
= scr
->focused_window
;
2850 while (wwin
!= NULL
) {
2851 XUngrabKey(dpy
, AnyKey
, AnyModifier
, wwin
->frame
->core
->window
);
2853 if (!WFLAGP(wwin
, no_bind_keys
)) {
2854 wWindowSetKeyGrabs(wwin
);
2862 static int setIconPosition(WScreen
* scr
, WDefaultEntry
* entry
, void *bar
, void *foo
)
2864 wScreenUpdateUsableArea(scr
);
2865 wArrangeIcons(scr
, True
);
2870 static int updateUsableArea(WScreen
* scr
, WDefaultEntry
* entry
, void *bar
, void *foo
)
2872 wScreenUpdateUsableArea(scr
);
2877 static int setMenuStyle(WScreen
* scr
, WDefaultEntry
* entry
, int *value
, void *foo
)
2879 return REFRESH_MENU_TEXTURE
;
2882 static RImage
*chopOffImage(RImage
* image
, int x
, int y
, int w
, int h
)
2884 RImage
*img
= RCreateImage(w
, h
, image
->format
== RRGBAFormat
);
2886 RCopyArea(img
, image
, x
, y
, w
, h
, 0, 0);
2891 static int setSwPOptions(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* array
, void *foo
)
2895 int cwidth
, cheight
;
2896 WPreferences
*prefs
= (WPreferences
*) foo
;
2898 if (!WMIsPLArray(array
) || WMGetPropListItemCount(array
) == 0) {
2899 if (prefs
->swtileImage
)
2900 RReleaseImage(prefs
->swtileImage
);
2901 prefs
->swtileImage
= NULL
;
2903 WMReleasePropList(array
);
2907 switch (WMGetPropListItemCount(array
)) {
2909 if (!WMIsPLString(WMGetFromPLArray(array
, 1))) {
2910 wwarning(_("Invalid arguments for option \"%s\""), entry
->key
);
2913 path
= FindImage(wPreferences
.pixmap_path
, WMGetFromPLString(WMGetFromPLArray(array
, 1)));
2916 wwarning(_("Could not find image \"%s\" for option \"%s\""),
2917 WMGetFromPLString(WMGetFromPLArray(array
, 1)), entry
->key
);
2919 bgimage
= RLoadImage(scr
->rcontext
, path
, 0);
2921 wwarning(_("Could not load image \"%s\" for option \"%s\""), path
, entry
->key
);
2926 cwidth
= atoi(WMGetFromPLString(WMGetFromPLArray(array
, 2)));
2927 cheight
= atoi(WMGetFromPLString(WMGetFromPLArray(array
, 3)));
2929 if (cwidth
<= 0 || cheight
<= 0 ||
2930 cwidth
>= bgimage
->width
- 2 || cheight
>= bgimage
->height
- 2)
2931 wwarning(_("Invalid split sizes for SwitchPanel back image."));
2934 int swidth
, theight
;
2935 for (i
= 0; i
< 9; i
++) {
2936 if (prefs
->swbackImage
[i
])
2937 RReleaseImage(prefs
->swbackImage
[i
]);
2938 prefs
->swbackImage
[i
] = NULL
;
2940 swidth
= (bgimage
->width
- cwidth
) / 2;
2941 theight
= (bgimage
->height
- cheight
) / 2;
2943 prefs
->swbackImage
[0] = chopOffImage(bgimage
, 0, 0, swidth
, theight
);
2944 prefs
->swbackImage
[1] = chopOffImage(bgimage
, swidth
, 0, cwidth
, theight
);
2945 prefs
->swbackImage
[2] = chopOffImage(bgimage
, swidth
+ cwidth
, 0,
2948 prefs
->swbackImage
[3] = chopOffImage(bgimage
, 0, theight
, swidth
, cheight
);
2949 prefs
->swbackImage
[4] = chopOffImage(bgimage
, swidth
, theight
,
2951 prefs
->swbackImage
[5] = chopOffImage(bgimage
, swidth
+ cwidth
, theight
,
2954 prefs
->swbackImage
[6] = chopOffImage(bgimage
, 0, theight
+ cheight
,
2956 prefs
->swbackImage
[7] = chopOffImage(bgimage
, swidth
, theight
+ cheight
,
2958 prefs
->swbackImage
[8] =
2959 chopOffImage(bgimage
, swidth
+ cwidth
, theight
+ cheight
, swidth
,
2962 // check if anything failed
2963 for (i
= 0; i
< 9; i
++) {
2964 if (!prefs
->swbackImage
[i
]) {
2965 for (; i
>= 0; --i
) {
2966 RReleaseImage(prefs
->swbackImage
[i
]);
2967 prefs
->swbackImage
[i
] = NULL
;
2973 RReleaseImage(bgimage
);
2978 if (!WMIsPLString(WMGetFromPLArray(array
, 0))) {
2979 wwarning(_("Invalid arguments for option \"%s\""), entry
->key
);
2982 path
= FindImage(wPreferences
.pixmap_path
, WMGetFromPLString(WMGetFromPLArray(array
, 0)));
2985 wwarning(_("Could not find image \"%s\" for option \"%s\""),
2986 WMGetFromPLString(WMGetFromPLArray(array
, 0)), entry
->key
);
2988 if (prefs
->swtileImage
)
2989 RReleaseImage(prefs
->swtileImage
);
2991 prefs
->swtileImage
= RLoadImage(scr
->rcontext
, path
, 0);
2992 if (!prefs
->swtileImage
) {
2993 wwarning(_("Could not load image \"%s\" for option \"%s\""), path
, entry
->key
);
3000 wwarning(_("Invalid number of arguments for option \"%s\""), entry
->key
);
3004 WMReleasePropList(array
);
3011 * Need access to the double click variables, so that all widgets in
3012 * wmaker panels will have the same dbl-click values.
3013 * TODO: figure a better way of dealing with it.
3015 #include <WINGs/WINGsP.h>
3017 static int setDoubleClick(WScreen
* scr
, WDefaultEntry
* entry
, int *value
, void *foo
)
3019 extern _WINGsConfiguration WINGsConfiguration
;
3024 WINGsConfiguration
.doubleClickDelay
= *value
;
3029 static int setCursor(WScreen
* scr
, WDefaultEntry
* entry
, Cursor
* cursor
, long widx
)
3031 if (wCursor
[widx
] != None
) {
3032 XFreeCursor(dpy
, wCursor
[widx
]);
3035 wCursor
[widx
] = *cursor
;
3037 if (widx
== WCUR_ROOT
&& *cursor
!= None
) {
3038 XDefineCursor(dpy
, scr
->root_win
, *cursor
);