~emersion/public-inbox

Add --query option and remove heads on quit v1 NEEDS REVISION

Petro Mozil: 1
 Add --query option and remove heads on quit

 1 files changed, 8 insertions(+), 6 deletions(-)
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/34638/mbox | git am -3
Learn more about email & git

[PATCH] Add --query option and remove heads on quit Export this patch

---
 main.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/main.c b/main.c
index 87f94af..3f4b6c4 100644
--- a/main.c
+++ b/main.c
@@ -420,6 +420,7 @@ static const struct option long_options[] = {
	{"pos", required_argument, 0, 0},
	{"transform", required_argument, 0, 0},
	{"scale", required_argument, 0, 0},
    {"query", no_argument, 0, 0},
	{0},
};

@@ -661,7 +662,7 @@ int main(int argc, char *argv[]) {
		}
	}

	bool changed = false, dry_run = false;
	bool changed = false, dry_run = false, query = false;
	struct randr_head *current_head = NULL;
	while (1) {
		int option_index = -1;
@@ -673,7 +674,7 @@ int main(int argc, char *argv[]) {
		} else if (c == 'h') {
			fprintf(stderr, "%s", usage);
			return EXIT_SUCCESS;
		}
        }

		const char *name = long_options[option_index].name;
		const char *value = optarg;
@@ -691,7 +692,9 @@ int main(int argc, char *argv[]) {
			}
		} else if (strcmp(name, "dryrun") == 0) {
			dry_run = true;
		} else { // output sub-option
		} else if (strcmp(name, "query") == 0) {
            query = true;
        } else { // output sub-option
			if (current_head == NULL) {
				fprintf(stderr, "no --output specified before --%s\n", name);
				return EXIT_FAILURE;
@@ -707,15 +710,14 @@ int main(int argc, char *argv[]) {

	if (changed) {
		apply_state(&state, dry_run);
	} else {
	} 
    if(!changed||query) {
		print_state(&state);
	}

	while (state.running && wl_display_dispatch(display) != -1) {
		// This space intentionally left blank
	}

	// TODO: destroy heads
	zwlr_output_manager_v1_destroy(state.output_manager);
	wl_registry_destroy(registry);
	wl_display_disconnect(display);
-- 
2.37.1
Code looks good, needs an update to fixup the code style, see below.

Can you also drop "and remove heads on quit" from the commit message?

On Saturday, August 13th, 2022 at 13:46, Petro Mozil <mozil.petryk@gmail.com> wrote: