all repos — openbox @ 1dac42d9ed074bcd44f9d1016b0971ae473cc2eb

openbox fork - make it a bit more like ryudo

scripts/windowplacement.py (raw)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
############################################################################
### Window placement algorithms, choose one of these and ebind it to the ###
### ob.EventAction.PlaceWindow event.                                    ###
###                                                                      ###
### Also see historyplacement.py for the history placement module which  ###
### provides an algorithm that can be used in place of, or alongside,    ###
### these.                                                               ###
############################################################################

##############################################################################
### Options for the windowplacement module:                                ###
###                                                                        ###
###                                                                        ###
##############################################################################

import otk
import ob
import random

_rand = random.Random()

def random(data):
    """Place windows randomly around the screen."""
    if not data.client: return
    if data.client.positionRequested(): return
    client_area = data.client.frame.area()
    screen_area = ob.openbox.screen(data.screen).area(data.client.desktop())
    width = screen_area.width() - client_area.width()
    height = screen_area.height() - client_area.height()
    global _rand
    x = _rand.randrange(screen_area.x(), width-1)
    y = _rand.randrange(screen_area.y(), height-1)
    data.client.move(x, y)

_cascade_x = 0
_cascade_y = 0

def cascade(data):
    """Place windows in a cascading order from top-left to bottom-right."""
    if not data.client: return
    if data.client.positionRequested(): return
    client_area = data.client.frame.area()
    screen_area = ob.openbox.screen(data.screen).area(data.client.desktop())
    width = screen_area.width() - client_area.width()
    height = screen_area.height() - client_area.height()
    global _cascade_x, _cascade_y
    if _cascade_x < screen_area.x() or _cascade_y < screen_area.y() or \
           _cascade_x >= width or _cascade_y >= height:
        _cascade_x = screen_area.x()
        _cascade_y = screen_area.y()
    data.client.move(_cascade_x, _cascade_y)
    frame_size = data.client.frame.size()
    _cascade_x += frame_size.top
    _cascade_y += frame_size.top

print "Loaded windowplacement.py"