diff --git a/app/src/main.c b/app/src/main.c index 4d954740..d72dd0f1 100644 --- a/app/src/main.c +++ b/app/src/main.c @@ -36,6 +36,7 @@ struct args { bool always_on_top; bool turn_screen_off; bool render_expired_frames; + bool window_borderless; }; static void usage(const char *arg0) { @@ -119,6 +120,9 @@ static void usage(const char *arg0) { " -v, --version\n" " Print the version of scrcpy.\n" "\n" + " --window_borderless\n" + " Disable window decorations (display borderless window).\n" + "\n" " --window-title text\n" " Set a custom window title.\n" "\n" @@ -378,6 +382,7 @@ guess_record_format(const char *filename) { #define OPT_WINDOW_Y 1004 #define OPT_WINDOW_WIDTH 1005 #define OPT_WINDOW_HEIGHT 1006 +#define OPT_WINDOW_BORDERLESS 1007 static bool parse_args(struct args *args, int argc, char *argv[]) { @@ -390,6 +395,8 @@ parse_args(struct args *args, int argc, char *argv[]) { {"max-size", required_argument, NULL, 'm'}, {"no-control", no_argument, NULL, 'n'}, {"no-display", no_argument, NULL, 'N'}, + {"window-borderless", no_argument, NULL, + OPT_WINDOW_BORDERLESS}, {"port", required_argument, NULL, 'p'}, {"push-target", required_argument, NULL, OPT_PUSH_TARGET}, @@ -491,6 +498,9 @@ parse_args(struct args *args, int argc, char *argv[]) { return false; } break; + case OPT_WINDOW_BORDERLESS: + args->window_borderless = true; + break; case OPT_PUSH_TARGET: args->push_target = optarg; break; @@ -568,6 +578,7 @@ main(int argc, char *argv[]) { .no_display = false, .turn_screen_off = false, .render_expired_frames = false, + .window_borderless = false, }; if (!parse_args(&args, argc, argv)) { return 1; @@ -618,6 +629,7 @@ main(int argc, char *argv[]) { .display = !args.no_display, .turn_screen_off = args.turn_screen_off, .render_expired_frames = args.render_expired_frames, + .window_borderless = args.window_borderless, }; int res = scrcpy(&options) ? 0 : 1; diff --git a/app/src/scrcpy.c b/app/src/scrcpy.c index 19a7e50b..63089d5f 100644 --- a/app/src/scrcpy.c +++ b/app/src/scrcpy.c @@ -392,7 +392,8 @@ scrcpy(const struct scrcpy_options *options) { if (!screen_init_rendering(&screen, window_title, frame_size, options->always_on_top, options->window_x, options->window_y, options->window_width, - options->window_height)) { + options->window_height, + options->window_borderless)) { goto end; } diff --git a/app/src/scrcpy.h b/app/src/scrcpy.h index f46773a3..096a2b5a 100644 --- a/app/src/scrcpy.h +++ b/app/src/scrcpy.h @@ -28,6 +28,7 @@ struct scrcpy_options { bool display; bool turn_screen_off; bool render_expired_frames; + bool window_borderless; }; bool diff --git a/app/src/screen.c b/app/src/screen.c index f8e99090..7bb5df36 100644 --- a/app/src/screen.c +++ b/app/src/screen.c @@ -159,7 +159,7 @@ bool screen_init_rendering(struct screen *screen, const char *window_title, struct size frame_size, bool always_on_top, int16_t window_x, int16_t window_y, uint16_t window_width, - uint16_t window_height) { + uint16_t window_height, bool window_borderless) { screen->frame_size = frame_size; struct size window_size = @@ -176,6 +176,9 @@ screen_init_rendering(struct screen *screen, const char *window_title, "(compile with SDL >= 2.0.5 to enable it)"); #endif } + if (window_borderless) { + window_flags |= SDL_WINDOW_BORDERLESS; + } int x = window_x != -1 ? window_x : SDL_WINDOWPOS_UNDEFINED; int y = window_y != -1 ? window_y : SDL_WINDOWPOS_UNDEFINED; diff --git a/app/src/screen.h b/app/src/screen.h index 606115b9..4fe5563b 100644 --- a/app/src/screen.h +++ b/app/src/screen.h @@ -48,7 +48,7 @@ bool screen_init_rendering(struct screen *screen, const char *window_title, struct size frame_size, bool always_on_top, int16_t window_x, int16_t window_y, uint16_t window_width, - uint16_t window_height); + uint16_t window_height, bool window_borderless); // show the window void