fix: RDP canvas re-measures container on tab switch
All checks were successful
Build & Sign Wraith / Build Windows + Sign (push) Successful in 3m44s
All checks were successful
Build & Sign Wraith / Build Windows + Sign (push) Successful in 3m44s
When switching from SSH back to RDP, the canvas retained the resolution from when the copilot panel was open — even after closing the panel. The ResizeObserver doesn't fire while the tab is hidden (v-show/display), so the container size change goes unnoticed. Fix: On tab activation, double-rAF waits for layout, measures the container via getBoundingClientRect, compares with canvas.width/height, and sends rdp_resize if they differ. This ensures the RDP session always matches the current available space. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
6d3e973848
commit
04c140f608
@ -204,17 +204,44 @@ onBeforeUnmount(() => {
|
|||||||
if (resizeTimeout) { clearTimeout(resizeTimeout); resizeTimeout = null; }
|
if (resizeTimeout) { clearTimeout(resizeTimeout); resizeTimeout = null; }
|
||||||
});
|
});
|
||||||
|
|
||||||
// Focus canvas and force full frame refresh when switching to this tab
|
// Focus canvas, re-check dimensions, and force full frame on tab switch
|
||||||
watch(
|
watch(
|
||||||
() => props.isActive,
|
() => props.isActive,
|
||||||
(active) => {
|
(active) => {
|
||||||
if (active && canvasRef.value) {
|
if (!active || !canvasRef.value) return;
|
||||||
// Force full frame fetch to repaint the canvas immediately
|
|
||||||
invoke("rdp_force_refresh", { sessionId: props.sessionId }).catch(() => {});
|
// Wait for layout to settle after tab becomes visible
|
||||||
if (keyboardGrabbed.value) {
|
requestAnimationFrame(() => {
|
||||||
setTimeout(() => canvasRef.value?.focus(), 0);
|
requestAnimationFrame(() => {
|
||||||
}
|
const wrapper = canvasWrapper.value;
|
||||||
}
|
const canvas = canvasRef.value;
|
||||||
|
if (!wrapper || !canvas) return;
|
||||||
|
|
||||||
|
const { width: cw, height: ch } = wrapper.getBoundingClientRect();
|
||||||
|
const newW = Math.round(cw) & ~1;
|
||||||
|
const newH = Math.round(ch);
|
||||||
|
|
||||||
|
// If container size differs from canvas resolution, resize the RDP session
|
||||||
|
if (newW >= 200 && newH >= 200 && (newW !== canvas.width || newH !== canvas.height)) {
|
||||||
|
invoke("rdp_resize", {
|
||||||
|
sessionId: props.sessionId,
|
||||||
|
width: newW,
|
||||||
|
height: newH,
|
||||||
|
}).then(() => {
|
||||||
|
canvas.width = newW;
|
||||||
|
canvas.height = newH;
|
||||||
|
setTimeout(() => {
|
||||||
|
invoke("rdp_force_refresh", { sessionId: props.sessionId }).catch(() => {});
|
||||||
|
}, 200);
|
||||||
|
}).catch(() => {});
|
||||||
|
} else {
|
||||||
|
// Same size — just refresh the frame
|
||||||
|
invoke("rdp_force_refresh", { sessionId: props.sessionId }).catch(() => {});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (keyboardGrabbed.value) canvas.focus();
|
||||||
|
});
|
||||||
|
});
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user