Skip to content

fixes #78

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions include/flutter-pi.h
Original file line number Diff line number Diff line change
Expand Up @@ -477,4 +477,6 @@ int flutterpi_respond_to_platform_message(
size_t message_size
);

int flutterpi_schedule_exit(void);

#endif
6 changes: 5 additions & 1 deletion src/compositor.c
Original file line number Diff line number Diff line change
Expand Up @@ -928,10 +928,14 @@ static bool on_present_layers(
}

for_each_unreserved_plane_in_atomic_req(req, plane) {
drmdev_atomic_req_put_plane_property(req, plane->plane->plane_id, "FB", 0);
if ((plane->type == DRM_PLANE_TYPE_PRIMARY) || (plane->type == DRM_PLANE_TYPE_OVERLAY)) {
drmdev_atomic_req_put_plane_property(req, plane->plane->plane_id, "FB_ID", 0);
drmdev_atomic_req_put_plane_property(req, plane->plane->plane_id, "CRTC_ID", 0);
}
}

eglMakeCurrent(flutterpi.egl.display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);

drmdev_atomic_req_commit(req, req_flags, NULL);

cpset_unlock(&compositor->cbs);
Expand Down
37 changes: 33 additions & 4 deletions src/flutter-pi.c
Original file line number Diff line number Diff line change
Expand Up @@ -597,10 +597,10 @@ static int post_platform_task_with_time(
if (pthread_self() != flutterpi.event_loop_thread) {
ok = write(flutterpi.wakeup_event_loop_fd, (uint8_t[8]) {0, 0, 0, 0, 0, 0, 0, 1}, 8);
if (ok < 0) {
perror("[flutter-pi] Error arming main loop for platform task. write");
ok = errno;
goto fail_unlock_event_loop;
}
perror("[flutter-pi] Error arming main loop for platform task. write");
ok = errno;
goto fail_unlock_event_loop;
}
}

if (pthread_self() != flutterpi.event_loop_thread) {
Expand All @@ -615,6 +615,9 @@ static int post_platform_task_with_time(
pthread_mutex_unlock(&flutterpi.event_loop_mutex);
}

fail_free_task:
free(task);

return ok;
}

Expand Down Expand Up @@ -1779,6 +1782,29 @@ static int init_application(void) {
return 0;
}

int flutterpi_schedule_exit(void) {
int ok;

if (pthread_self() != flutterpi.event_loop_thread) {
pthread_mutex_lock(&flutterpi.event_loop_mutex);
}

ok = sd_event_exit(flutterpi.event_loop, 0);
if (ok < 0) {
fprintf(stderr, "[flutter-pi] Could not schedule application exit. sd_event_exit: %s\n", strerror(-ok));
if (pthread_self() != flutterpi.event_loop_thread) {
pthread_mutex_unlock(&flutterpi.event_loop_mutex);
}
return -ok;
}

if (pthread_self() != flutterpi.event_loop_thread) {
pthread_mutex_unlock(&flutterpi.event_loop_mutex);
}

return 0;
}

/**************
* USER INPUT *
**************/
Expand Down Expand Up @@ -2049,6 +2075,9 @@ static int on_libinput_ready(sd_event_source *s, int fd, uint32_t revents, void

rawkb_on_keyevent(glfw_key, keycode, state == LIBINPUT_KEY_STATE_PRESSED ? GLFW_PRESS : GLFW_RELEASE);
}

libinput_event_destroy(event);
event = NULL;
}

if (n_pointer_events > 0) {
Expand Down
1 change: 1 addition & 0 deletions src/platformchannel.c
Original file line number Diff line number Diff line change
Expand Up @@ -1033,6 +1033,7 @@ int platch_send(char *channel, struct platch_obj *object, enum platch_codec resp
goto fail_release_handle;
}

// TODO: This won't work if we're not on the main thread
if (on_response) {
result = flutterpi.flutter.libflutter_engine.FlutterPlatformMessageReleaseResponseHandle(flutterpi.flutter.engine, response_handle);
if (result != kSuccess) {
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/services.c
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ static int on_receive_platform(char *channel, struct platch_obj *object, Flutter
* systemNavigationBarIconBrightness: null / Brightness
*/
} else if (strcmp(object->method, "SystemNavigator.pop") == 0) {
// do nothing
flutterpi_schedule_exit();
}

return platch_respond_not_implemented(responsehandle);
Expand Down