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 {
|
pub fn fromNode(node: *wlr.SceneNode) ?*SceneNodeData {
|
||||||
var it: ?*wlr.SceneTree = node.parent;
|
var n = node;
|
||||||
while (it) |tree| : (it = tree.node.parent) {
|
while (true) {
|
||||||
if (@as(?*SceneNodeData, @ptrFromInt(tree.node.data))) |scene_node_data| {
|
if (@as(?*SceneNodeData, @ptrFromInt(n.data))) |scene_node_data| {
|
||||||
return scene_node_data;
|
return scene_node_data;
|
||||||
}
|
}
|
||||||
|
if (n.parent) |parent_tree| {
|
||||||
|
n = &parent_tree.node;
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn fromSurface(surface: *wlr.Surface) ?*SceneNodeData {
|
pub fn fromSurface(surface: *wlr.Surface) ?*SceneNodeData {
|
||||||
|
Loading…
Reference in New Issue
Block a user