clipboard: make store idempotent to avoid re-init of in-use data source
This commit is contained in:
parent
5d456d5b95
commit
1bcd815001
|
|
@ -5352,6 +5352,19 @@ static void wl_clipboard_store_to_seat(const char *text, int len)
|
|||
if (!wl_state.seat || !text || len <= 0)
|
||||
return;
|
||||
|
||||
/* If we already own the seat selection, just update the buffer
|
||||
* instead of re-initializing the source (which can corrupt
|
||||
* wlroots' internal state for subsequent paste requests). */
|
||||
if (wl_state.seat->selection_source == &wl_seat_clipboard_source) {
|
||||
if (wl_seat_clipboard_text)
|
||||
free(wl_seat_clipboard_text);
|
||||
wl_seat_clipboard_text = malloc(len + 1);
|
||||
memcpy(wl_seat_clipboard_text, text, len);
|
||||
wl_seat_clipboard_text[len] = '\0';
|
||||
wl_seat_clipboard_len = len;
|
||||
return;
|
||||
}
|
||||
|
||||
if (wl_seat_clipboard_text)
|
||||
free(wl_seat_clipboard_text);
|
||||
wl_seat_clipboard_text = malloc(len + 1);
|
||||
|
|
|
|||
Loading…
Reference in New Issue