def main(argv): with Display() as display: signal.signal(signal.SIGINT, partial(sig_cb, display)) backend = Backend(display) renderer = Renderer(backend, display) compositor = Compositor(display, renderer) # noqa: F841 device_manager = DataDeviceManager(display) # noqa: F841 xdg_shell = XdgShell(display) with OutputLayout() as output_layout, Cursor( output_layout) as cursor, XCursorManager( 24) as xcursor_manager, Seat(display, "seat0") as seat: tinywl_server = TinywlServer( # noqa: F841 display=display, backend=backend, renderer=renderer, xdg_shell=xdg_shell, cursor=cursor, cursor_manager=xcursor_manager, seat=seat, output_layout=output_layout, ) socket = display.add_socket() print("socket:", socket.decode()) with backend: display.run()
def main(argv) -> None: with Display() as display: compositor, allocator, renderer, backend = build_compositor(display) device_manager = DataDeviceManager(display) # noqa: F841 xdg_shell = XdgShell(display) with OutputLayout() as output_layout, Cursor( output_layout ) as cursor, XCursorManager(24) as xcursor_manager, Seat( display, "seat0" ) as seat: scene = Scene(output_layout) tinywl_server = TinywlServer( # noqa: F841 display=display, backend=backend, allocator=allocator, renderer=renderer, scene=scene, xdg_shell=xdg_shell, cursor=cursor, cursor_manager=xcursor_manager, seat=seat, output_layout=output_layout, ) socket = display.add_socket() print("socket:", socket.decode()) with backend: display.run()
def __init__(self): """Setup the Wayland core backend""" self.qtile: Optional[Qtile] = None self.desktops: int = 1 self.current_desktop: int = 0 self.display = Display() self.event_loop = self.display.get_event_loop() self.compositor, self.backend = wlroots_helper.build_compositor( self.display) self.renderer = self.backend.renderer self.socket = self.display.add_socket() self.fd = None self._hovered_internal: Optional[window.Internal] = None # These windows have not been mapped yet; they'll get managed when mapped self.pending_windows: List[window.WindowType] = [] # mapped_windows contains just regular windows self.mapped_windows: List[window.WindowType] = [] # Ascending in Z # stacked_windows also contains layer_shell windows from the current output self.stacked_windows: List[window.WindowType] = [] # Ascending in Z self._current_output: Optional[Output] = None # set up inputs self.keyboards: List[keyboard.Keyboard] = [] self.grabbed_keys: List[Tuple[int, int]] = [] self.grabbed_buttons: List[Tuple[int, int]] = [] DataDeviceManager(self.display) DataControlManagerV1(self.display) self.seat = seat.Seat(self.display, "seat0") self.add_listener(self.seat.request_set_selection_event, self._on_request_set_selection) self.add_listener(self.backend.new_input_event, self._on_new_input) # set up outputs self.outputs: List[Output] = [] self.add_listener(self.backend.new_output_event, self._on_new_output) self.output_layout = OutputLayout() self.add_listener(self.output_layout.change_event, self._on_output_layout_change) self.output_manager = OutputManagerV1(self.display) self.add_listener(self.output_manager.apply_event, self._on_output_manager_apply) self.add_listener(self.output_manager.test_event, self._on_output_manager_test) # set up cursor self.cursor = Cursor(self.output_layout) self.cursor_manager = XCursorManager(24) self.add_listener(self.seat.request_set_cursor_event, self._on_request_cursor) self.add_listener(self.cursor.axis_event, self._on_cursor_axis) self.add_listener(self.cursor.frame_event, self._on_cursor_frame) self.add_listener(self.cursor.button_event, self._on_cursor_button) self.add_listener(self.cursor.motion_event, self._on_cursor_motion) self.add_listener(self.cursor.motion_absolute_event, self._on_cursor_motion_absolute) # set up shell self.xdg_shell = XdgShell(self.display) self.add_listener(self.xdg_shell.new_surface_event, self._on_new_xdg_surface) self.layer_shell = LayerShellV1(self.display) self.add_listener(self.layer_shell.new_surface_event, self._on_new_layer_surface) # Add support for additional protocols XdgOutputManagerV1(self.display, self.output_layout) ScreencopyManagerV1(self.display) GammaControlManagerV1(self.display) PrimarySelectionV1DeviceManager(self.display) self._virtual_keyboard_manager_v1 = VirtualKeyboardManagerV1( self.display) self.add_listener( self._virtual_keyboard_manager_v1.new_virtual_keyboard_event, self._on_new_virtual_keyboard) xdg_decoration_manager_v1 = xdg_decoration_v1.XdgDecorationManagerV1.create( self.display) self.add_listener( xdg_decoration_manager_v1.new_toplevel_decoration_event, self._on_new_toplevel_decoration, ) # wlr_server_decoration will be removed in a future version of wlroots server_decoration_manager = ServerDecorationManager.create( self.display) server_decoration_manager.set_default_mode( ServerDecorationManagerMode.SERVER) # start os.environ["WAYLAND_DISPLAY"] = self.socket.decode() logger.info("Starting core with WAYLAND_DISPLAY=" + self.socket.decode()) self.backend.start()
def __init__(self) -> None: """Setup the Wayland core backend""" self.qtile: Qtile | None = None self.desktops: int = 1 self.current_desktop: int = 0 self._hovered_internal: window.Internal | None = None self.focused_internal: window.Internal | None = None self.fd: int | None = None self.display = Display() self.event_loop = self.display.get_event_loop() ( self.compositor, self._allocator, self.renderer, self.backend, ) = wlroots_helper.build_compositor(self.display) self.socket = self.display.add_socket() os.environ["WAYLAND_DISPLAY"] = self.socket.decode() logger.info("Starting core with WAYLAND_DISPLAY=" + self.socket.decode()) # These windows have not been mapped yet; they'll get managed when mapped self.pending_windows: set[window.WindowType] = set() # mapped_windows contains just regular windows self.mapped_windows: list[window.WindowType] = [] # Ascending in Z # stacked_windows also contains layer_shell windows from the current output self.stacked_windows: Sequence[window.WindowType] = [ ] # Ascending in Z self._current_output: Output | None = None # set up inputs self.keyboards: list[inputs.Keyboard] = [] self.grabbed_keys: list[tuple[int, int]] = [] self.grabbed_buttons: list[tuple[int, int]] = [] DataDeviceManager(self.display) self.live_dnd: wlrq.Dnd | None = None DataControlManagerV1(self.display) self.seat = seat.Seat(self.display, "seat0") self.add_listener(self.seat.request_set_selection_event, self._on_request_set_selection) self.add_listener(self.seat.request_start_drag_event, self._on_request_start_drag) self.add_listener(self.seat.start_drag_event, self._on_start_drag) self.add_listener(self.backend.new_input_event, self._on_new_input) # Some devices are added early, so we need to remember to configure them self._pending_input_devices: list[input_device.InputDevice] = [] hook.subscribe.startup_complete(self._configure_pending_inputs) # set up outputs self.outputs: list[Output] = [] self.add_listener(self.backend.new_output_event, self._on_new_output) self.output_layout = OutputLayout() self.add_listener(self.output_layout.change_event, self._on_output_layout_change) self.output_manager = OutputManagerV1(self.display) self.add_listener(self.output_manager.apply_event, self._on_output_manager_apply) self.add_listener(self.output_manager.test_event, self._on_output_manager_test) # set up cursor self.cursor = Cursor(self.output_layout) self.cursor_manager = XCursorManager(24) self.add_listener(self.seat.request_set_cursor_event, self._on_request_cursor) self.add_listener(self.cursor.axis_event, self._on_cursor_axis) self.add_listener(self.cursor.frame_event, self._on_cursor_frame) self.add_listener(self.cursor.button_event, self._on_cursor_button) self.add_listener(self.cursor.motion_event, self._on_cursor_motion) self.add_listener(self.cursor.motion_absolute_event, self._on_cursor_motion_absolute) # set up shell self.xdg_shell = XdgShell(self.display) self.add_listener(self.xdg_shell.new_surface_event, self._on_new_xdg_surface) self.layer_shell = LayerShellV1(self.display) self.add_listener(self.layer_shell.new_surface_event, self._on_new_layer_surface) # Add support for additional protocols XdgOutputManagerV1(self.display, self.output_layout) ScreencopyManagerV1(self.display) GammaControlManagerV1(self.display) output_power_manager = OutputPowerManagerV1(self.display) self.add_listener(output_power_manager.set_mode_event, self._on_output_power_manager_set_mode) self.idle = Idle(self.display) idle_ihibitor_manager = IdleInhibitorManagerV1(self.display) self.add_listener(idle_ihibitor_manager.new_inhibitor_event, self._on_new_inhibitor) PrimarySelectionV1DeviceManager(self.display) self._virtual_keyboard_manager_v1 = VirtualKeyboardManagerV1( self.display) self.add_listener( self._virtual_keyboard_manager_v1.new_virtual_keyboard_event, self._on_new_virtual_keyboard, ) xdg_decoration_manager_v1 = xdg_decoration_v1.XdgDecorationManagerV1.create( self.display) self.add_listener( xdg_decoration_manager_v1.new_toplevel_decoration_event, self._on_new_toplevel_decoration, ) # wlr_server_decoration will be removed in a future version of wlroots server_decoration_manager = ServerDecorationManager.create( self.display) server_decoration_manager.set_default_mode( ServerDecorationManagerMode.SERVER) pointer_constraints_v1 = PointerConstraintsV1(self.display) self.add_listener( pointer_constraints_v1.new_constraint_event, self._on_new_pointer_constraint, ) self.pointer_constraints: set[window.PointerConstraint] = set() self.active_pointer_constraint: window.PointerConstraint | None = None self._relative_pointer_manager_v1 = RelativePointerManagerV1( self.display) self.foreign_toplevel_manager_v1 = ForeignToplevelManagerV1.create( self.display) # Set up XWayland self._xwayland = xwayland.XWayland(self.display, self.compositor, True) if self._xwayland: os.environ["DISPLAY"] = self._xwayland.display_name or "" logger.info("Set up XWayland with DISPLAY=" + os.environ["DISPLAY"]) self.add_listener(self._xwayland.ready_event, self._on_xwayland_ready) self.add_listener(self._xwayland.new_surface_event, self._on_xwayland_new_surface) else: logger.info("Failed to set up XWayland. Continuing without.") # Start self.backend.start()
def __init__(self): """Setup the Wayland core backend""" self.qtile: Optional[Qtile] = None self.desktops: int = 1 self.current_desktop: int = 0 self.display = Display() self.event_loop = self.display.get_event_loop() self.compositor, self.backend = wlroots_helper.build_compositor( self.display) self.renderer = self.backend.renderer self.socket = self.display.add_socket() self.fd = None # set up inputs self.keyboards: List[keyboard.Keyboard] = [] self.grabbed_keys: List[Tuple[int, int]] = [] self.grabbed_buttons: List[Tuple[int, int]] = [] self.device_manager = DataDeviceManager(self.display) self.seat = seat.Seat(self.display, "seat0") self._on_request_set_selection_listener = Listener( self._on_request_set_selection) self._on_new_input_listener = Listener(self._on_new_input) self.seat.request_set_selection_event.add( self._on_request_set_selection_listener) self.backend.new_input_event.add(self._on_new_input_listener) # set up outputs self.output_layout = OutputLayout() self.outputs: List[output.Output] = [] self._on_new_output_listener = Listener(self._on_new_output) self.backend.new_output_event.add(self._on_new_output_listener) # set up cursor self.cursor = Cursor(self.output_layout) self.cursor_manager = XCursorManager(24) self._on_request_cursor_listener = Listener(self._on_request_cursor) self.seat.request_set_cursor_event.add( self._on_request_cursor_listener) self._on_cursor_axis_listener = Listener(self._on_cursor_axis) self._on_cursor_frame_listener = Listener(self._on_cursor_frame) self._on_cursor_button_listener = Listener(self._on_cursor_button) self._on_cursor_motion_listener = Listener(self._on_cursor_motion) self._on_cursor_motion_absolute_listener = Listener( self._on_cursor_motion_absolute) self.cursor.axis_event.add(self._on_cursor_axis_listener) self.cursor.frame_event.add(self._on_cursor_frame_listener) self.cursor.button_event.add(self._on_cursor_button_listener) self.cursor.motion_event.add(self._on_cursor_motion_listener) self.cursor.motion_absolute_event.add( self._on_cursor_motion_absolute_listener) # set up shell self.xdg_shell = xdg_shell.XdgShell(self.display) self._on_new_xdg_surface_listener = Listener(self._on_new_xdg_surface) self.xdg_shell.new_surface_event.add(self._on_new_xdg_surface_listener) # Add support for additional protocols XdgOutputManagerV1(self.display, self.output_layout) ScreencopyManagerV1(self.display) GammaControlManagerV1(self.display) self._virtual_keyboard_manager_v1 = VirtualKeyboardManagerV1( self.display) self._on_new_virtual_keyboard_listener = Listener( self._on_new_virtual_keyboard) self._virtual_keyboard_manager_v1.new_virtual_keyboard_event.add( self._on_new_virtual_keyboard_listener) # start os.environ["WAYLAND_DISPLAY"] = self.socket.decode() logger.info("Starting core with WAYLAND_DISPLAY=" + self.socket.decode()) self.backend.start()