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 seColormapModes
[] = {
189 {"Manual", WCM_CLICK
, 0}, {"ClickToFocus", WCM_CLICK
, 1},
190 {"Auto", WCM_POINTER
, 0}, {"FocusFollowMouse", WCM_POINTER
, 1},
194 static WOptionEnumeration sePlacements
[] = {
195 {"Auto", WPM_AUTO
, 0},
196 {"Smart", WPM_SMART
, 0},
197 {"Cascade", WPM_CASCADE
, 0},
198 {"Random", WPM_RANDOM
, 0},
199 {"Manual", WPM_MANUAL
, 0},
203 static WOptionEnumeration seGeomDisplays
[] = {
204 {"None", WDIS_NONE
, 0},
205 {"Center", WDIS_CENTER
, 0},
206 {"Corner", WDIS_TOPLEFT
, 0},
207 {"Floating", WDIS_FRAME_CENTER
, 0},
208 {"Line", WDIS_NEW
, 0},
212 static WOptionEnumeration seSpeeds
[] = {
213 {"UltraFast", SPEED_ULTRAFAST
, 0},
214 {"Fast", SPEED_FAST
, 0},
215 {"Medium", SPEED_MEDIUM
, 0},
216 {"Slow", SPEED_SLOW
, 0},
217 {"UltraSlow", SPEED_ULTRASLOW
, 0},
221 static WOptionEnumeration seMouseButtonActions
[] = {
222 {"None", WA_NONE
, 0},
223 {"SelectWindows", WA_SELECT_WINDOWS
, 0},
224 {"OpenApplicationsMenu", WA_OPEN_APPMENU
, 0},
225 {"OpenWindowListMenu", WA_OPEN_WINLISTMENU
, 0},
229 static WOptionEnumeration seMouseWheelActions
[] = {
230 {"None", WA_NONE
, 0},
231 {"SwitchWorkspaces", WA_SWITCH_WORKSPACES
, 0},
235 static WOptionEnumeration seIconificationStyles
[] = {
236 {"Zoom", WIS_ZOOM
, 0},
237 {"Twist", WIS_TWIST
, 0},
238 {"Flip", WIS_FLIP
, 0},
239 {"None", WIS_NONE
, 0},
240 {"random", WIS_RANDOM
, 0},
244 static WOptionEnumeration seJustifications
[] = {
245 {"Left", WTJ_LEFT
, 0},
246 {"Center", WTJ_CENTER
, 0},
247 {"Right", WTJ_RIGHT
, 0},
251 static WOptionEnumeration seIconPositions
[] = {
252 {"blv", IY_BOTTOM
| IY_LEFT
| IY_VERT
, 0},
253 {"blh", IY_BOTTOM
| IY_LEFT
| IY_HORIZ
, 0},
254 {"brv", IY_BOTTOM
| IY_RIGHT
| IY_VERT
, 0},
255 {"brh", IY_BOTTOM
| IY_RIGHT
| IY_HORIZ
, 0},
256 {"tlv", IY_TOP
| IY_LEFT
| IY_VERT
, 0},
257 {"tlh", IY_TOP
| IY_LEFT
| IY_HORIZ
, 0},
258 {"trv", IY_TOP
| IY_RIGHT
| IY_VERT
, 0},
259 {"trh", IY_TOP
| IY_RIGHT
| IY_HORIZ
, 0},
263 static WOptionEnumeration seMenuStyles
[] = {
264 {"normal", MS_NORMAL
, 0},
265 {"singletexture", MS_SINGLE_TEXTURE
, 0},
266 {"flat", MS_FLAT
, 0},
270 static WOptionEnumeration seDisplayPositions
[] = {
271 {"none", WD_NONE
, 0},
272 {"center", WD_CENTER
, 0},
274 {"bottom", WD_BOTTOM
, 0},
275 {"topleft", WD_TOPLEFT
, 0},
276 {"topright", WD_TOPRIGHT
, 0},
277 {"bottomleft", WD_BOTTOMLEFT
, 0},
278 {"bottomright", WD_BOTTOMRIGHT
, 0},
282 static WOptionEnumeration seWorkspaceBorder
[] = {
283 {"None", WB_NONE
, 0},
284 {"LeftRight", WB_LEFTRIGHT
, 0},
285 {"TopBottom", WB_TOPBOTTOM
, 0},
286 {"AllDirections", WB_ALLDIRS
, 0},
291 * ALL entries in the tables bellow, NEED to have a default value
292 * defined, and this value needs to be correct.
295 /* these options will only affect the window manager on startup
297 * static defaults can't access the screen data, because it is
298 * created after these defaults are read
300 WDefaultEntry staticOptionList
[] = {
302 {"ColormapSize", "4", NULL
,
303 &wPreferences
.cmap_size
, getInt
, NULL
, NULL
, NULL
},
304 {"DisableDithering", "NO", NULL
,
305 &wPreferences
.no_dithering
, getBool
, NULL
, NULL
, NULL
},
306 {"IconSize", "64", NULL
,
307 &wPreferences
.icon_size
, getInt
, NULL
, NULL
, NULL
},
308 {"ModifierKey", "Mod1", NULL
,
309 &wPreferences
.modifier_mask
, getModMask
, NULL
, NULL
, NULL
},
310 {"DisableWSMouseActions", "NO", NULL
,
311 &wPreferences
.disable_root_mouse
, getBool
, NULL
, NULL
, NULL
},
312 {"FocusMode", "manual", seFocusModes
, /* have a problem when switching from */
313 &wPreferences
.focus_mode
, getEnum
, NULL
, NULL
, NULL
}, /* manual to sloppy without restart */
314 {"NewStyle", "NO", NULL
,
315 &wPreferences
.new_style
, getBool
, NULL
, NULL
, NULL
},
316 {"DisableDock", "NO", (void *)WM_DOCK
,
317 NULL
, getBool
, setIfDockPresent
, NULL
, NULL
},
318 {"DisableClip", "NO", (void *)WM_CLIP
,
319 NULL
, getBool
, setIfDockPresent
, NULL
, NULL
},
320 {"DisableMiniwindows", "NO", NULL
,
321 &wPreferences
.disable_miniwindows
, getBool
, NULL
, NULL
, NULL
}
324 WDefaultEntry optionList
[] = {
326 /* dynamic options */
328 {"IconPosition", "blh", seIconPositions
,
329 &wPreferences
.icon_yard
, getEnum
, setIconPosition
, NULL
, NULL
},
330 {"IconificationStyle", "Zoom", seIconificationStyles
,
331 &wPreferences
.iconification_style
, getEnum
, NULL
, NULL
, NULL
},
332 {"MouseLeftButtonAction", "SelectWindows", seMouseButtonActions
,
333 &wPreferences
.mouse_button1
, getEnum
, NULL
, NULL
, NULL
},
334 {"MouseMiddleButtonAction", "OpenWindowListMenu", seMouseButtonActions
,
335 &wPreferences
.mouse_button2
, getEnum
, NULL
, NULL
, NULL
},
336 {"MouseRightButtonAction", "OpenApplicationsMenu", seMouseButtonActions
,
337 &wPreferences
.mouse_button3
, getEnum
, NULL
, NULL
, NULL
},
338 {"MouseWheelAction", "None", seMouseWheelActions
,
339 &wPreferences
.mouse_wheel
, getEnum
, NULL
, NULL
, NULL
},
340 {"PixmapPath", DEF_PIXMAP_PATHS
, NULL
,
341 &wPreferences
.pixmap_path
, getPathList
, NULL
, NULL
, NULL
},
342 {"IconPath", DEF_ICON_PATHS
, NULL
,
343 &wPreferences
.icon_path
, getPathList
, NULL
, NULL
, NULL
},
344 {"ColormapMode", "auto", seColormapModes
,
345 &wPreferences
.colormap_mode
, getEnum
, NULL
, NULL
, NULL
},
346 {"AutoFocus", "NO", NULL
,
347 &wPreferences
.auto_focus
, getBool
, NULL
, NULL
, NULL
},
348 {"RaiseDelay", "0", NULL
,
349 &wPreferences
.raise_delay
, getInt
, NULL
, NULL
, NULL
},
350 {"CirculateRaise", "NO", NULL
,
351 &wPreferences
.circ_raise
, getBool
, NULL
, NULL
, NULL
},
352 {"Superfluous", "NO", NULL
,
353 &wPreferences
.superfluous
, getBool
, NULL
, NULL
, NULL
},
354 {"AdvanceToNewWorkspace", "NO", NULL
,
355 &wPreferences
.ws_advance
, getBool
, NULL
, NULL
, NULL
},
356 {"CycleWorkspaces", "NO", NULL
,
357 &wPreferences
.ws_cycle
, getBool
, NULL
, NULL
, NULL
},
358 {"WorkspaceNameDisplayPosition", "center", seDisplayPositions
,
359 &wPreferences
.workspace_name_display_position
, getEnum
, NULL
, NULL
, NULL
},
360 {"WorkspaceBorder", "None", seWorkspaceBorder
,
361 &wPreferences
.workspace_border_position
, getEnum
, updateUsableArea
, NULL
, NULL
},
362 {"WorkspaceBorderSize", "0", NULL
,
363 &wPreferences
.workspace_border_size
, getInt
, updateUsableArea
, NULL
, NULL
},
364 {"StickyIcons", "NO", NULL
,
365 &wPreferences
.sticky_icons
, getBool
, setStickyIcons
, NULL
, NULL
},
366 {"SaveSessionOnExit", "NO", NULL
,
367 &wPreferences
.save_session_on_exit
, getBool
, NULL
, NULL
, NULL
},
368 {"WrapMenus", "NO", NULL
,
369 &wPreferences
.wrap_menus
, getBool
, NULL
, NULL
, NULL
},
370 {"ScrollableMenus", "NO", NULL
,
371 &wPreferences
.scrollable_menus
, getBool
, NULL
, NULL
, NULL
},
372 {"MenuScrollSpeed", "medium", seSpeeds
,
373 &wPreferences
.menu_scroll_speed
, getEnum
, NULL
, NULL
, NULL
},
374 {"IconSlideSpeed", "medium", seSpeeds
,
375 &wPreferences
.icon_slide_speed
, getEnum
, NULL
, NULL
, NULL
},
376 {"ShadeSpeed", "medium", seSpeeds
,
377 &wPreferences
.shade_speed
, getEnum
, NULL
, NULL
, NULL
},
378 {"DoubleClickTime", "250", (void *)&wPreferences
.dblclick_time
,
379 &wPreferences
.dblclick_time
, getInt
, setDoubleClick
, NULL
, NULL
},
380 {"AlignSubmenus", "NO", NULL
,
381 &wPreferences
.align_menus
, getBool
, NULL
, NULL
, NULL
},
382 {"OpenTransientOnOwnerWorkspace", "NO", NULL
,
383 &wPreferences
.open_transients_with_parent
, getBool
, NULL
, NULL
, NULL
},
384 {"WindowPlacement", "auto", sePlacements
,
385 &wPreferences
.window_placement
, getEnum
, NULL
, NULL
, NULL
},
386 {"IgnoreFocusClick", "NO", NULL
,
387 &wPreferences
.ignore_focus_click
, getBool
, NULL
, NULL
, NULL
},
388 {"UseSaveUnders", "NO", NULL
,
389 &wPreferences
.use_saveunders
, getBool
, NULL
, NULL
, NULL
},
390 {"OpaqueMove", "NO", NULL
,
391 &wPreferences
.opaque_move
, getBool
, NULL
, NULL
, NULL
},
392 {"DisableAnimations", "NO", NULL
,
393 &wPreferences
.no_animations
, getBool
, NULL
, NULL
, NULL
},
394 {"DontLinkWorkspaces", "NO", NULL
,
395 &wPreferences
.no_autowrap
, getBool
, NULL
, NULL
, NULL
},
396 {"AutoArrangeIcons", "NO", NULL
,
397 &wPreferences
.auto_arrange_icons
, getBool
, NULL
, NULL
, NULL
},
398 {"NoWindowOverDock", "NO", NULL
,
399 &wPreferences
.no_window_over_dock
, getBool
, updateUsableArea
, NULL
, NULL
},
400 {"NoWindowOverIcons", "NO", NULL
,
401 &wPreferences
.no_window_over_icons
, getBool
, updateUsableArea
, NULL
, NULL
},
402 {"WindowPlaceOrigin", "(0, 0)", NULL
,
403 &wPreferences
.window_place_origin
, getCoord
, NULL
, NULL
, NULL
},
404 {"ResizeDisplay", "corner", seGeomDisplays
,
405 &wPreferences
.size_display
, getEnum
, NULL
, NULL
, NULL
},
406 {"MoveDisplay", "corner", seGeomDisplays
,
407 &wPreferences
.move_display
, getEnum
, NULL
, NULL
, NULL
},
408 {"DontConfirmKill", "NO", NULL
,
409 &wPreferences
.dont_confirm_kill
, getBool
, NULL
, NULL
, NULL
},
410 {"WindowTitleBalloons", "NO", NULL
,
411 &wPreferences
.window_balloon
, getBool
, NULL
, NULL
, NULL
},
412 {"MiniwindowTitleBalloons", "NO", NULL
,
413 &wPreferences
.miniwin_balloon
, getBool
, NULL
, NULL
, NULL
},
414 {"AppIconBalloons", "NO", NULL
,
415 &wPreferences
.appicon_balloon
, getBool
, NULL
, NULL
, NULL
},
416 {"HelpBalloons", "NO", NULL
,
417 &wPreferences
.help_balloon
, getBool
, NULL
, NULL
, NULL
},
418 {"EdgeResistance", "30", NULL
,
419 &wPreferences
.edge_resistance
, getInt
, NULL
, NULL
, NULL
},
420 {"ResizeIncrement", "32", NULL
,
421 &wPreferences
.resize_increment
, getInt
, NULL
, NULL
, NULL
},
422 {"Attraction", "NO", NULL
,
423 &wPreferences
.attract
, getBool
, NULL
, NULL
, NULL
},
424 {"DisableBlinking", "NO", NULL
,
425 &wPreferences
.dont_blink
, getBool
, NULL
, NULL
, NULL
},
426 {"SingleClickLaunch", "NO", NULL
,
427 &wPreferences
.single_click
, getBool
, NULL
, NULL
, NULL
},
431 {"MenuStyle", "normal", seMenuStyles
,
432 &wPreferences
.menu_style
, getEnum
, setMenuStyle
, NULL
, NULL
},
433 {"WidgetColor", "(solid, gray)", NULL
,
434 NULL
, getTexture
, setWidgetColor
, NULL
, NULL
},
435 {"WorkspaceSpecificBack", "()", NULL
,
436 NULL
, getWSSpecificBackground
, setWorkspaceSpecificBack
, NULL
, NULL
},
437 /* WorkspaceBack must come after WorkspaceSpecificBack or
438 * WorkspaceBack wont know WorkspaceSpecificBack was also
439 * specified and 2 copies of wmsetbg will be launched */
440 {"WorkspaceBack", "(solid, black)", NULL
,
441 NULL
, getWSBackground
, setWorkspaceBack
, NULL
, NULL
},
442 {"SmoothWorkspaceBack", "NO", NULL
,
443 NULL
, getBool
, NULL
, NULL
, NULL
},
444 {"IconBack", "(solid, gray)", NULL
,
445 NULL
, getTexture
, setIconTile
, NULL
, NULL
},
446 {"TitleJustify", "center", seJustifications
,
447 &wPreferences
.title_justification
, getEnum
, setJustify
, NULL
, NULL
},
448 {"WindowTitleFont", DEF_TITLE_FONT
, NULL
,
449 NULL
, getFont
, setWinTitleFont
, NULL
, NULL
},
450 {"WindowTitleExtendSpace", DEF_WINDOW_TITLE_EXTEND_SPACE
, NULL
,
451 &wPreferences
.window_title_clearance
, getInt
, setClearance
, NULL
, NULL
},
452 {"MenuTitleExtendSpace", DEF_MENU_TITLE_EXTEND_SPACE
, NULL
,
453 &wPreferences
.menu_title_clearance
, getInt
, setClearance
, NULL
, NULL
},
454 {"MenuTextExtendSpace", DEF_MENU_TEXT_EXTEND_SPACE
, NULL
,
455 &wPreferences
.menu_text_clearance
, getInt
, setClearance
, NULL
, NULL
},
456 {"MenuTitleFont", DEF_MENU_TITLE_FONT
, NULL
,
457 NULL
, getFont
, setMenuTitleFont
, NULL
, NULL
},
458 {"MenuTextFont", DEF_MENU_ENTRY_FONT
, NULL
,
459 NULL
, getFont
, setMenuTextFont
, NULL
, NULL
},
460 {"IconTitleFont", DEF_ICON_TITLE_FONT
, NULL
,
461 NULL
, getFont
, setIconTitleFont
, NULL
, NULL
},
462 {"ClipTitleFont", DEF_CLIP_TITLE_FONT
, NULL
,
463 NULL
, getFont
, setClipTitleFont
, NULL
, NULL
},
464 {"LargeDisplayFont", DEF_WORKSPACE_NAME_FONT
, NULL
,
465 NULL
, getFont
, setLargeDisplayFont
, NULL
, NULL
},
466 {"HighlightColor", "white", NULL
,
467 NULL
, getColor
, setHightlight
, NULL
, NULL
},
468 {"HighlightTextColor", "black", NULL
,
469 NULL
, getColor
, setHightlightText
, NULL
, NULL
},
470 {"ClipTitleColor", "black", (void *)CLIP_NORMAL
,
471 NULL
, getColor
, setClipTitleColor
, NULL
, NULL
},
472 {"CClipTitleColor", "\"#454045\"", (void *)CLIP_COLLAPSED
,
473 NULL
, getColor
, setClipTitleColor
, NULL
, NULL
},
474 {"FTitleColor", "white", (void *)WS_FOCUSED
,
475 NULL
, getColor
, setWTitleColor
, NULL
, NULL
},
476 {"PTitleColor", "white", (void *)WS_PFOCUSED
,
477 NULL
, getColor
, setWTitleColor
, NULL
, NULL
},
478 {"UTitleColor", "black", (void *)WS_UNFOCUSED
,
479 NULL
, getColor
, setWTitleColor
, NULL
, NULL
},
480 {"FTitleBack", "(solid, black)", NULL
,
481 NULL
, getTexture
, setFTitleBack
, NULL
, NULL
},
482 {"PTitleBack", "(solid, \"#616161\")", NULL
,
483 NULL
, getTexture
, setPTitleBack
, NULL
, NULL
},
484 {"UTitleBack", "(solid, gray)", NULL
,
485 NULL
, getTexture
, setUTitleBack
, NULL
, NULL
},
486 {"ResizebarBack", "(solid, gray)", NULL
,
487 NULL
, getTexture
, setResizebarBack
, NULL
, NULL
},
488 {"MenuTitleColor", "white", NULL
,
489 NULL
, getColor
, setMenuTitleColor
, NULL
, NULL
},
490 {"MenuTextColor", "black", NULL
,
491 NULL
, getColor
, setMenuTextColor
, NULL
, NULL
},
492 {"MenuDisabledColor", "\"#616161\"", NULL
,
493 NULL
, getColor
, setMenuDisabledColor
, NULL
, NULL
},
494 {"MenuTitleBack", "(solid, black)", NULL
,
495 NULL
, getTexture
, setMenuTitleBack
, NULL
, NULL
},
496 {"MenuTextBack", "(solid, gray)", NULL
,
497 NULL
, getTexture
, setMenuTextBack
, NULL
, NULL
},
498 {"IconTitleColor", "white", NULL
,
499 NULL
, getColor
, setIconTitleColor
, NULL
, NULL
},
500 {"IconTitleBack", "black", NULL
,
501 NULL
, getColor
, setIconTitleBack
, NULL
, NULL
},
502 {"SwitchPanelImages", "(swtile.png, swback.png, 30, 40)", &wPreferences
,
503 NULL
, getPropList
, setSwPOptions
, NULL
, NULL
},
507 {"RootMenuKey", "None", (void *)WKBD_ROOTMENU
,
508 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
509 {"WindowListKey", "None", (void *)WKBD_WINDOWLIST
,
510 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
511 {"WindowMenuKey", "None", (void *)WKBD_WINDOWMENU
,
512 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
513 {"DockRaiseLowerKey", "None", (void*)WKBD_DOCKRAISELOWER
,
514 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
515 {"ClipRaiseLowerKey", "None", (void *)WKBD_CLIPRAISELOWER
,
516 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
517 {"MiniaturizeKey", "None", (void *)WKBD_MINIATURIZE
,
518 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
519 {"HideKey", "None", (void *)WKBD_HIDE
,
520 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
521 {"HideOthersKey", "None", (void *)WKBD_HIDE_OTHERS
,
522 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
523 {"MoveResizeKey", "None", (void *)WKBD_MOVERESIZE
,
524 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
525 {"CloseKey", "None", (void *)WKBD_CLOSE
,
526 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
527 {"MaximizeKey", "None", (void *)WKBD_MAXIMIZE
,
528 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
529 {"VMaximizeKey", "None", (void *)WKBD_VMAXIMIZE
,
530 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
531 {"HMaximizeKey", "None", (void *)WKBD_HMAXIMIZE
,
532 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
533 {"LHMaximizeKey", "None", (void*)WKBD_LHMAXIMIZE
,
534 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
535 {"RHMaximizeKey", "None", (void*)WKBD_RHMAXIMIZE
,
536 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
537 {"MaximusKey", "None", (void*)WKBD_MAXIMUS
,
538 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
539 {"RaiseKey", "\"Meta+Up\"", (void *)WKBD_RAISE
,
540 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
541 {"LowerKey", "\"Meta+Down\"", (void *)WKBD_LOWER
,
542 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
543 {"RaiseLowerKey", "None", (void *)WKBD_RAISELOWER
,
544 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
545 {"ShadeKey", "None", (void *)WKBD_SHADE
,
546 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
547 {"SelectKey", "None", (void *)WKBD_SELECT
,
548 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
549 {"FocusNextKey", "None", (void *)WKBD_FOCUSNEXT
,
550 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
551 {"FocusPrevKey", "None", (void *)WKBD_FOCUSPREV
,
552 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
553 {"GroupNextKey", "None", (void *)WKBD_GROUPNEXT
,
554 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
555 {"GroupPrevKey", "None", (void *)WKBD_GROUPPREV
,
556 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
557 {"NextWorkspaceKey", "None", (void *)WKBD_NEXTWORKSPACE
,
558 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
559 {"PrevWorkspaceKey", "None", (void *)WKBD_PREVWORKSPACE
,
560 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
561 {"NextWorkspaceLayerKey", "None", (void *)WKBD_NEXTWSLAYER
,
562 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
563 {"PrevWorkspaceLayerKey", "None", (void *)WKBD_PREVWSLAYER
,
564 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
565 {"Workspace1Key", "None", (void *)WKBD_WORKSPACE1
,
566 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
567 {"Workspace2Key", "None", (void *)WKBD_WORKSPACE2
,
568 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
569 {"Workspace3Key", "None", (void *)WKBD_WORKSPACE3
,
570 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
571 {"Workspace4Key", "None", (void *)WKBD_WORKSPACE4
,
572 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
573 {"Workspace5Key", "None", (void *)WKBD_WORKSPACE5
,
574 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
575 {"Workspace6Key", "None", (void *)WKBD_WORKSPACE6
,
576 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
577 {"Workspace7Key", "None", (void *)WKBD_WORKSPACE7
,
578 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
579 {"Workspace8Key", "None", (void *)WKBD_WORKSPACE8
,
580 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
581 {"Workspace9Key", "None", (void *)WKBD_WORKSPACE9
,
582 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
583 {"Workspace10Key", "None", (void *)WKBD_WORKSPACE10
,
584 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
585 {"WindowShortcut1Key", "None", (void *)WKBD_WINDOW1
,
586 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
587 {"WindowShortcut2Key", "None", (void *)WKBD_WINDOW2
,
588 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
589 {"WindowShortcut3Key", "None", (void *)WKBD_WINDOW3
,
590 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
591 {"WindowShortcut4Key", "None", (void *)WKBD_WINDOW4
,
592 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
593 {"WindowShortcut5Key", "None", (void *)WKBD_WINDOW5
,
594 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
595 {"WindowShortcut6Key", "None", (void *)WKBD_WINDOW6
,
596 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
597 {"WindowShortcut7Key", "None", (void *)WKBD_WINDOW7
,
598 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
599 {"WindowShortcut8Key", "None", (void *)WKBD_WINDOW8
,
600 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
601 {"WindowShortcut9Key", "None", (void *)WKBD_WINDOW9
,
602 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
603 {"WindowShortcut10Key", "None", (void *)WKBD_WINDOW10
,
604 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
605 {"ScreenSwitchKey", "None", (void *)WKBD_SWITCH_SCREEN
,
606 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
608 #ifdef KEEP_XKB_LOCK_STATUS
609 {"ToggleKbdModeKey", "None", (void *)WKBD_TOGGLE
,
610 NULL
, getKeybind
, setKeyGrab
, NULL
, NULL
},
611 {"KbdModeLock", "NO", NULL
,
612 &wPreferences
.modelock
, getBool
, NULL
, NULL
, NULL
},
613 #endif /* KEEP_XKB_LOCK_STATUS */
615 {"NormalCursor", "(builtin, left_ptr)", (void *)WCUR_ROOT
,
616 NULL
, getCursor
, setCursor
, NULL
, NULL
},
617 {"ArrowCursor", "(builtin, top_left_arrow)", (void *)WCUR_ARROW
,
618 NULL
, getCursor
, setCursor
, NULL
, NULL
},
619 {"MoveCursor", "(builtin, fleur)", (void *)WCUR_MOVE
,
620 NULL
, getCursor
, setCursor
, NULL
, NULL
},
621 {"ResizeCursor", "(builtin, sizing)", (void *)WCUR_RESIZE
,
622 NULL
, getCursor
, setCursor
, NULL
, NULL
},
623 {"TopLeftResizeCursor", "(builtin, top_left_corner)", (void *)WCUR_TOPLEFTRESIZE
,
624 NULL
, getCursor
, setCursor
, NULL
, NULL
},
625 {"TopRightResizeCursor", "(builtin, top_right_corner)", (void *)WCUR_TOPRIGHTRESIZE
,
626 NULL
, getCursor
, setCursor
, NULL
, NULL
},
627 {"BottomLeftResizeCursor", "(builtin, bottom_left_corner)", (void *)WCUR_BOTTOMLEFTRESIZE
,
628 NULL
, getCursor
, setCursor
, NULL
, NULL
},
629 {"BottomRightResizeCursor", "(builtin, bottom_right_corner)", (void *)WCUR_BOTTOMRIGHTRESIZE
,
630 NULL
, getCursor
, setCursor
, NULL
, NULL
},
631 {"VerticalResizeCursor", "(builtin, sb_v_double_arrow)", (void *)WCUR_VERTICALRESIZE
,
632 NULL
, getCursor
, setCursor
, NULL
, NULL
},
633 {"HorizontalResizeCursor", "(builtin, sb_h_double_arrow)", (void *)WCUR_HORIZONRESIZE
,
634 NULL
, getCursor
, setCursor
, NULL
, NULL
},
635 {"WaitCursor", "(builtin, watch)", (void *)WCUR_WAIT
,
636 NULL
, getCursor
, setCursor
, NULL
, NULL
},
637 {"QuestionCursor", "(builtin, question_arrow)", (void *)WCUR_QUESTION
,
638 NULL
, getCursor
, setCursor
, NULL
, NULL
},
639 {"TextCursor", "(builtin, xterm)", (void *)WCUR_TEXT
,
640 NULL
, getCursor
, setCursor
, NULL
, NULL
},
641 {"SelectCursor", "(builtin, cross)", (void *)WCUR_SELECT
,
642 NULL
, getCursor
, setCursor
, NULL
, NULL
},
643 {"DialogHistoryLines", "500", NULL
,
644 &wPreferences
.history_lines
, getInt
, NULL
, NULL
, NULL
},
645 {"CycleActiveHeadOnly", "NO", NULL
,
646 &wPreferences
.cycle_active_head_only
, getBool
, NULL
, NULL
, NULL
}
649 static void initDefaults()
652 WDefaultEntry
*entry
;
654 WMPLSetCaseSensitive(False
);
656 for (i
= 0; i
< sizeof(optionList
) / sizeof(WDefaultEntry
); i
++) {
657 entry
= &optionList
[i
];
659 entry
->plkey
= WMCreatePLString(entry
->key
);
660 if (entry
->default_value
)
661 entry
->plvalue
= WMCreatePropListFromDescription(entry
->default_value
);
663 entry
->plvalue
= NULL
;
666 for (i
= 0; i
< sizeof(staticOptionList
) / sizeof(WDefaultEntry
); i
++) {
667 entry
= &staticOptionList
[i
];
669 entry
->plkey
= WMCreatePLString(entry
->key
);
670 if (entry
->default_value
)
671 entry
->plvalue
= WMCreatePropListFromDescription(entry
->default_value
);
673 entry
->plvalue
= NULL
;
677 static WMPropList
*readGlobalDomain(char *domainName
, Bool requireDictionary
)
679 WMPropList
*globalDict
= NULL
;
683 snprintf(path
, sizeof(path
), "%s/%s/%s", SYSCONFDIR
, GLOBAL_DEFAULTS_SUBDIR
, domainName
);
684 if (stat(path
, &stbuf
) >= 0) {
685 globalDict
= WMReadPropListFromFile(path
);
686 if (globalDict
&& requireDictionary
&& !WMIsPLDictionary(globalDict
)) {
687 wwarning(_("Domain %s (%s) of global defaults database is corrupted!"), domainName
, path
);
688 WMReleasePropList(globalDict
);
690 } else if (!globalDict
) {
691 wwarning(_("could not load domain %s from global defaults database"), domainName
);
698 #if defined(GLOBAL_PREAMBLE_MENU_FILE) || defined(GLOBAL_EPILOGUE_MENU_FILE)
699 static void prependMenu(WMPropList
* destarr
, WMPropList
* array
)
704 for (i
= 0; i
< WMGetPropListItemCount(array
); i
++) {
705 item
= WMGetFromPLArray(array
, i
);
707 WMInsertInPLArray(destarr
, i
+ 1, item
);
711 static void appendMenu(WMPropList
* destarr
, WMPropList
* array
)
716 for (i
= 0; i
< WMGetPropListItemCount(array
); i
++) {
717 item
= WMGetFromPLArray(array
, i
);
719 WMAddToPLArray(destarr
, item
);
724 void wDefaultsMergeGlobalMenus(WDDomain
* menuDomain
)
726 WMPropList
*menu
= menuDomain
->dictionary
;
729 if (!menu
|| !WMIsPLArray(menu
))
732 #ifdef GLOBAL_PREAMBLE_MENU_FILE
733 submenu
= WMReadPropListFromFile(SYSCONFDIR
"/" GLOBAL_DEFAULTS_SUBDIR
"/" GLOBAL_PREAMBLE_MENU_FILE
);
735 if (submenu
&& !WMIsPLArray(submenu
)) {
736 wwarning(_("invalid global menu file %s"), GLOBAL_PREAMBLE_MENU_FILE
);
737 WMReleasePropList(submenu
);
741 prependMenu(menu
, submenu
);
742 WMReleasePropList(submenu
);
746 #ifdef GLOBAL_EPILOGUE_MENU_FILE
747 submenu
= WMReadPropListFromFile(SYSCONFDIR
"/" GLOBAL_DEFAULTS_SUBDIR
"/" GLOBAL_EPILOGUE_MENU_FILE
);
749 if (submenu
&& !WMIsPLArray(submenu
)) {
750 wwarning(_("invalid global menu file %s"), GLOBAL_EPILOGUE_MENU_FILE
);
751 WMReleasePropList(submenu
);
755 appendMenu(menu
, submenu
);
756 WMReleasePropList(submenu
);
760 menuDomain
->dictionary
= menu
;
763 void wDefaultsDestroyDomain(WDDomain
* domain
)
765 if (domain
->dictionary
)
766 WMReleasePropList(domain
->dictionary
);
771 WDDomain
*wDefaultsInitDomain(char *domain
, Bool requireDictionary
)
775 static int inited
= 0;
778 WMPropList
*shared_dict
= NULL
;
785 db
= wmalloc(sizeof(WDDomain
));
786 memset(db
, 0, sizeof(WDDomain
));
787 db
->domain_name
= domain
;
788 db
->path
= wdefaultspathfordomain(domain
);
791 if (the_path
&& stat(the_path
, &stbuf
) >= 0) {
792 db
->dictionary
= WMReadPropListFromFile(the_path
);
793 if (db
->dictionary
) {
794 if (requireDictionary
&& !WMIsPLDictionary(db
->dictionary
)) {
795 WMReleasePropList(db
->dictionary
);
796 db
->dictionary
= NULL
;
797 wwarning(_("Domain %s (%s) of defaults database is corrupted!"), domain
, the_path
);
799 db
->timestamp
= stbuf
.st_mtime
;
801 wwarning(_("could not load domain %s from user defaults database"), domain
);
805 /* global system dictionary */
806 snprintf(path
, sizeof(path
), "%s/%s/%s", SYSCONFDIR
, GLOBAL_DEFAULTS_SUBDIR
, domain
);
807 if (stat(path
, &stbuf
) >= 0) {
808 shared_dict
= WMReadPropListFromFile(path
);
810 if (requireDictionary
&& !WMIsPLDictionary(shared_dict
)) {
811 wwarning(_("Domain %s (%s) of global defaults database is corrupted!"),
813 WMReleasePropList(shared_dict
);
816 if (db
->dictionary
&& WMIsPLDictionary(shared_dict
) &&
817 WMIsPLDictionary(db
->dictionary
)) {
818 WMMergePLDictionaries(shared_dict
, db
->dictionary
, True
);
819 WMReleasePropList(db
->dictionary
);
820 db
->dictionary
= shared_dict
;
821 if (stbuf
.st_mtime
> db
->timestamp
)
822 db
->timestamp
= stbuf
.st_mtime
;
823 } else if (!db
->dictionary
) {
824 db
->dictionary
= shared_dict
;
825 if (stbuf
.st_mtime
> db
->timestamp
)
826 db
->timestamp
= stbuf
.st_mtime
;
830 wwarning(_("could not load domain %s from global defaults database (%s)"), domain
, path
);
837 void wReadStaticDefaults(WMPropList
* dict
)
840 WDefaultEntry
*entry
;
844 for (i
= 0; i
< sizeof(staticOptionList
) / sizeof(WDefaultEntry
); i
++) {
845 entry
= &staticOptionList
[i
];
848 plvalue
= WMGetFromPLDictionary(dict
, entry
->plkey
);
853 /* no default in the DB. Use builtin default */
854 plvalue
= entry
->plvalue
;
859 (*entry
->convert
) (NULL
, entry
, plvalue
, entry
->addr
, &tdata
);
861 (*entry
->update
) (NULL
, entry
, tdata
, entry
->extra_data
);
867 void wDefaultsCheckDomains(void* arg
)
871 WMPropList
*shared_dict
= NULL
;
875 if (stat(WDWindowMaker
->path
, &stbuf
) >= 0 && WDWindowMaker
->timestamp
< stbuf
.st_mtime
) {
876 WDWindowMaker
->timestamp
= stbuf
.st_mtime
;
878 /* global dictionary */
879 shared_dict
= readGlobalDomain("WindowMaker", True
);
880 /* user dictionary */
881 dict
= WMReadPropListFromFile(WDWindowMaker
->path
);
883 if (!WMIsPLDictionary(dict
)) {
884 WMReleasePropList(dict
);
886 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
887 "WindowMaker", WDWindowMaker
->path
);
890 WMMergePLDictionaries(shared_dict
, dict
, True
);
891 WMReleasePropList(dict
);
895 for (i
= 0; i
< wScreenCount
; i
++) {
896 scr
= wScreenWithNumber(i
);
898 wReadDefaults(scr
, dict
);
900 if (WDWindowMaker
->dictionary
) {
901 WMReleasePropList(WDWindowMaker
->dictionary
);
903 WDWindowMaker
->dictionary
= dict
;
906 wwarning(_("could not load domain %s from user defaults database"), "WindowMaker");
909 WMReleasePropList(shared_dict
);
913 if (stat(WDWindowAttributes
->path
, &stbuf
) >= 0 && WDWindowAttributes
->timestamp
< stbuf
.st_mtime
) {
914 /* global dictionary */
915 shared_dict
= readGlobalDomain("WMWindowAttributes", True
);
916 /* user dictionary */
917 dict
= WMReadPropListFromFile(WDWindowAttributes
->path
);
919 if (!WMIsPLDictionary(dict
)) {
920 WMReleasePropList(dict
);
922 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
923 "WMWindowAttributes", WDWindowAttributes
->path
);
926 WMMergePLDictionaries(shared_dict
, dict
, True
);
927 WMReleasePropList(dict
);
931 if (WDWindowAttributes
->dictionary
) {
932 WMReleasePropList(WDWindowAttributes
->dictionary
);
934 WDWindowAttributes
->dictionary
= dict
;
935 for (i
= 0; i
< wScreenCount
; i
++) {
936 scr
= wScreenWithNumber(i
);
940 wDefaultUpdateIcons(scr
);
942 /* Update the panel image if changed */
943 /* Don't worry. If the image is the same these
944 * functions will have no performance impact. */
945 image
= wDefaultGetImage(scr
, "Logo", "WMPanel");
948 wwarning(_("could not load logo image for panels: %s"),
949 RMessageForError(RErrorCode
));
951 WMSetApplicationIconImage(scr
->wmscreen
, image
);
952 RReleaseImage(image
);
958 wwarning(_("could not load domain %s from user defaults database"), "WMWindowAttributes");
960 WDWindowAttributes
->timestamp
= stbuf
.st_mtime
;
962 WMReleasePropList(shared_dict
);
966 if (stat(WDRootMenu
->path
, &stbuf
) >= 0 && WDRootMenu
->timestamp
< stbuf
.st_mtime
) {
967 dict
= WMReadPropListFromFile(WDRootMenu
->path
);
969 if (!WMIsPLArray(dict
) && !WMIsPLString(dict
)) {
970 WMReleasePropList(dict
);
972 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
973 "WMRootMenu", WDRootMenu
->path
);
975 if (WDRootMenu
->dictionary
) {
976 WMReleasePropList(WDRootMenu
->dictionary
);
978 WDRootMenu
->dictionary
= dict
;
979 wDefaultsMergeGlobalMenus(WDRootMenu
);
982 wwarning(_("could not load domain %s from user defaults database"), "WMRootMenu");
984 WDRootMenu
->timestamp
= stbuf
.st_mtime
;
988 WMAddTimerHandler(DEFAULTS_CHECK_INTERVAL
, wDefaultsCheckDomains
, arg
);
992 void wReadDefaults(WScreen
* scr
, WMPropList
* new_dict
)
994 WMPropList
*plvalue
, *old_value
;
995 WDefaultEntry
*entry
;
996 unsigned int i
, must_update
;
997 int update_workspace_back
= 0; /* kluge :/ */
998 unsigned int needs_refresh
;
1000 WMPropList
*old_dict
= (WDWindowMaker
->dictionary
!= new_dict
? WDWindowMaker
->dictionary
: NULL
);
1006 for (i
= 0; i
< sizeof(optionList
) / sizeof(WDefaultEntry
); i
++) {
1007 entry
= &optionList
[i
];
1010 plvalue
= WMGetFromPLDictionary(new_dict
, entry
->plkey
);
1017 old_value
= WMGetFromPLDictionary(old_dict
, entry
->plkey
);
1019 if (!plvalue
&& !old_value
) {
1020 /* no default in the DB. Use builtin default */
1021 plvalue
= entry
->plvalue
;
1022 if (plvalue
&& new_dict
) {
1023 WMPutInPLDictionary(new_dict
, entry
->plkey
, plvalue
);
1026 } else if (!plvalue
) {
1027 /* value was deleted from DB. Keep current value */
1029 } else if (!old_value
) {
1030 /* set value for the 1st time */
1031 } else if (!WMIsPropListEqualTo(plvalue
, old_value
)) {
1032 /* value has changed */
1035 if (strcmp(entry
->key
, "WorkspaceBack") == 0
1036 && update_workspace_back
&& scr
->flags
.backimage_helper_launched
) {
1038 /* value was not changed since last time */
1045 if ((*entry
->convert
) (scr
, entry
, plvalue
, entry
->addr
, &tdata
)) {
1047 * If the WorkspaceSpecificBack data has been changed
1048 * so that the helper will be launched now, we must be
1049 * sure to send the default background texture config
1052 if (strcmp(entry
->key
, "WorkspaceSpecificBack") == 0
1053 && !scr
->flags
.backimage_helper_launched
) {
1054 update_workspace_back
= 1;
1056 if (entry
->update
) {
1057 needs_refresh
|= (*entry
->update
) (scr
, entry
, tdata
, entry
->extra_data
);
1063 if (needs_refresh
!= 0 && !scr
->flags
.startup
) {
1067 if (needs_refresh
& REFRESH_MENU_TITLE_TEXTURE
)
1068 foo
|= WTextureSettings
;
1069 if (needs_refresh
& REFRESH_MENU_TITLE_FONT
)
1070 foo
|= WFontSettings
;
1071 if (needs_refresh
& REFRESH_MENU_TITLE_COLOR
)
1072 foo
|= WColorSettings
;
1074 WMPostNotificationName(WNMenuTitleAppearanceSettingsChanged
, NULL
,
1075 (void *)(uintptr_t) foo
);
1078 if (needs_refresh
& REFRESH_MENU_TEXTURE
)
1079 foo
|= WTextureSettings
;
1080 if (needs_refresh
& REFRESH_MENU_FONT
)
1081 foo
|= WFontSettings
;
1082 if (needs_refresh
& REFRESH_MENU_COLOR
)
1083 foo
|= WColorSettings
;
1085 WMPostNotificationName(WNMenuAppearanceSettingsChanged
, NULL
, (void *)(uintptr_t) foo
);
1088 if (needs_refresh
& REFRESH_WINDOW_FONT
) {
1089 foo
|= WFontSettings
;
1091 if (needs_refresh
& REFRESH_WINDOW_TEXTURES
) {
1092 foo
|= WTextureSettings
;
1094 if (needs_refresh
& REFRESH_WINDOW_TITLE_COLOR
) {
1095 foo
|= WColorSettings
;
1098 WMPostNotificationName(WNWindowAppearanceSettingsChanged
, NULL
, (void *)(uintptr_t) foo
);
1100 if (!(needs_refresh
& REFRESH_ICON_TILE
)) {
1102 if (needs_refresh
& REFRESH_ICON_FONT
) {
1103 foo
|= WFontSettings
;
1105 if (needs_refresh
& REFRESH_ICON_TITLE_COLOR
) {
1106 foo
|= WTextureSettings
;
1108 if (needs_refresh
& REFRESH_ICON_TITLE_BACK
) {
1109 foo
|= WTextureSettings
;
1112 WMPostNotificationName(WNIconAppearanceSettingsChanged
, NULL
,
1113 (void *)(uintptr_t) foo
);
1115 if (needs_refresh
& REFRESH_ICON_TILE
)
1116 WMPostNotificationName(WNIconTileSettingsChanged
, NULL
, NULL
);
1120 void wDefaultUpdateIcons(WScreen
* scr
)
1122 WAppIcon
*aicon
= scr
->app_icon_list
;
1123 WWindow
*wwin
= scr
->focused_window
;
1127 file
= wDefaultGetIconFile(scr
, aicon
->wm_instance
, aicon
->wm_class
, False
);
1128 if ((file
&& aicon
->icon
->file
&& strcmp(file
, aicon
->icon
->file
) != 0)
1129 || (file
&& !aicon
->icon
->file
)) {
1132 if (aicon
->icon
->file
)
1133 wfree(aicon
->icon
->file
);
1134 aicon
->icon
->file
= wstrdup(file
);
1136 new_image
= wDefaultGetImage(scr
, aicon
->wm_instance
, aicon
->wm_class
);
1138 wIconChangeImage(aicon
->icon
, new_image
);
1139 wAppIconPaint(aicon
);
1142 aicon
= aicon
->next
;
1145 if (!wPreferences
.flags
.noclip
)
1146 wClipIconPaint(scr
->clip_icon
);
1149 if (wwin
->icon
&& wwin
->flags
.miniaturized
) {
1150 file
= wDefaultGetIconFile(scr
, wwin
->wm_instance
, wwin
->wm_class
, False
);
1151 if ((file
&& wwin
->icon
->file
&& strcmp(file
, wwin
->icon
->file
) != 0)
1152 || (file
&& !wwin
->icon
->file
)) {
1155 if (wwin
->icon
->file
)
1156 wfree(wwin
->icon
->file
);
1157 wwin
->icon
->file
= wstrdup(file
);
1159 new_image
= wDefaultGetImage(scr
, wwin
->wm_instance
, wwin
->wm_class
);
1161 wIconChangeImage(wwin
->icon
, new_image
);
1168 /* --------------------------- Local ----------------------- */
1170 #define GET_STRING_OR_DEFAULT(x, var) if (!WMIsPLString(value)) { \
1171 wwarning(_("Wrong option format for key \"%s\". Should be %s."), \
1173 wwarning(_("using default \"%s\" instead"), entry->default_value); \
1174 var = entry->default_value;\
1175 } else var = WMGetFromPLString(value)\
1178 static int string2index(WMPropList * key, WMPropList * val, char *def, WOptionEnumeration * values)
1181 WOptionEnumeration
*v
;
1182 char buffer
[TOTAL_VALUES_LENGTH
];
1184 if (WMIsPLString(val
) && (str
= WMGetFromPLString(val
))) {
1185 for (v
= values
; v
->string
!= NULL
; v
++) {
1186 if (strcasecmp(v
->string
, str
) == 0)
1192 for (v
= values
; v
->string
!= NULL
; v
++) {
1195 strcat(buffer
, ", ");
1196 strcat(buffer
, v
->string
);
1199 wwarning(_("wrong option value for key \"%s\". Should be one of %s"), WMGetFromPLString(key
), buffer
);
1202 return string2index(key
, val
, NULL
, values
);
1209 * value - is the value in the defaults DB
1210 * addr - is the address to store the data
1211 * ret - is the address to store a pointer to a temporary buffer. ret
1212 * must not be freed and is used by the set functions
1214 static int getBool(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1218 int second_pass
= 0;
1220 GET_STRING_OR_DEFAULT("Boolean", val
);
1223 if ((val
[1] == '\0' && (val
[0] == 'y' || val
[0] == 'Y'))
1224 || strcasecmp(val
, "YES") == 0) {
1227 } else if ((val
[1] == '\0' && (val
[0] == 'n' || val
[0] == 'N'))
1228 || strcasecmp(val
, "NO") == 0) {
1232 if (sscanf(val
, "%i", &i
) == 1) {
1238 wwarning(_("can't convert \"%s\" to boolean for key \"%s\""), val
, entry
->key
);
1239 if (second_pass
== 0) {
1240 val
= WMGetFromPLString(entry
->plvalue
);
1242 wwarning(_("using default \"%s\" instead"), val
);
1252 *(char *)addr
= data
;
1257 static int getInt(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1262 GET_STRING_OR_DEFAULT("Integer", val
);
1264 if (sscanf(val
, "%i", &data
) != 1) {
1265 wwarning(_("can't convert \"%s\" to integer for key \"%s\""), val
, entry
->key
);
1266 val
= WMGetFromPLString(entry
->plvalue
);
1267 wwarning(_("using default \"%s\" instead"), val
);
1268 if (sscanf(val
, "%i", &data
) != 1) {
1276 *(int *)addr
= data
;
1281 static int getCoord(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1284 char *val_x
, *val_y
;
1285 int nelem
, changed
= 0;
1286 WMPropList
*elem_x
, *elem_y
;
1289 if (!WMIsPLArray(value
)) {
1290 wwarning(_("Wrong option format for key \"%s\". Should be %s."), entry
->key
, "Coordinate");
1292 value
= entry
->plvalue
;
1294 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1300 nelem
= WMGetPropListItemCount(value
);
1302 wwarning(_("Incorrect number of elements in array for key \"%s\"."), entry
->key
);
1304 value
= entry
->plvalue
;
1306 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1312 elem_x
= WMGetFromPLArray(value
, 0);
1313 elem_y
= WMGetFromPLArray(value
, 1);
1315 if (!elem_x
|| !elem_y
|| !WMIsPLString(elem_x
) || !WMIsPLString(elem_y
)) {
1316 wwarning(_("Wrong value for key \"%s\". Should be Coordinate."), entry
->key
);
1318 value
= entry
->plvalue
;
1320 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1326 val_x
= WMGetFromPLString(elem_x
);
1327 val_y
= WMGetFromPLString(elem_y
);
1329 if (sscanf(val_x
, "%i", &data
.x
) != 1 || sscanf(val_y
, "%i", &data
.y
) != 1) {
1330 wwarning(_("can't convert array to integers for \"%s\"."), entry
->key
);
1332 value
= entry
->plvalue
;
1334 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1342 else if (data
.x
> scr
->scr_width
/ 3)
1343 data
.x
= scr
->scr_width
/ 3;
1346 else if (data
.y
> scr
->scr_height
/ 3)
1347 data
.y
= scr
->scr_height
/ 3;
1352 *(WCoord
*) addr
= data
;
1357 static int getPropList(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1359 WMRetainPropList(value
);
1366 static int getPathList(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1375 if (!WMIsPLArray(value
)) {
1376 wwarning(_("Wrong option format for key \"%s\". Should be %s."), entry
->key
, "an array of paths");
1378 value
= entry
->plvalue
;
1380 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1387 count
= WMGetPropListItemCount(value
);
1390 value
= entry
->plvalue
;
1392 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1399 for (i
= 0; i
< count
; i
++) {
1400 d
= WMGetFromPLArray(value
, i
);
1401 if (!d
|| !WMIsPLString(d
)) {
1405 len
+= strlen(WMGetFromPLString(d
)) + 1;
1408 ptr
= data
= wmalloc(len
+ 1);
1410 for (i
= 0; i
< count
; i
++) {
1411 d
= WMGetFromPLArray(value
, i
);
1412 if (!d
|| !WMIsPLString(d
)) {
1415 strcpy(ptr
, WMGetFromPLString(d
));
1416 ptr
+= strlen(WMGetFromPLString(d
));
1423 if (*(char **)addr
!= NULL
) {
1424 wfree(*(char **)addr
);
1426 *(char **)addr
= data
;
1431 static int getEnum(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1433 static signed char data
;
1435 data
= string2index(entry
->plkey
, value
, entry
->default_value
, (WOptionEnumeration
*) entry
->extra_data
);
1442 *(signed char *)addr
= data
;
1449 * (hgradient <color> <color>)
1450 * (vgradient <color> <color>)
1451 * (dgradient <color> <color>)
1452 * (mhgradient <color> <color> ...)
1453 * (mvgradient <color> <color> ...)
1454 * (mdgradient <color> <color> ...)
1455 * (igradient <color1> <color1> <thickness1> <color2> <color2> <thickness2>)
1456 * (tpixmap <file> <color>)
1457 * (spixmap <file> <color>)
1458 * (cpixmap <file> <color>)
1459 * (thgradient <file> <opaqueness> <color> <color>)
1460 * (tvgradient <file> <opaqueness> <color> <color>)
1461 * (tdgradient <file> <opaqueness> <color> <color>)
1462 * (function <lib> <function> ...)
1465 static WTexture
*parse_texture(WScreen
* scr
, WMPropList
* pl
)
1470 WTexture
*texture
= NULL
;
1472 nelem
= WMGetPropListItemCount(pl
);
1476 elem
= WMGetFromPLArray(pl
, 0);
1477 if (!elem
|| !WMIsPLString(elem
))
1479 val
= WMGetFromPLString(elem
);
1481 if (strcasecmp(val
, "solid") == 0) {
1489 elem
= WMGetFromPLArray(pl
, 1);
1490 if (!elem
|| !WMIsPLString(elem
))
1492 val
= WMGetFromPLString(elem
);
1494 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &color
)) {
1495 wwarning(_("\"%s\" is not a valid color name"), val
);
1499 texture
= (WTexture
*) wTextureMakeSolid(scr
, &color
);
1500 } else if (strcasecmp(val
, "dgradient") == 0
1501 || strcasecmp(val
, "vgradient") == 0 || strcasecmp(val
, "hgradient") == 0) {
1502 RColor color1
, color2
;
1507 wwarning(_("bad number of arguments in gradient specification"));
1511 if (val
[0] == 'd' || val
[0] == 'D')
1512 type
= WTEX_DGRADIENT
;
1513 else if (val
[0] == 'h' || val
[0] == 'H')
1514 type
= WTEX_HGRADIENT
;
1516 type
= WTEX_VGRADIENT
;
1518 /* get from color */
1519 elem
= WMGetFromPLArray(pl
, 1);
1520 if (!elem
|| !WMIsPLString(elem
))
1522 val
= WMGetFromPLString(elem
);
1524 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1525 wwarning(_("\"%s\" is not a valid color name"), val
);
1529 color1
.red
= xcolor
.red
>> 8;
1530 color1
.green
= xcolor
.green
>> 8;
1531 color1
.blue
= xcolor
.blue
>> 8;
1534 elem
= WMGetFromPLArray(pl
, 2);
1535 if (!elem
|| !WMIsPLString(elem
)) {
1538 val
= WMGetFromPLString(elem
);
1540 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1541 wwarning(_("\"%s\" is not a valid color name"), val
);
1545 color2
.red
= xcolor
.red
>> 8;
1546 color2
.green
= xcolor
.green
>> 8;
1547 color2
.blue
= xcolor
.blue
>> 8;
1549 texture
= (WTexture
*) wTextureMakeGradient(scr
, type
, &color1
, &color2
);
1551 } else if (strcasecmp(val
, "igradient") == 0) {
1552 RColor colors1
[2], colors2
[2];
1558 wwarning(_("bad number of arguments in gradient specification"));
1562 /* get from color */
1563 for (i
= 0; i
< 2; i
++) {
1564 elem
= WMGetFromPLArray(pl
, 1 + i
);
1565 if (!elem
|| !WMIsPLString(elem
))
1567 val
= WMGetFromPLString(elem
);
1569 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1570 wwarning(_("\"%s\" is not a valid color name"), val
);
1573 colors1
[i
].alpha
= 255;
1574 colors1
[i
].red
= xcolor
.red
>> 8;
1575 colors1
[i
].green
= xcolor
.green
>> 8;
1576 colors1
[i
].blue
= xcolor
.blue
>> 8;
1578 elem
= WMGetFromPLArray(pl
, 3);
1579 if (!elem
|| !WMIsPLString(elem
))
1581 val
= WMGetFromPLString(elem
);
1584 /* get from color */
1585 for (i
= 0; i
< 2; i
++) {
1586 elem
= WMGetFromPLArray(pl
, 4 + i
);
1587 if (!elem
|| !WMIsPLString(elem
))
1589 val
= WMGetFromPLString(elem
);
1591 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1592 wwarning(_("\"%s\" is not a valid color name"), val
);
1595 colors2
[i
].alpha
= 255;
1596 colors2
[i
].red
= xcolor
.red
>> 8;
1597 colors2
[i
].green
= xcolor
.green
>> 8;
1598 colors2
[i
].blue
= xcolor
.blue
>> 8;
1600 elem
= WMGetFromPLArray(pl
, 6);
1601 if (!elem
|| !WMIsPLString(elem
))
1603 val
= WMGetFromPLString(elem
);
1606 texture
= (WTexture
*) wTextureMakeIGradient(scr
, th1
, colors1
, th2
, colors2
);
1608 } else if (strcasecmp(val
, "mhgradient") == 0
1609 || strcasecmp(val
, "mvgradient") == 0 || strcasecmp(val
, "mdgradient") == 0) {
1616 wwarning(_("too few arguments in multicolor gradient specification"));
1620 if (val
[1] == 'h' || val
[1] == 'H')
1621 type
= WTEX_MHGRADIENT
;
1622 else if (val
[1] == 'v' || val
[1] == 'V')
1623 type
= WTEX_MVGRADIENT
;
1625 type
= WTEX_MDGRADIENT
;
1629 colors
= wmalloc(sizeof(RColor
*) * (count
+ 1));
1631 for (i
= 0; i
< count
; i
++) {
1632 elem
= WMGetFromPLArray(pl
, i
+ 1);
1633 if (!elem
|| !WMIsPLString(elem
)) {
1634 for (--i
; i
>= 0; --i
) {
1640 val
= WMGetFromPLString(elem
);
1642 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &color
)) {
1643 wwarning(_("\"%s\" is not a valid color name"), val
);
1644 for (--i
; i
>= 0; --i
) {
1650 colors
[i
] = wmalloc(sizeof(RColor
));
1651 colors
[i
]->red
= color
.red
>> 8;
1652 colors
[i
]->green
= color
.green
>> 8;
1653 colors
[i
]->blue
= color
.blue
>> 8;
1658 texture
= (WTexture
*) wTextureMakeMGradient(scr
, type
, colors
);
1659 } else if (strcasecmp(val
, "spixmap") == 0 ||
1660 strcasecmp(val
, "cpixmap") == 0 || strcasecmp(val
, "tpixmap") == 0) {
1667 if (val
[0] == 's' || val
[0] == 'S')
1669 else if (val
[0] == 'c' || val
[0] == 'C')
1675 elem
= WMGetFromPLArray(pl
, 2);
1676 if (!elem
|| !WMIsPLString(elem
)) {
1679 val
= WMGetFromPLString(elem
);
1681 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &color
)) {
1682 wwarning(_("\"%s\" is not a valid color name"), val
);
1687 elem
= WMGetFromPLArray(pl
, 1);
1688 if (!elem
|| !WMIsPLString(elem
))
1690 val
= WMGetFromPLString(elem
);
1692 texture
= (WTexture
*) wTextureMakePixmap(scr
, type
, val
, &color
);
1693 } else if (strcasecmp(val
, "thgradient") == 0
1694 || strcasecmp(val
, "tvgradient") == 0 || strcasecmp(val
, "tdgradient") == 0) {
1695 RColor color1
, color2
;
1700 if (val
[1] == 'h' || val
[1] == 'H')
1701 style
= WTEX_THGRADIENT
;
1702 else if (val
[1] == 'v' || val
[1] == 'V')
1703 style
= WTEX_TVGRADIENT
;
1705 style
= WTEX_TDGRADIENT
;
1708 wwarning(_("bad number of arguments in textured gradient specification"));
1712 /* get from color */
1713 elem
= WMGetFromPLArray(pl
, 3);
1714 if (!elem
|| !WMIsPLString(elem
))
1716 val
= WMGetFromPLString(elem
);
1718 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1719 wwarning(_("\"%s\" is not a valid color name"), val
);
1723 color1
.red
= xcolor
.red
>> 8;
1724 color1
.green
= xcolor
.green
>> 8;
1725 color1
.blue
= xcolor
.blue
>> 8;
1728 elem
= WMGetFromPLArray(pl
, 4);
1729 if (!elem
|| !WMIsPLString(elem
)) {
1732 val
= WMGetFromPLString(elem
);
1734 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1735 wwarning(_("\"%s\" is not a valid color name"), val
);
1739 color2
.red
= xcolor
.red
>> 8;
1740 color2
.green
= xcolor
.green
>> 8;
1741 color2
.blue
= xcolor
.blue
>> 8;
1744 elem
= WMGetFromPLArray(pl
, 2);
1745 if (!elem
|| !WMIsPLString(elem
))
1748 val
= WMGetFromPLString(elem
);
1750 if (!val
|| (opacity
= atoi(val
)) < 0 || opacity
> 255) {
1751 wwarning(_("bad opacity value for tgradient texture \"%s\". Should be [0..255]"), val
);
1756 elem
= WMGetFromPLArray(pl
, 1);
1757 if (!elem
|| !WMIsPLString(elem
))
1759 val
= WMGetFromPLString(elem
);
1761 texture
= (WTexture
*) wTextureMakeTGradient(scr
, style
, &color1
, &color2
, val
, opacity
);
1762 } else if (strcasecmp(val
, "function") == 0) {
1763 /* Leave this in to handle the unlikely case of
1764 * someone actually having function textures configured */
1765 wwarning("function texture support has been removed");
1768 wwarning(_("invalid texture type %s"), val
);
1774 static int getTexture(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1776 static WTexture
*texture
;
1780 if (!WMIsPLArray(value
)) {
1781 wwarning(_("Wrong option format for key \"%s\". Should be %s."), entry
->key
, "Texture");
1783 value
= entry
->plvalue
;
1785 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1791 if (strcmp(entry
->key
, "WidgetColor") == 0 && !changed
) {
1794 pl
= WMGetFromPLArray(value
, 0);
1795 if (!pl
|| !WMIsPLString(pl
) || !WMGetFromPLString(pl
)
1796 || strcasecmp(WMGetFromPLString(pl
), "solid") != 0) {
1797 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1798 entry
->key
, "Solid Texture");
1800 value
= entry
->plvalue
;
1802 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1807 texture
= parse_texture(scr
, value
);
1810 wwarning(_("Error in texture specification for key \"%s\""), entry
->key
);
1812 value
= entry
->plvalue
;
1814 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1824 *(WTexture
**) addr
= texture
;
1829 static int getWSBackground(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1837 if (!WMIsPLArray(value
)) {
1838 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1839 "WorkspaceBack", "Texture or None");
1841 value
= entry
->plvalue
;
1843 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1849 /* only do basic error checking and verify for None texture */
1851 nelem
= WMGetPropListItemCount(value
);
1853 elem
= WMGetFromPLArray(value
, 0);
1854 if (!elem
|| !WMIsPLString(elem
)) {
1855 wwarning(_("Wrong type for workspace background. Should be a texture type."));
1857 value
= entry
->plvalue
;
1859 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1864 val
= WMGetFromPLString(elem
);
1866 if (strcasecmp(val
, "None") == 0)
1869 *ret
= WMRetainPropList(value
);
1875 getWSSpecificBackground(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1882 if (!WMIsPLArray(value
)) {
1883 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1884 "WorkspaceSpecificBack", "an array of textures");
1886 value
= entry
->plvalue
;
1888 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1894 /* only do basic error checking and verify for None texture */
1896 nelem
= WMGetPropListItemCount(value
);
1899 elem
= WMGetFromPLArray(value
, nelem
);
1900 if (!elem
|| !WMIsPLArray(elem
)) {
1901 wwarning(_("Wrong type for background of workspace %i. Should be a texture."),
1907 *ret
= WMRetainPropList(value
);
1911 * Kluge to force wmsetbg helper to set the default background.
1912 * If the WorkspaceSpecificBack is changed once wmaker has started,
1913 * the WorkspaceBack won't be sent to the helper, unless the user
1914 * changes it's value too. So, we must force this by removing the
1915 * value from the defaults DB.
1917 if (!scr
->flags
.backimage_helper_launched
&& !scr
->flags
.startup
) {
1918 WMPropList
*key
= WMCreatePLString("WorkspaceBack");
1920 WMRemoveFromPLDictionary(WDWindowMaker
->dictionary
, key
);
1922 WMReleasePropList(key
);
1928 static int getFont(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1930 static WMFont
*font
;
1933 GET_STRING_OR_DEFAULT("Font", val
);
1935 font
= WMCreateFont(scr
->wmscreen
, val
);
1937 font
= WMCreateFont(scr
->wmscreen
, "fixed");
1940 wfatal(_("could not load any usable font!!!"));
1947 /* can't assign font value outside update function */
1948 wassertrv(addr
== NULL
, True
);
1953 static int getColor(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1955 static XColor color
;
1957 int second_pass
= 0;
1959 GET_STRING_OR_DEFAULT("Color", val
);
1962 if (!wGetColor(scr
, val
, &color
)) {
1963 wwarning(_("could not get color for key \"%s\""), entry
->key
);
1964 if (second_pass
== 0) {
1965 val
= WMGetFromPLString(entry
->plvalue
);
1967 wwarning(_("using default \"%s\" instead"), val
);
1976 assert(addr
== NULL
);
1979 *(unsigned long*)addr = pixel;
1985 static int getKeybind(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1987 static WShortKey shortcut
;
1991 char buf
[MAX_SHORTCUT_LENGTH
], *b
;
1993 GET_STRING_OR_DEFAULT("Key spec", val
);
1995 if (!val
|| strcasecmp(val
, "NONE") == 0) {
1996 shortcut
.keycode
= 0;
1997 shortcut
.modifier
= 0;
2003 strncpy(buf
, val
, MAX_SHORTCUT_LENGTH
);
2008 shortcut
.modifier
= 0;
2009 while ((k
= strchr(b
, '+')) != NULL
) {
2013 mod
= wXModifierFromKey(b
);
2015 wwarning(_("%s: invalid key modifier \"%s\""), entry
->key
, b
);
2018 shortcut
.modifier
|= mod
;
2024 ksym
= XStringToKeysym(b
);
2026 if (ksym
== NoSymbol
) {
2027 wwarning(_("%s:invalid kbd shortcut specification \"%s\""), entry
->key
, val
);
2031 shortcut
.keycode
= XKeysymToKeycode(dpy
, ksym
);
2032 if (shortcut
.keycode
== 0) {
2033 wwarning(_("%s:invalid key in shortcut \"%s\""), entry
->key
, val
);
2043 static int getModMask(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
2048 GET_STRING_OR_DEFAULT("Modifier Key", str
);
2053 mask
= wXModifierFromKey(str
);
2055 wwarning(_("%s: modifier key %s is not valid"), entry
->key
, str
);
2061 *(int *)addr
= mask
;
2069 # include <X11/cursorfont.h>
2075 #define CURSOR_ID_NONE (XC_num_glyphs)
2077 static WCursorLookup cursor_table
[] = {
2078 {"X_cursor", XC_X_cursor
},
2079 {"arrow", XC_arrow
},
2080 {"based_arrow_down", XC_based_arrow_down
},
2081 {"based_arrow_up", XC_based_arrow_up
},
2083 {"bogosity", XC_bogosity
},
2084 {"bottom_left_corner", XC_bottom_left_corner
},
2085 {"bottom_right_corner", XC_bottom_right_corner
},
2086 {"bottom_side", XC_bottom_side
},
2087 {"bottom_tee", XC_bottom_tee
},
2088 {"box_spiral", XC_box_spiral
},
2089 {"center_ptr", XC_center_ptr
},
2090 {"circle", XC_circle
},
2091 {"clock", XC_clock
},
2092 {"coffee_mug", XC_coffee_mug
},
2093 {"cross", XC_cross
},
2094 {"cross_reverse", XC_cross_reverse
},
2095 {"crosshair", XC_crosshair
},
2096 {"diamond_cross", XC_diamond_cross
},
2098 {"dotbox", XC_dotbox
},
2099 {"double_arrow", XC_double_arrow
},
2100 {"draft_large", XC_draft_large
},
2101 {"draft_small", XC_draft_small
},
2102 {"draped_box", XC_draped_box
},
2103 {"exchange", XC_exchange
},
2104 {"fleur", XC_fleur
},
2105 {"gobbler", XC_gobbler
},
2106 {"gumby", XC_gumby
},
2107 {"hand1", XC_hand1
},
2108 {"hand2", XC_hand2
},
2109 {"heart", XC_heart
},
2111 {"iron_cross", XC_iron_cross
},
2112 {"left_ptr", XC_left_ptr
},
2113 {"left_side", XC_left_side
},
2114 {"left_tee", XC_left_tee
},
2115 {"leftbutton", XC_leftbutton
},
2116 {"ll_angle", XC_ll_angle
},
2117 {"lr_angle", XC_lr_angle
},
2119 {"middlebutton", XC_middlebutton
},
2120 {"mouse", XC_mouse
},
2121 {"pencil", XC_pencil
},
2122 {"pirate", XC_pirate
},
2124 {"question_arrow", XC_question_arrow
},
2125 {"right_ptr", XC_right_ptr
},
2126 {"right_side", XC_right_side
},
2127 {"right_tee", XC_right_tee
},
2128 {"rightbutton", XC_rightbutton
},
2129 {"rtl_logo", XC_rtl_logo
},
2130 {"sailboat", XC_sailboat
},
2131 {"sb_down_arrow", XC_sb_down_arrow
},
2132 {"sb_h_double_arrow", XC_sb_h_double_arrow
},
2133 {"sb_left_arrow", XC_sb_left_arrow
},
2134 {"sb_right_arrow", XC_sb_right_arrow
},
2135 {"sb_up_arrow", XC_sb_up_arrow
},
2136 {"sb_v_double_arrow", XC_sb_v_double_arrow
},
2137 {"shuttle", XC_shuttle
},
2138 {"sizing", XC_sizing
},
2139 {"spider", XC_spider
},
2140 {"spraycan", XC_spraycan
},
2142 {"target", XC_target
},
2143 {"tcross", XC_tcross
},
2144 {"top_left_arrow", XC_top_left_arrow
},
2145 {"top_left_corner", XC_top_left_corner
},
2146 {"top_right_corner", XC_top_right_corner
},
2147 {"top_side", XC_top_side
},
2148 {"top_tee", XC_top_tee
},
2150 {"ul_angle", XC_ul_angle
},
2151 {"umbrella", XC_umbrella
},
2152 {"ur_angle", XC_ur_angle
},
2153 {"watch", XC_watch
},
2154 {"xterm", XC_xterm
},
2155 {NULL
, CURSOR_ID_NONE
}
2158 static void check_bitmap_status(int status
, char *filename
, Pixmap bitmap
)
2161 case BitmapOpenFailed
:
2162 wwarning(_("failed to open bitmap file \"%s\""), filename
);
2164 case BitmapFileInvalid
:
2165 wwarning(_("\"%s\" is not a valid bitmap file"), filename
);
2167 case BitmapNoMemory
:
2168 wwarning(_("out of memory reading bitmap file \"%s\""), filename
);
2171 XFreePixmap(dpy
, bitmap
);
2178 * (builtin, <cursor_name>)
2179 * (bitmap, <cursor_bitmap>, <cursor_mask>)
2181 static int parse_cursor(WScreen
* scr
, WMPropList
* pl
, Cursor
* cursor
)
2188 nelem
= WMGetPropListItemCount(pl
);
2192 elem
= WMGetFromPLArray(pl
, 0);
2193 if (!elem
|| !WMIsPLString(elem
)) {
2196 val
= WMGetFromPLString(elem
);
2198 if (strcasecmp(val
, "none") == 0) {
2201 } else if (strcasecmp(val
, "builtin") == 0) {
2203 int cursor_id
= CURSOR_ID_NONE
;
2206 wwarning(_("bad number of arguments in cursor specification"));
2209 elem
= WMGetFromPLArray(pl
, 1);
2210 if (!elem
|| !WMIsPLString(elem
)) {
2213 val
= WMGetFromPLString(elem
);
2215 for (i
= 0; cursor_table
[i
].name
!= NULL
; i
++) {
2216 if (strcasecmp(val
, cursor_table
[i
].name
) == 0) {
2217 cursor_id
= cursor_table
[i
].id
;
2221 if (CURSOR_ID_NONE
== cursor_id
) {
2222 wwarning(_("unknown builtin cursor name \"%s\""), val
);
2224 *cursor
= XCreateFontCursor(dpy
, cursor_id
);
2227 } else if (strcasecmp(val
, "bitmap") == 0) {
2239 wwarning(_("bad number of arguments in cursor specification"));
2242 elem
= WMGetFromPLArray(pl
, 1);
2243 if (!elem
|| !WMIsPLString(elem
)) {
2246 val
= WMGetFromPLString(elem
);
2247 bitmap_name
= FindImage(wPreferences
.pixmap_path
, val
);
2249 wwarning(_("could not find cursor bitmap file \"%s\""), val
);
2252 elem
= WMGetFromPLArray(pl
, 2);
2253 if (!elem
|| !WMIsPLString(elem
)) {
2257 val
= WMGetFromPLString(elem
);
2258 mask_name
= FindImage(wPreferences
.pixmap_path
, val
);
2261 wwarning(_("could not find cursor bitmap file \"%s\""), val
);
2264 mask_status
= XReadBitmapFile(dpy
, scr
->w_win
, mask_name
, &w
, &h
, &mask
, &x
, &y
);
2265 bitmap_status
= XReadBitmapFile(dpy
, scr
->w_win
, bitmap_name
, &w
, &h
, &bitmap
, &x
, &y
);
2266 if ((BitmapSuccess
== bitmap_status
) && (BitmapSuccess
== mask_status
)) {
2267 fg
.pixel
= scr
->black_pixel
;
2268 bg
.pixel
= scr
->white_pixel
;
2269 XQueryColor(dpy
, scr
->w_colormap
, &fg
);
2270 XQueryColor(dpy
, scr
->w_colormap
, &bg
);
2271 *cursor
= XCreatePixmapCursor(dpy
, bitmap
, mask
, &fg
, &bg
, x
, y
);
2274 check_bitmap_status(bitmap_status
, bitmap_name
, bitmap
);
2275 check_bitmap_status(mask_status
, mask_name
, mask
);
2282 static int getCursor(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
2284 static Cursor cursor
;
2289 if (!WMIsPLArray(value
)) {
2290 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
2291 entry
->key
, "cursor specification");
2293 value
= entry
->plvalue
;
2295 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
2300 status
= parse_cursor(scr
, value
, &cursor
);
2302 wwarning(_("Error in cursor specification for key \"%s\""), entry
->key
);
2304 value
= entry
->plvalue
;
2306 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
2315 *(Cursor
*) addr
= cursor
;
2320 #undef CURSOR_ID_NONE
2322 /* ---------------- value setting functions --------------- */
2323 static int setJustify(WScreen
* scr
, WDefaultEntry
* entry
, WTexture
** texture
, void *foo
)
2325 return REFRESH_WINDOW_TITLE_COLOR
;
2328 static int setClearance(WScreen
* scr
, WDefaultEntry
* entry
, void *bar
, void *foo
)
2330 return REFRESH_WINDOW_FONT
| REFRESH_BUTTON_IMAGES
| REFRESH_MENU_TITLE_FONT
| REFRESH_MENU_FONT
;
2333 static int setIfDockPresent(WScreen
* scr
, WDefaultEntry
* entry
, char *flag
, long which
)
2337 wPreferences
.flags
.nodock
= wPreferences
.flags
.nodock
|| *flag
;
2340 wPreferences
.flags
.noclip
= wPreferences
.flags
.noclip
|| *flag
;
2348 static int setStickyIcons(WScreen
* scr
, WDefaultEntry
* entry
, void *bar
, void *foo
)
2350 if (scr
->workspaces
) {
2351 wWorkspaceForceChange(scr
, scr
->current_workspace
);
2352 wArrangeIcons(scr
, False
);
2357 static int setIconTile(WScreen
* scr
, WDefaultEntry
* entry
, WTexture
** texture
, void *foo
)
2363 img
= wTextureRenderImage(*texture
, wPreferences
.icon_size
,
2364 wPreferences
.icon_size
, ((*texture
)->any
.type
& WREL_BORDER_MASK
)
2365 ? WREL_ICON
: WREL_FLAT
);
2367 wwarning(_("could not render texture for icon background"));
2369 wTextureDestroy(scr
, *texture
);
2372 RConvertImage(scr
->rcontext
, img
, &pixmap
);
2374 if (scr
->icon_tile
) {
2376 RReleaseImage(scr
->icon_tile
);
2377 XFreePixmap(dpy
, scr
->icon_tile_pixmap
);
2380 scr
->icon_tile
= img
;
2382 /* put the icon in the noticeboard hint */
2383 PropSetIconTileHint(scr
, img
);
2385 if (!wPreferences
.flags
.noclip
) {
2386 if (scr
->clip_tile
) {
2387 RReleaseImage(scr
->clip_tile
);
2389 scr
->clip_tile
= wClipMakeTile(scr
, img
);
2392 scr
->icon_tile_pixmap
= pixmap
;
2394 if (scr
->def_icon_pixmap
) {
2395 XFreePixmap(dpy
, scr
->def_icon_pixmap
);
2396 scr
->def_icon_pixmap
= None
;
2398 if (scr
->def_ticon_pixmap
) {
2399 XFreePixmap(dpy
, scr
->def_ticon_pixmap
);
2400 scr
->def_ticon_pixmap
= None
;
2403 if (scr
->icon_back_texture
) {
2404 wTextureDestroy(scr
, (WTexture
*) scr
->icon_back_texture
);
2406 scr
->icon_back_texture
= wTextureMakeSolid(scr
, &((*texture
)->any
.color
));
2408 if (scr
->clip_balloon
)
2409 XSetWindowBackground(dpy
, scr
->clip_balloon
, (*texture
)->any
.color
.pixel
);
2412 * Free the texture as nobody else will use it, nor refer to it.
2415 wTextureDestroy(scr
, *texture
);
2417 return (reset
? REFRESH_ICON_TILE
: 0);
2420 static int setWinTitleFont(WScreen
* scr
, WDefaultEntry
* entry
, WMFont
* font
, void *foo
)
2422 if (scr
->title_font
) {
2423 WMReleaseFont(scr
->title_font
);
2425 scr
->title_font
= font
;
2427 return REFRESH_WINDOW_FONT
| REFRESH_BUTTON_IMAGES
;
2430 static int setMenuTitleFont(WScreen
* scr
, WDefaultEntry
* entry
, WMFont
* font
, void *foo
)
2432 if (scr
->menu_title_font
) {
2433 WMReleaseFont(scr
->menu_title_font
);
2436 scr
->menu_title_font
= font
;
2438 return REFRESH_MENU_TITLE_FONT
;
2441 static int setMenuTextFont(WScreen
* scr
, WDefaultEntry
* entry
, WMFont
* font
, void *foo
)
2443 if (scr
->menu_entry_font
) {
2444 WMReleaseFont(scr
->menu_entry_font
);
2446 scr
->menu_entry_font
= font
;
2448 return REFRESH_MENU_FONT
;
2451 static int setIconTitleFont(WScreen
* scr
, WDefaultEntry
* entry
, WMFont
* font
, void *foo
)
2453 if (scr
->icon_title_font
) {
2454 WMReleaseFont(scr
->icon_title_font
);
2457 scr
->icon_title_font
= font
;
2459 return REFRESH_ICON_FONT
;
2462 static int setClipTitleFont(WScreen
* scr
, WDefaultEntry
* entry
, WMFont
* font
, void *foo
)
2464 if (scr
->clip_title_font
) {
2465 WMReleaseFont(scr
->clip_title_font
);
2468 scr
->clip_title_font
= font
;
2470 return REFRESH_ICON_FONT
;
2473 static int setLargeDisplayFont(WScreen
* scr
, WDefaultEntry
* entry
, WMFont
* font
, void *foo
)
2475 if (scr
->workspace_name_font
) {
2476 WMReleaseFont(scr
->workspace_name_font
);
2479 scr
->workspace_name_font
= font
;
2484 static int setHightlight(WScreen
* scr
, WDefaultEntry
* entry
, XColor
* color
, void *foo
)
2486 if (scr
->select_color
)
2487 WMReleaseColor(scr
->select_color
);
2489 scr
->select_color
= WMCreateRGBColor(scr
->wmscreen
, color
->red
, color
->green
, color
->blue
, True
);
2491 wFreeColor(scr
, color
->pixel
);
2493 return REFRESH_MENU_COLOR
;
2496 static int setHightlightText(WScreen
* scr
, WDefaultEntry
* entry
, XColor
* color
, void *foo
)
2498 if (scr
->select_text_color
)
2499 WMReleaseColor(scr
->select_text_color
);
2501 scr
->select_text_color
= WMCreateRGBColor(scr
->wmscreen
, color
->red
, color
->green
, color
->blue
, True
);
2503 wFreeColor(scr
, color
->pixel
);
2505 return REFRESH_MENU_COLOR
;
2508 static int setClipTitleColor(WScreen
* scr
, WDefaultEntry
* entry
, XColor
* color
, long widx
)
2510 if (scr
->clip_title_color
[widx
])
2511 WMReleaseColor(scr
->clip_title_color
[widx
]);
2512 scr
->clip_title_color
[widx
] = WMCreateRGBColor(scr
->wmscreen
, color
->red
, color
->green
, color
->blue
, True
);
2513 #ifdef GRADIENT_CLIP_ARROW
2514 if (widx
== CLIP_NORMAL
) {
2516 RColor color1
, color2
;
2517 int pt
= CLIP_BUTTON_SIZE
* wPreferences
.icon_size
/ 64;
2518 int as
= pt
- 15; /* 15 = 5+5+5 */
2520 FREE_PIXMAP(scr
->clip_arrow_gradient
);
2522 color1
.red
= (color
->red
>> 8) * 6 / 10;
2523 color1
.green
= (color
->green
>> 8) * 6 / 10;
2524 color1
.blue
= (color
->blue
>> 8) * 6 / 10;
2526 color2
.red
= WMIN((color
->red
>> 8) * 20 / 10, 255);
2527 color2
.green
= WMIN((color
->green
>> 8) * 20 / 10, 255);
2528 color2
.blue
= WMIN((color
->blue
>> 8) * 20 / 10, 255);
2530 image
= RRenderGradient(as
+ 1, as
+ 1, &color1
, &color2
, RDiagonalGradient
);
2531 RConvertImage(scr
->rcontext
, image
, &scr
->clip_arrow_gradient
);
2532 RReleaseImage(image
);
2534 #endif /* GRADIENT_CLIP_ARROW */
2536 wFreeColor(scr
, color
->pixel
);
2538 return REFRESH_ICON_TITLE_COLOR
;
2541 static int setWTitleColor(WScreen
* scr
, WDefaultEntry
* entry
, XColor
* color
, long widx
)
2543 if (scr
->window_title_color
[widx
])
2544 WMReleaseColor(scr
->window_title_color
[widx
]);
2546 scr
->window_title_color
[widx
] =
2547 WMCreateRGBColor(scr
->wmscreen
, color
->red
, color
->green
, color
->blue
, True
);
2549 wFreeColor(scr
, color
->pixel
);
2551 return REFRESH_WINDOW_TITLE_COLOR
;
2554 static int setMenuTitleColor(WScreen
* scr
, WDefaultEntry
* entry
, XColor
* color
, long widx
)
2556 if (scr
->menu_title_color
[0])
2557 WMReleaseColor(scr
->menu_title_color
[0]);
2559 scr
->menu_title_color
[0] = WMCreateRGBColor(scr
->wmscreen
, color
->red
, color
->green
, color
->blue
, True
);
2561 wFreeColor(scr
, color
->pixel
);
2563 return REFRESH_MENU_TITLE_COLOR
;
2566 static int setMenuTextColor(WScreen
* scr
, WDefaultEntry
* entry
, XColor
* color
, void *foo
)
2568 if (scr
->mtext_color
)
2569 WMReleaseColor(scr
->mtext_color
);
2571 scr
->mtext_color
= WMCreateRGBColor(scr
->wmscreen
, color
->red
, color
->green
, color
->blue
, True
);
2573 if (WMColorPixel(scr
->dtext_color
) == WMColorPixel(scr
->mtext_color
)) {
2574 WMSetColorAlpha(scr
->dtext_color
, 0x7fff);
2576 WMSetColorAlpha(scr
->dtext_color
, 0xffff);
2579 wFreeColor(scr
, color
->pixel
);
2581 return REFRESH_MENU_COLOR
;
2584 static int setMenuDisabledColor(WScreen
* scr
, WDefaultEntry
* entry
, XColor
* color
, void *foo
)
2586 if (scr
->dtext_color
)
2587 WMReleaseColor(scr
->dtext_color
);
2589 scr
->dtext_color
= WMCreateRGBColor(scr
->wmscreen
, color
->red
, color
->green
, color
->blue
, True
);
2591 if (WMColorPixel(scr
->dtext_color
) == WMColorPixel(scr
->mtext_color
)) {
2592 WMSetColorAlpha(scr
->dtext_color
, 0x7fff);
2594 WMSetColorAlpha(scr
->dtext_color
, 0xffff);
2597 wFreeColor(scr
, color
->pixel
);
2599 return REFRESH_MENU_COLOR
;
2602 static int setIconTitleColor(WScreen
* scr
, WDefaultEntry
* entry
, XColor
* color
, void *foo
)
2604 if (scr
->icon_title_color
)
2605 WMReleaseColor(scr
->icon_title_color
);
2606 scr
->icon_title_color
= WMCreateRGBColor(scr
->wmscreen
, color
->red
, color
->green
, color
->blue
, True
);
2608 wFreeColor(scr
, color
->pixel
);
2610 return REFRESH_ICON_TITLE_COLOR
;
2613 static int setIconTitleBack(WScreen
* scr
, WDefaultEntry
* entry
, XColor
* color
, void *foo
)
2615 if (scr
->icon_title_texture
) {
2616 wTextureDestroy(scr
, (WTexture
*) scr
->icon_title_texture
);
2618 scr
->icon_title_texture
= wTextureMakeSolid(scr
, color
);
2620 return REFRESH_ICON_TITLE_BACK
;
2623 static void trackDeadProcess(pid_t pid
, unsigned char status
, WScreen
* scr
)
2625 close(scr
->helper_fd
);
2627 scr
->helper_pid
= 0;
2628 scr
->flags
.backimage_helper_launched
= 0;
2631 static int setWorkspaceSpecificBack(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *bar
)
2637 if (scr
->flags
.backimage_helper_launched
) {
2638 if (WMGetPropListItemCount(value
) == 0) {
2639 SendHelperMessage(scr
, 'C', 0, NULL
);
2640 SendHelperMessage(scr
, 'K', 0, NULL
);
2642 WMReleasePropList(value
);
2649 if (WMGetPropListItemCount(value
) == 0)
2652 if (pipe(filedes
) < 0) {
2653 wsyserror("pipe() failed:can't set workspace specific background image");
2655 WMReleasePropList(value
);
2661 wsyserror("fork() failed:can't set workspace specific background image");
2662 if (close(filedes
[0]) < 0)
2663 wsyserror("could not close pipe");
2664 if (close(filedes
[1]) < 0)
2665 wsyserror("could not close pipe");
2667 } else if (pid
== 0) {
2670 SetupEnvironment(scr
);
2673 wsyserror("could not close pipe");
2674 if (dup(filedes
[0]) < 0) {
2675 wsyserror("dup() failed:can't set workspace specific background image");
2677 dither
= wPreferences
.no_dithering
? "-m" : "-d";
2678 if (wPreferences
.smooth_workspace_back
)
2679 execlp("wmsetbg", "wmsetbg", "-helper", "-S", dither
, NULL
);
2681 execlp("wmsetbg", "wmsetbg", "-helper", dither
, NULL
);
2682 wsyserror("could not execute wmsetbg");
2686 if (fcntl(filedes
[0], F_SETFD
, FD_CLOEXEC
) < 0) {
2687 wsyserror("error setting close-on-exec flag");
2689 if (fcntl(filedes
[1], F_SETFD
, FD_CLOEXEC
) < 0) {
2690 wsyserror("error setting close-on-exec flag");
2693 scr
->helper_fd
= filedes
[1];
2694 scr
->helper_pid
= pid
;
2695 scr
->flags
.backimage_helper_launched
= 1;
2697 wAddDeathHandler(pid
, (WDeathHandler
*) trackDeadProcess
, scr
);
2699 SendHelperMessage(scr
, 'P', -1, wPreferences
.pixmap_path
);
2704 for (i
= 0; i
< WMGetPropListItemCount(value
); i
++) {
2705 val
= WMGetFromPLArray(value
, i
);
2706 if (val
&& WMIsPLArray(val
) && WMGetPropListItemCount(val
) > 0) {
2707 str
= WMGetPropListDescription(val
, False
);
2709 SendHelperMessage(scr
, 'S', i
+ 1, str
);
2713 SendHelperMessage(scr
, 'U', i
+ 1, NULL
);
2718 WMReleasePropList(value
);
2722 static int setWorkspaceBack(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *bar
)
2724 if (scr
->flags
.backimage_helper_launched
) {
2727 if (WMGetPropListItemCount(value
) == 0) {
2728 SendHelperMessage(scr
, 'U', 0, NULL
);
2730 /* set the default workspace background to this one */
2731 str
= WMGetPropListDescription(value
, False
);
2733 SendHelperMessage(scr
, 'S', 0, str
);
2735 SendHelperMessage(scr
, 'C', scr
->current_workspace
+ 1, NULL
);
2737 SendHelperMessage(scr
, 'U', 0, NULL
);
2740 } else if (WMGetPropListItemCount(value
) > 0) {
2746 text
= WMGetPropListDescription(value
, False
);
2747 len
= strlen(text
) + 40;
2748 command
= wmalloc(len
);
2749 dither
= wPreferences
.no_dithering
? "-m" : "-d";
2750 if (wPreferences
.smooth_workspace_back
)
2751 snprintf(command
, len
, "wmsetbg %s -S -p '%s' &", dither
, text
);
2753 snprintf(command
, len
, "wmsetbg %s -p '%s' &", dither
, text
);
2755 ExecuteShellCommand(scr
, command
);
2758 WMReleasePropList(value
);
2763 static int setWidgetColor(WScreen
* scr
, WDefaultEntry
* entry
, WTexture
** texture
, void *foo
)
2765 if (scr
->widget_texture
) {
2766 wTextureDestroy(scr
, (WTexture
*) scr
->widget_texture
);
2768 scr
->widget_texture
= *(WTexSolid
**) texture
;
2773 static int setFTitleBack(WScreen
* scr
, WDefaultEntry
* entry
, WTexture
** texture
, void *foo
)
2775 if (scr
->window_title_texture
[WS_FOCUSED
]) {
2776 wTextureDestroy(scr
, scr
->window_title_texture
[WS_FOCUSED
]);
2778 scr
->window_title_texture
[WS_FOCUSED
] = *texture
;
2780 return REFRESH_WINDOW_TEXTURES
;
2783 static int setPTitleBack(WScreen
* scr
, WDefaultEntry
* entry
, WTexture
** texture
, void *foo
)
2785 if (scr
->window_title_texture
[WS_PFOCUSED
]) {
2786 wTextureDestroy(scr
, scr
->window_title_texture
[WS_PFOCUSED
]);
2788 scr
->window_title_texture
[WS_PFOCUSED
] = *texture
;
2790 return REFRESH_WINDOW_TEXTURES
;
2793 static int setUTitleBack(WScreen
* scr
, WDefaultEntry
* entry
, WTexture
** texture
, void *foo
)
2795 if (scr
->window_title_texture
[WS_UNFOCUSED
]) {
2796 wTextureDestroy(scr
, scr
->window_title_texture
[WS_UNFOCUSED
]);
2798 scr
->window_title_texture
[WS_UNFOCUSED
] = *texture
;
2800 return REFRESH_WINDOW_TEXTURES
;
2803 static int setResizebarBack(WScreen
* scr
, WDefaultEntry
* entry
, WTexture
** texture
, void *foo
)
2805 if (scr
->resizebar_texture
[0]) {
2806 wTextureDestroy(scr
, scr
->resizebar_texture
[0]);
2808 scr
->resizebar_texture
[0] = *texture
;
2810 return REFRESH_WINDOW_TEXTURES
;
2813 static int setMenuTitleBack(WScreen
* scr
, WDefaultEntry
* entry
, WTexture
** texture
, void *foo
)
2815 if (scr
->menu_title_texture
[0]) {
2816 wTextureDestroy(scr
, scr
->menu_title_texture
[0]);
2818 scr
->menu_title_texture
[0] = *texture
;
2820 return REFRESH_MENU_TITLE_TEXTURE
;
2823 static int setMenuTextBack(WScreen
* scr
, WDefaultEntry
* entry
, WTexture
** texture
, void *foo
)
2825 if (scr
->menu_item_texture
) {
2826 wTextureDestroy(scr
, scr
->menu_item_texture
);
2827 wTextureDestroy(scr
, (WTexture
*) scr
->menu_item_auxtexture
);
2829 scr
->menu_item_texture
= *texture
;
2831 scr
->menu_item_auxtexture
= wTextureMakeSolid(scr
, &scr
->menu_item_texture
->any
.color
);
2833 return REFRESH_MENU_TEXTURE
;
2836 static int setKeyGrab(WScreen
* scr
, WDefaultEntry
* entry
, WShortKey
* shortcut
, long widx
)
2839 wKeyBindings
[widx
] = *shortcut
;
2841 wwin
= scr
->focused_window
;
2843 while (wwin
!= NULL
) {
2844 XUngrabKey(dpy
, AnyKey
, AnyModifier
, wwin
->frame
->core
->window
);
2846 if (!WFLAGP(wwin
, no_bind_keys
)) {
2847 wWindowSetKeyGrabs(wwin
);
2855 static int setIconPosition(WScreen
* scr
, WDefaultEntry
* entry
, void *bar
, void *foo
)
2857 wScreenUpdateUsableArea(scr
);
2858 wArrangeIcons(scr
, True
);
2863 static int updateUsableArea(WScreen
* scr
, WDefaultEntry
* entry
, void *bar
, void *foo
)
2865 wScreenUpdateUsableArea(scr
);
2870 static int setMenuStyle(WScreen
* scr
, WDefaultEntry
* entry
, int *value
, void *foo
)
2872 return REFRESH_MENU_TEXTURE
;
2875 static RImage
*chopOffImage(RImage
* image
, int x
, int y
, int w
, int h
)
2877 RImage
*img
= RCreateImage(w
, h
, image
->format
== RRGBAFormat
);
2879 RCopyArea(img
, image
, x
, y
, w
, h
, 0, 0);
2884 static int setSwPOptions(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* array
, void *foo
)
2888 int cwidth
, cheight
;
2889 WPreferences
*prefs
= (WPreferences
*) foo
;
2891 if (!WMIsPLArray(array
) || WMGetPropListItemCount(array
) == 0) {
2892 if (prefs
->swtileImage
)
2893 RReleaseImage(prefs
->swtileImage
);
2894 prefs
->swtileImage
= NULL
;
2896 WMReleasePropList(array
);
2900 switch (WMGetPropListItemCount(array
)) {
2902 if (!WMIsPLString(WMGetFromPLArray(array
, 1))) {
2903 wwarning(_("Invalid arguments for option \"%s\""), entry
->key
);
2906 path
= FindImage(wPreferences
.pixmap_path
, WMGetFromPLString(WMGetFromPLArray(array
, 1)));
2909 wwarning(_("Could not find image \"%s\" for option \"%s\""),
2910 WMGetFromPLString(WMGetFromPLArray(array
, 1)), entry
->key
);
2912 bgimage
= RLoadImage(scr
->rcontext
, path
, 0);
2914 wwarning(_("Could not load image \"%s\" for option \"%s\""), path
, entry
->key
);
2919 cwidth
= atoi(WMGetFromPLString(WMGetFromPLArray(array
, 2)));
2920 cheight
= atoi(WMGetFromPLString(WMGetFromPLArray(array
, 3)));
2922 if (cwidth
<= 0 || cheight
<= 0 ||
2923 cwidth
>= bgimage
->width
- 2 || cheight
>= bgimage
->height
- 2)
2924 wwarning(_("Invalid split sizes for SwitchPanel back image."));
2927 int swidth
, theight
;
2928 for (i
= 0; i
< 9; i
++) {
2929 if (prefs
->swbackImage
[i
])
2930 RReleaseImage(prefs
->swbackImage
[i
]);
2931 prefs
->swbackImage
[i
] = NULL
;
2933 swidth
= (bgimage
->width
- cwidth
) / 2;
2934 theight
= (bgimage
->height
- cheight
) / 2;
2936 prefs
->swbackImage
[0] = chopOffImage(bgimage
, 0, 0, swidth
, theight
);
2937 prefs
->swbackImage
[1] = chopOffImage(bgimage
, swidth
, 0, cwidth
, theight
);
2938 prefs
->swbackImage
[2] = chopOffImage(bgimage
, swidth
+ cwidth
, 0,
2941 prefs
->swbackImage
[3] = chopOffImage(bgimage
, 0, theight
, swidth
, cheight
);
2942 prefs
->swbackImage
[4] = chopOffImage(bgimage
, swidth
, theight
,
2944 prefs
->swbackImage
[5] = chopOffImage(bgimage
, swidth
+ cwidth
, theight
,
2947 prefs
->swbackImage
[6] = chopOffImage(bgimage
, 0, theight
+ cheight
,
2949 prefs
->swbackImage
[7] = chopOffImage(bgimage
, swidth
, theight
+ cheight
,
2951 prefs
->swbackImage
[8] =
2952 chopOffImage(bgimage
, swidth
+ cwidth
, theight
+ cheight
, swidth
,
2955 // check if anything failed
2956 for (i
= 0; i
< 9; i
++) {
2957 if (!prefs
->swbackImage
[i
]) {
2958 for (; i
>= 0; --i
) {
2959 RReleaseImage(prefs
->swbackImage
[i
]);
2960 prefs
->swbackImage
[i
] = NULL
;
2966 RReleaseImage(bgimage
);
2971 if (!WMIsPLString(WMGetFromPLArray(array
, 0))) {
2972 wwarning(_("Invalid arguments for option \"%s\""), entry
->key
);
2975 path
= FindImage(wPreferences
.pixmap_path
, WMGetFromPLString(WMGetFromPLArray(array
, 0)));
2978 wwarning(_("Could not find image \"%s\" for option \"%s\""),
2979 WMGetFromPLString(WMGetFromPLArray(array
, 0)), entry
->key
);
2981 if (prefs
->swtileImage
)
2982 RReleaseImage(prefs
->swtileImage
);
2984 prefs
->swtileImage
= RLoadImage(scr
->rcontext
, path
, 0);
2985 if (!prefs
->swtileImage
) {
2986 wwarning(_("Could not load image \"%s\" for option \"%s\""), path
, entry
->key
);
2993 wwarning(_("Invalid number of arguments for option \"%s\""), entry
->key
);
2997 WMReleasePropList(array
);
3004 * Need access to the double click variables, so that all widgets in
3005 * wmaker panels will have the same dbl-click values.
3006 * TODO: figure a better way of dealing with it.
3008 #include <WINGs/WINGsP.h>
3010 static int setDoubleClick(WScreen
* scr
, WDefaultEntry
* entry
, int *value
, void *foo
)
3012 extern _WINGsConfiguration WINGsConfiguration
;
3017 WINGsConfiguration
.doubleClickDelay
= *value
;
3022 static int setCursor(WScreen
* scr
, WDefaultEntry
* entry
, Cursor
* cursor
, long widx
)
3024 if (wCursor
[widx
] != None
) {
3025 XFreeCursor(dpy
, wCursor
[widx
]);
3028 wCursor
[widx
] = *cursor
;
3030 if (widx
== WCUR_ROOT
&& *cursor
!= None
) {
3031 XDefineCursor(dpy
, scr
->root_win
, *cursor
);