@@ -19,6 +19,7 @@ import { IPC_CHANNELS, ProgressStatus, ServerArgs } from '../constants';
1919import { getAppResourcesPath } from '../install/resourcePaths' ;
2020import { useDesktopConfig } from '../store/desktopConfig' ;
2121import type { ElectronContextMenuOptions } from '../preload' ;
22+ import type { DesktopSettings } from '../store/desktopSettings' ;
2223
2324/**
2425 * Creates a single application window that displays the renderer and encapsulates all the logic for sending messages to the renderer.
@@ -109,14 +110,41 @@ export class AppWindow {
109110 return window ;
110111 }
111112
112- async recreateWindow ( ) {
113+ /**
114+ * Recreates the application window by closing the current window and creating a new one.
115+ *
116+ * After the new window is created, it reloads the last ComfyUI URL.
117+ * @returns A promise that resolves after the recreated window has loaded the last ComfyUI URL
118+ */
119+ async recreateWindow ( ) : Promise < void > {
113120 const { window } = this ;
114121
115122 this . window = this . #createWindow( ) ;
116123 window . close ( ) ;
117124 await this . reloadLastComfyUIUrl ( ) ;
118125 }
119126
127+ /**
128+ * Changes the custom window style for win32 / linux. Recreates the window if the style is changed.
129+ * @param style The new window style to be applied
130+ * @returns A promise that resolves when the window style has been set and the window has been recreated.
131+ * Ignores attempts to unset the style or set it to the current value.
132+ */
133+ async setWindowStyle ( style : DesktopSettings [ 'windowStyle' ] ) : Promise < void > {
134+ log . info ( `Setting window style:` , style ) ;
135+ if ( ! style ) return ;
136+
137+ const store = useDesktopConfig ( ) ;
138+ const current = store . get ( 'windowStyle' ) ;
139+ if ( style === current ) {
140+ log . warn ( `Ignoring attempt to set window style to current value [${ current } ]` ) ;
141+ // return;
142+ }
143+
144+ store . set ( 'windowStyle' , style ) ;
145+ await this . recreateWindow ( ) ;
146+ }
147+
120148 public isReady ( ) : boolean {
121149 return this . rendererReady ;
122150 }
0 commit comments