diff --git a/hw/xfree86/common/xf86Events.c b/hw/xfree86/common/xf86Events.c index 05fa2bb90..6076efa80 100644 --- a/hw/xfree86/common/xf86Events.c +++ b/hw/xfree86/common/xf86Events.c @@ -382,6 +382,17 @@ xf86VTLeave(void) for (i = 0; i < xf86NumGPUScreens; i++) xf86GPUScreens[i]->LeaveVT(xf86GPUScreens[i]); + if (systemd_logind_controls_session()) { + for (i = 0; i < xf86_num_platform_devices; i++) { + if (xf86_platform_devices[i].flags & XF86_PDEV_SERVER_FD) { + int major, minor; + major = xf86_platform_odev_attributes(i)->major; + minor = xf86_platform_odev_attributes(i)->minor; + systemd_logind_drop_master(major, minor); + } + } + } + if (!xf86VTSwitchAway()) goto switch_failed; diff --git a/hw/xfree86/os-support/linux/systemd-logind.c b/hw/xfree86/os-support/linux/systemd-logind.c index fce52ff93..35d5cc75b 100644 --- a/hw/xfree86/os-support/linux/systemd-logind.c +++ b/hw/xfree86/os-support/linux/systemd-logind.c @@ -303,6 +303,20 @@ cleanup: dbus_error_free(&error); } +/* + * Send a message to logind, to pause the drm device + * and ensure the drm_drop_master is done before + * VT_RELDISP when switching VT + */ +void systemd_logind_drop_master(int _major, int _minor) +{ + struct systemd_logind_info *info = &logind_info; + dbus_int32_t major = _major; + dbus_int32_t minor = _minor; + + systemd_logind_ack_pause(info, minor, major); +} + static DBusHandlerResult message_filter(DBusConnection * connection, DBusMessage * message, void *data) { diff --git a/include/systemd-logind.h b/include/systemd-logind.h index a4067d097..a8af2b96d 100644 --- a/include/systemd-logind.h +++ b/include/systemd-logind.h @@ -33,6 +33,7 @@ int systemd_logind_take_fd(int major, int minor, const char *path, Bool *paus); void systemd_logind_release_fd(int major, int minor, int fd); int systemd_logind_controls_session(void); void systemd_logind_vtenter(void); +void systemd_logind_drop_master(int major, int minor); #else #define systemd_logind_init() #define systemd_logind_fini() @@ -40,6 +41,7 @@ void systemd_logind_vtenter(void); #define systemd_logind_release_fd(major, minor, fd) close(fd) #define systemd_logind_controls_session() 0 #define systemd_logind_vtenter() +#define systemd_logind_drop_master(major, minor) #endif #endif