diff options
| -rw-r--r-- | args.c | 8 | ||||
| -rw-r--r-- | layer_surface.c | 6 | ||||
| -rw-r--r-- | state.h | 1 | ||||
| -rwxr-xr-x | swenu-run.sh | 2 |
4 files changed, 12 insertions, 5 deletions
@@ -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 @@ -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) |
