Skip to content

Commit

Permalink
fix floating might be out of screen
Browse files Browse the repository at this point in the history
  • Loading branch information
RoderickQiu committed Jan 19, 2024
1 parent db4d6d2 commit 5b2e914
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion main.js
Original file line number Diff line number Diff line change
Expand Up @@ -705,7 +705,7 @@ app.on('ready', () => {
store.set("suggest-star", "suggested");
}, 1000);
}

if (process.platform === "win32") {
if (winReleaseId() === -1 && win != null) {
let isNotified = store.has("windows-7-notification");
Expand Down Expand Up @@ -2226,6 +2226,21 @@ function externalTitle(title, notes) {
}

function floating() {
if (styleCache.has("floating-axis")) {
// fix that floating window may be out of screen after changing screen resolution
let isOnScreen = false;
const displays = screen.getAllDisplays();
for (let i = 0; i < displays.length; i++) {
if (displays[i].bounds.x <= styleCache.get("floating-axis").x
&& displays[i].bounds.x + displays[i].bounds.width >= styleCache.get("floating-axis").x
&& displays[i].bounds.y <= styleCache.get("floating-axis").y
&& displays[i].bounds.y + displays[i].bounds.height >= styleCache.get("floating-axis").y) {
isOnScreen = true;
break;
}
}
if (!isOnScreen) styleCache.delete("floating-axis");
}
if (app.isReady()) {
if (win != null) {
if (!hasFloating || floatingWin == null) {
Expand Down

0 comments on commit 5b2e914

Please sign in to comment.