Skip to content

Commit

Permalink
fix: prevent timer window change size on drag the window
Browse files Browse the repository at this point in the history
  • Loading branch information
syns2191 committed Oct 19, 2024
1 parent 7072c60 commit e5517ff
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions packages/desktop-window/src/lib/desktop-window-timer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@ Object.assign(console, log.functions);
const Store = require('electron-store');
const store = new Store();

function getScreenSize() {
const sizes = screen.getPrimaryDisplay().workAreaSize;
const width = sizes.height < 768 ? 310 : 360;
const height = sizes.height < 768 ? sizes.height - 20 : 768;
return { width, height }
}

export async function createTimeTrackerWindow(timeTrackerWindow, filePath, preloadPath?) {
const mainWindowSettings: Electron.BrowserWindowConstructorOptions = windowSetting(preloadPath);
const manager = WindowManager.getInstance();
Expand All @@ -29,24 +36,26 @@ export async function createTimeTrackerWindow(timeTrackerWindow, filePath, prelo

timeTrackerWindow.hide();
await timeTrackerWindow.loadURL(launchPath);
if (preloadPath) {
attachTitlebarToWindow(timeTrackerWindow);
}
const { width, height } = getScreenSize();
timeTrackerWindow.setMinimumSize(width, height);
timeTrackerWindow.setMenu(null);
timeTrackerWindow.on('close', (event) => {
event.preventDefault();
timeTrackerWindow.hide();
});

manager.register(RegisteredWindow.TIMER, timeTrackerWindow);
if (preloadPath) {
attachTitlebarToWindow(timeTrackerWindow);
}

return timeTrackerWindow;
}

const windowSetting = (preloadPath?) => {
const sizes = screen.getPrimaryDisplay().workAreaSize;
const height = sizes.height < 768 ? sizes.height - 20 : 768;
const { width, height } = getScreenSize();
const zoomF = sizes.height < 768 ? 0.8 : 1.0;
const width = sizes.height < 768 ? 310 : 360;
const filesPath = store.get('filePath');
console.log('file path == ', filesPath);
const mainWindowSettings: Electron.BrowserWindowConstructorOptions = {
Expand Down

0 comments on commit e5517ff

Please sign in to comment.