Skip to content

Commit

Permalink
Merge pull request #80 from neilenns/neilenns/issue79
Browse files Browse the repository at this point in the history
Fix restoring from mini mode on Windows
  • Loading branch information
pierr3 authored May 31, 2024
2 parents 00ffcf4 + 47250d1 commit b4e9700
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
6 changes: 6 additions & 0 deletions src/app/style/app.scss
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,8 @@ button:disabled {
padding-right: 0;
}

// When changing the max-width property make sure to update the miniModeWidthBreakpoint constant in
// the toggleMiniMode method in index.ts as well.
@media only screen and (max-width: 300px) {
.freq-box {
display: none;
Expand Down Expand Up @@ -383,12 +385,16 @@ select:disabled {
font-size: $mini-font-size;
}

// When changing the max-width property make sure to update the miniModeWidthBreakpoint constant in
// the toggleMiniMode method in index.ts as well.
@media only screen and (max-width: 300px) {
.mini {
display: block;
}
}

// When changing the max-width property make sure to update the miniModeWidthBreakpoint constant in
// the toggleMiniMode method in index.ts as well.
@media only screen and (max-width: 300px) {
.hide-topbar {
display: none !important;
Expand Down
18 changes: 13 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,24 @@ const setAudioSettings = () => {
};

const toggleMiniMode = () => {
if (
mainWindow.getSize()[0] == mainWindow.getMinimumSize()[0] &&
mainWindow.getSize()[1] == mainWindow.getMinimumSize()[1]
) {
const miniModeWidthBreakpoint = 300;

// Issue 79: Use the size of the content and the width breakpoint for mini-mode
// to determine whether to restore from mini-mode. This solves an issue where
// getSize() was returning a width value off by one from the getMinSize()
// call.
if (mainWindow.getContentSize()[0] <= miniModeWidthBreakpoint) {
mainWindow.setSize(savedLastWindowSize.width, savedLastWindowSize.height);
return;
}
savedLastWindowSize.width = mainWindow.getSize()[0];
savedLastWindowSize.height = mainWindow.getSize()[1];
mainWindow.setSize(1, 1);

// Issue 79: Use the width breakpoint for the width instead of setting to 1
// so the window doesn't go as small as possible when put in mini-mode. This
// makes toggling work properly when using 300 as the value for determining when
// to switch to big mode.
mainWindow.setSize(miniModeWidthBreakpoint, 1);
};

const restoreWindowBounds = (win: BrowserWindow) => {
Expand Down

0 comments on commit b4e9700

Please sign in to comment.