From af9808cf02c63c93ad82f1de111b7c85dc2e8d75 Mon Sep 17 00:00:00 2001 From: Philipp Sandhaus Date: Tue, 4 Sep 2018 15:55:20 +0200 Subject: [PATCH] Add option to start in fullscreen Signed-off-by: Romain Vimont --- app/src/main.c | 11 ++++++++++- app/src/scrcpy.c | 4 ++++ app/src/scrcpy.h | 1 + 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/app/src/main.c b/app/src/main.c index 1317da79..634c7bb4 100644 --- a/app/src/main.c +++ b/app/src/main.c @@ -11,6 +11,7 @@ struct args { const char *serial; const char *crop; + SDL_bool fullscreen; SDL_bool help; SDL_bool version; SDL_bool show_touches; @@ -36,6 +37,9 @@ static void usage(const char *arg0) { " (typically, portrait for a phone, landscape for a tablet).\n" " Any --max-size value is computed on the cropped size.\n" "\n" + " -f, --fullscreen\n" + " Start in fullscreen.\n" + "\n" " -h, --help\n" " Print this help.\n" "\n" @@ -200,6 +204,7 @@ static SDL_bool parse_args(struct args *args, int argc, char *argv[]) { static const struct option long_options[] = { {"bit-rate", required_argument, NULL, 'b'}, {"crop", required_argument, NULL, 'c'}, + {"fullscreen", no_argument, NULL, 'f'}, {"help", no_argument, NULL, 'h'}, {"max-size", required_argument, NULL, 'm'}, {"port", required_argument, NULL, 'p'}, @@ -209,7 +214,7 @@ static SDL_bool parse_args(struct args *args, int argc, char *argv[]) { {NULL, 0, NULL, 0 }, }; int c; - while ((c = getopt_long(argc, argv, "b:c:hm:p:s:tv", long_options, NULL)) != -1) { + while ((c = getopt_long(argc, argv, "b:c:fhm:p:s:tv", long_options, NULL)) != -1) { switch (c) { case 'b': if (!parse_bit_rate(optarg, &args->bit_rate)) { @@ -219,6 +224,9 @@ static SDL_bool parse_args(struct args *args, int argc, char *argv[]) { case 'c': args->crop = optarg; break; + case 'f': + args->fullscreen = SDL_TRUE; + break; case 'h': args->help = SDL_TRUE; break; @@ -305,6 +313,7 @@ int main(int argc, char *argv[]) { .max_size = args.max_size, .bit_rate = args.bit_rate, .show_touches = args.show_touches, + .fullscreen = args.fullscreen, }; int res = scrcpy(&options) ? 0 : 1; diff --git a/app/src/scrcpy.c b/app/src/scrcpy.c index 3eaa45c0..54a7f993 100644 --- a/app/src/scrcpy.c +++ b/app/src/scrcpy.c @@ -223,6 +223,10 @@ SDL_bool scrcpy(const struct scrcpy_options *options) { show_touches_waited = SDL_TRUE; } + if (options->fullscreen) { + screen_switch_fullscreen(&screen); + } + ret = event_loop(); LOGD("quit..."); diff --git a/app/src/scrcpy.h b/app/src/scrcpy.h index 7ddabf28..f64d4c02 100644 --- a/app/src/scrcpy.h +++ b/app/src/scrcpy.h @@ -10,6 +10,7 @@ struct scrcpy_options { Uint16 max_size; Uint32 bit_rate; SDL_bool show_touches; + SDL_bool fullscreen; }; SDL_bool scrcpy(const struct scrcpy_options *options);