mirror of
https://github.com/Genymobile/scrcpy.git
synced 2025-12-18 14:04:20 +01:00
Update code style
Limit source code to 80 chars, and declare functions return type and modifiers on a separate line. This allows to avoid very long lines, and all function names are aligned. (We do this on VLC, and I like it.)
This commit is contained in:
@@ -51,8 +51,10 @@ static struct input_manager input_manager = {
|
||||
//
|
||||
// <https://bugzilla.libsdl.org/show_bug.cgi?id=2077>
|
||||
// <https://stackoverflow.com/a/40693139/1987178>
|
||||
static int event_watcher(void *data, SDL_Event *event) {
|
||||
if (event->type == SDL_WINDOWEVENT && event->window.event == SDL_WINDOWEVENT_RESIZED) {
|
||||
static int
|
||||
event_watcher(void *data, SDL_Event *event) {
|
||||
if (event->type == SDL_WINDOWEVENT
|
||||
&& event->window.event == SDL_WINDOWEVENT_RESIZED) {
|
||||
// called from another thread, not very safe, but it's a workaround!
|
||||
screen_render(&screen);
|
||||
}
|
||||
@@ -60,12 +62,14 @@ static int event_watcher(void *data, SDL_Event *event) {
|
||||
}
|
||||
#endif
|
||||
|
||||
static SDL_bool is_apk(const char *file) {
|
||||
static SDL_bool
|
||||
is_apk(const char *file) {
|
||||
const char *ext = strrchr(file, '.');
|
||||
return ext && !strcmp(ext, ".apk");
|
||||
}
|
||||
|
||||
static SDL_bool event_loop(void) {
|
||||
static SDL_bool
|
||||
event_loop(void) {
|
||||
#ifdef CONTINUOUS_RESIZING_WORKAROUND
|
||||
SDL_AddEventWatch(event_watcher, NULL);
|
||||
#endif
|
||||
@@ -104,14 +108,17 @@ static SDL_bool event_loop(void) {
|
||||
input_manager_process_key(&input_manager, &event.key);
|
||||
break;
|
||||
case SDL_MOUSEMOTION:
|
||||
input_manager_process_mouse_motion(&input_manager, &event.motion);
|
||||
input_manager_process_mouse_motion(&input_manager,
|
||||
&event.motion);
|
||||
break;
|
||||
case SDL_MOUSEWHEEL:
|
||||
input_manager_process_mouse_wheel(&input_manager, &event.wheel);
|
||||
input_manager_process_mouse_wheel(&input_manager,
|
||||
&event.wheel);
|
||||
break;
|
||||
case SDL_MOUSEBUTTONDOWN:
|
||||
case SDL_MOUSEBUTTONUP:
|
||||
input_manager_process_mouse_button(&input_manager, &event.button);
|
||||
input_manager_process_mouse_button(&input_manager,
|
||||
&event.button);
|
||||
break;
|
||||
case SDL_DROPFILE: {
|
||||
file_handler_action_t action;
|
||||
@@ -128,7 +135,8 @@ static SDL_bool event_loop(void) {
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
static process_t set_show_touches_enabled(const char *serial, SDL_bool enabled) {
|
||||
static process_t
|
||||
set_show_touches_enabled(const char *serial, SDL_bool enabled) {
|
||||
const char *value = enabled ? "1" : "0";
|
||||
const char *const adb_cmd[] = {
|
||||
"shell", "settings", "put", "system", "show_touches", value
|
||||
@@ -136,12 +144,14 @@ static process_t set_show_touches_enabled(const char *serial, SDL_bool enabled)
|
||||
return adb_execute(serial, adb_cmd, ARRAY_LEN(adb_cmd));
|
||||
}
|
||||
|
||||
static void wait_show_touches(process_t process) {
|
||||
static void
|
||||
wait_show_touches(process_t process) {
|
||||
// reap the process, ignore the result
|
||||
process_check_success(process, "show_touches");
|
||||
}
|
||||
|
||||
static SDL_LogPriority sdl_priority_from_av_level(int level) {
|
||||
static SDL_LogPriority
|
||||
sdl_priority_from_av_level(int level) {
|
||||
switch (level) {
|
||||
case AV_LOG_PANIC:
|
||||
case AV_LOG_FATAL:
|
||||
@@ -175,7 +185,8 @@ av_log_callback(void *avcl, int level, const char *fmt, va_list vl) {
|
||||
SDL_free(local_fmt);
|
||||
}
|
||||
|
||||
SDL_bool scrcpy(const struct scrcpy_options *options) {
|
||||
SDL_bool
|
||||
scrcpy(const struct scrcpy_options *options) {
|
||||
SDL_bool record = !!options->record_filename;
|
||||
if (!server_start(&server, options->serial, options->port,
|
||||
options->max_size, options->bit_rate, options->crop,
|
||||
@@ -208,9 +219,9 @@ SDL_bool scrcpy(const struct scrcpy_options *options) {
|
||||
char device_name[DEVICE_NAME_FIELD_LENGTH];
|
||||
struct size frame_size;
|
||||
|
||||
// screenrecord does not send frames when the screen content does not change
|
||||
// therefore, we transmit the screen size before the video stream, to be able
|
||||
// to init the window immediately
|
||||
// screenrecord does not send frames when the screen content does not
|
||||
// change therefore, we transmit the screen size before the video stream,
|
||||
// to be able to init the window immediately
|
||||
if (!device_read_info(device_socket, device_name, &frame_size)) {
|
||||
server_stop(&server);
|
||||
ret = SDL_FALSE;
|
||||
@@ -273,7 +284,8 @@ SDL_bool scrcpy(const struct scrcpy_options *options) {
|
||||
goto finally_destroy_controller;
|
||||
}
|
||||
|
||||
if (!screen_init_rendering(&screen, device_name, frame_size, options->always_on_top)) {
|
||||
if (!screen_init_rendering(&screen, device_name, frame_size,
|
||||
options->always_on_top)) {
|
||||
ret = SDL_FALSE;
|
||||
goto finally_stop_and_join_controller;
|
||||
}
|
||||
@@ -328,7 +340,8 @@ finally_destroy_server:
|
||||
wait_show_touches(proc_show_touches);
|
||||
}
|
||||
LOGI("Disable show_touches");
|
||||
proc_show_touches = set_show_touches_enabled(options->serial, SDL_FALSE);
|
||||
proc_show_touches = set_show_touches_enabled(options->serial,
|
||||
SDL_FALSE);
|
||||
wait_show_touches(proc_show_touches);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user