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,11 +100,16 @@ 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() {
return Ok(());
} else {
// 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);
// 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);
}
}
}

View File

@ -106,7 +106,10 @@ 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()));
server.add_service(Box::new(input_service::new_window_focus()));
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))