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"
73 extern WDDomain
*WDWindowMaker
;
74 extern WDDomain
*WDWindowAttributes
;
75 extern WDDomain
*WDRootMenu
;
77 extern int wScreenCount
;
79 extern Atom _XA_WINDOWMAKER_ICON_SIZE
;
80 extern Atom _XA_WINDOWMAKER_ICON_TILE
;
82 extern WPreferences wPreferences
;
84 extern WShortKey wKeyBindings
[WKBD_LAST
];
94 WMPropList
*plvalue
; /* default value */
97 /* used to map strings to integers */
102 } WOptionEnumeration
;
104 /* type converters */
105 static int getBool();
107 static int getCoord();
108 static int getPathList();
109 static int getEnum();
110 static int getTexture();
111 static int getWSBackground();
112 static int getWSSpecificBackground();
113 static int getFont();
114 static int getColor();
115 static int getKeybind();
116 static int getModMask();
118 static int getRImage();
120 static int getPropList();
122 /* value setting functions */
123 static int setJustify();
124 static int setClearance();
125 static int setIfDockPresent();
126 static int setStickyIcons();
127 static int setWidgetColor();
128 static int setIconTile();
129 static int setWinTitleFont();
130 static int setMenuTitleFont();
131 static int setMenuTextFont();
132 static int setIconTitleFont();
133 static int setIconTitleColor();
134 static int setIconTitleBack();
135 static int setLargeDisplayFont();
136 static int setWTitleColor();
137 static int setFTitleBack();
138 static int setPTitleBack();
139 static int setUTitleBack();
140 static int setResizebarBack();
141 static int setWorkspaceBack();
142 static int setWorkspaceSpecificBack();
143 static int setMenuTitleColor();
144 static int setMenuTextColor();
145 static int setMenuDisabledColor();
146 static int setMenuTitleBack();
147 static int setMenuTextBack();
148 static int setHightlight();
149 static int setHightlightText();
150 static int setKeyGrab();
151 static int setDoubleClick();
152 static int setIconPosition();
154 static int setClipTitleFont();
155 static int setClipTitleColor();
157 static int setMenuStyle();
158 static int setSwPOptions();
159 static int updateUsableArea();
161 extern Cursor wCursor
[WCUR_LAST
];
162 static int getCursor();
163 static int setCursor();
166 * Tables to convert strings to enumeration values.
167 * Values stored are char
170 /* WARNING: sum of length of all value strings must not exceed
172 #define TOTAL_VALUES_LENGTH 80
174 #define REFRESH_WINDOW_TEXTURES (1<<0)
175 #define REFRESH_MENU_TEXTURE (1<<1)
176 #define REFRESH_MENU_FONT (1<<2)
177 #define REFRESH_MENU_COLOR (1<<3)
178 #define REFRESH_MENU_TITLE_TEXTURE (1<<4)
179 #define REFRESH_MENU_TITLE_FONT (1<<5)
180 #define REFRESH_MENU_TITLE_COLOR (1<<6)
181 #define REFRESH_WINDOW_TITLE_COLOR (1<<7)
182 #define REFRESH_WINDOW_FONT (1<<8)
183 #define REFRESH_ICON_TILE (1<<9)
184 #define REFRESH_ICON_FONT (1<<10)
185 #define REFRESH_WORKSPACE_BACK (1<<11)
187 #define REFRESH_BUTTON_IMAGES (1<<12)
189 #define REFRESH_ICON_TITLE_COLOR (1<<13)
190 #define REFRESH_ICON_TITLE_BACK (1<<14)
192 static WOptionEnumeration seFocusModes
[] = {
193 {"Manual", WKF_CLICK
, 0}, {"ClickToFocus", WKF_CLICK
, 1},
194 {"Sloppy", WKF_SLOPPY
, 0}, {"SemiAuto", WKF_SLOPPY
, 1}, {"Auto", WKF_SLOPPY
, 1},
198 static WOptionEnumeration seColormapModes
[] = {
199 {"Manual", WCM_CLICK
, 0}, {"ClickToFocus", WCM_CLICK
, 1},
200 {"Auto", WCM_POINTER
, 0}, {"FocusFollowMouse", WCM_POINTER
, 1},
204 static WOptionEnumeration sePlacements
[] = {
205 {"Auto", WPM_AUTO
, 0},
206 {"Smart", WPM_SMART
, 0},
207 {"Cascade", WPM_CASCADE
, 0},
208 {"Random", WPM_RANDOM
, 0},
209 {"Manual", WPM_MANUAL
, 0},
213 static WOptionEnumeration seGeomDisplays
[] = {
214 {"None", WDIS_NONE
, 0},
215 {"Center", WDIS_CENTER
, 0},
216 {"Corner", WDIS_TOPLEFT
, 0},
217 {"Floating", WDIS_FRAME_CENTER
, 0},
218 {"Line", WDIS_NEW
, 0},
222 static WOptionEnumeration seSpeeds
[] = {
223 {"UltraFast", SPEED_ULTRAFAST
, 0},
224 {"Fast", SPEED_FAST
, 0},
225 {"Medium", SPEED_MEDIUM
, 0},
226 {"Slow", SPEED_SLOW
, 0},
227 {"UltraSlow", SPEED_ULTRASLOW
, 0},
231 static WOptionEnumeration seMouseButtonActions
[] = {
232 {"None", WA_NONE
, 0},
233 {"SelectWindows", WA_SELECT_WINDOWS
, 0},
234 {"OpenApplicationsMenu", WA_OPEN_APPMENU
, 0},
235 {"OpenWindowListMenu", WA_OPEN_WINLISTMENU
, 0},
239 static WOptionEnumeration seMouseWheelActions
[] = {
240 {"None", WA_NONE
, 0},
241 {"SwitchWorkspaces", WA_SWITCH_WORKSPACES
, 0},
245 static WOptionEnumeration seIconificationStyles
[] = {
246 {"Zoom", WIS_ZOOM
, 0},
247 {"Twist", WIS_TWIST
, 0},
248 {"Flip", WIS_FLIP
, 0},
249 {"None", WIS_NONE
, 0},
250 {"random", WIS_RANDOM
, 0},
254 static WOptionEnumeration seJustifications
[] = {
255 {"Left", WTJ_LEFT
, 0},
256 {"Center", WTJ_CENTER
, 0},
257 {"Right", WTJ_RIGHT
, 0},
261 static WOptionEnumeration seIconPositions
[] = {
262 {"blv", IY_BOTTOM
| IY_LEFT
| IY_VERT
, 0},
263 {"blh", IY_BOTTOM
| IY_LEFT
| IY_HORIZ
, 0},
264 {"brv", IY_BOTTOM
| IY_RIGHT
| IY_VERT
, 0},
265 {"brh", IY_BOTTOM
| IY_RIGHT
| IY_HORIZ
, 0},
266 {"tlv", IY_TOP
| IY_LEFT
| IY_VERT
, 0},
267 {"tlh", IY_TOP
| IY_LEFT
| IY_HORIZ
, 0},
268 {"trv", IY_TOP
| IY_RIGHT
| IY_VERT
, 0},
269 {"trh", IY_TOP
| IY_RIGHT
| IY_HORIZ
, 0},
273 static WOptionEnumeration seMenuStyles
[] = {
274 {"normal", MS_NORMAL
, 0},
275 {"singletexture", MS_SINGLE_TEXTURE
, 0},
276 {"flat", MS_FLAT
, 0},
280 static WOptionEnumeration seDisplayPositions
[] = {
281 {"none", WD_NONE
, 0},
282 {"center", WD_CENTER
, 0},
284 {"bottom", WD_BOTTOM
, 0},
285 {"topleft", WD_TOPLEFT
, 0},
286 {"topright", WD_TOPRIGHT
, 0},
287 {"bottomleft", WD_BOTTOMLEFT
, 0},
288 {"bottomright", WD_BOTTOMRIGHT
, 0},
292 static WOptionEnumeration seWorkspaceBorder
[] = {
293 {"None", WB_NONE
, 0},
294 {"LeftRight", WB_LEFTRIGHT
, 0},
295 {"TopBottom", WB_TOPBOTTOM
, 0},
296 {"AllDirections", WB_ALLDIRS
, 0},
301 * ALL entries in the tables bellow, NEED to have a default value
302 * defined, and this value needs to be correct.
305 /* these options will only affect the window manager on startup
307 * static defaults can't access the screen data, because it is
308 * created after these defaults are read
310 WDefaultEntry staticOptionList
[] = {
312 {"ColormapSize", "4", NULL
,
313 &wPreferences
.cmap_size
, getInt
, NULL
, NULL
, NULL
},
314 {"DisableDithering", "NO", NULL
,
315 &wPreferences
.no_dithering
, getBool
, NULL
, NULL
, NULL
},
316 {"IconSize", "64", NULL
,
317 &wPreferences
.icon_size
, getInt
, NULL
, NULL
, NULL
},
318 {"ModifierKey", "Mod1", NULL
,
319 &wPreferences
.modifier_mask
, getModMask
, NULL
, NULL
, NULL
},
320 {"DisableWSMouseActions", "NO", NULL
,
321 &wPreferences
.disable_root_mouse
, getBool
, NULL
, NULL
, NULL
},
322 {"FocusMode", "manual", seFocusModes
, /* have a problem when switching from */
323 &wPreferences
.focus_mode
, getEnum
, NULL
, NULL
, NULL
}, /* manual to sloppy without restart */
324 {"NewStyle", "NO", NULL
,
325 &wPreferences
.new_style
, getBool
, NULL
, NULL
, NULL
},
326 {"DisableDock", "NO", (void *)WM_DOCK
,
327 NULL
, getBool
, setIfDockPresent
, NULL
, NULL
},
328 {"DisableClip", "NO", (void *)WM_CLIP
,
329 NULL
, getBool
, setIfDockPresent
, NULL
, NULL
},
330 {"DisableMiniwindows", "NO", NULL
,
331 &wPreferences
.disable_miniwindows
, getBool
, NULL
, NULL
, NULL
}
334 WDefaultEntry optionList
[] = {
336 /* dynamic options */
338 {"IconPosition", "blh", seIconPositions
,
339 &wPreferences
.icon_yard
, getEnum
, setIconPosition
, NULL
, NULL
},
340 {"IconificationStyle", "Zoom", seIconificationStyles
,
341 &wPreferences
.iconification_style
, getEnum
, NULL
, NULL
, NULL
},
342 {"MouseLeftButtonAction", "SelectWindows", seMouseButtonActions
,
343 &wPreferences
.mouse_button1
, getEnum
, NULL
, NULL
, NULL
},
344 {"MouseMiddleButtonAction", "OpenWindowListMenu", seMouseButtonActions
,
345 &wPreferences
.mouse_button2
, getEnum
, NULL
, NULL
, NULL
},
346 {"MouseRightButtonAction", "OpenApplicationsMenu", seMouseButtonActions
,
347 &wPreferences
.mouse_button3
, getEnum
, NULL
, NULL
, NULL
},
348 {"MouseWheelAction", "None", seMouseWheelActions
,
349 &wPreferences
.mouse_wheel
, getEnum
, NULL
, NULL
, NULL
},
350 {"PixmapPath", DEF_PIXMAP_PATHS
, NULL
,
351 &wPreferences
.pixmap_path
, getPathList
, NULL
, NULL
, NULL
},
352 {"IconPath", DEF_ICON_PATHS
, NULL
,
353 &wPreferences
.icon_path
, getPathList
, NULL
, NULL
, NULL
},
354 {"ColormapMode", "auto", seColormapModes
,
355 &wPreferences
.colormap_mode
, getEnum
, NULL
, NULL
, NULL
},
356 {"AutoFocus", "NO", NULL
,
357 &wPreferences
.auto_focus
, getBool
, NULL
, NULL
, NULL
},
358 {"RaiseDelay", "0", NULL
,
359 &wPreferences
.raise_delay
, getInt
, NULL
, NULL
, NULL
},
360 {"CirculateRaise", "NO", NULL
,
361 &wPreferences
.circ_raise
, getBool
, NULL
, NULL
, NULL
},
362 {"Superfluous", "NO", NULL
,
363 &wPreferences
.superfluous
, getBool
, NULL
, NULL
, NULL
},
364 {"AdvanceToNewWorkspace", "NO", NULL
,
365 &wPreferences
.ws_advance
, getBool
, NULL
, NULL
, NULL
},
366 {"CycleWorkspaces", "NO", NULL
,
367 &wPreferences
.ws_cycle
, getBool
, NULL
, NULL
, NULL
},
368 {"WorkspaceNameDisplayPosition", "center", seDisplayPositions
,
369 &wPreferences
.workspace_name_display_position
, getEnum
, NULL
, NULL
, NULL
},
370 {"WorkspaceBorder", "None", seWorkspaceBorder
,
371 &wPreferences
.workspace_border_position
, getEnum
, updateUsableArea
, NULL
, NULL
},
372 {"WorkspaceBorderSize", "0", NULL
,
373 &wPreferences
.workspace_border_size
, getInt
, updateUsableArea
, NULL
, NULL
},
374 {"StickyIcons", "NO", NULL
,
375 &wPreferences
.sticky_icons
, getBool
, setStickyIcons
, NULL
, NULL
},
376 {"SaveSessionOnExit", "NO", NULL
,
377 &wPreferences
.save_session_on_exit
, getBool
, NULL
, NULL
, NULL
},
378 {"WrapMenus", "NO", NULL
,
379 &wPreferences
.wrap_menus
, getBool
, NULL
, NULL
, NULL
},
380 {"ScrollableMenus", "NO", NULL
,
381 &wPreferences
.scrollable_menus
, getBool
, NULL
, NULL
, NULL
},
382 {"MenuScrollSpeed", "medium", seSpeeds
,
383 &wPreferences
.menu_scroll_speed
, getEnum
, NULL
, NULL
, NULL
},
384 {"IconSlideSpeed", "medium", seSpeeds
,
385 &wPreferences
.icon_slide_speed
, getEnum
, NULL
, NULL
, NULL
},
386 {"ShadeSpeed", "medium", seSpeeds
,
387 &wPreferences
.shade_speed
, getEnum
, NULL
, NULL
, NULL
},
388 {"DoubleClickTime", "250", (void *)&wPreferences
.dblclick_time
,
389 &wPreferences
.dblclick_time
, getInt
, setDoubleClick
, NULL
, NULL
},
390 {"AlignSubmenus", "NO", NULL
,
391 &wPreferences
.align_menus
, getBool
, NULL
, NULL
, NULL
},
392 {"OpenTransientOnOwnerWorkspace", "NO", NULL
,
393 &wPreferences
.open_transients_with_parent
, getBool
, NULL
, NULL
, NULL
},
394 {"WindowPlacement", "auto", sePlacements
,
395 &wPreferences
.window_placement
, getEnum
, NULL
, NULL
, NULL
},
396 {"IgnoreFocusClick", "NO", NULL
,
397 &wPreferences
.ignore_focus_click
, getBool
, NULL
, NULL
, NULL
},
398 {"UseSaveUnders", "NO", NULL
,
399 &wPreferences
.use_saveunders
, getBool
, NULL
, NULL
, NULL
},
400 {"OpaqueMove", "NO", NULL
,
401 &wPreferences
.opaque_move
, getBool
, NULL
, NULL
, NULL
},
402 {"DisableAnimations", "NO", NULL
,
403 &wPreferences
.no_animations
, getBool
, NULL
, NULL
, NULL
},
404 {"DontLinkWorkspaces", "NO", NULL
,
405 &wPreferences
.no_autowrap
, getBool
, NULL
, NULL
, NULL
},
406 {"AutoArrangeIcons", "NO", NULL
,
407 &wPreferences
.auto_arrange_icons
, getBool
, NULL
, NULL
, NULL
},
408 {"NoWindowOverDock", "NO", NULL
,
409 &wPreferences
.no_window_over_dock
, getBool
, updateUsableArea
, NULL
, NULL
},
410 {"NoWindowOverIcons", "NO", NULL
,
411 &wPreferences
.no_window_over_icons
, getBool
, updateUsableArea
, NULL
, NULL
},
412 {"WindowPlaceOrigin", "(0, 0)", NULL
,
413 &wPreferences
.window_place_origin
, getCoord
, NULL
, NULL
, NULL
},
414 {"ResizeDisplay", "corner", seGeomDisplays
,
415 &wPreferences
.size_display
, getEnum
, NULL
, NULL
, NULL
},
416 {"MoveDisplay", "corner", seGeomDisplays
,
417 &wPreferences
.move_display
, getEnum
, NULL
, NULL
, NULL
},
418 {"DontConfirmKill", "NO", NULL
,
419 &wPreferences
.dont_confirm_kill
, getBool
, NULL
, NULL
, NULL
},
420 {"WindowTitleBalloons", "NO", NULL
,
421 &wPreferences
.window_balloon
, getBool
, NULL
, NULL
, NULL
},
422 {"MiniwindowTitleBalloons", "NO", NULL
,
423 &wPreferences
.miniwin_balloon
, getBool
, NULL
, NULL
, NULL
},
424 {"AppIconBalloons", "NO", NULL
,
425 &wPreferences
.appicon_balloon
, getBool
, NULL
, NULL
, NULL
},
426 {"HelpBalloons", "NO", NULL
,
427 &wPreferences
.help_balloon
, getBool
, NULL
, NULL
, NULL
},
428 {"EdgeResistance", "30", NULL
,
429 &wPreferences
.edge_resistance
, getInt
, NULL
, NULL
, NULL
},
430 {"ResizeIncrement", "32", NULL
,
431 &wPreferences
.resize_increment
, getInt
, NULL
, NULL
, NULL
},
432 {"Attraction", "NO", NULL
,
433 &wPreferences
.attract
, getBool
, NULL
, NULL
, NULL
},
434 {"DisableBlinking", "NO", NULL
,
435 &wPreferences
.dont_blink
, getBool
, NULL
, NULL
, NULL
},
436 {"SingleClickLaunch", "NO", NULL
,
437 &wPreferences
.single_click
, getBool
, NULL
, NULL
, NULL
},
441 {"MenuStyle", "normal", seMenuStyles
,
442 &wPreferences
.menu_style
, getEnum
, setMenuStyle
, NULL
, NULL
},
443 {"WidgetColor", "(solid, gray)", NULL
,
444 NULL
, getTexture
, setWidgetColor
, NULL
, NULL
},
445 {"WorkspaceSpecificBack", "()", NULL
,
446 NULL
, getWSSpecificBackground
, setWorkspaceSpecificBack
, NULL
, NULL
},
447 /* WorkspaceBack must come after WorkspaceSpecificBack or
448 * WorkspaceBack wont know WorkspaceSpecificBack was also
449 * specified and 2 copies of wmsetbg will be launched */
450 {"WorkspaceBack", "(solid, black)", NULL
,
451 NULL
, getWSBackground
, setWorkspaceBack
, NULL
, NULL
},
452 {"SmoothWorkspaceBack", "NO", NULL
,
453 NULL
, getBool
, NULL
, NULL
, NULL
},
454 {"IconBack", "(solid, gray)", NULL
,
455 NULL
, getTexture
, setIconTile
, NULL
, NULL
},
456 {"TitleJustify", "center", seJustifications
,
457 &wPreferences
.title_justification
, getEnum
, setJustify
, NULL
, NULL
},
458 {"WindowTitleFont", DEF_TITLE_FONT
, NULL
,
459 NULL
, getFont
, setWinTitleFont
, NULL
, NULL
},
460 {"WindowTitleExtendSpace", DEF_WINDOW_TITLE_EXTEND_SPACE
, NULL
,
461 &wPreferences
.window_title_clearance
, getInt
, setClearance
, NULL
, NULL
},
462 {"MenuTitleExtendSpace", DEF_MENU_TITLE_EXTEND_SPACE
, NULL
,
463 &wPreferences
.menu_title_clearance
, getInt
, setClearance
, NULL
, NULL
},
464 {"MenuTextExtendSpace", DEF_MENU_TEXT_EXTEND_SPACE
, NULL
,
465 &wPreferences
.menu_text_clearance
, getInt
, setClearance
, NULL
, NULL
},
466 {"MenuTitleFont", DEF_MENU_TITLE_FONT
, NULL
,
467 NULL
, getFont
, setMenuTitleFont
, NULL
, NULL
},
468 {"MenuTextFont", DEF_MENU_ENTRY_FONT
, NULL
,
469 NULL
, getFont
, setMenuTextFont
, NULL
, NULL
},
470 {"IconTitleFont", DEF_ICON_TITLE_FONT
, NULL
,
471 NULL
, getFont
, setIconTitleFont
, NULL
, NULL
},
472 {"ClipTitleFont", DEF_CLIP_TITLE_FONT
, NULL
,
473 NULL
, getFont
, setClipTitleFont
, NULL
, NULL
},
474 {"LargeDisplayFont", DEF_WORKSPACE_NAME_FONT
, NULL
,
475 NULL
, getFont
, setLargeDisplayFont
, NULL
, NULL
},
476 {"HighlightColor", "white", NULL
,
477 NULL
, getColor
, setHightlight
, NULL
, NULL
},
478 {"HighlightTextColor", "black", NULL
,
479 NULL
, getColor
, setHightlightText
, NULL
, NULL
},
480 {"ClipTitleColor", "black", (void *)CLIP_NORMAL
,
481 NULL
, getColor
, setClipTitleColor
, NULL
, NULL
},
482 {"CClipTitleColor", "\"#454045\"", (void *)CLIP_COLLAPSED
,
483 NULL
, getColor
, setClipTitleColor
, NULL
, NULL
},
484 {"FTitleColor", "white", (void *)WS_FOCUSED
,
485 NULL
, getColor
, setWTitleColor
, NULL
, NULL
},
486 {"PTitleColor", "white", (void *)WS_PFOCUSED
,
487 NULL
, getColor
, setWTitleColor
, NULL
, NULL
},
488 {"UTitleColor", "black", (void *)WS_UNFOCUSED
,
489 NULL
, getColor
, setWTitleColor
, NULL
, NULL
},
490 {"FTitleBack", "(solid, black)", NULL
,
491 NULL
, getTexture
, setFTitleBack
, NULL
, NULL
},
492 {"PTitleBack", "(solid, \"#616161\")", NULL
,
493 NULL
, getTexture
, setPTitleBack
, NULL
, NULL
},
494 {"UTitleBack", "(solid, gray)", NULL
,
495 NULL
, getTexture
, setUTitleBack
, NULL
, NULL
},
496 {"ResizebarBack", "(solid, gray)", NULL
,
497 NULL
, getTexture
, setResizebarBack
, NULL
, NULL
},
498 {"MenuTitleColor", "white", NULL
,
499 NULL
, getColor
, setMenuTitleColor
, NULL
, NULL
},
500 {"MenuTextColor", "black", NULL
,
501 NULL
, getColor
, setMenuTextColor
, NULL
, NULL
},
502 {"MenuDisabledColor", "\"#616161\"", NULL
,
503 NULL
, getColor
, setMenuDisabledColor
, NULL
, NULL
},
504 {"MenuTitleBack", "(solid, black)", NULL
,
505 NULL
, getTexture
, setMenuTitleBack
, NULL
, NULL
},
506 {"MenuTextBack", "(solid, gray)", NULL
,
507 NULL
, getTexture
, setMenuTextBack
, NULL
, NULL
},
508 {"IconTitleColor", "white", NULL
,
509 NULL
, getColor
, setIconTitleColor
, NULL
, NULL
},
510 {"IconTitleBack", "black", NULL
,
511 NULL
, getColor
, setIconTitleBack
, NULL
, NULL
},
512 {"SwitchPanelImages", "(swtile.png, swback.png, 30, 40)", &wPreferences
,
513 NULL
, getPropList
, setSwPOptions
, NULL
, NULL
},
517 {"RootMenuKey", "None", (void *)WKBD_ROOTMENU
,
518 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
519 {"WindowListKey", "None", (void *)WKBD_WINDOWLIST
,
520 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
521 {"WindowMenuKey", "None", (void *)WKBD_WINDOWMENU
,
522 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
523 {"DockRaiseLowerKey", "None", (void*)WKBD_DOCKRAISELOWER
,
524 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
525 {"ClipRaiseLowerKey", "None", (void *)WKBD_CLIPRAISELOWER
,
526 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
527 {"MiniaturizeKey", "None", (void *)WKBD_MINIATURIZE
,
528 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
529 {"HideKey", "None", (void *)WKBD_HIDE
,
530 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
531 {"HideOthersKey", "None", (void *)WKBD_HIDE_OTHERS
,
532 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
533 {"MoveResizeKey", "None", (void *)WKBD_MOVERESIZE
,
534 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
535 {"CloseKey", "None", (void *)WKBD_CLOSE
,
536 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
537 {"MaximizeKey", "None", (void *)WKBD_MAXIMIZE
,
538 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
539 {"VMaximizeKey", "None", (void *)WKBD_VMAXIMIZE
,
540 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
541 {"HMaximizeKey", "None", (void *)WKBD_HMAXIMIZE
,
542 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
543 {"LHMaximizeKey", "None", (void*)WKBD_LHMAXIMIZE
,
544 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
545 {"RHMaximizeKey", "None", (void*)WKBD_RHMAXIMIZE
,
546 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
547 {"MaximusKey", "None", (void*)WKBD_MAXIMUS
,
548 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
549 {"RaiseKey", "\"Meta+Up\"", (void *)WKBD_RAISE
,
550 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
551 {"LowerKey", "\"Meta+Down\"", (void *)WKBD_LOWER
,
552 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
553 {"RaiseLowerKey", "None", (void *)WKBD_RAISELOWER
,
554 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
555 {"ShadeKey", "None", (void *)WKBD_SHADE
,
556 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
557 {"SelectKey", "None", (void *)WKBD_SELECT
,
558 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
559 {"FocusNextKey", "None", (void *)WKBD_FOCUSNEXT
,
560 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
561 {"FocusPrevKey", "None", (void *)WKBD_FOCUSPREV
,
562 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
563 {"GroupNextKey", "None", (void *)WKBD_GROUPNEXT
,
564 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
565 {"GroupPrevKey", "None", (void *)WKBD_GROUPPREV
,
566 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
567 {"NextWorkspaceKey", "None", (void *)WKBD_NEXTWORKSPACE
,
568 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
569 {"PrevWorkspaceKey", "None", (void *)WKBD_PREVWORKSPACE
,
570 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
571 {"NextWorkspaceLayerKey", "None", (void *)WKBD_NEXTWSLAYER
,
572 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
573 {"PrevWorkspaceLayerKey", "None", (void *)WKBD_PREVWSLAYER
,
574 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
575 {"Workspace1Key", "None", (void *)WKBD_WORKSPACE1
,
576 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
577 {"Workspace2Key", "None", (void *)WKBD_WORKSPACE2
,
578 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
579 {"Workspace3Key", "None", (void *)WKBD_WORKSPACE3
,
580 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
581 {"Workspace4Key", "None", (void *)WKBD_WORKSPACE4
,
582 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
583 {"Workspace5Key", "None", (void *)WKBD_WORKSPACE5
,
584 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
585 {"Workspace6Key", "None", (void *)WKBD_WORKSPACE6
,
586 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
587 {"Workspace7Key", "None", (void *)WKBD_WORKSPACE7
,
588 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
589 {"Workspace8Key", "None", (void *)WKBD_WORKSPACE8
,
590 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
591 {"Workspace9Key", "None", (void *)WKBD_WORKSPACE9
,
592 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
593 {"Workspace10Key", "None", (void *)WKBD_WORKSPACE10
,
594 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
595 {"WindowShortcut1Key", "None", (void *)WKBD_WINDOW1
,
596 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
597 {"WindowShortcut2Key", "None", (void *)WKBD_WINDOW2
,
598 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
599 {"WindowShortcut3Key", "None", (void *)WKBD_WINDOW3
,
600 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
601 {"WindowShortcut4Key", "None", (void *)WKBD_WINDOW4
,
602 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
603 {"WindowShortcut5Key", "None", (void *)WKBD_WINDOW5
,
604 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
605 {"WindowShortcut6Key", "None", (void *)WKBD_WINDOW6
,
606 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
607 {"WindowShortcut7Key", "None", (void *)WKBD_WINDOW7
,
608 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
609 {"WindowShortcut8Key", "None", (void *)WKBD_WINDOW8
,
610 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
611 {"WindowShortcut9Key", "None", (void *)WKBD_WINDOW9
,
612 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
613 {"WindowShortcut10Key", "None", (void *)WKBD_WINDOW10
,
614 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
615 {"ScreenSwitchKey", "None", (void *)WKBD_SWITCH_SCREEN
,
616 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
618 #ifdef KEEP_XKB_LOCK_STATUS
619 {"ToggleKbdModeKey", "None", (void *)WKBD_TOGGLE
,
620 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
621 {"KbdModeLock", "NO", NULL
,
622 &wPreferences
.modelock
, getBool
, NULL
, NULL
, NULL
},
623 #endif /* KEEP_XKB_LOCK_STATUS */
625 {"NormalCursor", "(builtin, left_ptr)", (void *)WCUR_ROOT
,
626 NULL
, getCursor
, setCursor
, NULL
, NULL
},
627 {"ArrowCursor", "(builtin, top_left_arrow)", (void *)WCUR_ARROW
,
628 NULL
, getCursor
, setCursor
, NULL
, NULL
},
629 {"MoveCursor", "(builtin, fleur)", (void *)WCUR_MOVE
,
630 NULL
, getCursor
, setCursor
, NULL
, NULL
},
631 {"ResizeCursor", "(builtin, sizing)", (void *)WCUR_RESIZE
,
632 NULL
, getCursor
, setCursor
, NULL
, NULL
},
633 {"TopLeftResizeCursor", "(builtin, top_left_corner)", (void *)WCUR_TOPLEFTRESIZE
,
634 NULL
, getCursor
, setCursor
, NULL
, NULL
},
635 {"TopRightResizeCursor", "(builtin, top_right_corner)", (void *)WCUR_TOPRIGHTRESIZE
,
636 NULL
, getCursor
, setCursor
, NULL
, NULL
},
637 {"BottomLeftResizeCursor", "(builtin, bottom_left_corner)", (void *)WCUR_BOTTOMLEFTRESIZE
,
638 NULL
, getCursor
, setCursor
, NULL
, NULL
},
639 {"BottomRightResizeCursor", "(builtin, bottom_right_corner)", (void *)WCUR_BOTTOMRIGHTRESIZE
,
640 NULL
, getCursor
, setCursor
, NULL
, NULL
},
641 {"VerticalResizeCursor", "(builtin, sb_v_double_arrow)", (void *)WCUR_VERTICALRESIZE
,
642 NULL
, getCursor
, setCursor
, NULL
, NULL
},
643 {"HorizontalResizeCursor", "(builtin, sb_h_double_arrow)", (void *)WCUR_HORIZONRESIZE
,
644 NULL
, getCursor
, setCursor
, NULL
, NULL
},
645 {"WaitCursor", "(builtin, watch)", (void *)WCUR_WAIT
,
646 NULL
, getCursor
, setCursor
, NULL
, NULL
},
647 {"QuestionCursor", "(builtin, question_arrow)", (void *)WCUR_QUESTION
,
648 NULL
, getCursor
, setCursor
, NULL
, NULL
},
649 {"TextCursor", "(builtin, xterm)", (void *)WCUR_TEXT
,
650 NULL
, getCursor
, setCursor
, NULL
, NULL
},
651 {"SelectCursor", "(builtin, cross)", (void *)WCUR_SELECT
,
652 NULL
, getCursor
, setCursor
, NULL
, NULL
},
653 {"DialogHistoryLines", "500", NULL
,
654 &wPreferences
.history_lines
, getInt
, NULL
, NULL
, NULL
},
655 {"CycleActiveHeadOnly", "NO", NULL
,
656 &wPreferences
.cycle_active_head_only
, getBool
, NULL
, NULL
, NULL
}
659 static void initDefaults()
662 WDefaultEntry
*entry
;
664 WMPLSetCaseSensitive(False
);
666 for (i
= 0; i
< sizeof(optionList
) / sizeof(WDefaultEntry
); i
++) {
667 entry
= &optionList
[i
];
669 entry
->plkey
= WMCreatePLString(entry
->key
);
670 if (entry
->default_value
)
671 entry
->plvalue
= WMCreatePropListFromDescription(entry
->default_value
);
673 entry
->plvalue
= NULL
;
676 for (i
= 0; i
< sizeof(staticOptionList
) / sizeof(WDefaultEntry
); i
++) {
677 entry
= &staticOptionList
[i
];
679 entry
->plkey
= WMCreatePLString(entry
->key
);
680 if (entry
->default_value
)
681 entry
->plvalue
= WMCreatePropListFromDescription(entry
->default_value
);
683 entry
->plvalue
= NULL
;
687 static WMPropList
*readGlobalDomain(char *domainName
, Bool requireDictionary
)
689 WMPropList
*globalDict
= NULL
;
693 snprintf(path
, sizeof(path
), "%s/%s/%s", SYSCONFDIR
, GLOBAL_DEFAULTS_SUBDIR
, domainName
);
694 if (stat(path
, &stbuf
) >= 0) {
695 globalDict
= WMReadPropListFromFile(path
);
696 if (globalDict
&& requireDictionary
&& !WMIsPLDictionary(globalDict
)) {
697 wwarning(_("Domain %s (%s) of global defaults database is corrupted!"), domainName
, path
);
698 WMReleasePropList(globalDict
);
700 } else if (!globalDict
) {
701 wwarning(_("could not load domain %s from global defaults database"), domainName
);
708 #if defined(GLOBAL_PREAMBLE_MENU_FILE) || defined(GLOBAL_EPILOGUE_MENU_FILE)
709 static void prependMenu(WMPropList
* destarr
, WMPropList
* array
)
714 for (i
= 0; i
< WMGetPropListItemCount(array
); i
++) {
715 item
= WMGetFromPLArray(array
, i
);
717 WMInsertInPLArray(destarr
, i
+ 1, item
);
721 static void appendMenu(WMPropList
* destarr
, WMPropList
* array
)
726 for (i
= 0; i
< WMGetPropListItemCount(array
); i
++) {
727 item
= WMGetFromPLArray(array
, i
);
729 WMAddToPLArray(destarr
, item
);
734 void wDefaultsMergeGlobalMenus(WDDomain
* menuDomain
)
736 WMPropList
*menu
= menuDomain
->dictionary
;
739 if (!menu
|| !WMIsPLArray(menu
))
742 #ifdef GLOBAL_PREAMBLE_MENU_FILE
743 submenu
= WMReadPropListFromFile(SYSCONFDIR
"/" GLOBAL_DEFAULTS_SUBDIR
"/" GLOBAL_PREAMBLE_MENU_FILE
);
745 if (submenu
&& !WMIsPLArray(submenu
)) {
746 wwarning(_("invalid global menu file %s"), GLOBAL_PREAMBLE_MENU_FILE
);
747 WMReleasePropList(submenu
);
751 prependMenu(menu
, submenu
);
752 WMReleasePropList(submenu
);
756 #ifdef GLOBAL_EPILOGUE_MENU_FILE
757 submenu
= WMReadPropListFromFile(SYSCONFDIR
"/" GLOBAL_DEFAULTS_SUBDIR
"/" GLOBAL_EPILOGUE_MENU_FILE
);
759 if (submenu
&& !WMIsPLArray(submenu
)) {
760 wwarning(_("invalid global menu file %s"), GLOBAL_EPILOGUE_MENU_FILE
);
761 WMReleasePropList(submenu
);
765 appendMenu(menu
, submenu
);
766 WMReleasePropList(submenu
);
770 menuDomain
->dictionary
= menu
;
773 void wDefaultsDestroyDomain(WDDomain
* domain
)
775 if (domain
->dictionary
)
776 WMReleasePropList(domain
->dictionary
);
781 WDDomain
*wDefaultsInitDomain(char *domain
, Bool requireDictionary
)
785 static int inited
= 0;
788 WMPropList
*shared_dict
= NULL
;
795 db
= wmalloc(sizeof(WDDomain
));
796 memset(db
, 0, sizeof(WDDomain
));
797 db
->domain_name
= domain
;
798 db
->path
= wdefaultspathfordomain(domain
);
801 if (the_path
&& stat(the_path
, &stbuf
) >= 0) {
802 db
->dictionary
= WMReadPropListFromFile(the_path
);
803 if (db
->dictionary
) {
804 if (requireDictionary
&& !WMIsPLDictionary(db
->dictionary
)) {
805 WMReleasePropList(db
->dictionary
);
806 db
->dictionary
= NULL
;
807 wwarning(_("Domain %s (%s) of defaults database is corrupted!"), domain
, the_path
);
809 db
->timestamp
= stbuf
.st_mtime
;
811 wwarning(_("could not load domain %s from user defaults database"), domain
);
815 /* global system dictionary */
816 snprintf(path
, sizeof(path
), "%s/%s/%s", SYSCONFDIR
, GLOBAL_DEFAULTS_SUBDIR
, domain
);
817 if (stat(path
, &stbuf
) >= 0) {
818 shared_dict
= WMReadPropListFromFile(path
);
820 if (requireDictionary
&& !WMIsPLDictionary(shared_dict
)) {
821 wwarning(_("Domain %s (%s) of global defaults database is corrupted!"),
823 WMReleasePropList(shared_dict
);
826 if (db
->dictionary
&& WMIsPLDictionary(shared_dict
) &&
827 WMIsPLDictionary(db
->dictionary
)) {
828 WMMergePLDictionaries(shared_dict
, db
->dictionary
, True
);
829 WMReleasePropList(db
->dictionary
);
830 db
->dictionary
= shared_dict
;
831 if (stbuf
.st_mtime
> db
->timestamp
)
832 db
->timestamp
= stbuf
.st_mtime
;
833 } else if (!db
->dictionary
) {
834 db
->dictionary
= shared_dict
;
835 if (stbuf
.st_mtime
> db
->timestamp
)
836 db
->timestamp
= stbuf
.st_mtime
;
840 wwarning(_("could not load domain %s from global defaults database (%s)"), domain
, path
);
847 void wReadStaticDefaults(WMPropList
* dict
)
850 WDefaultEntry
*entry
;
854 for (i
= 0; i
< sizeof(staticOptionList
) / sizeof(WDefaultEntry
); i
++) {
855 entry
= &staticOptionList
[i
];
858 plvalue
= WMGetFromPLDictionary(dict
, entry
->plkey
);
863 /* no default in the DB. Use builtin default */
864 plvalue
= entry
->plvalue
;
869 (*entry
->convert
) (NULL
, entry
, plvalue
, entry
->addr
, &tdata
);
871 (*entry
->update
) (NULL
, entry
, tdata
, entry
->extra_data
);
877 void wDefaultsCheckDomains(void* arg
)
881 WMPropList
*shared_dict
= NULL
;
885 if (stat(WDWindowMaker
->path
, &stbuf
) >= 0 && WDWindowMaker
->timestamp
< stbuf
.st_mtime
) {
886 WDWindowMaker
->timestamp
= stbuf
.st_mtime
;
888 /* global dictionary */
889 shared_dict
= readGlobalDomain("WindowMaker", True
);
890 /* user dictionary */
891 dict
= WMReadPropListFromFile(WDWindowMaker
->path
);
893 if (!WMIsPLDictionary(dict
)) {
894 WMReleasePropList(dict
);
896 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
897 "WindowMaker", WDWindowMaker
->path
);
900 WMMergePLDictionaries(shared_dict
, dict
, True
);
901 WMReleasePropList(dict
);
905 for (i
= 0; i
< wScreenCount
; i
++) {
906 scr
= wScreenWithNumber(i
);
908 wReadDefaults(scr
, dict
);
910 if (WDWindowMaker
->dictionary
) {
911 WMReleasePropList(WDWindowMaker
->dictionary
);
913 WDWindowMaker
->dictionary
= dict
;
916 wwarning(_("could not load domain %s from user defaults database"), "WindowMaker");
919 WMReleasePropList(shared_dict
);
923 if (stat(WDWindowAttributes
->path
, &stbuf
) >= 0 && WDWindowAttributes
->timestamp
< stbuf
.st_mtime
) {
924 /* global dictionary */
925 shared_dict
= readGlobalDomain("WMWindowAttributes", True
);
926 /* user dictionary */
927 dict
= WMReadPropListFromFile(WDWindowAttributes
->path
);
929 if (!WMIsPLDictionary(dict
)) {
930 WMReleasePropList(dict
);
932 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
933 "WMWindowAttributes", WDWindowAttributes
->path
);
936 WMMergePLDictionaries(shared_dict
, dict
, True
);
937 WMReleasePropList(dict
);
941 if (WDWindowAttributes
->dictionary
) {
942 WMReleasePropList(WDWindowAttributes
->dictionary
);
944 WDWindowAttributes
->dictionary
= dict
;
945 for (i
= 0; i
< wScreenCount
; i
++) {
946 scr
= wScreenWithNumber(i
);
950 wDefaultUpdateIcons(scr
);
952 /* Update the panel image if changed */
953 /* Don't worry. If the image is the same these
954 * functions will have no performance impact. */
955 image
= wDefaultGetImage(scr
, "Logo", "WMPanel");
958 wwarning(_("could not load logo image for panels: %s"),
959 RMessageForError(RErrorCode
));
961 WMSetApplicationIconImage(scr
->wmscreen
, image
);
962 RReleaseImage(image
);
968 wwarning(_("could not load domain %s from user defaults database"), "WMWindowAttributes");
970 WDWindowAttributes
->timestamp
= stbuf
.st_mtime
;
972 WMReleasePropList(shared_dict
);
976 if (stat(WDRootMenu
->path
, &stbuf
) >= 0 && WDRootMenu
->timestamp
< stbuf
.st_mtime
) {
977 dict
= WMReadPropListFromFile(WDRootMenu
->path
);
979 if (!WMIsPLArray(dict
) && !WMIsPLString(dict
)) {
980 WMReleasePropList(dict
);
982 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
983 "WMRootMenu", WDRootMenu
->path
);
985 if (WDRootMenu
->dictionary
) {
986 WMReleasePropList(WDRootMenu
->dictionary
);
988 WDRootMenu
->dictionary
= dict
;
989 wDefaultsMergeGlobalMenus(WDRootMenu
);
992 wwarning(_("could not load domain %s from user defaults database"), "WMRootMenu");
994 WDRootMenu
->timestamp
= stbuf
.st_mtime
;
998 WMAddTimerHandler(DEFAULTS_CHECK_INTERVAL
, wDefaultsCheckDomains
, arg
);
1002 void wReadDefaults(WScreen
* scr
, WMPropList
* new_dict
)
1004 WMPropList
*plvalue
, *old_value
;
1005 WDefaultEntry
*entry
;
1006 unsigned int i
, must_update
;
1007 int update_workspace_back
= 0; /* kluge :/ */
1008 unsigned int needs_refresh
;
1010 WMPropList
*old_dict
= (WDWindowMaker
->dictionary
!= new_dict
? WDWindowMaker
->dictionary
: NULL
);
1016 for (i
= 0; i
< sizeof(optionList
) / sizeof(WDefaultEntry
); i
++) {
1017 entry
= &optionList
[i
];
1020 plvalue
= WMGetFromPLDictionary(new_dict
, entry
->plkey
);
1027 old_value
= WMGetFromPLDictionary(old_dict
, entry
->plkey
);
1029 if (!plvalue
&& !old_value
) {
1030 /* no default in the DB. Use builtin default */
1031 plvalue
= entry
->plvalue
;
1032 if (plvalue
&& new_dict
) {
1033 WMPutInPLDictionary(new_dict
, entry
->plkey
, plvalue
);
1036 } else if (!plvalue
) {
1037 /* value was deleted from DB. Keep current value */
1039 } else if (!old_value
) {
1040 /* set value for the 1st time */
1041 } else if (!WMIsPropListEqualTo(plvalue
, old_value
)) {
1042 /* value has changed */
1045 if (strcmp(entry
->key
, "WorkspaceBack") == 0
1046 && update_workspace_back
&& scr
->flags
.backimage_helper_launched
) {
1048 /* value was not changed since last time */
1055 if ((*entry
->convert
) (scr
, entry
, plvalue
, entry
->addr
, &tdata
)) {
1057 * If the WorkspaceSpecificBack data has been changed
1058 * so that the helper will be launched now, we must be
1059 * sure to send the default background texture config
1062 if (strcmp(entry
->key
, "WorkspaceSpecificBack") == 0
1063 && !scr
->flags
.backimage_helper_launched
) {
1064 update_workspace_back
= 1;
1066 if (entry
->update
) {
1067 needs_refresh
|= (*entry
->update
) (scr
, entry
, tdata
, entry
->extra_data
);
1073 if (needs_refresh
!= 0 && !scr
->flags
.startup
) {
1077 if (needs_refresh
& REFRESH_MENU_TITLE_TEXTURE
)
1078 foo
|= WTextureSettings
;
1079 if (needs_refresh
& REFRESH_MENU_TITLE_FONT
)
1080 foo
|= WFontSettings
;
1081 if (needs_refresh
& REFRESH_MENU_TITLE_COLOR
)
1082 foo
|= WColorSettings
;
1084 WMPostNotificationName(WNMenuTitleAppearanceSettingsChanged
, NULL
,
1085 (void *)(uintptr_t) foo
);
1088 if (needs_refresh
& REFRESH_MENU_TEXTURE
)
1089 foo
|= WTextureSettings
;
1090 if (needs_refresh
& REFRESH_MENU_FONT
)
1091 foo
|= WFontSettings
;
1092 if (needs_refresh
& REFRESH_MENU_COLOR
)
1093 foo
|= WColorSettings
;
1095 WMPostNotificationName(WNMenuAppearanceSettingsChanged
, NULL
, (void *)(uintptr_t) foo
);
1098 if (needs_refresh
& REFRESH_WINDOW_FONT
) {
1099 foo
|= WFontSettings
;
1101 if (needs_refresh
& REFRESH_WINDOW_TEXTURES
) {
1102 foo
|= WTextureSettings
;
1104 if (needs_refresh
& REFRESH_WINDOW_TITLE_COLOR
) {
1105 foo
|= WColorSettings
;
1108 WMPostNotificationName(WNWindowAppearanceSettingsChanged
, NULL
, (void *)(uintptr_t) foo
);
1110 if (!(needs_refresh
& REFRESH_ICON_TILE
)) {
1112 if (needs_refresh
& REFRESH_ICON_FONT
) {
1113 foo
|= WFontSettings
;
1115 if (needs_refresh
& REFRESH_ICON_TITLE_COLOR
) {
1116 foo
|= WTextureSettings
;
1118 if (needs_refresh
& REFRESH_ICON_TITLE_BACK
) {
1119 foo
|= WTextureSettings
;
1122 WMPostNotificationName(WNIconAppearanceSettingsChanged
, NULL
,
1123 (void *)(uintptr_t) foo
);
1125 if (needs_refresh
& REFRESH_ICON_TILE
)
1126 WMPostNotificationName(WNIconTileSettingsChanged
, NULL
, NULL
);
1130 void wDefaultUpdateIcons(WScreen
* scr
)
1132 WAppIcon
*aicon
= scr
->app_icon_list
;
1133 WWindow
*wwin
= scr
->focused_window
;
1137 file
= wDefaultGetIconFile(scr
, aicon
->wm_instance
, aicon
->wm_class
, False
);
1138 if ((file
&& aicon
->icon
->file
&& strcmp(file
, aicon
->icon
->file
) != 0)
1139 || (file
&& !aicon
->icon
->file
)) {
1142 if (aicon
->icon
->file
)
1143 wfree(aicon
->icon
->file
);
1144 aicon
->icon
->file
= wstrdup(file
);
1146 new_image
= wDefaultGetImage(scr
, aicon
->wm_instance
, aicon
->wm_class
);
1148 wIconChangeImage(aicon
->icon
, new_image
);
1149 wAppIconPaint(aicon
);
1152 aicon
= aicon
->next
;
1155 if (!wPreferences
.flags
.noclip
)
1156 wClipIconPaint(scr
->clip_icon
);
1159 if (wwin
->icon
&& wwin
->flags
.miniaturized
) {
1160 file
= wDefaultGetIconFile(scr
, wwin
->wm_instance
, wwin
->wm_class
, False
);
1161 if ((file
&& wwin
->icon
->file
&& strcmp(file
, wwin
->icon
->file
) != 0)
1162 || (file
&& !wwin
->icon
->file
)) {
1165 if (wwin
->icon
->file
)
1166 wfree(wwin
->icon
->file
);
1167 wwin
->icon
->file
= wstrdup(file
);
1169 new_image
= wDefaultGetImage(scr
, wwin
->wm_instance
, wwin
->wm_class
);
1171 wIconChangeImage(wwin
->icon
, new_image
);
1178 /* --------------------------- Local ----------------------- */
1180 #define GET_STRING_OR_DEFAULT(x, var) if (!WMIsPLString(value)) { \
1181 wwarning(_("Wrong option format for key \"%s\". Should be %s."), \
1183 wwarning(_("using default \"%s\" instead"), entry->default_value); \
1184 var = entry->default_value;\
1185 } else var = WMGetFromPLString(value)\
1188 static int string2index(WMPropList * key, WMPropList * val, char *def, WOptionEnumeration * values)
1191 WOptionEnumeration
*v
;
1192 char buffer
[TOTAL_VALUES_LENGTH
];
1194 if (WMIsPLString(val
) && (str
= WMGetFromPLString(val
))) {
1195 for (v
= values
; v
->string
!= NULL
; v
++) {
1196 if (strcasecmp(v
->string
, str
) == 0)
1202 for (v
= values
; v
->string
!= NULL
; v
++) {
1205 strcat(buffer
, ", ");
1206 strcat(buffer
, v
->string
);
1209 wwarning(_("wrong option value for key \"%s\". Should be one of %s"), WMGetFromPLString(key
), buffer
);
1212 return string2index(key
, val
, NULL
, values
);
1219 * value - is the value in the defaults DB
1220 * addr - is the address to store the data
1221 * ret - is the address to store a pointer to a temporary buffer. ret
1222 * must not be freed and is used by the set functions
1224 static int getBool(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1228 int second_pass
= 0;
1230 GET_STRING_OR_DEFAULT("Boolean", val
);
1233 if ((val
[1] == '\0' && (val
[0] == 'y' || val
[0] == 'Y'))
1234 || strcasecmp(val
, "YES") == 0) {
1237 } else if ((val
[1] == '\0' && (val
[0] == 'n' || val
[0] == 'N'))
1238 || strcasecmp(val
, "NO") == 0) {
1242 if (sscanf(val
, "%i", &i
) == 1) {
1248 wwarning(_("can't convert \"%s\" to boolean for key \"%s\""), val
, entry
->key
);
1249 if (second_pass
== 0) {
1250 val
= WMGetFromPLString(entry
->plvalue
);
1252 wwarning(_("using default \"%s\" instead"), val
);
1262 *(char *)addr
= data
;
1267 static int getInt(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1272 GET_STRING_OR_DEFAULT("Integer", val
);
1274 if (sscanf(val
, "%i", &data
) != 1) {
1275 wwarning(_("can't convert \"%s\" to integer for key \"%s\""), val
, entry
->key
);
1276 val
= WMGetFromPLString(entry
->plvalue
);
1277 wwarning(_("using default \"%s\" instead"), val
);
1278 if (sscanf(val
, "%i", &data
) != 1) {
1286 *(int *)addr
= data
;
1291 static int getCoord(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1294 char *val_x
, *val_y
;
1295 int nelem
, changed
= 0;
1296 WMPropList
*elem_x
, *elem_y
;
1299 if (!WMIsPLArray(value
)) {
1300 wwarning(_("Wrong option format for key \"%s\". Should be %s."), entry
->key
, "Coordinate");
1302 value
= entry
->plvalue
;
1304 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1310 nelem
= WMGetPropListItemCount(value
);
1312 wwarning(_("Incorrect number of elements in array for key \"%s\"."), entry
->key
);
1314 value
= entry
->plvalue
;
1316 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1322 elem_x
= WMGetFromPLArray(value
, 0);
1323 elem_y
= WMGetFromPLArray(value
, 1);
1325 if (!elem_x
|| !elem_y
|| !WMIsPLString(elem_x
) || !WMIsPLString(elem_y
)) {
1326 wwarning(_("Wrong value for key \"%s\". Should be Coordinate."), entry
->key
);
1328 value
= entry
->plvalue
;
1330 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1336 val_x
= WMGetFromPLString(elem_x
);
1337 val_y
= WMGetFromPLString(elem_y
);
1339 if (sscanf(val_x
, "%i", &data
.x
) != 1 || sscanf(val_y
, "%i", &data
.y
) != 1) {
1340 wwarning(_("can't convert array to integers for \"%s\"."), entry
->key
);
1342 value
= entry
->plvalue
;
1344 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1352 else if (data
.x
> scr
->scr_width
/ 3)
1353 data
.x
= scr
->scr_width
/ 3;
1356 else if (data
.y
> scr
->scr_height
/ 3)
1357 data
.y
= scr
->scr_height
/ 3;
1362 *(WCoord
*) addr
= data
;
1367 static int getPropList(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1369 WMRetainPropList(value
);
1376 static int getPathList(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1385 if (!WMIsPLArray(value
)) {
1386 wwarning(_("Wrong option format for key \"%s\". Should be %s."), entry
->key
, "an array of paths");
1388 value
= entry
->plvalue
;
1390 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1397 count
= WMGetPropListItemCount(value
);
1400 value
= entry
->plvalue
;
1402 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1409 for (i
= 0; i
< count
; i
++) {
1410 d
= WMGetFromPLArray(value
, i
);
1411 if (!d
|| !WMIsPLString(d
)) {
1415 len
+= strlen(WMGetFromPLString(d
)) + 1;
1418 ptr
= data
= wmalloc(len
+ 1);
1420 for (i
= 0; i
< count
; i
++) {
1421 d
= WMGetFromPLArray(value
, i
);
1422 if (!d
|| !WMIsPLString(d
)) {
1425 strcpy(ptr
, WMGetFromPLString(d
));
1426 ptr
+= strlen(WMGetFromPLString(d
));
1433 if (*(char **)addr
!= NULL
) {
1434 wfree(*(char **)addr
);
1436 *(char **)addr
= data
;
1441 static int getEnum(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1443 static signed char data
;
1445 data
= string2index(entry
->plkey
, value
, entry
->default_value
, (WOptionEnumeration
*) entry
->extra_data
);
1452 *(signed char *)addr
= data
;
1459 * (hgradient <color> <color>)
1460 * (vgradient <color> <color>)
1461 * (dgradient <color> <color>)
1462 * (mhgradient <color> <color> ...)
1463 * (mvgradient <color> <color> ...)
1464 * (mdgradient <color> <color> ...)
1465 * (igradient <color1> <color1> <thickness1> <color2> <color2> <thickness2>)
1466 * (tpixmap <file> <color>)
1467 * (spixmap <file> <color>)
1468 * (cpixmap <file> <color>)
1469 * (thgradient <file> <opaqueness> <color> <color>)
1470 * (tvgradient <file> <opaqueness> <color> <color>)
1471 * (tdgradient <file> <opaqueness> <color> <color>)
1472 * (function <lib> <function> ...)
1475 static WTexture
*parse_texture(WScreen
* scr
, WMPropList
* pl
)
1480 WTexture
*texture
= NULL
;
1482 nelem
= WMGetPropListItemCount(pl
);
1486 elem
= WMGetFromPLArray(pl
, 0);
1487 if (!elem
|| !WMIsPLString(elem
))
1489 val
= WMGetFromPLString(elem
);
1491 if (strcasecmp(val
, "solid") == 0) {
1499 elem
= WMGetFromPLArray(pl
, 1);
1500 if (!elem
|| !WMIsPLString(elem
))
1502 val
= WMGetFromPLString(elem
);
1504 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &color
)) {
1505 wwarning(_("\"%s\" is not a valid color name"), val
);
1509 texture
= (WTexture
*) wTextureMakeSolid(scr
, &color
);
1510 } else if (strcasecmp(val
, "dgradient") == 0
1511 || strcasecmp(val
, "vgradient") == 0 || strcasecmp(val
, "hgradient") == 0) {
1512 RColor color1
, color2
;
1517 wwarning(_("bad number of arguments in gradient specification"));
1521 if (val
[0] == 'd' || val
[0] == 'D')
1522 type
= WTEX_DGRADIENT
;
1523 else if (val
[0] == 'h' || val
[0] == 'H')
1524 type
= WTEX_HGRADIENT
;
1526 type
= WTEX_VGRADIENT
;
1528 /* get from color */
1529 elem
= WMGetFromPLArray(pl
, 1);
1530 if (!elem
|| !WMIsPLString(elem
))
1532 val
= WMGetFromPLString(elem
);
1534 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1535 wwarning(_("\"%s\" is not a valid color name"), val
);
1539 color1
.red
= xcolor
.red
>> 8;
1540 color1
.green
= xcolor
.green
>> 8;
1541 color1
.blue
= xcolor
.blue
>> 8;
1544 elem
= WMGetFromPLArray(pl
, 2);
1545 if (!elem
|| !WMIsPLString(elem
)) {
1548 val
= WMGetFromPLString(elem
);
1550 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1551 wwarning(_("\"%s\" is not a valid color name"), val
);
1555 color2
.red
= xcolor
.red
>> 8;
1556 color2
.green
= xcolor
.green
>> 8;
1557 color2
.blue
= xcolor
.blue
>> 8;
1559 texture
= (WTexture
*) wTextureMakeGradient(scr
, type
, &color1
, &color2
);
1561 } else if (strcasecmp(val
, "igradient") == 0) {
1562 RColor colors1
[2], colors2
[2];
1568 wwarning(_("bad number of arguments in gradient specification"));
1572 /* get from color */
1573 for (i
= 0; i
< 2; i
++) {
1574 elem
= WMGetFromPLArray(pl
, 1 + i
);
1575 if (!elem
|| !WMIsPLString(elem
))
1577 val
= WMGetFromPLString(elem
);
1579 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1580 wwarning(_("\"%s\" is not a valid color name"), val
);
1583 colors1
[i
].alpha
= 255;
1584 colors1
[i
].red
= xcolor
.red
>> 8;
1585 colors1
[i
].green
= xcolor
.green
>> 8;
1586 colors1
[i
].blue
= xcolor
.blue
>> 8;
1588 elem
= WMGetFromPLArray(pl
, 3);
1589 if (!elem
|| !WMIsPLString(elem
))
1591 val
= WMGetFromPLString(elem
);
1594 /* get from color */
1595 for (i
= 0; i
< 2; i
++) {
1596 elem
= WMGetFromPLArray(pl
, 4 + i
);
1597 if (!elem
|| !WMIsPLString(elem
))
1599 val
= WMGetFromPLString(elem
);
1601 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1602 wwarning(_("\"%s\" is not a valid color name"), val
);
1605 colors2
[i
].alpha
= 255;
1606 colors2
[i
].red
= xcolor
.red
>> 8;
1607 colors2
[i
].green
= xcolor
.green
>> 8;
1608 colors2
[i
].blue
= xcolor
.blue
>> 8;
1610 elem
= WMGetFromPLArray(pl
, 6);
1611 if (!elem
|| !WMIsPLString(elem
))
1613 val
= WMGetFromPLString(elem
);
1616 texture
= (WTexture
*) wTextureMakeIGradient(scr
, th1
, colors1
, th2
, colors2
);
1618 } else if (strcasecmp(val
, "mhgradient") == 0
1619 || strcasecmp(val
, "mvgradient") == 0 || strcasecmp(val
, "mdgradient") == 0) {
1626 wwarning(_("too few arguments in multicolor gradient specification"));
1630 if (val
[1] == 'h' || val
[1] == 'H')
1631 type
= WTEX_MHGRADIENT
;
1632 else if (val
[1] == 'v' || val
[1] == 'V')
1633 type
= WTEX_MVGRADIENT
;
1635 type
= WTEX_MDGRADIENT
;
1639 colors
= wmalloc(sizeof(RColor
*) * (count
+ 1));
1641 for (i
= 0; i
< count
; i
++) {
1642 elem
= WMGetFromPLArray(pl
, i
+ 1);
1643 if (!elem
|| !WMIsPLString(elem
)) {
1644 for (--i
; i
>= 0; --i
) {
1650 val
= WMGetFromPLString(elem
);
1652 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &color
)) {
1653 wwarning(_("\"%s\" is not a valid color name"), val
);
1654 for (--i
; i
>= 0; --i
) {
1660 colors
[i
] = wmalloc(sizeof(RColor
));
1661 colors
[i
]->red
= color
.red
>> 8;
1662 colors
[i
]->green
= color
.green
>> 8;
1663 colors
[i
]->blue
= color
.blue
>> 8;
1668 texture
= (WTexture
*) wTextureMakeMGradient(scr
, type
, colors
);
1669 } else if (strcasecmp(val
, "spixmap") == 0 ||
1670 strcasecmp(val
, "cpixmap") == 0 || strcasecmp(val
, "tpixmap") == 0) {
1677 if (val
[0] == 's' || val
[0] == 'S')
1679 else if (val
[0] == 'c' || val
[0] == 'C')
1685 elem
= WMGetFromPLArray(pl
, 2);
1686 if (!elem
|| !WMIsPLString(elem
)) {
1689 val
= WMGetFromPLString(elem
);
1691 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &color
)) {
1692 wwarning(_("\"%s\" is not a valid color name"), val
);
1697 elem
= WMGetFromPLArray(pl
, 1);
1698 if (!elem
|| !WMIsPLString(elem
))
1700 val
= WMGetFromPLString(elem
);
1702 texture
= (WTexture
*) wTextureMakePixmap(scr
, type
, val
, &color
);
1703 } else if (strcasecmp(val
, "thgradient") == 0
1704 || strcasecmp(val
, "tvgradient") == 0 || strcasecmp(val
, "tdgradient") == 0) {
1705 RColor color1
, color2
;
1710 if (val
[1] == 'h' || val
[1] == 'H')
1711 style
= WTEX_THGRADIENT
;
1712 else if (val
[1] == 'v' || val
[1] == 'V')
1713 style
= WTEX_TVGRADIENT
;
1715 style
= WTEX_TDGRADIENT
;
1718 wwarning(_("bad number of arguments in textured gradient specification"));
1722 /* get from color */
1723 elem
= WMGetFromPLArray(pl
, 3);
1724 if (!elem
|| !WMIsPLString(elem
))
1726 val
= WMGetFromPLString(elem
);
1728 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1729 wwarning(_("\"%s\" is not a valid color name"), val
);
1733 color1
.red
= xcolor
.red
>> 8;
1734 color1
.green
= xcolor
.green
>> 8;
1735 color1
.blue
= xcolor
.blue
>> 8;
1738 elem
= WMGetFromPLArray(pl
, 4);
1739 if (!elem
|| !WMIsPLString(elem
)) {
1742 val
= WMGetFromPLString(elem
);
1744 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1745 wwarning(_("\"%s\" is not a valid color name"), val
);
1749 color2
.red
= xcolor
.red
>> 8;
1750 color2
.green
= xcolor
.green
>> 8;
1751 color2
.blue
= xcolor
.blue
>> 8;
1754 elem
= WMGetFromPLArray(pl
, 2);
1755 if (!elem
|| !WMIsPLString(elem
))
1758 val
= WMGetFromPLString(elem
);
1760 if (!val
|| (opacity
= atoi(val
)) < 0 || opacity
> 255) {
1761 wwarning(_("bad opacity value for tgradient texture \"%s\". Should be [0..255]"), val
);
1766 elem
= WMGetFromPLArray(pl
, 1);
1767 if (!elem
|| !WMIsPLString(elem
))
1769 val
= WMGetFromPLString(elem
);
1771 texture
= (WTexture
*) wTextureMakeTGradient(scr
, style
, &color1
, &color2
, val
, opacity
);
1772 } else if (strcasecmp(val
, "function") == 0) {
1773 /* Leave this in to handle the unlikely case of
1774 * someone actually having function textures configured */
1775 wwarning("function texture support has been removed");
1778 wwarning(_("invalid texture type %s"), val
);
1784 static int getTexture(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1786 static WTexture
*texture
;
1790 if (!WMIsPLArray(value
)) {
1791 wwarning(_("Wrong option format for key \"%s\". Should be %s."), entry
->key
, "Texture");
1793 value
= entry
->plvalue
;
1795 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1801 if (strcmp(entry
->key
, "WidgetColor") == 0 && !changed
) {
1804 pl
= WMGetFromPLArray(value
, 0);
1805 if (!pl
|| !WMIsPLString(pl
) || !WMGetFromPLString(pl
)
1806 || strcasecmp(WMGetFromPLString(pl
), "solid") != 0) {
1807 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1808 entry
->key
, "Solid Texture");
1810 value
= entry
->plvalue
;
1812 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1817 texture
= parse_texture(scr
, value
);
1820 wwarning(_("Error in texture specification for key \"%s\""), entry
->key
);
1822 value
= entry
->plvalue
;
1824 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1834 *(WTexture
**) addr
= texture
;
1839 static int getWSBackground(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1847 if (!WMIsPLArray(value
)) {
1848 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1849 "WorkspaceBack", "Texture or None");
1851 value
= entry
->plvalue
;
1853 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1859 /* only do basic error checking and verify for None texture */
1861 nelem
= WMGetPropListItemCount(value
);
1863 elem
= WMGetFromPLArray(value
, 0);
1864 if (!elem
|| !WMIsPLString(elem
)) {
1865 wwarning(_("Wrong type for workspace background. Should be a texture type."));
1867 value
= entry
->plvalue
;
1869 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1874 val
= WMGetFromPLString(elem
);
1876 if (strcasecmp(val
, "None") == 0)
1879 *ret
= WMRetainPropList(value
);
1885 getWSSpecificBackground(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1892 if (!WMIsPLArray(value
)) {
1893 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1894 "WorkspaceSpecificBack", "an array of textures");
1896 value
= entry
->plvalue
;
1898 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1904 /* only do basic error checking and verify for None texture */
1906 nelem
= WMGetPropListItemCount(value
);
1909 elem
= WMGetFromPLArray(value
, nelem
);
1910 if (!elem
|| !WMIsPLArray(elem
)) {
1911 wwarning(_("Wrong type for background of workspace %i. Should be a texture."),
1917 *ret
= WMRetainPropList(value
);
1921 * Kluge to force wmsetbg helper to set the default background.
1922 * If the WorkspaceSpecificBack is changed once wmaker has started,
1923 * the WorkspaceBack won't be sent to the helper, unless the user
1924 * changes it's value too. So, we must force this by removing the
1925 * value from the defaults DB.
1927 if (!scr
->flags
.backimage_helper_launched
&& !scr
->flags
.startup
) {
1928 WMPropList
*key
= WMCreatePLString("WorkspaceBack");
1930 WMRemoveFromPLDictionary(WDWindowMaker
->dictionary
, key
);
1932 WMReleasePropList(key
);
1938 static int getFont(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1940 static WMFont
*font
;
1943 GET_STRING_OR_DEFAULT("Font", val
);
1945 font
= WMCreateFont(scr
->wmscreen
, val
);
1947 font
= WMCreateFont(scr
->wmscreen
, "fixed");
1950 wfatal(_("could not load any usable font!!!"));
1957 /* can't assign font value outside update function */
1958 wassertrv(addr
== NULL
, True
);
1963 static int getColor(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1965 static XColor color
;
1967 int second_pass
= 0;
1969 GET_STRING_OR_DEFAULT("Color", val
);
1972 if (!wGetColor(scr
, val
, &color
)) {
1973 wwarning(_("could not get color for key \"%s\""), entry
->key
);
1974 if (second_pass
== 0) {
1975 val
= WMGetFromPLString(entry
->plvalue
);
1977 wwarning(_("using default \"%s\" instead"), val
);
1986 assert(addr
== NULL
);
1989 *(unsigned long*)addr = pixel;
1995 static int getKeybind(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1997 static WShortKey shortcut
;
2001 char buf
[MAX_SHORTCUT_LENGTH
], *b
;
2003 GET_STRING_OR_DEFAULT("Key spec", val
);
2005 if (!val
|| strcasecmp(val
, "NONE") == 0) {
2006 shortcut
.keycode
= 0;
2007 shortcut
.modifier
= 0;
2013 strncpy(buf
, val
, MAX_SHORTCUT_LENGTH
);
2018 shortcut
.modifier
= 0;
2019 while ((k
= strchr(b
, '+')) != NULL
) {
2023 mod
= wXModifierFromKey(b
);
2025 wwarning(_("%s: invalid key modifier \"%s\""), entry
->key
, b
);
2028 shortcut
.modifier
|= mod
;
2034 ksym
= XStringToKeysym(b
);
2036 if (ksym
== NoSymbol
) {
2037 wwarning(_("%s:invalid kbd shortcut specification \"%s\""), entry
->key
, val
);
2041 shortcut
.keycode
= XKeysymToKeycode(dpy
, ksym
);
2042 if (shortcut
.keycode
== 0) {
2043 wwarning(_("%s:invalid key in shortcut \"%s\""), entry
->key
, val
);
2053 static int getModMask(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
2058 GET_STRING_OR_DEFAULT("Modifier Key", str
);
2063 mask
= wXModifierFromKey(str
);
2065 wwarning(_("%s: modifier key %s is not valid"), entry
->key
, str
);
2071 *(int *)addr
= mask
;
2079 # include <X11/cursorfont.h>
2085 #define CURSOR_ID_NONE (XC_num_glyphs)
2087 static WCursorLookup cursor_table
[] = {
2088 {"X_cursor", XC_X_cursor
},
2089 {"arrow", XC_arrow
},
2090 {"based_arrow_down", XC_based_arrow_down
},
2091 {"based_arrow_up", XC_based_arrow_up
},
2093 {"bogosity", XC_bogosity
},
2094 {"bottom_left_corner", XC_bottom_left_corner
},
2095 {"bottom_right_corner", XC_bottom_right_corner
},
2096 {"bottom_side", XC_bottom_side
},
2097 {"bottom_tee", XC_bottom_tee
},
2098 {"box_spiral", XC_box_spiral
},
2099 {"center_ptr", XC_center_ptr
},
2100 {"circle", XC_circle
},
2101 {"clock", XC_clock
},
2102 {"coffee_mug", XC_coffee_mug
},
2103 {"cross", XC_cross
},
2104 {"cross_reverse", XC_cross_reverse
},
2105 {"crosshair", XC_crosshair
},
2106 {"diamond_cross", XC_diamond_cross
},
2108 {"dotbox", XC_dotbox
},
2109 {"double_arrow", XC_double_arrow
},
2110 {"draft_large", XC_draft_large
},
2111 {"draft_small", XC_draft_small
},
2112 {"draped_box", XC_draped_box
},
2113 {"exchange", XC_exchange
},
2114 {"fleur", XC_fleur
},
2115 {"gobbler", XC_gobbler
},
2116 {"gumby", XC_gumby
},
2117 {"hand1", XC_hand1
},
2118 {"hand2", XC_hand2
},
2119 {"heart", XC_heart
},
2121 {"iron_cross", XC_iron_cross
},
2122 {"left_ptr", XC_left_ptr
},
2123 {"left_side", XC_left_side
},
2124 {"left_tee", XC_left_tee
},
2125 {"leftbutton", XC_leftbutton
},
2126 {"ll_angle", XC_ll_angle
},
2127 {"lr_angle", XC_lr_angle
},
2129 {"middlebutton", XC_middlebutton
},
2130 {"mouse", XC_mouse
},
2131 {"pencil", XC_pencil
},
2132 {"pirate", XC_pirate
},
2134 {"question_arrow", XC_question_arrow
},
2135 {"right_ptr", XC_right_ptr
},
2136 {"right_side", XC_right_side
},
2137 {"right_tee", XC_right_tee
},
2138 {"rightbutton", XC_rightbutton
},
2139 {"rtl_logo", XC_rtl_logo
},
2140 {"sailboat", XC_sailboat
},
2141 {"sb_down_arrow", XC_sb_down_arrow
},
2142 {"sb_h_double_arrow", XC_sb_h_double_arrow
},
2143 {"sb_left_arrow", XC_sb_left_arrow
},
2144 {"sb_right_arrow", XC_sb_right_arrow
},
2145 {"sb_up_arrow", XC_sb_up_arrow
},
2146 {"sb_v_double_arrow", XC_sb_v_double_arrow
},
2147 {"shuttle", XC_shuttle
},
2148 {"sizing", XC_sizing
},
2149 {"spider", XC_spider
},
2150 {"spraycan", XC_spraycan
},
2152 {"target", XC_target
},
2153 {"tcross", XC_tcross
},
2154 {"top_left_arrow", XC_top_left_arrow
},
2155 {"top_left_corner", XC_top_left_corner
},
2156 {"top_right_corner", XC_top_right_corner
},
2157 {"top_side", XC_top_side
},
2158 {"top_tee", XC_top_tee
},
2160 {"ul_angle", XC_ul_angle
},
2161 {"umbrella", XC_umbrella
},
2162 {"ur_angle", XC_ur_angle
},
2163 {"watch", XC_watch
},
2164 {"xterm", XC_xterm
},
2165 {NULL
, CURSOR_ID_NONE
}
2168 static void check_bitmap_status(int status
, char *filename
, Pixmap bitmap
)
2171 case BitmapOpenFailed
:
2172 wwarning(_("failed to open bitmap file \"%s\""), filename
);
2174 case BitmapFileInvalid
:
2175 wwarning(_("\"%s\" is not a valid bitmap file"), filename
);
2177 case BitmapNoMemory
:
2178 wwarning(_("out of memory reading bitmap file \"%s\""), filename
);
2181 XFreePixmap(dpy
, bitmap
);
2188 * (builtin, <cursor_name>)
2189 * (bitmap, <cursor_bitmap>, <cursor_mask>)
2191 static int parse_cursor(WScreen
* scr
, WMPropList
* pl
, Cursor
* cursor
)
2198 nelem
= WMGetPropListItemCount(pl
);
2202 elem
= WMGetFromPLArray(pl
, 0);
2203 if (!elem
|| !WMIsPLString(elem
)) {
2206 val
= WMGetFromPLString(elem
);
2208 if (strcasecmp(val
, "none") == 0) {
2211 } else if (strcasecmp(val
, "builtin") == 0) {
2213 int cursor_id
= CURSOR_ID_NONE
;
2216 wwarning(_("bad number of arguments in cursor specification"));
2219 elem
= WMGetFromPLArray(pl
, 1);
2220 if (!elem
|| !WMIsPLString(elem
)) {
2223 val
= WMGetFromPLString(elem
);
2225 for (i
= 0; cursor_table
[i
].name
!= NULL
; i
++) {
2226 if (strcasecmp(val
, cursor_table
[i
].name
) == 0) {
2227 cursor_id
= cursor_table
[i
].id
;
2231 if (CURSOR_ID_NONE
== cursor_id
) {
2232 wwarning(_("unknown builtin cursor name \"%s\""), val
);
2234 *cursor
= XCreateFontCursor(dpy
, cursor_id
);
2237 } else if (strcasecmp(val
, "bitmap") == 0) {
2249 wwarning(_("bad number of arguments in cursor specification"));
2252 elem
= WMGetFromPLArray(pl
, 1);
2253 if (!elem
|| !WMIsPLString(elem
)) {
2256 val
= WMGetFromPLString(elem
);
2257 bitmap_name
= FindImage(wPreferences
.pixmap_path
, val
);
2259 wwarning(_("could not find cursor bitmap file \"%s\""), val
);
2262 elem
= WMGetFromPLArray(pl
, 2);
2263 if (!elem
|| !WMIsPLString(elem
)) {
2267 val
= WMGetFromPLString(elem
);
2268 mask_name
= FindImage(wPreferences
.pixmap_path
, val
);
2271 wwarning(_("could not find cursor bitmap file \"%s\""), val
);
2274 mask_status
= XReadBitmapFile(dpy
, scr
->w_win
, mask_name
, &w
, &h
, &mask
, &x
, &y
);
2275 bitmap_status
= XReadBitmapFile(dpy
, scr
->w_win
, bitmap_name
, &w
, &h
, &bitmap
, &x
, &y
);
2276 if ((BitmapSuccess
== bitmap_status
) && (BitmapSuccess
== mask_status
)) {
2277 fg
.pixel
= scr
->black_pixel
;
2278 bg
.pixel
= scr
->white_pixel
;
2279 XQueryColor(dpy
, scr
->w_colormap
, &fg
);
2280 XQueryColor(dpy
, scr
->w_colormap
, &bg
);
2281 *cursor
= XCreatePixmapCursor(dpy
, bitmap
, mask
, &fg
, &bg
, x
, y
);
2284 check_bitmap_status(bitmap_status
, bitmap_name
, bitmap
);
2285 check_bitmap_status(mask_status
, mask_name
, mask
);
2292 static int getCursor(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
2294 static Cursor cursor
;
2299 if (!WMIsPLArray(value
)) {
2300 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
2301 entry
->key
, "cursor specification");
2303 value
= entry
->plvalue
;
2305 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
2310 status
= parse_cursor(scr
, value
, &cursor
);
2312 wwarning(_("Error in cursor specification for key \"%s\""), entry
->key
);
2314 value
= entry
->plvalue
;
2316 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
2325 *(Cursor
*) addr
= cursor
;
2330 #undef CURSOR_ID_NONE
2332 /* ---------------- value setting functions --------------- */
2333 static int setJustify(WScreen
* scr
, WDefaultEntry
* entry
, WTexture
** texture
, void *foo
)
2335 return REFRESH_WINDOW_TITLE_COLOR
;
2338 static int setClearance(WScreen
* scr
, WDefaultEntry
* entry
, void *bar
, void *foo
)
2340 return REFRESH_WINDOW_FONT
| REFRESH_BUTTON_IMAGES
| REFRESH_MENU_TITLE_FONT
| REFRESH_MENU_FONT
;
2343 static int setIfDockPresent(WScreen
* scr
, WDefaultEntry
* entry
, char *flag
, long which
)
2347 wPreferences
.flags
.nodock
= wPreferences
.flags
.nodock
|| *flag
;
2350 wPreferences
.flags
.noclip
= wPreferences
.flags
.noclip
|| *flag
;
2358 static int setStickyIcons(WScreen
* scr
, WDefaultEntry
* entry
, void *bar
, void *foo
)
2360 if (scr
->workspaces
) {
2361 wWorkspaceForceChange(scr
, scr
->current_workspace
);
2362 wArrangeIcons(scr
, False
);
2367 static int setIconTile(WScreen
* scr
, WDefaultEntry
* entry
, WTexture
** texture
, void *foo
)
2373 img
= wTextureRenderImage(*texture
, wPreferences
.icon_size
,
2374 wPreferences
.icon_size
, ((*texture
)->any
.type
& WREL_BORDER_MASK
)
2375 ? WREL_ICON
: WREL_FLAT
);
2377 wwarning(_("could not render texture for icon background"));
2379 wTextureDestroy(scr
, *texture
);
2382 RConvertImage(scr
->rcontext
, img
, &pixmap
);
2384 if (scr
->icon_tile
) {
2386 RReleaseImage(scr
->icon_tile
);
2387 XFreePixmap(dpy
, scr
->icon_tile_pixmap
);
2390 scr
->icon_tile
= img
;
2392 /* put the icon in the noticeboard hint */
2393 PropSetIconTileHint(scr
, img
);
2395 if (!wPreferences
.flags
.noclip
) {
2396 if (scr
->clip_tile
) {
2397 RReleaseImage(scr
->clip_tile
);
2399 scr
->clip_tile
= wClipMakeTile(scr
, img
);
2402 scr
->icon_tile_pixmap
= pixmap
;
2404 if (scr
->def_icon_pixmap
) {
2405 XFreePixmap(dpy
, scr
->def_icon_pixmap
);
2406 scr
->def_icon_pixmap
= None
;
2408 if (scr
->def_ticon_pixmap
) {
2409 XFreePixmap(dpy
, scr
->def_ticon_pixmap
);
2410 scr
->def_ticon_pixmap
= None
;
2413 if (scr
->icon_back_texture
) {
2414 wTextureDestroy(scr
, (WTexture
*) scr
->icon_back_texture
);
2416 scr
->icon_back_texture
= wTextureMakeSolid(scr
, &((*texture
)->any
.color
));
2418 if (scr
->clip_balloon
)
2419 XSetWindowBackground(dpy
, scr
->clip_balloon
, (*texture
)->any
.color
.pixel
);
2422 * Free the texture as nobody else will use it, nor refer to it.
2425 wTextureDestroy(scr
, *texture
);
2427 return (reset
? REFRESH_ICON_TILE
: 0);
2430 static int setWinTitleFont(WScreen
* scr
, WDefaultEntry
* entry
, WMFont
* font
, void *foo
)
2432 if (scr
->title_font
) {
2433 WMReleaseFont(scr
->title_font
);
2435 scr
->title_font
= font
;
2437 return REFRESH_WINDOW_FONT
| REFRESH_BUTTON_IMAGES
;
2440 static int setMenuTitleFont(WScreen
* scr
, WDefaultEntry
* entry
, WMFont
* font
, void *foo
)
2442 if (scr
->menu_title_font
) {
2443 WMReleaseFont(scr
->menu_title_font
);
2446 scr
->menu_title_font
= font
;
2448 return REFRESH_MENU_TITLE_FONT
;
2451 static int setMenuTextFont(WScreen
* scr
, WDefaultEntry
* entry
, WMFont
* font
, void *foo
)
2453 if (scr
->menu_entry_font
) {
2454 WMReleaseFont(scr
->menu_entry_font
);
2456 scr
->menu_entry_font
= font
;
2458 return REFRESH_MENU_FONT
;
2461 static int setIconTitleFont(WScreen
* scr
, WDefaultEntry
* entry
, WMFont
* font
, void *foo
)
2463 if (scr
->icon_title_font
) {
2464 WMReleaseFont(scr
->icon_title_font
);
2467 scr
->icon_title_font
= font
;
2469 return REFRESH_ICON_FONT
;
2472 static int setClipTitleFont(WScreen
* scr
, WDefaultEntry
* entry
, WMFont
* font
, void *foo
)
2474 if (scr
->clip_title_font
) {
2475 WMReleaseFont(scr
->clip_title_font
);
2478 scr
->clip_title_font
= font
;
2480 return REFRESH_ICON_FONT
;
2483 static int setLargeDisplayFont(WScreen
* scr
, WDefaultEntry
* entry
, WMFont
* font
, void *foo
)
2485 if (scr
->workspace_name_font
) {
2486 WMReleaseFont(scr
->workspace_name_font
);
2489 scr
->workspace_name_font
= font
;
2494 static int setHightlight(WScreen
* scr
, WDefaultEntry
* entry
, XColor
* color
, void *foo
)
2496 if (scr
->select_color
)
2497 WMReleaseColor(scr
->select_color
);
2499 scr
->select_color
= WMCreateRGBColor(scr
->wmscreen
, color
->red
, color
->green
, color
->blue
, True
);
2501 wFreeColor(scr
, color
->pixel
);
2503 return REFRESH_MENU_COLOR
;
2506 static int setHightlightText(WScreen
* scr
, WDefaultEntry
* entry
, XColor
* color
, void *foo
)
2508 if (scr
->select_text_color
)
2509 WMReleaseColor(scr
->select_text_color
);
2511 scr
->select_text_color
= WMCreateRGBColor(scr
->wmscreen
, color
->red
, color
->green
, color
->blue
, True
);
2513 wFreeColor(scr
, color
->pixel
);
2515 return REFRESH_MENU_COLOR
;
2518 static int setClipTitleColor(WScreen
* scr
, WDefaultEntry
* entry
, XColor
* color
, long widx
)
2520 if (scr
->clip_title_color
[widx
])
2521 WMReleaseColor(scr
->clip_title_color
[widx
]);
2522 scr
->clip_title_color
[widx
] = WMCreateRGBColor(scr
->wmscreen
, color
->red
, color
->green
, color
->blue
, True
);
2523 #ifdef GRADIENT_CLIP_ARROW
2524 if (widx
== CLIP_NORMAL
) {
2526 RColor color1
, color2
;
2527 int pt
= CLIP_BUTTON_SIZE
* wPreferences
.icon_size
/ 64;
2528 int as
= pt
- 15; /* 15 = 5+5+5 */
2530 FREE_PIXMAP(scr
->clip_arrow_gradient
);
2532 color1
.red
= (color
->red
>> 8) * 6 / 10;
2533 color1
.green
= (color
->green
>> 8) * 6 / 10;
2534 color1
.blue
= (color
->blue
>> 8) * 6 / 10;
2536 color2
.red
= WMIN((color
->red
>> 8) * 20 / 10, 255);
2537 color2
.green
= WMIN((color
->green
>> 8) * 20 / 10, 255);
2538 color2
.blue
= WMIN((color
->blue
>> 8) * 20 / 10, 255);
2540 image
= RRenderGradient(as
+ 1, as
+ 1, &color1
, &color2
, RDiagonalGradient
);
2541 RConvertImage(scr
->rcontext
, image
, &scr
->clip_arrow_gradient
);
2542 RReleaseImage(image
);
2544 #endif /* GRADIENT_CLIP_ARROW */
2546 wFreeColor(scr
, color
->pixel
);
2548 return REFRESH_ICON_TITLE_COLOR
;
2551 static int setWTitleColor(WScreen
* scr
, WDefaultEntry
* entry
, XColor
* color
, long widx
)
2553 if (scr
->window_title_color
[widx
])
2554 WMReleaseColor(scr
->window_title_color
[widx
]);
2556 scr
->window_title_color
[widx
] =
2557 WMCreateRGBColor(scr
->wmscreen
, color
->red
, color
->green
, color
->blue
, True
);
2559 wFreeColor(scr
, color
->pixel
);
2561 return REFRESH_WINDOW_TITLE_COLOR
;
2564 static int setMenuTitleColor(WScreen
* scr
, WDefaultEntry
* entry
, XColor
* color
, long widx
)
2566 if (scr
->menu_title_color
[0])
2567 WMReleaseColor(scr
->menu_title_color
[0]);
2569 scr
->menu_title_color
[0] = WMCreateRGBColor(scr
->wmscreen
, color
->red
, color
->green
, color
->blue
, True
);
2571 wFreeColor(scr
, color
->pixel
);
2573 return REFRESH_MENU_TITLE_COLOR
;
2576 static int setMenuTextColor(WScreen
* scr
, WDefaultEntry
* entry
, XColor
* color
, void *foo
)
2578 if (scr
->mtext_color
)
2579 WMReleaseColor(scr
->mtext_color
);
2581 scr
->mtext_color
= WMCreateRGBColor(scr
->wmscreen
, color
->red
, color
->green
, color
->blue
, True
);
2583 if (WMColorPixel(scr
->dtext_color
) == WMColorPixel(scr
->mtext_color
)) {
2584 WMSetColorAlpha(scr
->dtext_color
, 0x7fff);
2586 WMSetColorAlpha(scr
->dtext_color
, 0xffff);
2589 wFreeColor(scr
, color
->pixel
);
2591 return REFRESH_MENU_COLOR
;
2594 static int setMenuDisabledColor(WScreen
* scr
, WDefaultEntry
* entry
, XColor
* color
, void *foo
)
2596 if (scr
->dtext_color
)
2597 WMReleaseColor(scr
->dtext_color
);
2599 scr
->dtext_color
= WMCreateRGBColor(scr
->wmscreen
, color
->red
, color
->green
, color
->blue
, True
);
2601 if (WMColorPixel(scr
->dtext_color
) == WMColorPixel(scr
->mtext_color
)) {
2602 WMSetColorAlpha(scr
->dtext_color
, 0x7fff);
2604 WMSetColorAlpha(scr
->dtext_color
, 0xffff);
2607 wFreeColor(scr
, color
->pixel
);
2609 return REFRESH_MENU_COLOR
;
2612 static int setIconTitleColor(WScreen
* scr
, WDefaultEntry
* entry
, XColor
* color
, void *foo
)
2614 if (scr
->icon_title_color
)
2615 WMReleaseColor(scr
->icon_title_color
);
2616 scr
->icon_title_color
= WMCreateRGBColor(scr
->wmscreen
, color
->red
, color
->green
, color
->blue
, True
);
2618 wFreeColor(scr
, color
->pixel
);
2620 return REFRESH_ICON_TITLE_COLOR
;
2623 static int setIconTitleBack(WScreen
* scr
, WDefaultEntry
* entry
, XColor
* color
, void *foo
)
2625 if (scr
->icon_title_texture
) {
2626 wTextureDestroy(scr
, (WTexture
*) scr
->icon_title_texture
);
2628 scr
->icon_title_texture
= wTextureMakeSolid(scr
, color
);
2630 return REFRESH_ICON_TITLE_BACK
;
2633 static void trackDeadProcess(pid_t pid
, unsigned char status
, WScreen
* scr
)
2635 close(scr
->helper_fd
);
2637 scr
->helper_pid
= 0;
2638 scr
->flags
.backimage_helper_launched
= 0;
2641 static int setWorkspaceSpecificBack(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *bar
)
2647 if (scr
->flags
.backimage_helper_launched
) {
2648 if (WMGetPropListItemCount(value
) == 0) {
2649 SendHelperMessage(scr
, 'C', 0, NULL
);
2650 SendHelperMessage(scr
, 'K', 0, NULL
);
2652 WMReleasePropList(value
);
2659 if (WMGetPropListItemCount(value
) == 0)
2662 if (pipe(filedes
) < 0) {
2663 wsyserror("pipe() failed:can't set workspace specific background image");
2665 WMReleasePropList(value
);
2671 wsyserror("fork() failed:can't set workspace specific background image");
2672 if (close(filedes
[0]) < 0)
2673 wsyserror("could not close pipe");
2674 if (close(filedes
[1]) < 0)
2675 wsyserror("could not close pipe");
2677 } else if (pid
== 0) {
2680 SetupEnvironment(scr
);
2683 wsyserror("could not close pipe");
2684 if (dup(filedes
[0]) < 0) {
2685 wsyserror("dup() failed:can't set workspace specific background image");
2687 dither
= wPreferences
.no_dithering
? "-m" : "-d";
2688 if (wPreferences
.smooth_workspace_back
)
2689 execlp("wmsetbg", "wmsetbg", "-helper", "-S", dither
, NULL
);
2691 execlp("wmsetbg", "wmsetbg", "-helper", dither
, NULL
);
2692 wsyserror("could not execute wmsetbg");
2696 if (fcntl(filedes
[0], F_SETFD
, FD_CLOEXEC
) < 0) {
2697 wsyserror("error setting close-on-exec flag");
2699 if (fcntl(filedes
[1], F_SETFD
, FD_CLOEXEC
) < 0) {
2700 wsyserror("error setting close-on-exec flag");
2703 scr
->helper_fd
= filedes
[1];
2704 scr
->helper_pid
= pid
;
2705 scr
->flags
.backimage_helper_launched
= 1;
2707 wAddDeathHandler(pid
, (WDeathHandler
*) trackDeadProcess
, scr
);
2709 SendHelperMessage(scr
, 'P', -1, wPreferences
.pixmap_path
);
2714 for (i
= 0; i
< WMGetPropListItemCount(value
); i
++) {
2715 val
= WMGetFromPLArray(value
, i
);
2716 if (val
&& WMIsPLArray(val
) && WMGetPropListItemCount(val
) > 0) {
2717 str
= WMGetPropListDescription(val
, False
);
2719 SendHelperMessage(scr
, 'S', i
+ 1, str
);
2723 SendHelperMessage(scr
, 'U', i
+ 1, NULL
);
2728 WMReleasePropList(value
);
2732 static int setWorkspaceBack(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *bar
)
2734 if (scr
->flags
.backimage_helper_launched
) {
2737 if (WMGetPropListItemCount(value
) == 0) {
2738 SendHelperMessage(scr
, 'U', 0, NULL
);
2740 /* set the default workspace background to this one */
2741 str
= WMGetPropListDescription(value
, False
);
2743 SendHelperMessage(scr
, 'S', 0, str
);
2745 SendHelperMessage(scr
, 'C', scr
->current_workspace
+ 1, NULL
);
2747 SendHelperMessage(scr
, 'U', 0, NULL
);
2750 } else if (WMGetPropListItemCount(value
) > 0) {
2756 text
= WMGetPropListDescription(value
, False
);
2757 len
= strlen(text
) + 40;
2758 command
= wmalloc(len
);
2759 dither
= wPreferences
.no_dithering
? "-m" : "-d";
2760 if (wPreferences
.smooth_workspace_back
)
2761 snprintf(command
, len
, "wmsetbg %s -S -p '%s' &", dither
, text
);
2763 snprintf(command
, len
, "wmsetbg %s -p '%s' &", dither
, text
);
2765 ExecuteShellCommand(scr
, command
);
2768 WMReleasePropList(value
);
2773 static int setWidgetColor(WScreen
* scr
, WDefaultEntry
* entry
, WTexture
** texture
, void *foo
)
2775 if (scr
->widget_texture
) {
2776 wTextureDestroy(scr
, (WTexture
*) scr
->widget_texture
);
2778 scr
->widget_texture
= *(WTexSolid
**) texture
;
2783 static int setFTitleBack(WScreen
* scr
, WDefaultEntry
* entry
, WTexture
** texture
, void *foo
)
2785 if (scr
->window_title_texture
[WS_FOCUSED
]) {
2786 wTextureDestroy(scr
, scr
->window_title_texture
[WS_FOCUSED
]);
2788 scr
->window_title_texture
[WS_FOCUSED
] = *texture
;
2790 return REFRESH_WINDOW_TEXTURES
;
2793 static int setPTitleBack(WScreen
* scr
, WDefaultEntry
* entry
, WTexture
** texture
, void *foo
)
2795 if (scr
->window_title_texture
[WS_PFOCUSED
]) {
2796 wTextureDestroy(scr
, scr
->window_title_texture
[WS_PFOCUSED
]);
2798 scr
->window_title_texture
[WS_PFOCUSED
] = *texture
;
2800 return REFRESH_WINDOW_TEXTURES
;
2803 static int setUTitleBack(WScreen
* scr
, WDefaultEntry
* entry
, WTexture
** texture
, void *foo
)
2805 if (scr
->window_title_texture
[WS_UNFOCUSED
]) {
2806 wTextureDestroy(scr
, scr
->window_title_texture
[WS_UNFOCUSED
]);
2808 scr
->window_title_texture
[WS_UNFOCUSED
] = *texture
;
2810 return REFRESH_WINDOW_TEXTURES
;
2813 static int setResizebarBack(WScreen
* scr
, WDefaultEntry
* entry
, WTexture
** texture
, void *foo
)
2815 if (scr
->resizebar_texture
[0]) {
2816 wTextureDestroy(scr
, scr
->resizebar_texture
[0]);
2818 scr
->resizebar_texture
[0] = *texture
;
2820 return REFRESH_WINDOW_TEXTURES
;
2823 static int setMenuTitleBack(WScreen
* scr
, WDefaultEntry
* entry
, WTexture
** texture
, void *foo
)
2825 if (scr
->menu_title_texture
[0]) {
2826 wTextureDestroy(scr
, scr
->menu_title_texture
[0]);
2828 scr
->menu_title_texture
[0] = *texture
;
2830 return REFRESH_MENU_TITLE_TEXTURE
;
2833 static int setMenuTextBack(WScreen
* scr
, WDefaultEntry
* entry
, WTexture
** texture
, void *foo
)
2835 if (scr
->menu_item_texture
) {
2836 wTextureDestroy(scr
, scr
->menu_item_texture
);
2837 wTextureDestroy(scr
, (WTexture
*) scr
->menu_item_auxtexture
);
2839 scr
->menu_item_texture
= *texture
;
2841 scr
->menu_item_auxtexture
= wTextureMakeSolid(scr
, &scr
->menu_item_texture
->any
.color
);
2843 return REFRESH_MENU_TEXTURE
;
2846 static int setKeyGrab(WScreen
* scr
, WDefaultEntry
* entry
, WShortKey
* shortcut
, long widx
)
2849 wKeyBindings
[widx
] = *shortcut
;
2851 wwin
= scr
->focused_window
;
2853 while (wwin
!= NULL
) {
2854 XUngrabKey(dpy
, AnyKey
, AnyModifier
, wwin
->frame
->core
->window
);
2856 if (!WFLAGP(wwin
, no_bind_keys
)) {
2857 wWindowSetKeyGrabs(wwin
);
2865 static int setIconPosition(WScreen
* scr
, WDefaultEntry
* entry
, void *bar
, void *foo
)
2867 wScreenUpdateUsableArea(scr
);
2868 wArrangeIcons(scr
, True
);
2873 static int updateUsableArea(WScreen
* scr
, WDefaultEntry
* entry
, void *bar
, void *foo
)
2875 wScreenUpdateUsableArea(scr
);
2880 static int setMenuStyle(WScreen
* scr
, WDefaultEntry
* entry
, int *value
, void *foo
)
2882 return REFRESH_MENU_TEXTURE
;
2885 static RImage
*chopOffImage(RImage
* image
, int x
, int y
, int w
, int h
)
2887 RImage
*img
= RCreateImage(w
, h
, image
->format
== RRGBAFormat
);
2889 RCopyArea(img
, image
, x
, y
, w
, h
, 0, 0);
2894 static int setSwPOptions(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* array
, void *foo
)
2898 int cwidth
, cheight
;
2899 WPreferences
*prefs
= (WPreferences
*) foo
;
2901 if (!WMIsPLArray(array
) || WMGetPropListItemCount(array
) == 0) {
2902 if (prefs
->swtileImage
)
2903 RReleaseImage(prefs
->swtileImage
);
2904 prefs
->swtileImage
= NULL
;
2906 WMReleasePropList(array
);
2910 switch (WMGetPropListItemCount(array
)) {
2912 if (!WMIsPLString(WMGetFromPLArray(array
, 1))) {
2913 wwarning(_("Invalid arguments for option \"%s\""), entry
->key
);
2916 path
= FindImage(wPreferences
.pixmap_path
, WMGetFromPLString(WMGetFromPLArray(array
, 1)));
2919 wwarning(_("Could not find image \"%s\" for option \"%s\""),
2920 WMGetFromPLString(WMGetFromPLArray(array
, 1)), entry
->key
);
2922 bgimage
= RLoadImage(scr
->rcontext
, path
, 0);
2924 wwarning(_("Could not load image \"%s\" for option \"%s\""), path
, entry
->key
);
2929 cwidth
= atoi(WMGetFromPLString(WMGetFromPLArray(array
, 2)));
2930 cheight
= atoi(WMGetFromPLString(WMGetFromPLArray(array
, 3)));
2932 if (cwidth
<= 0 || cheight
<= 0 ||
2933 cwidth
>= bgimage
->width
- 2 || cheight
>= bgimage
->height
- 2)
2934 wwarning(_("Invalid split sizes for SwitchPanel back image."));
2937 int swidth
, theight
;
2938 for (i
= 0; i
< 9; i
++) {
2939 if (prefs
->swbackImage
[i
])
2940 RReleaseImage(prefs
->swbackImage
[i
]);
2941 prefs
->swbackImage
[i
] = NULL
;
2943 swidth
= (bgimage
->width
- cwidth
) / 2;
2944 theight
= (bgimage
->height
- cheight
) / 2;
2946 prefs
->swbackImage
[0] = chopOffImage(bgimage
, 0, 0, swidth
, theight
);
2947 prefs
->swbackImage
[1] = chopOffImage(bgimage
, swidth
, 0, cwidth
, theight
);
2948 prefs
->swbackImage
[2] = chopOffImage(bgimage
, swidth
+ cwidth
, 0,
2951 prefs
->swbackImage
[3] = chopOffImage(bgimage
, 0, theight
, swidth
, cheight
);
2952 prefs
->swbackImage
[4] = chopOffImage(bgimage
, swidth
, theight
,
2954 prefs
->swbackImage
[5] = chopOffImage(bgimage
, swidth
+ cwidth
, theight
,
2957 prefs
->swbackImage
[6] = chopOffImage(bgimage
, 0, theight
+ cheight
,
2959 prefs
->swbackImage
[7] = chopOffImage(bgimage
, swidth
, theight
+ cheight
,
2961 prefs
->swbackImage
[8] =
2962 chopOffImage(bgimage
, swidth
+ cwidth
, theight
+ cheight
, swidth
,
2965 // check if anything failed
2966 for (i
= 0; i
< 9; i
++) {
2967 if (!prefs
->swbackImage
[i
]) {
2968 for (; i
>= 0; --i
) {
2969 RReleaseImage(prefs
->swbackImage
[i
]);
2970 prefs
->swbackImage
[i
] = NULL
;
2976 RReleaseImage(bgimage
);
2981 if (!WMIsPLString(WMGetFromPLArray(array
, 0))) {
2982 wwarning(_("Invalid arguments for option \"%s\""), entry
->key
);
2985 path
= FindImage(wPreferences
.pixmap_path
, WMGetFromPLString(WMGetFromPLArray(array
, 0)));
2988 wwarning(_("Could not find image \"%s\" for option \"%s\""),
2989 WMGetFromPLString(WMGetFromPLArray(array
, 0)), entry
->key
);
2991 if (prefs
->swtileImage
)
2992 RReleaseImage(prefs
->swtileImage
);
2994 prefs
->swtileImage
= RLoadImage(scr
->rcontext
, path
, 0);
2995 if (!prefs
->swtileImage
) {
2996 wwarning(_("Could not load image \"%s\" for option \"%s\""), path
, entry
->key
);
3003 wwarning(_("Invalid number of arguments for option \"%s\""), entry
->key
);
3007 WMReleasePropList(array
);
3014 * Need access to the double click variables, so that all widgets in
3015 * wmaker panels will have the same dbl-click values.
3016 * TODO: figure a better way of dealing with it.
3018 #include <WINGs/WINGsP.h>
3020 static int setDoubleClick(WScreen
* scr
, WDefaultEntry
* entry
, int *value
, void *foo
)
3022 extern _WINGsConfiguration WINGsConfiguration
;
3027 WINGsConfiguration
.doubleClickDelay
= *value
;
3032 static int setCursor(WScreen
* scr
, WDefaultEntry
* entry
, Cursor
* cursor
, long widx
)
3034 if (wCursor
[widx
] != None
) {
3035 XFreeCursor(dpy
, wCursor
[widx
]);
3038 wCursor
[widx
] = *cursor
;
3040 if (widx
== WCUR_ROOT
&& *cursor
!= None
) {
3041 XDefineCursor(dpy
, scr
->root_win
, *cursor
);