aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJack Jamison <jackqjamison@gmail.com>2025-10-18 13:16:02 -0400
committerJack Jamison <jackqjamison@gmail.com>2025-10-18 13:16:02 -0400
commit6cd7b5b05ee32be426d7e010b0c56603d0e228c8 (patch)
tree65b36bd6db774a63de7b86f4eadb647911478629
parentacef4398df70b984ad6f2f403b2fa55c72219c73 (diff)
center option
-rw-r--r--args.c8
-rw-r--r--layer_surface.c6
-rw-r--r--state.h1
-rwxr-xr-xswenu-run.sh2
4 files changed, 12 insertions, 5 deletions
diff --git a/args.c b/args.c
index 5fbc381..1967a24 100644
--- a/args.c
+++ b/args.c
@@ -8,17 +8,21 @@
void parse_args(client_state* state, int argc, char* argv[]) {
static struct option long_opts[] = {
{"lines", required_argument, 0, 'l'},
- {"allow-free-result", required_argument, 0, 'a'},
+ {"center", no_argument, 0, 'c'},
+ {"allow-free-result", no_argument, 0, 'a'},
{0, 0, 0, 0}
};
int opt;
int long_index = 0;
- while ((opt = getopt_long(argc, argv, "l:a", long_opts, &long_index)) != -1) {
+ while ((opt = getopt_long(argc, argv, "l:ca", long_opts, &long_index)) != -1) {
switch (opt) {
case 'l':
state->lines = atoi(optarg);
break;
+ case 'c':
+ state->center = true;
+ break;
case 'a':
state->allow_free_result = true;
break;
diff --git a/layer_surface.c b/layer_surface.c
index 936e1ab..bf17d45 100644
--- a/layer_surface.c
+++ b/layer_surface.c
@@ -8,16 +8,18 @@ void create_surface(client_state* state) {
uint32_t anchor = ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP |
ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT |
ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT;
- if (state->lines > 0) {
+ if (state->center) {
anchor |= ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM;
}
// figure out size
uint32_t desired_width = 0;
uint32_t desired_height = state->line_height;
+ if (state->center) {
+ desired_width = MAX(state->required_width, min_width);
+ }
if (state->lines > 0) {
desired_height = (state->lines + 1) * state->line_height;
- desired_width = MAX(state->required_width, min_width);
}
// create surface
diff --git a/state.h b/state.h
index 6940d0d..00adbc3 100644
--- a/state.h
+++ b/state.h
@@ -95,6 +95,7 @@ typedef struct {
// arguments
int lines;
bool allow_free_result;
+ bool center;
// state
char* input_buffer;
diff --git a/swenu-run.sh b/swenu-run.sh
index 8dd9daf..0e25c3d 100755
--- a/swenu-run.sh
+++ b/swenu-run.sh
@@ -6,4 +6,4 @@ exec $(
for file in "$dir"/*; do
[ -f "$file" ] && [ -x "$file" ] && printf '%s\n' "${file##*/}"
done
- done | sort -u | ./swenu -al 10)
+ done | sort -u | ./swenu -cal 10)