persist BackendAttrib across sessions
This commit is contained in:
@@ -6,7 +6,7 @@ use wgui::gfx::{
|
||||
WGfx,
|
||||
cmd::{GfxCommandBuffer, WGfxClearMode},
|
||||
};
|
||||
use wlx_capture::frame::Transform;
|
||||
use wlx_common::overlays::{BackendAttrib, BackendAttribValue};
|
||||
|
||||
use crate::{
|
||||
backend::input::{HoverResult, PointerHit},
|
||||
@@ -33,16 +33,6 @@ pub enum ShouldRender {
|
||||
Unable,
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, Clone, Copy)]
|
||||
pub enum StereoMode {
|
||||
#[default]
|
||||
None,
|
||||
LeftRight,
|
||||
RightLeft,
|
||||
TopBottom,
|
||||
BottomTop,
|
||||
}
|
||||
|
||||
pub struct RenderTarget {
|
||||
pub views: SmallVec<[Arc<ImageView>; 2]>,
|
||||
}
|
||||
@@ -109,18 +99,6 @@ macro_rules! attrib_value {
|
||||
};
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
pub enum BackendAttrib {
|
||||
Stereo,
|
||||
MouseTransform,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum BackendAttribValue {
|
||||
Stereo(StereoMode),
|
||||
MouseTransform(Transform),
|
||||
}
|
||||
|
||||
pub struct OverlayMeta {
|
||||
pub id: OverlayID,
|
||||
pub name: Arc<str>,
|
||||
|
||||
@@ -8,7 +8,7 @@ use slotmap::{HopSlotMap, Key, SecondaryMap};
|
||||
use wlx_common::{
|
||||
astr_containers::{AStrMap, AStrMapExt},
|
||||
config::SerializedWindowSet,
|
||||
overlays::ToastTopic,
|
||||
overlays::{BackendAttrib, ToastTopic},
|
||||
};
|
||||
|
||||
use crate::{
|
||||
@@ -277,6 +277,8 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
const SAVED_ATTRIBS: [BackendAttrib; 2] = [BackendAttrib::Stereo, BackendAttrib::MouseTransform];
|
||||
|
||||
impl<T> OverlayWindowManager<T> {
|
||||
pub fn pop_dropped(&mut self) -> Option<OverlayWindowData<T>> {
|
||||
self.dropped_overlays.pop_front()
|
||||
@@ -334,6 +336,17 @@ impl<T> OverlayWindowManager<T> {
|
||||
.insert(o.config.name.clone(), state.clone());
|
||||
}
|
||||
|
||||
// BackendAttrib
|
||||
for o in self.overlays.values() {
|
||||
app.session.config.attribs.arc_set(
|
||||
o.config.name.clone(),
|
||||
SAVED_ATTRIBS
|
||||
.iter()
|
||||
.filter_map(|a| o.config.backend.get_attrib(*a))
|
||||
.collect(),
|
||||
);
|
||||
}
|
||||
|
||||
if restore_after {
|
||||
self.switch_to_set(app, Some(self.restore_set));
|
||||
}
|
||||
@@ -389,6 +402,19 @@ impl<T> OverlayWindowManager<T> {
|
||||
}
|
||||
}
|
||||
|
||||
for (name, attribs) in &app.session.config.attribs.clone() {
|
||||
let Some(oid) = self.lookup(&*name) else {
|
||||
continue;
|
||||
};
|
||||
let Some(o) = self.mut_by_id(oid) else {
|
||||
continue;
|
||||
};
|
||||
|
||||
for value in attribs {
|
||||
o.config.backend.set_attrib(app, value.clone());
|
||||
}
|
||||
}
|
||||
|
||||
self.restore_set = (app.session.config.last_set as usize).min(self.sets.len() - 1);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user