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"
27 #include "parser/parse.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
;
37 ObPlacePolicy config_place_policy
;
40 gboolean config_theme_keepborder
;
42 gchar
*config_title_layout
;
44 gboolean config_animate_iconify
;
46 RrFont
*config_font_activewindow
;
47 RrFont
*config_font_inactivewindow
;
48 RrFont
*config_font_menuitem
;
49 RrFont
*config_font_menutitle
;
50 RrFont
*config_font_osd
;
52 gint config_desktops_num
;
53 GSList
*config_desktops_names
;
54 guint config_screen_firstdesk
;
56 gboolean config_resize_redraw
;
57 gboolean config_resize_four_corners
;
58 gint config_resize_popup_show
;
59 gint config_resize_popup_pos
;
61 ObStackingLayer config_dock_layer
;
62 gboolean config_dock_floating
;
63 gboolean config_dock_nostrut
;
64 ObDirection config_dock_pos
;
67 ObOrientation config_dock_orient
;
68 gboolean config_dock_hide
;
69 guint config_dock_hide_delay
;
70 guint config_dock_show_delay
;
71 guint config_dock_app_move_button
;
72 guint config_dock_app_move_modifiers
;
74 guint config_keyboard_reset_keycode
;
75 guint config_keyboard_reset_state
;
77 gint config_mouse_threshold
;
78 gint config_mouse_dclicktime
;
80 guint config_menu_hide_delay
;
81 gboolean config_menu_middle
;
82 guint config_submenu_show_delay
;
83 gboolean config_menu_client_list_icons
;
85 GSList
*config_menu_files
;
87 gint config_resist_win
;
88 gint config_resist_edge
;
90 GSList
*config_per_app_settings
;
92 ObAppSettings
* config_create_app_settings()
94 ObAppSettings
*settings
= g_new0(ObAppSettings
, 1);
97 settings
->monitor
= -1;
99 settings
->desktop
= 0;
100 settings
->layer
= -2;
101 settings
->iconic
= -1;
102 settings
->skip_pager
= -1;
103 settings
->skip_taskbar
= -1;
104 settings
->fullscreen
= -1;
105 settings
->max_horz
= -1;
106 settings
->max_vert
= -1;
110 #define copy_if(setting, default) \
111 if (src->setting != default) dst->setting = src->setting
112 void config_app_settings_copy_non_defaults(const ObAppSettings
*src
,
115 g_assert(src
!= NULL
);
116 g_assert(dst
!= NULL
);
124 copy_if(skip_pager
, -1);
125 copy_if(skip_taskbar
, -1);
126 copy_if(fullscreen
, -1);
127 copy_if(max_horz
, -1);
128 copy_if(max_vert
, -1);
130 if (src
->pos_given
) {
131 dst
->pos_given
= TRUE
;
132 dst
->center_x
= src
->center_x
;
133 dst
->center_y
= src
->center_y
;
134 dst
->position
.x
= src
->position
.x
;
135 dst
->position
.y
= src
->position
.y
;
136 dst
->monitor
= src
->monitor
;
142 <application name="aterm">
145 <application name="Rhythmbox">
152 .. there is a lot more settings available
157 /* Manages settings for individual applications.
158 Some notes: monitor is the screen number in a multi monitor
159 (Xinerama) setup (starting from 0) or mouse, meaning the
160 monitor the pointer is on. Default: mouse.
161 Layer can be three values, above (Always on top), below
162 (Always on bottom) and everything else (normal behaviour).
163 Positions can be an integer value or center, which will
164 center the window in the specified axis. Position is within
165 the monitor, so <position><x>center</x></position><monitor>2</monitor>
166 will center the window on the second monitor.
168 static void parse_per_app_settings(ObParseInst
*i
, xmlDocPtr doc
,
169 xmlNodePtr node
, gpointer d
)
171 xmlNodePtr app
= parse_find_node("application", node
->children
);
172 gchar
*name
= NULL
, *class = NULL
, *role
= NULL
;
173 gboolean name_set
, class_set
;
174 gboolean x_pos_given
;
177 name_set
= class_set
= x_pos_given
= FALSE
;
179 class_set
= parse_attr_string("class", app
, &class);
180 name_set
= parse_attr_string("name", app
, &name
);
181 if (class_set
|| name_set
) {
183 ObAppSettings
*settings
= config_create_app_settings();;
186 settings
->name
= g_pattern_spec_new(name
);
189 settings
->class = g_pattern_spec_new(class);
191 if (parse_attr_string("role", app
, &role
))
192 settings
->role
= g_pattern_spec_new(role
);
194 if ((n
= parse_find_node("decor", app
->children
)))
195 if (!parse_contains("default", doc
, n
))
196 settings
->decor
= parse_bool(doc
, n
);
198 if ((n
= parse_find_node("shade", app
->children
)))
199 if (!parse_contains("default", doc
, n
))
200 settings
->shade
= parse_bool(doc
, n
);
202 if ((n
= parse_find_node("position", app
->children
))) {
203 if ((c
= parse_find_node("x", n
->children
)))
204 if (!parse_contains("default", doc
, c
)) {
205 gchar
*s
= parse_string(doc
, c
);
206 if (!strcmp(s
, "center")) {
207 settings
->center_x
= TRUE
;
210 settings
->position
.x
= parse_int(doc
, c
);
216 if (x_pos_given
&& (c
= parse_find_node("y", n
->children
)))
217 if (!parse_contains("default", doc
, c
)) {
218 gchar
*s
= parse_string(doc
, c
);
219 if (!strcmp(s
, "center")) {
220 settings
->center_y
= TRUE
;
221 settings
->pos_given
= TRUE
;
223 settings
->position
.y
= parse_int(doc
, c
);
224 settings
->pos_given
= TRUE
;
229 if (settings
->pos_given
&&
230 (c
= parse_find_node("monitor", n
->children
)))
231 if (!parse_contains("default", doc
, c
)) {
232 gchar
*s
= parse_string(doc
, c
);
233 if (!strcmp(s
, "mouse"))
234 settings
->monitor
= 0;
236 settings
->monitor
= parse_int(doc
, c
) + 1;
241 if ((n
= parse_find_node("focus", app
->children
)))
242 if (!parse_contains("default", doc
, n
))
243 settings
->focus
= parse_bool(doc
, n
);
245 if ((n
= parse_find_node("desktop", app
->children
))) {
246 if (!parse_contains("default", doc
, n
)) {
247 gchar
*s
= parse_string(doc
, n
);
248 if (!strcmp(s
, "all"))
249 settings
->desktop
= DESKTOP_ALL
;
251 gint i
= parse_int(doc
, n
);
253 settings
->desktop
= i
;
259 if ((n
= parse_find_node("layer", app
->children
)))
260 if (!parse_contains("default", doc
, n
)) {
261 gchar
*s
= parse_string(doc
, n
);
262 if (!strcmp(s
, "above"))
264 else if (!strcmp(s
, "below"))
265 settings
->layer
= -1;
271 if ((n
= parse_find_node("iconic", app
->children
)))
272 if (!parse_contains("default", doc
, n
))
273 settings
->iconic
= parse_bool(doc
, n
);
275 if ((n
= parse_find_node("skip_pager", app
->children
)))
276 if (!parse_contains("default", doc
, n
))
277 settings
->skip_pager
= parse_bool(doc
, n
);
279 if ((n
= parse_find_node("skip_taskbar", app
->children
)))
280 if (!parse_contains("default", doc
, n
))
281 settings
->skip_taskbar
= parse_bool(doc
, n
);
283 if ((n
= parse_find_node("fullscreen", app
->children
)))
284 if (!parse_contains("default", doc
, n
))
285 settings
->fullscreen
= parse_bool(doc
, n
);
287 if ((n
= parse_find_node("maximized", app
->children
)))
288 if (!parse_contains("default", doc
, n
)) {
289 gchar
*s
= parse_string(doc
, n
);
290 if (!strcmp(s
, "horizontal")) {
291 settings
->max_horz
= TRUE
;
292 settings
->max_vert
= FALSE
;
293 } else if (!strcmp(s
, "vertical")) {
294 settings
->max_horz
= FALSE
;
295 settings
->max_vert
= TRUE
;
297 settings
->max_horz
= settings
->max_vert
=
302 config_per_app_settings
= g_slist_append(config_per_app_settings
,
303 (gpointer
) settings
);
306 app
= parse_find_node("application", app
->next
);
317 <action name="ChangeDesktop">
324 static void parse_key(ObParseInst
*i
, xmlDocPtr doc
, xmlNodePtr node
,
329 gboolean is_chroot
= FALSE
;
331 if (!parse_attr_string("key", node
, &key
))
334 parse_attr_bool("chroot", node
, &is_chroot
);
336 keylist
= g_list_append(keylist
, key
);
338 if ((n
= parse_find_node("keybind", node
->children
))) {
340 parse_key(i
, doc
, n
, keylist
);
341 n
= parse_find_node("keybind", n
->next
);
344 else if ((n
= parse_find_node("action", node
->children
))) {
348 action
= action_parse(i
, doc
, n
, OB_USER_ACTION_KEYBOARD_KEY
);
350 keyboard_bind(keylist
, action
);
351 n
= parse_find_node("action", n
->next
);
356 keyboard_chroot(keylist
);
359 keylist
= g_list_delete_link(keylist
, g_list_last(keylist
));
362 static void parse_keyboard(ObParseInst
*i
, xmlDocPtr doc
, xmlNodePtr node
,
368 keyboard_unbind_all();
370 if ((n
= parse_find_node("chainQuitKey", node
->children
))) {
371 key
= parse_string(doc
, n
);
372 translate_key(key
, &config_keyboard_reset_state
,
373 &config_keyboard_reset_keycode
);
377 if ((n
= parse_find_node("keybind", node
->children
)))
379 parse_key(i
, doc
, n
, NULL
);
380 n
= parse_find_node("keybind", n
->next
);
386 <context name="Titlebar">
387 <mousebind button="Left" action="Press">
388 <action name="Raise"></action>
394 static void parse_mouse(ObParseInst
*i
, xmlDocPtr doc
, xmlNodePtr node
,
397 xmlNodePtr n
, nbut
, nact
;
406 node
= node
->children
;
408 if ((n
= parse_find_node("dragThreshold", node
)))
409 config_mouse_threshold
= parse_int(doc
, n
);
410 if ((n
= parse_find_node("doubleClickTime", node
)))
411 config_mouse_dclicktime
= parse_int(doc
, n
);
413 n
= parse_find_node("context", node
);
415 if (!parse_attr_string("name", n
, &contextstr
))
417 nbut
= parse_find_node("mousebind", n
->children
);
419 if (!parse_attr_string("button", nbut
, &buttonstr
))
421 if (parse_attr_contains("press", nbut
, "action")) {
422 uact
= OB_USER_ACTION_MOUSE_PRESS
;
423 mact
= OB_MOUSE_ACTION_PRESS
;
424 } else if (parse_attr_contains("release", nbut
, "action")) {
425 uact
= OB_USER_ACTION_MOUSE_RELEASE
;
426 mact
= OB_MOUSE_ACTION_RELEASE
;
427 } else if (parse_attr_contains("click", nbut
, "action")) {
428 uact
= OB_USER_ACTION_MOUSE_CLICK
;
429 mact
= OB_MOUSE_ACTION_CLICK
;
430 } else if (parse_attr_contains("doubleclick", nbut
,"action")) {
431 uact
= OB_USER_ACTION_MOUSE_DOUBLE_CLICK
;
432 mact
= OB_MOUSE_ACTION_DOUBLE_CLICK
;
433 } else if (parse_attr_contains("drag", nbut
, "action")) {
434 uact
= OB_USER_ACTION_MOUSE_MOTION
;
435 mact
= OB_MOUSE_ACTION_MOTION
;
438 nact
= parse_find_node("action", nbut
->children
);
440 if ((action
= action_parse(i
, doc
, nact
, uact
)))
441 mouse_bind(buttonstr
, contextstr
, mact
, action
);
442 nact
= parse_find_node("action", nact
->next
);
446 nbut
= parse_find_node("mousebind", nbut
->next
);
450 n
= parse_find_node("context", n
->next
);
454 static void parse_focus(ObParseInst
*i
, xmlDocPtr doc
, xmlNodePtr node
,
459 node
= node
->children
;
461 if ((n
= parse_find_node("focusNew", node
)))
462 config_focus_new
= parse_bool(doc
, n
);
463 if ((n
= parse_find_node("followMouse", node
)))
464 config_focus_follow
= parse_bool(doc
, n
);
465 if ((n
= parse_find_node("focusDelay", node
)))
466 config_focus_delay
= parse_int(doc
, n
) * 1000;
467 if ((n
= parse_find_node("raiseOnFocus", node
)))
468 config_focus_raise
= parse_bool(doc
, n
);
469 if ((n
= parse_find_node("focusLast", node
)))
470 config_focus_last
= parse_bool(doc
, n
);
473 static void parse_placement(ObParseInst
*i
, xmlDocPtr doc
, xmlNodePtr node
,
478 node
= node
->children
;
480 if ((n
= parse_find_node("policy", node
)))
481 if (parse_contains("UnderMouse", doc
, n
))
482 config_place_policy
= OB_PLACE_POLICY_MOUSE
;
485 static void parse_theme(ObParseInst
*i
, xmlDocPtr doc
, xmlNodePtr node
,
490 node
= node
->children
;
492 if ((n
= parse_find_node("name", node
))) {
495 g_free(config_theme
);
496 c
= parse_string(doc
, n
);
497 config_theme
= parse_expand_tilde(c
);
500 if ((n
= parse_find_node("titleLayout", node
))) {
503 g_free(config_title_layout
);
504 config_title_layout
= parse_string(doc
, n
);
506 /* replace duplicates with spaces */
507 for (c
= config_title_layout
; *c
!= '\0'; ++c
)
508 for (d
= c
+1; *d
!= '\0'; ++d
)
509 if (*c
== *d
) *d
= ' ';
511 if ((n
= parse_find_node("keepBorder", node
)))
512 config_theme_keepborder
= parse_bool(doc
, n
);
513 if ((n
= parse_find_node("animateIconify", node
)))
514 config_animate_iconify
= parse_bool(doc
, n
);
516 n
= parse_find_node("font", node
);
520 gchar
*name
= g_strdup(RrDefaultFontFamily
);
521 gint size
= RrDefaultFontSize
;
522 RrFontWeight weight
= RrDefaultFontWeight
;
523 RrFontSlant slant
= RrDefaultFontSlant
;
525 if (parse_attr_contains("ActiveWindow", n
, "place"))
526 font
= &config_font_activewindow
;
527 else if (parse_attr_contains("InactiveWindow", n
, "place"))
528 font
= &config_font_inactivewindow
;
529 else if (parse_attr_contains("MenuHeader", n
, "place"))
530 font
= &config_font_menutitle
;
531 else if (parse_attr_contains("MenuItem", n
, "place"))
532 font
= &config_font_menuitem
;
533 else if (parse_attr_contains("OnScreenDisplay", n
, "place"))
534 font
= &config_font_osd
;
538 if ((fnode
= parse_find_node("name", n
->children
))) {
540 name
= parse_string(doc
, fnode
);
542 if ((fnode
= parse_find_node("size", n
->children
))) {
543 int s
= parse_int(doc
, fnode
);
546 if ((fnode
= parse_find_node("weight", n
->children
))) {
547 gchar
*w
= parse_string(doc
, fnode
);
548 if (!g_ascii_strcasecmp(w
, "Bold"))
549 weight
= RR_FONTWEIGHT_BOLD
;
552 if ((fnode
= parse_find_node("slant", n
->children
))) {
553 gchar
*s
= parse_string(doc
, fnode
);
554 if (!g_ascii_strcasecmp(s
, "Italic"))
555 slant
= RR_FONTSLANT_ITALIC
;
556 if (!g_ascii_strcasecmp(s
, "Oblique"))
557 slant
= RR_FONTSLANT_OBLIQUE
;
561 *font
= RrFontOpen(ob_rr_inst
, name
, size
, weight
, slant
);
564 n
= parse_find_node("font", n
->next
);
568 static void parse_desktops(ObParseInst
*i
, xmlDocPtr doc
, xmlNodePtr node
,
573 node
= node
->children
;
575 if ((n
= parse_find_node("number", node
))) {
576 gint d
= parse_int(doc
, n
);
578 config_desktops_num
= d
;
580 if ((n
= parse_find_node("firstdesk", node
))) {
581 gint d
= parse_int(doc
, n
);
583 config_screen_firstdesk
= (unsigned) d
;
585 if ((n
= parse_find_node("names", node
))) {
589 for (it
= config_desktops_names
; it
; it
= it
->next
)
591 g_slist_free(config_desktops_names
);
592 config_desktops_names
= NULL
;
594 nname
= parse_find_node("name", n
->children
);
596 config_desktops_names
= g_slist_append(config_desktops_names
,
597 parse_string(doc
, nname
));
598 nname
= parse_find_node("name", nname
->next
);
603 static void parse_resize(ObParseInst
*i
, xmlDocPtr doc
, xmlNodePtr node
,
608 node
= node
->children
;
610 if ((n
= parse_find_node("drawContents", node
)))
611 config_resize_redraw
= parse_bool(doc
, n
);
612 if ((n
= parse_find_node("popupShow", node
))) {
613 config_resize_popup_show
= parse_int(doc
, n
);
614 if (parse_contains("Always", doc
, n
))
615 config_resize_popup_show
= 2;
616 else if (parse_contains("Never", doc
, n
))
617 config_resize_popup_show
= 0;
618 else if (parse_contains("Nonpixel", doc
, n
))
619 config_resize_popup_show
= 1;
621 if ((n
= parse_find_node("popupPosition", node
))) {
622 config_resize_popup_pos
= parse_int(doc
, n
);
623 if (parse_contains("Top", doc
, n
))
624 config_resize_popup_pos
= 1;
625 else if (parse_contains("Center", doc
, n
))
626 config_resize_popup_pos
= 0;
630 static void parse_dock(ObParseInst
*i
, xmlDocPtr doc
, xmlNodePtr node
,
635 node
= node
->children
;
637 if ((n
= parse_find_node("position", node
))) {
638 if (parse_contains("TopLeft", doc
, n
))
639 config_dock_floating
= FALSE
,
640 config_dock_pos
= OB_DIRECTION_NORTHWEST
;
641 else if (parse_contains("Top", doc
, n
))
642 config_dock_floating
= FALSE
,
643 config_dock_pos
= OB_DIRECTION_NORTH
;
644 else if (parse_contains("TopRight", doc
, n
))
645 config_dock_floating
= FALSE
,
646 config_dock_pos
= OB_DIRECTION_NORTHEAST
;
647 else if (parse_contains("Right", doc
, n
))
648 config_dock_floating
= FALSE
,
649 config_dock_pos
= OB_DIRECTION_EAST
;
650 else if (parse_contains("BottomRight", doc
, n
))
651 config_dock_floating
= FALSE
,
652 config_dock_pos
= OB_DIRECTION_SOUTHEAST
;
653 else if (parse_contains("Bottom", doc
, n
))
654 config_dock_floating
= FALSE
,
655 config_dock_pos
= OB_DIRECTION_SOUTH
;
656 else if (parse_contains("BottomLeft", doc
, n
))
657 config_dock_floating
= FALSE
,
658 config_dock_pos
= OB_DIRECTION_SOUTHWEST
;
659 else if (parse_contains("Left", doc
, n
))
660 config_dock_floating
= FALSE
,
661 config_dock_pos
= OB_DIRECTION_WEST
;
662 else if (parse_contains("Floating", doc
, n
))
663 config_dock_floating
= TRUE
;
665 if (config_dock_floating
) {
666 if ((n
= parse_find_node("floatingX", node
)))
667 config_dock_x
= parse_int(doc
, n
);
668 if ((n
= parse_find_node("floatingY", node
)))
669 config_dock_y
= parse_int(doc
, n
);
671 if ((n
= parse_find_node("noStrut", node
)))
672 config_dock_nostrut
= parse_bool(doc
, n
);
674 if ((n
= parse_find_node("stacking", node
))) {
675 if (parse_contains("above", doc
, n
))
676 config_dock_layer
= OB_STACKING_LAYER_ABOVE
;
677 else if (parse_contains("normal", doc
, n
))
678 config_dock_layer
= OB_STACKING_LAYER_NORMAL
;
679 else if (parse_contains("below", doc
, n
))
680 config_dock_layer
= OB_STACKING_LAYER_BELOW
;
682 if ((n
= parse_find_node("direction", node
))) {
683 if (parse_contains("horizontal", doc
, n
))
684 config_dock_orient
= OB_ORIENTATION_HORZ
;
685 else if (parse_contains("vertical", doc
, n
))
686 config_dock_orient
= OB_ORIENTATION_VERT
;
688 if ((n
= parse_find_node("autoHide", node
)))
689 config_dock_hide
= parse_bool(doc
, n
);
690 if ((n
= parse_find_node("hideDelay", node
)))
691 config_dock_hide_delay
= parse_int(doc
, n
) * 1000;
692 if ((n
= parse_find_node("showDelay", node
)))
693 config_dock_show_delay
= parse_int(doc
, n
) * 1000;
694 if ((n
= parse_find_node("moveButton", node
))) {
695 gchar
*str
= parse_string(doc
, n
);
697 if (translate_button(str
, &s
, &b
)) {
698 config_dock_app_move_button
= b
;
699 config_dock_app_move_modifiers
= s
;
701 g_message(_("Invalid button '%s' specified in config file"), str
);
707 static void parse_menu(ObParseInst
*i
, xmlDocPtr doc
, xmlNodePtr node
,
711 for (node
= node
->children
; node
; node
= node
->next
) {
712 if (!xmlStrcasecmp(node
->name
, (const xmlChar
*) "file")) {
715 c
= parse_string(doc
, node
);
716 config_menu_files
= g_slist_append(config_menu_files
,
717 parse_expand_tilde(c
));
720 if ((n
= parse_find_node("hideDelay", node
)))
721 config_menu_hide_delay
= parse_int(doc
, n
);
722 if ((n
= parse_find_node("middle", node
)))
723 config_menu_middle
= parse_bool(doc
, n
);
724 if ((n
= parse_find_node("submenuShowDelay", node
)))
725 config_submenu_show_delay
= parse_int(doc
, n
);
726 if ((n
= parse_find_node("applicationIcons", node
)))
727 config_menu_client_list_icons
= parse_bool(doc
, n
);
731 static void parse_resistance(ObParseInst
*i
, xmlDocPtr doc
, xmlNodePtr node
,
736 node
= node
->children
;
737 if ((n
= parse_find_node("strength", node
)))
738 config_resist_win
= parse_int(doc
, n
);
739 if ((n
= parse_find_node("screen_edge_strength", node
)))
740 config_resist_edge
= parse_int(doc
, n
);
746 const gchar
*actname
;
749 static void bind_default_keyboard()
752 ObDefKeyBind binds
[] = {
753 { "A-Tab", "NextWindow" },
754 { "S-A-Tab", "PreviousWindow" },
759 for (it
= binds
; it
->key
; ++it
) {
760 GList
*l
= g_list_append(NULL
, g_strdup(it
->key
));
761 keyboard_bind(l
, action_from_string(it
->actname
,
762 OB_USER_ACTION_KEYBOARD_KEY
));
769 const gchar
*context
;
770 const ObMouseAction mact
;
771 const gchar
*actname
;
774 static void bind_default_mouse()
777 ObDefMouseBind binds
[] = {
778 { "Left", "Client", OB_MOUSE_ACTION_PRESS
, "Focus" },
779 { "Middle", "Client", OB_MOUSE_ACTION_PRESS
, "Focus" },
780 { "Right", "Client", OB_MOUSE_ACTION_PRESS
, "Focus" },
781 { "Left", "Desktop", OB_MOUSE_ACTION_PRESS
, "Focus" },
782 { "Middle", "Desktop", OB_MOUSE_ACTION_PRESS
, "Focus" },
783 { "Right", "Desktop", OB_MOUSE_ACTION_PRESS
, "Focus" },
784 { "Left", "Titlebar", OB_MOUSE_ACTION_PRESS
, "Focus" },
785 { "Left", "Bottom", OB_MOUSE_ACTION_PRESS
, "Focus" },
786 { "Left", "BLCorner", OB_MOUSE_ACTION_PRESS
, "Focus" },
787 { "Left", "BRCorner", OB_MOUSE_ACTION_PRESS
, "Focus" },
788 { "Left", "TLCorner", OB_MOUSE_ACTION_PRESS
, "Focus" },
789 { "Left", "TRCorner", OB_MOUSE_ACTION_PRESS
, "Focus" },
790 { "Left", "Close", OB_MOUSE_ACTION_PRESS
, "Focus" },
791 { "Left", "Maximize", OB_MOUSE_ACTION_PRESS
, "Focus" },
792 { "Left", "Iconify", OB_MOUSE_ACTION_PRESS
, "Focus" },
793 { "Left", "Icon", OB_MOUSE_ACTION_PRESS
, "Focus" },
794 { "Left", "AllDesktops", OB_MOUSE_ACTION_PRESS
, "Focus" },
795 { "Left", "Shade", OB_MOUSE_ACTION_PRESS
, "Focus" },
796 { "Left", "Client", OB_MOUSE_ACTION_CLICK
, "Raise" },
797 { "Left", "Titlebar", OB_MOUSE_ACTION_CLICK
, "Raise" },
798 { "Middle", "Titlebar", OB_MOUSE_ACTION_CLICK
, "Lower" },
799 { "Left", "BLCorner", OB_MOUSE_ACTION_CLICK
, "Raise" },
800 { "Left", "BRCorner", OB_MOUSE_ACTION_CLICK
, "Raise" },
801 { "Left", "TLCorner", OB_MOUSE_ACTION_CLICK
, "Raise" },
802 { "Left", "TRCorner", OB_MOUSE_ACTION_CLICK
, "Raise" },
803 { "Left", "Close", OB_MOUSE_ACTION_CLICK
, "Raise" },
804 { "Left", "Maximize", OB_MOUSE_ACTION_CLICK
, "Raise" },
805 { "Left", "Iconify", OB_MOUSE_ACTION_CLICK
, "Raise" },
806 { "Left", "Icon", OB_MOUSE_ACTION_CLICK
, "Raise" },
807 { "Left", "AllDesktops", OB_MOUSE_ACTION_CLICK
, "Raise" },
808 { "Left", "Shade", OB_MOUSE_ACTION_CLICK
, "Raise" },
809 { "Left", "Close", OB_MOUSE_ACTION_CLICK
, "Close" },
810 { "Left", "Maximize", OB_MOUSE_ACTION_CLICK
, "ToggleMaximizeFull" },
811 { "Left", "Iconify", OB_MOUSE_ACTION_CLICK
, "Iconify" },
812 { "Left", "AllDesktops", OB_MOUSE_ACTION_CLICK
, "ToggleOmnipresent" },
813 { "Left", "Shade", OB_MOUSE_ACTION_CLICK
, "ToggleShade" },
814 { "Left", "TLCorner", OB_MOUSE_ACTION_MOTION
, "Resize" },
815 { "Left", "TRCorner", OB_MOUSE_ACTION_MOTION
, "Resize" },
816 { "Left", "BLCorner", OB_MOUSE_ACTION_MOTION
, "Resize" },
817 { "Left", "BRCorner", OB_MOUSE_ACTION_MOTION
, "Resize" },
818 { "Left", "Titlebar", OB_MOUSE_ACTION_MOTION
, "Move" },
819 { "A-Left", "Frame", OB_MOUSE_ACTION_MOTION
, "Move" },
820 { "A-Middle", "Frame", OB_MOUSE_ACTION_MOTION
, "Resize" },
821 { NULL
, NULL
, 0, NULL
}
824 for (it
= binds
; it
->button
; ++it
) {
827 case OB_MOUSE_ACTION_PRESS
:
828 uact
= OB_USER_ACTION_MOUSE_PRESS
; break;
829 case OB_MOUSE_ACTION_RELEASE
:
830 uact
= OB_USER_ACTION_MOUSE_RELEASE
; break;
831 case OB_MOUSE_ACTION_CLICK
:
832 uact
= OB_USER_ACTION_MOUSE_CLICK
; break;
833 case OB_MOUSE_ACTION_DOUBLE_CLICK
:
834 uact
= OB_USER_ACTION_MOUSE_DOUBLE_CLICK
; break;
835 case OB_MOUSE_ACTION_MOTION
:
836 uact
= OB_USER_ACTION_MOUSE_MOTION
; break;
838 g_assert_not_reached();
840 mouse_bind(it
->button
, it
->context
, it
->mact
,
841 action_from_string(it
->actname
, uact
));
845 void config_startup(ObParseInst
*i
)
847 config_focus_new
= TRUE
;
848 config_focus_follow
= FALSE
;
849 config_focus_delay
= 0;
850 config_focus_raise
= FALSE
;
851 config_focus_last
= FALSE
;
853 parse_register(i
, "focus", parse_focus
, NULL
);
855 config_place_policy
= OB_PLACE_POLICY_SMART
;
857 parse_register(i
, "placement", parse_placement
, NULL
);
861 config_animate_iconify
= TRUE
;
862 config_title_layout
= g_strdup("NLIMC");
863 config_theme_keepborder
= TRUE
;
865 config_font_activewindow
= NULL
;
866 config_font_inactivewindow
= NULL
;
867 config_font_menuitem
= NULL
;
868 config_font_menutitle
= NULL
;
870 parse_register(i
, "theme", parse_theme
, NULL
);
872 config_desktops_num
= 4;
873 config_screen_firstdesk
= 1;
874 config_desktops_names
= NULL
;
876 parse_register(i
, "desktops", parse_desktops
, NULL
);
878 config_resize_redraw
= TRUE
;
879 config_resize_four_corners
= FALSE
;
880 config_resize_popup_show
= 1; /* nonpixel increments */
881 config_resize_popup_pos
= 0; /* center of client */
883 parse_register(i
, "resize", parse_resize
, NULL
);
885 config_dock_layer
= OB_STACKING_LAYER_ABOVE
;
886 config_dock_pos
= OB_DIRECTION_NORTHEAST
;
887 config_dock_floating
= FALSE
;
888 config_dock_nostrut
= FALSE
;
891 config_dock_orient
= OB_ORIENTATION_VERT
;
892 config_dock_hide
= FALSE
;
893 config_dock_hide_delay
= 300;
894 config_dock_show_delay
= 300;
895 config_dock_app_move_button
= 2; /* middle */
896 config_dock_app_move_modifiers
= 0;
898 parse_register(i
, "dock", parse_dock
, NULL
);
900 translate_key("C-g", &config_keyboard_reset_state
,
901 &config_keyboard_reset_keycode
);
903 bind_default_keyboard();
905 parse_register(i
, "keyboard", parse_keyboard
, NULL
);
907 config_mouse_threshold
= 8;
908 config_mouse_dclicktime
= 200;
910 bind_default_mouse();
912 parse_register(i
, "mouse", parse_mouse
, NULL
);
914 config_resist_win
= 10;
915 config_resist_edge
= 20;
917 parse_register(i
, "resistance", parse_resistance
, NULL
);
919 config_menu_hide_delay
= 250;
920 config_menu_middle
= FALSE
;
921 config_submenu_show_delay
= 0;
922 config_menu_client_list_icons
= TRUE
;
923 config_menu_files
= NULL
;
925 parse_register(i
, "menu", parse_menu
, NULL
);
927 config_per_app_settings
= NULL
;
929 parse_register(i
, "applications", parse_per_app_settings
, NULL
);
932 void config_shutdown()
936 g_free(config_theme
);
938 g_free(config_title_layout
);
940 RrFontClose(config_font_activewindow
);
941 RrFontClose(config_font_inactivewindow
);
942 RrFontClose(config_font_menuitem
);
943 RrFontClose(config_font_menutitle
);
945 for (it
= config_desktops_names
; it
; it
= g_slist_next(it
))
947 g_slist_free(config_desktops_names
);
949 for (it
= config_menu_files
; it
; it
= g_slist_next(it
))
951 g_slist_free(config_menu_files
);
953 for (it
= config_per_app_settings
; it
; it
= g_slist_next(it
)) {
954 ObAppSettings
*itd
= (ObAppSettings
*)it
->data
;
955 if (itd
->name
) g_pattern_spec_free(itd
->name
);
956 if (itd
->role
) g_pattern_spec_free(itd
->role
);
957 if (itd
->class) g_pattern_spec_free(itd
->class);
960 g_slist_free(config_per_app_settings
);