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>
44 #define PATH_MAX DEFAULT_PATH_MAX
48 #include <X11/Xutil.h>
49 #include <X11/keysym.h>
53 #include "WindowMaker.h"
59 #include "resources.h"
62 #include "xmodifier.h"
67 #include "workspace.h"
68 #include "properties.h"
70 #define MAX_SHORTCUT_LENGTH 32
72 #ifndef GLOBAL_DEFAULTS_SUBDIR
73 #define GLOBAL_DEFAULTS_SUBDIR "WindowMaker"
78 extern WDDomain
*WDWindowMaker
;
79 extern WDDomain
*WDWindowAttributes
;
80 extern WDDomain
*WDRootMenu
;
82 extern int wScreenCount
;
84 extern Atom _XA_WINDOWMAKER_ICON_SIZE
;
85 extern Atom _XA_WINDOWMAKER_ICON_TILE
;
87 extern WPreferences wPreferences
;
89 extern WShortKey wKeyBindings
[WKBD_LAST
];
99 WMPropList
*plvalue
; /* default value */
102 /* used to map strings to integers */
107 } WOptionEnumeration
;
109 /* type converters */
110 static int getBool();
112 static int getCoord();
113 static int getPathList();
114 static int getEnum();
115 static int getTexture();
116 static int getWSBackground();
117 static int getWSSpecificBackground();
118 static int getFont();
119 static int getColor();
120 static int getKeybind();
121 static int getModMask();
123 static int getRImage();
125 static int getPropList();
127 /* value setting functions */
128 static int setJustify();
129 static int setClearance();
130 static int setIfDockPresent();
131 static int setStickyIcons();
132 static int setWidgetColor();
133 static int setIconTile();
134 static int setWinTitleFont();
135 static int setMenuTitleFont();
136 static int setMenuTextFont();
137 static int setIconTitleFont();
138 static int setIconTitleColor();
139 static int setIconTitleBack();
140 static int setLargeDisplayFont();
141 static int setWTitleColor();
142 static int setFTitleBack();
143 static int setPTitleBack();
144 static int setUTitleBack();
145 static int setResizebarBack();
146 static int setWorkspaceBack();
147 static int setWorkspaceSpecificBack();
148 static int setMenuTitleColor();
149 static int setMenuTextColor();
150 static int setMenuDisabledColor();
151 static int setMenuTitleBack();
152 static int setMenuTextBack();
153 static int setHightlight();
154 static int setHightlightText();
155 static int setKeyGrab();
156 static int setDoubleClick();
157 static int setIconPosition();
159 static int setClipTitleFont();
160 static int setClipTitleColor();
162 static int setMenuStyle();
163 static int setSwPOptions();
164 static int updateUsableArea();
166 extern Cursor wCursor
[WCUR_LAST
];
167 static int getCursor();
168 static int setCursor();
171 * Tables to convert strings to enumeration values.
172 * Values stored are char
175 /* WARNING: sum of length of all value strings must not exceed
177 #define TOTAL_VALUES_LENGTH 80
179 #define REFRESH_WINDOW_TEXTURES (1<<0)
180 #define REFRESH_MENU_TEXTURE (1<<1)
181 #define REFRESH_MENU_FONT (1<<2)
182 #define REFRESH_MENU_COLOR (1<<3)
183 #define REFRESH_MENU_TITLE_TEXTURE (1<<4)
184 #define REFRESH_MENU_TITLE_FONT (1<<5)
185 #define REFRESH_MENU_TITLE_COLOR (1<<6)
186 #define REFRESH_WINDOW_TITLE_COLOR (1<<7)
187 #define REFRESH_WINDOW_FONT (1<<8)
188 #define REFRESH_ICON_TILE (1<<9)
189 #define REFRESH_ICON_FONT (1<<10)
190 #define REFRESH_WORKSPACE_BACK (1<<11)
192 #define REFRESH_BUTTON_IMAGES (1<<12)
194 #define REFRESH_ICON_TITLE_COLOR (1<<13)
195 #define REFRESH_ICON_TITLE_BACK (1<<14)
197 static WOptionEnumeration seFocusModes
[] = {
198 {"Manual", WKF_CLICK
, 0}, {"ClickToFocus", WKF_CLICK
, 1},
199 {"Sloppy", WKF_SLOPPY
, 0}, {"SemiAuto", WKF_SLOPPY
, 1}, {"Auto", WKF_SLOPPY
, 1},
203 static WOptionEnumeration seColormapModes
[] = {
204 {"Manual", WCM_CLICK
, 0}, {"ClickToFocus", WCM_CLICK
, 1},
205 {"Auto", WCM_POINTER
, 0}, {"FocusFollowMouse", WCM_POINTER
, 1},
209 static WOptionEnumeration sePlacements
[] = {
210 {"Auto", WPM_AUTO
, 0},
211 {"Smart", WPM_SMART
, 0},
212 {"Cascade", WPM_CASCADE
, 0},
213 {"Random", WPM_RANDOM
, 0},
214 {"Manual", WPM_MANUAL
, 0},
218 static WOptionEnumeration seGeomDisplays
[] = {
219 {"None", WDIS_NONE
, 0},
220 {"Center", WDIS_CENTER
, 0},
221 {"Corner", WDIS_TOPLEFT
, 0},
222 {"Floating", WDIS_FRAME_CENTER
, 0},
223 {"Line", WDIS_NEW
, 0},
227 static WOptionEnumeration seSpeeds
[] = {
228 {"UltraFast", SPEED_ULTRAFAST
, 0},
229 {"Fast", SPEED_FAST
, 0},
230 {"Medium", SPEED_MEDIUM
, 0},
231 {"Slow", SPEED_SLOW
, 0},
232 {"UltraSlow", SPEED_ULTRASLOW
, 0},
236 static WOptionEnumeration seMouseButtonActions
[] = {
237 {"None", WA_NONE
, 0},
238 {"SelectWindows", WA_SELECT_WINDOWS
, 0},
239 {"OpenApplicationsMenu", WA_OPEN_APPMENU
, 0},
240 {"OpenWindowListMenu", WA_OPEN_WINLISTMENU
, 0},
244 static WOptionEnumeration seMouseWheelActions
[] = {
245 {"None", WA_NONE
, 0},
246 {"SwitchWorkspaces", WA_SWITCH_WORKSPACES
, 0},
250 static WOptionEnumeration seIconificationStyles
[] = {
251 {"Zoom", WIS_ZOOM
, 0},
252 {"Twist", WIS_TWIST
, 0},
253 {"Flip", WIS_FLIP
, 0},
254 {"None", WIS_NONE
, 0},
255 {"random", WIS_RANDOM
, 0},
259 static WOptionEnumeration seJustifications
[] = {
260 {"Left", WTJ_LEFT
, 0},
261 {"Center", WTJ_CENTER
, 0},
262 {"Right", WTJ_RIGHT
, 0},
266 static WOptionEnumeration seIconPositions
[] = {
267 {"blv", IY_BOTTOM
| IY_LEFT
| IY_VERT
, 0},
268 {"blh", IY_BOTTOM
| IY_LEFT
| IY_HORIZ
, 0},
269 {"brv", IY_BOTTOM
| IY_RIGHT
| IY_VERT
, 0},
270 {"brh", IY_BOTTOM
| IY_RIGHT
| IY_HORIZ
, 0},
271 {"tlv", IY_TOP
| IY_LEFT
| IY_VERT
, 0},
272 {"tlh", IY_TOP
| IY_LEFT
| IY_HORIZ
, 0},
273 {"trv", IY_TOP
| IY_RIGHT
| IY_VERT
, 0},
274 {"trh", IY_TOP
| IY_RIGHT
| IY_HORIZ
, 0},
278 static WOptionEnumeration seMenuStyles
[] = {
279 {"normal", MS_NORMAL
, 0},
280 {"singletexture", MS_SINGLE_TEXTURE
, 0},
281 {"flat", MS_FLAT
, 0},
285 static WOptionEnumeration seDisplayPositions
[] = {
286 {"none", WD_NONE
, 0},
287 {"center", WD_CENTER
, 0},
289 {"bottom", WD_BOTTOM
, 0},
290 {"topleft", WD_TOPLEFT
, 0},
291 {"topright", WD_TOPRIGHT
, 0},
292 {"bottomleft", WD_BOTTOMLEFT
, 0},
293 {"bottomright", WD_BOTTOMRIGHT
, 0},
297 static WOptionEnumeration seWorkspaceBorder
[] = {
298 {"None", WB_NONE
, 0},
299 {"LeftRight", WB_LEFTRIGHT
, 0},
300 {"TopBottom", WB_TOPBOTTOM
, 0},
301 {"AllDirections", WB_ALLDIRS
, 0},
306 * ALL entries in the tables bellow, NEED to have a default value
307 * defined, and this value needs to be correct.
310 /* these options will only affect the window manager on startup
312 * static defaults can't access the screen data, because it is
313 * created after these defaults are read
315 WDefaultEntry staticOptionList
[] = {
317 {"ColormapSize", "4", NULL
,
318 &wPreferences
.cmap_size
, getInt
, NULL
},
319 {"DisableDithering", "NO", NULL
,
320 &wPreferences
.no_dithering
, getBool
, NULL
},
321 /* static by laziness */
322 {"IconSize", "64", NULL
,
323 &wPreferences
.icon_size
, getInt
, NULL
},
324 {"ModifierKey", "Mod1", NULL
,
325 &wPreferences
.modifier_mask
, getModMask
, NULL
},
326 {"DisableWSMouseActions", "NO", NULL
,
327 &wPreferences
.disable_root_mouse
, getBool
, NULL
},
328 {"FocusMode", "manual", seFocusModes
,
329 &wPreferences
.focus_mode
, getEnum
, NULL
}, /* have a problem when switching from manual to sloppy without restart */
330 {"NewStyle", "NO", NULL
,
331 &wPreferences
.new_style
, getBool
, NULL
},
332 {"DisableDock", "NO", (void *)WM_DOCK
,
333 NULL
, getBool
, setIfDockPresent
},
334 {"DisableClip", "NO", (void *)WM_CLIP
,
335 NULL
, getBool
, setIfDockPresent
},
336 {"DisableMiniwindows", "NO", NULL
,
337 &wPreferences
.disable_miniwindows
, getBool
, NULL
}
340 WDefaultEntry optionList
[] = {
341 /* dynamic options */
342 {"IconPosition", "blh", seIconPositions
,
343 &wPreferences
.icon_yard
, getEnum
, setIconPosition
},
344 {"IconificationStyle", "Zoom", seIconificationStyles
,
345 &wPreferences
.iconification_style
, getEnum
, NULL
},
346 {"MouseLeftButtonAction", "SelectWindows", seMouseButtonActions
,
347 &wPreferences
.mouse_button1
, getEnum
, NULL
},
348 {"MouseMiddleButtonAction", "OpenWindowListMenu", seMouseButtonActions
,
349 &wPreferences
.mouse_button2
, getEnum
, NULL
},
350 {"MouseRightButtonAction", "OpenApplicationsMenu", seMouseButtonActions
,
351 &wPreferences
.mouse_button3
, getEnum
, NULL
},
352 {"MouseWheelAction", "None", seMouseWheelActions
,
353 &wPreferences
.mouse_wheel
, getEnum
, NULL
},
354 {"PixmapPath", DEF_PIXMAP_PATHS
, NULL
,
355 &wPreferences
.pixmap_path
, getPathList
, NULL
},
356 {"IconPath", DEF_ICON_PATHS
, NULL
,
357 &wPreferences
.icon_path
, getPathList
, NULL
},
358 {"ColormapMode", "auto", seColormapModes
,
359 &wPreferences
.colormap_mode
, getEnum
, NULL
},
360 {"AutoFocus", "NO", NULL
,
361 &wPreferences
.auto_focus
, getBool
, NULL
},
362 {"RaiseDelay", "0", NULL
,
363 &wPreferences
.raise_delay
, getInt
, NULL
},
364 {"CirculateRaise", "NO", NULL
,
365 &wPreferences
.circ_raise
, getBool
, NULL
},
366 {"Superfluous", "NO", NULL
,
367 &wPreferences
.superfluous
, getBool
, NULL
},
368 {"AdvanceToNewWorkspace", "NO", NULL
,
369 &wPreferences
.ws_advance
, getBool
, NULL
},
370 {"CycleWorkspaces", "NO", NULL
,
371 &wPreferences
.ws_cycle
, getBool
, NULL
},
372 {"WorkspaceNameDisplayPosition", "center", seDisplayPositions
,
373 &wPreferences
.workspace_name_display_position
, getEnum
, NULL
},
374 {"WorkspaceBorder", "None", seWorkspaceBorder
,
375 &wPreferences
.workspace_border_position
, getEnum
, updateUsableArea
},
376 {"WorkspaceBorderSize", "0", NULL
,
377 &wPreferences
.workspace_border_size
, getInt
, updateUsableArea
},
378 {"StickyIcons", "NO", NULL
,
379 &wPreferences
.sticky_icons
, getBool
, setStickyIcons
},
380 {"SaveSessionOnExit", "NO", NULL
,
381 &wPreferences
.save_session_on_exit
, getBool
, NULL
},
382 {"WrapMenus", "NO", NULL
,
383 &wPreferences
.wrap_menus
, getBool
, NULL
},
384 {"ScrollableMenus", "NO", NULL
,
385 &wPreferences
.scrollable_menus
, getBool
, NULL
},
386 {"MenuScrollSpeed", "medium", seSpeeds
,
387 &wPreferences
.menu_scroll_speed
, getEnum
, NULL
},
388 {"IconSlideSpeed", "medium", seSpeeds
,
389 &wPreferences
.icon_slide_speed
, getEnum
, NULL
},
390 {"ShadeSpeed", "medium", seSpeeds
,
391 &wPreferences
.shade_speed
, getEnum
, NULL
},
392 {"DoubleClickTime", "250", (void *)&wPreferences
.dblclick_time
,
393 &wPreferences
.dblclick_time
, getInt
, setDoubleClick
,
395 {"AlignSubmenus", "NO", NULL
,
396 &wPreferences
.align_menus
, getBool
, NULL
},
397 {"OpenTransientOnOwnerWorkspace", "NO", NULL
,
398 &wPreferences
.open_transients_with_parent
, getBool
, NULL
},
399 {"WindowPlacement", "auto", sePlacements
,
400 &wPreferences
.window_placement
, getEnum
, NULL
},
401 {"IgnoreFocusClick", "NO", NULL
,
402 &wPreferences
.ignore_focus_click
, getBool
, NULL
},
403 {"UseSaveUnders", "NO", NULL
,
404 &wPreferences
.use_saveunders
, getBool
, NULL
},
405 {"OpaqueMove", "NO", NULL
,
406 &wPreferences
.opaque_move
, getBool
, NULL
},
407 {"DisableAnimations", "NO", NULL
,
408 &wPreferences
.no_animations
, getBool
, NULL
},
409 {"DontLinkWorkspaces", "NO", NULL
,
410 &wPreferences
.no_autowrap
, getBool
, NULL
},
411 {"AutoArrangeIcons", "NO", NULL
,
412 &wPreferences
.auto_arrange_icons
, getBool
, NULL
},
413 {"NoWindowOverDock", "NO", NULL
,
414 &wPreferences
.no_window_over_dock
, getBool
, updateUsableArea
},
415 {"NoWindowOverIcons", "NO", NULL
,
416 &wPreferences
.no_window_over_icons
, getBool
, updateUsableArea
},
417 {"WindowPlaceOrigin", "(0, 0)", NULL
,
418 &wPreferences
.window_place_origin
, getCoord
, NULL
},
419 {"ResizeDisplay", "corner", seGeomDisplays
,
420 &wPreferences
.size_display
, getEnum
, NULL
},
421 {"MoveDisplay", "corner", seGeomDisplays
,
422 &wPreferences
.move_display
, getEnum
, NULL
},
423 {"DontConfirmKill", "NO", NULL
,
424 &wPreferences
.dont_confirm_kill
, getBool
, NULL
},
425 {"WindowTitleBalloons", "NO", NULL
,
426 &wPreferences
.window_balloon
, getBool
, NULL
},
427 {"MiniwindowTitleBalloons", "NO", NULL
,
428 &wPreferences
.miniwin_balloon
, getBool
, NULL
},
429 {"AppIconBalloons", "NO", NULL
,
430 &wPreferences
.appicon_balloon
, getBool
, NULL
},
431 {"HelpBalloons", "NO", NULL
,
432 &wPreferences
.help_balloon
, getBool
, NULL
},
433 {"EdgeResistance", "30", NULL
,
434 &wPreferences
.edge_resistance
, getInt
, NULL
},
435 {"ResizeIncrement", "32", NULL
,
436 &wPreferences
.resize_increment
, getInt
, NULL
},
437 {"Attraction", "NO", NULL
,
438 &wPreferences
.attract
, getBool
, NULL
},
439 {"DisableBlinking", "NO", NULL
,
440 &wPreferences
.dont_blink
, getBool
, NULL
},
441 {"SingleClickLaunch", "NO", NULL
,
442 &wPreferences
.single_click
, getBool
, NULL
},
444 {"MenuStyle", "normal", seMenuStyles
,
445 &wPreferences
.menu_style
, getEnum
, setMenuStyle
},
446 {"WidgetColor", "(solid, gray)", NULL
,
447 NULL
, getTexture
, setWidgetColor
,
449 {"WorkspaceSpecificBack", "()", NULL
,
450 NULL
, getWSSpecificBackground
, setWorkspaceSpecificBack
},
451 /* WorkspaceBack must come after WorkspaceSpecificBack or
452 * WorkspaceBack wont know WorkspaceSpecificBack was also
453 * specified and 2 copies of wmsetbg will be launched */
454 {"WorkspaceBack", "(solid, black)", NULL
,
455 NULL
, getWSBackground
, setWorkspaceBack
},
456 {"SmoothWorkspaceBack", "NO", NULL
,
457 NULL
, getBool
, NULL
},
458 {"IconBack", "(solid, gray)", NULL
,
459 NULL
, getTexture
, setIconTile
},
460 {"TitleJustify", "center", seJustifications
,
461 &wPreferences
.title_justification
, getEnum
, setJustify
},
462 {"WindowTitleFont", DEF_TITLE_FONT
, NULL
,
463 NULL
, getFont
, setWinTitleFont
,
465 {"WindowTitleExtendSpace", DEF_WINDOW_TITLE_EXTEND_SPACE
, NULL
,
466 &wPreferences
.window_title_clearance
, getInt
, setClearance
},
467 {"MenuTitleExtendSpace", DEF_MENU_TITLE_EXTEND_SPACE
, NULL
,
468 &wPreferences
.menu_title_clearance
, getInt
, setClearance
},
469 {"MenuTextExtendSpace", DEF_MENU_TEXT_EXTEND_SPACE
, NULL
,
470 &wPreferences
.menu_text_clearance
, getInt
, setClearance
},
471 {"MenuTitleFont", DEF_MENU_TITLE_FONT
, NULL
,
472 NULL
, getFont
, setMenuTitleFont
},
473 {"MenuTextFont", DEF_MENU_ENTRY_FONT
, NULL
,
474 NULL
, getFont
, setMenuTextFont
},
475 {"IconTitleFont", DEF_ICON_TITLE_FONT
, NULL
,
476 NULL
, getFont
, setIconTitleFont
},
477 {"ClipTitleFont", DEF_CLIP_TITLE_FONT
, NULL
,
478 NULL
, getFont
, setClipTitleFont
},
479 {"LargeDisplayFont", DEF_WORKSPACE_NAME_FONT
, NULL
,
480 NULL
, getFont
, setLargeDisplayFont
},
481 {"HighlightColor", "white", NULL
,
482 NULL
, getColor
, setHightlight
},
483 {"HighlightTextColor", "black", NULL
,
484 NULL
, getColor
, setHightlightText
},
485 {"ClipTitleColor", "black", (void *)CLIP_NORMAL
,
486 NULL
, getColor
, setClipTitleColor
},
487 {"CClipTitleColor", "\"#454045\"", (void *)CLIP_COLLAPSED
,
488 NULL
, getColor
, setClipTitleColor
},
489 {"FTitleColor", "white", (void *)WS_FOCUSED
,
490 NULL
, getColor
, setWTitleColor
},
491 {"PTitleColor", "white", (void *)WS_PFOCUSED
,
492 NULL
, getColor
, setWTitleColor
},
493 {"UTitleColor", "black", (void *)WS_UNFOCUSED
,
494 NULL
, getColor
, setWTitleColor
},
495 {"FTitleBack", "(solid, black)", NULL
,
496 NULL
, getTexture
, setFTitleBack
},
497 {"PTitleBack", "(solid, \"#616161\")", NULL
,
498 NULL
, getTexture
, setPTitleBack
},
499 {"UTitleBack", "(solid, gray)", NULL
,
500 NULL
, getTexture
, setUTitleBack
},
501 {"ResizebarBack", "(solid, gray)", NULL
,
502 NULL
, getTexture
, setResizebarBack
},
503 {"MenuTitleColor", "white", NULL
,
504 NULL
, getColor
, setMenuTitleColor
},
505 {"MenuTextColor", "black", NULL
,
506 NULL
, getColor
, setMenuTextColor
},
507 {"MenuDisabledColor", "\"#616161\"", NULL
,
508 NULL
, getColor
, setMenuDisabledColor
},
509 {"MenuTitleBack", "(solid, black)", NULL
,
510 NULL
, getTexture
, setMenuTitleBack
},
511 {"MenuTextBack", "(solid, gray)", NULL
,
512 NULL
, getTexture
, setMenuTextBack
},
513 {"IconTitleColor", "white", NULL
,
514 NULL
, getColor
, setIconTitleColor
},
515 {"IconTitleBack", "black", NULL
,
516 NULL
, getColor
, setIconTitleBack
},
517 {"SwitchPanelImages", "(swtile.png, swback.png, 30, 40)", &wPreferences
,
518 NULL
, getPropList
, setSwPOptions
},
520 {"RootMenuKey", "None", (void *)WKBD_ROOTMENU
,
521 NULL
, getKeybind
, setKeyGrab
},
522 {"WindowListKey", "None", (void *)WKBD_WINDOWLIST
,
523 NULL
, getKeybind
, setKeyGrab
},
524 {"WindowMenuKey", "None", (void *)WKBD_WINDOWMENU
,
525 NULL
, getKeybind
, setKeyGrab
},
526 {"DockRaiseLowerKey", "None", (void*)WKBD_DOCKRAISELOWER
,
527 NULL
, getKeybind
, setKeyGrab
},
528 {"ClipRaiseLowerKey", "None", (void *)WKBD_CLIPRAISELOWER
,
529 NULL
, getKeybind
, setKeyGrab
},
530 {"MiniaturizeKey", "None", (void *)WKBD_MINIATURIZE
,
531 NULL
, getKeybind
, setKeyGrab
},
532 {"HideKey", "None", (void *)WKBD_HIDE
,
533 NULL
, getKeybind
, setKeyGrab
},
534 {"HideOthersKey", "None", (void *)WKBD_HIDE_OTHERS
,
535 NULL
, getKeybind
, setKeyGrab
},
536 {"MoveResizeKey", "None", (void *)WKBD_MOVERESIZE
,
537 NULL
, getKeybind
, setKeyGrab
},
538 {"CloseKey", "None", (void *)WKBD_CLOSE
,
539 NULL
, getKeybind
, setKeyGrab
},
540 {"MaximizeKey", "None", (void *)WKBD_MAXIMIZE
,
541 NULL
, getKeybind
, setKeyGrab
},
542 {"VMaximizeKey", "None", (void *)WKBD_VMAXIMIZE
,
543 NULL
, getKeybind
, setKeyGrab
},
544 {"HMaximizeKey", "None", (void *)WKBD_HMAXIMIZE
,
545 NULL
, getKeybind
, setKeyGrab
},
546 {"LHMaximizeKey", "None", (void*)WKBD_LHMAXIMIZE
,
547 NULL
, getKeybind
, setKeyGrab
},
548 {"RHMaximizeKey", "None", (void*)WKBD_RHMAXIMIZE
,
549 NULL
, getKeybind
, setKeyGrab
},
550 {"MaximusKey", "None", (void*)WKBD_MAXIMUS
,
551 NULL
, getKeybind
, setKeyGrab
},
552 {"RaiseKey", "\"Meta+Up\"", (void *)WKBD_RAISE
,
553 NULL
, getKeybind
, setKeyGrab
},
554 {"LowerKey", "\"Meta+Down\"", (void *)WKBD_LOWER
,
555 NULL
, getKeybind
, setKeyGrab
},
556 {"RaiseLowerKey", "None", (void *)WKBD_RAISELOWER
,
557 NULL
, getKeybind
, setKeyGrab
},
558 {"ShadeKey", "None", (void *)WKBD_SHADE
,
559 NULL
, getKeybind
, setKeyGrab
},
560 {"SelectKey", "None", (void *)WKBD_SELECT
,
561 NULL
, getKeybind
, setKeyGrab
},
562 {"FocusNextKey", "None", (void *)WKBD_FOCUSNEXT
,
563 NULL
, getKeybind
, setKeyGrab
},
564 {"FocusPrevKey", "None", (void *)WKBD_FOCUSPREV
,
565 NULL
, getKeybind
, setKeyGrab
},
566 {"GroupNextKey", "None", (void *)WKBD_GROUPNEXT
,
567 NULL
, getKeybind
, setKeyGrab
},
568 {"GroupPrevKey", "None", (void *)WKBD_GROUPPREV
,
569 NULL
, getKeybind
, setKeyGrab
},
570 {"NextWorkspaceKey", "None", (void *)WKBD_NEXTWORKSPACE
,
571 NULL
, getKeybind
, setKeyGrab
},
572 {"PrevWorkspaceKey", "None", (void *)WKBD_PREVWORKSPACE
,
573 NULL
, getKeybind
, setKeyGrab
},
574 {"NextWorkspaceLayerKey", "None", (void *)WKBD_NEXTWSLAYER
,
575 NULL
, getKeybind
, setKeyGrab
},
576 {"PrevWorkspaceLayerKey", "None", (void *)WKBD_PREVWSLAYER
,
577 NULL
, getKeybind
, setKeyGrab
},
578 {"Workspace1Key", "None", (void *)WKBD_WORKSPACE1
,
579 NULL
, getKeybind
, setKeyGrab
},
580 {"Workspace2Key", "None", (void *)WKBD_WORKSPACE2
,
581 NULL
, getKeybind
, setKeyGrab
},
582 {"Workspace3Key", "None", (void *)WKBD_WORKSPACE3
,
583 NULL
, getKeybind
, setKeyGrab
},
584 {"Workspace4Key", "None", (void *)WKBD_WORKSPACE4
,
585 NULL
, getKeybind
, setKeyGrab
},
586 {"Workspace5Key", "None", (void *)WKBD_WORKSPACE5
,
587 NULL
, getKeybind
, setKeyGrab
},
588 {"Workspace6Key", "None", (void *)WKBD_WORKSPACE6
,
589 NULL
, getKeybind
, setKeyGrab
},
590 {"Workspace7Key", "None", (void *)WKBD_WORKSPACE7
,
591 NULL
, getKeybind
, setKeyGrab
},
592 {"Workspace8Key", "None", (void *)WKBD_WORKSPACE8
,
593 NULL
, getKeybind
, setKeyGrab
},
594 {"Workspace9Key", "None", (void *)WKBD_WORKSPACE9
,
595 NULL
, getKeybind
, setKeyGrab
},
596 {"Workspace10Key", "None", (void *)WKBD_WORKSPACE10
,
597 NULL
, getKeybind
, setKeyGrab
},
598 {"WindowShortcut1Key", "None", (void *)WKBD_WINDOW1
,
599 NULL
, getKeybind
, setKeyGrab
},
600 {"WindowShortcut2Key", "None", (void *)WKBD_WINDOW2
,
601 NULL
, getKeybind
, setKeyGrab
},
602 {"WindowShortcut3Key", "None", (void *)WKBD_WINDOW3
,
603 NULL
, getKeybind
, setKeyGrab
},
604 {"WindowShortcut4Key", "None", (void *)WKBD_WINDOW4
,
605 NULL
, getKeybind
, setKeyGrab
}
606 , {"WindowShortcut5Key", "None", (void *)WKBD_WINDOW5
,
607 NULL
, getKeybind
, setKeyGrab
},
608 {"WindowShortcut6Key", "None", (void *)WKBD_WINDOW6
,
609 NULL
, getKeybind
, setKeyGrab
},
610 {"WindowShortcut7Key", "None", (void *)WKBD_WINDOW7
,
611 NULL
, getKeybind
, setKeyGrab
},
612 {"WindowShortcut8Key", "None", (void *)WKBD_WINDOW8
,
613 NULL
, getKeybind
, setKeyGrab
},
614 {"WindowShortcut9Key", "None", (void *)WKBD_WINDOW9
,
615 NULL
, getKeybind
, setKeyGrab
},
616 {"WindowShortcut10Key", "None", (void *)WKBD_WINDOW10
,
617 NULL
, getKeybind
, setKeyGrab
},
618 {"ScreenSwitchKey", "None", (void *)WKBD_SWITCH_SCREEN
,
619 NULL
, getKeybind
, setKeyGrab
},
621 #ifdef KEEP_XKB_LOCK_STATUS
622 {"ToggleKbdModeKey", "None", (void *)WKBD_TOGGLE
,
623 NULL
, getKeybind
, setKeyGrab
},
624 {"KbdModeLock", "NO", NULL
,
625 &wPreferences
.modelock
, getBool
, NULL
},
626 #endif /* KEEP_XKB_LOCK_STATUS */
628 {"NormalCursor", "(builtin, left_ptr)", (void *)WCUR_ROOT
,
629 NULL
, getCursor
, setCursor
},
630 {"ArrowCursor", "(builtin, top_left_arrow)", (void *)WCUR_ARROW
,
631 NULL
, getCursor
, setCursor
},
632 {"MoveCursor", "(builtin, fleur)", (void *)WCUR_MOVE
,
633 NULL
, getCursor
, setCursor
},
634 {"ResizeCursor", "(builtin, sizing)", (void *)WCUR_RESIZE
,
635 NULL
, getCursor
, setCursor
},
636 {"TopLeftResizeCursor", "(builtin, top_left_corner)",
637 (void *)WCUR_TOPLEFTRESIZE
,
638 NULL
, getCursor
, setCursor
},
639 {"TopRightResizeCursor", "(builtin, top_right_corner)",
640 (void *)WCUR_TOPRIGHTRESIZE
,
641 NULL
, getCursor
, setCursor
},
642 {"BottomLeftResizeCursor", "(builtin, bottom_left_corner)",
643 (void *)WCUR_BOTTOMLEFTRESIZE
,
644 NULL
, getCursor
, setCursor
},
645 {"BottomRightResizeCursor", "(builtin, bottom_right_corner)",
646 (void *)WCUR_BOTTOMRIGHTRESIZE
,
647 NULL
, getCursor
, setCursor
},
648 {"VerticalResizeCursor", "(builtin, sb_v_double_arrow)",
649 (void *)WCUR_VERTICALRESIZE
,
650 NULL
, getCursor
, setCursor
},
651 {"HorizontalResizeCursor", "(builtin, sb_h_double_arrow)",
652 (void *)WCUR_HORIZONRESIZE
,
653 NULL
, getCursor
, setCursor
},
654 {"WaitCursor", "(builtin, watch)", (void *)WCUR_WAIT
,
655 NULL
, getCursor
, setCursor
},
656 {"QuestionCursor", "(builtin, question_arrow)", (void *)WCUR_QUESTION
,
657 NULL
, getCursor
, setCursor
},
658 {"TextCursor", "(builtin, xterm)", (void *)WCUR_TEXT
,
659 NULL
, getCursor
, setCursor
},
660 {"SelectCursor", "(builtin, cross)", (void *)WCUR_SELECT
,
661 NULL
, getCursor
, setCursor
},
662 {"DialogHistoryLines", "500", NULL
,
663 &wPreferences
.history_lines
, getInt
, NULL
}
667 static void rereadDefaults(void)
669 /* must defer the update because accessing X data from a
670 * signal handler can mess up Xlib */
675 static void initDefaults()
678 WDefaultEntry
*entry
;
680 WMPLSetCaseSensitive(False
);
682 for (i
= 0; i
< sizeof(optionList
) / sizeof(WDefaultEntry
); i
++) {
683 entry
= &optionList
[i
];
685 entry
->plkey
= WMCreatePLString(entry
->key
);
686 if (entry
->default_value
)
687 entry
->plvalue
= WMCreatePropListFromDescription(entry
->default_value
);
689 entry
->plvalue
= NULL
;
692 for (i
= 0; i
< sizeof(staticOptionList
) / sizeof(WDefaultEntry
); i
++) {
693 entry
= &staticOptionList
[i
];
695 entry
->plkey
= WMCreatePLString(entry
->key
);
696 if (entry
->default_value
)
697 entry
->plvalue
= WMCreatePropListFromDescription(entry
->default_value
);
699 entry
->plvalue
= NULL
;
703 wDomainName = WMCreatePLString(WMDOMAIN_NAME);
704 wAttributeDomainName = WMCreatePLString(WMATTRIBUTE_DOMAIN_NAME);
706 PLRegister(wDomainName, rereadDefaults);
707 PLRegister(wAttributeDomainName, rereadDefaults);
711 static WMPropList
*readGlobalDomain(char *domainName
, Bool requireDictionary
)
713 WMPropList
*globalDict
= NULL
;
717 snprintf(path
, sizeof(path
), "%s/%s/%s", SYSCONFDIR
, GLOBAL_DEFAULTS_SUBDIR
, domainName
);
718 if (stat(path
, &stbuf
) >= 0) {
719 globalDict
= WMReadPropListFromFile(path
);
720 if (globalDict
&& requireDictionary
&& !WMIsPLDictionary(globalDict
)) {
721 wwarning(_("Domain %s (%s) of global defaults database is corrupted!"), domainName
, path
);
722 WMReleasePropList(globalDict
);
724 } else if (!globalDict
) {
725 wwarning(_("could not load domain %s from global defaults database"), domainName
);
732 #if defined(GLOBAL_PREAMBLE_MENU_FILE) || defined(GLOBAL_EPILOGUE_MENU_FILE)
733 static void prependMenu(WMPropList
* destarr
, WMPropList
* array
)
738 for (i
= 0; i
< WMGetPropListItemCount(array
); i
++) {
739 item
= WMGetFromPLArray(array
, i
);
741 WMInsertInPLArray(destarr
, i
+ 1, item
);
745 static void appendMenu(WMPropList
* destarr
, WMPropList
* array
)
750 for (i
= 0; i
< WMGetPropListItemCount(array
); i
++) {
751 item
= WMGetFromPLArray(array
, i
);
753 WMAddToPLArray(destarr
, item
);
758 void wDefaultsMergeGlobalMenus(WDDomain
* menuDomain
)
760 WMPropList
*menu
= menuDomain
->dictionary
;
763 if (!menu
|| !WMIsPLArray(menu
))
766 #ifdef GLOBAL_PREAMBLE_MENU_FILE
767 submenu
= WMReadPropListFromFile(SYSCONFDIR
"/" GLOBAL_DEFAULTS_SUBDIR
"/" GLOBAL_PREAMBLE_MENU_FILE
);
769 if (submenu
&& !WMIsPLArray(submenu
)) {
770 wwarning(_("invalid global menu file %s"), GLOBAL_PREAMBLE_MENU_FILE
);
771 WMReleasePropList(submenu
);
775 prependMenu(menu
, submenu
);
776 WMReleasePropList(submenu
);
780 #ifdef GLOBAL_EPILOGUE_MENU_FILE
781 submenu
= WMReadPropListFromFile(SYSCONFDIR
"/" GLOBAL_DEFAULTS_SUBDIR
"/" GLOBAL_EPILOGUE_MENU_FILE
);
783 if (submenu
&& !WMIsPLArray(submenu
)) {
784 wwarning(_("invalid global menu file %s"), GLOBAL_EPILOGUE_MENU_FILE
);
785 WMReleasePropList(submenu
);
789 appendMenu(menu
, submenu
);
790 WMReleasePropList(submenu
);
794 menuDomain
->dictionary
= menu
;
797 void wDefaultsDestroyDomain(WDDomain
* domain
)
799 if (domain
->dictionary
)
800 WMReleasePropList(domain
->dictionary
);
805 WDDomain
*wDefaultsInitDomain(char *domain
, Bool requireDictionary
)
809 static int inited
= 0;
812 WMPropList
*shared_dict
= NULL
;
819 db
= wmalloc(sizeof(WDDomain
));
820 memset(db
, 0, sizeof(WDDomain
));
821 db
->domain_name
= domain
;
822 db
->path
= wdefaultspathfordomain(domain
);
825 if (the_path
&& stat(the_path
, &stbuf
) >= 0) {
826 db
->dictionary
= WMReadPropListFromFile(the_path
);
827 if (db
->dictionary
) {
828 if (requireDictionary
&& !WMIsPLDictionary(db
->dictionary
)) {
829 WMReleasePropList(db
->dictionary
);
830 db
->dictionary
= NULL
;
831 wwarning(_("Domain %s (%s) of defaults database is corrupted!"), domain
, the_path
);
833 db
->timestamp
= stbuf
.st_mtime
;
835 wwarning(_("could not load domain %s from user defaults database"), domain
);
839 /* global system dictionary */
840 snprintf(path
, sizeof(path
), "%s/%s/%s", SYSCONFDIR
, GLOBAL_DEFAULTS_SUBDIR
, domain
);
841 if (stat(path
, &stbuf
) >= 0) {
842 shared_dict
= WMReadPropListFromFile(path
);
844 if (requireDictionary
&& !WMIsPLDictionary(shared_dict
)) {
845 wwarning(_("Domain %s (%s) of global defaults database is corrupted!"),
847 WMReleasePropList(shared_dict
);
850 if (db
->dictionary
&& WMIsPLDictionary(shared_dict
) &&
851 WMIsPLDictionary(db
->dictionary
)) {
852 WMMergePLDictionaries(shared_dict
, db
->dictionary
, True
);
853 WMReleasePropList(db
->dictionary
);
854 db
->dictionary
= shared_dict
;
855 if (stbuf
.st_mtime
> db
->timestamp
)
856 db
->timestamp
= stbuf
.st_mtime
;
857 } else if (!db
->dictionary
) {
858 db
->dictionary
= shared_dict
;
859 if (stbuf
.st_mtime
> db
->timestamp
)
860 db
->timestamp
= stbuf
.st_mtime
;
864 wwarning(_("could not load domain %s from global defaults database (%s)"), domain
, path
);
871 void wReadStaticDefaults(WMPropList
* dict
)
874 WDefaultEntry
*entry
;
878 for (i
= 0; i
< sizeof(staticOptionList
) / sizeof(WDefaultEntry
); i
++) {
879 entry
= &staticOptionList
[i
];
882 plvalue
= WMGetFromPLDictionary(dict
, entry
->plkey
);
887 /* no default in the DB. Use builtin default */
888 plvalue
= entry
->plvalue
;
893 (*entry
->convert
) (NULL
, entry
, plvalue
, entry
->addr
, &tdata
);
895 (*entry
->update
) (NULL
, entry
, tdata
, entry
->extra_data
);
901 void wDefaultsCheckDomains(void)
905 WMPropList
*shared_dict
= NULL
;
910 puts("Checking domains...");
912 if (stat(WDWindowMaker
->path
, &stbuf
) >= 0 && WDWindowMaker
->timestamp
< stbuf
.st_mtime
) {
914 puts("Checking WindowMaker domain");
916 WDWindowMaker
->timestamp
= stbuf
.st_mtime
;
918 /* global dictionary */
919 shared_dict
= readGlobalDomain("WindowMaker", True
);
920 /* user dictionary */
921 dict
= WMReadPropListFromFile(WDWindowMaker
->path
);
923 if (!WMIsPLDictionary(dict
)) {
924 WMReleasePropList(dict
);
926 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
927 "WindowMaker", WDWindowMaker
->path
);
930 WMMergePLDictionaries(shared_dict
, dict
, True
);
931 WMReleasePropList(dict
);
935 for (i
= 0; i
< wScreenCount
; i
++) {
936 scr
= wScreenWithNumber(i
);
938 wReadDefaults(scr
, dict
);
940 if (WDWindowMaker
->dictionary
) {
941 WMReleasePropList(WDWindowMaker
->dictionary
);
943 WDWindowMaker
->dictionary
= dict
;
946 wwarning(_("could not load domain %s from user defaults database"), "WindowMaker");
949 WMReleasePropList(shared_dict
);
953 if (stat(WDWindowAttributes
->path
, &stbuf
) >= 0 && WDWindowAttributes
->timestamp
< stbuf
.st_mtime
) {
955 puts("Checking WMWindowAttributes domain");
957 /* global dictionary */
958 shared_dict
= readGlobalDomain("WMWindowAttributes", True
);
959 /* user dictionary */
960 dict
= WMReadPropListFromFile(WDWindowAttributes
->path
);
962 if (!WMIsPLDictionary(dict
)) {
963 WMReleasePropList(dict
);
965 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
966 "WMWindowAttributes", WDWindowAttributes
->path
);
969 WMMergePLDictionaries(shared_dict
, dict
, True
);
970 WMReleasePropList(dict
);
974 if (WDWindowAttributes
->dictionary
) {
975 WMReleasePropList(WDWindowAttributes
->dictionary
);
977 WDWindowAttributes
->dictionary
= dict
;
978 for (i
= 0; i
< wScreenCount
; i
++) {
979 scr
= wScreenWithNumber(i
);
983 wDefaultUpdateIcons(scr
);
985 /* Update the panel image if changed */
986 /* Don't worry. If the image is the same these
987 * functions will have no performance impact. */
988 image
= wDefaultGetImage(scr
, "Logo", "WMPanel");
991 wwarning(_("could not load logo image for panels: %s"),
992 RMessageForError(RErrorCode
));
994 WMSetApplicationIconImage(scr
->wmscreen
, image
);
995 RReleaseImage(image
);
1001 wwarning(_("could not load domain %s from user defaults database"), "WMWindowAttributes");
1003 WDWindowAttributes
->timestamp
= stbuf
.st_mtime
;
1005 WMReleasePropList(shared_dict
);
1009 if (stat(WDRootMenu
->path
, &stbuf
) >= 0 && WDRootMenu
->timestamp
< stbuf
.st_mtime
) {
1010 dict
= WMReadPropListFromFile(WDRootMenu
->path
);
1012 puts("Checking WMRootMenu domain");
1015 if (!WMIsPLArray(dict
) && !WMIsPLString(dict
)) {
1016 WMReleasePropList(dict
);
1018 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
1019 "WMRootMenu", WDRootMenu
->path
);
1021 if (WDRootMenu
->dictionary
) {
1022 WMReleasePropList(WDRootMenu
->dictionary
);
1024 WDRootMenu
->dictionary
= dict
;
1025 wDefaultsMergeGlobalMenus(WDRootMenu
);
1028 wwarning(_("could not load domain %s from user defaults database"), "WMRootMenu");
1030 WDRootMenu
->timestamp
= stbuf
.st_mtime
;
1034 void wReadDefaults(WScreen
* scr
, WMPropList
* new_dict
)
1036 WMPropList
*plvalue
, *old_value
;
1037 WDefaultEntry
*entry
;
1038 unsigned int i
, must_update
;
1039 int update_workspace_back
= 0; /* kluge :/ */
1040 unsigned int needs_refresh
;
1042 WMPropList
*old_dict
= (WDWindowMaker
->dictionary
!= new_dict
? WDWindowMaker
->dictionary
: NULL
);
1048 for (i
= 0; i
< sizeof(optionList
) / sizeof(WDefaultEntry
); i
++) {
1049 entry
= &optionList
[i
];
1052 plvalue
= WMGetFromPLDictionary(new_dict
, entry
->plkey
);
1059 old_value
= WMGetFromPLDictionary(old_dict
, entry
->plkey
);
1061 if (!plvalue
&& !old_value
) {
1062 /* no default in the DB. Use builtin default */
1063 plvalue
= entry
->plvalue
;
1064 if (plvalue
&& new_dict
) {
1065 WMPutInPLDictionary(new_dict
, entry
->plkey
, plvalue
);
1068 } else if (!plvalue
) {
1069 /* value was deleted from DB. Keep current value */
1071 } else if (!old_value
) {
1072 /* set value for the 1st time */
1073 } else if (!WMIsPropListEqualTo(plvalue
, old_value
)) {
1074 /* value has changed */
1077 if (strcmp(entry
->key
, "WorkspaceBack") == 0
1078 && update_workspace_back
&& scr
->flags
.backimage_helper_launched
) {
1080 /* value was not changed since last time */
1087 printf("Updating %s to %s\n", entry
->key
, WMGetPropListDescription(plvalue
, False
));
1090 if ((*entry
->convert
) (scr
, entry
, plvalue
, entry
->addr
, &tdata
)) {
1092 * If the WorkspaceSpecificBack data has been changed
1093 * so that the helper will be launched now, we must be
1094 * sure to send the default background texture config
1097 if (strcmp(entry
->key
, "WorkspaceSpecificBack") == 0
1098 && !scr
->flags
.backimage_helper_launched
) {
1099 update_workspace_back
= 1;
1101 if (entry
->update
) {
1102 needs_refresh
|= (*entry
->update
) (scr
, entry
, tdata
, entry
->extra_data
);
1108 if (needs_refresh
!= 0 && !scr
->flags
.startup
) {
1112 if (needs_refresh
& REFRESH_MENU_TITLE_TEXTURE
)
1113 foo
|= WTextureSettings
;
1114 if (needs_refresh
& REFRESH_MENU_TITLE_FONT
)
1115 foo
|= WFontSettings
;
1116 if (needs_refresh
& REFRESH_MENU_TITLE_COLOR
)
1117 foo
|= WColorSettings
;
1119 WMPostNotificationName(WNMenuTitleAppearanceSettingsChanged
, NULL
,
1120 (void *)(uintptr_t) foo
);
1123 if (needs_refresh
& REFRESH_MENU_TEXTURE
)
1124 foo
|= WTextureSettings
;
1125 if (needs_refresh
& REFRESH_MENU_FONT
)
1126 foo
|= WFontSettings
;
1127 if (needs_refresh
& REFRESH_MENU_COLOR
)
1128 foo
|= WColorSettings
;
1130 WMPostNotificationName(WNMenuAppearanceSettingsChanged
, NULL
, (void *)(uintptr_t) foo
);
1133 if (needs_refresh
& REFRESH_WINDOW_FONT
) {
1134 foo
|= WFontSettings
;
1136 if (needs_refresh
& REFRESH_WINDOW_TEXTURES
) {
1137 foo
|= WTextureSettings
;
1139 if (needs_refresh
& REFRESH_WINDOW_TITLE_COLOR
) {
1140 foo
|= WColorSettings
;
1143 WMPostNotificationName(WNWindowAppearanceSettingsChanged
, NULL
, (void *)(uintptr_t) foo
);
1145 if (!(needs_refresh
& REFRESH_ICON_TILE
)) {
1147 if (needs_refresh
& REFRESH_ICON_FONT
) {
1148 foo
|= WFontSettings
;
1150 if (needs_refresh
& REFRESH_ICON_TITLE_COLOR
) {
1151 foo
|= WTextureSettings
;
1153 if (needs_refresh
& REFRESH_ICON_TITLE_BACK
) {
1154 foo
|= WTextureSettings
;
1157 WMPostNotificationName(WNIconAppearanceSettingsChanged
, NULL
,
1158 (void *)(uintptr_t) foo
);
1160 if (needs_refresh
& REFRESH_ICON_TILE
)
1161 WMPostNotificationName(WNIconTileSettingsChanged
, NULL
, NULL
);
1165 void wDefaultUpdateIcons(WScreen
* scr
)
1167 WAppIcon
*aicon
= scr
->app_icon_list
;
1168 WWindow
*wwin
= scr
->focused_window
;
1172 file
= wDefaultGetIconFile(scr
, aicon
->wm_instance
, aicon
->wm_class
, False
);
1173 if ((file
&& aicon
->icon
->file
&& strcmp(file
, aicon
->icon
->file
) != 0)
1174 || (file
&& !aicon
->icon
->file
)) {
1177 if (aicon
->icon
->file
)
1178 wfree(aicon
->icon
->file
);
1179 aicon
->icon
->file
= wstrdup(file
);
1181 new_image
= wDefaultGetImage(scr
, aicon
->wm_instance
, aicon
->wm_class
);
1183 wIconChangeImage(aicon
->icon
, new_image
);
1184 wAppIconPaint(aicon
);
1187 aicon
= aicon
->next
;
1190 if (!wPreferences
.flags
.noclip
)
1191 wClipIconPaint(scr
->clip_icon
);
1194 if (wwin
->icon
&& wwin
->flags
.miniaturized
) {
1195 file
= wDefaultGetIconFile(scr
, wwin
->wm_instance
, wwin
->wm_class
, False
);
1196 if ((file
&& wwin
->icon
->file
&& strcmp(file
, wwin
->icon
->file
) != 0)
1197 || (file
&& !wwin
->icon
->file
)) {
1200 if (wwin
->icon
->file
)
1201 wfree(wwin
->icon
->file
);
1202 wwin
->icon
->file
= wstrdup(file
);
1204 new_image
= wDefaultGetImage(scr
, wwin
->wm_instance
, wwin
->wm_class
);
1206 wIconChangeImage(wwin
->icon
, new_image
);
1213 /* --------------------------- Local ----------------------- */
1215 #define GET_STRING_OR_DEFAULT(x, var) if (!WMIsPLString(value)) { \
1216 wwarning(_("Wrong option format for key \"%s\". Should be %s."), \
1218 wwarning(_("using default \"%s\" instead"), entry->default_value); \
1219 var = entry->default_value;\
1220 } else var = WMGetFromPLString(value)\
1223 static int string2index(WMPropList * key, WMPropList * val, char *def, WOptionEnumeration * values)
1226 WOptionEnumeration
*v
;
1227 char buffer
[TOTAL_VALUES_LENGTH
];
1229 if (WMIsPLString(val
) && (str
= WMGetFromPLString(val
))) {
1230 for (v
= values
; v
->string
!= NULL
; v
++) {
1231 if (strcasecmp(v
->string
, str
) == 0)
1237 for (v
= values
; v
->string
!= NULL
; v
++) {
1240 strcat(buffer
, ", ");
1241 strcat(buffer
, v
->string
);
1244 wwarning(_("wrong option value for key \"%s\". Should be one of %s"), WMGetFromPLString(key
), buffer
);
1247 return string2index(key
, val
, NULL
, values
);
1254 * value - is the value in the defaults DB
1255 * addr - is the address to store the data
1256 * ret - is the address to store a pointer to a temporary buffer. ret
1257 * must not be freed and is used by the set functions
1259 static int getBool(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1263 int second_pass
= 0;
1265 GET_STRING_OR_DEFAULT("Boolean", val
);
1268 if ((val
[1] == '\0' && (val
[0] == 'y' || val
[0] == 'Y'))
1269 || strcasecmp(val
, "YES") == 0) {
1272 } else if ((val
[1] == '\0' && (val
[0] == 'n' || val
[0] == 'N'))
1273 || strcasecmp(val
, "NO") == 0) {
1277 if (sscanf(val
, "%i", &i
) == 1) {
1283 wwarning(_("can't convert \"%s\" to boolean for key \"%s\""), val
, entry
->key
);
1284 if (second_pass
== 0) {
1285 val
= WMGetFromPLString(entry
->plvalue
);
1287 wwarning(_("using default \"%s\" instead"), val
);
1297 *(char *)addr
= data
;
1302 static int getInt(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1307 GET_STRING_OR_DEFAULT("Integer", val
);
1309 if (sscanf(val
, "%i", &data
) != 1) {
1310 wwarning(_("can't convert \"%s\" to integer for key \"%s\""), val
, entry
->key
);
1311 val
= WMGetFromPLString(entry
->plvalue
);
1312 wwarning(_("using default \"%s\" instead"), val
);
1313 if (sscanf(val
, "%i", &data
) != 1) {
1321 *(int *)addr
= data
;
1326 static int getCoord(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1329 char *val_x
, *val_y
;
1330 int nelem
, changed
= 0;
1331 WMPropList
*elem_x
, *elem_y
;
1334 if (!WMIsPLArray(value
)) {
1335 wwarning(_("Wrong option format for key \"%s\". Should be %s."), entry
->key
, "Coordinate");
1337 value
= entry
->plvalue
;
1339 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1345 nelem
= WMGetPropListItemCount(value
);
1347 wwarning(_("Incorrect number of elements in array for key \"%s\"."), entry
->key
);
1349 value
= entry
->plvalue
;
1351 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1357 elem_x
= WMGetFromPLArray(value
, 0);
1358 elem_y
= WMGetFromPLArray(value
, 1);
1360 if (!elem_x
|| !elem_y
|| !WMIsPLString(elem_x
) || !WMIsPLString(elem_y
)) {
1361 wwarning(_("Wrong value for key \"%s\". Should be Coordinate."), entry
->key
);
1363 value
= entry
->plvalue
;
1365 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1371 val_x
= WMGetFromPLString(elem_x
);
1372 val_y
= WMGetFromPLString(elem_y
);
1374 if (sscanf(val_x
, "%i", &data
.x
) != 1 || sscanf(val_y
, "%i", &data
.y
) != 1) {
1375 wwarning(_("can't convert array to integers for \"%s\"."), entry
->key
);
1377 value
= entry
->plvalue
;
1379 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1387 else if (data
.x
> scr
->scr_width
/ 3)
1388 data
.x
= scr
->scr_width
/ 3;
1391 else if (data
.y
> scr
->scr_height
/ 3)
1392 data
.y
= scr
->scr_height
/ 3;
1397 *(WCoord
*) addr
= data
;
1402 static int getPropList(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1404 WMRetainPropList(value
);
1411 static int getPathList(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1420 if (!WMIsPLArray(value
)) {
1421 wwarning(_("Wrong option format for key \"%s\". Should be %s."), entry
->key
, "an array of paths");
1423 value
= entry
->plvalue
;
1425 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1432 count
= WMGetPropListItemCount(value
);
1435 value
= entry
->plvalue
;
1437 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1444 for (i
= 0; i
< count
; i
++) {
1445 d
= WMGetFromPLArray(value
, i
);
1446 if (!d
|| !WMIsPLString(d
)) {
1450 len
+= strlen(WMGetFromPLString(d
)) + 1;
1453 ptr
= data
= wmalloc(len
+ 1);
1455 for (i
= 0; i
< count
; i
++) {
1456 d
= WMGetFromPLArray(value
, i
);
1457 if (!d
|| !WMIsPLString(d
)) {
1460 strcpy(ptr
, WMGetFromPLString(d
));
1461 ptr
+= strlen(WMGetFromPLString(d
));
1468 if (*(char **)addr
!= NULL
) {
1469 wfree(*(char **)addr
);
1471 *(char **)addr
= data
;
1476 static int getEnum(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1478 static signed char data
;
1480 data
= string2index(entry
->plkey
, value
, entry
->default_value
, (WOptionEnumeration
*) entry
->extra_data
);
1487 *(signed char *)addr
= data
;
1494 * (hgradient <color> <color>)
1495 * (vgradient <color> <color>)
1496 * (dgradient <color> <color>)
1497 * (mhgradient <color> <color> ...)
1498 * (mvgradient <color> <color> ...)
1499 * (mdgradient <color> <color> ...)
1500 * (igradient <color1> <color1> <thickness1> <color2> <color2> <thickness2>)
1501 * (tpixmap <file> <color>)
1502 * (spixmap <file> <color>)
1503 * (cpixmap <file> <color>)
1504 * (thgradient <file> <opaqueness> <color> <color>)
1505 * (tvgradient <file> <opaqueness> <color> <color>)
1506 * (tdgradient <file> <opaqueness> <color> <color>)
1507 * (function <lib> <function> ...)
1510 static WTexture
*parse_texture(WScreen
* scr
, WMPropList
* pl
)
1515 WTexture
*texture
= NULL
;
1517 nelem
= WMGetPropListItemCount(pl
);
1521 elem
= WMGetFromPLArray(pl
, 0);
1522 if (!elem
|| !WMIsPLString(elem
))
1524 val
= WMGetFromPLString(elem
);
1526 if (strcasecmp(val
, "solid") == 0) {
1534 elem
= WMGetFromPLArray(pl
, 1);
1535 if (!elem
|| !WMIsPLString(elem
))
1537 val
= WMGetFromPLString(elem
);
1539 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &color
)) {
1540 wwarning(_("\"%s\" is not a valid color name"), val
);
1544 texture
= (WTexture
*) wTextureMakeSolid(scr
, &color
);
1545 } else if (strcasecmp(val
, "dgradient") == 0
1546 || strcasecmp(val
, "vgradient") == 0 || strcasecmp(val
, "hgradient") == 0) {
1547 RColor color1
, color2
;
1552 wwarning(_("bad number of arguments in gradient specification"));
1556 if (val
[0] == 'd' || val
[0] == 'D')
1557 type
= WTEX_DGRADIENT
;
1558 else if (val
[0] == 'h' || val
[0] == 'H')
1559 type
= WTEX_HGRADIENT
;
1561 type
= WTEX_VGRADIENT
;
1563 /* get from color */
1564 elem
= WMGetFromPLArray(pl
, 1);
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
);
1574 color1
.red
= xcolor
.red
>> 8;
1575 color1
.green
= xcolor
.green
>> 8;
1576 color1
.blue
= xcolor
.blue
>> 8;
1579 elem
= WMGetFromPLArray(pl
, 2);
1580 if (!elem
|| !WMIsPLString(elem
)) {
1583 val
= WMGetFromPLString(elem
);
1585 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1586 wwarning(_("\"%s\" is not a valid color name"), val
);
1590 color2
.red
= xcolor
.red
>> 8;
1591 color2
.green
= xcolor
.green
>> 8;
1592 color2
.blue
= xcolor
.blue
>> 8;
1594 texture
= (WTexture
*) wTextureMakeGradient(scr
, type
, &color1
, &color2
);
1596 } else if (strcasecmp(val
, "igradient") == 0) {
1597 RColor colors1
[2], colors2
[2];
1603 wwarning(_("bad number of arguments in gradient specification"));
1607 /* get from color */
1608 for (i
= 0; i
< 2; i
++) {
1609 elem
= WMGetFromPLArray(pl
, 1 + i
);
1610 if (!elem
|| !WMIsPLString(elem
))
1612 val
= WMGetFromPLString(elem
);
1614 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1615 wwarning(_("\"%s\" is not a valid color name"), val
);
1618 colors1
[i
].alpha
= 255;
1619 colors1
[i
].red
= xcolor
.red
>> 8;
1620 colors1
[i
].green
= xcolor
.green
>> 8;
1621 colors1
[i
].blue
= xcolor
.blue
>> 8;
1623 elem
= WMGetFromPLArray(pl
, 3);
1624 if (!elem
|| !WMIsPLString(elem
))
1626 val
= WMGetFromPLString(elem
);
1629 /* get from color */
1630 for (i
= 0; i
< 2; i
++) {
1631 elem
= WMGetFromPLArray(pl
, 4 + i
);
1632 if (!elem
|| !WMIsPLString(elem
))
1634 val
= WMGetFromPLString(elem
);
1636 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1637 wwarning(_("\"%s\" is not a valid color name"), val
);
1640 colors2
[i
].alpha
= 255;
1641 colors2
[i
].red
= xcolor
.red
>> 8;
1642 colors2
[i
].green
= xcolor
.green
>> 8;
1643 colors2
[i
].blue
= xcolor
.blue
>> 8;
1645 elem
= WMGetFromPLArray(pl
, 6);
1646 if (!elem
|| !WMIsPLString(elem
))
1648 val
= WMGetFromPLString(elem
);
1651 texture
= (WTexture
*) wTextureMakeIGradient(scr
, th1
, colors1
, th2
, colors2
);
1653 } else if (strcasecmp(val
, "mhgradient") == 0
1654 || strcasecmp(val
, "mvgradient") == 0 || strcasecmp(val
, "mdgradient") == 0) {
1661 wwarning(_("too few arguments in multicolor gradient specification"));
1665 if (val
[1] == 'h' || val
[1] == 'H')
1666 type
= WTEX_MHGRADIENT
;
1667 else if (val
[1] == 'v' || val
[1] == 'V')
1668 type
= WTEX_MVGRADIENT
;
1670 type
= WTEX_MDGRADIENT
;
1674 colors
= wmalloc(sizeof(RColor
*) * (count
+ 1));
1676 for (i
= 0; i
< count
; i
++) {
1677 elem
= WMGetFromPLArray(pl
, i
+ 1);
1678 if (!elem
|| !WMIsPLString(elem
)) {
1679 for (--i
; i
>= 0; --i
) {
1685 val
= WMGetFromPLString(elem
);
1687 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &color
)) {
1688 wwarning(_("\"%s\" is not a valid color name"), val
);
1689 for (--i
; i
>= 0; --i
) {
1695 colors
[i
] = wmalloc(sizeof(RColor
));
1696 colors
[i
]->red
= color
.red
>> 8;
1697 colors
[i
]->green
= color
.green
>> 8;
1698 colors
[i
]->blue
= color
.blue
>> 8;
1703 texture
= (WTexture
*) wTextureMakeMGradient(scr
, type
, colors
);
1704 } else if (strcasecmp(val
, "spixmap") == 0 ||
1705 strcasecmp(val
, "cpixmap") == 0 || strcasecmp(val
, "tpixmap") == 0) {
1712 if (val
[0] == 's' || val
[0] == 'S')
1714 else if (val
[0] == 'c' || val
[0] == 'C')
1720 elem
= WMGetFromPLArray(pl
, 2);
1721 if (!elem
|| !WMIsPLString(elem
)) {
1724 val
= WMGetFromPLString(elem
);
1726 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &color
)) {
1727 wwarning(_("\"%s\" is not a valid color name"), val
);
1732 elem
= WMGetFromPLArray(pl
, 1);
1733 if (!elem
|| !WMIsPLString(elem
))
1735 val
= WMGetFromPLString(elem
);
1737 texture
= (WTexture
*) wTextureMakePixmap(scr
, type
, val
, &color
);
1738 } else if (strcasecmp(val
, "thgradient") == 0
1739 || strcasecmp(val
, "tvgradient") == 0 || strcasecmp(val
, "tdgradient") == 0) {
1740 RColor color1
, color2
;
1745 if (val
[1] == 'h' || val
[1] == 'H')
1746 style
= WTEX_THGRADIENT
;
1747 else if (val
[1] == 'v' || val
[1] == 'V')
1748 style
= WTEX_TVGRADIENT
;
1750 style
= WTEX_TDGRADIENT
;
1753 wwarning(_("bad number of arguments in textured gradient specification"));
1757 /* get from color */
1758 elem
= WMGetFromPLArray(pl
, 3);
1759 if (!elem
|| !WMIsPLString(elem
))
1761 val
= WMGetFromPLString(elem
);
1763 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1764 wwarning(_("\"%s\" is not a valid color name"), val
);
1768 color1
.red
= xcolor
.red
>> 8;
1769 color1
.green
= xcolor
.green
>> 8;
1770 color1
.blue
= xcolor
.blue
>> 8;
1773 elem
= WMGetFromPLArray(pl
, 4);
1774 if (!elem
|| !WMIsPLString(elem
)) {
1777 val
= WMGetFromPLString(elem
);
1779 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1780 wwarning(_("\"%s\" is not a valid color name"), val
);
1784 color2
.red
= xcolor
.red
>> 8;
1785 color2
.green
= xcolor
.green
>> 8;
1786 color2
.blue
= xcolor
.blue
>> 8;
1789 elem
= WMGetFromPLArray(pl
, 2);
1790 if (!elem
|| !WMIsPLString(elem
))
1793 val
= WMGetFromPLString(elem
);
1795 if (!val
|| (opacity
= atoi(val
)) < 0 || opacity
> 255) {
1796 wwarning(_("bad opacity value for tgradient texture \"%s\". Should be [0..255]"), val
);
1801 elem
= WMGetFromPLArray(pl
, 1);
1802 if (!elem
|| !WMIsPLString(elem
))
1804 val
= WMGetFromPLString(elem
);
1806 texture
= (WTexture
*) wTextureMakeTGradient(scr
, style
, &color1
, &color2
, val
, opacity
);
1808 #ifdef TEXTURE_PLUGIN
1809 else if (strcasecmp(val
, "function") == 0) {
1810 WTexFunction
*function
;
1811 void (*initFunc
) (Display
*, Colormap
);
1812 char *lib
, *func
, **argv
;
1818 /* get the library name */
1819 elem
= WMGetFromPLArray(pl
, 1);
1820 if (!elem
|| !WMIsPLString(elem
)) {
1823 lib
= WMGetFromPLString(elem
);
1825 /* get the function name */
1826 elem
= WMGetFromPLArray(pl
, 2);
1827 if (!elem
|| !WMIsPLString(elem
)) {
1830 func
= WMGetFromPLString(elem
);
1833 argv
= (char **)wmalloc(argc
* sizeof(char *));
1835 /* get the parameters */
1836 argv
[0] = wstrdup(func
);
1837 for (i
= 0; i
< argc
- 1; i
++) {
1838 elem
= WMGetFromPLArray(pl
, 3 + i
);
1839 if (!elem
|| !WMIsPLString(elem
)) {
1844 argv
[i
+ 1] = wstrdup(WMGetFromPLString(elem
));
1847 function
= wTextureMakeFunction(scr
, lib
, func
, argc
, argv
);
1851 initFunc
= dlsym(function
->handle
, "initWindowMaker");
1853 initFunc(dpy
, scr
->w_colormap
);
1855 wwarning(_("could not initialize library %s"), lib
);
1858 wwarning(_("could not find function %s::%s"), lib
, func
);
1860 #endif /* HAVE_DLFCN_H */
1861 texture
= (WTexture
*) function
;
1863 #endif /* TEXTURE_PLUGIN */
1865 wwarning(_("invalid texture type %s"), val
);
1871 static int getTexture(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1873 static WTexture
*texture
;
1877 if (!WMIsPLArray(value
)) {
1878 wwarning(_("Wrong option format for key \"%s\". Should be %s."), entry
->key
, "Texture");
1880 value
= entry
->plvalue
;
1882 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1888 if (strcmp(entry
->key
, "WidgetColor") == 0 && !changed
) {
1891 pl
= WMGetFromPLArray(value
, 0);
1892 if (!pl
|| !WMIsPLString(pl
) || !WMGetFromPLString(pl
)
1893 || strcasecmp(WMGetFromPLString(pl
), "solid") != 0) {
1894 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1895 entry
->key
, "Solid Texture");
1897 value
= entry
->plvalue
;
1899 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1904 texture
= parse_texture(scr
, value
);
1907 wwarning(_("Error in texture specification for key \"%s\""), entry
->key
);
1909 value
= entry
->plvalue
;
1911 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1921 *(WTexture
**) addr
= texture
;
1926 static int getWSBackground(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1934 if (!WMIsPLArray(value
)) {
1935 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1936 "WorkspaceBack", "Texture or None");
1938 value
= entry
->plvalue
;
1940 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1946 /* only do basic error checking and verify for None texture */
1948 nelem
= WMGetPropListItemCount(value
);
1950 elem
= WMGetFromPLArray(value
, 0);
1951 if (!elem
|| !WMIsPLString(elem
)) {
1952 wwarning(_("Wrong type for workspace background. Should be a texture type."));
1954 value
= entry
->plvalue
;
1956 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1961 val
= WMGetFromPLString(elem
);
1963 if (strcasecmp(val
, "None") == 0)
1966 *ret
= WMRetainPropList(value
);
1972 getWSSpecificBackground(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1979 if (!WMIsPLArray(value
)) {
1980 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1981 "WorkspaceSpecificBack", "an array of textures");
1983 value
= entry
->plvalue
;
1985 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1991 /* only do basic error checking and verify for None texture */
1993 nelem
= WMGetPropListItemCount(value
);
1996 elem
= WMGetFromPLArray(value
, nelem
);
1997 if (!elem
|| !WMIsPLArray(elem
)) {
1998 wwarning(_("Wrong type for background of workspace %i. Should be a texture."),
2004 *ret
= WMRetainPropList(value
);
2008 * Kluge to force wmsetbg helper to set the default background.
2009 * If the WorkspaceSpecificBack is changed once wmaker has started,
2010 * the WorkspaceBack won't be sent to the helper, unless the user
2011 * changes it's value too. So, we must force this by removing the
2012 * value from the defaults DB.
2014 if (!scr
->flags
.backimage_helper_launched
&& !scr
->flags
.startup
) {
2015 WMPropList
*key
= WMCreatePLString("WorkspaceBack");
2017 WMRemoveFromPLDictionary(WDWindowMaker
->dictionary
, key
);
2019 WMReleasePropList(key
);
2025 static int getFont(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
2027 static WMFont
*font
;
2030 GET_STRING_OR_DEFAULT("Font", val
);
2032 font
= WMCreateFont(scr
->wmscreen
, val
);
2034 font
= WMCreateFont(scr
->wmscreen
, "fixed");
2037 wfatal(_("could not load any usable font!!!"));
2044 /* can't assign font value outside update function */
2045 wassertrv(addr
== NULL
, True
);
2050 static int getColor(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
2052 static XColor color
;
2054 int second_pass
= 0;
2056 GET_STRING_OR_DEFAULT("Color", val
);
2059 if (!wGetColor(scr
, val
, &color
)) {
2060 wwarning(_("could not get color for key \"%s\""), entry
->key
);
2061 if (second_pass
== 0) {
2062 val
= WMGetFromPLString(entry
->plvalue
);
2064 wwarning(_("using default \"%s\" instead"), val
);
2073 assert(addr
== NULL
);
2076 *(unsigned long*)addr = pixel;
2082 static int getKeybind(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
2084 static WShortKey shortcut
;
2088 char buf
[MAX_SHORTCUT_LENGTH
], *b
;
2090 GET_STRING_OR_DEFAULT("Key spec", val
);
2092 if (!val
|| strcasecmp(val
, "NONE") == 0) {
2093 shortcut
.keycode
= 0;
2094 shortcut
.modifier
= 0;
2100 strncpy(buf
, val
, MAX_SHORTCUT_LENGTH
);
2105 shortcut
.modifier
= 0;
2106 while ((k
= strchr(b
, '+')) != NULL
) {
2110 mod
= wXModifierFromKey(b
);
2112 wwarning(_("%s: invalid key modifier \"%s\""), entry
->key
, b
);
2115 shortcut
.modifier
|= mod
;
2121 ksym
= XStringToKeysym(b
);
2123 if (ksym
== NoSymbol
) {
2124 wwarning(_("%s:invalid kbd shortcut specification \"%s\""), entry
->key
, val
);
2128 shortcut
.keycode
= XKeysymToKeycode(dpy
, ksym
);
2129 if (shortcut
.keycode
== 0) {
2130 wwarning(_("%s:invalid key in shortcut \"%s\""), entry
->key
, val
);
2140 static int getModMask(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
2145 GET_STRING_OR_DEFAULT("Modifier Key", str
);
2150 mask
= wXModifierFromKey(str
);
2152 wwarning(_("%s: modifier key %s is not valid"), entry
->key
, str
);
2158 *(int *)addr
= mask
;
2166 # include <X11/cursorfont.h>
2172 #define CURSOR_ID_NONE (XC_num_glyphs)
2174 static WCursorLookup cursor_table
[] = {
2175 {"X_cursor", XC_X_cursor
},
2176 {"arrow", XC_arrow
},
2177 {"based_arrow_down", XC_based_arrow_down
},
2178 {"based_arrow_up", XC_based_arrow_up
},
2180 {"bogosity", XC_bogosity
},
2181 {"bottom_left_corner", XC_bottom_left_corner
},
2182 {"bottom_right_corner", XC_bottom_right_corner
},
2183 {"bottom_side", XC_bottom_side
},
2184 {"bottom_tee", XC_bottom_tee
},
2185 {"box_spiral", XC_box_spiral
},
2186 {"center_ptr", XC_center_ptr
},
2187 {"circle", XC_circle
},
2188 {"clock", XC_clock
},
2189 {"coffee_mug", XC_coffee_mug
},
2190 {"cross", XC_cross
},
2191 {"cross_reverse", XC_cross_reverse
},
2192 {"crosshair", XC_crosshair
},
2193 {"diamond_cross", XC_diamond_cross
},
2195 {"dotbox", XC_dotbox
},
2196 {"double_arrow", XC_double_arrow
},
2197 {"draft_large", XC_draft_large
},
2198 {"draft_small", XC_draft_small
},
2199 {"draped_box", XC_draped_box
},
2200 {"exchange", XC_exchange
},
2201 {"fleur", XC_fleur
},
2202 {"gobbler", XC_gobbler
},
2203 {"gumby", XC_gumby
},
2204 {"hand1", XC_hand1
},
2205 {"hand2", XC_hand2
},
2206 {"heart", XC_heart
},
2208 {"iron_cross", XC_iron_cross
},
2209 {"left_ptr", XC_left_ptr
},
2210 {"left_side", XC_left_side
},
2211 {"left_tee", XC_left_tee
},
2212 {"leftbutton", XC_leftbutton
},
2213 {"ll_angle", XC_ll_angle
},
2214 {"lr_angle", XC_lr_angle
},
2216 {"middlebutton", XC_middlebutton
},
2217 {"mouse", XC_mouse
},
2218 {"pencil", XC_pencil
},
2219 {"pirate", XC_pirate
},
2221 {"question_arrow", XC_question_arrow
},
2222 {"right_ptr", XC_right_ptr
},
2223 {"right_side", XC_right_side
},
2224 {"right_tee", XC_right_tee
},
2225 {"rightbutton", XC_rightbutton
},
2226 {"rtl_logo", XC_rtl_logo
},
2227 {"sailboat", XC_sailboat
},
2228 {"sb_down_arrow", XC_sb_down_arrow
},
2229 {"sb_h_double_arrow", XC_sb_h_double_arrow
},
2230 {"sb_left_arrow", XC_sb_left_arrow
},
2231 {"sb_right_arrow", XC_sb_right_arrow
},
2232 {"sb_up_arrow", XC_sb_up_arrow
},
2233 {"sb_v_double_arrow", XC_sb_v_double_arrow
},
2234 {"shuttle", XC_shuttle
},
2235 {"sizing", XC_sizing
},
2236 {"spider", XC_spider
},
2237 {"spraycan", XC_spraycan
},
2239 {"target", XC_target
},
2240 {"tcross", XC_tcross
},
2241 {"top_left_arrow", XC_top_left_arrow
},
2242 {"top_left_corner", XC_top_left_corner
},
2243 {"top_right_corner", XC_top_right_corner
},
2244 {"top_side", XC_top_side
},
2245 {"top_tee", XC_top_tee
},
2247 {"ul_angle", XC_ul_angle
},
2248 {"umbrella", XC_umbrella
},
2249 {"ur_angle", XC_ur_angle
},
2250 {"watch", XC_watch
},
2251 {"xterm", XC_xterm
},
2252 {NULL
, CURSOR_ID_NONE
}
2255 static void check_bitmap_status(int status
, char *filename
, Pixmap bitmap
)
2258 case BitmapOpenFailed
:
2259 wwarning(_("failed to open bitmap file \"%s\""), filename
);
2261 case BitmapFileInvalid
:
2262 wwarning(_("\"%s\" is not a valid bitmap file"), filename
);
2264 case BitmapNoMemory
:
2265 wwarning(_("out of memory reading bitmap file \"%s\""), filename
);
2268 XFreePixmap(dpy
, bitmap
);
2275 * (builtin, <cursor_name>)
2276 * (bitmap, <cursor_bitmap>, <cursor_mask>)
2278 static int parse_cursor(WScreen
* scr
, WMPropList
* pl
, Cursor
* cursor
)
2285 nelem
= WMGetPropListItemCount(pl
);
2289 elem
= WMGetFromPLArray(pl
, 0);
2290 if (!elem
|| !WMIsPLString(elem
)) {
2293 val
= WMGetFromPLString(elem
);
2295 if (0 == strcasecmp(val
, "none")) {
2298 } else if (0 == strcasecmp(val
, "builtin")) {
2300 int cursor_id
= CURSOR_ID_NONE
;
2303 wwarning(_("bad number of arguments in cursor specification"));
2306 elem
= WMGetFromPLArray(pl
, 1);
2307 if (!elem
|| !WMIsPLString(elem
)) {
2310 val
= WMGetFromPLString(elem
);
2312 for (i
= 0; NULL
!= cursor_table
[i
].name
; i
++) {
2313 if (0 == strcasecmp(val
, cursor_table
[i
].name
)) {
2314 cursor_id
= cursor_table
[i
].id
;
2318 if (CURSOR_ID_NONE
== cursor_id
) {
2319 wwarning(_("unknown builtin cursor name \"%s\""), val
);
2321 *cursor
= XCreateFontCursor(dpy
, cursor_id
);
2324 } else if (0 == strcasecmp(val
, "bitmap")) {
2336 wwarning(_("bad number of arguments in cursor specification"));
2339 elem
= WMGetFromPLArray(pl
, 1);
2340 if (!elem
|| !WMIsPLString(elem
)) {
2343 val
= WMGetFromPLString(elem
);
2344 bitmap_name
= FindImage(wPreferences
.pixmap_path
, val
);
2346 wwarning(_("could not find cursor bitmap file \"%s\""), val
);
2349 elem
= WMGetFromPLArray(pl
, 2);
2350 if (!elem
|| !WMIsPLString(elem
)) {
2354 val
= WMGetFromPLString(elem
);
2355 mask_name
= FindImage(wPreferences
.pixmap_path
, val
);
2358 wwarning(_("could not find cursor bitmap file \"%s\""), val
);
2361 mask_status
= XReadBitmapFile(dpy
, scr
->w_win
, mask_name
, &w
, &h
, &mask
, &x
, &y
);
2362 bitmap_status
= XReadBitmapFile(dpy
, scr
->w_win
, bitmap_name
, &w
, &h
, &bitmap
, &x
, &y
);
2363 if ((BitmapSuccess
== bitmap_status
) && (BitmapSuccess
== mask_status
)) {
2364 fg
.pixel
= scr
->black_pixel
;
2365 bg
.pixel
= scr
->white_pixel
;
2366 XQueryColor(dpy
, scr
->w_colormap
, &fg
);
2367 XQueryColor(dpy
, scr
->w_colormap
, &bg
);
2368 *cursor
= XCreatePixmapCursor(dpy
, bitmap
, mask
, &fg
, &bg
, x
, y
);
2371 check_bitmap_status(bitmap_status
, bitmap_name
, bitmap
);
2372 check_bitmap_status(mask_status
, mask_name
, mask
);
2379 static int getCursor(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
2381 static Cursor cursor
;
2386 if (!WMIsPLArray(value
)) {
2387 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
2388 entry
->key
, "cursor specification");
2390 value
= entry
->plvalue
;
2392 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
2397 status
= parse_cursor(scr
, value
, &cursor
);
2399 wwarning(_("Error in cursor specification for key \"%s\""), entry
->key
);
2401 value
= entry
->plvalue
;
2403 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
2412 *(Cursor
*) addr
= cursor
;
2417 #undef CURSOR_ID_NONE
2419 /* ---------------- value setting functions --------------- */
2420 static int setJustify(WScreen
* scr
, WDefaultEntry
* entry
, WTexture
** texture
, void *foo
)
2422 return REFRESH_WINDOW_TITLE_COLOR
;
2425 static int setClearance(WScreen
* scr
, WDefaultEntry
* entry
, void *bar
, void *foo
)
2427 return REFRESH_WINDOW_FONT
| REFRESH_BUTTON_IMAGES
| REFRESH_MENU_TITLE_FONT
| REFRESH_MENU_FONT
;
2430 static int setIfDockPresent(WScreen
* scr
, WDefaultEntry
* entry
, char *flag
, long which
)
2434 wPreferences
.flags
.nodock
= wPreferences
.flags
.nodock
|| *flag
;
2437 wPreferences
.flags
.noclip
= wPreferences
.flags
.noclip
|| *flag
;
2445 static int setStickyIcons(WScreen
* scr
, WDefaultEntry
* entry
, void *bar
, void *foo
)
2447 if (scr
->workspaces
) {
2448 wWorkspaceForceChange(scr
, scr
->current_workspace
);
2449 wArrangeIcons(scr
, False
);
2454 static int setIconTile(WScreen
* scr
, WDefaultEntry
* entry
, WTexture
** texture
, void *foo
)
2460 img
= wTextureRenderImage(*texture
, wPreferences
.icon_size
,
2461 wPreferences
.icon_size
, ((*texture
)->any
.type
& WREL_BORDER_MASK
)
2462 ? WREL_ICON
: WREL_FLAT
);
2464 wwarning(_("could not render texture for icon background"));
2466 wTextureDestroy(scr
, *texture
);
2469 RConvertImage(scr
->rcontext
, img
, &pixmap
);
2471 if (scr
->icon_tile
) {
2473 RReleaseImage(scr
->icon_tile
);
2474 XFreePixmap(dpy
, scr
->icon_tile_pixmap
);
2477 scr
->icon_tile
= img
;
2479 /* put the icon in the noticeboard hint */
2480 PropSetIconTileHint(scr
, img
);
2482 if (!wPreferences
.flags
.noclip
) {
2483 if (scr
->clip_tile
) {
2484 RReleaseImage(scr
->clip_tile
);
2486 scr
->clip_tile
= wClipMakeTile(scr
, img
);
2489 scr
->icon_tile_pixmap
= pixmap
;
2491 if (scr
->def_icon_pixmap
) {
2492 XFreePixmap(dpy
, scr
->def_icon_pixmap
);
2493 scr
->def_icon_pixmap
= None
;
2495 if (scr
->def_ticon_pixmap
) {
2496 XFreePixmap(dpy
, scr
->def_ticon_pixmap
);
2497 scr
->def_ticon_pixmap
= None
;
2500 if (scr
->icon_back_texture
) {
2501 wTextureDestroy(scr
, (WTexture
*) scr
->icon_back_texture
);
2503 scr
->icon_back_texture
= wTextureMakeSolid(scr
, &((*texture
)->any
.color
));
2505 if (scr
->clip_balloon
)
2506 XSetWindowBackground(dpy
, scr
->clip_balloon
, (*texture
)->any
.color
.pixel
);
2509 * Free the texture as nobody else will use it, nor refer to it.
2512 wTextureDestroy(scr
, *texture
);
2514 return (reset
? REFRESH_ICON_TILE
: 0);
2517 static int setWinTitleFont(WScreen
* scr
, WDefaultEntry
* entry
, WMFont
* font
, void *foo
)
2519 if (scr
->title_font
) {
2520 WMReleaseFont(scr
->title_font
);
2522 scr
->title_font
= font
;
2524 return REFRESH_WINDOW_FONT
| REFRESH_BUTTON_IMAGES
;
2527 static int setMenuTitleFont(WScreen
* scr
, WDefaultEntry
* entry
, WMFont
* font
, void *foo
)
2529 if (scr
->menu_title_font
) {
2530 WMReleaseFont(scr
->menu_title_font
);
2533 scr
->menu_title_font
= font
;
2535 return REFRESH_MENU_TITLE_FONT
;
2538 static int setMenuTextFont(WScreen
* scr
, WDefaultEntry
* entry
, WMFont
* font
, void *foo
)
2540 if (scr
->menu_entry_font
) {
2541 WMReleaseFont(scr
->menu_entry_font
);
2543 scr
->menu_entry_font
= font
;
2545 return REFRESH_MENU_FONT
;
2548 static int setIconTitleFont(WScreen
* scr
, WDefaultEntry
* entry
, WMFont
* font
, void *foo
)
2550 if (scr
->icon_title_font
) {
2551 WMReleaseFont(scr
->icon_title_font
);
2554 scr
->icon_title_font
= font
;
2556 return REFRESH_ICON_FONT
;
2559 static int setClipTitleFont(WScreen
* scr
, WDefaultEntry
* entry
, WMFont
* font
, void *foo
)
2561 if (scr
->clip_title_font
) {
2562 WMReleaseFont(scr
->clip_title_font
);
2565 scr
->clip_title_font
= font
;
2567 return REFRESH_ICON_FONT
;
2570 static int setLargeDisplayFont(WScreen
* scr
, WDefaultEntry
* entry
, WMFont
* font
, void *foo
)
2572 if (scr
->workspace_name_font
) {
2573 WMReleaseFont(scr
->workspace_name_font
);
2576 scr
->workspace_name_font
= font
;
2581 static int setHightlight(WScreen
* scr
, WDefaultEntry
* entry
, XColor
* color
, void *foo
)
2583 if (scr
->select_color
)
2584 WMReleaseColor(scr
->select_color
);
2586 scr
->select_color
= WMCreateRGBColor(scr
->wmscreen
, color
->red
, color
->green
, color
->blue
, True
);
2588 wFreeColor(scr
, color
->pixel
);
2590 return REFRESH_MENU_COLOR
;
2593 static int setHightlightText(WScreen
* scr
, WDefaultEntry
* entry
, XColor
* color
, void *foo
)
2595 if (scr
->select_text_color
)
2596 WMReleaseColor(scr
->select_text_color
);
2598 scr
->select_text_color
= WMCreateRGBColor(scr
->wmscreen
, color
->red
, color
->green
, color
->blue
, True
);
2600 wFreeColor(scr
, color
->pixel
);
2602 return REFRESH_MENU_COLOR
;
2605 static int setClipTitleColor(WScreen
* scr
, WDefaultEntry
* entry
, XColor
* color
, long widx
)
2607 if (scr
->clip_title_color
[widx
])
2608 WMReleaseColor(scr
->clip_title_color
[widx
]);
2609 scr
->clip_title_color
[widx
] = WMCreateRGBColor(scr
->wmscreen
, color
->red
, color
->green
, color
->blue
, True
);
2610 #ifdef GRADIENT_CLIP_ARROW
2611 if (widx
== CLIP_NORMAL
) {
2613 RColor color1
, color2
;
2614 int pt
= CLIP_BUTTON_SIZE
* wPreferences
.icon_size
/ 64;
2615 int as
= pt
- 15; /* 15 = 5+5+5 */
2617 FREE_PIXMAP(scr
->clip_arrow_gradient
);
2619 color1
.red
= (color
->red
>> 8) * 6 / 10;
2620 color1
.green
= (color
->green
>> 8) * 6 / 10;
2621 color1
.blue
= (color
->blue
>> 8) * 6 / 10;
2623 color2
.red
= WMIN((color
->red
>> 8) * 20 / 10, 255);
2624 color2
.green
= WMIN((color
->green
>> 8) * 20 / 10, 255);
2625 color2
.blue
= WMIN((color
->blue
>> 8) * 20 / 10, 255);
2627 image
= RRenderGradient(as
+ 1, as
+ 1, &color1
, &color2
, RDiagonalGradient
);
2628 RConvertImage(scr
->rcontext
, image
, &scr
->clip_arrow_gradient
);
2629 RReleaseImage(image
);
2631 #endif /* GRADIENT_CLIP_ARROW */
2633 wFreeColor(scr
, color
->pixel
);
2635 return REFRESH_ICON_TITLE_COLOR
;
2638 static int setWTitleColor(WScreen
* scr
, WDefaultEntry
* entry
, XColor
* color
, long widx
)
2640 if (scr
->window_title_color
[widx
])
2641 WMReleaseColor(scr
->window_title_color
[widx
]);
2643 scr
->window_title_color
[widx
] =
2644 WMCreateRGBColor(scr
->wmscreen
, color
->red
, color
->green
, color
->blue
, True
);
2646 wFreeColor(scr
, color
->pixel
);
2648 return REFRESH_WINDOW_TITLE_COLOR
;
2651 static int setMenuTitleColor(WScreen
* scr
, WDefaultEntry
* entry
, XColor
* color
, long widx
)
2653 if (scr
->menu_title_color
[0])
2654 WMReleaseColor(scr
->menu_title_color
[0]);
2656 scr
->menu_title_color
[0] = WMCreateRGBColor(scr
->wmscreen
, color
->red
, color
->green
, color
->blue
, True
);
2658 wFreeColor(scr
, color
->pixel
);
2660 return REFRESH_MENU_TITLE_COLOR
;
2663 static int setMenuTextColor(WScreen
* scr
, WDefaultEntry
* entry
, XColor
* color
, void *foo
)
2665 if (scr
->mtext_color
)
2666 WMReleaseColor(scr
->mtext_color
);
2668 scr
->mtext_color
= WMCreateRGBColor(scr
->wmscreen
, color
->red
, color
->green
, color
->blue
, True
);
2670 if (WMColorPixel(scr
->dtext_color
) == WMColorPixel(scr
->mtext_color
)) {
2671 WMSetColorAlpha(scr
->dtext_color
, 0x7fff);
2673 WMSetColorAlpha(scr
->dtext_color
, 0xffff);
2676 wFreeColor(scr
, color
->pixel
);
2678 return REFRESH_MENU_COLOR
;
2681 static int setMenuDisabledColor(WScreen
* scr
, WDefaultEntry
* entry
, XColor
* color
, void *foo
)
2683 if (scr
->dtext_color
)
2684 WMReleaseColor(scr
->dtext_color
);
2686 scr
->dtext_color
= WMCreateRGBColor(scr
->wmscreen
, color
->red
, color
->green
, color
->blue
, True
);
2688 if (WMColorPixel(scr
->dtext_color
) == WMColorPixel(scr
->mtext_color
)) {
2689 WMSetColorAlpha(scr
->dtext_color
, 0x7fff);
2691 WMSetColorAlpha(scr
->dtext_color
, 0xffff);
2694 wFreeColor(scr
, color
->pixel
);
2696 return REFRESH_MENU_COLOR
;
2699 static int setIconTitleColor(WScreen
* scr
, WDefaultEntry
* entry
, XColor
* color
, void *foo
)
2701 if (scr
->icon_title_color
)
2702 WMReleaseColor(scr
->icon_title_color
);
2703 scr
->icon_title_color
= WMCreateRGBColor(scr
->wmscreen
, color
->red
, color
->green
, color
->blue
, True
);
2705 wFreeColor(scr
, color
->pixel
);
2707 return REFRESH_ICON_TITLE_COLOR
;
2710 static int setIconTitleBack(WScreen
* scr
, WDefaultEntry
* entry
, XColor
* color
, void *foo
)
2712 if (scr
->icon_title_texture
) {
2713 wTextureDestroy(scr
, (WTexture
*) scr
->icon_title_texture
);
2715 scr
->icon_title_texture
= wTextureMakeSolid(scr
, color
);
2717 return REFRESH_ICON_TITLE_BACK
;
2720 static void trackDeadProcess(pid_t pid
, unsigned char status
, WScreen
* scr
)
2722 close(scr
->helper_fd
);
2724 scr
->helper_pid
= 0;
2725 scr
->flags
.backimage_helper_launched
= 0;
2728 static int setWorkspaceSpecificBack(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *bar
)
2734 if (scr
->flags
.backimage_helper_launched
) {
2735 if (WMGetPropListItemCount(value
) == 0) {
2736 SendHelperMessage(scr
, 'C', 0, NULL
);
2737 SendHelperMessage(scr
, 'K', 0, NULL
);
2739 WMReleasePropList(value
);
2746 if (WMGetPropListItemCount(value
) == 0)
2749 if (pipe(filedes
) < 0) {
2750 wsyserror("pipe() failed:can't set workspace specific background image");
2752 WMReleasePropList(value
);
2758 wsyserror("fork() failed:can't set workspace specific background image");
2759 if (close(filedes
[0]) < 0)
2760 wsyserror("could not close pipe");
2761 if (close(filedes
[1]) < 0)
2762 wsyserror("could not close pipe");
2764 } else if (pid
== 0) {
2767 SetupEnvironment(scr
);
2770 wsyserror("could not close pipe");
2771 if (dup(filedes
[0]) < 0) {
2772 wsyserror("dup() failed:can't set workspace specific background image");
2774 dither
= wPreferences
.no_dithering
? "-m" : "-d";
2775 if (wPreferences
.smooth_workspace_back
)
2776 execlp("wmsetbg", "wmsetbg", "-helper", "-S", dither
, NULL
);
2778 execlp("wmsetbg", "wmsetbg", "-helper", dither
, NULL
);
2779 wsyserror("could not execute wmsetbg");
2783 if (fcntl(filedes
[0], F_SETFD
, FD_CLOEXEC
) < 0) {
2784 wsyserror("error setting close-on-exec flag");
2786 if (fcntl(filedes
[1], F_SETFD
, FD_CLOEXEC
) < 0) {
2787 wsyserror("error setting close-on-exec flag");
2790 scr
->helper_fd
= filedes
[1];
2791 scr
->helper_pid
= pid
;
2792 scr
->flags
.backimage_helper_launched
= 1;
2794 wAddDeathHandler(pid
, (WDeathHandler
*) trackDeadProcess
, scr
);
2796 SendHelperMessage(scr
, 'P', -1, wPreferences
.pixmap_path
);
2801 for (i
= 0; i
< WMGetPropListItemCount(value
); i
++) {
2802 val
= WMGetFromPLArray(value
, i
);
2803 if (val
&& WMIsPLArray(val
) && WMGetPropListItemCount(val
) > 0) {
2804 str
= WMGetPropListDescription(val
, False
);
2806 SendHelperMessage(scr
, 'S', i
+ 1, str
);
2810 SendHelperMessage(scr
, 'U', i
+ 1, NULL
);
2815 WMReleasePropList(value
);
2819 static int setWorkspaceBack(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *bar
)
2821 if (scr
->flags
.backimage_helper_launched
) {
2824 if (WMGetPropListItemCount(value
) == 0) {
2825 SendHelperMessage(scr
, 'U', 0, NULL
);
2827 /* set the default workspace background to this one */
2828 str
= WMGetPropListDescription(value
, False
);
2830 SendHelperMessage(scr
, 'S', 0, str
);
2832 SendHelperMessage(scr
, 'C', scr
->current_workspace
+ 1, NULL
);
2834 SendHelperMessage(scr
, 'U', 0, NULL
);
2837 } else if (WMGetPropListItemCount(value
) > 0) {
2843 text
= WMGetPropListDescription(value
, False
);
2844 len
= strlen(text
) + 40;
2845 command
= wmalloc(len
);
2846 dither
= wPreferences
.no_dithering
? "-m" : "-d";
2847 if (wPreferences
.smooth_workspace_back
)
2848 snprintf(command
, len
, "wmsetbg %s -S -p '%s' &", dither
, text
);
2850 snprintf(command
, len
, "wmsetbg %s -p '%s' &", dither
, text
);
2852 ExecuteShellCommand(scr
, command
);
2855 WMReleasePropList(value
);
2860 static int setWidgetColor(WScreen
* scr
, WDefaultEntry
* entry
, WTexture
** texture
, void *foo
)
2862 if (scr
->widget_texture
) {
2863 wTextureDestroy(scr
, (WTexture
*) scr
->widget_texture
);
2865 scr
->widget_texture
= *(WTexSolid
**) texture
;
2870 static int setFTitleBack(WScreen
* scr
, WDefaultEntry
* entry
, WTexture
** texture
, void *foo
)
2872 if (scr
->window_title_texture
[WS_FOCUSED
]) {
2873 wTextureDestroy(scr
, scr
->window_title_texture
[WS_FOCUSED
]);
2875 scr
->window_title_texture
[WS_FOCUSED
] = *texture
;
2877 return REFRESH_WINDOW_TEXTURES
;
2880 static int setPTitleBack(WScreen
* scr
, WDefaultEntry
* entry
, WTexture
** texture
, void *foo
)
2882 if (scr
->window_title_texture
[WS_PFOCUSED
]) {
2883 wTextureDestroy(scr
, scr
->window_title_texture
[WS_PFOCUSED
]);
2885 scr
->window_title_texture
[WS_PFOCUSED
] = *texture
;
2887 return REFRESH_WINDOW_TEXTURES
;
2890 static int setUTitleBack(WScreen
* scr
, WDefaultEntry
* entry
, WTexture
** texture
, void *foo
)
2892 if (scr
->window_title_texture
[WS_UNFOCUSED
]) {
2893 wTextureDestroy(scr
, scr
->window_title_texture
[WS_UNFOCUSED
]);
2895 scr
->window_title_texture
[WS_UNFOCUSED
] = *texture
;
2897 return REFRESH_WINDOW_TEXTURES
;
2900 static int setResizebarBack(WScreen
* scr
, WDefaultEntry
* entry
, WTexture
** texture
, void *foo
)
2902 if (scr
->resizebar_texture
[0]) {
2903 wTextureDestroy(scr
, scr
->resizebar_texture
[0]);
2905 scr
->resizebar_texture
[0] = *texture
;
2907 return REFRESH_WINDOW_TEXTURES
;
2910 static int setMenuTitleBack(WScreen
* scr
, WDefaultEntry
* entry
, WTexture
** texture
, void *foo
)
2912 if (scr
->menu_title_texture
[0]) {
2913 wTextureDestroy(scr
, scr
->menu_title_texture
[0]);
2915 scr
->menu_title_texture
[0] = *texture
;
2917 return REFRESH_MENU_TITLE_TEXTURE
;
2920 static int setMenuTextBack(WScreen
* scr
, WDefaultEntry
* entry
, WTexture
** texture
, void *foo
)
2922 if (scr
->menu_item_texture
) {
2923 wTextureDestroy(scr
, scr
->menu_item_texture
);
2924 wTextureDestroy(scr
, (WTexture
*) scr
->menu_item_auxtexture
);
2926 scr
->menu_item_texture
= *texture
;
2928 scr
->menu_item_auxtexture
= wTextureMakeSolid(scr
, &scr
->menu_item_texture
->any
.color
);
2930 return REFRESH_MENU_TEXTURE
;
2933 static int setKeyGrab(WScreen
* scr
, WDefaultEntry
* entry
, WShortKey
* shortcut
, long widx
)
2936 wKeyBindings
[widx
] = *shortcut
;
2938 wwin
= scr
->focused_window
;
2940 while (wwin
!= NULL
) {
2941 XUngrabKey(dpy
, AnyKey
, AnyModifier
, wwin
->frame
->core
->window
);
2943 if (!WFLAGP(wwin
, no_bind_keys
)) {
2944 wWindowSetKeyGrabs(wwin
);
2952 static int setIconPosition(WScreen
* scr
, WDefaultEntry
* entry
, void *bar
, void *foo
)
2954 wScreenUpdateUsableArea(scr
);
2955 wArrangeIcons(scr
, True
);
2960 static int updateUsableArea(WScreen
* scr
, WDefaultEntry
* entry
, void *bar
, void *foo
)
2962 wScreenUpdateUsableArea(scr
);
2967 static int setMenuStyle(WScreen
* scr
, WDefaultEntry
* entry
, int *value
, void *foo
)
2969 return REFRESH_MENU_TEXTURE
;
2972 static RImage
*chopOffImage(RImage
* image
, int x
, int y
, int w
, int h
)
2974 RImage
*img
= RCreateImage(w
, h
, image
->format
== RRGBAFormat
);
2976 RCopyArea(img
, image
, x
, y
, w
, h
, 0, 0);
2981 static int setSwPOptions(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* array
, void *foo
)
2985 int cwidth
, cheight
;
2986 WPreferences
*prefs
= (WPreferences
*) foo
;
2988 if (!WMIsPLArray(array
) || WMGetPropListItemCount(array
) == 0) {
2989 if (prefs
->swtileImage
)
2990 RReleaseImage(prefs
->swtileImage
);
2991 prefs
->swtileImage
= NULL
;
2993 WMReleasePropList(array
);
2997 switch (WMGetPropListItemCount(array
)) {
2999 if (!WMIsPLString(WMGetFromPLArray(array
, 1))) {
3000 wwarning(_("Invalid arguments for option \"%s\""), entry
->key
);
3003 path
= FindImage(wPreferences
.pixmap_path
, WMGetFromPLString(WMGetFromPLArray(array
, 1)));
3006 wwarning(_("Could not find image \"%s\" for option \"%s\""),
3007 WMGetFromPLString(WMGetFromPLArray(array
, 1)), entry
->key
);
3009 bgimage
= RLoadImage(scr
->rcontext
, path
, 0);
3011 wwarning(_("Could not load image \"%s\" for option \"%s\""), path
, entry
->key
);
3016 cwidth
= atoi(WMGetFromPLString(WMGetFromPLArray(array
, 2)));
3017 cheight
= atoi(WMGetFromPLString(WMGetFromPLArray(array
, 3)));
3019 if (cwidth
<= 0 || cheight
<= 0 ||
3020 cwidth
>= bgimage
->width
- 2 || cheight
>= bgimage
->height
- 2)
3021 wwarning(_("Invalid split sizes for SwitchPanel back image."));
3024 int swidth
, theight
;
3025 for (i
= 0; i
< 9; i
++) {
3026 if (prefs
->swbackImage
[i
])
3027 RReleaseImage(prefs
->swbackImage
[i
]);
3028 prefs
->swbackImage
[i
] = NULL
;
3030 swidth
= (bgimage
->width
- cwidth
) / 2;
3031 theight
= (bgimage
->height
- cheight
) / 2;
3033 prefs
->swbackImage
[0] = chopOffImage(bgimage
, 0, 0, swidth
, theight
);
3034 prefs
->swbackImage
[1] = chopOffImage(bgimage
, swidth
, 0, cwidth
, theight
);
3035 prefs
->swbackImage
[2] = chopOffImage(bgimage
, swidth
+ cwidth
, 0,
3038 prefs
->swbackImage
[3] = chopOffImage(bgimage
, 0, theight
, swidth
, cheight
);
3039 prefs
->swbackImage
[4] = chopOffImage(bgimage
, swidth
, theight
,
3041 prefs
->swbackImage
[5] = chopOffImage(bgimage
, swidth
+ cwidth
, theight
,
3044 prefs
->swbackImage
[6] = chopOffImage(bgimage
, 0, theight
+ cheight
,
3046 prefs
->swbackImage
[7] = chopOffImage(bgimage
, swidth
, theight
+ cheight
,
3048 prefs
->swbackImage
[8] =
3049 chopOffImage(bgimage
, swidth
+ cwidth
, theight
+ cheight
, swidth
,
3052 // check if anything failed
3053 for (i
= 0; i
< 9; i
++) {
3054 if (!prefs
->swbackImage
[i
]) {
3055 for (; i
>= 0; --i
) {
3056 RReleaseImage(prefs
->swbackImage
[i
]);
3057 prefs
->swbackImage
[i
] = NULL
;
3063 RReleaseImage(bgimage
);
3068 if (!WMIsPLString(WMGetFromPLArray(array
, 0))) {
3069 wwarning(_("Invalid arguments for option \"%s\""), entry
->key
);
3072 path
= FindImage(wPreferences
.pixmap_path
, WMGetFromPLString(WMGetFromPLArray(array
, 0)));
3075 wwarning(_("Could not find image \"%s\" for option \"%s\""),
3076 WMGetFromPLString(WMGetFromPLArray(array
, 0)), entry
->key
);
3078 if (prefs
->swtileImage
)
3079 RReleaseImage(prefs
->swtileImage
);
3081 prefs
->swtileImage
= RLoadImage(scr
->rcontext
, path
, 0);
3082 if (!prefs
->swtileImage
) {
3083 wwarning(_("Could not load image \"%s\" for option \"%s\""), path
, entry
->key
);
3090 wwarning(_("Invalid number of arguments for option \"%s\""), entry
->key
);
3094 WMReleasePropList(array
);
3101 * Need access to the double click variables, so that all widgets in
3102 * wmaker panels will have the same dbl-click values.
3103 * TODO: figure a better way of dealing with it.
3105 #include <WINGs/WINGsP.h>
3107 static int setDoubleClick(WScreen
* scr
, WDefaultEntry
* entry
, int *value
, void *foo
)
3109 extern _WINGsConfiguration WINGsConfiguration
;
3114 WINGsConfiguration
.doubleClickDelay
= *value
;
3119 static int setCursor(WScreen
* scr
, WDefaultEntry
* entry
, Cursor
* cursor
, long widx
)
3121 if (wCursor
[widx
] != None
) {
3122 XFreeCursor(dpy
, wCursor
[widx
]);
3125 wCursor
[widx
] = *cursor
;
3127 if (widx
== WCUR_ROOT
&& *cursor
!= None
) {
3128 XDefineCursor(dpy
, scr
->root_win
, *cursor
);