From d2d3a19e28177d0fe9c72c40b629f3a3a16aa0d0 Mon Sep 17 00:00:00 2001 From: Jente Hidskes Date: Sun, 31 May 2020 16:20:59 +0200 Subject: [PATCH] cage: allow setting output mode --- cage.1.scd | 7 ++++++- cage.c | 29 ++++++++++++++++++----------- 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/cage.1.scd b/cage.1.scd index 2ca43bc..51714a3 100644 --- a/cage.1.scd +++ b/cage.1.scd @@ -6,7 +6,7 @@ cage - a Wayland kiosk compsitor # SYNOPSIS -*cage* [-dhrv] [--] _application_ [application argument ...] +*cage* [-dhmrv] [--] _application_ [application argument ...] # DESCRIPTION @@ -22,6 +22,11 @@ activities outside the scope of the running application are prevented. *-h* Show the help message. +*-m* + Set the multi-monitor behaviour. Supported modes are: + *last* Cage uses only the last connected monitor. + *extend* Cage extends the display across all connected monitors. + *-r* Rotate the output 90 degrees clockwise. This can be specifed up to three times, each resulting in an additional 90 degrees clockwise rotation. diff --git a/cage.c b/cage.c index 541c1c2..6853587 100644 --- a/cage.c +++ b/cage.c @@ -185,11 +185,13 @@ usage(FILE *file, const char *cage) "Usage: %s [OPTIONS] [--] APPLICATION\n" "\n" " -d\t Don't draw client side decorations, when possible\n" - " -r\t Rotate the output 90 degrees clockwise, specify up to three times\n" #ifdef DEBUG " -D\t Turn on damage tracking debugging\n" #endif " -h\t Display this help message\n" + " -m extend Extend the display across all connected outputs (default)\n" + " -m last Use only the last connected output\n" + " -r\t Rotate the output 90 degrees clockwise, specify up to three times\n" " -v\t Show the version number and exit\n" "\n" " Use -- when you want to pass arguments to APPLICATION\n", @@ -201,20 +203,14 @@ parse_args(struct cg_server *server, int argc, char *argv[]) { int c; #ifdef DEBUG - while ((c = getopt(argc, argv, "drDhv")) != -1) { + while ((c = getopt(argc, argv, "dDhm:rv")) != -1) { #else - while ((c = getopt(argc, argv, "drhv")) != -1) { + while ((c = getopt(argc, argv, "dhm:rv")) != -1) { #endif switch (c) { case 'd': server->xdg_decoration = true; break; - case 'r': - server->output_transform++; - if (server->output_transform > WL_OUTPUT_TRANSFORM_270) { - server->output_transform = WL_OUTPUT_TRANSFORM_NORMAL; - } - break; #ifdef DEBUG case 'D': server->debug_damage_tracking = true; @@ -223,6 +219,19 @@ parse_args(struct cg_server *server, int argc, char *argv[]) case 'h': usage(stdout, argv[0]); return false; + case 'm': + if (strcmp(optarg, "last") == 0) { + server->output_mode = CAGE_MULTI_OUTPUT_MODE_LAST; + } else if (strcmp(optarg, "extend") == 0) { + server->output_mode = CAGE_MULTI_OUTPUT_MODE_EXTEND; + } + break; + case 'r': + server->output_transform++; + if (server->output_transform > WL_OUTPUT_TRANSFORM_270) { + server->output_transform = WL_OUTPUT_TRANSFORM_NORMAL; + } + break; case 'v': fprintf(stdout, "Cage version " CAGE_VERSION "\n"); exit(0); @@ -270,8 +279,6 @@ main(int argc, char *argv[]) return 1; } - server.output_mode = CAGE_MULTI_OUTPUT_MODE_EXTEND; - #ifdef DEBUG wlr_log_init(WLR_DEBUG, NULL); #else