def __init__(self, win, position, gravity, size, width, height, cycle, xinerama): self.win_id = win.id self.args = (position, gravity, size, width, height) # TODO: remove me!? self.gravity = gravity workarea = get_current_workarea(win, xinerama) self.position = absolute_position(workarea, position) self.sizes = absolute_size(win, workarea, size, width, height) dummy = DummyWindow(win, self.position, self.sizes, self.gravity) expand = Expander(workarea=workarea, adjacent=False, vertical_first=cycle) max_geo = expand(dummy, dummy.gravity) widths = [] for width in self.sizes.width: if ( max_geo.width - width >= 0 and self.position.x - width * position.x >= max_geo.x and self.position.x + width * (1 - position.x) <= max_geo.x2 ): widths.append(width) heights = [] for height in self.sizes.height: if ( max_geo.height - height >= 0 and self.position.y - height * position.y >= max_geo.y and self.position.y + height * (1 - position.y) <= max_geo.y2 ): heights.append(height) width = max(widths) height = max(heights) self.sizes_iterator = Size(get_iterator(self.sizes.width, width), get_iterator(self.sizes.height, height)) [self.sizes_iterator.height, self.sizes_iterator.width][cycle].next() self.previous = Geometry(self.position.x, self.position.y, width, height, self.gravity)
def __init__(self, win, position, gravity, size, width, height, cycle, xinerama): self.win_id = win.id self.args = (position, gravity, size, width, height) # TODO: remove me!? self.gravity = gravity workarea = get_current_workarea(win, xinerama) self.position = absolute_position(workarea, position) self.sizes = absolute_size(win, workarea, size, width, height) dummy = DummyWindow(win, self.position, self.sizes, self.gravity) expand = Expander(workarea=workarea, adjacent=False, vertical_first=cycle) max_geo = expand(dummy, dummy.gravity) widths = [] for width in self.sizes.width: if max_geo.width - width >= 0 and \ self.position.x - width * position.x >= max_geo.x and \ self.position.x + width * (1 - position.x) <= max_geo.x2: widths.append(width) heights = [] for height in self.sizes.height: if max_geo.height - height >= 0 and \ self.position.y - height * position.y >= max_geo.y and \ self.position.y + height * (1 - position.y) <= max_geo.y2: heights.append(height) width = max(widths) height = max(heights) self.sizes_iterator = Size(get_iterator(self.sizes.width, width), get_iterator(self.sizes.height, height)) [self.sizes_iterator.height, self.sizes_iterator.width][cycle].next() self.previous = Geometry(self.position.x, self.position.y, width, height, self.gravity)
def _put(win, position, gravity=None, xinerama=False): """Put window in given position (without resizing).""" gravity = gravity or position workarea = get_current_workarea(win, xinerama) geometry = win.geometry x = workarea.x + workarea.width * position.x y = workarea.y + workarea.height * position.y geometry.set_position(x, y, gravity) log.debug('Setting %s' % (geometry,)) win.set_geometry(geometry)
def _expand(win, direction, vertical_first=True, xinerama=False): """Expand window in given direction.""" workarea = get_current_workarea(win, xinerama) expand = Expander(workarea=workarea, adjacent=not direction.is_middle, both_sides=not direction.is_middle, vertical_first=vertical_first) geometry = expand(win, direction) log.debug('Setting %s' % (geometry,)) win.set_geometry(geometry, direction)
def _shrink(win, direction, vertical_first=True, xinerama=False): """Shrink window in given direction.""" if direction.is_middle: # NOTE: This is not working correctly with is_middle anyway return workarea = get_current_workarea(win, xinerama) shrink = Shrinker(workarea=workarea, vertical_first=vertical_first) geometry = shrink(win, direction.invert()) log.debug('Setting %s' % (geometry,)) win.set_geometry(geometry, direction)
def _move(win, direction, vertical_first=True, xinerama=False): """Move window in given direction.""" workarea = get_current_workarea(win, xinerama) expand = Floater(workarea=workarea, adjacent=not direction.is_middle, both_sides=not direction.is_middle, vertical_first=vertical_first) border = expand(win, direction) 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) log.debug('Setting %s' % (geometry,)) win.set_geometry(geometry)