diff --git a/app/data/bash-completion/scrcpy b/app/data/bash-completion/scrcpy index f17f156f..a855a1a4 100644 --- a/app/data/bash-completion/scrcpy +++ b/app/data/bash-completion/scrcpy @@ -179,7 +179,7 @@ _scrcpy() { return ;; --render-fit) - COMPREPLY=($(compgen -W 'letterbox disabled' -- "$cur")) + COMPREPLY=($(compgen -W 'letterbox stretched disabled' -- "$cur")) return ;; --shortcut-mod) diff --git a/app/data/zsh-completion/_scrcpy b/app/data/zsh-completion/_scrcpy index fa966335..32f2a561 100644 --- a/app/data/zsh-completion/_scrcpy +++ b/app/data/zsh-completion/_scrcpy @@ -85,7 +85,7 @@ arguments=( '--record-format=[Force recording format]:format:(mp4 mkv m4a mka opus aac flac wav)' '--record-orientation=[Set the record orientation]:orientation values:(0 90 180 270)' '--render-driver=[Request SDL to use the given render driver]:driver name:(direct3d opengl opengles2 opengles metal software)' - '--render-fit=[Set the render-fit mode]:mode:(letterbox disabled)' + '--render-fit=[Set the render-fit mode]:mode:(letterbox stretched disabled)' '--require-audio=[Make scrcpy fail if audio is enabled but does not work]' {-s,--serial=}'[The device serial number \(mandatory for multiple devices only\)]:serial:($("${ADB-adb}" devices | awk '\''$2 == "device" {print $1}'\''))' {-S,--turn-screen-off}'[Turn the device screen off immediately]' diff --git a/app/scrcpy.1 b/app/scrcpy.1 index 1f8d5170..68593fce 100644 --- a/app/scrcpy.1 +++ b/app/scrcpy.1 @@ -518,9 +518,10 @@ Supported names are currently "direct3d", "opengl", "opengles2", "opengles", "me .BI "\-\-render\-fit " mode Set the render-fit mode to configure how the rendering fits the window. -Possible values are "letterbox" and "disabled": +Possible values are "letterbox", "stretched" and "disabled": - "letterbox": preserve the aspect ratio and fit the window as best as possible (black bars are added either at the top and bottom or at the sides if needed). + - "stretched": fit the window without preserving the aspect ratio. - "disabled": render the display at the top-left corner, without scaling. Default is "letterbox", unless --flex-display is set, in which case it is "disabled". diff --git a/app/src/cli.c b/app/src/cli.c index 74b89286..0921c36e 100644 --- a/app/src/cli.c +++ b/app/src/cli.c @@ -784,10 +784,13 @@ static const struct sc_option options[] = { .argdesc = "mode", .text = "Set the render-fit mode to configure how the rendering fits " "the window.\n" - "Possible values are \"letterbox\" and \"disabled\".\n" + "Possible values are \"letterbox\", \"stretched\" and " + "\"disabled\".\n" "\"letterbox\": preserve the aspect ratio and fit the window " "as best as possible (black bars are added either at the top " "and bottom or at the sides if needed).\n" + "\"stretched\": fit the window without preserving the aspect " + "ratio.\n" "\"disabled\": render the display at the top-left corner, " "without scaling.\n" "Default is \"letterbox\", unless --flex-display is set, in " @@ -2350,6 +2353,11 @@ parse_render_fit(const char *optarg, enum sc_render_fit *mode) { return true; } + if (!strcmp(optarg, "stretched")) { + *mode = SC_RENDER_FIT_STRETCHED; + return true; + } + if (!strcmp(optarg, "disabled")) { *mode = SC_RENDER_FIT_DISABLED; return true; diff --git a/app/src/options.h b/app/src/options.h index 2bc781b1..f8ffb558 100644 --- a/app/src/options.h +++ b/app/src/options.h @@ -223,6 +223,7 @@ enum sc_shortcut_mod { enum sc_render_fit { SC_RENDER_FIT_AUTO, SC_RENDER_FIT_LETTERBOX, + SC_RENDER_FIT_STRETCHED, SC_RENDER_FIT_DISABLED, }; diff --git a/app/src/screen.c b/app/src/screen.c index 48e73b57..943b6afe 100644 --- a/app/src/screen.c +++ b/app/src/screen.c @@ -168,6 +168,16 @@ compute_content_rect(struct sc_size render_size, struct sc_size content_size, return; } + if (render_fit == SC_RENDER_FIT_STRETCHED) { + rect->x = 0; + rect->y = 0; + rect->w = render_size.width; + rect->h = render_size.height; + return; + } + + assert(render_fit == SC_RENDER_FIT_LETTERBOX); + if (is_optimal_size(render_size, content_size)) { rect->x = 0; rect->y = 0;