colors: add surface resize event

This commit is contained in:
2025-07-14 17:16:54 +03:00
parent 8f7ac51fbb
commit 3683d721c7
3 changed files with 17 additions and 1 deletions
+9
View File
@@ -301,6 +301,15 @@ impl WindowServer for Server<'_> {
Command::new("/bin/colors-bar").spawn().ok();
}
fn handle_display_resize(&mut self, tx: &mut ServerSender, mut surface: DisplaySurface) {
log::info!("Display resize: {}x{}", surface.width(), surface.height());
self.display
.resize(surface.width() as u32, surface.height() as u32);
surface.fill(self.background);
self.redraw_all(tx);
surface.present();
}
fn handle_client_message(
&mut self,
mut surface: DisplaySurface,
+1
View File
@@ -32,6 +32,7 @@ pub struct Point<T>(pub T, pub T);
pub trait WindowServer {
fn handle_initial(&mut self, surface: DisplaySurface);
fn handle_display_resize(&mut self, tx: &mut ServerSender, surface: DisplaySurface);
fn handle_client_message(
&mut self,
surface: DisplaySurface,
+7 -1
View File
@@ -174,7 +174,13 @@ impl<S: WindowServer> ApplicationHandler<FromClient> for Backend<S> {
let width = NonZero::new(size.width).unwrap();
let height = NonZero::new(size.height).unwrap();
surface.resize(width, height).unwrap();
surface.buffer_mut().unwrap().present().unwrap();
let display_surface = DisplaySurface {
inner: surface.buffer_mut().unwrap(),
width: size.width as usize,
height: size.height as usize,
};
self.server
.handle_display_resize(&mut self.tx, display_surface);
}
WindowEvent::KeyboardInput { event, .. } => {
if let Some(event) = convert_key_event(event) {