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
;
36 gboolean config_focus_under_mouse
;
38 ObPlacePolicy config_place_policy
;
41 gboolean config_theme_keepborder
;
43 gchar
*config_title_layout
;
45 gboolean config_animate_iconify
;
47 RrFont
*config_font_activewindow
;
48 RrFont
*config_font_inactivewindow
;
49 RrFont
*config_font_menuitem
;
50 RrFont
*config_font_menutitle
;
51 RrFont
*config_font_osd
;
53 gint config_desktops_num
;
54 GSList
*config_desktops_names
;
55 guint config_screen_firstdesk
;
57 gboolean config_resize_redraw
;
58 gboolean config_resize_four_corners
;
59 gint config_resize_popup_show
;
60 gint config_resize_popup_pos
;
62 ObStackingLayer config_dock_layer
;
63 gboolean config_dock_floating
;
64 gboolean config_dock_nostrut
;
65 ObDirection config_dock_pos
;
68 ObOrientation config_dock_orient
;
69 gboolean config_dock_hide
;
70 guint config_dock_hide_delay
;
71 guint config_dock_show_delay
;
72 guint config_dock_app_move_button
;
73 guint config_dock_app_move_modifiers
;
75 guint config_keyboard_reset_keycode
;
76 guint config_keyboard_reset_state
;
78 gint config_mouse_threshold
;
79 gint config_mouse_dclicktime
;
81 guint config_menu_hide_delay
;
82 gboolean config_menu_middle
;
83 guint config_submenu_show_delay
;
84 gboolean config_menu_client_list_icons
;
86 GSList
*config_menu_files
;
88 gint config_resist_win
;
89 gint config_resist_edge
;
91 GSList
*config_per_app_settings
;
93 ObAppSettings
* config_create_app_settings()
95 ObAppSettings
*settings
= g_new0(ObAppSettings
, 1);
98 settings
->monitor
= -1;
100 settings
->desktop
= 0;
101 settings
->layer
= -2;
102 settings
->iconic
= -1;
103 settings
->skip_pager
= -1;
104 settings
->skip_taskbar
= -1;
105 settings
->fullscreen
= -1;
106 settings
->max_horz
= -1;
107 settings
->max_vert
= -1;
111 #define copy_if(setting, default) \
112 if (src->setting != default) dst->setting = src->setting
113 void config_app_settings_copy_non_defaults(const ObAppSettings
*src
,
116 g_assert(src
!= NULL
);
117 g_assert(dst
!= NULL
);
125 copy_if(skip_pager
, -1);
126 copy_if(skip_taskbar
, -1);
127 copy_if(fullscreen
, -1);
128 copy_if(max_horz
, -1);
129 copy_if(max_vert
, -1);
131 if (src
->pos_given
) {
132 dst
->pos_given
= TRUE
;
133 dst
->center_x
= src
->center_x
;
134 dst
->center_y
= src
->center_y
;
135 dst
->opposite_x
= src
->opposite_x
;
136 dst
->opposite_y
= src
->opposite_y
;
137 dst
->position
.x
= src
->position
.x
;
138 dst
->position
.y
= src
->position
.y
;
139 dst
->monitor
= src
->monitor
;
145 <application name="aterm">
148 <application name="Rhythmbox">
155 .. there is a lot more settings available
160 /* Manages settings for individual applications.
161 Some notes: monitor is the screen number in a multi monitor
162 (Xinerama) setup (starting from 0) or mouse, meaning the
163 monitor the pointer is on. Default: mouse.
164 Layer can be three values, above (Always on top), below
165 (Always on bottom) and everything else (normal behaviour).
166 Positions can be an integer value or center, which will
167 center the window in the specified axis. Position is within
168 the monitor, so <position><x>center</x></position><monitor>2</monitor>
169 will center the window on the second monitor.
171 static void parse_per_app_settings(ObParseInst
*i
, xmlDocPtr doc
,
172 xmlNodePtr node
, gpointer d
)
174 xmlNodePtr app
= parse_find_node("application", node
->children
);
175 gchar
*name
= NULL
, *class = NULL
, *role
= NULL
;
176 gboolean name_set
, class_set
;
177 gboolean x_pos_given
;
180 name_set
= class_set
= x_pos_given
= FALSE
;
182 class_set
= parse_attr_string("class", app
, &class);
183 name_set
= parse_attr_string("name", app
, &name
);
184 if (class_set
|| name_set
) {
186 ObAppSettings
*settings
= config_create_app_settings();;
189 settings
->name
= g_pattern_spec_new(name
);
192 settings
->class = g_pattern_spec_new(class);
194 if (parse_attr_string("role", app
, &role
))
195 settings
->role
= g_pattern_spec_new(role
);
197 if ((n
= parse_find_node("decor", app
->children
)))
198 if (!parse_contains("default", doc
, n
))
199 settings
->decor
= parse_bool(doc
, n
);
201 if ((n
= parse_find_node("shade", app
->children
)))
202 if (!parse_contains("default", doc
, n
))
203 settings
->shade
= parse_bool(doc
, n
);
205 if ((n
= parse_find_node("position", app
->children
))) {
206 if ((c
= parse_find_node("x", n
->children
)))
207 if (!parse_contains("default", doc
, c
)) {
208 gchar
*s
= parse_string(doc
, c
);
209 if (!strcmp(s
, "center")) {
210 settings
->center_x
= TRUE
;
214 settings
->opposite_x
= TRUE
;
215 if (s
[0] == '-' || s
[0] == '+')
216 settings
->position
.x
= atoi(s
+1);
218 settings
->position
.x
= atoi(s
);
224 if (x_pos_given
&& (c
= parse_find_node("y", n
->children
)))
225 if (!parse_contains("default", doc
, c
)) {
226 gchar
*s
= parse_string(doc
, c
);
227 if (!strcmp(s
, "center")) {
228 settings
->center_y
= TRUE
;
229 settings
->pos_given
= TRUE
;
232 settings
->opposite_y
= TRUE
;
233 if (s
[0] == '-' || s
[0] == '+')
234 settings
->position
.y
= atoi(s
+1);
236 settings
->position
.y
= atoi(s
);
237 settings
->pos_given
= TRUE
;
242 if (settings
->pos_given
&&
243 (c
= parse_find_node("monitor", n
->children
)))
244 if (!parse_contains("default", doc
, c
)) {
245 gchar
*s
= parse_string(doc
, c
);
246 if (!strcmp(s
, "mouse"))
247 settings
->monitor
= 0;
249 settings
->monitor
= parse_int(doc
, c
) + 1;
254 if ((n
= parse_find_node("focus", app
->children
)))
255 if (!parse_contains("default", doc
, n
))
256 settings
->focus
= parse_bool(doc
, n
);
258 if ((n
= parse_find_node("desktop", app
->children
))) {
259 if (!parse_contains("default", doc
, n
)) {
260 gchar
*s
= parse_string(doc
, n
);
261 if (!strcmp(s
, "all"))
262 settings
->desktop
= DESKTOP_ALL
;
264 gint i
= parse_int(doc
, n
);
266 settings
->desktop
= i
;
272 if ((n
= parse_find_node("layer", app
->children
)))
273 if (!parse_contains("default", doc
, n
)) {
274 gchar
*s
= parse_string(doc
, n
);
275 if (!strcmp(s
, "above"))
277 else if (!strcmp(s
, "below"))
278 settings
->layer
= -1;
284 if ((n
= parse_find_node("iconic", app
->children
)))
285 if (!parse_contains("default", doc
, n
))
286 settings
->iconic
= parse_bool(doc
, n
);
288 if ((n
= parse_find_node("skip_pager", app
->children
)))
289 if (!parse_contains("default", doc
, n
))
290 settings
->skip_pager
= parse_bool(doc
, n
);
292 if ((n
= parse_find_node("skip_taskbar", app
->children
)))
293 if (!parse_contains("default", doc
, n
))
294 settings
->skip_taskbar
= parse_bool(doc
, n
);
296 if ((n
= parse_find_node("fullscreen", app
->children
)))
297 if (!parse_contains("default", doc
, n
))
298 settings
->fullscreen
= parse_bool(doc
, n
);
300 if ((n
= parse_find_node("maximized", app
->children
)))
301 if (!parse_contains("default", doc
, n
)) {
302 gchar
*s
= parse_string(doc
, n
);
303 if (!strcmp(s
, "horizontal")) {
304 settings
->max_horz
= TRUE
;
305 settings
->max_vert
= FALSE
;
306 } else if (!strcmp(s
, "vertical")) {
307 settings
->max_horz
= FALSE
;
308 settings
->max_vert
= TRUE
;
310 settings
->max_horz
= settings
->max_vert
=
315 config_per_app_settings
= g_slist_append(config_per_app_settings
,
316 (gpointer
) settings
);
319 app
= parse_find_node("application", app
->next
);
330 <action name="ChangeDesktop">
337 static void parse_key(ObParseInst
*i
, xmlDocPtr doc
, xmlNodePtr node
,
342 gboolean is_chroot
= FALSE
;
344 if (!parse_attr_string("key", node
, &key
))
347 parse_attr_bool("chroot", node
, &is_chroot
);
349 keylist
= g_list_append(keylist
, key
);
351 if ((n
= parse_find_node("keybind", node
->children
))) {
353 parse_key(i
, doc
, n
, keylist
);
354 n
= parse_find_node("keybind", n
->next
);
357 else if ((n
= parse_find_node("action", node
->children
))) {
361 action
= action_parse(i
, doc
, n
, OB_USER_ACTION_KEYBOARD_KEY
);
363 keyboard_bind(keylist
, action
);
364 n
= parse_find_node("action", n
->next
);
369 keyboard_chroot(keylist
);
372 keylist
= g_list_delete_link(keylist
, g_list_last(keylist
));
375 static void parse_keyboard(ObParseInst
*i
, xmlDocPtr doc
, xmlNodePtr node
,
381 keyboard_unbind_all();
383 if ((n
= parse_find_node("chainQuitKey", node
->children
))) {
384 key
= parse_string(doc
, n
);
385 translate_key(key
, &config_keyboard_reset_state
,
386 &config_keyboard_reset_keycode
);
390 if ((n
= parse_find_node("keybind", node
->children
)))
392 parse_key(i
, doc
, n
, NULL
);
393 n
= parse_find_node("keybind", n
->next
);
399 <context name="Titlebar">
400 <mousebind button="Left" action="Press">
401 <action name="Raise"></action>
407 static void parse_mouse(ObParseInst
*i
, xmlDocPtr doc
, xmlNodePtr node
,
410 xmlNodePtr n
, nbut
, nact
;
419 node
= node
->children
;
421 if ((n
= parse_find_node("dragThreshold", node
)))
422 config_mouse_threshold
= parse_int(doc
, n
);
423 if ((n
= parse_find_node("doubleClickTime", node
)))
424 config_mouse_dclicktime
= parse_int(doc
, n
);
426 n
= parse_find_node("context", node
);
428 if (!parse_attr_string("name", n
, &contextstr
))
430 nbut
= parse_find_node("mousebind", n
->children
);
432 if (!parse_attr_string("button", nbut
, &buttonstr
))
434 if (parse_attr_contains("press", nbut
, "action")) {
435 uact
= OB_USER_ACTION_MOUSE_PRESS
;
436 mact
= OB_MOUSE_ACTION_PRESS
;
437 } else if (parse_attr_contains("release", nbut
, "action")) {
438 uact
= OB_USER_ACTION_MOUSE_RELEASE
;
439 mact
= OB_MOUSE_ACTION_RELEASE
;
440 } else if (parse_attr_contains("click", nbut
, "action")) {
441 uact
= OB_USER_ACTION_MOUSE_CLICK
;
442 mact
= OB_MOUSE_ACTION_CLICK
;
443 } else if (parse_attr_contains("doubleclick", nbut
,"action")) {
444 uact
= OB_USER_ACTION_MOUSE_DOUBLE_CLICK
;
445 mact
= OB_MOUSE_ACTION_DOUBLE_CLICK
;
446 } else if (parse_attr_contains("drag", nbut
, "action")) {
447 uact
= OB_USER_ACTION_MOUSE_MOTION
;
448 mact
= OB_MOUSE_ACTION_MOTION
;
451 nact
= parse_find_node("action", nbut
->children
);
453 if ((action
= action_parse(i
, doc
, nact
, uact
)))
454 mouse_bind(buttonstr
, contextstr
, mact
, action
);
455 nact
= parse_find_node("action", nact
->next
);
459 nbut
= parse_find_node("mousebind", nbut
->next
);
463 n
= parse_find_node("context", n
->next
);
467 static void parse_focus(ObParseInst
*i
, xmlDocPtr doc
, xmlNodePtr node
,
472 node
= node
->children
;
474 if ((n
= parse_find_node("focusNew", node
)))
475 config_focus_new
= parse_bool(doc
, n
);
476 if ((n
= parse_find_node("followMouse", node
)))
477 config_focus_follow
= parse_bool(doc
, n
);
478 if ((n
= parse_find_node("focusDelay", node
)))
479 config_focus_delay
= parse_int(doc
, n
) * 1000;
480 if ((n
= parse_find_node("raiseOnFocus", node
)))
481 config_focus_raise
= parse_bool(doc
, n
);
482 if ((n
= parse_find_node("focusLast", node
)))
483 config_focus_last
= parse_bool(doc
, n
);
484 if ((n
= parse_find_node("underMouse", node
)))
485 config_focus_under_mouse
= parse_bool(doc
, n
);
488 static void parse_placement(ObParseInst
*i
, xmlDocPtr doc
, xmlNodePtr node
,
493 node
= node
->children
;
495 if ((n
= parse_find_node("policy", node
)))
496 if (parse_contains("UnderMouse", doc
, n
))
497 config_place_policy
= OB_PLACE_POLICY_MOUSE
;
500 static void parse_theme(ObParseInst
*i
, xmlDocPtr doc
, xmlNodePtr node
,
505 node
= node
->children
;
507 if ((n
= parse_find_node("name", node
))) {
510 g_free(config_theme
);
511 c
= parse_string(doc
, n
);
512 config_theme
= parse_expand_tilde(c
);
515 if ((n
= parse_find_node("titleLayout", node
))) {
518 g_free(config_title_layout
);
519 config_title_layout
= parse_string(doc
, n
);
521 /* replace duplicates with spaces */
522 for (c
= config_title_layout
; *c
!= '\0'; ++c
)
523 for (d
= c
+1; *d
!= '\0'; ++d
)
524 if (*c
== *d
) *d
= ' ';
526 if ((n
= parse_find_node("keepBorder", node
)))
527 config_theme_keepborder
= parse_bool(doc
, n
);
528 if ((n
= parse_find_node("animateIconify", node
)))
529 config_animate_iconify
= parse_bool(doc
, n
);
531 n
= parse_find_node("font", node
);
535 gchar
*name
= g_strdup(RrDefaultFontFamily
);
536 gint size
= RrDefaultFontSize
;
537 RrFontWeight weight
= RrDefaultFontWeight
;
538 RrFontSlant slant
= RrDefaultFontSlant
;
540 if (parse_attr_contains("ActiveWindow", n
, "place"))
541 font
= &config_font_activewindow
;
542 else if (parse_attr_contains("InactiveWindow", n
, "place"))
543 font
= &config_font_inactivewindow
;
544 else if (parse_attr_contains("MenuHeader", n
, "place"))
545 font
= &config_font_menutitle
;
546 else if (parse_attr_contains("MenuItem", n
, "place"))
547 font
= &config_font_menuitem
;
548 else if (parse_attr_contains("OnScreenDisplay", n
, "place"))
549 font
= &config_font_osd
;
553 if ((fnode
= parse_find_node("name", n
->children
))) {
555 name
= parse_string(doc
, fnode
);
557 if ((fnode
= parse_find_node("size", n
->children
))) {
558 int s
= parse_int(doc
, fnode
);
561 if ((fnode
= parse_find_node("weight", n
->children
))) {
562 gchar
*w
= parse_string(doc
, fnode
);
563 if (!g_ascii_strcasecmp(w
, "Bold"))
564 weight
= RR_FONTWEIGHT_BOLD
;
567 if ((fnode
= parse_find_node("slant", n
->children
))) {
568 gchar
*s
= parse_string(doc
, fnode
);
569 if (!g_ascii_strcasecmp(s
, "Italic"))
570 slant
= RR_FONTSLANT_ITALIC
;
571 if (!g_ascii_strcasecmp(s
, "Oblique"))
572 slant
= RR_FONTSLANT_OBLIQUE
;
576 *font
= RrFontOpen(ob_rr_inst
, name
, size
, weight
, slant
);
579 n
= parse_find_node("font", n
->next
);
583 static void parse_desktops(ObParseInst
*i
, xmlDocPtr doc
, xmlNodePtr node
,
588 node
= node
->children
;
590 if ((n
= parse_find_node("number", node
))) {
591 gint d
= parse_int(doc
, n
);
593 config_desktops_num
= d
;
595 if ((n
= parse_find_node("firstdesk", node
))) {
596 gint d
= parse_int(doc
, n
);
598 config_screen_firstdesk
= (unsigned) d
;
600 if ((n
= parse_find_node("names", node
))) {
604 for (it
= config_desktops_names
; it
; it
= it
->next
)
606 g_slist_free(config_desktops_names
);
607 config_desktops_names
= NULL
;
609 nname
= parse_find_node("name", n
->children
);
611 config_desktops_names
= g_slist_append(config_desktops_names
,
612 parse_string(doc
, nname
));
613 nname
= parse_find_node("name", nname
->next
);
618 static void parse_resize(ObParseInst
*i
, xmlDocPtr doc
, xmlNodePtr node
,
623 node
= node
->children
;
625 if ((n
= parse_find_node("drawContents", node
)))
626 config_resize_redraw
= parse_bool(doc
, n
);
627 if ((n
= parse_find_node("popupShow", node
))) {
628 config_resize_popup_show
= parse_int(doc
, n
);
629 if (parse_contains("Always", doc
, n
))
630 config_resize_popup_show
= 2;
631 else if (parse_contains("Never", doc
, n
))
632 config_resize_popup_show
= 0;
633 else if (parse_contains("Nonpixel", doc
, n
))
634 config_resize_popup_show
= 1;
636 if ((n
= parse_find_node("popupPosition", node
))) {
637 config_resize_popup_pos
= parse_int(doc
, n
);
638 if (parse_contains("Top", doc
, n
))
639 config_resize_popup_pos
= 1;
640 else if (parse_contains("Center", doc
, n
))
641 config_resize_popup_pos
= 0;
645 static void parse_dock(ObParseInst
*i
, xmlDocPtr doc
, xmlNodePtr node
,
650 node
= node
->children
;
652 if ((n
= parse_find_node("position", node
))) {
653 if (parse_contains("TopLeft", doc
, n
))
654 config_dock_floating
= FALSE
,
655 config_dock_pos
= OB_DIRECTION_NORTHWEST
;
656 else if (parse_contains("Top", doc
, n
))
657 config_dock_floating
= FALSE
,
658 config_dock_pos
= OB_DIRECTION_NORTH
;
659 else if (parse_contains("TopRight", doc
, n
))
660 config_dock_floating
= FALSE
,
661 config_dock_pos
= OB_DIRECTION_NORTHEAST
;
662 else if (parse_contains("Right", doc
, n
))
663 config_dock_floating
= FALSE
,
664 config_dock_pos
= OB_DIRECTION_EAST
;
665 else if (parse_contains("BottomRight", doc
, n
))
666 config_dock_floating
= FALSE
,
667 config_dock_pos
= OB_DIRECTION_SOUTHEAST
;
668 else if (parse_contains("Bottom", doc
, n
))
669 config_dock_floating
= FALSE
,
670 config_dock_pos
= OB_DIRECTION_SOUTH
;
671 else if (parse_contains("BottomLeft", doc
, n
))
672 config_dock_floating
= FALSE
,
673 config_dock_pos
= OB_DIRECTION_SOUTHWEST
;
674 else if (parse_contains("Left", doc
, n
))
675 config_dock_floating
= FALSE
,
676 config_dock_pos
= OB_DIRECTION_WEST
;
677 else if (parse_contains("Floating", doc
, n
))
678 config_dock_floating
= TRUE
;
680 if (config_dock_floating
) {
681 if ((n
= parse_find_node("floatingX", node
)))
682 config_dock_x
= parse_int(doc
, n
);
683 if ((n
= parse_find_node("floatingY", node
)))
684 config_dock_y
= parse_int(doc
, n
);
686 if ((n
= parse_find_node("noStrut", node
)))
687 config_dock_nostrut
= parse_bool(doc
, n
);
689 if ((n
= parse_find_node("stacking", node
))) {
690 if (parse_contains("above", doc
, n
))
691 config_dock_layer
= OB_STACKING_LAYER_ABOVE
;
692 else if (parse_contains("normal", doc
, n
))
693 config_dock_layer
= OB_STACKING_LAYER_NORMAL
;
694 else if (parse_contains("below", doc
, n
))
695 config_dock_layer
= OB_STACKING_LAYER_BELOW
;
697 if ((n
= parse_find_node("direction", node
))) {
698 if (parse_contains("horizontal", doc
, n
))
699 config_dock_orient
= OB_ORIENTATION_HORZ
;
700 else if (parse_contains("vertical", doc
, n
))
701 config_dock_orient
= OB_ORIENTATION_VERT
;
703 if ((n
= parse_find_node("autoHide", node
)))
704 config_dock_hide
= parse_bool(doc
, n
);
705 if ((n
= parse_find_node("hideDelay", node
)))
706 config_dock_hide_delay
= parse_int(doc
, n
) * 1000;
707 if ((n
= parse_find_node("showDelay", node
)))
708 config_dock_show_delay
= parse_int(doc
, n
) * 1000;
709 if ((n
= parse_find_node("moveButton", node
))) {
710 gchar
*str
= parse_string(doc
, n
);
712 if (translate_button(str
, &s
, &b
)) {
713 config_dock_app_move_button
= b
;
714 config_dock_app_move_modifiers
= s
;
716 g_message(_("Invalid button '%s' specified in config file"), str
);
722 static void parse_menu(ObParseInst
*i
, xmlDocPtr doc
, xmlNodePtr node
,
726 for (node
= node
->children
; node
; node
= node
->next
) {
727 if (!xmlStrcasecmp(node
->name
, (const xmlChar
*) "file")) {
730 c
= parse_string(doc
, node
);
731 config_menu_files
= g_slist_append(config_menu_files
,
732 parse_expand_tilde(c
));
735 if ((n
= parse_find_node("hideDelay", node
)))
736 config_menu_hide_delay
= parse_int(doc
, n
);
737 if ((n
= parse_find_node("middle", node
)))
738 config_menu_middle
= parse_bool(doc
, n
);
739 if ((n
= parse_find_node("submenuShowDelay", node
)))
740 config_submenu_show_delay
= parse_int(doc
, n
);
741 if ((n
= parse_find_node("applicationIcons", node
)))
742 config_menu_client_list_icons
= parse_bool(doc
, n
);
746 static void parse_resistance(ObParseInst
*i
, xmlDocPtr doc
, xmlNodePtr node
,
751 node
= node
->children
;
752 if ((n
= parse_find_node("strength", node
)))
753 config_resist_win
= parse_int(doc
, n
);
754 if ((n
= parse_find_node("screen_edge_strength", node
)))
755 config_resist_edge
= parse_int(doc
, n
);
761 const gchar
*actname
;
764 static void bind_default_keyboard()
767 ObDefKeyBind binds
[] = {
768 { "A-Tab", "NextWindow" },
769 { "S-A-Tab", "PreviousWindow" },
774 for (it
= binds
; it
->key
; ++it
) {
775 GList
*l
= g_list_append(NULL
, g_strdup(it
->key
));
776 keyboard_bind(l
, action_from_string(it
->actname
,
777 OB_USER_ACTION_KEYBOARD_KEY
));
784 const gchar
*context
;
785 const ObMouseAction mact
;
786 const gchar
*actname
;
789 static void bind_default_mouse()
792 ObDefMouseBind binds
[] = {
793 { "Left", "Client", OB_MOUSE_ACTION_PRESS
, "Focus" },
794 { "Middle", "Client", OB_MOUSE_ACTION_PRESS
, "Focus" },
795 { "Right", "Client", OB_MOUSE_ACTION_PRESS
, "Focus" },
796 { "Left", "Desktop", OB_MOUSE_ACTION_PRESS
, "Focus" },
797 { "Middle", "Desktop", OB_MOUSE_ACTION_PRESS
, "Focus" },
798 { "Right", "Desktop", OB_MOUSE_ACTION_PRESS
, "Focus" },
799 { "Left", "Titlebar", OB_MOUSE_ACTION_PRESS
, "Focus" },
800 { "Left", "Bottom", OB_MOUSE_ACTION_PRESS
, "Focus" },
801 { "Left", "BLCorner", OB_MOUSE_ACTION_PRESS
, "Focus" },
802 { "Left", "BRCorner", OB_MOUSE_ACTION_PRESS
, "Focus" },
803 { "Left", "TLCorner", OB_MOUSE_ACTION_PRESS
, "Focus" },
804 { "Left", "TRCorner", OB_MOUSE_ACTION_PRESS
, "Focus" },
805 { "Left", "Close", OB_MOUSE_ACTION_PRESS
, "Focus" },
806 { "Left", "Maximize", OB_MOUSE_ACTION_PRESS
, "Focus" },
807 { "Left", "Iconify", OB_MOUSE_ACTION_PRESS
, "Focus" },
808 { "Left", "Icon", OB_MOUSE_ACTION_PRESS
, "Focus" },
809 { "Left", "AllDesktops", OB_MOUSE_ACTION_PRESS
, "Focus" },
810 { "Left", "Shade", OB_MOUSE_ACTION_PRESS
, "Focus" },
811 { "Left", "Client", OB_MOUSE_ACTION_CLICK
, "Raise" },
812 { "Left", "Titlebar", OB_MOUSE_ACTION_CLICK
, "Raise" },
813 { "Middle", "Titlebar", OB_MOUSE_ACTION_CLICK
, "Lower" },
814 { "Left", "BLCorner", OB_MOUSE_ACTION_CLICK
, "Raise" },
815 { "Left", "BRCorner", OB_MOUSE_ACTION_CLICK
, "Raise" },
816 { "Left", "TLCorner", OB_MOUSE_ACTION_CLICK
, "Raise" },
817 { "Left", "TRCorner", OB_MOUSE_ACTION_CLICK
, "Raise" },
818 { "Left", "Close", OB_MOUSE_ACTION_CLICK
, "Raise" },
819 { "Left", "Maximize", OB_MOUSE_ACTION_CLICK
, "Raise" },
820 { "Left", "Iconify", OB_MOUSE_ACTION_CLICK
, "Raise" },
821 { "Left", "Icon", OB_MOUSE_ACTION_CLICK
, "Raise" },
822 { "Left", "AllDesktops", OB_MOUSE_ACTION_CLICK
, "Raise" },
823 { "Left", "Shade", OB_MOUSE_ACTION_CLICK
, "Raise" },
824 { "Left", "Close", OB_MOUSE_ACTION_CLICK
, "Close" },
825 { "Left", "Maximize", OB_MOUSE_ACTION_CLICK
, "ToggleMaximizeFull" },
826 { "Left", "Iconify", OB_MOUSE_ACTION_CLICK
, "Iconify" },
827 { "Left", "AllDesktops", OB_MOUSE_ACTION_CLICK
, "ToggleOmnipresent" },
828 { "Left", "Shade", OB_MOUSE_ACTION_CLICK
, "ToggleShade" },
829 { "Left", "TLCorner", OB_MOUSE_ACTION_MOTION
, "Resize" },
830 { "Left", "TRCorner", OB_MOUSE_ACTION_MOTION
, "Resize" },
831 { "Left", "BLCorner", OB_MOUSE_ACTION_MOTION
, "Resize" },
832 { "Left", "BRCorner", OB_MOUSE_ACTION_MOTION
, "Resize" },
833 { "Left", "Titlebar", OB_MOUSE_ACTION_MOTION
, "Move" },
834 { "A-Left", "Frame", OB_MOUSE_ACTION_MOTION
, "Move" },
835 { "A-Middle", "Frame", OB_MOUSE_ACTION_MOTION
, "Resize" },
836 { NULL
, NULL
, 0, NULL
}
839 for (it
= binds
; it
->button
; ++it
) {
842 case OB_MOUSE_ACTION_PRESS
:
843 uact
= OB_USER_ACTION_MOUSE_PRESS
; break;
844 case OB_MOUSE_ACTION_RELEASE
:
845 uact
= OB_USER_ACTION_MOUSE_RELEASE
; break;
846 case OB_MOUSE_ACTION_CLICK
:
847 uact
= OB_USER_ACTION_MOUSE_CLICK
; break;
848 case OB_MOUSE_ACTION_DOUBLE_CLICK
:
849 uact
= OB_USER_ACTION_MOUSE_DOUBLE_CLICK
; break;
850 case OB_MOUSE_ACTION_MOTION
:
851 uact
= OB_USER_ACTION_MOUSE_MOTION
; break;
853 g_assert_not_reached();
855 mouse_bind(it
->button
, it
->context
, it
->mact
,
856 action_from_string(it
->actname
, uact
));
860 void config_startup(ObParseInst
*i
)
862 config_focus_new
= TRUE
;
863 config_focus_follow
= FALSE
;
864 config_focus_delay
= 0;
865 config_focus_raise
= FALSE
;
866 config_focus_last
= TRUE
;
867 config_focus_under_mouse
= FALSE
;
869 parse_register(i
, "focus", parse_focus
, NULL
);
871 config_place_policy
= OB_PLACE_POLICY_SMART
;
873 parse_register(i
, "placement", parse_placement
, NULL
);
877 config_animate_iconify
= TRUE
;
878 config_title_layout
= g_strdup("NLIMC");
879 config_theme_keepborder
= TRUE
;
881 config_font_activewindow
= NULL
;
882 config_font_inactivewindow
= NULL
;
883 config_font_menuitem
= NULL
;
884 config_font_menutitle
= NULL
;
886 parse_register(i
, "theme", parse_theme
, NULL
);
888 config_desktops_num
= 4;
889 config_screen_firstdesk
= 1;
890 config_desktops_names
= NULL
;
892 parse_register(i
, "desktops", parse_desktops
, NULL
);
894 config_resize_redraw
= TRUE
;
895 config_resize_four_corners
= FALSE
;
896 config_resize_popup_show
= 1; /* nonpixel increments */
897 config_resize_popup_pos
= 0; /* center of client */
899 parse_register(i
, "resize", parse_resize
, NULL
);
901 config_dock_layer
= OB_STACKING_LAYER_ABOVE
;
902 config_dock_pos
= OB_DIRECTION_NORTHEAST
;
903 config_dock_floating
= FALSE
;
904 config_dock_nostrut
= FALSE
;
907 config_dock_orient
= OB_ORIENTATION_VERT
;
908 config_dock_hide
= FALSE
;
909 config_dock_hide_delay
= 300;
910 config_dock_show_delay
= 300;
911 config_dock_app_move_button
= 2; /* middle */
912 config_dock_app_move_modifiers
= 0;
914 parse_register(i
, "dock", parse_dock
, NULL
);
916 translate_key("C-g", &config_keyboard_reset_state
,
917 &config_keyboard_reset_keycode
);
919 bind_default_keyboard();
921 parse_register(i
, "keyboard", parse_keyboard
, NULL
);
923 config_mouse_threshold
= 8;
924 config_mouse_dclicktime
= 200;
926 bind_default_mouse();
928 parse_register(i
, "mouse", parse_mouse
, NULL
);
930 config_resist_win
= 10;
931 config_resist_edge
= 20;
933 parse_register(i
, "resistance", parse_resistance
, NULL
);
935 config_menu_hide_delay
= 250;
936 config_menu_middle
= FALSE
;
937 config_submenu_show_delay
= 0;
938 config_menu_client_list_icons
= TRUE
;
939 config_menu_files
= NULL
;
941 parse_register(i
, "menu", parse_menu
, NULL
);
943 config_per_app_settings
= NULL
;
945 parse_register(i
, "applications", parse_per_app_settings
, NULL
);
948 void config_shutdown()
952 g_free(config_theme
);
954 g_free(config_title_layout
);
956 RrFontClose(config_font_activewindow
);
957 RrFontClose(config_font_inactivewindow
);
958 RrFontClose(config_font_menuitem
);
959 RrFontClose(config_font_menutitle
);
961 for (it
= config_desktops_names
; it
; it
= g_slist_next(it
))
963 g_slist_free(config_desktops_names
);
965 for (it
= config_menu_files
; it
; it
= g_slist_next(it
))
967 g_slist_free(config_menu_files
);
969 for (it
= config_per_app_settings
; it
; it
= g_slist_next(it
)) {
970 ObAppSettings
*itd
= (ObAppSettings
*)it
->data
;
971 if (itd
->name
) g_pattern_spec_free(itd
->name
);
972 if (itd
->role
) g_pattern_spec_free(itd
->role
);
973 if (itd
->class) g_pattern_spec_free(itd
->class);
976 g_slist_free(config_per_app_settings
);