示例#1
0
文件: props.py 项目: Luiji/whimsy
    def test_single_WINDOW(self):
        props.change_prop(self.dpy, self.root, '_NET_ACTIVE_WINDOW', X.NONE)
        val = props.get_prop(self.dpy, self.root, '_NET_ACTIVE_WINDOW')
        self.assertEqual(val, X.NONE)

        props.change_prop(self.dpy, self.root, '_NET_ACTIVE_WINDOW', self.win)
        val = props.get_prop(self.dpy, self.root, '_NET_ACTIVE_WINDOW')
        self.assertEqual(val, self.win.id)
示例#2
0
    def test_single_WINDOW(self):
        props.change_prop(self.dpy, self.root, '_NET_ACTIVE_WINDOW', X.NONE)
        val = props.get_prop(self.dpy, self.root, '_NET_ACTIVE_WINDOW')
        self.assertEqual(val, X.NONE)

        props.change_prop(self.dpy, self.root, '_NET_ACTIVE_WINDOW', self.win)
        val = props.get_prop(self.dpy, self.root, '_NET_ACTIVE_WINDOW')
        self.assertEqual(val, self.win.id)
示例#3
0
文件: builtins.py 项目: Luiji/whimsy
    def __call__(self, hub, wm, **kw):
        to_x, to_y = self.x, self.y

        if not wm.can_move_viewport_to(to_x, to_y):
            logging.error("viewport_absolute_move: can't move to %r; "
                "desktop isn't big enough" % ((to_x, to_y)))
            return

        current_x = wm.vx
        current_y = wm.vy

        if (current_x, current_y) == (to_x, to_y):
            return

        xdelta = current_x - to_x
        ydelta = current_y - to_y

        # moving the top windows first causes fewer redraw artifacts,
        # especially on slow-drawing apps like firefox
        wins = props.get_prop(wm.dpy, wm.root, '_NET_CLIENT_LIST_STACKING')
        for win in wins:
            c = wm.find_client(win)
            if not if_sticky(wm=wm, win=c.win):
                c.geom.move_ip(xdelta, ydelta)
                c.moveresize()
            #c.dpy.sync() # necessary?  maybe not
            #wish list: discard enternotifies

        hub.emit('after_viewport_move', x=to_x, y=to_y)
示例#4
0
文件: ewmh.py 项目: tockards/whimsy
def confine_window_to_workarea(hub, wm, client, **kw):
    try:
        x, y, width, height = props.get_prop(wm.dpy, wm.root, '_NET_WORKAREA')
    except ValueError:
        return
    c = client

    def fix_axis(begin, size, wm_size, work_begin, work_size):
        near_movable = 0 <= c.geom[begin]
        near_needs_move = 0 <= c.geom[begin] < work_begin
        far_movable = c.geom[begin] + c.geom[size] <= wm_size
        far_needs_move = work_begin + work_size < c.geom[begin] + c.geom[
            size] <= wm_size

        if near_needs_move:
            c.geom[begin] = work_begin
            if far_movable:
                c.geom[size] = min(c.geom[size], work_size)
        elif far_needs_move:
            c.geom[begin] -= (c.geom[begin] + c.geom[size]) - (work_begin +
                                                               work_size)
            if near_movable:
                near_overlap = work_begin - c.geom[begin]
                if near_overlap > 0:
                    c.geom[begin] += near_overlap
                    c.geom[size] -= near_overlap

        return near_needs_move or far_needs_move

    moved = fix_axis(0, 2, wm.root_geometry.width, x, width)
    moved |= fix_axis(1, 3, wm.root_geometry.height, y, height)

    if moved:
        c.moveresize()
示例#5
0
    def __call__(self, hub, wm, **kw):
        to_x, to_y = self.x, self.y

        if not wm.can_move_viewport_to(to_x, to_y):
            logging.error("viewport_absolute_move: can't move to %r; "
                          "desktop isn't big enough" % ((to_x, to_y)))
            return

        current_x = wm.vx
        current_y = wm.vy

        if (current_x, current_y) == (to_x, to_y):
            return

        xdelta = current_x - to_x
        ydelta = current_y - to_y

        # moving the top windows first causes fewer redraw artifacts,
        # especially on slow-drawing apps like firefox
        wins = props.get_prop(wm.dpy, wm.root, '_NET_CLIENT_LIST_STACKING')
        for win in wins:
            c = wm.find_client(win)
            if not if_sticky(wm=wm, win=c.win):
                c.geom.move_ip(xdelta, ydelta)
                c.moveresize()
            #c.dpy.sync() # necessary?  maybe not
            #wish list: discard enternotifies

        hub.emit('after_viewport_move', x=to_x, y=to_y)
示例#6
0
文件: ewmh.py 项目: Luiji/whimsy
def confine_window_to_workarea(hub, wm, client, **kw):
    try:
        x, y, width, height = props.get_prop(wm.dpy, wm.root, '_NET_WORKAREA')
    except ValueError:
        return
    c = client
    def fix_axis(begin, size, wm_size, work_begin, work_size):
        near_movable    = 0 <= c.geom[begin]
        near_needs_move = 0 <= c.geom[begin] < work_begin
        far_movable     =                        c.geom[begin]+c.geom[size] <= wm_size
        far_needs_move  = work_begin+work_size < c.geom[begin]+c.geom[size] <= wm_size

        if near_needs_move:
            c.geom[begin] = work_begin
            if far_movable:
                c.geom[size] = min(c.geom[size], work_size)
        elif far_needs_move:
            c.geom[begin] -= (c.geom[begin]+c.geom[size]) - (work_begin+work_size)
            if near_movable:
                near_overlap = work_begin - c.geom[begin]
                if near_overlap > 0:
                    c.geom[begin] += near_overlap
                    c.geom[size] -= near_overlap

        return near_needs_move or far_needs_move

    moved =  fix_axis(0, 2, wm.root_geometry.width, x, width)
    moved |= fix_axis(1, 3, wm.root_geometry.height, y, height)

    if moved:
        c.moveresize()
示例#7
0
文件: builtins.py 项目: Luiji/whimsy
 def __call__(self, wm, win, **kw):
     wins = props.get_prop(wm.dpy, wm.root, '_WHIMSY_CLIENT_LIST_FOCUS')
     try:
         wins.remove(win.id)
     except ValueError:
         pass
     wins.insert(0, win.id)
     props.change_prop(wm.dpy, wm.root, '_WHIMSY_CLIENT_LIST_FOCUS', wins)
示例#8
0
    def can_move_viewport_to(self, x, y):
        total_width, total_height = props.get_prop(self.dpy, self.root,
                                                   '_NET_DESKTOP_GEOMETRY')

        limit_x = total_width - self.root_geometry.width
        limit_y = total_height - self.root_geometry.height

        return 0 <= x <= limit_x and 0 <= y <= limit_y
示例#9
0
 def __call__(self, wm, win, **kw):
     wins = props.get_prop(wm.dpy, wm.root, '_WHIMSY_CLIENT_LIST_FOCUS')
     try:
         wins.remove(win.id)
     except ValueError:
         pass
     wins.insert(0, win.id)
     props.change_prop(wm.dpy, wm.root, '_WHIMSY_CLIENT_LIST_FOCUS', wins)
示例#10
0
    def can_move_viewport_to(self, x, y):
        total_width, total_height = props.get_prop(
            self.dpy, self.root, '_NET_DESKTOP_GEOMETRY')

        limit_x = total_width - self.root_geometry.width
        limit_y = total_height - self.root_geometry.height

        return 0 <= x <= limit_x and 0 <= y <= limit_y
示例#11
0
文件: ewmh.py 项目: Luiji/whimsy
 def closure(wm, win, **kw):
     client = wm.find_client(win)
     x, y, width, height = props.get_prop(wm.dpy, wm.root, '_NET_WORKAREA')
     client.moveresize(
         x=x+int(width*left_percent/100.0),
         y=y+int(height*top_percent/100.0),
         width=int(width*width_percent/100.0),
         height=int(height*height_percent/100.0),
     )
示例#12
0
文件: __init__.py 项目: Luiji/whimsy
def _if_hinted_win_state(wstates, wm, **kw):
    if 'win' not in kw:
        return False
    states = set(props.get_prop(wm.dpy, kw['win'], '_NET_WM_STATE'))
    ours = set([
        wm.dpy.get_atom('_NET_WM_STATE_'+wstate.upper())
        for wstate in wstates
    ])
    return bool(ours & states)
示例#13
0
文件: __init__.py 项目: Luiji/whimsy
def _if_hinted_win_type(wtypes, wm, **kw):
    if 'win' not in kw:
        return False
    types = set(props.get_prop(wm.dpy, kw['win'], '_NET_WM_WINDOW_TYPE'))
    ours = set([
        wm.dpy.get_atom('_NET_WM_WINDOW_TYPE_'+wtype.upper())
        for wtype in wtypes
    ])
    return bool(ours & types)
示例#14
0
文件: ewmh.py 项目: tockards/whimsy
 def closure(wm, win, **kw):
     client = wm.find_client(win)
     x, y, width, height = props.get_prop(wm.dpy, wm.root, '_NET_WORKAREA')
     client.moveresize(
         x=x + int(width * left_percent / 100.0),
         y=y + int(height * top_percent / 100.0),
         width=int(width * width_percent / 100.0),
         height=int(height * height_percent / 100.0),
     )
示例#15
0
 def __call__(self, wm, win, **kw):
     wins = props.get_prop(wm.dpy, wm.root, '_WHIMSY_CLIENT_LIST_FOCUS')
     while wins:
         c = wm.find_client(wins[0])
         if c:
             c.focus()
             break
         wins.pop(0)
     props.change_prop(wm.dpy, wm.root, '_WHIMSY_CLIENT_LIST_FOCUS', wins)
示例#16
0
文件: builtins.py 项目: Luiji/whimsy
 def __call__(self, wm, win, **kw):
     wins = props.get_prop(wm.dpy, wm.root, '_WHIMSY_CLIENT_LIST_FOCUS')
     while wins:
         c = wm.find_client(wins[0])
         if c:
             c.focus()
             break
         wins.pop(0)
     props.change_prop(wm.dpy, wm.root, '_WHIMSY_CLIENT_LIST_FOCUS', wins)
示例#17
0
def _if_hinted_win_type(wtypes, wm, **kw):
    if 'win' not in kw:
        return False
    types = set(props.get_prop(wm.dpy, kw['win'], '_NET_WM_WINDOW_TYPE'))
    ours = set([
        wm.dpy.get_atom('_NET_WM_WINDOW_TYPE_' + wtype.upper())
        for wtype in wtypes
    ])
    return bool(ours & types)
示例#18
0
def _if_hinted_win_state(wstates, wm, **kw):
    if 'win' not in kw:
        return False
    states = set(props.get_prop(wm.dpy, kw['win'], '_NET_WM_STATE'))
    ours = set([
        wm.dpy.get_atom('_NET_WM_STATE_' + wstate.upper())
        for wstate in wstates
    ])
    return bool(ours & states)
示例#19
0
文件: props.py 项目: Luiji/whimsy
 def test_single_UTF8_STRING(self):
     props.change_prop(self.dpy, self.win, '_NET_WM_NAME', 'hey guy')
     val = props.get_prop(self.dpy, self.win, '_NET_WM_NAME')
     self.assertEqual(val, 'hey guy')
示例#20
0
 def test_single_UTF8_STRING(self):
     props.change_prop(self.dpy, self.win, '_NET_WM_NAME', 'hey guy')
     val = props.get_prop(self.dpy, self.win, '_NET_WM_NAME')
     self.assertEqual(val, 'hey guy')
示例#21
0
    def can_move_viewport_by(self, x, y):
        current_x, current_y = props.get_prop(
            self.dpy, self.root, '_NET_DESKTOP_VIEWPORT')

        return self.can_move_viewport_to(current_x + x, current_y + y)
示例#22
0
文件: ewmh.py 项目: tockards/whimsy
 def get(self):
     return props.get_prop(self.wm.dpy, self.wm.root, self.propname())
示例#23
0
    def can_move_viewport_by(self, x, y):
        current_x, current_y = props.get_prop(self.dpy, self.root,
                                              '_NET_DESKTOP_VIEWPORT')

        return self.can_move_viewport_to(current_x + x, current_y + y)
示例#24
0
文件: ewmh.py 项目: Luiji/whimsy
 def get(self):
     return props.get_prop(self.wm.dpy, self.wm.root, self.propname())
示例#25
0
 def fetch_prop(self, propname):
     return props.get_prop(self.dpy, self.win, propname)
示例#26
0
文件: client.py 项目: Luiji/whimsy
 def fetch_prop(self, propname):
     return props.get_prop(self.dpy, self.win, propname)