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"
30 #include "obt/paths.h"
32 gboolean config_focus_new
;
33 gboolean config_focus_follow
;
34 guint config_focus_delay
;
35 gboolean config_focus_raise
;
36 gboolean config_focus_last
;
37 gboolean config_focus_under_mouse
;
39 ObPlacePolicy config_place_policy
;
40 gboolean config_place_center
;
41 ObPlaceMonitor config_place_monitor
;
43 StrutPartial config_margins
;
46 gboolean config_theme_keepborder
;
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);
135 copy_if(skip_pager
, -1);
136 copy_if(skip_taskbar
, -1);
137 copy_if(fullscreen
, -1);
138 copy_if(max_horz
, -1);
139 copy_if(max_vert
, -1);
141 if (src
->pos_given
) {
142 dst
->pos_given
= TRUE
;
143 dst
->pos_force
= src
->pos_force
;
144 dst
->position
= src
->position
;
145 dst
->monitor
= src
->monitor
;
149 static void config_parse_gravity_coord(xmlNodePtr node
, GravityCoord
*c
)
151 gchar
*s
= obt_parse_node_string(node
);
152 if (!g_ascii_strcasecmp(s
, "center"))
157 if (s
[0] == '-' || s
[0] == '+')
167 <application name="aterm">
170 <application name="Rhythmbox">
177 .. there is a lot more settings available
182 /* Manages settings for individual applications.
183 Some notes: monitor is the screen number in a multi monitor
184 (Xinerama) setup (starting from 0) or mouse, meaning the
185 monitor the pointer is on. Default: mouse.
186 Layer can be three values, above (Always on top), below
187 (Always on bottom) and everything else (normal behaviour).
188 Positions can be an integer value or center, which will
189 center the window in the specified axis. Position is within
190 the monitor, so <position><x>center</x></position><monitor>2</monitor>
191 will center the window on the second monitor.
193 static void parse_per_app_settings(xmlNodePtr node
, gpointer d
)
195 xmlNodePtr app
= obt_parse_find_node(node
->children
, "application");
196 gchar
*name
= NULL
, *class = NULL
, *role
= NULL
, *type
= NULL
;
197 gboolean name_set
, class_set
, type_set
;
198 gboolean x_pos_given
;
201 name_set
= class_set
= type_set
= x_pos_given
= FALSE
;
203 class_set
= obt_parse_attr_string(app
, "class", &class);
204 name_set
= obt_parse_attr_string(app
, "name", &name
);
205 type_set
= obt_parse_attr_string(app
, "type", &type
);
206 if (class_set
|| name_set
) {
208 ObAppSettings
*settings
= config_create_app_settings();;
211 settings
->name
= g_pattern_spec_new(name
);
214 settings
->class = g_pattern_spec_new(class);
217 if (!g_ascii_strcasecmp(type
, "normal"))
218 settings
->type
= OB_CLIENT_TYPE_NORMAL
;
219 else if (!g_ascii_strcasecmp(type
, "dialog"))
220 settings
->type
= OB_CLIENT_TYPE_DIALOG
;
221 else if (!g_ascii_strcasecmp(type
, "splash"))
222 settings
->type
= OB_CLIENT_TYPE_SPLASH
;
223 else if (!g_ascii_strcasecmp(type
, "utility"))
224 settings
->type
= OB_CLIENT_TYPE_UTILITY
;
225 else if (!g_ascii_strcasecmp(type
, "menu"))
226 settings
->type
= OB_CLIENT_TYPE_MENU
;
227 else if (!g_ascii_strcasecmp(type
, "toolbar"))
228 settings
->type
= OB_CLIENT_TYPE_TOOLBAR
;
229 else if (!g_ascii_strcasecmp(type
, "dock"))
230 settings
->type
= OB_CLIENT_TYPE_DOCK
;
231 else if (!g_ascii_strcasecmp(type
, "desktop"))
232 settings
->type
= OB_CLIENT_TYPE_DESKTOP
;
235 if (obt_parse_attr_string(app
, "role", &role
))
236 settings
->role
= g_pattern_spec_new(role
);
238 if ((n
= obt_parse_find_node(app
->children
, "decor")))
239 if (!obt_parse_node_contains(n
, "default"))
240 settings
->decor
= obt_parse_node_bool(n
);
242 if ((n
= obt_parse_find_node(app
->children
, "shade")))
243 if (!obt_parse_node_contains(n
, "default"))
244 settings
->shade
= obt_parse_node_bool(n
);
246 if ((n
= obt_parse_find_node(app
->children
, "position"))) {
247 if ((c
= obt_parse_find_node(n
->children
, "x")))
248 if (!obt_parse_node_contains(c
, "default")) {
249 config_parse_gravity_coord(c
, &settings
->position
.x
);
253 if (x_pos_given
&& (c
= obt_parse_find_node(n
->children
, "y")))
254 if (!obt_parse_node_contains(c
, "default")) {
255 config_parse_gravity_coord(c
, &settings
->position
.y
);
256 settings
->pos_given
= TRUE
;
259 if (settings
->pos_given
&&
260 (c
= obt_parse_find_node(n
->children
, "monitor")))
261 if (!obt_parse_node_contains(c
, "default")) {
262 gchar
*s
= obt_parse_node_string(c
);
263 if (!g_ascii_strcasecmp(s
, "mouse"))
264 settings
->monitor
= 0;
266 settings
->monitor
= obt_parse_node_int(c
) + 1;
270 obt_parse_attr_bool(n
, "force", &settings
->pos_force
);
273 if ((n
= obt_parse_find_node(app
->children
, "focus")))
274 if (!obt_parse_node_contains(n
, "default"))
275 settings
->focus
= obt_parse_node_bool(n
);
277 if ((n
= obt_parse_find_node(app
->children
, "desktop"))) {
278 if (!obt_parse_node_contains(n
, "default")) {
279 gchar
*s
= obt_parse_node_string(n
);
280 if (!g_ascii_strcasecmp(s
, "all"))
281 settings
->desktop
= DESKTOP_ALL
;
283 gint i
= obt_parse_node_int(n
);
285 settings
->desktop
= i
;
291 if ((n
= obt_parse_find_node(app
->children
, "layer")))
292 if (!obt_parse_node_contains(n
, "default")) {
293 gchar
*s
= obt_parse_node_string(n
);
294 if (!g_ascii_strcasecmp(s
, "above"))
296 else if (!g_ascii_strcasecmp(s
, "below"))
297 settings
->layer
= -1;
303 if ((n
= obt_parse_find_node(app
->children
, "iconic")))
304 if (!obt_parse_node_contains(n
, "default"))
305 settings
->iconic
= obt_parse_node_bool(n
);
307 if ((n
= obt_parse_find_node(app
->children
, "skip_pager")))
308 if (!obt_parse_node_contains(n
, "default"))
309 settings
->skip_pager
= obt_parse_node_bool(n
);
311 if ((n
= obt_parse_find_node(app
->children
, "skip_taskbar")))
312 if (!obt_parse_node_contains(n
, "default"))
313 settings
->skip_taskbar
= obt_parse_node_bool(n
);
315 if ((n
= obt_parse_find_node(app
->children
, "fullscreen")))
316 if (!obt_parse_node_contains(n
, "default"))
317 settings
->fullscreen
= obt_parse_node_bool(n
);
319 if ((n
= obt_parse_find_node(app
->children
, "maximized")))
320 if (!obt_parse_node_contains(n
, "default")) {
321 gchar
*s
= obt_parse_node_string(n
);
322 if (!g_ascii_strcasecmp(s
, "horizontal")) {
323 settings
->max_horz
= TRUE
;
324 settings
->max_vert
= FALSE
;
325 } else if (!g_ascii_strcasecmp(s
, "vertical")) {
326 settings
->max_horz
= FALSE
;
327 settings
->max_vert
= TRUE
;
329 settings
->max_horz
= settings
->max_vert
=
330 obt_parse_node_bool(n
);
334 config_per_app_settings
= g_slist_append(config_per_app_settings
,
335 (gpointer
) settings
);
339 name
= class = role
= NULL
;
342 app
= obt_parse_find_node(app
->next
, "application");
346 static void parse_hook(xmlNodePtr node
, gpointer d
)
353 if (!obt_parse_attr_string(node
, "name", &name
)) {
354 g_message(_("Hook in config file is missing a name"));
358 hook
= hooks_hook_from_name(name
);
360 g_message(_("Unknown hook \"%s\" in config file"), name
);
362 if ((n
= obt_parse_find_node(node
->children
, "action")))
364 ObActionsAct
*action
;
366 action
= actions_parse(n
);
368 hooks_add(hook
, action
);
369 n
= obt_parse_find_node(n
->next
, "action");
376 static void parse_hooks(xmlNodePtr node
, gpointer d
)
380 if ((n
= obt_parse_find_node(node
->children
, "hook")))
383 n
= obt_parse_find_node(n
->next
, "hook");
390 <action name="ChangeDesktop">
397 static void parse_key(xmlNodePtr node
, GList
*keylist
)
401 gboolean is_chroot
= FALSE
;
403 if (!obt_parse_attr_string(node
, "key", &key
))
406 obt_parse_attr_bool(node
, "chroot", &is_chroot
);
408 keylist
= g_list_append(keylist
, key
);
410 if ((n
= obt_parse_find_node(node
->children
, "keybind"))) {
412 parse_key(n
, keylist
);
413 n
= obt_parse_find_node(n
->next
, "keybind");
416 else if ((n
= obt_parse_find_node(node
->children
, "action"))) {
418 ObActionsAct
*action
;
420 action
= actions_parse(n
);
422 keyboard_bind(keylist
, action
);
423 n
= obt_parse_find_node(n
->next
, "action");
428 keyboard_chroot(keylist
);
431 keylist
= g_list_delete_link(keylist
, g_list_last(keylist
));
434 static void parse_keyboard(xmlNodePtr node
, gpointer d
)
439 keyboard_unbind_all();
441 if ((n
= obt_parse_find_node(node
->children
, "chainQuitKey"))) {
442 key
= obt_parse_node_string(n
);
443 translate_key(key
, &config_keyboard_reset_state
,
444 &config_keyboard_reset_keycode
);
448 if ((n
= obt_parse_find_node(node
->children
, "keybind")))
451 n
= obt_parse_find_node(n
->next
, "keybind");
457 <context name="Titlebar">
458 <mousebind button="Left" action="Press">
459 <action name="Raise"></action>
465 static void parse_mouse(xmlNodePtr node
, gpointer d
)
467 xmlNodePtr n
, nbut
, nact
;
474 node
= node
->children
;
476 if ((n
= obt_parse_find_node(node
, "dragThreshold")))
477 config_mouse_threshold
= obt_parse_node_int(n
);
478 if ((n
= obt_parse_find_node(node
, "doubleClickTime")))
479 config_mouse_dclicktime
= obt_parse_node_int(n
);
480 if ((n
= obt_parse_find_node(node
, "screenEdgeWarpTime")))
481 config_mouse_screenedgetime
= obt_parse_node_int(n
);
483 n
= obt_parse_find_node(node
, "context");
485 if (!obt_parse_attr_string(n
, "name", &contextstr
))
487 nbut
= obt_parse_find_node(n
->children
, "mousebind");
489 if (!obt_parse_attr_string(nbut
, "button", &buttonstr
))
491 if (obt_parse_attr_contains(nbut
, "action", "press")) {
492 mact
= OB_MOUSE_ACTION_PRESS
;
493 } else if (obt_parse_attr_contains(nbut
, "action", "release")) {
494 mact
= OB_MOUSE_ACTION_RELEASE
;
495 } else if (obt_parse_attr_contains(nbut
, "action", "click")) {
496 mact
= OB_MOUSE_ACTION_CLICK
;
497 } else if (obt_parse_attr_contains(nbut
, "action","doubleclick")) {
498 mact
= OB_MOUSE_ACTION_DOUBLE_CLICK
;
499 } else if (obt_parse_attr_contains(nbut
, "action", "drag")) {
500 mact
= OB_MOUSE_ACTION_MOTION
;
503 nact
= obt_parse_find_node(nbut
->children
, "action");
505 ObActionsAct
*action
;
507 if ((action
= actions_parse(nact
)))
508 mouse_bind(buttonstr
, contextstr
, mact
, action
);
509 nact
= obt_parse_find_node(nact
->next
, "action");
513 nbut
= obt_parse_find_node(nbut
->next
, "mousebind");
517 n
= obt_parse_find_node(n
->next
, "context");
521 static void parse_focus(xmlNodePtr node
, gpointer d
)
525 node
= node
->children
;
527 if ((n
= obt_parse_find_node(node
, "focusNew")))
528 config_focus_new
= obt_parse_node_bool(n
);
529 if ((n
= obt_parse_find_node(node
, "followMouse")))
530 config_focus_follow
= obt_parse_node_bool(n
);
531 if ((n
= obt_parse_find_node(node
, "focusDelay")))
532 config_focus_delay
= obt_parse_node_int(n
);
533 if ((n
= obt_parse_find_node(node
, "raiseOnFocus")))
534 config_focus_raise
= obt_parse_node_bool(n
);
535 if ((n
= obt_parse_find_node(node
, "focusLast")))
536 config_focus_last
= obt_parse_node_bool(n
);
537 if ((n
= obt_parse_find_node(node
, "underMouse")))
538 config_focus_under_mouse
= obt_parse_node_bool(n
);
541 static void parse_placement(xmlNodePtr node
, gpointer d
)
545 node
= node
->children
;
547 if ((n
= obt_parse_find_node(node
, "policy")))
548 if (obt_parse_node_contains(n
, "UnderMouse"))
549 config_place_policy
= OB_PLACE_POLICY_MOUSE
;
550 if ((n
= obt_parse_find_node(node
, "center")))
551 config_place_center
= obt_parse_node_bool(n
);
552 if ((n
= obt_parse_find_node(node
, "monitor"))) {
553 if (obt_parse_node_contains(n
, "active"))
554 config_place_monitor
= OB_PLACE_MONITOR_ACTIVE
;
555 else if (obt_parse_node_contains(n
, "mouse"))
556 config_place_monitor
= OB_PLACE_MONITOR_MOUSE
;
560 static void parse_margins(xmlNodePtr node
, gpointer d
)
564 node
= node
->children
;
566 if ((n
= obt_parse_find_node(node
, "top")))
567 config_margins
.top
= MAX(0, obt_parse_node_int(n
));
568 if ((n
= obt_parse_find_node(node
, "left")))
569 config_margins
.left
= MAX(0, obt_parse_node_int(n
));
570 if ((n
= obt_parse_find_node(node
, "right")))
571 config_margins
.right
= MAX(0, obt_parse_node_int(n
));
572 if ((n
= obt_parse_find_node(node
, "bottom")))
573 config_margins
.bottom
= MAX(0, obt_parse_node_int(n
));
576 static void parse_theme(xmlNodePtr node
, gpointer d
)
580 node
= node
->children
;
582 if ((n
= obt_parse_find_node(node
, "name"))) {
585 g_free(config_theme
);
586 c
= obt_parse_node_string(n
);
587 config_theme
= obt_paths_expand_tilde(c
);
590 if ((n
= obt_parse_find_node(node
, "titleLayout"))) {
593 g_free(config_title_layout
);
594 config_title_layout
= obt_parse_node_string(n
);
596 /* replace duplicates with spaces */
597 for (c
= config_title_layout
; *c
!= '\0'; ++c
)
598 for (d
= c
+1; *d
!= '\0'; ++d
)
599 if (*c
== *d
) *d
= ' ';
601 if ((n
= obt_parse_find_node(node
, "keepBorder")))
602 config_theme_keepborder
= obt_parse_node_bool(n
);
603 if ((n
= obt_parse_find_node(node
, "animateIconify")))
604 config_animate_iconify
= obt_parse_node_bool(n
);
606 n
= obt_parse_find_node(node
, "font");
610 gchar
*name
= g_strdup(RrDefaultFontFamily
);
611 gint size
= RrDefaultFontSize
;
612 RrFontWeight weight
= RrDefaultFontWeight
;
613 RrFontSlant slant
= RrDefaultFontSlant
;
615 if (obt_parse_attr_contains(n
, "place", "ActiveWindow"))
616 font
= &config_font_activewindow
;
617 else if (obt_parse_attr_contains(n
, "place", "InactiveWindow"))
618 font
= &config_font_inactivewindow
;
619 else if (obt_parse_attr_contains(n
, "place", "MenuHeader"))
620 font
= &config_font_menutitle
;
621 else if (obt_parse_attr_contains(n
, "place", "MenuItem"))
622 font
= &config_font_menuitem
;
623 else if (obt_parse_attr_contains(n
, "place", "OnScreenDisplay"))
624 font
= &config_font_osd
;
628 if ((fnode
= obt_parse_find_node(n
->children
, "name"))) {
630 name
= obt_parse_node_string(fnode
);
632 if ((fnode
= obt_parse_find_node(n
->children
, "size"))) {
633 int s
= obt_parse_node_int(fnode
);
636 if ((fnode
= obt_parse_find_node(n
->children
, "weight"))) {
637 gchar
*w
= obt_parse_node_string(fnode
);
638 if (!g_ascii_strcasecmp(w
, "Bold"))
639 weight
= RR_FONTWEIGHT_BOLD
;
642 if ((fnode
= obt_parse_find_node(n
->children
, "slant"))) {
643 gchar
*s
= obt_parse_node_string(fnode
);
644 if (!g_ascii_strcasecmp(s
, "Italic"))
645 slant
= RR_FONTSLANT_ITALIC
;
646 if (!g_ascii_strcasecmp(s
, "Oblique"))
647 slant
= RR_FONTSLANT_OBLIQUE
;
651 *font
= RrFontOpen(ob_rr_inst
, name
, size
, weight
, slant
);
654 n
= obt_parse_find_node(n
->next
, "font");
658 static void parse_desktops(xmlNodePtr node
, gpointer d
)
662 node
= node
->children
;
664 if ((n
= obt_parse_find_node(node
, "number"))) {
665 gint d
= obt_parse_node_int(n
);
667 config_desktops_num
= (unsigned) d
;
669 if ((n
= obt_parse_find_node(node
, "firstdesk"))) {
670 gint d
= obt_parse_node_int(n
);
672 config_screen_firstdesk
= (unsigned) d
;
674 if ((n
= obt_parse_find_node(node
, "names"))) {
678 for (it
= config_desktops_names
; it
; it
= it
->next
)
680 g_slist_free(config_desktops_names
);
681 config_desktops_names
= NULL
;
683 nname
= obt_parse_find_node(n
->children
, "name");
685 config_desktops_names
=
686 g_slist_append(config_desktops_names
,
687 obt_parse_node_string(nname
));
688 nname
= obt_parse_find_node(nname
->next
, "name");
691 if ((n
= obt_parse_find_node(node
, "popupTime")))
692 config_desktop_popup_time
= obt_parse_node_int(n
);
695 static void parse_resize(xmlNodePtr node
, gpointer d
)
699 node
= node
->children
;
701 if ((n
= obt_parse_find_node(node
, "drawContents")))
702 config_resize_redraw
= obt_parse_node_bool(n
);
703 if ((n
= obt_parse_find_node(node
, "popupShow"))) {
704 config_resize_popup_show
= obt_parse_node_int(n
);
705 if (obt_parse_node_contains(n
, "Always"))
706 config_resize_popup_show
= 2;
707 else if (obt_parse_node_contains(n
, "Never"))
708 config_resize_popup_show
= 0;
709 else if (obt_parse_node_contains(n
, "Nonpixel"))
710 config_resize_popup_show
= 1;
712 if ((n
= obt_parse_find_node(node
, "popupPosition"))) {
713 if (obt_parse_node_contains(n
, "Top"))
714 config_resize_popup_pos
= OB_RESIZE_POS_TOP
;
715 else if (obt_parse_node_contains(n
, "Center"))
716 config_resize_popup_pos
= OB_RESIZE_POS_CENTER
;
717 else if (obt_parse_node_contains(n
, "Fixed")) {
718 config_resize_popup_pos
= OB_RESIZE_POS_FIXED
;
720 if ((n
= obt_parse_find_node(node
, "popupFixedPosition"))) {
723 if ((n2
= obt_parse_find_node(n
->children
, "x")))
724 config_parse_gravity_coord(n2
,
725 &config_resize_popup_fixed
.x
);
726 if ((n2
= obt_parse_find_node(n
->children
, "y")))
727 config_parse_gravity_coord(n2
,
728 &config_resize_popup_fixed
.y
);
730 config_resize_popup_fixed
.x
.pos
=
731 MAX(config_resize_popup_fixed
.x
.pos
, 0);
732 config_resize_popup_fixed
.y
.pos
=
733 MAX(config_resize_popup_fixed
.y
.pos
, 0);
739 static void parse_dock(xmlNodePtr node
, gpointer d
)
743 node
= node
->children
;
745 if ((n
= obt_parse_find_node(node
, "position"))) {
746 if (obt_parse_node_contains(n
, "TopLeft"))
747 config_dock_floating
= FALSE
,
748 config_dock_pos
= OB_DIRECTION_NORTHWEST
;
749 else if (obt_parse_node_contains(n
, "Top"))
750 config_dock_floating
= FALSE
,
751 config_dock_pos
= OB_DIRECTION_NORTH
;
752 else if (obt_parse_node_contains(n
, "TopRight"))
753 config_dock_floating
= FALSE
,
754 config_dock_pos
= OB_DIRECTION_NORTHEAST
;
755 else if (obt_parse_node_contains(n
, "Right"))
756 config_dock_floating
= FALSE
,
757 config_dock_pos
= OB_DIRECTION_EAST
;
758 else if (obt_parse_node_contains(n
, "BottomRight"))
759 config_dock_floating
= FALSE
,
760 config_dock_pos
= OB_DIRECTION_SOUTHEAST
;
761 else if (obt_parse_node_contains(n
, "Bottom"))
762 config_dock_floating
= FALSE
,
763 config_dock_pos
= OB_DIRECTION_SOUTH
;
764 else if (obt_parse_node_contains(n
, "BottomLeft"))
765 config_dock_floating
= FALSE
,
766 config_dock_pos
= OB_DIRECTION_SOUTHWEST
;
767 else if (obt_parse_node_contains(n
, "Left"))
768 config_dock_floating
= FALSE
,
769 config_dock_pos
= OB_DIRECTION_WEST
;
770 else if (obt_parse_node_contains(n
, "Floating"))
771 config_dock_floating
= TRUE
;
773 if (config_dock_floating
) {
774 if ((n
= obt_parse_find_node(node
, "floatingX")))
775 config_dock_x
= obt_parse_node_int(n
);
776 if ((n
= obt_parse_find_node(node
, "floatingY")))
777 config_dock_y
= obt_parse_node_int(n
);
779 if ((n
= obt_parse_find_node(node
, "noStrut")))
780 config_dock_nostrut
= obt_parse_node_bool(n
);
782 if ((n
= obt_parse_find_node(node
, "stacking"))) {
783 if (obt_parse_node_contains(n
, "normal"))
784 config_dock_layer
= OB_STACKING_LAYER_NORMAL
;
785 else if (obt_parse_node_contains(n
, "below"))
786 config_dock_layer
= OB_STACKING_LAYER_BELOW
;
787 else if (obt_parse_node_contains(n
, "above"))
788 config_dock_layer
= OB_STACKING_LAYER_ABOVE
;
790 if ((n
= obt_parse_find_node(node
, "direction"))) {
791 if (obt_parse_node_contains(n
, "horizontal"))
792 config_dock_orient
= OB_ORIENTATION_HORZ
;
793 else if (obt_parse_node_contains(n
, "vertical"))
794 config_dock_orient
= OB_ORIENTATION_VERT
;
796 if ((n
= obt_parse_find_node(node
, "autoHide")))
797 config_dock_hide
= obt_parse_node_bool(n
);
798 if ((n
= obt_parse_find_node(node
, "hideDelay")))
799 config_dock_hide_delay
= obt_parse_node_int(n
);
800 if ((n
= obt_parse_find_node(node
, "showDelay")))
801 config_dock_show_delay
= obt_parse_node_int(n
);
802 if ((n
= obt_parse_find_node(node
, "moveButton"))) {
803 gchar
*str
= obt_parse_node_string(n
);
805 if (translate_button(str
, &s
, &b
)) {
806 config_dock_app_move_button
= b
;
807 config_dock_app_move_modifiers
= s
;
809 g_message(_("Invalid button \"%s\" specified in config file"), str
);
815 static void parse_menu(xmlNodePtr node
, gpointer d
)
818 for (node
= node
->children
; node
; node
= node
->next
) {
819 if (!xmlStrcasecmp(node
->name
, (const xmlChar
*) "file")) {
822 c
= obt_parse_node_string(node
);
823 config_menu_files
= g_slist_append(config_menu_files
,
824 obt_paths_expand_tilde(c
));
827 if ((n
= obt_parse_find_node(node
, "hideDelay")))
828 config_menu_hide_delay
= obt_parse_node_int(n
);
829 if ((n
= obt_parse_find_node(node
, "middle")))
830 config_menu_middle
= obt_parse_node_bool(n
);
831 if ((n
= obt_parse_find_node(node
, "submenuShowDelay")))
832 config_submenu_show_delay
= obt_parse_node_int(n
);
833 if ((n
= obt_parse_find_node(node
, "applicationIcons")))
834 config_menu_client_list_icons
= obt_parse_node_bool(n
);
835 if ((n
= obt_parse_find_node(node
, "manageDesktops")))
836 config_menu_manage_desktops
= obt_parse_node_bool(n
);
840 static void parse_resistance(xmlNodePtr node
, gpointer d
)
844 node
= node
->children
;
845 if ((n
= obt_parse_find_node(node
, "strength")))
846 config_resist_win
= obt_parse_node_int(n
);
847 if ((n
= obt_parse_find_node(node
, "screen_edge_strength")))
848 config_resist_edge
= obt_parse_node_int(n
);
854 const gchar
*actname
;
857 static void bind_default_keyboard(void)
860 ObDefKeyBind binds
[] = {
861 { "A-Tab", "NextWindow" },
862 { "S-A-Tab", "PreviousWindow" },
866 for (it
= binds
; it
->key
; ++it
) {
867 GList
*l
= g_list_append(NULL
, g_strdup(it
->key
));
868 keyboard_bind(l
, actions_parse_string(it
->actname
));
875 const gchar
*context
;
876 const ObMouseAction mact
;
877 const gchar
*actname
;
880 static void bind_default_mouse(void)
883 ObDefMouseBind binds
[] = {
884 { "Left", "Client", OB_MOUSE_ACTION_PRESS
, "Focus" },
885 { "Middle", "Client", OB_MOUSE_ACTION_PRESS
, "Focus" },
886 { "Right", "Client", OB_MOUSE_ACTION_PRESS
, "Focus" },
887 { "Left", "Desktop", OB_MOUSE_ACTION_PRESS
, "Focus" },
888 { "Middle", "Desktop", OB_MOUSE_ACTION_PRESS
, "Focus" },
889 { "Right", "Desktop", OB_MOUSE_ACTION_PRESS
, "Focus" },
890 { "Left", "Titlebar", OB_MOUSE_ACTION_PRESS
, "Focus" },
891 { "Left", "Bottom", OB_MOUSE_ACTION_PRESS
, "Focus" },
892 { "Left", "BLCorner", OB_MOUSE_ACTION_PRESS
, "Focus" },
893 { "Left", "BRCorner", OB_MOUSE_ACTION_PRESS
, "Focus" },
894 { "Left", "TLCorner", OB_MOUSE_ACTION_PRESS
, "Focus" },
895 { "Left", "TRCorner", OB_MOUSE_ACTION_PRESS
, "Focus" },
896 { "Left", "Close", OB_MOUSE_ACTION_PRESS
, "Focus" },
897 { "Left", "Maximize", OB_MOUSE_ACTION_PRESS
, "Focus" },
898 { "Left", "Iconify", OB_MOUSE_ACTION_PRESS
, "Focus" },
899 { "Left", "Icon", OB_MOUSE_ACTION_PRESS
, "Focus" },
900 { "Left", "AllDesktops", OB_MOUSE_ACTION_PRESS
, "Focus" },
901 { "Left", "Shade", OB_MOUSE_ACTION_PRESS
, "Focus" },
902 { "Left", "Client", OB_MOUSE_ACTION_CLICK
, "Raise" },
903 { "Left", "Titlebar", OB_MOUSE_ACTION_CLICK
, "Raise" },
904 { "Middle", "Titlebar", OB_MOUSE_ACTION_CLICK
, "Lower" },
905 { "Left", "BLCorner", OB_MOUSE_ACTION_CLICK
, "Raise" },
906 { "Left", "BRCorner", OB_MOUSE_ACTION_CLICK
, "Raise" },
907 { "Left", "TLCorner", OB_MOUSE_ACTION_CLICK
, "Raise" },
908 { "Left", "TRCorner", OB_MOUSE_ACTION_CLICK
, "Raise" },
909 { "Left", "Close", OB_MOUSE_ACTION_CLICK
, "Raise" },
910 { "Left", "Maximize", OB_MOUSE_ACTION_CLICK
, "Raise" },
911 { "Left", "Iconify", OB_MOUSE_ACTION_CLICK
, "Raise" },
912 { "Left", "Icon", OB_MOUSE_ACTION_CLICK
, "Raise" },
913 { "Left", "AllDesktops", OB_MOUSE_ACTION_CLICK
, "Raise" },
914 { "Left", "Shade", OB_MOUSE_ACTION_CLICK
, "Raise" },
915 { "Left", "Close", OB_MOUSE_ACTION_CLICK
, "Close" },
916 { "Left", "Maximize", OB_MOUSE_ACTION_CLICK
, "ToggleMaximize" },
917 { "Left", "Iconify", OB_MOUSE_ACTION_CLICK
, "Iconify" },
918 { "Left", "AllDesktops", OB_MOUSE_ACTION_CLICK
, "ToggleOmnipresent" },
919 { "Left", "Shade", OB_MOUSE_ACTION_CLICK
, "ToggleShade" },
920 { "Left", "TLCorner", OB_MOUSE_ACTION_MOTION
, "Resize" },
921 { "Left", "TRCorner", OB_MOUSE_ACTION_MOTION
, "Resize" },
922 { "Left", "BLCorner", OB_MOUSE_ACTION_MOTION
, "Resize" },
923 { "Left", "BRCorner", OB_MOUSE_ACTION_MOTION
, "Resize" },
924 { "Left", "Top", OB_MOUSE_ACTION_MOTION
, "Resize" },
925 { "Left", "Bottom", OB_MOUSE_ACTION_MOTION
, "Resize" },
926 { "Left", "Left", OB_MOUSE_ACTION_MOTION
, "Resize" },
927 { "Left", "Right", OB_MOUSE_ACTION_MOTION
, "Resize" },
928 { "Left", "Titlebar", OB_MOUSE_ACTION_MOTION
, "Move" },
929 { "A-Left", "Frame", OB_MOUSE_ACTION_MOTION
, "Move" },
930 { "A-Middle", "Frame", OB_MOUSE_ACTION_MOTION
, "Resize" },
931 { NULL
, NULL
, 0, NULL
}
934 for (it
= binds
; it
->button
; ++it
)
935 mouse_bind(it
->button
, it
->context
, it
->mact
,
936 actions_parse_string(it
->actname
));
939 void config_startup(ObtParseInst
*i
)
941 config_focus_new
= TRUE
;
942 config_focus_follow
= FALSE
;
943 config_focus_delay
= 0;
944 config_focus_raise
= FALSE
;
945 config_focus_last
= TRUE
;
946 config_focus_under_mouse
= FALSE
;
948 obt_parse_register(i
, "focus", parse_focus
, NULL
);
950 config_place_policy
= OB_PLACE_POLICY_SMART
;
951 config_place_center
= TRUE
;
952 config_place_monitor
= OB_PLACE_MONITOR_ANY
;
954 obt_parse_register(i
, "placement", parse_placement
, NULL
);
956 STRUT_PARTIAL_SET(config_margins
, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
958 obt_parse_register(i
, "margins", parse_margins
, NULL
);
962 config_animate_iconify
= TRUE
;
963 config_title_layout
= g_strdup("NLIMC");
964 config_theme_keepborder
= TRUE
;
966 config_font_activewindow
= NULL
;
967 config_font_inactivewindow
= NULL
;
968 config_font_menuitem
= NULL
;
969 config_font_menutitle
= NULL
;
971 obt_parse_register(i
, "theme", parse_theme
, NULL
);
973 config_desktops_num
= 4;
974 config_screen_firstdesk
= 1;
975 config_desktops_names
= NULL
;
976 config_desktop_popup_time
= 875;
978 obt_parse_register(i
, "desktops", parse_desktops
, NULL
);
980 config_resize_redraw
= TRUE
;
981 config_resize_popup_show
= 1; /* nonpixel increments */
982 config_resize_popup_pos
= OB_RESIZE_POS_CENTER
;
983 GRAVITY_COORD_SET(config_resize_popup_fixed
.x
, 0, FALSE
, FALSE
);
984 GRAVITY_COORD_SET(config_resize_popup_fixed
.y
, 0, FALSE
, FALSE
);
986 obt_parse_register(i
, "resize", parse_resize
, NULL
);
988 config_dock_layer
= OB_STACKING_LAYER_ABOVE
;
989 config_dock_pos
= OB_DIRECTION_NORTHEAST
;
990 config_dock_floating
= FALSE
;
991 config_dock_nostrut
= FALSE
;
994 config_dock_orient
= OB_ORIENTATION_VERT
;
995 config_dock_hide
= FALSE
;
996 config_dock_hide_delay
= 300;
997 config_dock_show_delay
= 300;
998 config_dock_app_move_button
= 2; /* middle */
999 config_dock_app_move_modifiers
= 0;
1001 obt_parse_register(i
, "dock", parse_dock
, NULL
);
1003 translate_key("C-g", &config_keyboard_reset_state
,
1004 &config_keyboard_reset_keycode
);
1006 bind_default_keyboard();
1008 obt_parse_register(i
, "keyboard", parse_keyboard
, NULL
);
1010 config_mouse_threshold
= 8;
1011 config_mouse_dclicktime
= 200;
1012 config_mouse_screenedgetime
= 400;
1014 bind_default_mouse();
1016 obt_parse_register(i
, "mouse", parse_mouse
, NULL
);
1018 config_resist_win
= 10;
1019 config_resist_edge
= 20;
1021 obt_parse_register(i
, "resistance", parse_resistance
, NULL
);
1023 config_menu_hide_delay
= 250;
1024 config_menu_middle
= FALSE
;
1025 config_submenu_show_delay
= 0;
1026 config_menu_client_list_icons
= TRUE
;
1027 config_menu_manage_desktops
= TRUE
;
1028 config_menu_files
= NULL
;
1030 obt_parse_register(i
, "menu", parse_menu
, NULL
);
1032 obt_parse_register(i
, "hooks", parse_hooks
, NULL
);
1034 config_per_app_settings
= NULL
;
1036 obt_parse_register(i
, "applications", parse_per_app_settings
, NULL
);
1039 void config_shutdown(void)
1043 g_free(config_theme
);
1045 g_free(config_title_layout
);
1047 RrFontClose(config_font_activewindow
);
1048 RrFontClose(config_font_inactivewindow
);
1049 RrFontClose(config_font_menuitem
);
1050 RrFontClose(config_font_menutitle
);
1051 RrFontClose(config_font_osd
);
1053 for (it
= config_desktops_names
; it
; it
= g_slist_next(it
))
1055 g_slist_free(config_desktops_names
);
1057 for (it
= config_menu_files
; it
; it
= g_slist_next(it
))
1059 g_slist_free(config_menu_files
);
1061 for (it
= config_per_app_settings
; it
; it
= g_slist_next(it
)) {
1062 ObAppSettings
*itd
= (ObAppSettings
*)it
->data
;
1063 if (itd
->name
) g_pattern_spec_free(itd
->name
);
1064 if (itd
->role
) g_pattern_spec_free(itd
->role
);
1065 if (itd
->class) g_pattern_spec_free(itd
->class);
1068 g_slist_free(config_per_app_settings
);