Ejemplo n.º 1
0
    def __init__(self, output_layout: OutputLayout) -> None:
        """Manage a cursor attached to the given output layout

        Uses the given layout to establish the boundaries and movement
        semantics of this cursor. Cursors without an output layout allow
        infinite movement in any direction and do not support absolute input
        events.

        :param output_layout:
            The output layout to attach the cursor to and bound the cursor by.
        """
        ptr = lib.wlr_cursor_create()
        self._ptr = ffi.gc(ptr, lib.wlr_cursor_destroy)
        lib.wlr_cursor_attach_output_layout(self._ptr, output_layout._ptr)

        self.motion_event = Signal(ptr=ffi.addressof(self._ptr.events.motion),
                                   data_wrapper=PointerEventMotion)
        self.motion_absolute_event = Signal(
            ptr=ffi.addressof(self._ptr.events.motion_absolute),
            data_wrapper=PointerEventMotionAbsolute,
        )
        self.button_event = Signal(ptr=ffi.addressof(self._ptr.events.button),
                                   data_wrapper=PointerEventButton)
        self.axis_event = Signal(ptr=ffi.addressof(self._ptr.events.axis),
                                 data_wrapper=PointerEventAxis)
        self.frame_event = Signal(ptr=ffi.addressof(self._ptr.events.frame))
Ejemplo n.º 2
0
    def __init__(self, display: Display, name: str) -> None:
        """Allocates a new seat and adds a seat global to the display

        :param display:
            The Wayland server display to attach the seat to
        :param name:
            The name of the seat to create
        """
        ptr = lib.wlr_seat_create(display._ptr, name.encode())
        self._ptr = ffi.gc(ptr, lib.wlr_seat_destroy)

        self.pointer_grab_begin_event = Signal(
            ptr=ffi.addressof(self._ptr.events.pointer_grab_begin))
        self.pointer_grab_end_event = Signal(
            ptr=ffi.addressof(self._ptr.events.pointer_grab_end))

        self.keyboard_grab_begin_event = Signal(
            ptr=ffi.addressof(self._ptr.events.keyboard_grab_begin))
        self.keyboard_grab_end_event = Signal(
            ptr=ffi.addressof(self._ptr.events.keyboard_grab_end))

        self.touch_grab_begin_event = Signal(
            ptr=ffi.addressof(self._ptr.events.touch_grab_begin))
        self.touch_grab_end_event = Signal(
            ptr=ffi.addressof(self._ptr.events.touch_grab_end))

        self.request_set_cursor_event = Signal(
            ptr=ffi.addressof(self._ptr.events.request_set_cursor),
            data_wrapper=PointerRequestSetCursorEvent,
        )

        # Called when an application _wants_ to set the selection
        self.request_set_selection_event = Signal(
            ptr=ffi.addressof(self._ptr.events.request_set_selection),
            data_wrapper=RequestSetSelectionEvent,
        )
        # Called after the data source is set for the selection
        self.set_selection_event = Signal(
            ptr=ffi.addressof(self._ptr.events.set_selection))

        # Called when an application _wants_ to set the primary selection (user selects some data)
        self.request_set_primary_selection_event = Signal(
            ptr=ffi.addressof(self._ptr.events.request_set_primary_selection),
            data_wrapper=RequestSetPrimarySelectionEvent,
        )
        # Called after the primary selection source object is set
        self.set_primary_selection_event = Signal(
            ptr=ffi.addressof(self._ptr.events.set_primary_selection))

        self.request_start_drag_event = Signal(
            ptr=ffi.addressof(self._ptr.events.request_start_drag),
            data_wrapper=RequestStartDragEvent,
        )
        self.start_drag_event = Signal(
            ptr=ffi.addressof(self._ptr.events.start_drag),
            data_wrapper=Drag,
        )
Ejemplo n.º 3
0
    def __init__(self, size, scale=1):
        """Creates a new XCursor manager

        Create cursor with base size and scale.
        """
        ptr = lib.wlr_xcursor_manager_create(ffi.NULL, size)
        self._ptr = ffi.gc(ptr, lib.wlr_xcursor_manager_destroy)

        lib.wlr_xcursor_manager_load(self._ptr, scale)
Ejemplo n.º 4
0
    def __init__(self) -> None:
        """Creates an output layout to work with a layout of screens

        Creates a output layout, which can be used to describing outputs in
        physical space relative to one another, and perform various useful
        operations on that state.
        """
        ptr = lib.wlr_output_layout_create()
        self._ptr = ffi.gc(ptr, lib.wlr_output_layout_destroy)
Ejemplo n.º 5
0
    def __init__(self, display: Display, options: ServerOptions) -> None:
        ptr = lib.wlr_xwayland_server_create(display._ptr, options._ptr)
        if ptr == ffi.NULL:
            raise RuntimeError("Unable to create a wlr_xwayland_server.")

        self._ptr = ffi.gc(ptr, lib.wlr_xwayland_server_destroy)

        self.ready_event = Signal(ptr=ffi.addressof(self._ptr.events.ready))
        self.destroy_event = Signal(
            ptr=ffi.addressof(self._ptr.events.destroy))
Ejemplo n.º 6
0
    def __init__(self, display: Display, name: str) -> None:
        """Allocates a new seat and adds a seat global to the display

        :param display:
            The Wayland server display to attach the seat to
        :param name:
            The name of the seat to create
        """
        ptr = lib.wlr_seat_create(display._ptr, name.encode())
        self._ptr = ffi.gc(ptr, lib.wlr_seat_destroy)

        self.request_set_cursor_event = Signal(
            ptr=ffi.addressof(self._ptr.events.request_set_cursor)
        )
Ejemplo n.º 7
0
    def __init__(self, display: Display, compositor: Compositor,
                 lazy: bool) -> None:
        ptr = lib.wlr_xwayland_create(display._ptr, compositor._ptr, lazy)

        if ptr == ffi.NULL:
            raise RuntimeError("Unable to create a wlr_xwayland.")

        self._ptr = ffi.gc(ptr, lib.wlr_xwayland_destroy)

        self.ready_event = Signal(ptr=ffi.addressof(self._ptr.events.ready))
        self.new_surface_event = Signal(
            ptr=ffi.addressof(self._ptr.events.new_surface),
            data_wrapper=Surface,
        )
        self.remove_startup_info_event = Signal(
            ptr=ffi.addressof(self._ptr.events.remove_startup_info))
Ejemplo n.º 8
0
    def from_pixels(
        cls,
        renderer: Renderer,
        fmt: int,
        stride: int,
        width: int,
        height: int,
        data: ffi.CData,
    ) -> Texture:
        """
        Create a new texture from raw pixel data. `stride` is in bytes. The returned
        texture is mutable.

        Should not be called in a rendering block like renderer_begin()/end() or
        between attaching a renderer to an output and committing it.
        """
        ptr = lib.wlr_texture_from_pixels(
            renderer._ptr, fmt, stride, width, height, data
        )
        ptr = ffi.gc(ptr, lib.wlr_texture_destroy)
        return Texture(ptr)
Ejemplo n.º 9
0
    def __init__(self, output_layout: OutputLayout) -> None:
        """Manage a cursor attached to the given output layout

        Uses the given layout to establish the boundaries and movement
        semantics of this cursor. Cursors without an output layout allow
        infinite movement in any direction and do not support absolute input
        events.

        :param output_layout:
            The output layout to attach the cursor to and bound the cursor by.
        """
        ptr = lib.wlr_cursor_create()
        self._ptr = ffi.gc(ptr, lib.wlr_cursor_destroy)
        lib.wlr_cursor_attach_output_layout(self._ptr, output_layout._ptr)

        self.motion_event = Signal(ptr=ffi.addressof(self._ptr.events.motion),
                                   data_wrapper=PointerEventMotion)
        self.motion_absolute_event = Signal(
            ptr=ffi.addressof(self._ptr.events.motion_absolute),
            data_wrapper=PointerEventMotionAbsolute,
        )
        self.button_event = Signal(ptr=ffi.addressof(self._ptr.events.button),
                                   data_wrapper=PointerEventButton)
        self.axis_event = Signal(ptr=ffi.addressof(self._ptr.events.axis),
                                 data_wrapper=PointerEventAxis)
        self.frame_event = Signal(ptr=ffi.addressof(self._ptr.events.frame))
        self.swipe_begin = Signal(
            ptr=ffi.addressof(self._ptr.events.swipe_begin),
            data_wrapper=PointerEventSwipeBegin,
        )
        self.swipe_update = Signal(
            ptr=ffi.addressof(self._ptr.events.swipe_update),
            data_wrapper=PointerEventSwipeUpdate,
        )
        self.swipe_end = Signal(
            ptr=ffi.addressof(self._ptr.events.swipe_end),
            data_wrapper=PointerEventSwipeEnd,
        )
        self.pinch_begin = Signal(
            ptr=ffi.addressof(self._ptr.events.pinch_begin),
            data_wrapper=PointerEventPinchBegin,
        )
        self.pinch_update = Signal(
            ptr=ffi.addressof(self._ptr.events.pinch_update),
            data_wrapper=PointerEventPinchUpdate,
        )
        self.pinch_end = Signal(
            ptr=ffi.addressof(self._ptr.events.pinch_end),
            data_wrapper=PointerEventPinchEnd,
        )

        self.touch_up_event = Signal(
            ptr=ffi.addressof(self._ptr.events.touch_up),
            data_wrapper=TouchEventUp,
        )
        self.touch_down_event = Signal(
            ptr=ffi.addressof(self._ptr.events.touch_down),
            data_wrapper=TouchEventDown,
        )
        self.touch_motion_event = Signal(
            ptr=ffi.addressof(self._ptr.events.touch_motion),
            data_wrapper=TouchEventMotion,
        )
        self.touch_cancel_event = Signal(
            ptr=ffi.addressof(self._ptr.events.touch_cancel),
            data_wrapper=TouchEventCancel,
        )