MCPcopy Create free account
hub / github.com/StrataWM/strata / init_winit

Function init_winit

src/backends/winit.rs:49–130  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

47};
48
49pub fn init_winit() {
50 let mut event_loop: EventLoop<StrataState> = EventLoop::try_new().unwrap();
51 let (display, socket) = state::init_wayland_listener(&event_loop);
52 let display_handle = display.handle();
53 let (backend, mut winit) = winit::init().unwrap();
54 let mode = Mode { size: backend.window_size(), refresh: 60_000 };
55 let output = Output::new(
56 "winit".to_string(),
57 PhysicalProperties {
58 size: (0, 0).into(),
59 subpixel: Subpixel::Unknown,
60 make: "Strata".into(),
61 model: "Winit".into(),
62 },
63 );
64 let _global = output.create_global::<StrataComp>(&display_handle);
65 output.change_current_state(Some(mode), Some(Transform::Flipped180), None, Some((0, 0).into()));
66 output.set_preferred(mode);
67 let damage_tracked_renderer = OutputDamageTracker::from_output(&output);
68 let mut comp = StrataComp::new(
69 &event_loop,
70 &display,
71 socket,
72 "winit".to_string(),
73 backend,
74 damage_tracked_renderer,
75 );
76 BorderShader::init(comp.backend.renderer());
77 for workspace in comp.workspaces.iter() {
78 workspace.add_output(output.clone());
79 }
80
81 std::env::set_var("WAYLAND_DISPLAY", &comp.socket_name);
82
83 let timer = Timer::immediate();
84 event_loop
85 .handle()
86 .insert_source(timer, move |_, _, data| {
87 winit_dispatch(&mut winit, data, &output);
88 TimeoutAction::ToDuration(Duration::from_millis(16))
89 })
90 .unwrap();
91
92 let mut lua_vm = lua::Lua::full();
93 let comp = Rc::new(RefCell::new(comp));
94
95 let ex = lua_vm
96 .try_enter(|ctx| {
97 bindings::register(ctx, Rc::clone(&comp))?;
98
99 let main = lua::Closure::load(
100 ctx,
101 None,
102 r#"
103 local Key = strata.input.Key
104 local Mod = strata.input.Mod
105
106 -- print(Mod.Super_L)

Callers 1

init_with_backendFunction · 0.85

Calls 5

init_wayland_listenerFunction · 0.85
winit_dispatchFunction · 0.85
registerFunction · 0.85
iterMethod · 0.80
add_outputMethod · 0.80

Tested by

no test coverage detected