idle: add a grace period
This commit is contained in:
parent
1ad3d11616
commit
e8be15a26c
29 changed files with 405 additions and 79 deletions
|
|
@ -243,6 +243,7 @@ impl ExtImageCopyCaptureFrameV1 {
|
|||
true,
|
||||
true,
|
||||
true,
|
||||
false,
|
||||
jay_config::video::Transform::None,
|
||||
)
|
||||
});
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ impl Global for JayCompositorGlobal {
|
|||
}
|
||||
|
||||
fn version(&self) -> u32 {
|
||||
12
|
||||
13
|
||||
}
|
||||
|
||||
fn required_caps(&self) -> ClientCaps {
|
||||
|
|
@ -213,6 +213,7 @@ impl JayCompositorRequestHandler for JayCompositor {
|
|||
id: req.id,
|
||||
client: self.client.clone(),
|
||||
tracker: Default::default(),
|
||||
version: self.version,
|
||||
});
|
||||
track!(self.client, idle);
|
||||
self.client.add_client_obj(&idle)?;
|
||||
|
|
|
|||
|
|
@ -14,8 +14,11 @@ pub struct JayIdle {
|
|||
pub id: JayIdleId,
|
||||
pub client: Rc<Client>,
|
||||
pub tracker: Tracker<Self>,
|
||||
pub version: Version,
|
||||
}
|
||||
|
||||
const GRACE_PERIOD_SINCE: Version = Version(13);
|
||||
|
||||
impl JayIdle {
|
||||
fn send_interval(&self) {
|
||||
let to = self.client.state.idle.timeout.get();
|
||||
|
|
@ -25,6 +28,14 @@ impl JayIdle {
|
|||
});
|
||||
}
|
||||
|
||||
fn send_grace_period(&self) {
|
||||
let to = self.client.state.idle.grace_period.get();
|
||||
self.client.event(GracePeriod {
|
||||
self_id: self.id,
|
||||
period: to.as_secs(),
|
||||
});
|
||||
}
|
||||
|
||||
fn send_inhibitor(&self, surface: &ZwpIdleInhibitorV1) {
|
||||
let surface = &surface.surface;
|
||||
self.client.event(Inhibitor {
|
||||
|
|
@ -42,6 +53,9 @@ impl JayIdleRequestHandler for JayIdle {
|
|||
|
||||
fn get_status(&self, _req: GetStatus, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
self.send_interval();
|
||||
if self.version >= GRACE_PERIOD_SINCE {
|
||||
self.send_grace_period();
|
||||
}
|
||||
{
|
||||
let inhibitors = self.client.state.idle.inhibitors.lock();
|
||||
for inhibitor in inhibitors.values() {
|
||||
|
|
@ -56,11 +70,17 @@ impl JayIdleRequestHandler for JayIdle {
|
|||
self.client.state.idle.set_timeout(interval);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn set_grace_period(&self, req: SetGracePeriod, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
let period = Duration::from_secs(req.period);
|
||||
self.client.state.idle.set_grace_period(period);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
object_base! {
|
||||
self = JayIdle;
|
||||
version = Version(1);
|
||||
version = self.version;
|
||||
}
|
||||
|
||||
impl Object for JayIdle {}
|
||||
|
|
|
|||
|
|
@ -200,6 +200,7 @@ impl JayScreencast {
|
|||
true,
|
||||
true,
|
||||
false,
|
||||
false,
|
||||
Transform::None,
|
||||
);
|
||||
match res {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue