clipboard: fix segfault when pasting to some X11 apps. Fixes #13891 (#13971)

pull/13972/head
Larpon 2022-04-08 12:32:38 +02:00 committed by GitHub
parent 52f1c615a6
commit 45a427e68b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 5 deletions

View File

@ -330,7 +330,7 @@ fn (mut cb Clipboard) start_listener() {
property: xsre.property property: xsre.property
} }
if !cb.transmit_selection(&xse) { if !cb.transmit_selection(&xse) {
xse.property = new_atom(0) xse.property = Atom(0)
} }
C.XSendEvent(cb.display, xse.requestor, 0, C.PropertyChangeMask, voidptr(&xse)) C.XSendEvent(cb.display, xse.requestor, 0, C.PropertyChangeMask, voidptr(&xse))
C.XFlush(cb.display) C.XFlush(cb.display)
@ -479,10 +479,6 @@ fn (cb &Clipboard) get_supported_targets() []Atom {
return cb.get_atoms(AtomType.utf8_string, .xa_string, .text, .text_plain, .text_html) return cb.get_atoms(AtomType.utf8_string, .xa_string, .text, .text_plain, .text_html)
} }
fn new_atom(value int) &Atom {
return unsafe { &Atom(&u64(u64(value))) }
}
fn create_xwindow(display &C.Display) Window { fn create_xwindow(display &C.Display) Window {
n := C.DefaultScreen(display) n := C.DefaultScreen(display)
return C.XCreateSimpleWindow(display, C.RootWindow(display, n), 0, 0, 1, 1, 0, C.BlackPixel(display, return C.XCreateSimpleWindow(display, C.RootWindow(display, n), 0, 0, 1, 1, 0, C.BlackPixel(display,