]>
Dogcows Code - chaz/openbox/blob - scripts/motion.py
1 ############################################################################
2 ### Functions that provide callbacks for motion events to move and ###
4 ############################################################################
6 #############################################################################
7 ### Options that can be modified to change the functions' behaviors. ###
9 # move_popup - display a coordinates popup when moving windows. ###
12 # NOT IMPLEMENTED (yet?) ###
13 # move_rubberband - display an outline while moving instead of moving the ###
14 ### actual window, until the move is completed. Good for ###
15 ### slower systems. ###
16 move_rubberband
= 0 ###
18 # resize_popup - display a size popup when resizing windows. ###
21 # NOT IMPLEMENTED (yet?) ###
22 # resize_rubberband - display an outline while resizing instead of ###
23 ### resizing the actual window, until the resize is ###
24 ### completed. Good for slower systems. ###
25 resize_rubberband
= 0 ###
27 # resize_nearest - 1 to resize from the corner nearest where the mouse ###
28 ### is, 0 to resize always from the bottom right corner. ###
29 resize_nearest
= 1 ###
31 #############################################################################
55 global _screen
, _client
, _cx
, _cy
, _dx
, _dy
60 global move_rubberband
62 # draw the outline ...
69 global _popwidget
, _poplabel
70 style
= ob
.openbox
.screen(_screen
).style()
71 font
= style
.labelFont()
72 text
= "X: " + str(x
) + " Y: " + str(y
)
73 length
= font
.measureString(text
)
75 _popwidget
= otk
.Widget(ob
.openbox
, style
,
76 otk
.Widget
.Horizontal
, 0,
77 style
.bevelWidth(), 1)
78 _popwidget
.setTexture(style
.titlebarFocusBackground())
79 _poplabel
= otk
.Label(_popwidget
)
80 _poplabel
.setTexture(style
.labelFocusBackground())
82 _poplabel
.resize(length
, font
.height())
83 _poplabel
.setText(text
)
84 area
= otk
.display
.screenInfo(_screen
).rect()
86 _popwidget
.move(area
.x() + (area
.width() -
87 _popwidget
.width()) / 2,
88 area
.y() + (area
.height() -
89 _popwidget
.height()) / 2)
92 """Moves the window interactively. This should only be used with
93 MouseMotion events. If move_popup or move_rubberband is enabled, then
94 the end_move function needs to be bound as well."""
95 if not data
.client
: return
97 # not-normal windows dont get moved
98 if not data
.client
.normal(): return
100 global _screen
, _client
, _cx
, _cy
, _dx
, _dy
101 _screen
= data
.screen
102 _client
= data
.client
103 _cx
= data
.press_clientx
104 _cy
= data
.press_clienty
105 _dx
= data
.xroot
- data
.pressx
106 _dy
= data
.yroot
- data
.pressy
111 """Complete the interactive move of a window."""
112 global move_rubberband
, _inmotion
113 global _popwidget
, _poplabel
124 global _screen
, _client
, _cx
, _cy
, _cw
, _ch
, _px
, _py
, _dx
, _dy
126 # pick a corner to anchor
127 if not (resize_nearest
or _context
== ob
.MouseContext
.Grip
):
128 corner
= ob
.Client
.TopLeft
134 corner
= ob
.Client
.BottomRight
137 corner
= ob
.Client
.BottomLeft
141 corner
= ob
.Client
.TopRight
144 corner
= ob
.Client
.TopLeft
150 if resize_rubberband
:
151 # draw the outline ...
154 _client
.resize(corner
, w
, h
)
158 global _popwidget
, _poplabel
159 style
= ob
.openbox
.screen(_screen
).style()
160 ls
= _client
.logicalSize()
161 text
= "W: " + str(ls
.x()) + " H: " + str(ls
.y())
163 _popwidget
= otk
.Widget(ob
.openbox
, style
,
164 otk
.Widget
.Horizontal
, 0,
165 style
.bevelWidth(), 1)
166 _popwidget
.setTexture(style
.titlebarFocusBackground())
167 _poplabel
= otk
.Label(_popwidget
)
168 _poplabel
.setTexture(style
.labelFocusBackground())
170 _poplabel
.fitString(text
)
171 _poplabel
.setText(text
)
172 area
= otk
.display
.screenInfo(_screen
).rect()
174 _popwidget
.move(area
.x() + (area
.width() -
175 _popwidget
.width()) / 2,
176 area
.y() + (area
.height() -
177 _popwidget
.height()) / 2)
180 """Resizes the window interactively. This should only be used with
181 MouseMotion events"""
182 if not data
.client
: return
184 # not-normal windows dont get resized
185 if not data
.client
.normal(): return
187 global _screen
, _client
, _cx
, _cy
, _cw
, _ch
, _px
, _py
, _dx
, _dy
188 _screen
= data
.screen
189 _client
= data
.client
190 _cx
= data
.press_clientx
191 _cy
= data
.press_clienty
192 _cw
= data
.press_clientwidth
193 _ch
= data
.press_clientheight
196 _dx
= data
.xroot
- _px
197 _dy
= data
.yroot
- _py
201 def end_resize(data
):
202 """Complete the interactive resize of a window."""
203 global resize_rubberband
, _inmotion
204 global _popwidget
, _poplabel
206 r
= resize_rubberband
207 resize_rubberband
= 0
209 resize_rubberband
= r
This page took 0.044682 seconds and 5 git commands to generate.