mirror of
https://gitlab.com/gabmus/envision.git
synced 2025-08-03 22:58:44 +00:00
feat: inhibit screen lock while xr service is active
This commit is contained in:
parent
51d9ae439f
commit
cab4f676ee
1 changed files with 37 additions and 6 deletions
|
@ -47,6 +47,10 @@ pub struct App {
|
||||||
|
|
||||||
#[tracker::do_not_track]
|
#[tracker::do_not_track]
|
||||||
application: adw::Application,
|
application: adw::Application,
|
||||||
|
#[tracker::do_not_track]
|
||||||
|
app_win: adw::ApplicationWindow,
|
||||||
|
#[tracker::do_not_track]
|
||||||
|
inhibit_id: Option<u32>,
|
||||||
|
|
||||||
#[tracker::do_not_track]
|
#[tracker::do_not_track]
|
||||||
main_view: Controller<MainView>,
|
main_view: Controller<MainView>,
|
||||||
|
@ -90,6 +94,7 @@ pub enum Msg {
|
||||||
OpenLibsurviveSetup,
|
OpenLibsurviveSetup,
|
||||||
Quit,
|
Quit,
|
||||||
ProcessDevicesLog(Vec<String>),
|
ProcessDevicesLog(Vec<String>),
|
||||||
|
InhibitSession(bool),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl App {
|
impl App {
|
||||||
|
@ -106,15 +111,34 @@ impl App {
|
||||||
self.config.get_selected_profile(&self.profiles)
|
self.config.get_selected_profile(&self.profiles)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn set_inhibit_session(&mut self, state: bool) {
|
||||||
|
if state {
|
||||||
|
if self.inhibit_id.is_some() {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
self.inhibit_id = Some(self.application.inhibit(
|
||||||
|
Some(&self.app_win),
|
||||||
|
gtk::ApplicationInhibitFlags::all(),
|
||||||
|
Some("XR Session running"),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if self.inhibit_id.is_none() {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
self.application.uninhibit(self.inhibit_id.unwrap());
|
||||||
|
self.inhibit_id = None;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn start_xrservice(&mut self) {
|
pub fn start_xrservice(&mut self) {
|
||||||
|
self.set_inhibit_session(true);
|
||||||
let prof = self.get_selected_profile();
|
let prof = self.get_selected_profile();
|
||||||
self.devices_processed = match prof.xrservice_type {
|
self.devices_processed = match prof.xrservice_type {
|
||||||
XRServiceType::Monado => false,
|
XRServiceType::Monado => false,
|
||||||
XRServiceType::Wivrn => true, // no device from log in wivrn
|
XRServiceType::Wivrn => true, // no device from log in wivrn
|
||||||
};
|
};
|
||||||
self.debug_view
|
self.debug_view.sender().emit(DebugViewMsg::ClearLog);
|
||||||
.sender()
|
|
||||||
.emit(DebugViewMsg::ClearLog);
|
|
||||||
let mut runner = Runner::xrservice_runner_from_profile(&prof);
|
let mut runner = Runner::xrservice_runner_from_profile(&prof);
|
||||||
match runner.try_start() {
|
match runner.try_start() {
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
|
@ -265,10 +289,12 @@ impl SimpleComponent for App {
|
||||||
Some(parsed) => {
|
Some(parsed) => {
|
||||||
if parsed.func == "p_create_system" {
|
if parsed.func == "p_create_system" {
|
||||||
match XRDevices::from_log_message(parsed.message) {
|
match XRDevices::from_log_message(parsed.message) {
|
||||||
None => {},
|
None => {}
|
||||||
Some(devices) => {
|
Some(devices) => {
|
||||||
self.devices_processed = true;
|
self.devices_processed = true;
|
||||||
self.main_view.sender().emit(MainViewMsg::UpdateDevices(Some(devices)));
|
self.main_view
|
||||||
|
.sender()
|
||||||
|
.emit(MainViewMsg::UpdateDevices(Some(devices)));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -281,7 +307,8 @@ impl SimpleComponent for App {
|
||||||
self.set_enable_debug_view(val);
|
self.set_enable_debug_view(val);
|
||||||
self.config.debug_view_enabled = val;
|
self.config.debug_view_enabled = val;
|
||||||
self.config.save();
|
self.config.save();
|
||||||
self.debug_view .sender()
|
self.debug_view
|
||||||
|
.sender()
|
||||||
.emit(DebugViewMsg::EnableDebugViewChanged(val));
|
.emit(DebugViewMsg::EnableDebugViewChanged(val));
|
||||||
self.main_view
|
self.main_view
|
||||||
.sender()
|
.sender()
|
||||||
|
@ -293,6 +320,7 @@ impl SimpleComponent for App {
|
||||||
}
|
}
|
||||||
Some(runner) => match runner.status() {
|
Some(runner) => match runner.status() {
|
||||||
RunnerStatus::Running => {
|
RunnerStatus::Running => {
|
||||||
|
sender.input(Msg::InhibitSession(false));
|
||||||
runner.terminate();
|
runner.terminate();
|
||||||
self.main_view
|
self.main_view
|
||||||
.sender()
|
.sender()
|
||||||
|
@ -303,6 +331,7 @@ impl SimpleComponent for App {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
Msg::InhibitSession(state) => self.set_inhibit_session(state),
|
||||||
Msg::BuildProfile => {
|
Msg::BuildProfile => {
|
||||||
let profile = self.get_selected_profile();
|
let profile = self.get_selected_profile();
|
||||||
let mut missing_deps = vec![];
|
let mut missing_deps = vec![];
|
||||||
|
@ -491,6 +520,8 @@ impl SimpleComponent for App {
|
||||||
|
|
||||||
let model = App {
|
let model = App {
|
||||||
application: init.application,
|
application: init.application,
|
||||||
|
app_win: root.clone(),
|
||||||
|
inhibit_id: None,
|
||||||
main_view: MainView::builder()
|
main_view: MainView::builder()
|
||||||
.launch(MainViewInit {
|
.launch(MainViewInit {
|
||||||
config: config.clone(),
|
config: config.clone(),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue