Skip to content

Display and control your Android device

Add a new option: -n/--no-window

CapsLock421a1141e29c
diff --git a/app/src/main.c b/app/src/main.c
index f18b3aaf..c4ffad24 100644
--- a/app/src/main.c
+++ b/app/src/main.c
@@ -16,6 +16,7 @@ struct args {
const char *record_filename;
enum recorder_format record_format;
SDL_bool fullscreen;
+ SDL_bool no_window;
SDL_bool help;
SDL_bool version;
SDL_bool show_touches;
@@ -57,6 +58,9 @@ static void usage(const char *arg0) {
" is preserved.\n"
" Default is %d%s.\n"
"\n"
+ " -n, --no-window\n"
+ " Do not show window (only when screen recording is enabled).\n"
+ "\n"
" -p, --port port\n"
" Set the TCP port the client listens on.\n"
" Default is %d.\n"
@@ -260,6 +264,7 @@ static SDL_bool parse_args(struct args *args, int argc, char *argv[]) {
{"fullscreen", no_argument, NULL, 'f'},
{"help", no_argument, NULL, 'h'},
{"max-size", required_argument, NULL, 'm'},
+ {"no-window", no_argument, NULL, 'n'},
{"port", required_argument, NULL, 'p'},
{"record", required_argument, NULL, 'r'},
{"record-format", required_argument, NULL, 'f'},
@@ -269,7 +274,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:fF:hm:p:r:s:tTv", long_options, NULL)) != -1) {
+ while ((c = getopt_long(argc, argv, "b:c:fF:hm:np:r:s:tTv", long_options, NULL)) != -1) {
switch (c) {
case 'b':
if (!parse_bit_rate(optarg, &args->bit_rate)) {
@@ -295,6 +300,9 @@ static SDL_bool parse_args(struct args *args, int argc, char *argv[]) {
return SDL_FALSE;
}
break;
+ case 'n':
+ args->no_window = SDL_TRUE;
+ break;
case 'p':
if (!parse_port(optarg, &args->port)) {
return SDL_FALSE;
@@ -321,6 +329,16 @@ static SDL_bool parse_args(struct args *args, int argc, char *argv[]) {
}
}
+ if (args->no_window && !args->record_filename) {
+ LOGE("-n/--no-window requires screen recording (-r/--record)");
+ return SDL_FALSE;
+ }
+
+ if (args->no_window && args->fullscreen) {
+ LOGE("-f/--fullscreen-window is incompatible with -n/--no-window");
+ return SDL_FALSE;
+ }
+
int index = optind;
if (index < argc) {
LOGE("Unexpected additional argument: %s", argv[index]);
@@ -401,6 +419,7 @@ int main(int argc, char *argv[]) {
.show_touches = args.show_touches,
.fullscreen = args.fullscreen,
.always_on_top = args.always_on_top,
+ .no_window = args.no_window,
};
int res = scrcpy(&options) ? 0 : 1;
diff --git a/app/src/scrcpy.h b/app/src/scrcpy.h
index aba1f336..ff7f482a 100644
--- a/app/src/scrcpy.h
+++ b/app/src/scrcpy.h
@@ -15,6 +15,7 @@ struct scrcpy_options {
SDL_bool show_touches;
SDL_bool fullscreen;
SDL_bool always_on_top;
+ SDL_bool no_window;
};
SDL_bool scrcpy(const struct scrcpy_options *options);
diff --git a/app/src/screen.h b/app/src/screen.h
index 4a13bfca..f857e981 100644
--- a/app/src/screen.h
+++ b/app/src/screen.h
@@ -17,6 +17,7 @@ struct screen {
struct size windowed_window_size;
SDL_bool has_frame;
SDL_bool fullscreen;
+ SDL_bool no_window;
};
#define SCREEN_INITIALIZER { \
@@ -33,6 +34,7 @@ struct screen {
}, \
.has_frame = SDL_FALSE, \
.fullscreen = SDL_FALSE, \
+ .no_window = SDL_FALSE, \
}
// init SDL and set appropriate hints