summaryrefslogtreecommitdiff
path: root/src/xwayland/XDataSource.cpp
diff options
context:
space:
mode:
authornyx <nnyyxxxx@protonmail.com>2025-02-15 14:03:37 -0500
committerGitHub <noreply@github.com>2025-02-15 20:03:37 +0100
commit9228116c9aa682477aae1a52d2d7d023bb075352 (patch)
treeaea45053ca19d777c17b9e326c4afc8957567c93 /src/xwayland/XDataSource.cpp
parent410da2e46fc44d93196cd902a070391a416cff01 (diff)
xwayland: fix a possible clipboard race condition (#9394)
Diffstat (limited to 'src/xwayland/XDataSource.cpp')
-rw-r--r--src/xwayland/XDataSource.cpp15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/xwayland/XDataSource.cpp b/src/xwayland/XDataSource.cpp
index 9384db69..003f6c9f 100644
--- a/src/xwayland/XDataSource.cpp
+++ b/src/xwayland/XDataSource.cpp
@@ -71,19 +71,20 @@ void CXDataSource::send(const std::string& mime, CFileDescriptor fd) {
Debug::log(LOG, "[XDataSource] send with mime {} to fd {}", mime, fd.get());
- selection.transfer = makeUnique<SXTransfer>(selection);
- selection.transfer->incomingWindow = xcb_generate_id(g_pXWayland->pWM->connection);
- const uint32_t MASK = XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY | XCB_EVENT_MASK_PROPERTY_CHANGE;
- xcb_create_window(g_pXWayland->pWM->connection, XCB_COPY_FROM_PARENT, selection.transfer->incomingWindow, g_pXWayland->pWM->screen->root, 0, 0, 10, 10, 0,
- XCB_WINDOW_CLASS_INPUT_OUTPUT, g_pXWayland->pWM->screen->root_visual, XCB_CW_EVENT_MASK, &MASK);
+ auto transfer = makeUnique<SXTransfer>(selection);
+ transfer->incomingWindow = xcb_generate_id(g_pXWayland->pWM->connection);
+ const uint32_t MASK = XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY | XCB_EVENT_MASK_PROPERTY_CHANGE;
+ xcb_create_window(g_pXWayland->pWM->connection, XCB_COPY_FROM_PARENT, transfer->incomingWindow, g_pXWayland->pWM->screen->root, 0, 0, 10, 10, 0, XCB_WINDOW_CLASS_INPUT_OUTPUT,
+ g_pXWayland->pWM->screen->root_visual, XCB_CW_EVENT_MASK, &MASK);
- xcb_convert_selection(g_pXWayland->pWM->connection, selection.transfer->incomingWindow, HYPRATOMS["CLIPBOARD"], mimeAtom, HYPRATOMS["_WL_SELECTION"], XCB_TIME_CURRENT_TIME);
+ xcb_convert_selection(g_pXWayland->pWM->connection, transfer->incomingWindow, HYPRATOMS["CLIPBOARD"], mimeAtom, HYPRATOMS["_WL_SELECTION"], XCB_TIME_CURRENT_TIME);
xcb_flush(g_pXWayland->pWM->connection);
//TODO: make CFileDescriptor setflags take SETFL aswell
fcntl(fd.get(), F_SETFL, O_WRONLY | O_NONBLOCK);
- selection.transfer->wlFD = std::move(fd);
+ transfer->wlFD = std::move(fd);
+ selection.transfers.emplace_back(std::move(transfer));
}
void CXDataSource::accepted(const std::string& mime) {