cage: allow setting output mode

This commit is contained in:
Jente Hidskes 2020-05-31 16:20:59 +02:00
parent 72f6c0bae3
commit bd961db6f5
2 changed files with 24 additions and 12 deletions

View file

@ -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* <mode>
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.

29
cage.c
View file

@ -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