Added null handling for findCustom
parent
7e0dc09873
commit
bb246b2e0c
|
|
@ -2022,18 +2022,19 @@ const Action = struct {
|
||||||
const glist = gtk.Window.listToplevels();
|
const glist = gtk.Window.listToplevels();
|
||||||
defer glist.free();
|
defer glist.free();
|
||||||
|
|
||||||
const node = glist.findCustom(null, findActiveWindow);
|
const node = @as(?*glib.List, glist.findCustom(null, findActiveWindow));
|
||||||
|
|
||||||
const target_node = switch (direction) {
|
const target_node = if (node) |n| switch (direction) {
|
||||||
.next => node.f_next orelse glist,
|
.next => n.f_next orelse glist,
|
||||||
.previous => node.f_prev orelse last: {
|
.previous => n.f_prev orelse last: {
|
||||||
var current = glist;
|
var current = glist;
|
||||||
while (current.f_next) |next| {
|
while (current.f_next) |next| {
|
||||||
current = next;
|
current = next;
|
||||||
}
|
}
|
||||||
break :last current;
|
break :last current;
|
||||||
},
|
},
|
||||||
};
|
} else glist;
|
||||||
|
|
||||||
const data = target_node.f_data orelse return false;
|
const data = target_node.f_data orelse return false;
|
||||||
const gtk_window: *gtk.Window = @ptrCast(@alignCast(data));
|
const gtk_window: *gtk.Window = @ptrCast(@alignCast(data));
|
||||||
gtk.Window.present(gtk_window);
|
gtk.Window.present(gtk_window);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue