Exemple #1
0
    def find(self, win, direction, sticky=False, insideout=False, vertical_first=True):
        """Return new geometry for the window."""
        # TODO: add limit? and use limit geometry instead of workarea?
        current = win.geometry
        wm = WindowManager()
        workarea = wm.workarea_geometry
        windows = [
            window.geometry
            for window in wm.windows(self.__main_filter)
            if window.id != win.id and window.desktop == win.desktop
        ]

        order = {True: [self.__vertical, self.__horizontal], False: [self.__horizontal, self.__vertical]}
        for method in order[vertical_first]:
            method(win, current, workarea, windows, direction, sticky, insideout)
        return current
Exemple #2
0
    def find(self, win, direction, 
             sticky=False, insideout=False, vertical_first=True):
        """Return new geometry for the window."""
        #TODO: add limit? and use limit geometry instead of workarea?
        current = win.geometry
        wm = WindowManager()
        workarea = wm.workarea_geometry
        windows = [window.geometry for window in wm.windows(self.__main_filter)
                                   if window.id != win.id and \
                                      window.desktop == win.desktop]


        order = {True: [self.__vertical, self.__horizontal],
                 False: [self.__horizontal, self.__vertical]}
        for method in order[vertical_first]:
            method(win, current, workarea,
                   windows, direction, sticky, insideout)
        return current
Exemple #3
0
import time
import sys

from core import Gravity, Size, Geometry, Window, WindowManager
from events import KeyPressHandler, PropertyNotifyHandler
from config import Config
from reposition import reposition_resize, shrink_window

from pymouse import PyMouse
global m
m = PyMouse()

__author__ = "Wojciech 'KosciaK' Pietrzok <*****@*****.**>"
__version__ = "0.2"

WM = WindowManager()
CONFIG = Config()
GRIDED = {}


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)

Exemple #4
0
from logging.handlers import RotatingFileHandler
import operator
import time
import sys

from core import Gravity, Size, Geometry, Window, WindowManager
from events import KeyPressHandler, PropertyNotifyHandler
from config import Config
from reposition import reposition_resize, shrink_window


__author__ = "Wojciech 'KosciaK' Pietrzok <*****@*****.**>"
__version__ = "0.2"


WM = WindowManager()
CONFIG = Config()
GRIDED = {}

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)


def shrink(win, direction):
    """Shrink window in given direction."""
    border = shrink_window(win, direction.invert(), sticky=True,
Exemple #5
0
    def load(self, filename='.pyworc'):
        """Load configuration file"""
        logging.info('Loading configuration file...')
        # Reset values
        self.settings = {}
        self.mappings = {}
        self.ignore = []
        # Load config file
        self.__config.read([os.path.join(os.path.dirname(__file__), 'pyworc'),
                            os.path.join(os.path.expanduser('~'), '.pyworc')])
        keys = dict(self.__config.items('KEYS'))
        self.__config.remove_section('KEYS')
        # Parse SETTINGS section
        self.__parse_settings()
        if self.__config.has_option('SETTINGS', 'layout'):
            # Load layout definition
            layout = self.__config.get('SETTINGS', 'layout')
            self.__config.read([os.path.join(os.path.dirname(__file__), layout),
                                os.path.join(os.path.expanduser('~'), layout)])
        if self.__config.has_option('SETTINGS', 'ignore_actions'):
            # Parse ignore_actions setting
            ignore = self.__config.get('SETTINGS', 'ignore_actions')
            self.ignore = ignore.split(', ')
        self.__config.remove_section('SETTINGS')
        # Parse every section
        for section in self.__config.sections():
            data = dict(self.__config.items(section))
            ignore = []
            mask_key = keys[section]
            if 'ignore_actions' in data:
                ignore = data['ignore_actions'].split(', ')
            if not (('float' in self.ignore or 'float' in ignore) and \
                    ('expand' in self.ignore or 'expand' in ignore) and \
                    ('shrink' in self.ignore or 'shrink' in ignore)):
                # No need to parse if float, expand, shrink are ignored
                direction = self.__parse_gravity(data['direction'])
            if not (('put' in self.ignore or 'put' in ignore) and \
                    ('grid' in self.ignore or 'grid' in ignore or \
                     ('grid_width' in self.ignore or \
                      'grid_width' in ignore) and \
                     ('grid_height' in self.ignore or \
                      'grid_height' in ignore))):
                # No need to parse these if put and grid are ignored
                position  = self.__parse_gravity(data['position'])
                if 'gravity' in data:
                    gravity = self.__parse_gravity(data['gravity'])
                else:
                    gravity = position
                sizes = self.__parse_size(data['widths'], data['heights'])

            # Parse put, grid actions if not ignored
            if not ('put' in self.ignore or 'put' in ignore):
                key = WM.str2keycode(keys['put'], mask_key)
                self.mappings[key] = ['put', [position]]
            if not ('grid' in self.ignore or 'grid' in ignore or \
                    'grid_width' in ignore or 'grid_width' in ignore):
                key = WM.str2keycode(keys['grid_width'], mask_key)
                self.mappings[key] = ['grid', 
                                     [position, gravity, sizes, 'width']]
            if not ('grid' in self.ignore or 'grid' in ignore or \
                    'grid_height' in self.ignore or 'grid_height' in ignore):
                key = WM.str2keycode(keys['grid_height'], mask_key)
                self.mappings[key] = ['grid', 
                                     [position, gravity, sizes, 'height']]

            # Parse float, expand, shrink actions if not ignored
            if not ('float' in self.ignore or 'float' in ignore):
                key = WM.str2keycode(keys['float'], mask_key)
                self.mappings[key] = ['float', [direction]]
            if not ('expand' in self.ignore or 'expand' in ignore):
                key = WM.str2keycode(keys['expand'], mask_key)
                self.mappings[key] = ['expand', [direction]]
            if not ('shrink' in self.ignore or 'shrink' in ignore):
                key = WM.str2keycode(keys['shrink'], mask_key)
                self.mappings[key] = ['shrink', [direction]]
                self.__config.remove_section(section)

        # Parse switch, cycle if not ignored
        if not 'switch' in self.ignore:
            key = WM.str2keycode(keys['switch'])
            self.mappings[key] = ['switch_cycle', [True]]
        if not 'cycle' in self.ignore:
            key = WM.str2keycode(keys['cycle'])
            self.mappings[key] = ['switch_cycle', [False]]

        # Parse reload, exit, debug. Can not be ignored!
        key = WM.str2keycode(keys['reload'])
        self.mappings[key] = ['reload', []]
        key = WM.str2keycode(keys['exit'])
        self.mappings[key] = ['exit', []]
        key = WM.str2keycode(keys['debug'])
        self.mappings[key] = ['debug', []]
        logging.info('Configuration loaded.')