SceneNodeData: fix fromNode()
This currently fails to check the node passed and skips directly to the parent.
This commit is contained in:
parent
7ee6c79b6b
commit
6bfaf62cef
@ -51,13 +51,17 @@ pub fn attach(node: *wlr.SceneNode, data: Data) error{OutOfMemory}!void {
|
||||
}
|
||||
|
||||
pub fn fromNode(node: *wlr.SceneNode) ?*SceneNodeData {
|
||||
var it: ?*wlr.SceneTree = node.parent;
|
||||
while (it) |tree| : (it = tree.node.parent) {
|
||||
if (@as(?*SceneNodeData, @ptrFromInt(tree.node.data))) |scene_node_data| {
|
||||
var n = node;
|
||||
while (true) {
|
||||
if (@as(?*SceneNodeData, @ptrFromInt(n.data))) |scene_node_data| {
|
||||
return scene_node_data;
|
||||
}
|
||||
}
|
||||
if (n.parent) |parent_tree| {
|
||||
n = &parent_tree.node;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn fromSurface(surface: *wlr.Surface) ?*SceneNodeData {
|
||||
|
Loading…
Reference in New Issue
Block a user