Skip to content

Display disconnected icon before closing#6662

Open
rom1v wants to merge 8 commits intodevfrom
disconnected
Open

Display disconnected icon before closing#6662
rom1v wants to merge 8 commits intodevfrom
disconnected

Conversation

@rom1v
Copy link
Collaborator

@rom1v rom1v commented Feb 9, 2026

When the connection to the device is 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.

The icon replaces the screen content immediately:

scrcpy_disconnected_small

On purpose, the last frame is immediately removed. For example, during a presentation, the device might inadvertently show some private content on screen, the user should be able to immediately disconnects the USB cable to remove the content.


I intentionally did not add an option to configure the timeout delay (it's hardcoded to 2 seconds), there are already a lot of options…

The implementation is a bit "ad hoc", but hey it works.

I replaced SCRCPY_ICON_PATH (which defined the unique scrcpy icon) with SCRCPY_ICON_DIR now that there are several icons.


I get the (temporary) disconnected icon from a free icons website (I can't remember where).

@varlesh As the author of the main icon (#1987 (comment)), may I ask you to create an icon for this use case?

This is an "Android disconnection"

  • in normal mode, it's the adb socket (either over USB or wifi)
  • in OTG mode, it's the AOA connection (over USB)

so this is not specifically for USB or Wifi (and even less wall socket). If it needs to represent something physical, USB is probably fine though.

@rom1v
Copy link
Collaborator Author

rom1v commented Feb 23, 2026

I fixed some issues and updated the icon.

The new icon is derived from this one.

I think it makes it clear that the communication with the device is lost:

scrcpy_disconnected_2_small

Copy link

@anotheruserofgithub anotheruserofgithub left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, first I noticed a few possible issues.

Copy link

@anotheruserofgithub anotheruserofgithub left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then some possible (debatable) improvements.

Copy link

@anotheruserofgithub anotheruserofgithub left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One last suggested improvement from my side.

@rom1v
Copy link
Collaborator Author

rom1v commented Feb 25, 2026

When the disconnected icon is shown, we should still handle events (to leave fullscreen mode for example).

I will need to rework that before merging.

@rom1v rom1v changed the title Display disconnected icon before closing [Draft] Display disconnected icon before closing Feb 25, 2026
rom1v added 5 commits March 11, 2026 15:40
This makes the icon name consistent everywhere.

PR #6662 <#6662>
Add a utility function to create a full path from a directory and a
filename.

PR #6662 <#6662>
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 <#6662>
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 <#6662>
rom1v added a commit that referenced this pull request Mar 15, 2026
rom1v added a commit that referenced this pull request Mar 15, 2026
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 <#6662>
rom1v added a commit that referenced this pull request Mar 15, 2026
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 <#6662>
@rom1v rom1v changed the title [Draft] Display disconnected icon before closing Display disconnected icon before closing Mar 15, 2026
@rom1v
Copy link
Collaborator Author

rom1v commented Mar 15, 2026

I will need to rework that before merging.

Done. Ready to be merged.

(Please review and test if you can)

Copy link

@anotheruserofgithub anotheruserofgithub left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small details of style (just to nitpick).

@anotheruserofgithub
Copy link

I still couldn't test for real, I'd need to buy a new phone… one day.

rom1v added 3 commits March 16, 2026 10:52
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 <#6662>
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 <#6662>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants