From aeaa480b0c10fad11a8f951c2559c5f7e9061b6d Mon Sep 17 00:00:00 2001 From: David Edmundson Date: Mon, 16 Aug 2021 17:36:15 +0100 Subject: [PATCH] Add API to record the socket name used by a given file descriptor --- src/wayland/display.cpp | 5 ++++- src/wayland/display.h | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/wayland/display.cpp b/src/wayland/display.cpp index acfd39499c..a340990ef1 100644 --- a/src/wayland/display.cpp +++ b/src/wayland/display.cpp @@ -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; } diff --git a/src/wayland/display.h b/src/wayland/display.h index 223e41b73a..d8be231ec8 100644 --- a/src/wayland/display.h +++ b/src/wayland/display.h @@ -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.