@@ -29,12 +29,38 @@ impl FromFltkWindow for Webview {
2929 {
3030 extern "system" {
3131 pub fn SetFocus ( child : * mut ( ) ) -> * mut ( ) ;
32+ pub fn CoInitializeEx ( pvReserved : * mut ( ) , dwCoInit : u32 ) -> i32 ;
33+ pub fn SendMessageW ( hwnd : * mut ( ) , msg : u32 , wparam : usize , lparam : isize ) -> isize ;
3234 }
35+ const COINIT_APARTMENTTHREADED : u32 = 0x2 ;
36+ const WM_SIZE : u32 = 0x0005 ;
37+ CoInitializeEx ( std:: ptr:: null_mut ( ) , COINIT_APARTMENTTHREADED ) ;
3338 inner = wv:: webview_create (
3439 debug as i32 ,
35- & mut win . raw_handle ( ) as * mut * mut raw :: c_void as * mut raw :: c_void ,
40+ std :: ptr :: null_mut ( ) ,
3641 ) ;
37- win. draw ( move |w| { wv:: webview_set_size ( inner, w. w ( ) , w. h ( ) , 0 ) ; } ) ;
42+ wv:: webview_set_size ( inner, win. w ( ) , win. h ( ) , 0 ) ;
43+ let wv_hwnd = wv:: webview_get_window ( inner) ;
44+ // Manually set the webview window as a child and position it
45+ extern "system" {
46+ pub fn SetParent ( child : * mut ( ) , parent : * mut ( ) ) -> * mut ( ) ;
47+ pub fn SetWindowPos ( hwnd : * mut ( ) , hwnd_insert_after : * mut ( ) , x : i32 , y : i32 , cx : i32 , cy : i32 , flags : u32 ) -> i32 ;
48+ pub fn GetWindowLongW ( hwnd : * mut ( ) , index : i32 ) -> i32 ;
49+ pub fn SetWindowLongW ( hwnd : * mut ( ) , index : i32 , new_long : i32 ) -> i32 ;
50+ }
51+ const GWL_STYLE : i32 = -16 ;
52+ const WS_CHILD : i32 = 0x40000000 ;
53+ const WS_VISIBLE : i32 = 0x10000000 ;
54+ const SWP_NOZORDER : u32 = 0x0004 ;
55+ const SWP_NOACTIVATE : u32 = 0x0010 ;
56+ const SWP_FRAMECHANGED : u32 = 0x0020 ;
57+ // Change window style to WS_CHILD to remove decorations
58+ SetWindowLongW ( wv_hwnd as _ , GWL_STYLE , WS_CHILD | WS_VISIBLE ) ;
59+ SetParent ( wv_hwnd as _ , win. raw_handle ( ) as _ ) ;
60+ SetWindowPos ( wv_hwnd as _ , std:: ptr:: null_mut ( ) , 0 , 0 , win. w ( ) , win. h ( ) , SWP_NOZORDER | SWP_NOACTIVATE | SWP_FRAMECHANGED ) ;
61+ win. resize_callback ( move |w, _, _, _, _| {
62+ SetWindowPos ( wv_hwnd as _ , std:: ptr:: null_mut ( ) , 0 , 0 , w. w ( ) , w. h ( ) , SWP_NOZORDER | SWP_NOACTIVATE ) ;
63+ } ) ;
3864 let mut topwin =
3965 window:: Window :: from_widget_ptr ( win. top_window ( ) . unwrap ( ) . as_widget_ptr ( ) ) ;
4066 // SetFocus(topwin.raw_handle() as _);
@@ -66,7 +92,7 @@ impl FromFltkWindow for Webview {
6692 let handle = win. raw_handle ( ) ;
6793 inner = wv:: webview_create ( debug as i32 , handle as _ ) ;
6894 make_delegate ( wv:: webview_get_window ( inner) as _ , handle as _ , 1 ) ;
69- win. draw ( move |w| { wv:: webview_set_size ( inner, w. w ( ) , w. h ( ) , 0 ) ; } ) ;
95+ win. resize_callback ( move |w, _ , _ , _ , _ | { wv:: webview_set_size ( inner, w. w ( ) , w. h ( ) , 0 ) ; } ) ;
7096 let mut topwin =
7197 window:: Window :: from_widget_ptr ( win. top_window ( ) . unwrap ( ) . as_widget_ptr ( ) ) ;
7298 let inner = inner. clone ( ) ;
@@ -107,7 +133,7 @@ impl FromFltkWindow for Webview {
107133 // Ensure input focus goes to the embedded child when shown
108134 x_focus ( app:: display ( ) as _ , xid) ;
109135
110- win. draw ( move |w| { wv:: webview_set_size ( inner, w. w ( ) , w. h ( ) , 0 ) ; } ) ;
136+ win. resize_callback ( move |w, _ , _ , _ , _ | { wv:: webview_set_size ( inner, w. w ( ) , w. h ( ) , 0 ) ; } ) ;
111137
112138 // Set focus to child on mouse press to ensure keystrokes reach WebKit
113139 let xid_for_focus = xid;
0 commit comments