BlueGit

ict rusty-teams

fix(video): show the inline player above the gpui surface

- player container is an owned popup that follows the main window; gpui's topmost composition hid the child window
- video stops while a dialog is open
- demo standup recording carries a video for the player
- demo uses its own WebView2 folder

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

metis Daniel Däschle · pushed by metis

Authored 2026-11-05 · 3 weeks ago

Hash
8bc9582fc0aedadb90d32e96fb8b220d5d08aa9f
Parent
33b53d7d
5 files changed +97 −23
crates/app-state/src/demo.rs +12 −9
@@ -1546,15 +1546,18 @@ fn standup_messages() -> Vec<MessageRecord> {
1546 1546 ),
1547 1547 r#"[{"content_type":"reference","name":"Standup-notes.docx","url":"https://example.com/files/standup-notes.docx","text":null,"size":38900}]"#,
1548 1548 ),
1549 message(
1550 "demo-chat-meeting-standup",
1551 "su2",
1552 None,
1553 jonas,
1554 at(0, 9, 45),
1555 "<p>Recording is available</p>",
1556 "[]",
1557 false,
1549 with_attachments(
1550 message(
1551 "demo-chat-meeting-standup",
1552 "su2",
1553 None,
1554 jonas,
1555 at(0, 9, 45),
1556 "<p>Recording is available</p>",
1557 "[]",
1558 false,
1559 ),
1560 r#"[{"content_type":"reference","name":"Standup-recording.mp4","url":"https://contoso-my.sharepoint.com/personal/jonas_contoso_com/Documents/Recordings/Standup-recording.mp4","text":null,"size":18400000}]"#,
1558 1561 ),
1559 1562 with_links(
1560 1563 message(
@@ -1546,15 +1546,18 @@ fn standup_messages() -> Vec<MessageRecord> {
1546 ),
1546 ),
1547 r#"[{"content_type":"reference","name":"Standup-notes.docx","url":"https://example.com/files/standup-notes.docx","text":null,"size":38900}]"#,
1547 r#"[{"content_type":"reference","name":"Standup-notes.docx","url":"https://example.com/files/standup-notes.docx","text":null,"size":38900}]"#,
1548 ),
1548 ),
1549 message(
1549 with_attachments(
1550 "demo-chat-meeting-standup",
1550 message(
1551 "su2",
1551 "demo-chat-meeting-standup",
1552 None,
1552 "su2",
1553 jonas,
1553 None,
1554 at(0, 9, 45),
1554 jonas,
1555 "<p>Recording is available</p>",
1555 at(0, 9, 45),
1556 "[]",
1556 "<p>Recording is available</p>",
1557 false,
1557 "[]",
1558 false,
1559 ),
1560 r#"[{"content_type":"reference","name":"Standup-recording.mp4","url":"https://contoso-my.sharepoint.com/personal/jonas_contoso_com/Documents/Recordings/Standup-recording.mp4","text":null,"size":18400000}]"#,
1558 ),
1561 ),
1559 with_links(
1562 with_links(
1560 message(
1563 message(
crates/app/src/main.rs +6 −0
@@ -38,6 +38,8 @@ const SINGLE_INSTANCE_NAME: &str = "rusty-teams";
38 38 const DATABASE_FILE: &str = "cache.sqlite3";
39 39 #[cfg(windows)]
40 40 const WEBVIEW_FOLDER: &str = "WebView2";
41 #[cfg(windows)]
42 const DEMO_WEBVIEW_FOLDER: &str = "rusty-teams-demo-WebView2";
41 43
42 44 #[derive(Default)]
43 45 struct Arguments {
@@ -169,6 +171,10 @@ fn main() {
169 171 read_only: arguments.read_only,
170 172 demo_sync: arguments.demo_sync,
171 173 };
174 #[cfg(windows)]
175 if arguments.demo {
176 inline_video::configure(std::env::temp_dir().join(DEMO_WEBVIEW_FOLDER));
177 }
172 178 let store = if arguments.demo {
173 179 let store = Store::open_in_memory().expect("in-memory store");
174 180 demo::seed(&store);
@@ -38,6 +38,8 @@ const SINGLE_INSTANCE_NAME: &str = "rusty-teams";
38const DATABASE_FILE: &str = "cache.sqlite3";
38const DATABASE_FILE: &str = "cache.sqlite3";
39#[cfg(windows)]
39#[cfg(windows)]
40const WEBVIEW_FOLDER: &str = "WebView2";
40const WEBVIEW_FOLDER: &str = "WebView2";
41#[cfg(windows)]
42const DEMO_WEBVIEW_FOLDER: &str = "rusty-teams-demo-WebView2";
41
43
42#[derive(Default)]
44#[derive(Default)]
43struct Arguments {
45struct Arguments {
@@ -169,6 +171,10 @@ fn main() {
169 read_only: arguments.read_only,
171 read_only: arguments.read_only,
170 demo_sync: arguments.demo_sync,
172 demo_sync: arguments.demo_sync,
171 };
173 };
174 #[cfg(windows)]
175 if arguments.demo {
176 inline_video::configure(std::env::temp_dir().join(DEMO_WEBVIEW_FOLDER));
177 }
172 let store = if arguments.demo {
178 let store = if arguments.demo {
173 let store = Store::open_in_memory().expect("in-memory store");
179 let store = Store::open_in_memory().expect("in-memory store");
174 demo::seed(&store);
180 demo::seed(&store);
crates/app/src/views/shell.rs +3 −0
@@ -875,6 +875,9 @@ impl Render for AppShell {
875 875 .filter(|open| *open)
876 876 .count();
877 877 elevation::set_app_modal_layers(window, open_dialogs, cx);
878 if open_dialogs > 0 {
879 crate::inline_video::stop(cx);
880 }
878 881 if let Some(dialog) = self
879 882 .state
880 883 .read(cx)
@@ -875,6 +875,9 @@ impl Render for AppShell {
875 .filter(|open| *open)
875 .filter(|open| *open)
876 .count();
876 .count();
877 elevation::set_app_modal_layers(window, open_dialogs, cx);
877 elevation::set_app_modal_layers(window, open_dialogs, cx);
878 if open_dialogs > 0 {
879 crate::inline_video::stop(cx);
880 }
878 if let Some(dialog) = self
881 if let Some(dialog) = self
879 .state
882 .state
880 .read(cx)
883 .read(cx)
crates/webview/examples/embed_probe.rs +12 −3
@@ -225,9 +225,18 @@ mod probe {
225 225 }
226 226
227 227 fn find_container(parent: HWND) -> Option<HWND> {
228 unsafe { FindWindowExW(Some(parent), None, CONTAINER_CLASS, PCWSTR::null()) }
229 .ok()
230 .filter(|window| !window.is_invalid())
228 let mut after = None;
229 loop {
230 let window =
231 unsafe { FindWindowExW(None, after, CONTAINER_CLASS, PCWSTR::null()) }.ok()?;
232 if window.is_invalid() {
233 return None;
234 }
235 if unsafe { GetWindow(window, GW_OWNER) }.is_ok_and(|owner| owner == parent) {
236 return Some(window);
237 }
238 after = Some(window);
239 }
231 240 }
232 241
233 242 fn window_rect(window: HWND) -> RECT {
@@ -225,9 +225,18 @@ mod probe {
225 }
225 }
226
226
227 fn find_container(parent: HWND) -> Option<HWND> {
227 fn find_container(parent: HWND) -> Option<HWND> {
228 unsafe { FindWindowExW(Some(parent), None, CONTAINER_CLASS, PCWSTR::null()) }
228 let mut after = None;
229 .ok()
229 loop {
230 .filter(|window| !window.is_invalid())
230 let window =
231 unsafe { FindWindowExW(None, after, CONTAINER_CLASS, PCWSTR::null()) }.ok()?;
232 if window.is_invalid() {
233 return None;
234 }
235 if unsafe { GetWindow(window, GW_OWNER) }.is_ok_and(|owner| owner == parent) {
236 return Some(window);
237 }
238 after = Some(window);
239 }
231 }
240 }
232
241
233 fn window_rect(window: HWND) -> RECT {
242 fn window_rect(window: HWND) -> RECT {
crates/webview/src/main_embed.rs +64 −11
@@ -1,6 +1,6 @@
1 1 use std::cell::RefCell;
2 2 use std::path::PathBuf;
3 use std::rc::Rc;
3 use std::rc::{Rc, Weak};
4 4 use std::sync::Once;
5 5
6 6 use tokio::sync::mpsc::{UnboundedReceiver, UnboundedSender, unbounded_channel};
@@ -10,12 +10,13 @@ use webview2_com::{
10 10 NavigationCompletedEventHandler, NewWindowRequestedEventHandler, SourceChangedEventHandler,
11 11 take_pwstr,
12 12 };
13 use windows::Win32::Foundation::{HINSTANCE, HWND, LPARAM, LRESULT, RECT, WPARAM};
13 use windows::Win32::Foundation::{HINSTANCE, HWND, LPARAM, LRESULT, POINT, RECT, WPARAM};
14 14 use windows::Win32::Graphics::Gdi::{
15 CombineRgn, CreateRectRgn, DeleteObject, HGDIOBJ, RGN_DIFF, SetWindowRgn,
15 ClientToScreen, CombineRgn, CreateRectRgn, DeleteObject, HGDIOBJ, RGN_DIFF, SetWindowRgn,
16 16 };
17 17 use windows::Win32::System::Com::{COINIT_APARTMENTTHREADED, CoInitializeEx};
18 18 use windows::Win32::System::LibraryLoader::GetModuleHandleW;
19 use windows::Win32::UI::Shell::{DefSubclassProc, SetWindowSubclass};
19 20 use windows::Win32::UI::WindowsAndMessaging::*;
20 21 use windows::core::{HRESULT, HSTRING, Interface, PCWSTR, PWSTR, w};
21 22
@@ -24,8 +25,13 @@ use crate::geometry::{EmbedBounds, local_cutouts};
24 25 use crate::host::environment_options;
25 26
26 27 const CONTAINER_CLASS: PCWSTR = w!("RustyTeamsEmbedContainer");
28 const OWNER_SUBCLASS_ID: usize = 0x5254_4542;
27 29 static REGISTER_CONTAINER_CLASS: Once = Once::new();
28 30
31 thread_local! {
32 static OPEN_EMBEDS: RefCell<Vec<Weak<RefCell<EmbedState>>>> = const { RefCell::new(Vec::new()) };
33 }
34
29 35 enum Environment {
30 36 Idle,
31 37 Creating(Vec<SharedEmbed>),
@@ -80,7 +86,9 @@ impl EmbedHost {
80 86 }
81 87
82 88 pub fn open(&self, spec: EmbedSpec) -> Option<(MainEmbed, UnboundedReceiver<EmbedEvent>)> {
83 let container = create_container(HWND(spec.parent as *mut _)).ok()?;
89 let owner = HWND(spec.parent as *mut _);
90 let container = create_container(owner).ok()?;
91 follow_owner(owner);
84 92 let (events, receiver) = unbounded_channel();
85 93 let state = Rc::new(RefCell::new(EmbedState {
86 94 spec,
@@ -92,6 +100,11 @@ impl EmbedHost {
92 100 closed: false,
93 101 events,
94 102 }));
103 OPEN_EMBEDS.with(|embeds| {
104 let mut embeds = embeds.borrow_mut();
105 embeds.retain(|embed| embed.strong_count() > 0);
106 embeds.push(Rc::downgrade(&state));
107 });
95 108 self.request_controller(&state);
96 109 Some((MainEmbed { state }, receiver))
97 110 }
@@ -270,12 +283,13 @@ fn teardown(embed: &SharedEmbed) -> bool {
270 283 }
271 284
272 285 fn layout(embed: &SharedEmbed) {
273 let (container, bounds, visible, cutouts, controller) = {
286 let (owner, container, bounds, visible, cutouts, controller) = {
274 287 let state = embed.borrow();
275 288 if state.closed {
276 289 return;
277 290 }
278 291 (
292 HWND(state.spec.parent as *mut _),
279 293 state.container,
280 294 state.bounds,
281 295 state.visible,
@@ -287,12 +301,17 @@ fn layout(embed: &SharedEmbed) {
287 301 return;
288 302 };
289 303 let shown = visible && bounds.has_area();
304 let mut origin = POINT {
305 x: bounds.x,
306 y: bounds.y,
307 };
290 308 unsafe {
309 let _ = ClientToScreen(owner, &mut origin);
291 310 let _ = SetWindowPos(
292 311 container,
293 312 None,
294 bounds.x,
295 bounds.y,
313 origin.x,
314 origin.y,
296 315 bounds.width,
297 316 bounds.height,
298 317 SWP_NOZORDER | SWP_NOACTIVATE,
@@ -333,7 +352,41 @@ unsafe fn apply_region(container: HWND, content: EmbedBounds, cutouts: &[EmbedBo
333 352 }
334 353 }
335 354
336 fn create_container(parent: HWND) -> windows::core::Result<HWND> {
355 fn follow_owner(owner: HWND) {
356 unsafe {
357 let _ = SetWindowSubclass(owner, Some(owner_procedure), OWNER_SUBCLASS_ID, 0);
358 }
359 }
360
361 extern "system" fn owner_procedure(
362 window: HWND,
363 message: u32,
364 wparam: WPARAM,
365 lparam: LPARAM,
366 _subclass: usize,
367 _data: usize,
368 ) -> LRESULT {
369 if message == WM_WINDOWPOSCHANGED {
370 let moved: Vec<SharedEmbed> = OPEN_EMBEDS.with(|embeds| {
371 embeds
372 .borrow()
373 .iter()
374 .filter_map(Weak::upgrade)
375 .filter(|embed| {
376 embed
377 .try_borrow()
378 .is_ok_and(|state| state.spec.parent == window.0 as isize)
379 })
380 .collect()
381 });
382 for embed in &moved {
383 layout(embed);
384 }
385 }
386 unsafe { DefSubclassProc(window, message, wparam, lparam) }
387 }
388
389 fn create_container(owner: HWND) -> windows::core::Result<HWND> {
337 390 let instance = HINSTANCE(unsafe { GetModuleHandleW(None) }?.0);
338 391 REGISTER_CONTAINER_CLASS.call_once(|| {
339 392 let class = WNDCLASSW {
@@ -346,15 +399,15 @@ fn create_container(parent: HWND) -> windows::core::Result<HWND> {
346 399 });
347 400 unsafe {
348 401 CreateWindowExW(
349 WINDOW_EX_STYLE::default(),
402 WS_EX_TOOLWINDOW | WS_EX_NOACTIVATE,
350 403 CONTAINER_CLASS,
351 404 w!(""),
352 WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS,
405 WS_POPUP | WS_CLIPCHILDREN,
353 406 0,
354 407 0,
355 408 0,
356 409 0,
357 Some(parent),
410 Some(owner),
358 411 None,
359 412 Some(instance),
360 413 None,
@@ -1,6 +1,6 @@
1use std::cell::RefCell;
1use std::cell::RefCell;
2use std::path::PathBuf;
2use std::path::PathBuf;
3use std::rc::Rc;
3use std::rc::{Rc, Weak};
4use std::sync::Once;
4use std::sync::Once;
5
5
6use tokio::sync::mpsc::{UnboundedReceiver, UnboundedSender, unbounded_channel};
6use tokio::sync::mpsc::{UnboundedReceiver, UnboundedSender, unbounded_channel};
@@ -10,12 +10,13 @@ use webview2_com::{
10 NavigationCompletedEventHandler, NewWindowRequestedEventHandler, SourceChangedEventHandler,
10 NavigationCompletedEventHandler, NewWindowRequestedEventHandler, SourceChangedEventHandler,
11 take_pwstr,
11 take_pwstr,
12};
12};
13use windows::Win32::Foundation::{HINSTANCE, HWND, LPARAM, LRESULT, RECT, WPARAM};
13use windows::Win32::Foundation::{HINSTANCE, HWND, LPARAM, LRESULT, POINT, RECT, WPARAM};
14use windows::Win32::Graphics::Gdi::{
14use windows::Win32::Graphics::Gdi::{
15 CombineRgn, CreateRectRgn, DeleteObject, HGDIOBJ, RGN_DIFF, SetWindowRgn,
15 ClientToScreen, CombineRgn, CreateRectRgn, DeleteObject, HGDIOBJ, RGN_DIFF, SetWindowRgn,
16};
16};
17use windows::Win32::System::Com::{COINIT_APARTMENTTHREADED, CoInitializeEx};
17use windows::Win32::System::Com::{COINIT_APARTMENTTHREADED, CoInitializeEx};
18use windows::Win32::System::LibraryLoader::GetModuleHandleW;
18use windows::Win32::System::LibraryLoader::GetModuleHandleW;
19use windows::Win32::UI::Shell::{DefSubclassProc, SetWindowSubclass};
19use windows::Win32::UI::WindowsAndMessaging::*;
20use windows::Win32::UI::WindowsAndMessaging::*;
20use windows::core::{HRESULT, HSTRING, Interface, PCWSTR, PWSTR, w};
21use windows::core::{HRESULT, HSTRING, Interface, PCWSTR, PWSTR, w};
21
22
@@ -24,8 +25,13 @@ use crate::geometry::{EmbedBounds, local_cutouts};
24use crate::host::environment_options;
25use crate::host::environment_options;
25
26
26const CONTAINER_CLASS: PCWSTR = w!("RustyTeamsEmbedContainer");
27const CONTAINER_CLASS: PCWSTR = w!("RustyTeamsEmbedContainer");
28const OWNER_SUBCLASS_ID: usize = 0x5254_4542;
27static REGISTER_CONTAINER_CLASS: Once = Once::new();
29static REGISTER_CONTAINER_CLASS: Once = Once::new();
28
30
31thread_local! {
32 static OPEN_EMBEDS: RefCell<Vec<Weak<RefCell<EmbedState>>>> = const { RefCell::new(Vec::new()) };
33}
34
29enum Environment {
35enum Environment {
30 Idle,
36 Idle,
31 Creating(Vec<SharedEmbed>),
37 Creating(Vec<SharedEmbed>),
@@ -80,7 +86,9 @@ impl EmbedHost {
80 }
86 }
81
87
82 pub fn open(&self, spec: EmbedSpec) -> Option<(MainEmbed, UnboundedReceiver<EmbedEvent>)> {
88 pub fn open(&self, spec: EmbedSpec) -> Option<(MainEmbed, UnboundedReceiver<EmbedEvent>)> {
83 let container = create_container(HWND(spec.parent as *mut _)).ok()?;
89 let owner = HWND(spec.parent as *mut _);
90 let container = create_container(owner).ok()?;
91 follow_owner(owner);
84 let (events, receiver) = unbounded_channel();
92 let (events, receiver) = unbounded_channel();
85 let state = Rc::new(RefCell::new(EmbedState {
93 let state = Rc::new(RefCell::new(EmbedState {
86 spec,
94 spec,
@@ -92,6 +100,11 @@ impl EmbedHost {
92 closed: false,
100 closed: false,
93 events,
101 events,
94 }));
102 }));
103 OPEN_EMBEDS.with(|embeds| {
104 let mut embeds = embeds.borrow_mut();
105 embeds.retain(|embed| embed.strong_count() > 0);
106 embeds.push(Rc::downgrade(&state));
107 });
95 self.request_controller(&state);
108 self.request_controller(&state);
96 Some((MainEmbed { state }, receiver))
109 Some((MainEmbed { state }, receiver))
97 }
110 }
@@ -270,12 +283,13 @@ fn teardown(embed: &SharedEmbed) -> bool {
270}
283}
271
284
272fn layout(embed: &SharedEmbed) {
285fn layout(embed: &SharedEmbed) {
273 let (container, bounds, visible, cutouts, controller) = {
286 let (owner, container, bounds, visible, cutouts, controller) = {
274 let state = embed.borrow();
287 let state = embed.borrow();
275 if state.closed {
288 if state.closed {
276 return;
289 return;
277 }
290 }
278 (
291 (
292 HWND(state.spec.parent as *mut _),
279 state.container,
293 state.container,
280 state.bounds,
294 state.bounds,
281 state.visible,
295 state.visible,
@@ -287,12 +301,17 @@ fn layout(embed: &SharedEmbed) {
287 return;
301 return;
288 };
302 };
289 let shown = visible && bounds.has_area();
303 let shown = visible && bounds.has_area();
304 let mut origin = POINT {
305 x: bounds.x,
306 y: bounds.y,
307 };
290 unsafe {
308 unsafe {
309 let _ = ClientToScreen(owner, &mut origin);
291 let _ = SetWindowPos(
310 let _ = SetWindowPos(
292 container,
311 container,
293 None,
312 None,
294 bounds.x,
313 origin.x,
295 bounds.y,
314 origin.y,
296 bounds.width,
315 bounds.width,
297 bounds.height,
316 bounds.height,
298 SWP_NOZORDER | SWP_NOACTIVATE,
317 SWP_NOZORDER | SWP_NOACTIVATE,
@@ -333,7 +352,41 @@ unsafe fn apply_region(container: HWND, content: EmbedBounds, cutouts: &[EmbedBo
333 }
352 }
334}
353}
335
354
336fn create_container(parent: HWND) -> windows::core::Result<HWND> {
355fn follow_owner(owner: HWND) {
356 unsafe {
357 let _ = SetWindowSubclass(owner, Some(owner_procedure), OWNER_SUBCLASS_ID, 0);
358 }
359}
360
361extern "system" fn owner_procedure(
362 window: HWND,
363 message: u32,
364 wparam: WPARAM,
365 lparam: LPARAM,
366 _subclass: usize,
367 _data: usize,
368) -> LRESULT {
369 if message == WM_WINDOWPOSCHANGED {
370 let moved: Vec<SharedEmbed> = OPEN_EMBEDS.with(|embeds| {
371 embeds
372 .borrow()
373 .iter()
374 .filter_map(Weak::upgrade)
375 .filter(|embed| {
376 embed
377 .try_borrow()
378 .is_ok_and(|state| state.spec.parent == window.0 as isize)
379 })
380 .collect()
381 });
382 for embed in &moved {
383 layout(embed);
384 }
385 }
386 unsafe { DefSubclassProc(window, message, wparam, lparam) }
387}
388
389fn create_container(owner: HWND) -> windows::core::Result<HWND> {
337 let instance = HINSTANCE(unsafe { GetModuleHandleW(None) }?.0);
390 let instance = HINSTANCE(unsafe { GetModuleHandleW(None) }?.0);
338 REGISTER_CONTAINER_CLASS.call_once(|| {
391 REGISTER_CONTAINER_CLASS.call_once(|| {
339 let class = WNDCLASSW {
392 let class = WNDCLASSW {
@@ -346,15 +399,15 @@ fn create_container(parent: HWND) -> windows::core::Result<HWND> {
346 });
399 });
347 unsafe {
400 unsafe {
348 CreateWindowExW(
401 CreateWindowExW(
349 WINDOW_EX_STYLE::default(),
402 WS_EX_TOOLWINDOW | WS_EX_NOACTIVATE,
350 CONTAINER_CLASS,
403 CONTAINER_CLASS,
351 w!(""),
404 w!(""),
352 WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS,
405 WS_POPUP | WS_CLIPCHILDREN,
353 0,
406 0,
354 0,
407 0,
355 0,
408 0,
356 0,
409 0,
357 Some(parent),
410 Some(owner),
358 None,
411 None,
359 Some(instance),
412 Some(instance),
360 None,
413 None,