mirror of
https://github.com/Genymobile/scrcpy.git
synced 2026-04-21 01:33:36 +00:00
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>
47 lines
1.1 KiB
C
47 lines
1.1 KiB
C
#ifndef SC_DISCONNECT
|
|
#define SC_DISCONNECT
|
|
|
|
#include "common.h"
|
|
|
|
#include "SDL3/SDL_surface.h"
|
|
#include "util/tick.h"
|
|
#include "util/thread.h"
|
|
|
|
// Tool to handle loading the icon and signal timeout when the device is
|
|
// unexpectedly disconnected
|
|
struct sc_disconnect {
|
|
sc_tick deadline;
|
|
|
|
struct sc_thread thread;
|
|
struct sc_mutex mutex;
|
|
struct sc_cond cond;
|
|
bool interrupted;
|
|
|
|
const struct sc_disconnect_callbacks *cbs;
|
|
void *cbs_userdata;
|
|
};
|
|
|
|
struct sc_disconnect_callbacks {
|
|
// Called when the disconnected icon is loaded
|
|
void (*on_icon_loaded)(struct sc_disconnect *d, SDL_Surface *icon,
|
|
void *userdata);
|
|
|
|
// Called when the timeout expired (the scrcpy window must be closed)
|
|
void (*on_timeout)(struct sc_disconnect *d, void *userdata);
|
|
};
|
|
|
|
bool
|
|
sc_disconnect_start(struct sc_disconnect *d, sc_tick deadline,
|
|
const struct sc_disconnect_callbacks *cbs,
|
|
void *cbs_userdata);
|
|
|
|
void
|
|
sc_disconnect_interrupt(struct sc_disconnect *d);
|
|
|
|
void
|
|
sc_disconnect_join(struct sc_disconnect *d);
|
|
|
|
void
|
|
sc_disconnect_destroy(struct sc_disconnect *d);
|
|
|
|
#endif
|