コード例 #1
0
ファイル: listkeys.py プロジェクト: rmsilva/tilenol
    def main():
        proto = Proto()
        proto.load_xml("xproto")
        core = Core(Connection(proto))
        core.init_keymap()
        ksyms = Keysyms()
        ksyms.load_default()

        if options.action == "keysyms":
            list_keysyms(options, xcore=core, keysyms=ksyms)
コード例 #2
0
 def testPicture(self, conn):
     from tilenol.xcb.core import Core, Rectangle
     core = Core(conn)
     img = cairo.ImageSurface(cairo.FORMAT_ARGB32, 128, 128)
     ctx = cairo.Context(img)
     ctx.set_source_rgb(1, 0, 0)
     ctx.move_to(64, 0)
     ctx.line_to(128, 128)
     ctx.line_to(0, 128)
     ctx.fill()
     conn.connection()
     win = core.create_toplevel(
         bounds=Rectangle(10, 10, 100, 100),
         border=1,
         klass=core.WindowClass.InputOutput,
         params={
             core.CW.BackPixel:
             conn.init_data['roots'][0]['white_pixel'],
             core.CW.EventMask:
             core.EventMask.Exposure | core.EventMask.KeyPress,
         })
     core.raw.MapWindow(window=win)
     for ev in conn.get_events():
         if ev.__class__.__name__ == 'ExposeEvent' and ev.window == win:
             break
     gc = conn.new_xid()
     core.raw.CreateGC(
         cid=gc,
         drawable=conn.init_data['roots'][0]['root'],
         params={},
     )
     assert len(bytes(img)) == 128 * 128 * 4, len(bytes(img))
     core.raw.PutImage(
         format=core.ImageFormat.ZPixmap,
         drawable=win,
         gc=gc,
         width=128,
         height=128,
         dst_x=0,
         dst_y=0,
         left_pad=0,
         depth=24,
         data=bytes(img),
     )
     core.raw.GetAtomName(atom=1)  # ensures putimage error will be printed
コード例 #3
0
ファイル: test_cairo.py プロジェクト: KenjiTakahashi/tilenol
 def testPicture(self, conn):
     from tilenol.xcb.core import Core, Rectangle
     core = Core(conn)
     img = cairo.ImageSurface(cairo.FORMAT_ARGB32, 128, 128)
     ctx = cairo.Context(img)
     ctx.set_source_rgb(1, 0, 0)
     ctx.move_to(64, 0)
     ctx.line_to(128, 128)
     ctx.line_to(0, 128)
     ctx.fill()
     conn.connection()
     win = core.create_toplevel(
         bounds=Rectangle(10, 10, 100, 100),
         border=1,
         klass=core.WindowClass.InputOutput,
         params={
             core.CW.BackPixel: conn.init_data['roots'][0]['white_pixel'],
             core.CW.EventMask:
                 core.EventMask.Exposure | core.EventMask.KeyPress,
             })
     core.raw.MapWindow(window=win)
     for ev in conn.get_events():
         if ev.__class__.__name__ == 'ExposeEvent' and ev.window == win:
             break
     gc = conn.new_xid()
     core.raw.CreateGC(
         cid=gc,
         drawable=conn.init_data['roots'][0]['root'],
         params={},
         )
     assert len(bytes(img)) == 128*128*4, len(bytes(img))
     core.raw.PutImage(
         format=core.ImageFormat.ZPixmap,
         drawable=win,
         gc=gc,
         width=128,
         height=128,
         dst_x=0,
         dst_y=0,
         left_pad=0,
         depth=24,
         data=bytes(img),
         )
     core.raw.GetAtomName(atom=1)  # ensures putimage error will be printed
コード例 #4
0
 def testWin(self, conn):
     from tilenol.xcb.core import Core, Rectangle
     core = Core(conn)
     conn.connection()
     win = core.create_toplevel(
         bounds=Rectangle(10, 10, 100, 100),
         border=1,
         klass=core.WindowClass.InputOutput,
         params={
             core.CW.BackPixel: conn.init_data['roots'][0]['white_pixel'],
             core.CW.EventMask:
                 core.EventMask.Exposure | core.EventMask.KeyPress,
             })
     core.raw.MapWindow(window=win)
     for ev in conn.get_events():
         if ev.__class__.__name__ == 'ExposeEvent' and ev.window == win:
             break
     attr = core.raw.GetWindowAttributes(window=win)
     self.assertTrue(attr['map_state'])
コード例 #5
0
 def testAtoms(self, conn):
     from tilenol.xcb.core import Core
     core = Core(conn)
     self.assertEqual(core.atom.WM_CLASS, 67)
     self.assertEqual(core.atom.WM_CLASS.name, 'WM_CLASS')
     self.assertEqual(repr(core.atom.WM_CLASS), '<Atom WM_CLASS:67>')
     a1 = conn.do_request(conn.proto.requests['InternAtom'],
         only_if_exists=False, name="_ZXCB")['atom']
     self.assertTrue(a1 > 200)
     self.assertEquals(core.atom._ZXCB, a1)
コード例 #6
0
ファイル: test_xcb.py プロジェクト: rmsilva/tilenol
    def testWin(self, conn):
        from tilenol.xcb.core import Core, Rectangle

        core = Core(conn)
        conn.connection()
        win = core.create_toplevel(
            bounds=Rectangle(10, 10, 100, 100),
            border=1,
            klass=core.WindowClass.InputOutput,
            params={
                core.CW.BackPixel: conn.init_data["roots"][0]["white_pixel"],
                core.CW.EventMask: core.EventMask.Exposure | core.EventMask.KeyPress,
            },
        )
        core.raw.MapWindow(window=win)
        for ev in conn.get_events():
            if ev.__class__.__name__ == "ExposeEvent" and ev.window == win:
                break
        attr = core.raw.GetWindowAttributes(window=win)
        self.assertTrue(attr["map_state"])
コード例 #7
0
    def main():
        nonlocal retcode
        proto = Proto()
        proto.load_xml('xproto')
        proto.load_xml('randr')
        proto.load_xml('xinerama')
        core = Core(Connection(proto))
        core.randr._proto.requests['GetScreenInfo'].reply.items['rates'].code \
            = compile('0', 'XPROTO', 'eval')

        if options.disable is not None:
            disable_output(core, options.disable)
        elif options.action == 'help':
            val = core.randr._proto.requests['SetCrtcConfig'].read_from(
                b"\226\25\10\0"
                b"@\0\0\0"  #crtc
                b"\0\0\0\0"  # timestamp
                b"mi&\6"  #cfg timestamp
                b"\200\7"  # x
                b"\0\0"  # y
                b"\270\0\0\0"  # mode
                b"\1\0"  # rotation
                b"\0\0"  # padding
                b"D\0\0\0"  # output
                ,
                4)
            print_help(ap)
        elif options.action == 'all':
            print_screen(core)
            print_screen_size_range(core)
            print_crtc(core)
            print_output(core)
            print_xinerama(core)
        elif options.action == 'screen':
            print_screen(core)
        elif options.action == 'screen_size_range':
            print_screen_size_range(core)
        elif options.action == 'crtc':
            print_crtc(core)
        elif options.action == 'crtc_extra':
            print_crtc_extra(core)
        elif options.action == 'output':
            print_output(core)
        elif options.action == 'output_properties':
            print_output_properties(core)
        elif options.action == 'xinerama':
            print_xinerama(core)
        elif options.action == 'providers':
            print_providers(core)
        elif options.action == 'autoconfig':
            configure_outputs(core, options.ppm)
        elif options.action == 'check':
            retcode = check_screens(core)
コード例 #8
0
 def testRaw(self, conn):
     from tilenol.xcb.core import Core
     core = Core(conn)
     a2 = core.raw.InternAtom(only_if_exists=True, name="WM_CLASS")['atom']
     self.assertEqual(a2, 67)
コード例 #9
0
 def testAtoms(self, conn):
     from tilenol.xcb.core import Core
     core = Core(conn)
     self.assertEqual(core.EventMask.Exposure, 32768)
     self.assertEqual(core.CW.BackPixel, 2)
     self.assertEqual(repr(core.CW.BackPixel), '<Const BackPixel:2>')