gtk: simplify Wayland output-order state handling
parent
c982253543
commit
18fa161222
|
|
@ -54,10 +54,6 @@ pub const App = struct {
|
||||||
/// Initialized to true so the first event after binding is captured.
|
/// Initialized to true so the first event after binding is captured.
|
||||||
output_order_done: bool = true,
|
output_order_done: bool = true,
|
||||||
|
|
||||||
/// True if we've received an `output` event in the current cycle.
|
|
||||||
/// This lets us detect empty cycles and clear stale cached state.
|
|
||||||
output_order_seen_output: bool = false,
|
|
||||||
|
|
||||||
default_deco_mode: ?org.KdeKwinServerDecorationManager.Mode = null,
|
default_deco_mode: ?org.KdeKwinServerDecorationManager.Mode = null,
|
||||||
|
|
||||||
xdg_activation: ?*xdg.ActivationV1 = null,
|
xdg_activation: ?*xdg.ActivationV1 = null,
|
||||||
|
|
@ -243,6 +239,13 @@ pub const App = struct {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Reset cached state derived from kde_output_order_v1.
|
||||||
|
fn resetOutputOrderState(context: *Context) void {
|
||||||
|
context.primary_output_name = null;
|
||||||
|
context.primary_output_match_failed_logged = false;
|
||||||
|
context.output_order_done = true;
|
||||||
|
}
|
||||||
|
|
||||||
fn registryListener(
|
fn registryListener(
|
||||||
registry: *wl.Registry,
|
registry: *wl.Registry,
|
||||||
event: wl.Registry.Event,
|
event: wl.Registry.Event,
|
||||||
|
|
@ -315,6 +318,12 @@ pub const App = struct {
|
||||||
.{ v.interface, existing_global_name orelse 0, v.name },
|
.{ v.interface, existing_global_name orelse 0, v.name },
|
||||||
);
|
);
|
||||||
old.destroy();
|
old.destroy();
|
||||||
|
|
||||||
|
if (comptime std.mem.eql(u8, field.name, "kde_output_order")) {
|
||||||
|
// Replacement means the previous primary may be stale
|
||||||
|
// until the new object sends a fresh cycle.
|
||||||
|
resetOutputOrderState(context);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@field(context, field.name) = global;
|
@field(context, field.name) = global;
|
||||||
|
|
@ -352,10 +361,7 @@ pub const App = struct {
|
||||||
@field(context, name_field) = null;
|
@field(context, name_field) = null;
|
||||||
|
|
||||||
if (comptime std.mem.eql(u8, field.name, "kde_output_order")) {
|
if (comptime std.mem.eql(u8, field.name, "kde_output_order")) {
|
||||||
context.primary_output_name = null;
|
resetOutputOrderState(context);
|
||||||
context.primary_output_match_failed_logged = false;
|
|
||||||
context.output_order_done = true;
|
|
||||||
context.output_order_seen_output = false;
|
|
||||||
}
|
}
|
||||||
break :remove;
|
break :remove;
|
||||||
}
|
}
|
||||||
|
|
@ -396,7 +402,6 @@ pub const App = struct {
|
||||||
// Only the first output event after a `done` is the new primary.
|
// Only the first output event after a `done` is the new primary.
|
||||||
if (!context.output_order_done) return;
|
if (!context.output_order_done) return;
|
||||||
context.output_order_done = false;
|
context.output_order_done = false;
|
||||||
context.output_order_seen_output = true;
|
|
||||||
// A new primary invalidates any cached match-failure state.
|
// A new primary invalidates any cached match-failure state.
|
||||||
context.primary_output_match_failed_logged = false;
|
context.primary_output_match_failed_logged = false;
|
||||||
|
|
||||||
|
|
@ -415,14 +420,13 @@ pub const App = struct {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
.done => {
|
.done => {
|
||||||
// An empty update means the compositor currently reports no
|
if (context.output_order_done) {
|
||||||
// outputs in priority order, so drop any stale cached primary.
|
// No output arrived since the previous done. Treat this as
|
||||||
if (!context.output_order_seen_output) {
|
// an empty update and drop any stale cached primary.
|
||||||
context.primary_output_name = null;
|
resetOutputOrderState(context);
|
||||||
context.primary_output_match_failed_logged = false;
|
return;
|
||||||
}
|
}
|
||||||
context.output_order_done = true;
|
context.output_order_done = true;
|
||||||
context.output_order_seen_output = false;
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -661,14 +661,10 @@ fn addGtkNg(
|
||||||
.optimize = optimize,
|
.optimize = optimize,
|
||||||
})) |gtk4_layer_shell| {
|
})) |gtk4_layer_shell| {
|
||||||
const layer_shell_module = gtk4_layer_shell.module("gtk4-layer-shell");
|
const layer_shell_module = gtk4_layer_shell.module("gtk4-layer-shell");
|
||||||
if (gobject_) |gobject| layer_shell_module.addImport(
|
if (gobject_) |gobject| {
|
||||||
"gtk",
|
layer_shell_module.addImport("gtk", gobject.module("gtk4"));
|
||||||
gobject.module("gtk4"),
|
layer_shell_module.addImport("gdk", gobject.module("gdk4"));
|
||||||
);
|
}
|
||||||
if (gobject_) |gobject| layer_shell_module.addImport(
|
|
||||||
"gdk",
|
|
||||||
gobject.module("gdk4"),
|
|
||||||
);
|
|
||||||
step.root_module.addImport(
|
step.root_module.addImport(
|
||||||
"gtk4-layer-shell",
|
"gtk4-layer-shell",
|
||||||
layer_shell_module,
|
layer_shell_module,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue