mirror of
https://github.com/hyprwm/Hyprland
synced 2025-01-23 22:29:49 +01:00
xwayland: support sending clipboard change notification on focus (#9111)
This commit is contained in:
parent
2d82a92324
commit
9e8d9791c7
2 changed files with 15 additions and 1 deletions
|
@ -1144,7 +1144,8 @@ void CXWM::initSelection() {
|
|||
XCB_XFIXES_SELECTION_EVENT_MASK_SET_SELECTION_OWNER | XCB_XFIXES_SELECTION_EVENT_MASK_SELECTION_WINDOW_DESTROY | XCB_XFIXES_SELECTION_EVENT_MASK_SELECTION_CLIENT_CLOSE;
|
||||
xcb_xfixes_select_selection_input(connection, clipboard.window, HYPRATOMS["CLIPBOARD"], mask2);
|
||||
|
||||
clipboard.listeners.setSelection = g_pSeatManager->events.setSelection.registerListener([this](std::any d) { clipboard.onSelection(); });
|
||||
clipboard.listeners.setSelection = g_pSeatManager->events.setSelection.registerListener([this](std::any d) { clipboard.onSelection(); });
|
||||
clipboard.listeners.keyboardFocusChange = g_pSeatManager->events.keyboardFocusChange.registerListener([this](std::any d) { clipboard.onKeyboardFocus(); });
|
||||
|
||||
dndSelection.window = xcb_generate_id(connection);
|
||||
xcb_create_window(connection, XCB_COPY_FROM_PARENT, dndSelection.window, screen->root, 0, 0, 8192, 8192, 0, XCB_WINDOW_CLASS_INPUT_ONLY, screen->root_visual, XCB_CW_EVENT_MASK,
|
||||
|
@ -1287,6 +1288,16 @@ void SXSelection::onSelection() {
|
|||
if (g_pSeatManager->selection.currentSelection) {
|
||||
xcb_set_selection_owner(g_pXWayland->pWM->connection, g_pXWayland->pWM->clipboard.window, HYPRATOMS["CLIPBOARD"], XCB_TIME_CURRENT_TIME);
|
||||
xcb_flush(g_pXWayland->pWM->connection);
|
||||
g_pXWayland->pWM->clipboard.notifyOnFocus = true;
|
||||
}
|
||||
}
|
||||
|
||||
void SXSelection::onKeyboardFocus() {
|
||||
if (!g_pSeatManager->state.keyboardFocusResource || g_pSeatManager->state.keyboardFocusResource->client() != g_pXWayland->pServer->xwaylandClient)
|
||||
return;
|
||||
if (g_pXWayland->pWM->clipboard.notifyOnFocus) {
|
||||
onSelection();
|
||||
g_pXWayland->pWM->clipboard.notifyOnFocus = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -44,13 +44,16 @@ struct SXSelection {
|
|||
xcb_window_t owner = 0;
|
||||
xcb_timestamp_t timestamp = 0;
|
||||
SP<CXDataSource> dataSource;
|
||||
bool notifyOnFocus = false;
|
||||
|
||||
void onSelection();
|
||||
void onKeyboardFocus();
|
||||
bool sendData(xcb_selection_request_event_t* e, std::string mime);
|
||||
int onRead(int fd, uint32_t mask);
|
||||
|
||||
struct {
|
||||
CHyprSignalListener setSelection;
|
||||
CHyprSignalListener keyboardFocusChange;
|
||||
} listeners;
|
||||
|
||||
std::unique_ptr<SXTransfer> transfer;
|
||||
|
|
Loading…
Reference in a new issue