Compare commits

..

8 Commits

Author SHA1 Message Date
Romain Vimont
0589acfb78 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-15 14:37:58 +01:00
Romain Vimont
a124a8756e 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-11 15:41:18 +01:00
Romain Vimont
9a50c02bf4 Add utility to push an SDL event with data
PR #6662 <https://github.com/Genymobile/scrcpy/pull/6662>
2026-03-11 15:41:15 +01:00
Romain Vimont
28ba0912d2 Add function to delete current texture
PR #6662 <https://github.com/Genymobile/scrcpy/pull/6662>
2026-03-11 15:41:12 +01:00
Romain Vimont
2145f6ddbd 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-11 15:41:07 +01:00
Romain Vimont
7f5fd43e4e 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-11 15:41:04 +01:00
Romain Vimont
8f51e23645 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-11 15:41:01 +01:00
Romain Vimont
c4aefde96f Rename icon.png to scrcpy.png
This makes the icon name consistent everywhere.

PR #6662 <https://github.com/Genymobile/scrcpy/pull/6662>
2026-03-11 15:40:58 +01:00
6 changed files with 6 additions and 10 deletions

View File

@@ -6,7 +6,7 @@
#include "util/thread.h"
bool
sc_push_event_impl(uint32_t type, void *ptr, const char *name) {
sc_push_event_impl(uint32_t type, void* ptr, const char *name) {
SDL_Event event = {
.user = {
.type = type,

View File

@@ -24,7 +24,7 @@ enum {
};
bool
sc_push_event_impl(uint32_t type, void *ptr, const char *name);
sc_push_event_impl(uint32_t type, void* ptr, const char *name);
#define sc_push_event(TYPE) sc_push_event_impl(TYPE, NULL, # TYPE)
#define sc_push_event_with_data(TYPE, PTR) sc_push_event_impl(TYPE, PTR, # TYPE)

View File

@@ -1002,15 +1002,11 @@ sc_screen_handle_disconnection(struct sc_screen *screen) {
SDL_Event event;
while (SDL_WaitEvent(&event)) {
switch (event.type) {
case SDL_EVENT_WINDOW_EXPOSED:
sc_screen_render(screen, true);
break;
case SC_EVENT_DISCONNECTED_ICON_LOADED: {
SDL_Surface *icon_disconnected = event.user.data1;
assert(icon_disconnected);
bool ok = sc_texture_set_from_surface(&screen->tex,
icon_disconnected);
bool ok = sc_texture_set_from_surface(&screen->tex, icon_disconnected);
if (ok) {
screen->content_size.width = icon_disconnected->w;
screen->content_size.height = icon_disconnected->h;
@@ -1023,6 +1019,9 @@ sc_screen_handle_disconnection(struct sc_screen *screen) {
sc_icon_destroy(icon_disconnected);
break;
}
case SDL_EVENT_WINDOW_EXPOSED:
sc_screen_render(screen, true);
break;
case SC_EVENT_DISCONNECTED_TIMEOUT:
LOGD("Closing after device disconnection");
return;

View File

@@ -42,6 +42,5 @@ ninja -C "$LINUX_BUILD_DIR"
mkdir -p "$LINUX_BUILD_DIR/dist"
cp "$LINUX_BUILD_DIR"/app/scrcpy "$LINUX_BUILD_DIR/dist/"
cp app/data/scrcpy.png "$LINUX_BUILD_DIR/dist/"
cp app/data/disconnected.png "$LINUX_BUILD_DIR/dist/"
cp app/scrcpy.1 "$LINUX_BUILD_DIR/dist/"
cp -r "$ADB_INSTALL_DIR"/. "$LINUX_BUILD_DIR/dist/"

View File

@@ -42,6 +42,5 @@ ninja -C "$MACOS_BUILD_DIR"
mkdir -p "$MACOS_BUILD_DIR/dist"
cp "$MACOS_BUILD_DIR"/app/scrcpy "$MACOS_BUILD_DIR/dist/"
cp app/data/scrcpy.png "$MACOS_BUILD_DIR/dist/"
cp app/data/disconnected.png "$MACOS_BUILD_DIR/dist/"
cp app/scrcpy.1 "$MACOS_BUILD_DIR/dist/"
cp -r "$ADB_INSTALL_DIR"/. "$MACOS_BUILD_DIR/dist/"

View File

@@ -50,7 +50,6 @@ mkdir -p "$WINXX_BUILD_DIR/dist"
cp "$WINXX_BUILD_DIR"/app/scrcpy.exe "$WINXX_BUILD_DIR/dist/"
cp app/data/scrcpy-noconsole.vbs "$WINXX_BUILD_DIR/dist/"
cp app/data/scrcpy.png "$WINXX_BUILD_DIR/dist/"
cp app/data/disconnected.png "$WINXX_BUILD_DIR/dist/"
cp app/data/open_a_terminal_here.bat "$WINXX_BUILD_DIR/dist/"
cp "$DEPS_INSTALL_DIR"/bin/*.dll "$WINXX_BUILD_DIR/dist/"
cp -r "$ADB_INSTALL_DIR"/. "$WINXX_BUILD_DIR/dist/"