Esempio n. 1
0
    def __init__(self):
        self.display = Display()
        self.connected = False
        self.formats = set()

        # initialize these to None
        self.compositor = None
        self.shell = None
        self.registry = None

        self.connect()
Esempio n. 2
0
def main():
    window = Window()

    display = Display()
    display.connect()
    print("connected to display")

    registry = display.get_registry()
    registry.dispatcher["global"] = registry_global_handler
    registry.dispatcher["global_remove"] = registry_global_remover
    registry.user_data = window

    display.dispatch(block=True)
    display.roundtrip()

    if window.compositor is None:
        raise RuntimeError("no compositor found")
    elif window.shell is None:
        raise RuntimeError("no shell found")
    elif window.shm is None:
        raise RuntimeError("no shm found")

    window.surface = window.compositor.create_surface()

    shell_surface = window.shell.get_shell_surface(window.surface)
    shell_surface.set_toplevel()
    shell_surface.dispatcher["ping"] = shell_surface_ping_handler

    frame_callback = window.surface.frame()
    frame_callback.dispatcher["done"] = redraw
    frame_callback.user_data = window

    create_window(window)
    redraw(frame_callback, 0, destroy_callback=False)

    while display.dispatch(block=True) != -1:
        pass

    import time

    time.sleep(1)

    display.disconnect()
Esempio n. 3
0
def touch_create(width, height):
    from pywayland.client import Display

    touch = {}

    # Make the display and get the registry
    touch['display'] = Display()
    touch['display'].connect()

    touch['registry'] = touch['display'].get_registry()
    touch['registry'].user_data = touch
    touch['registry'].dispatcher['global'] = handle_registry_global

    touch['display'].dispatch()
    touch['display'].roundtrip()

    if not touch['has_argb']:
        print("WL_SHM_FORMAT_ARGB32 not available", file=sys.stderr)
        touch['display'].disconnect()
        return

    touch['width'] = width
    touch['height'] = height
    touch['surface'] = touch['compositor'].create_surface()
    touch['shell_surface'] = touch['shell'].get_shell_surface(touch['surface'])
    create_shm_buffer(touch, width, height)

    if touch['shell_surface']:
        print('shell')
        touch['shell_surface'].dispatcher['ping'] = handle_shell_surface_ping
        touch['shell_surface'].set_toplevel()

    touch['surface'].user_data = touch
    touch['shell_surface'].set_title("simple-touch")

    touch['surface'].attach(touch['buffer'], 0, 0)
    touch['surface'].damage(0, 0, width, height)
    touch['surface'].commit()

    return touch
Esempio n. 4
0
def touch_create(width, height):
    touch = {}

    # Make the display and get the registry
    touch["display"] = Display()
    touch["display"].connect()

    touch["registry"] = touch["display"].get_registry()
    touch["registry"].user_data = touch
    touch["registry"].dispatcher["global"] = handle_registry_global

    touch["display"].dispatch()
    touch["display"].roundtrip()
    touch["display"].roundtrip()

    if not touch["has_argb"]:
        print("WL_SHM_FORMAT_ARGB32 not available", file=sys.stderr)
        touch["display"].disconnect()
        return

    touch["width"] = width
    touch["height"] = height
    touch["surface"] = touch["compositor"].create_surface()
    touch["shell_surface"] = touch["shell"].get_shell_surface(touch["surface"])
    create_shm_buffer(touch, width, height)

    if touch["shell_surface"]:
        print("shell")
        touch["shell_surface"].dispatcher["ping"] = handle_shell_surface_ping
        touch["shell_surface"].set_toplevel()

    touch["surface"].user_data = touch
    touch["shell_surface"].set_title("simple-touch")

    touch["surface"].attach(touch["buffer"], 0, 0)
    touch["surface"].damage(0, 0, width, height)
    touch["surface"].commit()

    return touch
Esempio n. 5
0
    def __init__(self, display: Union[str, int], qml_view: QUrl,
                 gl_context: QOpenGLContext):
        super().__init__()
        self.qml_view = qml_view
        self.display = display
        self.wl_display = Display(display)
        self.wl_compositor = None
        self.wl_shm = None
        self.wl_embedder = None
        self.views = {}
        self.fd_notifier = None
        self.engine = Engine()
        self.component = None
        self.qml_view = qml_view
        self.connected = False
        self.gl_context = gl_context

        assert gl_context.isOpenGLES()
        surface = QOffscreenSurface()
        surface.setFormat(gl_context.format())
        surface.create()
        gl_context.makeCurrent(surface)
Esempio n. 6
0
    elif interface == 'wl_shm':
        window['shm'] = registry.bind(id_, Shm, version)
        window['shm'].dispatcher['format'] = shm_format_handler


def registry_global_remover(registry, id_):
    print("got a registry losing event for {}".format(id))


def shell_surface_ping_handler(shell_surface, serial):
    shell_surface.pong(serial)


window = {'compositor': None, 'shell': None, 'shm': None}

display = Display()
display.connect()

registry = display.get_registry()
registry.dispatcher['global'] = registry_global_handler
registry.dispatcher['global_remove'] = registry_global_remover
registry.user_data = window

display.dispatch()
display.roundtrip()

assert window['compositor']
assert window['shell']
assert window['shm']

surface = window['compositor'].create_surface()