class Window(object): ''' Window for X clients ''' def __init__(self, wid): ''' Arguments: - `wid`: window id. ''' self._wid = wid self._wrapper_ = WMWrapper() def get_info(self): return self._wrapper_.get_window_info(self._wid) def get_position(self): info = self.get_info() area_x, area_y, area_width, area_height = \ self._wrapper_.get_current_workarea() return (info.geometry.x - info.extent.left - area_x, info.geometry.y - info.extent.top - area_y) def get_size(self): info = self.get_info() return (info.geometry.width + info.extent.left + info.extent.right, info.geometry.height + info.extent.top + info.extent.bottom) def move(self, x, y): area_x, area_y, area_width, area_height = \ self._wrapper_.get_current_workarea() self._wrapper_.move_window(self._wid, x + area_x, y + area_y) def resize(self, width, height): info = self.get_info() self._wrapper_.resize_window(self._wid, width - info.extent.left \ - info.extent.right, height - info.extent.top \ - info.extent.bottom) def title(self): info = self.get_info() return info.wm_name def wm_class(self): info = self.get_info() return info.wm_class def get_type(self): return WindowType(self._wrapper_.get_window_type(self._wid)) def get_states(self): return [WindowState(stateid) for stateid in \ self._wrapper_.get_window_state(self._wid)] def __repr__(self): return self.title()
def __init__(self, wid): ''' Arguments: - `wid`: window id. ''' self._wid = wid self._wrapper_ = WMWrapper()
class WindowManager(object): def __init__(self): self._wrapper_ = WMWrapper() def current_window(self): return Window(self._wrapper_.get_active_window()) def set_current_window(self, win, switch_desktop=False): return self._wrapper_.set_active_window(win._wid, switch_desktop) def list_windows(self): return [Window(wid) for wid in self._wrapper_.list_clients()] def current_desktop(self): return self._wrapper_.get_current_desktop() def set_current_desktop(self, desk_id): return self._wrapper_.set_current_desktop(desk_id)
def __init__(self): self._wrapper_ = WMWrapper()