gtk(wayland): bind globals correctly (#8110)

This commit is contained in:
Leah Amelia Chen
2025-07-31 18:28:05 +02:00
committed by GitHub
2 changed files with 48 additions and 28 deletions

View File

@ -157,11 +157,19 @@ pub const App = struct {
const ctx_fields = @typeInfo(Context).@"struct".fields; const ctx_fields = @typeInfo(Context).@"struct".fields;
switch (event) { switch (event) {
.global => |v| global: { .global => |v| {
log.debug("found global {s}", .{v.interface});
// We don't actually do anything with this other than checking // We don't actually do anything with this other than checking
// for its existence, so we process this separately. // for its existence, so we process this separately.
if (std.mem.orderZ(u8, v.interface, "xdg_wm_dialog_v1") == .eq) if (std.mem.orderZ(
u8,
v.interface,
"xdg_wm_dialog_v1",
) == .eq) {
context.xdg_wm_dialog_present = true; context.xdg_wm_dialog_present = true;
return;
}
inline for (ctx_fields) |field| { inline for (ctx_fields) |field| {
const T = getInterfaceType(field) orelse continue; const T = getInterfaceType(field) orelse continue;
@ -170,19 +178,21 @@ pub const App = struct {
u8, u8,
v.interface, v.interface,
T.interface.name, T.interface.name,
) != .eq) break :global; ) == .eq) {
log.debug("matched {}", .{T});
@field(context, field.name) = registry.bind( @field(context, field.name) = registry.bind(
v.name, v.name,
T, T,
T.generated_version, T.generated_version,
) catch |err| { ) catch |err| {
log.warn( log.warn(
"error binding interface {s} error={}", "error binding interface {s} error={}",
.{ v.interface, err }, .{ v.interface, err },
); );
return; return;
}; };
}
} }
}, },

View File

@ -157,11 +157,19 @@ pub const App = struct {
const ctx_fields = @typeInfo(Context).@"struct".fields; const ctx_fields = @typeInfo(Context).@"struct".fields;
switch (event) { switch (event) {
.global => |v| global: { .global => |v| {
log.debug("found global {s}", .{v.interface});
// We don't actually do anything with this other than checking // We don't actually do anything with this other than checking
// for its existence, so we process this separately. // for its existence, so we process this separately.
if (std.mem.orderZ(u8, v.interface, "xdg_wm_dialog_v1") == .eq) if (std.mem.orderZ(
u8,
v.interface,
"xdg_wm_dialog_v1",
) == .eq) {
context.xdg_wm_dialog_present = true; context.xdg_wm_dialog_present = true;
return;
}
inline for (ctx_fields) |field| { inline for (ctx_fields) |field| {
const T = getInterfaceType(field) orelse continue; const T = getInterfaceType(field) orelse continue;
@ -170,19 +178,21 @@ pub const App = struct {
u8, u8,
v.interface, v.interface,
T.interface.name, T.interface.name,
) != .eq) break :global; ) == .eq) {
log.debug("matched {}", .{T});
@field(context, field.name) = registry.bind( @field(context, field.name) = registry.bind(
v.name, v.name,
T, T,
T.generated_version, T.generated_version,
) catch |err| { ) catch |err| {
log.warn( log.warn(
"error binding interface {s} error={}", "error binding interface {s} error={}",
.{ v.interface, err }, .{ v.interface, err },
); );
return; return;
}; };
}
} }
}, },