예제 #1
0
파일: fpwm.py 프로젝트: sduverger/fpwm
def setup():
    runtime.focused_color = config.focused_color
    runtime.passive_color = config.passive_color

    runtime.ignored_windows = config.ignored_windows
    runtime.pointer_follow = config.pointer_follow

    runtime.keyboard.bind(config.keyboard_bindings)
    runtime.mouse.bind(config.mouse_bindings)

    reply = runtime.xrandr.GetScreenResources(runtime.viewport.root).reply()

    if len(config.workspaces) < reply.num_crtcs:
        debug("Not enough workspaces\n")
        runtime.con.disconnect()
        sys.exit(1)

    ext_clients = acquire_ext_clients()

    for w in config.workspaces:
        runtime.workspaces.append(Workspace(runtime.con, runtime.viewport, w, config.layouts))

    build_status()

    w = 0
    screen_ids = unpack_from("%dI" % reply.num_crtcs, reply.crtcs.buf())
    for sid in screen_ids:
        reply = runtime.xrandr.GetCrtcInfo(sid,0).reply()
        if reply.width == 0 or reply.height == 0:
            continue
        if reply.x == runtime.status_line.gap.x:
            gap = runtime.status_line.gap
        else:
            gap = None
            debug("screen: x %d y %d w %d h %d\n" % (reply.x, reply.y, reply.width, reply.height))

        duplicate = False
        for s in runtime.screens:
            if reply.x == s.x:
                duplicate = True
                break

        if duplicate:
            continue

        scr = Screen(runtime.viewport, reply.x, reply.y, reply.width, reply.height, runtime.workspaces, gap)
        runtime.focused_screen = scr
        scr.set_workspace(runtime.workspaces[w])
        runtime.screens.append(scr)
        w += 1

    add_ext_clients(ext_clients, Client)

    for w in runtime.workspaces:
        if w.screen is not None:
            w.update()
        else:
            w.set_passive()

    runtime.keyboard.attach(runtime.viewport.root)
    runtime.mouse.attach(runtime.viewport.root)