gtk: improve signal handler management

Instead of making two separate passes over the surfaces in a split tree
to manage signal handlers, do it in one pass.
pull/9001/head
Jeffrey C. Ollie 2025-10-02 17:18:08 -05:00
parent 10adef3092
commit c8ed3031bc
No known key found for this signature in database
GPG Key ID: 1BB9EB7EA602265B
1 changed files with 13 additions and 4 deletions

View File

@ -693,14 +693,23 @@ pub const Window = extern struct {
self: *Self,
tree: *const Surface.Tree,
) void {
// Ensure that all old signal handlers have been removed before adding
// them. Otherwise we get duplicate surface handlers.
self.disconnectSurfaceHandlers(tree);
const priv = self.private();
var it = tree.iterator();
while (it.next()) |entry| {
const surface = entry.view;
// Before adding any new signal handlers, disconnect any that we may
// have added before. Otherwise we may get multiple handlers for the
// same signal.
_ = gobject.signalHandlersDisconnectMatched(
surface.as(gobject.Object),
.{ .data = true },
0,
0,
null,
null,
self,
);
_ = Surface.signals.@"present-request".connect(
surface,
*Self,