Skip to content

Display and control your Android device

Add --no-vd-system-decorations

Romain Vimont145b823b1d02
diff --git a/app/data/bash-completion/scrcpy b/app/data/bash-completion/scrcpy
index 8fae972f..6c88927e 100644
--- a/app/data/bash-completion/scrcpy
+++ b/app/data/bash-completion/scrcpy
@@ -57,6 +57,7 @@ _scrcpy() {
--no-mipmaps
--no-mouse-hover
--no-power-on
+ --no-vd-system-decorations
--no-video
--no-video-playback
--orientation=
diff --git a/app/data/zsh-completion/_scrcpy b/app/data/zsh-completion/_scrcpy
index cda49e8e..e0c5e265 100644
--- a/app/data/zsh-completion/_scrcpy
+++ b/app/data/zsh-completion/_scrcpy
@@ -63,6 +63,7 @@ arguments=(
'--no-mipmaps[Disable the generation of mipmaps]'
'--no-mouse-hover[Do not forward mouse hover events]'
'--no-power-on[Do not power on the device on start]'
+ '--no-vd-system-decorations[Disable virtual display system decorations flag]'
'--no-video[Disable video forwarding]'
'--no-video-playback[Disable video playback]'
'--orientation=[Set the video orientation]:orientation values:(0 90 180 270 flip0 flip90 flip180 flip270)'
diff --git a/app/scrcpy.1 b/app/scrcpy.1
index bb77d25e..711c53c6 100644
--- a/app/scrcpy.1
+++ b/app/scrcpy.1
@@ -370,6 +370,10 @@ Do not forward mouse hover (mouse motion without any clicks) events.
.B \-\-no\-power\-on
Do not power on the device on start.
+.TP
+.B \-\-no\-vd\-system\-decorations
+Disable virtual display system decorations flag.
+
.TP
.B \-\-no\-video
Disable video forwarding.
diff --git a/app/src/cli.c b/app/src/cli.c
index 08f1db2b..177bf934 100644
--- a/app/src/cli.c
+++ b/app/src/cli.c
@@ -109,6 +109,7 @@ enum {
OPT_SCREEN_OFF_TIMEOUT,
OPT_CAPTURE_ORIENTATION,
OPT_ANGLE,
+ OPT_NO_VD_SYSTEM_DECORATIONS,
};
struct sc_option {
@@ -659,6 +660,11 @@ static const struct sc_option options[] = {
.longopt = "no-power-on",
.text = "Do not power on the device on start.",
},
+ {
+ .longopt_id = OPT_NO_VD_SYSTEM_DECORATIONS,
+ .longopt = "no-vd-system-decorations",
+ .text = "Disable virtual display system decorations flag.",
+ },
{
.longopt_id = OPT_NO_VIDEO,
.longopt = "no-video",
@@ -2699,6 +2705,9 @@ parse_args_with_getopt(struct scrcpy_cli_args *args, int argc, char *argv[],
case OPT_ANGLE:
opts->angle = optarg;
break;
+ case OPT_NO_VD_SYSTEM_DECORATIONS:
+ opts->vd_system_decorations = optarg;
+ break;
default:
// getopt prints the error message on stderr
return false;
diff --git a/app/src/options.c b/app/src/options.c
index adc7ba0c..be3cf8d1 100644
--- a/app/src/options.c
+++ b/app/src/options.c
@@ -108,6 +108,7 @@ const struct scrcpy_options scrcpy_options_default = {
.new_display = NULL,
.start_app = NULL,
.angle = NULL,
+ .vd_system_decorations = true,
};
enum sc_orientation
diff --git a/app/src/options.h b/app/src/options.h
index 0692276e..eaeba2f2 100644
--- a/app/src/options.h
+++ b/app/src/options.h
@@ -310,6 +310,7 @@ struct scrcpy_options {
bool audio_dup;
const char *new_display; // [<width>x<height>][/<dpi>] parsed by the server
const char *start_app;
+ bool vd_system_decorations;
};
extern const struct scrcpy_options scrcpy_options_default;
diff --git a/app/src/scrcpy.c b/app/src/scrcpy.c
index 48befb1d..dc9e237f 100644
--- a/app/src/scrcpy.c
+++ b/app/src/scrcpy.c
@@ -458,6 +458,7 @@ scrcpy(struct scrcpy_options *options) {
.power_on = options->power_on,
.kill_adb_on_close = options->kill_adb_on_close,
.camera_high_speed = options->camera_high_speed,
+ .vd_system_decorations = options->vd_system_decorations,
.list = options->list,
};
diff --git a/app/src/server.c b/app/src/server.c
index 9c81a7f6..ce7b1aaf 100644
--- a/app/src/server.c
+++ b/app/src/server.c
@@ -376,6 +376,9 @@ execute_server(struct sc_server *server,
VALIDATE_STRING(params->new_display);
ADD_PARAM("new_display=%s", params->new_display);
}
+ if (!params->vd_system_decorations) {
+ ADD_PARAM("vd_system_decorations=false");
+ }
if (params->list & SC_OPTION_LIST_ENCODERS) {
ADD_PARAM("list_encoders=true");
}
diff --git a/app/src/server.h b/app/src/server.h
index 9d46b354..6d9dbd4d 100644
--- a/app/src/server.h
+++ b/app/src/server.h
@@ -69,6 +69,7 @@ struct sc_server_params {
bool power_on;
bool kill_adb_on_close;
bool camera_high_speed;
+ bool vd_system_decorations;
uint8_t list;
};
diff --git a/doc/virtual_display.md b/doc/virtual_display.md
index 4ed5961f..97ac01b2 100644
--- a/doc/virtual_display.md
+++ b/doc/virtual_display.md
@@ -24,3 +24,13 @@ For example:
```bash
scrcpy --new-display=1920x1080 --start-app=org.videolan.vlc
```
+
+## System decorations
+
+By default, virtual display system decorations are enabled. But some devices
+might display a broken UI;
+
+Use `--no-vd-system-decorations` to disable it.
+
+Note that if no app is started, no content will be rendered, so no video frame
+will be produced at all.
diff --git a/server/src/main/java/com/genymobile/scrcpy/Options.java b/server/src/main/java/com/genymobile/scrcpy/Options.java
index 6a59fbe7..43cc790d 100644
--- a/server/src/main/java/com/genymobile/scrcpy/Options.java
+++ b/server/src/main/java/com/genymobile/scrcpy/Options.java
@@ -60,6 +60,7 @@ public class Options {
private boolean powerOn = true;
private NewDisplay newDisplay;
+ private boolean vdSystemDecorations = true;
private Orientation.Lock captureOrientationLock = Orientation.Lock.Unlocked;
private Orientation captureOrientation = Orientation.Orient0;
@@ -232,6 +233,10 @@ public class Options {
return captureOrientationLock;
}
+ public boolean getVDSystemDecorations() {
+ return vdSystemDecorations;
+ }
+
public boolean getList() {
return listEncoders || listDisplays || listCameras || listCameraSizes || listApps;
}
@@ -461,6 +466,9 @@ public class Options {
case "new_display":
options.newDisplay = parseNewDisplay(value);
break;
+ case "vd_system_decorations":
+ options.vdSystemDecorations = Boolean.parseBoolean(value);
+ break;
case "capture_orientation":
Pair<Orientation.Lock, Orientation> pair = parseCaptureOrientation(value);
options.captureOrientationLock = pair.first;
diff --git a/server/src/main/java/com/genymobile/scrcpy/video/NewDisplayCapture.java b/server/src/main/java/com/genymobile/scrcpy/video/NewDisplayCapture.java
index 6a70704e..dc9c8897 100644
--- a/server/src/main/java/com/genymobile/scrcpy/video/NewDisplayCapture.java
+++ b/server/src/main/java/com/genymobile/scrcpy/video/NewDisplayCapture.java
@@ -53,6 +53,7 @@ public class NewDisplayCapture extends SurfaceCapture {
private final boolean captureOrientationLocked;
private final Orientation captureOrientation;
private final float angle;
+ private final boolean vdSystemDecorations;
private VirtualDisplay virtualDisplay;
private Size videoSize;
@@ -72,6 +73,7 @@ public class NewDisplayCapture extends SurfaceCapture {
this.captureOrientation = options.getCaptureOrientation();
assert captureOrientation != null;
this.angle = options.getAngle();
+ this.vdSystemDecorations = options.getVDSystemDecorations();
}
@Override
@@ -157,8 +159,10 @@ public class NewDisplayCapture extends SurfaceCapture {
| VIRTUAL_DISPLAY_FLAG_OWN_CONTENT_ONLY
| VIRTUAL_DISPLAY_FLAG_SUPPORTS_TOUCH
| VIRTUAL_DISPLAY_FLAG_ROTATES_WITH_CONTENT
- | VIRTUAL_DISPLAY_FLAG_DESTROY_CONTENT_ON_REMOVAL
- | VIRTUAL_DISPLAY_FLAG_SHOULD_SHOW_SYSTEM_DECORATIONS;
+ | VIRTUAL_DISPLAY_FLAG_DESTROY_CONTENT_ON_REMOVAL;
+ if (vdSystemDecorations) {
+ flags |= VIRTUAL_DISPLAY_FLAG_SHOULD_SHOW_SYSTEM_DECORATIONS;
+ }
if (Build.VERSION.SDK_INT >= AndroidVersions.API_33_ANDROID_13) {
flags |= VIRTUAL_DISPLAY_FLAG_TRUSTED
| VIRTUAL_DISPLAY_FLAG_OWN_DISPLAY_GROUP