kms: Fix VT switching back to cosmic

This commit is contained in:
Victoria Brekenfeld 2022-04-27 13:25:17 +02:00
parent 8eff406a4f
commit c567448fc8
3 changed files with 12 additions and 5 deletions

View file

@ -174,6 +174,7 @@ pub fn init_backend(event_loop: &mut EventLoop<'static, State>, state: &mut Stat
.unwrap();
let handle = event_loop.handle();
let loop_signal = state.common.event_loop_signal.clone();
let dispatcher = udev_dispatcher.clone();
let _restart_token = signaler.register(move |signal| {
if let Signal::ActivateSession = signal {
@ -205,10 +206,14 @@ pub fn init_backend(event_loop: &mut EventLoop<'static, State>, state: &mut Stat
state.common.shell.refresh_outputs();
state.common.config.write_outputs(state.common.output_conf.outputs());
for surface in state.backend.kms().devices.values_mut().flat_map(|d| d.surfaces.values_mut()) {
surface.pending = false;
}
for output in state.common.shell.outputs() {
state.backend.kms().schedule_render(output);
}
});
loop_signal.wakeup();
}
});

View file

@ -30,18 +30,17 @@ fn main() -> Result<()> {
// init wayland
let (display, socket) = init_wayland_display(&mut event_loop)?;
// init state
let mut state = state::State::new(display, socket, event_loop.handle(), log);
let mut state = state::State::new(display, socket, event_loop.handle(), event_loop.get_signal(), log);
// init backend
backend::init_backend_auto(&mut event_loop, &mut state)?;
// run the event loop
let signal = event_loop.get_signal();
event_loop.run(None, &mut state, |state| {
// shall we shut down?
if state.common.shell.outputs().next().is_none() || state.common.should_stop {
slog_scope::info!("Shutting down");
signal.stop();
signal.wakeup();
state.common.event_loop_signal.stop();
state.common.event_loop_signal.wakeup();
return;
}

View file

@ -8,7 +8,7 @@ use crate::{
};
use smithay::{
reexports::{
calloop::LoopHandle,
calloop::{LoopHandle, LoopSignal},
wayland_server::{protocol::wl_surface::WlSurface, Display},
},
wayland::{
@ -47,6 +47,7 @@ pub struct Common {
pub display: Rc<RefCell<Display>>,
pub socket: OsString,
pub event_loop_handle: LoopHandle<'static, State>,
pub event_loop_signal: LoopSignal,
pub output_conf: ConfigurationManager,
pub shell: Shell,
@ -182,6 +183,7 @@ impl State {
mut display: Display,
socket: OsString,
handle: LoopHandle<'static, State>,
signal: LoopSignal,
log: LogState,
) -> State {
let config = Config::load();
@ -326,6 +328,7 @@ impl State {
display: Rc::new(RefCell::new(display)),
socket,
event_loop_handle: handle,
event_loop_signal: signal,
output_conf,
shell,