mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-08-04 19:21:33 -07:00
fix(overlay): Linux X11/XWayland stacking, stale pause state, multi-copy selector (#101)
This commit is contained in:
@@ -5,6 +5,7 @@ const logger = createLogger('main:overlay-content-measurement');
|
||||
const MAX_VIEWPORT = 10000;
|
||||
const MAX_RECT_DIMENSION = 10000;
|
||||
const MAX_RECT_OFFSET = 50000;
|
||||
const MAX_INTERACTIVE_RECTS = 8;
|
||||
const MAX_FUTURE_TIMESTAMP_MS = 60_000;
|
||||
const INVALID_LOG_THROTTLE_MS = 10_000;
|
||||
|
||||
@@ -26,6 +27,7 @@ export function sanitizeOverlayContentMeasurement(
|
||||
width?: unknown;
|
||||
height?: unknown;
|
||||
} | null;
|
||||
interactiveRects?: unknown;
|
||||
};
|
||||
|
||||
if (candidate.layer !== 'visible') {
|
||||
@@ -53,11 +55,21 @@ export function sanitizeOverlayContentMeasurement(
|
||||
return null;
|
||||
}
|
||||
|
||||
let interactiveRects: OverlayContentRect[] | undefined;
|
||||
if (candidate.interactiveRects !== undefined) {
|
||||
const sanitizedRects = sanitizeOverlayInteractiveRects(candidate.interactiveRects);
|
||||
if (!sanitizedRects) {
|
||||
return null;
|
||||
}
|
||||
interactiveRects = sanitizedRects;
|
||||
}
|
||||
|
||||
return {
|
||||
layer: candidate.layer,
|
||||
measuredAtMs,
|
||||
viewport: { width: viewportWidth, height: viewportHeight },
|
||||
contentRect,
|
||||
...(interactiveRects !== undefined ? { interactiveRects } : {}),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -94,6 +106,22 @@ function sanitizeOverlayContentRect(rect: unknown): OverlayContentRect | null {
|
||||
return { x, y, width, height };
|
||||
}
|
||||
|
||||
function sanitizeOverlayInteractiveRects(rects: unknown): OverlayContentRect[] | null {
|
||||
if (!Array.isArray(rects) || rects.length > MAX_INTERACTIVE_RECTS) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const sanitized: OverlayContentRect[] = [];
|
||||
for (const rect of rects) {
|
||||
const sanitizedRect = sanitizeOverlayContentRect(rect);
|
||||
if (!sanitizedRect) {
|
||||
return null;
|
||||
}
|
||||
sanitized.push(sanitizedRect);
|
||||
}
|
||||
return sanitized;
|
||||
}
|
||||
|
||||
function readFiniteInRange(value: unknown, min: number, max: number): number {
|
||||
if (typeof value !== 'number' || !Number.isFinite(value)) {
|
||||
return Number.NaN;
|
||||
@@ -140,7 +168,12 @@ export function createOverlayContentMeasurementStore(options?: {
|
||||
return latestByLayer[layer];
|
||||
}
|
||||
|
||||
function clear(layer: OverlayLayer): void {
|
||||
latestByLayer[layer] = null;
|
||||
}
|
||||
|
||||
return {
|
||||
clear,
|
||||
getLatestByLayer,
|
||||
report,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user