launcher: move weston_environment_get_fd

weston_environment_get_fd was declared in weston-launch and implemented
in compositor.c. Since the function is not used elsewhere in the code,
it is replaced by a static function in launcher-weston-launch.c

Signed-off-by: Guillaume Champagne <champagne.guillaume.c@gmail.com>
dev
Guillaume Champagne 5 years ago committed by Pekka Paalanen
parent 60b6572b35
commit b4bd12b738
  1. 20
      libweston/compositor.c
  2. 26
      libweston/launcher-weston-launch.c
  3. 3
      libweston/weston-launch.h

@ -6929,26 +6929,6 @@ compositor_bind(struct wl_client *client,
compositor, NULL);
}
WL_EXPORT int
weston_environment_get_fd(const char *env)
{
char *e;
int fd, flags;
e = getenv(env);
if (!e || !safe_strtoint(e, &fd))
return -1;
flags = fcntl(fd, F_GETFD);
if (flags == -1)
return -1;
fcntl(fd, F_SETFD, flags | FD_CLOEXEC);
unsetenv(env);
return fd;
}
static const char *
output_repaint_status_text(struct weston_output *output)
{

@ -47,6 +47,7 @@
#include <libweston/libweston.h>
#include "weston-launch.h"
#include "launcher-impl.h"
#include "shared/string-helpers.h"
#define DRM_MAJOR 226
@ -231,6 +232,27 @@ launcher_weston_launch_activate_vt(struct weston_launcher *launcher_base, int vt
return ioctl(launcher->tty, VT_ACTIVATE, vt);
}
static int
launcher_weston_environment_get_fd(const char *env)
{
char *e;
int fd, flags;
e = getenv(env);
if (!e || !safe_strtoint(e, &fd))
return -1;
flags = fcntl(fd, F_GETFD);
if (flags == -1)
return -1;
fcntl(fd, F_SETFD, flags | FD_CLOEXEC);
unsetenv(env);
return fd;
}
static int
launcher_weston_launch_connect(struct weston_launcher **out, struct weston_compositor *compositor,
int tty, const char *seat_id, bool sync_drm)
@ -246,9 +268,9 @@ launcher_weston_launch_connect(struct weston_launcher **out, struct weston_compo
* (struct launcher_weston_launch **) out = launcher;
launcher->compositor = compositor;
launcher->drm_fd = -1;
launcher->fd = weston_environment_get_fd("WESTON_LAUNCHER_SOCK");
launcher->fd = launcher_weston_environment_get_fd("WESTON_LAUNCHER_SOCK");
if (launcher->fd != -1) {
launcher->tty = weston_environment_get_fd("WESTON_TTY_FD");
launcher->tty = launcher_weston_environment_get_fd("WESTON_TTY_FD");
/* We don't get a chance to read out the original kb
* mode for the tty, so just hard code K_UNICODE here
* in case we have to clean if weston-launch dies. */

@ -46,7 +46,4 @@ struct weston_launcher_open {
char path[0];
};
int
weston_environment_get_fd(const char *env);
#endif

Loading…
Cancel
Save