From ae4478e17f56c1fb52a77d1f034387f154eddef5 Mon Sep 17 00:00:00 2001 From: Scott Anderson Date: Tue, 11 Jul 2017 18:51:19 +1200 Subject: Changed ownership of wlr_session to the multi backend. Currently breaks VT switching for examples. --- backend/multi/backend.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'backend/multi') diff --git a/backend/multi/backend.c b/backend/multi/backend.c index d33d137c..2e8f117c 100644 --- a/backend/multi/backend.c +++ b/backend/multi/backend.c @@ -1,6 +1,8 @@ #include #include #include +#include +#include #include #include "backend/multi.h" @@ -31,6 +33,8 @@ static void multi_backend_destroy(struct wlr_backend_state *state) { free(sub); } list_free(state->backends); + wlr_session_finish(state->session); + wlr_udev_destroy(state->udev); free(state); } @@ -39,21 +43,26 @@ struct wlr_backend_impl backend_impl = { .destroy = multi_backend_destroy }; -struct wlr_backend *wlr_multi_backend_create() { +struct wlr_backend *wlr_multi_backend_create(struct wlr_session *session, + struct wlr_udev *udev) { struct wlr_backend_state *state = calloc(1, sizeof(struct wlr_backend_state)); if (!state) { wlr_log(L_ERROR, "Backend allocation failed"); return NULL; } + state->backends = list_create(); if (!state->backends) { free(state); wlr_log(L_ERROR, "Backend allocation failed"); return NULL; } + struct wlr_backend *backend = wlr_backend_create(&backend_impl, state); state->backend = backend; + state->session = session; + state->udev = udev; return backend; } -- cgit v1.2.3 From cb4d50e22c217027d641fc36cd022d12bba8d1ad Mon Sep 17 00:00:00 2001 From: Scott Anderson Date: Tue, 11 Jul 2017 19:18:34 +1200 Subject: Changed header paths. --- backend/backend.c | 2 +- backend/drm/backend.c | 2 +- backend/libinput/backend.c | 2 +- backend/libinput/events.c | 2 +- backend/libinput/keyboard.c | 2 +- backend/libinput/pointer.c | 2 +- backend/libinput/tablet_pad.c | 2 +- backend/libinput/tablet_tool.c | 2 +- backend/libinput/touch.c | 2 +- backend/multi/backend.c | 2 +- backend/session/direct-ipc.c | 2 +- backend/session/direct.c | 4 ++-- backend/session/logind.c | 2 +- backend/session/session.c | 4 ++-- backend/udev.c | 2 +- examples/compositor/main.c | 2 +- examples/pointer.c | 2 +- examples/rotation.c | 2 +- examples/shared.c | 2 +- examples/shared.h | 2 +- examples/simple.c | 2 +- examples/tablet.c | 2 +- examples/touch.c | 2 +- include/backend/drm.h | 2 +- include/backend/multi.h | 2 +- include/backend/udev.h | 2 +- include/wlr/backend.h | 2 +- include/wlr/backend/drm.h | 2 +- include/wlr/backend/libinput.h | 2 +- include/wlr/backend/multi.h | 2 +- include/wlr/backend/session/interface.h | 2 +- 31 files changed, 33 insertions(+), 33 deletions(-) (limited to 'backend/multi') diff --git a/backend/backend.c b/backend/backend.c index 93f764f6..b47b7f13 100644 --- a/backend/backend.c +++ b/backend/backend.c @@ -4,7 +4,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/backend/drm/backend.c b/backend/drm/backend.c index d52adba9..a2c71317 100644 --- a/backend/drm/backend.c +++ b/backend/drm/backend.c @@ -7,7 +7,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/backend/libinput/backend.c b/backend/libinput/backend.c index a3523dc0..68f1752b 100644 --- a/backend/libinput/backend.c +++ b/backend/libinput/backend.c @@ -1,7 +1,7 @@ #include #include #include -#include +#include #include #include #include "backend/udev.h" diff --git a/backend/libinput/events.c b/backend/libinput/events.c index 6cd33e3d..9fe81782 100644 --- a/backend/libinput/events.c +++ b/backend/libinput/events.c @@ -1,7 +1,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/backend/libinput/keyboard.c b/backend/libinput/keyboard.c index f19d7120..957cc3f2 100644 --- a/backend/libinput/keyboard.c +++ b/backend/libinput/keyboard.c @@ -1,7 +1,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/backend/libinput/pointer.c b/backend/libinput/pointer.c index 57c417c8..59e219d8 100644 --- a/backend/libinput/pointer.c +++ b/backend/libinput/pointer.c @@ -1,7 +1,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/backend/libinput/tablet_pad.c b/backend/libinput/tablet_pad.c index 5517fa63..9bf45ba6 100644 --- a/backend/libinput/tablet_pad.c +++ b/backend/libinput/tablet_pad.c @@ -1,7 +1,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/backend/libinput/tablet_tool.c b/backend/libinput/tablet_tool.c index 95bdd3fd..9bbb0e34 100644 --- a/backend/libinput/tablet_tool.c +++ b/backend/libinput/tablet_tool.c @@ -1,7 +1,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/backend/libinput/touch.c b/backend/libinput/touch.c index c002b6a0..e0e866b0 100644 --- a/backend/libinput/touch.c +++ b/backend/libinput/touch.c @@ -1,7 +1,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/backend/multi/backend.c b/backend/multi/backend.c index 2e8f117c..8026e970 100644 --- a/backend/multi/backend.c +++ b/backend/multi/backend.c @@ -2,7 +2,7 @@ #include #include #include -#include +#include #include #include "backend/multi.h" diff --git a/backend/session/direct-ipc.c b/backend/session/direct-ipc.c index 885662e0..71e22148 100644 --- a/backend/session/direct-ipc.c +++ b/backend/session/direct-ipc.c @@ -13,7 +13,7 @@ #include #include #include -#include "session/direct-ipc.h" +#include "backend/session/direct-ipc.h" enum { DRM_MAJOR = 226 }; diff --git a/backend/session/direct.c b/backend/session/direct.c index 1247663b..82aa8e00 100644 --- a/backend/session/direct.c +++ b/backend/session/direct.c @@ -13,9 +13,9 @@ #include #include #include -#include +#include #include -#include "session/direct-ipc.h" +#include "backend/session/direct-ipc.h" enum { DRM_MAJOR = 226 }; diff --git a/backend/session/logind.c b/backend/session/logind.c index 6744215a..20d9b5ed 100644 --- a/backend/session/logind.c +++ b/backend/session/logind.c @@ -11,7 +11,7 @@ #include #include #include -#include +#include #include enum { DRM_MAJOR = 226 }; diff --git a/backend/session/session.c b/backend/session/session.c index 3f4c7910..a07d3cda 100644 --- a/backend/session/session.c +++ b/backend/session/session.c @@ -1,7 +1,7 @@ #include #include -#include -#include +#include +#include #include extern const struct session_impl session_logind; diff --git a/backend/udev.c b/backend/udev.c index 1fecaee4..1cc53f60 100644 --- a/backend/udev.c +++ b/backend/udev.c @@ -8,7 +8,7 @@ #include #include #include -#include +#include #include #include "backend/udev.h" diff --git a/examples/compositor/main.c b/examples/compositor/main.c index e13fda24..c618961d 100644 --- a/examples/compositor/main.c +++ b/examples/compositor/main.c @@ -6,7 +6,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/examples/pointer.c b/examples/pointer.c index c7518841..d159caf5 100644 --- a/examples/pointer.c +++ b/examples/pointer.c @@ -14,7 +14,7 @@ #include #include #include -#include +#include #include #include #include "shared.h" diff --git a/examples/rotation.c b/examples/rotation.c index 36e95f50..bcf855d9 100644 --- a/examples/rotation.c +++ b/examples/rotation.c @@ -14,7 +14,7 @@ #include #include #include -#include +#include #include #include #include "shared.h" diff --git a/examples/shared.c b/examples/shared.c index 823d8e0c..bd5f7ec5 100644 --- a/examples/shared.c +++ b/examples/shared.c @@ -8,7 +8,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/examples/shared.h b/examples/shared.h index 1633f2c8..2379eef9 100644 --- a/examples/shared.h +++ b/examples/shared.h @@ -8,7 +8,7 @@ #include #include #include -#include +#include #include #include diff --git a/examples/simple.c b/examples/simple.c index 45cb2b93..8e098e18 100644 --- a/examples/simple.c +++ b/examples/simple.c @@ -7,7 +7,7 @@ #include #include #include -#include +#include #include #include #include "shared.h" diff --git a/examples/tablet.c b/examples/tablet.c index d7f7d042..0be6dcb9 100644 --- a/examples/tablet.c +++ b/examples/tablet.c @@ -13,7 +13,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/examples/touch.c b/examples/touch.c index 97009e81..15ad9d49 100644 --- a/examples/touch.c +++ b/examples/touch.c @@ -15,7 +15,7 @@ #include #include #include -#include +#include #include #include "shared.h" #include "cat.h" diff --git a/include/backend/drm.h b/include/backend/drm.h index dc12c258..ecdd945b 100644 --- a/include/backend/drm.h +++ b/include/backend/drm.h @@ -10,7 +10,7 @@ #include #include -#include +#include #include #include diff --git a/include/backend/multi.h b/include/backend/multi.h index 617d4c98..5ac9cc1d 100644 --- a/include/backend/multi.h +++ b/include/backend/multi.h @@ -5,7 +5,7 @@ #include #include #include -#include +#include struct wlr_backend_state { struct wlr_backend *backend; diff --git a/include/backend/udev.h b/include/backend/udev.h index a2834063..080422c0 100644 --- a/include/backend/udev.h +++ b/include/backend/udev.h @@ -3,7 +3,7 @@ #include #include -#include +#include #include #include diff --git a/include/wlr/backend.h b/include/wlr/backend.h index 74cb34a9..3910e406 100644 --- a/include/wlr/backend.h +++ b/include/wlr/backend.h @@ -2,7 +2,7 @@ #define _WLR_BACKEND_H #include -#include +#include struct wlr_backend_impl; struct wlr_backend_state; diff --git a/include/wlr/backend/drm.h b/include/wlr/backend/drm.h index a486757d..7332d608 100644 --- a/include/wlr/backend/drm.h +++ b/include/wlr/backend/drm.h @@ -2,7 +2,7 @@ #define WLR_BACKEND_DRM_H #include -#include +#include #include #include diff --git a/include/wlr/backend/libinput.h b/include/wlr/backend/libinput.h index 29748b77..bba68888 100644 --- a/include/wlr/backend/libinput.h +++ b/include/wlr/backend/libinput.h @@ -3,7 +3,7 @@ #include #include -#include +#include #include #include #include diff --git a/include/wlr/backend/multi.h b/include/wlr/backend/multi.h index 00b34722..8b68284d 100644 --- a/include/wlr/backend/multi.h +++ b/include/wlr/backend/multi.h @@ -3,7 +3,7 @@ #include #include -#include +#include struct wlr_backend *wlr_multi_backend_create(struct wlr_session *session, struct wlr_udev *udev); diff --git a/include/wlr/backend/session/interface.h b/include/wlr/backend/session/interface.h index 4938110d..16814446 100644 --- a/include/wlr/backend/session/interface.h +++ b/include/wlr/backend/session/interface.h @@ -1,7 +1,7 @@ #ifndef WLR_SESSION_INTERFACE_H #define WLR_SESSION_INTERFACE_H -#include +#include struct session_impl { struct wlr_session *(*start)(struct wl_display *disp); -- cgit v1.2.3 From 4d4da18437849df850b4ae199fbffb54d31c86b4 Mon Sep 17 00:00:00 2001 From: Scott Anderson Date: Sun, 6 Aug 2017 13:37:49 +1200 Subject: Fixed VT switching --- backend/multi/backend.c | 8 ++++++++ examples/shared.c | 11 +++++++++-- include/wlr/backend/multi.h | 2 ++ 3 files changed, 19 insertions(+), 2 deletions(-) (limited to 'backend/multi') diff --git a/backend/multi/backend.c b/backend/multi/backend.c index 8026e970..a5913f5d 100644 --- a/backend/multi/backend.c +++ b/backend/multi/backend.c @@ -113,3 +113,11 @@ void wlr_multi_backend_add(struct wlr_backend *multi, list_add(multi->state->backends, sub); } + +struct wlr_session *wlr_multi_get_session(struct wlr_backend *base) { + if (base->impl != &backend_impl) + return NULL; + + struct wlr_backend_state *multi = base->state; + return multi->session; +} diff --git a/examples/shared.c b/examples/shared.c index bd5f7ec5..27e5b9ca 100644 --- a/examples/shared.c +++ b/examples/shared.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -44,8 +45,14 @@ static void keyboard_key_notify(struct wl_listener *listener, void *data) { } if (sym == XKB_KEY_Escape) { wl_display_terminate(kbstate->compositor->display); - } 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); + } else if (key_state == WLR_KEY_PRESSED && + sym >= XKB_KEY_XF86Switch_VT_1 && + sym <= XKB_KEY_XF86Switch_VT_12) { + struct wlr_session *session = + wlr_multi_get_session(kbstate->compositor->backend); + if (session) { + wlr_session_change_vt(session, sym - XKB_KEY_XF86Switch_VT_1 + 1); + } } } xkb_state_update_key(kbstate->xkb_state, keycode, diff --git a/include/wlr/backend/multi.h b/include/wlr/backend/multi.h index 8b68284d..048c4043 100644 --- a/include/wlr/backend/multi.h +++ b/include/wlr/backend/multi.h @@ -10,4 +10,6 @@ struct wlr_backend *wlr_multi_backend_create(struct wlr_session *session, void wlr_multi_backend_add(struct wlr_backend *multi, struct wlr_backend *backend); +struct wlr_session *wlr_multi_get_session(struct wlr_backend *base); + #endif -- cgit v1.2.3 From 5bf61ca7edb658737f3ccbaed0a99f4779d329bb Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Sat, 5 Aug 2017 23:08:35 -0400 Subject: Check for multi backend before using it --- backend/multi/backend.c | 4 ++++ examples/shared.c | 10 ++++++---- include/wlr/backend/multi.h | 2 ++ 3 files changed, 12 insertions(+), 4 deletions(-) (limited to 'backend/multi') diff --git a/backend/multi/backend.c b/backend/multi/backend.c index a5913f5d..19839629 100644 --- a/backend/multi/backend.c +++ b/backend/multi/backend.c @@ -66,6 +66,10 @@ struct wlr_backend *wlr_multi_backend_create(struct wlr_session *session, return backend; } +bool wlr_backend_is_multi(struct wlr_backend *b) { + return b->impl == &backend_impl; +} + static void input_add_reemit(struct wl_listener *listener, void *data) { struct subbackend_state *state = wl_container_of(listener, state, input_add); diff --git a/examples/shared.c b/examples/shared.c index 27e5b9ca..c66b8a23 100644 --- a/examples/shared.c +++ b/examples/shared.c @@ -48,10 +48,12 @@ static void keyboard_key_notify(struct wl_listener *listener, void *data) { } else if (key_state == WLR_KEY_PRESSED && sym >= XKB_KEY_XF86Switch_VT_1 && sym <= XKB_KEY_XF86Switch_VT_12) { - struct wlr_session *session = - wlr_multi_get_session(kbstate->compositor->backend); - if (session) { - wlr_session_change_vt(session, sym - XKB_KEY_XF86Switch_VT_1 + 1); + if (wlr_backend_is_multi(kbstate->compositor->backend)) { + struct wlr_session *session = + wlr_multi_get_session(kbstate->compositor->backend); + if (session) { + wlr_session_change_vt(session, sym - XKB_KEY_XF86Switch_VT_1 + 1); + } } } } diff --git a/include/wlr/backend/multi.h b/include/wlr/backend/multi.h index 048c4043..e8e46bed 100644 --- a/include/wlr/backend/multi.h +++ b/include/wlr/backend/multi.h @@ -10,6 +10,8 @@ struct wlr_backend *wlr_multi_backend_create(struct wlr_session *session, void wlr_multi_backend_add(struct wlr_backend *multi, struct wlr_backend *backend); +bool wlr_backend_is_multi(struct wlr_backend *backend); + struct wlr_session *wlr_multi_get_session(struct wlr_backend *base); #endif -- cgit v1.2.3