You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
118 lines
3.1 KiB
118 lines
3.1 KiB
13 years ago
|
/*
|
||
|
* Copyright © 2012 Benjamin Franzke
|
||
11 years ago
|
* Copyright © 2013 Intel Corporation
|
||
13 years ago
|
*
|
||
10 years ago
|
* Permission is hereby granted, free of charge, to any person obtaining
|
||
|
* a copy of this software and associated documentation files (the
|
||
|
* "Software"), to deal in the Software without restriction, including
|
||
|
* without limitation the rights to use, copy, modify, merge, publish,
|
||
|
* distribute, sublicense, and/or sell copies of the Software, and to
|
||
|
* permit persons to whom the Software is furnished to do so, subject to
|
||
|
* the following conditions:
|
||
13 years ago
|
*
|
||
10 years ago
|
* The above copyright notice and this permission notice (including the
|
||
|
* next paragraph) shall be included in all copies or substantial
|
||
|
* portions of the Software.
|
||
|
*
|
||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
||
|
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||
|
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||
|
* SOFTWARE.
|
||
13 years ago
|
*/
|
||
|
|
||
12 years ago
|
#include "config.h"
|
||
|
|
||
13 years ago
|
#include "compositor.h"
|
||
9 years ago
|
|
||
13 years ago
|
#include "launcher-util.h"
|
||
9 years ago
|
#include "launcher-impl.h"
|
||
13 years ago
|
|
||
9 years ago
|
#include <unistd.h>
|
||
9 years ago
|
#include <linux/input.h>
|
||
11 years ago
|
|
||
9 years ago
|
static struct launcher_interface *ifaces[] = {
|
||
|
#ifdef HAVE_SYSTEMD_LOGIN
|
||
|
&launcher_logind_iface,
|
||
11 years ago
|
#endif
|
||
9 years ago
|
&launcher_weston_launch_iface,
|
||
|
&launcher_direct_iface,
|
||
|
NULL,
|
||
|
};
|
||
11 years ago
|
|
||
9 years ago
|
WL_EXPORT struct weston_launcher *
|
||
|
weston_launcher_connect(struct weston_compositor *compositor, int tty,
|
||
|
const char *seat_id, bool sync_drm)
|
||
11 years ago
|
{
|
||
9 years ago
|
struct launcher_interface **it;
|
||
11 years ago
|
|
||
9 years ago
|
for (it = ifaces; *it != NULL; it++) {
|
||
|
struct launcher_interface *iface = *it;
|
||
|
struct weston_launcher *launcher;
|
||
11 years ago
|
|
||
9 years ago
|
if (iface->connect(&launcher, compositor, tty, seat_id, sync_drm) == 0)
|
||
|
return launcher;
|
||
|
}
|
||
11 years ago
|
|
||
9 years ago
|
return NULL;
|
||
11 years ago
|
}
|
||
|
|
||
9 years ago
|
WL_EXPORT void
|
||
|
weston_launcher_destroy(struct weston_launcher *launcher)
|
||
11 years ago
|
{
|
||
9 years ago
|
launcher->iface->destroy(launcher);
|
||
11 years ago
|
}
|
||
|
|
||
9 years ago
|
WL_EXPORT int
|
||
11 years ago
|
weston_launcher_open(struct weston_launcher *launcher,
|
||
13 years ago
|
const char *path, int flags)
|
||
|
{
|
||
9 years ago
|
return launcher->iface->open(launcher, path, flags);
|
||
13 years ago
|
}
|
||
|
|
||
9 years ago
|
WL_EXPORT void
|
||
11 years ago
|
weston_launcher_close(struct weston_launcher *launcher, int fd)
|
||
|
{
|
||
9 years ago
|
launcher->iface->close(launcher, fd);
|
||
11 years ago
|
}
|
||
|
|
||
9 years ago
|
WL_EXPORT int
|
||
11 years ago
|
weston_launcher_activate_vt(struct weston_launcher *launcher, int vt)
|
||
|
{
|
||
9 years ago
|
return launcher->iface->activate_vt(launcher, vt);
|
||
11 years ago
|
}
|
||
|
|
||
9 years ago
|
WL_EXPORT void
|
||
|
weston_launcher_restore(struct weston_launcher *launcher)
|
||
11 years ago
|
{
|
||
9 years ago
|
launcher->iface->restore(launcher);
|
||
11 years ago
|
}
|
||
9 years ago
|
|
||
|
|
||
|
static void
|
||
|
switch_vt_binding(struct weston_keyboard *keyboard,
|
||
|
uint32_t time, uint32_t key, void *data)
|
||
|
{
|
||
|
struct weston_compositor *compositor = data;
|
||
|
|
||
|
weston_launcher_activate_vt(compositor->launcher, key - KEY_F1 + 1);
|
||
|
}
|
||
|
|
||
|
WL_EXPORT void
|
||
|
weston_setup_vt_switch_bindings(struct weston_compositor *compositor)
|
||
|
{
|
||
|
uint32_t key;
|
||
|
|
||
|
if (compositor->vt_switching == false)
|
||
|
return;
|
||
|
|
||
|
for (key = KEY_F1; key < KEY_F9; key++)
|
||
|
weston_compositor_add_key_binding(compositor, key,
|
||
|
MODIFIER_CTRL | MODIFIER_ALT,
|
||
|
switch_vt_binding,
|
||
|
compositor);
|
||
|
}
|