예제 #1
0
def set_initial_resolution(res=DEFAULT_VFB_RESOLUTION):
    try:
        log = get_vfb_logger()
        log("set_initial_resolution(%s)", res)
        from xpra.x11.bindings.randr_bindings import RandRBindings      #@UnresolvedImport
        #try to set a reasonable display size:
        randr = RandRBindings()
        if not randr.has_randr():
            log.warn("Warning: no RandR support,")
            log.warn(" default virtual display size unchanged")
            return
        sizes = randr.get_xrr_screen_sizes()
        size = randr.get_screen_size()
        log("RandR available, current size=%s, sizes available=%s", size, sizes)
        if res not in sizes:
            log.warn("Warning: cannot set resolution to %s", res)
            log.warn(" (this resolution is not available)")
        elif res==size:
            log("initial resolution already set: %s", res)
        else:
            log("RandR setting new screen size to %s", res)
            randr.set_screen_size(*res)
    except Exception as e:
        log("set_initial_resolution(%s)", res, exc_info=True)
        log.error("Error: failed to set the default screen size:")
        log.error(" %s", e)
예제 #2
0
def set_initial_resolution(desktop=False):
    try:
        log = get_vfb_logger()
        log("set_initial_resolution")
        if desktop:
            res = DEFAULT_DESKTOP_VFB_RESOLUTION
        else:
            res = DEFAULT_VFB_RESOLUTION
        from xpra.x11.bindings.randr_bindings import RandRBindings  #@UnresolvedImport
        #try to set a reasonable display size:
        randr = RandRBindings()
        if not randr.has_randr():
            l = log
            if desktop:
                l = log.warn
            l("Warning: no RandR support,")
            l(" default virtual display size unchanged")
            return
        sizes = randr.get_xrr_screen_sizes()
        size = randr.get_screen_size()
        log("RandR available, current size=%s, sizes available=%s", size,
            sizes)
        if res in sizes:
            log("RandR setting new screen size to %s", res)
            randr.set_screen_size(*res)
    except Exception as e:
        log("set_initial_resolution(%s)", desktop, exc_info=True)
        log.error("Error: failed to set the default screen size:")
        log.error(" %s", e)
예제 #3
0
def test_add(w, h):
    from xpra.x11.gtk_x11.gdk_display_source import init_gdk_display_source
    init_gdk_display_source()
    from xpra.x11.bindings.randr_bindings import RandRBindings, log  #@UnresolvedImport
    log.enable_debug()
    RandR = RandRBindings()
    screen_sizes = RandR.get_xrr_screen_sizes()
    print("screen_sizes=%s" % (screen_sizes, ))
    if (w, h) in screen_sizes:
        print("resolution %s is already present!" % ((w, h), ))
        return
    from xpra.gtk_common.error import xsync
    with xsync:
        r = RandR.add_screen_size(w, h)
        print("add_screen_size(%i, %i)=%s" % (w, h, r))
    import time
    time.sleep(2)
    screen_sizes = RandR.get_xrr_screen_sizes()
    print("updated screen_sizes=%s" % (screen_sizes, ))