mirror of
https://github.com/Genymobile/scrcpy.git
synced 2026-04-21 01:33:36 +00:00
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. Refs #6754 <https://github.com/Genymobile/scrcpy/pull/6754>
This commit is contained in:
parent
c527bc76de
commit
07f8eb0ec6
1 changed files with 13 additions and 13 deletions
|
|
@ -99,6 +99,15 @@ static BOOL WINAPI windows_ctrl_handler(DWORD ctrl_type) {
|
|||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
sdl_configure_ctrl_c_windows(void) {
|
||||
// Clean up properly on Ctrl+C on Windows
|
||||
bool ok = SetConsoleCtrlHandler(windows_ctrl_handler, TRUE);
|
||||
if (!ok) {
|
||||
LOGW("Could not set Ctrl+C handler");
|
||||
}
|
||||
}
|
||||
#endif // _WIN32
|
||||
|
||||
static void
|
||||
|
|
@ -144,17 +153,6 @@ sdl_set_hints(const char *render_driver, bool disable_screensaver) {
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
sdl_configure(void) {
|
||||
#ifdef _WIN32
|
||||
// Clean up properly on Ctrl+C on Windows
|
||||
bool ok = SetConsoleCtrlHandler(windows_ctrl_handler, TRUE);
|
||||
if (!ok) {
|
||||
LOGW("Could not set Ctrl+C handler");
|
||||
}
|
||||
#endif // _WIN32
|
||||
}
|
||||
|
||||
static enum scrcpy_exit_code
|
||||
event_loop(struct scrcpy *s, bool has_screen) {
|
||||
SDL_Event event;
|
||||
|
|
@ -480,6 +478,10 @@ scrcpy(struct scrcpy_options *options) {
|
|||
return SCRCPY_EXIT_FAILURE;
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
sdl_configure_ctrl_c_windows();
|
||||
#endif
|
||||
|
||||
// Set hints before starting the server thread to avoid race conditions in
|
||||
// SDL
|
||||
sdl_set_hints(options->render_driver, options->disable_screensaver);
|
||||
|
|
@ -531,8 +533,6 @@ scrcpy(struct scrcpy_options *options) {
|
|||
}
|
||||
}
|
||||
|
||||
sdl_configure();
|
||||
|
||||
// Await for server without blocking Ctrl+C handling
|
||||
bool connected;
|
||||
if (!await_for_server(&connected)) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue