@@ -38,7 +38,7 @@ use tao::platform::unix::{WindowBuilderExtUnix, WindowExtUnix};
3838#[ cfg( windows) ]
3939use tao:: platform:: windows:: { WindowBuilderExtWindows , WindowExtWindows } ;
4040#[ cfg( windows) ]
41- use webview2_com:: FocusChangedEventHandler ;
41+ use webview2_com:: { ContainsFullScreenElementChangedEventHandler , FocusChangedEventHandler } ;
4242#[ cfg( windows) ]
4343use windows:: Win32 :: Foundation :: HWND ;
4444#[ cfg( target_os = "ios" ) ]
@@ -4821,8 +4821,7 @@ You may have it installed on another user account, but it is not available for t
48214821 #[ cfg( windows) ]
48224822 {
48234823 let controller = webview. controller ( ) ;
4824- let proxy = context. proxy . clone ( ) ;
4825- let proxy_ = proxy. clone ( ) ;
4824+ let proxy_clone = context. proxy . clone ( ) ;
48264825 let window_id_ = window_id. clone ( ) ;
48274826 let mut token = 0 ;
48284827 unsafe {
@@ -4837,7 +4836,7 @@ You may have it installed on another user account, but it is not available for t
48374836 focused_webview. replace ( label_. clone ( ) ) ;
48384837
48394838 if !already_focused {
4840- let _ = proxy . send_event ( Message :: Webview (
4839+ let _ = proxy_clone . send_event ( Message :: Webview (
48414840 * window_id_. lock ( ) . unwrap ( ) ,
48424841 id,
48434842 WebviewMessage :: SynthesizedWindowEvent ( SynthesizedWindowEvent :: Focused ( true ) ) ,
@@ -4851,6 +4850,8 @@ You may have it installed on another user account, but it is not available for t
48514850 . unwrap ( ) ;
48524851 unsafe {
48534852 let label_ = label. clone ( ) ;
4853+ let window_id_ = window_id. clone ( ) ;
4854+ let proxy_clone = context. proxy . clone ( ) ;
48544855 controller. add_LostFocus (
48554856 & FocusChangedEventHandler :: create ( Box :: new ( move |_, _| {
48564857 let mut focused_webview = focused_webview. lock ( ) . unwrap ( ) ;
@@ -4866,8 +4867,8 @@ You may have it installed on another user account, but it is not available for t
48664867 if lost_window_focus {
48674868 // only reset when we lost window focus - otherwise some other webview is focused
48684869 * focused_webview = None ;
4869- let _ = proxy_ . send_event ( Message :: Webview (
4870- * window_id . lock ( ) . unwrap ( ) ,
4870+ let _ = proxy_clone . send_event ( Message :: Webview (
4871+ * window_id_ . lock ( ) . unwrap ( ) ,
48714872 id,
48724873 WebviewMessage :: SynthesizedWindowEvent ( SynthesizedWindowEvent :: Focused ( false ) ) ,
48734874 ) ) ;
@@ -4878,6 +4879,26 @@ You may have it installed on another user account, but it is not available for t
48784879 )
48794880 }
48804881 . unwrap ( ) ;
4882+
4883+ if let Ok ( webview) = unsafe { controller. CoreWebView2 ( ) } {
4884+ let proxy_clone = context. proxy . clone ( ) ;
4885+ unsafe {
4886+ let _ = webview. add_ContainsFullScreenElementChanged (
4887+ & ContainsFullScreenElementChangedEventHandler :: create ( Box :: new ( move |sender, _| {
4888+ let mut contains_fullscreen_element = windows:: core:: BOOL :: default ( ) ;
4889+ sender
4890+ . ok_or_else ( windows:: core:: Error :: empty) ?
4891+ . ContainsFullScreenElement ( & mut contains_fullscreen_element) ?;
4892+ let _ = proxy_clone. send_event ( Message :: Window (
4893+ * window_id. lock ( ) . unwrap ( ) ,
4894+ WindowMessage :: SetFullscreen ( contains_fullscreen_element. as_bool ( ) ) ,
4895+ ) ) ;
4896+ Ok ( ( ) )
4897+ } ) ) ,
4898+ & mut token,
4899+ ) ;
4900+ }
4901+ }
48814902 }
48824903
48834904 Ok ( WebviewWrapper {
0 commit comments