Display disconnected icon before closing#6662
Conversation
|
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:
|
anotheruserofgithub
left a comment
There was a problem hiding this comment.
Hi, first I noticed a few possible issues.
anotheruserofgithub
left a comment
There was a problem hiding this comment.
One last suggested improvement from my side.
|
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. |
Done. Ready to be merged. (Please review and test if you can) |
anotheruserofgithub
left a comment
There was a problem hiding this comment.
Small details of style (just to nitpick).
|
I still couldn't test for real, I'd need to buy a new phone… one day. |
The icon has been renamed by 8a4955e, fix its reference. Refs #6662 comment <#6662 (comment)>
|
@anotheruserofgithub Thank you, fixed: c2e1cf0 |
The icon has been renamed by 8a4955e, fix its reference. Refs #6662 comment <#6662 (comment)>
This makes the icon name consistent everywhere. PR #6662 <Genymobile/scrcpy#6662>
Add a utility function to create a full path from a directory and a filename. PR #6662 <Genymobile/scrcpy#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 <Genymobile/scrcpy#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 <Genymobile/scrcpy#6662>
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 <Genymobile/scrcpy#6662>
Use a flag to determine 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 displaying a "disconnected" icon on device disconnection when the window is currently shown. PR #6662 <Genymobile/scrcpy#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 <Genymobile/scrcpy#6662>
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 <Genymobile/scrcpy#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 <Genymobile/scrcpy#6662>
Now that the |
You can no longer cutomize a single icon. Instead, use |

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:
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) withSCRCPY_ICON_DIRnow 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"
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.