mirror of
https://github.com/Genymobile/scrcpy.git
synced 2024-09-19 05:31:21 +02:00
Add a mechanism to report errors on event handling
This paves the way to workaround HiDPI issues, which may recreate the renderer and texture (which may fail) on window event.
This commit is contained in:
parent
04a31ef7b9
commit
f3b7712ea2
3 changed files with 12 additions and 3 deletions
|
@ -128,6 +128,7 @@ enum event_result {
|
||||||
EVENT_RESULT_CONTINUE,
|
EVENT_RESULT_CONTINUE,
|
||||||
EVENT_RESULT_STOPPED_BY_USER,
|
EVENT_RESULT_STOPPED_BY_USER,
|
||||||
EVENT_RESULT_STOPPED_BY_EOS,
|
EVENT_RESULT_STOPPED_BY_EOS,
|
||||||
|
EVENT_RESULT_STOPPED_BY_ERROR,
|
||||||
};
|
};
|
||||||
|
|
||||||
static enum event_result
|
static enum event_result
|
||||||
|
@ -150,7 +151,9 @@ handle_event(SDL_Event *event, bool control) {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SDL_WINDOWEVENT:
|
case SDL_WINDOWEVENT:
|
||||||
screen_handle_window_event(&screen, &event->window);
|
if (!screen_handle_window_event(&screen, &event->window)) {
|
||||||
|
return EVENT_RESULT_STOPPED_BY_ERROR;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case SDL_TEXTINPUT:
|
case SDL_TEXTINPUT:
|
||||||
if (!control) {
|
if (!control) {
|
||||||
|
@ -222,6 +225,9 @@ event_loop(bool display, bool control) {
|
||||||
case EVENT_RESULT_STOPPED_BY_EOS:
|
case EVENT_RESULT_STOPPED_BY_EOS:
|
||||||
LOGW("Device disconnected");
|
LOGW("Device disconnected");
|
||||||
return false;
|
return false;
|
||||||
|
case EVENT_RESULT_STOPPED_BY_ERROR:
|
||||||
|
LOGC("Stopping due to unrecoverable error");
|
||||||
|
return false;
|
||||||
case EVENT_RESULT_CONTINUE:
|
case EVENT_RESULT_CONTINUE:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -518,7 +518,7 @@ screen_resize_to_pixel_perfect(struct screen *screen) {
|
||||||
content_size.height);
|
content_size.height);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
bool
|
||||||
screen_handle_window_event(struct screen *screen,
|
screen_handle_window_event(struct screen *screen,
|
||||||
const SDL_WindowEvent *event) {
|
const SDL_WindowEvent *event) {
|
||||||
switch (event->event) {
|
switch (event->event) {
|
||||||
|
@ -558,6 +558,8 @@ screen_handle_window_event(struct screen *screen,
|
||||||
apply_windowed_size(screen);
|
apply_windowed_size(screen);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct point
|
struct point
|
||||||
|
|
|
@ -111,7 +111,8 @@ void
|
||||||
screen_set_rotation(struct screen *screen, unsigned rotation);
|
screen_set_rotation(struct screen *screen, unsigned rotation);
|
||||||
|
|
||||||
// react to window events
|
// react to window events
|
||||||
void
|
// return true on success, false on unrecoverable error
|
||||||
|
bool
|
||||||
screen_handle_window_event(struct screen *screen, const SDL_WindowEvent *event);
|
screen_handle_window_event(struct screen *screen, const SDL_WindowEvent *event);
|
||||||
|
|
||||||
// convert point from window coordinates to frame coordinates
|
// convert point from window coordinates to frame coordinates
|
||||||
|
|
Loading…
Reference in a new issue