Commit Graph

2987 Commits

Author SHA1 Message Date
Romain Vimont
d6ffa2dbc6 Move Ctrl+C handler configuration
The function sdl_configure() now only sets the Ctrl+C handler on
Windows. Define it only on Windows, and call it earlier.
2026-04-06 12:16:21 +02:00
Romain Vimont
6f636fb2b5 Enable screensaver using hints
SDL disables the screensaver by default. It can be configured via a
hint instead of explicitly calling SDL_EnableScreenSaver().
2026-04-06 12:16:21 +02:00
Romain Vimont
d44cba26f2 Always set hints
Some hints can be useful even when window is dsabled.
2026-04-06 12:16:21 +02:00
ayooh
930cf6a1bc Fix screensaver disabled unexpectedly
By default, scrcpy does not prevent the screensaver from running on the
computer unless the `--disable-screensaver` option is passed.

Otherwise, SDL_EnableScreenSaver() must be called explicitly, since SDL
disables the screensaver by default.

Refs <https://wiki.libsdl.org/SDL3/SDL_DisableScreenSaver>
TODO ref 6754.

Signed-off-by: Romain Vimont <rom@rom1v.com>
2026-04-06 12:16:21 +02:00
Romain Vimont
5fedc79530 Fix device rotation shortcut
MOD+r was never handled because it was consumed by the MOD+Shift+r
handler.
2026-04-03 21:35:26 +02:00
Romain Vimont
df91514112 Fix camera failure handling
The camera capture must be closed on error (isClosed() returns the value
of the disconnected flag).
2026-03-31 20:03:46 +02:00
Romain Vimont
a6c16180ee Fix display size monitor synchronization
Do not unlock the mutex between reading and writing to
sessionDisplaySize.
2026-03-31 20:03:44 +02:00
Romain Vimont
57a40917d4 Remove trailing comma
Fix typo.
2026-03-31 19:54:46 +02:00
Romain Vimont
edc81b4a1c Do not fallback to main display
If the virtual display is not initialized yet, do not send events to the
main display.
2026-03-31 19:54:13 +02:00
Romain Vimont
ecbe914351 Enable gradle cache
This speeds up server builds during development.
2026-03-24 20:57:24 +01:00
Romain Vimont
1c68d79eea Upgrade AGP (9.1.0) and Gradle (9.3.1) 2026-03-24 20:56:19 +01:00
Romain Vimont
89b63f081f Set latency only for API >= 26
Contrary to what the previous commit message says, KEY_LATENCY was
introduced in API 26, not 23.
2026-03-24 20:55:14 +01:00
Romain Vimont
72d1aedcaa Set priority and latency only for API level >= 23
The KEY_PRIORITY and KEY_LATENCY constants were introduced in Android
API level 23.
2026-03-20 17:52:12 +01:00
Romain Vimont
740460d04e Rename "hole" to "uninitialized" in vector APIs
The sc_vector and sc_vecdeque utilities define insert_hole() and
push_hole() functions to insert uninitialized items (to be initialized
after the call).

However, "hole" is a poor name. Rename it to "uninitialized" for
clarity.
2026-03-17 20:46:40 +01:00
Romain Vimont
c2e1cf0884 Fix icon link in README
The icon has been renamed by 8a4955ec57,
fix its reference.

Refs #6662 comment <https://github.com/Genymobile/scrcpy/pull/6662#issuecomment-4077308676>
2026-03-17 20:02:25 +01:00
Romain Vimont
a4000a1487 Display disconnected icon before closing
Previously, when the connection to the device was lost while mirroring,
the window closed immediately, suggesting scrcpy had crashed.

To make it clear that a disconnection occurred, display a disconnected
icon for 2 seconds before closing the window.

PR #6662 <https://github.com/Genymobile/scrcpy/pull/6662>
2026-03-17 18:40:35 +01:00
Romain Vimont
6bf8b8d957 Only reject RUN_ON_MAIN_THREAD events on quit
Use SDL_PeepEvents() to consume only SC_EVENT_RUN_ON_MAIN_THREAD events.
Other events are not dropped and can still be processed later.

PR #6662 <https://github.com/Genymobile/scrcpy/pull/6662>
2026-03-17 18:40:35 +01:00
Romain Vimont
fe1fd557f7 Add utility to push an SDL event with data
PR #6662 <https://github.com/Genymobile/scrcpy/pull/6662>
2026-03-17 18:40:35 +01:00
Romain Vimont
a2055c0a47 Add function to delete current texture
PR #6662 <https://github.com/Genymobile/scrcpy/pull/6662>
2026-03-17 18:40:35 +01:00
Romain Vimont
6ca1b79228 Add filename parameter to icon loading
Replace scrcpy_icon_load(), which loaded the unique scrcpy app icon,
with sc_icon_load(filename), which can load any icon from the icons
directory.

PR #6662 <https://github.com/Genymobile/scrcpy/pull/6662>
2026-03-17 18:40:34 +01:00
Romain Vimont
d6590738be Replace SCRCPY_ICON_PATH with SCRCPY_ICON_DIR
SCRCPY_ICON_PATH defined the path of the scrcpy app icon.
SCRCPY_ICON_DIR defines the directory where scrcpy icons reside.

This change prepares for the addition of other icons.

PR #6662 <https://github.com/Genymobile/scrcpy/pull/6662>
2026-03-17 18:40:34 +01:00
Romain Vimont
c994f9df6a Extract function to build file paths
Add a utility function to create a full path from a directory and a
filename.

PR #6662 <https://github.com/Genymobile/scrcpy/pull/6662>
2026-03-17 18:40:34 +01:00
Romain Vimont
8a4955ec57 Rename icon.png to scrcpy.png
This makes the icon name consistent everywhere.

PR #6662 <https://github.com/Genymobile/scrcpy/pull/6662>
2026-03-17 18:40:34 +01:00
chengjiansu
bad2183087 Fix orientation error message
When running `scrcpy --capture-orientation=@100`, the error shown is:

> Unsupported orientation: @100 (expected 0, 90, 180, 270, flip0, flip90, flip180 or flip270)

We should tell the user that the error is 100, not @100.

Moreover, the function parse_orientation() should not access the
`optarg` global variable.

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

Signed-off-by: Romain Vimont <rom@rom1v.com>
2026-03-10 20:14:23 +01:00
Romain Vimont
e17a885f32 Draw a dark square when no texture is rendered
Draw a dark 10x10 square in the top-right corner to distinguish a black
frame from the absence of a frame (useful for debugging).

PR #6694 <https://github.com/Genymobile/scrcpy/pull/6694>
2026-03-10 20:11:04 +01:00
Romain Vimont
691a63761c Open the scrcpy window earlier
Previously, the window was opened only once the first frame was
available. Instead, open it as soon as the frame dimensions are known.

This is especially useful when the encoder does not produce an initial
frame while the phone is turned off (e.g., with --no-power-on).

Fixes #6546 <https://github.com/Genymobile/scrcpy/issues/6546>
PR #6694 <https://github.com/Genymobile/scrcpy/pull/6694>
2026-03-10 20:11:04 +01:00
Romain Vimont
57af6b9209 Track window shown state
Use a flag to indicate whether the window is currently shown.

This replaces the old has_video_window flag, which was true only when
the window was shown and video was enabled.

This will simplify performing actions only when the window is currently
shown.

PR #6694 <https://github.com/Genymobile/scrcpy/pull/6694>
2026-03-10 20:11:04 +01:00
Romain Vimont
0597c5eb8d Remove unnecessary void cast
The ctx variable is used.

PR #6694 <https://github.com/Genymobile/scrcpy/pull/6694>
2026-03-10 20:11:04 +01:00
Romain Vimont
10e0c3226c Fix typo in documentation
Refs #6667 comment <https://github.com/Genymobile/scrcpy/pull/6667#pullrequestreview-3848495119>

Suggested-by: anotheruserofgithub
2026-02-24 16:01:00 +01:00
Romain Vimont
323549e82f Prevent build from falling back to system libs
Ensure that if a file or function is not found, the build does not
attempt to use system libraries. Falling back could result in using
libraries that are incompatible due to wrong versions or features.

PR #6671 <https://github.com/Genymobile/scrcpy/pull/6671>
2026-02-21 12:24:41 +01:00
Romain Vimont
90d11810e3 Set MediaCodec KEY_LATENCY to the minimum value
The encoder must output a frame as soon as one frame is queued.

Refs <https://developer.android.com/reference/android/media/MediaFormat#KEY_LATENCY>
Refs #6238 comment <https://github.com/Genymobile/scrcpy/issues/6238#issuecomment-3828402687>
PR #6670 <https://github.com/Genymobile/scrcpy/pull/6670>
2026-02-21 12:21:54 +01:00
Romain Vimont
1f19ec4aec Set MediaCodec KEY_PRIORITY to real-time (0)
Refs <https://developer.android.com/reference/android/media/MediaFormat#KEY_PRIORITY>
Refs #6238 comment <https://github.com/Genymobile/scrcpy/issues/6238#issuecomment-3828402687>
PR #6670 <https://github.com/Genymobile/scrcpy/pull/6670>
2026-02-21 12:21:44 +01:00
Romain Vimont
8b0206f7be Keep Windows terminal open on error
If scrcpy is launched by double-clicking scrcpy.exe in Windows Explorer,
automatically set --pause-on-exit=if-error.

Without this, the terminal would close immediately, preventing the user
from seeing the error.

Also remove scrcpy-console.bat, which is now useless.

PR #6667 <https://github.com/Genymobile/scrcpy/pull/6667>
2026-02-21 12:17:31 +01:00
Romain Vimont
f91fa56593 Fix segfault on rotation while recording
The packet sink push_session() callback is optional, but it was called
unconditionnally even when not implemented, leading to a segfault.

Bug introduced by commit 78cba1b7c2.

Fixes #6687 <https://github.com/Genymobile/scrcpy/issues/6687>
2026-02-21 10:45:12 +01:00
Romain Vimont
23710e04c1 Disable audio stream with fatal error Throwable
Only an AudioCaptureException should disable the audio stream without
making scrcpy exit (it is not a fatal error).

A ConfigurationException or any other Throwable must be considered a
fatal error.

                               BEFORE      AFTER
  AudioCaptureException:    non-fatal  non-fatal
  ConfigurationException:       fatal      fatal
  any other Throwable:      non-fatal      fatal

Refs #6600 comment <https://github.com/Genymobile/scrcpy/issues/6600#issuecomment-3744934826>
2026-02-12 20:20:52 +01:00
Romain Vimont
51cbd9a5bc Detect TCP devices provided by mDNS
Their serial is not in the form ip:port, but rather a complex string
containing "adb-tls-connect".

Fixes #6248 <https://github.com/Genymobile/scrcpy/issues/6248>
PR #6665 <https://github.com/Genymobile/scrcpy/pull/6665>
2026-02-12 20:08:46 +01:00
Romain Vimont
82e102e036 Improve adb devices parsing
`adb devices -l` prints one device per line, containing, separated by
spaces:
 - the device serial,
 - the device state,
 - a list of key:value pairs.

However, the device serial itself may contain spaces, making a simple
split ambiguous.

To avoid ambiguity, parse the string backwards:
 - first, parse all the trailing values until the device state,
   identified using a list of well-known values;
 - finally, treat the remaining leading token as the device serial.

Fixes #3537 <https://github.com/Genymobile/scrcpy/issues/3537>
Refs #6248 <https://github.com/Genymobile/scrcpy/issues/6248>
PR #6664 <https://github.com/Genymobile/scrcpy/pull/6664>
2026-02-12 20:06:11 +01:00
Romain Vimont
e39d7a06e4 Remove sc_str_quote()
It is no longer used.

PR #6663 <https://github.com/Genymobile/scrcpy/pull/6663>
2026-02-12 20:00:59 +01:00
Romain Vimont
be34f37a57 Use proper argument serialization for Windows
Replace the hacky implementation for executing simple commands on
Windows with the proper serialization mechanism.

PR #6663 <https://github.com/Genymobile/scrcpy/pull/6663>
2026-02-12 20:00:59 +01:00
Romain Vimont
f7e74dd04d Add utility to serialize windows arguments
Add a function to convert an argv array into a single escaped string to
be passed to CreateProcess() on Windows.

Refs <https://learn.microsoft.com/en-us/cpp/c-language/parsing-c-command-line-arguments>
Refs <https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-createprocessw>
PR #6663 <https://github.com/Genymobile/scrcpy/pull/6663>
2026-02-12 20:00:39 +01:00
Romain Vimont
bb6d1c6348 Set Windows console code page to UTF-8
Refs #6663 comment <https://github.com/Genymobile/scrcpy/pull/6663#issuecomment-3875602219>

Suggested-by: Simon Chan <1330321+yume-chan@users.noreply.github.com>
2026-02-10 08:27:22 +01:00
Romain Vimont
2301f64158 Make icon loading failure non-fatal
Do not close scrcpy if the content icon cannot be loaded, even when
video playback is disabled.
2026-02-09 18:36:54 +01:00
Romain Vimont
d7f0e22067 Make screen event handler return void
The function always returned true.
2026-02-09 18:36:54 +01:00
Romain Vimont
77998f543f Rename sc_display to sc_texture
The sc_display component now only handles a texture. Rendering has been
moved to sc_screen.

PR #6651 <https://github.com/Genymobile/scrcpy/pull/6651>
2026-02-09 18:33:57 +01:00
Romain Vimont
c43cc2ddc3 Set display texture from a frame
Add a function to set a texture from an AVFrame on a sc_display.

PR #6651 <https://github.com/Genymobile/scrcpy/pull/6651>
2026-02-09 18:33:52 +01:00
Romain Vimont
1617979549 Set display texture from a surface
Add a function to set a texture from a surface on a sc_display.

PR #6651 <https://github.com/Genymobile/scrcpy/pull/6651>
2026-02-09 18:33:48 +01:00
Romain Vimont
58818dc860 Use floating-point for content location
In SDL3, texture rendering uses SDL_FRect, unlike SDL2 which used
SDL_Rect.

Compute content location using floating-point coordinates from the
start.

PR #6651 <https://github.com/Genymobile/scrcpy/pull/6651>
2026-02-09 18:33:44 +01:00
Romain Vimont
3ef51e691e Factorize icon rendering
Replace SDL "logical rendering" with explicit computation of icon
location, and unify rendering of video frames and icons using the same
common code.

PR #6651 <https://github.com/Genymobile/scrcpy/pull/6651>
2026-02-09 18:33:41 +01:00
Romain Vimont
fb77f8556a Extract function to compute content location
PR #6651 <https://github.com/Genymobile/scrcpy/pull/6651>
2026-02-09 18:33:38 +01:00
Romain Vimont
e3f0c21f2a Use render output size to compute content location
The coordinates of the content to render depend on the render output
size, not the window size in pixels. In theory, the two could differ.

PR #6651 <https://github.com/Genymobile/scrcpy/pull/6651>
2026-02-09 18:33:35 +01:00