Pass full options struct to static functions
This avoids to pass specific options values individually. Since these function are static (internal to the file), this is not a problem to make them depend on scrcpy_options. Refs #1623 <https://github.com/Genymobile/scrcpy/pull/1623> Signed-off-by: Romain Vimont <rom@rom1v.com>
This commit is contained in:
parent
74079ea5e4
commit
65d06a3663
1 changed files with 9 additions and 10 deletions
|
@ -170,7 +170,7 @@ enum event_result {
|
||||||
};
|
};
|
||||||
|
|
||||||
static enum event_result
|
static enum event_result
|
||||||
handle_event(SDL_Event *event, bool control) {
|
handle_event(SDL_Event *event, const struct scrcpy_options *options) {
|
||||||
switch (event->type) {
|
switch (event->type) {
|
||||||
case EVENT_STREAM_STOPPED:
|
case EVENT_STREAM_STOPPED:
|
||||||
LOGD("Video stream stopped");
|
LOGD("Video stream stopped");
|
||||||
|
@ -192,7 +192,7 @@ handle_event(SDL_Event *event, bool control) {
|
||||||
screen_handle_window_event(&screen, &event->window);
|
screen_handle_window_event(&screen, &event->window);
|
||||||
break;
|
break;
|
||||||
case SDL_TEXTINPUT:
|
case SDL_TEXTINPUT:
|
||||||
if (!control) {
|
if (!options->control) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
input_manager_process_text_input(&input_manager, &event->text);
|
input_manager_process_text_input(&input_manager, &event->text);
|
||||||
|
@ -204,13 +204,13 @@ handle_event(SDL_Event *event, bool control) {
|
||||||
input_manager_process_key(&input_manager, &event->key);
|
input_manager_process_key(&input_manager, &event->key);
|
||||||
break;
|
break;
|
||||||
case SDL_MOUSEMOTION:
|
case SDL_MOUSEMOTION:
|
||||||
if (!control) {
|
if (!options->control) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
input_manager_process_mouse_motion(&input_manager, &event->motion);
|
input_manager_process_mouse_motion(&input_manager, &event->motion);
|
||||||
break;
|
break;
|
||||||
case SDL_MOUSEWHEEL:
|
case SDL_MOUSEWHEEL:
|
||||||
if (!control) {
|
if (!options->control) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
input_manager_process_mouse_wheel(&input_manager, &event->wheel);
|
input_manager_process_mouse_wheel(&input_manager, &event->wheel);
|
||||||
|
@ -227,7 +227,7 @@ handle_event(SDL_Event *event, bool control) {
|
||||||
input_manager_process_touch(&input_manager, &event->tfinger);
|
input_manager_process_touch(&input_manager, &event->tfinger);
|
||||||
break;
|
break;
|
||||||
case SDL_DROPFILE: {
|
case SDL_DROPFILE: {
|
||||||
if (!control) {
|
if (!options->control) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
file_handler_action_t action;
|
file_handler_action_t action;
|
||||||
|
@ -244,16 +244,15 @@ handle_event(SDL_Event *event, bool control) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
event_loop(bool display, bool control) {
|
event_loop(const struct scrcpy_options *options) {
|
||||||
(void) display;
|
|
||||||
#ifdef CONTINUOUS_RESIZING_WORKAROUND
|
#ifdef CONTINUOUS_RESIZING_WORKAROUND
|
||||||
if (display) {
|
if (options->display) {
|
||||||
SDL_AddEventWatch(event_watcher, NULL);
|
SDL_AddEventWatch(event_watcher, NULL);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
SDL_Event event;
|
SDL_Event event;
|
||||||
while (SDL_WaitEvent(&event)) {
|
while (SDL_WaitEvent(&event)) {
|
||||||
enum event_result result = handle_event(&event, control);
|
enum event_result result = handle_event(&event, options);
|
||||||
switch (result) {
|
switch (result) {
|
||||||
case EVENT_RESULT_STOPPED_BY_USER:
|
case EVENT_RESULT_STOPPED_BY_USER:
|
||||||
return true;
|
return true;
|
||||||
|
@ -444,7 +443,7 @@ scrcpy(const struct scrcpy_options *options) {
|
||||||
|
|
||||||
input_manager_init(&input_manager, options);
|
input_manager_init(&input_manager, options);
|
||||||
|
|
||||||
ret = event_loop(options->display, options->control);
|
ret = event_loop(options);
|
||||||
LOGD("quit...");
|
LOGD("quit...");
|
||||||
|
|
||||||
screen_destroy(&screen);
|
screen_destroy(&screen);
|
||||||
|
|
Loading…
Reference in a new issue