]> Dogcows Code - chaz/openbox/blob - scripts/behavior.py
change the default titlebar layout
[chaz/openbox] / scripts / behavior.py
1 ###############################################################################
2 ### Functions for setting up some default behaviors. This includes the ###
3 ### default bindings for clicking on various parts of a window, the ###
4 ### titlebar buttons, and bindings for the scroll wheel on your mouse. ###
5 ###############################################################################
6
7 import ob
8 import callbacks
9 import motion
10
11 def setup_window_clicks():
12 """Sets up the default bindings for various mouse buttons for various
13 contexts.
14 This includes:
15 * Alt-left drag anywhere on a window will move it
16 * Alt-right drag anywhere on a window will resize it
17 * Left drag on a window's titlebar/handle will move it
18 * Left drag on a window's handle grips will resize it
19 * Alt-left press anywhere on a window's will raise it to the front of
20 its stacking layer.
21 * Left press on a window's titlebar/handle will raise it to the front
22 of its stacking layer.
23 * Alt-middle click anywhere on a window's will lower it to the bottom
24 of its stacking layer.
25 * Middle click on a window's titlebar/handle will lower it to the
26 bottom of its stacking layer.
27 * Double-left click on a window's titlebar will toggle shading it
28 """
29 ob.mbind("A-Left", ob.MouseContext.Frame,
30 ob.MouseAction.Motion, motion.move)
31 ob.mbind("A-Left", ob.MouseContext.Frame,
32 ob.MouseAction.Release, motion.end_move)
33 ob.mbind("Left", ob.MouseContext.Titlebar,
34 ob.MouseAction.Motion, motion.move)
35 ob.mbind("Left", ob.MouseContext.Titlebar,
36 ob.MouseAction.Release, motion.end_move)
37 ob.mbind("Left", ob.MouseContext.Handle,
38 ob.MouseAction.Motion, motion.move)
39 ob.mbind("Left", ob.MouseContext.Handle,
40 ob.MouseAction.Release, motion.end_move)
41
42 ob.mbind("A-Right", ob.MouseContext.Frame,
43 ob.MouseAction.Motion, motion.resize)
44 ob.mbind("A-Right", ob.MouseContext.Frame,
45 ob.MouseAction.Release, motion.end_resize)
46 ob.mbind("Left", ob.MouseContext.Grip,
47 ob.MouseAction.Motion, motion.resize)
48 ob.mbind("Left", ob.MouseContext.Grip,
49 ob.MouseAction.Release, motion.end_resize)
50
51 ob.mbind("Left", ob.MouseContext.Titlebar,
52 ob.MouseAction.Press, callbacks.raise_win)
53 ob.mbind("Left", ob.MouseContext.Handle,
54 ob.MouseAction.Press, callbacks.raise_win)
55 ob.mbind("A-Left", ob.MouseContext.Frame,
56 ob.MouseAction.Press, callbacks.raise_win)
57 ob.mbind("A-Middle", ob.MouseContext.Frame,
58 ob.MouseAction.Click, callbacks.lower_win)
59 ob.mbind("Middle", ob.MouseContext.Titlebar,
60 ob.MouseAction.Click, callbacks.lower_win)
61 ob.mbind("Middle", ob.MouseContext.Handle,
62 ob.MouseAction.Click, callbacks.lower_win)
63
64 ob.mbind("Left", ob.MouseContext.Titlebar,
65 ob.MouseAction.DoubleClick, callbacks.toggle_shade)
66
67 def setup_window_buttons():
68 """Sets up the default behaviors for the buttons in the window titlebar."""
69 ob.mbind("Left", ob.MouseContext.AllDesktopsButton,
70 ob.MouseAction.Click, callbacks.toggle_all_desktops)
71 ob.mbind("Left", ob.MouseContext.CloseButton,
72 ob.MouseAction.Click, callbacks.close)
73 ob.mbind("Left", ob.MouseContext.IconifyButton,
74 ob.MouseAction.Click, callbacks.iconify)
75 ob.mbind("Left", ob.MouseContext.MaximizeButton,
76 ob.MouseAction.Click, callbacks.toggle_maximize)
77 ob.mbind("Middle", ob.MouseContext.MaximizeButton,
78 ob.MouseAction.Click, callbacks.toggle_maximize_vert)
79 ob.mbind("Right", ob.MouseContext.MaximizeButton,
80 ob.MouseAction.Click, callbacks.toggle_maximize_horz)
81
82 def setup_scroll():
83 """Sets up the default behaviors for the mouse scroll wheel.
84 This includes:
85 * scrolling on a window titlebar will shade/unshade it
86 * alt-scrolling anywhere will switch to the next/previous desktop
87 * control-alt-scrolling on a window will send it to the next/previous
88 desktop, and switch to the desktop with the window
89 """
90 ob.mbind("Up", ob.MouseContext.Titlebar,
91 ob.MouseAction.Click, callbacks.shade)
92 ob.mbind("Down", ob.MouseContext.Titlebar,
93 ob.MouseAction.Click, callbacks.unshade)
94
95 ob.mbind("A-Up", ob.MouseContext.Frame,
96 ob.MouseAction.Click, callbacks.next_desktop)
97 ob.mbind("A-Up", ob.MouseContext.Root,
98 ob.MouseAction.Click, callbacks.next_desktop)
99 ob.mbind("Up", ob.MouseContext.Root,
100 ob.MouseAction.Click, callbacks.next_desktop)
101 ob.mbind("A-Down", ob.MouseContext.Frame,
102 ob.MouseAction.Click, callbacks.prev_desktop)
103 ob.mbind("A-Down", ob.MouseContext.Root,
104 ob.MouseAction.Click, callbacks.prev_desktop)
105 ob.mbind("Down", ob.MouseContext.Root,
106 ob.MouseAction.Click, callbacks.prev_desktop)
107
108 ob.mbind("C-A-Up", ob.MouseContext.Frame,
109 ob.MouseAction.Click, callbacks.send_to_next_desktop)
110 ob.mbind("C-A-Down", ob.MouseContext.Frame,
111 ob.MouseAction.Click, callbacks.send_to_prev_desktop)
112
113 print "Loaded behavior.py"
This page took 0.037678 seconds and 4 git commands to generate.