blob: e1beef6bb689541eae4d673c3798762693df0a3d [file] [log] [blame]
Benjamin Franzkebfeda132012-01-30 14:04:04 +01001/*
2 * Copyright © 2012 Benjamin Franzke
Kristian Høgsberg05ad1e42013-09-17 14:41:03 -07003 * Copyright © 2013 Intel Corporation
Benjamin Franzkebfeda132012-01-30 14:04:04 +01004 *
Bryce Harringtona0bbfea2015-06-11 15:35:43 -07005 * Permission is hereby granted, free of charge, to any person obtaining
6 * a copy of this software and associated documentation files (the
7 * "Software"), to deal in the Software without restriction, including
8 * without limitation the rights to use, copy, modify, merge, publish,
9 * distribute, sublicense, and/or sell copies of the Software, and to
10 * permit persons to whom the Software is furnished to do so, subject to
11 * the following conditions:
Benjamin Franzkebfeda132012-01-30 14:04:04 +010012 *
Bryce Harringtona0bbfea2015-06-11 15:35:43 -070013 * The above copyright notice and this permission notice (including the
14 * next paragraph) shall be included in all copies or substantial
15 * portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
21 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
22 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 * SOFTWARE.
Benjamin Franzkebfeda132012-01-30 14:04:04 +010025 */
26
Daniel Stonec228e232013-05-22 18:03:19 +030027#include "config.h"
28
Benjamin Franzkebfeda132012-01-30 14:04:04 +010029#include "compositor.h"
Jasper St. Pierre72dea062015-09-23 10:46:47 -070030
Benjamin Franzkebfeda132012-01-30 14:04:04 +010031#include "launcher-util.h"
Jasper St. Pierre72dea062015-09-23 10:46:47 -070032#include "launcher-impl.h"
Benjamin Franzkebfeda132012-01-30 14:04:04 +010033
Jasper St. Pierre72dea062015-09-23 10:46:47 -070034#include <unistd.h>
Kristian Høgsberg3f495872013-09-18 23:00:17 -070035
Jasper St. Pierre72dea062015-09-23 10:46:47 -070036static struct launcher_interface *ifaces[] = {
37#ifdef HAVE_SYSTEMD_LOGIN
38 &launcher_logind_iface,
Kristian Høgsberg3f495872013-09-18 23:00:17 -070039#endif
Jasper St. Pierre72dea062015-09-23 10:46:47 -070040 &launcher_weston_launch_iface,
41 &launcher_direct_iface,
42 NULL,
Kristian Høgsbergd2c9d8a2013-11-24 14:37:07 -080043};
44
Jasper St. Pierre72dea062015-09-23 10:46:47 -070045WL_EXPORT struct weston_launcher *
David Herrmanncc5b2ed2013-10-22 00:28:09 +020046weston_launcher_connect(struct weston_compositor *compositor, int tty,
David Herrmann2ecb84a2014-12-30 14:33:22 +010047 const char *seat_id, bool sync_drm)
Kristian Høgsberg05ad1e42013-09-17 14:41:03 -070048{
Jasper St. Pierre72dea062015-09-23 10:46:47 -070049 struct launcher_interface **it;
Kristian Høgsberg05ad1e42013-09-17 14:41:03 -070050
Jasper St. Pierre72dea062015-09-23 10:46:47 -070051 for (it = ifaces; *it != NULL; it++) {
52 struct launcher_interface *iface = *it;
53 struct weston_launcher *launcher;
Kristian Høgsberg05ad1e42013-09-17 14:41:03 -070054
Jasper St. Pierre72dea062015-09-23 10:46:47 -070055 if (iface->connect(&launcher, compositor, tty, seat_id, sync_drm) == 0)
56 return launcher;
Kristian Høgsberg1eb482d2013-09-17 22:15:37 -070057 }
58
Jasper St. Pierre72dea062015-09-23 10:46:47 -070059 return NULL;
Kristian Høgsberg05ad1e42013-09-17 14:41:03 -070060}
61
Jasper St. Pierre72dea062015-09-23 10:46:47 -070062WL_EXPORT void
Kristian Høgsberg05ad1e42013-09-17 14:41:03 -070063weston_launcher_destroy(struct weston_launcher *launcher)
64{
Jasper St. Pierre72dea062015-09-23 10:46:47 -070065 launcher->iface->destroy(launcher);
66}
Kristian Høgsberg3f495872013-09-18 23:00:17 -070067
Jasper St. Pierre72dea062015-09-23 10:46:47 -070068WL_EXPORT int
69weston_launcher_open(struct weston_launcher *launcher,
70 const char *path, int flags)
71{
72 return launcher->iface->open(launcher, path, flags);
73}
David Herrmanncc5b2ed2013-10-22 00:28:09 +020074
Jasper St. Pierre72dea062015-09-23 10:46:47 -070075WL_EXPORT void
76weston_launcher_close(struct weston_launcher *launcher, int fd)
77{
78 launcher->iface->close(launcher, fd);
79}
80
81WL_EXPORT int
82weston_launcher_activate_vt(struct weston_launcher *launcher, int vt)
83{
84 return launcher->iface->activate_vt(launcher, vt);
85}
86
87WL_EXPORT void
88weston_launcher_restore(struct weston_launcher *launcher)
89{
90 launcher->iface->restore(launcher);
Kristian Høgsberg05ad1e42013-09-17 14:41:03 -070091}