Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions core/src/graphics/direct_composition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,3 +157,12 @@ impl DirectComposition {
Ok(())
}
}

impl Drop for DirectComposition {
fn drop(&mut self) {
unsafe {
let _ = self.target.SetRoot(None);
let _ = self.desktop.Commit();
}
}
}
8 changes: 8 additions & 0 deletions core/src/graphics/graphics_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,14 @@ impl<'a> GraphicsContext<'a> {
}
}

impl Drop for GraphicsContext<'_> {
fn drop(&mut self) {
// This is needed for windows, because otherwise the title bar becomes
// visible when a new overlay surface is created.
self.window.set_minimized(true);
}
}

/// Creates a GPU texture from an image file for overlay rendering.
///
/// This function loads an image from disk, uploads it to GPU memory, and creates
Expand Down
21 changes: 14 additions & 7 deletions core/src/input/mouse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::{
Arc, Mutex,
},
thread::JoinHandle,
time::Duration,
time::{Duration, Instant},
};

use crate::{
Expand Down Expand Up @@ -98,6 +98,8 @@ pub static SVG_BADGE_COLORS: [&str; 7] = [
"#7CCF00", "#615FFF", "#009689", "#C800DE", "#00A6F4", "#FFB900", "#ED0040",
];

const SHARER_POSITION_UPDATE_INTERVAL: Duration = Duration::from_millis(30);

/// Specific error types for CursorController initialization failures.
///
/// These errors provide detailed information about what component failed during
Expand Down Expand Up @@ -460,6 +462,7 @@ pub struct SharerCursor {
controllers_cursors: Arc<Mutex<Vec<ControllerCursor>>>,
cursor_simulator: Arc<Mutex<CursorSimulator>>,
last_event_position: Position,
last_event_position_time: Instant,
}

impl SharerCursor {
Expand All @@ -478,6 +481,7 @@ impl SharerCursor {
controllers_cursors,
cursor_simulator,
last_event_position: Position::default(),
last_event_position_time: Instant::now(),
}
}

Expand All @@ -494,12 +498,15 @@ impl SharerCursor {
self.cursor
.set_position(global_position, local_position, !self.has_control);

let res = self.event_loop_proxy.send_event(UserEvent::SharerPosition(
display_percentage.x,
display_percentage.y,
));
if let Err(e) = res {
error!("sharer_cursor: set_position: error sending sharer position: {e:?}");
if self.last_event_position_time.elapsed() > SHARER_POSITION_UPDATE_INTERVAL {
let res = self.event_loop_proxy.send_event(UserEvent::SharerPosition(
display_percentage.x,
display_percentage.y,
));
if let Err(e) = res {
error!("sharer_cursor: set_position: error sending sharer position: {e:?}");
}
self.last_event_position_time = Instant::now();
}
}

Expand Down
2 changes: 1 addition & 1 deletion core/src/input/mouse_windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ impl CursorSimulatorFunctions for CursorSimulator {
* get from a mouse. A touchpad has smaller deltas but is generating more
* events compared to a mouse.
*
* We try to work around this by using a different multipling factor to
* We try to work around this by using a different multiplying factor to
* 120 for different input values, below 100 the factor is bigger and as
* delta is increasing the factor become smaller and eventually 1. We want
*
Expand Down
3 changes: 3 additions & 0 deletions core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,9 @@ impl<'a> Application<'a> {
screenshare_input.accessibility_permission,
screenshare_input.use_av1
);

self.stop_screenshare();

let mut screen_capturer = self.screen_capturer.lock().unwrap();
/*
* In order to not rely on the buffer source to exist before starting the room
Expand Down
8 changes: 4 additions & 4 deletions tauri/src/components/SharingScreen/SharingScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ const ConsumerComponent = React.memo(() => {
useEffect(() => {
const videoElement = videoRef.current;

const handleMouseMove = (e: MouseEvent) => {
const handleMouseMove = throttle((e: MouseEvent) => {
if (videoElement) {
const { relativeX, relativeY } = getRelativePosition(videoElement, e);
// console.debug(`Mouse moving 🚶: relativeX: ${relativeX}, relativeY: ${relativeY}`);
Expand All @@ -292,7 +292,7 @@ const ConsumerComponent = React.memo(() => {
topic: CURSORS_TOPIC,
});
}
};
}, 30);

const handleMouseDown = (e: MouseEvent) => {
if (videoElement) {
Expand Down Expand Up @@ -351,7 +351,7 @@ const ConsumerComponent = React.memo(() => {
e.preventDefault();
};

const handleWheel = (e: WheelEvent) => {
const handleWheel = throttle((e: WheelEvent) => {
if (videoElement) {
// Solve natural flow of the wheel
// Source: https://stackoverflow.com/a/23668035
Expand All @@ -370,7 +370,7 @@ const ConsumerComponent = React.memo(() => {

localParticipant.localParticipant?.publishData(encoder.encode(JSON.stringify(payload)), { reliable: true });
}
};
}, 16);

// Send mouse visible data
if (videoElement) {
Expand Down
Loading