From 091de12bf4b91c9326c84a11ce10d51ca41fee0b Mon Sep 17 00:00:00 2001 From: Scott Anderson Date: Wed, 21 Jun 2017 12:47:53 +1200 Subject: Changed session signal to only emit on DRM changes --- example/simple.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'example') diff --git a/example/simple.c b/example/simple.c index f3a66db9..16d8d460 100644 --- a/example/simple.c +++ b/example/simple.c @@ -42,6 +42,8 @@ static void handle_keyboard_key(struct keyboard_state *kbstate, xkb_keysym_t sym, enum wlr_key_state key_state) { if (sym == XKB_KEY_Escape) { kbstate->compositor->exit = true; + } else if (sym >= XKB_KEY_F1 && sym <= XKB_KEY_F12) { + wlr_session_change_vt(kbstate->compositor->session, sym - XKB_KEY_F1 + 1); } } -- cgit v1.2.3 From 55854565dc80352e8aca122a76da21152e428995 Mon Sep 17 00:00:00 2001 From: Scott Anderson Date: Wed, 21 Jun 2017 13:31:29 +1200 Subject: Fixed VT switching --- backend/drm/backend.c | 6 ++++-- backend/drm/drm.c | 17 ++++++++++++++++- backend/libinput/backend.c | 18 ++++++++++++++++++ example/simple.c | 2 +- include/backend/drm.h | 1 + include/backend/libinput.h | 2 ++ 6 files changed, 42 insertions(+), 4 deletions(-) (limited to 'example') 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); diff --git a/example/simple.c b/example/simple.c index 16d8d460..34d9c9b1 100644 --- a/example/simple.c +++ b/example/simple.c @@ -42,7 +42,7 @@ static void handle_keyboard_key(struct keyboard_state *kbstate, xkb_keysym_t sym, enum wlr_key_state key_state) { if (sym == XKB_KEY_Escape) { kbstate->compositor->exit = true; - } else if (sym >= XKB_KEY_F1 && sym <= XKB_KEY_F12) { + } else if (key_state == WLR_KEY_PRESSED && sym >= XKB_KEY_F1 && sym <= XKB_KEY_F12) { wlr_session_change_vt(kbstate->compositor->session, sym - XKB_KEY_F1 + 1); } } diff --git a/include/backend/drm.h b/include/backend/drm.h index 7d90ce57..a4995fa9 100644 --- a/include/backend/drm.h +++ b/include/backend/drm.h @@ -89,5 +89,6 @@ void wlr_drm_scan_connectors(struct wlr_backend_state *state); int wlr_drm_event(int fd, uint32_t mask, void *data); void wlr_drm_output_start_renderer(struct wlr_output_state *output); +void wlr_drm_output_pause_renderer(struct wlr_output_state *output); #endif diff --git a/include/backend/libinput.h b/include/backend/libinput.h index 89286ab8..1e8b9072 100644 --- a/include/backend/libinput.h +++ b/include/backend/libinput.h @@ -16,6 +16,8 @@ struct wlr_backend_state { struct libinput *libinput; struct wl_event_source *input_event; + struct wl_listener session_signal; + list_t *devices; }; -- cgit v1.2.3 From d87574948e839afe6ec0224183c59b633ad0c9a0 Mon Sep 17 00:00:00 2001 From: Scott Anderson Date: Wed, 21 Jun 2017 13:40:09 +1200 Subject: Added VT switching to every example --- example/pointer.c | 2 ++ example/rotation.c | 4 ++++ example/tablet.c | 2 ++ example/touch.c | 2 ++ 4 files changed, 10 insertions(+) (limited to 'example') diff --git a/example/pointer.c b/example/pointer.c index 8735c61e..9aeb41a7 100644 --- a/example/pointer.c +++ b/example/pointer.c @@ -50,6 +50,8 @@ static void handle_keyboard_key(struct keyboard_state *kbstate, xkb_keysym_t sym, enum wlr_key_state key_state) { if (sym == XKB_KEY_Escape) { kbstate->compositor->exit = true; + } else if (key_state == WLR_KEY_PRESSED && sym >= XKB_KEY_F1 && sym <= XKB_KEY_F12) { + wlr_session_change_vt(kbstate->compositor->session, sym - XKB_KEY_F1 + 1); } } diff --git a/example/rotation.c b/example/rotation.c index d7b6b169..412a81ca 100644 --- a/example/rotation.c +++ b/example/rotation.c @@ -123,6 +123,10 @@ static void handle_keyboard_key(struct keyboard_state *kbstate, update_velocities(kbstate->compositor, 0, 16); break; } + + if (sym >= XKB_KEY_F1 && sym <= XKB_KEY_F12) { + wlr_session_change_vt(kbstate->compositor->session, sym - XKB_KEY_F1 + 1); + } } } diff --git a/example/tablet.c b/example/tablet.c index 6be006f0..4d64b638 100644 --- a/example/tablet.c +++ b/example/tablet.c @@ -78,6 +78,8 @@ static void handle_keyboard_key(struct keyboard_state *kbstate, xkb_keysym_t sym, enum wlr_key_state key_state) { if (sym == XKB_KEY_Escape) { kbstate->compositor->exit = true; + } else if (key_state == WLR_KEY_PRESSED && sym >= XKB_KEY_F1 && sym <= XKB_KEY_F12) { + wlr_session_change_vt(kbstate->compositor->session, sym - XKB_KEY_F1 + 1); } } diff --git a/example/touch.c b/example/touch.c index 1b4233bb..2b6cb173 100644 --- a/example/touch.c +++ b/example/touch.c @@ -59,6 +59,8 @@ static void handle_keyboard_key(struct keyboard_state *kbstate, xkb_keysym_t sym, enum wlr_key_state key_state) { if (sym == XKB_KEY_Escape) { kbstate->compositor->exit = true; + } else if (key_state == WLR_KEY_PRESSED && sym >= XKB_KEY_F1 && sym <= XKB_KEY_F12) { + wlr_session_change_vt(kbstate->compositor->session, sym - XKB_KEY_F1 + 1); } } -- cgit v1.2.3