Refactor Windows work area handling for improved frame overhang management
All checks were successful
farmcontrol/farmcontrol-ui/pipeline/head This commit looks good
All checks were successful
farmcontrol/farmcontrol-ui/pipeline/head This commit looks good
- Introduced separate constants for native and CEF window frame overhangs to accommodate different rendering contexts. - Updated `getMaximizedWorkAreaFrame` to accept a window parameter, allowing dynamic selection of the appropriate overhang based on the window type. - Enhanced `isWindowWorkAreaMaximized` and `clampWindowToWorkArea` functions to utilize the updated frame overhang logic, improving accuracy in window positioning.
This commit is contained in:
parent
f52f0e35a9
commit
517921f3e3
@ -4,12 +4,24 @@ const FRAME_TOLERANCE_PX = 4
|
||||
// Win32 DWM invisible borders sit outside the client work area; Electrobun's
|
||||
// maximized frame includes those overhangs, so we treat this adjusted rect as
|
||||
// the canonical "maximized to work area" geometry.
|
||||
const WIN32_FRAME_OVERHANG = {
|
||||
const WIN32_FRAME_OVERHANG_NATIVE = {
|
||||
x: -8,
|
||||
y: 0,
|
||||
width: 16,
|
||||
height: 8
|
||||
}
|
||||
const WIN32_FRAME_OVERHANG_CEF = {
|
||||
x: -10,
|
||||
y: 0,
|
||||
width: 20,
|
||||
height: 10
|
||||
}
|
||||
|
||||
function getWin32FrameOverhang(window) {
|
||||
return window?.renderer === 'cef'
|
||||
? WIN32_FRAME_OVERHANG_CEF
|
||||
: WIN32_FRAME_OVERHANG_NATIVE
|
||||
}
|
||||
|
||||
function framesMatch(a, b, tolerance = FRAME_TOLERANCE_PX) {
|
||||
return (
|
||||
@ -20,12 +32,13 @@ function framesMatch(a, b, tolerance = FRAME_TOLERANCE_PX) {
|
||||
)
|
||||
}
|
||||
|
||||
function getMaximizedWorkAreaFrame(workArea) {
|
||||
function getMaximizedWorkAreaFrame(workArea, window) {
|
||||
const overhang = getWin32FrameOverhang(window)
|
||||
return {
|
||||
x: workArea.x + WIN32_FRAME_OVERHANG.x,
|
||||
y: workArea.y + WIN32_FRAME_OVERHANG.y,
|
||||
width: workArea.width + WIN32_FRAME_OVERHANG.width,
|
||||
height: workArea.height + WIN32_FRAME_OVERHANG.height
|
||||
x: workArea.x + overhang.x,
|
||||
y: workArea.y + overhang.y,
|
||||
width: workArea.width + overhang.width,
|
||||
height: workArea.height + overhang.height
|
||||
}
|
||||
}
|
||||
|
||||
@ -70,7 +83,7 @@ export function isWindowWorkAreaMaximized(window) {
|
||||
const { workArea } = getDisplayForFrame(frame)
|
||||
return (
|
||||
framesMatch(frame, workArea) ||
|
||||
framesMatch(frame, getMaximizedWorkAreaFrame(workArea))
|
||||
framesMatch(frame, getMaximizedWorkAreaFrame(workArea, window))
|
||||
)
|
||||
}
|
||||
|
||||
@ -90,7 +103,7 @@ export function clampWindowToWorkArea(window) {
|
||||
|
||||
const display = getDisplayForFrame(frame)
|
||||
const { bounds, workArea } = display
|
||||
const maximizedFrame = getMaximizedWorkAreaFrame(workArea)
|
||||
const maximizedFrame = getMaximizedWorkAreaFrame(workArea, window)
|
||||
|
||||
if (framesMatch(frame, workArea) || framesMatch(frame, maximizedFrame)) {
|
||||
return false
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user