~emersion/public-inbox

kanshi: Forget current profile on match_and_apply failure v1 APPLIED

Andrew J. Hesford: 1
 Forget current profile on match_and_apply failure

 1 files changed, 8 insertions(+), 2 deletions(-)
#1127105 .build.yml success
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~emersion/public-inbox/patches/48294/mbox | git am -3
Learn more about email & git

[PATCH kanshi] Forget current profile on match_and_apply failure Export this patch

When an output changes and match_and_apply() attempts to match a new
profile, any failure to match (or apply) a new profile would prevent
re-application of any previously matched profile, even if it matches
after a subsequent output change. The right conceptual behavior is to
forget a no-longer-applicable profile after match_and_apply fails, which
fixes this issue.

Fixes: https://todo.sr.ht/~emersion/kanshi/100

---
 main.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/main.c b/main.c
index c7cdd9d..b028d1f 100644
--- a/main.c
+++ b/main.c
@@ -539,9 +539,15 @@ static bool match_and_apply(struct kanshi_state *state,
	}
	struct kanshi_profile *profile = match(state, matches);
	if (profile != NULL) {
		return apply_profile(state, profile, matches, callback, data);
		if (apply_profile(state, profile, matches, callback, data)) {
			return true;
		}
	} else {
		fprintf(stderr, "no profile matched\n");
	}
	fprintf(stderr, "no profile matched\n");

	// If a profile failed to match or apply, forget the current profile
	state->current_profile = NULL;
	return false;
}

-- 
2.43.0
kanshi/patches/.build.yml: SUCCESS in 27s

[Forget current profile on match_and_apply failure][0] from [Andrew J. Hesford][1]

[0]: https://lists.sr.ht/~emersion/public-inbox/patches/48294
[1]: mailto:ajh@sideband.org

✓ #1127105 SUCCESS kanshi/patches/.build.yml https://builds.sr.ht/~emersion/job/1127105
Pushed with a small edit to expand the comment. Thanks!