Add API to record the socket name used by a given file descriptor

This commit is contained in:
David Edmundson 2021-08-16 17:36:15 +01:00
parent d0a0c70d9c
commit aeaa480b0c
2 changed files with 6 additions and 2 deletions

View file

@ -50,12 +50,15 @@ Display::~Display()
wl_display_destroy(d->display);
}
bool Display::addSocketFileDescriptor(int fileDescriptor)
bool Display::addSocketFileDescriptor(int fileDescriptor, const QString &name)
{
if (wl_display_add_socket_fd(d->display, fileDescriptor)) {
qCWarning(KWAYLAND_SERVER, "Failed to add %d fd to display", fileDescriptor);
return false;
}
if (!name.isEmpty()) {
d->registerSocketName(name);
}
return true;
}

View file

@ -57,10 +57,11 @@ public:
* returns @c true if the socket has been added successfully; otherwise returns @c false.
*
* The compositor can call this function even after the display has been started.
* @arg socketName can optionally be parsed to store the socket name represented by the given file-descriptor
*
* @see start()
*/
bool addSocketFileDescriptor(int fileDescriptor);
bool addSocketFileDescriptor(int fileDescriptor, const QString &socketName = QString());
/**
* Adds a UNIX socket with the specified @p name to the Wayland display. This function
* returns @c true if the socket has been added successfully; otherwise returns @c false.