From 13a4fb3c9aa6f6c6f0d2f6fe496fa2bfbeb3d656 Mon Sep 17 00:00:00 2001 From: Jeroen Wijenbergh Date: Sun, 12 May 2024 15:26:50 +0200 Subject: [PATCH] Wlroots SceneTree: Add a children iterator --- wlroots/wlr_types/scene.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/wlroots/wlr_types/scene.py b/wlroots/wlr_types/scene.py index 9e73a524..3972e700 100644 --- a/wlroots/wlr_types/scene.py +++ b/wlroots/wlr_types/scene.py @@ -5,11 +5,15 @@ import enum from typing import TYPE_CHECKING, Callable, TypeVar +from pywayland.utils import wl_list_for_each + from wlroots import Ptr, PtrHasData, ffi, lib from wlroots.util.region import PixmanRegion32 from wlroots.wlr_types import OutputLayoutOutput, Surface if TYPE_CHECKING: + from typing import Iterator + from wlroots.util.box import Box from wlroots.util.clock import Timespec from wlroots.wlr_types import Buffer, Output, OutputLayout @@ -145,6 +149,16 @@ def subsurface_tree_create(cls, parent: SceneTree, surface: Surface) -> SceneTre def drag_icon_create(cls, parent: SceneTree, drag_icon: DragIcon) -> SceneTree: return SceneTree(lib.wlr_scene_drag_icon_create(parent._ptr, drag_icon._ptr)) + @property + def children(self) -> Iterator[SceneNode]: + for ptr in wl_list_for_each( + "struct wlr_scene_node *", + self._ptr.children, + "link", + ffi=ffi, + ): + yield SceneNode(ptr) + class SceneBuffer(Ptr): def __init__(self, ptr) -> None: