Fix garbled display on video mode switch and framebuffer clipping
Clear the entire framebuffer pixel buffer on resize instead of preserving stale data from the previous resolution. Vec::resize() only zeroes newly-added bytes, so old pixels were reinterpreted with the new stride, producing garbled output after mode changes. Fix bottom/right clipping by giving the Image explicit dimensions bound to framebuffer size properties instead of using image-fit: contain with a hardcoded toolbar width estimate. The window's preferred size now derives from the layout. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
186322b765
commit
fe143db717
3 changed files with 13 additions and 14 deletions
|
|
@ -12,7 +12,6 @@ use slint::winit_030::{winit, EventResult, WinitWindowAccessor};
|
|||
|
||||
use aten_kvm::{InputEvent, KvmConfig, KvmEvent, KvmSession};
|
||||
|
||||
const TOOLBAR_WIDTH: f32 = 70.0;
|
||||
|
||||
#[derive(Parser)]
|
||||
#[command(about = "KVM console viewer for ATEN BMC")]
|
||||
|
|
@ -117,10 +116,8 @@ fn main() {
|
|||
let weak = app_weak.clone();
|
||||
slint::invoke_from_event_loop(move || {
|
||||
if let Some(app) = weak.upgrade() {
|
||||
app.window().set_size(slint::LogicalSize::new(
|
||||
width as f32 + TOOLBAR_WIDTH,
|
||||
height as f32,
|
||||
));
|
||||
app.set_fb_width(width as i32);
|
||||
app.set_fb_height(height as i32);
|
||||
}
|
||||
})
|
||||
.ok();
|
||||
|
|
@ -130,10 +127,8 @@ fn main() {
|
|||
let weak = app_weak.clone();
|
||||
slint::invoke_from_event_loop(move || {
|
||||
if let Some(app) = weak.upgrade() {
|
||||
app.window().set_size(slint::LogicalSize::new(
|
||||
width as f32 + TOOLBAR_WIDTH,
|
||||
height as f32,
|
||||
));
|
||||
app.set_fb_width(width as i32);
|
||||
app.set_fb_height(height as i32);
|
||||
}
|
||||
})
|
||||
.ok();
|
||||
|
|
|
|||
|
|
@ -2,12 +2,13 @@ import { Button } from "std-widgets.slint";
|
|||
|
||||
export component Main inherits Window {
|
||||
title: "aten-kvm";
|
||||
preferred-width: 800px;
|
||||
preferred-height: 600px;
|
||||
|
||||
in-out property <image> frame;
|
||||
in-out property <string> error-text;
|
||||
in-out property <bool> show-error: false;
|
||||
in-out property <int> fb-width: 800;
|
||||
in-out property <int> fb-height: 600;
|
||||
preferred-width: fb-width * 1px + 78px;
|
||||
preferred-height: fb-height * 1px;
|
||||
|
||||
callback ctrl-toggled(bool);
|
||||
callback alt-toggled(bool);
|
||||
|
|
@ -47,7 +48,8 @@ export component Main inherits Window {
|
|||
|
||||
Image {
|
||||
source: root.frame;
|
||||
image-fit: contain;
|
||||
width: root.fb-width * 1px;
|
||||
height: root.fb-height * 1px;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,9 @@ impl Framebuffer {
|
|||
pub fn resize(&mut self, width: u16, height: u16) {
|
||||
self.width = width;
|
||||
self.height = height;
|
||||
self.pixels.resize(width as usize * height as usize * 4, 0);
|
||||
let size = width as usize * height as usize * 4;
|
||||
self.pixels.clear();
|
||||
self.pixels.resize(size, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue