Skip to content

Commit

Permalink
Merge pull request #254 from HazelNutHoney/main
Browse files Browse the repository at this point in the history
(Fixed) Minimum Window Size Bug
  • Loading branch information
AlexTorresDev committed May 11, 2024
2 parents 9995f12 + 26b7866 commit bb4eb1b
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 3 deletions.
12 changes: 11 additions & 1 deletion src/main/setup-titlebar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down Expand Up @@ -77,4 +87,4 @@ function getMenuItemByCommandId(commandId: Number, menu: Electron.Menu | null):
}

return undefined
}
}
6 changes: 5 additions & 1 deletion src/titlebar/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ export class CustomTitlebar extends ThemeBar {
minimize: 'Minimize',
restoreDown: 'Restore Down'
},
unfocusEffect: true
unfocusEffect: true,
minWidth: 400,
minHeight: 270,
}

private platformIcons: { [key: string]: string }
Expand Down Expand Up @@ -192,6 +194,8 @@ export class CustomTitlebar extends ThemeBar {
}

append(this.titlebar, this.menuBarContainer)

ipcRenderer.send('window-set-minimumSize', this.currentOptions.minWidth, this.currentOptions.minHeight);
}

private setupTitle() {
Expand Down
13 changes: 12 additions & 1 deletion src/titlebar/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,15 @@ export interface TitleBarOptions extends MenuBarOptions {
* *The default is true*
*/
unfocusEffect?: boolean;
}
/**
* 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;
}

0 comments on commit bb4eb1b

Please sign in to comment.