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 # SYNOPSIS
*cage* [-dhrv] [--] _application_ [application argument ...] *cage* [-dhmrv] [--] _application_ [application argument ...]
# DESCRIPTION # DESCRIPTION
@ -22,6 +22,11 @@ activities outside the scope of the running application are prevented.
*-h* *-h*
Show the help message. 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* *-r*
Rotate the output 90 degrees clockwise. This can be specifed up to three Rotate the output 90 degrees clockwise. This can be specifed up to three
times, each resulting in an additional 90 degrees clockwise rotation. 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" "Usage: %s [OPTIONS] [--] APPLICATION\n"
"\n" "\n"
" -d\t Don't draw client side decorations, when possible\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 #ifdef DEBUG
" -D\t Turn on damage tracking debugging\n" " -D\t Turn on damage tracking debugging\n"
#endif #endif
" -h\t Display this help message\n" " -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" " -v\t Show the version number and exit\n"
"\n" "\n"
" Use -- when you want to pass arguments to APPLICATION\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; int c;
#ifdef DEBUG #ifdef DEBUG
while ((c = getopt(argc, argv, "drDhv")) != -1) { while ((c = getopt(argc, argv, "dDhm:rv")) != -1) {
#else #else
while ((c = getopt(argc, argv, "drhv")) != -1) { while ((c = getopt(argc, argv, "dhm:rv")) != -1) {
#endif #endif
switch (c) { switch (c) {
case 'd': case 'd':
server->xdg_decoration = true; server->xdg_decoration = true;
break; break;
case 'r':
server->output_transform++;
if (server->output_transform > WL_OUTPUT_TRANSFORM_270) {
server->output_transform = WL_OUTPUT_TRANSFORM_NORMAL;
}
break;
#ifdef DEBUG #ifdef DEBUG
case 'D': case 'D':
server->debug_damage_tracking = true; server->debug_damage_tracking = true;
@ -223,6 +219,19 @@ parse_args(struct cg_server *server, int argc, char *argv[])
case 'h': case 'h':
usage(stdout, argv[0]); usage(stdout, argv[0]);
return false; 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': case 'v':
fprintf(stdout, "Cage version " CAGE_VERSION "\n"); fprintf(stdout, "Cage version " CAGE_VERSION "\n");
exit(0); exit(0);
@ -270,8 +279,6 @@ main(int argc, char *argv[])
return 1; return 1;
} }
server.output_mode = CAGE_MULTI_OUTPUT_MODE_EXTEND;
#ifdef DEBUG #ifdef DEBUG
wlr_log_init(WLR_DEBUG, NULL); wlr_log_init(WLR_DEBUG, NULL);
#else #else