11use rfd:: AsyncFileDialog ;
22use std:: fs;
33use std:: path:: PathBuf ;
4- use std:: sync:: Arc ;
54use std:: sync:: mpsc:: Receiver ;
65use std:: sync:: mpsc:: Sender ;
76use std:: sync:: mpsc:: SyncSender ;
@@ -12,22 +11,20 @@ use winit::application::ApplicationHandler;
1211use winit:: event:: WindowEvent ;
1312use winit:: event_loop:: ActiveEventLoop ;
1413use winit:: event_loop:: ControlFlow ;
15- use winit:: window:: Window ;
1614use winit:: window:: WindowId ;
1715
1816use crate :: cef;
1917use crate :: consts:: CEF_MESSAGE_LOOP_MAX_ITERATIONS ;
2018use crate :: event:: { AppEvent , AppEventScheduler } ;
21- use crate :: native_window;
2219use crate :: persist:: PersistentData ;
2320use crate :: render:: GraphicsState ;
21+ use crate :: window:: Window ;
2422use graphite_desktop_wrapper:: messages:: { DesktopFrontendMessage , DesktopWrapperMessage , Platform } ;
2523use graphite_desktop_wrapper:: { DesktopWrapper , NodeGraphExecutionResult , WgpuContext , serialize_frontend_messages} ;
2624
2725pub ( crate ) struct App {
2826 cef_context : Box < dyn cef:: CefContext > ,
29- window : Option < Arc < dyn Window > > ,
30- native_window : native_window:: NativeWindowHandle ,
27+ window : Option < Window > ,
3128 cef_schedule : Option < Instant > ,
3229 cef_window_size_sender : Sender < cef:: WindowSize > ,
3330 graphics_state : Option < GraphicsState > ,
@@ -82,7 +79,6 @@ impl App {
8279 web_communication_initialized : false ,
8380 web_communication_startup_buffer : Vec :: new ( ) ,
8481 persistent_data,
85- native_window : Default :: default ( ) ,
8682 launch_documents,
8783 }
8884 }
@@ -173,18 +169,17 @@ impl App {
173169 }
174170 DesktopFrontendMessage :: MinimizeWindow => {
175171 if let Some ( window) = & self . window {
176- window. set_minimized ( true ) ;
172+ window. minimize ( ) ;
177173 }
178174 }
179175 DesktopFrontendMessage :: MaximizeWindow => {
180176 if let Some ( window) = & self . window {
181- let maximized = !window. is_maximized ( ) ;
182- window. set_maximized ( maximized) ;
177+ window. toggle_maximize ( ) ;
183178 }
184179 }
185180 DesktopFrontendMessage :: DragWindow => {
186181 if let Some ( window) = & self . window {
187- let _ = window. drag_window ( ) ;
182+ let _ = window. start_drag ( ) ;
188183 }
189184 }
190185 DesktopFrontendMessage :: CloseWindow => {
@@ -348,15 +343,11 @@ impl App {
348343}
349344impl ApplicationHandler for App {
350345 fn can_create_surfaces ( & mut self , event_loop : & dyn ActiveEventLoop ) {
351- let window_attributes = self . native_window . build ( event_loop) ;
352-
353- let window: Arc < dyn Window > = Arc :: from ( event_loop. create_window ( window_attributes) . unwrap ( ) ) ;
354-
355- self . native_window . setup ( window. as_ref ( ) ) ;
346+ let window = Window :: new ( event_loop) ;
347+ self . window = Some ( window) ;
356348
357- let graphics_state = GraphicsState :: new ( window. clone ( ) , self . wgpu_context . clone ( ) ) ;
349+ let graphics_state = GraphicsState :: new ( self . window . as_ref ( ) . unwrap ( ) , self . wgpu_context . clone ( ) ) ;
358350
359- self . window = Some ( window) ;
360351 self . graphics_state = Some ( graphics_state) ;
361352
362353 tracing:: info!( "Winit window created and ready" ) ;
@@ -397,7 +388,7 @@ impl ApplicationHandler for App {
397388 let Some ( ref mut graphics_state) = self . graphics_state else { return } ;
398389 // Only rerender once we have a new UI texture to display
399390 if let Some ( window) = & self . window {
400- match graphics_state. render ( window. as_ref ( ) ) {
391+ match graphics_state. render ( window) {
401392 Ok ( _) => { }
402393 Err ( wgpu:: SurfaceError :: Lost ) => {
403394 tracing:: warn!( "lost surface" ) ;
0 commit comments