not run window focus service on wayland (#9354)

Signed-off-by: 21pages <sunboeasy@gmail.com>
This commit is contained in:
21pages 2024-09-14 09:59:14 +08:00 committed by GitHub
parent 81fc22a156
commit 40af9dc78b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 14 additions and 5 deletions

View File

@ -1,3 +1,4 @@
use hbb_common::libc;
use std::ptr;
use std::rc::Rc;
@ -99,13 +100,18 @@ unsafe fn check_x11_shm_available(c: *mut xcb_connection_t) -> Result<(), Error>
if reply.is_null() {
// TODO: Should seperate SHM disabled from SHM not supported?
return Err(Error::UnsupportedExtension);
} else if e.is_null() {
} else {
// https://github.com/FFmpeg/FFmpeg/blob/6229e4ac425b4566446edefb67d5c225eb397b58/libavdevice/xcbgrab.c#L229
libc::free(reply as *mut _);
if e.is_null() {
return Ok(());
} else {
libc::free(e as *mut _);
// TODO: Does "This request does never generate any errors" in manual means `e` is never set, so we would never reach here?
return Err(Error::Generic);
}
}
}
impl Drop for Server {
fn drop(&mut self) {

View File

@ -106,9 +106,12 @@ pub fn new() -> ServerPtr {
if !display_service::capture_cursor_embedded() {
server.add_service(Box::new(input_service::new_cursor()));
server.add_service(Box::new(input_service::new_pos()));
if scrap::is_x11() {
// wayland does not support multiple displays currently
server.add_service(Box::new(input_service::new_window_focus()));
}
}
}
Arc::new(RwLock::new(server))
}