From 808b543a6a710011412b8e6e2f93b0a95e3f291e Mon Sep 17 00:00:00 2001 From: mcol Date: Tue, 3 Oct 2023 23:34:14 +0100 Subject: [PATCH 01/68] (wlroots 9f793d3) layer-shell-v1: specify version in constructor --- wlroots/ffi_build.py | 3 ++- wlroots/wlr_types/layer_shell_v1.py | 10 ++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/wlroots/ffi_build.py b/wlroots/ffi_build.py index f5606844..abecbb19 100644 --- a/wlroots/ffi_build.py +++ b/wlroots/ffi_build.py @@ -2915,7 +2915,8 @@ def has_xwayland() -> bool: ...; }; -struct wlr_layer_shell_v1 *wlr_layer_shell_v1_create(struct wl_display *display); +struct wlr_layer_shell_v1 *wlr_layer_shell_v1_create(struct wl_display *display, + uint32_t version); void wlr_layer_surface_v1_configure(struct wlr_layer_surface_v1 *surface, uint32_t width, uint32_t height); diff --git a/wlroots/wlr_types/layer_shell_v1.py b/wlroots/wlr_types/layer_shell_v1.py index 2cca23a3..91b6409e 100644 --- a/wlroots/wlr_types/layer_shell_v1.py +++ b/wlroots/wlr_types/layer_shell_v1.py @@ -197,10 +197,16 @@ def surface_at(self, sx: float, sy: float) -> tuple[Surface | None, float, float return Surface(surface_ptr), sub_x_data[0], sub_y_data[0] +LAYER_SHELL_VERSION = 4 + + class LayerShellV1(PtrHasData): - def __init__(self, display: Display) -> None: + def __init__(self, display: Display, version: int) -> None: """Create an wlr_xdg_output_manager_v1""" - self._ptr = lib.wlr_layer_shell_v1_create(display._ptr) + if not 0 < version <= LAYER_SHELL_VERSION: + raise ValueError("Invalid layer shell version.") + + self._ptr = lib.wlr_layer_shell_v1_create(display._ptr, version) self.new_surface_event = Signal( ptr=ffi.addressof(self._ptr.events.new_surface), data_wrapper=LayerSurfaceV1 From a002817c75c7ab55e221cb5f1ff9740412055e35 Mon Sep 17 00:00:00 2001 From: mcol Date: Tue, 3 Oct 2023 23:53:44 +0100 Subject: [PATCH 02/68] (wlroots c8a5dfc) wlr_scene: Add drag icon helper --- wlroots/ffi_build.py | 3 +++ wlroots/wlr_types/scene.py | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/wlroots/ffi_build.py b/wlroots/ffi_build.py index abecbb19..e87fdbe7 100644 --- a/wlroots/ffi_build.py +++ b/wlroots/ffi_build.py @@ -1928,6 +1928,9 @@ def has_xwayland() -> bool: void wlr_scene_layer_surface_v1_configure( struct wlr_scene_layer_surface_v1 *scene_layer_surface, const struct wlr_box *full_area, struct wlr_box *usable_area); + +struct wlr_scene_tree *wlr_scene_drag_icon_create( + struct wlr_scene_tree *parent, struct wlr_drag_icon *drag_icon); """ # types/wlr_screencopy_v1.h diff --git a/wlroots/wlr_types/scene.py b/wlroots/wlr_types/scene.py index 3a99d2f9..55942832 100644 --- a/wlroots/wlr_types/scene.py +++ b/wlroots/wlr_types/scene.py @@ -13,6 +13,7 @@ from wlroots.util.box import Box from wlroots.util.clock import Timespec from wlroots.wlr_types import Buffer, Output, OutputLayout + from wlroots.wlr_types.data_device_manager import DragIcon from wlroots.wlr_types.layer_shell_v1 import LayerSurfaceV1 from wlroots.wlr_types.presentation_time import Presentation from wlroots.wlr_types.xdg_shell import XdgSurface @@ -134,6 +135,10 @@ def subsurface_tree_create(cls, parent: SceneTree, surface: Surface) -> SceneTre lib.wlr_scene_subsurface_tree_create(parent._ptr, surface._ptr) ) + @classmethod + def drag_icon_create(cls, parent: SceneTree, drag_icon: DragIcon) -> SceneTree: + return SceneTree(lib.wlr_scene_drag_icon_create(parent._ptr, drag_icon._ptr)) + class SceneBuffer(Ptr): def __init__(self, ptr) -> None: From d13f88c331b1c700e6e2adf8c2f613b6a2908166 Mon Sep 17 00:00:00 2001 From: mcol Date: Wed, 4 Oct 2023 00:11:35 +0100 Subject: [PATCH 03/68] (wlroots 258bf9b) compositor: drop wlr_surface.{sx,sy} --- wlroots/ffi_build.py | 1 - wlroots/wlr_types/compositor.py | 10 ---------- 2 files changed, 11 deletions(-) diff --git a/wlroots/ffi_build.py b/wlroots/ffi_build.py index e87fdbe7..64e920eb 100644 --- a/wlroots/ffi_build.py +++ b/wlroots/ffi_build.py @@ -362,7 +362,6 @@ def has_xwayland() -> bool: struct wl_resource *resource; struct wlr_renderer *renderer; struct wlr_client_buffer *buffer; - int sx, sy; struct pixman_region32 buffer_damage; struct pixman_region32 external_damage; struct pixman_region32 opaque_region; diff --git a/wlroots/wlr_types/compositor.py b/wlroots/wlr_types/compositor.py index 42d114fe..d9eae97a 100644 --- a/wlroots/wlr_types/compositor.py +++ b/wlroots/wlr_types/compositor.py @@ -71,16 +71,6 @@ def is_xwayland_surface(self) -> bool: """ return lib.wlr_surface_is_xwayland_surface(self._ptr) - @property - def sx(self) -> int: - """Surface local buffer x position""" - return self._ptr.sx - - @property - def sy(self) -> int: - """Surface local buffer y position""" - return self._ptr.sy - @property def current(self) -> SurfaceState: """The current commited surface state""" From d56147a4d4c6620993a9216bffc1dbbd0f4e78bc Mon Sep 17 00:00:00 2001 From: mcol Date: Wed, 4 Oct 2023 00:58:57 +0100 Subject: [PATCH 04/68] (wlroots ff55663) output: introduce request_state event --- wlroots/ffi_build.py | 27 ++++++++++++++++++++++----- wlroots/wlr_types/output.py | 22 ++++++++++++++++++++++ 2 files changed, 44 insertions(+), 5 deletions(-) diff --git a/wlroots/ffi_build.py b/wlroots/ffi_build.py index 64e920eb..30e1f899 100644 --- a/wlroots/ffi_build.py +++ b/wlroots/ffi_build.py @@ -1101,13 +1101,19 @@ def has_xwayland() -> bool: float scale; enum wl_output_subpixel subpixel; enum wl_output_transform transform; + enum wlr_output_adaptive_sync_status adaptive_sync_status; + uint32_t render_format; bool needs_frame; bool frame_pending; float transform_matrix[9]; + bool non_desktop; struct wlr_output_state pending; + // Commit sequence number. Incremented on each commit, may overflow. + uint32_t commit_seq; + struct { struct wl_signal frame; struct wl_signal damage; @@ -1119,24 +1125,35 @@ def has_xwayland() -> bool: struct wl_signal enable; struct wl_signal mode; struct wl_signal description; + struct wl_signal request_state; struct wl_signal destroy; } events; struct wl_event_source *idle_frame; struct wl_event_source *idle_done; - - int attach_render_locks; // number of locks forcing rendering - - struct wl_list cursors; // wlr_output_cursor::link + int attach_render_locks; + struct wl_list cursors; struct wlr_output_cursor *hardware_cursor; + struct wlr_swapchain *cursor_swapchain; + struct wlr_buffer *cursor_front_buffer; int software_cursor_locks; - + struct wlr_allocator *allocator; + struct wlr_renderer *renderer; + struct wlr_swapchain *swapchain; + struct wlr_buffer *back_buffer; struct wl_listener display_destroy; + struct wlr_addon_set addons; void *data; ...; }; +struct wlr_output_event_request_state { + struct wlr_output *output; + const struct wlr_output_state *state; + ...; +}; + void wlr_output_enable(struct wlr_output *output, bool enable); void wlr_output_create_global(struct wlr_output *output); void wlr_output_destroy_global(struct wlr_output *output); diff --git a/wlroots/wlr_types/output.py b/wlroots/wlr_types/output.py index 21fac421..9b518cc2 100644 --- a/wlroots/wlr_types/output.py +++ b/wlroots/wlr_types/output.py @@ -51,6 +51,10 @@ def __init__(self, ptr) -> None: self.enable_event = Signal(ptr=ffi.addressof(self._ptr.events.enable)) self.mode_event = Signal(ptr=ffi.addressof(self._ptr.events.mode)) self.description_event = Signal(ptr=ffi.addressof(self._ptr.events.description)) + self.request_state_event = Signal( + ptr=ffi.addressof(self._ptr.events.request_state), + data_wrapper=OutputEventRequestState, + ) self.destroy_event = Signal(ptr=ffi.addressof(self._ptr.events.destroy)) @property @@ -300,3 +304,21 @@ def refresh_mhz(self) -> int: @property def preferred(self) -> int: return self._ptr.preferred + + +class OutputState(Ptr): + def __init__(self, ptr) -> None: + self._ptr = ptr + + +class OutputEventRequestState(Ptr): + def __init__(self, ptr) -> None: + self._ptr = ffi.cast("struct wlr_output_event_request_state *", ptr) + + @property + def output(self) -> Output: + return Output(self._ptr.output) + + @property + def state(self) -> OutputState: + return OutputState(self._ptr.state) From 082e3b6ac7ca7df4d7f32c1a0518b00b6cfe3acd Mon Sep 17 00:00:00 2001 From: mcol Date: Wed, 4 Oct 2023 01:03:16 +0100 Subject: [PATCH 05/68] (wlroots a541c95) render: make wlr_renderer_begin return a bool --- wlroots/ffi_build.py | 2 +- wlroots/renderer.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/wlroots/ffi_build.py b/wlroots/ffi_build.py index 30e1f899..682c87c2 100644 --- a/wlroots/ffi_build.py +++ b/wlroots/ffi_build.py @@ -145,7 +145,7 @@ def has_xwayland() -> bool: CDEF += """ struct wlr_renderer *wlr_renderer_autocreate(struct wlr_backend *backend); -void wlr_renderer_begin(struct wlr_renderer *r, int width, int height); +bool wlr_renderer_begin(struct wlr_renderer *r, int width, int height); void wlr_renderer_end(struct wlr_renderer *r); void wlr_renderer_clear(struct wlr_renderer *r, const float color[static 4]); diff --git a/wlroots/renderer.py b/wlroots/renderer.py index 904f5ac2..b1f350a5 100644 --- a/wlroots/renderer.py +++ b/wlroots/renderer.py @@ -50,9 +50,9 @@ def render(self, width: int, height: int) -> Iterator[Renderer]: finally: self.end() - def begin(self, width: int, height: int) -> None: + def begin(self, width: int, height: int) -> bool: """Begin rendering with the given height and width""" - lib.wlr_renderer_begin(self._ptr, width, height) + return lib.wlr_renderer_begin(self._ptr, width, height) def end(self): """Finish rendering""" From f93bc3cc90d04a8575f2859e140328dfedc8e0ee Mon Sep 17 00:00:00 2001 From: mcol Date: Wed, 4 Oct 2023 01:05:54 +0100 Subject: [PATCH 06/68] (wlroots 8cfd449) input-inhibitor: deprecate --- wlroots/wlr_types/input_inhibit.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/wlroots/wlr_types/input_inhibit.py b/wlroots/wlr_types/input_inhibit.py index 7a31c0a3..ef44567b 100644 --- a/wlroots/wlr_types/input_inhibit.py +++ b/wlroots/wlr_types/input_inhibit.py @@ -1,5 +1,7 @@ # Copyright (c) 2021 Graeme Holliday +import warnings + from pywayland.server import Client, Display, Signal from wlroots import Ptr, ffi, lib @@ -8,6 +10,13 @@ class InputInhibitManager(Ptr): def __init__(self, display: Display) -> None: """Creates a wlr_input_inhibit_manager""" + warnings.warn( + "Following the protocol deprecation, wlr/types/wlr_input_inhibitor.h is" + " deprecated and will be removed in the next release.", + DeprecationWarning, + stacklevel=1, + ) + self._ptr = lib.wlr_input_inhibit_manager_create(display._ptr) self.activate_event = Signal(ptr=ffi.addressof(self._ptr.events.activate)) From 8d9661bf32ed8cc29fb53a6bf4f9b28a051320c9 Mon Sep 17 00:00:00 2001 From: mcol Date: Wed, 4 Oct 2023 01:12:29 +0100 Subject: [PATCH 07/68] (wlroots 41b7acb) backend: return wlr_session in wlr_backend_autocreate() call --- wlroots/backend.py | 2 +- wlroots/ffi_build.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/wlroots/backend.py b/wlroots/backend.py index 8ddf5372..4e9c54e3 100644 --- a/wlroots/backend.py +++ b/wlroots/backend.py @@ -33,7 +33,7 @@ def __init__(self, display: Display, *, backend_type=BackendType.AUTO) -> None: $WLR_BACKENDS (to set the available backends). """ if backend_type == BackendType.AUTO: - ptr = lib.wlr_backend_autocreate(display._ptr) + ptr = lib.wlr_backend_autocreate(display._ptr, ffi.NULL) elif backend_type == BackendType.HEADLESS: ptr = lib.wlr_headless_backend_create(display._ptr) else: diff --git a/wlroots/ffi_build.py b/wlroots/ffi_build.py index 682c87c2..672e8868 100644 --- a/wlroots/ffi_build.py +++ b/wlroots/ffi_build.py @@ -110,7 +110,8 @@ def has_xwayland() -> bool: ...; }; -struct wlr_backend *wlr_backend_autocreate(struct wl_display *display); +struct wlr_backend *wlr_backend_autocreate(struct wl_display *display, + struct wlr_session **session_ptr); bool wlr_backend_start(struct wlr_backend *backend); void wlr_backend_destroy(struct wlr_backend *backend); From db433371e9ba55dae2d251d5b6ee750aa12b60b8 Mon Sep 17 00:00:00 2001 From: mcol Date: Wed, 4 Oct 2023 23:11:14 +0100 Subject: [PATCH 08/68] (wlroots e7c556f) backend: drop wlr_backend_get_session() --- wlroots/backend.py | 14 ++++++++++---- wlroots/ffi_build.py | 1 - 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/wlroots/backend.py b/wlroots/backend.py index 4e9c54e3..4c8a4b36 100644 --- a/wlroots/backend.py +++ b/wlroots/backend.py @@ -32,8 +32,12 @@ def __init__(self, display: Display, *, backend_type=BackendType.AUTO) -> None: backends), $WAYLAND_DISPLAY (for Wayland backends), and $WLR_BACKENDS (to set the available backends). """ + self.session: Session | None = None + if backend_type == BackendType.AUTO: - ptr = lib.wlr_backend_autocreate(display._ptr, ffi.NULL) + session_ptr = ffi.new("struct wlr_session **") + ptr = lib.wlr_backend_autocreate(display._ptr, session_ptr) + self.session = Session(session_ptr[0]) elif backend_type == BackendType.HEADLESS: ptr = lib.wlr_headless_backend_create(display._ptr) else: @@ -93,7 +97,9 @@ def __exit__(self, exc_type, exc_value, exc_tb) -> None: self.destroy() def get_session(self) -> Session: - return Session(self) + if self.session is None: + raise ValueError("Backend does not have a session") + return self.session @property def is_headless(self) -> bool: @@ -101,9 +107,9 @@ def is_headless(self) -> bool: class Session: - def __init__(self, backend: Backend) -> None: + def __init__(self, ptr) -> None: """The running session""" - self._ptr = lib.wlr_backend_get_session(backend._ptr) + self._ptr = ptr def change_vt(self, vt: int) -> bool: return lib.wlr_session_change_vt(self._ptr, vt) diff --git a/wlroots/ffi_build.py b/wlroots/ffi_build.py index 672e8868..da68624b 100644 --- a/wlroots/ffi_build.py +++ b/wlroots/ffi_build.py @@ -115,7 +115,6 @@ def has_xwayland() -> bool: bool wlr_backend_start(struct wlr_backend *backend); void wlr_backend_destroy(struct wlr_backend *backend); -struct wlr_session *wlr_backend_get_session(struct wlr_backend *backend); """ # backend/libinput.h From 149249021b69a8ab351ff92768670e40292937d1 Mon Sep 17 00:00:00 2001 From: mcol Date: Wed, 4 Oct 2023 23:17:47 +0100 Subject: [PATCH 09/68] (wlroots 236918d) Nuke deprecated include/wlr/types/wlr_surface.h --- wlroots/wlr_types/cursor.py | 2 +- wlroots/wlr_types/data_device_manager.py | 2 +- .../wlr_types/foreign_toplevel_management_v1.py | 2 +- wlroots/wlr_types/idle_inhibit_v1.py | 2 +- wlroots/wlr_types/layer_shell_v1.py | 2 +- wlroots/wlr_types/pointer_constraints_v1.py | 2 +- wlroots/wlr_types/seat.py | 2 +- wlroots/wlr_types/surface.py | 14 -------------- wlroots/wlr_types/xdg_activation_v1.py | 2 +- wlroots/wlr_types/xdg_decoration_v1.py | 2 +- wlroots/wlr_types/xdg_shell.py | 2 +- wlroots/xwayland.py | 2 +- 12 files changed, 11 insertions(+), 25 deletions(-) delete mode 100644 wlroots/wlr_types/surface.py diff --git a/wlroots/wlr_types/cursor.py b/wlroots/wlr_types/cursor.py index fe00c015..8f8b6f29 100644 --- a/wlroots/wlr_types/cursor.py +++ b/wlroots/wlr_types/cursor.py @@ -24,7 +24,7 @@ PointerSwipeEndEvent, PointerSwipeUpdateEvent, ) -from .surface import Surface +from .compositor import Surface from .touch import ( TouchEventCancel, TouchEventDown, diff --git a/wlroots/wlr_types/data_device_manager.py b/wlroots/wlr_types/data_device_manager.py index 4baf333d..4970e13c 100644 --- a/wlroots/wlr_types/data_device_manager.py +++ b/wlroots/wlr_types/data_device_manager.py @@ -7,7 +7,7 @@ from wlroots import Ptr, PtrHasData, ffi, lib -from .surface import Surface +from .compositor import Surface _weakkeydict: WeakKeyDictionary = WeakKeyDictionary() diff --git a/wlroots/wlr_types/foreign_toplevel_management_v1.py b/wlroots/wlr_types/foreign_toplevel_management_v1.py index de7af312..25dd9bb9 100644 --- a/wlroots/wlr_types/foreign_toplevel_management_v1.py +++ b/wlroots/wlr_types/foreign_toplevel_management_v1.py @@ -11,7 +11,7 @@ from wlroots import Ptr, PtrHasData, ffi, lib from .output import Output -from .surface import Surface +from .compositor import Surface if TYPE_CHECKING: from pywayland.server import Display diff --git a/wlroots/wlr_types/idle_inhibit_v1.py b/wlroots/wlr_types/idle_inhibit_v1.py index ee074561..93d7bf3b 100644 --- a/wlroots/wlr_types/idle_inhibit_v1.py +++ b/wlroots/wlr_types/idle_inhibit_v1.py @@ -3,7 +3,7 @@ from wlroots import Ptr, PtrHasData, ffi, lib -from .surface import Surface +from .compositor import Surface class IdleInhibitorManagerV1(Ptr): diff --git a/wlroots/wlr_types/layer_shell_v1.py b/wlroots/wlr_types/layer_shell_v1.py index 91b6409e..1a62e3a6 100644 --- a/wlroots/wlr_types/layer_shell_v1.py +++ b/wlroots/wlr_types/layer_shell_v1.py @@ -11,7 +11,7 @@ from wlroots import Ptr, PtrHasData, ffi, lib from .output import Output -from .surface import Surface +from .compositor import Surface from .xdg_shell import SurfaceCallback, T if TYPE_CHECKING: diff --git a/wlroots/wlr_types/pointer_constraints_v1.py b/wlroots/wlr_types/pointer_constraints_v1.py index 2c2f2f1a..98db3bb8 100644 --- a/wlroots/wlr_types/pointer_constraints_v1.py +++ b/wlroots/wlr_types/pointer_constraints_v1.py @@ -11,7 +11,7 @@ from wlroots import Ptr, ffi, lib from wlroots.util.region import PixmanRegion32 -from .surface import Surface +from .compositor import Surface if TYPE_CHECKING: from pywayland.server import Display diff --git a/wlroots/wlr_types/seat.py b/wlroots/wlr_types/seat.py index a0c86670..b523166b 100644 --- a/wlroots/wlr_types/seat.py +++ b/wlroots/wlr_types/seat.py @@ -13,7 +13,7 @@ from .input_device import ButtonState from .keyboard import Keyboard, KeyboardKeyEvent, KeyboardModifiers from .pointer import AxisOrientation, AxisSource -from .surface import Surface +from .compositor import Surface _weakkeydict: WeakKeyDictionary = WeakKeyDictionary() diff --git a/wlroots/wlr_types/surface.py b/wlroots/wlr_types/surface.py deleted file mode 100644 index 31a47dff..00000000 --- a/wlroots/wlr_types/surface.py +++ /dev/null @@ -1,14 +0,0 @@ -# Copyright Sean Vig (c) 2020 -# -# The contents of this module has been moved to compositor.py for wlroots 0.16.0 and -# this file will be removed in the future. - -import warnings - -from wlroots.wlr_types.compositor import * # noqa: F403 - -warnings.warn( - "wlroots.wlr_types.surface has moved to wlroots.wlr_types.compositor and will be removed in the future.", - DeprecationWarning, - stacklevel=1, -) diff --git a/wlroots/wlr_types/xdg_activation_v1.py b/wlroots/wlr_types/xdg_activation_v1.py index d92c9cce..02a7a437 100644 --- a/wlroots/wlr_types/xdg_activation_v1.py +++ b/wlroots/wlr_types/xdg_activation_v1.py @@ -9,7 +9,7 @@ from wlroots import Ptr, ffi, lib -from .surface import Surface +from .compositor import Surface if TYPE_CHECKING: from pywayland.server import Display diff --git a/wlroots/wlr_types/xdg_decoration_v1.py b/wlroots/wlr_types/xdg_decoration_v1.py index 311ff741..d0f09ef0 100644 --- a/wlroots/wlr_types/xdg_decoration_v1.py +++ b/wlroots/wlr_types/xdg_decoration_v1.py @@ -10,7 +10,7 @@ from wlroots import PtrHasData, ffi, lib -from .surface import Surface +from .compositor import Surface if TYPE_CHECKING: from pywayland.server import Display diff --git a/wlroots/wlr_types/xdg_shell.py b/wlroots/wlr_types/xdg_shell.py index 73a5eefd..0b6a9126 100644 --- a/wlroots/wlr_types/xdg_shell.py +++ b/wlroots/wlr_types/xdg_shell.py @@ -13,7 +13,7 @@ from wlroots.util.edges import Edges from .output import Output -from .surface import Surface +from .compositor import Surface _weakkeydict: weakref.WeakKeyDictionary = weakref.WeakKeyDictionary() diff --git a/wlroots/xwayland.py b/wlroots/xwayland.py index 8ed51e76..e5c052d0 100644 --- a/wlroots/xwayland.py +++ b/wlroots/xwayland.py @@ -8,7 +8,7 @@ from pywayland.server import Signal from wlroots import Ptr, PtrHasData, ffi, lib, str_or_none -from wlroots.wlr_types.surface import Surface as WlrSurface +from wlroots.wlr_types.compositor import Surface as WlrSurface if TYPE_CHECKING: from typing import TypeVar From 46e931daaa0d05b435cf6f2b9422d0b55ceb4077 Mon Sep 17 00:00:00 2001 From: mcol Date: Wed, 4 Oct 2023 23:29:04 +0100 Subject: [PATCH 10/68] (wlroots 42016fa) compositor: make renderer optional --- wlroots/wlr_types/compositor.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/wlroots/wlr_types/compositor.py b/wlroots/wlr_types/compositor.py index d9eae97a..0314b12e 100644 --- a/wlroots/wlr_types/compositor.py +++ b/wlroots/wlr_types/compositor.py @@ -20,7 +20,7 @@ class Compositor(Ptr): - def __init__(self, display: Display, renderer: Renderer) -> None: + def __init__(self, display: Display, renderer: Renderer | None = None) -> None: """A compositor for clients to be able to allocate surfaces :param display: @@ -28,7 +28,10 @@ def __init__(self, display: Display, renderer: Renderer) -> None: :param renderer: The wlroots renderer to attach the compositor to. """ - self._ptr = lib.wlr_compositor_create(display._ptr, renderer._ptr) + if renderer is None: + self._ptr = lib.wlr_compositor_create(display._ptr, ffi.NULL) + else: + self._ptr = lib.wlr_compositor_create(display._ptr, renderer._ptr) class SubCompositor(Ptr): From 9906f2db7f37acab482a7087c99225d8982476bc Mon Sep 17 00:00:00 2001 From: mcol Date: Wed, 4 Oct 2023 23:31:24 +0100 Subject: [PATCH 11/68] (wlroots 060df4c) scene: introduce wlr_scene_buffer.events.outputs_update --- wlroots/ffi_build.py | 1 + 1 file changed, 1 insertion(+) diff --git a/wlroots/ffi_build.py b/wlroots/ffi_build.py index da68624b..5ecac6b0 100644 --- a/wlroots/ffi_build.py +++ b/wlroots/ffi_build.py @@ -1806,6 +1806,7 @@ def has_xwayland() -> bool: struct wlr_buffer *buffer; struct { + struct wl_signal outputs_update; struct wl_signal output_enter; // struct wlr_scene_output struct wl_signal output_leave; // struct wlr_scene_output struct wl_signal output_present; // struct wlr_scene_output From ac6c246d4a706ae3f5e507ac3327e0745fc7248a Mon Sep 17 00:00:00 2001 From: mcol Date: Wed, 4 Oct 2023 23:41:44 +0100 Subject: [PATCH 12/68] (wlroots f103dc74) linux-dmabuf-v1: introduce wlr_linux_dmabuf_v1_create() --- wlroots/ffi_build.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wlroots/ffi_build.py b/wlroots/ffi_build.py index 5ecac6b0..76246875 100644 --- a/wlroots/ffi_build.py +++ b/wlroots/ffi_build.py @@ -1014,7 +1014,7 @@ def has_xwayland() -> bool: # types/wlr_linux_dmabuf_v1.h CDEF += """ struct wlr_linux_dmabuf_v1 *wlr_linux_dmabuf_v1_create(struct wl_display *display, - struct wlr_renderer *renderer); + uint32_t version, const struct wlr_linux_dmabuf_feedback_v1 *default_feedback); """ # types/wlr_matrix.h From 03e7047a1d1381188877966edd86344239c30837 Mon Sep 17 00:00:00 2001 From: mcol Date: Wed, 4 Oct 2023 23:42:09 +0100 Subject: [PATCH 13/68] (wlroots 19dfe99) output-damage: stop listening for output mode events --- wlroots/ffi_build.py | 7 ------- 1 file changed, 7 deletions(-) diff --git a/wlroots/ffi_build.py b/wlroots/ffi_build.py index 76246875..453c342d 100644 --- a/wlroots/ffi_build.py +++ b/wlroots/ffi_build.py @@ -1207,13 +1207,6 @@ def has_xwayland() -> bool: struct wl_signal frame; struct wl_signal destroy; } events; - - struct wl_listener output_destroy; - struct wl_listener output_mode; - struct wl_listener output_needs_frame; - struct wl_listener output_damage; - struct wl_listener output_frame; - struct wl_listener output_commit; ...; }; From bca77bf8cf2a8a419dd3558fa80ca4d7d0d8dd8b Mon Sep 17 00:00:00 2001 From: mcol Date: Thu, 5 Oct 2023 00:21:32 +0100 Subject: [PATCH 14/68] (wlroots c8eb24d) output: drop enable/mode events --- wlroots/ffi_build.py | 2 -- wlroots/wlr_types/output.py | 2 -- 2 files changed, 4 deletions(-) diff --git a/wlroots/ffi_build.py b/wlroots/ffi_build.py index 453c342d..2440b935 100644 --- a/wlroots/ffi_build.py +++ b/wlroots/ffi_build.py @@ -1122,8 +1122,6 @@ def has_xwayland() -> bool: struct wl_signal commit; struct wl_signal present; struct wl_signal bind; - struct wl_signal enable; - struct wl_signal mode; struct wl_signal description; struct wl_signal request_state; struct wl_signal destroy; diff --git a/wlroots/wlr_types/output.py b/wlroots/wlr_types/output.py index 9b518cc2..9a0da236 100644 --- a/wlroots/wlr_types/output.py +++ b/wlroots/wlr_types/output.py @@ -48,8 +48,6 @@ def __init__(self, ptr) -> None: self.commit_event = Signal(ptr=ffi.addressof(self._ptr.events.commit)) self.present_event = Signal(ptr=ffi.addressof(self._ptr.events.present)) self.bind_event = Signal(ptr=ffi.addressof(self._ptr.events.bind)) - self.enable_event = Signal(ptr=ffi.addressof(self._ptr.events.enable)) - self.mode_event = Signal(ptr=ffi.addressof(self._ptr.events.mode)) self.description_event = Signal(ptr=ffi.addressof(self._ptr.events.description)) self.request_state_event = Signal( ptr=ffi.addressof(self._ptr.events.request_state), From 7a2f7d70c4c41941c9f3a0f92725296a66185774 Mon Sep 17 00:00:00 2001 From: mcol Date: Thu, 5 Oct 2023 00:25:06 +0100 Subject: [PATCH 15/68] (wlroots 512deeb) compositor: add wlr_surface.events.precommit --- wlroots/ffi_build.py | 1 + wlroots/wlr_types/compositor.py | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/wlroots/ffi_build.py b/wlroots/ffi_build.py index 2440b935..5be9c4e7 100644 --- a/wlroots/ffi_build.py +++ b/wlroots/ffi_build.py @@ -375,6 +375,7 @@ def has_xwayland() -> bool: struct { struct wl_signal client_commit; + struct wl_signal precommit; struct wl_signal commit; struct wl_signal new_subsurface; struct wl_signal destroy; diff --git a/wlroots/wlr_types/compositor.py b/wlroots/wlr_types/compositor.py index 0314b12e..f7574086 100644 --- a/wlroots/wlr_types/compositor.py +++ b/wlroots/wlr_types/compositor.py @@ -48,6 +48,10 @@ def __init__(self, ptr) -> None: """ self._ptr = ptr + self.precommit_event = Signal( + ptr=ffi.addressof(self._ptr.events.precommit), + data_wrapper=SurfaceState, + ) self.commit_event = Signal(ptr=ffi.addressof(self._ptr.events.commit)) self.new_subsurface_event = Signal( ptr=ffi.addressof(self._ptr.events.new_subsurface), From d3558e410429d785fe563a173ce2388c5d93d646 Mon Sep 17 00:00:00 2001 From: mcol Date: Thu, 5 Oct 2023 22:15:46 +0100 Subject: [PATCH 16/68] (wlroots 097ea84) output-layout: improve API --- wlroots/ffi_build.py | 7 ++----- wlroots/wlr_types/output_layout.py | 32 +++++++++++++----------------- 2 files changed, 16 insertions(+), 23 deletions(-) diff --git a/wlroots/ffi_build.py b/wlroots/ffi_build.py index 5be9c4e7..e493da28 100644 --- a/wlroots/ffi_build.py +++ b/wlroots/ffi_build.py @@ -1248,10 +1248,7 @@ def has_xwayland() -> bool: struct wlr_output *reference, double lx, double ly, double *dest_lx, double *dest_ly); -void wlr_output_layout_add(struct wlr_output_layout *layout, - struct wlr_output *output, int lx, int ly); - -void wlr_output_layout_move(struct wlr_output_layout *layout, +bool wlr_output_layout_add(struct wlr_output_layout *layout, struct wlr_output *output, int lx, int ly); void wlr_output_layout_remove(struct wlr_output_layout *layout, @@ -1260,7 +1257,7 @@ def has_xwayland() -> bool: void wlr_output_layout_get_box(struct wlr_output_layout *layout, struct wlr_output *reference, struct wlr_box *dest_box); -void wlr_output_layout_add_auto(struct wlr_output_layout *layout, +bool wlr_output_layout_add_auto(struct wlr_output_layout *layout, struct wlr_output *output); struct wlr_output *wlr_output_layout_output_at(struct wlr_output_layout *layout, diff --git a/wlroots/wlr_types/output_layout.py b/wlroots/wlr_types/output_layout.py index a7bf3a73..b5e29f9f 100644 --- a/wlroots/wlr_types/output_layout.py +++ b/wlroots/wlr_types/output_layout.py @@ -31,19 +31,16 @@ def destroy(self) -> None: ffi.release(self._ptr) self._ptr = None - def add_auto(self, output: Output) -> None: - """Add an auto configured output to the layout - - This will place the output in a sensible location in the layout. The - coordinates of the output in the layout may adjust dynamically when the - layout changes. If the output is already in the layout, it will become - auto configured. If the position of the output is set such as with - `wlr_output_layout_move()`, the output will become manually configured. + def add_auto(self, output: Output) -> bool: + """ + Add the output to the layout as automatically configured. This will place the + output in a sensible location in the layout. The coordinates of the output in + the layout will be adjusted dynamically when the layout changes. If the output + is already a part of the layout, it will become automatically configured. - :param output: - The output to configure the layout against. + Returns true on success, false on a memory allocation error. """ - lib.wlr_output_layout_add_auto(self._ptr, output._ptr) + return lib.wlr_output_layout_add_auto(self._ptr, output._ptr) def output_coords(self, output: Output) -> tuple[float, float]: """Determine coordinates of the output in the layout @@ -75,16 +72,15 @@ def output_at(self, x: float, y: float) -> Output | None: return None return Output(output_ptr) - def add(self, output: Output, lx: int, ly: int) -> None: + def add(self, output: Output, lx: int, ly: int) -> bool: """ Add the output to the layout at the specified coordinates. If the output is - already part of the output layout, this moves the output. - """ - lib.wlr_output_layout_add(self._ptr, output._ptr, lx, ly) + already a part of the output layout, it will become manually configured and will + be moved to the specified coordinates. - def move(self, output: Output, lx: int, ly: int) -> None: - """Move an output to specified coordinates.""" - lib.wlr_output_layout_move(self._ptr, output._ptr, lx, ly) + Returns true on success, false on a memory allocation error. + """ + return lib.wlr_output_layout_add(self._ptr, output._ptr, lx, ly) def remove(self, output: Output) -> None: """Remove an output from the layout.""" From 738e8bb8ea233d4a7e9ef3cdf2f7c340667d0c4f Mon Sep 17 00:00:00 2001 From: mcol Date: Thu, 5 Oct 2023 22:18:31 +0100 Subject: [PATCH 17/68] (wlroots f8e70af) wlr_xdg_activation_v1: add new_token event --- wlroots/ffi_build.py | 1 + 1 file changed, 1 insertion(+) diff --git a/wlroots/ffi_build.py b/wlroots/ffi_build.py index e493da28..b5f657dd 100644 --- a/wlroots/ffi_build.py +++ b/wlroots/ffi_build.py @@ -2324,6 +2324,7 @@ def has_xwayland() -> bool: struct { struct wl_signal destroy; struct wl_signal request_activate; + struct wl_signal new_token; } events; ...; }; From abd56b130c90e959b6db324790f037d4def6515a Mon Sep 17 00:00:00 2001 From: mcol Date: Thu, 5 Oct 2023 22:25:25 +0100 Subject: [PATCH 18/68] add method for wlr_output_commit_state --- wlroots/ffi_build.py | 2 ++ wlroots/wlr_types/output.py | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/wlroots/ffi_build.py b/wlroots/ffi_build.py index b5f657dd..3bb475f6 100644 --- a/wlroots/ffi_build.py +++ b/wlroots/ffi_build.py @@ -1180,6 +1180,8 @@ def has_xwayland() -> bool: bool wlr_output_test(struct wlr_output *output); bool wlr_output_commit(struct wlr_output *output); void wlr_output_rollback(struct wlr_output *output); +bool wlr_output_commit_state(struct wlr_output *output, + const struct wlr_output_state *state); void wlr_output_render_software_cursors(struct wlr_output *output, struct pixman_region32 *damage); diff --git a/wlroots/wlr_types/output.py b/wlroots/wlr_types/output.py index 9a0da236..c2fe5909 100644 --- a/wlroots/wlr_types/output.py +++ b/wlroots/wlr_types/output.py @@ -205,6 +205,10 @@ def rollback(self) -> None: """Discard the pending output state""" lib.wlr_output_rollback(self._ptr) + def commit_state(self, state: OutputEventRequestState) -> None: + """Commit requested state""" + lib.wlr_output_commit_state(self._ptr, state._ptr) + def effective_resolution(self) -> tuple[int, int]: """Computes the transformed and scaled output resolution""" width_ptr = ffi.new("int *") From 95e2a61f4c416c8aba613bb8976e8f271a6886e0 Mon Sep 17 00:00:00 2001 From: mcol Date: Thu, 5 Oct 2023 22:35:24 +0100 Subject: [PATCH 19/68] (wlroots 7f6d646) keyboard: only update LEDs when changed --- wlroots/ffi_build.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/wlroots/ffi_build.py b/wlroots/ffi_build.py index 3bb475f6..15009c10 100644 --- a/wlroots/ffi_build.py +++ b/wlroots/ffi_build.py @@ -963,11 +963,13 @@ def has_xwayland() -> bool: char *keymap_string; size_t keymap_size; + int keymap_fd; struct xkb_keymap *keymap; struct xkb_state *xkb_state; xkb_led_index_t led_indexes[WLR_LED_COUNT]; xkb_mod_index_t mod_indexes[WLR_MODIFIER_COUNT]; + uint32_t leds; uint32_t keycodes[WLR_KEYBOARD_KEYS_CAP]; size_t num_keycodes; struct wlr_keyboard_modifiers modifiers; From 3fba4090291395e3dabb819a554bcda64902f4ab Mon Sep 17 00:00:00 2001 From: mcol Date: Thu, 5 Oct 2023 22:44:23 +0100 Subject: [PATCH 20/68] (wlroots df0c926) xdg-shell: rename wlr_xdg_toplevel.added to sent_initial_configure --- wlroots/ffi_build.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wlroots/ffi_build.py b/wlroots/ffi_build.py index 15009c10..c8aec3c0 100644 --- a/wlroots/ffi_build.py +++ b/wlroots/ffi_build.py @@ -2572,7 +2572,7 @@ def has_xwayland() -> bool: struct wlr_xdg_toplevel { struct wl_resource *resource; struct wlr_xdg_surface *base; - bool added; + bool sent_initial_configure; struct wlr_xdg_toplevel *parent; struct wl_listener parent_unmap; From 7f0e9327f6fcc0d2d5e28e2c29f895651c82279a Mon Sep 17 00:00:00 2001 From: mcol Date: Thu, 5 Oct 2023 22:45:50 +0100 Subject: [PATCH 21/68] (wlroots 0f24d27) xdg-shell: rename wlr_xdg_popup.committed to sent_initial_configure --- wlroots/ffi_build.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wlroots/ffi_build.py b/wlroots/ffi_build.py index c8aec3c0..8ded2ca8 100644 --- a/wlroots/ffi_build.py +++ b/wlroots/ffi_build.py @@ -2527,7 +2527,7 @@ def has_xwayland() -> bool: struct wl_list link; struct wl_resource *resource; - bool committed; + bool sent_initial_configure; struct wlr_surface *parent; struct wlr_seat *seat; From 99aba4863bdc1fa97db7ec14fd8cb7afe91d2b92 Mon Sep 17 00:00:00 2001 From: mcol Date: Thu, 5 Oct 2023 22:59:00 +0100 Subject: [PATCH 22/68] (wlroots fbf5982) xwayland/xwm: introduce wlr_xwayland_surface_try_from_wlr_surface() --- wlroots/ffi_build.py | 3 +-- wlroots/wlr_types/compositor.py | 9 --------- wlroots/xwayland.py | 7 +++++-- 3 files changed, 6 insertions(+), 13 deletions(-) diff --git a/wlroots/ffi_build.py b/wlroots/ffi_build.py index 8ded2ca8..6594ef48 100644 --- a/wlroots/ffi_build.py +++ b/wlroots/ffi_build.py @@ -3159,8 +3159,7 @@ def has_xwayland() -> bool: bool fullscreen); void wlr_xwayland_set_seat(struct wlr_xwayland *xwayland, struct wlr_seat *seat); - bool wlr_surface_is_xwayland_surface(struct wlr_surface *surface); - struct wlr_xwayland_surface *wlr_xwayland_surface_from_wlr_surface( + struct wlr_xwayland_surface *wlr_xwayland_surface_try_from_wlr_surface( struct wlr_surface *surface); void wlr_xwayland_surface_ping(struct wlr_xwayland_surface *surface); bool wlr_xwayland_or_surface_wants_focus( diff --git a/wlroots/wlr_types/compositor.py b/wlroots/wlr_types/compositor.py index f7574086..f264f8d2 100644 --- a/wlroots/wlr_types/compositor.py +++ b/wlroots/wlr_types/compositor.py @@ -69,15 +69,6 @@ def is_layer_surface(self) -> bool: """True if the current surface is a layer surface""" return lib.wlr_surface_is_layer_surface(self._ptr) - @property - def is_xwayland_surface(self) -> bool: - """ - True if the current surface is an XWayland surface. - - Requires that pywlroots was built with XWayland support. - """ - return lib.wlr_surface_is_xwayland_surface(self._ptr) - @property def current(self) -> SurfaceState: """The current commited surface state""" diff --git a/wlroots/xwayland.py b/wlroots/xwayland.py index e5c052d0..496deee8 100644 --- a/wlroots/xwayland.py +++ b/wlroots/xwayland.py @@ -224,8 +224,11 @@ def set_fullscreen(self, fullscreen: bool) -> None: lib.wlr_xwayland_surface_set_fullscreen(self._ptr, fullscreen) @classmethod - def from_wlr_surface(cls, surface: WlrSurface) -> Surface: - return cls(lib.wlr_xwayland_surface_from_wlr_surface(surface._ptr)) + def try_from_wlr_surface(cls, surface: WlrSurface) -> Surface | None: + maybe_ptr = lib.wlr_xwayland_surface_try_from_wlr_surface(surface._ptr) + if maybe_ptr == ffi.NULL: + return None + return cls(maybe_ptr) def ping(self) -> None: lib.wlr_xwayland_surface_ping(self._ptr) From 4984ccf422cf19dacafa46d1fee6d68d163d081a Mon Sep 17 00:00:00 2001 From: mcol Date: Thu, 5 Oct 2023 23:12:54 +0100 Subject: [PATCH 23/68] (wlroots 711a1a3) xdg-shell: convert to try_from --- wlroots/ffi_build.py | 3 +-- wlroots/wlr_types/compositor.py | 5 ----- wlroots/wlr_types/xdg_shell.py | 10 +++++----- 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/wlroots/ffi_build.py b/wlroots/ffi_build.py index 6594ef48..fe51a73e 100644 --- a/wlroots/ffi_build.py +++ b/wlroots/ffi_build.py @@ -2718,9 +2718,8 @@ def has_xwayland() -> bool: struct wlr_surface *wlr_xdg_surface_surface_at( struct wlr_xdg_surface *surface, double sx, double sy, double *sub_x, double *sub_y); -bool wlr_surface_is_xdg_surface(struct wlr_surface *surface); -struct wlr_xdg_surface *wlr_xdg_surface_from_wlr_surface( +struct wlr_xdg_surface *wlr_xdg_surface_try_from_wlr_surface( struct wlr_surface *surface); void wlr_xdg_surface_get_geometry(struct wlr_xdg_surface *surface, diff --git a/wlroots/wlr_types/compositor.py b/wlroots/wlr_types/compositor.py index f264f8d2..a71f48d7 100644 --- a/wlroots/wlr_types/compositor.py +++ b/wlroots/wlr_types/compositor.py @@ -59,11 +59,6 @@ def __init__(self, ptr) -> None: ) self.destroy_event = Signal(ptr=ffi.addressof(self._ptr.events.destroy)) - @property - def is_xdg_surface(self) -> bool: - """True if the current surface is an XDG surface""" - return lib.wlr_surface_is_xdg_surface(self._ptr) - @property def is_layer_surface(self) -> bool: """True if the current surface is a layer surface""" diff --git a/wlroots/wlr_types/xdg_shell.py b/wlroots/wlr_types/xdg_shell.py index 0b6a9126..01802395 100644 --- a/wlroots/wlr_types/xdg_shell.py +++ b/wlroots/wlr_types/xdg_shell.py @@ -88,12 +88,12 @@ def __init__(self, ptr) -> None: ) @classmethod - def from_surface(cls, surface: Surface) -> XdgSurface: + def try_from_surface(cls, surface: Surface) -> XdgSurface | None: """Get the xdg surface associated with the given surface""" - if not surface.is_xdg_surface: - raise RuntimeError("Surface is not XDG surface") - surface_ptr = lib.wlr_xdg_surface_from_wlr_surface(surface._ptr) - return XdgSurface(surface_ptr) + maybe_ptr = lib.wlr_xdg_surface_try_from_wlr_surface(surface._ptr) + if maybe_ptr == ffi.NULL: + return None + return XdgSurface(maybe_ptr) @property def surface(self) -> Surface: From 49eab9586642a9d6bf791fcdcfa0631b68d898ea Mon Sep 17 00:00:00 2001 From: mcol Date: Thu, 5 Oct 2023 23:19:33 +0100 Subject: [PATCH 24/68] (wlroots f9bd416) layer-shell-v1: convert to try_from --- wlroots/ffi_build.py | 4 +--- wlroots/wlr_types/compositor.py | 5 ----- wlroots/wlr_types/layer_shell_v1.py | 10 ++++++---- 3 files changed, 7 insertions(+), 12 deletions(-) diff --git a/wlroots/ffi_build.py b/wlroots/ffi_build.py index fe51a73e..ffcdc10c 100644 --- a/wlroots/ffi_build.py +++ b/wlroots/ffi_build.py @@ -2936,9 +2936,7 @@ def has_xwayland() -> bool: void wlr_layer_surface_v1_destroy(struct wlr_layer_surface_v1 *surface); -bool wlr_surface_is_layer_surface(struct wlr_surface *surface); - -struct wlr_layer_surface_v1 *wlr_layer_surface_v1_from_wlr_surface( +struct wlr_layer_surface_v1 *wlr_layer_surface_v1_try_from_wlr_surface( struct wlr_surface *surface); void wlr_layer_surface_v1_for_each_surface(struct wlr_layer_surface_v1 *surface, diff --git a/wlroots/wlr_types/compositor.py b/wlroots/wlr_types/compositor.py index a71f48d7..3d023aed 100644 --- a/wlroots/wlr_types/compositor.py +++ b/wlroots/wlr_types/compositor.py @@ -59,11 +59,6 @@ def __init__(self, ptr) -> None: ) self.destroy_event = Signal(ptr=ffi.addressof(self._ptr.events.destroy)) - @property - def is_layer_surface(self) -> bool: - """True if the current surface is a layer surface""" - return lib.wlr_surface_is_layer_surface(self._ptr) - @property def current(self) -> SurfaceState: """The current commited surface state""" diff --git a/wlroots/wlr_types/layer_shell_v1.py b/wlroots/wlr_types/layer_shell_v1.py index 1a62e3a6..1ca213bd 100644 --- a/wlroots/wlr_types/layer_shell_v1.py +++ b/wlroots/wlr_types/layer_shell_v1.py @@ -163,10 +163,12 @@ def destroy(self) -> None: lib.wlr_layer_surface_v1_destroy(self._ptr) @classmethod - def from_wlr_surface(cls, surface: Surface): - surface_ptr = lib.wlr_layer_surface_v1_from_wlr_surface(surface._ptr) - _weakkeydict[surface_ptr] = surface._ptr - return LayerSurfaceV1(surface_ptr) + def try_from_wlr_surface(cls, surface: Surface) -> LayerSurfaceV1 | None: + maybe_ptr = lib.wlr_layer_surface_v1_try_from_wlr_surface(surface._ptr) + if maybe_ptr == ffi.NULL: + return None + _weakkeydict[maybe_ptr] = maybe_ptr._ptr + return LayerSurfaceV1(maybe_ptr) def for_each_surface( self, iterator: SurfaceCallback[T], data: T | None = None From 632bc7916782403bf453c7e6150b1a272996caa0 Mon Sep 17 00:00:00 2001 From: mcol Date: Thu, 5 Oct 2023 23:35:40 +0100 Subject: [PATCH 25/68] (wlroots 7b32c25) wlr_scene: Rename wlr_scene_surface_from_buffer --- wlroots/ffi_build.py | 7 +------ wlroots/wlr_types/scene.py | 2 +- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/wlroots/ffi_build.py b/wlroots/ffi_build.py index ffcdc10c..9284077a 100644 --- a/wlroots/ffi_build.py +++ b/wlroots/ffi_build.py @@ -478,11 +478,6 @@ def has_xwayland() -> bool: ...; }; -bool wlr_surface_is_subsurface(struct wlr_surface *surface); - -struct wlr_subsurface *wlr_subsurface_from_wlr_surface( - struct wlr_surface *surface); - struct wlr_subcompositor *wlr_subcompositor_create(struct wl_display *display); """ @@ -1870,7 +1865,7 @@ def has_xwayland() -> bool: struct wlr_scene_buffer *wlr_scene_buffer_from_node(struct wlr_scene_node *node); -struct wlr_scene_surface *wlr_scene_surface_from_buffer( +struct wlr_scene_surface *wlr_scene_surface_try_from_buffer( struct wlr_scene_buffer *scene_buffer); struct wlr_scene_rect *wlr_scene_rect_create(struct wlr_scene_tree *parent, diff --git a/wlroots/wlr_types/scene.py b/wlroots/wlr_types/scene.py index 55942832..305227b5 100644 --- a/wlroots/wlr_types/scene.py +++ b/wlroots/wlr_types/scene.py @@ -286,7 +286,7 @@ def __init__(self, ptr) -> None: @classmethod def from_buffer(cls, buffer: SceneBuffer) -> SceneSurface | None: - ptr = lib.wlr_scene_surface_from_buffer(buffer._ptr) + ptr = lib.wlr_scene_surface_try_from_buffer(buffer._ptr) if ptr == ffi.NULL: return None return cls(ptr) From d6d8bbecfe207d654cc5b6e15c3548de50a2e12b Mon Sep 17 00:00:00 2001 From: mcol Date: Thu, 5 Oct 2023 23:44:57 +0100 Subject: [PATCH 26/68] (wlroots 0682802) xwayland: Read and publish _NET_WM_STRUT_PARTIAL property --- wlroots/ffi_build.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/wlroots/ffi_build.py b/wlroots/ffi_build.py index 9284077a..d6b84dc1 100644 --- a/wlroots/ffi_build.py +++ b/wlroots/ffi_build.py @@ -2957,6 +2957,9 @@ def has_xwayland() -> bool: typedef struct { ...; } xcb_generic_event_t; + typedef struct { + ...; + } xcb_ewmh_wm_strut_partial_t; typedef uint32_t xcb_pixmap_t; typedef uint32_t xcb_window_t; typedef uint32_t xcb_atom_t; @@ -3040,10 +3043,14 @@ def has_xwayland() -> bool: xcb_window_t window_id; struct wlr_xwm *xwm; uint32_t surface_id; + uint64_t serial; struct wl_list link; struct wl_list stack_link; struct wl_list unpaired_link; struct wlr_surface *surface; + struct wlr_addon surface_addon; + struct wl_listener surface_commit; + struct wl_listener surface_precommit; int16_t x, y; uint16_t width, height; uint16_t saved_width, saved_height; @@ -3066,9 +3073,9 @@ def has_xwayland() -> bool: uint32_t decorations; xcb_icccm_wm_hints_t *hints; xcb_size_hints_t *size_hints; + xcb_ewmh_wm_strut_partial_t *strut_partial; bool pinging; struct wl_event_source *ping_timer; - // _NET_WM_STATE bool modal; bool fullscreen; bool maximized_vert, maximized_horz; @@ -3094,6 +3101,7 @@ def has_xwayland() -> bool: struct wl_signal set_window_type; struct wl_signal set_hints; struct wl_signal set_decorations; + struct wl_signal set_strut_partial; struct wl_signal set_override_redirect; struct wl_signal set_geometry; struct wl_signal ping_timeout; From 45ea4c3dc5e817adc8cbab705e435f6db595fb6f Mon Sep 17 00:00:00 2001 From: mcol Date: Fri, 6 Oct 2023 11:52:08 +0100 Subject: [PATCH 27/68] (wlroots 9ef9845) output-damage: drop --- wlroots/ffi_build.py | 37 -------------- wlroots/wlr_types/__init__.py | 1 - wlroots/wlr_types/output_damage.py | 78 ------------------------------ 3 files changed, 116 deletions(-) delete mode 100644 wlroots/wlr_types/output_damage.py diff --git a/wlroots/ffi_build.py b/wlroots/ffi_build.py index d6b84dc1..efcc4ea7 100644 --- a/wlroots/ffi_build.py +++ b/wlroots/ffi_build.py @@ -1187,42 +1187,6 @@ def has_xwayland() -> bool: enum wl_output_transform tr); """ -# types/wlr_output_damage.h -CDEF += """ -#define WLR_OUTPUT_DAMAGE_PREVIOUS_LEN 2 - -struct wlr_output_damage { - struct wlr_output *output; - int max_rects; // max number of damaged rectangles - - struct pixman_region32 current; // in output-local coordinates - - // circular queue for previous damage - struct pixman_region32 previous[WLR_OUTPUT_DAMAGE_PREVIOUS_LEN]; - size_t previous_idx; - - struct { - struct wl_signal frame; - struct wl_signal destroy; - } events; - ...; -}; - -struct wlr_output_damage *wlr_output_damage_create(struct wlr_output *output); -void wlr_output_damage_destroy(struct wlr_output_damage *output_damage); - -bool wlr_output_damage_attach_render(struct wlr_output_damage *output_damage, - bool *needs_frame, struct pixman_region32 *buffer_damage); - -void wlr_output_damage_add(struct wlr_output_damage *output_damage, - struct pixman_region32 *damage); - -void wlr_output_damage_add_whole(struct wlr_output_damage *output_damage); - -void wlr_output_damage_add_box(struct wlr_output_damage *output_damage, - struct wlr_box *box); -""" - # types/wlr_output_layout.h CDEF += """ struct wlr_output_layout { @@ -2810,7 +2774,6 @@ def has_xwayland() -> bool: #include #include #include -#include #include #include #include diff --git a/wlroots/wlr_types/__init__.py b/wlroots/wlr_types/__init__.py index 96f1261a..b261a2a3 100644 --- a/wlroots/wlr_types/__init__.py +++ b/wlroots/wlr_types/__init__.py @@ -20,7 +20,6 @@ from .layer_shell_v1 import LayerShellV1 # noqa: F401 from .matrix import Matrix # noqa: F401 from .output import Output # noqa: F401 -from .output_damage import OutputDamage # noqa: F401 from .output_layout import OutputLayout # noqa: F401 from .pointer import ( # noqa: F401 PointerAxisEvent, diff --git a/wlroots/wlr_types/output_damage.py b/wlroots/wlr_types/output_damage.py deleted file mode 100644 index 9d58bedf..00000000 --- a/wlroots/wlr_types/output_damage.py +++ /dev/null @@ -1,78 +0,0 @@ -# Copyright (c) Matt Colligan 2021 - -from pywayland.server import Signal - -from wlroots import Ptr, ffi, lib -from wlroots.util.box import Box -from wlroots.util.region import PixmanRegion32 - -from .output import Output - - -class OutputDamage(Ptr): - def __init__(self, output: Output) -> None: - """ - Tracks damage for an output. - - The `frame` event will be emitted when it is a good time for the compositor - to submit a new frame. - - To render a new frame, compositors should call - `wlr_output_damage_attach_render`, render and call `wlr_output_commit`. No - rendering should happen outside a `frame` event handler or before - `wlr_output_damage_attach_render`. - """ - self._ptr = lib.wlr_output_damage_create(output._ptr) - - self.frame_event = Signal(ptr=ffi.addressof(self._ptr.events.frame)) - self.destroy_event = Signal(ptr=ffi.addressof(self._ptr.events.destroy)) - - @property - def output(self) -> Output: - """The name of the output""" - return Output(self._ptr.output) - - @property - def current(self) -> PixmanRegion32: - return PixmanRegion32(ffi.addressof(self._ptr.current)) - - def destroy(self) -> None: - """The name of the output""" - lib.wlr_output_damage_destroy(self._ptr) - self._ptr = None - - def attach_render(self, damage: PixmanRegion32) -> bool: - """ - Attach the renderer's buffer to the output. Compositors must call this - function before rendering. After they are done rendering, they should call - `wlr_output_set_damage` and `wlr_output_commit` to submit the new frame. - - `needs_frame` will be set to true if a frame should be submitted. `damage` - will be set to the region of the output that needs to be repainted, in - output-buffer-local coordinates. - - The buffer damage region accumulates all damage since the buffer has last - been swapped. This is not to be confused with the output surface damage, - which only contains the changes between two frames. - - Returns a bool specifying whether the output needs a new frame rendered. - """ - needs_frame_ptr = ffi.new("bool *") - if not lib.wlr_output_damage_attach_render( - self._ptr, needs_frame_ptr, damage._ptr - ): - raise RuntimeError("Rendering on output failed") - - return needs_frame_ptr[0] - - def add(self, damage: PixmanRegion32) -> None: - """Accumulates damage and schedules a `frame` event.""" - lib.wlr_output_damage_add(self._ptr, damage._ptr) - - def add_whole(self) -> None: - """Damages the whole output and schedules a `frame` event.""" - lib.wlr_output_damage_add_whole(self._ptr) - - def add_box(self, box: Box) -> None: - """Accumulates damage from a box and schedules a `frame` event.""" - lib.wlr_output_damage_add_box(self._ptr, box._ptr) From fdb0f5a96f07b967479b3604fe4ce46e860cac9c Mon Sep 17 00:00:00 2001 From: mcol Date: Fri, 6 Oct 2023 11:58:36 +0100 Subject: [PATCH 28/68] (wlroots 0bb5742) compositor: pass version in wlr_compositor_create --- wlroots/ffi_build.py | 2 +- wlroots/helper.py | 9 +++++++-- wlroots/wlr_types/compositor.py | 17 ++++++++++++++--- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/wlroots/ffi_build.py b/wlroots/ffi_build.py index efcc4ea7..a8e55fd0 100644 --- a/wlroots/ffi_build.py +++ b/wlroots/ffi_build.py @@ -318,7 +318,7 @@ def has_xwayland() -> bool: }; struct wlr_compositor *wlr_compositor_create(struct wl_display *display, - struct wlr_renderer *renderer); + uint32_t version, struct wlr_renderer *renderer); struct wlr_surface_state { uint32_t committed; diff --git a/wlroots/helper.py b/wlroots/helper.py index 2c4bcedf..daf347e5 100644 --- a/wlroots/helper.py +++ b/wlroots/helper.py @@ -11,7 +11,10 @@ def build_compositor( - display: Display, *, backend_type=BackendType.AUTO + display: Display, + *, + backend_type=BackendType.AUTO, + compositor_version: int = 5, ) -> tuple[Compositor, Allocator, Renderer, Backend, SubCompositor]: """Build and run a compositor @@ -21,6 +24,8 @@ def build_compositor( :param backend_type: The type of the backend to setup the compositor for, by default use the auto-detected backend. + :param compositor_version: + The version of the wlr_compositor interface to use. :return: The compositor, allocator, renderer, and the backend. """ @@ -28,7 +33,7 @@ def build_compositor( renderer = Renderer.autocreate(backend) renderer.init_display(display) allocator = Allocator.autocreate(backend, renderer) - compositor = Compositor(display, renderer) + compositor = Compositor(display, compositor_version, renderer) subcompositor = SubCompositor(display) return compositor, allocator, renderer, backend, subcompositor diff --git a/wlroots/wlr_types/compositor.py b/wlroots/wlr_types/compositor.py index 3d023aed..3ca595a3 100644 --- a/wlroots/wlr_types/compositor.py +++ b/wlroots/wlr_types/compositor.py @@ -19,19 +19,30 @@ from wlroots.renderer import Renderer +COMPOSITOR_VERSION = 5 + + class Compositor(Ptr): - def __init__(self, display: Display, renderer: Renderer | None = None) -> None: + def __init__( + self, display: Display, version: int, renderer: Renderer | None = None + ) -> None: """A compositor for clients to be able to allocate surfaces :param display: The Wayland server display to attach to the compositor. + :param version: + The version of the wlr_compositor interface to use. :param renderer: The wlroots renderer to attach the compositor to. """ + if not version <= COMPOSITOR_VERSION: + raise ValueError( + f"Compositor version must be less than or equal to {COMPOSITOR_VERSION}" + ) if renderer is None: - self._ptr = lib.wlr_compositor_create(display._ptr, ffi.NULL) + self._ptr = lib.wlr_compositor_create(display._ptr, version, ffi.NULL) else: - self._ptr = lib.wlr_compositor_create(display._ptr, renderer._ptr) + self._ptr = lib.wlr_compositor_create(display._ptr, version, renderer._ptr) class SubCompositor(Ptr): From d49d774ff67715ed5d1e568bab49b9cbb757aeda Mon Sep 17 00:00:00 2001 From: mcol Date: Fri, 6 Oct 2023 13:05:10 +0100 Subject: [PATCH 29/68] (wlroots 9506290) wlr_scene: Introduce wlr_scene_buffer_set_opacity --- wlroots/ffi_build.py | 3 +++ wlroots/wlr_types/scene.py | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/wlroots/ffi_build.py b/wlroots/ffi_build.py index a8e55fd0..9b468cd0 100644 --- a/wlroots/ffi_build.py +++ b/wlroots/ffi_build.py @@ -1863,6 +1863,9 @@ def has_xwayland() -> bool: void wlr_scene_buffer_send_frame_done(struct wlr_scene_buffer *scene_buffer, struct timespec *now); +void wlr_scene_buffer_set_opacity(struct wlr_scene_buffer *scene_buffer, + float opacity); + struct wlr_scene_output *wlr_scene_output_create(struct wlr_scene *scene, struct wlr_output *output); diff --git a/wlroots/wlr_types/scene.py b/wlroots/wlr_types/scene.py index 305227b5..6c10825f 100644 --- a/wlroots/wlr_types/scene.py +++ b/wlroots/wlr_types/scene.py @@ -175,6 +175,10 @@ def set_buffer_with_damage( region_ptr = region._ptr if region else ffi.NULL lib.wlr_scene_buffer_set_buffer_with_damage(self._ptr, buffer_ptr, region_ptr) + def set_opacity(self, opacity: float) -> None: + """Sets the opacity of this buffer""" + lib.wlr_scene_buffer_set_opacity(self._ptr, opacity) + T = TypeVar("T") BufferCallback = Callable[[SceneBuffer, int, int, T], None] From 70a2152450e64d5dc830ae76ad40468e5b24becb Mon Sep 17 00:00:00 2001 From: mcol Date: Fri, 6 Oct 2023 20:10:40 +0100 Subject: [PATCH 30/68] (wlroots 75d03f2) xwm: introduce associate/dissociate events I miss this wlroots commit and these changes earlier; this pywlroots commit is out of order compared with the others and re-ordering during a rebase caused some conflicts that aren't worth the time. --- wlroots/ffi_build.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/wlroots/ffi_build.py b/wlroots/ffi_build.py index 9b468cd0..659ab239 100644 --- a/wlroots/ffi_build.py +++ b/wlroots/ffi_build.py @@ -3056,6 +3056,8 @@ def has_xwayland() -> bool: struct wl_signal request_maximize; struct wl_signal request_fullscreen; struct wl_signal request_activate; + struct wl_signal associate; + struct wl_signal dissociate; struct wl_signal map; struct wl_signal unmap; struct wl_signal set_title; From 2968f1273ca480e9de51709842a40d9b21dc1d19 Mon Sep 17 00:00:00 2001 From: mcol Date: Fri, 6 Oct 2023 16:17:17 +0100 Subject: [PATCH 31/68] (wlroots 6b40e08) compositor: introduce unified map logic --- wlroots/ffi_build.py | 5 ++++- wlroots/wlr_types/compositor.py | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/wlroots/ffi_build.py b/wlroots/ffi_build.py index 659ab239..d5654306 100644 --- a/wlroots/ffi_build.py +++ b/wlroots/ffi_build.py @@ -345,6 +345,7 @@ def has_xwayland() -> bool: void (*commit)(struct wlr_surface *surface); void (*precommit)(struct wlr_surface *surface, const struct wlr_surface_state *state); + void (*unmap)(struct wlr_surface *surface); void (*destroy)(struct wlr_surface *surface); ...; }; @@ -369,6 +370,7 @@ def has_xwayland() -> bool: struct wlr_surface_state current, pending; struct wl_list cached; + bool mapped; const struct wlr_surface_role *role; void *role_data; @@ -377,6 +379,8 @@ def has_xwayland() -> bool: struct wl_signal client_commit; struct wl_signal precommit; struct wl_signal commit; + struct wl_signal map; + struct wl_signal unmap; struct wl_signal new_subsurface; struct wl_signal destroy; } events; @@ -384,7 +388,6 @@ def has_xwayland() -> bool: struct wl_list current_outputs; struct wlr_addon_set addons; void *data; - struct wl_listener renderer_destroy; ...; }; diff --git a/wlroots/wlr_types/compositor.py b/wlroots/wlr_types/compositor.py index 3ca595a3..652f8454 100644 --- a/wlroots/wlr_types/compositor.py +++ b/wlroots/wlr_types/compositor.py @@ -64,6 +64,8 @@ def __init__(self, ptr) -> None: data_wrapper=SurfaceState, ) self.commit_event = Signal(ptr=ffi.addressof(self._ptr.events.commit)) + self.map_event = Signal(ptr=ffi.addressof(self._ptr.events.map)) + self.unmap_event = Signal(ptr=ffi.addressof(self._ptr.events.unmap)) self.new_subsurface_event = Signal( ptr=ffi.addressof(self._ptr.events.new_subsurface), data_wrapper=SubSurface, From ed0aadc40e9be36886e011267cfdd5136e63dbe8 Mon Sep 17 00:00:00 2001 From: mcol Date: Fri, 6 Oct 2023 17:00:52 +0100 Subject: [PATCH 32/68] (wlroots c590bb6) subcompositor: use unified map logic --- wlroots/ffi_build.py | 3 --- wlroots/wlr_types/compositor.py | 2 -- 2 files changed, 5 deletions(-) diff --git a/wlroots/ffi_build.py b/wlroots/ffi_build.py index d5654306..ffe78ef5 100644 --- a/wlroots/ffi_build.py +++ b/wlroots/ffi_build.py @@ -460,7 +460,6 @@ def has_xwayland() -> bool: bool synchronized; bool reordered; - bool mapped; bool added; struct wl_listener surface_client_commit; @@ -468,8 +467,6 @@ def has_xwayland() -> bool: struct { struct wl_signal destroy; - struct wl_signal map; - struct wl_signal unmap; } events; void *data; diff --git a/wlroots/wlr_types/compositor.py b/wlroots/wlr_types/compositor.py index 652f8454..8f3232d9 100644 --- a/wlroots/wlr_types/compositor.py +++ b/wlroots/wlr_types/compositor.py @@ -138,8 +138,6 @@ def __init__(self, ptr): self._ptr = ffi.cast("struct wlr_subsurface *", ptr) self.destroy_event = Signal(ptr=ffi.addressof(self._ptr.events.destroy)) - self.map_event = Signal(ptr=ffi.addressof(self._ptr.events.map)) - self.unmap_event = Signal(ptr=ffi.addressof(self._ptr.events.unmap)) @property def surface(self) -> Surface: From 794fe0bf01af274c250b760656c4beee840b1804 Mon Sep 17 00:00:00 2001 From: mcol Date: Fri, 6 Oct 2023 17:37:13 +0100 Subject: [PATCH 33/68] (wlroots b0437fc) xdg-shell: use unified map logic --- wlroots/ffi_build.py | 4 +--- wlroots/wlr_types/xdg_shell.py | 2 -- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/wlroots/ffi_build.py b/wlroots/ffi_build.py index ffe78ef5..1003e321 100644 --- a/wlroots/ffi_build.py +++ b/wlroots/ffi_build.py @@ -2590,7 +2590,7 @@ def has_xwayland() -> bool: struct wl_list popups; // wlr_xdg_popup::link - bool added, configured, mapped; + bool added, configured; struct wl_event_source *configure_idle; uint32_t scheduled_serial; struct wl_list configure_list; @@ -2603,8 +2603,6 @@ def has_xwayland() -> bool: struct wl_signal destroy; struct wl_signal ping_timeout; struct wl_signal new_popup; - struct wl_signal map; - struct wl_signal unmap; struct wl_signal configure; // wlr_xdg_surface_configure struct wl_signal ack_configure; // wlr_xdg_surface_configure diff --git a/wlroots/wlr_types/xdg_shell.py b/wlroots/wlr_types/xdg_shell.py index 01802395..9e53b032 100644 --- a/wlroots/wlr_types/xdg_shell.py +++ b/wlroots/wlr_types/xdg_shell.py @@ -72,8 +72,6 @@ def __init__(self, ptr) -> None: """ self._ptr = ffi.cast("struct wlr_xdg_surface *", ptr) - self.map_event = Signal(ptr=ffi.addressof(self._ptr.events.map)) - self.unmap_event = Signal(ptr=ffi.addressof(self._ptr.events.unmap)) self.destroy_event = Signal(ptr=ffi.addressof(self._ptr.events.destroy)) self.new_popup_event = Signal( ptr=ffi.addressof(self._ptr.events.new_popup), data_wrapper=XdgPopup From da61575cc147112b7b368aa135424360765aacf6 Mon Sep 17 00:00:00 2001 From: mcol Date: Fri, 6 Oct 2023 17:40:21 +0100 Subject: [PATCH 34/68] (wlroots c63f365) layer-shell: use unified map logic --- wlroots/ffi_build.py | 4 +--- wlroots/wlr_types/layer_shell_v1.py | 2 -- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/wlroots/ffi_build.py b/wlroots/ffi_build.py index 1003e321..99b1af06 100644 --- a/wlroots/ffi_build.py +++ b/wlroots/ffi_build.py @@ -2873,13 +2873,11 @@ def has_xwayland() -> bool: struct wlr_layer_shell_v1 *shell; struct wl_list popups; // wlr_xdg_popup::link char *namespace; - bool added, configured, mapped; + bool added, configured; struct wl_list configure_list; struct wlr_layer_surface_v1_state current, pending; struct { struct wl_signal destroy; - struct wl_signal map; - struct wl_signal unmap; struct wl_signal new_popup; } events; diff --git a/wlroots/wlr_types/layer_shell_v1.py b/wlroots/wlr_types/layer_shell_v1.py index 1ca213bd..69f771bc 100644 --- a/wlroots/wlr_types/layer_shell_v1.py +++ b/wlroots/wlr_types/layer_shell_v1.py @@ -97,8 +97,6 @@ def __init__(self, ptr): self._ptr = ffi.cast("struct wlr_layer_surface_v1 *", ptr) self.destroy_event = Signal(ptr=ffi.addressof(self._ptr.events.destroy)) - self.map_event = Signal(ptr=ffi.addressof(self._ptr.events.map)) - self.unmap_event = Signal(ptr=ffi.addressof(self._ptr.events.unmap)) self.new_popup_event = Signal(ptr=ffi.addressof(self._ptr.events.new_popup)) @property From ae465fa11ee96237d77c437f1d75d17fe44c445e Mon Sep 17 00:00:00 2001 From: mcol Date: Fri, 6 Oct 2023 17:45:54 +0100 Subject: [PATCH 35/68] (wlroots af4181f) drag: use unified map logic --- wlroots/ffi_build.py | 3 --- wlroots/wlr_types/data_device_manager.py | 2 -- 2 files changed, 5 deletions(-) diff --git a/wlroots/ffi_build.py b/wlroots/ffi_build.py index 99b1af06..c122d2e3 100644 --- a/wlroots/ffi_build.py +++ b/wlroots/ffi_build.py @@ -522,10 +522,7 @@ def has_xwayland() -> bool: struct wlr_drag_icon { struct wlr_drag *drag; struct wlr_surface *surface; - bool mapped; struct { - struct wl_signal map; - struct wl_signal unmap; struct wl_signal destroy; } events; void *data; diff --git a/wlroots/wlr_types/data_device_manager.py b/wlroots/wlr_types/data_device_manager.py index 4970e13c..ab43e6f2 100644 --- a/wlroots/wlr_types/data_device_manager.py +++ b/wlroots/wlr_types/data_device_manager.py @@ -86,8 +86,6 @@ class DragIcon(PtrHasData): def __init__(self, ptr) -> None: self._ptr = ffi.cast("struct wlr_drag_icon *", ptr) - self.map_event = Signal(ptr=ffi.addressof(self._ptr.events.map)) - self.unmap_event = Signal(ptr=ffi.addressof(self._ptr.events.unmap)) self.destroy_event = Signal(ptr=ffi.addressof(self._ptr.events.destroy)) @property From 776abf84c4d767794eda2a892c1a1ee4c5c09994 Mon Sep 17 00:00:00 2001 From: mcol Date: Fri, 6 Oct 2023 17:47:57 +0100 Subject: [PATCH 36/68] (wlroots 26676c8) xwm: use unified map logic --- wlroots/ffi_build.py | 6 ++---- wlroots/xwayland.py | 6 ------ 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/wlroots/ffi_build.py b/wlroots/ffi_build.py index c122d2e3..5d37b5be 100644 --- a/wlroots/ffi_build.py +++ b/wlroots/ffi_build.py @@ -3009,12 +3009,12 @@ def has_xwayland() -> bool: struct wlr_surface *surface; struct wlr_addon surface_addon; struct wl_listener surface_commit; - struct wl_listener surface_precommit; + struct wl_listener surface_map; + struct wl_listener surface_unmap; int16_t x, y; uint16_t width, height; uint16_t saved_width, saved_height; bool override_redirect; - bool mapped; char *title; char *class; char *instance; @@ -3051,8 +3051,6 @@ def has_xwayland() -> bool: struct wl_signal request_activate; struct wl_signal associate; struct wl_signal dissociate; - struct wl_signal map; - struct wl_signal unmap; struct wl_signal set_title; struct wl_signal set_class; struct wl_signal set_role; diff --git a/wlroots/xwayland.py b/wlroots/xwayland.py index 496deee8..553a93b2 100644 --- a/wlroots/xwayland.py +++ b/wlroots/xwayland.py @@ -172,8 +172,6 @@ def __init__(self, ptr) -> None: self.request_activate_event = Signal( ptr=ffi.addressof(self._ptr.events.request_activate) ) - self.map_event = Signal(ptr=ffi.addressof(self._ptr.events.map)) - self.unmap_event = Signal(ptr=ffi.addressof(self._ptr.events.unmap)) self.set_title_event = Signal(ptr=ffi.addressof(self._ptr.events.set_title)) self.set_class_event = Signal(ptr=ffi.addressof(self._ptr.events.set_class)) self.set_role_event = Signal(ptr=ffi.addressof(self._ptr.events.set_role)) @@ -263,10 +261,6 @@ def height(self) -> int: def override_redirect(self) -> bool: return self._ptr.override_redirect - @property - def mapped(self) -> bool: - return self._ptr.mapped - @property def title(self) -> str | None: return str_or_none(self._ptr.title) From b96884a53fec77a059bcd4b4800bed8b5181a130 Mon Sep 17 00:00:00 2001 From: mcol Date: Fri, 6 Oct 2023 17:48:55 +0100 Subject: [PATCH 37/68] (wlroots d086ee1) compositor: remove wlr_surface_role.precommit --- wlroots/ffi_build.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/wlroots/ffi_build.py b/wlroots/ffi_build.py index 5d37b5be..5c6a65ea 100644 --- a/wlroots/ffi_build.py +++ b/wlroots/ffi_build.py @@ -343,8 +343,6 @@ def has_xwayland() -> bool: struct wlr_surface_role { const char *name; void (*commit)(struct wlr_surface *surface); - void (*precommit)(struct wlr_surface *surface, - const struct wlr_surface_state *state); void (*unmap)(struct wlr_surface *surface); void (*destroy)(struct wlr_surface *surface); ...; From 143814ddd017eacef588fca6af9a78f80a31c4af Mon Sep 17 00:00:00 2001 From: mcol Date: Fri, 6 Oct 2023 17:55:52 +0100 Subject: [PATCH 38/68] (wlroots 24a479a) drag: don't set icon's role_data --- wlroots/ffi_build.py | 1 + 1 file changed, 1 insertion(+) diff --git a/wlroots/ffi_build.py b/wlroots/ffi_build.py index 5c6a65ea..32e70932 100644 --- a/wlroots/ffi_build.py +++ b/wlroots/ffi_build.py @@ -523,6 +523,7 @@ def has_xwayland() -> bool: struct { struct wl_signal destroy; } events; + struct wl_listener surface_destroy; void *data; ...; }; From 3d1a4278fe531b6fef7807923d1a033b5add6d45 Mon Sep 17 00:00:00 2001 From: mcol Date: Fri, 6 Oct 2023 19:36:35 +0100 Subject: [PATCH 39/68] (wlroots 70c1a57) gamma-control-v1: introduce set_gamma event --- wlroots/ffi_build.py | 1 + 1 file changed, 1 insertion(+) diff --git a/wlroots/ffi_build.py b/wlroots/ffi_build.py index 32e70932..bd685dd7 100644 --- a/wlroots/ffi_build.py +++ b/wlroots/ffi_build.py @@ -734,6 +734,7 @@ def has_xwayland() -> bool: struct { struct wl_signal destroy; + struct wl_signal set_gamma; } events; void *data; From de8f1ff48843d62da77ddb5d190805f73b347764 Mon Sep 17 00:00:00 2001 From: mcol Date: Fri, 6 Oct 2023 18:44:39 +0100 Subject: [PATCH 40/68] Add bindings to wlr_output_state methods --- wlroots/ffi_build.py | 8 ++++++++ wlroots/wlr_types/__init__.py | 2 +- wlroots/wlr_types/output.py | 19 ++++++++++++++++++- 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/wlroots/ffi_build.py b/wlroots/ffi_build.py index bd685dd7..92f9d9c8 100644 --- a/wlroots/ffi_build.py +++ b/wlroots/ffi_build.py @@ -1182,6 +1182,14 @@ def has_xwayland() -> bool: enum wl_output_transform wlr_output_transform_invert( enum wl_output_transform tr); + +void wlr_output_state_finish(struct wlr_output_state *state); +void wlr_output_state_set_enabled(struct wlr_output_state *state, + bool enabled); +void wlr_output_state_set_mode(struct wlr_output_state *state, + struct wlr_output_mode *mode); +void wlr_output_state_set_custom_mode(struct wlr_output_state *state, + int32_t width, int32_t height, int32_t refresh); """ # types/wlr_output_layout.h diff --git a/wlroots/wlr_types/__init__.py b/wlroots/wlr_types/__init__.py index b261a2a3..9507ac0c 100644 --- a/wlroots/wlr_types/__init__.py +++ b/wlroots/wlr_types/__init__.py @@ -19,7 +19,7 @@ from .keyboard import Keyboard # noqa: F401 from .layer_shell_v1 import LayerShellV1 # noqa: F401 from .matrix import Matrix # noqa: F401 -from .output import Output # noqa: F401 +from .output import Output, OutputState # noqa: F401 from .output_layout import OutputLayout # noqa: F401 from .pointer import ( # noqa: F401 PointerAxisEvent, diff --git a/wlroots/wlr_types/output.py b/wlroots/wlr_types/output.py index c2fe5909..99321f9e 100644 --- a/wlroots/wlr_types/output.py +++ b/wlroots/wlr_types/output.py @@ -309,9 +309,26 @@ def preferred(self) -> int: class OutputState(Ptr): - def __init__(self, ptr) -> None: + def __init__(self, ptr: ffi.CData | None = None) -> None: + if ptr is None: + ptr = ffi.new("struct wlr_output_state *") self._ptr = ptr + def finish(self) -> None: + lib.wlr_output_state_finish(self._ptr) + + def set_enabled(self, *, enabled: bool = True) -> None: + lib.wlr_output_state_set_enabled(self._ptr, enabled) + + def set_mode(self, mode: OutputMode | None) -> None: + if mode is None: + lib.wlr_output_state_set_mode(self._ptr, ffi.NULL) + else: + lib.wlr_output_state_set_mode(self._ptr, mode._ptr) + + def set_custom_mode(self, width: int, height: int, refresh: int) -> None: + lib.wlr_output_state_set_custom_mode(self._ptr, width, height, refresh) + class OutputEventRequestState(Ptr): def __init__(self, ptr) -> None: From 03c72640c9fdd0db70c6a4989634b7588ee2284b Mon Sep 17 00:00:00 2001 From: mcol Date: Fri, 6 Oct 2023 18:59:26 +0100 Subject: [PATCH 41/68] fix OutputState.commit_state signature --- wlroots/wlr_types/output.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wlroots/wlr_types/output.py b/wlroots/wlr_types/output.py index 99321f9e..1e4060fb 100644 --- a/wlroots/wlr_types/output.py +++ b/wlroots/wlr_types/output.py @@ -205,9 +205,9 @@ def rollback(self) -> None: """Discard the pending output state""" lib.wlr_output_rollback(self._ptr) - def commit_state(self, state: OutputEventRequestState) -> None: + def commit_state(self, state: OutputState) -> bool: """Commit requested state""" - lib.wlr_output_commit_state(self._ptr, state._ptr) + return lib.wlr_output_commit_state(self._ptr, state._ptr) def effective_resolution(self) -> tuple[int, int]: """Computes the transformed and scaled output resolution""" From 73b500b6c9e34f31bf36c7f5f878ab04bcadeba3 Mon Sep 17 00:00:00 2001 From: mcol Date: Fri, 6 Oct 2023 19:41:38 +0100 Subject: [PATCH 42/68] (wlroots 753f3cc) compositor: add wlr_surface_role.no_object --- wlroots/ffi_build.py | 1 + 1 file changed, 1 insertion(+) diff --git a/wlroots/ffi_build.py b/wlroots/ffi_build.py index 92f9d9c8..ff3485de 100644 --- a/wlroots/ffi_build.py +++ b/wlroots/ffi_build.py @@ -342,6 +342,7 @@ def has_xwayland() -> bool: struct wlr_surface_role { const char *name; + bool no_object; void (*commit)(struct wlr_surface *surface); void (*unmap)(struct wlr_surface *surface); void (*destroy)(struct wlr_surface *surface); From 95fef0400d88065afb71c2137370eeed03099f84 Mon Sep 17 00:00:00 2001 From: mcol Date: Fri, 6 Oct 2023 20:40:44 +0100 Subject: [PATCH 43/68] (wlroots da04b06) cursor: add wlr_cursor_set_xcursor() --- wlroots/ffi_build.py | 2 ++ wlroots/wlr_types/cursor.py | 12 ++++++++++++ 2 files changed, 14 insertions(+) diff --git a/wlroots/ffi_build.py b/wlroots/ffi_build.py index ff3485de..8551ffb7 100644 --- a/wlroots/ffi_build.py +++ b/wlroots/ffi_build.py @@ -300,6 +300,8 @@ def has_xwayland() -> bool: struct wlr_output *output); void wlr_cursor_map_input_to_output(struct wlr_cursor *cur, struct wlr_input_device *dev, struct wlr_output *output); +void wlr_cursor_set_xcursor(struct wlr_cursor *cur, + struct wlr_xcursor_manager *manager, const char *name); """ # types/wlr_compositor.h diff --git a/wlroots/wlr_types/cursor.py b/wlroots/wlr_types/cursor.py index 8f8b6f29..79cbe6f4 100644 --- a/wlroots/wlr_types/cursor.py +++ b/wlroots/wlr_types/cursor.py @@ -2,6 +2,7 @@ from __future__ import annotations import enum +from typing import TYPE_CHECKING from pywayland.server import Signal @@ -32,6 +33,9 @@ TouchEventUp, ) +if TYPE_CHECKING: + from .xcursor_manager import XCursorManager + class WarpMode(enum.Enum): Layout = enum.auto() @@ -293,3 +297,11 @@ def map_input_to_output( output_ptr = output._ptr lib.wlr_cursor_map_input_to_output(self._ptr, input_device._ptr, output_ptr) + + def set_xcursor(self, manager: XCursorManager, name: str) -> None: + """ + Set the cursor image from an XCursor theme. + + The image will be loaded from the struct wlr_xcursor_manager. + """ + lib.wlr_cursor_set_xcursor(self._ptr, manager._ptr, name.encode()) From cd9402b93f20bbc71ae4135b6162c19d0585b692 Mon Sep 17 00:00:00 2001 From: mcol Date: Fri, 6 Oct 2023 19:53:36 +0100 Subject: [PATCH 44/68] (wlroots 0f67580) compositor: introduce wlr_surface_set_role_object() --- wlroots/ffi_build.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/wlroots/ffi_build.py b/wlroots/ffi_build.py index 8551ffb7..ed0db79e 100644 --- a/wlroots/ffi_build.py +++ b/wlroots/ffi_build.py @@ -395,8 +395,7 @@ def has_xwayland() -> bool: typedef void (*wlr_surface_iterator_func_t)(struct wlr_surface *surface, int sx, int sy, void *data); -bool wlr_surface_set_role(struct wlr_surface *surface, - const struct wlr_surface_role *role, void *role_data, +bool wlr_surface_set_role(struct wlr_surface *surface, const struct wlr_surface_role *role, struct wl_resource *error_resource, uint32_t error_code); void wlr_surface_destroy_role_object(struct wlr_surface *surface); From eb44b5d3209dd90872f59e83239e460aa65d54f8 Mon Sep 17 00:00:00 2001 From: mcol Date: Fri, 6 Oct 2023 19:55:17 +0100 Subject: [PATCH 45/68] (wlroots 89cb484) compositor: replace role_data with role_resource --- wlroots/ffi_build.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wlroots/ffi_build.py b/wlroots/ffi_build.py index ed0db79e..b8569916 100644 --- a/wlroots/ffi_build.py +++ b/wlroots/ffi_build.py @@ -374,7 +374,7 @@ def has_xwayland() -> bool: bool mapped; const struct wlr_surface_role *role; - void *role_data; + struct wl_resource *role_resource; struct { struct wl_signal client_commit; From 0a3f1979dce2c1b02565713fb1acc958c11183a6 Mon Sep 17 00:00:00 2001 From: mcol Date: Fri, 6 Oct 2023 19:58:00 +0100 Subject: [PATCH 46/68] (wlroots be05097) output: add wlr_output_state_init() --- wlroots/ffi_build.py | 1 + wlroots/wlr_types/output.py | 1 + 2 files changed, 2 insertions(+) diff --git a/wlroots/ffi_build.py b/wlroots/ffi_build.py index b8569916..b394a38c 100644 --- a/wlroots/ffi_build.py +++ b/wlroots/ffi_build.py @@ -1185,6 +1185,7 @@ def has_xwayland() -> bool: enum wl_output_transform wlr_output_transform_invert( enum wl_output_transform tr); +void wlr_output_state_init(struct wlr_output_state *state); void wlr_output_state_finish(struct wlr_output_state *state); void wlr_output_state_set_enabled(struct wlr_output_state *state, bool enabled); diff --git a/wlroots/wlr_types/output.py b/wlroots/wlr_types/output.py index 1e4060fb..7b102b9e 100644 --- a/wlroots/wlr_types/output.py +++ b/wlroots/wlr_types/output.py @@ -312,6 +312,7 @@ class OutputState(Ptr): def __init__(self, ptr: ffi.CData | None = None) -> None: if ptr is None: ptr = ffi.new("struct wlr_output_state *") + lib.wlr_output_state_init(ptr) self._ptr = ptr def finish(self) -> None: From 7847df171ccdfba52b73829d4cddc3ecd8335b8c Mon Sep 17 00:00:00 2001 From: mcol Date: Fri, 6 Oct 2023 20:20:02 +0100 Subject: [PATCH 47/68] add missing wlr_xwayland_surface.withdrawn --- wlroots/ffi_build.py | 1 + 1 file changed, 1 insertion(+) diff --git a/wlroots/ffi_build.py b/wlroots/ffi_build.py index b394a38c..e5fbf066 100644 --- a/wlroots/ffi_build.py +++ b/wlroots/ffi_build.py @@ -3050,6 +3050,7 @@ def has_xwayland() -> bool: bool fullscreen; bool maximized_vert, maximized_horz; bool minimized; + bool withdrawn; bool has_alpha; struct { struct wl_signal destroy; From 790438ff74956e19d78e0df7280282c3bceb1bea Mon Sep 17 00:00:00 2001 From: mcol Date: Fri, 6 Oct 2023 20:31:20 +0100 Subject: [PATCH 48/68] (wlroots 18bafbf) xcursor-manager: drop wlr_xcursor_manager_set_cursor_image() --- wlroots/ffi_build.py | 2 -- wlroots/wlr_types/xcursor_manager.py | 11 ----------- 2 files changed, 13 deletions(-) diff --git a/wlroots/ffi_build.py b/wlroots/ffi_build.py index e5fbf066..86a0555f 100644 --- a/wlroots/ffi_build.py +++ b/wlroots/ffi_build.py @@ -2265,8 +2265,6 @@ def has_xwayland() -> bool: int wlr_xcursor_manager_load(struct wlr_xcursor_manager *manager, float scale); -void wlr_xcursor_manager_set_cursor_image(struct wlr_xcursor_manager *manager, - const char *name, struct wlr_cursor *cursor); struct wlr_xcursor *wlr_xcursor_manager_get_xcursor( struct wlr_xcursor_manager *manager, const char *name, float scale); """ diff --git a/wlroots/wlr_types/xcursor_manager.py b/wlroots/wlr_types/xcursor_manager.py index f83eb7c5..d8502ffa 100644 --- a/wlroots/wlr_types/xcursor_manager.py +++ b/wlroots/wlr_types/xcursor_manager.py @@ -29,17 +29,6 @@ def destroy(self): ffi.release(self._ptr) self._ptr = None - def set_cursor_image(self, name: str, cursor: Cursor): - """Set the cursor image - - Set a Cursor image to the specified cursor name for all scale factors. - The wlroots cursor will take over from this point and ensure the - correct cursor is used on each output, assuming an output layout is - attached to it. - """ - name_cdata = ffi.new("char []", name.encode()) - lib.wlr_xcursor_manager_set_cursor_image(self._ptr, name_cdata, cursor._ptr) - def get_xcursor(self, name: str, scale: float = 1) -> XCursor | None: """ Retrieves a wlr_xcursor reference for the given cursor name at the given scale From 0891b152dd4d4e816df05922b17f4daaefbbde07 Mon Sep 17 00:00:00 2001 From: mcol Date: Fri, 6 Oct 2023 20:50:04 +0100 Subject: [PATCH 49/68] (wlroots 19ba3f0) xwayland: drop struct wlr_xwayland_move_event --- wlroots/ffi_build.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/wlroots/ffi_build.py b/wlroots/ffi_build.py index 86a0555f..63238105 100644 --- a/wlroots/ffi_build.py +++ b/wlroots/ffi_build.py @@ -3085,10 +3085,6 @@ def has_xwayland() -> bool: uint16_t mask; // xcb_config_window_t ...; }; - struct wlr_xwayland_move_event { - struct wlr_xwayland_surface *surface; - ...; - }; struct wlr_xwayland_remove_startup_info_event { const char *id; xcb_window_t window; From 0fefc038bb62cc6e7ca0c22b85b87c0eefa87c61 Mon Sep 17 00:00:00 2001 From: mcol Date: Fri, 6 Oct 2023 20:57:33 +0100 Subject: [PATCH 50/68] (wlroots 214df8e) scene_output: optionally record and report timings --- wlroots/ffi_build.py | 7 ++++++- wlroots/wlr_types/scene.py | 12 ++++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/wlroots/ffi_build.py b/wlroots/ffi_build.py index 63238105..2de3c04c 100644 --- a/wlroots/ffi_build.py +++ b/wlroots/ffi_build.py @@ -1798,6 +1798,10 @@ def has_xwayland() -> bool: ...; }; +struct wlr_scene_output_state_options { + struct wlr_scene_timer *timer; +}; + void wlr_scene_node_destroy(struct wlr_scene_node *node); void wlr_scene_node_set_enabled(struct wlr_scene_node *node, bool enabled); @@ -1882,7 +1886,8 @@ def has_xwayland() -> bool: void wlr_scene_output_set_position(struct wlr_scene_output *scene_output, int lx, int ly); -bool wlr_scene_output_commit(struct wlr_scene_output *scene_output); +bool wlr_scene_output_commit(struct wlr_scene_output *scene_output, + const struct wlr_scene_output_state_options *options); void wlr_scene_output_send_frame_done(struct wlr_scene_output *scene_output, struct timespec *now); diff --git a/wlroots/wlr_types/scene.py b/wlroots/wlr_types/scene.py index 6c10825f..b23ffd42 100644 --- a/wlroots/wlr_types/scene.py +++ b/wlroots/wlr_types/scene.py @@ -91,9 +91,11 @@ def create(cls, scene: Scene, output: Output) -> SceneOutput: """ return cls(lib.wlr_scene_output_create(scene._ptr, output._ptr)) - def commit(self) -> None: + def commit(self, options: SceneOutputStateOptions | None = None) -> None: """Render and commit an output.""" - if not lib.wlr_scene_output_commit(self._ptr): + options_ptr = options._ptr if options is not None else ffi.NULL + + if not lib.wlr_scene_output_commit(self._ptr, options_ptr): raise RuntimeError("Unable to commit scene output") def destroy(self) -> None: @@ -345,3 +347,9 @@ def configure(self, full_area: Box, usable_area: Box) -> None: lib.wlr_scene_layer_surface_v1_configure( self._ptr, full_area._ptr, usable_area._ptr ) + + +class SceneOutputStateOptions(Ptr): + def __init__(self, ptr) -> None: + """A `struct wlr_scene_output_state_options`.""" + self._ptr = ptr From 6e872e21bb13962be9f002093a92b399547b4e7d Mon Sep 17 00:00:00 2001 From: mcol Date: Fri, 6 Oct 2023 20:59:57 +0100 Subject: [PATCH 51/68] (wlroots 88942d4) scene: rename output_present event to output_sample --- wlroots/ffi_build.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wlroots/ffi_build.py b/wlroots/ffi_build.py index 2de3c04c..fbed4d11 100644 --- a/wlroots/ffi_build.py +++ b/wlroots/ffi_build.py @@ -1769,7 +1769,7 @@ def has_xwayland() -> bool: struct wl_signal outputs_update; struct wl_signal output_enter; // struct wlr_scene_output struct wl_signal output_leave; // struct wlr_scene_output - struct wl_signal output_present; // struct wlr_scene_output + struct wl_signal output_sample; // struct wlr_scene_output struct wl_signal frame_done; // struct timespec } events; From 1d29bb299d05dcdf6b8e9a843efc4909f5c1e4ed Mon Sep 17 00:00:00 2001 From: mcol Date: Fri, 6 Oct 2023 21:27:22 +0100 Subject: [PATCH 52/68] (wlroots 77dc1c2) xwayland: drop wlr_xwayland_surface.events.set_pid --- wlroots/ffi_build.py | 1 - wlroots/xwayland.py | 1 - 2 files changed, 2 deletions(-) diff --git a/wlroots/ffi_build.py b/wlroots/ffi_build.py index fbed4d11..214d2eae 100644 --- a/wlroots/ffi_build.py +++ b/wlroots/ffi_build.py @@ -3070,7 +3070,6 @@ def has_xwayland() -> bool: struct wl_signal set_class; struct wl_signal set_role; struct wl_signal set_parent; - struct wl_signal set_pid; struct wl_signal set_startup_id; struct wl_signal set_window_type; struct wl_signal set_hints; diff --git a/wlroots/xwayland.py b/wlroots/xwayland.py index 553a93b2..7d126ab2 100644 --- a/wlroots/xwayland.py +++ b/wlroots/xwayland.py @@ -176,7 +176,6 @@ def __init__(self, ptr) -> None: self.set_class_event = Signal(ptr=ffi.addressof(self._ptr.events.set_class)) self.set_role_event = Signal(ptr=ffi.addressof(self._ptr.events.set_role)) self.set_parent_event = Signal(ptr=ffi.addressof(self._ptr.events.set_parent)) - self.set_pid_event = Signal(ptr=ffi.addressof(self._ptr.events.set_pid)) self.set_startup_id_event = Signal( ptr=ffi.addressof(self._ptr.events.set_startup_id) ) From 5e03000900469d5ba8d922c89b7c71bed38c72fb Mon Sep 17 00:00:00 2001 From: mcol Date: Fri, 6 Oct 2023 21:19:23 +0100 Subject: [PATCH 53/68] (wlroots bdc3440) xdg-decoration: store an xdg_toplevel instead of xdg_surface --- wlroots/ffi_build.py | 2 +- wlroots/wlr_types/xdg_decoration_v1.py | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/wlroots/ffi_build.py b/wlroots/ffi_build.py index 214d2eae..6e4bf241 100644 --- a/wlroots/ffi_build.py +++ b/wlroots/ffi_build.py @@ -2353,7 +2353,7 @@ def has_xwayland() -> bool: struct wlr_xdg_toplevel_decoration_v1 { struct wl_resource *resource; - struct wlr_xdg_surface *surface; + struct wlr_xdg_toplevel *toplevel; struct wlr_xdg_decoration_manager_v1 *manager; struct wl_list link; // wlr_xdg_decoration_manager_v1::link diff --git a/wlroots/wlr_types/xdg_decoration_v1.py b/wlroots/wlr_types/xdg_decoration_v1.py index d0f09ef0..f6df86ec 100644 --- a/wlroots/wlr_types/xdg_decoration_v1.py +++ b/wlroots/wlr_types/xdg_decoration_v1.py @@ -11,6 +11,7 @@ from wlroots import PtrHasData, ffi, lib from .compositor import Surface +from .xdg_shell import XdgTopLevel if TYPE_CHECKING: from pywayland.server import Display @@ -53,10 +54,10 @@ def __init__(self, ptr) -> None: ) @property - def surface(self) -> Surface: - surface_ptr = self._ptr.surface - _weakkeydict[surface_ptr] = self._ptr - return Surface(surface_ptr) + def toplevel(self) -> XdgTopLevel: + toplevel_ptr = self._ptr.toplevel + _weakkeydict[toplevel_ptr] = self._ptr + return XdgTopLevel(toplevel_ptr) @property def manager(self) -> XdgDecorationManagerV1: From e87255df7ada8b8a5e085a75b0965e69693d0bd2 Mon Sep 17 00:00:00 2001 From: mcol Date: Fri, 6 Oct 2023 21:44:07 +0100 Subject: [PATCH 54/68] (wlroots bd5c4f4) xdg-shell: rework roles --- wlroots/ffi_build.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/wlroots/ffi_build.py b/wlroots/ffi_build.py index 6e4bf241..50fbe6f4 100644 --- a/wlroots/ffi_build.py +++ b/wlroots/ffi_build.py @@ -2593,6 +2593,7 @@ def has_xwayland() -> bool: struct wlr_surface *surface; struct wl_list link; // wlr_xdg_client::surfaces enum wlr_xdg_surface_role role; + struct wl_resource *role_resource; union { struct wlr_xdg_toplevel *toplevel; @@ -2608,8 +2609,6 @@ def has_xwayland() -> bool: struct wlr_xdg_surface_state current, pending; - struct wl_listener surface_commit; - struct { struct wl_signal destroy; struct wl_signal ping_timeout; From 8ac80ab425c7020f9026fc7cda4d25bf014c43a9 Mon Sep 17 00:00:00 2001 From: mcol Date: Fri, 6 Oct 2023 21:57:16 +0100 Subject: [PATCH 55/68] (wlroots 72787db) compositor: drop wlr_surface_destroy_role_object() --- wlroots/ffi_build.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/wlroots/ffi_build.py b/wlroots/ffi_build.py index 50fbe6f4..538b879b 100644 --- a/wlroots/ffi_build.py +++ b/wlroots/ffi_build.py @@ -398,8 +398,6 @@ def has_xwayland() -> bool: bool wlr_surface_set_role(struct wlr_surface *surface, const struct wlr_surface_role *role, struct wl_resource *error_resource, uint32_t error_code); -void wlr_surface_destroy_role_object(struct wlr_surface *surface); - bool wlr_surface_has_buffer(struct wlr_surface *surface); struct wlr_texture *wlr_surface_get_texture(struct wlr_surface *surface); From a04476fef359cc4b4719e76403bb27a5b0728d3e Mon Sep 17 00:00:00 2001 From: mcol Date: Fri, 6 Oct 2023 22:06:13 +0100 Subject: [PATCH 56/68] (wlroots 91f813f) output_layout: return wlr_output_layout_output when adding output --- wlroots/ffi_build.py | 4 ++-- wlroots/wlr_types/__init__.py | 2 +- wlroots/wlr_types/output_layout.py | 22 ++++++++++++++++------ 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/wlroots/ffi_build.py b/wlroots/ffi_build.py index 538b879b..bc8d55aa 100644 --- a/wlroots/ffi_build.py +++ b/wlroots/ffi_build.py @@ -1217,7 +1217,7 @@ def has_xwayland() -> bool: struct wlr_output *reference, double lx, double ly, double *dest_lx, double *dest_ly); -bool wlr_output_layout_add(struct wlr_output_layout *layout, +struct wlr_output_layout_output *wlr_output_layout_add(struct wlr_output_layout *layout, struct wlr_output *output, int lx, int ly); void wlr_output_layout_remove(struct wlr_output_layout *layout, @@ -1226,7 +1226,7 @@ def has_xwayland() -> bool: void wlr_output_layout_get_box(struct wlr_output_layout *layout, struct wlr_output *reference, struct wlr_box *dest_box); -bool wlr_output_layout_add_auto(struct wlr_output_layout *layout, +struct wlr_output_layout_output *wlr_output_layout_add_auto(struct wlr_output_layout *layout, struct wlr_output *output); struct wlr_output *wlr_output_layout_output_at(struct wlr_output_layout *layout, diff --git a/wlroots/wlr_types/__init__.py b/wlroots/wlr_types/__init__.py index 9507ac0c..1666d18a 100644 --- a/wlroots/wlr_types/__init__.py +++ b/wlroots/wlr_types/__init__.py @@ -20,7 +20,7 @@ from .layer_shell_v1 import LayerShellV1 # noqa: F401 from .matrix import Matrix # noqa: F401 from .output import Output, OutputState # noqa: F401 -from .output_layout import OutputLayout # noqa: F401 +from .output_layout import OutputLayout, OutputLayoutOutput # noqa: F401 from .pointer import ( # noqa: F401 PointerAxisEvent, PointerButtonEvent, diff --git a/wlroots/wlr_types/output_layout.py b/wlroots/wlr_types/output_layout.py index b5e29f9f..ae40dadf 100644 --- a/wlroots/wlr_types/output_layout.py +++ b/wlroots/wlr_types/output_layout.py @@ -31,7 +31,7 @@ def destroy(self) -> None: ffi.release(self._ptr) self._ptr = None - def add_auto(self, output: Output) -> bool: + def add_auto(self, output: Output) -> OutputLayoutOutput | None: """ Add the output to the layout as automatically configured. This will place the output in a sensible location in the layout. The coordinates of the output in @@ -40,7 +40,10 @@ def add_auto(self, output: Output) -> bool: Returns true on success, false on a memory allocation error. """ - return lib.wlr_output_layout_add_auto(self._ptr, output._ptr) + ptr = lib.wlr_output_layout_add_auto(self._ptr, output._ptr) + if ptr == ffi.NULL: + return None + return OutputLayoutOutput(ptr) def output_coords(self, output: Output) -> tuple[float, float]: """Determine coordinates of the output in the layout @@ -72,15 +75,16 @@ def output_at(self, x: float, y: float) -> Output | None: return None return Output(output_ptr) - def add(self, output: Output, lx: int, ly: int) -> bool: + def add(self, output: Output, lx: int, ly: int) -> OutputLayoutOutput | None: """ Add the output to the layout at the specified coordinates. If the output is already a part of the output layout, it will become manually configured and will be moved to the specified coordinates. - - Returns true on success, false on a memory allocation error. """ - return lib.wlr_output_layout_add(self._ptr, output._ptr, lx, ly) + ptr = lib.wlr_output_layout_add(self._ptr, output._ptr, lx, ly) + if ptr == ffi.NULL: + return None + return OutputLayoutOutput(ptr) def remove(self, output: Output) -> None: """Remove an output from the layout.""" @@ -123,3 +127,9 @@ def closest_point( self._ptr, reference_ptr, lx, ly, dest_lx, dest_ly ) return dest_lx[0], dest_ly[0] + + +class OutputLayoutOutput(Ptr): + def __init__(self, ptr) -> None: + """A `struct wlr_output_layout_output`""" + self._ptr = ptr From 847a5bafa403044ee2a2a7241807f81c3bb86199 Mon Sep 17 00:00:00 2001 From: mcol Date: Fri, 6 Oct 2023 22:14:51 +0100 Subject: [PATCH 57/68] (wlroots f5917f0) scene_output_layout: make output adding explicit --- wlroots/ffi_build.py | 2 +- wlroots/wlr_types/scene.py | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/wlroots/ffi_build.py b/wlroots/ffi_build.py index bc8d55aa..6586e6ac 100644 --- a/wlroots/ffi_build.py +++ b/wlroots/ffi_build.py @@ -1896,7 +1896,7 @@ def has_xwayland() -> bool: struct wlr_scene_output *wlr_scene_get_scene_output(struct wlr_scene *scene, struct wlr_output *output); -bool wlr_scene_attach_output_layout(struct wlr_scene *scene, +struct wlr_scene_output_layout *wlr_scene_attach_output_layout(struct wlr_scene *scene, struct wlr_output_layout *output_layout); struct wlr_scene_tree *wlr_scene_subsurface_tree_create( diff --git a/wlroots/wlr_types/scene.py b/wlroots/wlr_types/scene.py index b23ffd42..14c16900 100644 --- a/wlroots/wlr_types/scene.py +++ b/wlroots/wlr_types/scene.py @@ -7,7 +7,7 @@ from wlroots import Ptr, PtrHasData, ffi, lib from wlroots.util.region import PixmanRegion32 -from wlroots.wlr_types import Surface +from wlroots.wlr_types import Surface, OutputLayoutOutput if TYPE_CHECKING: from wlroots.util.box import Box @@ -36,9 +36,14 @@ def tree(self) -> SceneTree: ptr = ffi.addressof(self._ptr.tree) return SceneTree(ptr) - def attach_output_layout(self, output_layout: OutputLayout) -> bool: + def attach_output_layout( + self, output_layout: OutputLayout + ) -> OutputLayoutOutput | None: """Get a scene-graph output from a wlr_output.""" - return lib.wlr_scene_attach_output_layout(self._ptr, output_layout._ptr) + ptr = lib.wlr_scene_attach_output_layout(self._ptr, output_layout._ptr) + if ptr == ffi.NULL: + return None + return OutputLayoutOutput(ptr) def set_presentation(self, presentation: Presentation) -> None: """ From 4d939fa5090d95d8a34299a64f5cb2c63382b1d6 Mon Sep 17 00:00:00 2001 From: mcol Date: Fri, 6 Oct 2023 22:37:36 +0100 Subject: [PATCH 58/68] (wlroots 0fdbdc3) xdg-surface: fix init state flow --- wlroots/ffi_build.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/wlroots/ffi_build.py b/wlroots/ffi_build.py index 6586e6ac..4513cbd3 100644 --- a/wlroots/ffi_build.py +++ b/wlroots/ffi_build.py @@ -2543,7 +2543,6 @@ def has_xwayland() -> bool: struct wlr_xdg_toplevel { struct wl_resource *resource; struct wlr_xdg_surface *base; - bool sent_initial_configure; struct wlr_xdg_toplevel *parent; struct wl_listener parent_unmap; @@ -2607,6 +2606,9 @@ def has_xwayland() -> bool: struct wlr_xdg_surface_state current, pending; + bool initialized; + bool initial_commit; + struct { struct wl_signal destroy; struct wl_signal ping_timeout; From 530c52745a54f978b3ba68949f200487a08adb2a Mon Sep 17 00:00:00 2001 From: mcol Date: Sat, 7 Oct 2023 00:23:54 +0100 Subject: [PATCH 59/68] (wlroots a289f81) drop KDE idle protocol support --- wlroots/ffi_build.py | 68 --------------------------------------- wlroots/wlr_types/idle.py | 67 -------------------------------------- 2 files changed, 135 deletions(-) delete mode 100644 wlroots/wlr_types/idle.py diff --git a/wlroots/ffi_build.py b/wlroots/ffi_build.py index 4513cbd3..6573e5e5 100644 --- a/wlroots/ffi_build.py +++ b/wlroots/ffi_build.py @@ -744,73 +744,6 @@ def has_xwayland() -> bool: struct wl_display *display); """ -# types/wlr_idle.h -CDEF += """ -struct wlr_idle { - struct wl_global *global; - struct wl_list idle_timers; // wlr_idle_timeout::link - struct wl_event_loop *event_loop; - bool enabled; - - struct wl_listener display_destroy; - struct { - struct wl_signal activity_notify; - struct wl_signal destroy; - } events; - - void *data; - ...; -}; - -struct wlr_idle_timeout { - struct wl_resource *resource; - struct wl_list link; - struct wlr_seat *seat; - - struct wl_event_source *idle_source; - bool idle_state; - bool enabled; - uint32_t timeout; // milliseconds - - struct { - struct wl_signal idle; - struct wl_signal resume; - struct wl_signal destroy; - } events; - - struct wl_listener input_listener; - struct wl_listener seat_destroy; - - void *data; - ...; -}; - -struct wlr_idle *wlr_idle_create(struct wl_display *display); - -/** - * Send notification to restart all timers for the given seat. Called by - * compositor when there is an user activity event on that seat. - */ -void wlr_idle_notify_activity(struct wlr_idle *idle, struct wlr_seat *seat); - -/** - * Enable or disable timers for a given idle resource by seat. - * Passing a NULL seat means update timers for all seats. - */ -void wlr_idle_set_enabled(struct wlr_idle *idle, struct wlr_seat *seat, - bool enabled); - -/** - * Create a new timer on the given seat. The idle event will be called after - * the given amount of milliseconds of inactivity, and the resumed event will - * be sent at the first user activity after the fired event. - */ -struct wlr_idle_timeout *wlr_idle_timeout_create(struct wlr_idle *idle, - struct wlr_seat *seat, uint32_t timeout); - -void wlr_idle_timeout_destroy(struct wlr_idle_timeout *timeout); -""" - # types/wlr_input_inhibit_v1.h CDEF += """ struct wlr_idle_inhibit_manager_v1 { @@ -2776,7 +2709,6 @@ def has_xwayland() -> bool: #include #include #include -#include #include #include #include diff --git a/wlroots/wlr_types/idle.py b/wlroots/wlr_types/idle.py deleted file mode 100644 index 2e7414bd..00000000 --- a/wlroots/wlr_types/idle.py +++ /dev/null @@ -1,67 +0,0 @@ -from pywayland.server import Display, Signal - -from wlroots import Ptr, ffi, lib - -from .seat import Seat - - -class IdleTimeout(Ptr): - def __init__(self, ptr) -> None: - self._ptr = ffi.cast("struct wlr_idle_timeout *", ptr) - - self.idle_event = Signal(ptr=ffi.addressof(self._ptr.events.idle)) - self.resume_event = Signal(ptr=ffi.addressof(self._ptr.events.resume)) - self.destroy_event = Signal(ptr=ffi.addressof(self._ptr.events.destroy)) - - @property - def idle_state(self) -> bool: - return self._ptr.idle_state - - @property - def enabled(self) -> bool: - return self._ptr.enabled - - @property - def timeout(self) -> int: - return self._ptr.timeout - - def destroy(self) -> None: - if self._ptr is not None: - ffi.release(self._ptr) - self._ptr = None - - -class Idle(Ptr): - def __init__(self, display: Display) -> None: - self._ptr = lib.wlr_idle_create(display._ptr) - - self.activity_notify_event = Signal( - ptr=ffi.addressof(self._ptr.events.activity_notify) - ) - self.destroy_event = Signal(ptr=ffi.addressof(self._ptr.events.destroy)) - - @property - def enabled(self) -> bool: - return self._ptr.enabled - - def notify_activity(self, seat: Seat) -> None: - """ - Send notification to restart all timers for the given seat. Called by - compositor when there is an user activity event on that seat. - """ - lib.wlr_idle_notify_activity(self._ptr, seat._ptr) - - def set_enabled(self, seat: Seat, enabled: bool): - """ - Enable or disable timers for a given idle resource by seat. - Passing a NULL seat means update timers for all seats. - """ - lib.wlr_idle_set_enabled(self._ptr, seat._ptr, enabled) - - def idle_timeout_create(self, seat: Seat, timeout: int) -> IdleTimeout: - """ - Create a new timer on the given seat. The idle event will be called after - the given amount of milliseconds of inactivity, and the resumed event will - be sent at the first user activity after the fired event. - """ - return IdleTimeout(lib.wlr_idle_timeout_create(self._ptr, seat._ptr, timeout)) From 5c10a6464e0c8c171862f000d7fdb2942cac2af7 Mon Sep 17 00:00:00 2001 From: mcol Date: Fri, 1 Dec 2023 20:33:22 +0000 Subject: [PATCH 60/68] (wlroots bdcf997) xwayland/server: add ready flag --- wlroots/ffi_build.py | 1 + wlroots/xwayland.py | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/wlroots/ffi_build.py b/wlroots/ffi_build.py index 6573e5e5..b624f88b 100644 --- a/wlroots/ffi_build.py +++ b/wlroots/ffi_build.py @@ -2896,6 +2896,7 @@ def has_xwayland() -> bool: struct wl_client *client; struct wl_event_source *pipe_source; int wm_fd[2], wl_fd[2]; + bool ready; time_t server_start; int display; char display_name[16]; diff --git a/wlroots/xwayland.py b/wlroots/xwayland.py index 7d126ab2..7a604ada 100644 --- a/wlroots/xwayland.py +++ b/wlroots/xwayland.py @@ -71,6 +71,10 @@ def __init__(self, display: Display, options: ServerOptions) -> None: self.ready_event = Signal(ptr=ffi.addressof(self._ptr.events.ready)) self.destroy_event = Signal(ptr=ffi.addressof(self._ptr.events.destroy)) + @property + def ready(self) -> bool: + return self._ptr.ready + class XWayland(PtrHasData): def __init__(self, display: Display, compositor: Compositor, lazy: bool) -> None: From e1f658d2b0e13f650dee6ad0b722cc21019f0375 Mon Sep 17 00:00:00 2001 From: mcol Date: Fri, 1 Dec 2023 21:23:47 +0000 Subject: [PATCH 61/68] make xwayland.Surface.surface an optional type --- wlroots/xwayland.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/wlroots/xwayland.py b/wlroots/xwayland.py index 7a604ada..23fa7a96 100644 --- a/wlroots/xwayland.py +++ b/wlroots/xwayland.py @@ -241,7 +241,9 @@ def icccm_input_model(self) -> int: return lib.wlr_xwayland_icccm_input_model(self._ptr) @property - def surface(self) -> WlrSurface: + def surface(self) -> WlrSurface | None: + if self._ptr.surface == ffi.NULL: + return None return WlrSurface(self._ptr.surface) @property From c92c9f6f8c043a3faf48cc5cd602d7b3ab047d24 Mon Sep 17 00:00:00 2001 From: mcol Date: Fri, 1 Dec 2023 21:23:57 +0000 Subject: [PATCH 62/68] add xwayland.Surface associate/dissociate events --- wlroots/xwayland.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/wlroots/xwayland.py b/wlroots/xwayland.py index 23fa7a96..0ff154e6 100644 --- a/wlroots/xwayland.py +++ b/wlroots/xwayland.py @@ -176,6 +176,8 @@ def __init__(self, ptr) -> None: self.request_activate_event = Signal( ptr=ffi.addressof(self._ptr.events.request_activate) ) + self.associate_event = Signal(ptr=ffi.addressof(self._ptr.events.associate)) + self.dissociate_event = Signal(ptr=ffi.addressof(self._ptr.events.dissociate)) self.set_title_event = Signal(ptr=ffi.addressof(self._ptr.events.set_title)) self.set_class_event = Signal(ptr=ffi.addressof(self._ptr.events.set_class)) self.set_role_event = Signal(ptr=ffi.addressof(self._ptr.events.set_role)) From 07d91f3c81342c51e7cb245b7870be165694205b Mon Sep 17 00:00:00 2001 From: mcol Date: Fri, 1 Dec 2023 21:37:07 +0000 Subject: [PATCH 63/68] (wlroots 33b437d) wlr_scene: Amend scene_buffer.point_accepts_input to take coordinate pointers --- wlroots/ffi_build.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wlroots/ffi_build.py b/wlroots/ffi_build.py index b624f88b..71c2ad83 100644 --- a/wlroots/ffi_build.py +++ b/wlroots/ffi_build.py @@ -1636,7 +1636,7 @@ def has_xwayland() -> bool: # types/wlr_scene.h CDEF += """ typedef bool (*wlr_scene_buffer_point_accepts_input_func_t)( - struct wlr_scene_buffer *buffer, int sx, int sy); + struct wlr_scene_buffer *buffer, double *sx, double *sy); typedef void (*wlr_scene_buffer_iterator_func_t)( struct wlr_scene_buffer *buffer, int sx, int sy, void *user_data); extern "Python" void buffer_iterator_callback( From 0be469e5bfc1020b6a0f948f3f69d72e0d10ef7d Mon Sep 17 00:00:00 2001 From: mcol Date: Fri, 1 Dec 2023 21:55:59 +0000 Subject: [PATCH 64/68] ruff --- wlroots/wlr_types/cursor.py | 2 +- wlroots/wlr_types/foreign_toplevel_management_v1.py | 2 +- wlroots/wlr_types/layer_shell_v1.py | 2 +- wlroots/wlr_types/scene.py | 2 +- wlroots/wlr_types/seat.py | 2 +- wlroots/wlr_types/xcursor_manager.py | 2 -- wlroots/wlr_types/xdg_decoration_v1.py | 1 - wlroots/wlr_types/xdg_shell.py | 2 +- 8 files changed, 6 insertions(+), 9 deletions(-) diff --git a/wlroots/wlr_types/cursor.py b/wlroots/wlr_types/cursor.py index 79cbe6f4..90ab97d1 100644 --- a/wlroots/wlr_types/cursor.py +++ b/wlroots/wlr_types/cursor.py @@ -8,6 +8,7 @@ from wlroots import PtrHasData, ffi, lib +from .compositor import Surface from .input_device import InputDevice, InputDeviceType from .output import Output from .output_layout import OutputLayout @@ -25,7 +26,6 @@ PointerSwipeEndEvent, PointerSwipeUpdateEvent, ) -from .compositor import Surface from .touch import ( TouchEventCancel, TouchEventDown, diff --git a/wlroots/wlr_types/foreign_toplevel_management_v1.py b/wlroots/wlr_types/foreign_toplevel_management_v1.py index 25dd9bb9..9e132451 100644 --- a/wlroots/wlr_types/foreign_toplevel_management_v1.py +++ b/wlroots/wlr_types/foreign_toplevel_management_v1.py @@ -10,8 +10,8 @@ from wlroots import Ptr, PtrHasData, ffi, lib -from .output import Output from .compositor import Surface +from .output import Output if TYPE_CHECKING: from pywayland.server import Display diff --git a/wlroots/wlr_types/layer_shell_v1.py b/wlroots/wlr_types/layer_shell_v1.py index 69f771bc..f696102f 100644 --- a/wlroots/wlr_types/layer_shell_v1.py +++ b/wlroots/wlr_types/layer_shell_v1.py @@ -10,8 +10,8 @@ from wlroots import Ptr, PtrHasData, ffi, lib -from .output import Output from .compositor import Surface +from .output import Output from .xdg_shell import SurfaceCallback, T if TYPE_CHECKING: diff --git a/wlroots/wlr_types/scene.py b/wlroots/wlr_types/scene.py index 14c16900..18648293 100644 --- a/wlroots/wlr_types/scene.py +++ b/wlroots/wlr_types/scene.py @@ -7,7 +7,7 @@ from wlroots import Ptr, PtrHasData, ffi, lib from wlroots.util.region import PixmanRegion32 -from wlroots.wlr_types import Surface, OutputLayoutOutput +from wlroots.wlr_types import OutputLayoutOutput, Surface if TYPE_CHECKING: from wlroots.util.box import Box diff --git a/wlroots/wlr_types/seat.py b/wlroots/wlr_types/seat.py index b523166b..449e1e18 100644 --- a/wlroots/wlr_types/seat.py +++ b/wlroots/wlr_types/seat.py @@ -9,11 +9,11 @@ from wlroots import Ptr, PtrHasData, ffi, lib +from .compositor import Surface from .data_device_manager import Drag from .input_device import ButtonState from .keyboard import Keyboard, KeyboardKeyEvent, KeyboardModifiers from .pointer import AxisOrientation, AxisSource -from .compositor import Surface _weakkeydict: WeakKeyDictionary = WeakKeyDictionary() diff --git a/wlroots/wlr_types/xcursor_manager.py b/wlroots/wlr_types/xcursor_manager.py index d8502ffa..7e43fb40 100644 --- a/wlroots/wlr_types/xcursor_manager.py +++ b/wlroots/wlr_types/xcursor_manager.py @@ -6,8 +6,6 @@ from wlroots import Ptr, ffi, lib -from .cursor import Cursor - if TYPE_CHECKING: from typing import Iterator diff --git a/wlroots/wlr_types/xdg_decoration_v1.py b/wlroots/wlr_types/xdg_decoration_v1.py index f6df86ec..adfdeae2 100644 --- a/wlroots/wlr_types/xdg_decoration_v1.py +++ b/wlroots/wlr_types/xdg_decoration_v1.py @@ -10,7 +10,6 @@ from wlroots import PtrHasData, ffi, lib -from .compositor import Surface from .xdg_shell import XdgTopLevel if TYPE_CHECKING: diff --git a/wlroots/wlr_types/xdg_shell.py b/wlroots/wlr_types/xdg_shell.py index 9e53b032..c7396bfc 100644 --- a/wlroots/wlr_types/xdg_shell.py +++ b/wlroots/wlr_types/xdg_shell.py @@ -12,8 +12,8 @@ from wlroots.util.box import Box from wlroots.util.edges import Edges -from .output import Output from .compositor import Surface +from .output import Output _weakkeydict: weakref.WeakKeyDictionary = weakref.WeakKeyDictionary() From 8f145ca576c495a0d9ca6dc3c3cfb661139bb52b Mon Sep 17 00:00:00 2001 From: mcol Date: Fri, 1 Dec 2023 21:58:55 +0000 Subject: [PATCH 65/68] misc type fixes --- wlroots/xwayland.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/wlroots/xwayland.py b/wlroots/xwayland.py index 0ff154e6..c6853a87 100644 --- a/wlroots/xwayland.py +++ b/wlroots/xwayland.py @@ -364,7 +364,8 @@ def for_each_surface( The iterator is called using the only wlr_surface and it's local coordinates. """ - iterator(self.surface, 0, 0, data) + if surface := self.surface: + iterator(surface, 0, 0, data) class SurfaceConfigureEvent(Ptr): From bbaf58045feffb5a766404a4367f5572a7099bd6 Mon Sep 17 00:00:00 2001 From: mcol Date: Fri, 1 Dec 2023 22:44:49 +0000 Subject: [PATCH 66/68] update tinywl --- tiny/server.py | 39 ++++++++++++++++++++++++++++----------- tiny/view.py | 4 ++-- 2 files changed, 30 insertions(+), 13 deletions(-) diff --git a/tiny/server.py b/tiny/server.py index 18cea1ee..7422430d 100644 --- a/tiny/server.py +++ b/tiny/server.py @@ -22,9 +22,11 @@ Keyboard, Output, OutputLayout, + OutputState, Scene, SceneBuffer, SceneNodeType, + SceneOutput, SceneSurface, SceneTree, Seat, @@ -51,6 +53,7 @@ if TYPE_CHECKING: from wlroots.wlr_types import InputDevice from wlroots.wlr_types.keyboard import KeyboardKeyEvent, KeyboardModifiers + from wlroots.wlr_types.output import OutputEventRequestState _weakkeydict: WeakKeyDictionary = WeakKeyDictionary() @@ -213,7 +216,7 @@ def process_cursor_motion(self, time) -> None: logging.debug("Processing cursor motion: %s, %s", sx, sy) if view is None: - self._cursor_manager.set_cursor_image("left_ptr", self._cursor) + self._cursor.set_xcursor(self._cursor_manager, "default") if surface is None: # Clear pointer focus so future button events and such are not sent @@ -289,8 +292,8 @@ def focus_view(self, view: View, surface: Surface | None = None) -> None: if previous_surface is not None: # Deactivate the previously focused surface logging.info("Un-focusing previous") - previous_xdg_surface = XdgSurface.from_surface(previous_surface) - previous_xdg_surface.set_activated(False) + if previous_xdg_surface := XdgSurface.try_from_surface(previous_surface): + previous_xdg_surface.set_activated(False) view.scene_node.raise_to_top() # roll the given surface to the front of the list, copy and modify the @@ -322,10 +325,12 @@ def server_new_xdg_surface(self, listener, xdg_surface: XdgSurface) -> None: # we must provide the proper parent scene node of the xdg popup. To # enable this, we always set the user data field of xdg_surfaces to # the corresponding scene node. - parent_xdg_surface = XdgSurface.from_surface(xdg_surface.popup.parent) - parent_scene_tree = cast(SceneTree, parent_xdg_surface.data) - scene_tree = Scene.xdg_surface_create(parent_scene_tree, xdg_surface) - xdg_surface.data = scene_tree + if parent_xdg_surface := XdgSurface.try_from_surface( + xdg_surface.popup.parent + ): + parent_scene_tree = cast(SceneTree, parent_xdg_surface.data) + scene_tree = Scene.xdg_surface_create(parent_scene_tree, xdg_surface) + xdg_surface.data = scene_tree return assert xdg_surface.role == XdgSurfaceRole.TOPLEVEL @@ -344,16 +349,24 @@ def server_new_xdg_surface(self, listener, xdg_surface: XdgSurface) -> None: # output and frame handling callbacks def server_new_output(self, listener, output: Output) -> None: + SceneOutput.create(self._scene, output) output.init_render(self._allocator, self._renderer) - output.set_mode(output.preferred_mode()) - output.enable() - output.commit() + state = OutputState() + state.set_enabled() + if mode := output.preferred_mode(): + state.set_mode(mode) + + output.commit_state(state) + state.finish() self.outputs.append(output) - self._output_layout.add_auto(output) + if not self._output_layout.add_auto(output): + logging.warning("Failed to add output to layout.") + return output.frame_event.add(Listener(self.output_frame)) + output.request_state_event.add(Listener(self.output_request_state)) def output_frame(self, listener, data) -> None: output = self.outputs[0] @@ -363,6 +376,10 @@ def output_frame(self, listener, data) -> None: now = Timespec.get_monotonic_time() scene_output.send_frame_done(now) + def output_request_state(self, listener, request: OutputEventRequestState) -> None: + output = self.outputs[0] + output.commit_state(request.state) + # ############################################################# # input handling callbacks diff --git a/tiny/view.py b/tiny/view.py index 82266b3d..7089e523 100644 --- a/tiny/view.py +++ b/tiny/view.py @@ -31,8 +31,8 @@ def __init__( self.x = 0.0 self.y = 0.0 - xdg_surface.map_event.add(Listener(self.xdg_toplevel_map)) - xdg_surface.unmap_event.add(Listener(self.xdg_toplevel_unmap)) + xdg_surface.surface.map_event.add(Listener(self.xdg_toplevel_map)) + xdg_surface.surface.unmap_event.add(Listener(self.xdg_toplevel_unmap)) xdg_surface.destroy_event.add(Listener(self.xdg_toplevel_destroy)) toplevel = xdg_surface.toplevel From 84f7dfb986f141bd8ae0d33bded50a651db84c8a Mon Sep 17 00:00:00 2001 From: mcol Date: Fri, 1 Dec 2023 22:55:22 +0000 Subject: [PATCH 67/68] bump wlroots version to 0.17 in CI --- .github/workflows/ci.yml | 8 ++++---- .github/workflows/release.yml | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index da0928e8..fc08fdd1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,7 +20,7 @@ jobs: strategy: fail-fast: false matrix: - wlroots-version: ["0.16.2", master] + wlroots-version: ["0.17.0", master] steps: - name: Install dependencies run: | @@ -147,7 +147,7 @@ jobs: - "pypy-3.8" - "pypy-3.9" - "pypy-3.10" - wlroots-version: ["0.16.2"] + wlroots-version: ["0.17.0"] include: - python-version: "3.12" wlroots-version: master @@ -262,7 +262,7 @@ jobs: needs: build-wayland env: python-version: "3.12" - wlroots-version: "0.16.2" + wlroots-version: "0.17.0" steps: - name: Download wayland libraries uses: actions/download-artifact@v3 @@ -298,7 +298,7 @@ jobs: needs: build-wayland env: python-version: "3.12" - wlroots-version: "0.16.2" + wlroots-version: "0.17.0" steps: - name: Download wayland libraries uses: actions/download-artifact@v3 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index fb637b96..d464b7d4 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -13,9 +13,9 @@ jobs: libdrm-version: "2.4.114" seatd-version: "0.6.3" pixman-version: "0.42.0" - wayland-protocols-version: "1.31" + wayland-protocols-version: "1.32" wayland-version: "1.22.0" - wlroots-version: "0.16.2" + wlroots-version: "0.17.0" steps: - name: Install dependencies run: | From 24ab9b2337a406197444ee2cd51804bd0c307324 Mon Sep 17 00:00:00 2001 From: mcol Date: Fri, 1 Dec 2023 23:08:14 +0000 Subject: [PATCH 68/68] bump protocols version in CI --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fc08fdd1..4b06089e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,7 +16,7 @@ jobs: pixman-version: "0.42.0" hwdata-version: "0.364" wayland-version: "1.22.0" - wayland-protocols-version: "1.31" + wayland-protocols-version: "1.32" strategy: fail-fast: false matrix: