Skip to content

Commit 622fbc1

Browse files
committed
Not blur
1 parent 57992ac commit 622fbc1

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

src/components/printer/Screen.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,13 @@ const Screen = ({ select }: { select: string }) => {
8181
};
8282

8383
useEffect(() => {
84-
window.onblur = closeScreen;
8584
window.onresize = setCanvasSize;
8685
}, []);
8786

87+
ipcRenderer.on('screen-show', () => {
88+
setCanvasSize();
89+
});
90+
8891
return (
8992
<div
9093
style={{ cursor: draging ? 'crosshair' : 'default' }}

src/main.dev.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {
1717
dialog,
1818
globalShortcut,
1919
ipcMain,
20+
screen,
2021
shell,
2122
} from 'electron';
2223
import { autoUpdater } from 'electron-updater';
@@ -115,7 +116,7 @@ const createWindow = async () => {
115116
}
116117
});
117118

118-
mainWindow.webContents.on('before-input-event', (event, ipnut) => {
119+
mainWindow.webContents.on('before-input-event', (_event, ipnut) => {
119120
if (ipnut.key === 'Escape') {
120121
stopPrinting = true;
121122
}
@@ -190,23 +191,25 @@ const createScreenWindow = (select: string) => {
190191
screenWindow = new BrowserWindow({
191192
frame: false,
192193
transparent: true,
194+
parent: mainWindow || undefined,
195+
width: screen.getPrimaryDisplay().size.width,
196+
height: screen.getPrimaryDisplay().size.height,
193197
webPreferences: {
194198
nodeIntegration: true,
195199
contextIsolation: false,
196200
},
197-
parent: mainWindow || undefined,
198201
});
199202
}
200203
screenWindow.loadURL(
201204
`file://${__dirname}/index.html?page=screen&select=${select}`
202205
);
203206

204207
screenWindow.webContents.on('did-finish-load', () => {
205-
screenWindow?.maximize();
206208
screenWindow?.show();
209+
screenWindow?.webContents.send('screen-show');
207210
});
208211

209-
screenWindow.webContents.on('before-input-event', (event, ipnut) => {
212+
screenWindow.webContents.on('before-input-event', (_event, ipnut) => {
210213
if (ipnut.key === 'Escape') {
211214
screenWindow?.close();
212215
}
@@ -234,6 +237,10 @@ ipcMain.handle('close-screen', (_, coord) => {
234237

235238
ipcMain.handle('start-printing', (_, { frameCoord, nextCoord, pages }) => {
236239
console.log('Print with params', frameCoord, nextCoord, pages);
240+
241+
if (stopPrinting) {
242+
console.log('Stop now');
243+
}
237244
});
238245

239246
/**

0 commit comments

Comments
 (0)