1 /* defaults.c - manage configuration through defaults db
3 * Window Maker window manager
5 * Copyright (c) 1997-2003 Alfredo K. Kojima
6 * Copyright (c) 1998-2003 Dan Pascu
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
33 #include <sys/types.h>
40 #define PATH_MAX DEFAULT_PATH_MAX
44 #include <X11/Xutil.h>
45 #include <X11/keysym.h>
49 #include "WindowMaker.h"
54 #include "resources.h"
57 #include "xmodifier.h"
62 #include "workspace.h"
63 #include "properties.h"
65 #define MAX_SHORTCUT_LENGTH 32
67 #ifndef GLOBAL_DEFAULTS_SUBDIR
68 #define GLOBAL_DEFAULTS_SUBDIR "WindowMaker"
73 extern WDDomain
*WDWindowMaker
;
74 extern WDDomain
*WDWindowAttributes
;
75 extern WDDomain
*WDRootMenu
;
77 extern int wScreenCount
;
79 extern Atom _XA_WINDOWMAKER_ICON_SIZE
;
80 extern Atom _XA_WINDOWMAKER_ICON_TILE
;
82 extern WPreferences wPreferences
;
84 extern WShortKey wKeyBindings
[WKBD_LAST
];
94 WMPropList
*plvalue
; /* default value */
97 /* used to map strings to integers */
102 } WOptionEnumeration
;
104 /* type converters */
105 static int getBool();
107 static int getCoord();
108 static int getPathList();
109 static int getEnum();
110 static int getTexture();
111 static int getWSBackground();
112 static int getWSSpecificBackground();
113 static int getFont();
114 static int getColor();
115 static int getKeybind();
116 static int getModMask();
118 static int getRImage();
120 static int getPropList();
122 /* value setting functions */
123 static int setJustify();
124 static int setClearance();
125 static int setIfDockPresent();
126 static int setStickyIcons();
127 static int setWidgetColor();
128 static int setIconTile();
129 static int setWinTitleFont();
130 static int setMenuTitleFont();
131 static int setMenuTextFont();
132 static int setIconTitleFont();
133 static int setIconTitleColor();
134 static int setIconTitleBack();
135 static int setLargeDisplayFont();
136 static int setWTitleColor();
137 static int setFTitleBack();
138 static int setPTitleBack();
139 static int setUTitleBack();
140 static int setResizebarBack();
141 static int setWorkspaceBack();
142 static int setWorkspaceSpecificBack();
143 static int setMenuTitleColor();
144 static int setMenuTextColor();
145 static int setMenuDisabledColor();
146 static int setMenuTitleBack();
147 static int setMenuTextBack();
148 static int setHightlight();
149 static int setHightlightText();
150 static int setKeyGrab();
151 static int setDoubleClick();
152 static int setIconPosition();
154 static int setClipTitleFont();
155 static int setClipTitleColor();
157 static int setMenuStyle();
158 static int setSwPOptions();
159 static int updateUsableArea();
161 extern Cursor wCursor
[WCUR_LAST
];
162 static int getCursor();
163 static int setCursor();
166 * Tables to convert strings to enumeration values.
167 * Values stored are char
170 /* WARNING: sum of length of all value strings must not exceed
172 #define TOTAL_VALUES_LENGTH 80
174 #define REFRESH_WINDOW_TEXTURES (1<<0)
175 #define REFRESH_MENU_TEXTURE (1<<1)
176 #define REFRESH_MENU_FONT (1<<2)
177 #define REFRESH_MENU_COLOR (1<<3)
178 #define REFRESH_MENU_TITLE_TEXTURE (1<<4)
179 #define REFRESH_MENU_TITLE_FONT (1<<5)
180 #define REFRESH_MENU_TITLE_COLOR (1<<6)
181 #define REFRESH_WINDOW_TITLE_COLOR (1<<7)
182 #define REFRESH_WINDOW_FONT (1<<8)
183 #define REFRESH_ICON_TILE (1<<9)
184 #define REFRESH_ICON_FONT (1<<10)
185 #define REFRESH_WORKSPACE_BACK (1<<11)
187 #define REFRESH_BUTTON_IMAGES (1<<12)
189 #define REFRESH_ICON_TITLE_COLOR (1<<13)
190 #define REFRESH_ICON_TITLE_BACK (1<<14)
192 static WOptionEnumeration seFocusModes
[] = {
193 {"Manual", WKF_CLICK
, 0}, {"ClickToFocus", WKF_CLICK
, 1},
194 {"Sloppy", WKF_SLOPPY
, 0}, {"SemiAuto", WKF_SLOPPY
, 1}, {"Auto", WKF_SLOPPY
, 1},
198 static WOptionEnumeration seColormapModes
[] = {
199 {"Manual", WCM_CLICK
, 0}, {"ClickToFocus", WCM_CLICK
, 1},
200 {"Auto", WCM_POINTER
, 0}, {"FocusFollowMouse", WCM_POINTER
, 1},
204 static WOptionEnumeration sePlacements
[] = {
205 {"Auto", WPM_AUTO
, 0},
206 {"Smart", WPM_SMART
, 0},
207 {"Cascade", WPM_CASCADE
, 0},
208 {"Random", WPM_RANDOM
, 0},
209 {"Manual", WPM_MANUAL
, 0},
213 static WOptionEnumeration seGeomDisplays
[] = {
214 {"None", WDIS_NONE
, 0},
215 {"Center", WDIS_CENTER
, 0},
216 {"Corner", WDIS_TOPLEFT
, 0},
217 {"Floating", WDIS_FRAME_CENTER
, 0},
218 {"Line", WDIS_NEW
, 0},
222 static WOptionEnumeration seSpeeds
[] = {
223 {"UltraFast", SPEED_ULTRAFAST
, 0},
224 {"Fast", SPEED_FAST
, 0},
225 {"Medium", SPEED_MEDIUM
, 0},
226 {"Slow", SPEED_SLOW
, 0},
227 {"UltraSlow", SPEED_ULTRASLOW
, 0},
231 static WOptionEnumeration seMouseButtonActions
[] = {
232 {"None", WA_NONE
, 0},
233 {"SelectWindows", WA_SELECT_WINDOWS
, 0},
234 {"OpenApplicationsMenu", WA_OPEN_APPMENU
, 0},
235 {"OpenWindowListMenu", WA_OPEN_WINLISTMENU
, 0},
239 static WOptionEnumeration seMouseWheelActions
[] = {
240 {"None", WA_NONE
, 0},
241 {"SwitchWorkspaces", WA_SWITCH_WORKSPACES
, 0},
245 static WOptionEnumeration seIconificationStyles
[] = {
246 {"Zoom", WIS_ZOOM
, 0},
247 {"Twist", WIS_TWIST
, 0},
248 {"Flip", WIS_FLIP
, 0},
249 {"None", WIS_NONE
, 0},
250 {"random", WIS_RANDOM
, 0},
254 static WOptionEnumeration seJustifications
[] = {
255 {"Left", WTJ_LEFT
, 0},
256 {"Center", WTJ_CENTER
, 0},
257 {"Right", WTJ_RIGHT
, 0},
261 static WOptionEnumeration seIconPositions
[] = {
262 {"blv", IY_BOTTOM
| IY_LEFT
| IY_VERT
, 0},
263 {"blh", IY_BOTTOM
| IY_LEFT
| IY_HORIZ
, 0},
264 {"brv", IY_BOTTOM
| IY_RIGHT
| IY_VERT
, 0},
265 {"brh", IY_BOTTOM
| IY_RIGHT
| IY_HORIZ
, 0},
266 {"tlv", IY_TOP
| IY_LEFT
| IY_VERT
, 0},
267 {"tlh", IY_TOP
| IY_LEFT
| IY_HORIZ
, 0},
268 {"trv", IY_TOP
| IY_RIGHT
| IY_VERT
, 0},
269 {"trh", IY_TOP
| IY_RIGHT
| IY_HORIZ
, 0},
273 static WOptionEnumeration seMenuStyles
[] = {
274 {"normal", MS_NORMAL
, 0},
275 {"singletexture", MS_SINGLE_TEXTURE
, 0},
276 {"flat", MS_FLAT
, 0},
280 static WOptionEnumeration seDisplayPositions
[] = {
281 {"none", WD_NONE
, 0},
282 {"center", WD_CENTER
, 0},
284 {"bottom", WD_BOTTOM
, 0},
285 {"topleft", WD_TOPLEFT
, 0},
286 {"topright", WD_TOPRIGHT
, 0},
287 {"bottomleft", WD_BOTTOMLEFT
, 0},
288 {"bottomright", WD_BOTTOMRIGHT
, 0},
292 static WOptionEnumeration seWorkspaceBorder
[] = {
293 {"None", WB_NONE
, 0},
294 {"LeftRight", WB_LEFTRIGHT
, 0},
295 {"TopBottom", WB_TOPBOTTOM
, 0},
296 {"AllDirections", WB_ALLDIRS
, 0},
301 * ALL entries in the tables bellow, NEED to have a default value
302 * defined, and this value needs to be correct.
305 /* these options will only affect the window manager on startup
307 * static defaults can't access the screen data, because it is
308 * created after these defaults are read
310 WDefaultEntry staticOptionList
[] = {
312 {"ColormapSize", "4", NULL
,
313 &wPreferences
.cmap_size
, getInt
, NULL
},
314 {"DisableDithering", "NO", NULL
,
315 &wPreferences
.no_dithering
, getBool
, NULL
},
316 /* static by laziness */
317 {"IconSize", "64", NULL
,
318 &wPreferences
.icon_size
, getInt
, NULL
},
319 {"ModifierKey", "Mod1", NULL
,
320 &wPreferences
.modifier_mask
, getModMask
, NULL
},
321 {"DisableWSMouseActions", "NO", NULL
,
322 &wPreferences
.disable_root_mouse
, getBool
, NULL
},
323 {"FocusMode", "manual", seFocusModes
,
324 &wPreferences
.focus_mode
, getEnum
, NULL
}, /* have a problem when switching from manual to sloppy without restart */
325 {"NewStyle", "NO", NULL
,
326 &wPreferences
.new_style
, getBool
, NULL
},
327 {"DisableDock", "NO", (void *)WM_DOCK
,
328 NULL
, getBool
, setIfDockPresent
},
329 {"DisableClip", "NO", (void *)WM_CLIP
,
330 NULL
, getBool
, setIfDockPresent
},
331 {"DisableMiniwindows", "NO", NULL
,
332 &wPreferences
.disable_miniwindows
, getBool
, NULL
}
335 WDefaultEntry optionList
[] = {
336 /* dynamic options */
337 {"IconPosition", "blh", seIconPositions
,
338 &wPreferences
.icon_yard
, getEnum
, setIconPosition
},
339 {"IconificationStyle", "Zoom", seIconificationStyles
,
340 &wPreferences
.iconification_style
, getEnum
, NULL
},
341 {"MouseLeftButtonAction", "SelectWindows", seMouseButtonActions
,
342 &wPreferences
.mouse_button1
, getEnum
, NULL
},
343 {"MouseMiddleButtonAction", "OpenWindowListMenu", seMouseButtonActions
,
344 &wPreferences
.mouse_button2
, getEnum
, NULL
},
345 {"MouseRightButtonAction", "OpenApplicationsMenu", seMouseButtonActions
,
346 &wPreferences
.mouse_button3
, getEnum
, NULL
},
347 {"MouseWheelAction", "None", seMouseWheelActions
,
348 &wPreferences
.mouse_wheel
, getEnum
, NULL
},
349 {"PixmapPath", DEF_PIXMAP_PATHS
, NULL
,
350 &wPreferences
.pixmap_path
, getPathList
, NULL
},
351 {"IconPath", DEF_ICON_PATHS
, NULL
,
352 &wPreferences
.icon_path
, getPathList
, NULL
},
353 {"ColormapMode", "auto", seColormapModes
,
354 &wPreferences
.colormap_mode
, getEnum
, NULL
},
355 {"AutoFocus", "NO", NULL
,
356 &wPreferences
.auto_focus
, getBool
, NULL
},
357 {"RaiseDelay", "0", NULL
,
358 &wPreferences
.raise_delay
, getInt
, NULL
},
359 {"CirculateRaise", "NO", NULL
,
360 &wPreferences
.circ_raise
, getBool
, NULL
},
361 {"Superfluous", "NO", NULL
,
362 &wPreferences
.superfluous
, getBool
, NULL
},
363 {"AdvanceToNewWorkspace", "NO", NULL
,
364 &wPreferences
.ws_advance
, getBool
, NULL
},
365 {"CycleWorkspaces", "NO", NULL
,
366 &wPreferences
.ws_cycle
, getBool
, NULL
},
367 {"WorkspaceNameDisplayPosition", "center", seDisplayPositions
,
368 &wPreferences
.workspace_name_display_position
, getEnum
, NULL
},
369 {"WorkspaceBorder", "None", seWorkspaceBorder
,
370 &wPreferences
.workspace_border_position
, getEnum
, updateUsableArea
},
371 {"WorkspaceBorderSize", "0", NULL
,
372 &wPreferences
.workspace_border_size
, getInt
, updateUsableArea
},
373 {"StickyIcons", "NO", NULL
,
374 &wPreferences
.sticky_icons
, getBool
, setStickyIcons
},
375 {"SaveSessionOnExit", "NO", NULL
,
376 &wPreferences
.save_session_on_exit
, getBool
, NULL
},
377 {"WrapMenus", "NO", NULL
,
378 &wPreferences
.wrap_menus
, getBool
, NULL
},
379 {"ScrollableMenus", "NO", NULL
,
380 &wPreferences
.scrollable_menus
, getBool
, NULL
},
381 {"MenuScrollSpeed", "medium", seSpeeds
,
382 &wPreferences
.menu_scroll_speed
, getEnum
, NULL
},
383 {"IconSlideSpeed", "medium", seSpeeds
,
384 &wPreferences
.icon_slide_speed
, getEnum
, NULL
},
385 {"ShadeSpeed", "medium", seSpeeds
,
386 &wPreferences
.shade_speed
, getEnum
, NULL
},
387 {"DoubleClickTime", "250", (void *)&wPreferences
.dblclick_time
,
388 &wPreferences
.dblclick_time
, getInt
, setDoubleClick
,
390 {"AlignSubmenus", "NO", NULL
,
391 &wPreferences
.align_menus
, getBool
, NULL
},
392 {"OpenTransientOnOwnerWorkspace", "NO", NULL
,
393 &wPreferences
.open_transients_with_parent
, getBool
, NULL
},
394 {"WindowPlacement", "auto", sePlacements
,
395 &wPreferences
.window_placement
, getEnum
, NULL
},
396 {"IgnoreFocusClick", "NO", NULL
,
397 &wPreferences
.ignore_focus_click
, getBool
, NULL
},
398 {"UseSaveUnders", "NO", NULL
,
399 &wPreferences
.use_saveunders
, getBool
, NULL
},
400 {"OpaqueMove", "NO", NULL
,
401 &wPreferences
.opaque_move
, getBool
, NULL
},
402 {"DisableAnimations", "NO", NULL
,
403 &wPreferences
.no_animations
, getBool
, NULL
},
404 {"DontLinkWorkspaces", "NO", NULL
,
405 &wPreferences
.no_autowrap
, getBool
, NULL
},
406 {"AutoArrangeIcons", "NO", NULL
,
407 &wPreferences
.auto_arrange_icons
, getBool
, NULL
},
408 {"NoWindowOverDock", "NO", NULL
,
409 &wPreferences
.no_window_over_dock
, getBool
, updateUsableArea
},
410 {"NoWindowOverIcons", "NO", NULL
,
411 &wPreferences
.no_window_over_icons
, getBool
, updateUsableArea
},
412 {"WindowPlaceOrigin", "(0, 0)", NULL
,
413 &wPreferences
.window_place_origin
, getCoord
, NULL
},
414 {"ResizeDisplay", "corner", seGeomDisplays
,
415 &wPreferences
.size_display
, getEnum
, NULL
},
416 {"MoveDisplay", "corner", seGeomDisplays
,
417 &wPreferences
.move_display
, getEnum
, NULL
},
418 {"DontConfirmKill", "NO", NULL
,
419 &wPreferences
.dont_confirm_kill
, getBool
, NULL
},
420 {"WindowTitleBalloons", "NO", NULL
,
421 &wPreferences
.window_balloon
, getBool
, NULL
},
422 {"MiniwindowTitleBalloons", "NO", NULL
,
423 &wPreferences
.miniwin_balloon
, getBool
, NULL
},
424 {"AppIconBalloons", "NO", NULL
,
425 &wPreferences
.appicon_balloon
, getBool
, NULL
},
426 {"HelpBalloons", "NO", NULL
,
427 &wPreferences
.help_balloon
, getBool
, NULL
},
428 {"EdgeResistance", "30", NULL
,
429 &wPreferences
.edge_resistance
, getInt
, NULL
},
430 {"ResizeIncrement", "32", NULL
,
431 &wPreferences
.resize_increment
, getInt
, NULL
},
432 {"Attraction", "NO", NULL
,
433 &wPreferences
.attract
, getBool
, NULL
},
434 {"DisableBlinking", "NO", NULL
,
435 &wPreferences
.dont_blink
, getBool
, NULL
},
436 {"SingleClickLaunch", "NO", NULL
,
437 &wPreferences
.single_click
, getBool
, NULL
},
439 {"MenuStyle", "normal", seMenuStyles
,
440 &wPreferences
.menu_style
, getEnum
, setMenuStyle
},
441 {"WidgetColor", "(solid, gray)", NULL
,
442 NULL
, getTexture
, setWidgetColor
,
444 {"WorkspaceSpecificBack", "()", NULL
,
445 NULL
, getWSSpecificBackground
, setWorkspaceSpecificBack
},
446 /* WorkspaceBack must come after WorkspaceSpecificBack or
447 * WorkspaceBack wont know WorkspaceSpecificBack was also
448 * specified and 2 copies of wmsetbg will be launched */
449 {"WorkspaceBack", "(solid, black)", NULL
,
450 NULL
, getWSBackground
, setWorkspaceBack
},
451 {"SmoothWorkspaceBack", "NO", NULL
,
452 NULL
, getBool
, NULL
},
453 {"IconBack", "(solid, gray)", NULL
,
454 NULL
, getTexture
, setIconTile
},
455 {"TitleJustify", "center", seJustifications
,
456 &wPreferences
.title_justification
, getEnum
, setJustify
},
457 {"WindowTitleFont", DEF_TITLE_FONT
, NULL
,
458 NULL
, getFont
, setWinTitleFont
,
460 {"WindowTitleExtendSpace", DEF_WINDOW_TITLE_EXTEND_SPACE
, NULL
,
461 &wPreferences
.window_title_clearance
, getInt
, setClearance
},
462 {"MenuTitleExtendSpace", DEF_MENU_TITLE_EXTEND_SPACE
, NULL
,
463 &wPreferences
.menu_title_clearance
, getInt
, setClearance
},
464 {"MenuTextExtendSpace", DEF_MENU_TEXT_EXTEND_SPACE
, NULL
,
465 &wPreferences
.menu_text_clearance
, getInt
, setClearance
},
466 {"MenuTitleFont", DEF_MENU_TITLE_FONT
, NULL
,
467 NULL
, getFont
, setMenuTitleFont
},
468 {"MenuTextFont", DEF_MENU_ENTRY_FONT
, NULL
,
469 NULL
, getFont
, setMenuTextFont
},
470 {"IconTitleFont", DEF_ICON_TITLE_FONT
, NULL
,
471 NULL
, getFont
, setIconTitleFont
},
472 {"ClipTitleFont", DEF_CLIP_TITLE_FONT
, NULL
,
473 NULL
, getFont
, setClipTitleFont
},
474 {"LargeDisplayFont", DEF_WORKSPACE_NAME_FONT
, NULL
,
475 NULL
, getFont
, setLargeDisplayFont
},
476 {"HighlightColor", "white", NULL
,
477 NULL
, getColor
, setHightlight
},
478 {"HighlightTextColor", "black", NULL
,
479 NULL
, getColor
, setHightlightText
},
480 {"ClipTitleColor", "black", (void *)CLIP_NORMAL
,
481 NULL
, getColor
, setClipTitleColor
},
482 {"CClipTitleColor", "\"#454045\"", (void *)CLIP_COLLAPSED
,
483 NULL
, getColor
, setClipTitleColor
},
484 {"FTitleColor", "white", (void *)WS_FOCUSED
,
485 NULL
, getColor
, setWTitleColor
},
486 {"PTitleColor", "white", (void *)WS_PFOCUSED
,
487 NULL
, getColor
, setWTitleColor
},
488 {"UTitleColor", "black", (void *)WS_UNFOCUSED
,
489 NULL
, getColor
, setWTitleColor
},
490 {"FTitleBack", "(solid, black)", NULL
,
491 NULL
, getTexture
, setFTitleBack
},
492 {"PTitleBack", "(solid, \"#616161\")", NULL
,
493 NULL
, getTexture
, setPTitleBack
},
494 {"UTitleBack", "(solid, gray)", NULL
,
495 NULL
, getTexture
, setUTitleBack
},
496 {"ResizebarBack", "(solid, gray)", NULL
,
497 NULL
, getTexture
, setResizebarBack
},
498 {"MenuTitleColor", "white", NULL
,
499 NULL
, getColor
, setMenuTitleColor
},
500 {"MenuTextColor", "black", NULL
,
501 NULL
, getColor
, setMenuTextColor
},
502 {"MenuDisabledColor", "\"#616161\"", NULL
,
503 NULL
, getColor
, setMenuDisabledColor
},
504 {"MenuTitleBack", "(solid, black)", NULL
,
505 NULL
, getTexture
, setMenuTitleBack
},
506 {"MenuTextBack", "(solid, gray)", NULL
,
507 NULL
, getTexture
, setMenuTextBack
},
508 {"IconTitleColor", "white", NULL
,
509 NULL
, getColor
, setIconTitleColor
},
510 {"IconTitleBack", "black", NULL
,
511 NULL
, getColor
, setIconTitleBack
},
512 {"SwitchPanelImages", "(swtile.png, swback.png, 30, 40)", &wPreferences
,
513 NULL
, getPropList
, setSwPOptions
},
515 {"RootMenuKey", "None", (void *)WKBD_ROOTMENU
,
516 NULL
, getKeybind
, setKeyGrab
},
517 {"WindowListKey", "None", (void *)WKBD_WINDOWLIST
,
518 NULL
, getKeybind
, setKeyGrab
},
519 {"WindowMenuKey", "None", (void *)WKBD_WINDOWMENU
,
520 NULL
, getKeybind
, setKeyGrab
},
521 {"DockRaiseLowerKey", "None", (void*)WKBD_DOCKRAISELOWER
,
522 NULL
, getKeybind
, setKeyGrab
},
523 {"ClipRaiseLowerKey", "None", (void *)WKBD_CLIPRAISELOWER
,
524 NULL
, getKeybind
, setKeyGrab
},
525 {"MiniaturizeKey", "None", (void *)WKBD_MINIATURIZE
,
526 NULL
, getKeybind
, setKeyGrab
},
527 {"HideKey", "None", (void *)WKBD_HIDE
,
528 NULL
, getKeybind
, setKeyGrab
},
529 {"HideOthersKey", "None", (void *)WKBD_HIDE_OTHERS
,
530 NULL
, getKeybind
, setKeyGrab
},
531 {"MoveResizeKey", "None", (void *)WKBD_MOVERESIZE
,
532 NULL
, getKeybind
, setKeyGrab
},
533 {"CloseKey", "None", (void *)WKBD_CLOSE
,
534 NULL
, getKeybind
, setKeyGrab
},
535 {"MaximizeKey", "None", (void *)WKBD_MAXIMIZE
,
536 NULL
, getKeybind
, setKeyGrab
},
537 {"VMaximizeKey", "None", (void *)WKBD_VMAXIMIZE
,
538 NULL
, getKeybind
, setKeyGrab
},
539 {"HMaximizeKey", "None", (void *)WKBD_HMAXIMIZE
,
540 NULL
, getKeybind
, setKeyGrab
},
541 {"LHMaximizeKey", "None", (void*)WKBD_LHMAXIMIZE
,
542 NULL
, getKeybind
, setKeyGrab
},
543 {"RHMaximizeKey", "None", (void*)WKBD_RHMAXIMIZE
,
544 NULL
, getKeybind
, setKeyGrab
},
545 {"MaximusKey", "None", (void*)WKBD_MAXIMUS
,
546 NULL
, getKeybind
, setKeyGrab
},
547 {"RaiseKey", "\"Meta+Up\"", (void *)WKBD_RAISE
,
548 NULL
, getKeybind
, setKeyGrab
},
549 {"LowerKey", "\"Meta+Down\"", (void *)WKBD_LOWER
,
550 NULL
, getKeybind
, setKeyGrab
},
551 {"RaiseLowerKey", "None", (void *)WKBD_RAISELOWER
,
552 NULL
, getKeybind
, setKeyGrab
},
553 {"ShadeKey", "None", (void *)WKBD_SHADE
,
554 NULL
, getKeybind
, setKeyGrab
},
555 {"SelectKey", "None", (void *)WKBD_SELECT
,
556 NULL
, getKeybind
, setKeyGrab
},
557 {"FocusNextKey", "None", (void *)WKBD_FOCUSNEXT
,
558 NULL
, getKeybind
, setKeyGrab
},
559 {"FocusPrevKey", "None", (void *)WKBD_FOCUSPREV
,
560 NULL
, getKeybind
, setKeyGrab
},
561 {"GroupNextKey", "None", (void *)WKBD_GROUPNEXT
,
562 NULL
, getKeybind
, setKeyGrab
},
563 {"GroupPrevKey", "None", (void *)WKBD_GROUPPREV
,
564 NULL
, getKeybind
, setKeyGrab
},
565 {"NextWorkspaceKey", "None", (void *)WKBD_NEXTWORKSPACE
,
566 NULL
, getKeybind
, setKeyGrab
},
567 {"PrevWorkspaceKey", "None", (void *)WKBD_PREVWORKSPACE
,
568 NULL
, getKeybind
, setKeyGrab
},
569 {"NextWorkspaceLayerKey", "None", (void *)WKBD_NEXTWSLAYER
,
570 NULL
, getKeybind
, setKeyGrab
},
571 {"PrevWorkspaceLayerKey", "None", (void *)WKBD_PREVWSLAYER
,
572 NULL
, getKeybind
, setKeyGrab
},
573 {"Workspace1Key", "None", (void *)WKBD_WORKSPACE1
,
574 NULL
, getKeybind
, setKeyGrab
},
575 {"Workspace2Key", "None", (void *)WKBD_WORKSPACE2
,
576 NULL
, getKeybind
, setKeyGrab
},
577 {"Workspace3Key", "None", (void *)WKBD_WORKSPACE3
,
578 NULL
, getKeybind
, setKeyGrab
},
579 {"Workspace4Key", "None", (void *)WKBD_WORKSPACE4
,
580 NULL
, getKeybind
, setKeyGrab
},
581 {"Workspace5Key", "None", (void *)WKBD_WORKSPACE5
,
582 NULL
, getKeybind
, setKeyGrab
},
583 {"Workspace6Key", "None", (void *)WKBD_WORKSPACE6
,
584 NULL
, getKeybind
, setKeyGrab
},
585 {"Workspace7Key", "None", (void *)WKBD_WORKSPACE7
,
586 NULL
, getKeybind
, setKeyGrab
},
587 {"Workspace8Key", "None", (void *)WKBD_WORKSPACE8
,
588 NULL
, getKeybind
, setKeyGrab
},
589 {"Workspace9Key", "None", (void *)WKBD_WORKSPACE9
,
590 NULL
, getKeybind
, setKeyGrab
},
591 {"Workspace10Key", "None", (void *)WKBD_WORKSPACE10
,
592 NULL
, getKeybind
, setKeyGrab
},
593 {"WindowShortcut1Key", "None", (void *)WKBD_WINDOW1
,
594 NULL
, getKeybind
, setKeyGrab
},
595 {"WindowShortcut2Key", "None", (void *)WKBD_WINDOW2
,
596 NULL
, getKeybind
, setKeyGrab
},
597 {"WindowShortcut3Key", "None", (void *)WKBD_WINDOW3
,
598 NULL
, getKeybind
, setKeyGrab
},
599 {"WindowShortcut4Key", "None", (void *)WKBD_WINDOW4
,
600 NULL
, getKeybind
, setKeyGrab
}
601 , {"WindowShortcut5Key", "None", (void *)WKBD_WINDOW5
,
602 NULL
, getKeybind
, setKeyGrab
},
603 {"WindowShortcut6Key", "None", (void *)WKBD_WINDOW6
,
604 NULL
, getKeybind
, setKeyGrab
},
605 {"WindowShortcut7Key", "None", (void *)WKBD_WINDOW7
,
606 NULL
, getKeybind
, setKeyGrab
},
607 {"WindowShortcut8Key", "None", (void *)WKBD_WINDOW8
,
608 NULL
, getKeybind
, setKeyGrab
},
609 {"WindowShortcut9Key", "None", (void *)WKBD_WINDOW9
,
610 NULL
, getKeybind
, setKeyGrab
},
611 {"WindowShortcut10Key", "None", (void *)WKBD_WINDOW10
,
612 NULL
, getKeybind
, setKeyGrab
},
613 {"ScreenSwitchKey", "None", (void *)WKBD_SWITCH_SCREEN
,
614 NULL
, getKeybind
, setKeyGrab
},
616 #ifdef KEEP_XKB_LOCK_STATUS
617 {"ToggleKbdModeKey", "None", (void *)WKBD_TOGGLE
,
618 NULL
, getKeybind
, setKeyGrab
},
619 {"KbdModeLock", "NO", NULL
,
620 &wPreferences
.modelock
, getBool
, NULL
},
621 #endif /* KEEP_XKB_LOCK_STATUS */
623 {"NormalCursor", "(builtin, left_ptr)", (void *)WCUR_ROOT
,
624 NULL
, getCursor
, setCursor
},
625 {"ArrowCursor", "(builtin, top_left_arrow)", (void *)WCUR_ARROW
,
626 NULL
, getCursor
, setCursor
},
627 {"MoveCursor", "(builtin, fleur)", (void *)WCUR_MOVE
,
628 NULL
, getCursor
, setCursor
},
629 {"ResizeCursor", "(builtin, sizing)", (void *)WCUR_RESIZE
,
630 NULL
, getCursor
, setCursor
},
631 {"TopLeftResizeCursor", "(builtin, top_left_corner)",
632 (void *)WCUR_TOPLEFTRESIZE
,
633 NULL
, getCursor
, setCursor
},
634 {"TopRightResizeCursor", "(builtin, top_right_corner)",
635 (void *)WCUR_TOPRIGHTRESIZE
,
636 NULL
, getCursor
, setCursor
},
637 {"BottomLeftResizeCursor", "(builtin, bottom_left_corner)",
638 (void *)WCUR_BOTTOMLEFTRESIZE
,
639 NULL
, getCursor
, setCursor
},
640 {"BottomRightResizeCursor", "(builtin, bottom_right_corner)",
641 (void *)WCUR_BOTTOMRIGHTRESIZE
,
642 NULL
, getCursor
, setCursor
},
643 {"VerticalResizeCursor", "(builtin, sb_v_double_arrow)",
644 (void *)WCUR_VERTICALRESIZE
,
645 NULL
, getCursor
, setCursor
},
646 {"HorizontalResizeCursor", "(builtin, sb_h_double_arrow)",
647 (void *)WCUR_HORIZONRESIZE
,
648 NULL
, getCursor
, setCursor
},
649 {"WaitCursor", "(builtin, watch)", (void *)WCUR_WAIT
,
650 NULL
, getCursor
, setCursor
},
651 {"QuestionCursor", "(builtin, question_arrow)", (void *)WCUR_QUESTION
,
652 NULL
, getCursor
, setCursor
},
653 {"TextCursor", "(builtin, xterm)", (void *)WCUR_TEXT
,
654 NULL
, getCursor
, setCursor
},
655 {"SelectCursor", "(builtin, cross)", (void *)WCUR_SELECT
,
656 NULL
, getCursor
, setCursor
},
657 {"DialogHistoryLines", "500", NULL
,
658 &wPreferences
.history_lines
, getInt
, NULL
}
662 static void rereadDefaults(void)
664 /* must defer the update because accessing X data from a
665 * signal handler can mess up Xlib */
670 static void initDefaults()
673 WDefaultEntry
*entry
;
675 WMPLSetCaseSensitive(False
);
677 for (i
= 0; i
< sizeof(optionList
) / sizeof(WDefaultEntry
); i
++) {
678 entry
= &optionList
[i
];
680 entry
->plkey
= WMCreatePLString(entry
->key
);
681 if (entry
->default_value
)
682 entry
->plvalue
= WMCreatePropListFromDescription(entry
->default_value
);
684 entry
->plvalue
= NULL
;
687 for (i
= 0; i
< sizeof(staticOptionList
) / sizeof(WDefaultEntry
); i
++) {
688 entry
= &staticOptionList
[i
];
690 entry
->plkey
= WMCreatePLString(entry
->key
);
691 if (entry
->default_value
)
692 entry
->plvalue
= WMCreatePropListFromDescription(entry
->default_value
);
694 entry
->plvalue
= NULL
;
698 wDomainName = WMCreatePLString(WMDOMAIN_NAME);
699 wAttributeDomainName = WMCreatePLString(WMATTRIBUTE_DOMAIN_NAME);
701 PLRegister(wDomainName, rereadDefaults);
702 PLRegister(wAttributeDomainName, rereadDefaults);
706 static WMPropList
*readGlobalDomain(char *domainName
, Bool requireDictionary
)
708 WMPropList
*globalDict
= NULL
;
712 snprintf(path
, sizeof(path
), "%s/%s/%s", SYSCONFDIR
, GLOBAL_DEFAULTS_SUBDIR
, domainName
);
713 if (stat(path
, &stbuf
) >= 0) {
714 globalDict
= WMReadPropListFromFile(path
);
715 if (globalDict
&& requireDictionary
&& !WMIsPLDictionary(globalDict
)) {
716 wwarning(_("Domain %s (%s) of global defaults database is corrupted!"), domainName
, path
);
717 WMReleasePropList(globalDict
);
719 } else if (!globalDict
) {
720 wwarning(_("could not load domain %s from global defaults database"), domainName
);
727 #if defined(GLOBAL_PREAMBLE_MENU_FILE) || defined(GLOBAL_EPILOGUE_MENU_FILE)
728 static void prependMenu(WMPropList
* destarr
, WMPropList
* array
)
733 for (i
= 0; i
< WMGetPropListItemCount(array
); i
++) {
734 item
= WMGetFromPLArray(array
, i
);
736 WMInsertInPLArray(destarr
, i
+ 1, item
);
740 static void appendMenu(WMPropList
* destarr
, WMPropList
* array
)
745 for (i
= 0; i
< WMGetPropListItemCount(array
); i
++) {
746 item
= WMGetFromPLArray(array
, i
);
748 WMAddToPLArray(destarr
, item
);
753 void wDefaultsMergeGlobalMenus(WDDomain
* menuDomain
)
755 WMPropList
*menu
= menuDomain
->dictionary
;
758 if (!menu
|| !WMIsPLArray(menu
))
761 #ifdef GLOBAL_PREAMBLE_MENU_FILE
762 submenu
= WMReadPropListFromFile(SYSCONFDIR
"/" GLOBAL_DEFAULTS_SUBDIR
"/" GLOBAL_PREAMBLE_MENU_FILE
);
764 if (submenu
&& !WMIsPLArray(submenu
)) {
765 wwarning(_("invalid global menu file %s"), GLOBAL_PREAMBLE_MENU_FILE
);
766 WMReleasePropList(submenu
);
770 prependMenu(menu
, submenu
);
771 WMReleasePropList(submenu
);
775 #ifdef GLOBAL_EPILOGUE_MENU_FILE
776 submenu
= WMReadPropListFromFile(SYSCONFDIR
"/" GLOBAL_DEFAULTS_SUBDIR
"/" GLOBAL_EPILOGUE_MENU_FILE
);
778 if (submenu
&& !WMIsPLArray(submenu
)) {
779 wwarning(_("invalid global menu file %s"), GLOBAL_EPILOGUE_MENU_FILE
);
780 WMReleasePropList(submenu
);
784 appendMenu(menu
, submenu
);
785 WMReleasePropList(submenu
);
789 menuDomain
->dictionary
= menu
;
792 void wDefaultsDestroyDomain(WDDomain
* domain
)
794 if (domain
->dictionary
)
795 WMReleasePropList(domain
->dictionary
);
800 WDDomain
*wDefaultsInitDomain(char *domain
, Bool requireDictionary
)
804 static int inited
= 0;
807 WMPropList
*shared_dict
= NULL
;
814 db
= wmalloc(sizeof(WDDomain
));
815 memset(db
, 0, sizeof(WDDomain
));
816 db
->domain_name
= domain
;
817 db
->path
= wdefaultspathfordomain(domain
);
820 if (the_path
&& stat(the_path
, &stbuf
) >= 0) {
821 db
->dictionary
= WMReadPropListFromFile(the_path
);
822 if (db
->dictionary
) {
823 if (requireDictionary
&& !WMIsPLDictionary(db
->dictionary
)) {
824 WMReleasePropList(db
->dictionary
);
825 db
->dictionary
= NULL
;
826 wwarning(_("Domain %s (%s) of defaults database is corrupted!"), domain
, the_path
);
828 db
->timestamp
= stbuf
.st_mtime
;
830 wwarning(_("could not load domain %s from user defaults database"), domain
);
834 /* global system dictionary */
835 snprintf(path
, sizeof(path
), "%s/%s/%s", SYSCONFDIR
, GLOBAL_DEFAULTS_SUBDIR
, domain
);
836 if (stat(path
, &stbuf
) >= 0) {
837 shared_dict
= WMReadPropListFromFile(path
);
839 if (requireDictionary
&& !WMIsPLDictionary(shared_dict
)) {
840 wwarning(_("Domain %s (%s) of global defaults database is corrupted!"),
842 WMReleasePropList(shared_dict
);
845 if (db
->dictionary
&& WMIsPLDictionary(shared_dict
) &&
846 WMIsPLDictionary(db
->dictionary
)) {
847 WMMergePLDictionaries(shared_dict
, db
->dictionary
, True
);
848 WMReleasePropList(db
->dictionary
);
849 db
->dictionary
= shared_dict
;
850 if (stbuf
.st_mtime
> db
->timestamp
)
851 db
->timestamp
= stbuf
.st_mtime
;
852 } else if (!db
->dictionary
) {
853 db
->dictionary
= shared_dict
;
854 if (stbuf
.st_mtime
> db
->timestamp
)
855 db
->timestamp
= stbuf
.st_mtime
;
859 wwarning(_("could not load domain %s from global defaults database (%s)"), domain
, path
);
866 void wReadStaticDefaults(WMPropList
* dict
)
869 WDefaultEntry
*entry
;
873 for (i
= 0; i
< sizeof(staticOptionList
) / sizeof(WDefaultEntry
); i
++) {
874 entry
= &staticOptionList
[i
];
877 plvalue
= WMGetFromPLDictionary(dict
, entry
->plkey
);
882 /* no default in the DB. Use builtin default */
883 plvalue
= entry
->plvalue
;
888 (*entry
->convert
) (NULL
, entry
, plvalue
, entry
->addr
, &tdata
);
890 (*entry
->update
) (NULL
, entry
, tdata
, entry
->extra_data
);
896 void wDefaultsCheckDomains(void* arg
)
900 WMPropList
*shared_dict
= NULL
;
904 if (stat(WDWindowMaker
->path
, &stbuf
) >= 0 && WDWindowMaker
->timestamp
< stbuf
.st_mtime
) {
905 WDWindowMaker
->timestamp
= stbuf
.st_mtime
;
907 /* global dictionary */
908 shared_dict
= readGlobalDomain("WindowMaker", True
);
909 /* user dictionary */
910 dict
= WMReadPropListFromFile(WDWindowMaker
->path
);
912 if (!WMIsPLDictionary(dict
)) {
913 WMReleasePropList(dict
);
915 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
916 "WindowMaker", WDWindowMaker
->path
);
919 WMMergePLDictionaries(shared_dict
, dict
, True
);
920 WMReleasePropList(dict
);
924 for (i
= 0; i
< wScreenCount
; i
++) {
925 scr
= wScreenWithNumber(i
);
927 wReadDefaults(scr
, dict
);
929 if (WDWindowMaker
->dictionary
) {
930 WMReleasePropList(WDWindowMaker
->dictionary
);
932 WDWindowMaker
->dictionary
= dict
;
935 wwarning(_("could not load domain %s from user defaults database"), "WindowMaker");
938 WMReleasePropList(shared_dict
);
942 if (stat(WDWindowAttributes
->path
, &stbuf
) >= 0 && WDWindowAttributes
->timestamp
< stbuf
.st_mtime
) {
943 /* global dictionary */
944 shared_dict
= readGlobalDomain("WMWindowAttributes", True
);
945 /* user dictionary */
946 dict
= WMReadPropListFromFile(WDWindowAttributes
->path
);
948 if (!WMIsPLDictionary(dict
)) {
949 WMReleasePropList(dict
);
951 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
952 "WMWindowAttributes", WDWindowAttributes
->path
);
955 WMMergePLDictionaries(shared_dict
, dict
, True
);
956 WMReleasePropList(dict
);
960 if (WDWindowAttributes
->dictionary
) {
961 WMReleasePropList(WDWindowAttributes
->dictionary
);
963 WDWindowAttributes
->dictionary
= dict
;
964 for (i
= 0; i
< wScreenCount
; i
++) {
965 scr
= wScreenWithNumber(i
);
969 wDefaultUpdateIcons(scr
);
971 /* Update the panel image if changed */
972 /* Don't worry. If the image is the same these
973 * functions will have no performance impact. */
974 image
= wDefaultGetImage(scr
, "Logo", "WMPanel");
977 wwarning(_("could not load logo image for panels: %s"),
978 RMessageForError(RErrorCode
));
980 WMSetApplicationIconImage(scr
->wmscreen
, image
);
981 RReleaseImage(image
);
987 wwarning(_("could not load domain %s from user defaults database"), "WMWindowAttributes");
989 WDWindowAttributes
->timestamp
= stbuf
.st_mtime
;
991 WMReleasePropList(shared_dict
);
995 if (stat(WDRootMenu
->path
, &stbuf
) >= 0 && WDRootMenu
->timestamp
< stbuf
.st_mtime
) {
996 dict
= WMReadPropListFromFile(WDRootMenu
->path
);
998 if (!WMIsPLArray(dict
) && !WMIsPLString(dict
)) {
999 WMReleasePropList(dict
);
1001 wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
1002 "WMRootMenu", WDRootMenu
->path
);
1004 if (WDRootMenu
->dictionary
) {
1005 WMReleasePropList(WDRootMenu
->dictionary
);
1007 WDRootMenu
->dictionary
= dict
;
1008 wDefaultsMergeGlobalMenus(WDRootMenu
);
1011 wwarning(_("could not load domain %s from user defaults database"), "WMRootMenu");
1013 WDRootMenu
->timestamp
= stbuf
.st_mtime
;
1015 #ifndef HAVE_INOTIFY
1017 WMAddTimerHandler(DEFAULTS_CHECK_INTERVAL
, wDefaultsCheckDomains
, arg
);
1021 void wReadDefaults(WScreen
* scr
, WMPropList
* new_dict
)
1023 WMPropList
*plvalue
, *old_value
;
1024 WDefaultEntry
*entry
;
1025 unsigned int i
, must_update
;
1026 int update_workspace_back
= 0; /* kluge :/ */
1027 unsigned int needs_refresh
;
1029 WMPropList
*old_dict
= (WDWindowMaker
->dictionary
!= new_dict
? WDWindowMaker
->dictionary
: NULL
);
1035 for (i
= 0; i
< sizeof(optionList
) / sizeof(WDefaultEntry
); i
++) {
1036 entry
= &optionList
[i
];
1039 plvalue
= WMGetFromPLDictionary(new_dict
, entry
->plkey
);
1046 old_value
= WMGetFromPLDictionary(old_dict
, entry
->plkey
);
1048 if (!plvalue
&& !old_value
) {
1049 /* no default in the DB. Use builtin default */
1050 plvalue
= entry
->plvalue
;
1051 if (plvalue
&& new_dict
) {
1052 WMPutInPLDictionary(new_dict
, entry
->plkey
, plvalue
);
1055 } else if (!plvalue
) {
1056 /* value was deleted from DB. Keep current value */
1058 } else if (!old_value
) {
1059 /* set value for the 1st time */
1060 } else if (!WMIsPropListEqualTo(plvalue
, old_value
)) {
1061 /* value has changed */
1064 if (strcmp(entry
->key
, "WorkspaceBack") == 0
1065 && update_workspace_back
&& scr
->flags
.backimage_helper_launched
) {
1067 /* value was not changed since last time */
1074 if ((*entry
->convert
) (scr
, entry
, plvalue
, entry
->addr
, &tdata
)) {
1076 * If the WorkspaceSpecificBack data has been changed
1077 * so that the helper will be launched now, we must be
1078 * sure to send the default background texture config
1081 if (strcmp(entry
->key
, "WorkspaceSpecificBack") == 0
1082 && !scr
->flags
.backimage_helper_launched
) {
1083 update_workspace_back
= 1;
1085 if (entry
->update
) {
1086 needs_refresh
|= (*entry
->update
) (scr
, entry
, tdata
, entry
->extra_data
);
1092 if (needs_refresh
!= 0 && !scr
->flags
.startup
) {
1096 if (needs_refresh
& REFRESH_MENU_TITLE_TEXTURE
)
1097 foo
|= WTextureSettings
;
1098 if (needs_refresh
& REFRESH_MENU_TITLE_FONT
)
1099 foo
|= WFontSettings
;
1100 if (needs_refresh
& REFRESH_MENU_TITLE_COLOR
)
1101 foo
|= WColorSettings
;
1103 WMPostNotificationName(WNMenuTitleAppearanceSettingsChanged
, NULL
,
1104 (void *)(uintptr_t) foo
);
1107 if (needs_refresh
& REFRESH_MENU_TEXTURE
)
1108 foo
|= WTextureSettings
;
1109 if (needs_refresh
& REFRESH_MENU_FONT
)
1110 foo
|= WFontSettings
;
1111 if (needs_refresh
& REFRESH_MENU_COLOR
)
1112 foo
|= WColorSettings
;
1114 WMPostNotificationName(WNMenuAppearanceSettingsChanged
, NULL
, (void *)(uintptr_t) foo
);
1117 if (needs_refresh
& REFRESH_WINDOW_FONT
) {
1118 foo
|= WFontSettings
;
1120 if (needs_refresh
& REFRESH_WINDOW_TEXTURES
) {
1121 foo
|= WTextureSettings
;
1123 if (needs_refresh
& REFRESH_WINDOW_TITLE_COLOR
) {
1124 foo
|= WColorSettings
;
1127 WMPostNotificationName(WNWindowAppearanceSettingsChanged
, NULL
, (void *)(uintptr_t) foo
);
1129 if (!(needs_refresh
& REFRESH_ICON_TILE
)) {
1131 if (needs_refresh
& REFRESH_ICON_FONT
) {
1132 foo
|= WFontSettings
;
1134 if (needs_refresh
& REFRESH_ICON_TITLE_COLOR
) {
1135 foo
|= WTextureSettings
;
1137 if (needs_refresh
& REFRESH_ICON_TITLE_BACK
) {
1138 foo
|= WTextureSettings
;
1141 WMPostNotificationName(WNIconAppearanceSettingsChanged
, NULL
,
1142 (void *)(uintptr_t) foo
);
1144 if (needs_refresh
& REFRESH_ICON_TILE
)
1145 WMPostNotificationName(WNIconTileSettingsChanged
, NULL
, NULL
);
1149 void wDefaultUpdateIcons(WScreen
* scr
)
1151 WAppIcon
*aicon
= scr
->app_icon_list
;
1152 WWindow
*wwin
= scr
->focused_window
;
1156 file
= wDefaultGetIconFile(scr
, aicon
->wm_instance
, aicon
->wm_class
, False
);
1157 if ((file
&& aicon
->icon
->file
&& strcmp(file
, aicon
->icon
->file
) != 0)
1158 || (file
&& !aicon
->icon
->file
)) {
1161 if (aicon
->icon
->file
)
1162 wfree(aicon
->icon
->file
);
1163 aicon
->icon
->file
= wstrdup(file
);
1165 new_image
= wDefaultGetImage(scr
, aicon
->wm_instance
, aicon
->wm_class
);
1167 wIconChangeImage(aicon
->icon
, new_image
);
1168 wAppIconPaint(aicon
);
1171 aicon
= aicon
->next
;
1174 if (!wPreferences
.flags
.noclip
)
1175 wClipIconPaint(scr
->clip_icon
);
1178 if (wwin
->icon
&& wwin
->flags
.miniaturized
) {
1179 file
= wDefaultGetIconFile(scr
, wwin
->wm_instance
, wwin
->wm_class
, False
);
1180 if ((file
&& wwin
->icon
->file
&& strcmp(file
, wwin
->icon
->file
) != 0)
1181 || (file
&& !wwin
->icon
->file
)) {
1184 if (wwin
->icon
->file
)
1185 wfree(wwin
->icon
->file
);
1186 wwin
->icon
->file
= wstrdup(file
);
1188 new_image
= wDefaultGetImage(scr
, wwin
->wm_instance
, wwin
->wm_class
);
1190 wIconChangeImage(wwin
->icon
, new_image
);
1197 /* --------------------------- Local ----------------------- */
1199 #define GET_STRING_OR_DEFAULT(x, var) if (!WMIsPLString(value)) { \
1200 wwarning(_("Wrong option format for key \"%s\". Should be %s."), \
1202 wwarning(_("using default \"%s\" instead"), entry->default_value); \
1203 var = entry->default_value;\
1204 } else var = WMGetFromPLString(value)\
1207 static int string2index(WMPropList * key, WMPropList * val, char *def, WOptionEnumeration * values)
1210 WOptionEnumeration
*v
;
1211 char buffer
[TOTAL_VALUES_LENGTH
];
1213 if (WMIsPLString(val
) && (str
= WMGetFromPLString(val
))) {
1214 for (v
= values
; v
->string
!= NULL
; v
++) {
1215 if (strcasecmp(v
->string
, str
) == 0)
1221 for (v
= values
; v
->string
!= NULL
; v
++) {
1224 strcat(buffer
, ", ");
1225 strcat(buffer
, v
->string
);
1228 wwarning(_("wrong option value for key \"%s\". Should be one of %s"), WMGetFromPLString(key
), buffer
);
1231 return string2index(key
, val
, NULL
, values
);
1238 * value - is the value in the defaults DB
1239 * addr - is the address to store the data
1240 * ret - is the address to store a pointer to a temporary buffer. ret
1241 * must not be freed and is used by the set functions
1243 static int getBool(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1247 int second_pass
= 0;
1249 GET_STRING_OR_DEFAULT("Boolean", val
);
1252 if ((val
[1] == '\0' && (val
[0] == 'y' || val
[0] == 'Y'))
1253 || strcasecmp(val
, "YES") == 0) {
1256 } else if ((val
[1] == '\0' && (val
[0] == 'n' || val
[0] == 'N'))
1257 || strcasecmp(val
, "NO") == 0) {
1261 if (sscanf(val
, "%i", &i
) == 1) {
1267 wwarning(_("can't convert \"%s\" to boolean for key \"%s\""), val
, entry
->key
);
1268 if (second_pass
== 0) {
1269 val
= WMGetFromPLString(entry
->plvalue
);
1271 wwarning(_("using default \"%s\" instead"), val
);
1281 *(char *)addr
= data
;
1286 static int getInt(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1291 GET_STRING_OR_DEFAULT("Integer", val
);
1293 if (sscanf(val
, "%i", &data
) != 1) {
1294 wwarning(_("can't convert \"%s\" to integer for key \"%s\""), val
, entry
->key
);
1295 val
= WMGetFromPLString(entry
->plvalue
);
1296 wwarning(_("using default \"%s\" instead"), val
);
1297 if (sscanf(val
, "%i", &data
) != 1) {
1305 *(int *)addr
= data
;
1310 static int getCoord(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1313 char *val_x
, *val_y
;
1314 int nelem
, changed
= 0;
1315 WMPropList
*elem_x
, *elem_y
;
1318 if (!WMIsPLArray(value
)) {
1319 wwarning(_("Wrong option format for key \"%s\". Should be %s."), entry
->key
, "Coordinate");
1321 value
= entry
->plvalue
;
1323 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1329 nelem
= WMGetPropListItemCount(value
);
1331 wwarning(_("Incorrect number of elements in array for key \"%s\"."), entry
->key
);
1333 value
= entry
->plvalue
;
1335 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1341 elem_x
= WMGetFromPLArray(value
, 0);
1342 elem_y
= WMGetFromPLArray(value
, 1);
1344 if (!elem_x
|| !elem_y
|| !WMIsPLString(elem_x
) || !WMIsPLString(elem_y
)) {
1345 wwarning(_("Wrong value for key \"%s\". Should be Coordinate."), entry
->key
);
1347 value
= entry
->plvalue
;
1349 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1355 val_x
= WMGetFromPLString(elem_x
);
1356 val_y
= WMGetFromPLString(elem_y
);
1358 if (sscanf(val_x
, "%i", &data
.x
) != 1 || sscanf(val_y
, "%i", &data
.y
) != 1) {
1359 wwarning(_("can't convert array to integers for \"%s\"."), entry
->key
);
1361 value
= entry
->plvalue
;
1363 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1371 else if (data
.x
> scr
->scr_width
/ 3)
1372 data
.x
= scr
->scr_width
/ 3;
1375 else if (data
.y
> scr
->scr_height
/ 3)
1376 data
.y
= scr
->scr_height
/ 3;
1381 *(WCoord
*) addr
= data
;
1386 static int getPropList(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1388 WMRetainPropList(value
);
1395 static int getPathList(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1404 if (!WMIsPLArray(value
)) {
1405 wwarning(_("Wrong option format for key \"%s\". Should be %s."), entry
->key
, "an array of paths");
1407 value
= entry
->plvalue
;
1409 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1416 count
= WMGetPropListItemCount(value
);
1419 value
= entry
->plvalue
;
1421 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1428 for (i
= 0; i
< count
; i
++) {
1429 d
= WMGetFromPLArray(value
, i
);
1430 if (!d
|| !WMIsPLString(d
)) {
1434 len
+= strlen(WMGetFromPLString(d
)) + 1;
1437 ptr
= data
= wmalloc(len
+ 1);
1439 for (i
= 0; i
< count
; i
++) {
1440 d
= WMGetFromPLArray(value
, i
);
1441 if (!d
|| !WMIsPLString(d
)) {
1444 strcpy(ptr
, WMGetFromPLString(d
));
1445 ptr
+= strlen(WMGetFromPLString(d
));
1452 if (*(char **)addr
!= NULL
) {
1453 wfree(*(char **)addr
);
1455 *(char **)addr
= data
;
1460 static int getEnum(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1462 static signed char data
;
1464 data
= string2index(entry
->plkey
, value
, entry
->default_value
, (WOptionEnumeration
*) entry
->extra_data
);
1471 *(signed char *)addr
= data
;
1478 * (hgradient <color> <color>)
1479 * (vgradient <color> <color>)
1480 * (dgradient <color> <color>)
1481 * (mhgradient <color> <color> ...)
1482 * (mvgradient <color> <color> ...)
1483 * (mdgradient <color> <color> ...)
1484 * (igradient <color1> <color1> <thickness1> <color2> <color2> <thickness2>)
1485 * (tpixmap <file> <color>)
1486 * (spixmap <file> <color>)
1487 * (cpixmap <file> <color>)
1488 * (thgradient <file> <opaqueness> <color> <color>)
1489 * (tvgradient <file> <opaqueness> <color> <color>)
1490 * (tdgradient <file> <opaqueness> <color> <color>)
1491 * (function <lib> <function> ...)
1494 static WTexture
*parse_texture(WScreen
* scr
, WMPropList
* pl
)
1499 WTexture
*texture
= NULL
;
1501 nelem
= WMGetPropListItemCount(pl
);
1505 elem
= WMGetFromPLArray(pl
, 0);
1506 if (!elem
|| !WMIsPLString(elem
))
1508 val
= WMGetFromPLString(elem
);
1510 if (strcasecmp(val
, "solid") == 0) {
1518 elem
= WMGetFromPLArray(pl
, 1);
1519 if (!elem
|| !WMIsPLString(elem
))
1521 val
= WMGetFromPLString(elem
);
1523 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &color
)) {
1524 wwarning(_("\"%s\" is not a valid color name"), val
);
1528 texture
= (WTexture
*) wTextureMakeSolid(scr
, &color
);
1529 } else if (strcasecmp(val
, "dgradient") == 0
1530 || strcasecmp(val
, "vgradient") == 0 || strcasecmp(val
, "hgradient") == 0) {
1531 RColor color1
, color2
;
1536 wwarning(_("bad number of arguments in gradient specification"));
1540 if (val
[0] == 'd' || val
[0] == 'D')
1541 type
= WTEX_DGRADIENT
;
1542 else if (val
[0] == 'h' || val
[0] == 'H')
1543 type
= WTEX_HGRADIENT
;
1545 type
= WTEX_VGRADIENT
;
1547 /* get from color */
1548 elem
= WMGetFromPLArray(pl
, 1);
1549 if (!elem
|| !WMIsPLString(elem
))
1551 val
= WMGetFromPLString(elem
);
1553 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1554 wwarning(_("\"%s\" is not a valid color name"), val
);
1558 color1
.red
= xcolor
.red
>> 8;
1559 color1
.green
= xcolor
.green
>> 8;
1560 color1
.blue
= xcolor
.blue
>> 8;
1563 elem
= WMGetFromPLArray(pl
, 2);
1564 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 color2
.red
= xcolor
.red
>> 8;
1575 color2
.green
= xcolor
.green
>> 8;
1576 color2
.blue
= xcolor
.blue
>> 8;
1578 texture
= (WTexture
*) wTextureMakeGradient(scr
, type
, &color1
, &color2
);
1580 } else if (strcasecmp(val
, "igradient") == 0) {
1581 RColor colors1
[2], colors2
[2];
1587 wwarning(_("bad number of arguments in gradient specification"));
1591 /* get from color */
1592 for (i
= 0; i
< 2; i
++) {
1593 elem
= WMGetFromPLArray(pl
, 1 + i
);
1594 if (!elem
|| !WMIsPLString(elem
))
1596 val
= WMGetFromPLString(elem
);
1598 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1599 wwarning(_("\"%s\" is not a valid color name"), val
);
1602 colors1
[i
].alpha
= 255;
1603 colors1
[i
].red
= xcolor
.red
>> 8;
1604 colors1
[i
].green
= xcolor
.green
>> 8;
1605 colors1
[i
].blue
= xcolor
.blue
>> 8;
1607 elem
= WMGetFromPLArray(pl
, 3);
1608 if (!elem
|| !WMIsPLString(elem
))
1610 val
= WMGetFromPLString(elem
);
1613 /* get from color */
1614 for (i
= 0; i
< 2; i
++) {
1615 elem
= WMGetFromPLArray(pl
, 4 + i
);
1616 if (!elem
|| !WMIsPLString(elem
))
1618 val
= WMGetFromPLString(elem
);
1620 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1621 wwarning(_("\"%s\" is not a valid color name"), val
);
1624 colors2
[i
].alpha
= 255;
1625 colors2
[i
].red
= xcolor
.red
>> 8;
1626 colors2
[i
].green
= xcolor
.green
>> 8;
1627 colors2
[i
].blue
= xcolor
.blue
>> 8;
1629 elem
= WMGetFromPLArray(pl
, 6);
1630 if (!elem
|| !WMIsPLString(elem
))
1632 val
= WMGetFromPLString(elem
);
1635 texture
= (WTexture
*) wTextureMakeIGradient(scr
, th1
, colors1
, th2
, colors2
);
1637 } else if (strcasecmp(val
, "mhgradient") == 0
1638 || strcasecmp(val
, "mvgradient") == 0 || strcasecmp(val
, "mdgradient") == 0) {
1645 wwarning(_("too few arguments in multicolor gradient specification"));
1649 if (val
[1] == 'h' || val
[1] == 'H')
1650 type
= WTEX_MHGRADIENT
;
1651 else if (val
[1] == 'v' || val
[1] == 'V')
1652 type
= WTEX_MVGRADIENT
;
1654 type
= WTEX_MDGRADIENT
;
1658 colors
= wmalloc(sizeof(RColor
*) * (count
+ 1));
1660 for (i
= 0; i
< count
; i
++) {
1661 elem
= WMGetFromPLArray(pl
, i
+ 1);
1662 if (!elem
|| !WMIsPLString(elem
)) {
1663 for (--i
; i
>= 0; --i
) {
1669 val
= WMGetFromPLString(elem
);
1671 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &color
)) {
1672 wwarning(_("\"%s\" is not a valid color name"), val
);
1673 for (--i
; i
>= 0; --i
) {
1679 colors
[i
] = wmalloc(sizeof(RColor
));
1680 colors
[i
]->red
= color
.red
>> 8;
1681 colors
[i
]->green
= color
.green
>> 8;
1682 colors
[i
]->blue
= color
.blue
>> 8;
1687 texture
= (WTexture
*) wTextureMakeMGradient(scr
, type
, colors
);
1688 } else if (strcasecmp(val
, "spixmap") == 0 ||
1689 strcasecmp(val
, "cpixmap") == 0 || strcasecmp(val
, "tpixmap") == 0) {
1696 if (val
[0] == 's' || val
[0] == 'S')
1698 else if (val
[0] == 'c' || val
[0] == 'C')
1704 elem
= WMGetFromPLArray(pl
, 2);
1705 if (!elem
|| !WMIsPLString(elem
)) {
1708 val
= WMGetFromPLString(elem
);
1710 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &color
)) {
1711 wwarning(_("\"%s\" is not a valid color name"), val
);
1716 elem
= WMGetFromPLArray(pl
, 1);
1717 if (!elem
|| !WMIsPLString(elem
))
1719 val
= WMGetFromPLString(elem
);
1721 texture
= (WTexture
*) wTextureMakePixmap(scr
, type
, val
, &color
);
1722 } else if (strcasecmp(val
, "thgradient") == 0
1723 || strcasecmp(val
, "tvgradient") == 0 || strcasecmp(val
, "tdgradient") == 0) {
1724 RColor color1
, color2
;
1729 if (val
[1] == 'h' || val
[1] == 'H')
1730 style
= WTEX_THGRADIENT
;
1731 else if (val
[1] == 'v' || val
[1] == 'V')
1732 style
= WTEX_TVGRADIENT
;
1734 style
= WTEX_TDGRADIENT
;
1737 wwarning(_("bad number of arguments in textured gradient specification"));
1741 /* get from color */
1742 elem
= WMGetFromPLArray(pl
, 3);
1743 if (!elem
|| !WMIsPLString(elem
))
1745 val
= WMGetFromPLString(elem
);
1747 if (!XParseColor(dpy
, scr
->w_colormap
, val
, &xcolor
)) {
1748 wwarning(_("\"%s\" is not a valid color name"), val
);
1752 color1
.red
= xcolor
.red
>> 8;
1753 color1
.green
= xcolor
.green
>> 8;
1754 color1
.blue
= xcolor
.blue
>> 8;
1757 elem
= WMGetFromPLArray(pl
, 4);
1758 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 color2
.red
= xcolor
.red
>> 8;
1769 color2
.green
= xcolor
.green
>> 8;
1770 color2
.blue
= xcolor
.blue
>> 8;
1773 elem
= WMGetFromPLArray(pl
, 2);
1774 if (!elem
|| !WMIsPLString(elem
))
1777 val
= WMGetFromPLString(elem
);
1779 if (!val
|| (opacity
= atoi(val
)) < 0 || opacity
> 255) {
1780 wwarning(_("bad opacity value for tgradient texture \"%s\". Should be [0..255]"), val
);
1785 elem
= WMGetFromPLArray(pl
, 1);
1786 if (!elem
|| !WMIsPLString(elem
))
1788 val
= WMGetFromPLString(elem
);
1790 texture
= (WTexture
*) wTextureMakeTGradient(scr
, style
, &color1
, &color2
, val
, opacity
);
1791 } else if (strcasecmp(val
, "function") == 0) {
1792 /* Leave this in to handle the unlikely case of
1793 * someone actually having function textures configured */
1794 wwarning("function texture support has been removed");
1797 wwarning(_("invalid texture type %s"), val
);
1803 static int getTexture(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1805 static WTexture
*texture
;
1809 if (!WMIsPLArray(value
)) {
1810 wwarning(_("Wrong option format for key \"%s\". Should be %s."), entry
->key
, "Texture");
1812 value
= entry
->plvalue
;
1814 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1820 if (strcmp(entry
->key
, "WidgetColor") == 0 && !changed
) {
1823 pl
= WMGetFromPLArray(value
, 0);
1824 if (!pl
|| !WMIsPLString(pl
) || !WMGetFromPLString(pl
)
1825 || strcasecmp(WMGetFromPLString(pl
), "solid") != 0) {
1826 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1827 entry
->key
, "Solid Texture");
1829 value
= entry
->plvalue
;
1831 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1836 texture
= parse_texture(scr
, value
);
1839 wwarning(_("Error in texture specification for key \"%s\""), entry
->key
);
1841 value
= entry
->plvalue
;
1843 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1853 *(WTexture
**) addr
= texture
;
1858 static int getWSBackground(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1866 if (!WMIsPLArray(value
)) {
1867 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1868 "WorkspaceBack", "Texture or None");
1870 value
= entry
->plvalue
;
1872 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1878 /* only do basic error checking and verify for None texture */
1880 nelem
= WMGetPropListItemCount(value
);
1882 elem
= WMGetFromPLArray(value
, 0);
1883 if (!elem
|| !WMIsPLString(elem
)) {
1884 wwarning(_("Wrong type for workspace background. Should be a texture type."));
1886 value
= entry
->plvalue
;
1888 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1893 val
= WMGetFromPLString(elem
);
1895 if (strcasecmp(val
, "None") == 0)
1898 *ret
= WMRetainPropList(value
);
1904 getWSSpecificBackground(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1911 if (!WMIsPLArray(value
)) {
1912 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
1913 "WorkspaceSpecificBack", "an array of textures");
1915 value
= entry
->plvalue
;
1917 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
1923 /* only do basic error checking and verify for None texture */
1925 nelem
= WMGetPropListItemCount(value
);
1928 elem
= WMGetFromPLArray(value
, nelem
);
1929 if (!elem
|| !WMIsPLArray(elem
)) {
1930 wwarning(_("Wrong type for background of workspace %i. Should be a texture."),
1936 *ret
= WMRetainPropList(value
);
1940 * Kluge to force wmsetbg helper to set the default background.
1941 * If the WorkspaceSpecificBack is changed once wmaker has started,
1942 * the WorkspaceBack won't be sent to the helper, unless the user
1943 * changes it's value too. So, we must force this by removing the
1944 * value from the defaults DB.
1946 if (!scr
->flags
.backimage_helper_launched
&& !scr
->flags
.startup
) {
1947 WMPropList
*key
= WMCreatePLString("WorkspaceBack");
1949 WMRemoveFromPLDictionary(WDWindowMaker
->dictionary
, key
);
1951 WMReleasePropList(key
);
1957 static int getFont(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1959 static WMFont
*font
;
1962 GET_STRING_OR_DEFAULT("Font", val
);
1964 font
= WMCreateFont(scr
->wmscreen
, val
);
1966 font
= WMCreateFont(scr
->wmscreen
, "fixed");
1969 wfatal(_("could not load any usable font!!!"));
1976 /* can't assign font value outside update function */
1977 wassertrv(addr
== NULL
, True
);
1982 static int getColor(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
1984 static XColor color
;
1986 int second_pass
= 0;
1988 GET_STRING_OR_DEFAULT("Color", val
);
1991 if (!wGetColor(scr
, val
, &color
)) {
1992 wwarning(_("could not get color for key \"%s\""), entry
->key
);
1993 if (second_pass
== 0) {
1994 val
= WMGetFromPLString(entry
->plvalue
);
1996 wwarning(_("using default \"%s\" instead"), val
);
2005 assert(addr
== NULL
);
2008 *(unsigned long*)addr = pixel;
2014 static int getKeybind(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
2016 static WShortKey shortcut
;
2020 char buf
[MAX_SHORTCUT_LENGTH
], *b
;
2022 GET_STRING_OR_DEFAULT("Key spec", val
);
2024 if (!val
|| strcasecmp(val
, "NONE") == 0) {
2025 shortcut
.keycode
= 0;
2026 shortcut
.modifier
= 0;
2032 strncpy(buf
, val
, MAX_SHORTCUT_LENGTH
);
2037 shortcut
.modifier
= 0;
2038 while ((k
= strchr(b
, '+')) != NULL
) {
2042 mod
= wXModifierFromKey(b
);
2044 wwarning(_("%s: invalid key modifier \"%s\""), entry
->key
, b
);
2047 shortcut
.modifier
|= mod
;
2053 ksym
= XStringToKeysym(b
);
2055 if (ksym
== NoSymbol
) {
2056 wwarning(_("%s:invalid kbd shortcut specification \"%s\""), entry
->key
, val
);
2060 shortcut
.keycode
= XKeysymToKeycode(dpy
, ksym
);
2061 if (shortcut
.keycode
== 0) {
2062 wwarning(_("%s:invalid key in shortcut \"%s\""), entry
->key
, val
);
2072 static int getModMask(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
2077 GET_STRING_OR_DEFAULT("Modifier Key", str
);
2082 mask
= wXModifierFromKey(str
);
2084 wwarning(_("%s: modifier key %s is not valid"), entry
->key
, str
);
2090 *(int *)addr
= mask
;
2098 # include <X11/cursorfont.h>
2104 #define CURSOR_ID_NONE (XC_num_glyphs)
2106 static WCursorLookup cursor_table
[] = {
2107 {"X_cursor", XC_X_cursor
},
2108 {"arrow", XC_arrow
},
2109 {"based_arrow_down", XC_based_arrow_down
},
2110 {"based_arrow_up", XC_based_arrow_up
},
2112 {"bogosity", XC_bogosity
},
2113 {"bottom_left_corner", XC_bottom_left_corner
},
2114 {"bottom_right_corner", XC_bottom_right_corner
},
2115 {"bottom_side", XC_bottom_side
},
2116 {"bottom_tee", XC_bottom_tee
},
2117 {"box_spiral", XC_box_spiral
},
2118 {"center_ptr", XC_center_ptr
},
2119 {"circle", XC_circle
},
2120 {"clock", XC_clock
},
2121 {"coffee_mug", XC_coffee_mug
},
2122 {"cross", XC_cross
},
2123 {"cross_reverse", XC_cross_reverse
},
2124 {"crosshair", XC_crosshair
},
2125 {"diamond_cross", XC_diamond_cross
},
2127 {"dotbox", XC_dotbox
},
2128 {"double_arrow", XC_double_arrow
},
2129 {"draft_large", XC_draft_large
},
2130 {"draft_small", XC_draft_small
},
2131 {"draped_box", XC_draped_box
},
2132 {"exchange", XC_exchange
},
2133 {"fleur", XC_fleur
},
2134 {"gobbler", XC_gobbler
},
2135 {"gumby", XC_gumby
},
2136 {"hand1", XC_hand1
},
2137 {"hand2", XC_hand2
},
2138 {"heart", XC_heart
},
2140 {"iron_cross", XC_iron_cross
},
2141 {"left_ptr", XC_left_ptr
},
2142 {"left_side", XC_left_side
},
2143 {"left_tee", XC_left_tee
},
2144 {"leftbutton", XC_leftbutton
},
2145 {"ll_angle", XC_ll_angle
},
2146 {"lr_angle", XC_lr_angle
},
2148 {"middlebutton", XC_middlebutton
},
2149 {"mouse", XC_mouse
},
2150 {"pencil", XC_pencil
},
2151 {"pirate", XC_pirate
},
2153 {"question_arrow", XC_question_arrow
},
2154 {"right_ptr", XC_right_ptr
},
2155 {"right_side", XC_right_side
},
2156 {"right_tee", XC_right_tee
},
2157 {"rightbutton", XC_rightbutton
},
2158 {"rtl_logo", XC_rtl_logo
},
2159 {"sailboat", XC_sailboat
},
2160 {"sb_down_arrow", XC_sb_down_arrow
},
2161 {"sb_h_double_arrow", XC_sb_h_double_arrow
},
2162 {"sb_left_arrow", XC_sb_left_arrow
},
2163 {"sb_right_arrow", XC_sb_right_arrow
},
2164 {"sb_up_arrow", XC_sb_up_arrow
},
2165 {"sb_v_double_arrow", XC_sb_v_double_arrow
},
2166 {"shuttle", XC_shuttle
},
2167 {"sizing", XC_sizing
},
2168 {"spider", XC_spider
},
2169 {"spraycan", XC_spraycan
},
2171 {"target", XC_target
},
2172 {"tcross", XC_tcross
},
2173 {"top_left_arrow", XC_top_left_arrow
},
2174 {"top_left_corner", XC_top_left_corner
},
2175 {"top_right_corner", XC_top_right_corner
},
2176 {"top_side", XC_top_side
},
2177 {"top_tee", XC_top_tee
},
2179 {"ul_angle", XC_ul_angle
},
2180 {"umbrella", XC_umbrella
},
2181 {"ur_angle", XC_ur_angle
},
2182 {"watch", XC_watch
},
2183 {"xterm", XC_xterm
},
2184 {NULL
, CURSOR_ID_NONE
}
2187 static void check_bitmap_status(int status
, char *filename
, Pixmap bitmap
)
2190 case BitmapOpenFailed
:
2191 wwarning(_("failed to open bitmap file \"%s\""), filename
);
2193 case BitmapFileInvalid
:
2194 wwarning(_("\"%s\" is not a valid bitmap file"), filename
);
2196 case BitmapNoMemory
:
2197 wwarning(_("out of memory reading bitmap file \"%s\""), filename
);
2200 XFreePixmap(dpy
, bitmap
);
2207 * (builtin, <cursor_name>)
2208 * (bitmap, <cursor_bitmap>, <cursor_mask>)
2210 static int parse_cursor(WScreen
* scr
, WMPropList
* pl
, Cursor
* cursor
)
2217 nelem
= WMGetPropListItemCount(pl
);
2221 elem
= WMGetFromPLArray(pl
, 0);
2222 if (!elem
|| !WMIsPLString(elem
)) {
2225 val
= WMGetFromPLString(elem
);
2227 if (0 == strcasecmp(val
, "none")) {
2230 } else if (0 == strcasecmp(val
, "builtin")) {
2232 int cursor_id
= CURSOR_ID_NONE
;
2235 wwarning(_("bad number of arguments in cursor specification"));
2238 elem
= WMGetFromPLArray(pl
, 1);
2239 if (!elem
|| !WMIsPLString(elem
)) {
2242 val
= WMGetFromPLString(elem
);
2244 for (i
= 0; NULL
!= cursor_table
[i
].name
; i
++) {
2245 if (0 == strcasecmp(val
, cursor_table
[i
].name
)) {
2246 cursor_id
= cursor_table
[i
].id
;
2250 if (CURSOR_ID_NONE
== cursor_id
) {
2251 wwarning(_("unknown builtin cursor name \"%s\""), val
);
2253 *cursor
= XCreateFontCursor(dpy
, cursor_id
);
2256 } else if (0 == strcasecmp(val
, "bitmap")) {
2268 wwarning(_("bad number of arguments in cursor specification"));
2271 elem
= WMGetFromPLArray(pl
, 1);
2272 if (!elem
|| !WMIsPLString(elem
)) {
2275 val
= WMGetFromPLString(elem
);
2276 bitmap_name
= FindImage(wPreferences
.pixmap_path
, val
);
2278 wwarning(_("could not find cursor bitmap file \"%s\""), val
);
2281 elem
= WMGetFromPLArray(pl
, 2);
2282 if (!elem
|| !WMIsPLString(elem
)) {
2286 val
= WMGetFromPLString(elem
);
2287 mask_name
= FindImage(wPreferences
.pixmap_path
, val
);
2290 wwarning(_("could not find cursor bitmap file \"%s\""), val
);
2293 mask_status
= XReadBitmapFile(dpy
, scr
->w_win
, mask_name
, &w
, &h
, &mask
, &x
, &y
);
2294 bitmap_status
= XReadBitmapFile(dpy
, scr
->w_win
, bitmap_name
, &w
, &h
, &bitmap
, &x
, &y
);
2295 if ((BitmapSuccess
== bitmap_status
) && (BitmapSuccess
== mask_status
)) {
2296 fg
.pixel
= scr
->black_pixel
;
2297 bg
.pixel
= scr
->white_pixel
;
2298 XQueryColor(dpy
, scr
->w_colormap
, &fg
);
2299 XQueryColor(dpy
, scr
->w_colormap
, &bg
);
2300 *cursor
= XCreatePixmapCursor(dpy
, bitmap
, mask
, &fg
, &bg
, x
, y
);
2303 check_bitmap_status(bitmap_status
, bitmap_name
, bitmap
);
2304 check_bitmap_status(mask_status
, mask_name
, mask
);
2311 static int getCursor(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *addr
, void **ret
)
2313 static Cursor cursor
;
2318 if (!WMIsPLArray(value
)) {
2319 wwarning(_("Wrong option format for key \"%s\". Should be %s."),
2320 entry
->key
, "cursor specification");
2322 value
= entry
->plvalue
;
2324 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
2329 status
= parse_cursor(scr
, value
, &cursor
);
2331 wwarning(_("Error in cursor specification for key \"%s\""), entry
->key
);
2333 value
= entry
->plvalue
;
2335 wwarning(_("using default \"%s\" instead"), entry
->default_value
);
2344 *(Cursor
*) addr
= cursor
;
2349 #undef CURSOR_ID_NONE
2351 /* ---------------- value setting functions --------------- */
2352 static int setJustify(WScreen
* scr
, WDefaultEntry
* entry
, WTexture
** texture
, void *foo
)
2354 return REFRESH_WINDOW_TITLE_COLOR
;
2357 static int setClearance(WScreen
* scr
, WDefaultEntry
* entry
, void *bar
, void *foo
)
2359 return REFRESH_WINDOW_FONT
| REFRESH_BUTTON_IMAGES
| REFRESH_MENU_TITLE_FONT
| REFRESH_MENU_FONT
;
2362 static int setIfDockPresent(WScreen
* scr
, WDefaultEntry
* entry
, char *flag
, long which
)
2366 wPreferences
.flags
.nodock
= wPreferences
.flags
.nodock
|| *flag
;
2369 wPreferences
.flags
.noclip
= wPreferences
.flags
.noclip
|| *flag
;
2377 static int setStickyIcons(WScreen
* scr
, WDefaultEntry
* entry
, void *bar
, void *foo
)
2379 if (scr
->workspaces
) {
2380 wWorkspaceForceChange(scr
, scr
->current_workspace
);
2381 wArrangeIcons(scr
, False
);
2386 static int setIconTile(WScreen
* scr
, WDefaultEntry
* entry
, WTexture
** texture
, void *foo
)
2392 img
= wTextureRenderImage(*texture
, wPreferences
.icon_size
,
2393 wPreferences
.icon_size
, ((*texture
)->any
.type
& WREL_BORDER_MASK
)
2394 ? WREL_ICON
: WREL_FLAT
);
2396 wwarning(_("could not render texture for icon background"));
2398 wTextureDestroy(scr
, *texture
);
2401 RConvertImage(scr
->rcontext
, img
, &pixmap
);
2403 if (scr
->icon_tile
) {
2405 RReleaseImage(scr
->icon_tile
);
2406 XFreePixmap(dpy
, scr
->icon_tile_pixmap
);
2409 scr
->icon_tile
= img
;
2411 /* put the icon in the noticeboard hint */
2412 PropSetIconTileHint(scr
, img
);
2414 if (!wPreferences
.flags
.noclip
) {
2415 if (scr
->clip_tile
) {
2416 RReleaseImage(scr
->clip_tile
);
2418 scr
->clip_tile
= wClipMakeTile(scr
, img
);
2421 scr
->icon_tile_pixmap
= pixmap
;
2423 if (scr
->def_icon_pixmap
) {
2424 XFreePixmap(dpy
, scr
->def_icon_pixmap
);
2425 scr
->def_icon_pixmap
= None
;
2427 if (scr
->def_ticon_pixmap
) {
2428 XFreePixmap(dpy
, scr
->def_ticon_pixmap
);
2429 scr
->def_ticon_pixmap
= None
;
2432 if (scr
->icon_back_texture
) {
2433 wTextureDestroy(scr
, (WTexture
*) scr
->icon_back_texture
);
2435 scr
->icon_back_texture
= wTextureMakeSolid(scr
, &((*texture
)->any
.color
));
2437 if (scr
->clip_balloon
)
2438 XSetWindowBackground(dpy
, scr
->clip_balloon
, (*texture
)->any
.color
.pixel
);
2441 * Free the texture as nobody else will use it, nor refer to it.
2444 wTextureDestroy(scr
, *texture
);
2446 return (reset
? REFRESH_ICON_TILE
: 0);
2449 static int setWinTitleFont(WScreen
* scr
, WDefaultEntry
* entry
, WMFont
* font
, void *foo
)
2451 if (scr
->title_font
) {
2452 WMReleaseFont(scr
->title_font
);
2454 scr
->title_font
= font
;
2456 return REFRESH_WINDOW_FONT
| REFRESH_BUTTON_IMAGES
;
2459 static int setMenuTitleFont(WScreen
* scr
, WDefaultEntry
* entry
, WMFont
* font
, void *foo
)
2461 if (scr
->menu_title_font
) {
2462 WMReleaseFont(scr
->menu_title_font
);
2465 scr
->menu_title_font
= font
;
2467 return REFRESH_MENU_TITLE_FONT
;
2470 static int setMenuTextFont(WScreen
* scr
, WDefaultEntry
* entry
, WMFont
* font
, void *foo
)
2472 if (scr
->menu_entry_font
) {
2473 WMReleaseFont(scr
->menu_entry_font
);
2475 scr
->menu_entry_font
= font
;
2477 return REFRESH_MENU_FONT
;
2480 static int setIconTitleFont(WScreen
* scr
, WDefaultEntry
* entry
, WMFont
* font
, void *foo
)
2482 if (scr
->icon_title_font
) {
2483 WMReleaseFont(scr
->icon_title_font
);
2486 scr
->icon_title_font
= font
;
2488 return REFRESH_ICON_FONT
;
2491 static int setClipTitleFont(WScreen
* scr
, WDefaultEntry
* entry
, WMFont
* font
, void *foo
)
2493 if (scr
->clip_title_font
) {
2494 WMReleaseFont(scr
->clip_title_font
);
2497 scr
->clip_title_font
= font
;
2499 return REFRESH_ICON_FONT
;
2502 static int setLargeDisplayFont(WScreen
* scr
, WDefaultEntry
* entry
, WMFont
* font
, void *foo
)
2504 if (scr
->workspace_name_font
) {
2505 WMReleaseFont(scr
->workspace_name_font
);
2508 scr
->workspace_name_font
= font
;
2513 static int setHightlight(WScreen
* scr
, WDefaultEntry
* entry
, XColor
* color
, void *foo
)
2515 if (scr
->select_color
)
2516 WMReleaseColor(scr
->select_color
);
2518 scr
->select_color
= WMCreateRGBColor(scr
->wmscreen
, color
->red
, color
->green
, color
->blue
, True
);
2520 wFreeColor(scr
, color
->pixel
);
2522 return REFRESH_MENU_COLOR
;
2525 static int setHightlightText(WScreen
* scr
, WDefaultEntry
* entry
, XColor
* color
, void *foo
)
2527 if (scr
->select_text_color
)
2528 WMReleaseColor(scr
->select_text_color
);
2530 scr
->select_text_color
= WMCreateRGBColor(scr
->wmscreen
, color
->red
, color
->green
, color
->blue
, True
);
2532 wFreeColor(scr
, color
->pixel
);
2534 return REFRESH_MENU_COLOR
;
2537 static int setClipTitleColor(WScreen
* scr
, WDefaultEntry
* entry
, XColor
* color
, long widx
)
2539 if (scr
->clip_title_color
[widx
])
2540 WMReleaseColor(scr
->clip_title_color
[widx
]);
2541 scr
->clip_title_color
[widx
] = WMCreateRGBColor(scr
->wmscreen
, color
->red
, color
->green
, color
->blue
, True
);
2542 #ifdef GRADIENT_CLIP_ARROW
2543 if (widx
== CLIP_NORMAL
) {
2545 RColor color1
, color2
;
2546 int pt
= CLIP_BUTTON_SIZE
* wPreferences
.icon_size
/ 64;
2547 int as
= pt
- 15; /* 15 = 5+5+5 */
2549 FREE_PIXMAP(scr
->clip_arrow_gradient
);
2551 color1
.red
= (color
->red
>> 8) * 6 / 10;
2552 color1
.green
= (color
->green
>> 8) * 6 / 10;
2553 color1
.blue
= (color
->blue
>> 8) * 6 / 10;
2555 color2
.red
= WMIN((color
->red
>> 8) * 20 / 10, 255);
2556 color2
.green
= WMIN((color
->green
>> 8) * 20 / 10, 255);
2557 color2
.blue
= WMIN((color
->blue
>> 8) * 20 / 10, 255);
2559 image
= RRenderGradient(as
+ 1, as
+ 1, &color1
, &color2
, RDiagonalGradient
);
2560 RConvertImage(scr
->rcontext
, image
, &scr
->clip_arrow_gradient
);
2561 RReleaseImage(image
);
2563 #endif /* GRADIENT_CLIP_ARROW */
2565 wFreeColor(scr
, color
->pixel
);
2567 return REFRESH_ICON_TITLE_COLOR
;
2570 static int setWTitleColor(WScreen
* scr
, WDefaultEntry
* entry
, XColor
* color
, long widx
)
2572 if (scr
->window_title_color
[widx
])
2573 WMReleaseColor(scr
->window_title_color
[widx
]);
2575 scr
->window_title_color
[widx
] =
2576 WMCreateRGBColor(scr
->wmscreen
, color
->red
, color
->green
, color
->blue
, True
);
2578 wFreeColor(scr
, color
->pixel
);
2580 return REFRESH_WINDOW_TITLE_COLOR
;
2583 static int setMenuTitleColor(WScreen
* scr
, WDefaultEntry
* entry
, XColor
* color
, long widx
)
2585 if (scr
->menu_title_color
[0])
2586 WMReleaseColor(scr
->menu_title_color
[0]);
2588 scr
->menu_title_color
[0] = WMCreateRGBColor(scr
->wmscreen
, color
->red
, color
->green
, color
->blue
, True
);
2590 wFreeColor(scr
, color
->pixel
);
2592 return REFRESH_MENU_TITLE_COLOR
;
2595 static int setMenuTextColor(WScreen
* scr
, WDefaultEntry
* entry
, XColor
* color
, void *foo
)
2597 if (scr
->mtext_color
)
2598 WMReleaseColor(scr
->mtext_color
);
2600 scr
->mtext_color
= WMCreateRGBColor(scr
->wmscreen
, color
->red
, color
->green
, color
->blue
, True
);
2602 if (WMColorPixel(scr
->dtext_color
) == WMColorPixel(scr
->mtext_color
)) {
2603 WMSetColorAlpha(scr
->dtext_color
, 0x7fff);
2605 WMSetColorAlpha(scr
->dtext_color
, 0xffff);
2608 wFreeColor(scr
, color
->pixel
);
2610 return REFRESH_MENU_COLOR
;
2613 static int setMenuDisabledColor(WScreen
* scr
, WDefaultEntry
* entry
, XColor
* color
, void *foo
)
2615 if (scr
->dtext_color
)
2616 WMReleaseColor(scr
->dtext_color
);
2618 scr
->dtext_color
= WMCreateRGBColor(scr
->wmscreen
, color
->red
, color
->green
, color
->blue
, True
);
2620 if (WMColorPixel(scr
->dtext_color
) == WMColorPixel(scr
->mtext_color
)) {
2621 WMSetColorAlpha(scr
->dtext_color
, 0x7fff);
2623 WMSetColorAlpha(scr
->dtext_color
, 0xffff);
2626 wFreeColor(scr
, color
->pixel
);
2628 return REFRESH_MENU_COLOR
;
2631 static int setIconTitleColor(WScreen
* scr
, WDefaultEntry
* entry
, XColor
* color
, void *foo
)
2633 if (scr
->icon_title_color
)
2634 WMReleaseColor(scr
->icon_title_color
);
2635 scr
->icon_title_color
= WMCreateRGBColor(scr
->wmscreen
, color
->red
, color
->green
, color
->blue
, True
);
2637 wFreeColor(scr
, color
->pixel
);
2639 return REFRESH_ICON_TITLE_COLOR
;
2642 static int setIconTitleBack(WScreen
* scr
, WDefaultEntry
* entry
, XColor
* color
, void *foo
)
2644 if (scr
->icon_title_texture
) {
2645 wTextureDestroy(scr
, (WTexture
*) scr
->icon_title_texture
);
2647 scr
->icon_title_texture
= wTextureMakeSolid(scr
, color
);
2649 return REFRESH_ICON_TITLE_BACK
;
2652 static void trackDeadProcess(pid_t pid
, unsigned char status
, WScreen
* scr
)
2654 close(scr
->helper_fd
);
2656 scr
->helper_pid
= 0;
2657 scr
->flags
.backimage_helper_launched
= 0;
2660 static int setWorkspaceSpecificBack(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *bar
)
2666 if (scr
->flags
.backimage_helper_launched
) {
2667 if (WMGetPropListItemCount(value
) == 0) {
2668 SendHelperMessage(scr
, 'C', 0, NULL
);
2669 SendHelperMessage(scr
, 'K', 0, NULL
);
2671 WMReleasePropList(value
);
2678 if (WMGetPropListItemCount(value
) == 0)
2681 if (pipe(filedes
) < 0) {
2682 wsyserror("pipe() failed:can't set workspace specific background image");
2684 WMReleasePropList(value
);
2690 wsyserror("fork() failed:can't set workspace specific background image");
2691 if (close(filedes
[0]) < 0)
2692 wsyserror("could not close pipe");
2693 if (close(filedes
[1]) < 0)
2694 wsyserror("could not close pipe");
2696 } else if (pid
== 0) {
2699 SetupEnvironment(scr
);
2702 wsyserror("could not close pipe");
2703 if (dup(filedes
[0]) < 0) {
2704 wsyserror("dup() failed:can't set workspace specific background image");
2706 dither
= wPreferences
.no_dithering
? "-m" : "-d";
2707 if (wPreferences
.smooth_workspace_back
)
2708 execlp("wmsetbg", "wmsetbg", "-helper", "-S", dither
, NULL
);
2710 execlp("wmsetbg", "wmsetbg", "-helper", dither
, NULL
);
2711 wsyserror("could not execute wmsetbg");
2715 if (fcntl(filedes
[0], F_SETFD
, FD_CLOEXEC
) < 0) {
2716 wsyserror("error setting close-on-exec flag");
2718 if (fcntl(filedes
[1], F_SETFD
, FD_CLOEXEC
) < 0) {
2719 wsyserror("error setting close-on-exec flag");
2722 scr
->helper_fd
= filedes
[1];
2723 scr
->helper_pid
= pid
;
2724 scr
->flags
.backimage_helper_launched
= 1;
2726 wAddDeathHandler(pid
, (WDeathHandler
*) trackDeadProcess
, scr
);
2728 SendHelperMessage(scr
, 'P', -1, wPreferences
.pixmap_path
);
2733 for (i
= 0; i
< WMGetPropListItemCount(value
); i
++) {
2734 val
= WMGetFromPLArray(value
, i
);
2735 if (val
&& WMIsPLArray(val
) && WMGetPropListItemCount(val
) > 0) {
2736 str
= WMGetPropListDescription(val
, False
);
2738 SendHelperMessage(scr
, 'S', i
+ 1, str
);
2742 SendHelperMessage(scr
, 'U', i
+ 1, NULL
);
2747 WMReleasePropList(value
);
2751 static int setWorkspaceBack(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* value
, void *bar
)
2753 if (scr
->flags
.backimage_helper_launched
) {
2756 if (WMGetPropListItemCount(value
) == 0) {
2757 SendHelperMessage(scr
, 'U', 0, NULL
);
2759 /* set the default workspace background to this one */
2760 str
= WMGetPropListDescription(value
, False
);
2762 SendHelperMessage(scr
, 'S', 0, str
);
2764 SendHelperMessage(scr
, 'C', scr
->current_workspace
+ 1, NULL
);
2766 SendHelperMessage(scr
, 'U', 0, NULL
);
2769 } else if (WMGetPropListItemCount(value
) > 0) {
2775 text
= WMGetPropListDescription(value
, False
);
2776 len
= strlen(text
) + 40;
2777 command
= wmalloc(len
);
2778 dither
= wPreferences
.no_dithering
? "-m" : "-d";
2779 if (wPreferences
.smooth_workspace_back
)
2780 snprintf(command
, len
, "wmsetbg %s -S -p '%s' &", dither
, text
);
2782 snprintf(command
, len
, "wmsetbg %s -p '%s' &", dither
, text
);
2784 ExecuteShellCommand(scr
, command
);
2787 WMReleasePropList(value
);
2792 static int setWidgetColor(WScreen
* scr
, WDefaultEntry
* entry
, WTexture
** texture
, void *foo
)
2794 if (scr
->widget_texture
) {
2795 wTextureDestroy(scr
, (WTexture
*) scr
->widget_texture
);
2797 scr
->widget_texture
= *(WTexSolid
**) texture
;
2802 static int setFTitleBack(WScreen
* scr
, WDefaultEntry
* entry
, WTexture
** texture
, void *foo
)
2804 if (scr
->window_title_texture
[WS_FOCUSED
]) {
2805 wTextureDestroy(scr
, scr
->window_title_texture
[WS_FOCUSED
]);
2807 scr
->window_title_texture
[WS_FOCUSED
] = *texture
;
2809 return REFRESH_WINDOW_TEXTURES
;
2812 static int setPTitleBack(WScreen
* scr
, WDefaultEntry
* entry
, WTexture
** texture
, void *foo
)
2814 if (scr
->window_title_texture
[WS_PFOCUSED
]) {
2815 wTextureDestroy(scr
, scr
->window_title_texture
[WS_PFOCUSED
]);
2817 scr
->window_title_texture
[WS_PFOCUSED
] = *texture
;
2819 return REFRESH_WINDOW_TEXTURES
;
2822 static int setUTitleBack(WScreen
* scr
, WDefaultEntry
* entry
, WTexture
** texture
, void *foo
)
2824 if (scr
->window_title_texture
[WS_UNFOCUSED
]) {
2825 wTextureDestroy(scr
, scr
->window_title_texture
[WS_UNFOCUSED
]);
2827 scr
->window_title_texture
[WS_UNFOCUSED
] = *texture
;
2829 return REFRESH_WINDOW_TEXTURES
;
2832 static int setResizebarBack(WScreen
* scr
, WDefaultEntry
* entry
, WTexture
** texture
, void *foo
)
2834 if (scr
->resizebar_texture
[0]) {
2835 wTextureDestroy(scr
, scr
->resizebar_texture
[0]);
2837 scr
->resizebar_texture
[0] = *texture
;
2839 return REFRESH_WINDOW_TEXTURES
;
2842 static int setMenuTitleBack(WScreen
* scr
, WDefaultEntry
* entry
, WTexture
** texture
, void *foo
)
2844 if (scr
->menu_title_texture
[0]) {
2845 wTextureDestroy(scr
, scr
->menu_title_texture
[0]);
2847 scr
->menu_title_texture
[0] = *texture
;
2849 return REFRESH_MENU_TITLE_TEXTURE
;
2852 static int setMenuTextBack(WScreen
* scr
, WDefaultEntry
* entry
, WTexture
** texture
, void *foo
)
2854 if (scr
->menu_item_texture
) {
2855 wTextureDestroy(scr
, scr
->menu_item_texture
);
2856 wTextureDestroy(scr
, (WTexture
*) scr
->menu_item_auxtexture
);
2858 scr
->menu_item_texture
= *texture
;
2860 scr
->menu_item_auxtexture
= wTextureMakeSolid(scr
, &scr
->menu_item_texture
->any
.color
);
2862 return REFRESH_MENU_TEXTURE
;
2865 static int setKeyGrab(WScreen
* scr
, WDefaultEntry
* entry
, WShortKey
* shortcut
, long widx
)
2868 wKeyBindings
[widx
] = *shortcut
;
2870 wwin
= scr
->focused_window
;
2872 while (wwin
!= NULL
) {
2873 XUngrabKey(dpy
, AnyKey
, AnyModifier
, wwin
->frame
->core
->window
);
2875 if (!WFLAGP(wwin
, no_bind_keys
)) {
2876 wWindowSetKeyGrabs(wwin
);
2884 static int setIconPosition(WScreen
* scr
, WDefaultEntry
* entry
, void *bar
, void *foo
)
2886 wScreenUpdateUsableArea(scr
);
2887 wArrangeIcons(scr
, True
);
2892 static int updateUsableArea(WScreen
* scr
, WDefaultEntry
* entry
, void *bar
, void *foo
)
2894 wScreenUpdateUsableArea(scr
);
2899 static int setMenuStyle(WScreen
* scr
, WDefaultEntry
* entry
, int *value
, void *foo
)
2901 return REFRESH_MENU_TEXTURE
;
2904 static RImage
*chopOffImage(RImage
* image
, int x
, int y
, int w
, int h
)
2906 RImage
*img
= RCreateImage(w
, h
, image
->format
== RRGBAFormat
);
2908 RCopyArea(img
, image
, x
, y
, w
, h
, 0, 0);
2913 static int setSwPOptions(WScreen
* scr
, WDefaultEntry
* entry
, WMPropList
* array
, void *foo
)
2917 int cwidth
, cheight
;
2918 WPreferences
*prefs
= (WPreferences
*) foo
;
2920 if (!WMIsPLArray(array
) || WMGetPropListItemCount(array
) == 0) {
2921 if (prefs
->swtileImage
)
2922 RReleaseImage(prefs
->swtileImage
);
2923 prefs
->swtileImage
= NULL
;
2925 WMReleasePropList(array
);
2929 switch (WMGetPropListItemCount(array
)) {
2931 if (!WMIsPLString(WMGetFromPLArray(array
, 1))) {
2932 wwarning(_("Invalid arguments for option \"%s\""), entry
->key
);
2935 path
= FindImage(wPreferences
.pixmap_path
, WMGetFromPLString(WMGetFromPLArray(array
, 1)));
2938 wwarning(_("Could not find image \"%s\" for option \"%s\""),
2939 WMGetFromPLString(WMGetFromPLArray(array
, 1)), entry
->key
);
2941 bgimage
= RLoadImage(scr
->rcontext
, path
, 0);
2943 wwarning(_("Could not load image \"%s\" for option \"%s\""), path
, entry
->key
);
2948 cwidth
= atoi(WMGetFromPLString(WMGetFromPLArray(array
, 2)));
2949 cheight
= atoi(WMGetFromPLString(WMGetFromPLArray(array
, 3)));
2951 if (cwidth
<= 0 || cheight
<= 0 ||
2952 cwidth
>= bgimage
->width
- 2 || cheight
>= bgimage
->height
- 2)
2953 wwarning(_("Invalid split sizes for SwitchPanel back image."));
2956 int swidth
, theight
;
2957 for (i
= 0; i
< 9; i
++) {
2958 if (prefs
->swbackImage
[i
])
2959 RReleaseImage(prefs
->swbackImage
[i
]);
2960 prefs
->swbackImage
[i
] = NULL
;
2962 swidth
= (bgimage
->width
- cwidth
) / 2;
2963 theight
= (bgimage
->height
- cheight
) / 2;
2965 prefs
->swbackImage
[0] = chopOffImage(bgimage
, 0, 0, swidth
, theight
);
2966 prefs
->swbackImage
[1] = chopOffImage(bgimage
, swidth
, 0, cwidth
, theight
);
2967 prefs
->swbackImage
[2] = chopOffImage(bgimage
, swidth
+ cwidth
, 0,
2970 prefs
->swbackImage
[3] = chopOffImage(bgimage
, 0, theight
, swidth
, cheight
);
2971 prefs
->swbackImage
[4] = chopOffImage(bgimage
, swidth
, theight
,
2973 prefs
->swbackImage
[5] = chopOffImage(bgimage
, swidth
+ cwidth
, theight
,
2976 prefs
->swbackImage
[6] = chopOffImage(bgimage
, 0, theight
+ cheight
,
2978 prefs
->swbackImage
[7] = chopOffImage(bgimage
, swidth
, theight
+ cheight
,
2980 prefs
->swbackImage
[8] =
2981 chopOffImage(bgimage
, swidth
+ cwidth
, theight
+ cheight
, swidth
,
2984 // check if anything failed
2985 for (i
= 0; i
< 9; i
++) {
2986 if (!prefs
->swbackImage
[i
]) {
2987 for (; i
>= 0; --i
) {
2988 RReleaseImage(prefs
->swbackImage
[i
]);
2989 prefs
->swbackImage
[i
] = NULL
;
2995 RReleaseImage(bgimage
);
3000 if (!WMIsPLString(WMGetFromPLArray(array
, 0))) {
3001 wwarning(_("Invalid arguments for option \"%s\""), entry
->key
);
3004 path
= FindImage(wPreferences
.pixmap_path
, WMGetFromPLString(WMGetFromPLArray(array
, 0)));
3007 wwarning(_("Could not find image \"%s\" for option \"%s\""),
3008 WMGetFromPLString(WMGetFromPLArray(array
, 0)), entry
->key
);
3010 if (prefs
->swtileImage
)
3011 RReleaseImage(prefs
->swtileImage
);
3013 prefs
->swtileImage
= RLoadImage(scr
->rcontext
, path
, 0);
3014 if (!prefs
->swtileImage
) {
3015 wwarning(_("Could not load image \"%s\" for option \"%s\""), path
, entry
->key
);
3022 wwarning(_("Invalid number of arguments for option \"%s\""), entry
->key
);
3026 WMReleasePropList(array
);
3033 * Need access to the double click variables, so that all widgets in
3034 * wmaker panels will have the same dbl-click values.
3035 * TODO: figure a better way of dealing with it.
3037 #include <WINGs/WINGsP.h>
3039 static int setDoubleClick(WScreen
* scr
, WDefaultEntry
* entry
, int *value
, void *foo
)
3041 extern _WINGsConfiguration WINGsConfiguration
;
3046 WINGsConfiguration
.doubleClickDelay
= *value
;
3051 static int setCursor(WScreen
* scr
, WDefaultEntry
* entry
, Cursor
* cursor
, long widx
)
3053 if (wCursor
[widx
] != None
) {
3054 XFreeCursor(dpy
, wCursor
[widx
]);
3057 wCursor
[widx
] = *cursor
;
3059 if (widx
== WCUR_ROOT
&& *cursor
!= None
) {
3060 XDefineCursor(dpy
, scr
->root_win
, *cursor
);