mirror of
https://github.com/noctalia-dev/noctalia-shell.git
synced 2026-05-11 17:08:27 +08:00
NiriService: wait for display scale before checking for maximized window (#952)
This commit is contained in:
@@ -302,9 +302,15 @@ Item {
|
||||
if (maximizedIndex >= 0) {
|
||||
maximizedWindows.splice(maximizedIndex, 1);
|
||||
|
||||
if (maximizedWindows.length === 0 && barFloatingStateSaved) {
|
||||
Settings.data.bar.floating = originalBarFloatingState;
|
||||
barFloatingStateSaved = false;
|
||||
if (maximizedWindows.length === 0) {
|
||||
if (barFloatingStateSaved) {
|
||||
Settings.data.bar.floating = originalBarFloatingState;
|
||||
barFloatingStateSaved = false;
|
||||
}
|
||||
if (barOuterCornersStateSaved) {
|
||||
Settings.data.bar.outerCorners = originalBarOuterCornersState;
|
||||
barOuterCornersStateSaved = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -368,59 +374,64 @@ Item {
|
||||
window.position = getWindowPosition(layout);
|
||||
|
||||
if (layout.window_size && window.output && CompositorService) {
|
||||
const outputInfo = CompositorService.getDisplayInfo(window.output);
|
||||
if (outputInfo && outputInfo.width && outputInfo.height) {
|
||||
const windowWidth = layout.window_size[0];
|
||||
const windowHeight = layout.window_size[1];
|
||||
const outputWidth = outputInfo.width;
|
||||
const outputHeight = outputInfo.height;
|
||||
// Only check for maximized windows if display scales are loaded
|
||||
// This prevents false positives during startup when display info might not be ready
|
||||
if (CompositorService.displayScalesLoaded) {
|
||||
const outputInfo = CompositorService.getDisplayInfo(window.output);
|
||||
// Ensure outputInfo is valid and has reasonable dimensions (not 0 or invalid)
|
||||
if (outputInfo && outputInfo.width && outputInfo.height && outputInfo.width > 100 && outputInfo.height > 100) {
|
||||
const windowWidth = layout.window_size[0];
|
||||
const windowHeight = layout.window_size[1];
|
||||
const outputWidth = outputInfo.width;
|
||||
const outputHeight = outputInfo.height;
|
||||
|
||||
const barPosition = Settings.data.bar.position || "top";
|
||||
const isVerticalBar = barPosition === "left" || barPosition === "right";
|
||||
const barSize = Style.barHeight;
|
||||
const barPosition = Settings.data.bar.position || "top";
|
||||
const isVerticalBar = barPosition === "left" || barPosition === "right";
|
||||
const barSize = Style.barHeight;
|
||||
|
||||
let widthMatch, heightMatch;
|
||||
if (isVerticalBar) {
|
||||
widthMatch = Math.abs(windowWidth - (outputWidth - barSize)) < 10;
|
||||
heightMatch = Math.abs(windowHeight - outputHeight) < 10;
|
||||
} else {
|
||||
widthMatch = Math.abs(windowWidth - outputWidth) < 10;
|
||||
heightMatch = Math.abs(windowHeight - (outputHeight - barSize)) < 50;
|
||||
}
|
||||
|
||||
const isMaximized = widthMatch && heightMatch;
|
||||
const wasMaximized = maximizedWindows.indexOf(windowId) >= 0;
|
||||
|
||||
if (isMaximized && !wasMaximized) {
|
||||
Logger.i("NiriService", "Detected maximize-window-to-edges");
|
||||
maximizedWindows.push(windowId);
|
||||
|
||||
if (!barFloatingStateSaved) {
|
||||
originalBarFloatingState = Settings.data.bar.floating;
|
||||
barFloatingStateSaved = true;
|
||||
let widthMatch, heightMatch;
|
||||
if (isVerticalBar) {
|
||||
widthMatch = Math.abs(windowWidth - (outputWidth - barSize)) < 10;
|
||||
heightMatch = Math.abs(windowHeight - outputHeight) < 10;
|
||||
} else {
|
||||
widthMatch = Math.abs(windowWidth - outputWidth) < 10;
|
||||
heightMatch = Math.abs(windowHeight - (outputHeight - barSize)) < 50;
|
||||
}
|
||||
|
||||
if (!barOuterCornersStateSaved) {
|
||||
originalBarOuterCornersState = Settings.data.bar.outerCorners;
|
||||
barOuterCornersStateSaved = true;
|
||||
}
|
||||
const isMaximized = widthMatch && heightMatch;
|
||||
const wasMaximized = maximizedWindows.indexOf(windowId) >= 0;
|
||||
|
||||
Settings.data.bar.floating = false;
|
||||
Settings.data.bar.outerCorners = false;
|
||||
} else if (!isMaximized && wasMaximized) {
|
||||
const index = maximizedWindows.indexOf(windowId);
|
||||
if (index >= 0) {
|
||||
maximizedWindows.splice(index, 1);
|
||||
}
|
||||
if (isMaximized && !wasMaximized) {
|
||||
Logger.i("NiriService", "Detected maximize-window-to-edges");
|
||||
maximizedWindows.push(windowId);
|
||||
|
||||
if (maximizedWindows.length === 0) {
|
||||
if (barFloatingStateSaved) {
|
||||
Settings.data.bar.floating = originalBarFloatingState;
|
||||
barFloatingStateSaved = false;
|
||||
if (!barFloatingStateSaved) {
|
||||
originalBarFloatingState = Settings.data.bar.floating;
|
||||
barFloatingStateSaved = true;
|
||||
}
|
||||
if (barOuterCornersStateSaved) {
|
||||
Settings.data.bar.outerCorners = originalBarOuterCornersState;
|
||||
barOuterCornersStateSaved = false;
|
||||
|
||||
if (!barOuterCornersStateSaved) {
|
||||
originalBarOuterCornersState = Settings.data.bar.outerCorners;
|
||||
barOuterCornersStateSaved = true;
|
||||
}
|
||||
|
||||
Settings.data.bar.floating = false;
|
||||
Settings.data.bar.outerCorners = false;
|
||||
} else if (!isMaximized && wasMaximized) {
|
||||
const index = maximizedWindows.indexOf(windowId);
|
||||
if (index >= 0) {
|
||||
maximizedWindows.splice(index, 1);
|
||||
}
|
||||
|
||||
if (maximizedWindows.length === 0) {
|
||||
if (barFloatingStateSaved) {
|
||||
Settings.data.bar.floating = originalBarFloatingState;
|
||||
barFloatingStateSaved = false;
|
||||
}
|
||||
if (barOuterCornersStateSaved) {
|
||||
Settings.data.bar.outerCorners = originalBarOuterCornersState;
|
||||
barOuterCornersStateSaved = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user