@@ -71,6 +71,8 @@ const installExtensions = async () => {
7171 . catch ( console . log ) ;
7272} ;
7373
74+ let stopPrinting = false ;
75+
7476const createWindow = async ( ) => {
7577 if (
7678 process . env . NODE_ENV === 'development' ||
@@ -89,8 +91,8 @@ const createWindow = async () => {
8991
9092 mainWindow = new BrowserWindow ( {
9193 show : false ,
92- width : 1024 ,
93- height : 728 ,
94+ width : 512 ,
95+ height : 364 ,
9496 icon : getAssetPath ( 'icon.png' ) ,
9597 webPreferences : {
9698 nodeIntegration : true ,
@@ -113,6 +115,12 @@ const createWindow = async () => {
113115 }
114116 } ) ;
115117
118+ mainWindow . webContents . on ( 'before-input-event' , ( event , ipnut ) => {
119+ if ( ipnut . key === 'Escape' ) {
120+ stopPrinting = true ;
121+ }
122+ } ) ;
123+
116124 mainWindow . on ( 'closed' , ( ) => {
117125 mainWindow = null ;
118126 } ) ;
@@ -177,21 +185,25 @@ ipcMain.handle(
177185 }
178186) ;
179187
180- const createScreenWindow = ( ) => {
188+ const createScreenWindow = ( select : string ) => {
181189 if ( screenWindow == null ) {
182190 screenWindow = new BrowserWindow ( {
183191 frame : false ,
184192 transparent : true ,
185193 webPreferences : {
186194 nodeIntegration : true ,
195+ contextIsolation : false ,
187196 } ,
197+ parent : mainWindow || undefined ,
188198 } ) ;
189199 }
190- screenWindow . loadURL ( `file://${ __dirname } /index.html?page=screen` ) ;
200+ screenWindow . loadURL (
201+ `file://${ __dirname } /index.html?page=screen&select=${ select } `
202+ ) ;
191203
192204 screenWindow . webContents . on ( 'did-finish-load' , ( ) => {
193- screenWindow ?. show ( ) ;
194205 screenWindow ?. maximize ( ) ;
206+ screenWindow ?. show ( ) ;
195207 } ) ;
196208
197209 screenWindow . webContents . on ( 'before-input-event' , ( event , ipnut ) => {
@@ -207,14 +219,23 @@ const createScreenWindow = () => {
207219 screenWindow . webContents . openDevTools ( { mode : 'undocked' } ) ;
208220} ;
209221
210- ipcMain . handle ( 'open-screen' , async ( ) => {
211- createScreenWindow ( ) ;
222+ ipcMain . handle ( 'open-screen' , async ( _ , { select } ) => {
223+ createScreenWindow ( select ) ;
212224} ) ;
213225
214226ipcMain . handle ( 'get-store' , ( _event , { key } ) => {
215227 return store . get ( key ) ;
216228} ) ;
217229
230+ ipcMain . handle ( 'close-screen' , ( _ , coord ) => {
231+ mainWindow ?. webContents . send ( 'close-screen' , coord ) ;
232+ screenWindow ?. close ( ) ;
233+ } ) ;
234+
235+ ipcMain . handle ( 'start-printing' , ( _ , { frameCoord, nextCoord, pages } ) => {
236+ console . log ( 'Print with params' , frameCoord , nextCoord , pages ) ;
237+ } ) ;
238+
218239/**
219240 * Add event listeners...
220241 */
0 commit comments