wayland: fix enigo crash & mid commit

Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
fufesou
2022-10-13 06:34:50 -07:00
parent 3c9ac9e4d7
commit 5ddb10366e
7 changed files with 65 additions and 32 deletions

View File

@@ -379,6 +379,10 @@ fn run(sp: GenericService) -> ResultType<()> {
#[cfg(windows)]
ensure_close_virtual_device()?;
// ensure_inited() is needed because release_resouce() may be called.
#[cfg(target_os = "linux")]
super::wayland::ensure_inited()?;
let mut c = get_capturer(true)?;
let mut video_qos = VIDEO_QOS.lock().unwrap();
@@ -458,6 +462,8 @@ fn run(sp: GenericService) -> ResultType<()> {
#[cfg(windows)]
start_uac_elevation_check();
let mut would_block_count = 0u32;
while sp.ok() {
#[cfg(windows)]
check_uac_switch(c.privacy_mode_id, c._captuerer_privacy_mode_id)?;
@@ -547,8 +553,7 @@ fn run(sp: GenericService) -> ResultType<()> {
};
match res {
Err(ref e) if e.kind() == WouldBlock =>
{
Err(ref e) if e.kind() == WouldBlock => {
#[cfg(windows)]
if try_gdi > 0 && !c.is_gdi() {
if try_gdi > 3 {
@@ -558,6 +563,19 @@ fn run(sp: GenericService) -> ResultType<()> {
}
try_gdi += 1;
}
would_block_count += 1;
#[cfg(target_os = "linux")]
{
if !scrap::is_x11() {
if would_block_count >= 100 {
// For now, the user should choose and agree screen sharing agiain.
// to-do: Remember choice, attendless...
super::wayland::release_resouce();
bail!("Wayland capturer none 100 times, try restart captuere");
}
}
}
}
Err(err) => {
if check_display_changed(c.ndisplay, c.current, c.width, c.height) {
@@ -575,7 +593,9 @@ fn run(sp: GenericService) -> ResultType<()> {
return Err(err.into());
}
_ => {}
_ => {
would_block_count = 0;
}
}
let mut fetched_conn_ids = HashSet::new();