コード例 #1
0
def main():
    from xpra.platform import program_context
    with program_context("Platform-Events", "Platform Events Test"):
        if "-v" in sys.argv or "--verbose" in sys.argv:
            from xpra.platform.win32.win32_events import log as win32_event_logger
            log.enable_debug()
            win32_event_logger.enable_debug()

        import gobject
        gobject.threads_init()      #@UndefinedVariable

        log.info("Event loop is running")
        loop = gobject.MainLoop()

        def suspend():
            log.info("suspend event")
        def resume():
            log.info("resume event")
        fake_client = AdHocStruct()
        fake_client._focused = False
        fake_client.keyboard_grabbed = False
        fake_client.window_with_grab = None
        fake_client.suspend = suspend
        fake_client.resume = resume
        fake_client.keyboard_helper = None
        def signal_quit(*args):
            loop.quit()
        fake_client.signal_disconnect_and_quit = signal_quit
        ClientExtras(fake_client, None)

        try:
            loop.run()
        except KeyboardInterrupt:
            log.info("exiting on keyboard interrupt")
コード例 #2
0
def test_gl_client_window(gl_client_window_class,
                          max_window_size=(1024, 1024),
                          pixel_depth=24):
    #try to render using a temporary window:
    draw_result = {}
    window = None
    try:
        w, h = 50, 50
        from xpra.client.window_border import WindowBorder
        border = WindowBorder()
        default_cursor_data = None
        noclient = AdHocStruct()

        def no_idle_add(fn, *args, **kwargs):
            fn(*args, **kwargs)

        def no_timeout_add(*args, **kwargs):
            raise Exception("timeout_add should not have been called")

        def no_source_remove(*args, **kwargs):
            raise Exception("source_remove should not have been called")

        def no_scaling(*args):
            return args

        def get_None(*args):
            return None

        def noop(*args):
            pass

        #we have to suspend idle_add to make this synchronous
        #we can do this because this method must be running in the UI thread already:
        noclient.idle_add = no_idle_add
        noclient.timeout_add = no_timeout_add
        noclient.source_remove = no_source_remove
        noclient.sp = noclient.sx = noclient.sy = noclient.srect = no_scaling
        noclient.xscale = noclient.yscale = 1
        noclient.server_window_decorations = True
        noclient.mmap_enabled = False
        noclient.mmap = None
        noclient.encoding_defaults = {}
        noclient.get_window_frame_sizes = get_None
        noclient._set_window_menu = None
        noclient._focused = None
        noclient.request_frame_extents = noop
        window = gl_client_window_class(noclient, None, None, 2**32 - 1, -100,
                                        -100, w, h, w, h, typedict({}), False,
                                        typedict({}), border, max_window_size,
                                        default_cursor_data, pixel_depth)
        window._backing.idle_add = no_idle_add
        window._backing.timeout_add = no_timeout_add
        window._backing.source_remove = no_source_remove
        window.realize()
        pixel_format = "BGRX"
        bpp = len(pixel_format)
        options = typedict({"pixel_format": pixel_format})
        stride = bpp * w
        img_data = b"\0" * stride * h
        coding = "rgb32"
        widget = window._backing._backing
        widget.realize()

        def paint_callback(success, message):
            log("paint_callback(%s, %s)", success, message)
            draw_result.update({
                "success": success,
                "message": message,
            })

        log("OpenGL: testing draw on %s widget %s with %s : %s", window,
            widget, coding, pixel_format)
        window.draw_region(0, 0, w, h, coding, img_data, stride, 1, options,
                           [paint_callback])
    finally:
        if window:
            window.destroy()
    log("test_gl_client_window(..) draw_result=%s", draw_result)
    return draw_result