X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=scripts%2Fmotion.py;h=174f3c8e2bebf93f455161c404e3018ad690e306;hb=96a949ec1f2be9da216e4d228992d1ce6855a6d4;hp=b5cc279f936dcd2506fbd0e71f30bf69c12131dd;hpb=f32ddbbf628b6a27bf2a85f9e98c70e2661c3a1d;p=chaz%2Fopenbox diff --git a/scripts/motion.py b/scripts/motion.py index b5cc279f..174f3c8e 100644 --- a/scripts/motion.py +++ b/scripts/motion.py @@ -1,11 +1,16 @@ ############################################################################ -### Functions that provide callbacks for motion events to move and ### -### windows. ### +### Functions that provide callbacks for motion events to move and ### +### resize windows. ### ############################################################################ ############################################################################# ### Options that can be modified to change the functions' behaviors. ### ### ### +# edge_resistance - the amount of resistance to provide to moving a ### +### window past a screen boundary. Specify a value of 0 ### +### to disable edge resistance. ### +edge_resistance = 10 ### +### ### # move_popup - display a coordinates popup when moving windows. ### move_popup = 1 ### ### ### @@ -28,6 +33,20 @@ resize_rubberband = 0 ### ### is, 0 to resize always from the bottom right corner. ### resize_nearest = 1 ### ### ### +### ### +# Provides: ### +# def move(data): ### +# """Moves the window interactively. This should only be used with ### +# MouseMotion events. If move_popup or move_rubberband is enabled, ### +# then the end_move function needs to be bound as well.""" ### +# def end_move(data): ### +# """Complete the interactive move of a window.""" ### +# def resize(data): ### +# """Resizes the window interactively. This should only be used with ### +# MouseMotion events""" ### +# def end_resize(data): ### +# """Complete the interactive resize of a window.""" ### +### ### ############################################################################# import ob @@ -73,6 +92,30 @@ def _do_move(): x = _cx + _dx y = _cy + _dy + global edge_resistance + if edge_resistance: + fs = _client.frame.size() + w = _client.area().width() + fs.left + fs.right + h = _client.area().height() + fs.top + fs.bottom + # use the area based on the struts + area = ob.openbox.screen(_screen).area() + l = area.left() + r = area.right() - w + 1 + t = area.top() + b = area.bottom() - h + 1 + # left screen edge + if x < l and x >= l - edge_resistance: + x = l + # right screen edge + if x > r and x <= r + edge_resistance: + x = r + # top screen edge + if y < t and y >= t - edge_resistance: + y = t + # right screen edge + if y > b and y <= b + edge_resistance: + y = b + global move_rubberband if move_rubberband: # draw the outline ... @@ -94,15 +137,15 @@ def _do_move(): _popwidget.setTexture(style.titlebarFocusBackground()) _poplabel = otk.Label(_popwidget) _poplabel.setTexture(style.labelFocusBackground()) - _popwidget.show(1) _poplabel.fitString(text) _poplabel.setText(text) - area = otk.display.screenInfo(_screen).rect() _popwidget.update() + area = otk.display.screenInfo(_screen).rect() _popwidget.move(area.x() + (area.width() - _popwidget.width()) / 2, area.y() + (area.height() - _popwidget.height()) / 2) + _popwidget.show(1) def move(data): """Moves the window interactively. This should only be used with @@ -189,7 +232,6 @@ def _do_resize(): _popwidget.setTexture(style.titlebarFocusBackground()) _poplabel = otk.Label(_popwidget) _poplabel.setTexture(style.labelFocusBackground()) - _popwidget.show(1) _poplabel.fitString(text) _poplabel.setText(text) area = otk.display.screenInfo(_screen).rect() @@ -198,6 +240,7 @@ def _do_resize(): _popwidget.width()) / 2, area.y() + (area.height() - _popwidget.height()) / 2) + _popwidget.show(1) def resize(data): """Resizes the window interactively. This should only be used with