Fixed VT switching

This commit is contained in:
Scott Anderson 2017-06-21 13:31:29 +12:00
parent 091de12bf4
commit 55854565dc
6 changed files with 42 additions and 4 deletions

View file

@ -54,8 +54,10 @@ static void session_signal(struct wl_listener *listener, void *data) {
} else { } else {
wlr_log(L_INFO, "DRM fd paused"); wlr_log(L_INFO, "DRM fd paused");
// TODO: Actually pause the renderer or something. for (size_t i = 0; i < drm->outputs->length; ++i) {
// We currently just expect it to fail its next pageflip. struct wlr_output_state *output = drm->outputs->items[i];
wlr_drm_output_pause_renderer(output);
}
} }
} }

View file

@ -116,6 +116,21 @@ static void wlr_drm_output_end(struct wlr_output_state *output) {
output->bo[0] = bo; 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) { void wlr_drm_output_start_renderer(struct wlr_output_state *output) {
if (output->state != DRM_OUTPUT_CONNECTED) { if (output->state != DRM_OUTPUT_CONNECTED) {
return; return;
@ -608,7 +623,7 @@ static void page_flip_handler(int fd, unsigned seq,
} }
output->pageflip_pending = false; output->pageflip_pending = false;
if (output->state == DRM_OUTPUT_CONNECTED) { if (output->state == DRM_OUTPUT_CONNECTED && state->session->active) {
wlr_drm_output_begin(output); wlr_drm_output_begin(output);
wl_signal_emit(&output->wlr_output->events.frame, output->wlr_output); wl_signal_emit(&output->wlr_output->events.frame, output->wlr_output);
wlr_drm_output_end(output); wlr_drm_output_end(output);

View file

@ -86,6 +86,21 @@ static struct wlr_backend_impl backend_impl = {
.destroy = wlr_libinput_backend_destroy .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_backend *wlr_libinput_backend_create(struct wl_display *display,
struct wlr_session *session, struct wlr_udev *udev) { struct wlr_session *session, struct wlr_udev *udev) {
assert(display && session && udev); assert(display && session && udev);
@ -112,6 +127,9 @@ struct wlr_backend *wlr_libinput_backend_create(struct wl_display *display,
state->udev = udev; state->udev = udev;
state->display = display; state->display = display;
state->session_signal.notify = session_signal;
wl_signal_add(&session->session_signal, &state->session_signal);
return backend; return backend;
error_state: error_state:
free(state); free(state);

View file

@ -42,7 +42,7 @@ static void handle_keyboard_key(struct keyboard_state *kbstate,
xkb_keysym_t sym, enum wlr_key_state key_state) { xkb_keysym_t sym, enum wlr_key_state key_state) {
if (sym == XKB_KEY_Escape) { if (sym == XKB_KEY_Escape) {
kbstate->compositor->exit = true; 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); wlr_session_change_vt(kbstate->compositor->session, sym - XKB_KEY_F1 + 1);
} }
} }

View file

@ -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); 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_start_renderer(struct wlr_output_state *output);
void wlr_drm_output_pause_renderer(struct wlr_output_state *output);
#endif #endif

View file

@ -16,6 +16,8 @@ struct wlr_backend_state {
struct libinput *libinput; struct libinput *libinput;
struct wl_event_source *input_event; struct wl_event_source *input_event;
struct wl_listener session_signal;
list_t *devices; list_t *devices;
}; };