fix build linux

Signed-off-by: dignow <linlong1265@gmail.com>
This commit is contained in:
dignow 2023-10-18 08:07:00 +08:00
parent c4f09b5598
commit a32e740242
5 changed files with 27 additions and 18 deletions

View File

@ -1,4 +1,4 @@
#[cfg(not(any(target_os = "android", target_os = "ios")))]
#[cfg(windows)]
use crate::client::translate;
#[cfg(not(debug_assertions))]
#[cfg(not(any(target_os = "android", target_os = "ios")))]

View File

@ -151,7 +151,7 @@ fn displays_to_msg(displays: Vec<DisplayInfo>) -> Message {
}
fn check_get_displays_changed_msg() -> Option<Message> {
check_update_displays(try_get_displays().ok()?);
check_update_displays(&try_get_displays().ok()?);
let displays = SYNC_DISPLAYS.lock().unwrap().get_update_sync_displays()?;
Some(displays_to_msg(displays))
}
@ -225,9 +225,14 @@ pub(super) fn get_original_resolution(
.into()
}
#[cfg(target_os = "linux")]
pub(super) fn get_sync_displays() -> Vec<DisplayInfo> {
SYNC_DISPLAYS.lock().unwrap().displays.clone()
}
// Display to DisplayInfo
// The DisplayInfo is be sent to the peer.
fn check_update_displays(all: Vec<Display>) {
pub(super) fn check_update_displays(all: &Vec<Display>) {
let displays = all
.iter()
.map(|d| {
@ -264,7 +269,7 @@ pub async fn update_get_sync_displays() -> ResultType<Vec<DisplayInfo>> {
return super::wayland::get_displays().await;
}
}
check_update_displays(try_get_displays()?);
check_update_displays(&try_get_displays()?);
Ok(SYNC_DISPLAYS.lock().unwrap().displays.clone())
}

View File

@ -407,7 +407,7 @@ fn run(vs: VideoService) -> ResultType<()> {
#[cfg(target_os = "linux")]
super::wayland::ensure_inited()?;
#[cfg(target_os = "linux")]
let wayland_call_on_ret = SimpleCallOnReturn {
let _wayland_call_on_ret = SimpleCallOnReturn {
b: true,
f: Box::new(|| {
super::wayland::clear();

View File

@ -84,7 +84,6 @@ impl TraitCapturer for CapturerPtr {
struct CapDisplayInfo {
rects: Vec<((i32, i32), usize, usize)>,
displays: Vec<DisplayInfo>,
num: usize,
primary: usize,
current: usize,
capturer: CapturerPtr,
@ -146,7 +145,8 @@ pub(super) async fn check_init() -> ResultType<()> {
let num = all.len();
let primary = super::display_service::get_primary_2(&all);
let current = primary;
let mut displays = super::display_service::to_display_info(&all);
super::display_service::check_update_displays(&all);
let mut displays = super::display_service::get_sync_displays();
for display in displays.iter_mut() {
display.cursor_embedded = is_cursor_embedded();
}
@ -173,10 +173,13 @@ pub(super) async fn check_init() -> ResultType<()> {
Some(result) if !result.is_empty() => {
let resolution: Vec<&str> = result.split(" ").collect();
let w: i32 = resolution[0].parse().unwrap_or(origin.0 + width as i32);
let h: i32 = resolution[2].trim_end_matches(",").parse().unwrap_or(origin.1 + height as i32);
let h: i32 = resolution[2]
.trim_end_matches(",")
.parse()
.unwrap_or(origin.1 + height as i32);
(w, h)
}
_ => (origin.0 + width as i32, origin.1 + height as i32)
_ => (origin.0 + width as i32, origin.1 + height as i32),
};
minx = 0;
@ -191,7 +194,6 @@ pub(super) async fn check_init() -> ResultType<()> {
let cap_display_info = Box::into_raw(Box::new(CapDisplayInfo {
rects,
displays,
num,
primary,
current,
capturer,
@ -273,7 +275,6 @@ pub(super) fn get_capturer() -> ResultType<super::video_service::CapturerInfo> {
origin: rect.0,
width: rect.1,
height: rect.2,
ndisplay: cap_display_info.num,
current: cap_display_info.current,
privacy_mode_id: 0,
_capturer_privacy_mode_id: 0,

View File

@ -1,9 +1,12 @@
use crate::{client::translate, ipc::Data};
use hbb_common::{allow_err, log, tokio};
use std::{
sync::{Arc, Mutex},
time::Duration,
};
use crate::client::translate;
#[cfg(windows)]
use crate::ipc::Data;
#[cfg(windows)]
use hbb_common::tokio;
use hbb_common::{allow_err, log};
use std::sync::{Arc, Mutex};
#[cfg(windows)]
use std::time::Duration;
pub fn start_tray() {
allow_err!(make_tray());