-
-
Notifications
You must be signed in to change notification settings - Fork 10.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Single App Package Screen Mirroring instead of whole screen #1887
Comments
If I understand the feature request correctly, you are asking for app-specific screens to be mirrored. If this indeed can be implemented I wonder if that means we can have different scrcpy windows per app so that you can sort of run and control multiple apps at once? |
@guanzhangrtk yepp! Totally right , but I don't know it's possible to spawn single app window screen without system am policies implementation ? |
Yeah I don't know if it is possible but I know that with MuMu App Player (android emulator) you can open multiple apps and then drag them off the main window and they would continue running in the background and you switch between them as if they're both running simultaneously. This is the only android emulator I'm aware of that has this feature (at least on the Mac). |
It isnt really a solution, but using a split terminal with windows terminal and termux over usb/adb is pretty effective. Also, made a I get it though, it would be great to be able to launch individual apps kind of like the way an x11 GUI app runs in wsl or something... |
@hltdev8642 What's the benefit of doing this instead of just running |
You could have running shell + another app using adb shell /ssh but that's not what i am seeking for , instead modifying surfaceflinger behaviour to send different apps as seperate window like different Wayland clients and scrcpy attaching itself to windows not whole display ie. display 0 , display 1 .which also need changes in hwc to paint windows surface and launcher surface + status bar + nav bar differently by id . |
I don't know if this is the solution that you are looking for. On Android 10+, the desktop mode can be forced on secondary displays and secondary displays can be simulated. Here's a simple PowerShell script (.ps1 file) that launches Chrome at the simulated display in fullscreen then opens the simulated display in scrcpy, also in fullscreen. The simulated display is automatically destroyed on scrcpy exit:
|
So you can have an app running on the secondary display and then still have access to the main display via |
If You can have 4 secondary displays running simultaneously. Every time the adb overlay_display_devices is run, previous virtual displays, if any, will be closed (apps moved to main display) and new one/s with greater display id number/s will be generated. Simply running my sample above won't simply generate a new display. You need to explicitly specify how many displays you want to simulate. Also, you'll have an overlay for each on the main display which may block certain screen elements. There's no way to hide the overlays currently to my best knowledge. Sample adb command for 4 simulated displays: To list the available displays: Sample to open an app on a specific display: |
@4nric Thank you for the details to start a new display.
On my OnePlus 7 Pro (Android 10), it starts a new display overlay visible on the main screen on the device (as you say). But on scrcpy, it shows a black screen (having the correct size). It's the same as when I enable a secondary display from developer options. I guess this is a ROM issue/limitation? |
@rom1v Have you enabled Force Desktop mode first before simulating the secondary display? Force Desktop mode has to be enabled first. Force Desktop mode can be enabled from developer settings or by running the adb command I don't have other Android 10 devices to test with, unfortunately. I'm guessing System UI From an xda article, though specific for freeform:
|
@guanzhangrtk I don't use the emulator, but I am certain that the ROM it runs is modified to enable that behavior— just like other device manufacturers can modify AOSP to add their own skins (i.e One UI, MIUI, EMUI) and additional features (i.e Samsung DeX since Android 7.0, EMUI Desktop). Stock Android 6.0 only has experimental multiwindow. Later versions do have experimental freeform windows (multiple apps on same display). Only in Android 10+ that the experimental desktop mode option is available (open multiple apps not only on main display, but on other available ones as well). |
If nothing works, this probably is a ROM limitation, unfortunately. Maybe the implementation of Wireless DeX somehow influenced this behavior? I have yet to try other Samsung devices (non-flagship) with Android 10+ |
Oh, I didn't. Now it works. Thank you 👍 So to summarize: # enable a secondary display (2560x1440, dpi=160, use a higher value for bigger icons)
adb shell settings put global overlay_display_devices 2560x1440/160
# run on the secondary display (if the id does not exist, scrcpy will print available display ids)
# (set the bitrate to 16Mbps for better quality)
scrcpy -b16M --display=1
# disable secondary displays
adb shell settings delete global overlay_display_devices To enable freeform window mode: # enable freeform support
adb shell settings put global enable_freeform_support 1 # then reboot the device (It could be added in the README I guess) Some feedbacks: in practice (at least on my device), it's not very convenient for daily usage:
|
@guanzhangrtk I 99 % doubt that is another window but just another full android instance so too much overhead ! |
MuMu doesn't support multi-instance. Also if each window is a separate full instance then the apps wouldn't be able to share services and interop with each other (but they do). |
This doesn't seem to work for me... :/
|
Leaving off the |
its a longshot, but try adding the flag |
Didn't help |
@luke-jr what is your device and what version of android are you on? |
lineage-16.0-20190811-nightly-marlin-signed.zip I think (original Pixel XL) |
@hltdev8642 how about specifying main activity directly instead of specifying only package name like
Like this |
LineageOS 16 is based on Android 9 Pie. I have yet to confirm if apps can be launched on simulated displays with Android 9 Pie and below. The "force desktop mode on external displays" option is also only available on Android 10+ To my best knowledge, scrcpy block controls on secondary displays if it detects the connected device is running Android 9 Pie and below. If you mirrored only your main display (no --display #) and still can't get touch working, the problem could be related to something else. With regards to launching Chrome, can you please try if this adb command works? |
Why does it do that?
Yes, it seems to. |
Thanks @yume-chan for your reply.
Actually I tried calling A part of my Android app
So I am wondering if you did any special things for the virtual display so that you can mirror it. |
@huynhtanloc2612 I don't know. Virtual displays created with |
Thanks @yume-chan for your reply (especially with the example in #4370 which you pointed was very helpful for me). |
Just to make sure, this(virtual display system given by @yume-chan) does not work below Android 10 right? |
As #1887 (comment) |
Exploring the use of desktop mode on Android devices reveals a mixture of potential and frustration. The journey led me to experiment with an HDMI dummy plug, a clever workaround that simulates a display connection, bypassing the need for direct physical output. This trick opens up possibilities for using SCRCPY more seamlessly, aiming to cast the desktop mode to laptops or other screens without the clutter of on-screen overlays or convoluted workarounds. However, the solution is not without its drawbacks. The app intended to facilitate this process is currently buggy. At times, attempts to push the display result in nothing being shown; other times, the graphics appear distorted, far from the crisp, clean output desired. This inconsistency begs for a deeper dive into the code behind these operations. Is there a way to refine the app, to offer an option that directly supports second-screen desktop mode, bypassing per-app selection? The current workaround, while functional, highlights a gap in the user experience. Ideally, an app would manage the complexity internally, executing ADB commands within a virtual environment to mirror the display without additional hardware. This approach would not only streamline the process but also encapsulate the functionality in a more user-friendly manner. The requirement for an overlay on Android during these operations is puzzling. Why is this overlay mandatory, and why is it so challenging to hide or bypass it? It seems there should be a way to circumvent this, to make the transition to desktop mode more seamless and integrated. The exploration brought me to Miracast, which offers a partial solution by enabling casting to a new display, thus eliminating the overlay. But this, too, feels like a workaround rather than a direct solution. In essence, the journey to optimize desktop mode on Android devices, to enable easy casting to other devices without the overlays |
I'm having this one issue and idk how to make it stop. I'd like to go into desktop mode and when I open a gain it full screen but with out the black bar on the top that minizes or fullscreens it or go back button. I want like exclusive fullescreen. But for the life of me can't get this to work. Is there a command I need? I'm certain it's a window mode I need to enable. I disabled freeform windows. I disabled everything except desktop mode but all apps keep opening like this. Only the YouTube app seems to open and makes it become transparent which makes it much much better but clearly this is not system wide. Any advice? |
I am assuming that you want to open an app in window form in desktop mode, right? I suggest you starting an activity with
|
Did anyone figure out how to create a virtual screen without it showing up on the actual display? Also, how do you unlock Android within the virtual screen itself? If I connect to locked phone, I get a gray background with a lock icon that changes position now and then. Can't click, gesture or otherwise interact with it. Only goes away after I unlock from main display, then use as normal. |
As @yume-chan mentioned in #1887 (comment)
I have made the standalone java program which based on @yume-chan 's code to create an virtual display and added/called it in my Android app which was mentioned in #1887 (comment) . And #1887 (comment)
I also made an simple apps launcher in Desktop mode with other activity which can support scrcpy client tool of @rom1v Demo video: https://youtu.be/ysv5OL3IL1w For anyone who needs Desktop mode, please try it. Hope it help. Thanks |
@huynhtanloc2612 thanks for all the work you have put into this, amazing stuff! I am basically trying to recreate the experience that Windows Phone Companion has with Samsung phones where you can see a list of all apps on your phone and launch them from desktop in separate windows. |
Thanks @sidevesh
It is quite difficult for me because I am not familiar with internal API which is used in scrcpy project (even I have been trying to learn them from scrcpy code). I think scrcpy developers can help do this. |
@4nric How to use adb command to create more than 4 monitors? |
I've used your AG Displays app for a day or so, and I couldn't get the Desktop display to take any touch input (using the mouse) except for the middle-click and right-click for home/back. I could use the keyboard to move around the app drawer and launch apps, but of course that's not very useful if I can't interact with said apps. I've suspect it's to do with the virtual "touchscreen" not aligned correctly with the virtual display. Regardless, can you tech me how to crete the virtul screen using |
I believe that you are facing the issue |
Sorry, it looks I forgot to mention. Yes, it's Android 14 (LineageOS 21). But the main thing is, if I manually create the display, using With manually creating the virtual screen, I've other problems:
Since this is working for me, I'm asking you how to manually create this virtual display without it showing on the main screen all the time. This is the main issue I have with manually creating virtual display, otherwise I'm happy with the experience. I hope |
They are different display types.
This display which is created by above command is "real" display but "virtual" display. The system simulates the real display by using your phone physical screen. It is similar to that you connect your phone (Android 14) with a monitor/TV, the display id is created. Then you can use scrcpy to mirror it via the display id. You will see all click events,... work as expectation. The monitor/TV is real display type. But they require physical screens.
The issue only happens with virtual display type (from Android 14) which the app and java program are using. |
Very sorry for replying so much time later. So I understand your app doesn't use the |
Does this mean that for apps which don't allow screenshots:
|
Even Samsung dex is not able to mirror protected apps like incognito mode... so I guess this won't work |
@yume-chan are the changes that permit --video-source=virtual going to be brought into the main scrcpy release or was this only a proof of concept? |
No. |
I've created a proof of concept that creates a resizable virtual display (independent of @yume-chan's changeset): https://github.com/anirudhb/scrcpy/tree/virtual-display It still needs a lot of cleanup before it can be integrated, and is quite hacky (segfaults on quit), but it works. I would appreciate any feedback that would help get this into scrcpy. |
@anirudhb just now, I end reading this, and your branch is great, even I have to upgrade the version to 2.5 of the server but with but if desktop mode on developer options opens in a 💩 way (Xiaomi fault) |
scrcpy like casting "single app" with virtual-display of @anirudhb and FUP work in progress Grabacion.de.pantalla.2024-08-01.a.las.10.49.49.mp4 |
Is your feature request related to a problem? Please describe.
No, but feature enhancement. Instead of using single screen i would like to mirror different app windows in free form mode independently of main canvas.
Describe the solution you'd like
an option like passing package=com.android.contacts to mirror specific app only screen instead of whole ui.
Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.
Additional context
Add any other context or screenshots about the feature request here.
The text was updated successfully, but these errors were encountered: