No description
Find a file
Jonathan Johnson 8f49442f28
Window panics are now handled
Prior to this commit, if a window panic happened, the window would be
left on the screen frozen. Now, the panic is caught and the window is
closed before resuming the panic.

The app event loop has a separate message it receives when a window
panics, and if it's the last window, the process exits with a non-zero
exit code.

This places the burden of handling a panicking window into the
developer's hands: ultimately if the window has a way to communicate
with it, the behavior is being dropped as part of the panic handling,
which ensures any channels the window had will be dropped too.
2023-07-03 08:38:38 -07:00
src Window panics are now handled 2023-07-03 08:38:38 -07:00
.gitignore Initial commit. 2023-06-27 09:21:38 -07:00
Cargo.toml Initial commit. 2023-06-27 09:21:38 -07:00
README.md Initial commit. 2023-06-27 09:21:38 -07:00

appit

An opinionated wrapper for winit that provides a trait-based approach to implementing multi-window applications.

This crate's main type is WindowBehavior, a trait that provides functions for nearly every winit::event::WindowEvent. This allows you to implement exactly which events you wish to respond to, and ignore the rest without a large match statement.

This crate also keeps track of the redraw state of the window, and allows scheduling redraws in the future.

use appit::WindowBehavior;

struct MyWindow;

impl WindowBehavior for MyWindow {
    type Context = ();

    fn initialize(_window: &mut appit::RunningWindow, _context: Self::Context) -> Self {
        Self
    }

    fn redraw(&mut self, window: &mut appit::RunningWindow) {
        println!("Should redraw");
    }
}

fn main() {
    MyWindow::run()
}

Why not use this crate?

  • Very new, largely untested.
  • Not all platforms support threads, and a single-window, single-thread code path is not supported yet.