1 /* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
3 config.c for the Openbox window manager
4 Copyright (c) 2006 Mikael Magnusson
5 Copyright (c) 2003-2007 Dana Jansens
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 See the COPYING file for a copy of the GNU General Public License.
24 #include "translate.h"
29 #include "obt/paths.h"
31 gboolean config_focus_new
;
32 gboolean config_focus_follow
;
33 guint config_focus_delay
;
34 gboolean config_focus_raise
;
35 gboolean config_focus_last
;
36 gboolean config_focus_under_mouse
;
38 ObPlacePolicy config_place_policy
;
39 gboolean config_place_center
;
40 ObPlaceMonitor config_place_monitor
;
42 StrutPartial config_margins
;
45 gboolean config_theme_keepborder
;
46 guint config_theme_window_list_icon_size
;
48 gchar
*config_title_layout
;
50 gboolean config_animate_iconify
;
52 RrFont
*config_font_activewindow
;
53 RrFont
*config_font_inactivewindow
;
54 RrFont
*config_font_menuitem
;
55 RrFont
*config_font_menutitle
;
56 RrFont
*config_font_osd
;
58 guint config_desktops_num
;
59 GSList
*config_desktops_names
;
60 guint config_screen_firstdesk
;
61 guint config_desktop_popup_time
;
63 gboolean config_resize_redraw
;
64 gint config_resize_popup_show
;
65 ObResizePopupPos config_resize_popup_pos
;
66 GravityPoint config_resize_popup_fixed
;
68 ObStackingLayer config_dock_layer
;
69 gboolean config_dock_floating
;
70 gboolean config_dock_nostrut
;
71 ObDirection config_dock_pos
;
74 ObOrientation config_dock_orient
;
75 gboolean config_dock_hide
;
76 guint config_dock_hide_delay
;
77 guint config_dock_show_delay
;
78 guint config_dock_app_move_button
;
79 guint config_dock_app_move_modifiers
;
81 guint config_keyboard_reset_keycode
;
82 guint config_keyboard_reset_state
;
84 gint config_mouse_threshold
;
85 gint config_mouse_dclicktime
;
86 gint config_mouse_screenedgetime
;
88 guint config_menu_hide_delay
;
89 gboolean config_menu_middle
;
90 guint config_submenu_show_delay
;
91 gboolean config_menu_client_list_icons
;
92 gboolean config_menu_manage_desktops
;
94 GSList
*config_menu_files
;
96 gint config_resist_win
;
97 gint config_resist_edge
;
99 GSList
*config_per_app_settings
;
101 ObAppSettings
* config_create_app_settings(void)
103 ObAppSettings
*settings
= g_new0(ObAppSettings
, 1);
105 settings
->decor
= -1;
106 settings
->shade
= -1;
107 settings
->monitor
= -1;
108 settings
->focus
= -1;
109 settings
->desktop
= 0;
110 settings
->layer
= -2;
111 settings
->iconic
= -1;
112 settings
->skip_pager
= -1;
113 settings
->skip_taskbar
= -1;
114 settings
->fullscreen
= -1;
115 settings
->max_horz
= -1;
116 settings
->max_vert
= -1;
120 #define copy_if(setting, default) \
121 if (src->setting != default) dst->setting = src->setting
122 void config_app_settings_copy_non_defaults(const ObAppSettings
*src
,
125 g_assert(src
!= NULL
);
126 g_assert(dst
!= NULL
);
128 copy_if(type
, (ObClientType
)-1);
131 copy_if(monitor
, -1);
136 copy_if(skip_pager
, -1);
137 copy_if(skip_taskbar
, -1);
138 copy_if(fullscreen
, -1);
139 copy_if(max_horz
, -1);
140 copy_if(max_vert
, -1);
142 if (src
->pos_given
) {
143 dst
->pos_given
= TRUE
;
144 dst
->pos_force
= src
->pos_force
;
145 dst
->position
= src
->position
;
146 dst
->monitor
= src
->monitor
;
150 static void config_parse_gravity_coord(xmlNodePtr node
, GravityCoord
*c
)
152 gchar
*s
= obt_parse_node_string(node
);
153 if (!g_ascii_strcasecmp(s
, "center"))
158 if (s
[0] == '-' || s
[0] == '+')
168 <application name="aterm">
171 <application name="Rhythmbox">
178 .. there is a lot more settings available
183 /* Manages settings for individual applications.
184 Some notes: monitor is the screen number in a multi monitor
185 (Xinerama) setup (starting from 0) or mouse, meaning the
186 monitor the pointer is on. Default: mouse.
187 Layer can be three values, above (Always on top), below
188 (Always on bottom) and everything else (normal behaviour).
189 Positions can be an integer value or center, which will
190 center the window in the specified axis. Position is within
191 the monitor, so <position><x>center</x></position><monitor>2</monitor>
192 will center the window on the second monitor.
194 static void parse_per_app_settings(xmlNodePtr node
, gpointer d
)
196 xmlNodePtr app
= obt_parse_find_node(node
->children
, "application");
197 gchar
*name
= NULL
, *class = NULL
, *role
= NULL
, *type
= NULL
;
198 gboolean name_set
, class_set
, type_set
;
199 gboolean x_pos_given
;
204 class_set
= obt_parse_attr_string(app
, "class", &class);
205 name_set
= obt_parse_attr_string(app
, "name", &name
);
206 type_set
= obt_parse_attr_string(app
, "type", &type
);
207 if (class_set
|| name_set
) {
209 ObAppSettings
*settings
= config_create_app_settings();;
212 settings
->name
= g_pattern_spec_new(name
);
215 settings
->class = g_pattern_spec_new(class);
218 if (!g_ascii_strcasecmp(type
, "normal"))
219 settings
->type
= OB_CLIENT_TYPE_NORMAL
;
220 else if (!g_ascii_strcasecmp(type
, "dialog"))
221 settings
->type
= OB_CLIENT_TYPE_DIALOG
;
222 else if (!g_ascii_strcasecmp(type
, "splash"))
223 settings
->type
= OB_CLIENT_TYPE_SPLASH
;
224 else if (!g_ascii_strcasecmp(type
, "utility"))
225 settings
->type
= OB_CLIENT_TYPE_UTILITY
;
226 else if (!g_ascii_strcasecmp(type
, "menu"))
227 settings
->type
= OB_CLIENT_TYPE_MENU
;
228 else if (!g_ascii_strcasecmp(type
, "toolbar"))
229 settings
->type
= OB_CLIENT_TYPE_TOOLBAR
;
230 else if (!g_ascii_strcasecmp(type
, "dock"))
231 settings
->type
= OB_CLIENT_TYPE_DOCK
;
232 else if (!g_ascii_strcasecmp(type
, "desktop"))
233 settings
->type
= OB_CLIENT_TYPE_DESKTOP
;
236 if (obt_parse_attr_string(app
, "role", &role
))
237 settings
->role
= g_pattern_spec_new(role
);
239 if ((n
= obt_parse_find_node(app
->children
, "decor")))
240 if (!obt_parse_node_contains(n
, "default"))
241 settings
->decor
= obt_parse_node_bool(n
);
243 if ((n
= obt_parse_find_node(app
->children
, "shade")))
244 if (!obt_parse_node_contains(n
, "default"))
245 settings
->shade
= obt_parse_node_bool(n
);
247 if ((n
= obt_parse_find_node(app
->children
, "position"))) {
248 if ((c
= obt_parse_find_node(n
->children
, "x")))
249 if (!obt_parse_node_contains(c
, "default")) {
250 config_parse_gravity_coord(c
, &settings
->position
.x
);
254 if (x_pos_given
&& (c
= obt_parse_find_node(n
->children
, "y")))
255 if (!obt_parse_node_contains(c
, "default")) {
256 config_parse_gravity_coord(c
, &settings
->position
.y
);
257 settings
->pos_given
= TRUE
;
260 if (settings
->pos_given
&&
261 (c
= obt_parse_find_node(n
->children
, "monitor")))
262 if (!obt_parse_node_contains(c
, "default")) {
263 gchar
*s
= obt_parse_node_string(c
);
264 if (!g_ascii_strcasecmp(s
, "mouse"))
265 settings
->monitor
= 0;
267 settings
->monitor
= obt_parse_node_int(c
);
271 obt_parse_attr_bool(n
, "force", &settings
->pos_force
);
274 if ((n
= obt_parse_find_node(app
->children
, "focus")))
275 if (!obt_parse_node_contains(n
, "default"))
276 settings
->focus
= obt_parse_node_bool(n
);
278 if ((n
= obt_parse_find_node(app
->children
, "desktop"))) {
279 if (!obt_parse_node_contains(n
, "default")) {
280 gchar
*s
= obt_parse_node_string(n
);
281 if (!g_ascii_strcasecmp(s
, "all"))
282 settings
->desktop
= DESKTOP_ALL
;
284 gint i
= obt_parse_node_int(n
);
286 settings
->desktop
= i
;
292 if ((n
= obt_parse_find_node(app
->children
, "layer")))
293 if (!obt_parse_node_contains(n
, "default")) {
294 gchar
*s
= obt_parse_node_string(n
);
295 if (!g_ascii_strcasecmp(s
, "above"))
297 else if (!g_ascii_strcasecmp(s
, "below"))
298 settings
->layer
= -1;
304 if ((n
= obt_parse_find_node(app
->children
, "iconic")))
305 if (!obt_parse_node_contains(n
, "default"))
306 settings
->iconic
= obt_parse_node_bool(n
);
308 if ((n
= obt_parse_find_node(app
->children
, "skip_pager")))
309 if (!obt_parse_node_contains(n
, "default"))
310 settings
->skip_pager
= obt_parse_node_bool(n
);
312 if ((n
= obt_parse_find_node(app
->children
, "skip_taskbar")))
313 if (!obt_parse_node_contains(n
, "default"))
314 settings
->skip_taskbar
= obt_parse_node_bool(n
);
316 if ((n
= obt_parse_find_node(app
->children
, "fullscreen")))
317 if (!obt_parse_node_contains(n
, "default"))
318 settings
->fullscreen
= obt_parse_node_bool(n
);
320 if ((n
= obt_parse_find_node(app
->children
, "maximized")))
321 if (!obt_parse_node_contains(n
, "default")) {
322 gchar
*s
= obt_parse_node_string(n
);
323 if (!g_ascii_strcasecmp(s
, "horizontal")) {
324 settings
->max_horz
= TRUE
;
325 settings
->max_vert
= FALSE
;
326 } else if (!g_ascii_strcasecmp(s
, "vertical")) {
327 settings
->max_horz
= FALSE
;
328 settings
->max_vert
= TRUE
;
330 settings
->max_horz
= settings
->max_vert
=
331 obt_parse_node_bool(n
);
335 config_per_app_settings
= g_slist_append(config_per_app_settings
,
336 (gpointer
) settings
);
340 name
= class = role
= NULL
;
343 app
= obt_parse_find_node(app
->next
, "application");
350 <action name="ChangeDesktop">
357 static void parse_key(xmlNodePtr node
, GList
*keylist
)
361 gboolean is_chroot
= FALSE
;
363 if (!obt_parse_attr_string(node
, "key", &key
))
366 obt_parse_attr_bool(node
, "chroot", &is_chroot
);
368 keylist
= g_list_append(keylist
, key
);
370 if ((n
= obt_parse_find_node(node
->children
, "keybind"))) {
372 parse_key(n
, keylist
);
373 n
= obt_parse_find_node(n
->next
, "keybind");
376 else if ((n
= obt_parse_find_node(node
->children
, "action"))) {
378 ObActionsAct
*action
;
380 action
= actions_parse(n
);
382 keyboard_bind(keylist
, action
);
383 n
= obt_parse_find_node(n
->next
, "action");
388 keyboard_chroot(keylist
);
391 keylist
= g_list_delete_link(keylist
, g_list_last(keylist
));
394 static void parse_keyboard(xmlNodePtr node
, gpointer d
)
399 keyboard_unbind_all();
401 if ((n
= obt_parse_find_node(node
->children
, "chainQuitKey"))) {
402 key
= obt_parse_node_string(n
);
403 translate_key(key
, &config_keyboard_reset_state
,
404 &config_keyboard_reset_keycode
);
408 if ((n
= obt_parse_find_node(node
->children
, "keybind")))
411 n
= obt_parse_find_node(n
->next
, "keybind");
417 <context name="Titlebar">
418 <mousebind button="Left" action="Press">
419 <action name="Raise"></action>
425 static void parse_mouse(xmlNodePtr node
, gpointer d
)
427 xmlNodePtr n
, nbut
, nact
;
434 node
= node
->children
;
436 if ((n
= obt_parse_find_node(node
, "dragThreshold")))
437 config_mouse_threshold
= obt_parse_node_int(n
);
438 if ((n
= obt_parse_find_node(node
, "doubleClickTime")))
439 config_mouse_dclicktime
= obt_parse_node_int(n
);
440 if ((n
= obt_parse_find_node(node
, "screenEdgeWarpTime")))
441 config_mouse_screenedgetime
= obt_parse_node_int(n
);
443 n
= obt_parse_find_node(node
, "context");
445 if (!obt_parse_attr_string(n
, "name", &contextstr
))
447 nbut
= obt_parse_find_node(n
->children
, "mousebind");
449 if (!obt_parse_attr_string(nbut
, "button", &buttonstr
))
451 if (obt_parse_attr_contains(nbut
, "action", "press")) {
452 mact
= OB_MOUSE_ACTION_PRESS
;
453 } else if (obt_parse_attr_contains(nbut
, "action", "release")) {
454 mact
= OB_MOUSE_ACTION_RELEASE
;
455 } else if (obt_parse_attr_contains(nbut
, "action", "click")) {
456 mact
= OB_MOUSE_ACTION_CLICK
;
457 } else if (obt_parse_attr_contains(nbut
, "action","doubleclick")) {
458 mact
= OB_MOUSE_ACTION_DOUBLE_CLICK
;
459 } else if (obt_parse_attr_contains(nbut
, "action", "drag")) {
460 mact
= OB_MOUSE_ACTION_MOTION
;
463 nact
= obt_parse_find_node(nbut
->children
, "action");
465 ObActionsAct
*action
;
467 if ((action
= actions_parse(nact
)))
468 mouse_bind(buttonstr
, contextstr
, mact
, action
);
469 nact
= obt_parse_find_node(nact
->next
, "action");
473 nbut
= obt_parse_find_node(nbut
->next
, "mousebind");
477 n
= obt_parse_find_node(n
->next
, "context");
481 static void parse_focus(xmlNodePtr node
, gpointer d
)
485 node
= node
->children
;
487 if ((n
= obt_parse_find_node(node
, "focusNew")))
488 config_focus_new
= obt_parse_node_bool(n
);
489 if ((n
= obt_parse_find_node(node
, "followMouse")))
490 config_focus_follow
= obt_parse_node_bool(n
);
491 if ((n
= obt_parse_find_node(node
, "focusDelay")))
492 config_focus_delay
= obt_parse_node_int(n
);
493 if ((n
= obt_parse_find_node(node
, "raiseOnFocus")))
494 config_focus_raise
= obt_parse_node_bool(n
);
495 if ((n
= obt_parse_find_node(node
, "focusLast")))
496 config_focus_last
= obt_parse_node_bool(n
);
497 if ((n
= obt_parse_find_node(node
, "underMouse")))
498 config_focus_under_mouse
= obt_parse_node_bool(n
);
501 static void parse_placement(xmlNodePtr node
, gpointer d
)
505 node
= node
->children
;
507 if ((n
= obt_parse_find_node(node
, "policy")))
508 if (obt_parse_node_contains(n
, "UnderMouse"))
509 config_place_policy
= OB_PLACE_POLICY_MOUSE
;
510 if ((n
= obt_parse_find_node(node
, "center")))
511 config_place_center
= obt_parse_node_bool(n
);
512 if ((n
= obt_parse_find_node(node
, "monitor"))) {
513 if (obt_parse_node_contains(n
, "active"))
514 config_place_monitor
= OB_PLACE_MONITOR_ACTIVE
;
515 else if (obt_parse_node_contains(n
, "mouse"))
516 config_place_monitor
= OB_PLACE_MONITOR_MOUSE
;
520 static void parse_margins(xmlNodePtr node
, gpointer d
)
524 node
= node
->children
;
526 if ((n
= obt_parse_find_node(node
, "top")))
527 config_margins
.top
= MAX(0, obt_parse_node_int(n
));
528 if ((n
= obt_parse_find_node(node
, "left")))
529 config_margins
.left
= MAX(0, obt_parse_node_int(n
));
530 if ((n
= obt_parse_find_node(node
, "right")))
531 config_margins
.right
= MAX(0, obt_parse_node_int(n
));
532 if ((n
= obt_parse_find_node(node
, "bottom")))
533 config_margins
.bottom
= MAX(0, obt_parse_node_int(n
));
536 static void parse_theme(xmlNodePtr node
, gpointer d
)
540 node
= node
->children
;
542 if ((n
= obt_parse_find_node(node
, "name"))) {
545 g_free(config_theme
);
546 c
= obt_parse_node_string(n
);
547 config_theme
= obt_paths_expand_tilde(c
);
550 if ((n
= obt_parse_find_node(node
, "titleLayout"))) {
553 g_free(config_title_layout
);
554 config_title_layout
= obt_parse_node_string(n
);
556 /* replace duplicates with spaces */
557 for (c
= config_title_layout
; *c
!= '\0'; ++c
)
558 for (d
= c
+1; *d
!= '\0'; ++d
)
559 if (*c
== *d
) *d
= ' ';
561 if ((n
= obt_parse_find_node(node
, "keepBorder")))
562 config_theme_keepborder
= obt_parse_node_bool(n
);
563 if ((n
= obt_parse_find_node(node
, "animateIconify")))
564 config_animate_iconify
= obt_parse_node_bool(n
);
565 if ((n
= obt_parse_find_node(node
, "windowListIconSize"))) {
566 config_theme_window_list_icon_size
= obt_parse_node_int(n
);
567 if (config_theme_window_list_icon_size
< 16)
568 config_theme_window_list_icon_size
= 16;
569 else if (config_theme_window_list_icon_size
> 96)
570 config_theme_window_list_icon_size
= 96;
573 n
= obt_parse_find_node(node
, "font");
577 gchar
*name
= g_strdup(RrDefaultFontFamily
);
578 gint size
= RrDefaultFontSize
;
579 RrFontWeight weight
= RrDefaultFontWeight
;
580 RrFontSlant slant
= RrDefaultFontSlant
;
582 if (obt_parse_attr_contains(n
, "place", "ActiveWindow"))
583 font
= &config_font_activewindow
;
584 else if (obt_parse_attr_contains(n
, "place", "InactiveWindow"))
585 font
= &config_font_inactivewindow
;
586 else if (obt_parse_attr_contains(n
, "place", "MenuHeader"))
587 font
= &config_font_menutitle
;
588 else if (obt_parse_attr_contains(n
, "place", "MenuItem"))
589 font
= &config_font_menuitem
;
590 else if (obt_parse_attr_contains(n
, "place", "OnScreenDisplay"))
591 font
= &config_font_osd
;
595 if ((fnode
= obt_parse_find_node(n
->children
, "name"))) {
597 name
= obt_parse_node_string(fnode
);
599 if ((fnode
= obt_parse_find_node(n
->children
, "size"))) {
600 int s
= obt_parse_node_int(fnode
);
603 if ((fnode
= obt_parse_find_node(n
->children
, "weight"))) {
604 gchar
*w
= obt_parse_node_string(fnode
);
605 if (!g_ascii_strcasecmp(w
, "Bold"))
606 weight
= RR_FONTWEIGHT_BOLD
;
609 if ((fnode
= obt_parse_find_node(n
->children
, "slant"))) {
610 gchar
*s
= obt_parse_node_string(fnode
);
611 if (!g_ascii_strcasecmp(s
, "Italic"))
612 slant
= RR_FONTSLANT_ITALIC
;
613 if (!g_ascii_strcasecmp(s
, "Oblique"))
614 slant
= RR_FONTSLANT_OBLIQUE
;
618 *font
= RrFontOpen(ob_rr_inst
, name
, size
, weight
, slant
);
621 n
= obt_parse_find_node(n
->next
, "font");
625 static void parse_desktops(xmlNodePtr node
, gpointer d
)
629 node
= node
->children
;
631 if ((n
= obt_parse_find_node(node
, "number"))) {
632 gint d
= obt_parse_node_int(n
);
634 config_desktops_num
= (unsigned) d
;
636 if ((n
= obt_parse_find_node(node
, "firstdesk"))) {
637 gint d
= obt_parse_node_int(n
);
639 config_screen_firstdesk
= (unsigned) d
;
641 if ((n
= obt_parse_find_node(node
, "names"))) {
645 for (it
= config_desktops_names
; it
; it
= it
->next
)
647 g_slist_free(config_desktops_names
);
648 config_desktops_names
= NULL
;
650 nname
= obt_parse_find_node(n
->children
, "name");
652 config_desktops_names
=
653 g_slist_append(config_desktops_names
,
654 obt_parse_node_string(nname
));
655 nname
= obt_parse_find_node(nname
->next
, "name");
658 if ((n
= obt_parse_find_node(node
, "popupTime")))
659 config_desktop_popup_time
= obt_parse_node_int(n
);
662 static void parse_resize(xmlNodePtr node
, gpointer d
)
666 node
= node
->children
;
668 if ((n
= obt_parse_find_node(node
, "drawContents")))
669 config_resize_redraw
= obt_parse_node_bool(n
);
670 if ((n
= obt_parse_find_node(node
, "popupShow"))) {
671 config_resize_popup_show
= obt_parse_node_int(n
);
672 if (obt_parse_node_contains(n
, "Always"))
673 config_resize_popup_show
= 2;
674 else if (obt_parse_node_contains(n
, "Never"))
675 config_resize_popup_show
= 0;
676 else if (obt_parse_node_contains(n
, "Nonpixel"))
677 config_resize_popup_show
= 1;
679 if ((n
= obt_parse_find_node(node
, "popupPosition"))) {
680 if (obt_parse_node_contains(n
, "Top"))
681 config_resize_popup_pos
= OB_RESIZE_POS_TOP
;
682 else if (obt_parse_node_contains(n
, "Center"))
683 config_resize_popup_pos
= OB_RESIZE_POS_CENTER
;
684 else if (obt_parse_node_contains(n
, "Fixed")) {
685 config_resize_popup_pos
= OB_RESIZE_POS_FIXED
;
687 if ((n
= obt_parse_find_node(node
, "popupFixedPosition"))) {
690 if ((n2
= obt_parse_find_node(n
->children
, "x")))
691 config_parse_gravity_coord(n2
,
692 &config_resize_popup_fixed
.x
);
693 if ((n2
= obt_parse_find_node(n
->children
, "y")))
694 config_parse_gravity_coord(n2
,
695 &config_resize_popup_fixed
.y
);
697 config_resize_popup_fixed
.x
.pos
=
698 MAX(config_resize_popup_fixed
.x
.pos
, 0);
699 config_resize_popup_fixed
.y
.pos
=
700 MAX(config_resize_popup_fixed
.y
.pos
, 0);
706 static void parse_dock(xmlNodePtr node
, gpointer d
)
710 node
= node
->children
;
712 if ((n
= obt_parse_find_node(node
, "position"))) {
713 if (obt_parse_node_contains(n
, "TopLeft"))
714 config_dock_floating
= FALSE
,
715 config_dock_pos
= OB_DIRECTION_NORTHWEST
;
716 else if (obt_parse_node_contains(n
, "Top"))
717 config_dock_floating
= FALSE
,
718 config_dock_pos
= OB_DIRECTION_NORTH
;
719 else if (obt_parse_node_contains(n
, "TopRight"))
720 config_dock_floating
= FALSE
,
721 config_dock_pos
= OB_DIRECTION_NORTHEAST
;
722 else if (obt_parse_node_contains(n
, "Right"))
723 config_dock_floating
= FALSE
,
724 config_dock_pos
= OB_DIRECTION_EAST
;
725 else if (obt_parse_node_contains(n
, "BottomRight"))
726 config_dock_floating
= FALSE
,
727 config_dock_pos
= OB_DIRECTION_SOUTHEAST
;
728 else if (obt_parse_node_contains(n
, "Bottom"))
729 config_dock_floating
= FALSE
,
730 config_dock_pos
= OB_DIRECTION_SOUTH
;
731 else if (obt_parse_node_contains(n
, "BottomLeft"))
732 config_dock_floating
= FALSE
,
733 config_dock_pos
= OB_DIRECTION_SOUTHWEST
;
734 else if (obt_parse_node_contains(n
, "Left"))
735 config_dock_floating
= FALSE
,
736 config_dock_pos
= OB_DIRECTION_WEST
;
737 else if (obt_parse_node_contains(n
, "Floating"))
738 config_dock_floating
= TRUE
;
740 if (config_dock_floating
) {
741 if ((n
= obt_parse_find_node(node
, "floatingX")))
742 config_dock_x
= obt_parse_node_int(n
);
743 if ((n
= obt_parse_find_node(node
, "floatingY")))
744 config_dock_y
= obt_parse_node_int(n
);
746 if ((n
= obt_parse_find_node(node
, "noStrut")))
747 config_dock_nostrut
= obt_parse_node_bool(n
);
749 if ((n
= obt_parse_find_node(node
, "stacking"))) {
750 if (obt_parse_node_contains(n
, "normal"))
751 config_dock_layer
= OB_STACKING_LAYER_NORMAL
;
752 else if (obt_parse_node_contains(n
, "below"))
753 config_dock_layer
= OB_STACKING_LAYER_BELOW
;
754 else if (obt_parse_node_contains(n
, "above"))
755 config_dock_layer
= OB_STACKING_LAYER_ABOVE
;
757 if ((n
= obt_parse_find_node(node
, "direction"))) {
758 if (obt_parse_node_contains(n
, "horizontal"))
759 config_dock_orient
= OB_ORIENTATION_HORZ
;
760 else if (obt_parse_node_contains(n
, "vertical"))
761 config_dock_orient
= OB_ORIENTATION_VERT
;
763 if ((n
= obt_parse_find_node(node
, "autoHide")))
764 config_dock_hide
= obt_parse_node_bool(n
);
765 if ((n
= obt_parse_find_node(node
, "hideDelay")))
766 config_dock_hide_delay
= obt_parse_node_int(n
);
767 if ((n
= obt_parse_find_node(node
, "showDelay")))
768 config_dock_show_delay
= obt_parse_node_int(n
);
769 if ((n
= obt_parse_find_node(node
, "moveButton"))) {
770 gchar
*str
= obt_parse_node_string(n
);
772 if (translate_button(str
, &s
, &b
)) {
773 config_dock_app_move_button
= b
;
774 config_dock_app_move_modifiers
= s
;
776 g_message(_("Invalid button \"%s\" specified in config file"), str
);
782 static void parse_menu(xmlNodePtr node
, gpointer d
)
785 node
= node
->children
;
787 if ((n
= obt_parse_find_node(node
, "hideDelay")))
788 config_menu_hide_delay
= obt_parse_node_int(n
);
789 if ((n
= obt_parse_find_node(node
, "middle")))
790 config_menu_middle
= obt_parse_node_bool(n
);
791 if ((n
= obt_parse_find_node(node
, "submenuShowDelay")))
792 config_submenu_show_delay
= obt_parse_node_int(n
);
793 if ((n
= obt_parse_find_node(node
, "applicationIcons")))
794 config_menu_client_list_icons
= obt_parse_node_bool(n
);
795 if ((n
= obt_parse_find_node(node
, "manageDesktops")))
796 config_menu_manage_desktops
= obt_parse_node_bool(n
);
798 while ((node
= obt_parse_find_node(node
, "file"))) {
799 gchar
*c
= obt_parse_node_string(node
);
800 config_menu_files
= g_slist_append(config_menu_files
,
801 obt_paths_expand_tilde(c
));
807 static void parse_resistance(xmlNodePtr node
, gpointer d
)
811 node
= node
->children
;
812 if ((n
= obt_parse_find_node(node
, "strength")))
813 config_resist_win
= obt_parse_node_int(n
);
814 if ((n
= obt_parse_find_node(node
, "screen_edge_strength")))
815 config_resist_edge
= obt_parse_node_int(n
);
821 const gchar
*actname
;
824 static void bind_default_keyboard(void)
827 ObDefKeyBind binds
[] = {
828 { "A-Tab", "NextWindow" },
829 { "S-A-Tab", "PreviousWindow" },
833 for (it
= binds
; it
->key
; ++it
) {
834 GList
*l
= g_list_append(NULL
, g_strdup(it
->key
));
835 keyboard_bind(l
, actions_parse_string(it
->actname
));
842 const gchar
*context
;
843 const ObMouseAction mact
;
844 const gchar
*actname
;
847 static void bind_default_mouse(void)
850 ObDefMouseBind binds
[] = {
851 { "Left", "Client", OB_MOUSE_ACTION_PRESS
, "Focus" },
852 { "Middle", "Client", OB_MOUSE_ACTION_PRESS
, "Focus" },
853 { "Right", "Client", OB_MOUSE_ACTION_PRESS
, "Focus" },
854 { "Left", "Desktop", OB_MOUSE_ACTION_PRESS
, "Focus" },
855 { "Middle", "Desktop", OB_MOUSE_ACTION_PRESS
, "Focus" },
856 { "Right", "Desktop", OB_MOUSE_ACTION_PRESS
, "Focus" },
857 { "Left", "Titlebar", OB_MOUSE_ACTION_PRESS
, "Focus" },
858 { "Left", "Bottom", OB_MOUSE_ACTION_PRESS
, "Focus" },
859 { "Left", "BLCorner", OB_MOUSE_ACTION_PRESS
, "Focus" },
860 { "Left", "BRCorner", OB_MOUSE_ACTION_PRESS
, "Focus" },
861 { "Left", "TLCorner", OB_MOUSE_ACTION_PRESS
, "Focus" },
862 { "Left", "TRCorner", OB_MOUSE_ACTION_PRESS
, "Focus" },
863 { "Left", "Close", OB_MOUSE_ACTION_PRESS
, "Focus" },
864 { "Left", "Maximize", OB_MOUSE_ACTION_PRESS
, "Focus" },
865 { "Left", "Iconify", OB_MOUSE_ACTION_PRESS
, "Focus" },
866 { "Left", "Icon", OB_MOUSE_ACTION_PRESS
, "Focus" },
867 { "Left", "AllDesktops", OB_MOUSE_ACTION_PRESS
, "Focus" },
868 { "Left", "Shade", OB_MOUSE_ACTION_PRESS
, "Focus" },
869 { "Left", "Client", OB_MOUSE_ACTION_CLICK
, "Raise" },
870 { "Left", "Titlebar", OB_MOUSE_ACTION_CLICK
, "Raise" },
871 { "Middle", "Titlebar", OB_MOUSE_ACTION_CLICK
, "Lower" },
872 { "Left", "BLCorner", OB_MOUSE_ACTION_CLICK
, "Raise" },
873 { "Left", "BRCorner", OB_MOUSE_ACTION_CLICK
, "Raise" },
874 { "Left", "TLCorner", OB_MOUSE_ACTION_CLICK
, "Raise" },
875 { "Left", "TRCorner", OB_MOUSE_ACTION_CLICK
, "Raise" },
876 { "Left", "Close", OB_MOUSE_ACTION_CLICK
, "Raise" },
877 { "Left", "Maximize", OB_MOUSE_ACTION_CLICK
, "Raise" },
878 { "Left", "Iconify", OB_MOUSE_ACTION_CLICK
, "Raise" },
879 { "Left", "Icon", OB_MOUSE_ACTION_CLICK
, "Raise" },
880 { "Left", "AllDesktops", OB_MOUSE_ACTION_CLICK
, "Raise" },
881 { "Left", "Shade", OB_MOUSE_ACTION_CLICK
, "Raise" },
882 { "Left", "Close", OB_MOUSE_ACTION_CLICK
, "Close" },
883 { "Left", "Maximize", OB_MOUSE_ACTION_CLICK
, "ToggleMaximize" },
884 { "Left", "Iconify", OB_MOUSE_ACTION_CLICK
, "Iconify" },
885 { "Left", "AllDesktops", OB_MOUSE_ACTION_CLICK
, "ToggleOmnipresent" },
886 { "Left", "Shade", OB_MOUSE_ACTION_CLICK
, "ToggleShade" },
887 { "Left", "TLCorner", OB_MOUSE_ACTION_MOTION
, "Resize" },
888 { "Left", "TRCorner", OB_MOUSE_ACTION_MOTION
, "Resize" },
889 { "Left", "BLCorner", OB_MOUSE_ACTION_MOTION
, "Resize" },
890 { "Left", "BRCorner", OB_MOUSE_ACTION_MOTION
, "Resize" },
891 { "Left", "Top", OB_MOUSE_ACTION_MOTION
, "Resize" },
892 { "Left", "Bottom", OB_MOUSE_ACTION_MOTION
, "Resize" },
893 { "Left", "Left", OB_MOUSE_ACTION_MOTION
, "Resize" },
894 { "Left", "Right", OB_MOUSE_ACTION_MOTION
, "Resize" },
895 { "Left", "Titlebar", OB_MOUSE_ACTION_MOTION
, "Move" },
896 { "A-Left", "Frame", OB_MOUSE_ACTION_MOTION
, "Move" },
897 { "A-Middle", "Frame", OB_MOUSE_ACTION_MOTION
, "Resize" },
898 { NULL
, NULL
, 0, NULL
}
901 for (it
= binds
; it
->button
; ++it
)
902 mouse_bind(it
->button
, it
->context
, it
->mact
,
903 actions_parse_string(it
->actname
));
906 void config_startup(ObtParseInst
*i
)
908 config_focus_new
= TRUE
;
909 config_focus_follow
= FALSE
;
910 config_focus_delay
= 0;
911 config_focus_raise
= FALSE
;
912 config_focus_last
= TRUE
;
913 config_focus_under_mouse
= FALSE
;
915 obt_parse_register(i
, "focus", parse_focus
, NULL
);
917 config_place_policy
= OB_PLACE_POLICY_SMART
;
918 config_place_center
= TRUE
;
919 config_place_monitor
= OB_PLACE_MONITOR_ANY
;
921 obt_parse_register(i
, "placement", parse_placement
, NULL
);
923 STRUT_PARTIAL_SET(config_margins
, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
925 obt_parse_register(i
, "margins", parse_margins
, NULL
);
929 config_animate_iconify
= TRUE
;
930 config_title_layout
= g_strdup("NLIMC");
931 config_theme_keepborder
= TRUE
;
932 config_theme_window_list_icon_size
= 36;
934 config_font_activewindow
= NULL
;
935 config_font_inactivewindow
= NULL
;
936 config_font_menuitem
= NULL
;
937 config_font_menutitle
= NULL
;
939 obt_parse_register(i
, "theme", parse_theme
, NULL
);
941 config_desktops_num
= 4;
942 config_screen_firstdesk
= 1;
943 config_desktops_names
= NULL
;
944 config_desktop_popup_time
= 875;
946 obt_parse_register(i
, "desktops", parse_desktops
, NULL
);
948 config_resize_redraw
= TRUE
;
949 config_resize_popup_show
= 1; /* nonpixel increments */
950 config_resize_popup_pos
= OB_RESIZE_POS_CENTER
;
951 GRAVITY_COORD_SET(config_resize_popup_fixed
.x
, 0, FALSE
, FALSE
);
952 GRAVITY_COORD_SET(config_resize_popup_fixed
.y
, 0, FALSE
, FALSE
);
954 obt_parse_register(i
, "resize", parse_resize
, NULL
);
956 config_dock_layer
= OB_STACKING_LAYER_ABOVE
;
957 config_dock_pos
= OB_DIRECTION_NORTHEAST
;
958 config_dock_floating
= FALSE
;
959 config_dock_nostrut
= FALSE
;
962 config_dock_orient
= OB_ORIENTATION_VERT
;
963 config_dock_hide
= FALSE
;
964 config_dock_hide_delay
= 300;
965 config_dock_show_delay
= 300;
966 config_dock_app_move_button
= 2; /* middle */
967 config_dock_app_move_modifiers
= 0;
969 obt_parse_register(i
, "dock", parse_dock
, NULL
);
971 translate_key("C-g", &config_keyboard_reset_state
,
972 &config_keyboard_reset_keycode
);
974 bind_default_keyboard();
976 obt_parse_register(i
, "keyboard", parse_keyboard
, NULL
);
978 config_mouse_threshold
= 8;
979 config_mouse_dclicktime
= 200;
980 config_mouse_screenedgetime
= 400;
982 bind_default_mouse();
984 obt_parse_register(i
, "mouse", parse_mouse
, NULL
);
986 config_resist_win
= 10;
987 config_resist_edge
= 20;
989 obt_parse_register(i
, "resistance", parse_resistance
, NULL
);
991 config_menu_hide_delay
= 250;
992 config_menu_middle
= FALSE
;
993 config_submenu_show_delay
= 0;
994 config_menu_client_list_icons
= TRUE
;
995 config_menu_manage_desktops
= TRUE
;
996 config_menu_files
= NULL
;
998 obt_parse_register(i
, "menu", parse_menu
, NULL
);
1000 config_per_app_settings
= NULL
;
1002 obt_parse_register(i
, "applications", parse_per_app_settings
, NULL
);
1005 void config_shutdown(void)
1009 g_free(config_theme
);
1011 g_free(config_title_layout
);
1013 RrFontClose(config_font_activewindow
);
1014 RrFontClose(config_font_inactivewindow
);
1015 RrFontClose(config_font_menuitem
);
1016 RrFontClose(config_font_menutitle
);
1017 RrFontClose(config_font_osd
);
1019 for (it
= config_desktops_names
; it
; it
= g_slist_next(it
))
1021 g_slist_free(config_desktops_names
);
1023 for (it
= config_menu_files
; it
; it
= g_slist_next(it
))
1025 g_slist_free(config_menu_files
);
1027 for (it
= config_per_app_settings
; it
; it
= g_slist_next(it
)) {
1028 ObAppSettings
*itd
= (ObAppSettings
*)it
->data
;
1029 if (itd
->name
) g_pattern_spec_free(itd
->name
);
1030 if (itd
->role
) g_pattern_spec_free(itd
->role
);
1031 if (itd
->class) g_pattern_spec_free(itd
->class);
1034 g_slist_free(config_per_app_settings
);