Display and control your Android device
Add --render-fit=stretched
Romain Vimontf9c9c25983df
diff --git a/app/data/bash-completion/scrcpy b/app/data/bash-completion/scrcpyindex 368cec30..f55db26f 100644--- a/app/data/bash-completion/scrcpy+++ b/app/data/bash-completion/scrcpy@@ -181,7 +181,7 @@ _scrcpy() {return;;--render-fit)- COMPREPLY=($(compgen -W 'letterbox unscaled' -- "$cur"))+ COMPREPLY=($(compgen -W 'letterbox stretched unscaled' -- "$cur"))return;;--shortcut-mod)diff --git a/app/data/zsh-completion/_scrcpy b/app/data/zsh-completion/_scrcpyindex 92dd07b0..a6dd68d9 100644--- a/app/data/zsh-completion/_scrcpy+++ b/app/data/zsh-completion/_scrcpy@@ -87,7 +87,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 unscaled)'+ '--render-fit=[Set the render-fit mode]:mode:(letterbox stretched unscaled)''--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.1index c275add9..8dd89ca6 100644--- a/app/scrcpy.1+++ b/app/scrcpy.1@@ -528,9 +528,10 @@ Supported names are currently "direct3d", "opengl", "opengles2", "opengles", "me.BI "\-\-render\-fit " modeSet the render-fit mode to configure how the rendering fits the window.-Possible values are "letterbox" and "unscaled":+Possible values are "letterbox", "stretched" and "unscaled":- "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.- "unscaled": render the display without scaling.Default is "letterbox", unless --flex-display is set, in which case it is "unscaled".diff --git a/app/src/cli.c b/app/src/cli.cindex a83409a9..177d98d0 100644--- a/app/src/cli.c+++ b/app/src/cli.c@@ -799,10 +799,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 \"unscaled\".\n"+ "Possible values are \"letterbox\", \"stretched\" and "+ "\"unscaled\".\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""\"unscaled\": render the display without scaling.\n""Default is \"letterbox\", unless --flex-display is set, in ""which case it is \"unscaled\".",@@ -2436,12 +2439,18 @@ 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, "unscaled")) {*mode = SC_RENDER_FIT_UNSCALED;return true;}- LOGE("Unsupported render-fit: %s (expected letterbox or unscaled)", optarg);+ LOGE("Unsupported render-fit: %s (expected letterbox, stretched or "+ "unscaled)", optarg);return false;}diff --git a/app/src/options.h b/app/src/options.hindex 184b5df5..e479b3a2 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_UNSCALED,};diff --git a/app/src/screen.c b/app/src/screen.cindex 330caf9d..c66bdd92 100644--- a/app/src/screen.c+++ b/app/src/screen.c@@ -186,6 +186,12 @@ compute_content_rect(struct sc_size render_size, struct sc_size content_size,rect->w = content_size.width;rect->h = content_size.height;return;+ } else 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(is_icon || render_fit == SC_RENDER_FIT_LETTERBOX);@@ -988,6 +994,11 @@ sc_screen_resize_to_fit(struct sc_screen *screen) {return;}+ if (screen->render_fit == SC_RENDER_FIT_STRETCHED) {+ // nothing to do+ return;+ }+struct sc_size window_size = sc_sdl_get_window_size(screen->window);if (screen->render_fit == SC_RENDER_FIT_UNSCALED) {