@@ -30,21 +30,31 @@ impl FromFltkWindow for Webview {
3030 extern "system" {
3131 pub fn SetFocus ( child : * mut ( ) ) -> * mut ( ) ;
3232 pub fn CoInitializeEx ( pvReserved : * mut ( ) , dwCoInit : u32 ) -> i32 ;
33- pub fn SendMessageW ( hwnd : * mut ( ) , msg : u32 , wparam : usize , lparam : isize ) -> isize ;
33+ pub fn SendMessageW (
34+ hwnd : * mut ( ) ,
35+ msg : u32 ,
36+ wparam : usize ,
37+ lparam : isize ,
38+ ) -> isize ;
3439 }
3540 const COINIT_APARTMENTTHREADED : u32 = 0x2 ;
3641 const WM_SIZE : u32 = 0x0005 ;
3742 CoInitializeEx ( std:: ptr:: null_mut ( ) , COINIT_APARTMENTTHREADED ) ;
38- inner = wv:: webview_create (
39- debug as i32 ,
40- std:: ptr:: null_mut ( ) ,
41- ) ;
42- wv:: webview_set_size ( inner, win. w ( ) , win. h ( ) , 0 ) ;
43+ inner = wv:: webview_create ( debug as i32 , std:: ptr:: null_mut ( ) ) ;
44+ wv:: webview_set_size ( inner, win. w ( ) , win. h ( ) , 3 ) ;
4345 let wv_hwnd = wv:: webview_get_window ( inner) ;
4446 // Manually set the webview window as a child and position it
4547 extern "system" {
4648 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 ;
49+ pub fn SetWindowPos (
50+ hwnd : * mut ( ) ,
51+ hwnd_insert_after : * mut ( ) ,
52+ x : i32 ,
53+ y : i32 ,
54+ cx : i32 ,
55+ cy : i32 ,
56+ flags : u32 ,
57+ ) -> i32 ;
4858 pub fn GetWindowLongW ( hwnd : * mut ( ) , index : i32 ) -> i32 ;
4959 pub fn SetWindowLongW ( hwnd : * mut ( ) , index : i32 , new_long : i32 ) -> i32 ;
5060 }
@@ -57,9 +67,26 @@ impl FromFltkWindow for Webview {
5767 // Change window style to WS_CHILD to remove decorations
5868 SetWindowLongW ( wv_hwnd as _ , GWL_STYLE , WS_CHILD | WS_VISIBLE ) ;
5969 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 ) ;
70+ SetWindowPos (
71+ wv_hwnd as _ ,
72+ std:: ptr:: null_mut ( ) ,
73+ 0 ,
74+ 0 ,
75+ win. w ( ) ,
76+ win. h ( ) ,
77+ SWP_NOZORDER | SWP_NOACTIVATE | SWP_FRAMECHANGED ,
78+ ) ;
6179 win. resize_callback ( move |w, _, _, _, _| {
62- SetWindowPos ( wv_hwnd as _ , std:: ptr:: null_mut ( ) , 0 , 0 , w. w ( ) , w. h ( ) , SWP_NOZORDER | SWP_NOACTIVATE ) ;
80+ wv:: webview_set_size ( inner, w. w ( ) , w. h ( ) , 3 ) ;
81+ } ) ;
82+ win. resize ( win. x ( ) , win. y ( ) , win. w ( ) , win. h ( ) ) ;
83+ win. handle ( |w, ev| {
84+ if ev == enums:: Event :: Focus {
85+ SetFocus ( w. raw_handle ( ) as _ ) ;
86+ true
87+ } else {
88+ false
89+ }
6390 } ) ;
6491 let mut topwin =
6592 window:: Window :: from_widget_ptr ( win. top_window ( ) . unwrap ( ) . as_widget_ptr ( ) ) ;
@@ -92,7 +119,9 @@ impl FromFltkWindow for Webview {
92119 let handle = win. raw_handle ( ) ;
93120 inner = wv:: webview_create ( debug as i32 , handle as _ ) ;
94121 make_delegate ( wv:: webview_get_window ( inner) as _ , handle as _ , 1 ) ;
95- win. resize_callback ( move |w, _, _, _, _| { wv:: webview_set_size ( inner, w. w ( ) , w. h ( ) , 0 ) ; } ) ;
122+ win. resize_callback ( move |w, _, _, _, _| {
123+ wv:: webview_set_size ( inner, w. w ( ) , w. h ( ) , 0 ) ;
124+ } ) ;
96125 let mut topwin =
97126 window:: Window :: from_widget_ptr ( win. top_window ( ) . unwrap ( ) . as_widget_ptr ( ) ) ;
98127 let inner = inner. clone ( ) ;
@@ -133,7 +162,9 @@ impl FromFltkWindow for Webview {
133162 // Ensure input focus goes to the embedded child when shown
134163 x_focus ( app:: display ( ) as _ , xid) ;
135164
136- win. resize_callback ( move |w, _, _, _, _| { wv:: webview_set_size ( inner, w. w ( ) , w. h ( ) , 0 ) ; } ) ;
165+ win. resize_callback ( move |w, _, _, _, _| {
166+ wv:: webview_set_size ( inner, w. w ( ) , w. h ( ) , 0 ) ;
167+ } ) ;
137168
138169 // Set focus to child on mouse press to ensure keystrokes reach WebKit
139170 let xid_for_focus = xid;
0 commit comments