Exemplo n.º 1
0
def expand(win, direction):
    """Expand window in given direction."""
    border = reposition_resize(win, direction, 
                               sticky=(not direction.is_middle),
                               vertical_first=CONFIG.settings['vertical_first'])
    logging.debug(border)
    win.move_resize(border, direction)
Exemplo n.º 2
0
def expand(win, direction):
    """Expand window in given direction."""
    border = reposition_resize(
        win,
        direction,
        sticky=(not direction.is_middle),
        vertical_first=CONFIG.settings['vertical_first'])
    logging.debug(border)
    win.move_resize(border, direction)
Exemplo n.º 3
0
def move(win, direction):
    """Move window in given direction."""
    border = reposition_resize(win, direction, 
                               sticky=(not direction.is_middle), 
                               insideout=(not direction.is_middle),
                               vertical_first=CONFIG.settings['vertical_first'])
    geometry = win.geometry
    geometry.width = min(border.width, geometry.width)
    geometry.height = min(border.height, geometry.height)
    x = border.x + border.width * direction.x
    y = border.y + border.height * direction.y
    geometry.set_position(x, y, direction)
    logging.debug('x: %s, y: %s, gravity: %s' % 
                  (geometry.x, geometry.y, direction))
    win.move_resize(geometry)
Exemplo n.º 4
0
def move(win, direction):
    """Move window in given direction."""
    border = reposition_resize(
        win,
        direction,
        sticky=(not direction.is_middle),
        insideout=(not direction.is_middle),
        vertical_first=CONFIG.settings['vertical_first'])
    geometry = win.geometry
    geometry.width = min(border.width, geometry.width)
    geometry.height = min(border.height, geometry.height)
    x = border.x + border.width * direction.x
    y = border.y + border.height * direction.y
    geometry.set_position(x, y, direction)
    logging.debug('x: %s, y: %s, gravity: %s' %
                  (geometry.x, geometry.y, direction))
    win.move_resize(geometry)
Exemplo n.º 5
0
def grid(win, position, gravity, sizes, cycle='width'):
    """Put window in given position and resize it."""
    win.reset()
    win.sync()
    workarea = WM.workarea_geometry
    x = workarea.x + workarea.width * position.x
    y = workarea.y + workarea.height * position.y
    m.move(
        position.x - 20, position.y + 10
    )  # might need to check what position was pressed and invert it accordingly.
    heights = [int(workarea.height * height) for height in sizes.height]
    widths = [int(workarea.width * width) for width in sizes.width]
    if GRIDED and win.id == GRIDED['id'] and \
       GRIDED['placement'] == (position, gravity):
        old = win.geometry
        if cycle == 'width':
            new_width = GRIDED['width'].next()
            new_height = old.height + \
                         min(abs(old.height - height) for height in heights)
        elif cycle == 'height':
            new_height = GRIDED['height'].next()
            new_width = old.width + \
                        min(abs(old.width - width) for width in widths)
    else:
        dummy = DummyWindow(workarea, win, x, y, sizes, gravity)
        border = reposition_resize(dummy,
                                   dummy.gravity,
                                   vertical_first=(cycle is 'height'))
        new_width = max([width for width in widths
                               if border.width - width >= 0 and \
                                  x - width * position.x >= border.x and \
                                  x + width * (1 - position.x) <= border.x2])
        new_height = max([height for height in heights
                                 if border.height - height >= 0 and \
                                    y - height * position.y >= border.y and \
                                    y + height * (1 - position.y) <= border.y2])
        GRIDED['id'] = win.id
        GRIDED['width'] = __get_iterator(widths, new_width)
        GRIDED['height'] = __get_iterator(heights, new_height)
        GRIDED['placement'] = (position, gravity)
    geometry = Geometry(x, y, new_width, new_height, gravity)
    logging.debug('width: %s, height: %s' % (geometry.width, geometry.height))
    if CONFIG.settings['invert_on_resize']:
        win.move_resize(geometry, gravity.invert())
    else:
        win.move_resize(geometry, gravity)
Exemplo n.º 6
0
def grid(win, position, gravity, sizes, cycle='width'):
    """Put window in given position and resize it."""
    win.reset() 
    win.sync() 
    workarea = WM.workarea_geometry
    x = workarea.x + workarea.width * position.x
    y = workarea.y + workarea.height * position.y
    m.move(position.x-20,position.y+10)  # might need to check what position was pressed and invert it accordingly.
    heights = [int(workarea.height * height) for height in sizes.height]
    widths = [int(workarea.width * width) for width in sizes.width]
    if GRIDED and win.id == GRIDED['id'] and \
       GRIDED['placement'] == (position, gravity):
        old = win.geometry
        if cycle == 'width':
            new_width = GRIDED['width'].next()
            new_height = old.height + \
                         min(abs(old.height - height) for height in heights)
        elif cycle == 'height':
            new_height = GRIDED['height'].next()
            new_width = old.width + \
                        min(abs(old.width - width) for width in widths)
    else:
        dummy = DummyWindow(workarea, win, x, y, sizes, gravity)
        border = reposition_resize(dummy, dummy.gravity,
                                   vertical_first=(cycle is 'height'))
        new_width = max([width for width in widths 
                               if border.width - width >= 0 and \
                                  x - width * position.x >= border.x and \
                                  x + width * (1 - position.x) <= border.x2])
        new_height = max([height for height in heights 
                                 if border.height - height >= 0 and \
                                    y - height * position.y >= border.y and \
                                    y + height * (1 - position.y) <= border.y2])
        GRIDED['id'] = win.id
        GRIDED['width'] = __get_iterator(widths, new_width)
        GRIDED['height'] = __get_iterator(heights, new_height)
        GRIDED['placement'] = (position, gravity)
    geometry = Geometry(x, y, new_width, new_height, gravity)
    logging.debug('width: %s, height: %s' % (geometry.width, geometry.height))
    if CONFIG.settings['invert_on_resize']: win.move_resize(geometry,
                                                            gravity.invert())
    else: win.move_resize(geometry, gravity)