diff options
Diffstat (limited to 'backend')
-rw-r--r-- | backend/drm/backend.c | 6 | ||||
-rw-r--r-- | backend/drm/drm.c | 17 | ||||
-rw-r--r-- | backend/libinput/backend.c | 18 |
3 files changed, 38 insertions, 3 deletions
diff --git a/backend/drm/backend.c b/backend/drm/backend.c index 8859022f..e5614ae2 100644 --- a/backend/drm/backend.c +++ b/backend/drm/backend.c @@ -54,8 +54,10 @@ static void session_signal(struct wl_listener *listener, void *data) { } else { wlr_log(L_INFO, "DRM fd paused"); - // TODO: Actually pause the renderer or something. - // We currently just expect it to fail its next pageflip. + for (size_t i = 0; i < drm->outputs->length; ++i) { + struct wlr_output_state *output = drm->outputs->items[i]; + wlr_drm_output_pause_renderer(output); + } } } diff --git a/backend/drm/drm.c b/backend/drm/drm.c index 5afdf3c3..ca4f56c3 100644 --- a/backend/drm/drm.c +++ b/backend/drm/drm.c @@ -116,6 +116,21 @@ static void wlr_drm_output_end(struct wlr_output_state *output) { output->bo[0] = bo; } +void wlr_drm_output_pause_renderer(struct wlr_output_state *output) { + if (output->state != DRM_OUTPUT_CONNECTED) { + return; + } + + if (output->bo[1]) { + gbm_surface_release_buffer(output->gbm, output->bo[1]); + output->bo[1] = NULL; + } + if (output->bo[0]) { + gbm_surface_release_buffer(output->gbm, output->bo[0]); + output->bo[0] = NULL; + } +} + void wlr_drm_output_start_renderer(struct wlr_output_state *output) { if (output->state != DRM_OUTPUT_CONNECTED) { return; @@ -608,7 +623,7 @@ static void page_flip_handler(int fd, unsigned seq, } output->pageflip_pending = false; - if (output->state == DRM_OUTPUT_CONNECTED) { + if (output->state == DRM_OUTPUT_CONNECTED && state->session->active) { wlr_drm_output_begin(output); wl_signal_emit(&output->wlr_output->events.frame, output->wlr_output); wlr_drm_output_end(output); diff --git a/backend/libinput/backend.c b/backend/libinput/backend.c index 82ba44a6..fedab148 100644 --- a/backend/libinput/backend.c +++ b/backend/libinput/backend.c @@ -86,6 +86,21 @@ static struct wlr_backend_impl backend_impl = { .destroy = wlr_libinput_backend_destroy }; +static void session_signal(struct wl_listener *listener, void *data) { + struct wlr_backend_state *backend = wl_container_of(listener, backend, session_signal); + struct wlr_session *session = data; + + if (!backend->libinput) { + return; + } + + if (session->active) { + libinput_resume(backend->libinput); + } else { + libinput_suspend(backend->libinput); + } +} + struct wlr_backend *wlr_libinput_backend_create(struct wl_display *display, struct wlr_session *session, struct wlr_udev *udev) { assert(display && session && udev); @@ -112,6 +127,9 @@ struct wlr_backend *wlr_libinput_backend_create(struct wl_display *display, state->udev = udev; state->display = display; + state->session_signal.notify = session_signal; + wl_signal_add(&session->session_signal, &state->session_signal); + return backend; error_state: free(state); |