diff --git a/src/main/setup-titlebar.ts b/src/main/setup-titlebar.ts index c403978..5510f16 100644 --- a/src/main/setup-titlebar.ts +++ b/src/main/setup-titlebar.ts @@ -45,6 +45,16 @@ export default () => { if (item) item.click(undefined, BrowserWindow.fromWebContents(event.sender), event.sender) }) + // Handle the minimum size. + ipcMain.on('window-set-minimumSize', (event, width, height) => { + const window = BrowserWindow.fromWebContents(event.sender); + + /* eslint-disable indent */ + if (window) { + window?.setMinimumSize(width, height); + } + }); + // Handle menu item icon ipcMain.on('menu-icon', (event, commandId: Number) => { const item = getMenuItemByCommandId(commandId, Menu.getApplicationMenu()) @@ -77,4 +87,4 @@ function getMenuItemByCommandId(commandId: Number, menu: Electron.Menu | null): } return undefined -} \ No newline at end of file +} diff --git a/src/titlebar/index.ts b/src/titlebar/index.ts index 6da3e70..83c7b3a 100644 --- a/src/titlebar/index.ts +++ b/src/titlebar/index.ts @@ -56,7 +56,9 @@ export class CustomTitlebar extends ThemeBar { minimize: 'Minimize', restoreDown: 'Restore Down' }, - unfocusEffect: true + unfocusEffect: true, + minWidth: 400, + minHeight: 270, } private platformIcons: { [key: string]: string } @@ -196,6 +198,8 @@ export class CustomTitlebar extends ThemeBar { if (removeMenuBar) return append(this.titlebar, this.menuBarContainer) + + ipcRenderer.send('window-set-minimumSize', this.currentOptions.minWidth, this.currentOptions.minHeight); } private setupTitle() { diff --git a/src/titlebar/options.ts b/src/titlebar/options.ts index c5c6697..4a096b3 100644 --- a/src/titlebar/options.ts +++ b/src/titlebar/options.ts @@ -93,4 +93,15 @@ export interface TitleBarOptions extends MenuBarOptions { * *The default is true* */ unfocusEffect?: boolean; -} \ No newline at end of file + /** + * Controls the Minimum Width the user is allowed to resize the window to. + * **The default is 400* + */ + minWidth: 400; + + /** + * Controls the Minimum Height the user is allowed to resize the window to. + * **The default is 270* + */ + minHeight: 270; +}