2755 Commits

Author SHA1 Message Date
Romain Vimont
c59a3c3169 Start cleanup process with setsid or nohup
If available, start the cleanup process in a new session to reduce the
likelihood of it being terminated along with the scrcpy server process
on some devices.

The binaries setsid and nohup are often available, but it is not
guaranteed.

Refs #5601 <https://github.com/Genymobile/scrcpy/issues/5601>
PR #5613 <https://github.com/Genymobile/scrcpy/pull/5613>
2024-12-08 10:58:22 +01:00
Romain Vimont
2780e0bd7b Do not interrupt cleanup configuration
Some options, such as --show-touches or --stay-awake, modify Android
settings and must be restored upon exit.

If scrcpy terminates (e.g. due to an early error) in the middle of the
clean up configuration, the device may be left in an inconsistent state
(some settings might be changed but not restored).

This issue can be reproduced with high probability by forcing scrcpy to
fail:

    scrcpy --show-touches --video-encoder=fail

To prevent this problem, ensure that the clean up thread is not
interrupted until the clean up process is started.

Refs #5601 <https://github.com/Genymobile/scrcpy/issues/5601>
PR #5613 <https://github.com/Genymobile/scrcpy/pull/5613>
2024-12-08 10:58:07 +01:00
Romain Vimont
6c6607d404 Add --no-vd-destroy-content
Add an option to disable the following flag for virtual displays:

    DisplayManager.VIRTUAL_DISPLAY_FLAG_DESTROY_CONTENT_ON_REMOVAL

With this option, when the virtual display is closed, the running apps
are moved to the main display rather than being destroyed.

PR #5615 <https://github.com/Genymobile/scrcpy/pull/5615>
2024-12-08 09:33:03 +01:00
Romain Vimont
988174805c Fix boolean assignment
On --no-vd-system-decoration, the boolean option must be set to false.

It was wrongly assigned from optarg (this worked because optarg is NULL
at this point, so it was converted to false).

PR #5615 <https://github.com/Genymobile/scrcpy/pull/5615>
2024-12-08 09:26:53 +01:00
Romain Vimont
f90dc216d1 Refactor virtual display properties initialization
Following the changes from the previous commit, the behavior is now
identical when mirroring the main display or using the SurfaceControl
API.

Factorize the code to perform the initialization in a single location.

Refs #5605 <https://github.com/Genymobile/scrcpy/issues/5605>
PR #5614 <https://github.com/Genymobile/scrcpy/pull/5614>
2024-12-07 20:09:14 +01:00
Romain Vimont
97fa77c76c Inject main display events to the original display
When mirroring a secondary display, touch and scroll events must be sent
to the mirroring virtual display id (with coordinates relative to the
virtual display size), rather than to the original display (with
coordinates relative to the original display size).

This behavior, introduced by d19396718ee0c0ba7fb578f595a6553c0458da59,
was also applied for the main display for consistency. However, it
causes some UI elements to become unclickable.

To minimize inconveniences, restore the previous behavior when mirroring
the main display: send all events to the original display id (0) with
coordinates relative to the original display size.

Fixes #5545 <https://github.com/Genymobile/scrcpy/issues/5545>
Fixes #5605 <https://github.com/Genymobile/scrcpy/issues/5605>
Fixes #5616 <https://github.com/Genymobile/scrcpy/issues/5616>
Refs #4598 <https://github.com/Genymobile/scrcpy/issues/4598>
Refs #5137 <https://github.com/Genymobile/scrcpy/issues/5137>
Refs #5370 <https://github.com/Genymobile/scrcpy/pull/5370>
PR #5614 <https://github.com/Genymobile/scrcpy/pull/5614>
2024-12-07 20:08:49 +01:00
Romain Vimont
baa10ed0a3 Update links to 3.0.2 v3.0.2 2024-12-04 22:48:27 +01:00
Romain Vimont
2ed2247e8f Bump version to 3.0.2
The version was not bumped for 3.0.1.
2024-12-04 22:35:25 +01:00
Romain Vimont
5febb1e9fb Update links to 3.0.1 v3.0.1 2024-12-04 21:46:06 +01:00
Romain Vimont
5c3626ed47 Handle broken pipe errors specifically
Since 9555d3a537a828731ad89ef5258ba537acf8cc11, a capture/encoding error
was sometimes logged on exit.
2024-12-04 18:38:23 +01:00
Romain Vimont
0e473eb005 Reset TCP/IP connection with a '+' prefix
When running scrcpy with --tcpip=xx.xx.xx.xx, to make sure a new working
connection is established, it was first disconnected by a call to:

    adb disconnect <addr>

However, this caused all running instances connected to that address to
be killed. Running several instances of scrcpy on the same device is now
useful with virtual displays, so change the default behavior to NOT
disconnect.

To force a reconnection, a '+' prefix can be added:

    scrcpy --tcpip=+192.168.0.x

Fixes #5562 <https://github.com/Genymobile/scrcpy/issues/5562>
2024-12-04 13:16:51 +01:00
Romain Vimont
b26b4fb745 Document launchers in virtual displays
Mention how to start a launcher in a virtual display.

Refs #5592 <https://github.com/Genymobile/scrcpy/issues/5592>
2024-12-04 13:10:35 +01:00
Romain Vimont
9555d3a537 Retry capture on IOException
If the capture fails with an IOException, retry with a lower resolution.

Fixes #5539 <https://github.com/Genymobile/scrcpy/issues/5539>
2024-12-03 23:06:33 +01:00
Romain Vimont
aea6a371aa Remove scrcpy wrapper script for static builds
All portable builds now use the files located in the same directory as
the scrcpy executable by default.

PR #5560 <https://github.com/Genymobile/scrcpy/pull/5560>
2024-12-02 18:23:18 +01:00
Romain Vimont
dc6c279b1e Log adb executable path
Log the ADB executable path (at the DEBUG level) if it is not the
default one.

PR #5560 <https://github.com/Genymobile/scrcpy/pull/5560>
2024-12-02 18:23:18 +01:00
Romain Vimont
6d0ac3626d Use local adb in portable builds
For non-Windows portable builds, use the absolute path to the adb
executable located in the same directory as scrcpy.

On Windows, just use "adb", which is sufficient to use the local one.

PR #5560 <https://github.com/Genymobile/scrcpy/pull/5560>
2024-12-02 18:23:18 +01:00
Romain Vimont
beee42fb06 Load ADB value using sc_get_env()
Contrary to getenv(), the result of sc_get_env() is encoded in UTF-8 on
all platforms. Since it is allocated, it requires an explicit init() and
destroy() functions.

PR #5560 <https://github.com/Genymobile/scrcpy/pull/5560>
2024-12-02 18:23:18 +01:00
Romain Vimont
131372d2c4 Expose sc_get_env() to read environment variable
Contrary to getenv(), sc_get_env() returns an allocated string that is
guaranteed to be encoded in UTF-8 on all platforms (it uses _wgetenv()
internally on Windows and converts the strings).

PR #5560 <https://github.com/Genymobile/scrcpy/pull/5560>
2024-12-02 18:23:18 +01:00
Genxster1998
0fd7534bd5 Add method to get executable path on MacOS
PR #5560 <https://github.com/Genymobile/scrcpy/pull/5560>

Signed-off-by: Romain Vimont <rom@rom1v.com>
2024-12-02 18:23:18 +01:00
Romain Vimont
36574d2ee7 Fix .tar.gz compression
The generated .tar.gz releases were in fact non-gzipped tarballs.

Fixes #5581 <https://github.com/Genymobile/scrcpy/issues/5581>
2024-12-02 08:54:57 +01:00
Romain Vimont
3b2b3625e4 Accept positional control events without display
The position of touch and scroll must normally be "resolved" with a
"position mapper" associated to the display.

But to support the injection of such events with scrcpy-server alone
without video, handle the case where there is no display.

Fixes #5542 <https://github.com/Genymobile/scrcpy/issues/5542>
2024-12-01 17:22:47 +01:00
Romain Vimont
b2cdaa4bdc Factorize position mapper resolution
The code was duplicated for touch and scroll events. Extract it to a
private function.

Refs #5542 <https://github.com/Genymobile/scrcpy/issues/5542>
2024-12-01 17:22:47 +01:00
Romain Vimont
d01373c03c Enable close-on-interrupt for macOS
This behavior is also necessary on macOS.

Fixes #5536 <https://github.com/Genymobile/scrcpy/issues/5536>
2024-11-28 21:02:51 +01:00
Romain Vimont
ff06b6dcc1 Split network macro conditions
On Windows, interrupting a socket with shutdown() does not wake up
accept() or read() calls, the socket must be closed.

Introduce a new macro constant SC_SOCKET_CLOSE_ON_INTERRUPT, distinct of
_WIN32, because Windows will not be the only platform exhibiting this
behavior.

Refs #5536 <https://github.com/Genymobile/scrcpy/issues/5536>
2024-11-28 21:02:31 +01:00
Romain Vimont
017a3672a4 Check GitHub runner architecture
Make sure that the releases are built for the expected target arch.
2024-11-28 20:09:21 +01:00
Genxster1998
c1351b250e Build macOS x86_64 release
Add actions to build a release for macOS x86_64 in addition to the
aarch64 version.

PR #5526 <https://github.com/Genymobile/scrcpy/pull/5526>

Signed-off-by: Romain Vimont <rom@rom1v.com>
2024-11-28 20:09:21 +01:00
Romain Vimont
618a978f5b Specify architecture for Linux and macOS releases
PR #5526 <https://github.com/Genymobile/scrcpy/pull/5526>

Co-authored-by: Genxster1998 <ck.2229.ck@gmail.com>
2024-11-28 20:09:18 +01:00
Romain Vimont
acddd811bf Rename TARGET to TARGET_DIRNAME
This avoids confusion with "$1", which is also documented as "<target>".

If "$1" (the target) is "linux", then TARGET_DIRNAME is
"scrcpy-linux-v3.0".
2024-11-28 19:59:06 +01:00
Romain Vimont
ee9f7126ff Use FORMAT variable name in package_client.sh
The format is used several times, avoid using "$2" directly.
2024-11-28 19:58:41 +01:00
Romain Vimont
a18ed1ee7a Simplify GitHub actions step descriptions
Each step is executed within the context of an action, so mentioning the
name of the action is unnecessary.
2024-11-28 19:58:08 +01:00
Romain Vimont
678025b316 Remove apt update on GitHub Actions
Assume the image is up-to-date.
2024-11-28 19:40:47 +01:00
Romain Vimont
3e689020ba Fix null return value in DisplayManager.toString()
Ensure DisplayListener.toString() returns a non-null value to prevent a
NullPointerException on certain devices.

Fixes #5537 <https://github.com/Genymobile/scrcpy/issues/5537>
2024-11-27 07:45:35 +01:00
Romain Vimont
3d1f036c04 Rollback to old --turn-screen-off for Android 15
When the screen is turned off with the new display power method
introduced in Android 15, video mirroring freezes.

Use the Android 14 method for Android 15.

Refs 58ba00fa060c9a1f439120f8869ed106e1c935f9
Refs #5418 <https://github.com/Genymobile/scrcpy/pull/5418>
Fixes #5530 <https://github.com/Genymobile/scrcpy/issues/5530>
2024-11-26 15:55:16 +01:00
Romain Vimont
3d5294c1e5 Set main display power for virtual display
Change the display power of the main display when mirroring a virtual
display, to make it possible to turn off the screen.

Fixes #5522 <https://github.com/Genymobile/scrcpy/issues/5522>
Refs #5530 <https://github.com/Genymobile/scrcpy/issues/5530>
2024-11-26 15:43:41 +01:00
Romain Vimont
1d2f16dbb5 Fix documentation about default mouse mode
When video playback is turned off, the default mouse mode has changed
from "uhid" to "disabled" in 2c25fd7a8082307da19645a690c31403903fbb1e.

Update the documentation accordingly.

Refs #5410 <https://github.com/Genymobile/scrcpy/issues/5410>
Refs #5542 <https://github.com/Genymobile/scrcpy/issues/5542>
2024-11-26 14:10:11 +01:00
Romain Vimont
7fef051976 Add BlueSky link
Scrcpy now has a BlueSky account.
2024-11-25 20:06:32 +01:00
Wouter Schoot
da8ade88fd Fix link to virtual display doc in README
PR #5525 <https://github.com/Genymobile/scrcpy/pull/5525>

Signed-off-by: Romain Vimont <rom@rom1v.com>
2024-11-25 08:21:06 +01:00
Romain Vimont
74aecc00b5 Update links to 3.0 v3.0 2024-11-24 18:30:01 +01:00
Romain Vimont
5e05f2a25b Bump version to 3.0 2024-11-24 17:52:54 +01:00
Romain Vimont
3d478d7d5b Build FFmpeg with v4l2 support for Linux
So that --v4l2-sink works with Linux static builds.
2024-11-24 17:52:53 +01:00
Romain Vimont
54e1f8e060 Include scrcpy manpage in Linux and macOS releases 2024-11-24 16:50:47 +01:00
Romain Vimont
d40224f299 Fix alphabetic order of cli args 2024-11-24 16:37:32 +01:00
Romain Vimont
0628ffcb0b Merge branch 'master' into release 2024-11-24 16:01:05 +01:00
Romain Vimont
6f9520f3e2 Test build_without_gradle.sh in GitHub Actions
Build the server without gradle to make sure that the script works.

PR #5515 <https://github.com/Genymobile/scrcpy/pull/5515>
2024-11-24 15:46:37 +01:00
Romain Vimont
a7efb180b9 Add script to release macOS static binary
Provide a prebuilt binary for macOS.

Fixes #1733 <https://github.com/Genymobile/scrcpy/issues/1733>
Fixes #3235 <https://github.com/Genymobile/scrcpy/issues/3235>
Fixes #4489 <https://github.com/Genymobile/scrcpy/issues/4489>
Fixes #5327 <https://github.com/Genymobile/scrcpy/issues/5327>
PR #5515 <https://github.com/Genymobile/scrcpy/pull/5515>

Co-authored-by: Muvaffak Onus <me@muvaf.com>
2024-11-24 15:46:23 +01:00
Muvaffak Onus
28c372e838 Use generic command for SHA-256
The command sha256sum does not exist on macOS, but `shasum -a256` works
both on Linux and macOS.

PR #5515 <https://github.com/Genymobile/scrcpy/pull/5515>

Co-authored-by: Romain Vimont <rom@rom1v.com>
Signed-off-by: Romain Vimont <rom@rom1v.com>
2024-11-24 15:41:13 +01:00
Romain Vimont
cb19686d79 Add script to release Linux static binary
Provide a prebuilt binary for Linux.

Fixes #5327 <https://github.com/Genymobile/scrcpy/issues/5327>
PR #5515 <https://github.com/Genymobile/scrcpy/pull/5515>
2024-11-24 15:41:13 +01:00
Romain Vimont
93da693e8c Add support for .tar.gz packaging
Make package_client.sh accept an archive format.

PR #5515 <https://github.com/Genymobile/scrcpy/pull/5515>
2024-11-24 15:41:13 +01:00
Romain Vimont
179c664e2b Add static build option
Use static dependencies if the option is set.

PR #5515 <https://github.com/Genymobile/scrcpy/pull/5515>
2024-11-24 15:41:13 +01:00
Romain Vimont
360936248c Add support for build and link types for deps
Make dependencies build scripts more flexible, to accept a build type
(native or cross) and a link type (static or shared).

This lays the groundwork for building binaries for Linux and macOS.

PR #5515 <https://github.com/Genymobile/scrcpy/pull/5515>
2024-11-24 15:41:13 +01:00