Skip to content
This repository was archived by the owner on Sep 13, 2024. It is now read-only.

Commit bb4eb1b

Browse files
Merge pull request #254 from HazelNutHoney/main
(Fixed) Minimum Window Size Bug
2 parents 9995f12 + 26b7866 commit bb4eb1b

File tree

3 files changed

+28
-3
lines changed

3 files changed

+28
-3
lines changed

src/main/setup-titlebar.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,16 @@ export default () => {
4545
if (item) item.click(undefined, BrowserWindow.fromWebContents(event.sender), event.sender)
4646
})
4747

48+
// Handle the minimum size.
49+
ipcMain.on('window-set-minimumSize', (event, width, height) => {
50+
const window = BrowserWindow.fromWebContents(event.sender);
51+
52+
/* eslint-disable indent */
53+
if (window) {
54+
window?.setMinimumSize(width, height);
55+
}
56+
});
57+
4858
// Handle menu item icon
4959
ipcMain.on('menu-icon', (event, commandId: Number) => {
5060
const item = getMenuItemByCommandId(commandId, Menu.getApplicationMenu())
@@ -77,4 +87,4 @@ function getMenuItemByCommandId(commandId: Number, menu: Electron.Menu | null):
7787
}
7888

7989
return undefined
80-
}
90+
}

src/titlebar/index.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,9 @@ export class CustomTitlebar extends ThemeBar {
5555
minimize: 'Minimize',
5656
restoreDown: 'Restore Down'
5757
},
58-
unfocusEffect: true
58+
unfocusEffect: true,
59+
minWidth: 400,
60+
minHeight: 270,
5961
}
6062

6163
private platformIcons: { [key: string]: string }
@@ -192,6 +194,8 @@ export class CustomTitlebar extends ThemeBar {
192194
}
193195

194196
append(this.titlebar, this.menuBarContainer)
197+
198+
ipcRenderer.send('window-set-minimumSize', this.currentOptions.minWidth, this.currentOptions.minHeight);
195199
}
196200

197201
private setupTitle() {

src/titlebar/options.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,4 +93,15 @@ export interface TitleBarOptions extends MenuBarOptions {
9393
* *The default is true*
9494
*/
9595
unfocusEffect?: boolean;
96-
}
96+
/**
97+
* Controls the Minimum Width the user is allowed to resize the window to.
98+
* **The default is 400*
99+
*/
100+
minWidth: 400;
101+
102+
/**
103+
* Controls the Minimum Height the user is allowed to resize the window to.
104+
* **The default is 270*
105+
*/
106+
minHeight: 270;
107+
}

0 commit comments

Comments
 (0)