mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2025-12-16 08:56:26 -05:00
Renaming.
This commit is contained in:
parent
9ac46ec5ed
commit
41a82fd2fc
13 changed files with 395 additions and 350 deletions
|
|
@ -11,18 +11,17 @@
|
|||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include "backend/drm/backend.h"
|
||||
#include "backend/drm/session.h"
|
||||
#include "backend/drm/otd.h"
|
||||
|
||||
int take_device(struct otd *restrict otd,
|
||||
const char *restrict path,
|
||||
bool *restrict paused_out)
|
||||
int wlr_session_take_device(struct wlr_session *restrict session,
|
||||
const char *restrict path,
|
||||
bool *restrict paused_out)
|
||||
{
|
||||
int ret;
|
||||
int fd = -1;
|
||||
sd_bus_message *msg = NULL;
|
||||
sd_bus_error error = SD_BUS_ERROR_NULL;
|
||||
struct otd_session *s = &otd->session;
|
||||
|
||||
struct stat st;
|
||||
if (stat(path, &st) < 0) {
|
||||
|
|
@ -30,9 +29,9 @@ int take_device(struct otd *restrict otd,
|
|||
return -1;
|
||||
}
|
||||
|
||||
ret = sd_bus_call_method(s->bus,
|
||||
ret = sd_bus_call_method(session->bus,
|
||||
"org.freedesktop.login1",
|
||||
s->path,
|
||||
session->path,
|
||||
"org.freedesktop.login1.Session",
|
||||
"TakeDevice",
|
||||
&error, &msg,
|
||||
|
|
@ -62,12 +61,11 @@ error:
|
|||
return fd;
|
||||
}
|
||||
|
||||
void release_device(struct otd *otd, int fd)
|
||||
void wlr_session_release_device(struct wlr_session *session, int fd)
|
||||
{
|
||||
int ret;
|
||||
sd_bus_message *msg = NULL;
|
||||
sd_bus_error error = SD_BUS_ERROR_NULL;
|
||||
struct otd_session *s = &otd->session;
|
||||
|
||||
struct stat st;
|
||||
if (fstat(fd, &st) < 0) {
|
||||
|
|
@ -75,9 +73,9 @@ void release_device(struct otd *otd, int fd)
|
|||
return;
|
||||
}
|
||||
|
||||
ret = sd_bus_call_method(s->bus,
|
||||
ret = sd_bus_call_method(session->bus,
|
||||
"org.freedesktop.login1",
|
||||
s->path,
|
||||
session->path,
|
||||
"org.freedesktop.login1.Session",
|
||||
"ReleaseDevice",
|
||||
&error, &msg,
|
||||
|
|
@ -90,16 +88,15 @@ void release_device(struct otd *otd, int fd)
|
|||
sd_bus_message_unref(msg);
|
||||
}
|
||||
|
||||
static bool session_activate(struct otd *otd)
|
||||
static bool session_activate(struct wlr_session *session)
|
||||
{
|
||||
int ret;
|
||||
sd_bus_message *msg = NULL;
|
||||
sd_bus_error error = SD_BUS_ERROR_NULL;
|
||||
struct otd_session *s = &otd->session;
|
||||
|
||||
ret = sd_bus_call_method(s->bus,
|
||||
ret = sd_bus_call_method(session->bus,
|
||||
"org.freedesktop.login1",
|
||||
s->path,
|
||||
session->path,
|
||||
"org.freedesktop.login1.Session",
|
||||
"Activate",
|
||||
&error, &msg,
|
||||
|
|
@ -113,16 +110,15 @@ static bool session_activate(struct otd *otd)
|
|||
return ret >= 0;
|
||||
}
|
||||
|
||||
static bool take_control(struct otd *otd)
|
||||
static bool take_control(struct wlr_session *session)
|
||||
{
|
||||
int ret;
|
||||
sd_bus_message *msg = NULL;
|
||||
sd_bus_error error = SD_BUS_ERROR_NULL;
|
||||
struct otd_session *s = &otd->session;
|
||||
|
||||
ret = sd_bus_call_method(s->bus,
|
||||
ret = sd_bus_call_method(session->bus,
|
||||
"org.freedesktop.login1",
|
||||
s->path,
|
||||
session->path,
|
||||
"org.freedesktop.login1.Session",
|
||||
"TakeControl",
|
||||
&error, &msg,
|
||||
|
|
@ -136,16 +132,15 @@ static bool take_control(struct otd *otd)
|
|||
return ret >= 0;
|
||||
}
|
||||
|
||||
static void release_control(struct otd *otd)
|
||||
static void release_control(struct wlr_session *session)
|
||||
{
|
||||
int ret;
|
||||
sd_bus_message *msg = NULL;
|
||||
sd_bus_error error = SD_BUS_ERROR_NULL;
|
||||
struct otd_session *s = &otd->session;
|
||||
|
||||
ret = sd_bus_call_method(s->bus,
|
||||
ret = sd_bus_call_method(session->bus,
|
||||
"org.freedesktop.login1",
|
||||
s->path,
|
||||
session->path,
|
||||
"org.freedesktop.login1.Session",
|
||||
"ReleaseControl",
|
||||
&error, &msg,
|
||||
|
|
@ -158,29 +153,27 @@ static void release_control(struct otd *otd)
|
|||
sd_bus_message_unref(msg);
|
||||
}
|
||||
|
||||
void otd_close_session(struct otd *otd)
|
||||
void wlr_session_end(struct wlr_session *session)
|
||||
{
|
||||
release_device(otd, otd->fd);
|
||||
release_control(otd);
|
||||
release_control(session);
|
||||
|
||||
sd_bus_unref(otd->session.bus);
|
||||
free(otd->session.id);
|
||||
free(otd->session.path);
|
||||
free(otd->session.seat);
|
||||
sd_bus_unref(session->bus);
|
||||
free(session->id);
|
||||
free(session->path);
|
||||
free(session->seat);
|
||||
}
|
||||
|
||||
bool otd_new_session(struct otd *otd)
|
||||
bool wlr_session_start(struct wlr_session *session)
|
||||
{
|
||||
int ret;
|
||||
struct otd_session *s = &otd->session;
|
||||
|
||||
ret = sd_pid_get_session(getpid(), &s->id);
|
||||
ret = sd_pid_get_session(getpid(), &session->id);
|
||||
if (ret < 0) {
|
||||
fprintf(stderr, "Could not get session\n");
|
||||
goto error;
|
||||
}
|
||||
|
||||
ret = sd_session_get_seat(s->id, &s->seat);
|
||||
ret = sd_session_get_seat(session->id, &session->seat);
|
||||
if (ret < 0) {
|
||||
fprintf(stderr, "Could not get seat\n");
|
||||
goto error;
|
||||
|
|
@ -189,26 +182,26 @@ bool otd_new_session(struct otd *otd)
|
|||
// This could be done using asprintf, but I don't want to define _GNU_SOURCE
|
||||
|
||||
const char *fmt = "/org/freedesktop/login1/session/%s";
|
||||
int len = snprintf(NULL, 0, fmt, s->id);
|
||||
int len = snprintf(NULL, 0, fmt, session->id);
|
||||
|
||||
s->path = malloc(len + 1);
|
||||
if (!s->path)
|
||||
session->path = malloc(len + 1);
|
||||
if (!session->path)
|
||||
goto error;
|
||||
|
||||
sprintf(s->path, fmt, s->id);
|
||||
sprintf(session->path, fmt, session->id);
|
||||
|
||||
ret = sd_bus_open_system(&s->bus);
|
||||
ret = sd_bus_open_system(&session->bus);
|
||||
if (ret < 0) {
|
||||
fprintf(stderr, "Could not open bus\n");
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (!session_activate(otd)) {
|
||||
if (!session_activate(session)) {
|
||||
fprintf(stderr, "Could not activate session\n");
|
||||
goto error_bus;
|
||||
}
|
||||
|
||||
if (!take_control(otd)) {
|
||||
if (!take_control(session)) {
|
||||
fprintf(stderr, "Could not take control of session\n");
|
||||
goto error_bus;
|
||||
}
|
||||
|
|
@ -216,11 +209,11 @@ bool otd_new_session(struct otd *otd)
|
|||
return true;
|
||||
|
||||
error_bus:
|
||||
sd_bus_unref(s->bus);
|
||||
sd_bus_unref(session->bus);
|
||||
|
||||
error:
|
||||
free(s->path);
|
||||
free(s->id);
|
||||
free(s->seat);
|
||||
free(session->path);
|
||||
free(session->id);
|
||||
free(session->seat);
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue