mirror of
https://github.com/X11Libre/xserver.git
synced 2026-04-14 17:18:09 +00:00
Patch 4/5 xfree86: libseat support, wire-up support seatd-libseat.h into Xserver
Add necessary code into Xserver to support libseat (this time enabling functionality). Code used from Devuan repository + local changes to make functional in Xlibre Co-Authored-By: Mark Hindley <mark@hindley.org.uk> Co-Authored-By: Ralph Ronnquist <rrq@rrq.au> Signed-off-By: Tautvis <gtautvis@gmail.com>
This commit is contained in:
@@ -91,6 +91,8 @@
|
||||
#endif
|
||||
|
||||
#include "../os-support/linux/systemd-logind.h"
|
||||
#include "seatd-libseat.h"
|
||||
|
||||
|
||||
extern void (*xf86OSPMClose) (void);
|
||||
|
||||
@@ -182,7 +184,9 @@ xf86ProcessActionEvent(ActionEvent action, void *arg)
|
||||
int vtno = *((int *) arg);
|
||||
|
||||
if (vtno != xf86Info.vtno) {
|
||||
if (!xf86VTActivate(vtno)) {
|
||||
if (seatd_libseat_controls_session()) {
|
||||
seatd_libseat_switch_session(vtno);
|
||||
} else if (!xf86VTActivate(vtno)) {
|
||||
ErrorF("Failed to switch from vt%02d to vt%02d: %s\n",
|
||||
xf86Info.vtno, vtno, strerror(errno));
|
||||
}
|
||||
@@ -191,7 +195,9 @@ xf86ProcessActionEvent(ActionEvent action, void *arg)
|
||||
break;
|
||||
case ACTION_SWITCHSCREEN_NEXT:
|
||||
if (!xf86Info.dontVTSwitch) {
|
||||
if (!xf86VTActivate(xf86Info.vtno + 1)) {
|
||||
if (seatd_libseat_controls_session()) {
|
||||
seatd_libseat_switch_session(xf86Info.vtno + 1);
|
||||
} else if (!xf86VTActivate(xf86Info.vtno + 1)) {
|
||||
/* If first try failed, assume this is the last VT and
|
||||
* try wrapping around to the first vt.
|
||||
*/
|
||||
@@ -204,7 +210,9 @@ xf86ProcessActionEvent(ActionEvent action, void *arg)
|
||||
break;
|
||||
case ACTION_SWITCHSCREEN_PREV:
|
||||
if (!xf86Info.dontVTSwitch && xf86Info.vtno > 0) {
|
||||
if (!xf86VTActivate(xf86Info.vtno - 1)) {
|
||||
if (seatd_libseat_controls_session()) {
|
||||
seatd_libseat_switch_session(xf86Info.vtno - 1);
|
||||
} else if (!xf86VTActivate(xf86Info.vtno - 1)) {
|
||||
/* Don't know what the maximum VT is, so can't wrap around */
|
||||
ErrorF("Failed to switch from vt%02d to previous vt: %s\n",
|
||||
xf86Info.vtno, strerror(errno));
|
||||
@@ -225,8 +233,10 @@ xf86ProcessActionEvent(ActionEvent action, void *arg)
|
||||
void
|
||||
xf86Wakeup(void *blockData, int err)
|
||||
{
|
||||
if (xf86VTSwitchPending())
|
||||
xf86VTSwitch();
|
||||
if (xf86VTSwitchPending() ||
|
||||
(dispatchException & DE_TERMINATE)){
|
||||
xf86VTSwitch();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -304,6 +314,7 @@ static void xf86DisableInputDeviceForVTSwitch(InputInfoPtr pInfo)
|
||||
|
||||
xf86ReleaseKeys(pInfo->dev);
|
||||
ProcessInputEvents();
|
||||
seatd_libseat_close_device(pInfo);
|
||||
DisableDevice(pInfo->dev, TRUE);
|
||||
}
|
||||
|
||||
@@ -489,7 +500,7 @@ xf86VTEnter(void)
|
||||
dixSaveScreens(serverClient, SCREEN_SAVER_FORCER, ScreenSaverReset);
|
||||
|
||||
for (pInfo = xf86InputDevs; pInfo; pInfo = pInfo->next) {
|
||||
/* Devices with server managed fds get enabled on logind resume */
|
||||
/* Devices with server managed fds get enabled on logind/libseat resume */
|
||||
if (!(pInfo->flags & XI86_SERVER_FD))
|
||||
xf86EnableInputDeviceForVTSwitch(pInfo);
|
||||
}
|
||||
@@ -519,6 +530,9 @@ xf86VTSwitch(void)
|
||||
{
|
||||
DebugF("xf86VTSwitch()\n");
|
||||
|
||||
if(!(dispatchException & DE_TERMINATE))
|
||||
assert(!seatd_libseat_controls_session());
|
||||
|
||||
#ifdef XFreeXDGA
|
||||
if (!DGAVTSwitch())
|
||||
return;
|
||||
|
||||
@@ -66,6 +66,8 @@
|
||||
#include "windowstr.h"
|
||||
#include "scrnintstr.h"
|
||||
#include "../os-support/linux/systemd-logind.h"
|
||||
#include "seatd-libseat.h"
|
||||
|
||||
#include "xf86VGAarbiter_priv.h"
|
||||
#include "loaderProcs.h"
|
||||
|
||||
@@ -339,6 +341,7 @@ InitOutput(int argc, char **argv)
|
||||
DoShowOptions();
|
||||
|
||||
dbus_core_init();
|
||||
seatd_libseat_init(xf86VTKeepTtyIsSet());
|
||||
systemd_logind_init();
|
||||
|
||||
/* Do a general bus probe. This will be a PCI probe for x86 platforms */
|
||||
@@ -432,9 +435,11 @@ InitOutput(int argc, char **argv)
|
||||
xorgHWOpenConsole = TRUE;
|
||||
}
|
||||
|
||||
if (xorgHWOpenConsole)
|
||||
xf86OpenConsole();
|
||||
else
|
||||
if (xorgHWOpenConsole) {
|
||||
if (!seatd_libseat_controls_session()) {
|
||||
xf86OpenConsole();
|
||||
}
|
||||
} else
|
||||
xf86Info.dontVTSwitch = TRUE;
|
||||
|
||||
/* Enable full I/O access */
|
||||
@@ -566,8 +571,11 @@ InitOutput(int argc, char **argv)
|
||||
/*
|
||||
* serverGeneration != 1; some OSs have to do things here, too.
|
||||
*/
|
||||
if (xorgHWOpenConsole)
|
||||
xf86OpenConsole();
|
||||
if (xorgHWOpenConsole) {
|
||||
if (!seatd_libseat_controls_session()) {
|
||||
xf86OpenConsole();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
should we reopen it here? We need to deal with an already opened
|
||||
@@ -845,9 +853,13 @@ ddxGiveUp(enum ExitCode error)
|
||||
xf86Screens[i]->vtSema = FALSE;
|
||||
}
|
||||
|
||||
if (xorgHWOpenConsole)
|
||||
xf86CloseConsole();
|
||||
if (xorgHWOpenConsole) {
|
||||
if (!seatd_libseat_controls_session()) {
|
||||
xf86CloseConsole();
|
||||
}
|
||||
}
|
||||
|
||||
seatd_libseat_fini();
|
||||
systemd_logind_fini();
|
||||
dbus_core_fini();
|
||||
|
||||
|
||||
@@ -72,6 +72,8 @@
|
||||
#include "mipointer.h"
|
||||
#include "loaderProcs.h"
|
||||
#include "../os-support/linux/systemd-logind.h"
|
||||
#include "seatd-libseat.h"
|
||||
|
||||
#include "exevents.h" /* AddInputDevice */
|
||||
#include "exglobals.h"
|
||||
#include "eventstr.h"
|
||||
@@ -858,9 +860,10 @@ xf86DeleteInput(InputInfoPtr pInp, int flags)
|
||||
|
||||
FreeInputAttributes(pInp->attrs);
|
||||
|
||||
if (pInp->flags & XI86_SERVER_FD)
|
||||
if (pInp->flags & XI86_SERVER_FD){
|
||||
seatd_libseat_close_device(pInp);
|
||||
systemd_logind_release_fd(pInp->major, pInp->minor, pInp->fd);
|
||||
|
||||
}
|
||||
/* Remove the entry from the list. */
|
||||
if (pInp == xf86InputDevs)
|
||||
xf86InputDevs = pInp->next;
|
||||
@@ -987,6 +990,7 @@ xf86NewInputDevice(InputInfoPtr pInfo, DeviceIntPtr *pdev, BOOL enable)
|
||||
if (path && (drv->capabilities & XI86_DRV_CAP_SERVER_FD)){
|
||||
int fd = systemd_logind_take_fd(pInfo->major, pInfo->minor,
|
||||
path, &paused);
|
||||
seatd_libseat_open_device(pInfo,&fd,&paused);
|
||||
if (fd != -1) {
|
||||
if (paused) {
|
||||
/* Put on new_input_devices list for delayed probe */
|
||||
|
||||
@@ -45,6 +45,8 @@
|
||||
|
||||
#include "os/osdep.h"
|
||||
|
||||
#include "seatd-libseat.h"
|
||||
|
||||
static Bool KeepTty = FALSE;
|
||||
|
||||
#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
|
||||
@@ -157,6 +159,12 @@ xf86OpenConsole(void)
|
||||
#endif
|
||||
|
||||
if (serverGeneration == 1) {
|
||||
|
||||
/* If libseat is in control, it handles VT switching. */
|
||||
if (seatd_libseat_controls_session()) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* check if we are run with euid==0 */
|
||||
if (geteuid() != 0) {
|
||||
FatalError("xf86OpenConsole: Server must be suid root");
|
||||
|
||||
@@ -41,6 +41,9 @@
|
||||
#include "xf86_os_support.h"
|
||||
#include "xf86_OSlib.h"
|
||||
|
||||
#include "seatd-libseat.h"
|
||||
|
||||
|
||||
#include <sys/stat.h>
|
||||
#ifdef HAVE_SYS_SYSMACROS_H
|
||||
#include <sys/sysmacros.h>
|
||||
@@ -114,7 +117,7 @@ linux_parse_vt_settings(int may_fail)
|
||||
if (fd < 0) {
|
||||
if (may_fail)
|
||||
return 0;
|
||||
FatalError("parse_vt_settings: Cannot open /dev/tty0 (%s)\n",
|
||||
FatalError("parse_vt_settings: Cannot open /dev/tty0 (%s), maybe missing for ex. '-seat seat0 -keeptty' parameters? (in case trying to run uid !=0 mode)\n",
|
||||
strerror(errno));
|
||||
}
|
||||
|
||||
@@ -213,6 +216,11 @@ xf86OpenConsole(void)
|
||||
i++;
|
||||
}
|
||||
|
||||
|
||||
/* If libseat is in control, it handles VT switching. */
|
||||
if (seatd_libseat_controls_session())
|
||||
return;
|
||||
|
||||
if (xf86Info.consoleFd < 0)
|
||||
FatalError("xf86OpenConsole: Cannot open virtual console"
|
||||
" %d (%s)\n", xf86Info.vtno, strerror(errno));
|
||||
@@ -306,7 +314,7 @@ xf86CloseConsole(void)
|
||||
struct vt_stat vts;
|
||||
int ret;
|
||||
|
||||
if (xf86Info.ShareVTs) {
|
||||
if (xf86Info.ShareVTs || seatd_libseat_controls_session()) {
|
||||
close(xf86Info.consoleFd);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -34,6 +34,8 @@
|
||||
#include "xf86_os_support.h"
|
||||
#include "xf86_OSlib.h"
|
||||
|
||||
#include "seatd-libseat.h"
|
||||
|
||||
/*
|
||||
* Handle the VT-switching interface for OSs that use USL-style ioctl()s
|
||||
* (this used to include the sysv, sco, and linux subdirs, but only linux
|
||||
@@ -62,6 +64,8 @@ Bool
|
||||
xf86VTSwitchAway(void)
|
||||
{
|
||||
xf86Info.vtRequestsPending = FALSE;
|
||||
if (seatd_libseat_controls_session())
|
||||
return TRUE;
|
||||
if (ioctl(xf86Info.consoleFd, VT_RELDISP, 1) < 0)
|
||||
return FALSE;
|
||||
else
|
||||
@@ -72,6 +76,8 @@ Bool
|
||||
xf86VTSwitchTo(void)
|
||||
{
|
||||
xf86Info.vtRequestsPending = FALSE;
|
||||
if (seatd_libseat_controls_session())
|
||||
return TRUE;
|
||||
if (ioctl(xf86Info.consoleFd, VT_RELDISP, VT_ACKACQ) < 0)
|
||||
return FALSE;
|
||||
else
|
||||
|
||||
@@ -21,34 +21,44 @@
|
||||
#include "xf86Bus.h"
|
||||
|
||||
#include "../linux/systemd-logind.h"
|
||||
#include "seatd-libseat.h"
|
||||
|
||||
static Bool
|
||||
get_drm_info(struct OdevAttributes *attribs, char *path, int delayed_index)
|
||||
{
|
||||
drmVersionPtr v;
|
||||
int fd;
|
||||
int fd = -1;
|
||||
int err = 0;
|
||||
Bool paused = FALSE, server_fd = FALSE;
|
||||
|
||||
LogMessage(X_INFO, "Platform probe for %s\n", attribs->syspath);
|
||||
|
||||
fd = systemd_logind_take_fd(attribs->major, attribs->minor, path, &paused);
|
||||
fd = seatd_libseat_open_graphics(path);
|
||||
if (fd != -1) {
|
||||
if (paused) {
|
||||
LogMessage(X_ERROR,
|
||||
"Error systemd-logind returned paused fd for drm node\n");
|
||||
systemd_logind_release_fd(attribs->major, attribs->minor, -1);
|
||||
return FALSE;
|
||||
}
|
||||
attribs->fd = fd;
|
||||
server_fd = TRUE;
|
||||
} else {
|
||||
fd = systemd_logind_take_fd(attribs->major, attribs->minor, path, &paused);
|
||||
if (fd != -1) {
|
||||
if (paused) {
|
||||
LogMessage(X_ERROR,
|
||||
"Error systemd-logind returned paused fd for drm node\n");
|
||||
systemd_logind_release_fd(attribs->major, attribs->minor, -1);
|
||||
return FALSE;
|
||||
}
|
||||
attribs->fd = fd;
|
||||
server_fd = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
if (fd == -1)
|
||||
if (fd == -1) {
|
||||
/* Try opening the path directly */
|
||||
fd = open(path, O_RDWR | O_CLOEXEC, 0);
|
||||
|
||||
if (fd == -1)
|
||||
return FALSE;
|
||||
if (fd == -1) {
|
||||
xf86Msg(X_ERROR, "cannot open %s\n", path);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/* for a delayed probe we've already added the device */
|
||||
if (delayed_index == -1) {
|
||||
|
||||
Reference in New Issue
Block a user